Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectMAME memory issues Reply to this message
Posted bycgfm
Posted on03/09/04 01:44 AM




I'm a little unclear on how to handle mirroring in MAME, maybe someone can help out.

In one situation, I'm trying to mirror RAM at $F800-$FFFF across $C000-$FFFF. Here's what I've used:

AM_RANGE(0xc000,0xffff) AM_READ(MRA8_RAM) AM_MASK(0x7ff)

This allocates a 16k chunk, and correctly maps all accesses to offsets $0000-$07FF only. So it works but is a waste of space.

AM_RANGE(0xc000,0xc7ff) AM_READ(MRA8_RAM) AM_MIRROR(0xf800)

and:

AM_RANGE(0xc000,0xffff) AM_READ(MRA8_RAM) AM_MIRROR(0xf800)

In both cases 2k is allocated, but the memory isn't mirrored above the base area ($c000-$c7ff) so the game crashes.

I had looked at the system24 driver and saw something confusing about the mirroring used:

AM_RANGE(0x000000, 0x03ffff) AM_MIRROR(0x140000) AM_ROM AM_SHARE(1)

Going by the documentation in memory.c, I would assume this maps the ROM as follows:

$000000-$03FFFF : ROM
$040000-$07FFFF : ROM (mirror)
$100000-$13FFFF : ROM (mirror)
$140000-$17FFFF : ROM (mirror)

If this means that the mirroring area can exceed the upper bound of the AM_RANGE macro ($03FFFF), then wouldn't AM_MIRROR not work for mirrored memory at a lower address with something above it? For example in my case, if the RAM was mirrored through $C000-$E7FF, but not $E800-$FFFF, AM_MIRROR would still put the mirrored RAM in the $E800-$FFFF range, right?

Now for handling mirroring of handlers, I'm stuck on this one too:

AM_RANGE(0x80, 0x80) AM_WRITE(YM2151_register_port_0_w)
AM_RANGE(0x81, 0x81) AM_WRITE(YM2151_data_port_0_w)

I'd like to mirror these from $80 to $BF each, so the first one is called for I/O ports $80, $82,..$BE, and the latter is for $81, $83,..$BF. Can the mirroring macros handle this? Or would it be better to define a handler for the full range, manage the mirroring myself, and call the above routines from there?





SubjectRe: MAME memory issues new Reply to this message
Posted bygalibert
Posted on03/09/04 05:31 AM



>
> I'm a little unclear on how to handle mirroring in MAME, maybe someone can help
> out.

You have essentially three possibilites, AM_MASK, AM_MIRROR and AM_SHARE.
- AM_MASK is a mask to apply after testing for AM_RANGE
- AM_MIRROR is an inverted mask to apply to the address (i.e., ignored lines) before testing for AM_RANGE
- AM_SHARE allows to share memory zones

> AM_RANGE(0xc000,0xc7ff) AM_READ(MRA8_RAM) AM_MIRROR(0xf800)

What you want is:
AM_RANGE(0xc000,0xc7ff) AM_READ(MRA8_RAM) AM_MIRROR(0x3800)

> If this means that the mirroring area can exceed the upper bound of the AM_RANGE
> macro ($03FFFF), then wouldn't AM_MIRROR not work for mirrored memory at a lower
> address with something above it? For example in my case, if the RAM was mirrored
> through $C000-$E7FF, but not $E800-$FFFF, AM_MIRROR would still put the mirrored
> RAM in the $E800-$FFFF range, right?

Yes, you'd have to split in in two entries using AM_SHARE, one mirroring over c000-dfff and one at e000.


> Now for handling mirroring of handlers, I'm stuck on this one too:
>
> AM_RANGE(0x80, 0x80) AM_WRITE(YM2151_register_port_0_w)
> AM_RANGE(0x81, 0x81) AM_WRITE(YM2151_data_port_0_w)
>
> I'd like to mirror these from $80 to $BF each, so the first one is called for
> I/O ports $80, $82,..$BE, and the latter is for $81, $83,..$BF. Can the
> mirroring macros handle this? Or would it be better to define a handler for the
> full range, manage the mirroring myself, and call the above routines from there?

AM_RANGE(0x80, 0x80) AM_WRITE(YM2151_register_port_0_w) AM_MIRROR(0x3e)
AM_RANGE(0x81, 0x81) AM_WRITE(YM2151_data_port_0_w) AM_MIRROR(0x3e)

You have to read it as "the hardware ignores the address lines 1 to 5 around there", which is very probably what happens in the real thing.

OG.





Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode