From 0078eb6b9690c6b487f919eb8b40e81bbdd1c8d7 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Sun, 13 Jan 2019 14:36:34 -0800 Subject: [PATCH] Fix IIc+ detection. Fixes #25 --- desktop/desktop_main.s | 55 ++++++++++++++++++++++++++++-------------- inc/apple2.inc | 1 + 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/desktop/desktop_main.s b/desktop/desktop_main.s index fb89ea9..39a5a23 100644 --- a/desktop/desktop_main.s +++ b/desktop/desktop_main.s @@ -14912,43 +14912,58 @@ start: ;;; ============================================================ ;;; Detect Machine Type +;;; NOTE: Starts with ROM paged in, exits with LCBANK1 paged in. + .scope machine_type ;; See Apple II Miscellaneous #7: Apple II Family Identification + + ;; First, detect IIgs copy #0, iigs_flag - lda ID_BYTE_FBC0 ; 0 = IIc or IIc+ - beq :+ sec ; Follow detection protocol jsr ID_BYTE_FE1F ; RTS on pre-IIgs bcs :+ ; carry clear = IIgs copy #$80, iigs_flag +: + ;; Now stash the bytes we need + copy ID_BYTE_FBB3, id_FBB3 ; $06 = IIe or later + copy ID_BYTE_FBC0, id_FBC0 ; $00 = IIc or later + copy ID_BYTE_FBBF, id_FBBF ; IIc ROM version (IIc+ = $05) -: ldx ID_BYTE_FBB3 - ldy ID_BYTE_FBC0 - cpx #$06 ; Ensure a IIe or later - beq :+ - brk ; Otherwise (][, ][+, ///), just crash - + ;; ... and page in LCBANK1 : sta ALTZPON lda LCBANK1 lda LCBANK1 sta SET80COL - stx startdesktop_params::machine - sty startdesktop_params::subid + ;; Ensure we're on a IIe or later + lda id_FBB3 + cmp #$06 ; Ensure a IIe or later + beq :+ + brk ; Otherwise (][, ][+, ///), just crash - cpy #0 - beq is_iic ; Now identify/store specific machine type. - bit iigs_flag ; (number is used in double-click timer) - bpl is_iie + ;; State needed by MGTK +: copy id_FBB3, startdesktop_params::machine + copy id_FBC0, startdesktop_params::subid + + ;; Identify machine type (double-click timer, other flags) + copy #0, is_iic_plus_flag + + lda id_FBC0 + beq is_iic ; $FBC0 = $00 -> is IIc or IIc+ + bit iigs_flag + bmi is_iigs + + copy #$96, machine_type ; IIe + jmp end + +is_iigs: copy #$FD, machine_type ; IIgs jmp end -is_iie: copy #$96, machine_type ; IIe - jmp end is_iic: copy #$FA, machine_type ; IIc - lda $FBBF ; for IIc, ROM version - cmp #$05 ; IIc Plus? + lda id_FBBF ; ROM version + cmp #$05 ; IIc Plus = $05 bne :+ copy #$80, is_iic_plus_flag : jmp end @@ -14956,6 +14971,10 @@ is_iic: copy #$FA, machine_type ; IIc iigs_flag: ; High bit set if IIgs detected. .byte 0 +id_FBB3: .byte 0 +id_FBC0: .byte 0 +id_FBBF: .byte 0 + end: .endscope ;;; ============================================================ diff --git a/inc/apple2.inc b/inc/apple2.inc index c4cc94e..702228b 100644 --- a/inc/apple2.inc +++ b/inc/apple2.inc @@ -63,6 +63,7 @@ IRQ_VECTOR := $3FE ID_BYTE_FBB3 := $FBB3 ; $06 = IIe or later ID_BYTE_FBC0 := $FBC0 ; $EA = IIe, $E0 = IIe enh/IIgs, $00 = IIc/IIc+ +ID_BYTE_FBBF := $FBBF ; IIc ROM version ($05 = IIc+) ID_BYTE_FE1F := $FE1F ; RTS ($60) on pre-IIgs, clears carry on IIgs