113 lines
2.1 KiB
Tal
113 lines
2.1 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
|
||
|
|
||
|
|0100
|
||
|
|
||
|
#23ef .System/r DEO2
|
||
|
#3b7f .System/g DEO2
|
||
|
#665f .System/b DEO2
|
||
|
,draw-tree JSR
|
||
|
;prng-init JSR2
|
||
|
( prepare particles )
|
||
|
.Screen/width DEI2 #0000
|
||
|
&l
|
||
|
( addr ) DUP2 #20 SFT2 ;snow ADD2 STH2
|
||
|
( x ) DUP2 STH2kr STA2
|
||
|
( y ) INC2r INC2r ;prng JSR2 #0100 ( mod2 ) DIV2k MUL2 SUB2 STH2r STA2
|
||
|
INC2 GTH2k ,&l JCN
|
||
|
POP2 POP2
|
||
|
( animate )
|
||
|
;on-frame .Screen/vector DEO2
|
||
|
|
||
|
BRK
|
||
|
|
||
|
@draw-tree ( -- )
|
||
|
|
||
|
#0060 .Screen/y DEO2
|
||
|
( star )
|
||
|
#0103
|
||
|
DUP2 ,draw-line JSR
|
||
|
#0203 ,draw-line JSR
|
||
|
,draw-line JSR
|
||
|
( tree )
|
||
|
#8000
|
||
|
&tree
|
||
|
DUP #02 SFT #3f AND DUP ADD STH
|
||
|
DUP #0f AND STHr ADD #01 ,draw-line JSR
|
||
|
INC GTHk ,&tree JCN
|
||
|
POP2
|
||
|
( bark )
|
||
|
#1000
|
||
|
&bark
|
||
|
#0802 ,draw-line JSR
|
||
|
INC GTHk ,&bark JCN
|
||
|
POP2
|
||
|
( ground )
|
||
|
#ff03
|
||
|
|
||
|
@draw-line ( width color -- )
|
||
|
|
||
|
,&c STR
|
||
|
#00 SWP
|
||
|
DUP2 .Screen/width DEI2 #01 SFT2 SWP2 SUB2 ,&o STR2
|
||
|
DUP2 ADD2 INC2 #0000
|
||
|
&l
|
||
|
DUP2 [ LIT2 &o $2 ] ADD2 .Screen/x DEO2
|
||
|
[ LIT &c $1 ] .Screen/pixel DEO
|
||
|
INC2 GTH2k ,&l JCN
|
||
|
POP2 POP2
|
||
|
.Screen/y DEI2k INC2 ROT DEO2
|
||
|
|
||
|
JMP2r
|
||
|
|
||
|
@on-frame ( -> )
|
||
|
|
||
|
.Screen/width DEI2 #0000
|
||
|
&l
|
||
|
;prng JSR2 NIP #07 AND ,&skip JCN
|
||
|
DUP2 #20 SFT2 ;snow ADD2
|
||
|
( clear ) DUP2 #40 ,draw-snowflake JSR
|
||
|
( y ) INC2k INC2 LDA2k INC2 #00f0 DIV2k MUL2 SUB2 SWP2 STA2
|
||
|
( draw ) #43 ,draw-snowflake JSR
|
||
|
&skip
|
||
|
INC2 GTH2k ,&l JCN
|
||
|
POP2 POP2
|
||
|
|
||
|
BRK
|
||
|
|
||
|
@draw-snowflake ( addr* color -- )
|
||
|
|
||
|
ROT ROT LDA2k .Screen/x DEO2
|
||
|
INC2 INC2 LDA2 .Screen/y DEO2
|
||
|
.Screen/pixel DEO
|
||
|
|
||
|
JMP2r
|
||
|
|
||
|
@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
|
||
|
|
||
|
@snow
|
||
|
|