Apple2: Safely check for 80-columns card
Check the Pascal ID bytes for an 80-columns card to avoid blindly jumping into a $C300 that could be totally unrelated.
This commit is contained in:
committed by
Oliver Schmidt
parent
816666615b
commit
e444f4c40e
56
libsrc/apple2/detect80cols.s
Normal file
56
libsrc/apple2/detect80cols.s
Normal file
@@ -0,0 +1,56 @@
|
||||
;
|
||||
; Colin Leroy-Mira, 27/05/2025
|
||||
;
|
||||
; Verify the presence of a 80 columns card in slot 3,
|
||||
; and publish a flag accordingly.
|
||||
;
|
||||
.export aux80col
|
||||
|
||||
.ifndef __APPLE2ENH__
|
||||
.import machinetype
|
||||
.endif
|
||||
|
||||
.constructor detect80cols
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
.data
|
||||
|
||||
aux80col: .byte 0
|
||||
|
||||
.segment "ONCE"
|
||||
|
||||
IdOfsTable: ; Table of bytes positions, used to check four
|
||||
; specific bytes on the slot's firmware to make
|
||||
; sure this is a serial card.
|
||||
.byte $05 ; Pascal 1.0 ID byte
|
||||
.byte $07 ; Pascal 1.0 ID byte
|
||||
.byte $0B ; Pascal 1.1 generic signature byte
|
||||
.byte $0C ; Device signature byte
|
||||
|
||||
IdValTable: ; Table of expected values for the four checked
|
||||
; bytes
|
||||
.byte $38 ; ID Byte 0 (from Pascal 1.0), fixed
|
||||
.byte $18 ; ID Byte 1 (from Pascal 1.0), fixed
|
||||
.byte $01 ; Generic signature for Pascal 1.1, fixed
|
||||
.byte $88 ; Device signature byte (80 columns card)
|
||||
|
||||
IdTableLen = * - IdValTable
|
||||
|
||||
detect80cols:
|
||||
.ifndef __APPLE2ENH__
|
||||
lda machinetype ; Check we're on a //e at least, otherwise we
|
||||
bpl NoDev ; handle no 80cols hardware (like Videx)
|
||||
.endif
|
||||
|
||||
ldx #IdTableLen-1
|
||||
: ldy IdOfsTable,x ; Check Pascal 1.1 Firmware Protocol ID bytes
|
||||
lda IdValTable,x
|
||||
cmp $C300,y
|
||||
bne NoDev
|
||||
dex
|
||||
bpl :-
|
||||
|
||||
dec aux80col ; We have an 80-columns card! Set flag to $FF
|
||||
|
||||
NoDev: rts
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
.export _exec
|
||||
.import mli_file_info_direct
|
||||
.import aux80col
|
||||
.import pushname, popname, popax, done, _exit
|
||||
|
||||
.include "zeropage.inc"
|
||||
@@ -115,7 +116,8 @@ setbuf: lda #$00 ; Low byte
|
||||
sta io_buffer
|
||||
stx io_buffer+1
|
||||
|
||||
.ifdef __APPLE2ENH__
|
||||
bit aux80col
|
||||
bpl :+
|
||||
; Calling the 80 column firmware needs the ROM switched
|
||||
; in, otherwise it copies the F8 ROM to the LC (@ $CEF4)
|
||||
bit $C082
|
||||
@@ -128,9 +130,8 @@ setbuf: lda #$00 ; Low byte
|
||||
|
||||
; Switch in LC bank 2 for R/O
|
||||
bit $C080
|
||||
.endif
|
||||
|
||||
; Reset stack as we already passed
|
||||
: ; Reset stack as we already passed
|
||||
; the point of no return anyway
|
||||
ldx #$FF
|
||||
txs
|
||||
|
||||
@@ -5,14 +5,10 @@
|
||||
;
|
||||
.export _videomode
|
||||
|
||||
.ifndef __APPLE2ENH__
|
||||
.import machinetype
|
||||
.endif
|
||||
|
||||
.import aux80col
|
||||
.import returnFFFF
|
||||
|
||||
.include "apple2.inc"
|
||||
.include "mli.inc"
|
||||
|
||||
|
||||
VIDEOMODE_40x24 = $15
|
||||
@@ -21,19 +17,14 @@ VIDEOMODE_80x24 = $00
|
||||
.segment "LOWCODE"
|
||||
|
||||
_videomode:
|
||||
; Functionally equivalent to previous assumption that
|
||||
; __APPLE2ENH__ == 80 columns hardware present. Will be
|
||||
; correctly checked in the very near future.
|
||||
.ifndef __APPLE2ENH__
|
||||
bit machinetype
|
||||
bvs set_mode
|
||||
bit aux80col
|
||||
bmi set_mode
|
||||
|
||||
; No 80 column card, return error if requested mode is 80cols
|
||||
cmp #VIDEOMODE_40x24
|
||||
beq out
|
||||
jmp returnFFFF
|
||||
set_mode:
|
||||
.endif
|
||||
|
||||
; Get and save current videomode flag
|
||||
bit RD80VID
|
||||
|
||||
Reference in New Issue
Block a user