clean up drawing

This commit is contained in:
~d6 2024-07-15 23:11:42 -04:00
parent bdc7e250c4
commit 7a77a48667
1 changed files with 36 additions and 41 deletions

View File

@ -64,17 +64,13 @@
#16 LDZ #bf AND .waste #01 ADD STZ #0016 STZ #16 LDZ #bf AND .waste #01 ADD STZ #0016 STZ
#15 LDZ #bf AND .waste #02 ADD STZ #0015 STZ #15 LDZ #bf AND .waste #02 ADD STZ #0015 STZ
draw-background draw
draw-stock
draw-waste
draw-foundation
draw-tableau
;on-mouse .Mouse/vect DEO2 ;on-mouse .Mouse/vect DEO2
;on-key .Controller/vect DEO2 ;on-key .Controller/vect DEO2
BRK BRK
( @not-holding-cards ( -> bool^ ) .held LDZ #00 EQU JMP2r ) @draw ( -> )
( @holding-cards ( -> bool^ ) .held LDZ #00 NEQ JMP2r ) draw-background draw-stock draw-waste draw-foundation !draw-tableau
@initialize ( start^ count^ -> ) @initialize ( start^ count^ -> )
OVR ADD SWP STH2 #00 ( 0^ [lim=start+count^ start^] ) OVR ADD SWP STH2 #00 ( 0^ [lim=start+count^ start^] )
@ -160,7 +156,6 @@
#00 SWP #0018 MUL2 #0030 ADD2 JMP2r #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 ) )
DUP column-x ,&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^ )
@ -231,7 +226,6 @@
.Mouse/state DEI ( state^ ) .Mouse/state DEI ( state^ )
.prev/mouse-state LDZ #ff EOR AND ( down^ ) .prev/mouse-state LDZ #ff EOR AND ( down^ )
#01 AND ?&ok JMP2r &ok #01 AND ?&ok JMP2r &ok
( TODO: when already holding, different behavior )
.dragging LDZ ?release .dragging LDZ ?release
maybe-select-stock ?&found maybe-select-stock ?&found
maybe-select-waste ?&found maybe-select-waste ?&found
@ -244,7 +238,7 @@
&loop DUP LDZk #80 EOR SWP STZ ( last^ first ; first<-c^0x80 ) &loop DUP LDZk #80 EOR SWP STZ ( last^ first ; first<-c^0x80 )
INC LTHk #00 EQU ?&loop ( last^ first+1^ ) INC LTHk #00 EQU ?&loop ( last^ first+1^ )
POP2 .dragging #05 initialize ( ) POP2 .dragging #05 initialize ( )
#0000 .held STZ2 JMP2r ( ) #0000 .held STZ2 !draw ( )
@find-top ( lim^ start^ -> zp^ ) @find-top ( lim^ start^ -> zp^ )
&loop LDZk ?&ok !&done &ok INC GTHk ?&loop &done NIP #01 SUB JMP2r &loop LDZk ?&ok !&done &ok INC GTHk ?&loop &done NIP #01 SUB JMP2r
@ -255,7 +249,7 @@
@bot-column ( i^ -> zp^ ) @bot-column ( i^ -> zp^ )
#13 MUL .tableau ADD JMP2r #13 MUL .tableau ADD JMP2r
@top-column ( i^ -> zp^ ) @top-column ( i^ -> zp^ )
( #13 MUL .tableau ADD ) bot-column #13 OVR ADD SWP !find-top bot-column #13 OVR ADD SWP !find-top
@maybe-select-stock ( -> bool^ ) @maybe-select-stock ( -> bool^ )
.Mouse/x DEI2 #0008 LTH2 ?&no1 ( ; x<8 ) .Mouse/x DEI2 #0008 LTH2 ?&no1 ( ; x<8 )
@ -266,7 +260,7 @@
#00 STHkr .stock SUB #03 SFT2 SUB2 ( min=8-[z-stock]/8* [z^] ) #00 STHkr .stock SUB #03 SFT2 SUB2 ( min=8-[z-stock]/8* [z^] )
.Mouse/y DEI2 GTH2 ?&no2 ( [z^] ) .Mouse/y DEI2 GTH2 ?&no2 ( [z^] )
STHr LDZk #80 EOR SWP STZ ( ; z<-z^0x80 ) STHr LDZk #80 EOR SWP STZ ( ; z<-z^0x80 )
draw-stock #01 JMP2r ( 1^ ) draw #01 JMP2r ( 1^ )
&no2 POPr &no1 #00 JMP2r ( 0^ ) &no2 POPr &no1 #00 JMP2r ( 0^ )
@start-drag ( x* y* first^ last^ -> ) @start-drag ( x* y* first^ last^ -> )
@ -281,17 +275,17 @@
#01 .dragging STZ JMP2r ( ) #01 .dragging STZ JMP2r ( )
@maybe-select-waste ( -> bool^ ) @maybe-select-waste ( -> bool^ )
.Mouse/y DEI2 #0008 LTH2 ?&no1 .Mouse/y DEI2 #0008 LTH2 ?&no1 ( )
.Mouse/y DEI2 #0020 GTH2 ?&no1 .Mouse/y DEI2 #0020 GTH2 ?&no1 ( )
top-waste STHk #00 EQU ?&no2 ( [t^] ) top-waste STHk #00 EQU ?&no2 ( [t^] )
#001c #00 STHkr .waste SUB #0008 MUL2 ADD2 ( w=0x1c+8*index* [t^ w*] ) #001c #00 STHkr .waste SUB #0008 MUL2 ADD2 ( w=0x1c+8*index* [t^ w*] )
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^] ) .Mouse/x DEI2 LTH2 ?&no2 ( [t^] )
LIT2 [ &dx $2 ] #0008 STHr DUP ( dx* dy=8* t^ t^ ) LIT2 [ &dx $2 ] #0008 STHr DUP ( dx* dy=8* t^ t^ )
start-drag draw-waste #01 JMP2r ( 1^ ) start-drag draw #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^ )
.Mouse/y DEI2 #0024 LTH2 ?&no1 ( ) .Mouse/y DEI2 #0024 LTH2 ?&no1 ( )
@ -309,24 +303,25 @@
POP2 NIPr STHr !maybe-select-column ( bool^ ) POP2 NIPr STHr !maybe-select-column ( bool^ )
@maybe-select-column ( i^ -> bool^ ) @maybe-select-column ( i^ -> bool^ )
.Mouse/y DEI2 #0024 LTH2 ?&no ( i^ ) .Mouse/y DEI2 #0024 LTH2 ?&no ( i^ )
DUP top-column OVR bot-column LIT2r 0001 ( i^ top^ bot^ [1*] ) DUP top-column OVR bot-column ( i^ top^ bot^ )
&loop ( i^ top^ row^ [n*] ) LIT2r 0001 ( i^ top^ bot^ [1*] )
GTHk ?&next !&done ( i^ top^ row^ [n*] ) &loop ( i^ top^ row^ [n*] )
&next ( i^ top^ row^ [n*] ) GTHk ?&next !&done ( i^ top^ row^ [n*] )
.Mouse/y DEI2 ( i^ top^ row^ y* [n*] ) &next ( i^ top^ row^ [n*] )
STH2kr #0008 MUL2 #0024 ADD2 ( i^ top^ row^ y* lim=36+8n* [n*] ) .Mouse/y DEI2 ( i^ top^ row^ y* [n*] )
LTH2 ?&match INC INC2r !&loop ( i^ top^ row+1^ [n+1*] ) STH2kr #0008 MUL2 #0024 ADD2 ( i^ top^ row^ y* lim=36+8n* [n*] )
&done ( i^ top^ row^ [n*] ) LTH2 ?&match INC INC2r !&loop ( i^ top^ row+1^ [n+1*] )
.Mouse/y DEI2 ( i^ top^ row^ y* [n*] ) &done ( i^ top^ row^ [n*] )
STH2kr #0008 MUL2 #0034 ADD2 ( i^ top^ row^ y* lim=52+8n* [n*] ) .Mouse/y DEI2 ( i^ top^ row^ y* [n*] )
LTH2 ?&match ( i^ top^ row^ [n*] ) STH2kr #0008 MUL2 #0034 ADD2 ( i^ top^ row^ y* lim=52+8n* [n*] )
POP2r POP2 &no POP #00 JMP2r ( 0^ ) LTH2 ?&match ( i^ top^ row^ [n*] )
&match ( i^ top^ row^ [n*] ) POP2r POP2 &no POP #00 JMP2r ( 0^ )
STH2 SWP2r column-x ( x* [top^ row^ n*] ) &match ( i^ top^ row^ [n*] )
STH2r #0008 MUL2 #001c ADD2 ( x* y=28+8n* [top^ row^] ) STH2 SWP2r column-x ( x* [top^ row^ n*] )
STH2r SWP ( x* y* row^ top^ ) STH2r #0008 MUL2 #001c ADD2 ( x* y=28+8n* [top^ row^] )
start-drag draw-tableau #01 JMP2r ( 1^ ) STH2r SWP ( x* y* row^ top^ )
start-drag draw #01 JMP2r ( 1^ )
( @on-click-up ( -> ) ( @on-click-up ( -> )