diff --git a/.gitattributes b/.gitattributes index 4f45fb00888..0010d16eb7d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -182,6 +182,7 @@ hash/neocd.xml svneol=native#text/xml hash/neogeo.xml svneol=native#text/xml hash/nes.hsi svneol=native#text/xml hash/nes.xml svneol=native#text/xml +hash/nes_datach.xml svneol=native#text/xml hash/nes_ntbrom.xml svneol=native#text/xml hash/next.xml svneol=native#text/xml hash/ngp.xml svneol=native#text/xml @@ -8161,6 +8162,8 @@ src/mess/machine/nes_cne.c svneol=native#text/plain src/mess/machine/nes_cne.h svneol=native#text/plain src/mess/machine/nes_cony.c svneol=native#text/plain src/mess/machine/nes_cony.h svneol=native#text/plain +src/mess/machine/nes_datach.c svneol=native#text/plain +src/mess/machine/nes_datach.h svneol=native#text/plain src/mess/machine/nes_discrete.c svneol=native#text/plain src/mess/machine/nes_discrete.h svneol=native#text/plain src/mess/machine/nes_event.c svneol=native#text/plain diff --git a/hash/nes.xml b/hash/nes.xml index 2b65f3c805f..62a341e34db 100644 --- a/hash/nes.xml +++ b/hash/nes.xml @@ -44570,139 +44570,6 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - - Datach - Battle Rush - Build Up Robot Tournament (Jpn) - 1993 - Bandai - - - - - - - - - - - - - - - - - Datach - Crayon Shin-Chan - Ora to Poi Poi (Jpn) - 1993 - Bandai - - - - - - - - - - - - - - - - - Datach - Dragon Ball Z - Gekitou Tenkaichi Budou Kai (Jpn) - 1992 - Bandai - - - - - - - - - - - - - - - - - Datach - J League Super Top Players (Jpn) - 1994 - Bandai - - - - - - - - - - - - - - - - - Datach - SD Gundam - Gundam Wars (Jpn) - 1993 - Bandai - - - - - - - - - - - - - - - - - Datach - Ultraman Club - Supokon Fight! (Jpn) - 1993 - Bandai - - - - - - - - - - - - - - - - - Datach - Yu Yu Hakusho - Bakutou Ankoku Bujutsu Kai (Jpn) - 1993 - Bandai - - - - - - - - - - - - - - - De-Block (Jpn) 1991 @@ -55934,7 +55801,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -58250,7 +58117,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -58271,7 +58138,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -59737,7 +59604,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + @@ -59798,7 +59665,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - Super Car (Chi) + Super Car (Chi) 19?? <unknown> @@ -60136,18 +60003,19 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx - + + Dragon Ball Z IV (Asia) 19?? <unknown> - + - + @@ -60732,7 +60600,7 @@ preliminary proto for the PAL version, still running on NTSC systems) or the gfx Subor - + @@ -78470,6 +78338,22 @@ that the real dumps might surface --> - + + + Datach Joint ROM System + 1988 + Bandai + + + + + + + + + + + + diff --git a/hash/nes_datach.xml b/hash/nes_datach.xml new file mode 100644 index 00000000000..ca0a5259910 --- /dev/null +++ b/hash/nes_datach.xml @@ -0,0 +1,117 @@ + + + + + + Datach - Battle Rush - Build Up Robot Tournament (Jpn) + 1993 + Bandai + + + + + + + + + + + + + + Datach - Crayon Shin-Chan - Ora to Poi Poi (Jpn) + 1993 + Bandai + + + + + + + + + + + + + + Datach - Dragon Ball Z - Gekitou Tenkaichi Budou Kai (Jpn) + 1992 + Bandai + + + + + + + + + + + + + + Datach - J League Super Top Players (Jpn) + 1994 + Bandai + + + + + + + + + + + + + + Datach - SD Gundam - Gundam Wars (Jpn) + 1993 + Bandai + + + + + + + + + + + + + + Datach - Ultraman Club - Supokon Fight! (Jpn) + 1993 + Bandai + + + + + + + + + + + + + + Datach - Yu Yu Hakusho - Bakutou Ankoku Bujutsu Kai (Jpn) + 1993 + Bandai + + + + + + + + + + + + + diff --git a/hash/nes_ntbrom.xml b/hash/nes_ntbrom.xml index 5b3aa3de5e6..7d3bd28224a 100644 --- a/hash/nes_ntbrom.xml +++ b/hash/nes_ntbrom.xml @@ -1,6 +1,6 @@ - + Nantettatte!! Baseball '91 Kaimaku Hen (Jpn) diff --git a/src/mess/drivers/nes.c b/src/mess/drivers/nes.c index 430de412d8d..807b25f20e9 100644 --- a/src/mess/drivers/nes.c +++ b/src/mess/drivers/nes.c @@ -1070,7 +1070,8 @@ static MACHINE_CONFIG_START( nes, nes_state ) MCFG_NES_CARTRIDGE_ADD("nes_slot", nes_crt_interface, nes_cart, NULL) MCFG_SOFTWARE_LIST_ADD("cart_list", "nes") - MCFG_SOFTWARE_LIST_ADD("ntb_list", "nes_ntbrom") // Nantettate Baseball mini_carts + MCFG_SOFTWARE_LIST_ADD("ntb_list", "nes_ntbrom") // Sunsoft Nantettate! Baseball mini-carts + MCFG_SOFTWARE_LIST_ADD("datach_list", "nes_datach") // Bandai Datach Joint ROM System mini-carts MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( nespal, nes ) diff --git a/src/mess/includes/nes.h b/src/mess/includes/nes.h index 315f3047c29..80353c6194c 100644 --- a/src/mess/includes/nes.h +++ b/src/mess/includes/nes.h @@ -22,6 +22,7 @@ #include "machine/nes_mmc3.h" #include "machine/nes_mmc5.h" #include "machine/nes_bandai.h" +#include "machine/nes_datach.h" #include "machine/nes_discrete.h" #include "machine/nes_event.h" #include "machine/nes_irem.h" diff --git a/src/mess/machine/nes.c b/src/mess/machine/nes.c index 49c6ef2ecf6..3c7c8e8ea26 100644 --- a/src/mess/machine/nes.c +++ b/src/mess/machine/nes.c @@ -159,7 +159,7 @@ void nes_state::machine_start() m_ppu->set_latch(ppu2c0x_latch_delegate(FUNC(device_nes_cart_interface::ppu_latch),m_cartslot->m_cart)); // 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() == SUNSOFT_DCS + if (m_cartslot->get_pcb_id() == STD_NROM368 || m_cartslot->get_pcb_id() == GG_NROM || m_cartslot->get_pcb_id() == SUNSOFT_DCS || m_cartslot->get_pcb_id() == BANDAI_DATACH || 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 diff --git a/src/mess/machine/nes_bandai.c b/src/mess/machine/nes_bandai.c index 1d48bd86a77..50e0bbc5ba4 100644 --- a/src/mess/machine/nes_bandai.c +++ b/src/mess/machine/nes_bandai.c @@ -14,10 +14,14 @@ * Bandai LZ93D50 + 24C01 EEPROM [mapper 159] * Bandai LZ93D50 + 24C02 EEPROM [mapper 16] * Bandai Famicom Jump 2 (aka LZ93D50 + SRAM) [mapper 153] - * Bandai LZ93D50 + Datach Barcode reader [mapper 157] * Bandai Karaoke Studio [mapper 188] * Bandai Oeka Kids [mapper 96] + * Bandai Datach Joint ROM System [mapper 157] is emulated in a separate source file + to implement also the subslot, but the PCB is basically a Bandai LZ93D50 + 24C02 EEPROM + pcb with added barcode reader and subslot + + TODO: - investigate why EEPROM does not work - try to implement some sort of Karaoke emulation @@ -52,7 +56,6 @@ const device_type NES_FCG = &device_creator; const device_type NES_LZ93D50 = &device_creator; const device_type NES_LZ93D50_24C01 = &device_creator; const device_type NES_LZ93D50_24C02 = &device_creator; -const device_type NES_DATACH = &device_creator; const device_type NES_FJUMP2 = &device_creator; @@ -103,12 +106,6 @@ nes_lz93d50_24c02_device::nes_lz93d50_24c02_device(const machine_config &mconfig { } -nes_datach_device::nes_datach_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : nes_lz93d50_device(mconfig, NES_DATACH, "NES Cart Bandai Datach PCB", tag, owner, clock, "nes_datach", __FILE__), - m_reader(*this, "datach") -{ -} - nes_fjump2_device::nes_fjump2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : nes_lz93d50_device(mconfig, NES_FJUMP2, "NES Cart Bandai Famicom Jump II PCB", tag, owner, clock, "nes_fjump2", __FILE__) { @@ -191,31 +188,6 @@ void nes_lz93d50_24c01_device::pcb_reset() m_i2c_dir = 0; } -void nes_datach_device::device_start() -{ - common_start(); - irq_timer = timer_alloc(TIMER_IRQ); - serial_timer = timer_alloc(TIMER_SERIAL); - irq_timer->adjust(attotime::zero, 0, machine().device("maincpu")->cycles_to_attotime(1)); - serial_timer->adjust(attotime::zero, 0, machine().device("maincpu")->cycles_to_attotime(1000)); - - save_item(NAME(m_irq_enable)); - save_item(NAME(m_irq_count)); - save_item(NAME(m_datach_latch)); -} - -void nes_datach_device::pcb_reset() -{ - m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; - prg16_89ab(0); - prg16_cdef(m_prg_chunks - 1); - chr8(0, m_chr_source); - - m_irq_enable = 0; - m_irq_count = 0; - m_datach_latch = 0; -} - void nes_fjump2_device::device_start() { common_start(); @@ -470,7 +442,6 @@ machine_config_constructor nes_lz93d50_24c01_device::device_mconfig_additions() } - MACHINE_CONFIG_FRAGMENT( bandai_i2c_24c02 ) MCFG_24C02_ADD("i2cmem") MACHINE_CONFIG_END @@ -543,99 +514,3 @@ WRITE8_MEMBER(nes_fjump2_device::write_h) break; } } - - -/*------------------------------------------------- - - Bandai LZ93D50 + Datach barcode reader emulation - - Games: Datach Games - - iNES: mappers 157 - - In MESS: Supported - - TODO: Datach carts should actually be handled - separately! Original carts were minicarts to be - inserted in a smaller slot of the Barcode reader - FC cart. The Barcode reader acts as a passthrough - but it has no internal ROM (it does not work if - you don't have any minicart inserted) - - TODO2: This class should be derived from the - LZ93D50 + X24C02 class, since the main board - has this EEPROM. Moreover, Datach - Battle Rush - has a second X24C01 EEPROM that we don't emulate yet... - - -------------------------------------------------*/ - - -void nes_datach_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) -{ - if (id == TIMER_IRQ) - { - if (m_irq_enable) - { - // 16bit counter, IRQ fired when the counter goes from 1 to 0 - // after firing, the counter is *not* reloaded, but next clock - // counter wraps around from 0 to 0xffff - if (!m_irq_count) - m_irq_count = 0xffff; - else - m_irq_count--; - - if (!m_irq_count) - { - machine().device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, ASSERT_LINE); - m_irq_enable = 0; - } - } - } - if (id == TIMER_SERIAL) - { - m_datach_latch = (m_reader->read_pixel() << 3); - } -} - -READ8_MEMBER(nes_datach_device::read_m) -{ - LOG_MMC(("Datach read_m, offset: %04x\n", offset)); - return m_datach_latch; -} - - -WRITE8_MEMBER(nes_datach_device::write_h) -{ - LOG_MMC(("Datach write_h, offset: %04x, data: %02x\n", offset, data)); - - switch (offset & 0x0f) - { - case 0: case 1: case 2: case 3: - case 4: case 5: case 6: case 7: - // these don't switch CHR bank, but are SCL output - // of the oncart I2C EEPROM! - break; - case 0x0d: - // these should go to the I2C EEPROM on the Datach base - // but SDA line is shared with the oncart I2C EEPROM if - // there is one (only in Datach - Battle Rush ) - break; - default: - fcg_write(space, offset & 0x0f, data, mem_mask); - break; - } -} - - -//------------------------------------------------- -// BARCODE READER DEVICE -//------------------------------------------------- - -MACHINE_CONFIG_FRAGMENT( bandai_datach ) - MCFG_BARCODE_READER_ADD("datach") -MACHINE_CONFIG_END - -machine_config_constructor nes_datach_device::device_mconfig_additions() const -{ - return MACHINE_CONFIG_NAME( bandai_datach ); -} diff --git a/src/mess/machine/nes_bandai.h b/src/mess/machine/nes_bandai.h index 3791b18a0a4..804ffbf9ab0 100644 --- a/src/mess/machine/nes_bandai.h +++ b/src/mess/machine/nes_bandai.h @@ -3,7 +3,6 @@ #include "machine/nes_nxrom.h" #include "machine/i2cmem.h" -#include "machine/bcreader.h" // ======================> nes_karaokestudio_device @@ -125,32 +124,6 @@ public: }; -// ======================> nes_datach_device - -class nes_datach_device : public nes_lz93d50_device -{ -public: - // construction/destruction - nes_datach_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - - // device-level overrides - virtual void device_start(); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); - virtual machine_config_constructor device_mconfig_additions() const; - virtual DECLARE_READ8_MEMBER(read_m); - virtual DECLARE_WRITE8_MEMBER(write_h); - - virtual void pcb_reset(); - -protected: - UINT8 m_datach_latch; - required_device m_reader; - - static const device_timer_id TIMER_SERIAL = 1; - emu_timer *serial_timer; -}; - - // ======================> nes_fjump2_device class nes_fjump2_device : public nes_lz93d50_device @@ -180,7 +153,6 @@ extern const device_type NES_FCG; extern const device_type NES_LZ93D50; extern const device_type NES_LZ93D50_24C01; extern const device_type NES_LZ93D50_24C02; -extern const device_type NES_DATACH; extern const device_type NES_FJUMP2; #endif diff --git a/src/mess/machine/nes_datach.c b/src/mess/machine/nes_datach.c new file mode 100644 index 00000000000..aaf970e52b2 --- /dev/null +++ b/src/mess/machine/nes_datach.c @@ -0,0 +1,356 @@ +/*********************************************************************************************************** + + + NES/Famicom cartridge emulation for Bandai Datach PCBs + + Copyright MESS Team. + Visit http://mamedev.org for licensing and usage restrictions. + + + Here we emulate the Bandai Datach Joint ROM System [mapper 157]. + The base unit features: a Bandai LZ93D50 + 24C02 EEPROM PCB + + barcode reader + subslot for PRG cart + + + ***********************************************************************************************************/ + + +#include "emu.h" +#include "machine/nes_datach.h" +#include "cpu/m6502/m6502.h" + +#ifdef NES_PCB_DEBUG +#define VERBOSE 1 +#else +#define VERBOSE 0 +#endif + +#define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) + + +//-------------------------------- +// +// Datach Cartslot implementation +// +//-------------------------------- + +//------------------------------------------------- +// sub-cart interface +//------------------------------------------------- + +datach_cart_interface::datach_cart_interface(const machine_config &mconfig, device_t &device) + : device_slot_card_interface(mconfig, device), + m_rom(NULL), + m_rom_size(0) +{ +} + +datach_cart_interface::~datach_cart_interface() +{ +} + +READ8_MEMBER(datach_cart_interface::read) +{ + if (offset < 0x4000) + return m_rom[(m_bank * 0x4000) + (offset & 0x3fff)]; + else + return m_rom[(0x0f * 0x4000) + (offset & 0x3fff)]; +} + +//------------------------------------------------- +// sub-cart slot device +//------------------------------------------------- + +const device_type NES_DATACH_SLOT = &device_creator; + +nes_datach_slot_device::nes_datach_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, NES_DATACH_SLOT, "NES Datach Cartridge Slot", tag, owner, clock, "nes_datach_slot", __FILE__), + device_image_interface(mconfig, *this), + device_slot_interface(mconfig, *this) +{ +} + +nes_datach_slot_device::~nes_datach_slot_device() +{ +} + + +void nes_datach_slot_device::device_start() +{ + m_cart = dynamic_cast(get_card_device()); +} + +READ8_MEMBER(nes_datach_slot_device::read) +{ + if (m_cart) + return m_cart->read(space, offset, mem_mask); + + return 0xff; +} + +bool nes_datach_slot_device::call_load() +{ + if (m_cart) + { + UINT8 *ROM = m_cart->get_cart_base(); + + if (!ROM) + return IMAGE_INIT_FAIL; + + // Existing Datach carts are all 256K, so we only load files of this size + if (software_entry() == NULL) + { + if (length() != 0x40000 && length() != 0x40010) + return IMAGE_INIT_FAIL; + + int shift = length() - 0x40000; + UINT8 temp[0x40010]; + fread(&temp, length()); + memcpy(ROM, temp + shift, 0x40000); + + // double check that iNES files are really mapper 157 + // (or 16, since some older .nes files marked Datach as mapper 16) + if (length() == 0x40010) + { + UINT8 mapper = (temp[6] & 0xf0) >> 4; + mapper |= temp[7] & 0xf0; + if (mapper != 157 && mapper != 16) + { + return IMAGE_INIT_FAIL; + } + } + } + else + { + if (get_software_region_length("rom") != 0x40000) + return IMAGE_INIT_FAIL; + + memcpy(ROM, get_software_region("rom"), 0x40000); + } + } + + return IMAGE_INIT_PASS; +} + + +bool nes_datach_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry) +{ + load_software_part_region(this, swlist, swname, start_entry ); + return TRUE; +} + +const char * nes_datach_slot_device::get_default_card_software(const machine_config &config, emu_options &options) +{ + return software_get_default_slot(config, options, this, "datach_rom"); +} + + +//-------------------------------- +// +// Datach Minicart implementation +// +//-------------------------------- + +ROM_START( datach_rom ) + ROM_REGION(0x40000, "datachrom", ROMREGION_ERASEFF) +ROM_END + +const device_type NES_DATACH_ROM = &device_creator; + +nes_datach_rom_device::nes_datach_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, NES_DATACH_ROM, "NES Datach ROM", tag, owner, clock, "nes_datach_rom", __FILE__), + datach_cart_interface( mconfig, *this ) +{ +} + +void nes_datach_rom_device::device_start() +{ + m_rom = (UINT8*)memregion("datachrom")->base(); + save_item(NAME(m_bank)); +} + +void nes_datach_rom_device::device_reset() +{ + m_bank = 0; +} + +const rom_entry *nes_datach_rom_device::device_rom_region() const +{ + return ROM_NAME( datach_rom ); +} + +UINT8 *nes_datach_rom_device::get_cart_base() +{ + return m_rom; +} + + +//--------------------------------- +// +// Datach Base Unit implementation +// +//--------------------------------- + +const device_type NES_DATACH = &device_creator; + + +nes_datach_device::nes_datach_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : nes_lz93d50_device(mconfig, NES_DATACH, "NES Cart Bandai Datach PCB", tag, owner, clock, "nes_datach", __FILE__), + m_i2cmem(*this, "i2cmem"), + m_reader(*this, "datach"), + m_subslot(*this, "datach_slot") +{ +} + + +void nes_datach_device::device_start() +{ + common_start(); + irq_timer = timer_alloc(TIMER_IRQ); + serial_timer = timer_alloc(TIMER_SERIAL); + irq_timer->adjust(attotime::zero, 0, machine().device("maincpu")->cycles_to_attotime(1)); + serial_timer->adjust(attotime::zero, 0, machine().device("maincpu")->cycles_to_attotime(1000)); + + save_item(NAME(m_irq_enable)); + save_item(NAME(m_irq_count)); + save_item(NAME(m_datach_latch)); +} + +void nes_datach_device::pcb_reset() +{ + m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM; + prg16_89ab(0); + prg16_cdef(m_prg_chunks - 1); + chr8(0, m_chr_source); + + m_irq_enable = 0; + m_irq_count = 0; + m_datach_latch = 0; +} + + +/*------------------------------------------------- + mapper specific handlers + -------------------------------------------------*/ + +/*------------------------------------------------- + + Bandai LZ93D50 + Datach barcode reader emulation + + Games: Datach Games + + iNES: mappers 157 + + In MESS: Supported + + TODO: Datach carts should actually be handled + separately! Original carts were minicarts to be + inserted in a smaller slot of the Barcode reader + FC cart. The Barcode reader acts as a passthrough + but it has no internal ROM (it does not work if + you don't have any minicart inserted) + + TODO2: This class should be derived from the + LZ93D50 + X24C02 class, since the main board + has this EEPROM. Moreover, Datach - Battle Rush + has a second X24C01 EEPROM that we don't emulate yet... + + -------------------------------------------------*/ + + +READ8_MEMBER(nes_datach_device::read_m) +{ + LOG_MMC(("Datach read_m, offset: %04x\n", offset)); + return m_datach_latch; +} + + +READ8_MEMBER(nes_datach_device::read_h) +{ + LOG_MMC(("Datach read_h, offset: %04x\n", offset)); + // this shall be the proper code, but it's a bit slower, so we access directly the subcart below + //return m_subslot->read(space, offset, mem_mask); + + if (m_subslot->m_cart) + return m_subslot->m_cart->read(space, offset, mem_mask); + else // this is "fake" in the sense that we fill CPU space with 0xff if no Datach cart is loaded + return hi_access_rom(offset); +} + +WRITE8_MEMBER(nes_datach_device::write_h) +{ + LOG_MMC(("Datach write_h, offset: %04x, data: %02x\n", offset, data)); + + switch (offset & 0x0f) + { + case 0: case 1: case 2: case 3: + case 4: case 5: case 6: case 7: + // these don't switch CHR bank, but are SCL output + // of the oncart I2C EEPROM! + break; + case 0x08: + m_subslot->write_prg_bank(data & 0x0f); + break; + case 0x0d: + // these should go to the I2C EEPROM on the Datach base + // but SDA line is shared with the oncart I2C EEPROM if + // there is one (only in Datach - Battle Rush) + break; + default: + fcg_write(space, offset & 0x0f, data, mem_mask); + break; + } +} + + +//------------------------------------------------- +// BARCODE READER + CART SLOT + X24C02 +//------------------------------------------------- + +static SLOT_INTERFACE_START(datach_cart) + SLOT_INTERFACE("datach_rom", NES_DATACH_ROM) +SLOT_INTERFACE_END + + +MACHINE_CONFIG_FRAGMENT( bandai_datach ) + MCFG_BARCODE_READER_ADD("datach") + MCFG_DATACH_MINICART_ADD("datach_slot", datach_cart) + MCFG_24C02_ADD("i2cmem") +MACHINE_CONFIG_END + +machine_config_constructor nes_datach_device::device_mconfig_additions() const +{ + return MACHINE_CONFIG_NAME( bandai_datach ); +} + + +//------------------------------------------------- +// device_timer - handler timer events +//------------------------------------------------- + +void nes_datach_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +{ + if (id == TIMER_IRQ) + { + if (m_irq_enable) + { + // 16bit counter, IRQ fired when the counter goes from 1 to 0 + // after firing, the counter is *not* reloaded, but next clock + // counter wraps around from 0 to 0xffff + if (!m_irq_count) + m_irq_count = 0xffff; + else + m_irq_count--; + + if (!m_irq_count) + { + machine().device("maincpu")->execute().set_input_line(M6502_IRQ_LINE, ASSERT_LINE); + m_irq_enable = 0; + } + } + } + if (id == TIMER_SERIAL) + { + m_datach_latch = (m_reader->read_pixel() << 3); + } +} diff --git a/src/mess/machine/nes_datach.h b/src/mess/machine/nes_datach.h new file mode 100644 index 00000000000..f2953efbb11 --- /dev/null +++ b/src/mess/machine/nes_datach.h @@ -0,0 +1,152 @@ +#ifndef __NES_DATACH_H +#define __NES_DATACH_H + +#include "machine/nes_bandai.h" +#include "machine/i2cmem.h" +#include "machine/bcreader.h" + +//-------------------------------- +// +// Datach Cartslot implementation +// +//-------------------------------- + +// ======================> datach_cart_interface + +class datach_cart_interface : public device_slot_card_interface +{ +public: + // construction/destruction + datach_cart_interface(const machine_config &mconfig, device_t &device); + virtual ~datach_cart_interface(); + + // reading and writing + virtual DECLARE_READ8_MEMBER(read); + + UINT8 *get_cart_base() { return m_rom; } + void write_prg_bank(UINT8 bank) { m_bank = bank; } + +protected: + // internal state + UINT8 *m_rom; + UINT32 m_rom_size; + // ROM is accessed via two 16K banks, but only the first one can be switched + UINT8 m_bank; +}; + +// ======================> nes_datach_slot_device + +class nes_datach_slot_device : public device_t, + public device_image_interface, + public device_slot_interface +{ +public: + // construction/destruction + nes_datach_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + virtual ~nes_datach_slot_device(); + + // device-level overrides + virtual void device_start(); + virtual void device_config_complete() { update_names(); } + + // image-level overrides + virtual bool call_load(); + virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry); + + virtual iodevice_t image_type() const { return IO_CARTSLOT; } + virtual bool is_readable() const { return 1; } + virtual bool is_writeable() const { return 0; } + virtual bool is_creatable() const { return 0; } + virtual bool must_be_loaded() const { return 0; } + virtual bool is_reset_on_load() const { return 1; } + virtual const char *image_interface() const { return "datach_cart"; } + virtual const char *file_extensions() const { return "nes,bin"; } + virtual const option_guide *create_option_guide() const { return NULL; } + + // slot interface overrides + virtual const char * get_default_card_software(const machine_config &config, emu_options &options); + + virtual DECLARE_READ8_MEMBER(read); + void write_prg_bank(UINT8 bank) { if (m_cart) m_cart->write_prg_bank(bank); } + + datach_cart_interface* m_cart; +}; + +// device type definition +extern const device_type NES_DATACH_SLOT; + + +#define MCFG_DATACH_MINICART_ADD(_tag, _slot_intf) \ + MCFG_DEVICE_ADD(_tag, NES_DATACH_SLOT, 0) \ + MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, NULL, false) + + +//-------------------------------- +// +// Datach Minicart implementation +// +//-------------------------------- + +// ======================> nes_datach_rom_device + +class nes_datach_rom_device : public device_t, + public datach_cart_interface +{ +public: + // construction/destruction + nes_datach_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // optional information overrides + virtual const rom_entry *device_rom_region() const; + virtual UINT8* get_cart_base(); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); +}; + +// device type definition +extern const device_type NES_DATACH_ROM; + + +//--------------------------------- +// +// Datach Base Unit implementation +// +//--------------------------------- + +// ======================> nes_datach_device + +class nes_datach_device : public nes_lz93d50_device +{ +public: + // construction/destruction + nes_datach_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); + virtual machine_config_constructor device_mconfig_additions() const; + virtual DECLARE_READ8_MEMBER(read_m); + virtual DECLARE_READ8_MEMBER(read_h); + virtual DECLARE_WRITE8_MEMBER(write_h); + + virtual void pcb_reset(); + +protected: + UINT8 m_datach_latch; + required_device m_i2cmem; + required_device m_reader; + required_device m_subslot; + UINT8 m_i2c_dir; + + static const device_timer_id TIMER_SERIAL = 1; + emu_timer *serial_timer; +}; + + +// device type definition +extern const device_type NES_DATACH; + +#endif diff --git a/src/mess/machine/nes_sunsoft_dcs.c b/src/mess/machine/nes_sunsoft_dcs.c index 91a2e7e3bbc..3fc0d4a4b4a 100644 --- a/src/mess/machine/nes_sunsoft_dcs.c +++ b/src/mess/machine/nes_sunsoft_dcs.c @@ -25,8 +25,14 @@ #define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) +//----------------------------------------------- +// +// Nantettate!! Baseball Cartslot implementation +// +//----------------------------------------------- + //------------------------------------------------- -// sub-cart device +// sub-cart interface //------------------------------------------------- ntb_cart_interface::ntb_cart_interface(const machine_config &mconfig, device_t &device) @@ -112,9 +118,11 @@ const char * nes_ntb_slot_device::get_default_card_software(const machine_config return software_get_default_slot(config, options, this, "ntbrom"); } -//------------------------------------------------- -// NTB ROM device -//------------------------------------------------- +//----------------------------------------------- +// +// Nantettate!! Baseball Minicart implementation +// +//----------------------------------------------- ROM_START( ntb_rom ) ROM_REGION(0x8000, "ntbrom", ROMREGION_ERASEFF) @@ -143,9 +151,15 @@ UINT8 *nes_ntb_rom_device::get_cart_base() return m_rom; } -//------------------------------------------------- -// constructor -//------------------------------------------------- + + +//------------------------------------------------ +// +// Nantettate!! Baseball base cart implementation +// a.k.a. Sunsoft Dual Cassette System +// (variant of Sunsoft-4 PCB) +// +//------------------------------------------------ const device_type NES_SUNSOFT_DCS = &device_creator; diff --git a/src/mess/machine/nes_sunsoft_dcs.h b/src/mess/machine/nes_sunsoft_dcs.h index 0fbb60ea006..b12a366b568 100644 --- a/src/mess/machine/nes_sunsoft_dcs.h +++ b/src/mess/machine/nes_sunsoft_dcs.h @@ -4,6 +4,12 @@ #include "machine/nes_sunsoft.h" +//----------------------------------------------- +// +// Nantettate!! Baseball Cartslot implementation +// +//----------------------------------------------- + // ======================> ntb_cart_interface class ntb_cart_interface : public device_slot_card_interface @@ -65,18 +71,16 @@ public: extern const device_type NES_NTB_SLOT; -/*************************************************************************** - DEVICE CONFIGURATION MACROS - ***************************************************************************/ - #define MCFG_NTB_MINICART_ADD(_tag, _slot_intf) \ MCFG_DEVICE_ADD(_tag, NES_NTB_SLOT, 0) \ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, NULL, false) -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** +//----------------------------------------------- +// +// Nantettate!! Baseball Minicart implementation +// +//----------------------------------------------- // ======================> nes_ntb_rom_device @@ -101,6 +105,14 @@ extern const device_type NES_NTB_ROM; +//------------------------------------------------ +// +// Nantettate!! Baseball base cart implementation +// a.k.a. Sunsoft Dual Cassette System +// (variant of Sunsoft-4 PCB) +// +//------------------------------------------------ + // ======================> nes_sunsoft_dcs_device class nes_sunsoft_dcs_device : public nes_sunsoft_4_device diff --git a/src/mess/mess.mak b/src/mess/mess.mak index 2c11ca006e2..878788c85da 100644 --- a/src/mess/mess.mak +++ b/src/mess/mess.mak @@ -1543,6 +1543,7 @@ $(MESSOBJ)/nintendo.a: \ $(MESS_MACHINE)/nes_camerica.o \ $(MESS_MACHINE)/nes_cne.o \ $(MESS_MACHINE)/nes_cony.o \ + $(MESS_MACHINE)/nes_datach.o \ $(MESS_MACHINE)/nes_discrete.o \ $(MESS_MACHINE)/nes_event.o \ $(MESS_MACHINE)/nes_ggenie.o \