summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-04-06 21:20:01 -0400
committer AJR <ajrhacker@users.noreply.github.com>2020-04-06 21:20:01 -0400
commitf47877cfd1938fb3c15772d378ce187105245d2c (patch)
tree238ecc590060f0b8d95b88ca19e36471e9f3eb4a
parent6b9120d9238d94505b3f2f958c9da0b2293e0962 (diff)
pasopia, pasopia2: PAC2 overhaul
- PAC2 is now a separate bus with slot devices - Kanji ROM and RAM PAC2 expansions are no longer built into pasopia7, but may be configured as slot options - RAM PAC2 expansion made nonvolatile and provided in multiple sizes - Two PAC2 slots added to pasopia
-rw-r--r--scripts/src/bus.lua19
-rw-r--r--scripts/target/mame/mess.lua1
-rw-r--r--src/devices/bus/pasopia/pac2.cpp159
-rw-r--r--src/devices/bus/pasopia/pac2.h83
-rw-r--r--src/devices/bus/pasopia/pac2exp.cpp92
-rw-r--r--src/devices/bus/pasopia/pac2exp.h44
-rw-r--r--src/devices/bus/pasopia/rampac2.cpp149
-rw-r--r--src/devices/bus/pasopia/rampac2.h76
-rw-r--r--src/devices/bus/pasopia/rompac2.cpp98
-rw-r--r--src/devices/bus/pasopia/rompac2.h44
-rw-r--r--src/mame/drivers/pasopia.cpp8
-rw-r--r--src/mame/drivers/pasopia7.cpp120
12 files changed, 778 insertions, 115 deletions
diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua
index 2b64a7008a4..5f606673a01 100644
--- a/scripts/src/bus.lua
+++ b/scripts/src/bus.lua
@@ -1690,6 +1690,25 @@ end
---------------------------------------------------
--
+--@src/devices/bus/pasopia/pac2.h,BUSES["PASOPIA"] = true
+---------------------------------------------------
+
+if (BUSES["PASOPIA"]~=null) then
+ files {
+ MAME_DIR .. "src/devices/bus/pasopia/pac2.cpp",
+ MAME_DIR .. "src/devices/bus/pasopia/pac2.h",
+ MAME_DIR .. "src/devices/bus/pasopia/pac2exp.cpp",
+ MAME_DIR .. "src/devices/bus/pasopia/pac2exp.h",
+ MAME_DIR .. "src/devices/bus/pasopia/rampac2.cpp",
+ MAME_DIR .. "src/devices/bus/pasopia/rampac2.h",
+ MAME_DIR .. "src/devices/bus/pasopia/rompac2.cpp",
+ MAME_DIR .. "src/devices/bus/pasopia/rompac2.h",
+ }
+end
+
+
+---------------------------------------------------
+--
--@src/devices/bus/pc_joy/pc_joy.h,BUSES["PC_JOY"] = true
---------------------------------------------------
diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua
index 67f09cda7e8..6b427024704 100644
--- a/scripts/target/mame/mess.lua
+++ b/scripts/target/mame/mess.lua
@@ -853,6 +853,7 @@ BUSES["NSCSI"] = true
BUSES["NUBUS"] = true
BUSES["O2"] = true
BUSES["ORICEXT"] = true
+BUSES["PASOPIA"] = true
BUSES["PC1512"] = true
BUSES["PCE"] = true
BUSES["PC_JOY"] = true
diff --git a/src/devices/bus/pasopia/pac2.cpp b/src/devices/bus/pasopia/pac2.cpp
new file mode 100644
index 00000000000..13955bba61f
--- /dev/null
+++ b/src/devices/bus/pasopia/pac2.cpp
@@ -0,0 +1,159 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+/****************************************************************************
+
+ Toshiba Pasopia PAC2 slot
+
+ This is the smallest of the three Pasopia expansion connectors. Despite
+ only providing access to a 4-by-8-bit space, this was mostly used for
+ memory cartridges.
+
+ ______
+ CDB 7 1 | . . | 2 CDB 6
+ GND 3 | . . | 4 CDB 5
+ CDB 4 5 | . . | 6 CDB 3
+ GND 7 | . . | 8 CDB 2
+ CDB 1 9 | . . | 10 CDB 0
+ CDAD01 11 | . . | 12 CDAD00
+ GND 13 | . . | 14 CSELP2
+ CDRD 15 | . . | 16 CDWR
+ GND 17 | . . | 18 GND
+ +5V 19 | . . | 20 +5V
+ ------
+
+****************************************************************************/
+
+#include "emu.h"
+#include "pac2.h"
+
+#include "pac2exp.h"
+#include "rampac2.h"
+#include "rompac2.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(PASOPIA_PAC2, pasopia_pac2_slot_device, "pasopia_pac2", "Pasopia PAC2 Slot")
+
+//**************************************************************************
+// PAC2 SLOT DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// pasopia_pac2_slot_device - construction
+//-------------------------------------------------
+
+pasopia_pac2_slot_device::pasopia_pac2_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, PASOPIA_PAC2, tag, owner, clock)
+ , device_single_card_slot_interface<pac2_card_interface>(mconfig, *this)
+ , m_card(nullptr)
+{
+}
+
+
+//-------------------------------------------------
+// device_resolve_objects - resolve objects that
+// may be needed for other devices to set
+// initial conditions at start time
+//-------------------------------------------------
+
+void pasopia_pac2_slot_device::device_resolve_objects()
+{
+ m_card = get_card_device();
+ if (m_card != nullptr)
+ m_card->m_slot = this;
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void pasopia_pac2_slot_device::device_start()
+{
+}
+
+
+//-------------------------------------------------
+// read - I/O read access
+//-------------------------------------------------
+
+u8 pasopia_pac2_slot_device::read(offs_t offset)
+{
+ if (m_card == nullptr)
+ {
+ if (!machine().side_effects_disabled())
+ logerror("%s: Read from unconnected PAC2 (CDAD = %X)\n", machine().describe_context(), offset);
+ return 0;
+ }
+
+ return m_card->pac2_read(offset);
+}
+
+
+//-------------------------------------------------
+// write - I/O write access
+//-------------------------------------------------
+
+void pasopia_pac2_slot_device::write(offs_t offset, u8 data)
+{
+ if (m_card != nullptr)
+ m_card->pac2_write(offset, data);
+}
+
+//**************************************************************************
+// PAC2 CARD INTERFACE
+//**************************************************************************
+
+//-------------------------------------------------
+// pac2_card_interface - construction
+//-------------------------------------------------
+
+pac2_card_interface::pac2_card_interface(const machine_config &mconfig, device_t &device)
+ : device_interface(device, "pac2card")
+ , m_slot(nullptr)
+{
+}
+
+
+//-------------------------------------------------
+// interface_pre_start - called before the
+// device's own start function
+//-------------------------------------------------
+
+void pac2_card_interface::interface_pre_start()
+{
+ if (!m_slot)
+ throw device_missing_dependencies();
+}
+
+
+//-------------------------------------------------
+// pac2_subslot_devices - add standard options
+// for subslots
+//-------------------------------------------------
+
+void pac2_subslot_devices(device_slot_interface &device)
+{
+ //device.option_add("ram4k", PASOPIA_PA7241);
+ device.option_add("ram16k", PASOPIA_PA7243);
+ device.option_add("ram32k", PASOPIA_PA7245);
+ device.option_add("kanji", PASOPIA_PA7246);
+ //device.option_add("kanji2", PASOPIA_PA7247);
+ device.option_add("ram64k", PASOPIA_PA7248);
+ //device.option_add("joy", PASOPIA_PA7390);
+}
+
+
+//-------------------------------------------------
+// pac2_default_devices - add standard options
+// for main slots
+//-------------------------------------------------
+
+void pac2_default_devices(device_slot_interface &device)
+{
+ device.option_add("exp", PASOPIA_PA7234);
+ pac2_subslot_devices(device);
+}
diff --git a/src/devices/bus/pasopia/pac2.h b/src/devices/bus/pasopia/pac2.h
new file mode 100644
index 00000000000..9bbf30b44ca
--- /dev/null
+++ b/src/devices/bus/pasopia/pac2.h
@@ -0,0 +1,83 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+/**********************************************************************
+
+ Toshiba Pasopia PAC2 slot
+
+**********************************************************************/
+
+#ifndef MAME_BUS_PASOPIA_PAC2_H
+#define MAME_BUS_PASOPIA_PAC2_H
+
+#pragma once
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// forward declarations
+class pac2_card_interface;
+
+// ======================> pasopia_pac2_slot_device
+
+class pasopia_pac2_slot_device : public device_t, public device_single_card_slot_interface<pac2_card_interface>
+{
+ friend class pac2_card_interface;
+
+public:
+ // construction/destruction
+ template <typename T>
+ pasopia_pac2_slot_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt)
+ : pasopia_pac2_slot_device(mconfig, tag, owner, 0)
+ {
+ option_reset();
+ opts(*this);
+ set_default_option(dflt);
+ set_fixed(false);
+ }
+
+ pasopia_pac2_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
+
+ // memory accesses
+ u8 read(offs_t offset);
+ void write(offs_t offset, u8 data);
+
+protected:
+ // device-specific overrides
+ virtual void device_resolve_objects() override;
+ virtual void device_start() override;
+
+private:
+ pac2_card_interface *m_card;
+};
+
+
+// ======================> pac2_card_interface
+
+class pac2_card_interface : public device_interface
+{
+ friend class pasopia_pac2_slot_device;
+
+protected:
+ // construction/destruction
+ pac2_card_interface(const machine_config &mconfig, device_t &device);
+
+ // required overrides
+ virtual u8 pac2_read(offs_t offset) = 0;
+ virtual void pac2_write(offs_t offset, u8 data) = 0;
+
+private:
+ virtual void interface_pre_start() override;
+
+ pasopia_pac2_slot_device *m_slot;
+};
+
+
+// device type definition
+DECLARE_DEVICE_TYPE(PASOPIA_PAC2, pasopia_pac2_slot_device)
+
+void pac2_subslot_devices(device_slot_interface &device);
+void pac2_default_devices(device_slot_interface &device);
+
+#endif // MAME_BUS_PASOPIA_PAC2_H
diff --git a/src/devices/bus/pasopia/pac2exp.cpp b/src/devices/bus/pasopia/pac2exp.cpp
new file mode 100644
index 00000000000..9b5b1987564
--- /dev/null
+++ b/src/devices/bus/pasopia/pac2exp.cpp
@@ -0,0 +1,92 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+/****************************************************************************
+
+ Toshiba Pasopia PAC2 expander
+
+ Not much is known about the internal circuitry of this 4-slot expansion.
+ It was apparently designed primarily for the Pasopia 7, with the cord
+ connecting the sidecar to the main unit through a hole in a modified
+ slot cover.
+
+ The one-based slot selection scheme is due to the need to avoid
+ interfering with the 0x80 control byte needed to configure the PPI on
+ the PA7241 RAM PAC2.
+
+****************************************************************************/
+
+#include "emu.h"
+#include "pac2exp.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(PASOPIA_PA7234, pasopia_pa7234_device, "pa7234", "PA7234 Pasopia PAC2 Expansion Unit")
+
+//**************************************************************************
+// DEVICE DEFINITION
+//**************************************************************************
+
+//-------------------------------------------------
+// pasopia_pa7234_device - construction
+//-------------------------------------------------
+
+pasopia_pa7234_device::pasopia_pa7234_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, PASOPIA_PA7234, tag, owner, clock)
+ , pac2_card_interface(mconfig, *this)
+ , m_slot(*this, "slot%u", 1U)
+ , m_slot_selected(0)
+{
+}
+
+
+//-------------------------------------------------
+// device_add_mconfig - add device-specific
+// machine configuration
+//-------------------------------------------------
+
+void pasopia_pa7234_device::device_add_mconfig(machine_config &config)
+{
+ for (auto &slot : m_slot)
+ PASOPIA_PAC2(config, slot, pac2_subslot_devices, nullptr);
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void pasopia_pa7234_device::device_start()
+{
+ save_item(NAME(m_slot_selected));
+}
+
+//**************************************************************************
+// PAC2 INTERFACE
+//**************************************************************************
+
+//-------------------------------------------------
+// pac2_read - I/O read access
+//-------------------------------------------------
+
+u8 pasopia_pa7234_device::pac2_read(offs_t offset)
+{
+ return m_slot[m_slot_selected]->read(offset);
+}
+
+
+//-------------------------------------------------
+// pac2_write - I/O write access
+//-------------------------------------------------
+
+void pasopia_pa7234_device::pac2_write(offs_t offset, u8 data)
+{
+ // Assume all writes are passed through
+ m_slot[m_slot_selected]->write(offset, data);
+
+ // 1, 2, 3, 4 or 7 may supposedly be written here
+ if ((offset & 3) == 3 && (data & 0x07) != 0)
+ m_slot_selected = (data & 0x03) - 1;
+}
diff --git a/src/devices/bus/pasopia/pac2exp.h b/src/devices/bus/pasopia/pac2exp.h
new file mode 100644
index 00000000000..ae874c01490
--- /dev/null
+++ b/src/devices/bus/pasopia/pac2exp.h
@@ -0,0 +1,44 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+
+#ifndef MAME_BUS_PASOPIA_PAC2EXP_H
+#define MAME_BUS_PASOPIA_PAC2EXP_H
+
+#pragma once
+
+#include "pac2.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> pasopia_pa7234_device
+
+class pasopia_pa7234_device : public device_t, public pac2_card_interface
+{
+public:
+ // device type constructor
+ pasopia_pa7234_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+protected:
+ // device-level overrides
+ virtual void device_add_mconfig(machine_config &config) override;
+ virtual void device_start() override;
+
+ // pac2_card_interface overrides
+ virtual u8 pac2_read(offs_t offset) override;
+ virtual void pac2_write(offs_t offset, u8 data) override;
+
+private:
+ // object finders
+ required_device_array<pasopia_pac2_slot_device, 4> m_slot;
+
+ // internal state
+ u8 m_slot_selected;
+};
+
+// device type declaration
+DECLARE_DEVICE_TYPE(PASOPIA_PA7234, pasopia_pa7234_device)
+
+#endif // MAME_BUS_PASOPIA_PAC2EXP_H
diff --git a/src/devices/bus/pasopia/rampac2.cpp b/src/devices/bus/pasopia/rampac2.cpp
new file mode 100644
index 00000000000..1ce1cd4141d
--- /dev/null
+++ b/src/devices/bus/pasopia/rampac2.cpp
@@ -0,0 +1,149 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR, Angelo Salese
+/****************************************************************************
+
+ Toshiba Pasopia RAM PAC2 emulation
+
+ This emulates the later, larger cartridges, but not the original 4K
+ model which used a 8255 PPI to latch the RAM address.
+
+****************************************************************************/
+
+#include "emu.h"
+#include "rampac2.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definitions
+DEFINE_DEVICE_TYPE(PASOPIA_PA7243, pasopia_pa7243_device, "pa7243", "PA7243 Pasopia RAM PAC2 (16KB)")
+DEFINE_DEVICE_TYPE(PASOPIA_PA7245, pasopia_pa7245_device, "pa7245", "PA7245 Pasopia RAM PAC2 (32KB)")
+DEFINE_DEVICE_TYPE(PASOPIA_PA7248, pasopia_pa7248_device, "pa7248", "PA7248 Pasopia RAM PAC2 (64KB)")
+
+//**************************************************************************
+// DEVICE DEFINITION
+//**************************************************************************
+
+//-------------------------------------------------
+// pasopia_rampac2_device - construction
+//-------------------------------------------------
+
+pasopia_rampac2_device::pasopia_rampac2_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 ram_size)
+ : device_t(mconfig, type, tag, owner, clock)
+ , pac2_card_interface(mconfig, *this)
+ , device_nvram_interface(mconfig, *this)
+ , m_ram_size(ram_size)
+ , m_ram_index(0)
+{
+}
+
+
+//-------------------------------------------------
+// pasopia_pa7243_device - construction
+//-------------------------------------------------
+
+pasopia_pa7243_device::pasopia_pa7243_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : pasopia_rampac2_device(mconfig, PASOPIA_PA7243, tag, owner, clock, 0x4000)
+{
+}
+
+
+//-------------------------------------------------
+// pasopia_pa7245_device - construction
+//-------------------------------------------------
+
+pasopia_pa7245_device::pasopia_pa7245_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : pasopia_rampac2_device(mconfig, PASOPIA_PA7245, tag, owner, clock, 0x8000)
+{
+}
+
+
+//-------------------------------------------------
+// pasopia_pa7248_device - construction
+//-------------------------------------------------
+
+pasopia_pa7248_device::pasopia_pa7248_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : pasopia_rampac2_device(mconfig, PASOPIA_PA7248, tag, owner, clock, 0x10000)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void pasopia_rampac2_device::device_start()
+{
+ m_ram = std::make_unique<u8[]>(m_ram_size);
+
+ save_pointer(NAME(m_ram), m_ram_size);
+ save_item(NAME(m_ram_index));
+}
+
+
+//-------------------------------------------------
+// nvram_read - read NVRAM from the file
+//-------------------------------------------------
+
+void pasopia_rampac2_device::nvram_read(emu_file &file)
+{
+ file.read(&m_ram[0], m_ram_size);
+}
+
+
+//-------------------------------------------------
+// nvram_write - write NVRAM to the file
+//-------------------------------------------------
+
+void pasopia_rampac2_device::nvram_write(emu_file &file)
+{
+ file.write(&m_ram[0], m_ram_size);
+}
+
+
+//-------------------------------------------------
+// nvram_default - initialize NVRAM to its
+// default state
+//-------------------------------------------------
+
+void pasopia_rampac2_device::nvram_default()
+{
+ std::fill_n(&m_ram[0], m_ram_size, 0);
+}
+
+//**************************************************************************
+// PAC2 INTERFACE
+//**************************************************************************
+
+//-------------------------------------------------
+// pac2_read - I/O read access
+//-------------------------------------------------
+
+u8 pasopia_rampac2_device::pac2_read(offs_t offset)
+{
+ return m_ram[m_ram_index];
+}
+
+
+//-------------------------------------------------
+// pac2_write - I/O write access
+//-------------------------------------------------
+
+void pasopia_rampac2_device::pac2_write(offs_t offset, u8 data)
+{
+ switch (offset)
+ {
+ case 0:
+ m_ram_index = (m_ram_index & 0xff00) | (data & 0xff);
+ break;
+
+ case 1:
+ m_ram_index = (m_ram_index & 0xff) | ((data & 0xff) << 8);
+ break;
+
+ case 2: // PAC2 RAM write
+ m_ram[m_ram_index & (m_ram_size - 1)] = data;
+ break;
+ }
+}
diff --git a/src/devices/bus/pasopia/rampac2.h b/src/devices/bus/pasopia/rampac2.h
new file mode 100644
index 00000000000..b2ad3633394
--- /dev/null
+++ b/src/devices/bus/pasopia/rampac2.h
@@ -0,0 +1,76 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+
+#ifndef MAME_BUS_PASOPIA_RAMPAC2_H
+#define MAME_BUS_PASOPIA_RAMPAC2_H
+
+#pragma once
+
+#include "pac2.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> pasopia_rampac2_device
+
+class pasopia_rampac2_device : public device_t, public pac2_card_interface, public device_nvram_interface
+{
+protected:
+ // construction/destruction
+ pasopia_rampac2_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 ram_size);
+
+ // device-level overrides
+ virtual void device_start() override;
+
+ // device_nvram_interface overrides
+ virtual void nvram_read(emu_file &file) override;
+ virtual void nvram_write(emu_file &file) override;
+ virtual void nvram_default() override;
+
+ // pac2_card_interface overrides
+ virtual u8 pac2_read(offs_t offset) override;
+ virtual void pac2_write(offs_t offset, u8 data) override;
+
+private:
+ const u32 m_ram_size;
+
+ // internal state
+ std::unique_ptr<u8[]> m_ram;
+ u16 m_ram_index;
+};
+
+// ======================> pasopia_pa7243_device
+
+class pasopia_pa7243_device : public pasopia_rampac2_device
+{
+public:
+ // device type constructor
+ pasopia_pa7243_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+};
+
+// ======================> pasopia_pa7245_device
+
+class pasopia_pa7245_device : public pasopia_rampac2_device
+{
+public:
+ // device type constructor
+ pasopia_pa7245_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+};
+
+// ======================> pasopia_pa7248_device
+
+class pasopia_pa7248_device : public pasopia_rampac2_device
+{
+public:
+ // device type constructor
+ pasopia_pa7248_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+};
+
+// device type declarations
+DECLARE_DEVICE_TYPE(PASOPIA_PA7243, pasopia_pa7243_device)
+DECLARE_DEVICE_TYPE(PASOPIA_PA7245, pasopia_pa7245_device)
+DECLARE_DEVICE_TYPE(PASOPIA_PA7248, pasopia_pa7248_device)
+
+#endif // MAME_BUS_PASOPIA_RAMPAC2_H
diff --git a/src/devices/bus/pasopia/rompac2.cpp b/src/devices/bus/pasopia/rompac2.cpp
new file mode 100644
index 00000000000..5ec120ac120
--- /dev/null
+++ b/src/devices/bus/pasopia/rompac2.cpp
@@ -0,0 +1,98 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR, Angelo Salese
+/****************************************************************************
+
+ Toshiba Pasopia Kanji ROM PAC2 emulation
+
+ TODO: find out the difference between PA7246 and PA7247 (which one
+ is actually dumped here?)
+
+****************************************************************************/
+
+#include "emu.h"
+#include "rompac2.h"
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+// device type definition
+DEFINE_DEVICE_TYPE(PASOPIA_PA7246, pasopia_pa7246_device, "pa7246", "PA7246 Pasopia Kanji ROM PAC2")
+
+//**************************************************************************
+// DEVICE DEFINITION
+//**************************************************************************
+
+//-------------------------------------------------
+// pasopia_pa7246_device - construction
+//-------------------------------------------------
+
+pasopia_pa7246_device::pasopia_pa7246_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
+ : device_t(mconfig, PASOPIA_PA7246, tag, owner, clock)
+ , pac2_card_interface(mconfig, *this)
+ , m_kanji_rom(*this, "kanji")
+ , m_kanji_index(0)
+{
+}
+
+
+ROM_START(pa7246)
+ ROM_REGION(0x20000, "kanji", 0)
+ ROM_LOAD("kanji.rom", 0x00000, 0x20000, CRC(6109e308) SHA1(5c21cf1f241ef1fa0b41009ea41e81771729785f))
+ROM_END
+
+//-------------------------------------------------
+// device_rom_region - return a pointer to the
+// rom region description for this device
+//-------------------------------------------------
+
+const tiny_rom_entry *pasopia_pa7246_device::device_rom_region() const
+{
+ return ROM_NAME(pa7246);
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void pasopia_pa7246_device::device_start()
+{
+ save_item(NAME(m_kanji_index));
+}
+
+//**************************************************************************
+// PAC2 INTERFACE
+//**************************************************************************
+
+//-------------------------------------------------
+// pac2_read - I/O read access
+//-------------------------------------------------
+
+u8 pasopia_pa7246_device::pac2_read(offs_t offset)
+{
+ return m_kanji_rom[m_kanji_index];
+}
+
+
+//-------------------------------------------------
+// pac2_write - I/O write access
+//-------------------------------------------------
+
+void pasopia_pa7246_device::pac2_write(offs_t offset, u8 data)
+{
+ switch (offset)
+ {
+ case 0:
+ m_kanji_index = (m_kanji_index & 0x1ff00) | ((data & 0xff) << 0);
+ break;
+
+ case 1:
+ m_kanji_index = (m_kanji_index & 0x100ff) | ((data & 0xff) << 8);
+ break;
+
+ case 2:
+ m_kanji_index = (m_kanji_index & 0x0ffff) | ((data & 0x01) << 16);
+ break;
+ }
+}
diff --git a/src/devices/bus/pasopia/rompac2.h b/src/devices/bus/pasopia/rompac2.h
new file mode 100644
index 00000000000..1b734e3b29f
--- /dev/null
+++ b/src/devices/bus/pasopia/rompac2.h
@@ -0,0 +1,44 @@
+// license:BSD-3-Clause
+// copyright-holders:AJR
+
+#ifndef MAME_BUS_PASOPIA_ROMPAC2_H
+#define MAME_BUS_PASOPIA_ROMPAC2_H
+
+#pragma once
+
+#include "pac2.h"
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> pasopia_pa7246_device
+
+class pasopia_pa7246_device : public device_t, public pac2_card_interface
+{
+public:
+ // device type constructor
+ pasopia_pa7246_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
+
+protected:
+ // device-level overrides
+ virtual const tiny_rom_entry *device_rom_region() const override;
+ virtual void device_start() override;
+
+ // pac2_card_interface overrides
+ virtual u8 pac2_read(offs_t offset) override;
+ virtual void pac2_write(offs_t offset, u8 data) override;
+
+private:
+ // object finders
+ required_region_ptr<u8> m_kanji_rom;
+
+ // internal state
+ u32 m_kanji_index;
+};
+
+// device type declaration
+DECLARE_DEVICE_TYPE(PASOPIA_PA7246, pasopia_pa7246_device)
+
+#endif // MAME_BUS_PASOPIA_ROMPAC2_H
diff --git a/src/mame/drivers/pasopia.cpp b/src/mame/drivers/pasopia.cpp
index 494e601c7b8..20ed052f766 100644
--- a/src/mame/drivers/pasopia.cpp
+++ b/src/mame/drivers/pasopia.cpp
@@ -25,6 +25,7 @@
#include "emu.h"
#include "includes/pasopia.h"
+#include "bus/pasopia/pac2.h"
#include "cpu/z80/z80.h"
#include "machine/i8255.h"
#include "machine/z80ctc.h"
@@ -168,8 +169,8 @@ void pasopia_state::pasopia_io(address_map &map)
map(0x08, 0x0b).rw(m_ppi1, FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x10, 0x10).rw(m_crtc, FUNC(mc6845_device::status_r), FUNC(mc6845_device::address_w));
map(0x11, 0x11).rw(m_crtc, FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w));
-// 0x18 - 0x1b pac2
-// 0x1c - 0x1f something
+ map(0x18, 0x1b).rw("dtfcst", FUNC(pasopia_pac2_slot_device::read), FUNC(pasopia_pac2_slot_device::write));
+ map(0x1c, 0x1f).rw("dtfunt", FUNC(pasopia_pac2_slot_device::read), FUNC(pasopia_pac2_slot_device::write));
map(0x20, 0x23).rw(m_ppi2, FUNC(i8255_device::read), FUNC(i8255_device::write));
map(0x28, 0x2b).rw(m_ctc, FUNC(z80ctc_device::read), FUNC(z80ctc_device::write));
map(0x30, 0x33).rw(m_pio, FUNC(z80pio_device::read), FUNC(z80pio_device::write));
@@ -376,6 +377,9 @@ void pasopia_state::pasopia(machine_config &config)
m_cass->set_default_state(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED);
m_cass->add_route(ALL_OUTPUTS, "mono", 0.05);
+ PASOPIA_PAC2(config, "dtfcst", pac2_default_devices, nullptr); // "Data File Cassette"
+ PASOPIA_PAC2(config, "dtfunt", pac2_default_devices, nullptr); // "Data File Unit"
+
SOFTWARE_LIST(config, "cass_list").set_original("pasopia_cass");
}
diff --git a/src/mame/drivers/pasopia7.cpp b/src/mame/drivers/pasopia7.cpp
index 92f1b8036e5..3dd0dabb6b8 100644
--- a/src/mame/drivers/pasopia7.cpp
+++ b/src/mame/drivers/pasopia7.cpp
@@ -30,6 +30,7 @@
#include "emu.h"
#include "includes/pasopia.h"
+#include "bus/pasopia/pac2.h"
#include "cpu/z80/z80.h"
#include "imagedev/floppy.h"
#include "machine/i8255.h"
@@ -65,6 +66,7 @@ public:
, m_palette(*this, "palette")
, m_keyboard(*this, "KEY.%d", 0)
, m_cass(*this, "cassette")
+ , m_pac2(*this, "pac2")
, m_speaker(*this, "speaker")
, m_font_rom(*this, "font")
{ }
@@ -83,8 +85,6 @@ private:
uint8_t vram_r(offs_t offset);
void vram_w(offs_t offset, uint8_t data);
void memory_ctrl_w(uint8_t data);
- void pac2_w(offs_t offset, uint8_t data);
- uint8_t pac2_r(offs_t offset);
void ram_bank_w(offs_t offset, uint8_t data);
void pasopia7_6845_w(offs_t offset, uint8_t data);
uint8_t io_r(offs_t offset);
@@ -131,9 +131,6 @@ private:
uint8_t m_nmi_enable_reg;
uint8_t m_nmi_trap;
uint8_t m_nmi_reset;
- uint16_t m_pac2_index[2];
- uint32_t m_kanji_index;
- uint8_t m_pac2_bank_select;
uint8_t m_screen_type;
void pasopia_nmi_trap();
uint8_t m_mux_data;
@@ -161,6 +158,7 @@ private:
required_device<palette_device> m_palette;
required_ioport_array<12> m_keyboard;
required_device<cassette_image_device> m_cass;
+ required_device<pasopia_pac2_slot_device> m_pac2;
required_device<speaker_sound_device> m_speaker;
required_region_ptr<uint8_t> m_font_rom;
};
@@ -378,82 +376,6 @@ void pasopia7_state::memory_ctrl_w(uint8_t data)
// printf("%02x\n",m_vram_sel);
}
-
-void pasopia7_state::pac2_w(offs_t offset, uint8_t data)
-{
- /*
- select register:
- 4 = ram1;
- 3 = ram2;
- 2 = kanji ROM;
- 1 = joy;
- anything else is nop
- */
-
- if(m_pac2_bank_select == 3 || m_pac2_bank_select == 4)
- {
- switch(offset)
- {
- case 0: m_pac2_index[(m_pac2_bank_select-3) & 1] = (m_pac2_index[(m_pac2_bank_select-3) & 1] & 0x7f00) | (data & 0xff); break;
- case 1: m_pac2_index[(m_pac2_bank_select-3) & 1] = (m_pac2_index[(m_pac2_bank_select-3) & 1] & 0xff) | ((data & 0x7f) << 8); break;
- case 2: // PAC2 RAM write
- {
- uint8_t *pac2_ram;
-
- pac2_ram = memregion(((m_pac2_bank_select-3) & 1) ? "rampac2" : "rampac1")->base();
-
- pac2_ram[m_pac2_index[(m_pac2_bank_select-3) & 1]] = data;
- }
- }
- }
- else if(m_pac2_bank_select == 2) // kanji ROM
- {
- switch(offset)
- {
- case 0: m_kanji_index = (m_kanji_index & 0x1ff00) | ((data & 0xff) << 0); break;
- case 1: m_kanji_index = (m_kanji_index & 0x100ff) | ((data & 0xff) << 8); break;
- case 2: m_kanji_index = (m_kanji_index & 0x0ffff) | ((data & 0x01) << 16); break;
- }
- }
-
- if(offset == 3)
- {
- if(data & 0x80)
- {
- // ...
- }
- else
- m_pac2_bank_select = data & 7;
- }
-}
-
-uint8_t pasopia7_state::pac2_r(offs_t offset)
-{
- if(offset == 2)
- {
- if(m_pac2_bank_select == 3 || m_pac2_bank_select == 4)
- {
- uint8_t *pac2_ram;
-
- pac2_ram = memregion(((m_pac2_bank_select-3) & 1) ? "rampac2" : "rampac1")->base();
-
- return pac2_ram[m_pac2_index[(m_pac2_bank_select-3) & 1]];
- }
- else if(m_pac2_bank_select == 2)
- {
- uint8_t *kanji_rom = memregion("kanji")->base();
-
- return kanji_rom[m_kanji_index];
- }
- else
- {
- //printf("RAMPAC bank_select = %02x\n",m_pac2_bank_select);
- }
- }
-
- return 0xff;
-}
-
/* writes always occurs to the RAM banks, even if the ROMs are selected. */
void pasopia7_state::ram_bank_w(offs_t offset, uint8_t data)
{
@@ -544,7 +466,7 @@ uint8_t pasopia7_state::io_r(offs_t offset)
return m_crtc->register_r();
else
if(io_port >= 0x18 && io_port <= 0x1b)
- return pac2_r(io_port & 3);
+ return m_pac2->read(io_port & 3);
else
if(io_port >= 0x20 && io_port <= 0x23)
{
@@ -593,7 +515,7 @@ void pasopia7_state::io_w(offs_t offset, uint8_t data)
pasopia7_6845_w(io_port-0x10, data);
else
if(io_port >= 0x18 && io_port <= 0x1b)
- pac2_w(io_port & 3, data);
+ m_pac2->write(io_port & 3, data);
else
if(io_port >= 0x20 && io_port <= 0x23)
{
@@ -679,20 +601,8 @@ static const gfx_layout p7_chars_8x8 =
8*8
};
-static const gfx_layout p7_chars_16x16 =
-{
- 16,16,
- RGN_FRAC(1,1),
- 1,
- { 0 },
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
- { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 },
- 16*16
-};
-
static GFXDECODE_START( gfx_pasopia7 )
GFXDECODE_ENTRY( "font", 0x00000, p7_chars_8x8, 0, 0x10 )
- GFXDECODE_ENTRY( "kanji", 0x00000, p7_chars_16x16, 0, 0x10 )
GFXDECODE_END
uint8_t pasopia7_state::keyb_r()
@@ -928,6 +838,8 @@ void pasopia7_state::p7_base(machine_config &config)
CASSETTE(config, m_cass);
m_cass->set_default_state(CASSETTE_PLAY | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED);
m_cass->add_route(ALL_OUTPUTS, "mono", 0.05);
+
+ PASOPIA_PAC2(config, m_pac2, pac2_default_devices, nullptr);
}
void pasopia7_state::p7_raster(machine_config &config)
@@ -985,15 +897,6 @@ ROM_START( pasopia7 )
ROM_REGION( 0x800, "font", ROMREGION_ERASEFF )
ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(a91c45a9) SHA1(a472adf791b9bac3dfa6437662e1a9e94a88b412))
-
- ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF )
- ROM_LOAD( "kanji.rom", 0x0000, 0x20000, CRC(6109e308) SHA1(5c21cf1f241ef1fa0b41009ea41e81771729785f))
-
- ROM_REGION( 0x8000, "rampac1", ROMREGION_ERASEFF )
-// ROM_LOAD( "rampac1.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) )
-
- ROM_REGION( 0x8000, "rampac2", ROMREGION_ERASEFF )
-// ROM_LOAD( "rampac2.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) )
ROM_END
/* using an identical ROMset from now, but the screen type is different */
@@ -1006,15 +909,6 @@ ROM_START( pasopia7lcd )
ROM_REGION( 0x800, "font", ROMREGION_ERASEFF )
ROM_LOAD( "font.rom", 0x0000, 0x0800, BAD_DUMP CRC(a91c45a9) SHA1(a472adf791b9bac3dfa6437662e1a9e94a88b412))
-
- ROM_REGION( 0x20000, "kanji", ROMREGION_ERASEFF )
- ROM_LOAD( "kanji.rom", 0x0000, 0x20000, CRC(6109e308) SHA1(5c21cf1f241ef1fa0b41009ea41e81771729785f))
-
- ROM_REGION( 0x8000, "rampac1", ROMREGION_ERASEFF )
-// ROM_LOAD( "rampac1.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) )
-
- ROM_REGION( 0x8000, "rampac2", ROMREGION_ERASEFF )
-// ROM_LOAD( "rampac2.bin", 0x0000, 0x8000, CRC(0e4f09bd) SHA1(4088906d57e4f6085a75b249a6139a0e2eb531a1) )
ROM_END