diff options
author | 0kmg <9137159+0kmg@users.noreply.github.com> | 2021-09-25 21:14:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 15:14:37 +1000 |
commit | 7ed5abfe755f33bddccd8c2405660eb67286e0e6 (patch) | |
tree | 469816592d2ac26dd1716c0225f0f654ce00b6e4 /src/devices/bus/nes | |
parent | 2827239d3780073f4bf660725ae252715fb43970 (diff) |
bus/nes: Simplified handling of SxROM + MMC1A boards a bit. (#8614)
* Removed pseudo board types SXROM_A and SOROM_A that are simply SXROM and SOROM boards fitted with MMC1A chips.
* Provide the equivalent behavior directly in SXROM and SOROM by letting each board know which MMC1 type it has from the existing feature in the softlist.
Diffstat (limited to 'src/devices/bus/nes')
-rw-r--r-- | src/devices/bus/nes/mmc1.cpp | 110 | ||||
-rw-r--r-- | src/devices/bus/nes/mmc1.h | 30 | ||||
-rw-r--r-- | src/devices/bus/nes/nes_carts.cpp | 2 | ||||
-rw-r--r-- | src/devices/bus/nes/nes_ines.hxx | 19 | ||||
-rw-r--r-- | src/devices/bus/nes/nes_pcb.hxx | 20 | ||||
-rw-r--r-- | src/devices/bus/nes/nes_slot.cpp | 1 | ||||
-rw-r--r-- | src/devices/bus/nes/nes_slot.h | 9 |
7 files changed, 50 insertions, 141 deletions
diff --git a/src/devices/bus/nes/mmc1.cpp b/src/devices/bus/nes/mmc1.cpp index cb752cb0754..8c8e7bc31bd 100644 --- a/src/devices/bus/nes/mmc1.cpp +++ b/src/devices/bus/nes/mmc1.cpp @@ -16,6 +16,9 @@ TODO: - Combine 2 versions of set_prg in SxROM base class. This means dealing with variant boards SNROM, SUROM, etc which repurpose bits in the MMC1 regs. + - Determine if "MMC1" marked chips, the earliest version, ignores WRAM + enable/disable bit like its first revision, MMC1A. Also determine if MMC1C + really exists. It's described by kevtris, but it's not in BootGod's DB. ***********************************************************************************************************/ @@ -36,10 +39,8 @@ // constructor //------------------------------------------------- -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_SXROM_A, nes_sxrom_a_device, "nes_sxrom_a", "NES Cart SxROM (MMC-1A) PCB") -DEFINE_DEVICE_TYPE(NES_SOROM_A, nes_sorom_a_device, "nes_sorom_a", "NES Cart SOROM (MMC-1A) PCB") +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") @@ -58,16 +59,6 @@ nes_sorom_device::nes_sorom_device(const machine_config &mconfig, const char *ta { } -nes_sxrom_a_device::nes_sxrom_a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_sxrom_device(mconfig, NES_SXROM_A, tag, owner, clock) -{ -} - -nes_sorom_a_device::nes_sorom_a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nes_sxrom_device(mconfig, NES_SOROM_A, tag, owner, clock) -{ -} - void nes_sxrom_device::device_start() @@ -86,7 +77,8 @@ void nes_sxrom_device::pcb_reset() m_latch = 0; m_count = 0; m_reg[0] = 0x0f; - m_reg[1] = m_reg[2] = m_reg[3] = 0; + m_reg[1] = m_reg[2] = 0; + m_reg[3] = m_mmc1_type == mmc1_type::MMC1C ? 0x10 : 0x00; // WRAM disabled by default on MMC1C m_reg_write_enable = 1; set_nt_mirroring(PPU_MIRROR_HORZ); @@ -94,35 +86,6 @@ void nes_sxrom_device::pcb_reset() set_prg(); } -void nes_sorom_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - - m_latch = 0; - m_count = 0; - m_reg[0] = 0x0f; - m_reg[1] = m_reg[2] = m_reg[3] = 0; - m_reg_write_enable = 1; - - set_nt_mirroring(PPU_MIRROR_HORZ); - set_chr(); - set_prg(); -} - -void nes_sorom_a_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - - m_latch = 0; - m_count = 0; - m_reg[0] = 0x0f; - m_reg[1] = m_reg[2] = m_reg[3] = 0; - m_reg_write_enable = 1; - - set_nt_mirroring(PPU_MIRROR_HORZ); - set_chr(); - set_prg(); -} @@ -295,7 +258,7 @@ void nes_sxrom_device::write_m(offs_t offset, uint8_t data) uint8_t bank = (m_reg[1] >> 2) & 3; LOG_MMC(("sxrom write_m, offset: %04x, data: %02x\n", offset, data)); - if (!BIT(m_reg[3], 4)) // WRAM enabled + if (!BIT(m_reg[3], 4) || m_mmc1_type == mmc1_type::MMC1A) // WRAM enabled { if (!m_battery.empty()) m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)] = data; @@ -309,7 +272,7 @@ uint8_t nes_sxrom_device::read_m(offs_t offset) uint8_t bank = (m_reg[1] >> 2) & 3; LOG_MMC(("sxrom read_m, offset: %04x\n", offset)); - if (!BIT(m_reg[3], 4)) // WRAM enabled + if (!BIT(m_reg[3], 4) || m_mmc1_type == mmc1_type::MMC1A) // WRAM enabled { if (!m_battery.empty()) return m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)]; @@ -317,7 +280,7 @@ uint8_t nes_sxrom_device::read_m(offs_t offset) return m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)]; } - return get_open_bus(); // open bus + return get_open_bus(); } // SOROM has two RAM banks, the first is not battery backed up, the second is. @@ -326,7 +289,7 @@ void nes_sorom_device::write_m(offs_t offset, uint8_t data) uint8_t type = BIT(m_reg[0], 4) ? BIT(m_reg[1], 4) : BIT(m_reg[1], 3); LOG_MMC(("sorom write_m, offset: %04x, data: %02x\n", offset, data)); - if (!BIT(m_reg[3], 4)) // WRAM enabled + if (!BIT(m_reg[3], 4) || m_mmc1_type == mmc1_type::MMC1A) // WRAM enabled { if (type) m_battery[offset & (m_battery.size() - 1)] = data; @@ -340,7 +303,7 @@ uint8_t nes_sorom_device::read_m(offs_t offset) uint8_t type = BIT(m_reg[0], 4) ? BIT(m_reg[1], 4) : BIT(m_reg[1], 3); LOG_MMC(("sorom read_m, offset: %04x\n", offset)); - if (!BIT(m_reg[3], 4)) // WRAM enabled + if (!BIT(m_reg[3], 4) || m_mmc1_type == mmc1_type::MMC1A) // WRAM enabled { if (type) return m_battery[offset & (m_battery.size() - 1)]; @@ -348,52 +311,5 @@ uint8_t nes_sorom_device::read_m(offs_t offset) return m_prgram[offset & (m_prgram.size() - 1)]; } - return get_open_bus(); // open bus -} - -// MMC1A boards have no wram enable/disable bit -void nes_sxrom_a_device::write_m(offs_t offset, uint8_t data) -{ - uint8_t bank = (m_reg[1] >> 2) & 3; - LOG_MMC(("sxrom_a write_m, offset: %04x, data: %02x\n", offset, data)); - - if (!m_battery.empty()) - m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)] = data; - if (!m_prgram.empty()) - m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)] = data; -} - -uint8_t nes_sxrom_a_device::read_m(offs_t offset) -{ - uint8_t bank = (m_reg[1] >> 2) & 3; - LOG_MMC(("sxrom_a read_m, offset: %04x\n", offset)); - - if (!m_battery.empty()) - return m_battery[((bank * 0x2000) + offset) & (m_battery.size() - 1)]; - if (!m_prgram.empty()) - return m_prgram[((bank * 0x2000) + offset) & (m_prgram.size() - 1)]; - - return get_open_bus(); // open bus -} - -void nes_sorom_a_device::write_m(offs_t offset, uint8_t data) -{ - uint8_t type = BIT(m_reg[0], 4) ? BIT(m_reg[1], 4) : BIT(m_reg[1], 3); - LOG_MMC(("sorom_a write_m, offset: %04x, data: %02x\n", offset, data)); - - if (type) - m_battery[offset & (m_battery.size() - 1)] = data; - else - m_prgram[offset & (m_prgram.size() - 1)] = data; -} - -uint8_t nes_sorom_a_device::read_m(offs_t offset) -{ - uint8_t type = BIT(m_reg[0], 4) ? BIT(m_reg[1], 4) : BIT(m_reg[1], 3); - LOG_MMC(("sorom_a read_m, offset: %04x\n", offset)); - - if (type) - return m_battery[offset & (m_battery.size() - 1)]; - else - return m_prgram[offset & (m_prgram.size() - 1)]; + return get_open_bus(); } diff --git a/src/devices/bus/nes/mmc1.h b/src/devices/bus/nes/mmc1.h index 2cd0a8ec256..dbf234f734f 100644 --- a/src/devices/bus/nes/mmc1.h +++ b/src/devices/bus/nes/mmc1.h @@ -51,37 +51,11 @@ public: virtual uint8_t read_m(offs_t offset) override; virtual void write_m(offs_t offset, uint8_t data) override; - - virtual void pcb_reset() override; -}; - -class nes_sxrom_a_device : public nes_sxrom_device -{ -public: - // construction/destruction - nes_sxrom_a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - virtual uint8_t read_m(offs_t offset) override; - virtual void write_m(offs_t offset, uint8_t data) override; -}; - -class nes_sorom_a_device : public nes_sxrom_device -{ -public: - // construction/destruction - nes_sorom_a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - virtual uint8_t read_m(offs_t offset) override; - virtual void write_m(offs_t offset, uint8_t data) override; - - virtual void pcb_reset() override; }; // device type definition -DECLARE_DEVICE_TYPE(NES_SXROM, nes_sxrom_device) -DECLARE_DEVICE_TYPE(NES_SOROM, nes_sorom_device) -DECLARE_DEVICE_TYPE(NES_SXROM_A, nes_sxrom_a_device) -DECLARE_DEVICE_TYPE(NES_SOROM_A, nes_sorom_a_device) +DECLARE_DEVICE_TYPE(NES_SXROM, nes_sxrom_device) +DECLARE_DEVICE_TYPE(NES_SOROM, nes_sorom_device) #endif // MAME_BUS_NES_MMC1_H diff --git a/src/devices/bus/nes/nes_carts.cpp b/src/devices/bus/nes/nes_carts.cpp index e45b4cbc7f4..e7eab6a1166 100644 --- a/src/devices/bus/nes/nes_carts.cpp +++ b/src/devices/bus/nes/nes_carts.cpp @@ -101,8 +101,6 @@ 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("sxrom_a", NES_SXROM_A); // in MMC1-A PRG RAM is always enabled - device.option_add_internal("sorom_a", NES_SOROM_A); // in MMC1-A PRG RAM is always enabled // TxROM device.option_add_internal("txrom", NES_TXROM); // HKROM diff --git a/src/devices/bus/nes/nes_ines.hxx b/src/devices/bus/nes/nes_ines.hxx index 2bbea2571d4..9de292f5225 100644 --- a/src/devices/bus/nes/nes_ines.hxx +++ b/src/devices/bus/nes/nes_ines.hxx @@ -188,7 +188,7 @@ static const nes_mmc mmc_list[] = { 152, DIS_74X161X161X32 }, { 153, BANDAI_LZ93 }, { 154, NAMCOT_34X3 }, - { 155, STD_SXROM_A }, // diff compared to MMC1 concern WRAM + { 155, STD_SXROM }, // same as mapper 1 but forces the use of MMC1A { 156, OPENCORP_DAOU306 }, { 157, BANDAI_DATACH }, // Datach Reader games -> must go in the Datach subslot { 158, TENGEN_800037 }, @@ -651,10 +651,8 @@ void nes_cart_slot_device::call_load_ines() // handle submappers if (submapper) { - // 001: MMC1 - if (mapper == 1 && submapper == 3) - pcb_id = STD_SXROM_A; - else if (mapper == 1 && submapper == 5) + // 001: MMC1 (other submappers are deprecated) + if (mapper == 1 && submapper == 5) logerror("Unimplemented NES 2.0 submapper: SEROM/SHROM/SH1ROM.\n"); // 002, 003, 007: UxROM, CNROM, AxROM else if (mapper == 2 && submapper == 2) @@ -780,6 +778,11 @@ void nes_cart_slot_device::call_load_ines() } break; + case STD_SXROM: + if (mapper == 155) + m_cart->set_mmc1_type(device_nes_cart_interface::mmc1_type::MMC1A); + break; + case NOCASH_NOCHR: // this mapper uses mirroring flags differently m_cart->set_four_screen_vram(false); @@ -1155,10 +1158,8 @@ const char * nes_cart_slot_device::get_default_card_ines(get_default_card_softwa // handle submappers if (submapper) { - // 001: MMC1 - if (mapper == 1 && submapper == 3) - pcb_id = STD_SXROM_A; - else if (mapper == 1 && submapper == 5) + // 001: MMC1 (other submappers are deprecated) + if (mapper == 1 && submapper == 5) logerror("Unimplemented NES 2.0 submapper: SEROM/SHROM/SH1ROM.\n"); // 021, 023, 025: VRC4 / VRC2 else if (mapper == 21 || mapper == 23 || mapper == 25) diff --git a/src/devices/bus/nes/nes_pcb.hxx b/src/devices/bus/nes/nes_pcb.hxx index a6909062ffe..abf0dfc1aae 100644 --- a/src/devices/bus/nes/nes_pcb.hxx +++ b/src/devices/bus/nes/nes_pcb.hxx @@ -32,8 +32,6 @@ static const nes_pcb pcb_list[] = { "un1rom", STD_UN1ROM }, { "sxrom", STD_SXROM }, { "sorom", STD_SOROM }, - { "sxrom_a", STD_SXROM_A }, - { "sorom_a", STD_SOROM_A }, { "txrom", STD_TXROM }, { "hkrom", STD_HKROM }, { "tqrom", STD_TQROM }, @@ -628,6 +626,24 @@ void nes_cart_slot_device::call_load_pcb() // osd_printf_error("VRC-6, pin9: A%d, pin10: A%d\n", nes_cart_get_line(get_feature("vrc6-pin9"), nes_cart_get_line(get_feature("vrc6-pin10")); } + if (m_pcb_id == STD_SXROM || m_pcb_id == STD_SOROM) + { + if (get_feature("mmc1_type") != nullptr) + { + using mmc1_type = device_nes_cart_interface::mmc1_type; + + const char *type = get_feature("mmc1_type"); + if (!strcmp(type, "MMC1")) + m_cart->set_mmc1_type(mmc1_type::MMC1); + else if (!strcmp(type, "MMC1A")) + m_cart->set_mmc1_type(mmc1_type::MMC1A); + else if (!strncmp(type, "MMC1B", 5)) // common prefix of several variants + m_cart->set_mmc1_type(mmc1_type::MMC1B); + else if (!strcmp(type, "MMC1C")) + m_cart->set_mmc1_type(mmc1_type::MMC1C); + } + } + if (m_pcb_id == STD_HKROM || m_pcb_id == TAITO_X1_017) mapper_sram_size = m_cart->get_mapper_sram_size(); diff --git a/src/devices/bus/nes/nes_slot.cpp b/src/devices/bus/nes/nes_slot.cpp index ebaf5ea0406..fef76b520d0 100644 --- a/src/devices/bus/nes/nes_slot.cpp +++ b/src/devices/bus/nes/nes_slot.cpp @@ -122,6 +122,7 @@ device_nes_cart_interface::device_nes_cart_interface(const machine_config &mconf , m_misc_rom_size(0) , m_ce_mask(0) , m_ce_state(0) + , m_mmc1_type(mmc1_type::MMC1B) , m_vrc_ls_prg_a(0) , m_vrc_ls_prg_b(0) , m_vrc_ls_chr(0) diff --git a/src/devices/bus/nes/nes_slot.h b/src/devices/bus/nes/nes_slot.h index e86d22f3312..8ddb7d15ce9 100644 --- a/src/devices/bus/nes/nes_slot.h +++ b/src/devices/bus/nes/nes_slot.h @@ -23,11 +23,10 @@ enum STD_CNROM, STD_CPROM, STD_EXROM, STD_FXROM, STD_GXROM, STD_HKROM, STD_PXROM, - STD_SXROM, STD_TXROM, STD_TXSROM, - STD_TKROM, STD_TQROM, + STD_SXROM, STD_SOROM, + STD_TXROM, STD_TXSROM, STD_TKROM, STD_TQROM, STD_UXROM, STD_UN1ROM, UXROM_CC, HVC_FAMBASIC, NES_QJ, PAL_ZZ, STD_EVENT, - STD_SXROM_A, STD_SOROM, STD_SOROM_A, STD_DISKSYS, STD_NROM368,//homebrew extension of NROM! // Discrete components boards (by various manufacturer) @@ -176,6 +175,8 @@ enum class device_nes_cart_interface : public device_interface { public: + enum class mmc1_type : u8 { MMC1, MMC1A, MMC1B, MMC1C }; + // construction/destruction virtual ~device_nes_cart_interface(); @@ -214,6 +215,7 @@ public: void set_trainer(bool val) { m_has_trainer = val; } void set_ce(int mask, int state) { m_ce_mask = mask; m_ce_state = state; } + void set_mmc1_type(mmc1_type val) { m_mmc1_type = val; } void set_vrc_lines(int PRG_A, int PRG_B, int CHR) { m_vrc_ls_prg_a = PRG_A; m_vrc_ls_prg_b = PRG_B; m_vrc_ls_chr = CHR; } void set_n163_vol(int vol) { m_n163_vol = vol; } void set_x1_005_alt(bool val) { m_x1_005_alt_mirroring = val; } @@ -284,6 +286,7 @@ protected: int m_ce_mask; int m_ce_state; + mmc1_type m_mmc1_type; int m_vrc_ls_prg_a; int m_vrc_ls_prg_b; int m_vrc_ls_chr; |