From 11071bc6bff77650f7e2bd716df71456992c2214 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 8 Feb 2023 18:32:46 -0800 Subject: [PATCH] Preparing to bring drool into project --- etc/drool.tal | 164 +++++++++++++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 68 deletions(-) diff --git a/etc/drool.tal b/etc/drool.tal index 997453b..18df6b0 100644 --- a/etc/drool.tal +++ b/etc/drool.tal @@ -16,15 +16,7 @@ |0100 @Reset ( -> ) - ( seed prng ) - #00 .DateTime/second DEI - #00 .DateTime/minute DEI #60 SFT2 EOR2 - #00 .DateTime/hour DEI #c0 SFT2 EOR2 ;prng/x STA2 - #00 .DateTime/hour DEI #04 SFT2 - #00 .DateTime/day DEI DUP2 ADD2 EOR2 - #00 .DateTime/month DEI #60 SFT2 EOR2 - .DateTime/year DEI2 #a0 SFT2 EOR2 ;prng/y STA2 - ;prng/x LDA2 ;prng/y LDA2 EOR2 + prng-init LIT2r =rabbits #0f05 &loop-x #0f05 &loop-y @@ -40,7 +32,7 @@ @repeat init-occupancy - #00 ;precalc-frame STA + #00 ;precalculate/f STA ;precalculate-vector .Screen/vector DEO2 BRK @@ -48,13 +40,13 @@ BRK @init-occupancy ( -- ) #1400 - &loop-y + &y #1400 - &loop-x + &x ROTk #00 set-occupied POP - INC GTHk ?&loop-x + INC GTHk ?&x POP2 - INC GTHk ?&loop-y + INC GTHk ?&y POP2 ;rabbits @@ -74,92 +66,95 @@ BRK @precalculate ( -- ) - ;rabbits #00c8 OVR ,precalc-frame LDR MUL2 ADD2 ( first rabbit address ) - DUP2 #00c8 ADD2 SWP2 &loop-rabbits - DUP2 ,move-rabbit JSR - INC2 INC2 - GTH2k ?&loop-rabbits - POP2 POP2 - ,precalc-frame LDR INC DUP ,precalc-frame STR + ;rabbits #00c8 OVR ,&f LDR MUL2 ADD2 ( first rabbit address ) + DUP2 #00c8 ADD2 SWP2 + + &loop-rabbits + DUP2 move-rabbit + INC2 INC2 GTH2k ?&loop-rabbits + POP2 POP2 + + [ LIT &f $1 ] INCk ,&f STR #05 EQU [ JMP JMP2r ] - display-init + + ( init display ) + .Screen/width DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/xoffset STA2 + .Screen/height DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/yoffset STA2 + ;rabbit-icn .Screen/addr DEO2 ;display .Screen/vector DEO2 JMP2r -@precalc-frame $1 - @set-occupied ( x y value -- ) + STH #00 SWP #0014 MUL2 ( x yoffset* / value ) ROT #00 SWP ADD2 ( offset* / value ) ;occupied ADD2 STH2 STAr - JMP2r + +JMP2r @move-rabbit ( addr* -- ) + STH2k LDA2 ( x y / addr* ) DUP2 #00 set-occupied ;&possible-moves ( x y possible* / addr* ) - OVR2 #01 SUB ,&check-move JSR ( up ) - OVR2 INC INC ,&check-move JSR ( down ) - OVR2 #0100 SUB2 ,&check-move JSR ( left ) - OVR2 #0100 ADD2 ,&check-move JSR ( right ) + ( up ) OVR2 #01 SUB check-move + ( down ) OVR2 INC INC check-move + ( left ) OVR2 #0100 SUB2 check-move + ( right ) OVR2 #0100 ADD2 check-move ;&possible-moves SUB2 ( x y num-possible-times-2* / addr* ) DUP ?&can-move POP2 &write ( x y / addr* ) DUP2 #01 set-occupied STH2r #00c8 ADD2 STA2 - JMP2r - &can-move ( x y num-possible-times-2* / addr* ) +JMP2r + +&can-move ( x y num-possible-times-2* / addr* ) + NIP2 ( num-possible-times-2* / addr* ) - ,prng JSR SWP2 DIV2k MUL2 SUB2 #fe AND ( chosen-move* / addr* ) + prng SWP2 DIV2k MUL2 SUB2 #fe AND ( chosen-move* / addr* ) ;&possible-moves ADD2 LDA2 - ,&write JMP - &check-move ( possible* new-x new-y -- possible'* ) +!&write + +&possible-moves $10 + +@check-move ( possible* new-x new-y -- possible'* ) + DUP2 get-occupied ?&blocked OVR2r LIT2r 00c8 SUB2r ( possible* new-x new-y / previous-frame-addr* ) - &check-history-loop + &l ;rabbits INC2 STH2kr GTH2 ?&history-okay DUP2 STH2kr LDA2 EQU2 ?&history-clash LIT2r 00c8 SUB2r - ,&check-history-loop JMP - &history-okay + !&l + +&history-okay + POP2r OVR2 STA2 INC2 INC2 - JMP2r - &history-clash ( possible* new-x new-y / previous-frame-addr* ) - POP2r - &blocked ( possible* new-x new-y ) - POP2 - JMP2r - &possible-moves $10 +JMP2r + +&history-clash ( possible* new-x new-y / previous-frame-addr* ) + POP2r +&blocked ( possible* new-x new-y ) + POP2 +JMP2r @get-occupied ( x y -- value ) + #00 SWP #0014 MUL2 ( x yoffset* ) ROT #00 SWP ADD2 ( offset* ) ;occupied ADD2 LDA - 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 - -@display-init ( -- ) - .Screen/width DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/xoffset STA2 - .Screen/height DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/yoffset STA2 - ;rabbit-icn .Screen/addr DEO2 - JMP2r +JMP2r @display-rabbit ( color n counter -- ) + OVR LTHk ?&finish SUB ( color n timeline ) DUP #63 GTH ?&start @@ -174,12 +169,15 @@ JMP2r STHr ,&mix JSR LIT2 &yoffset $2 ADD2 .Screen/y DEO2 STHr ,&mix JSR LIT2 &xoffset $2 ADD2 .Screen/x DEO2 .Screen/sprite DEO - JMP2r - &mix ( to-z from-z -- mixed* ) +JMP2r + +&mix ( to-z from-z -- mixed* ) + #00 SWP LIT2 00 &from-weight 00 MUL2 ( to-n from-mixed* ) ROT #00 SWP LIT2 00 &to-weight 00 MUL2 ADD2 - JMP2r + +JMP2r &finish ( color n counter n ) POP @@ -193,10 +191,8 @@ JMP2r LDA2 STH2k ,&draw JMP -@display-counter $1 - @display ( -> ) - ,display-counter LDR #01 SUB DUP ,display-counter STR + [ LIT &counter $1 ] #01 SUB DUP ,&counter STR DUP #f0 LTH ?&skip-palette #ff OVR SUB #00 DUP2 .System/r DEO2 @@ -219,7 +215,8 @@ JMP2r BRK @sunset ( -> ) - ;display-counter LDA #02 SUB DUP ;display-counter STA + + ;display/counter LDA #02 SUB DUP ;display/counter STA DUP #1f GTH ?&skip-palette DUP #01 SFT #00 DUP2 .System/r DEO2 @@ -232,9 +229,40 @@ JMP2r POP2 &skip-palette ?&no-finish - ;repeat JMP2 + !repeat &no-finish - BRK + +BRK + +( +@|stdlib ) + +@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 ) @rabbit-icn [ 003c 7e7e 7e7e 3c00 ]