-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrominit64.asm
243 lines (216 loc) · 4.09 KB
/
rominit64.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set pages and subslot
;
ENASLT: equ 024h
RSLREG: equ 0138h
EXPTBL: equ 0FCC1h ; Bios Slot / Expansion Slot
; ----------------------------
; pre-set main slot for page 3
; and set sub-slot for page 3
; ----------------------------
macro mainslot_setup n
and 3
[2] rrca
and 0xC0
ld c,a
ld a,d
and 0x3F
or c
ld c,a ; Primary slot value with main slot in page 3
ld a,b
and 0x0C
[2] rrca
and 3
ld b,a ; B = Expanded slot in page 3
ld a,c
out (0A8h),a ; Slot : Main Slot, xx, xx, Main slot
ld a,(0FFFFh)
cpl
if (n<=4)
[n] RLCA
else
[8-n] RRCA
endif
and 0xFC
or b
if (n<=4)
[n] RRCA
else
[8-n] RLCA
endif
ld (0FFFFh),a ; Expanded slot selected
ld b,a ; save for later
endmacro
; ------------------------------
; SEARCH_SLOT
; look for the slot of our rom
; active in page 1
; ------------------------------
search_slot:
call RSLREG
[2] rrca
and 3
ld c,a
ld b,0
ld hl,EXPTBL
add hl,bc
ld a,(hl)
and 080h
or c
ld c,a
[4] inc hl
ld a,(hl)
and 0Ch
or c
ld (slotvar),a
ret
; ------------------------------
; look for the slot of ram
; active in page 3
; ------------------------------
search_slotram:
di
call RSLREG
[2] rlca
and 3
ld c,a
ld b,0
ld hl,EXPTBL
add hl,bc
ld a,(hl)
and 080h
jr z,search_slotram0
or c
ld c,a
[4] inc hl
ld a,(hl)
[4] rlca
and 0Ch
search_slotram0:
or c
ld (slotram),a
ret
; ------------------------------
; SETROMPAGE0
; Set the chart in
; Page 0
; -----------------------------
setrompage0:
ld a,(slotvar)
jp setslotpage0
setrompage2:
ld a,(slotvar)
jp setslotpage2
setrampage2:
ld a,(slotram)
jp setslotpage2
setrompage3:
ld a,(slotvar)
jp setslotpage3
setrampage3:
ld a,(slotram)
jp setslotpage3
; ------------------------------
; RECBIOS
; set the bios ROM
; -------------------------------
recbios:
ld a,(EXPTBL)
; ---------------------------
; SETSLOTPAGE0
; Set the slot passed in A
; at page 0 in the Z80 address space
; A: Format FxxxSSPP
; ----------------------------
setslotpage0:
di
ld b,a ; B = Slot param in FxxxSSPP format
in a,(0A8h)
and 0xFC
ld d,a ; D = Primary slot value
ld a,b
and 3
or d
ld d,a ; D = Final Value for primary slot
ld a,b ; Check if expanded
bit 7,a
jr z,1f ; Not Expanded
mainslot_setup 0
1: ld a,d ; A = Final value
out (0A8h),a ; Slot Final. Ram, rom c, rom c, Main
ret
; ---------------------------
; SETSLOTPAGE1
; Set the slot passed in A
; at page 1 in the Z80 address space
; A: Format FxxxSSPP
; ----------------------------
setslotpage1:
di
ld b,a ; B = Slot param in FxxxSSPP format
in a,(0A8h)
[2] RRCA
and 0xFC
ld d,a ; D = Primary slot value
ld a,b
and 3
or d
[2] RLCA
ld d,a ; D = Final Value for primary slot
ld a,b ; Check if expanded
bit 7,a
jr z,1f ; Not Expanded
mainslot_setup 6
1: ld a,d ; A = Final value
out (0A8h),a ; Slot Final. Ram, rom c, rom c, Main
ret
; ---------------------------
; SETSLOTPAGE2
; Set the slot passed in A
; at page 2 in the Z80 address space
; A: Format FxxxSSPP
; ----------------------------
setslotpage2:
di
ld b,a ; B = Slot param in FxxxSSPP format
in a,(0A8h)
[4] RLCA
and 0xFC
ld d,a ; D = Primary slot value
ld a,b
and 3
or d
[4] RRCA
ld d,a ; D = Final Value for primary slot
ld a,b ; Check if expanded
bit 7,a
jr z,1f ; Not Expanded
mainslot_setup 4
1: ld a,d ; A = Final value
out (0A8h),a ; Slot Final. Ram, rom c, rom c, Main
ret
; ---------------------------
; SETSLOTPAGE3
; Set the slot passed in A
; at page 3 in the Z80 address space
; A: Format FxxxSSPP
; ----------------------------
setslotpage3:
di
ld b,a ; B = Slot param in FxxxSSPP format
in a,(0A8h)
[2] RLCA
and 0xFC
ld d,a ; D = Primary slot value
ld a,b
and 3
or d
[2] RRCA
ld d,a ; D = Final Value for primary slot
ld a,b ; Check if expanded
bit 7,a
jr z,1f ; Not Expanded
mainslot_setup 2
1: ld a,d ; A = Final value
out (0A8h),a ; Slot Final. Ram, rom c, rom c, Main
ret