M src/MapView.asm +3 -3
@@ 203,7 203,7 @@ Loop:
; ix = this
MapView_DrawTileColumn: PROC
push ix
- ld hl,(ROMMapper_instance.pageA000)
+ ld hl,(ROM_mapper.pageA000)
push hl
ld iyl,c
ld iyh,e
@@ 363,7 363,7 @@ MapView_DrawColumnTile_M: MACRO ?lines
; ix = this
MapView_DrawTileRow: PROC
push ix
- ld hl,(ROMMapper_instance.pageA000)
+ ld hl,(ROM_mapper.pageA000)
push hl
ld iyl,c
ld iyh,e
@@ 499,7 499,7 @@ DrawRowTile12:
; hl <- tile pixels
MapView_GetTileSource_M: MACRO
ld a,(ix + Tile.image.bank)
- ld (ROMMapper_instance.pageA000.BANK_SELECT),a
+ ld (ROM_mapper.pageA000.BANK_SELECT),a
IF Video_4BPU
ld h,(ix + Tile.image.address)
add hl,hl
M src/ROM.asm +7 -0
@@ 73,3 73,10 @@ RAM_RESIDENT: equ RAM
INCLUDE "Resources.asm"
ENDS
+
+ SECTION RAM
+
+ROM_mapper:
+ ROMMapper
+
+ ENDS
M src/ROMMapper.asm +16 -12
@@ 25,6 25,18 @@ ROMPage: MACRO ?base, ?bankSelect, ?init
db ?base >> 8
ENDM
+; ix = this
+ROMMapper_Construct:
+ ld a,(ix + ROMMapper.page4000.bank)
+ ld (ROMMapper.page4000.BANK_SELECT),a
+ ld a,(ix + ROMMapper.page6000.bank)
+ ld (ROMMapper.page6000.BANK_SELECT),a
+ ld a,(ix + ROMMapper.page8000.bank)
+ ld (ROMMapper.page8000.BANK_SELECT),a
+ ld a,(ix + ROMMapper.pageA000.bank)
+ ld (ROMMapper.pageA000.BANK_SELECT),a
+ ret
+
; hl = page base
; a <- bank
ROMMapper_GetBank:
@@ 53,10 65,10 @@ ROMMapper_GetPage: PROC
bit 5,h
jr nz,Page6000
Page4000:
- ld hl,ROMMapper_instance.page4000
+ ld hl,ROM_mapper.page4000
ret
Page6000:
- ld hl,ROMMapper_instance.page6000
+ ld hl,ROM_mapper.page6000
ret
UpperHalf:
bit 6,h
@@ 64,10 76,10 @@ UpperHalf:
bit 5,h
jr nz,PageA000
Page8000:
- ld hl,ROMMapper_instance.page8000
+ ld hl,ROM_mapper.page8000
ret
PageA000:
- ld hl,ROMMapper_instance.pageA000
+ ld hl,ROM_mapper.pageA000
ret
PageOutOfRange:
call System_ThrowException
@@ 88,11 100,3 @@ ROMPage_SetBank:
ld h,(hl)
ld (hl),a
ret
-
-;
- SECTION RAM
-
-ROMMapper_instance:
- ROMMapper
-
- ENDS
M src/ROMRuntime.asm +3 -1
@@ 17,11 17,13 @@ ROMRuntime: MACRO ?main
ld h,80H
call Memory_SetSlot
ld a,ROM_RAMInitBank
- ld (ROMMapper_instance.pageA000.BANK_SELECT),a
+ ld (ROM_mapper.pageA000.BANK_SELECT),a
ld hl,RAM_sourceAddress
ld de,RAM_startAddress
ld bc,RAM_endAddress - RAM_startAddress
ldir
+ ld ix,ROM_mapper
+ call ROMMapper_Construct
call System_SetDirectBIOSHandlers
ld hl,?main
call System_TryCall
M src/audio/Audio.asm +3 -3
@@ 11,7 11,7 @@ Audio: MACRO
playing: ret
ld a,0
bank: equ $ - 1
- ld (ROMMapper_instance.page8000.BANK_SELECT),a
+ ld (ROM_mapper.page8000.BANK_SELECT),a
ld hl,0
address: equ $ - 2
ld a,1
@@ 20,8 20,8 @@ Audio: MACRO
call z,Audio_Process
ld (wait),a
ld (address),hl
- ld a,(ROMMapper_instance.page8000.bank)
- ld (ROMMapper_instance.page8000.BANK_SELECT),a
+ ld a,(ROM_mapper.page8000.bank)
+ ld (ROM_mapper.page8000.BANK_SELECT),a
ret
psg: