grabbing stacks works
This commit is contained in:
parent
86fb2dab75
commit
aff923b155
68
kodiak.tal
68
kodiak.tal
|
@ -29,7 +29,8 @@
|
||||||
@waste $18 ( face up pile - 24 bytes )
|
@waste $18 ( face up pile - 24 bytes )
|
||||||
@foundation $4 ( one per suit - 4 bytes, 4x1 )
|
@foundation $4 ( one per suit - 4 bytes, 4x1 )
|
||||||
@tableau $85 ( the main board - 133 bytes, 7x19 )
|
@tableau $85 ( the main board - 133 bytes, 7x19 )
|
||||||
@held $0d ( stack of up to 13 held cards )
|
@held [ &first $1 ( stack of up to 13 held cards )
|
||||||
|
&last $1 ] ( stack of up to 13 held cards )
|
||||||
@dragging [ $1 ( are we dragging? )
|
@dragging [ $1 ( are we dragging? )
|
||||||
&x $2 ( x-coord for start of drag )
|
&x $2 ( x-coord for start of drag )
|
||||||
&y $2 ] ( y-coord for start of drag )
|
&y $2 ] ( y-coord for start of drag )
|
||||||
|
@ -155,8 +156,12 @@
|
||||||
@draw-tableau
|
@draw-tableau
|
||||||
#0700 &loop DUP draw-column INC GTHk ?&loop POP2 JMP2r
|
#0700 &loop DUP draw-column INC GTHk ?&loop POP2 JMP2r
|
||||||
|
|
||||||
|
@column-x ( idx^ -> x* )
|
||||||
|
#00 SWP #0018 MUL2 #0030 ADD2 JMP2r
|
||||||
|
|
||||||
@draw-column ( idx^ -> )
|
@draw-column ( idx^ -> )
|
||||||
#00 OVR #0018 MUL2 #0030 ADD2 ,&x STR2 ( idx^ ; x<-32+24*idx )
|
( #00 OVR #0018 MUL2 #0030 ADD2 ,&x STR2 ( idx^ ; x<-32+24*idx ) )
|
||||||
|
DUP column-x ,&x STR2 ( idx^ ; x<-32+24*idx )
|
||||||
#0024 ,&y STR2 ( idx^ ; y<-32 )
|
#0024 ,&y STR2 ( idx^ ; y<-32 )
|
||||||
#13 MUL .tableau ADD ( pos=t+idx*19^ )
|
#13 MUL .tableau ADD ( pos=t+idx*19^ )
|
||||||
DUP #13 ADD SWP ( lim=pos+19^ pos^ )
|
DUP #13 ADD SWP ( lim=pos+19^ pos^ )
|
||||||
|
@ -256,10 +261,16 @@
|
||||||
draw-stock #01 JMP2r ( 1^ )
|
draw-stock #01 JMP2r ( 1^ )
|
||||||
&no2 POPr &no1 #00 JMP2r ( 0^ )
|
&no2 POPr &no1 #00 JMP2r ( 0^ )
|
||||||
|
|
||||||
@start-drag ( x* y* -> )
|
@start-drag ( x* y* first^ last^ -> )
|
||||||
( TODO: take t^ input, update t, update held )
|
DUP2 .held STZ2 ( x* y* first^ last^ ; held<-first,last )
|
||||||
.dragging/y STZ2 .dragging/x STZ2
|
SWP ( x* y* last^ first^ [h0^] )
|
||||||
#01 .dragging STZ JMP2r
|
&loop LTHk ?&done ( x* y* last^ z^ [h^] )
|
||||||
|
DUP LDZk #80 EOR SWP STZ ( x* y* last^ z^ [h^] ; z<-q )
|
||||||
|
INC !&loop ( x* y* last^ z+1^ [h+1^] )
|
||||||
|
&done POP2 ( x* y* )
|
||||||
|
.dragging/y STZ2 ( x* ; d/y<-y )
|
||||||
|
.dragging/x STZ2 ( ; d/x<-x )
|
||||||
|
#01 .dragging STZ JMP2r ( )
|
||||||
|
|
||||||
@maybe-select-waste ( -> bool^ )
|
@maybe-select-waste ( -> bool^ )
|
||||||
.Mouse/y DEI2 #0008 LTH2 ?&no1
|
.Mouse/y DEI2 #0008 LTH2 ?&no1
|
||||||
|
@ -269,9 +280,9 @@
|
||||||
DUP2 ,&dx STR2 ( w* [t^ w*] ; dx<-w )
|
DUP2 ,&dx STR2 ( w* [t^ w*] ; dx<-w )
|
||||||
.Mouse/x DEI2 GTH2 ?&no2 ( [t^ w*] )
|
.Mouse/x DEI2 GTH2 ?&no2 ( [t^ w*] )
|
||||||
#002c #00 STHkr .waste SUB #0008 MUL2 ADD2 ( 0x2c+8*index* [t^ w*] )
|
#002c #00 STHkr .waste SUB #0008 MUL2 ADD2 ( 0x2c+8*index* [t^ w*] )
|
||||||
.Mouse/x DEI2 LTH2 ?&no2 ( [t^ w*] )
|
.Mouse/x DEI2 LTH2 ?&no2 ( [t^] )
|
||||||
LIT2 [ &dx $2 ] #0008 start-drag ( [^t] )
|
LIT2 [ &dx $2 ] #0008 STHr DUP ( dx* dy=8* t^ t^ )
|
||||||
STHr LDZk #80 EOR SWP STZ draw-waste #01 JMP2r ( 1^ )
|
start-drag draw-waste #01 JMP2r ( 1^ )
|
||||||
&no2 POP2r POPr &no1 #00 JMP2r ( 0^ )
|
&no2 POP2r POPr &no1 #00 JMP2r ( 0^ )
|
||||||
|
|
||||||
@maybe-select-tableau ( -> bool^ )
|
@maybe-select-tableau ( -> bool^ )
|
||||||
|
@ -280,28 +291,35 @@
|
||||||
.Mouse/x DEI2 #00cf GTH2 ?&no1 ( )
|
.Mouse/x DEI2 #00cf GTH2 ?&no1 ( )
|
||||||
#0040 LIT2r 0700 ( 64* [7^ 0^] )
|
#0040 LIT2r 0700 ( 64* [7^ 0^] )
|
||||||
&loop ( x* [lim^ i^] )
|
&loop ( x* [lim^ i^] )
|
||||||
DUP2 #0010 SUB2 ,&dx STR2 ( x* [lim^ i^] ; dx<-x )
|
|
||||||
.Mouse/x DEI2 OVR2 LTH2 ?&col ( x* [lim^ i^] )
|
.Mouse/x DEI2 OVR2 LTH2 ?&col ( x* [lim^ i^] )
|
||||||
#0008 ADD2 ( y1=y+8* [lim^ i^] )
|
#0008 ADD2 ( y1=y+8* [lim^ i^] )
|
||||||
.Mouse/x DEI2 OVR2 LTH2 ?&no2 ( y1* [lim^ i^] )
|
.Mouse/x DEI2 OVR2 LTH2 ?&no2 ( y1* [lim^ i^] )
|
||||||
#0010 ADD2 ( y2=y1+16* [lim^ i^] )
|
#0010 ADD2 ( y2=y1+16* [lim^ i^] )
|
||||||
INCr GTHkr STHr ?&loop ( y2 [lim i+1^] )
|
INCr GTHkr STHr ?&loop ( y2 [lim i+1^] )
|
||||||
&no2 POP2 POP2r &no1 #00 JMP2r ( 0^ )
|
&no2 POP2 POP2r &no1 #00 JMP2r ( 0^ )
|
||||||
&col ( i^ )
|
&col ( x* [lim^ i^] )
|
||||||
POP2 NIPr STHr ( i^ )
|
POP2 NIPr STHr !maybe-select-column ( bool^ )
|
||||||
DUPk top-column STHk SWP bot-column ( i^ top^ bot^ [top^] )
|
|
||||||
SUB #00 SWP ( i^ count* [top^] )
|
@maybe-select-column ( i^ -> bool^ )
|
||||||
#0008 MUL2 #0024 ADD2 ( i^ min=0x24+8*i* [top^] )
|
.Mouse/y DEI2 #0024 LTH2 ?&no ( i^ )
|
||||||
DUP2 ,&dy STR2 ( i^ min* [top^] ; dy<-min )
|
DUP top-column OVR bot-column LIT2r 0001 ( i^ top^ bot^ [1*] )
|
||||||
DUP2 #0018 ADD2 ( i^ min* max=min+0x18* [top^] )
|
&loop ( i^ top^ row^ [n*] )
|
||||||
.Mouse/y DEI2 LTH2 #00 EQU STH ( i^ min* [top^ max>=y^] )
|
GTHk ?&next !&done ( i^ top^ row^ [n*] )
|
||||||
.Mouse/y DEI2 GTH2 #00 EQU STHr ( i^ min<=y^ max>=y^ [top^] )
|
&next ( i^ top^ row^ [n*] )
|
||||||
AND ?&ok ( i^ [top^] )
|
.Mouse/y DEI2 ( i^ top^ row^ y* [n*] )
|
||||||
POP POPr #00 JMP2r ( 0^ )
|
STH2kr #0008 MUL2 #0024 ADD2 ( i^ top^ row^ y* lim=36+8n* [n*] )
|
||||||
&ok LIT2 [ &dx $2 ] LIT2 [ &dy $2 ] ( i^ dx* dy* )
|
LTH2 ?&match INC INC2r !&loop ( i^ top^ row+1^ [n+1*] )
|
||||||
start-drag ( i^ )
|
&done ( i^ top^ row^ [n*] )
|
||||||
STHr LDZk #80 EOR SWP STZ ( i^ ; top<-top^0x80 )
|
.Mouse/y DEI2 ( i^ top^ row^ y* [n*] )
|
||||||
draw-column #01 JMP2r ( 1^ )
|
STH2kr #0008 MUL2 #0034 ADD2 ( i^ top^ row^ y* lim=52+8n* [n*] )
|
||||||
|
LTH2 ?&match ( i^ top^ row^ [n*] )
|
||||||
|
POP2r POP2 &no POP #00 JMP2r ( 0^ )
|
||||||
|
&match ( i^ top^ row^ [n*] )
|
||||||
|
STH2 SWP2r column-x ( x* [top^ row^ n*] )
|
||||||
|
STH2r #0008 MUL2 #001c ADD2 ( x* y=28+8n* [top^ row^] )
|
||||||
|
STH2r SWP ( x* y* row^ top^ )
|
||||||
|
start-drag draw-tableau #01 JMP2r ( 1^ )
|
||||||
|
|
||||||
|
|
||||||
( @on-click-up ( -> )
|
( @on-click-up ( -> )
|
||||||
.Mouse/state DEI #ff EOR ( not-state^ )
|
.Mouse/state DEI #ff EOR ( not-state^ )
|
||||||
|
|
Loading…
Reference in New Issue