uxn-utils/tcc/day5.tal

91 lines
1.3 KiB
Tal

|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|0000
@f $2
|0100
#ff0f .System/r DEO2
#f0a0 .System/g DEO2
#f020 .System/b DEO2
( size )
#0100 .Screen/width DEO2
#0080 .Screen/height DEO2
( animate )
;on-frame .Screen/vector DEO2
BRK
@print ( short* -- )
SWP ,&byte JSR
&byte ( byte -- ) DUP #04 SFT ,&char JSR
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@on-frame ( -> )
.Screen/height DEI2 #0000
&v
STH2k
DUP2 .Screen/y DEO2
.Screen/width DEI2 #0000
&h
DUP2 .Screen/x DEO2
INC2k STH2kr INC2
;pixel JSR2
INC2 GTH2k ,&h JCN
POP2 POP2 POP2r
INC2 GTH2k ,&v JCN
POP2 POP2
.f LDZ2k INC2 ROT STZ2
BRK
@pixel ( x* y* -- )
OVR2 OVR2 ;get-quad JSR2 STH
SWP2
.Screen/width DEI2 #01 SFT2 GTH2k JMP SWP2 SUB2
SWP2
.Screen/height DEI2 #01 SFT2 GTH2k JMP SWP2 SUB2
SWP2 #007f AND2 SWP2
#0080 MUL2 ADD2 #1fff AND2
;atan2 ADD2 LDA
( ring )
DUP #0f AND .f LDZ2 #01 SFT2 NIP #0f AND EQU STH
#04 SFT
( cadran )
STHr ORA
STHr EOR
.Screen/pixel DEO
JMP2r
@get-quad ( x* y* -- quad )
.Screen/height DEI2 #01 SFT2 GTH2 #10 SFT STH
.Screen/width DEI2 #01 SFT2 GTH2 STHr ORA
JMP2r
@atan2 ~lut5.tal