summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author David Haywood <davidhaywood@users.noreply.github.com>2017-10-20 01:43:09 +0100
committer Vas Crabb <cuavas@users.noreply.github.com>2017-10-20 12:14:23 +1100
commitb8feed79290f0a6e347416db31f6dc0e765fc244 (patch)
tree52c548d0a2079f1ed46f1e4761315715dcbac4b1
parent3cfd826defe785deaff78daa01c7c53514658bde (diff)
use slot device for gamate cartridge slot, do protection handling there (it's a mapper chip in the cartridge)
protection handled etc. written from scratch based on notes from Kevtris and Peter banking in the slot system seems somewhat archaic compared to proper modern banking, but this is how all other drivers I saw using slot roms did it.
-rw-r--r--hash/gamate.xml76
-rw-r--r--scripts/src/bus.lua17
-rw-r--r--scripts/target/mame/mess.lua1
-rw-r--r--src/devices/bus/gamate/gamate_protection.cpp113
-rw-r--r--src/devices/bus/gamate/gamate_protection.h39
-rw-r--r--src/devices/bus/gamate/rom.cpp184
-rw-r--r--src/devices/bus/gamate/rom.h86
-rw-r--r--src/devices/bus/gamate/slot.cpp248
-rw-r--r--src/devices/bus/gamate/slot.h104
-rw-r--r--src/mame/drivers/gamate.cpp169
10 files changed, 893 insertions, 144 deletions
diff --git a/hash/gamate.xml b/hash/gamate.xml
index 18e0f75995e..1fd1c058fb6 100644
--- a/hash/gamate.xml
+++ b/hash/gamate.xml
@@ -111,6 +111,7 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1008" />
<part name="cart" interface="gamate_cart">
+ <feature name="slot" value="banked" />
<dataarea name="rom" size="65536">
<rom name="c1-008.bin" size="65536" crc="a67ba296" sha1="d01988984e2950fde8096a0156808995a0e5c515" offset="0" />
</dataarea>
@@ -195,7 +196,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1016" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="131072">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="131072">
<rom name="c1-016.bin" size="131072" crc="1c2921df" sha1="958f4936f3aa8db5e76d315ee6acc6aee0e010b4" offset="0" />
</dataarea>
</part>
@@ -376,7 +378,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1033" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-033.bin" size="65536" crc="9002269d" sha1="899d1592f0da06f9684cb271ec34541c702f21ab" offset="0" />
</dataarea>
</part>
@@ -424,7 +427,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1038" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-038.bin" size="65536" crc="19bba397" sha1="01163f89447c68554cd2fe60b22dea7b578f1605" offset="0" />
</dataarea>
</part>
@@ -436,7 +440,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1042" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-042.bin" size="65536" crc="8363c32d" sha1="b07681e28b65af53fed23def3f6305ab929bb8f1" offset="0" />
</dataarea>
</part>
@@ -472,7 +477,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1045" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-045.bin" size="65536" crc="c165094f" sha1="148bd0e461d8f967b483136460a770820d2e7226" offset="0" />
</dataarea>
</part>
@@ -484,7 +490,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1046" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-046.bin" size="65536" crc="e492ef8e" sha1="fa2b9666c9c1090573c40cafa273c9ff5c1787be" offset="0" />
</dataarea>
</part>
@@ -496,7 +503,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1047" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="131072">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="131072">
<rom name="c1-047.bin" size="131072" crc="39660803" sha1="8719418a6b30c2cc9d013d35d1baacde86016da3" offset="0" />
</dataarea>
</part>
@@ -508,7 +516,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1048" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-048.bin" size="65536" crc="daf715c5" sha1="f10e180c4aac41e9c710ce38ca9a93ca6f331f57" offset="0" />
</dataarea>
</part>
@@ -520,7 +529,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1049" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-049.bin" size="65536" crc="aa2e0d32" sha1="1b3082be0698c12c8fc978db6a0c63c8958c33f8" offset="0" />
</dataarea>
</part>
@@ -532,7 +542,8 @@ C1066 - ??
<publisher>United Microelectronics Corporation</publisher>
<info name="serial" value="C1052" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="65536">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="65536">
<rom name="c1-052.bin" size="65536" crc="0fa48c23" sha1="ea422fe969b260296b99397cdeff6ae053ac4a86" offset="0" />
</dataarea>
</part>
@@ -544,7 +555,8 @@ C1066 - ??
<publisher>United Microelectronics Corporation</publisher>
<info name="serial" value="C1053" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="131072">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="131072">
<rom name="c1-053.bin" size="131072" crc="727299c7" sha1="5515f7dc5a00fa38677c4ac5b73af232008f3e51" offset="0" />
</dataarea>
</part>
@@ -568,7 +580,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1056" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="131072">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="131072">
<rom name="c1-056.bin" size="131072" crc="447595e4" sha1="1b471f8ac8ffb107c62ec3b765c43e268d90b73a" offset="0" />
</dataarea>
</part>
@@ -580,7 +593,8 @@ C1066 - ??
<publisher>United Microelectronics Corporation</publisher>
<info name="serial" value="C1057" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="131072">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="131072">
<rom name="c1-057.bin" size="131072" crc="a542c61f" sha1="2eccf1fe8d400a54ffb2f026af8b9842442b6d9f" offset="0" />
</dataarea>
</part>
@@ -592,7 +606,8 @@ C1066 - ??
<publisher>United Microelectronics Corporation</publisher>
<info name="serial" value="C1058" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="262144">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="262144">
<rom name="c1-058.bin" size="262144" crc="16a79cd8" sha1="7d638bf61286adfa612de974efff2d9b5b4b3331" offset="0" />
</dataarea>
</part>
@@ -604,7 +619,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1060" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-060.bin" size="524288" crc="9aa13551" sha1="a1163f1da52e23bda0502f229488a5b4d04bbe8a" offset="0" />
</dataarea>
</part>
@@ -617,7 +633,8 @@ C1066 - ??
<info name="serial" value="C1061" />
<part name="cart" interface="gamate_cart">
<dataarea name="rom" size="524288">
- <rom name="c1-061.bin" size="524288" crc="00356983" sha1="e93c671ee1eb40bb4d7298671dc213a07afef9e0" offset="0" />
+ <feature name="slot" value="banked" />
+ <rom name="c1-061.bin" size="524288" crc="00356983" sha1="e93c671ee1eb40bb4d7298671dc213a07afef9e0" offset="0" />
</dataarea>
</part>
</software>
@@ -628,7 +645,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1063" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="262144">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="262144">
<rom name="c1-063.bin" size="262144" crc="93d5f365" sha1="91b9b9060b76d2012d5cbc6523839f67caa37aaf" offset="0" />
</dataarea>
</part>
@@ -640,7 +658,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1064" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-064.bin" size="524288" crc="8574f0eb" sha1="ba42622b9ff4b2fa0cb70f322ee24b1d8c387222" offset="0" />
</dataarea>
</part>
@@ -652,7 +671,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1065" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-065.bin" size="524288" crc="1ed9d0a3" sha1="568f87864c0ed6117fe34e3f79e56c01e911e482" offset="0" />
</dataarea>
</part>
@@ -664,7 +684,8 @@ C1066 - ??
<publisher>Phinnex Co., Ltd.</publisher>
<info name="serial" value="C1067" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-067.bin" size="524288" crc="76e26b63" sha1="bfb2f4b5b771277333ffc1e27cf3a5608e9ea163" offset="0" />
</dataarea>
</part>
@@ -676,7 +697,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1068" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-068.bin" size="524288" crc="96386b08" sha1="69909b78598184760b3e261da897a9bc90af9dfb" offset="0" />
</dataarea>
</part>
@@ -688,7 +710,8 @@ C1066 - ??
<publisher>Unknown</publisher>
<info name="serial" value="C1069" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-069.bin" size="524288" crc="3bceb859" sha1="32187903c10dc80d62e9bf794b912921542d6d38" offset="0" />
</dataarea>
</part>
@@ -700,7 +723,8 @@ C1066 - ??
<publisher>United Microelectronics Corporation</publisher>
<info name="serial" value="C1070" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="c1-070.bin" size="524288" crc="7ba8af6d" sha1="6aa0364010272c82c7cc8c7afd60254de148fa72" offset="0" />
</dataarea>
</part>
@@ -712,7 +736,8 @@ C1066 - ??
<publisher>Bit Corporation</publisher>
<info name="serial" value="C1401" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="131072">
+ <feature name="slot" value="4in1" />
+ <dataarea name="rom" size="131072">
<rom name="c1-401.bin" size="131072" crc="10e81571" sha1="4dd20632eb31023e18241290eca7d5a5acb1fa84" offset="0" />
</dataarea>
</part>
@@ -724,7 +749,8 @@ C1066 - ??
<publisher>United Microelectronics Corporation</publisher>
<info name="serial" value="K1001" />
<part name="cart" interface="gamate_cart">
- <dataarea name="rom" size="524288">
+ <feature name="slot" value="banked" />
+ <dataarea name="rom" size="524288">
<rom name="k1-001.bin" size="524288" crc="ebb46efe" sha1="beae4f3365031f4e8ae192a5e6d27a28979ef84b" offset="0" />
</dataarea>
</part>
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index 65bd0e0de03..29605ec7213 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -739,6 +739,23 @@ end
---------------------------------------------------
--
+--@src/devices/bus/gamate/slot.h,BUSES["GAMATE"] = true
+---------------------------------------------------
+
+if (BUSES["GAMATE"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/bus/gamate/slot.cpp",
+ MAME_DIR .. "src/devices/bus/gamate/slot.h",
+ MAME_DIR .. "src/devices/bus/gamate/rom.cpp",
+ MAME_DIR .. "src/devices/bus/gamate/rom.h",
+ MAME_DIR .. "src/devices/bus/gamate/gamate_protection.cpp",
+ MAME_DIR .. "src/devices/bus/gamate/gamate_protection.h",
+ }
+end
+
+
+---------------------------------------------------
+--
--@src/devices/bus/hp_hil/hp_hil.h,BUSES["HPHIL"] = true
---------------------------------------------------
diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua
index dc9d42af3aa..916c4be6903 100644
--- a/scripts/target/mame/mess.lua
+++ b/scripts/target/mame/mess.lua
@@ -664,6 +664,7 @@ BUSES["ECONET"] = true
BUSES["ELECTRON"] = true
BUSES["EP64"] = true
BUSES["EPSON_SIO"] = true
+BUSES["GAMATE"] = true
BUSES["GAMEBOY"] = true
BUSES["GAMEGEAR"] = true
BUSES["GBA"] = true
diff --git a/src/devices/bus/gamate/gamate_protection.cpp b/src/devices/bus/gamate/gamate_protection.cpp
new file mode 100644
index 00000000000..d3c257c53fa
--- /dev/null
+++ b/src/devices/bus/gamate/gamate_protection.cpp
@@ -0,0 +1,113 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+
+#include "emu.h"
+#include "gamate_protection.h"
+
+DEFINE_DEVICE_TYPE(GAMATE_PROT, gamate_protection_device, "gamate_prot", "Gamate Protection Mapper")
+
+gamate_protection_device::gamate_protection_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, GAMATE_PROT, tag, owner, clock),
+ m_is_protection_passed(0),
+ m_has_failed(0),
+ m_passed_write(0),
+ m_inpos(0),
+ m_inbyte(0),
+ m_inseq(0)
+{
+}
+
+void gamate_protection_device::device_start()
+{
+ save_item(NAME(m_is_protection_passed));
+ save_item(NAME(m_has_failed));
+ save_item(NAME(m_passed_write));
+ save_item(NAME(m_inpos));
+ save_item(NAME(m_inbyte));
+ save_item(NAME(m_inseq));
+}
+
+void gamate_protection_device::device_reset()
+{
+ m_is_protection_passed = 0;
+ m_has_failed = 0;
+ m_passed_write = 0;
+ m_inpos = 0;
+ m_inbyte = 0;
+ m_inseq = 0;
+}
+
+bool gamate_protection_device::is_protection_passed()
+{
+ return m_is_protection_passed;
+}
+
+WRITE_LINE_MEMBER(gamate_protection_device::prot_w)
+{
+ logerror("write to protection %01x\n", state);
+
+ if (m_inpos < 8)
+ {
+ m_inbyte |= state << (7 - m_inpos);
+ m_inpos++;
+ }
+ else
+ {
+ logerror("byte in was %c\n", m_inbyte);
+
+ if (!m_has_failed)
+ {
+ if (m_inseq < 15)
+ {
+ if (m_inbyte == m_prot_string[m_inseq])
+ {
+ logerror("OK\n");
+ }
+ else
+ {
+ m_has_failed = 1;
+ }
+ }
+ }
+
+ m_inpos = 0;
+ m_inbyte = 0;
+
+ m_inseq++;
+
+ if (!m_has_failed && m_inseq == 15)
+ {
+ m_inbyte = 0x47;
+ logerror("setting byte to output\n");
+ m_passed_write = 1;
+ }
+ }
+}
+
+READ_LINE_MEMBER(gamate_protection_device::prot_r)
+{
+
+ if (m_passed_write)
+ {
+ int retval = (m_inbyte >> (7 - m_inpos)) & 1;
+ m_inpos++;
+
+ logerror("read from protection %01x\n", retval);
+
+ if (m_inpos == 8)
+ {
+ logerror("unlocking ROM\n");
+ m_is_protection_passed = 1;
+ m_inpos = 0;
+ m_inbyte = 0;
+ }
+
+ return retval;
+ }
+ else
+ {
+ logerror("read from protection when not ready\n");
+ }
+
+ return 0x0;
+}
diff --git a/src/devices/bus/gamate/gamate_protection.h b/src/devices/bus/gamate/gamate_protection.h
new file mode 100644
index 00000000000..006307af344
--- /dev/null
+++ b/src/devices/bus/gamate/gamate_protection.h
@@ -0,0 +1,39 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+
+#ifndef MAME_BUS_GAMATE_PROTECTION_H
+#define MAME_BUS_GAMATE_PROTECTION_H
+
+#pragma once
+
+DECLARE_DEVICE_TYPE(GAMATE_PROT, gamate_protection_device)
+
+class gamate_protection_device : public device_t
+{
+public:
+ // construction/destruction
+ gamate_protection_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ bool is_protection_passed();
+
+ DECLARE_WRITE_LINE_MEMBER( prot_w );
+ DECLARE_READ_LINE_MEMBER( prot_r );
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ int m_is_protection_passed;
+ int m_has_failed;
+ int m_passed_write;
+ int m_inpos;
+ uint8_t m_inbyte;
+ uint8_t m_inseq;
+
+ // this string is contained within the protection mapper, you must write it to unlock the cartridge
+ const uint8_t m_prot_string[15] = { 0x42, 0x49, 0x54, 0x20, 0x43, 0x4F, 0x52, 0x50, 0x4F, 0x52, 0x41, 0x54, 0x49, 0x4F, 0x4E }; // "BIT CORPORATION"
+};
+
+#endif // MAME_BUS_GAMATE_PROTECTION_H
+
diff --git a/src/devices/bus/gamate/rom.cpp b/src/devices/bus/gamate/rom.cpp
new file mode 100644
index 00000000000..59a70b3a9a9
--- /dev/null
+++ b/src/devices/bus/gamate/rom.cpp
@@ -0,0 +1,184 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+
+// this assumes that the regular banked carts don't also have the 4-in-1 logic.
+
+#include "emu.h"
+#include "rom.h"
+
+//-------------------------------------------------
+// gamate_rom_device - constructor
+//-------------------------------------------------
+
+DEFINE_DEVICE_TYPE(GAMATE_ROM_PLAIN, gamate_rom_plain_device, "gamate_rom_plain", "GAMATE Cartridge")
+DEFINE_DEVICE_TYPE(GAMATE_ROM_BANKED, gamate_rom_banked_device, "gamate_rom_banked", "GAMATE Cartridge with banking")
+DEFINE_DEVICE_TYPE(GAMATE_ROM_4IN1, gamate_rom_4in1_device, "gamate_rom_4in1", "GAMATE 4-in-1 Cartridge")
+
+
+gamate_rom_plain_device::gamate_rom_plain_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_gamate_cart_interface(mconfig, *this),
+ m_protection(*this, "protection")
+{
+}
+
+gamate_rom_plain_device::gamate_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ gamate_rom_plain_device(mconfig, GAMATE_ROM_PLAIN, tag, owner, clock)
+{
+}
+
+gamate_rom_banked_device::gamate_rom_banked_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ gamate_rom_plain_device(mconfig, GAMATE_ROM_BANKED, tag, owner, clock),
+ m_bank(0)
+{
+}
+
+gamate_rom_banked_device::gamate_rom_banked_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+ gamate_rom_plain_device(mconfig, type, tag, owner, clock),
+ m_bank(0)
+{
+}
+
+
+gamate_rom_4in1_device::gamate_rom_4in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ gamate_rom_banked_device(mconfig, GAMATE_ROM_4IN1, tag, owner, clock),
+ m_multibank(0)
+{
+}
+
+//-------------------------------------------------
+// mapper specific start/reset
+//-------------------------------------------------
+
+void gamate_rom_banked_device::device_start()
+{
+ save_item(NAME(m_bank));
+}
+
+void gamate_rom_4in1_device::device_start()
+{
+ gamate_rom_banked_device::device_start();
+ save_item(NAME(m_multibank));
+}
+
+
+void gamate_rom_banked_device::device_reset()
+{
+ m_bank = 0;
+}
+
+void gamate_rom_4in1_device::device_reset()
+{
+ gamate_rom_banked_device::device_reset();
+ m_multibank = 0;
+}
+
+/*-------------------------------------------------
+ mapper specific handlers
+ -------------------------------------------------*/
+
+
+READ8_MEMBER(gamate_rom_plain_device::read_cart)
+{
+ if (m_protection->is_protection_passed())
+ {
+ return read_rom(space, offset, mem_mask);
+ }
+ else
+ {
+ return m_protection->prot_r() << 1;
+ }
+
+ return 0xff;
+}
+
+READ8_MEMBER(gamate_rom_plain_device::read_rom)
+{
+ return m_rom[offset & (m_rom_size-1)];
+}
+
+READ8_MEMBER(gamate_rom_banked_device::read_rom)
+{
+ if (offset < 0x4000)
+ {
+ return m_rom[offset & (m_rom_size - 1)];
+ }
+ else
+ {
+ return m_rom[((m_bank * 0x4000) + (offset & 0x3fff)) & (m_rom_size - 1)];
+ }
+
+ return 0xff;
+}
+
+READ8_MEMBER(gamate_rom_4in1_device::read_rom)
+{
+ if (offset < 0x4000)
+ {
+ return m_rom[((m_multibank * 0x4000) + (offset & 0x3fff)) & (m_rom_size - 1)];
+ }
+ else
+ {
+ return m_rom[((m_bank * 0x4000) + (offset & 0x3fff)) & (m_rom_size - 1)];
+ }
+}
+
+WRITE8_MEMBER(gamate_rom_plain_device::write_cart)
+{
+ if (m_protection->is_protection_passed())
+ {
+ write_rom(space, offset, data, mem_mask);
+ }
+ else
+ {
+ m_protection->prot_w((data & 0x04) >> 2);
+ }
+}
+
+WRITE8_MEMBER(gamate_rom_plain_device::write_rom)
+{
+ // shouldn't be any write on an unbanked game
+ logerror("gamate_rom_plain_device::write_rom %04x %02x\n", offset, data);
+}
+
+WRITE8_MEMBER(gamate_rom_banked_device::write_rom)
+{
+ if (offset == 0x6000)
+ {
+ m_bank = data;
+ }
+ else
+ {
+ logerror("gamate_rom_banked_device::write_rom %04x %02x\n", offset, data);
+ }
+}
+
+WRITE8_MEMBER(gamate_rom_4in1_device::write_rom)
+{
+ if (offset == 0x2000)
+ {
+ m_multibank = data;
+ }
+ else if (offset == 0x6000)
+ {
+ m_bank = data;
+ }
+ else
+ {
+ logerror("gamate_rom_4in1_device::write_rom %04x %02x\n", offset, data);
+ }
+}
+
+MACHINE_CONFIG_MEMBER( gamate_rom_plain_device::device_add_mconfig )
+ MCFG_DEVICE_ADD("protection", GAMATE_PROT, 0)
+MACHINE_CONFIG_END
+
+
+/*-------------------------------------------------
+ slot interface
+ -------------------------------------------------*/
+
+SLOT_INTERFACE_START(gamate_cart)
+ SLOT_INTERFACE_INTERNAL("plain", GAMATE_ROM_PLAIN)
+ SLOT_INTERFACE_INTERNAL("banked", GAMATE_ROM_BANKED)
+ SLOT_INTERFACE_INTERNAL("4in1", GAMATE_ROM_4IN1)
+SLOT_INTERFACE_END
diff --git a/src/devices/bus/gamate/rom.h b/src/devices/bus/gamate/rom.h
new file mode 100644
index 00000000000..1d500082e36
--- /dev/null
+++ b/src/devices/bus/gamate/rom.h
@@ -0,0 +1,86 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+#ifndef MAME_BUS_GAMATE_ROM_H
+#define MAME_BUS_GAMATE_ROM_H
+
+#pragma once
+
+#include "slot.h"
+#include "gamate_protection.h"
+
+// ======================> gamate_rom_plain_device
+
+class gamate_rom_plain_device : public device_t,
+ public device_gamate_cart_interface
+{
+public:
+ // construction/destruction
+ gamate_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_cart) override;
+ virtual DECLARE_WRITE8_MEMBER(write_cart) override;
+ virtual READ8_MEMBER(read_rom);
+ virtual WRITE8_MEMBER(write_rom);
+
+protected:
+ gamate_rom_plain_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ virtual void device_add_mconfig(machine_config &config) override;
+
+ // device-level overrides
+ virtual void device_start() override { }
+ virtual void device_reset() override { }
+
+ optional_device<gamate_protection_device> m_protection;
+};
+
+// ======================> gamate_rom_banked_device
+
+class gamate_rom_banked_device : public gamate_rom_plain_device
+{
+public:
+ // construction/destruction
+ gamate_rom_banked_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ gamate_rom_banked_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ // reading and writing
+ virtual READ8_MEMBER(read_rom) override;
+ virtual WRITE8_MEMBER(write_rom) override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ int m_bank;
+};
+
+
+// ======================> gamate_rom_4in1_device
+
+class gamate_rom_4in1_device : public gamate_rom_banked_device
+{
+public:
+ // construction/destruction
+ gamate_rom_4in1_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ // reading and writing
+ virtual READ8_MEMBER(read_rom) override;
+ virtual WRITE8_MEMBER(write_rom) override;
+
+protected:
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+private:
+ int m_multibank;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(GAMATE_ROM_PLAIN, gamate_rom_plain_device)
+DECLARE_DEVICE_TYPE(GAMATE_ROM_BANKED, gamate_rom_banked_device)
+DECLARE_DEVICE_TYPE(GAMATE_ROM_4IN1, gamate_rom_4in1_device)
+
+#endif // MAME_BUS_GAMATE_ROM_H
diff --git a/src/devices/bus/gamate/slot.cpp b/src/devices/bus/gamate/slot.cpp
new file mode 100644
index 00000000000..a74b4569b6e
--- /dev/null
+++ b/src/devices/bus/gamate/slot.cpp
@@ -0,0 +1,248 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+
+#include "emu.h"
+#include "slot.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(GAMATE_CART_SLOT, gamate_cart_slot_device, "gamate_cart_slot", "Gamate Cartridge Slot")
+
+//**************************************************************************
+// GAMATE cartridges Interface
+//**************************************************************************
+
+//-------------------------------------------------
+// device_gamate_cart_interface - constructor
+//-------------------------------------------------
+
+device_gamate_cart_interface::device_gamate_cart_interface(const machine_config &mconfig, device_t &device)
+ : device_slot_card_interface(mconfig, device),
+ m_rom(nullptr),
+ m_rom_size(0)
+{
+}
+
+
+//-------------------------------------------------
+// ~device_gamate_cart_interface - destructor
+//-------------------------------------------------
+
+device_gamate_cart_interface::~device_gamate_cart_interface()
+{
+}
+
+//-------------------------------------------------
+// rom_alloc - alloc the space for the cart
+//-------------------------------------------------
+
+void device_gamate_cart_interface::rom_alloc(uint32_t size, const char *tag)
+{
+ if (m_rom == nullptr)
+ {
+ m_rom = device().machine().memory().region_alloc(std::string(tag).append(GAMATESLOT_ROM_REGION_TAG).c_str(), size, 1, ENDIANNESS_BIG)->base();
+ m_rom_size = size;
+ }
+}
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// gamate_cart_slot_device - constructor
+//-------------------------------------------------
+gamate_cart_slot_device::gamate_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, GAMATE_CART_SLOT, tag, owner, clock),
+ device_image_interface(mconfig, *this),
+ device_slot_interface(mconfig, *this),
+ m_type(GAMATE_PLAIN),
+ m_cart(nullptr)
+{
+}
+
+//-------------------------------------------------
+// gamate_cart_slot_device - destructor
+//-------------------------------------------------
+
+gamate_cart_slot_device::~gamate_cart_slot_device()
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void gamate_cart_slot_device::device_start()
+{
+ m_cart = dynamic_cast<device_gamate_cart_interface *>(get_card_device());
+}
+
+//-------------------------------------------------
+// GAMATE PCB
+//-------------------------------------------------
+
+struct gamate_slot
+{
+ int pcb_id;
+ const char *slot_option;
+};
+
+// Here, we take the feature attribute from .xml (i.e. the PCB name) and we assign a unique ID to it
+static const gamate_slot slot_list[] =
+{
+ { GAMATE_PLAIN, "plain" },
+ { GAMATE_BANKED, "banked" },
+ { GAMATE_4IN1, "4in1" },
+};
+
+static int gamate_get_pcb_id(const char *slot)
+{
+ for (auto & elem : slot_list)
+ {
+ if (!core_stricmp(elem.slot_option, slot))
+ return elem.pcb_id;
+ }
+
+ return 0;
+}
+
+static const char *gamate_get_slot(int type)
+{
+ for (auto & elem : slot_list)
+ {
+ if (elem.pcb_id == type)
+ return elem.slot_option;
+ }
+
+ return "plain";
+}
+
+
+/*-------------------------------------------------
+ call load
+ -------------------------------------------------*/
+
+image_init_result gamate_cart_slot_device::call_load()
+{
+ if (m_cart)
+ {
+ uint8_t *ROM;
+ uint32_t len = !loaded_through_softlist() ? length() : get_software_region_length("rom");
+
+ if (len > 0x80000)
+ {
+ seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
+ return image_init_result::FAIL;
+ }
+
+ m_cart->rom_alloc(len, tag());
+
+ ROM = m_cart->get_rom_base();
+
+ if (!loaded_through_softlist())
+ fread(ROM, len);
+ else
+ memcpy(ROM, get_software_region("rom"), len);
+
+ if (!loaded_through_softlist())
+ {
+ // attempt to detect cart type without softlist assistance
+ m_type = get_cart_type(ROM, len);
+ }
+ else
+ {
+ // or for softlist loading, use the type specified
+ const char *pcb_name = get_feature("slot");
+ if (pcb_name)
+ m_type = gamate_get_pcb_id(pcb_name);
+ }
+
+ return image_init_result::PASS;
+ }
+
+ return image_init_result::PASS;
+}
+
+
+/*-------------------------------------------------
+ get_cart_type - code to detect cart type from
+ fullpath
+ -------------------------------------------------*/
+
+int gamate_cart_slot_device::get_cart_type(const uint8_t *ROM, uint32_t len)
+{
+ int type = GAMATE_PLAIN;
+
+ switch (len)
+ {
+ case 0x4000:
+ case 0x8000:
+ type = GAMATE_PLAIN;
+ break;
+
+ case 0x10000:
+ case 0x20000:
+ case 0x40000:
+ case 0x80000:
+ type = GAMATE_BANKED;
+ break;
+ }
+
+ return type;
+}
+
+
+/*-------------------------------------------------
+ get default card software
+ -------------------------------------------------*/
+
+std::string gamate_cart_slot_device::get_default_card_software(get_default_card_software_hook &hook) const
+{
+ if (hook.image_file())
+ {
+ const char *slot_string;
+ uint32_t len = hook.image_file()->size();
+ std::vector<uint8_t> rom(len);
+ int type;
+
+ hook.image_file()->read(&rom[0], len);
+
+ type = get_cart_type(&rom[0], len);
+ slot_string = gamate_get_slot(type);
+
+ //printf("type: %s\n", slot_string);
+
+ return std::string(slot_string);
+ }
+
+ return software_get_default_slot("plain");
+}
+
+/*-------------------------------------------------
+ read
+ -------------------------------------------------*/
+
+READ8_MEMBER(gamate_cart_slot_device::read_cart)
+{
+ if (m_cart)
+ {
+ return m_cart->read_cart(space, offset);
+ }
+ else
+ return 0xff;
+}
+
+/*-------------------------------------------------
+ write
+ -------------------------------------------------*/
+
+WRITE8_MEMBER(gamate_cart_slot_device::write_cart)
+{
+ if (m_cart)
+ {
+ m_cart->write_cart(space, offset, data);
+ }
+}
diff --git a/src/devices/bus/gamate/slot.h b/src/devices/bus/gamate/slot.h
new file mode 100644
index 00000000000..802fdb360e3
--- /dev/null
+++ b/src/devices/bus/gamate/slot.h
@@ -0,0 +1,104 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+#ifndef MAME_BUS_GAMATE_SLOT_H
+#define MAME_BUS_GAMATE_SLOT_H
+
+#pragma once
+
+#include "softlist_dev.h"
+
+/***************************************************************************
+ TYPE DEFINITIONS
+ ***************************************************************************/
+
+/* PCB */
+enum
+{
+ GAMATE_PLAIN = 0,
+ GAMATE_BANKED,
+ GAMATE_4IN1,
+};
+
+// ======================> device_gamate_cart_interface
+
+class device_gamate_cart_interface : public device_slot_card_interface
+{
+public:
+ // construction/destruction
+ virtual ~device_gamate_cart_interface();
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_cart) { return 0xff; }
+ virtual DECLARE_WRITE8_MEMBER(write_cart) { }
+
+ void rom_alloc(uint32_t size, const char *tag);
+ uint8_t* get_rom_base() { return m_rom; }
+ uint32_t get_rom_size() { return m_rom_size; }
+
+protected:
+ device_gamate_cart_interface(const machine_config &mconfig, device_t &device);
+
+ // internal state
+ uint8_t *m_rom;
+ uint32_t m_rom_size;
+};
+
+// ======================> gamate_cart_slot_device
+
+class gamate_cart_slot_device : public device_t,
+ public device_image_interface,
+ public device_slot_interface
+{
+public:
+ // construction/destruction
+ gamate_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ virtual ~gamate_cart_slot_device();
+
+ // image-level overrides
+ virtual image_init_result call_load() override;
+ virtual void call_unload() override {}
+ virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
+
+ int get_type() { return m_type; }
+ static int get_cart_type(const uint8_t *ROM, uint32_t len);
+
+ virtual iodevice_t image_type() const override { return IO_CARTSLOT; }
+ virtual bool is_readable() const override { return 1; }
+ virtual bool is_writeable() const override { return 0; }
+ virtual bool is_creatable() const override { return 0; }
+ virtual bool must_be_loaded() const override { return 0; }
+ virtual bool is_reset_on_load() const override { return 1; }
+ virtual const char *image_interface() const override { return "gamate_cart"; }
+ virtual const char *file_extensions() const override { return "bin"; }
+
+ // slot interface overrides
+ virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
+
+ // reading and writing
+ virtual DECLARE_READ8_MEMBER(read_cart);
+ virtual DECLARE_WRITE8_MEMBER(write_cart);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+ int m_type;
+ device_gamate_cart_interface* m_cart;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(GAMATE_CART_SLOT, gamate_cart_slot_device)
+
+/***************************************************************************
+ DEVICE CONFIGURATION MACROS
+ ***************************************************************************/
+
+#define GAMATESLOT_ROM_REGION_TAG ":cart:rom"
+
+#define MCFG_GAMATE_CARTRIDGE_ADD(_tag,_slot_intf,_def_slot) \
+ MCFG_DEVICE_ADD(_tag, GAMATE_CART_SLOT, 0) \
+ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
+
+SLOT_INTERFACE_EXTERN( gamate_cart );
+
+#endif // MAME_BUS_GAMATE_SLOT_H
diff --git a/src/mame/drivers/gamate.cpp b/src/mame/drivers/gamate.cpp
index f95bf53bf10..49dcdd3e792 100644
--- a/src/mame/drivers/gamate.cpp
+++ b/src/mame/drivers/gamate.cpp
@@ -9,14 +9,11 @@
A complete hardware description can be found at
http://blog.kevtris.org/blogfiles/Gamate%20Inside.txt
- nmi unknown
- bomb blast top status line missing
******************************************************************************/
#include "emu.h"
#include "sound/ay8910.h"
-#include "bus/generic/carts.h"
-#include "bus/generic/slot.h"
+#include "bus/gamate/slot.h"
#include "cpu/m6502/m6502.h"
#include "video/gamate.h"
#include "screen.h"
@@ -30,137 +27,68 @@ public:
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_ay(*this, "ay8910")
- , m_cart(*this, "cartslot")
+ , m_cartslot(*this, "cartslot")
, m_io_joy(*this, "JOY")
, m_bios(*this, "bios")
- , m_bank(*this, "bank")
- , m_bankmulti(*this, "bankmulti")
{ }
DECLARE_PALETTE_INIT(gamate);
- DECLARE_READ8_MEMBER(protection_r);
- DECLARE_READ8_MEMBER(newer_protection_set);
- DECLARE_WRITE8_MEMBER(protection_reset);
- DECLARE_READ8_MEMBER(gamate_cart_protection_r);
- DECLARE_WRITE8_MEMBER(gamate_cart_protection_w);
- DECLARE_WRITE8_MEMBER(cart_bankswitchmulti_w);
- DECLARE_WRITE8_MEMBER(cart_bankswitch_w);
+
+ DECLARE_READ8_MEMBER(card_available_check);
+ DECLARE_READ8_MEMBER(card_available_set);
+ DECLARE_WRITE8_MEMBER(card_reset);
+
DECLARE_READ8_MEMBER(gamate_nmi_r);
DECLARE_WRITE8_MEMBER(sound_w);
DECLARE_READ8_MEMBER(sound_r);
+ DECLARE_WRITE8_MEMBER(write_cart);
+ DECLARE_READ8_MEMBER(read_cart);
+
DECLARE_DRIVER_INIT(gamate);
+
uint32_t screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- INTERRUPT_GEN_MEMBER(gamate_interrupt);
+
TIMER_CALLBACK_MEMBER(gamate_timer);
TIMER_CALLBACK_MEMBER(gamate_timer2);
private:
virtual void machine_start() override;
+ virtual void machine_reset() override;
- struct
- {
- bool set;
- int bit_shifter;
- uint8_t cartridge_byte;
- uint16_t address; // in reality something more like short local cartridge address offset
- bool unprotected;
- bool failed;
- } card_protection;
+ int m_card_available;
required_device<cpu_device> m_maincpu;
required_device<ay8910_device> m_ay;
- required_device<generic_slot_device> m_cart;
+ required_device<gamate_cart_slot_device> m_cartslot;
required_ioport m_io_joy;
required_shared_ptr<uint8_t> m_bios;
- required_memory_bank m_bank;
- required_memory_bank m_bankmulti;
emu_timer *timer1;
emu_timer *timer2;
- uint8_t bank_multi;
- uint8_t *m_cart_ptr;
};
-WRITE8_MEMBER( gamate_state::gamate_cart_protection_w )
+/* todo: what are these really, do they go to the cartridge slot? */
+READ8_MEMBER( gamate_state::card_available_check )
{
- logerror("%.6f protection write %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, data, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
-
- switch (offset)
- {
- case 0:
- card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0);
- card_protection.bit_shifter++;
- if (card_protection.bit_shifter>=8)
- {
- card_protection.cartridge_byte=m_cart_ptr[card_protection.address++];
- card_protection.bit_shifter=0;
- }
- break;
- }
-}
+ // bits 0 and 1 checked
+ return m_card_available ? 3: 1;
+}
-READ8_MEMBER( gamate_state::gamate_cart_protection_r )
+WRITE8_MEMBER( gamate_state::card_reset )
{
- uint8_t ret=1;
- if (card_protection.bit_shifter==7 && card_protection.unprotected)
- {
- ret=m_cart_ptr[bank_multi*0x4000];
- }
- else
- {
- card_protection.bit_shifter++;
- if (card_protection.bit_shifter==8)
- {
- card_protection.bit_shifter=0;
- card_protection.cartridge_byte='G';
- card_protection.unprotected=true;
- }
- ret=(card_protection.cartridge_byte&0x80) ? 2 : 0;
- if (card_protection.bit_shifter==7 && !card_protection.failed)
- { // now protection chip on cartridge activates cartridge chip select on cpu accesses
-// m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); // next time I will try to get this working
- }
- card_protection.cartridge_byte<<=1;
- }
- logerror("%.6f protection read %x %x address:%x data:%x shift:%d\n",machine().time().as_double(), offset, ret, card_protection.address, card_protection.cartridge_byte, card_protection.bit_shifter);
- return ret;
+ // might reset the card / protection?
}
-READ8_MEMBER( gamate_state::protection_r )
-{
- return card_protection.set? 3: 1;
-} // bits 0 and 1 checked
-
-WRITE8_MEMBER( gamate_state::protection_reset )
+READ8_MEMBER( gamate_state::card_available_set )
{
-// writes 0x20
- card_protection.address=0x6005-0x6001;
- card_protection.bit_shifter=0;
- card_protection.cartridge_byte=m_cart_ptr[card_protection.address++]; //m_cart_rom[card_protection.address++];
- card_protection.failed=false;
- card_protection.unprotected=false;
-}
-
-READ8_MEMBER( gamate_state::newer_protection_set )
-{
- card_protection.set=true;
+ m_card_available = 1;
return 0;
}
-WRITE8_MEMBER( gamate_state::cart_bankswitchmulti_w )
-{
- bank_multi=data;
- m_bankmulti->set_base(m_cart_ptr+0x4000*data+1);
-}
-
-WRITE8_MEMBER( gamate_state::cart_bankswitch_w )
-{
- m_bank->set_base(m_cart_ptr+0x4000*data);
-}
-
+// serial connection
READ8_MEMBER( gamate_state::gamate_nmi_r )
{
uint8_t data=0;
- popmessage("nmi/4800 read\n");
+ logerror("nmi/4800 read\n");
return data;
}
@@ -176,20 +104,27 @@ WRITE8_MEMBER(gamate_state::sound_w)
m_ay->data_w(space, 0, data);
}
+WRITE8_MEMBER(gamate_state::write_cart)
+{
+ m_cartslot->write_cart(space, offset, data);
+}
+
+READ8_MEMBER(gamate_state::read_cart)
+{
+ return m_cartslot->read_cart(space, offset);
+}
+
static ADDRESS_MAP_START( gamate_mem, AS_PROGRAM, 8, gamate_state )
AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM
AM_RANGE(0x4000, 0x400f) AM_MIRROR(0x03f0) AM_READWRITE(sound_r,sound_w)
AM_RANGE(0x4400, 0x4400) AM_MIRROR(0x03ff) AM_READ_PORT("JOY")
AM_RANGE(0x4800, 0x4800) AM_MIRROR(0x03ff) AM_READ(gamate_nmi_r)
AM_RANGE(0x5000, 0x5007) AM_MIRROR(0x03f8) AM_DEVICE("video", gamate_video_device, regs_map)
- AM_RANGE(0x5800, 0x5800) AM_READ(newer_protection_set)
- AM_RANGE(0x5900, 0x5900) AM_WRITE(protection_reset)
- AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r)
- AM_RANGE(0x6001, 0x9fff) AM_READ_BANK("bankmulti")
- AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank")
- AM_RANGE(0x6000, 0x6000) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w)
- AM_RANGE(0x8000, 0x8000) AM_WRITE(cart_bankswitchmulti_w)
- AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w)
+ AM_RANGE(0x5800, 0x5800) AM_READ(card_available_set)
+ AM_RANGE(0x5900, 0x5900) AM_WRITE(card_reset)
+ AM_RANGE(0x5a00, 0x5a00) AM_READ(card_available_check)
+ AM_RANGE(0x6000, 0xdfff) AM_READWRITE(read_cart, write_cart)
+
AM_RANGE(0xe000, 0xefff) AM_MIRROR(0x1000) AM_ROM AM_SHARE("bios") AM_REGION("maincpu",0)
ADDRESS_MAP_END
@@ -214,20 +149,15 @@ DRIVER_INIT_MEMBER(gamate_state,gamate)
void gamate_state::machine_start()
{
- m_cart_ptr = memregion("maincpu")->base() + 0x6000;
- if (m_cart->exists())
- {
-// m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r));
- m_cart_ptr = m_cart->get_rom_base();
- m_bankmulti->set_base(m_cart->get_rom_base()+1);
- m_bank->set_base(m_cart->get_rom_base()+0x4000); // bankswitched games in reality no offset
- }
-// m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // default bios: $47 protection readback
- card_protection.set=false;
- bank_multi=0;
- card_protection.unprotected=false;
timer2->enable(true);
timer2->reset(m_maincpu->cycles_to_attotime(1000));
+
+ save_item(NAME(m_card_available));
+}
+
+void gamate_state::machine_reset()
+{
+ m_card_available = 0;
}
TIMER_CALLBACK_MEMBER(gamate_state::gamate_timer)
@@ -259,7 +189,8 @@ static MACHINE_CONFIG_START( gamate )
MCFG_SOUND_ROUTE(2, "lspeaker", 0.25)
MCFG_SOUND_ROUTE(2, "rspeaker", 0.25)
- MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_linear_slot, "gamate_cart")
+ MCFG_GAMATE_CARTRIDGE_ADD("cartslot", gamate_cart, nullptr)
+
MCFG_SOFTWARE_LIST_ADD("cart_list","gamate")
MACHINE_CONFIG_END