Skip to content

Commit e68952f

Browse files
committed
Allocate segments if MSX DOS 1 or harcode them (4, 5, 6, 7) if MSX DOS 1
1 parent b400964 commit e68952f

File tree

1 file changed

+66
-57
lines changed

1 file changed

+66
-57
lines changed

lstate.c

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -195,63 +195,72 @@ void main(char *argv[], int argc) {
195195
//rom_selected_p0 = 0;
196196
//rom_selected_p1 = 0;
197197

198-
// Allocate segments
199-
/* Parameter: A = 0
200-
D = 4 (device number of mapper support)
201-
E = 1
202-
Result: A = slot address of primary mapper
203-
DE = reserved
204-
HL = start address of mapper variable table
205-
*/
206-
__asm
207-
push af
208-
push de
209-
push hl
210-
push iy
211-
212-
xor a // A=0
213-
ld de, #0x0402 // D=4, E=2
214-
call EXTBIO
215-
// Now we have in HL the address of the mapper call table
216-
217-
xor a
218-
ld b, a // A=0, B=0
219-
call CALL_HL // ALL_SEG
220-
221-
ld iy, #_segments
222-
ld 0 (iy), a
223-
//
224-
xor a
225-
ld b, a // A=0, B=0
226-
call CALL_HL // ALL_SEG
227-
228-
ld iy, #_segments
229-
ld 1 (iy), a
230-
//
231-
xor a
232-
ld b, a // A=0, B=0
233-
call CALL_HL // ALL_SEG
234-
235-
ld iy, #_segments
236-
ld 2 (iy), a
237-
//
238-
xor a
239-
ld b, a // A=0, B=0
240-
call CALL_HL // ALL_SEG
241-
242-
ld iy, #_segments
243-
ld 3 (iy), a
244-
245-
pop iy
246-
pop hl
247-
pop de
248-
pop af
249-
jp 70002$ // Get out
250-
251-
CALL_HL:
252-
jp (hl)
253-
70002$:
254-
__endasm;
198+
// Allocate segment if MSX DOS 2.
199+
// Hardcode them in MSX DOS 2.
200+
201+
if (GetOSVersion() >= 2) {
202+
// Allocate segments
203+
/* Parameter: A = 0
204+
D = 4 (device number of mapper support)
205+
E = 1
206+
Result: A = slot address of primary mapper
207+
DE = reserved
208+
HL = start address of mapper variable table
209+
*/
210+
__asm
211+
push af
212+
push de
213+
push hl
214+
push iy
215+
216+
xor a // A=0
217+
ld de, #0x0402 // D=4, E=2
218+
call EXTBIO
219+
// Now we have in HL the address of the mapper call table
220+
221+
xor a
222+
ld b, a // A=0, B=0
223+
call CALL_HL // ALL_SEG
224+
225+
ld iy, #_segments
226+
ld 0 (iy), a
227+
//
228+
xor a
229+
ld b, a // A=0, B=0
230+
call CALL_HL // ALL_SEG
231+
232+
ld iy, #_segments
233+
ld 1 (iy), a
234+
//
235+
xor a
236+
ld b, a // A=0, B=0
237+
call CALL_HL // ALL_SEG
238+
239+
ld iy, #_segments
240+
ld 2 (iy), a
241+
//
242+
xor a
243+
ld b, a // A=0, B=0
244+
call CALL_HL // ALL_SEG
245+
246+
ld iy, #_segments
247+
ld 3 (iy), a
248+
249+
pop iy
250+
pop hl
251+
pop de
252+
pop af
253+
jp 70002$ // Get out
254+
255+
CALL_HL:
256+
jp (hl)
257+
70002$:
258+
__endasm;
259+
}
260+
else {
261+
for (i = 0; i < 4; i++)
262+
segments[i] = i + 4;
263+
}
255264

256265
// Read RAM
257266
for (i = 0; i < 4; i++) {

0 commit comments

Comments
 (0)