automatic movement key

This commit is contained in:
~d6 2024-07-28 15:19:05 -04:00
parent 68d8fc725d
commit 1c714bae46
3 changed files with 63 additions and 23 deletions

View File

@ -10,6 +10,7 @@
- Click to pick up cards; release to drop them
- Press *Esc* to restart the game
- Press *Return* to print internal game state
- Press *Space* to automatically move "safe" cards to the foundation
## details
@ -21,7 +22,8 @@ Currently *Kodiak* is very limited:
- No scoring or timing
- No music or animations
- No splash screen
- No buttons to restart or quit
- No on-screen buttons to restart or quit
- No options
Future releases may relax some or all of these constraints.

Binary file not shown.

View File

@ -6,8 +6,8 @@
( * music? )
( * save game file? stats? )
( * animations? flash stock when clicked? )
( * moving/drawing near boundaries is weird )
( * sometimes movement feels stutter-y )
( * automatically keeping @auto up-to-date is arguably better than recalculating )
|00 @System [ &vect $2 &expansion $2 &title $2 &metadata $2 &r $2 &g $2 &b $2 ]
|10 @Console [ &vect $2 &r $1 &exec $2 &mode $1 &dead $1 &exit $1 &w $1 ]
@ -46,6 +46,7 @@
&mouse-state $1 ( previous mouse state )
&mouse-x $2 ( previous x-coordinate )
&mouse-y $2 ] ( previous y-coordinate )
@auto $4 ( sorted foundation for auto-move: C D S H )
|0100
@ -123,6 +124,7 @@
.held #02 dump-mem
.dragging #05 dump-mem
.prev #06 dump-mem
.auto #04 dump-mem
LIT "- .Console/w DEOk DEOk DEOk DEOk DEO
#0a .Console/w DEO
JMP2r
@ -553,6 +555,59 @@
&cancel ( i^ top^ row^ [n*] )
POP2 POP POP2r #00 JMP2r ( 0^ )
@min ( x^ y^ -> min[x,y]^ )
LTHk JMP SWP POP JMP2r
@check-auto ( card^ -> ok^ )
DUP #30 AND ( card^ suit^ )
#04 SFT .auto ADD LDZ INC ( card^ base+1^ )
OVR #0f AND EQU ?&ok ( card^ ; base+1=face? )
POP #00 JMP2r ( 0^ )
&ok DUP #30 AND ( card^ suit^ )
#04 SFT INC #03 AND ( card^ alt1^ )
INCk INC #03 AND ( card^ alt1^ alt2^ )
.auto ADD LDZ SWP ( card^ face2^ alt1^ )
.auto ADD LDZ min ( card^ min-face^ )
INC INC INC SWP #0f AND ( min-face+3^ face^ )
GTH JMP2r ( min-face+3>face^ )
@auto-move-col ( col^ -> ok^ )
DUP top-column LDZ ( col^ card^ )
DUP check-auto ?&ok !&done ( col^ card^ )
&ok auto-dest STH top-column ( src^ [dst^] )
LDZk STHr STZ remove-card #01 JMP2r ( 1^ )
&done POP2 #00 JMP2r ( 0^ )
@auto-dest ( card^ -> dst^ )
DUP #0f AND #01 EQU ?&aces ( card^ )
#30 AND STH ( [suit^] )
.foundation #04 OVR ADD SWP ( lim^ start^ [suit^] )
&loop LDZk #30 AND STHkr EQU ?&ok ( lim^ zp^ [suit^] )
INC GTHk ?&loop ( lim^ zp+1^ [suit^] )
&ok POPr NIP JMP2r ( zp^ )
&aces ( card^ )
POP .foundation #04 OVR ADD SWP ( lim^ start^ )
&loop2 LDZk ?&next NIP JMP2r ( zp^ )
&next INC GTHk ?&loop2 ( lim^ zp+1^ )
@auto-move ( -> )
prepare-auto #0700 ( lim^ col0^ )
&loop DUP auto-move-col ?&found INC GTHk ?&loop ( lim^ col+1^ )
POP2 draw JMP2r ( ; FIXME )
&found POP2 !auto-move ( )
@prepare-auto ( -> )
.auto #04 initialize ( ; reset auto )
.foundation #04 OVR ADD SWP ( lim^ start^ )
&loop LDZk update-auto ( lim^ pos^ )
INC GTHk ?&loop ( lim^ pos+1^ )
POP2 JMP2r ()
@update-auto ( card^ -> )
DUP ?&ok POP JMP2r ( )
&ok DUP #30 AND ( card^ suit^ )
#04 SFT .auto ADD ( card^ zp^ )
SWP #0f AND SWP STZ JMP2r ( ; zp<-face )
@on-click-up ( -> )
.Mouse/state DEI #ff EOR ( not-state^ )
@ -562,34 +617,17 @@
JMP2r
@on-key ( -> brk )
on-press on-release
on-press
.Controller/button DEI .prev/button STZ
BRK
@on-release ( -> )
JMP2r
( .Controller/button DEI #ff EOR ( not-button^ )
.prev/button LDZ AND ( release^ )
DUP #00 EQU ?&skip
DUP #08 AND ?&start
&skip POP JMP2r
&start POP !draw-cards )
@on-press ( -> )
.Controller/key DEI #0d EQU ?dump-state
.Controller/key DEI #1b EQU ?reset
.Controller/key DEI #0d EQU ?dump-state ( ; 0x0d: return )
.Controller/key DEI #1b EQU ?reset ( ; 0x1b: esc )
.Controller/key DEI #20 EQU ?auto-move ( ; 0x20: space )
JMP2r
( .Controller/button DEI ( button^ )
.prev/button LDZ #ff EOR AND ( press^ )
DUP #00 EQU ?&skip
DUP #01 AND ?&ctrl
DUP #02 AND ?&alt
DUP #04 AND ?&select
DUP #08 AND ?&start
&skip POP JMP2r
&ctrl POP !try-to-flip
&alt POP !flip-all-cards
&select POP !randomize
&start POP !reset )
~cards.tal