Make /RAM restoration consistent. Fixes #96

This commit is contained in:
Joshua Bell 2018-12-27 12:42:48 -08:00
parent cb5cc42c6e
commit cb99c2c9c9

View File

@ -684,8 +684,6 @@ append: lda DEVLST,y ; add it to the list
inx inx
sta removable_device_table,x sta removable_device_table,x
bne next ; always bne next ; always
rts ; remove ???
.endproc .endproc
;;; ============================================================ ;;; ============================================================
@ -2148,15 +2146,13 @@ start:
MLI_RELAY_CALL READ, read_params MLI_RELAY_CALL READ, read_params
MLI_RELAY_CALL CLOSE, close_params MLI_RELAY_CALL CLOSE, close_params
jsr restore_device_list
;; Restore machine to text state ;; Restore machine to text state
sta ALTZPOFF sta ALTZPOFF
jsr exit_dhr_mode jsr exit_dhr_mode
;; S3D2 /RAM driver still in place? jsr maybe_reformat_ram
RAMSLOT := DEVADR + $10 + 3*2 ; Slot 3, Drive 2
cmp16 RAMSLOT, NODEV
beq quit ; No, so give up
jsr reinstall_ram
quit: jmp quit_code_addr quit: jmp quit_code_addr
@ -3474,6 +3470,7 @@ check_drive_flags:
.proc reset_and_invoke .proc reset_and_invoke
sta ALTZPOFF sta ALTZPOFF
jsr exit_dhr_mode jsr exit_dhr_mode
jsr maybe_reformat_ram
;; also used by launcher code ;; also used by launcher code
target := *+1 target := *+1
@ -12067,35 +12064,33 @@ do_on_line:
;;; ============================================================ ;;; ============================================================
;;; Reinstall /RAM (Slot 3, Drive 2) ;;; Reformat /RAM (Slot 3, Drive 2) if present
;;; Assumes ROM is banked in, restores it when complete. Also
;;; TODO: Do everything correcly per ProDOS TRM ;;; assumes hires screen (main and aux) are safe to destroy.
;;; http://www.easy68k.com/paulrsm/6502/PDOS8TRM.HTM#5.2.2.4
.proc reinstall_ram
php
sei ; Disable interrupts
.proc maybe_reformat_ram
ram_unit_number = (1<<7 | 3<<4 | DT_RAM) ram_unit_number = (1<<7 | 3<<4 | DT_RAM)
;; Append unit number ;; Search DEVLST to see if S3D2 RAM was restored
inc DEVCNT
ldx DEVCNT ldx DEVCNT
lda #ram_unit_number ; Slot 3, Drive 2 : lda DEVLST,x
sta DEVLST,x cmp #ram_unit_number
beq format
dex
bpl :-
rts
;; NOTE: Assumes driver (in DEVADR) was not modified ;; NOTE: Assumes driver (in DEVADR) was not modified
;; when detached. ;; when detached.
;; /RAM FORMAT call ;; /RAM FORMAT call; see ProDOS 8 TRM 5.2.2.4 for details
copy #DRIVER_COMMAND_FORMAT, DRIVER_COMMAND format: copy #DRIVER_COMMAND_FORMAT, DRIVER_COMMAND
copy #ram_unit_number, DRIVER_UNIT_NUMBER copy #ram_unit_number, DRIVER_UNIT_NUMBER
copy16 #$2000, DRIVER_BUFFER copy16 #$2000, DRIVER_BUFFER
lda LCBANK1 lda LCBANK1
lda LCBANK1 lda LCBANK1
jsr driver jsr driver
sta ROMIN2
plp ; Restore interrupts
rts rts
RAMSLOT := DEVADR + $16 ; Slot 3, Drive 2 RAMSLOT := DEVADR + $16 ; Slot 3, Drive 2