> I'm a little unclear on how to handle mirroring in MAME, maybe someone can help
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.