You can also ask questions like these on IRC channel #msxdev on the Rizon network.
To detect a SCC in a subslot requires quite a bit of code. Here's the code from my PSG/FM/SCC music player:
ld de,SearchSCC
ld hl,SCCSlot
call Search
;
Search:
ld [.srch_s],de ; insert search routine address
ld [.srch_p],de
ld [.read_s],hl ; insert address to store slotnr in
ld [.read_p],hl
ld [hl],0 ; reset slotnr
ld b,4
.pri_l: push bc
ld a,4
sub b
ld c,a
ld hl,EXPTBL
add a,l
ld l,a
ld a,[hl]
add a,a
jr nc,.notExp
ld b,4 ; slot is expanded
.exp_l: push bc
ld a,24h
sub b
rlca
rlca
or c
ld [.temp],a
.srch_s: equ $+1
call 0
.read_s: equ $+1
ld a,[0]
or a
pop bc
jr nz,.end
djnz .exp_l
.nextpri:
pop bc
djnz .pri_l
ret
.notExp: ; slot is not expanded
ld a,c
ld [.temp],a
.srch_p: equ $+1
call 0
.read_p: equ $+1
ld a,[0]
or a
jp z,.nextpri
.end: pop bc
ret
.temp: db 0
SearchSCC:
ld hl,[F343h] ; read RAM Slot for page 2
cp l
scf
ret z
ld a,[Search.temp]
ld b,a
and 3
rrca
rrca
ld e,a
rrca
rrca
or e
ld [WriteSCC.PriSlot],a
ld e,a
in a,[A8h]
ld [.restoreA8],a
and 00001111b
or e
out [A8h],a
ld a,b
and 00001100b
rlca
rlca
ld [WriteSCC.SecSlot],a
ld e,a
ld a,[FFFFh]
cpl
ld [.restoreFFFF],a
and 11001111b
or e
ld [ffffh],a
ld hl,9000h
ld de,9800h
ld c,[hl]
ld [hl],3fh
ex de,hl
ld a,[hl]
cpl
ld [hl],a
cp [hl]
cpl
ld [hl],a
ex de,hl
scf
jr nz,.end
ld [hl],0
ex de,hl
ld a,[hl]
cpl
ld [hl],a
cp [hl]
cpl
ld [hl],a
ex de,hl
scf
jr z,.end
ld a,b
ld [SCCSlot],a
or a
.end: ld [hl],c
.restoreFFFF: equ $+1
ld a,0
ld [ffffh],a
.restoreA8: equ $+1
ld a,0
out [a8h],a
ret
|