From 1c714bae468588b77e771a5b506da6e4bfc0d93a Mon Sep 17 00:00:00 2001 From: d_m Date: Sun, 28 Jul 2024 15:19:05 -0400 Subject: [PATCH] automatic movement key --- README.md | 4 ++- kodiak.rom | Bin 10915 -> 11161 bytes kodiak.tal | 82 +++++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 63 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e59ef36..ffae5fa 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/kodiak.rom b/kodiak.rom index de5ff3fc9b3492ddd4ba5c49182f0d8d249d4c24..053e62d0f9f018e062675bc112b409fed59ae835 100644 GIT binary patch delta 651 zcmYk2O=uHQ5Xax_zU*$cE=iCi8@rM<)`e=79#XoNnnVQ^QA`iwMQ{)=mWRCvf*_7s zd#E2o78Iq2_2Vdb=s_w7JqX29PvWH)3qsLeEXF8W*Y}D+-(eVjGynh0o2Mrqo@#C1 z-*XdToT}s^jL|XT2uG<&5+0;?q#=ybdrBb;(GnR5dk{_|Od@QK`AcdI$M)NM=i2VF z)FnG;H@OewE0RraQJ^&wjl*%x-Znc2&pr9E6c!S&az6FL03LLe#|J{gZd zx_WX@Mjgj=c}wPt=Os+Rw4baU(1q5m_)OD$Sk^EprsrWbfZ9y<$qgHNv}*sRpMKIaw+;@ z^=VEiDyQoMTT3ypkOqe74knKU71SC3!6{5`|AkU8ojy`>N@2|A!-FaH7J;>VEy delta 412 zcmYL?%}X0m6vf}2nT%%gw5E`c)L@ZTV+9V= z0@~PSn!^z+rUs6YVw%D!T&5>X9j3QTQak(Do!04-Z=2`YNfdvWDZoRq5c9wvwMDB| z`bE;E-}F3n842Mc%2dQd7ciD}(KR+~MX56uBawS#(lx>o3p;W*)OY(S4XUm^YsrGT zvfGxEs5PhRIbR?U6tto5ooAMOkR(pdQ3vUqf4v>E$gmi|hdfTRBF4u&h6XDafBRw7 zgsS?Vp0K2^a$Z;~`ID+zxE#PaPQL{GzajO9!bBcMYs8ydxsT4u@;qP zJiejL_MbOum3(#M6x REd$0HvDz!=lE?C0`4*>mc`X0{ diff --git a/kodiak.tal b/kodiak.tal index 0ead9ee..172c5bb 100644 --- a/kodiak.tal +++ b/kodiak.tal @@ -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