diff options
author | Erwin Jansen <pokowaka@users.noreply.github.com> | 2020-10-07 10:07:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 04:07:38 +1100 |
commit | 75741b3cb763a848d7d9c8da52ed9d863e0875c6 (patch) | |
tree | 72901ea49a62d0645bae315772959ee82c390340 | |
parent | 83ba872b6a35d3a7393d56ba6b08c8663fc2d257 (diff) |
P2000t: Add support for selecting memory and bankswitching. (#7280)
-rw-r--r-- | src/mame/drivers/p2000t.cpp | 13 | ||||
-rw-r--r-- | src/mame/includes/p2000t.h | 28 | ||||
-rw-r--r-- | src/mame/machine/p2000t.cpp | 30 |
3 files changed, 55 insertions, 16 deletions
diff --git a/src/mame/drivers/p2000t.cpp b/src/mame/drivers/p2000t.cpp index 3c7f428d37f..9cba555622a 100644 --- a/src/mame/drivers/p2000t.cpp +++ b/src/mame/drivers/p2000t.cpp @@ -56,8 +56,8 @@ void p2000t_state::p2000t_mem(address_map &map) map(0x0000, 0x0fff).rom(); map(0x1000, 0x4fff).rom(); map(0x5000, 0x57ff).ram().share("videoram"); - map(0x5800, 0x9fff).ram(); - map(0xa000, 0xffff).noprw(); + map(0x5800, 0xdfff).ram(); + map(0xe000, 0xffff).bankrw(m_bank); } void p2000m_state::p2000m_mem(address_map &map) @@ -65,8 +65,8 @@ void p2000m_state::p2000m_mem(address_map &map) map(0x0000, 0x0fff).rom(); map(0x1000, 0x4fff).rom(); map(0x5000, 0x5fff).ram().share("videoram"); - map(0x6000, 0x9fff).ram(); - map(0xa000, 0xffff).noprw(); + map(0x6000, 0xdfff).ram(); + map(0xe000, 0xffff).bankrw(m_bank); } /* graphics output */ @@ -248,6 +248,9 @@ void p2000t_state::p2000t(machine_config &config) /* the mini cassette driver */ MDCR(config, m_mdcr, 0); + + /* internal ram */ + RAM(config, m_ram).set_default_size("16K").set_extra_options("16K,32K,48K,64K,80K,102K"); } @@ -279,6 +282,8 @@ void p2000m_state::p2000m(machine_config &config) /* the mini cassette driver */ MDCR(config, m_mdcr, 0); + /* internal ram */ + RAM(config, m_ram).set_default_size("16K").set_extra_options("16K,32K,48K,64K,80K,102K"); } diff --git a/src/mame/includes/p2000t.h b/src/mame/includes/p2000t.h index c8f06bcf7da..715da03ebec 100644 --- a/src/mame/includes/p2000t.h +++ b/src/mame/includes/p2000t.h @@ -15,6 +15,7 @@ #include "sound/spkrdev.h" #include "video/saa5050.h" #include "machine/p2000t_mdcr.h" +#include "machine/ram.h" #include "emupal.h" @@ -22,12 +23,14 @@ class p2000t_state : public driver_device { public: p2000t_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , m_videoram(*this, "videoram") - , m_maincpu(*this, "maincpu") - , m_speaker(*this, "speaker") - , m_mdcr(*this, "mdcr") - , m_keyboard(*this, "KEY.%u", 0) + : driver_device(mconfig, type, tag) + , m_videoram(*this, "videoram") + , m_maincpu(*this, "maincpu") + , m_speaker(*this, "speaker") + , m_mdcr(*this, "mdcr") + , m_ram(*this, RAM_TAG) + , m_bank(*this, "bank") + , m_keyboard(*this, "KEY.%u", 0) { } @@ -35,8 +38,8 @@ public: protected: uint8_t p2000t_port_000f_r(offs_t offset); - uint8_t p2000t_port_202f_r(); - void p2000t_port_101f_w(uint8_t data); + virtual uint8_t p2000t_port_202f_r(); + virtual void p2000t_port_101f_w(uint8_t data); void p2000t_port_303f_w(uint8_t data); void p2000t_port_505f_w(uint8_t data); void p2000t_port_707f_w(uint8_t data); @@ -44,6 +47,7 @@ protected: void p2000t_port_8c90_w(uint8_t data); void p2000t_port_9494_w(uint8_t data); uint8_t videoram_r(offs_t offset); + virtual void machine_start() override; INTERRUPT_GEN_MEMBER(p2000_interrupt); @@ -55,6 +59,8 @@ protected: required_device<cpu_device> m_maincpu; required_device<speaker_sound_device> m_speaker; required_device<mdcr_device> m_mdcr; + required_device<ram_device> m_ram; + required_memory_bank m_bank; private: required_ioport_array<10> m_keyboard; @@ -68,9 +74,9 @@ class p2000m_state : public p2000t_state { public: p2000m_state(const machine_config &mconfig, device_type type, const char *tag) - : p2000t_state(mconfig, type, tag) - , m_gfxdecode(*this, "gfxdecode") - , m_palette(*this, "palette") + : p2000t_state(mconfig, type, tag) + , m_gfxdecode(*this, "gfxdecode") + , m_palette(*this, "palette") { } diff --git a/src/mame/machine/p2000t.cpp b/src/mame/machine/p2000t.cpp index 7f9dc3e50e3..e155e3afd33 100644 --- a/src/mame/machine/p2000t.cpp +++ b/src/mame/machine/p2000t.cpp @@ -154,4 +154,32 @@ void p2000t_state::p2000t_port_707f_w(uint8_t data) { m_port_707f = data; } void p2000t_state::p2000t_port_888b_w(uint8_t data) {} void p2000t_state::p2000t_port_8c90_w(uint8_t data) {} -void p2000t_state::p2000t_port_9494_w(uint8_t data) {} + + +void p2000t_state::p2000t_port_9494_w(uint8_t data) { + // The memory region E000-FFFF (8k) is bank switched + int available_banks = (m_ram->size() - 0xe000) / 0x2000; + if (data < available_banks) + m_bank->set_entry(data); +} + +void p2000t_state::machine_start() +{ + auto program = &m_maincpu->space(AS_PROGRAM); + auto ramsize = m_ram->size(); + switch(ramsize) { + case 0x4000: // 16kb + program->unmap_readwrite(0xa000, 0xffff); + break; + case 0x8000: // 32kb + program->unmap_readwrite(0xe000, 0xffff); + break; + default: // more.. (48kb, 64kb, 102kb) + // In this case we have a set of 8kb memory banks. + uint8_t *ram = m_ram->pointer(); + auto available_banks = (ramsize - 0xe000) / 0x2000; + for(int i = 0; i < available_banks; i++) + m_bank->configure_entry(i, ram + (i * 0x2000)); + break; + } +} |