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
#15 LDZ #bf AND .waste #02 ADD STZ #0015 STZ
draw-background
draw-stock
draw-waste
draw-foundation
draw-tableau
draw
;on-mouse .Mouse/vect DEO2
;on-key .Controller/vect DEO2
BRK
( @not-holding-cards ( -> bool^ ) .held LDZ #00 EQU JMP2r )
( @holding-cards ( -> bool^ ) .held LDZ #00 NEQ JMP2r )
@draw ( -> )
draw-background draw-stock draw-waste draw-foundation !draw-tableau
@initialize ( start^ count^ -> )
OVR ADD SWP STH2 #00 ( 0^ [lim=start+count^ start^] )
@ -160,7 +156,6 @@
#00 SWP #0018 MUL2 #0030 ADD2 JMP2r
@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 )
#0024 ,&y STR2 ( idx^ ; y<-32 )
#13 MUL .tableau ADD ( pos=t+idx*19^ )
@ -231,7 +226,6 @@
.Mouse/state DEI ( state^ )
.prev/mouse-state LDZ #ff EOR AND ( down^ )
#01 AND ?&ok JMP2r &ok
( TODO: when already holding, different behavior )
.dragging LDZ ?release
maybe-select-stock ?&found
maybe-select-waste ?&found
@ -244,7 +238,7 @@
&loop DUP LDZk #80 EOR SWP STZ ( last^ first ; first<-c^0x80 )
INC LTHk #00 EQU ?&loop ( last^ first+1^ )
POP2 .dragging #05 initialize ( )
#0000 .held STZ2 JMP2r ( )
#0000 .held STZ2 !draw ( )
@find-top ( lim^ start^ -> zp^ )
&loop LDZk ?&ok !&done &ok INC GTHk ?&loop &done NIP #01 SUB JMP2r
@ -255,7 +249,7 @@
@bot-column ( i^ -> zp^ )
#13 MUL .tableau ADD JMP2r
@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^ )
.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^] )
.Mouse/y DEI2 GTH2 ?&no2 ( [z^] )
STHr LDZk #80 EOR SWP STZ ( ; z<-z^0x80 )
draw-stock #01 JMP2r ( 1^ )
draw #01 JMP2r ( 1^ )
&no2 POPr &no1 #00 JMP2r ( 0^ )
@start-drag ( x* y* first^ last^ -> )
@ -281,8 +275,8 @@
#01 .dragging STZ JMP2r ( )
@maybe-select-waste ( -> bool^ )
.Mouse/y DEI2 #0008 LTH2 ?&no1
.Mouse/y DEI2 #0020 GTH2 ?&no1
.Mouse/y DEI2 #0008 LTH2 ?&no1 ( )
.Mouse/y DEI2 #0020 GTH2 ?&no1 ( )
top-waste STHk #00 EQU ?&no2 ( [t^] )
#001c #00 STHkr .waste SUB #0008 MUL2 ADD2 ( w=0x1c+8*index* [t^ w*] )
DUP2 ,&dx STR2 ( w* [t^ w*] ; dx<-w )
@ -290,7 +284,7 @@
#002c #00 STHkr .waste SUB #0008 MUL2 ADD2 ( 0x2c+8*index* [t^ w*] )
.Mouse/x DEI2 LTH2 ?&no2 ( [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^ )
@maybe-select-tableau ( -> bool^ )
@ -310,7 +304,8 @@
@maybe-select-column ( i^ -> bool^ )
.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^ )
LIT2r 0001 ( i^ top^ bot^ [1*] )
&loop ( i^ top^ row^ [n*] )
GTHk ?&next !&done ( i^ top^ row^ [n*] )
&next ( i^ top^ row^ [n*] )
@ -326,7 +321,7 @@
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^ )
start-drag draw #01 JMP2r ( 1^ )
( @on-click-up ( -> )