ROMX Clock Driver: Ensure bank is restored if detection fails.

c/o @apple2geek: If your ROMX is in recovery mode, [not doing so]
hangs the system and requires a power cycle to get it back.
This commit is contained in:
Joshua Bell 2022-06-24 12:42:07 -07:00
parent 188f1b4ce8
commit 3b8fe3c461
1 changed files with 16 additions and 26 deletions

View File

@ -46,6 +46,12 @@ SEL_MBANK := $F851 ; Select Main bank reg
;;; ============================================================ ;;; ============================================================
;;; Ensure there is not a previous clock driver installed. ;;; Ensure there is not a previous clock driver installed.
.ifdef FAKE_CLOCK
maybe_install_driver := install_driver
.else
.proc maybe_install_driver .proc maybe_install_driver
lda MACHID lda MACHID
and #$01 ; existing clock card? and #$01 ; existing clock card?
@ -57,14 +63,6 @@ SEL_MBANK := $F851 ; Select Main bank reg
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
.proc detect_romx .proc detect_romx
;; Preserve date/time
ldy #3 ; copy 4 bytes
: lda DATELO,y
sta saved,y
dey
bpl :-
.ifndef FAKE_CLOCK
;; Try to detect ROMX and RTC ;; Try to detect ROMX and RTC
bit ROMIN2 ; enable ROM bit ROMIN2 ; enable ROM
bit ZipSlo ; disable ZIP bit ZipSlo ; disable ZIP
@ -74,26 +72,18 @@ SEL_MBANK := $F851 ; Select Main bank reg
lda SigCk ; Check for ROMX signature bytes lda SigCk ; Check for ROMX signature bytes
cmp #$4A cmp #$4A
bne not_found bne nope
lda SigCk+1 lda SigCk+1
cmp #$CD cmp #$CD
bne not_found bne nope
lda FWReadClock ; is RTC code there? lda FWReadClock ; is RTC code there?
cmp #$AD cmp #$AD
php bne nope
bit SEL_MBANK ; restore original bank clc ; found clock!
plp bcc :+
bne not_found nope: sec ; not found
.endif : bit SEL_MBANK ; restore original bank (unconditionally)
jmp install_driver ; found clock! bcc install_driver ; found clock!
not_found:
;; Restore date/time
ldy #3
: lda saved,y
sta DATELO,y
dey
bpl :-
;; Show failure message ;; Show failure message
jsr log_message jsr log_message
@ -101,10 +91,10 @@ not_found:
.byte 0 .byte 0
rts rts
saved: .byte 0, 0, 0, 0
.endproc .endproc
.endif
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;;; Install ROMX RTC Driver. Copy into address at DATETIME vector, ;;; Install ROMX RTC Driver. Copy into address at DATETIME vector,
;;; update the vector and update MACHID bits to signal a clock ;;; update the vector and update MACHID bits to signal a clock