I am writing an MSX1 emulator and I am a bit confused about how to initialize RAM memory. I am trying to learn from openMSX behavior but it's a bit tricky.
I have the following configuration on openMSX:
<primary slot="0"> <ROM id="Temporary Machine"> <mem base="0x0000" size="0x8000" /> <rom> <sha1>2f997e8a57528518c82ab3693fdae243dbbcc508</sha1> <filename>/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom</filename> </rom> </ROM> </primary> <primary external="true" slot="1" /> <primary external="true" slot="2" /> <primary slot="3"> <RAM id="Main RAM"> <mem base="0x0000" size="0x10000" /> </RAM> </primary>
And on my emulator:
Slot #0: ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000 Slot #1: Empty Slot #2: Empty Slot #3: RAM base=0x0000 size=0xFFFF
The primary slot config starts as 0 and so far my emulator has the same behavior:
Primary Slot Config: 00000000 Segment 0: 0x0000 - 0xFFFF - base: 0x0000 - (slot 0) Memory page 0 (0x0000 - 0x3FFF): primary slot 0 (ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000) Memory page 1 (0x4000 - 0x7FFF): primary slot 0 (ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000) Memory page 2 (0x8000 - 0xBFFF): primary slot 0 (ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000) Memory page 3 (0xC000 - 0xFFFF): primary slot 0 (ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000)
As openMSX:
At some later point, the value 0xF0 is written to the PPI's port 0xA8:
2023-04-09T22:08:00.578123Z INFO msx::ppi: [PPI] [WR] [PrimarySlot] [A8] = F0
And the layout changes:
And the same happens on my emulator:
Primary Slot Config: 11110000 Segment 0: 0x0000 - 0x7FFF - base: 0x0000 - (slot 0) Segment 1: 0x8000 - 0xFFFF - base: 0x0000 - (slot 3) Memory page 0 (0x0000 - 0x3FFF): primary slot 0 (ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000) Memory page 1 (0x4000 - 0x7FFF): primary slot 0 (ROM path=Some("/Users/fcoury/code/msx_emulator/cbios_main_msx1.rom") base=0x0000 size=0x8000) Memory page 2 (0x8000 - 0xBFFF): primary slot 3 (RAM base=0x0000 size=0xFFFF) Memory page 3 (0xC000 - 0xFFFF): primary slot 3 (RAM base=0x0000 size=0xFFFF)
Now the tricky part is that after this layout change, the memory contents I see on openMSX is completely different.
For openMSX:
And for my emulator:
ffb0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ffc0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ffd0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ffe0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ fff0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
Is this because of the default memory map defined here: The Memory - MSX Wiki?
I so, does anyone know the logic I should employ to the RAM type slot? Are there any good documents out there about it?
Thank you!