0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2025-01-05 15:11:18 +00:00

(mandelbrot.tal) Added fractal

This commit is contained in:
neauoire 2022-02-07 16:59:34 -08:00
parent 1a34fcefa9
commit 20d6ab3cb4
2 changed files with 47 additions and 77 deletions

View file

@ -4,27 +4,24 @@
%< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
%AUTO-X { #01 .Screen/auto DEO }
%NEXT-LINE { #0000 .Screen/x DEO2 .Screen/y DEI2k INC2 ROT DEO2 }
%WIDTH { #0280 }
%HEIGHT { #01e0 }
%XMIN { #de69 } ( -8601 )
%XMAX { #0b33 } ( 2867 )
%YMIN { #ecc7 } ( -4915 )
%YMAX { #1333 } ( 4915 )
%MAXI { #20 } ( 32 )
%DX { XMAX XMIN -- #004f // } ( (XMAX-XMIN)/79 )
%DY { YMAX YMIN -- #0018 // } ( (YMAX-YMIN)/24 )
%X { .x LDZ2 } %Y { .y LDZ2 }
%DX { XMAX XMIN -- WIDTH // } ( (XMAX-XMIN)/W )
%DY { YMAX YMIN -- HEIGHT // } ( (YMAX-YMIN)/H )
%X { .x LDZ2 } %Y { .y LDZ2 }
%X2 { .x2 LDZ2 } %Y2 { .y2 LDZ2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ << }
%HALT { #010f DEO }
%EMIT { #18 DEO }
%PRINT { ;print-str JSR2 #0a EMIT }
%DEBUG { ;print-hex/byte JSR2 #0a EMIT }
%DEBUG2 { ;print-hex JSR2 #0a EMIT }
|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
@ -36,17 +33,15 @@
|0100 ( -> )
( theme )
#048c .System/r DEO2
#048c .System/g DEO2
#048c .System/b DEO2
#0f0f .System/r DEO2
#0ff0 .System/g DEO2
#00ff .System/b DEO2
#0280 .Screen/width DEO2 ( 640 )
#01e0 .Screen/height DEO2 ( 480 )
#0000 .Screen/x DEO2
#0000 .Screen/y DEO2
WIDTH .Screen/width DEO2 ( 640 )
HEIGHT .Screen/height DEO2 ( 480 )
AUTO-X
;draw-mandel JSR2
BRK
@ -62,14 +57,14 @@ BRK
#0000 DUP2 DUP2 DUP2 .x STZ2 .y STZ2 .x2 STZ2 .y2 STZ2
MAXI #00
&loop
X Y ;smul2 JSR2 #0b SFT2 [ LIT2 &y $2 ] ++ .y STZ2
X Y ;smul2 JSR2 DUP2 ADD2 [ LIT2 &y $2 ] ++ .y STZ2
X2 Y2 -- [ LIT2 &x $2 ] ++ .x STZ2
X X ;smul2 JSR2 #0c SFT2 .x2 STZ2
Y Y ;smul2 JSR2 #0c SFT2 .y2 STZ2
X2 Y2 ++ >> #4000 ,&end JCN
X DUP2 ;smul2 JSR2 .x2 STZ2
Y DUP2 ;smul2 JSR2 .y2 STZ2
X2 Y2 ++ #4000 >> ,&end JCN
INC GTHk ,&loop JCN
&end
NIP POP #03 .Screen/pixel DEO
NIP .Screen/pixel DEO
DX ++ OVR2 OVR2 GTS2 ;&hor JCN2
POP2 POP2
NEXT-LINE
@ -78,60 +73,35 @@ BRK
JMP2r
@print-hex ( value* -- )
SWP ,&byte JSR
&byte ( byte -- )
STHk #04 SFT ,&parse JSR #18 DEO
STHr #0f AND ,&parse JSR #18 DEO
JMP2r
&parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r
&above #57 ADD JMP2r
JMP2r
@smul2 ( a* b* -- c* )
OVR2 POP #80 AND #07 SFT STH
OVR #80 AND #07 SFT STHr ADD #01 AND ,&sign STR
#10 SFT2 #01 SFT2
LITr 00
DUP2 #8000 LTH2 ,&b-positive JCN
INCr DUP2k EOR2 SWP2 SUB2
&b-positive
SWP2
#10 SFT2 #01 SFT2
MUL2
,&sign LDR ,&flip JCN
JMP2r
&flip
#0000 SWP2 --
DUP2 #8000 LTH2 ,&a-positive JCN
INCr DUP2k EOR2 SWP2 SUB2
&a-positive
( ahi alo bhi blo )
LITr 00 STH ( ahi alo bhi / blo* )
OVRr STH ( ahi alo / blo* bhi* )
OVRr STH ( ahi / blo* bhi* alo* )
OVRr STH ( asign / blo* bhi* alo* ahi* )
ROT2r MUL2kr STH2r ( asign ahi-bhi* / blo* alo* ahi* bhi* )
ROT2r MUL2kr STH2r ( asign ahi-bhi* alo-bhi* / blo* ahi* bhi* alo* )
NIP2r ( asign ahi-bhi* alo-bhi* / blo* ahi* alo* )
ROT2r MUL2kr STH2r ( asign ahi-bhi* alo-bhi* alo-blo* / ahi* alo* blo* )
ROT2r MUL2r STH2r POP2r ( asign ahi-bhi* alo-bhi* alo-blo* ahi-blo* )
SWP2 ( asign ahi-bhi* alo-bhi* ahi-blo* alo-blo* )
( 32-bit result is [ r3 r2 r1 r0 ] )
POP #00 SWP ( asign ahi-bhi* alo-bhi* ahi-blo* r21* )
( r21 max is 00fe, ahi-blo max is 7e81, max sum is 7f7f )
ADD2 ( asign ahi-bhi* alo-bhi* r21'* )
( r21' max is 7f7f, alo-bhi max is 7e81, max sum is fe00 )
ADD2 ( asign ahi-bhi* r21"* )
( The result we want is bits 27-12 due to the fixed point representation we use. )
#04 SFT2 SWP2 #40 SFT2 ADD2
STHr #01 EQU JMP JMP2r
DUP2k EOR2 SWP2 SUB2
JMP2r
&sign $1
@sprites
0000 0000 0000 0000 0000 0000 0000 0000
0000 0018 1800 0000 0000 0000 0000 0000
0000 183c 3c18 0000 0000 0000 0000 0000
0018 3c7e 7e3c 1800 0000 0000 0000 0000
183c 7eff ff7e 3c18 0000 0000 0000 0000
3c7e ffff ffff 7e3c 0000 0000 0000 0000
7eff ffff ffff ff7e 0000 0000 0000 0000
ffff ffff ffff ffff 0000 0000 0000 0000
ffff ffe7 e7ff ffff 0000 0018 1800 0000
ffff e7c3 c3e7 ffff 0000 183c 3c18 0000
ffe7 c381 81c3 e7ff 0018 3c7e 7e3c 1800
e7c3 8100 0081 c3e7 183c 7eff ff7e 3c18
c381 0000 0000 81c3 3c7e ffff ffff 7e3c
8100 0000 0000 0081 7eff ffff ffff ff7e
0000 0000 0000 0000 ffff ffff ffff ffff
0000 0018 1800 0000 ffff ffff ffff ffff
0000 183c 3c18 0000 ffff ffff ffff ffff
0018 3c7e 7e3c 1800 ffff ffff ffff ffff
183c 7eff ff7e 3c18 ffff ffff ffff ffff
3c7e ffff ffff 7e3c ffff ffff ffff ffff
7eff ffff ffff ff7e ffff ffff ffff ffff
ffff ffff ffff ffff ffff ffff ffff ffff
ffff ffe7 e7ff ffff ffff ffe7 e7ff ffff
ffff e7c3 c3e7 ffff ffff e7c3 c3e7 ffff
ffe7 c381 81c3 e7ff ffe7 c381 81c3 e7ff
e7c3 8100 0081 c3e7 e7c3 8100 0081 c3e7
c381 0000 0000 81c3 c381 0000 0000 81c3
8100 0000 0000 0081 8100 0000 0000 0081

Binary file not shown.