bus/nes: Added MMC1 variant board SZROM. (#8658)

This fixes corrupt (NVRAM) save games for A Ressha de Ikou, the only known game to use this board.
This commit is contained in:
0kmg 2021-10-04 09:44:40 -08:00 committed by GitHub
parent 30d6d25053
commit e1676a4818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 2 deletions

View File

@ -44502,7 +44502,7 @@ Also notice that VRAM, WRAM & mirror are probably incorrect for some of these se
<info name="release" value="19910821"/>
<info name="alt_title" value="A列車で行こう"/>
<part name="cart" interface="nes_cart">
<feature name="slot" value="sxrom" />
<feature name="slot" value="szrom" />
<feature name="pcb_model" value="HVC-SZROM-01" />
<feature name="mmc1_type" value="MMC1B2" />
<dataarea name="prg" size="131072">

View File

@ -41,6 +41,7 @@
DEFINE_DEVICE_TYPE(NES_SXROM, nes_sxrom_device, "nes_sxrom", "NES Cart SxROM (MMC-1) PCB")
DEFINE_DEVICE_TYPE(NES_SOROM, nes_sorom_device, "nes_sorom", "NES Cart SOROM (MMC-1) PCB")
DEFINE_DEVICE_TYPE(NES_SZROM, nes_szrom_device, "nes_szrom", "NES Cart SZROM (MMC-1) PCB")
@ -59,6 +60,11 @@ nes_sorom_device::nes_sorom_device(const machine_config &mconfig, const char *ta
{
}
nes_szrom_device::nes_szrom_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: nes_sxrom_device(mconfig, NES_SZROM, tag, owner, clock)
{
}
void nes_sxrom_device::device_start()
@ -313,3 +319,32 @@ uint8_t nes_sorom_device::read_m(offs_t offset)
return get_open_bus();
}
// SZROM has two RAM banks, the first is not battery backed up, the second is.
void nes_szrom_device::write_m(offs_t offset, u8 data)
{
LOG_MMC(("szrom write_m, offset: %04x, data: %02x\n", offset, data));
if (!BIT(m_reg[3], 4) || m_mmc1_type == mmc1_type::MMC1A) // WRAM enabled
{
if (BIT(m_reg[BIT(m_reg[0], 4) + 1], 4))
m_battery[offset & (m_battery.size() - 1)] = data;
else
m_prgram[offset & (m_prgram.size() - 1)] = data;
}
}
u8 nes_szrom_device::read_m(offs_t offset)
{
LOG_MMC(("szrom read_m, offset: %04x\n", offset));
if (!BIT(m_reg[3], 4) || m_mmc1_type == mmc1_type::MMC1A) // WRAM enabled
{
if (BIT(m_reg[BIT(m_reg[0], 4) + 1], 4))
return m_battery[offset & (m_battery.size() - 1)];
else
return m_prgram[offset & (m_prgram.size() - 1)];
}
return get_open_bus();
}

View File

@ -43,6 +43,9 @@ protected:
int m_count;
};
// ======================> nes_sorom_device
class nes_sorom_device : public nes_sxrom_device
{
public:
@ -54,8 +57,22 @@ public:
};
// ======================> nes_szrom_device
class nes_szrom_device : public nes_sxrom_device
{
public:
// construction/destruction
nes_szrom_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
virtual u8 read_m(offs_t offset) override;
virtual void write_m(offs_t offset, u8 data) override;
};
// device type definition
DECLARE_DEVICE_TYPE(NES_SXROM, nes_sxrom_device)
DECLARE_DEVICE_TYPE(NES_SOROM, nes_sorom_device)
DECLARE_DEVICE_TYPE(NES_SZROM, nes_szrom_device)
#endif // MAME_BUS_NES_MMC1_H

View File

@ -101,6 +101,7 @@ void nes_cart(device_slot_interface &device)
// SxROM
device.option_add_internal("sxrom", NES_SXROM);
device.option_add_internal("sorom", NES_SOROM);
device.option_add_internal("szrom", NES_SZROM);
// TxROM
device.option_add_internal("txrom", NES_TXROM);
// HKROM

View File

@ -798,6 +798,8 @@ void nes_cart_slot_device::call_load_ines()
break;
case STD_SXROM:
if (mapper == 1 && ines20 && prgram_size == 0x2000 && battery_size == 0x2000 && vrom_size == 0x4000)
m_pcb_id = STD_SZROM;
if (mapper == 155)
m_cart->set_mmc1_type(device_nes_cart_interface::mmc1_type::MMC1A);
break;
@ -1219,6 +1221,12 @@ const char * nes_cart_slot_device::get_default_card_ines(get_default_card_softwa
pcb_id = STD_NROM368;
break;
case STD_SXROM:
// only A Ressha de Ikou uses SZROM and it can be detected by its profile: 8K WRAM, 8K BWRAM, 16K CHR ROM
if (mapper == 1 && ines20 && ROM[10] == 0x77 && ROM[5] == 2)
pcb_id = STD_SZROM;
break;
case KONAMI_VRC2:
if (mapper == 23 && crc_hack && !submapper)
pcb_id = KONAMI_VRC4; // this allows for konami_irq to be installed at reset

View File

@ -32,6 +32,7 @@ static const nes_pcb pcb_list[] =
{ "un1rom", STD_UN1ROM },
{ "sxrom", STD_SXROM },
{ "sorom", STD_SOROM },
{ "szrom", STD_SZROM },
{ "txrom", STD_TXROM },
{ "hkrom", STD_HKROM },
{ "tqrom", STD_TQROM },

View File

@ -23,7 +23,7 @@ enum
STD_CNROM, STD_CPROM,
STD_EXROM, STD_FXROM, STD_GXROM,
STD_HKROM, STD_PXROM,
STD_SXROM, STD_SOROM,
STD_SXROM, STD_SOROM, STD_SZROM,
STD_TXROM, STD_TXSROM, STD_TKROM, STD_TQROM,
STD_UXROM, STD_UN1ROM, UXROM_CC,
HVC_FAMBASIC, NES_QJ, PAL_ZZ, STD_EVENT,