half-way to flying cards

This commit is contained in:
~d6 2024-07-30 22:25:37 -04:00
parent 8563effb87
commit 1cacc983c7
1 changed files with 69 additions and 15 deletions

View File

@ -3,6 +3,8 @@
( TODO )
( * restart/quit game button )
( * automatically moving safe cards to foundation? )
( * make bear react to moving cards )
( * move cards back from foundation? )
( * music? )
( * save game file? stats? )
( * animations? flash stock when clicked? )
@ -47,7 +49,14 @@
&mouse-x $2 ( previous x-coordinate )
&mouse-y $2 ] ( previous y-coordinate )
@auto $4 ( sorted foundation for auto-move: C D S H )
@frame $1 ( frame counter )
@frame $1 ( frame counter; cycles 0-255 continually )
@move [ &src $1 ( card starting address )
&dst $1 ( card destination address after move )
&time $1 ( time spent moving, 0-15 frames )
&x0 $2 ( starting x coord )
&y0 $2 ( starting y coord )
&x1 $2 ( ending x coord )
&y1 $2 ] ( ending y coord )
|0100
@ -71,6 +80,9 @@
.held #02 initialize
.dragging #05 initialize
.prev #06 initialize
.auto #04 initialize
.frame #01 initialize
.move #0a initialize
shuffle-stock
deal-tableau
@ -127,9 +139,10 @@
.dragging #05 dump-mem
.prev #06 dump-mem
.auto #04 dump-mem
.move #0a dump-mem
LIT "- .Console/w DEOk DEOk DEOk DEOk DEO
#0a .Console/w DEO
JMP2r
#0a .Console/w DEO JMP2r
@draw ( -> )
draw-background
@ -215,7 +228,7 @@
&done POP POP2 POPr JMP2r ( )
&empty POP #0008 DUP2 ( 8* 8* )
.Screen/x DEO2 .Screen/y DEO2 ( ; x<-8, y<-8 )
#00 maybe-draw-c JMP2r ( )
#00 !maybe-draw-c ( )
@draw-waste ( -> )
#001c ,&x STR2 ( ; x0<-28 )
@ -291,7 +304,47 @@
DUP #31 LTH #03 MUL ADD #24 SUB JMP2r
&lt DUP #11 LTH #1d MUL ADD #09 ADD JMP2r
@card-pos-xy ( card^ -> x* y* )
( TODO )
( - copy from other implementations )
( - consider refactoring them to use this intead )
POP #ffff #ffff JMP2r ( FIXME )
( we expect 0 <= time <= 16 )
@move-pos-xy ( -> x* y* )
#00 .move/time LDZ ( t* )
.move/x1 LDZ2 .move/x0 LDZ2 STH2k SUB2 ( dx* [x0*] )
OVR2 MUL2 #04 SFT2 STH2r ADD2 SWP2 ( x=x0+[dx*t/16]* t* )
.move/y1 LDZ2 .move/y0 LDZ2 STH2k SUB2 ( x* t* dy* [y0*] )
MUL2 #04 SFT2 STH2r ADD2 JMP2r ( x* y=y0+[dy*t/16]* )
@start-move ( src^ dst^ -> )
DUP card-pos-xy ( src^ dst^ x1* y1* )
.move/y1 STZ2 .move/x1 STZ2 .move/dst STZ ( src^ )
DUP card-pos-xy ( src^ x0* y* )
.move/y0 STZ2 .move/x0 STZ2 .move/src STZ ( )
#00 .move/time STZ !update-move ( )
@update-move ( -> )
move-pos-xy ( x* y* )
.Screen/y DEO2 .Screen/x DEO2 ( ; set x,y )
;blank .Screen/addr DEO2 ( ; use blank tile )
#12 .Screen/auto DEO ( ; draw 2, inc x )
#41 .Screen/sprite DEOk DEOk DEO ( ; erase three rows )
.move/time LDZ #0f GTH ?end-move ( ; are we done? )
.move/time LDZk INC SWP STZ ( ; time<-time+1 )
move-pos-xy ( x* y* )
.Screen/y DEO2 .Screen/x DEO2 ( ; set x,y )
.move/src LDZ LDZ !draw-c ( ; draw card )
@end-move ( -> )
( TODO )
( - copy the card over )
( - do any necessary flipping, i.e. remove-card )
( - zero out moving )
@on-refresh ( -> brk )
.move/src LDZ #00 EQU ?{ update-move }
.frame LDZ
DUP #e8 NEQ ?{ ;sprites #0040 ADD2 !&update }
DUP #f0 NEQ ?{ ;sprites #0080 ADD2 !&update }
@ -307,9 +360,10 @@
@on-mouse ( -> brk )
on-move
.move/src LDZ ?&skip
on-click-down
on-click-up
.Mouse/state DEI .prev/mouse-state STZ
&skip .Mouse/state DEI .prev/mouse-state STZ
BRK
@on-move ( -> )
@ -437,17 +491,14 @@
.held LDZ LDZ #7f AND SWP STZ ( ; z<-held )
.held LDZ remove-card ( ; remove held from prev position )
#0000 .held STZ2 ( ; remove holding status )
#01 JMP2r ( 1^ )
post-move #01 JMP2r ( 1^ )
@try-release-tableau ( -> bool^ )
#0700 &loop
DUP try-release-column ?&success
INC GTHk ?&loop POP2 #00 JMP2r
&success #01 JMP2r
&success post-move #01 JMP2r
( TODO: check if bottom of stack intersects with top card of column )
( TODO: check if bottom of stack is compatible with top of column )
( TODO: place stack, clear prev, and return #01 if ok )
@try-release-column ( col^ -> bool^ )
STHk column-x
STHkr column-y ( x0* y* [col^] )
@ -456,8 +507,8 @@
&found ( [col^] )
STHkr top-column LDZ ( under^ [col^] )
.held LDZ LDZ ( under^ over^ [col^] )
valid-card-tableau ?&ok ( ok^ [col^] )
POPr #00 JMP2r ( 0^ ; TODO )
valid-card-tableau ?&ok ( [col^] )
POPr #00 JMP2r ( 0^ )
&ok STHr top-column ( top^ )
inc-unless-empty STH ( [dst^] ; inc unless column is empty )
.held LDZ2 INC SWP ( lim^ src^ [dst^] )
@ -472,8 +523,8 @@
@release ( -> )
clear-prev-hold ( )
try-release-foundation ?&done ( )
try-release-tableau ?&done ( )
try-release-foundation ?&done ( )
try-release-tableau ?&done ( )
.held LDZ2 SWP ( last^ first^ )
&loop DUP LDZk #80 EOR SWP STZ ( last^ pos^ ; pos<-c^0x80 )
INC LTHk #00 EQU ?&loop POP2 ( )
@ -628,7 +679,7 @@
@auto-move ( -> )
prepare-auto #0700 ( lim^ col0^ )
&loop DUP auto-move-col ?&found INC GTHk ?&loop ( lim^ col+1^ )
POP2 draw JMP2r ( ; FIXME )
POP2 post-move !draw ( x; FIXME )
&found POP2 !auto-move ( )
@prepare-auto ( -> )
@ -644,6 +695,9 @@
#04 SFT .auto ADD ( card^ zp^ )
SWP #0f AND SWP STZ JMP2r ( ; zp<-face )
@post-move ( -> )
JMP2r
@on-click-up ( -> )
.Mouse/state DEI #ff EOR ( not-state^ )
.prev/mouse-state LDZ AND ( up^ )