Change the slot address of RAM

By saccopharynx

Expert (128)

saccopharynx's picture

10-10-2018, 06:45

Hi guys,

I wonder if there exists any MSX-DOS tool to change the slot address of RAM. For example, in case of having multimappers (slot 1 - 64KB; slot 2 - 512KB), large games would only work when the mapper in slot 2 is selected. The tool should also change the system variables RAMAD0-RAMAD3.


Login or register to post comments

By Eugeny_Brychkov

Paragon (1050)

Eugeny_Brychkov's picture

10-10-2018, 08:23

saccopharynx wrote:

The tool should also change the system variables RAMAD0-RAMAD3.

I guess these are key variables, as well as one or two more above F380 to be changed, and also first RAM page to be copied to the target slot. You can write this tool in 20 minutes.

By saccopharynx

Expert (128)

saccopharynx's picture

11-10-2018, 23:19

Yes, the development of the tool should not be too complicated, but I am not aware of all the variables I should modify. Could you please specify on those you mentioned above #F380?


By gdx

Prophet (2492)

gdx's picture

12-10-2018, 02:06

I working on it...

By saccopharynx

Expert (128)

saccopharynx's picture

18-10-2018, 06:11

I have been working on a solution for this, but I am not yet quite happy with the results. The solution works for all of the few configurations I tried, but it fails for the default MSX2 - Daewoo CPC-400S with an extra mapped RAM connected to slot 3-0:

0-0 "Normal ROM: 400sbios.rom"
0-1 "Normal 4000h: 400shan.rom"
0-2 128 kB Mapped RAM -> Original mapper
0-3 "Normal ROM: 400sext.rom"
2-0 "National Disk Controller: 400sdisk.rom"
3-0 512 kB Mapped RAM -> Added mapper

When the code below is called, it is executed out of #c000-#ffff. Interrupts are disabled and register 'de' contains the requested slot-subslot (de = 0x30). The whole process seems to work fine and the added mapper successfully connects to Page 3 containing a copy of the data in the original mapper. However, after returning to the calling code, everything starts going wrong as soon as I enable interrupts again 'ei'. Going wrong means that the interruption is fired and it never returns to my code.

As I formerly mentioned, this issue only occurs with the configuration above. Any clue what could be causing this bug?

; Set mapper segment #0 for Page 1 (already connected to the requested slot/subslot)
ld a, 0
out(#fd), a

push de ; Save copy of slot/subslot
; Make a copy of Page 3 (#c000)
ld hl, #c000
ld de, #4000
ld bc, #4000

in a,(#a8) ; db a8: read slot configuration
pop de

; copy the slot/subslot
ld b, d
ld c, e
; shift slot right to bits 7-6
rrc b
rrc b

; Select slot for Page 3
and %00111111
xor b
; Set slot for Page 3
out (#a8), a; d3 a8

; Read subslot configuration
ld a, (#ffff)
; shift subslot right to bits 7-6
rrc c
rrc c
rrc c
rrc c
; Select subslot for Page 3
and %00111111
xor c
; Set subslot for Page 3
ld (#ffff),a ;32 ff ff

; Update the corresponding value of SLTTBL
ld hl, #fcc5
ld b, 0
ld c, d
add hl, bc
ld (hl), a

ret ;c9: All done and return :-)


By sd_snatcher

Prophet (2902)

sd_snatcher's picture

18-10-2018, 14:50

There are other risks related to warm changing the default slot address of RAM: on MSX machines, your program can never assume it’s running alone in the world.

For example, other extensions might already be present and might have captured hooks and set up them with RST30h instructions that point to the previous RAM configuration.

By saccopharynx

Expert (128)

saccopharynx's picture

18-10-2018, 15:27

But what's the problem with those hooks? I don't really see your point. Could you please expand on that? The hooks in page 3 would also be copied. In fact, this works except from the MSX configuration described above...

My MSX profile