summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Curt Coder <curtcoder@mail.com>2016-08-08 13:40:03 +0300
committer Curt Coder <curtcoder@mail.com>2016-08-08 14:44:20 +0300
commit6673af1285376eee38a7fa0f924ddf5b61c3c654 (patch)
treeeec6b480351bf436d1279e4a1a660fd12302a0e2 /src
parentf67311c5a5b1e08a0d285795d9182683a270a2d8 (diff)
pofo: Added memory card slot interface and ROM/RAM cards. [Curt Coder]
Diffstat (limited to 'src')
-rw-r--r--src/devices/bus/pofo/ccm.cpp109
-rw-r--r--src/devices/bus/pofo/ccm.h120
-rw-r--r--src/devices/bus/pofo/ram.cpp63
-rw-r--r--src/devices/bus/pofo/ram.h56
-rw-r--r--src/devices/bus/pofo/rom.cpp51
-rw-r--r--src/devices/bus/pofo/rom.h48
-rw-r--r--src/mame/drivers/pofo.cpp57
7 files changed, 470 insertions, 34 deletions
diff --git a/src/devices/bus/pofo/ccm.cpp b/src/devices/bus/pofo/ccm.cpp
new file mode 100644
index 00000000000..a28f29c7637
--- /dev/null
+++ b/src/devices/bus/pofo/ccm.cpp
@@ -0,0 +1,109 @@
+// license:BSD-3-Clause
+// copyright-holders:Curt Coder
+/**********************************************************************
+
+ Atari Portfolio Memory Card Port emulation
+
+**********************************************************************/
+
+#include "ccm.h"
+
+
+
+//**************************************************************************
+// GLOBAL VARIABLES
+//**************************************************************************
+
+const device_type PORTFOLIO_MEMORY_CARD_SLOT = &device_creator<portfolio_memory_card_slot_t>;
+
+
+
+//**************************************************************************
+// CARD INTERFACE
+//**************************************************************************
+
+//-------------------------------------------------
+// device_portfolio_memory_card_slot_interface - constructor
+//-------------------------------------------------
+
+device_portfolio_memory_card_slot_interface::device_portfolio_memory_card_slot_interface(const machine_config &mconfig, device_t &device) :
+ device_slot_card_interface(mconfig, device),
+ m_rom(*this, "rom"),
+ m_nvram(*this, "nvram")
+{
+ m_slot = dynamic_cast<portfolio_memory_card_slot_t *>(device.owner());
+}
+
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// portfolio_memory_card_slot_t - constructor
+//-------------------------------------------------
+
+portfolio_memory_card_slot_t::portfolio_memory_card_slot_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
+ device_t(mconfig, PORTFOLIO_MEMORY_CARD_SLOT, "Atari Portfolio memory card port", tag, owner, clock, "portfolio_ccm_slot", __FILE__),
+ device_slot_interface(mconfig, *this),
+ device_image_interface(mconfig, *this),
+ m_card(nullptr)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void portfolio_memory_card_slot_t::device_start()
+{
+ m_card = dynamic_cast<device_portfolio_memory_card_slot_interface *>(get_card_device());
+}
+
+
+//-------------------------------------------------
+// call_load -
+//-------------------------------------------------
+
+image_init_result portfolio_memory_card_slot_t::call_load()
+{
+ if (m_card)
+ {
+ if (software_entry() == nullptr)
+ {
+ fread(m_card->m_rom, length());
+ }
+ else
+ {
+ load_software_region("rom", m_card->m_rom);
+ }
+ }
+
+ return image_init_result::PASS;
+}
+
+
+//-------------------------------------------------
+// get_default_card_software -
+//-------------------------------------------------
+
+std::string portfolio_memory_card_slot_t::get_default_card_software()
+{
+ return software_get_default_slot("rom");
+}
+
+
+//-------------------------------------------------
+// SLOT_INTERFACE( portfolio_memory_cards )
+//-------------------------------------------------
+
+// slot devices
+#include "ram.h"
+#include "rom.h"
+
+SLOT_INTERFACE_START( portfolio_memory_cards )
+ SLOT_INTERFACE("ram", PORTFOLIO_RAM_CARD)
+ SLOT_INTERFACE("rom", PORTFOLIO_ROM_CARD)
+SLOT_INTERFACE_END
diff --git a/src/devices/bus/pofo/ccm.h b/src/devices/bus/pofo/ccm.h
new file mode 100644
index 00000000000..f8387326207
--- /dev/null
+++ b/src/devices/bus/pofo/ccm.h
@@ -0,0 +1,120 @@
+// license:BSD-3-Clause
+// copyright-holders:Curt Coder
+/**********************************************************************
+
+ Atari Portfolio Memory Card port emulation
+
+**********************************************************************
+
+**********************************************************************/
+
+#pragma once
+
+#ifndef __PORTFOLIO_MEMORY_CARD_SLOT__
+#define __PORTFOLIO_MEMORY_CARD_SLOT__
+
+#include "emu.h"
+
+
+
+//**************************************************************************
+// CONSTANTS
+//**************************************************************************
+
+#define PORTFOLIO_MEMORY_CARD_SLOT_A_TAG "ccma"
+#define PORTFOLIO_MEMORY_CARD_SLOT_B_TAG "ccmb"
+
+
+
+//**************************************************************************
+// INTERFACE CONFIGURATION MACROS
+//**************************************************************************
+
+#define MCFG_PORTFOLIO_MEMORY_CARD_SLOT_ADD(_tag, _slot_intf, _def_slot) \
+ MCFG_DEVICE_ADD(_tag, PORTFOLIO_MEMORY_CARD_SLOT, 0) \
+ MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
+
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> device_portfolio_memory_card_slot_interface
+
+class portfolio_memory_card_slot_t;
+
+class device_portfolio_memory_card_slot_interface : public device_slot_card_interface
+{
+ friend class portfolio_memory_card_slot_t;
+
+public:
+ // construction/destruction
+ device_portfolio_memory_card_slot_interface(const machine_config &mconfig, device_t &device);
+ virtual ~device_portfolio_memory_card_slot_interface() { }
+
+ virtual bool cdet() { return 1; }
+
+ virtual UINT8 nrdi_r(address_space &space, offs_t offset) { return 0xff; };
+ virtual void nwri_w(address_space &space, offs_t offset, UINT8 data) { };
+
+protected:
+ optional_shared_ptr<UINT8> m_rom;
+ optional_shared_ptr<UINT8> m_nvram;
+
+ portfolio_memory_card_slot_t *m_slot;
+};
+
+
+// ======================> portfolio_memory_card_slot_t
+
+class portfolio_memory_card_slot_t : public device_t,
+ public device_slot_interface,
+ public device_image_interface
+{
+public:
+ // construction/destruction
+ portfolio_memory_card_slot_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+ virtual ~portfolio_memory_card_slot_t() { }
+
+ // computer interface
+ bool cdet_r() { return (m_card != nullptr) ? m_card->cdet() : 1; }
+
+ DECLARE_READ8_MEMBER( nrdi_r ) { return (m_card != nullptr) ? m_card->nrdi_r(space, offset) : 0xff; }
+ DECLARE_WRITE8_MEMBER( nwri_w ) { if (m_card != nullptr) m_card->nwri_w(space, offset, data); }
+
+protected:
+ // device-level overrides
+ virtual void device_config_complete() override { update_names(); }
+ virtual void device_start() override;
+
+ // image-level overrides
+ virtual image_init_result call_load() override;
+ virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); }
+
+ 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 1; }
+ virtual bool is_creatable() const override { return 1; }
+ 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 "pofo_card"; }
+ virtual const char *file_extensions() const override { return "rom,bin"; }
+
+ // slot interface overrides
+ virtual std::string get_default_card_software() override;
+
+ device_portfolio_memory_card_slot_interface *m_card;
+};
+
+
+// device type definition
+extern const device_type PORTFOLIO_MEMORY_CARD_SLOT;
+
+
+SLOT_INTERFACE_EXTERN( portfolio_memory_cards );
+
+
+
+#endif
diff --git a/src/devices/bus/pofo/ram.cpp b/src/devices/bus/pofo/ram.cpp
new file mode 100644
index 00000000000..e1fdce1b7ad
--- /dev/null
+++ b/src/devices/bus/pofo/ram.cpp
@@ -0,0 +1,63 @@
+// license:BSD-3-Clause
+// copyright-holders:Curt Coder
+/**********************************************************************
+
+ Atari Portfolio 128KB RAM card emulation
+
+**********************************************************************/
+
+#include "ram.h"
+
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+const device_type PORTFOLIO_RAM_CARD = &device_creator<portfolio_ram_card_t>;
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// portfolio_ram_card_t - constructor
+//-------------------------------------------------
+
+portfolio_ram_card_t::portfolio_ram_card_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
+ device_t(mconfig, PORTFOLIO_RAM_CARD, "Atari Portfolio RAM card", tag, owner, clock, "portfolio_ram_card", __FILE__),
+ device_portfolio_memory_card_slot_interface(mconfig, *this),
+ device_nvram_interface(mconfig, *this)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void portfolio_ram_card_t::device_start()
+{
+ m_nvram.allocate(0x20000);
+}
+
+
+//-------------------------------------------------
+// nrdi_r - read
+//-------------------------------------------------
+
+UINT8 portfolio_ram_card_t::nrdi_r(address_space &space, offs_t offset)
+{
+ return m_nvram[offset];
+}
+
+
+//-------------------------------------------------
+// nwri_w - write
+//-------------------------------------------------
+
+void portfolio_ram_card_t::nwri_w(address_space &space, offs_t offset, UINT8 data)
+{
+ m_nvram[offset] = data;
+}
diff --git a/src/devices/bus/pofo/ram.h b/src/devices/bus/pofo/ram.h
new file mode 100644
index 00000000000..fb8f7917890
--- /dev/null
+++ b/src/devices/bus/pofo/ram.h
@@ -0,0 +1,56 @@
+// license:BSD-3-Clause
+// copyright-holders:Curt Coder
+/**********************************************************************
+
+ Atari Portfolio 128KB RAM card emulation
+
+**********************************************************************/
+
+#pragma once
+
+#ifndef __PORTFOLIO_RAM_CARD__
+#define __PORTFOLIO_RAM_CARD__
+
+#include "emu.h"
+#include "ccm.h"
+#include "machine/nvram.h"
+
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> portfolio_ram_card_t
+
+class portfolio_ram_card_t : public device_t,
+ public device_portfolio_memory_card_slot_interface,
+ public device_nvram_interface
+{
+public:
+ // construction/destruction
+ portfolio_ram_card_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+ // device_nvram_interface overrides
+ virtual void nvram_default() override { }
+ virtual void nvram_read(emu_file &file) override { if (m_nvram != nullptr) { file.read(m_nvram, m_nvram.bytes()); } }
+ virtual void nvram_write(emu_file &file) override { if (m_nvram != nullptr) { file.write(m_nvram, m_nvram.bytes()); } }
+
+ // device_portfolio_memory_card_slot_interface overrides
+ bool cdet() override { return 0; }
+
+ virtual UINT8 nrdi_r(address_space &space, offs_t offset) override;
+ virtual void nwri_w(address_space &space, offs_t offset, UINT8 data) override;
+};
+
+
+// device type definition
+extern const device_type PORTFOLIO_RAM_CARD;
+
+
+
+#endif
diff --git a/src/devices/bus/pofo/rom.cpp b/src/devices/bus/pofo/rom.cpp
new file mode 100644
index 00000000000..fbc4c5961b5
--- /dev/null
+++ b/src/devices/bus/pofo/rom.cpp
@@ -0,0 +1,51 @@
+// license:BSD-3-Clause
+// copyright-holders:Curt Coder
+/**********************************************************************
+
+ Atari Portfolio ROM card emulation
+
+**********************************************************************/
+
+#include "rom.h"
+
+
+
+//**************************************************************************
+// DEVICE DEFINITIONS
+//**************************************************************************
+
+const device_type PORTFOLIO_ROM_CARD = &device_creator<portfolio_rom_card_t>;
+
+
+//**************************************************************************
+// LIVE DEVICE
+//**************************************************************************
+
+//-------------------------------------------------
+// portfolio_rom_card_t - constructor
+//-------------------------------------------------
+
+portfolio_rom_card_t::portfolio_rom_card_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
+ device_t(mconfig, PORTFOLIO_ROM_CARD, "Atari Portfolio ROM card", tag, owner, clock, "portfolio_rom_card", __FILE__),
+ device_portfolio_memory_card_slot_interface(mconfig, *this)
+{
+}
+
+
+//-------------------------------------------------
+// device_start - device-specific startup
+//-------------------------------------------------
+
+void portfolio_rom_card_t::device_start()
+{
+}
+
+
+//-------------------------------------------------
+// nrdi_r - read
+//-------------------------------------------------
+
+UINT8 portfolio_rom_card_t::nrdi_r(address_space &space, offs_t offset)
+{
+ return m_rom[offset];
+}
diff --git a/src/devices/bus/pofo/rom.h b/src/devices/bus/pofo/rom.h
new file mode 100644
index 00000000000..4d854b5b9f8
--- /dev/null
+++ b/src/devices/bus/pofo/rom.h
@@ -0,0 +1,48 @@
+// license:BSD-3-Clause
+// copyright-holders:Curt Coder
+/**********************************************************************
+
+ Atari Portfolio ROM card emulation
+
+**********************************************************************/
+
+#pragma once
+
+#ifndef __PORTFOLIO_ROM_CARD__
+#define __PORTFOLIO_ROM_CARD__
+
+#include "emu.h"
+#include "ccm.h"
+
+
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> portfolio_rom_card_t
+
+class portfolio_rom_card_t : public device_t,
+ public device_portfolio_memory_card_slot_interface
+{
+public:
+ // construction/destruction
+ portfolio_rom_card_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+
+ // device_portfolio_memory_card_slot_interface overrides
+ bool cdet() override { return 0; }
+
+ virtual UINT8 nrdi_r(address_space &space, offs_t offset) override;
+};
+
+
+// device type definition
+extern const device_type PORTFOLIO_ROM_CARD;
+
+
+
+#endif
diff --git a/src/mame/drivers/pofo.cpp b/src/mame/drivers/pofo.cpp
index 8e3500e10e1..7b7405244d4 100644
--- a/src/mame/drivers/pofo.cpp
+++ b/src/mame/drivers/pofo.cpp
@@ -28,8 +28,7 @@
#include "rendlay.h"
#include "softlist.h"
#include "cpu/i86/i86.h"
-#include "bus/generic/slot.h"
-#include "bus/generic/carts.h"
+#include "bus/pofo/ccm.h"
#include "bus/pofo/exp.h"
#include "machine/nvram.h"
#include "machine/ram.h"
@@ -51,7 +50,7 @@ public:
m_maincpu(*this, M80C88A_TAG),
m_lcdc(*this, HD61830_TAG),
m_speaker(*this, "speaker"),
- m_card(*this, "cardslot"),
+ m_ccm(*this, PORTFOLIO_MEMORY_CARD_SLOT_A_TAG),
m_exp(*this, PORTFOLIO_EXPANSION_SLOT_TAG),
m_timer_tick(*this, TIMER_TICK_TAG),
m_rom(*this, M80C88A_TAG),
@@ -72,7 +71,7 @@ public:
required_device<cpu_device> m_maincpu;
required_device<hd61830_device> m_lcdc;
required_device<speaker_sound_device> m_speaker;
- required_device<generic_slot_device> m_card;
+ required_device<portfolio_memory_card_slot_t> m_ccm;
required_device<portfolio_expansion_slot_t> m_exp;
required_device<timer_device> m_timer_tick;
required_region_ptr<UINT8> m_rom;
@@ -111,6 +110,7 @@ public:
};
DECLARE_READ8_MEMBER( rom_b_r );
+ DECLARE_WRITE8_MEMBER( rom_b_w );
DECLARE_READ8_MEMBER( irq_status_r );
DECLARE_READ8_MEMBER( keyboard_r );
@@ -148,7 +148,6 @@ public:
TIMER_DEVICE_CALLBACK_MEMBER(counter_tick);
DECLARE_READ8_MEMBER(hd61830_rd_r);
IRQ_CALLBACK_MEMBER(portfolio_int_ack);
- DECLARE_DEVICE_IMAGE_LOAD_MEMBER( portfolio_card );
required_device<ram_device> m_ram;
};
@@ -477,10 +476,7 @@ READ8_MEMBER( portfolio_state::rom_b_r )
break;
case CCM_A:
- if (m_card->exists())
- {
- data = m_card->read_rom(space, offset);
- }
+ data = m_ccm->nrdi_r(space, offset & 0x1ffff);
break;
case CCM_B:
@@ -497,6 +493,21 @@ READ8_MEMBER( portfolio_state::rom_b_r )
//-------------------------------------------------
+// rom_b_w -
+//-------------------------------------------------
+
+WRITE8_MEMBER( portfolio_state::rom_b_w )
+{
+ switch (m_rom_b)
+ {
+ case CCM_A:
+ m_ccm->nwri_w(space, offset & 0x1ffff, data);
+ break;
+ }
+}
+
+
+//-------------------------------------------------
// counter_r - counter register read
//-------------------------------------------------
@@ -551,7 +562,7 @@ static ADDRESS_MAP_START( portfolio_mem, AS_PROGRAM, 8, portfolio_state )
AM_RANGE(0x00000, 0x1efff) AM_RAM AM_SHARE("nvram1")
AM_RANGE(0x1f000, 0x9efff) AM_RAM // expansion
AM_RANGE(0xb0000, 0xb0fff) AM_MIRROR(0xf000) AM_RAM AM_SHARE("nvram2") // video RAM
- AM_RANGE(0xc0000, 0xdffff) AM_READ(rom_b_r)
+ AM_RANGE(0xc0000, 0xdffff) AM_READWRITE(rom_b_r, rom_b_w)
AM_RANGE(0xe0000, 0xfffff) AM_ROM AM_REGION(M80C88A_TAG, 0x20000)
ADDRESS_MAP_END
@@ -735,25 +746,6 @@ WRITE_LINE_MEMBER( portfolio_state::eint_w )
trigger_interrupt(INT_EXTERNAL);
}
-//**************************************************************************
-// IMAGE LOADING
-//**************************************************************************
-
-//-------------------------------------------------
-// DEVICE_IMAGE_LOAD( portfolio_card )
-//-------------------------------------------------
-
-DEVICE_IMAGE_LOAD_MEMBER( portfolio_state, portfolio_card )
-{
- UINT32 size = m_card->common_get_size("rom");
-
- m_card->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_BIG);
- m_card->common_load_rom(m_card->get_rom_base(), size, "rom");
-
- return image_init_result::PASS;
-}
-
-
//**************************************************************************
// MACHINE INITIALIZATION
@@ -841,6 +833,8 @@ static MACHINE_CONFIG_START( portfolio, portfolio_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
// devices
+ MCFG_PORTFOLIO_MEMORY_CARD_SLOT_ADD(PORTFOLIO_MEMORY_CARD_SLOT_A_TAG, portfolio_memory_cards, nullptr)
+
MCFG_PORTFOLIO_EXPANSION_SLOT_ADD(PORTFOLIO_EXPANSION_SLOT_TAG, XTAL_4_9152MHz, portfolio_expansion_cards, nullptr)
MCFG_PORTFOLIO_EXPANSION_SLOT_IINT_CALLBACK(WRITELINE(portfolio_state, iint_w))
MCFG_PORTFOLIO_EXPANSION_SLOT_EINT_CALLBACK(WRITELINE(portfolio_state, eint_w))
@@ -853,11 +847,6 @@ static MACHINE_CONFIG_START( portfolio, portfolio_state )
/* fake keyboard */
MCFG_TIMER_DRIVER_ADD_PERIODIC("keyboard", portfolio_state, keyboard_tick, attotime::from_usec(2500))
- /* cartridge */
- MCFG_GENERIC_CARTSLOT_ADD("cardslot", generic_plain_slot, "pofo_card")
- MCFG_GENERIC_EXTENSIONS("rom,bin")
- MCFG_GENERIC_LOAD(portfolio_state, portfolio_card)
-
/* software lists */
MCFG_SOFTWARE_LIST_ADD("cart_list", "pofo")