summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/jakks_gamekey
diff options
context:
space:
mode:
author David Haywood <mamehaze@gmail.com>2019-02-10 17:47:03 +0000
committer MooglyGuy <MooglyGuy@users.noreply.github.com>2019-02-10 18:47:03 +0100
commitdea868dfaa94a588c114aeaba103794c826fa302 (patch)
treea72b291565f641812a4b2ebc443dfd4389bd8035 /src/devices/bus/jakks_gamekey
parent15a995ff0a44c0a37788d094fca16d2374cb39e7 (diff)
new WORKING machines (JAKKS stuff) (#4624)
New WORKING machines --- Ms. Pac-Man 5-in-1 (Ms. Pac-Man, Pole Position, Galaga, Xevious, Mappy) (JAKKS Pacific TV Game, Game-Key Ready) [Sean Riddle, Peter Wilhelmsen, 19 external donators] Disney Princess (JAKKS Pacific TV Game, Game-Key Ready) [Sean Riddle, 20 external donators] New WORKING Software List entries --- jakks_gamekey_nm:nrxdig New Rally X & Dig Dug [Sean Riddle, Peter Wilhelmsen, 19 external donators] note, Pole Position is not really very playable at the moment due to raster rendering glitches, the rest are, aside from some obvious sound issues (nw) New machines marked as NOT WORKING --- Wheel of Fortune (JAKKS Pacific TV Game, Game-Key Ready) [Sean Riddle, 20 external donators] There is a video rendering glitch (lkely another off by x lines raster issue) causing the letter selection text to not render properly, it appears the letters scroll instead of the text scroller below, which doesn't. (nw) -spg2xx: Make rowscroll offset configurable, can't find register to control it, but JAKKS games need 0, while the chinese stuff needs 15 (nw) -jak_wof: Marked as working, analog wheel isn't emulated, but is optional (I don't see where / how it maps) (nw) -jak_wof: Improved inputs (nw) -gamekeys now save to the gamekey seeprom not the system one (nw)
Diffstat (limited to 'src/devices/bus/jakks_gamekey')
-rw-r--r--src/devices/bus/jakks_gamekey/rom.cpp110
-rw-r--r--src/devices/bus/jakks_gamekey/rom.h77
-rw-r--r--src/devices/bus/jakks_gamekey/slot.cpp237
-rw-r--r--src/devices/bus/jakks_gamekey/slot.h119
4 files changed, 543 insertions, 0 deletions
diff --git a/src/devices/bus/jakks_gamekey/rom.cpp b/src/devices/bus/jakks_gamekey/rom.cpp
new file mode 100644
index 00000000000..caabfe225c2
--- /dev/null
+++ b/src/devices/bus/jakks_gamekey/rom.cpp
@@ -0,0 +1,110 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+
+#include "emu.h"
+#include "rom.h"
+
+//-------------------------------------------------
+// jakks_gamekey_rom_device - constructor
+//-------------------------------------------------
+
+DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_PLAIN, jakks_gamekey_rom_plain_device, "jakks_gamekey_rom_plain", "JAKKS Pacific GameKey")
+DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_I2C_BASE, jakks_gamekey_rom_i2c_base_device, "jakks_gamekey_rom_i2c_base", "JAKKS Pacific GameKey with I2C")
+DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_I2C_24LC04, jakks_gamekey_rom_i2c_24lc04_device, "jakks_gamekey_rom_i2c_24lc04", "JAKKS Pacific GameKey with I2C 24LC04")
+
+
+jakks_gamekey_rom_plain_device::jakks_gamekey_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_jakks_gamekey_interface(mconfig, *this)
+{
+}
+
+jakks_gamekey_rom_plain_device::jakks_gamekey_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ jakks_gamekey_rom_plain_device(mconfig, JAKKS_GAMEKEY_ROM_PLAIN, tag, owner, clock)
+{
+}
+
+jakks_gamekey_rom_i2c_base_device::jakks_gamekey_rom_i2c_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
+ jakks_gamekey_rom_plain_device(mconfig, type, tag, owner, clock),
+ m_i2cmem(*this, "i2cmem")
+{
+}
+
+jakks_gamekey_rom_i2c_base_device::jakks_gamekey_rom_i2c_base_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ jakks_gamekey_rom_i2c_base_device(mconfig, JAKKS_GAMEKEY_ROM_I2C_BASE, tag, owner, clock)
+{
+}
+
+jakks_gamekey_rom_i2c_24lc04_device::jakks_gamekey_rom_i2c_24lc04_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ jakks_gamekey_rom_i2c_base_device(mconfig, JAKKS_GAMEKEY_ROM_I2C_24LC04, tag, owner, clock)
+{
+}
+
+/*-------------------------------------------------
+ mapper specific handlers
+ -------------------------------------------------*/
+
+// plain
+
+READ16_MEMBER(jakks_gamekey_rom_plain_device::read_cart)
+{
+ return read_rom(space, offset, mem_mask);
+}
+
+READ16_MEMBER(jakks_gamekey_rom_plain_device::read_rom)
+{
+ return m_rom[offset & (m_rom_size-1)];
+}
+
+WRITE16_MEMBER(jakks_gamekey_rom_plain_device::write_cart)
+{
+ write_rom(space, offset, data, mem_mask);
+}
+
+WRITE16_MEMBER(jakks_gamekey_rom_plain_device::write_rom)
+{
+ logerror("jakks_gamekey_rom_plain_device::write_rom %08x %02x\n", offset, data);
+}
+
+// i2c base
+
+WRITE16_MEMBER(jakks_gamekey_rom_i2c_base_device::write_rom)
+{
+ logerror("jakks_gamekey_rom_i2c_base_device::write_rom %08x %02x\n", offset, data);
+}
+
+READ16_MEMBER(jakks_gamekey_rom_i2c_base_device::read_rom)
+{
+ return m_rom[offset & (m_rom_size - 1)];
+}
+
+uint8_t jakks_gamekey_rom_i2c_base_device::read_cart_seeprom(void)
+{
+ logerror("jakks_gamekey_rom_i2c_base_device::read_cart_seeprom\n");
+
+ return m_i2cmem->read_sda();
+}
+
+WRITE16_MEMBER(jakks_gamekey_rom_i2c_base_device::write_cart_seeprom)
+{
+ if (BIT(mem_mask, 1))
+ m_i2cmem->write_scl(BIT(data, 1));
+ if (BIT(mem_mask, 0))
+ m_i2cmem->write_sda(BIT(data, 0));
+}
+
+// i2c 24lc04
+
+MACHINE_CONFIG_START(jakks_gamekey_rom_i2c_24lc04_device::device_add_mconfig)
+ I2CMEM(config, "i2cmem", 0)/*.set_page_size(16)*/.set_data_size(0x200); // 24LC04
+MACHINE_CONFIG_END
+
+
+/*-------------------------------------------------
+ slot interface
+ -------------------------------------------------*/
+
+void jakks_gamekey(device_slot_interface &device)
+{
+ device.option_add_internal("plain", JAKKS_GAMEKEY_ROM_PLAIN);
+ device.option_add_internal("rom_24lc04", JAKKS_GAMEKEY_ROM_I2C_24LC04);
+}
diff --git a/src/devices/bus/jakks_gamekey/rom.h b/src/devices/bus/jakks_gamekey/rom.h
new file mode 100644
index 00000000000..7f85e9f21fb
--- /dev/null
+++ b/src/devices/bus/jakks_gamekey/rom.h
@@ -0,0 +1,77 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+#ifndef MAME_BUS_JAKKS_GAMEKEY_ROM_H
+#define MAME_BUS_JAKKS_GAMEKEY_ROM_H
+
+#pragma once
+
+#include "slot.h"
+#include "machine/i2cmem.h"
+
+// ======================> jakks_gamekey_rom_plain_device
+
+class jakks_gamekey_rom_plain_device : public device_t,
+ public device_jakks_gamekey_interface
+{
+public:
+ // construction/destruction
+ jakks_gamekey_rom_plain_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ // reading and writing
+ virtual DECLARE_READ16_MEMBER(read_cart) override;
+ virtual DECLARE_WRITE16_MEMBER(write_cart) override;
+
+ virtual uint8_t read_cart_seeprom(void) override { return 1; };
+ virtual DECLARE_WRITE16_MEMBER(write_cart_seeprom) override { };
+
+ virtual READ16_MEMBER(read_rom);
+ virtual WRITE16_MEMBER(write_rom);
+
+protected:
+ jakks_gamekey_rom_plain_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 { }
+ virtual void device_reset() override { }
+};
+
+// ======================> jakks_gamekey_rom_i2c_base_device
+
+class jakks_gamekey_rom_i2c_base_device : public jakks_gamekey_rom_plain_device
+{
+public:
+ // construction/destruction
+ jakks_gamekey_rom_i2c_base_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ jakks_gamekey_rom_i2c_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+
+ // reading and writing
+ virtual READ16_MEMBER(read_rom) override;
+ virtual WRITE16_MEMBER(write_rom) override;
+
+ optional_device<i2cmem_device> m_i2cmem;
+
+ virtual uint8_t read_cart_seeprom(void) override;
+ virtual DECLARE_WRITE16_MEMBER(write_cart_seeprom) override;
+};
+
+
+// ======================> jakks_gamekey_rom_i2c_24lc04_device
+
+class jakks_gamekey_rom_i2c_24lc04_device : public jakks_gamekey_rom_i2c_base_device
+{
+public:
+ // construction/destruction
+ jakks_gamekey_rom_i2c_24lc04_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+protected:
+ virtual void device_add_mconfig(machine_config &config) override;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_PLAIN, jakks_gamekey_rom_plain_device)
+DECLARE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_I2C_BASE, jakks_gamekey_rom_i2c_base_device)
+DECLARE_DEVICE_TYPE(JAKKS_GAMEKEY_ROM_I2C_24LC04, jakks_gamekey_rom_i2c_24lc04_device)
+
+#endif // MAME_BUS_JAKKS_GAMEKEY_ROM_H
diff --git a/src/devices/bus/jakks_gamekey/slot.cpp b/src/devices/bus/jakks_gamekey/slot.cpp
new file mode 100644
index 00000000000..6a5196875b1
--- /dev/null
+++ b/src/devices/bus/jakks_gamekey/slot.cpp
@@ -0,0 +1,237 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+
+#include "emu.h"
+#include "slot.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+DEFINE_DEVICE_TYPE(JAKKS_GAMEKEY_SLOT, jakks_gamekey_slot_device, "jakks_gamekey_slot", "JAKKS Pacific Gamekey Slot")
+
+//**************************************************************************
+// JAKKS GAMEKEY cartridges Interface
+//**************************************************************************
+
+//-------------------------------------------------
+// device_jakks_gamekey_interface - constructor
+//-------------------------------------------------
+
+device_jakks_gamekey_interface::device_jakks_gamekey_interface(const machine_config &mconfig, device_t &device)
+ : device_slot_card_interface(mconfig, device),
+ m_rom(nullptr),
+ m_rom_size(0)
+{
+}
+
+
+//-------------------------------------------------
+// ~device_jakks_gamekey_interface - destructor
+//-------------------------------------------------
+
+device_jakks_gamekey_interface::~device_jakks_gamekey_interface()
+{
+}
+
+//-------------------------------------------------
+// rom_alloc - alloc the space for the cart
+//-------------------------------------------------
+
+void device_jakks_gamekey_interface::rom_alloc(uint32_t size, const char *tag)
+{
+ if (m_rom == nullptr)
+ {
+ m_rom = device().machine().memory().region_alloc(std::string(tag).append(JAKKSSLOT_ROM_REGION_TAG).c_str(), size, 1, ENDIANNESS_BIG)->base();
+ m_rom_size = size;
+ }
+}
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// jakks_gamekey_slot_device - constructor
+//-------------------------------------------------
+jakks_gamekey_slot_device::jakks_gamekey_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
+ device_t(mconfig, JAKKS_GAMEKEY_SLOT, tag, owner, clock),
+ device_image_interface(mconfig, *this),
+ device_slot_interface(mconfig, *this),
+ m_type(JAKKS_GAMEKEY_PLAIN),
+ m_cart(nullptr)
+{
+}
+
+//-------------------------------------------------
+// jakks_gamekey_slot_device - destructor
+//-------------------------------------------------
+
+jakks_gamekey_slot_device::~jakks_gamekey_slot_device()
+{
+}
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void jakks_gamekey_slot_device::device_start()
+{
+ m_cart = dynamic_cast<device_jakks_gamekey_interface *>(get_card_device());
+}
+
+//-------------------------------------------------
+// JAKKS GAMEKEY PCB
+//-------------------------------------------------
+
+struct jakks_gamekey_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 jakks_gamekey_slot slot_list[] =
+{
+ { JAKKS_GAMEKEY_PLAIN, "plain" },
+ { JAKKS_GAMEKEY_I2C_BASE, "i2c_base" },
+ { JAKKS_GAMEKEY_I2C_24LC04, "rom_24lc04" },
+};
+
+static int jakks_gamekey_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 *jakks_gamekey_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 jakks_gamekey_slot_device::call_load()
+{
+ if (m_cart)
+ {
+ uint8_t *ROM;
+ uint32_t len = !loaded_through_softlist() ? length() : get_software_region_length("rom");
+
+ 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 = jakks_gamekey_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 jakks_gamekey_slot_device::get_cart_type(const uint8_t *ROM, uint32_t len)
+{
+ // without code analysis we have no way of knowing.
+ int type = JAKKS_GAMEKEY_PLAIN;
+ return type;
+}
+
+
+/*-------------------------------------------------
+ get default card software
+ -------------------------------------------------*/
+
+std::string jakks_gamekey_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 = jakks_gamekey_get_slot(type);
+
+ printf("type: %s\n", slot_string);
+
+ return std::string(slot_string);
+ }
+
+ return software_get_default_slot("plain");
+}
+
+/*-------------------------------------------------
+ read
+ -------------------------------------------------*/
+
+READ16_MEMBER(jakks_gamekey_slot_device::read_cart)
+{
+ return m_cart->read_cart(space, offset);
+}
+
+/*-------------------------------------------------
+ write
+ -------------------------------------------------*/
+
+WRITE16_MEMBER(jakks_gamekey_slot_device::write_cart)
+{
+ m_cart->write_cart(space, offset, data);
+}
+
+/*-------------------------------------------------
+ read seeprom
+ -------------------------------------------------*/
+
+uint8_t jakks_gamekey_slot_device::read_cart_seeprom(void)
+{
+ return m_cart->read_cart_seeprom();
+}
+
+/*-------------------------------------------------
+ write seeprom
+ -------------------------------------------------*/
+
+WRITE16_MEMBER(jakks_gamekey_slot_device::write_cart_seeprom)
+{
+ m_cart->write_cart_seeprom(space, offset, data);
+}
diff --git a/src/devices/bus/jakks_gamekey/slot.h b/src/devices/bus/jakks_gamekey/slot.h
new file mode 100644
index 00000000000..8fd0961aad8
--- /dev/null
+++ b/src/devices/bus/jakks_gamekey/slot.h
@@ -0,0 +1,119 @@
+// license:BSD-3-Clause
+// copyright-holders:David Haywood
+#ifndef MAME_BUS_JAKKS_GAMEKEY_SLOT_H
+#define MAME_BUS_JAKKS_GAMEKEY_SLOT_H
+
+#pragma once
+
+#include "softlist_dev.h"
+
+/***************************************************************************
+ TYPE DEFINITIONS
+ ***************************************************************************/
+
+/* PCB */
+enum
+{
+ JAKKS_GAMEKEY_PLAIN = 0,
+ JAKKS_GAMEKEY_I2C_BASE,
+ JAKKS_GAMEKEY_I2C_24LC04,
+};
+
+// ======================> device_jakks_gamekey_interface
+
+class device_jakks_gamekey_interface : public device_slot_card_interface
+{
+public:
+ // construction/destruction
+ virtual ~device_jakks_gamekey_interface();
+
+ // reading and writing
+ virtual DECLARE_READ16_MEMBER(read_cart) { return 0xffff; }
+ virtual DECLARE_WRITE16_MEMBER(write_cart) { }
+
+ virtual uint8_t read_cart_seeprom(void) { return 1; }
+ virtual DECLARE_WRITE16_MEMBER(write_cart_seeprom) { }
+
+ 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_jakks_gamekey_interface(const machine_config &mconfig, device_t &device);
+
+ // internal state
+ uint8_t *m_rom;
+ uint32_t m_rom_size;
+};
+
+// ======================> jakks_gamekey_slot_device
+
+class jakks_gamekey_slot_device : public device_t,
+ public device_image_interface,
+ public device_slot_interface
+{
+public:
+ // construction/destruction
+ jakks_gamekey_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+
+ template <typename T>
+ jakks_gamekey_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&opts, const char *dflt)
+ : jakks_gamekey_slot_device(mconfig, tag, owner, clock)
+ {
+ option_reset();
+ opts(*this);
+ set_default_option(dflt);
+ set_fixed(false);
+ }
+
+ virtual ~jakks_gamekey_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 "jakks_gamekey"; }
+ virtual const char *file_extensions() const override { return "bin,u1"; }
+
+ // slot interface overrides
+ virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override;
+
+ // reading and writing
+ virtual DECLARE_READ16_MEMBER(read_cart);
+ virtual DECLARE_WRITE16_MEMBER(write_cart);
+
+ virtual uint8_t read_cart_seeprom(void);
+ virtual DECLARE_WRITE16_MEMBER(write_cart_seeprom);
+
+ bool has_cart() { return m_cart ? true : false; }
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+ int m_type;
+ device_jakks_gamekey_interface* m_cart;
+};
+
+// device type definition
+DECLARE_DEVICE_TYPE(JAKKS_GAMEKEY_SLOT, jakks_gamekey_slot_device)
+
+/***************************************************************************
+ DEVICE CONFIGURATION MACROS
+ ***************************************************************************/
+
+#define JAKKSSLOT_ROM_REGION_TAG ":cart:rom"
+
+void jakks_gamekey(device_slot_interface &device);
+
+#endif // MAME_BUS_JAKKS_GAMEKEY_SLOT_H