4cade/src/hw.vidhd.a

73 lines
2.0 KiB
Plaintext
Raw Normal View History

;license:MIT
;(c) 2018-9 by 4am
;
; VidHD support functions
;
2019-01-13 23:55:40 +00:00
;------------------------------------------------------------------------------
; HasVidHDCard
; detect VidHD card by searching for magic bytes across all slots
;
; in: none
; out: C set if VidHD card found in any slot
; if card was found, X = #$Cn where n is the slot number of the card
; C clear if no VidHD card found
; other flags clobbered
; A/Y clobbered
;------------------------------------------------------------------------------
HasVidHDCard
2019-10-05 20:40:29 +00:00
ldx #$C7
2019-01-13 23:55:40 +00:00
@slotLoop
stx @byteLoop+2
ldy #$02
@byteLoop
lda $FD00, y ; SMC (high byte)
cmp @kVidHDMagicBytes, y
bne @nextSlot
dey
bpl @byteLoop
2019-10-05 20:40:29 +00:00
@found
2019-01-13 23:55:40 +00:00
sec ; found
rts
@nextSlot
dex
2019-10-05 20:40:29 +00:00
cpx #$C0
2019-01-13 23:55:40 +00:00
bne @slotLoop
2019-10-05 20:40:29 +00:00
; check for a slot where the Cx00 page is all zeroes
; and the devsel bytes are also all zeroes, which
; indicates that VidHD is probably present but is in
; passive mode because some other card is hogging DMA
ldx #$C7
@passiveSlotLoop
stx @passiveByteLoop+2
ldy #0
@passiveByteLoop
lda $FD00, y ; SMC (high byte)
bne @passiveNextSlot
2019-10-11 00:03:03 +00:00
dey
bne @passiveByteLoop
2019-10-05 20:40:29 +00:00
txa
and #$0F ; A = $01..$07
asl
asl
asl
asl ; A = $10..$70
ora #$80 ; A = $90..$F0
sta @devselLoop+1
ldy #$0F
@devselLoop
lda $C0FD, y ; SMC (low byte)
bne @passiveNextSlot
dey
bpl @devselLoop
bmi @found ; always branches
@passiveNextSlot
dex
cpx #$C0
bne @passiveSlotLoop
2019-01-13 23:55:40 +00:00
clc ; not found
rts
@kVidHDMagicBytes
2019-06-27 14:55:07 +00:00
!byte $24, $EA, $4C