From d9d4a8b699c751f06cf860e55e2f7e2cac9e447c Mon Sep 17 00:00:00 2001 From: 4am Date: Tue, 17 Apr 2018 15:43:00 -0400 Subject: [PATCH] refactor HardResetWeeGUI and use everywhere --- src/glue.onbeyond.a | 8 ++++---- src/ui.common.a | 25 +++++++++++++++++++++++++ src/ui.main.a | 3 +-- src/ui.options.a | 3 +-- src/ui.resume.a | 19 +++---------------- src/ui.versions.a | 3 +-- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/glue.onbeyond.a b/src/glue.onbeyond.a index 08bf3b5..046b088 100644 --- a/src/glue.onbeyond.a +++ b/src/glue.onbeyond.a @@ -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 diff --git a/src/ui.common.a b/src/ui.common.a index 3de6a0c..b91fe1a 100644 --- a/src/ui.common.a +++ b/src/ui.common.a @@ -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 diff --git a/src/ui.main.a b/src/ui.main.a index b2fab17..1faa22a 100644 --- a/src/ui.main.a +++ b/src/ui.main.a @@ -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 diff --git a/src/ui.options.a b/src/ui.options.a index eb0aab0..524ff1f 100644 --- a/src/ui.options.a +++ b/src/ui.options.a @@ -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 diff --git a/src/ui.resume.a b/src/ui.resume.a index d161dd4..2faa65c 100644 --- a/src/ui.resume.a +++ b/src/ui.resume.a @@ -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 } diff --git a/src/ui.versions.a b/src/ui.versions.a index 6301c5a..1960c05 100644 --- a/src/ui.versions.a +++ b/src/ui.versions.a @@ -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)