snes: shuffling some code around (part 4). nw.

This commit is contained in:
Fabio Priuli 2013-03-05 06:34:52 +00:00
parent 7f96567518
commit e73193344f
4 changed files with 55 additions and 50 deletions

View File

@ -776,6 +776,9 @@ void CX4_write(running_machine &machine, UINT32 addr, UINT8 data);
UINT8 sdd1_mmio_read(address_space &space, UINT32 addr);
void sdd1_mmio_write(address_space &space, UINT32 addr, UINT8 data);
UINT8 sdd1_read(running_machine& machine, UINT32 addr);
UINT8 spc7110_mmio_read(address_space &space, UINT32 addr);
void spc7110_mmio_write(running_machine &machine, UINT32 addr, UINT8 data);
UINT8 spc7110_bank7_read(address_space &space, UINT32 offset);
extern struct snes_cart_info snes_cart;

View File

@ -410,14 +410,6 @@ READ8_HANDLER( snes_r_io )
return superfx_mmio_read(state->m_superfx, offset);
}
}
else if (state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
{
UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
if (offset >= 0x4800 && offset <= limit)
{
return spc7110_mmio_read(space, offset);
}
}
if (offset >= DMAP0 && offset < 0x4380)
{
@ -529,15 +521,6 @@ WRITE8_HANDLER( snes_w_io )
return;
}
}
else if (state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
{
UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
if (offset >= 0x4800 && offset <= limit)
{
spc7110_mmio_write(space.machine(), (UINT32)offset, data);
return;
}
}
if (offset >= DMAP0 && offset < 0x4380)
{
@ -755,11 +738,6 @@ READ8_HANDLER( snes_r_bank1 )
else
value = snes_open_bus_r(space, 0);
}
else if (state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
{
if (offset < 0x10000)
value = snes_ram[0x306000 + (offset & 0x1fff)];
}
else
{
logerror("(PC=%06x) snes_r_bank1: Unmapped external chip read: %04x\n",space.device().safe_pc(),address);
@ -797,11 +775,6 @@ READ8_HANDLER( snes_r_bank2 )
else
value = snes_open_bus_r(space, 0);
}
else if (state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
{
if (offset < 0x10000)
value = snes_ram[0x306000 + (offset & 0x1fff)];
}
else if ((state->m_cart[0].mode == SNES_MODE_21) && (state->m_cart[0].sram > 0))
{
/* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */
@ -841,11 +814,6 @@ READ8_HANDLER( snes_r_bank3 )
return sfx_data[offset & 0x0f];
}
}
else if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC))
{
if (offset >= 0x100000 && offset < 0x110000)
value = spc7110_mmio_read(space, 0x4800);
}
else if ((state->m_cart[0].mode & 5) && !(state->m_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */
{
if ((address < 0x8000) && (state->m_cart[0].mode == SNES_MODE_20))
@ -995,8 +963,6 @@ READ8_HANDLER( snes_r_bank7 )
value = snes_open_bus_r(space, 0);
}
}
else if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
value = spc7110_bank7_read(space, offset);
else if ((state->m_cart[0].mode & 5) && !(state->m_has_addon_chip == HAS_SUPERFX)) /* Mode 20 & 22 */
{
if (address < 0x8000)
@ -1030,11 +996,6 @@ WRITE8_HANDLER( snes_w_bank1 )
{
if (state->m_has_addon_chip == HAS_SUPERFX)
snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues
else if (state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
{
if (offset < 0x10000)
snes_ram[0x306000 + (offset & 0x1fff)] = data;
}
else
logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data);
}
@ -1061,11 +1022,6 @@ WRITE8_HANDLER( snes_w_bank2 )
{
if (state->m_has_addon_chip == HAS_SUPERFX)
snes_ram[0xf00000 + (offset & 0x1fff)] = data; // here it should be 0xe00000 but there are mirroring issues
else if (state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
{
if (offset < 0x10000)
snes_ram[0x306000 + (offset & 0x1fff)] = data;
}
else if ((state->m_cart[0].mode == SNES_MODE_21) && (state->m_cart[0].sram > 0))
{
/* Donkey Kong Country checks this and detects a copier if 0x800 is not masked out due to sram size */

View File

@ -758,8 +758,6 @@ UINT32 SPC7110Decomp::morton_4x8(UINT32 data)
+ m_morton32[2][(data >> 16) & 255] + m_morton32[3][(data >> 24) & 255];
}
static void spc7110_mmio_write(running_machine &machine, UINT32 addr, UINT8 data);
static UINT8 spc7110_mmio_read(address_space &space, UINT32 addr);
static void spc7110_update_time(running_machine &machine, UINT8 offset);
enum RTC_State
@ -1058,7 +1056,7 @@ static void spc7110_update_time(running_machine &machine, UINT8 offset)
}
}
static UINT8 spc7110_mmio_read(address_space &space, UINT32 addr)
UINT8 spc7110_mmio_read(address_space &space, UINT32 addr)
{
running_machine &machine = space.machine();
UINT8 *ROM = machine.root_device().memregion("cart")->base();
@ -1245,7 +1243,7 @@ static UINT8 spc7110_mmio_read(address_space &space, UINT32 addr)
return snes_open_bus_r(space, 0);
}
static void spc7110_mmio_write(running_machine &machine, UINT32 addr, UINT8 data)
void spc7110_mmio_write(running_machine &machine, UINT32 addr, UINT8 data)
{
UINT8 *ROM = machine.root_device().memregion("cart")->base();
@ -1631,7 +1629,7 @@ static void spc7110_mmio_write(running_machine &machine, UINT32 addr, UINT8 data
}
}
static UINT8 spc7110_bank7_read(address_space &space, UINT32 offset)
UINT8 spc7110_bank7_read(address_space &space, UINT32 offset)
{
UINT8 *ROM = space.machine().root_device().memregion("cart")->base();
UINT32 addr = offset & 0x0fffff;

View File

@ -144,6 +144,20 @@ static READ8_HANDLER( snes_lo_r )
if (state->m_has_addon_chip == HAS_SDD1
&& (offset < 0x400000 && (offset & 0xffff) >= 0x4800 && (offset & 0xffff) < 0x4808))
return sdd1_mmio_read(space, (UINT32)(offset & 0xffff));
if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
&& offset < 0x400000)
{
UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
if ((offset & 0xffff) >= 0x4800 && (offset & 0xffff) <= limit)
return spc7110_mmio_read(space, (UINT32)(offset & 0xffff));
if (offset < 0x10000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
return snes_ram[0x306000 + (offset & 0x1fff)];
if (offset >= 0x300000 && offset < 0x310000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
return snes_ram[0x306000 + (offset & 0x1fff)];
}
if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
&& offset >= 0x500000 && offset < 0x510000)
return spc7110_mmio_read(space, 0x4800);
// base cart access
if (offset < 0x300000)
@ -198,7 +212,21 @@ static READ8_HANDLER( snes_hi_r )
&& (offset < 0x400000 && (offset & 0xffff) >= 0x4800 && (offset & 0xffff) < 0x4808))
return sdd1_mmio_read(space, (UINT32)(offset & 0xffff));
if (state->m_has_addon_chip == HAS_SDD1 && offset >= 0x400000)
return sdd1_read(space.machine(), offset - 0x400000);;
return sdd1_read(space.machine(), offset - 0x400000);
if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
&& offset < 0x400000)
{
UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
if ((offset & 0xffff) >= 0x4800 && (offset & 0xffff) <= limit)
return spc7110_mmio_read(space, (UINT32)(offset & 0xffff));
if (offset < 0x10000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
return snes_ram[0x306000 + (offset & 0x1fff)];
if (offset >= 0x300000 && offset < 0x310000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
return snes_ram[0x306000 + (offset & 0x1fff)];
}
if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC)
&& offset >= 0x500000)
return spc7110_bank7_read(space, offset - 0x400000);
// base cart access
if (offset < 0x400000)
@ -276,6 +304,16 @@ static WRITE8_HANDLER( snes_lo_w )
// here we don't return, but we let the w_io happen...
}
}
if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000)
{
UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
if ((offset & 0xffff) >= 0x4800 && (offset & 0xffff) <= limit)
{ spc7110_mmio_write(space.machine(), (UINT32)(offset & 0xffff), data); return; }
if (offset < 0x10000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
{ snes_ram[0x306000 + (offset & 0x1fff)] = data; return; }
if (offset >= 0x300000 && offset < 0x310000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
{ snes_ram[0x306000 + (offset & 0x1fff)] = data; return; }
}
// base cart access
if (offset < 0x300000)
@ -359,6 +397,16 @@ static WRITE8_HANDLER( snes_hi_w )
// here we don't return, but we let the w_io happen...
}
}
if ((state->m_has_addon_chip == HAS_SPC7110 || state->m_has_addon_chip == HAS_SPC7110_RTC) && offset < 0x400000)
{
UINT16 limit = (state->m_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
if ((offset & 0xffff) >= 0x4800 && (offset & 0xffff) <= limit)
{ spc7110_mmio_write(space.machine(), (UINT32)(offset & 0xffff), data); return; }
if (offset < 0x10000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
{ snes_ram[0x306000 + (offset & 0x1fff)] = data; return; }
if (offset >= 0x300000 && offset < 0x310000 && (offset & 0xffff) >= 0x6000 && (offset & 0xffff) < 0x8000)
{ snes_ram[0x306000 + (offset & 0x1fff)] = data; return; }
}
// base cart access
if (offset < 0x400000)