summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/nes/sunsoft_dcs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/nes/sunsoft_dcs.cpp')
-rw-r--r--src/devices/bus/nes/sunsoft_dcs.cpp64
1 files changed, 24 insertions, 40 deletions
diff --git a/src/devices/bus/nes/sunsoft_dcs.cpp b/src/devices/bus/nes/sunsoft_dcs.cpp
index 04dc3219716..188f0a83b32 100644
--- a/src/devices/bus/nes/sunsoft_dcs.cpp
+++ b/src/devices/bus/nes/sunsoft_dcs.cpp
@@ -16,12 +16,11 @@
#include "sunsoft_dcs.h"
#ifdef NES_PCB_DEBUG
-#define VERBOSE 1
+#define VERBOSE (LOG_GENERAL)
#else
-#define VERBOSE 0
+#define VERBOSE (0)
#endif
-
-#define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0)
+#include "logmacro.h"
//-----------------------------------------------
@@ -52,7 +51,7 @@ DEFINE_DEVICE_TYPE(NES_NTB_SLOT, nes_ntb_slot_device, "nes_ntb_slot", "NES NTB C
nes_ntb_slot_device::nes_ntb_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, NES_NTB_SLOT, tag, owner, clock)
- , device_image_interface(mconfig, *this)
+ , device_cartrom_image_interface(mconfig, *this)
, device_single_card_slot_interface<ntb_cart_interface>(mconfig, *this)
, m_cart(nullptr)
{
@@ -77,32 +76,31 @@ uint8_t nes_ntb_slot_device::read(offs_t offset)
}
-image_init_result nes_ntb_slot_device::call_load()
+std::pair<std::error_condition, std::string> nes_ntb_slot_device::call_load()
{
if (m_cart)
{
- uint8_t *ROM = m_cart->get_cart_base();
-
+ uint8_t *const ROM = m_cart->get_cart_base();
if (!ROM)
- return image_init_result::FAIL;
+ return std::make_pair(image_error::INTERNAL, std::string());
if (!loaded_through_softlist())
{
if (length() != 0x4000)
- return image_init_result::FAIL;
+ return std::make_pair(image_error::INVALIDLENGTH, "Unsupported cartridge size (must be 16K)");
- fread(&ROM, 0x4000);
+ fread(ROM, 0x4000);
}
else
{
if (get_software_region_length("rom") != 0x4000)
- return image_init_result::FAIL;
+ return std::make_pair(image_error::INVALIDLENGTH, "Unsupported cartridge size (must be 16K)");
memcpy(ROM, get_software_region("rom"), 0x4000);
}
}
- return image_init_result::PASS;
+ return std::make_pair(std::error_condition(), std::string());
}
@@ -166,30 +164,19 @@ nes_sunsoft_dcs_device::nes_sunsoft_dcs_device(const machine_config &mconfig, co
void nes_sunsoft_dcs_device::device_start()
{
- common_start();
- ntb_enable_timer = timer_alloc(TIMER_PROTECT);
+ nes_sunsoft_4_device::device_start();
+
+ ntb_enable_timer = timer_alloc(FUNC(nes_sunsoft_dcs_device::protect_tick), this);
ntb_enable_timer->reset();
timer_freq = clocks_to_attotime(107520);
- save_item(NAME(m_latch1));
- save_item(NAME(m_latch2));
- save_item(NAME(m_reg));
- save_item(NAME(m_wram_enable));
save_item(NAME(m_exrom_enable));
save_item(NAME(m_timer_on));
}
void nes_sunsoft_dcs_device::pcb_reset()
{
- m_chr_source = m_vrom_chunks ? CHRROM : CHRRAM;
- prg16_89ab(0);
- prg16_cdef(m_prg_chunks - 1);
- chr8(0, m_chr_source);
-
- m_reg = 0;
- m_latch1 = 0;
- m_latch2 = 0;
- m_wram_enable = 0;
+ nes_sunsoft_4_device::pcb_reset();
m_exrom_enable = 0;
m_timer_on = 0;
}
@@ -214,7 +201,7 @@ void nes_sunsoft_dcs_device::pcb_reset()
void nes_sunsoft_dcs_device::write_h(offs_t offset, uint8_t data)
{
- LOG_MMC(("Sunsoft DCS write_h, offset %04x, data: %02x\n", offset, data));
+ LOG("Sunsoft DCS write_h, offset %04x, data: %02x\n", offset, data);
switch (offset & 0x7000)
{
@@ -231,7 +218,7 @@ void nes_sunsoft_dcs_device::write_h(offs_t offset, uint8_t data)
uint8_t nes_sunsoft_dcs_device::read_h(offs_t offset)
{
- LOG_MMC(("Sunsoft DCS read_h, offset: %04x\n", offset));
+ LOG("Sunsoft DCS read_h, offset: %04x\n", offset);
if (m_exrom_enable && m_subslot->m_cart && offset < 0x4000)
{
@@ -246,7 +233,7 @@ uint8_t nes_sunsoft_dcs_device::read_h(offs_t offset)
void nes_sunsoft_dcs_device::write_m(offs_t offset, uint8_t data)
{
- LOG_MMC(("Sunsoft DCS write_m, offset: %04x, data: %02x\n", offset, data));
+ LOG("Sunsoft DCS write_m, offset: %04x, data: %02x\n", offset, data);
if (!m_battery.empty() && m_wram_enable)
m_battery[offset & (m_battery.size() - 1)] = data;
@@ -262,14 +249,14 @@ void nes_sunsoft_dcs_device::write_m(offs_t offset, uint8_t data)
uint8_t nes_sunsoft_dcs_device::read_m(offs_t offset)
{
- LOG_MMC(("Sunsoft DCS read_m, offset: %04x\n", offset));
+ LOG("Sunsoft DCS read_m, offset: %04x\n", offset);
if (!m_battery.empty() && m_wram_enable)
return m_battery[offset & (m_battery.size() - 1)];
if (!m_prgram.empty() && m_wram_enable)
return m_prgram[offset & (m_prgram.size() - 1)];
- return get_open_bus(); // open bus
+ return get_open_bus();
}
@@ -292,14 +279,11 @@ void nes_sunsoft_dcs_device::device_add_mconfig(machine_config &config)
//-------------------------------------------------
-// device_timer - handler timer events
+// protect_tick - handler NTB-ROM timer elapsing
//-------------------------------------------------
-void nes_sunsoft_dcs_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
+TIMER_CALLBACK_MEMBER(nes_sunsoft_dcs_device::protect_tick)
{
- if (id == TIMER_PROTECT)
- {
- m_timer_on = 0;
- ntb_enable_timer->reset();
- }
+ m_timer_on = 0;
+ ntb_enable_timer->reset();
}