uxn-utils/gui/misc/tcc/day8.tal

134 lines
2.6 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
|c0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1
|0000
@f $2
|0100
( theme )
#0f0f .System/r DEO2
#0ff0 .System/g DEO2
#0f0f .System/b DEO2
( size )
#0100 .Screen/width DEO2
#0100 .Screen/height DEO2
( animate )
#01 .Screen/auto DEO
;on-frame2 .Screen/vector DEO2
prng-init
BRK
@on-frame2 ( -> )
[ LIT2 &f $2 ] INC2k ,&f STR2
draw-circle
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
@draw-bg ( -- )
#0000 .Screen/y DEO2
#0008 .f LDZ2 #01 SFT2 #004f AND2 SUB2 .Screen/x DEO2
#f1 .Screen/auto DEO
;tile-icn .Screen/addr DEO2
#2200
&l
DUP #01 AND .Screen/sprite DEO
INC GTHk ,&l JCN
POP2
JMP2r
@draw-circles ( offset* -- )
STH2
#1000
&l
#00 OVR #40 SFT2 STH2kr ADD2 ;draw-circle JSR2
INC GTHk ,&l JCN
POP2
POP2r
JMP2r
@draw-circle ( offset* -- )
( x )
DUP2 #001f ADD2 #007f AND2 #10 SFT2 ;cos ADD2 LDA2 #09 SFT2
#0080 ADD2
#0040 SUB2
.Screen/x DEO2
( y )
#007f AND2 #10 SFT2 ;cos ADD2 LDA2 #09 SFT2
#0030 ADD2 .Screen/y DEO2
prng ADD #80 ORA .Screen/pixel DEO
JMP2r
&colors 05 0a 0f 0a
@prng-init ( -- )
( seed )
#00 .DateTime/second DEI
#00 .DateTime/minute DEI #60 SFT2 EOR2
#00 .DateTime/hour DEI #c0 SFT2 EOR2 ,prng/x STR2
#00 .DateTime/hour DEI #04 SFT2
#00 .DateTime/day DEI #10 SFT2 EOR2
#00 .DateTime/month DEI #60 SFT2 EOR2
.DateTime/year DEI2 #a0 SFT2 EOR2 ,prng/y STR2
JMP2r
@prng ( -- number* )
LIT2 &x $2
DUP2 #50 SFT2 EOR2
DUP2 #03 SFT2 EOR2
LIT2 &y $2 DUP2 ,&x STR2
DUP2 #01 SFT2 EOR2 EOR2
,&y STR2k POP
JMP2r
(
@|assets )
@tile-icn
ffff ffff ffff ffff
@circle-icn
030f 3f3f 7f7f ffff c0f0 fcfc fefe ffff
ffff 7f7f 3f3f 0f03 ffff fefe fcfc f0c0
@cos ( cos256 )
ffff ffff ffff fefe fdfc fcfb faf9 f8f7
f6f5 f3f2 f0ef edec eae8 e6e4 e2e0 dedc
dad8 d5d3 d1ce ccc9 c7c4 c1bf bcb9 b6b3
b0ae aba8 a5a2 9f9c 9895 928f 8c89 8683
807c 7976 7370 6d6a 6763 605d 5a57 5451
4f4c 4946 4340 3e3b 3836 3331 2e2c 2a27
2523 211f 1d1b 1917 1513 1210 0f0d 0c0a
0908 0706 0504 0303 0201 0100 0000 0000
0000 0000 0000 0101 0203 0304 0506 0708
090a 0c0d 0f10 1213 1517 191b 1d1f 2123
2527 2a2c 2e31 3336 383b 3e40 4346 494c
4f51 5457 5a5d 6063 676a 6d70 7376 797c
7f83 8689 8c8f 9295 989c 9fa2 a5a8 abae
b0b3 b6b9 bcbf c1c4 c7c9 ccce d1d3 d5d8
dadc dee0 e2e4 e6e8 eaec edef f0f2 f3f5
f6f7 f8f9 fafb fcfc fdfe feff ffff ffff