summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/odyssey2/chess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/odyssey2/chess.cpp')
-rw-r--r--src/devices/bus/odyssey2/chess.cpp93
1 files changed, 65 insertions, 28 deletions
diff --git a/src/devices/bus/odyssey2/chess.cpp b/src/devices/bus/odyssey2/chess.cpp
index 6ff1ff76dd2..1e63062af7a 100644
--- a/src/devices/bus/odyssey2/chess.cpp
+++ b/src/devices/bus/odyssey2/chess.cpp
@@ -14,13 +14,45 @@ Hardware notes:
#include "emu.h"
#include "chess.h"
-DEFINE_DEVICE_TYPE(O2_ROM_CHESS, o2_chess_device, "o2_chess", "Odyssey 2 Videopac C7010")
+#include "cpu/z80/z80.h"
+#include "machine/gen_latch.h"
+namespace {
//-------------------------------------------------
-// o2_chess_device - constructor
+// initialization
//-------------------------------------------------
+class o2_chess_device : public device_t, public device_o2_cart_interface
+{
+public:
+ o2_chess_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+protected:
+ virtual void device_start() override;
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ virtual void cart_init() override;
+
+ virtual u8 read_rom04(offs_t offset) override { return m_rom[offset]; }
+ virtual u8 read_rom0c(offs_t offset) override { return m_rom[offset + 0x400]; }
+
+ virtual void write_p1(u8 data) override;
+ virtual void io_write(offs_t offset, u8 data) override;
+ virtual u8 io_read(offs_t offset) override;
+
+private:
+ required_device<cpu_device> m_maincpu;
+ required_device_array<generic_latch_8_device, 2> m_latch;
+
+ u8 m_control = 0;
+
+ u8 internal_rom_r(offs_t offset) { return m_exrom[offset]; }
+
+ void chess_io(address_map &map);
+ void chess_mem(address_map &map);
+};
+
o2_chess_device::o2_chess_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
device_t(mconfig, O2_ROM_CHESS, tag, owner, clock),
device_o2_cart_interface(mconfig, *this),
@@ -35,12 +67,40 @@ void o2_chess_device::device_start()
void o2_chess_device::cart_init()
{
- if (m_rom.bytes() != 0x800 || !m_exrom || m_exrom.bytes() != 0x2000)
+ if (m_rom_size != 0x800 || m_exrom_size != 0x2000)
fatalerror("o2_chess_device: Wrong ROM region size\n");
}
//-------------------------------------------------
+// mapper specific handlers
+//-------------------------------------------------
+
+void o2_chess_device::write_p1(u8 data)
+{
+ // P11: reset
+ m_maincpu->set_input_line(INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
+
+ // P10,P14: must be low to access latches
+ m_control = data;
+}
+
+u8 o2_chess_device::io_read(offs_t offset)
+{
+ if ((offset & 0xa0) == 0xa0 && (m_control & 0x11) == 0)
+ return m_latch[0]->read();
+ else
+ return 0xff;
+}
+
+void o2_chess_device::io_write(offs_t offset, u8 data)
+{
+ if (offset & 0x80 && (m_control & 0x11) == 0)
+ m_latch[1]->write(data);
+}
+
+
+//-------------------------------------------------
// address maps
//-------------------------------------------------
@@ -72,30 +132,7 @@ void o2_chess_device::device_add_mconfig(machine_config &config)
GENERIC_LATCH_8(config, m_latch[1]);
}
+} // anonymous namespace
-//-------------------------------------------------
-// mapper specific handlers
-//-------------------------------------------------
-
-void o2_chess_device::write_p1(u8 data)
-{
- // P11: reset
- m_maincpu->set_input_line(INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
- // P10,P14: must be low to access latches
- m_control = data;
-}
-
-u8 o2_chess_device::io_read(offs_t offset)
-{
- if ((offset & 0xa0) == 0xa0 && (m_control & 0x11) == 0)
- return m_latch[0]->read();
- else
- return 0xff;
-}
-
-void o2_chess_device::io_write(offs_t offset, u8 data)
-{
- if (offset & 0x80 && (m_control & 0x11) == 0)
- m_latch[1]->write(data);
-}
+DEFINE_DEVICE_TYPE_PRIVATE(O2_ROM_CHESS, device_o2_cart_interface, o2_chess_device, "o2_chess", "Videopac C7010 Cartridge")