4cade/src/hw.vbl.init.a

67 lines
1.9 KiB
Plaintext

;license:MIT
;(c) 2020 by qkumba
;
; Identify platform and construct appropriate VBL routine
romid = $FBB3
; $38=][, $EA=][+, $06=//e compatible
ROMID_IIECOMPAT = 6
romid_ec = $FBC0
; $EA=//e original, $E0=//e enhanced, $E1=//e EDM, $00=//c
romid_mac = $FBDD
ROMID_IIECARD = 2
; IIGS
idroutine = $FE1F ; SEC, JSR $FE1F, BCS notgs
BuildVBLFunction
ldx romid
cpx #ROMID_IIECOMPAT
bne @build_none ; not a //e
lda romid_ec
beq @build_iic ; //c family
lda romid_mac
cmp #ROMID_IIECARD
beq @build_iiecard ; Mac Apple IIe card
sec
jsr idroutine ; check for IIgs
bcs @NotGS
lda #$30
sta patch_VBL_iigs1
lda #$10
sta patch_VBL_iigs2
@NotGS
rts
@build_iic
sta patch_VBL_iic2+1
lda #$70
sta patch_VBL_iic1+1
lda #$10
sta patch_VBL_iic3
lda #<iWaitForVBL
sta WaitForVBL+1
lda #>iWaitForVBL
sta WaitForVBL+2
lda #$4C
sta UnwaitForVBL
rts
@build_iiecard
lda $FBBE ; check IIe card software version because v2.2.2d1 is broken
cmp #$03 ; $03 = v2.2.x
bne @NotGS ; all other versions are ok
ldy #$08 ; Found v2.2.x but don't know which one, so test if VBL works
ldx #$00
- bit $C019
bmi @NotGS
dex
bne -
dey ; keep checking for ~22,000 cycles (a little over 1/50 of a second)
bne - ; if no VBL by then fall through to @build_none
@build_none
lda #$60
sta WaitForVBL
rts