refactor HardResetWeeGUI and use everywhere

This commit is contained in:
4am 2018-04-17 15:43:00 -04:00
parent 2b9c727e54
commit d9d4a8b699
6 changed files with 35 additions and 26 deletions

View File

@ -36,16 +36,13 @@ kOnBeyondChecksum = $0306
; all flags clobbered
;------------------------------------------------------------------------------
ClearInterpreterOptions
ldy #6
ldy #(kOnBeyondChecksum-kOnBeyondOptionsStruct)
lda #0
- sta kOnBeyondOptionsStruct,y
dey
bpl -
rts
LaunchInterpreterWithNewGame
lda #$FF
; execution falls through here
;------------------------------------------------------------------------------
; LaunchInterpreterWithGame
; load interpreter and launch it with a game based on global preferences store,
@ -57,6 +54,9 @@ LaunchInterpreterWithNewGame
; otherwise does not return (calls ExitWeeGUI and jumps to interpreter)
; gPathname clobbered
;------------------------------------------------------------------------------
LaunchInterpreterWithNewGame
lda #$FF
; execution falls through here
LaunchInterpreterWithGame
sta kOnBeyondAutoRestore
jsr SaveGlobalPreferences

View File

@ -4,6 +4,7 @@
; User interface - common views and paint routines across screens
;
; Public functions
; - HardResetWeeGUI
; - CreateRadio
; - CreateCheckbox
; - CreateButton
@ -25,6 +26,30 @@ kStringCancel
!byte $03 ; 'C' inverse
!text "ancel",0
;------------------------------------------------------------------------------
; HardResetWeeGUI
; super-resets all WeeGUI views by creating 16 dummy views (which clears their
; internal state and callbacks and so on) then calling WeeGUI WGResetAll method
;
; in: WeeGUI initialized
; out: $00/$01 clobbered
; all registers clobbered
;------------------------------------------------------------------------------
HardResetWeeGUI
lda #15 ; highest possible WeeGUI view ID
sta kHardResetDummyView
.hardResetLoop
+LDAY kHardResetDummyView
+STAY PARAM0
ldx #WGCreateView
jsr WeeGUI ; create dummy views to reset state on all views
dec kHardResetDummyView
bpl .hardResetLoop
ldx #WGResetAll ; reset WeeGUI (destroys everything we just created)
jmp WeeGUI
kHardResetDummyView
!byte 0,0,0,0,0,0,0,0
;------------------------------------------------------------------------------
; CreateRadio/CreateCheckbox/CreateButton
; creates a WeeGUI UI control with the 'raw title' option set

View File

@ -40,8 +40,7 @@ gViewInUse
;------------------------------------------------------------------------------
!zone {
PaintMain
ldx #WGResetAll
jsr WeeGUI
jsr HardResetWeeGUI
stz gViewInUse+ID_BOXART
stz gViewInUse+ID_HINTS
stz gViewInUse+ID_VERSIONS

View File

@ -45,8 +45,7 @@ ID_OPTIONS_CANCEL = 7
OptionsDialog
ldx #$FF
txs
ldx #WGResetAll ; reset WeeGUI, destroy all views
jsr WeeGUI
jsr HardResetWeeGUI
jsr CreateDialog ; create frame and OK/Cancel buttons
!word kViewOptionsFrame

View File

@ -63,21 +63,11 @@ ID_RESUME_NEXT = $82
ResumeDialog
ldx #$FF
txs
lda #15
sta kDummyView
.hardReset
+LDAY kDummyView
+STAY PARAM0
ldx #WGCreateView
jsr WeeGUI ; create dummy views to reset state on all views
dec kDummyView
bpl .hardReset
ldx #WGResetAll ; reset WeeGUI (destroys everything we just created)
jsr WeeGUI
jsr HardResetWeeGUI
jsr LoadSavedGameInfo
jsr LoadSavedGameInfo ; call ZINFO to get the information we need for this dialog
lda gSavedGamesSlotsInUse
lda gSavedGamesSlotsInUse ; populated by LoadSavedGameInfo
asl
clc
adc #3
@ -277,7 +267,4 @@ kViewResumeNewGameTop
kStringNewGame
!text " Start ",110,"ew game",0
kDummyView
!byte 0,0,0,0,0,0,0,0
}

View File

@ -63,8 +63,7 @@ ID_VERSIONS_NEXT = $82
VersionsDialog
ldx #$FF
txs
ldx #WGResetAll ; reset WeeGUI
jsr WeeGUI
jsr HardResetWeeGUI
ldx #9
- stz gVersionsViewInUse,x ; reset flags for which radio buttons are in use (1-9)