uxn-utils/tcc/day5.tal

75 lines
1.3 KiB
Tal
Raw Normal View History

2022-12-16 14:59:44 -05:00
|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
2022-12-16 16:07:24 -05:00
#03af .System/r DEO2
#03af .System/g DEO2
#03af .System/b DEO2
2022-12-16 14:59:44 -05:00
( 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
2022-12-16 16:07:24 -05:00
#70 SFT2 ADD2 #1fff AND2
2022-12-16 14:59:44 -05:00
;atan2 ADD2 LDA
2022-12-16 16:07:24 -05:00
DUP #04 SFT STHr ADD
DUP #04 SFT ORA
OVR #0f AND EOR
SWP #0f AND .f LDZ2 #01 SFT2 NIP #0f AND #0f SWP SUB EQU ORA
2022-12-16 14:59:44 -05:00
.Screen/pixel DEO
JMP2r
@get-quad ( x* y* -- quad )
.Screen/height DEI2 #01 SFT2 GTH2 #10 SFT STH
2022-12-16 16:07:24 -05:00
.Screen/width DEI2 #01 SFT2 LTH2 STHr ORA
2022-12-16 14:59:44 -05:00
JMP2r
@atan2 ~lut5.tal