summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar hap <happppp@users.noreply.github.com>2020-08-12 00:20:49 +0200
committerGravatarGravatar hap <happppp@users.noreply.github.com>2020-08-12 00:20:49 +0200
commit19f596c3adeb55b80b1399a6cc1b51c274320a1a (patch)
treeceb255753605e05120220c73a98c18987e12281d
parent9baaf195802b8e145f9bd5da5ba32b58906deddb (diff)
untangle bus/odyssey2/rom.cpp
-rw-r--r--hash/odyssey2.xml2
-rw-r--r--scripts/src/bus.lua6
-rw-r--r--src/devices/bus/odyssey2/4in1.cpp5
-rw-r--r--src/devices/bus/odyssey2/4in1.h4
-rw-r--r--src/devices/bus/odyssey2/chess.cpp3
-rw-r--r--src/devices/bus/odyssey2/chess.h4
-rw-r--r--src/devices/bus/odyssey2/ktaa.cpp52
-rw-r--r--src/devices/bus/odyssey2/ktaa.h45
-rw-r--r--src/devices/bus/odyssey2/rally.cpp3
-rw-r--r--src/devices/bus/odyssey2/rally.h4
-rw-r--r--src/devices/bus/odyssey2/rom.cpp80
-rw-r--r--src/devices/bus/odyssey2/rom.h50
-rw-r--r--src/devices/bus/odyssey2/slot.cpp27
-rw-r--r--src/devices/bus/odyssey2/slot.h3
-rw-r--r--src/devices/bus/odyssey2/voice.cpp3
-rw-r--r--src/devices/bus/odyssey2/voice.h4
16 files changed, 159 insertions, 136 deletions
diff --git a/hash/odyssey2.xml b/hash/odyssey2.xml
index 7927d291061..a865b226d2d 100644
--- a/hash/odyssey2.xml
+++ b/hash/odyssey2.xml
@@ -1851,7 +1851,7 @@ The C7010 Chess Module had a NSC800 CMOS microprocessor, with 2K RAM and 8K ROM.
<publisher>&lt;homebrew&gt;</publisher>
<info name="programmer" value="Soeren Gust" />
<part name="cart" interface="odyssey_cart">
- <feature name="slot" value="o2_rom12" />
+ <feature name="slot" value="o2_ktaa" />
<dataarea name="rom" size="12288">
<rom name="ktaa.bin" size="12288" crc="4e2cc6d3" sha1="42ad0c57bd16b7f24c242f60b5c0e9988d8dfba8" offset="0" />
</dataarea>
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index a5ad661c924..2704e17faf7 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -1694,10 +1694,12 @@ 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/ktaa.cpp",
+ MAME_DIR .. "src/devices/bus/odyssey2/ktaa.h",
+ MAME_DIR .. "src/devices/bus/odyssey2/rally.cpp",
+ MAME_DIR .. "src/devices/bus/odyssey2/rally.h",
MAME_DIR .. "src/devices/bus/odyssey2/voice.cpp",
MAME_DIR .. "src/devices/bus/odyssey2/voice.h",
}
diff --git a/src/devices/bus/odyssey2/4in1.cpp b/src/devices/bus/odyssey2/4in1.cpp
index d458347c076..17259589979 100644
--- a/src/devices/bus/odyssey2/4in1.cpp
+++ b/src/devices/bus/odyssey2/4in1.cpp
@@ -23,7 +23,8 @@ DEFINE_DEVICE_TYPE(O2_ROM_4IN1, o2_4in1_device, "o2_4in1", "Odyssey 2 Videopac 4
//-------------------------------------------------
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)
+ device_t(mconfig, O2_ROM_4IN1, tag, owner, clock),
+ device_o2_cart_interface(mconfig, *this)
{ }
void o2_4in1_device::device_start()
@@ -35,7 +36,7 @@ void o2_4in1_device::device_start()
void o2_4in1_device::cart_init()
{
if (m_rom_size != 0x1000)
- fatalerror("o2_4in1_device: ROM size must be 4096\n");
+ fatalerror("o2_4in1_device: ROM size must be 4KB\n");
}
diff --git a/src/devices/bus/odyssey2/4in1.h b/src/devices/bus/odyssey2/4in1.h
index c9a6ed78b2a..09cfa626b38 100644
--- a/src/devices/bus/odyssey2/4in1.h
+++ b/src/devices/bus/odyssey2/4in1.h
@@ -12,12 +12,12 @@
#pragma once
#include "slot.h"
-#include "rom.h"
// ======================> o2_4in1_device
-class o2_4in1_device : public o2_rom_device
+class o2_4in1_device : public device_t,
+ public device_o2_cart_interface
{
public:
// construction/destruction
diff --git a/src/devices/bus/odyssey2/chess.cpp b/src/devices/bus/odyssey2/chess.cpp
index ec058b9cf48..67dbfe0bd4d 100644
--- a/src/devices/bus/odyssey2/chess.cpp
+++ b/src/devices/bus/odyssey2/chess.cpp
@@ -24,7 +24,8 @@ DEFINE_DEVICE_TYPE(O2_ROM_CHESS, o2_chess_device, "o2_chess", "Odyssey 2 Videopa
//-------------------------------------------------
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),
+ device_t(mconfig, O2_ROM_CHESS, tag, owner, clock),
+ device_o2_cart_interface(mconfig, *this),
m_cpu(*this, "subcpu"),
m_latch(*this, "latch%u", 0)
{ }
diff --git a/src/devices/bus/odyssey2/chess.h b/src/devices/bus/odyssey2/chess.h
index 291f97e9b9d..4ebc81886af 100644
--- a/src/devices/bus/odyssey2/chess.h
+++ b/src/devices/bus/odyssey2/chess.h
@@ -12,14 +12,14 @@
#pragma once
#include "slot.h"
-#include "rom.h"
#include "cpu/z80/z80.h"
#include "machine/gen_latch.h"
// ======================> o2_chess_device
-class o2_chess_device : public o2_rom_device
+class o2_chess_device : public device_t,
+ public device_o2_cart_interface
{
public:
// construction/destruction
diff --git a/src/devices/bus/odyssey2/ktaa.cpp b/src/devices/bus/odyssey2/ktaa.cpp
new file mode 100644
index 00000000000..e898f1c1282
--- /dev/null
+++ b/src/devices/bus/odyssey2/ktaa.cpp
@@ -0,0 +1,52 @@
+// license:BSD-3-Clause
+// copyright-holders:Wilbert Pol, Fabio Priuli, hap
+/******************************************************************************
+
+Homebrew KTAA(Kill the Attacking Aliens) cartridge emulation
+
+Bankswitched ROM with page size of 3KB.
+
+******************************************************************************/
+
+#include "emu.h"
+#include "ktaa.h"
+
+DEFINE_DEVICE_TYPE(O2_ROM_KTAA, o2_ktaa_device, "o2_ktaa", "Odyssey 2 Homebrew KTAA")
+
+
+//-------------------------------------------------
+// o2_ktaa_device - constructor
+//-------------------------------------------------
+
+o2_ktaa_device::o2_ktaa_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, O2_ROM_KTAA, tag, owner, clock),
+ device_o2_cart_interface(mconfig, *this)
+{ }
+
+void o2_ktaa_device::device_start()
+{
+ save_item(NAME(m_bank));
+}
+
+void o2_ktaa_device::cart_init()
+{
+ if (m_rom_size != 0xc00 && m_rom_size != 0xc00*2 && m_rom_size != 0xc00*4)
+ fatalerror("o2_ktaa_device: ROM size must be multiple of 3KB\n");
+
+ m_bank_mask = (m_rom_size / 0xc00) - 1;
+}
+
+
+//-------------------------------------------------
+// mapper specific handlers
+//-------------------------------------------------
+
+u8 o2_ktaa_device::read_rom04(offs_t offset)
+{
+ return m_rom[offset + m_bank * 0xc00];
+}
+
+u8 o2_ktaa_device::read_rom0c(offs_t offset)
+{
+ return m_rom[offset + 0x800 + m_bank * 0xc00];
+}
diff --git a/src/devices/bus/odyssey2/ktaa.h b/src/devices/bus/odyssey2/ktaa.h
new file mode 100644
index 00000000000..e1ac477e445
--- /dev/null
+++ b/src/devices/bus/odyssey2/ktaa.h
@@ -0,0 +1,45 @@
+// license:BSD-3-Clause
+// copyright-holders:Wilbert Pol, Fabio Priuli, hap
+/**********************************************************************
+
+ Homebrew KTAA cartridge emulation
+
+**********************************************************************/
+
+#ifndef MAME_BUS_ODYSSEY2_KTAA_H
+#define MAME_BUS_ODYSSEY2_KTAA_H
+
+#pragma once
+
+#include "slot.h"
+
+
+// ======================> o2_ktaa_device
+
+class o2_ktaa_device : public device_t,
+ public device_o2_cart_interface
+{
+public:
+ // construction/destruction
+ o2_ktaa_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;
+
+ virtual void write_p1(u8 data) override { m_bank = data & m_bank_mask; }
+
+private:
+ u8 m_bank_mask = 0;
+ u8 m_bank = 0;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(O2_ROM_KTAA, o2_ktaa_device)
+
+#endif // MAME_BUS_ODYSSEY2_KTAA_H
diff --git a/src/devices/bus/odyssey2/rally.cpp b/src/devices/bus/odyssey2/rally.cpp
index e965d49b1c8..e2ab2fe31e2 100644
--- a/src/devices/bus/odyssey2/rally.cpp
+++ b/src/devices/bus/odyssey2/rally.cpp
@@ -25,7 +25,8 @@ DEFINE_DEVICE_TYPE(O2_ROM_RALLY, o2_rally_device, "o2_rally", "Odyssey 2 Videopa
//-------------------------------------------------
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)
+ device_t(mconfig, O2_ROM_RALLY, tag, owner, clock),
+ device_o2_cart_interface(mconfig, *this)
{ }
void o2_rally_device::device_start()
diff --git a/src/devices/bus/odyssey2/rally.h b/src/devices/bus/odyssey2/rally.h
index 580d3f1df63..13021a3a317 100644
--- a/src/devices/bus/odyssey2/rally.h
+++ b/src/devices/bus/odyssey2/rally.h
@@ -12,12 +12,12 @@
#pragma once
#include "slot.h"
-#include "rom.h"
// ======================> o2_rally_device
-class o2_rally_device : public o2_rom_device
+class o2_rally_device : public device_t,
+ public device_o2_cart_interface
{
public:
// construction/destruction
diff --git a/src/devices/bus/odyssey2/rom.cpp b/src/devices/bus/odyssey2/rom.cpp
index 2db336ed247..04e83a7d55a 100644
--- a/src/devices/bus/odyssey2/rom.cpp
+++ b/src/devices/bus/odyssey2/rom.cpp
@@ -1,87 +1,43 @@
// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol, Fabio Priuli
-/***********************************************************************************************************
+// copyright-holders:Wilbert Pol, Fabio Priuli, hap
+/******************************************************************************
+Standard cartridges emulation, optionally bankswitched up to 8KB.
- Magnavox Odyssey cart emulation
-
-
- ***********************************************************************************************************/
-
+******************************************************************************/
#include "emu.h"
#include "rom.h"
+DEFINE_DEVICE_TYPE(O2_ROM_STD, o2_rom_device, "o2_rom", "Odyssey 2 Standard Carts")
+
//-------------------------------------------------
// o2_rom_device - constructor
//-------------------------------------------------
-DEFINE_DEVICE_TYPE(O2_ROM_STD, o2_rom_device, "o2_rom", "Odyssey 2 Standard Carts")
-DEFINE_DEVICE_TYPE(O2_ROM_12K, o2_rom12_device, "o2_rom12", "Odyssey 2 12K Carts")
-DEFINE_DEVICE_TYPE(O2_ROM_16K, o2_rom16_device, "o2_rom16", "Odyssey 2 16K Carts")
-
-
-o2_rom_device::o2_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
- : device_t(mconfig, type, tag, owner, clock)
- , device_o2_cart_interface(mconfig, *this)
- , m_bank_base(0)
-{
-}
+o2_rom_device::o2_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, O2_ROM_STD, tag, owner, clock),
+ device_o2_cart_interface(mconfig, *this)
+{ }
-o2_rom_device::o2_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : o2_rom_device(mconfig, O2_ROM_STD, tag, owner, clock)
-{
-}
-
-o2_rom12_device::o2_rom12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : o2_rom_device(mconfig, O2_ROM_12K, tag, owner, clock)
+void o2_rom_device::device_start()
{
+ save_item(NAME(m_bank));
}
-o2_rom16_device::o2_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
- : o2_rom_device(mconfig, O2_ROM_16K, tag, owner, clock)
+void o2_rom_device::cart_init()
{
+ m_cart_mask = (1 << (31 - count_leading_zeros(m_rom_size))) - 1;
}
//-------------------------------------------------
-// device_start/device_reset - device-specific startup
+// mapper specific handlers
//-------------------------------------------------
-void o2_rom_device::device_start()
-{
- save_item(NAME(m_bank_base));
-}
-
-
-/*-------------------------------------------------
- mapper specific handlers
- -------------------------------------------------*/
-
-uint8_t o2_rom_device::read_rom04(offs_t offset)
-{
- return m_rom[(offset + (m_bank_base & 0x03) * 0x800) & (m_rom_size - 1)];
-}
-uint8_t o2_rom_device::read_rom0c(offs_t offset)
-{
- return m_rom[(offset + (m_bank_base & 0x03) * 0x800) & (m_rom_size - 1)];
-}
-
-uint8_t o2_rom12_device::read_rom04(offs_t offset)
-{
- return m_rom[offset + (m_bank_base & 0x03) * 0xc00];
-}
-uint8_t o2_rom12_device::read_rom0c(offs_t offset)
-{
- return m_rom[offset + 0x800 + (m_bank_base & 0x03) * 0xc00];
-}
-
-uint8_t o2_rom16_device::read_rom04(offs_t offset)
-{
- return m_rom[offset + 0x400 + (m_bank_base & 0x03) * 0x1000];
-}
-uint8_t o2_rom16_device::read_rom0c(offs_t offset)
+u8 o2_rom_device::read_rom04(offs_t offset)
{
- return m_rom[offset + 0xc00 + (m_bank_base & 0x03) * 0x1000];
+ offset = (offset + m_bank * 0x800) & m_cart_mask;
+ return (offset < m_rom_size) ? m_rom[offset] : 0xff;
}
diff --git a/src/devices/bus/odyssey2/rom.h b/src/devices/bus/odyssey2/rom.h
index 541a81ef742..74e742a38d8 100644
--- a/src/devices/bus/odyssey2/rom.h
+++ b/src/devices/bus/odyssey2/rom.h
@@ -1,5 +1,11 @@
// license:BSD-3-Clause
-// copyright-holders:Wilbert Pol, Fabio Priuli
+// copyright-holders:Wilbert Pol, Fabio Priuli, hap
+/**********************************************************************
+
+ Standard cartridges emulation
+
+**********************************************************************/
+
#ifndef MAME_BUS_ODYSSEY2_ROM_H
#define MAME_BUS_ODYSSEY2_ROM_H
@@ -17,51 +23,23 @@ public:
// construction/destruction
o2_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- // reading and writing
- virtual uint8_t read_rom04(offs_t offset) override;
- virtual uint8_t read_rom0c(offs_t offset) override;
-
- virtual void write_p1(uint8_t data) override { m_bank_base = data & 3; }
-
protected:
- o2_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
-
// device-level overrides
virtual void device_start() override;
- int m_bank_base;
-};
-
-// ======================> o2_rom12_device
-
-class o2_rom12_device : public o2_rom_device
-{
-public:
- // construction/destruction
- o2_rom12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ virtual void cart_init() override;
- // reading and writing
- virtual uint8_t read_rom04(offs_t offset) override;
- virtual uint8_t read_rom0c(offs_t offset) override;
-};
+ virtual u8 read_rom04(offs_t offset) override;
+ virtual u8 read_rom0c(offs_t offset) override { return read_rom04(offset); }
-// ======================> o2_rom16_device
+ virtual void write_p1(u8 data) override { m_bank = data & 3; }
-class o2_rom16_device : public o2_rom_device
-{
-public:
- // construction/destruction
- o2_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- // reading and writing
- virtual uint8_t read_rom04(offs_t offset) override;
- virtual uint8_t read_rom0c(offs_t offset) override;
+private:
+ u32 m_cart_mask = 0;
+ u8 m_bank = 0;
};
-
// device type definition
DECLARE_DEVICE_TYPE(O2_ROM_STD, o2_rom_device)
-DECLARE_DEVICE_TYPE(O2_ROM_12K, o2_rom12_device)
-DECLARE_DEVICE_TYPE(O2_ROM_16K, o2_rom16_device)
#endif // MAME_BUS_ODYSSEY2_ROM_H
diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp
index 8f5a0fee6d0..ab97e4d7679 100644
--- a/src/devices/bus/odyssey2/slot.cpp
+++ b/src/devices/bus/odyssey2/slot.cpp
@@ -114,10 +114,9 @@ struct o2_slot
static const o2_slot slot_list[] =
{
{ O2_STD, "o2_rom" },
- { O2_ROM12, "o2_rom12" },
- { O2_ROM16, "o2_rom16" },
{ O2_4IN1, "o2_4in1" },
{ O2_RALLY, "o2_rally" },
+ { O2_KTAA, "o2_ktaa" },
{ O2_CHESS, "o2_chess" },
{ O2_VOICE, "o2_voice" }
};
@@ -161,20 +160,14 @@ image_init_result o2_cart_slot_device::call_load()
else
memcpy(m_cart->get_rom_base(), get_software_region("rom"), size);
- if (!loaded_through_softlist())
- {
- m_type = O2_STD;
- if (size == 12288)
- m_type = O2_ROM12;
- if (size == 16384)
- m_type = O2_ROM16;
- }
- else
+ if (loaded_through_softlist())
{
const char *pcb_name = get_feature("slot");
if (pcb_name)
m_type = o2_get_pcb_id(pcb_name);
}
+ else
+ m_type = (size == 16384) ? O2_RALLY : O2_STD;
m_cart->cart_init();
@@ -195,13 +188,7 @@ std::string o2_cart_slot_device::get_default_card_software(get_default_card_soft
{
const char *slot_string;
uint32_t size = hook.image_file()->size();
- int type = O2_STD;
-
- if (size == 12288)
- type = O2_ROM12;
- if (size == 16384)
- type = O2_ROM16;
-
+ int type = (size == 16384) ? O2_RALLY : O2_STD;
slot_string = o2_get_slot(type);
//printf("type: %s\n", slot_string);
@@ -254,16 +241,16 @@ 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/ktaa.h"
#include "bus/odyssey2/chess.h"
#include "bus/odyssey2/voice.h"
void o2_cart(device_slot_interface &device)
{
device.option_add_internal("o2_rom", O2_ROM_STD);
- 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_ktaa", O2_ROM_KTAA);
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 c9192a8e17f..2e0d847e642 100644
--- a/src/devices/bus/odyssey2/slot.h
+++ b/src/devices/bus/odyssey2/slot.h
@@ -17,10 +17,9 @@
enum
{
O2_STD = 0,
- O2_ROM12,
- O2_ROM16,
O2_4IN1,
O2_RALLY,
+ O2_KTAA,
O2_CHESS,
O2_VOICE
};
diff --git a/src/devices/bus/odyssey2/voice.cpp b/src/devices/bus/odyssey2/voice.cpp
index b23a8abf8a0..e458043d4c4 100644
--- a/src/devices/bus/odyssey2/voice.cpp
+++ b/src/devices/bus/odyssey2/voice.cpp
@@ -21,7 +21,8 @@ DEFINE_DEVICE_TYPE(O2_ROM_VOICE, o2_voice_device, "o2_voice", "Odyssey 2 The Voi
//-------------------------------------------------
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),
+ device_t(mconfig, O2_ROM_VOICE, tag, owner, clock),
+ device_o2_cart_interface(mconfig, *this),
m_speech(*this, "sp0256_speech"),
m_subslot(*this, "subslot")
{ }
diff --git a/src/devices/bus/odyssey2/voice.h b/src/devices/bus/odyssey2/voice.h
index 65caab93d8d..981eddeb1dd 100644
--- a/src/devices/bus/odyssey2/voice.h
+++ b/src/devices/bus/odyssey2/voice.h
@@ -12,13 +12,13 @@
#pragma once
#include "slot.h"
-#include "rom.h"
#include "sound/sp0256.h"
// ======================> o2_voice_device
-class o2_voice_device : public o2_rom_device
+class o2_voice_device : public device_t,
+ public device_o2_cart_interface
{
public:
// construction/destruction