Fix timers and save/restore audio setting.

This fixes a subtle bug that occurs once every 60 seconds
due to rst corruption. It also saves and restores the audio
preferences, which will be nice for people who get tired
of the music.
This commit is contained in:
~d6 2024-11-17 23:32:25 -05:00
parent a32abcdff0
commit bcff5c6eb2
2 changed files with 23 additions and 26 deletions

Binary file not shown.

View File

@ -97,7 +97,7 @@
.DateTime/sec DEI .seconds STZ
#00 .tick STZ
start-audio
.audio LDZ #00 EQU ?{ start-audio }
( display about window when first starting )
#01 .about STZ
@ -122,7 +122,7 @@
;draw-scores/games LDA2 STH2kr STA2 INC2r INC2r
;draw-scores/wins LDA2 STH2kr STA2 INC2r INC2r
;draw-scores/time LDA2 STH2kr STA2 INC2r INC2r
.easy LDZ #01 AND #00 STH2r STA2
.easy LDZ #01 AND .audio LDZ STH2r STA2
;score-file .File1/name DEO2
#000a .File1/len DEO2
@ -147,9 +147,10 @@
LDA2k ;draw-scores/time STA2 INC2 INC2
( next byte contains easy/hard bit )
LDA #01 AND .easy STZ
LDAk #01 AND .easy STZ INC2
( last byte ignored, for now )
( last byte is whether audio should play )
LDA .audio STZ
JMP2r
&invalid
@ -340,7 +341,6 @@
&resume ;resume-button JMP2r
@draw-about ( -> )
.about LDZ #7f GTH ?{ clear-screen !draw-about-content }
fill-box !draw-about-content
@ -401,13 +401,6 @@
#80 .Screen/sprite DEOk DEO
JMP2r
( @draw-face ( x* y* addr* -> )
.Screen/addr DEO2
.Screen/y DEO2
.Screen/x DEO2
#16 .Screen/auto DEO
#80 .Screen/sprite DEOk DEO JMP2r )
@draw-mouth ( x* y* addr* -> )
#0020 ADD2 .Screen/addr DEO2
#0008 ADD2 .Screen/y DEO2
@ -736,7 +729,7 @@
DUP .Audio1/pitch DEO
DUP .Audio2/pitch DEO
DUP .Audio3/pitch DEO
DUP .Audio4/pitch DEO
.Audio4/pitch DEO
JMP2r
@start-audio ( -> )
@ -759,12 +752,18 @@
STH2r INC2 .audio/pos STZ2 JMP2r ( )
@on-audio ( -> brk )
.audio LDZ ?{ BRK } play-audio BRK
.audio LDZ ?&enabled
#0000 #0000
DUP2 DUP2 .Audio1 #01 play-track
DUP2 DUP2 .Audio2 #01 play-track
DUP2 DUP2 .Audio3 #01 play-track
.Audio4 #01 play-track BRK
&enabled play-audio BRK
@update-time ( -> )
.DateTime/sec DEI .seconds LDZ EQU STHk
.tick LDZ AND ?{ STHr #00 EQU .tick STZ JMP2r }
;draw-scores/time LDA2k INC2 SWP2 STA2
POPr ;draw-scores/time LDA2k INC2 SWP2 STA2
#00 .tick STZ !draw
@on-refresh ( -> brk )
@ -889,7 +888,8 @@
DUP2 #009c GTH2 ?&no
POP2 .Mouse/x DEI2
DUP2 #0070 LTH2 ?&no
DUP2 #0090 LTH2 ?close-about
DUP2 #008f GTH2 ?&no
POP2 !close-about
&no POP2 JMP2r
@distance ( a* b* -> max[a,b]-min[a,b]* )
@ -988,10 +988,6 @@
INC LTHk #00 EQU ?&loop POP2 ( )
&done .dragging #05 initialize ( )
#0000 .held STZ2 !draw ( )
.held LDZ2 SWP LITr 00 ( last^ first^ [zero^] )
&loop2 STHkr OVR STZ ( last^ pos^ [zero^] ; pos<-zero )
INC LTHk #00 EQU ?&loop2 ( last^ pos+1^ [zero^] )
POP2 POPr !&done ( )
@find-top ( start^ size^ -> zp^ )
OVR LDZ ?&non-empty POP JMP2r
@ -1057,10 +1053,11 @@
.Mouse/y DEI2 STH2kr LTH2 ?&yes
LIT2r 0008 ADD2r
INC GTHk ?&loop
&no2 POP2r POP2
&no1 #00 JMP2r
&no2 POP2r POP2 ( )
&no1 #00 JMP2r ( 0^ )
&yes #0008 STH2r #0018 SUB2 ( lim^ zp^ x* y* )
ROT2 NIP DUP start-drag draw #01 JMP2r
ROT2 NIP DUP LDZk ?&ok POP2 POP2 POP2 #00 JMP2r
&ok start-drag draw #01 JMP2r
@maybe-select-waste ( -> bool^ )
.waste LDZ #00 EQU ?&no1
@ -1174,8 +1171,8 @@
#04 SFT .auto ADD LDZ INC ( card^ base+1^ )
OVR #0f AND EQU ?&ok ( card^ ; base+1=face? )
POP #00 JMP2r ( 0^ )
&ok ( card^ suit^ )
DUP #30 AND ( card^ )
&ok ( card^ )
DUP #30 AND ( card^ suit^ )
#04 SFT INC INC #03 AND ( card^ par^ )
.auto ADD LDZ #04 ADD ( card^ pface+4^ )
OVR #0f AND GTH ?&ok2 ( card^ )
@ -1234,7 +1231,7 @@
@on-click-up ( -> )
#ff .Mouse/state DEI EOR ( not-state^ )
.prev/mouse-state LDZ AND ( up^ )
#01 AND ?&ok JMP2r &ok
#01 AND ?{ JMP2r }
.dragging LDZ ?release
JMP2r