From 89e90a66166ca52661f84895d1a3fa50eae10cab Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 7 Jan 2019 19:53:32 +0900 Subject: [PATCH] devices/bus/neogeo/cmc.cpp, rom.cpp : Implement NVRAM Both jockeygp, vliner has battery-backed RAM, Correct this --- src/devices/bus/neogeo/cmc.cpp | 12 ++++++++---- src/devices/bus/neogeo/cmc.h | 8 ++++++-- src/devices/bus/neogeo/rom.cpp | 12 +++++++----- src/devices/bus/neogeo/rom.h | 8 ++++++-- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/devices/bus/neogeo/cmc.cpp b/src/devices/bus/neogeo/cmc.cpp index 841244c478e..a6e6265c12f 100644 --- a/src/devices/bus/neogeo/cmc.cpp +++ b/src/devices/bus/neogeo/cmc.cpp @@ -251,19 +251,23 @@ void neogeo_cmc_kof2000n_cart_device::decrypt_all(DECRYPT_ALL_PARAMS) DEFINE_DEVICE_TYPE(NEOGEO_CMC_JOCKEYGP_CART, neogeo_cmc_jockeygp_cart_device, "neocart_jockeygp", "Neo Geo Jockey GP CMC50 Cart") neogeo_cmc_jockeygp_cart_device::neogeo_cmc_jockeygp_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - neogeo_cmc_cart_device(mconfig, NEOGEO_CMC_JOCKEYGP_CART, tag, owner, clock) + neogeo_cmc_cart_device(mconfig, NEOGEO_CMC_JOCKEYGP_CART, tag, owner, clock), + m_nvram(*this, "nvram") { } void neogeo_cmc_jockeygp_cart_device::device_start() { - save_item(NAME(m_ram)); + m_ram = make_unique_clear(0x2000/2); + m_nvram->set_base(m_ram.get(), 0x2000); + save_pointer(NAME(m_ram), 0x2000/2); } -void neogeo_cmc_jockeygp_cart_device::device_reset() +void neogeo_cmc_jockeygp_cart_device::device_add_mconfig(machine_config &config) { - memset(m_ram, 0, 0x2000); + neogeo_cmc_cart_device::device_add_mconfig(config); + NVRAM(config, m_nvram); } void neogeo_cmc_jockeygp_cart_device::decrypt_all(DECRYPT_ALL_PARAMS) diff --git a/src/devices/bus/neogeo/cmc.h b/src/devices/bus/neogeo/cmc.h index 88b1c27cd9f..bba8251d2e5 100644 --- a/src/devices/bus/neogeo/cmc.h +++ b/src/devices/bus/neogeo/cmc.h @@ -8,6 +8,7 @@ #include "slot.h" #include "rom.h" #include "prot_cmc.h" +#include "machine/nvram.h" // ======================> neogeo_cmc_cart_device @@ -218,10 +219,13 @@ public: protected: virtual void device_start() override; - virtual void device_reset() override; + + virtual void device_add_mconfig(machine_config &config) override; private: - uint16_t m_ram[0x1000]; + std::unique_ptr m_ram; + + required_device m_nvram; }; DECLARE_DEVICE_TYPE(NEOGEO_CMC_JOCKEYGP_CART, neogeo_cmc_jockeygp_cart_device) diff --git a/src/devices/bus/neogeo/rom.cpp b/src/devices/bus/neogeo/rom.cpp index 10c61858386..0f54a808cef 100644 --- a/src/devices/bus/neogeo/rom.cpp +++ b/src/devices/bus/neogeo/rom.cpp @@ -73,17 +73,19 @@ WRITE16_MEMBER(neogeo_rom_device::banksel_w) DEFINE_DEVICE_TYPE(NEOGEO_VLINER_CART, neogeo_vliner_cart_device, "neocart_vliner", "Neo Geo V-Liner Cart") neogeo_vliner_cart_device::neogeo_vliner_cart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - neogeo_rom_device(mconfig, NEOGEO_VLINER_CART, tag, owner, clock) + neogeo_rom_device(mconfig, NEOGEO_VLINER_CART, tag, owner, clock), + m_nvram(*this, "nvram") { } - void neogeo_vliner_cart_device::device_start() { - save_item(NAME(m_cart_ram)); + m_cart_ram = make_unique_clear(0x2000/2); + m_nvram->set_base(m_cart_ram.get(), 0x2000); + save_pointer(NAME(m_cart_ram), 0x2000/2); } -void neogeo_vliner_cart_device::device_reset() +void neogeo_vliner_cart_device::device_add_mconfig(machine_config &config) { - memset(m_cart_ram, 0, 0x2000); + NVRAM(config, m_nvram); } diff --git a/src/devices/bus/neogeo/rom.h b/src/devices/bus/neogeo/rom.h index 17efc4da4a7..1f62a890859 100644 --- a/src/devices/bus/neogeo/rom.h +++ b/src/devices/bus/neogeo/rom.h @@ -6,6 +6,7 @@ #pragma once #include "slot.h" +#include "machine/nvram.h" // ======================> neogeo_rom_device @@ -50,10 +51,13 @@ public: protected: virtual void device_start() override; - virtual void device_reset() override; + + virtual void device_add_mconfig(machine_config &config) override; private: - uint16_t m_cart_ram[0x1000]; + std::unique_ptr m_cart_ram; + + required_device m_nvram; }; DECLARE_DEVICE_TYPE(NEOGEO_VLINER_CART, neogeo_vliner_cart_device)