tag:blogger.com,1999:blog-4757118446768919900.post3327271683789757803..comments2023-03-30T01:53:44.203-07:00Comments on Retro Programming: ZX Spectrum Koch (Lévy C) CurveJohn Metcalfhttp://www.blogger.com/profile/09108374348083307900noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-4757118446768919900.post-87374874071809230202013-08-20T23:36:35.184-07:002013-08-20T23:36:35.184-07:00hey, if fractal building on the ZX Spectrum, why n...hey, if fractal building on the ZX Spectrum, why not to use ROM routines?;)<br />53 bytes! or less?<br /><br /> device zxspectrum128<br /><br /> org 65000;65467<br /> <br />begin<br />; call frac<br />; jr $<br />frac:<br /> ld de,49023 ; d = position on x axis<br /> ; e = position on y axis<br /> ld bc,3840 ; b = number of iterations<br /> ; c = initial direction<br />RECURSE:<br /> djnz DOWN<br /><br /> ld a,6 ; check direction<br /> and c ; c=0, left<br /> rrca ; c=2, up<br /> rrca ; c=4, right<br /> add a,a ; c=6, down<br /> dec a<br /> jr nc,XMOVE<br /><br /> add a,e ; adjust y position +/-1<br /><br /> ld e,a ; calculate high byte of screen pos<br /> <br /> push bc<br /> ld c,d<br /> ;;ld a,e<br /> ;A=y<br /> ;c=X<br /> call 022B0h<br /> inc a<br /> ld b,a<br /> xor a:scf<br />bwlp:rra:djnz bwlp<br /> xor (hl):ld (hl),a<br /> pop bc<br /> xor a<br /><br />; rrca<br />; scf<br />; rra<br />; rrca<br />; xor e<br />; and 88<br />; xor e<br />; and 95<br />; ld h,a<br />; sub h<br />;<br />XMOVE:<br /> add a,d ; adjust x position +/-1<br /><br /> ld d,a ; calculate low byte of screen pos<br /><br />; rlca<br />; rlca<br />; rlca<br />; xor e<br />; and 199<br />; xor e<br />; rlca<br />; rlca<br />; ld l,a<br />;<br />; ld a,7 ; calculate bit position of pixel<br />; and d<br />; ld b,a<br /> ld b,0;inc b<br /><br />; ld a,1<br />;SHIFTBIT:<br />; rrca<br />; djnz SHIFTBIT<br />;<br />; xor (hl) ; plot<br />; ld (hl),a<br /> ret<br /><br />DOWN:<br /> inc c ; turn 45° clockwise<br /> call RECURSE<br /> inc b<br /> dec c ; turn 90° anti-clockwise<br /> dec c<br /> call RECURSE<br /> inc b<br /> inc c ; turn 45° clockwise<br /> ret<br /><br />end<br /> display /d,end-begin<br /> savesna "frac.sna",begin<br /><br />antiseptichttps://www.blogger.com/profile/15018128217752373876noreply@blogger.comtag:blogger.com,1999:blog-4757118446768919900.post-53833016410755877522013-08-02T05:58:03.390-07:002013-08-02T05:58:03.390-07:00Wow. Got to try that. Really 69 bytes? Amazing!...Wow. Got to try that. Really 69 bytes? Amazing!<br />BloodBazhttps://www.blogger.com/profile/00226019438431758716noreply@blogger.com