-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsccdetec.asm
130 lines (115 loc) · 2.98 KB
/
sccdetec.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
;------------------------------------------------------------
; SCC-search v1.0
; by Alwin Henseler
; using method described in bulletin # 18 MSX-club Enschede
; input: none
; output: B=slot that contains SCC (=255 if no SCC found)
; enaslt: equ #0024
; exptbl: equ #fcc1
; slttbl: equ #fcc5
begin:
MAP #c000
in a,(#a8) ; read prim. slotregister
rra
rra
rra
rra
and %00000011 ; A = prim.slot page 2
ld b,0
ld c,a
ld hl,exptbl
add hl,bc
bit 7,(hl) ; page 2-slot expanded ?
jr z,scctest
ld hl,slttbl
add hl,bc
ld a,(hl) ; A = sec.sel.reg. of page 2-slot
rra
rra
and %00001100 ; bit 1/2 = sec.slot page 2
or c
set 7,a ; compose sec.slot-code
scctest:
push af ; save page 2-slot on the stack
ld a,(exptbl) ; 1st slot to test
testslot:
push af ; save test-slot on the stack
ld h,#80
call enaslt ; switch slot-to-test in 8000-bfffh
ld hl,#9000
ld b,(hl) ; save contents of address 9000h
ld (hl),#3f ; activate SCC (if present)
xor a
ld (0xbffe),a ; scc+ patch for bluemsx
ld h,#9c ; address of SCC-register mirrors
ld de,#9800 ; 9800h = address of SCC-registers
testreg:
ld a,(de)
ld c,a ; save contents of address 98xxh
ld a,(hl) ; read byte from address 9cxxh
cpl ; and invert it
ld (de),a ; write inverted byte to 98xxh
cp (hl) ; same value on 9cxxh ?
ld a,c
ld (de),a ; restore value on 98xxh
jr nz,nextslot ; unequal -> no SCC -> continue search
inc hl
inc de ; next test-addresses
bit 7,l ; 128 addresses (registers) tested ?
jr z,testreg ; no -> repeat mirror-test
ld a,b
ld (#9000),a ; restore value on 9000h
pop bc ; retrieve slotcode (=SCC-slot) from stack
jr done ; SCC found, restore page 2-slot & return
nextslot:
ld a,b
ld (#9000),a ; restore value on 9000h
pop bc ; retrieve slotcode from stack
bit 7,b ; test-slot = sec.slot ?
jr z,nextprim
ld a,b
add a,4 ; increase sec.slotnumber
bit 4,a ; sec.slot = 4 ?
jr z,testslot
nextprim:
ld a,b
and %00000011
cp 3 ; prim.slot = 3 ?
jr z,noscc
inc a ; increase prim.slotnumber
ld d,0
ld e,a
ld hl,exptbl
add hl,de
or (hl) ; combine slot-expansion with slotcode
jr testslot
noscc:
ld b,255 ; code for no SCC
done:
pop af ; retrieve page 2-slot from stack
push bc
ld h,#80
call enaslt ; restore original page 2-slot
pop bc
ei
ret
end:
endmap
; -------------------------------------------------------------
; ====================
; Initialization
; ====================
SCCINIT
ld hl,begin
ld de,0C000H
ld bc,end-begin+1
ldir
call 0C000H
ld a,b
ld (SCC),a
ret
; SLOT .db 0
; PAGE1RAM .db 0
; RAMSLOT .db 0
; SCC .db 0
; SUB .db 0FFH