Fix generation of large Mandelbrot PPMs
This commit is contained in:
parent
8d320f3744
commit
5a255d239e
@ -1,6 +1,8 @@
|
||||
\documentclass{article}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\usepackage{avremu}
|
||||
\useavremulibrary{avr.draw}
|
||||
|
||||
\errorcontextlines=23
|
||||
|
||||
|
@ -68,6 +68,9 @@ int main() {
|
||||
uint8_t i;
|
||||
for (hy=1;hy<=hyres;hy++) {
|
||||
for (hx=1;hx<=hxres;hx++) {
|
||||
setcolor(hx * 100, 255, 0);
|
||||
dot(hx-1, hy-1);
|
||||
continue;
|
||||
cx = (((float)hx)/((float)hxres)-0.5)/magnify*3.0-0.7;
|
||||
cy = (((float)hy)/((float)hyres)-0.5)/magnify*3.0;
|
||||
cx += xdelta;
|
||||
@ -104,30 +107,14 @@ int main() {
|
||||
check-start:
|
||||
\def\avr@debug#1{}
|
||||
|
||||
\newcommand{\mydot}[3]{%
|
||||
\definecolor{avrfill}{RGB}{#3}%
|
||||
\node[minimum size = 1mm,%
|
||||
anchor=north west,
|
||||
inner sep=0,
|
||||
draw=avrfill,fill=avrfill]
|
||||
at (#1 mm,#2 mm) {};%
|
||||
}
|
||||
|
||||
\avr@instr@run
|
||||
|
||||
% Dump to .dat file
|
||||
\newwrite\coords
|
||||
\openout\coords=\jobname.coords.dat
|
||||
\newcommand{\mydump}[3]{%
|
||||
\edef\@tempa{#1,#2,#3}%
|
||||
\expandafter\write\expandafter\coords\expandafter{\@tempa}%
|
||||
}
|
||||
\avrdrawiter{\mydump}
|
||||
\closeout\coords
|
||||
|
||||
\begin{tikzpicture}[every node/.style={draw}]
|
||||
\avrdrawiter{\mydot}
|
||||
\end{tikzpicture}
|
||||
\avrdrawppm{mandelbrot.ppm}
|
||||
|
||||
\immediate\write18{convert mandelbrot.ppm mandelbrot.png}
|
||||
|
||||
\includegraphics[width=\linewidth]{mandelbrot.png}
|
||||
|
||||
check-end:
|
||||
*/
|
||||
|
@ -54,10 +54,14 @@
|
||||
|
||||
\def\avr@compile#1#2{%
|
||||
\ifnum\pdfshellescape=1%
|
||||
\immediate\write18{rm #1.hex #1.elf}%
|
||||
\immediate\write18{avr-gcc -o #1.elf #1 #2}%
|
||||
\immediate\write18{avr-objcopy -O ihex -R .eeprom #1.elf #1.hex}%
|
||||
\IfFileExists{#1.hex}{}{%
|
||||
\errmessage{avremu: Compilation of Source code failed (#1)}%
|
||||
}%
|
||||
\else%
|
||||
\typeout{avr@compile: --shell-escape is disabled}%
|
||||
\errmessage{avremu: --shell-escape is disabled; cannot compile}%
|
||||
\fi%
|
||||
}
|
||||
|
||||
@ -67,6 +71,15 @@
|
||||
\avr@ihex@load{#2.hex}%
|
||||
}
|
||||
|
||||
\newcommand{\avrcompile}[2][-Os -mmcu=atmega8]{%
|
||||
\avr@compile{#2}{#1}%
|
||||
}
|
||||
|
||||
\newcommand{\avrloadihex}[1]{%
|
||||
\avr@ihex@load{#1}%
|
||||
}
|
||||
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: t
|
||||
|
@ -2,9 +2,6 @@
|
||||
% We define 2 IO Registers to communicate from AVR to the Drawing
|
||||
% mechanism
|
||||
|
||||
\usepackage{tikz}
|
||||
|
||||
|
||||
\newcount\avr@draw@x
|
||||
\newcount\avr@draw@y
|
||||
\newcount\avr@draw@maxx
|
||||
@ -77,21 +74,58 @@
|
||||
|
||||
\newcommand{\avrdrawiter}[1]{%
|
||||
\avr@draw@x=0%
|
||||
\loop%
|
||||
\unless\ifnum \avr@draw@x > \avr@draw@maxx
|
||||
\avr@draw@y=0%
|
||||
{\loop%
|
||||
\unless\ifnum \avr@draw@y > \avr@draw@maxy
|
||||
\ifcsdef{avr@draw@\the\avr@draw@x @\the\avr@draw@y}{%
|
||||
#1{\the\avr@draw@x}{\the\avr@draw@y}{\csuse{avr@draw@\the\avr@draw@x @\the\avr@draw@y}}%
|
||||
}{}%
|
||||
\advance \avr@draw@y by 1\relax%
|
||||
\repeat}%
|
||||
\advance \avr@draw@x by 1\relax%
|
||||
\repeat%
|
||||
\def\avr@iter@yloop{%
|
||||
\avr@draw@x=0%
|
||||
\ifnum \avr@draw@y > \avr@draw@maxy%
|
||||
\let\avr@iter@yloop=\relax%
|
||||
\else%
|
||||
\let\avr@iter@xloop@rec=\avr@iter@xloop%
|
||||
\avr@iter@xloop\relax%
|
||||
\advance \avr@draw@y by 1\relax%
|
||||
\fi%
|
||||
\avr@iter@yloop%
|
||||
}%
|
||||
\def\avr@iter@xloop{%
|
||||
\ifnum \avr@draw@x > \avr@draw@maxx%
|
||||
\let\avr@iter@xloop@rec=\relax%
|
||||
\else%
|
||||
\ifcsdef{avr@draw@\the\avr@draw@x @\the\avr@draw@y}{%
|
||||
#1 {\the\avr@draw@x}{\the\avr@draw@y}{\csuse{avr@draw@\the\avr@draw@x @\the\avr@draw@y}}%
|
||||
}{% Dot not defined
|
||||
}%
|
||||
\advance \avr@draw@x by 1\relax%
|
||||
\fi%
|
||||
\avr@iter@xloop@rec%
|
||||
}%
|
||||
\avr@iter@yloop%
|
||||
}
|
||||
|
||||
|
||||
\newcommand{\avrdrawSize}[2]{%
|
||||
\avr@count@tmpa=\avr@draw@maxx%
|
||||
\advance \avr@count@tmpa by 1\relax%
|
||||
\edef#1{\the\avr@count@tmpa}%
|
||||
\avr@count@tmpa=\avr@draw@maxy%
|
||||
\advance \avr@count@tmpa by 1\relax%
|
||||
\edef#2{\the\avr@count@tmpa}%
|
||||
}
|
||||
|
||||
\newwrite\avr@file%
|
||||
|
||||
\newcommand{\avrdrawppm}[1]{
|
||||
% Dump to .ppm file
|
||||
\immediate\openout\avr@file=#1%
|
||||
\immediate\write\avr@file{P3}%
|
||||
\avrdrawSize{\x}{\y}%
|
||||
\immediate\write\avr@file{\x \space \y \space 255}%
|
||||
\def\removecomma##1,##2,##3,{##1 ##2 ##3}%
|
||||
\newcommand{\avr@draw@ppm}[3]{%
|
||||
\edef\@tempa{##3}%
|
||||
\edef\@tempa{\expandafter \removecomma \@tempa,}%
|
||||
\expandafter\immediate\expandafter\write\expandafter\avr@file\expandafter{\@tempa}%
|
||||
}%
|
||||
\avrdrawiter{\avr@draw@ppm}%
|
||||
\immediate\closeout\avr@file%
|
||||
}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
|
@ -15,14 +15,14 @@
|
||||
}
|
||||
|
||||
\csdef{avr@instr@10111}#1#2#3#4#5#6#7#8\@nnil{%
|
||||
\def\@@A{#1#2#8}%
|
||||
\def\@@IOA{#1#2#8}%
|
||||
\avr@reg@get{#3#4#5#6#7}{\avr@Rr}%
|
||||
\avr@debug{OUT \@@A <- \avr@Rr}%
|
||||
\avr@io@set{\avr@Rr}{\@@A}%
|
||||
\avr@debug{OUT \@@IOA <- \avr@Rr}%
|
||||
\avr@io@set{\avr@Rr}{\@@IOA}%
|
||||
\avr@pc@inc%
|
||||
}
|
||||
|
||||
% OUT
|
||||
% IN
|
||||
\def\avr@instr@IN#1#2#3{% A, R
|
||||
\def\@@A{#2}
|
||||
\avr@bin@msb@del{\@@A}{\@@A}{\@@a}%
|
||||
@ -61,11 +61,11 @@
|
||||
}
|
||||
|
||||
\def\avr@io@set@default#1#2{%
|
||||
\avr@error{IO Port #2 is not defined (OUT #1)}%
|
||||
\avr@error{IO Port #2 is not defined (OUT <-#1)}%
|
||||
}
|
||||
|
||||
\def\avr@io@get@default#1#2{%
|
||||
\avr@error{IO Port #1 is not defined (IN -> #2)}%
|
||||
\avr@error{IO Port #1 is not defined (IN ->#2)}%
|
||||
}
|
||||
|
||||
\csdef{avr@io@111111@set}#1{%
|
||||
|
@ -8,3 +8,19 @@
|
||||
\input{avr.instr}
|
||||
\input{avr.io}
|
||||
\input{avr.testsuite}
|
||||
|
||||
|
||||
\newcommand{\useavremulibrary}[1]{
|
||||
\def\do##1{%
|
||||
\IfFileExists{##1}{%
|
||||
\csedef{avr@atcode}{\the\catcode`\@}%
|
||||
\makeatletter%
|
||||
\input{##1}\relax%
|
||||
\catcode`\@=\csname avr@atcode\endcsname%
|
||||
}{%
|
||||
\errmessage{avremu: Cannot find library ##1}%
|
||||
}%
|
||||
}%
|
||||
\edef\@tempa{#1}%
|
||||
\expandafter\docsvlist\expandafter{\@tempa}%
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user