RBH DA: Restore devices and reformat /RAM. Fixes #98

This commit is contained in:
Joshua Bell 2018-12-27 12:55:56 -08:00
parent cb99c2c9c9
commit 231d03b548
3 changed files with 53 additions and 3 deletions

View File

@ -50,8 +50,11 @@ start:
lda #$FE ; "BASIC.SYSTEM not found"
bne fail
;; Restore devices DeskTop may have removed
: jsr restore_device_list
;; Restore to normal state
: sta ALTZPOFF
sta ALTZPOFF
lda ROMIN2
jsr SETVID
jsr SETKBD
@ -66,7 +69,8 @@ start:
sta CLR80VID
sta CLR80COL
;; TODO: restore /RAM?
;; Reformat /RAM if it was restored
jsr maybe_reformat_ram
;; Set PREFIX
MLI_CALL SET_PREFIX, set_prefix_params
@ -221,3 +225,44 @@ fail: return #1
.endproc
;;; ============================================================
.proc restore_device_list
ldx devlst_backup
inx
: copy devlst_backup,x, DEVLST-1,x
dex
bpl :-
rts
.endproc
;;; ============================================================
.proc maybe_reformat_ram
ram_unit_number = (1<<7 | 3<<4 | DT_RAM)
;; Search DEVLST to see if S3D2 RAM was restored
ldx DEVCNT
: lda DEVLST,x
cmp #ram_unit_number
beq format
dex
bpl :-
rts
;; NOTE: Assumes driver (in DEVADR) was not modified
;; when detached.
;; /RAM FORMAT call; see ProDOS 8 TRM 5.2.2.4 for details
format: copy #DRIVER_COMMAND_FORMAT, DRIVER_COMMAND
copy #ram_unit_number, DRIVER_UNIT_NUMBER
copy16 #$2000, DRIVER_BUFFER
lda LCBANK1
lda LCBANK1
jsr driver
sta ROMIN2
rts
RAMSLOT := DEVADR + $16 ; Slot 3, Drive 2
driver: jmp (RAMSLOT)
.endproc

View File

@ -171,6 +171,10 @@ path_table := $DFB3 ; window address table
selected_file_list := $DF22 ; indexes of selected file (global, not w/in window, up to 127)
file_table := $DD9F ; file address table
;;; Copy of DEVLST before DeskTop modifies it. Used when exiting or
;;; invoking to restore devices.
devlst_backup := $E196
last_menu_click_params := $E25A
;;; Icon (file/volume) entries - length 27 bytes, maximum of 127

View File

@ -989,7 +989,8 @@ entries_read_this_block:
;;; ============================================================
;; Backup copy of DEVLST made before detaching ramdisk
devlst_backup:
devlst_backup_:
.assert * = devlst_backup, error, "Entry point mismatch"
.res 10, 0
;; index is device number (in DEVLST), value is icon number