restore and refactor ResetVector, fix SwapProDOS confusion on exit

This commit is contained in:
4am 2021-04-19 20:53:33 -04:00
parent 3e9dd24ed9
commit 80c2b93165
2 changed files with 43 additions and 21 deletions

View File

@ -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 $03F2
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
;-------------------------------

View File

@ -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"