From 82be4e22f184412f37805999232439ed1c36c31d Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 12 Aug 2018 09:01:16 -0400 Subject: [PATCH] cpu/nec: Start pushing down V33/V53-specific memory stuff into a new base class (nw) mpc3000: Add even more RAM (nw) --- src/devices/cpu/nec/nec.cpp | 20 +++++++++++++------- src/devices/cpu/nec/nec.h | 26 ++++++++++++++++++-------- src/devices/cpu/nec/v53.cpp | 12 ++++++------ src/devices/cpu/nec/v53.h | 4 ++-- src/mame/drivers/mpc3000.cpp | 3 ++- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/devices/cpu/nec/nec.cpp b/src/devices/cpu/nec/nec.cpp index 04b51fca719..f1433f219b8 100644 --- a/src/devices/cpu/nec/nec.cpp +++ b/src/devices/cpu/nec/nec.cpp @@ -157,28 +157,34 @@ device_memory_interface::space_config_vector nec_common_device::memory_space_con /* FIXME: Need information about prefetch size and cycles for V33. * complete guess below, nbbatman will not work * properly without. */ +v33_base_device::v33_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal_port_map) + : nec_common_device(mconfig, type, tag, owner, clock, true, 6, 1, V33_TYPE, internal_port_map) +{ +} + + v33_device::v33_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nec_common_device(mconfig, V33, tag, owner, clock, true, 6, 1, V33_TYPE, address_map_constructor(FUNC(v33_device::v33_internal_port_map), this)) + : v33_base_device(mconfig, V33, tag, owner, clock, address_map_constructor(FUNC(v33_device::v33_internal_port_map), this)) { } v33a_device::v33a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : nec_common_device(mconfig, V33A, tag, owner, clock, true, 6, 1, V33_TYPE, address_map_constructor(FUNC(v33a_device::v33_internal_port_map), this)) + : v33_base_device(mconfig, V33A, tag, owner, clock, address_map_constructor(FUNC(v33a_device::v33_internal_port_map), this)) { } -uint16_t nec_common_device::xam_r() +uint16_t v33_base_device::xam_r() { // Only bit 0 is defined return m_xa ? 1 : 0; } -void nec_common_device::v33_internal_port_map(address_map &map) +void v33_base_device::v33_internal_port_map(address_map &map) { map(0xff00, 0xff7f).ram().share("v33_transtable"); - map(0xff80, 0xff81).r(FUNC(nec_common_device::xam_r)).unmapw(); + map(0xff80, 0xff81).r(FUNC(v33_base_device::xam_r)).unmapw(); map(0xff82, 0xffff).unmaprw(); } @@ -191,9 +197,9 @@ offs_t nec_common_device::v33_translate(offs_t addr) return addr & 0xfffff; } -bool nec_common_device::memory_translate(int spacenum, int intention, offs_t &address) +bool v33_base_device::memory_translate(int spacenum, int intention, offs_t &address) { - if (m_chip_type == V33_TYPE && spacenum == AS_PROGRAM) + if (spacenum == AS_PROGRAM) address = v33_translate(address); return true; } diff --git a/src/devices/cpu/nec/nec.h b/src/devices/cpu/nec/nec.h index bc4e6589e65..fc402a5c397 100644 --- a/src/devices/cpu/nec/nec.h +++ b/src/devices/cpu/nec/nec.h @@ -40,7 +40,6 @@ protected: // device_memory_interface overrides virtual space_config_vector memory_space_config() const override; - virtual bool memory_translate(int spacenum, int intention, offs_t &address) override; // device_state_interface overrides virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; @@ -100,9 +99,6 @@ private: uint32_t m_prefix_base; /* base address of the latest prefix segment */ uint8_t m_seg_prefix; /* prefix segment indicator */ - bool m_xa; - optional_shared_ptr m_v33_transtable; - uint32_t m_EA; uint16_t m_EO; uint16_t m_E16; @@ -115,8 +111,10 @@ private: static const nec_eahandler s_GetEA[192]; protected: - void v33_internal_port_map(address_map &map); - uint16_t xam_r(); + // FIXME: these belong in v33_base_device + bool m_xa; + optional_shared_ptr m_v33_transtable; + offs_t v33_translate(offs_t addr); private: @@ -418,13 +416,25 @@ public: }; -class v33_device : public nec_common_device +class v33_base_device : public nec_common_device +{ +protected: + v33_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal_port_map); + + // device_memory_interface overrides + virtual bool memory_translate(int spacenum, int intention, offs_t &address) override; + + void v33_internal_port_map(address_map &map); + uint16_t xam_r(); +}; + +class v33_device : public v33_base_device { public: v33_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); }; -class v33a_device : public nec_common_device +class v33a_device : public v33_base_device { public: v33a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); diff --git a/src/devices/cpu/nec/v53.cpp b/src/devices/cpu/nec/v53.cpp index 697d12d461f..ba71f8fb296 100644 --- a/src/devices/cpu/nec/v53.cpp +++ b/src/devices/cpu/nec/v53.cpp @@ -174,7 +174,7 @@ m_DMK = 0x0f; void v53_base_device::device_reset() { - nec_common_device::device_reset(); + v33_base_device::device_reset(); m_SCTL = 0x00; m_OPSEL= 0x00; @@ -191,7 +191,7 @@ void v53_base_device::device_reset() void v53_base_device::device_start() { - nec_common_device::device_start(); + v33_base_device::device_start(); m_txd_handler.resolve_safe(); m_rts_handler.resolve_safe(); @@ -525,8 +525,8 @@ MACHINE_CONFIG_START(v53_base_device::device_add_mconfig) MACHINE_CONFIG_END -v53_base_device::v53_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t prefetch_size, uint8_t prefetch_cycles, uint32_t chip_type) : - nec_common_device(mconfig, type, tag, owner, clock, true, prefetch_size, prefetch_cycles, chip_type, address_map_constructor(FUNC(v53_base_device::v53_internal_port_map), this)), +v53_base_device::v53_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + v33_base_device(mconfig, type, tag, owner, clock, address_map_constructor(FUNC(v53_base_device::v53_internal_port_map), this)), m_v53tcu(*this, "pit"), m_v53dmau(*this, "upd71071dma"), m_v53icu(*this, "upd71059pic"), @@ -565,12 +565,12 @@ v53_base_device::v53_base_device(const machine_config &mconfig, device_type type v53_device::v53_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : v53_base_device(mconfig, V53, tag, owner, clock, 6, 1, V33_TYPE) + : v53_base_device(mconfig, V53, tag, owner, clock) { } v53a_device::v53a_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : v53_base_device(mconfig, V53A, tag, owner, clock, 6, 1, V33_TYPE) + : v53_base_device(mconfig, V53A, tag, owner, clock) { } diff --git a/src/devices/cpu/nec/v53.h b/src/devices/cpu/nec/v53.h index c91a264bbf6..fab17150500 100644 --- a/src/devices/cpu/nec/v53.h +++ b/src/devices/cpu/nec/v53.h @@ -107,7 +107,7 @@ -class v53_base_device : public nec_common_device +class v53_base_device : public v33_base_device { public: DECLARE_WRITE8_MEMBER(BSEL_w); @@ -191,7 +191,7 @@ public: void v53_internal_port_map(address_map &map); protected: - v53_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint8_t prefetch_size, uint8_t prefetch_cycles, uint32_t chip_type); + v53_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); // device-level overrides virtual void device_add_mconfig(machine_config &config) override; diff --git a/src/mame/drivers/mpc3000.cpp b/src/mame/drivers/mpc3000.cpp index 17b55b75a8e..3151837c8e7 100644 --- a/src/mame/drivers/mpc3000.cpp +++ b/src/mame/drivers/mpc3000.cpp @@ -97,7 +97,8 @@ void mpc3000_state::machine_reset() void mpc3000_state::mpc3000_map(address_map &map) { map(0x000000, 0x07ffff).mirror(0x80000).rom().region("maincpu", 0); - map(0x300000, 0x38ffff).ram(); + map(0x300000, 0x3fffff).ram(); + map(0x500000, 0x500fff).ram(); // actually 8-bit battery-backed RAM } void mpc3000_state::mpc3000_io_map(address_map &map)