From 9baaf195802b8e145f9bd5da5ba32b58906deddb Mon Sep 17 00:00:00 2001 From: hap Date: Tue, 11 Aug 2020 22:42:58 +0200 Subject: odyssey2: add support for 16KB bankswitched roms --- hash/g7400.xml | 26 +++++++++-------- scripts/src/bus.lua | 2 ++ src/devices/bus/odyssey2/4in1.cpp | 9 +++--- src/devices/bus/odyssey2/4in1.h | 2 +- src/devices/bus/odyssey2/chess.cpp | 5 ++-- src/devices/bus/odyssey2/rally.cpp | 59 ++++++++++++++++++++++++++++++++++++++ src/devices/bus/odyssey2/rally.h | 46 +++++++++++++++++++++++++++++ src/devices/bus/odyssey2/slot.cpp | 3 ++ src/devices/bus/odyssey2/slot.h | 1 + src/devices/bus/odyssey2/voice.cpp | 4 +-- 10 files changed, 133 insertions(+), 24 deletions(-) create mode 100644 src/devices/bus/odyssey2/rally.cpp create mode 100644 src/devices/bus/odyssey2/rally.h diff --git a/hash/g7400.xml b/hash/g7400.xml index aab6d87f5c2..0f8a120341f 100644 --- a/hash/g7400.xml +++ b/hash/g7400.xml @@ -46,9 +46,10 @@ adds 16K RAM and 16K ROM, that plugs into the G7000. Philips - - - + + + + @@ -221,9 +222,9 @@ adds 16K RAM and 16K ROM, that plugs into the G7000. Philips - - - + + + @@ -294,9 +295,10 @@ adds 16K RAM and 16K ROM, that plugs into the G7000. Philips - - - + + + + @@ -405,9 +407,9 @@ adds 16K RAM and 16K ROM, that plugs into the G7000. 198? Philips - - - + + + diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 9c3c3fe2210..a5ad661c924 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -1694,6 +1694,8 @@ if (BUSES["O2"]~=null) then MAME_DIR .. "src/devices/bus/odyssey2/rom.h", MAME_DIR .. "src/devices/bus/odyssey2/4in1.cpp", MAME_DIR .. "src/devices/bus/odyssey2/4in1.h", + MAME_DIR .. "src/devices/bus/odyssey2/rally.cpp", + MAME_DIR .. "src/devices/bus/odyssey2/rally.h", MAME_DIR .. "src/devices/bus/odyssey2/chess.cpp", MAME_DIR .. "src/devices/bus/odyssey2/chess.h", MAME_DIR .. "src/devices/bus/odyssey2/voice.cpp", diff --git a/src/devices/bus/odyssey2/4in1.cpp b/src/devices/bus/odyssey2/4in1.cpp index fac0c1337d1..d458347c076 100644 --- a/src/devices/bus/odyssey2/4in1.cpp +++ b/src/devices/bus/odyssey2/4in1.cpp @@ -2,7 +2,7 @@ // copyright-holders:hap /****************************************************************************** -Videopac 40 cartridge emulation +Videopac 31/40 cartridge emulation 4KB ROM (program ROM is fixed, data ROM is 'bankswitched' via P11) @@ -15,14 +15,13 @@ Used in: #include "emu.h" #include "4in1.h" +DEFINE_DEVICE_TYPE(O2_ROM_4IN1, o2_4in1_device, "o2_4in1", "Odyssey 2 Videopac 40") + //------------------------------------------------- // o2_4in1_device - constructor //------------------------------------------------- -DEFINE_DEVICE_TYPE(O2_ROM_4IN1, o2_4in1_device, "o2_4in1", "Odyssey 2 Videopac 40") - - o2_4in1_device::o2_4in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : o2_rom_device(mconfig, O2_ROM_4IN1, tag, owner, clock) { } @@ -36,7 +35,7 @@ void o2_4in1_device::device_start() void o2_4in1_device::cart_init() { if (m_rom_size != 0x1000) - fatalerror("o2_4in1_device: Wrong ROM region size\n"); + fatalerror("o2_4in1_device: ROM size must be 4096\n"); } diff --git a/src/devices/bus/odyssey2/4in1.h b/src/devices/bus/odyssey2/4in1.h index 51585ff5dc1..c9a6ed78b2a 100644 --- a/src/devices/bus/odyssey2/4in1.h +++ b/src/devices/bus/odyssey2/4in1.h @@ -2,7 +2,7 @@ // copyright-holders:hap /********************************************************************** - Videopac 40 cartridge emulation + Videopac 31/40 cartridge emulation **********************************************************************/ diff --git a/src/devices/bus/odyssey2/chess.cpp b/src/devices/bus/odyssey2/chess.cpp index 068050a7dcd..ec058b9cf48 100644 --- a/src/devices/bus/odyssey2/chess.cpp +++ b/src/devices/bus/odyssey2/chess.cpp @@ -16,14 +16,13 @@ Service manual with schematics is available. #include "emu.h" #include "chess.h" +DEFINE_DEVICE_TYPE(O2_ROM_CHESS, o2_chess_device, "o2_chess", "Odyssey 2 Videopac C7010") + //------------------------------------------------- // o2_chess_device - constructor //------------------------------------------------- -DEFINE_DEVICE_TYPE(O2_ROM_CHESS, o2_chess_device, "o2_chess", "Odyssey 2 Videopac C7010") - - o2_chess_device::o2_chess_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : o2_rom_device(mconfig, O2_ROM_CHESS, tag, owner, clock), m_cpu(*this, "subcpu"), diff --git a/src/devices/bus/odyssey2/rally.cpp b/src/devices/bus/odyssey2/rally.cpp new file mode 100644 index 00000000000..e965d49b1c8 --- /dev/null +++ b/src/devices/bus/odyssey2/rally.cpp @@ -0,0 +1,59 @@ +// license:BSD-3-Clause +// copyright-holders:hap +/****************************************************************************** + +Videopac 55/58/59/60 cartridge emulation + +Bankswitched ROM via latch, either 16KB/2*8KB, or 4KB+8KB. + +Used in: +- #55: Neutron Star +- #58: Air Battle +- #59: Helicopter Rescue +- #60: Trans American Rally + +******************************************************************************/ + +#include "emu.h" +#include "rally.h" + +DEFINE_DEVICE_TYPE(O2_ROM_RALLY, o2_rally_device, "o2_rally", "Odyssey 2 Videopac 60") + + +//------------------------------------------------- +// o2_rally_device - constructor +//------------------------------------------------- + +o2_rally_device::o2_rally_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + o2_rom_device(mconfig, O2_ROM_RALLY, tag, owner, clock) +{ } + +void o2_rally_device::device_start() +{ + save_item(NAME(m_control)); + save_item(NAME(m_bank)); +} + +void o2_rally_device::cart_init() +{ + if (m_rom_size & (m_rom_size - 1) || m_rom_size < 0x800) + fatalerror("o2_rally_device: ROM size must be 2^x\n"); +} + + +//------------------------------------------------- +// mapper specific handlers +//------------------------------------------------- + +u8 o2_rally_device::read_rom04(offs_t offset) +{ + // P10 enables latch output + u8 bank = (m_control & 1) ? ~0 : m_bank; + return m_rom[(offset + bank * 0x800) & (m_rom_size - 1)]; +} + +void o2_rally_device::io_write(offs_t offset, u8 data) +{ + if (offset & 0x80 && ~m_control & 0x10) + m_bank = data; +} diff --git a/src/devices/bus/odyssey2/rally.h b/src/devices/bus/odyssey2/rally.h new file mode 100644 index 00000000000..580d3f1df63 --- /dev/null +++ b/src/devices/bus/odyssey2/rally.h @@ -0,0 +1,46 @@ +// license:BSD-3-Clause +// copyright-holders:hap +/********************************************************************** + + Videopac 55/58/59/60 cartridge emulation + +**********************************************************************/ + +#ifndef MAME_BUS_ODYSSEY2_RALLY_H +#define MAME_BUS_ODYSSEY2_RALLY_H + +#pragma once + +#include "slot.h" +#include "rom.h" + + +// ======================> o2_rally_device + +class o2_rally_device : public o2_rom_device +{ +public: + // construction/destruction + o2_rally_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + // device-level overrides + virtual void device_start() override; + + virtual void cart_init() override; + + virtual u8 read_rom04(offs_t offset) override; + virtual u8 read_rom0c(offs_t offset) override { return read_rom04(offset); } + + virtual void write_p1(u8 data) override { m_control = data; } + virtual void io_write(offs_t offset, u8 data) override; + +private: + u8 m_control = 0; + u8 m_bank = 0; +}; + +// device type definition +DECLARE_DEVICE_TYPE(O2_ROM_RALLY, o2_rally_device) + +#endif // MAME_BUS_ODYSSEY2_RALLY_H diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp index ee814e3cc26..8f5a0fee6d0 100644 --- a/src/devices/bus/odyssey2/slot.cpp +++ b/src/devices/bus/odyssey2/slot.cpp @@ -117,6 +117,7 @@ static const o2_slot slot_list[] = { O2_ROM12, "o2_rom12" }, { O2_ROM16, "o2_rom16" }, { O2_4IN1, "o2_4in1" }, + { O2_RALLY, "o2_rally" }, { O2_CHESS, "o2_chess" }, { O2_VOICE, "o2_voice" } }; @@ -252,6 +253,7 @@ uint8_t o2_cart_slot_device::io_read(offs_t offset) #include "bus/odyssey2/rom.h" #include "bus/odyssey2/4in1.h" +#include "bus/odyssey2/rally.h" #include "bus/odyssey2/chess.h" #include "bus/odyssey2/voice.h" @@ -261,6 +263,7 @@ void o2_cart(device_slot_interface &device) device.option_add_internal("o2_rom12", O2_ROM_12K); device.option_add_internal("o2_rom16", O2_ROM_16K); device.option_add_internal("o2_4in1", O2_ROM_4IN1); + device.option_add_internal("o2_rally", O2_ROM_RALLY); device.option_add_internal("o2_chess", O2_ROM_CHESS); device.option_add_internal("o2_voice", O2_ROM_VOICE); } diff --git a/src/devices/bus/odyssey2/slot.h b/src/devices/bus/odyssey2/slot.h index 50119f71085..c9192a8e17f 100644 --- a/src/devices/bus/odyssey2/slot.h +++ b/src/devices/bus/odyssey2/slot.h @@ -20,6 +20,7 @@ enum O2_ROM12, O2_ROM16, O2_4IN1, + O2_RALLY, O2_CHESS, O2_VOICE }; diff --git a/src/devices/bus/odyssey2/voice.cpp b/src/devices/bus/odyssey2/voice.cpp index cfcbc1f03be..b23a8abf8a0 100644 --- a/src/devices/bus/odyssey2/voice.cpp +++ b/src/devices/bus/odyssey2/voice.cpp @@ -14,14 +14,12 @@ TODO: #include "voice.h" #include "speaker.h" +DEFINE_DEVICE_TYPE(O2_ROM_VOICE, o2_voice_device, "o2_voice", "Odyssey 2 The Voice Passthrough Cart") //------------------------------------------------- // o2_voice_device - constructor //------------------------------------------------- -DEFINE_DEVICE_TYPE(O2_ROM_VOICE, o2_voice_device, "o2_voice", "Odyssey 2 The Voice Passthrough Cart") - - o2_voice_device::o2_voice_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : o2_rom_device(mconfig, O2_ROM_VOICE, tag, owner, clock), m_speech(*this, "sp0256_speech"), -- cgit v1.2.3