From 80c2b9316570b65b6317f4423ba1349dea2357da Mon Sep 17 00:00:00 2001 From: 4am Date: Mon, 19 Apr 2021 20:53:33 -0400 Subject: [PATCH] restore and refactor ResetVector, fix SwapProDOS confusion on exit --- src/passport.a | 54 ++++++++++++++++++++++++++++++++------------------ src/wrapper.a | 10 ++++++++-- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/passport.a b/src/passport.a index 2abcaea..120fc62 100755 --- a/src/passport.a +++ b/src/passport.a @@ -65,7 +65,7 @@ UNIV_D3 = $B8FC !source "apidefs.a" FirstMover - jmp MainMenu + jmp ResetVector !source "strings/en.a" !source "analyze.a" @@ -115,16 +115,11 @@ FirstMover !source "prefs.a" !source "keys.a" !source "cffa.a" + !source "progress.a" !source "rwts.a" !source "standarddelivery.a" -MainMenu - lda #MainMenu - sta $03F3 - eor #$A5 - sta $03F4 +ResetVector ldx #$FF txs lda $C0E8 @@ -135,8 +130,10 @@ MainMenu sta $C004 sta $C00C sta $C00E - jsr CleanupFiles jsr ThisSlot + jsr CleanupFiles ; RAM/HD files might be left open after Ctrl-Reset + ; /!\ execution falls through here +MainMenu jsr ClearScreen lda #s_header jsr PrintByID @@ -581,6 +578,24 @@ TheEnd beq HandleRedoWithIgnore jmp MainMenu +;------------------------------- +; CleanupFiles +; +; Cleans up open files (if any) +; +; in: ProDOS is NOT in memory +; out: all registers and flags clobbered +;------------------------------- +CleanupFiles + lda gHardDiskRef + ora gRAMDiskRef + beq + + jsr SwapProDOS ; ProDOS out -> in + jsr DeleteFileOnRAMDisk + jsr CloseFileOnHardDisk + jsr SwapProDOS ; ProDOS out -> in ++ rts + HandleRedoWithIgnore jsr InitSectorMapWithIgnore jmp Reaction @@ -609,25 +624,26 @@ RestartScan txs jmp ReadWithRWTS +;------------------------------- +; CleanExit +; +; Cleans up open files, saves preferences (if modified), +; and quits via ProDOS MLI +; +; in: ProDOS is NOT in memory +; out: does not return +;------------------------------- CleanExit + jsr CleanupFiles jsr SwapProDOS ; ProDOS out -> in lda gChangedPrefs bne + jsr SavePrefs -+ jsr CleanupFiles - jsr MLI ; does not return ++ jsr MLI ; does not return !byte $65 !word + + !byte $04 - !source "progress.a" - -CleanupFiles - jsr SwapProDOS ; ProDOS out -> in - jsr DeleteFileOnRAMDisk ; always safe to call - jsr CloseFileOnHardDisk ; always safe to call - jmp SwapProDOS ; ProDOS in -> out - ;------------------------------- ; WriteTrack ;------------------------------- diff --git a/src/wrapper.a b/src/wrapper.a index 7797caf..a9a5c0d 100644 --- a/src/wrapper.a +++ b/src/wrapper.a @@ -18,7 +18,7 @@ OneTimeSetup jsr $FB2F ; TEXT jsr $FC58 ; HOME jsr decrunch ; decompress main Passport code - sty $fe ;;zp_dest_lo = low byte of Passport entry point + sty $FE ;;zp_dest_lo = low byte of Passport entry point ldy #0 ; save a copy of ProDOS system global page - lda $BF00, y ; (will be copied back and forth by SwapProDOS later) sta $0F00, y @@ -40,7 +40,13 @@ OneTimeSetup + jsr ScanForRAMAndHardDisks; scan for things that look like RAM disks or hard disks jsr LoadPrefs ; load preferences (if available) - jmp ($fe) ; jump to decompressed code (FirstMover) + lda $FE + sta $03F2 + lda $FF + sta $03F3 + eor #$A5 + sta $03F4 + jmp ($FE) ; jump to decompressed code (FirstMover) !source "apidefs.a" !source "strings/enid.a"