Switching RAM in page 0 on MSX2

Página 2/3
1 | | 3

Por aoineko

Paladin (687)

Imagen del aoineko

19-06-2022, 19:54

Metalion wrote:

It seems no one have seen my second question, so here it is again:

I just thought that, alternatively, I might also switch page 0 to a page of the megarom.
That might be easier, since I know already which slot it's in, right ?
Is it possible ?

If the mapped-ROM cartridge is mirrored, if page 0 be the same than page 2, an ISR at 8038h should be visible at 0038h. In this case, I don't see why it wouldn't work by putting page 0 on the slot of your cartridge.

Now, I'm not sure if (all) the mapped-ROM are mirrored.

Por gdx

Enlighted (5815)

Imagen del gdx

20-06-2022, 02:03

This is the case for original cartridges but not for others. It depends on the developer.

What flash card interface do you have?

Por Metalion

Paragon (1587)

Imagen del Metalion

20-06-2022, 09:53

Personnally, I have a MegaflashROM SCC and a Sunrise CF. But ideally I would like it to work in all cases.
So I guess it's back to the RAM switch, then.

Por gdx

Enlighted (5815)

Imagen del gdx

20-06-2022, 12:01

I asked what your interface is because I made a patch that allows to check if a cartridge has mirrors or not (with SHEM for example) for Sunrise ATA-IDE/CF and Beer.

Konami cartridges with Konami8 or SCC mapper have all mirrors but people who imitate them do not necessarily reproduce the mirrors, same for emulators.

Por Metalion

Paragon (1587)

Imagen del Metalion

22-06-2022, 20:25

gdx wrote:

Once you have the slot number, it becomes easy to select it.

I'm sure it is, but I don't really know how to do it ...
You just load the slot address (RAMAD0 for example) in 'a' and call ENASLT ?

Por aoineko

Paladin (687)

Imagen del aoineko

22-06-2022, 20:36

If I understand well, RAMADx are only set by DiskROM.
And as RAM slot for each page is not store we have no other choice than read each slot's page 0 and see if it's RAM.

Por ro

Scribe (4810)

Imagen del ro

22-06-2022, 21:03

Switching p0 is done like this, indeed
Ld a, (ramad0)
Ld h, 0
Call enaslt

When diskrom is active
Enaslt essentially does this
Out (a8), pslot
Ld (-1),sslot

Finding RAM yourself is not that difficult perse. Let us say we found RAM in 2,3 (arbitrary) then use that to format A to the slot id that enaslt needs and call that.

I Could sure whip up some findram function, dont have one at hand atm

Por gdx

Enlighted (5815)

Imagen del gdx

23-06-2022, 12:37

ro wrote:

Switching p0 is done like this, indeed
Ld a, (ramad0)
Ld h, 0
Call enaslt

If I remember correctly, it does not work on some MSX's that have its RAM in a slot 0-X.

If I didn't make a mistake, the routine below should work:

;
; Select the Main-RAM slot on page 0
;

SelectMainRamSlt-p0:
	di
	in	a,(0A8h)
	and	0c0h
	ld	e,a		; Store the current primary slots for page 3 to E
	ld	a,(0FFFFh)
	cpl
	and	0c0h
	ld	d,a		; Store the current secondary slots for page 3 to D

; Select the slot of Main-RAM on page 0 into page 3 & 0

	ld	a,(MainRamSlt-p0)
	ld	b,a		; Store the slot number for the Main-RAM on page 0
	and	3
	ld	c,a		; Store the page 3 Main-RAM primary slot number
	rlca			; P000000P
	rlca			; PP000000
	or	c		; PP0000PP
	ld	c,a
	ld	a,b
	and	3ch
	or	c
	out	(0A8h),a	; Select the page 3 Main-RAM primary slot on pages 0 and 3
	bit	7,b
	jr	z,NoSecSlt
	ld	a,(0FFFFh)
	cpl
	and	0FCh
	ld	c,a
	ld	a,b
	and	00Ch
	rlca		; 00000SS0
	rlca		; 000000SS
	or	c
	ld	(0FFFFh),a	; Select the page 3 Main-RAM secondary slot on pages 0

; Restore the Main-RAM to page 3 

	in	a,(0A8h)
	and	3fh
	or	e		; restore the previous current primary slots on page 3
	out	(0A8h),a	; Select the previous current primary slots on page 3
	ld	a,(0FFFFh)
	cpl
	and	3fh
	or	d
	ld	(0FFFFh),a	; restore the previous current secondary slots on page 3
NoSecSlt:
	ei
	ret

At first sight, it can look complicated but it's just moving right bits to the right places.
The conditional relative jump to NoSecSlt is not essential.

Por ro

Scribe (4810)

Imagen del ro

23-06-2022, 11:03

Switching slots is in essence easy, what makes it difficult is WHERE you have the switch function located and is page 3 the default RAM where secslt (#FFFF / -1) is present.
If you take away all those prereqs, you can out #a8 and poke -1 directly.

The ENASLT does checks on the prereqs and is bulky to say the least. But it's a very save one. If you have a slot switch on interrupt for example, and need high speed, you could just use direct addressing of port information. Provided you know how the system is set-up at that moment.

In most situations, page 3 is the default RAM, so the secslt info is always present.

GDX his example should, ofcourse, not be in page 0.

btw, GDX: should this

ld a,(CurrentRamSlt)
and 00Ch

not be

ld a,d ; you stored this earlier

?

Por gdx

Enlighted (5815)

Imagen del gdx

23-06-2022, 11:47

Ro, I edited this passage just before your comment, but it's possible there's still a mistake. I make this routine by modifying another one earlier.

Edit: I added the following missing line towards the end.

out (0A8h),a ; Select the previous current primary slots on page 3

Página 2/3
1 | | 3