From fc73f51afe8055b23053fa3acce54cc4cda66d3e Mon Sep 17 00:00:00 2001 From: 4am Date: Tue, 17 Apr 2018 13:56:50 -0400 Subject: [PATCH] set On Beyond restore slot properly based on resume dialog --- src/glue.onbeyond.a | 127 ++++++++++++++++++++++++-------------------- src/ui.main.keys.a | 2 +- src/ui.resume.a | 28 ++++++++-- 3 files changed, 95 insertions(+), 62 deletions(-) diff --git a/src/glue.onbeyond.a b/src/glue.onbeyond.a index 342de24..56f06c2 100644 --- a/src/glue.onbeyond.a +++ b/src/glue.onbeyond.a @@ -5,8 +5,6 @@ ; ; Public functions ; - ClearInterpreterOptions -; - SetInterpreterOptions -; - SetInterpreterOptionsExceptForce40 ; - LaunchInterpreterWithGame ; - LaunchInterpreterWithHints ; @@ -45,6 +43,74 @@ ClearInterpreterOptions bpl - rts +;------------------------------------------------------------------------------ +; LaunchInterpreterWithNewGame +; load interpreter and launch it with a game based on global preferences store +; +; in: current ProDOS prefix is the same as the PITCH.DARK file +; out: returns with C set if interpreter could not be loaded or game +; directory could not be found +; otherwise does not return (calls ExitWeeGUI and jumps to interpreter) +; gPathname clobbered +;------------------------------------------------------------------------------ +LaunchInterpreterWithNewGame + lda #$FF + ; execution falls through here +;------------------------------------------------------------------------------ +; LaunchInterpreterWithSavedGame +; load interpreter and launch it with a game based on global preferences store, +; and tell it to restore from a specific saved game slot +; in: A = saved game slot, or #$FF for none +LaunchInterpreterWithSavedGame + sta iRestoreSlot + jsr SaveGlobalPreferences + jsr LoadInterpreter + bcs .launchError + jsr SetStartupPathToCurrentVersionOfCurrentGame + jsr ExitWeeGUI ; shut down WeeGUI + jsr SetInterpreterOptions ; set options struct at $300 + jmp kSystemAddress ; exit via interpreter +.launchError + jmp SoftBell + +;------------------------------------------------------------------------------ +; LaunchInterpreterWithHints +; load interpreter and launch it with the hints file for the current game +; +; in: current ProDOS prefix is the same as the PITCH.DARK file +; out: returns with C set if interpreter could not be loaded or hints +; directory could not be found +; otherwise does not return (calls ExitWeeGUI and jumps to interpreter) +; gPathname clobbered +;------------------------------------------------------------------------------ +LaunchInterpreterWithHints + lda #$FF + sta iRestoreSlot ; no saved game to restore + jsr SaveGlobalPreferences + jsr LoadInterpreter + bcs .launchError + + jsr ResetPath + + +LDADDR kHintsRootDirectory + jsr AddToPath + + jsr SetPrefix + !word gPathname + bcs .launchError + + jsr okvs_get + !word gGlobalPrefsStore + !word kLastPlayed + jsr SetStartupPath ; store hints filename at $2006 + + jsr ExitWeeGUI + jsr SetInterpreterOptionsExceptForce40 + jmp kSystemAddress + +;------------------------------------------------------------------------------ +; internal functions + ;------------------------------------------------------------------------------ ; SetInterpreterOptions ; set options struct based on global preferences store @@ -84,7 +150,8 @@ SetInterpreterOptionsExceptForce40 + lda #1 sta kOnBeyondCase - lda #$FF ; TODO this will eventually be set based on 'Resume Game' screen +iRestoreSlot=*+1 + lda #$FD ; SMC sta kOnBeyondAutoRestore jsr okvs_get @@ -120,60 +187,6 @@ SetInterpreterOptionsExceptForce40 sta kOnBeyondChecksum rts -;------------------------------------------------------------------------------ -; LaunchInterpreterWithGame -; load interpreter and launch it with a game based on global preferences store -; -; in: current ProDOS prefix is the same as the PITCH.DARK file -; out: returns with C set if interpreter could not be loaded or game -; directory could not be found -; otherwise does not return (calls ExitWeeGUI and jumps to interpreter) -; gPathname clobbered -;------------------------------------------------------------------------------ -LaunchInterpreterWithGame - jsr SaveGlobalPreferences - jsr LoadInterpreter - bcs .launchError - jsr SetStartupPathToCurrentVersionOfCurrentGame - jsr ExitWeeGUI ; shut down WeeGUI - jsr SetInterpreterOptions ; set options struct at $300 - jmp kSystemAddress ; exit via interpreter -.launchError - jmp SoftBell - -;------------------------------------------------------------------------------ -; LaunchInterpreterWithHints -; load interpreter and launch it with the hints file for the current game -; -; in: current ProDOS prefix is the same as the PITCH.DARK file -; out: returns with C set if interpreter could not be loaded or hints -; directory could not be found -; otherwise does not return (calls ExitWeeGUI and jumps to interpreter) -; gPathname clobbered -;------------------------------------------------------------------------------ -LaunchInterpreterWithHints - jsr SaveGlobalPreferences - jsr LoadInterpreter - bcs .launchError - - jsr ResetPath - - +LDADDR kHintsRootDirectory - jsr AddToPath - - jsr SetPrefix - !word gPathname - bcs .launchError - - jsr okvs_get - !word gGlobalPrefsStore - !word kLastPlayed - jsr SetStartupPath ; store hints filename at $2006 - - jsr ExitWeeGUI - jsr SetInterpreterOptionsExceptForce40 - jmp kSystemAddress - ;------------------------------------------------------------------------------ ; LoadInterpreter ; load interpreter and launch it with the hints file for the current game diff --git a/src/ui.main.keys.a b/src/ui.main.keys.a index 83cdb0c..7a4c353 100644 --- a/src/ui.main.keys.a +++ b/src/ui.main.keys.a @@ -209,7 +209,7 @@ callback_next } callback_options = OptionsDialog -callback_play = LaunchInterpreterWithGame +callback_play = LaunchInterpreterWithNewGame callback_resume = ResumeDialog callback_boxart = DisplayArtwork callback_hints = LaunchInterpreterWithHints diff --git a/src/ui.resume.a b/src/ui.resume.a index e0513c2..434e46f 100644 --- a/src/ui.resume.a +++ b/src/ui.resume.a @@ -58,13 +58,21 @@ ID_RESUME_NEXT = $82 ; call WeeGUI to create and paint 'resume game' screen, and run to completion ; ; in: WeeGUI initialized -; out: exits via MainScreen or LaunchInterpreterWithGame -; all registers and flags clobbered +; out: exits via MainScreen, LaunchInterpreterWithSavedGame, or LaunchInterpreterWithNewGame ;------------------------------------------------------------------------------ ResumeDialog ldx #$FF txs - ldx #WGResetAll ; reset WeeGUI + 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 LoadSavedGameInfo @@ -211,7 +219,16 @@ HandleResumeKey jsr WeeGUI jmp SimulateClick -callback_resume_ok = LaunchInterpreterWithGame +callback_resume_ok + lda #ID_RESUME_SLOT0 + ldy #ID_RESUME_NEWGAME+1 + jsr GetCheckedRadioButton ; returns A = WeeGUI view ID + cmp #ID_RESUME_NEWGAME + bne + + lda #0 ++ dec ; A = saved game slot (which is WeeGUI view ID - 1) or #$FF + jmp LaunchInterpreterWithSavedGame + callback_resume_cancel = MainScreen kViewResumeFrame @@ -260,4 +277,7 @@ kViewResumeNewGameTop kStringNewGame !text " Start ",110,"ew game",0 + +kDummyView + !byte 0,0,0,0,0,0,0,0 }