// license:BSD-3-Clause // copyright-holders:Fabio Priuli /*********************************************************************************************************** NES/Famicom cartridge emulation for PCBs mostly based on discrete components Here we emulate the following PCBs * PCB with IC 74x161x161x32 [mapper 70 & 152] * PCB with IC 74x139x74 [mapper 87] * PCB with IC 74x377 [mapper 11] * PCB with IC 74x161x138 [mapper 38] ***********************************************************************************************************/ #include "emu.h" #include "discrete.h" #ifdef NES_PCB_DEBUG #define VERBOSE 1 #else #define VERBOSE 0 #endif #define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) //------------------------------------------------- // constructor //------------------------------------------------- DEFINE_DEVICE_TYPE(NES_74X161X161X32, nes_74x161x161x32_device, "nes_74x161", "NES Cart Discrete Logic (74*161/161/32) PCB") DEFINE_DEVICE_TYPE(NES_74X139X74, nes_74x139x74_device, "nes_74x139", "NES Cart Discrete Logic (74*139/74) PCB") DEFINE_DEVICE_TYPE(NES_74X377, nes_74x377_device, "nes_74x377", "NES Cart Discrete Logic (74*377) PCB") DEFINE_DEVICE_TYPE(NES_74X161X138, nes_74x161x138_device, "nes_bitcorp_dis", "NES Cart Discrete Logic (74*161/138) PCB") nes_74x161x161x32_device::nes_74x161x161x32_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) : nes_nrom_device(mconfig, NES_74X161X161X32, tag, owner, clock) { } nes_74x139x74_device::nes_74x139x74_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) : nes_nrom_device(mconfig, NES_74X139X74, tag, owner, clock) { } nes_74x377_device::nes_74x377_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) : nes_nrom_device(mconfig, NES_74X377, tag, owner, clock) { } nes_74x161x138_device::nes_74x161x138_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) : nes_nrom_device(mconfig, NES_74X161X138, tag, owner, clock) { } void nes_74x161x161x32_device::pcb_reset() { prg16_89ab(0); prg16_cdef(m_prg_chunks - 1); chr8(0, m_chr_source); if (m_pcb_ctrl_mirror) set_nt_mirroring(PPU_MIRROR_LOW); } /*------------------------------------------------- mapper specific handlers -------------------------------------------------*/ /*------------------------------------------------- Discrete Logic board IC 74x161x161x32 There are two variants (one with hardwired mirroring, the other with a mirroring control), making necessary two distinct mappers & pcb_id iNES: mappers 70 & 152 -------------------------------------------------*/ // there are two 'variants' depending on hardwired or mapper ctrl mirroring void nes_74x161x161x32_device::write_h(offs_t offset, u8 data) { LOG_MMC(("74x161x161x32 write_h, offset: %04x, data: %02x\n", offset, data)); // this pcb is subject to bus conflict data = account_bus_conflict(offset, data); if (m_pcb_ctrl_mirror) set_nt_mirroring(BIT(data, 7) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW); chr8(data, CHRROM); prg16_89ab(data >> 4); } /*------------------------------------------------- Discrete Logic board IC 74x139x74 by Konami & Jaleco iNES: mapper 87 -------------------------------------------------*/ void nes_74x139x74_device::write_m(offs_t offset, u8 data) { LOG_MMC(("74x139x74 write_m, offset: %04x, data: %02x\n", offset, data)); chr8(bitswap<2>(data, 0, 1), CHRROM); } /*------------------------------------------------- Discrete Logic board IC 74x377 by Color Dreams / Nina-007 emulation Games: many Color Dreams and Wisdom Tree titles iNES: mapper 11 In MAME: Supported Note: bit2 & bit3 are actually related to CIC lockout defeating, and real Color Dreams titles use only bit0 & bit1 for PRG switching. Our usage allows for support of extended PRG games (e.g. homebrew) -------------------------------------------------*/ void nes_74x377_device::write_h(offs_t offset, u8 data) { LOG_MMC(("74x377 write_h, offset: %04x, data: %02x\n", offset, data)); // this pcb is subject to bus conflict, but not the prototype of Secret Scout, which actually breaks in case of conflict... data = account_bus_conflict(offset, data); chr8(data >> 4, m_chr_source); prg32(data & 0x0f); } /*------------------------------------------------- Discrete Logic board IC 74x161x138 Games: Crime Busters iNES: mapper 38 -------------------------------------------------*/ void nes_74x161x138_device::write_m(offs_t offset, u8 data) { LOG_MMC(("74x161x138 write_m, offset: %04x, data: %02x\n", offset, data)); chr8(data >> 2, CHRROM); prg32(data); }