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
|
.export _exec
|
||||||
.import mli_file_info_direct
|
.import mli_file_info_direct
|
||||||
|
.import aux80col
|
||||||
.import pushname, popname, popax, done, _exit
|
.import pushname, popname, popax, done, _exit
|
||||||
|
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
@@ -115,7 +116,8 @@ setbuf: lda #$00 ; Low byte
|
|||||||
sta io_buffer
|
sta io_buffer
|
||||||
stx io_buffer+1
|
stx io_buffer+1
|
||||||
|
|
||||||
.ifdef __APPLE2ENH__
|
bit aux80col
|
||||||
|
bpl :+
|
||||||
; Calling the 80 column firmware needs the ROM switched
|
; Calling the 80 column firmware needs the ROM switched
|
||||||
; in, otherwise it copies the F8 ROM to the LC (@ $CEF4)
|
; in, otherwise it copies the F8 ROM to the LC (@ $CEF4)
|
||||||
bit $C082
|
bit $C082
|
||||||
@@ -128,9 +130,8 @@ setbuf: lda #$00 ; Low byte
|
|||||||
|
|
||||||
; Switch in LC bank 2 for R/O
|
; Switch in LC bank 2 for R/O
|
||||||
bit $C080
|
bit $C080
|
||||||
.endif
|
|
||||||
|
|
||||||
; Reset stack as we already passed
|
: ; Reset stack as we already passed
|
||||||
; the point of no return anyway
|
; the point of no return anyway
|
||||||
ldx #$FF
|
ldx #$FF
|
||||||
txs
|
txs
|
||||||
|
|||||||
@@ -5,14 +5,10 @@
|
|||||||
;
|
;
|
||||||
.export _videomode
|
.export _videomode
|
||||||
|
|
||||||
.ifndef __APPLE2ENH__
|
.import aux80col
|
||||||
.import machinetype
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.import returnFFFF
|
.import returnFFFF
|
||||||
|
|
||||||
.include "apple2.inc"
|
.include "apple2.inc"
|
||||||
.include "mli.inc"
|
|
||||||
|
|
||||||
|
|
||||||
VIDEOMODE_40x24 = $15
|
VIDEOMODE_40x24 = $15
|
||||||
@@ -21,19 +17,14 @@ VIDEOMODE_80x24 = $00
|
|||||||
.segment "LOWCODE"
|
.segment "LOWCODE"
|
||||||
|
|
||||||
_videomode:
|
_videomode:
|
||||||
; Functionally equivalent to previous assumption that
|
bit aux80col
|
||||||
; __APPLE2ENH__ == 80 columns hardware present. Will be
|
bmi set_mode
|
||||||
; correctly checked in the very near future.
|
|
||||||
.ifndef __APPLE2ENH__
|
|
||||||
bit machinetype
|
|
||||||
bvs set_mode
|
|
||||||
|
|
||||||
; No 80 column card, return error if requested mode is 80cols
|
; No 80 column card, return error if requested mode is 80cols
|
||||||
cmp #VIDEOMODE_40x24
|
cmp #VIDEOMODE_40x24
|
||||||
beq out
|
beq out
|
||||||
jmp returnFFFF
|
jmp returnFFFF
|
||||||
set_mode:
|
set_mode:
|
||||||
.endif
|
|
||||||
|
|
||||||
; Get and save current videomode flag
|
; Get and save current videomode flag
|
||||||
bit RD80VID
|
bit RD80VID
|
||||||
|
|||||||
Reference in New Issue
Block a user