From 63dbd9fb524ab90438cc265540c69020a53fb6f8 Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Tue, 29 Apr 2014 07:46:23 +0000 Subject: [PATCH] (MESS) nes: added support the new homebrew PCB used by 2A03 Puritans Album. [Fabio Priuli] --- .gitattributes | 2 + src/emu/bus/bus.mak | 1 + src/emu/bus/nes/2a03pur.c | 110 +++++++++++++++++++++++++++++++++++ src/emu/bus/nes/2a03pur.h | 31 ++++++++++ src/emu/bus/nes/nes_carts.c | 3 +- src/emu/bus/nes/nes_carts.h | 1 + src/emu/bus/nes/nes_ines.inc | 2 +- src/emu/bus/nes/nes_pcb.inc | 1 + src/emu/bus/nes/nes_slot.h | 1 + src/mess/machine/nes.c | 2 +- 10 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 src/emu/bus/nes/2a03pur.c create mode 100644 src/emu/bus/nes/2a03pur.h diff --git a/.gitattributes b/.gitattributes index 823528854cb..8468c261350 100644 --- a/.gitattributes +++ b/.gitattributes @@ -970,6 +970,8 @@ src/emu/bus/midi/midiinport.c svneol=native#text/plain src/emu/bus/midi/midiinport.h svneol=native#text/plain src/emu/bus/midi/midioutport.c svneol=native#text/plain src/emu/bus/midi/midioutport.h svneol=native#text/plain +src/emu/bus/nes/2a03pur.c svneol=native#text/plain +src/emu/bus/nes/2a03pur.h svneol=native#text/plain src/emu/bus/nes/act53.c svneol=native#text/plain src/emu/bus/nes/act53.h svneol=native#text/plain src/emu/bus/nes/aladdin.c svneol=native#text/plain diff --git a/src/emu/bus/bus.mak b/src/emu/bus/bus.mak index c16ea7c153b..e47605433d8 100644 --- a/src/emu/bus/bus.mak +++ b/src/emu/bus/bus.mak @@ -751,6 +751,7 @@ ifneq ($(filter NES,$(BUSES)),) OBJDIRS += $(BUSOBJ)/nes BUSOBJS += $(BUSOBJ)/nes/nes_slot.o BUSOBJS += $(BUSOBJ)/nes/nes_carts.o +BUSOBJS += $(BUSOBJ)/nes/2a03pur.o BUSOBJS += $(BUSOBJ)/nes/act53.o BUSOBJS += $(BUSOBJ)/nes/aladdin.o BUSOBJS += $(BUSOBJ)/nes/ave.o diff --git a/src/emu/bus/nes/2a03pur.c b/src/emu/bus/nes/2a03pur.c new file mode 100644 index 00000000000..70627962caa --- /dev/null +++ b/src/emu/bus/nes/2a03pur.c @@ -0,0 +1,110 @@ +/*********************************************************************************************************** + + + NES/Famicom cartridge emulation for 2A03 Puritans Album + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + + + Here we emulate the PCB designed by infiniteneslives and + rainwarrior for this homebew multicart [mapper 30?] + The main difference of this PCB compared to others is that it + uses 4k PRG banks! + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "2a03pur.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 +//------------------------------------------------- + +const device_type NES_2A03PURITANS = &device_creator; + + +nes_2a03pur_device::nes_2a03pur_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : nes_nrom_device(mconfig, NES_2A03PURITANS, "NES Cart 2A03 Puritans Album PCB", tag, owner, clock, "nes_2a03pur", __FILE__) +{ +} + + + +void nes_2a03pur_device::device_start() +{ + common_start(); + save_item(NAME(m_reg)); + memset(m_reg, 0x00, sizeof(m_reg)); + m_reg[7] = 0xff; +} + +void nes_2a03pur_device::pcb_reset() +{ + m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; + chr8(0, m_chr_source); + // register content is not touched by reset +} + + +/*------------------------------------------------- + mapper specific handlers + -------------------------------------------------*/ + +/*------------------------------------------------- + + Board 2A03 Puritans Album + + In MESS: supported. + + This mapper supports up to 1MB of PRG-ROM, in 4k + banks located at $8000, $9000, $A000, $B000, $C000, + $D000, $E000, and $F000. Each bank is selected by n + 8-bit register at $5FF8, $5FF9, $5FFA, $5FFB, $5FFC, + $5FFD, $5FFE, and $5FFF, respectively, just like NSF + banking. These registers are mirrored across the + entire $5000-$5FFF region (the register is selected + by the low 3 bits), but it is recommended to use the + original addresses. The mirroring is merely a + convenience for the hardware implementation. + + The 8kb CHR region may be RAM or ROM. This project + uses CHR-RAM, and the board used by infiniteneslives + for this project may only support CHR-RAM. + + At power-on, the mapper automatically sets all bits + in the $5FFF bank register, placing the highest bank + in $F000. This occurs on power-on but not on reset, + so any bank that is mapped to $F000 after power-on + should contain a valid reset vector. + + At present, the project uses iNES mapper 30 to + designate this mapper. No mapper number has been + officially reserved yet. + -------------------------------------------------*/ + +WRITE8_MEMBER(nes_2a03pur_device::write_l) +{ + LOG_MMC(("2a03 puritans write_l, offset: %04x, data: %02x\n", offset, data)); + offset += 0x100; + if (offset >= 0x1000) + m_reg[offset & 7] = data; +} + +READ8_MEMBER(nes_2a03pur_device::read_h) +{ + LOG_MMC(("2a03 puritans read_h, offset: %04x\n", offset)); + + return m_prg[(m_reg[(offset >> 12) & 7] * 0x1000) + (offset & 0x0fff)]; +} diff --git a/src/emu/bus/nes/2a03pur.h b/src/emu/bus/nes/2a03pur.h new file mode 100644 index 00000000000..29329e0c58b --- /dev/null +++ b/src/emu/bus/nes/2a03pur.h @@ -0,0 +1,31 @@ +#ifndef __NES_2A03PUR_H +#define __NES_2A03PUR_H + +#include "nxrom.h" + + +// ======================> nes_racermate_device + +class nes_2a03pur_device : public nes_nrom_device +{ +public: + // construction/destruction + nes_2a03pur_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual DECLARE_READ8_MEMBER(read_h); + virtual DECLARE_WRITE8_MEMBER(write_l); + + virtual void pcb_reset(); + +private: + UINT8 m_reg[8]; +}; + + + +// device type definition +extern const device_type NES_2A03PURITANS; + +#endif diff --git a/src/emu/bus/nes/nes_carts.c b/src/emu/bus/nes/nes_carts.c index 27ef460b504..36fcc76c0e4 100644 --- a/src/emu/bus/nes/nes_carts.c +++ b/src/emu/bus/nes/nes_carts.c @@ -332,6 +332,7 @@ SLOT_INTERFACE_START(nes_cart) SLOT_INTERFACE_INTERNAL("pjoy84", NES_PJOY84) SLOT_INTERFACE_INTERNAL("nocash_nochr", NES_NOCHR) SLOT_INTERFACE_INTERNAL("nes_action53", NES_ACTION53) + SLOT_INTERFACE_INTERNAL("nes_2a03pur", NES_2A03PURITANS) // other unsupported... SLOT_INTERFACE_INTERNAL("ninjaryu", NES_NROM) // mapper 111 - UNSUPPORTED SLOT_INTERFACE_INTERNAL("unl_dance", NES_NROM) // UNSUPPORTED @@ -350,7 +351,7 @@ SLOT_INTERFACE_START(nes_cart) SLOT_INTERFACE_INTERNAL("ffe3", NES_FFE3) SLOT_INTERFACE_INTERNAL("ffe4", NES_FFE4) SLOT_INTERFACE_INTERNAL("ffe8", NES_FFE8) -SLOT_INTERFACE_INTERNAL("test", NES_NROM) + SLOT_INTERFACE_INTERNAL("test", NES_NROM) // SLOT_INTERFACE_INTERNAL("unknown", NES_NROM) // a few pirate dumps uses the wrong mapper... SLOT_INTERFACE_END diff --git a/src/emu/bus/nes/nes_carts.h b/src/emu/bus/nes/nes_carts.h index 3f1eed77f5c..1c434b72d64 100644 --- a/src/emu/bus/nes/nes_carts.h +++ b/src/emu/bus/nes/nes_carts.h @@ -31,6 +31,7 @@ #include "sunsoft_dcs.h" #include "taito.h" // unlicensed/bootleg/pirate PCBs +#include "2a03pur.h" #include "act53.h" #include "aladdin.h" #include "ave.h" diff --git a/src/emu/bus/nes/nes_ines.inc b/src/emu/bus/nes/nes_ines.inc index 49304387c7e..4e29f4a72ab 100644 --- a/src/emu/bus/nes/nes_ines.inc +++ b/src/emu/bus/nes/nes_ines.inc @@ -59,7 +59,7 @@ static const nes_mmc mmc_list[] = { 27, UNL_WORLDHERO }, // 27 World Hero board - Unsupported { 28, BTL_ACTION53 }, // 28 - Multi-discrete PCB designed by Tepples for Action 53 // 29 Unused - // 30 Unused + { 30, BTL_2A03_PURITANS }, // 30 - PCB designed by infinitelives & rainwarrior for 2A03 Puritans Album // 31 Unused { 32, IREM_G101 }, { 33, TAITO_TC0190FMC }, diff --git a/src/emu/bus/nes/nes_pcb.inc b/src/emu/bus/nes/nes_pcb.inc index b26411821b3..ccb08819617 100644 --- a/src/emu/bus/nes/nes_pcb.inc +++ b/src/emu/bus/nes/nes_pcb.inc @@ -302,6 +302,7 @@ static const nes_pcb pcb_list[] = { "unl_cfight", UNL_CITYFIGHT }, { "nocash_nochr", NOCASH_NOCHR }, { "nes_action53", BTL_ACTION53 }, + { "nes_2a03pur", BTL_2A03_PURITANS }, { "ffe3", FFE3_BOARD }, { "ffe4", FFE4_BOARD }, { "ffe8", FFE8_BOARD }, diff --git a/src/emu/bus/nes/nes_slot.h b/src/emu/bus/nes/nes_slot.h index 6567f5a2330..d8407cf7af3 100644 --- a/src/emu/bus/nes/nes_slot.h +++ b/src/emu/bus/nes/nes_slot.h @@ -121,6 +121,7 @@ enum WHIRLWIND_2706, NOCASH_NOCHR, // homebrew PCB design which uses NTRAM for CHRRAM BTL_ACTION53, // homebrew PCB for homebrew multicarts + BTL_2A03_PURITANS, // homebrew PCB /* FFE boards, for mappers 6, 8, 17 */ FFE3_BOARD, FFE4_BOARD, FFE8_BOARD, TEST_BOARD, /* Unsupported (for place-holder boards, with no working emulation) & no-board (at init) */ diff --git a/src/mess/machine/nes.c b/src/mess/machine/nes.c index 382d8639855..1eeca495fff 100644 --- a/src/mess/machine/nes.c +++ b/src/mess/machine/nes.c @@ -159,7 +159,7 @@ void nes_state::machine_start() // install additional handlers (read_h, read_ex, write_ex) if (m_cartslot->get_pcb_id() == STD_NROM368 || m_cartslot->get_pcb_id() == GG_NROM || m_cartslot->get_pcb_id() == CAMERICA_ALADDIN || m_cartslot->get_pcb_id() == SUNSOFT_DCS - || m_cartslot->get_pcb_id() == BANDAI_DATACH || m_cartslot->get_pcb_id() == BANDAI_KARAOKE || m_cartslot->get_pcb_id() == AVE_MAXI15 + || m_cartslot->get_pcb_id() == BANDAI_DATACH || m_cartslot->get_pcb_id() == BANDAI_KARAOKE || m_cartslot->get_pcb_id() == BTL_2A03_PURITANS || m_cartslot->get_pcb_id() == AVE_MAXI15 || m_cartslot->get_pcb_id() == KAISER_KS7022 || m_cartslot->get_pcb_id() == KAISER_KS7031 || m_cartslot->get_pcb_id() == BMC_VT5201 || m_cartslot->get_pcb_id() == UNL_LH32 || m_cartslot->get_pcb_id() == UNL_LH10 || m_cartslot->get_pcb_id() == UNL_2708 || m_cartslot->get_pcb_id() == UNL_43272 || m_cartslot->get_pcb_id() == BMC_G63IN1 || m_cartslot->get_pcb_id() == BMC_8157