Merge pull request #4486 from cam900/neogeo_nvram

devices/bus/neogeo/cmc.cpp, rom.cpp : Implement NVRAM
This commit is contained in:
ajrhacker 2019-01-07 14:06:47 -05:00 committed by GitHub
commit 8da31f65aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 13 deletions

View File

@ -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") 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_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() void neogeo_cmc_jockeygp_cart_device::device_start()
{ {
save_item(NAME(m_ram)); m_ram = make_unique_clear<uint16_t[]>(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) void neogeo_cmc_jockeygp_cart_device::decrypt_all(DECRYPT_ALL_PARAMS)

View File

@ -8,6 +8,7 @@
#include "slot.h" #include "slot.h"
#include "rom.h" #include "rom.h"
#include "prot_cmc.h" #include "prot_cmc.h"
#include "machine/nvram.h"
// ======================> neogeo_cmc_cart_device // ======================> neogeo_cmc_cart_device
@ -218,10 +219,13 @@ public:
protected: protected:
virtual void device_start() override; virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
private: private:
uint16_t m_ram[0x1000]; std::unique_ptr<uint16_t[]> m_ram;
required_device<nvram_device> m_nvram;
}; };
DECLARE_DEVICE_TYPE(NEOGEO_CMC_JOCKEYGP_CART, neogeo_cmc_jockeygp_cart_device) DECLARE_DEVICE_TYPE(NEOGEO_CMC_JOCKEYGP_CART, neogeo_cmc_jockeygp_cart_device)

View File

@ -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") 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_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() void neogeo_vliner_cart_device::device_start()
{ {
save_item(NAME(m_cart_ram)); m_cart_ram = make_unique_clear<uint16_t[]>(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);
} }

View File

@ -6,6 +6,7 @@
#pragma once #pragma once
#include "slot.h" #include "slot.h"
#include "machine/nvram.h"
// ======================> neogeo_rom_device // ======================> neogeo_rom_device
@ -50,10 +51,13 @@ public:
protected: protected:
virtual void device_start() override; virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
private: private:
uint16_t m_cart_ram[0x1000]; std::unique_ptr<uint16_t[]> m_cart_ram;
required_device<nvram_device> m_nvram;
}; };
DECLARE_DEVICE_TYPE(NEOGEO_VLINER_CART, neogeo_vliner_cart_device) DECLARE_DEVICE_TYPE(NEOGEO_VLINER_CART, neogeo_vliner_cart_device)