summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/snes/snes_slot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/bus/snes/snes_slot.cpp')
-rw-r--r--src/devices/bus/snes/snes_slot.cpp88
1 files changed, 33 insertions, 55 deletions
diff --git a/src/devices/bus/snes/snes_slot.cpp b/src/devices/bus/snes/snes_slot.cpp
index 9cb4a0a0f81..d447c390bd2 100644
--- a/src/devices/bus/snes/snes_slot.cpp
+++ b/src/devices/bus/snes/snes_slot.cpp
@@ -88,11 +88,11 @@ device_sns_cart_interface::~device_sns_cart_interface()
// rom_alloc - alloc the space for the cart
//-------------------------------------------------
-void device_sns_cart_interface::rom_alloc(uint32_t size, const char *tag)
+void device_sns_cart_interface::rom_alloc(uint32_t size)
{
if (m_rom == nullptr)
{
- m_rom = device().machine().memory().region_alloc(std::string(tag).append(SNSSLOT_ROM_REGION_TAG).c_str(), size, 1, ENDIANNESS_LITTLE)->base();
+ m_rom = device().machine().memory().region_alloc(device().subtag("^cart:rom"), size, 1, ENDIANNESS_LITTLE)->base();
m_rom_size = size;
}
}
@@ -170,7 +170,7 @@ void device_sns_cart_interface::rom_map_setup(uint32_t size)
// write_irq - set the cart IRQ output
//-------------------------------------------------
-WRITE_LINE_MEMBER(device_sns_cart_interface::write_irq)
+void device_sns_cart_interface::write_irq(int state)
{
if (m_slot != nullptr)
m_slot->write_irq(state);
@@ -221,13 +221,13 @@ offs_t device_sns_cart_interface::address_r()
//-------------------------------------------------
base_sns_cart_slot_device::base_sns_cart_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, type, tag, owner, clock),
- device_image_interface(mconfig, *this),
+ device_cartrom_image_interface(mconfig, *this),
device_slot_interface(mconfig, *this),
m_addon(ADDON_NONE),
m_type(SNES_MODE20),
m_cart(nullptr),
m_irq_callback(*this),
- m_open_bus_callback(*this)
+ m_open_bus_callback(*this, 0xff)
{
}
@@ -263,9 +263,6 @@ void base_sns_cart_slot_device::device_start()
m_cart = dynamic_cast<device_sns_cart_interface *>(get_card_device());
if (m_cart != nullptr)
m_cart->m_slot = this;
-
- m_irq_callback.resolve_safe();
- m_open_bus_callback.resolve_safe(0xff);
}
@@ -649,15 +646,12 @@ static int snes_find_addon_chip(const uint8_t *buffer, uint32_t start_offs, uint
-------------------------------------------------*/
-image_init_result base_sns_cart_slot_device::call_load()
+std::pair<std::error_condition, std::string> base_sns_cart_slot_device::call_load()
{
if (m_cart)
{
- uint8_t *ROM;
- uint32_t len, offset = 0;
- const char *slot_name;
-
- /* Check for a header (512 bytes), and skip it if found */
+ // Check for a header (512 bytes), and skip it if found
+ uint32_t offset = 0;
if (!loaded_through_softlist())
{
uint32_t tmplen = length();
@@ -667,10 +661,10 @@ image_init_result base_sns_cart_slot_device::call_load()
fseek(offset, SEEK_SET);
}
- len = !loaded_through_softlist() ? (length() - offset) : get_software_region_length("rom");
+ uint32_t const len = !loaded_through_softlist() ? (length() - offset) : get_software_region_length("rom");
- m_cart->rom_alloc(len, tag());
- ROM = m_cart->get_rom_base();
+ m_cart->rom_alloc(len);
+ uint8_t *const ROM = m_cart->get_rom_base();
if (!loaded_through_softlist())
fread(ROM, len);
else
@@ -693,13 +687,14 @@ image_init_result base_sns_cart_slot_device::call_load()
get_cart_type_addon(ROM, len, m_type, m_addon);
else
{
+ const char *slot_name;
if ((slot_name = get_feature("slot")) == nullptr)
m_type = SNES_MODE20;
else
m_type = sns_get_pcb_id(slot_name);
if (m_type == SNES_DSP && len > 0x100000)
- m_type = SNES_DSP_2MB;
+ m_type = SNES_DSP_2MB;
}
if (!loaded_through_softlist())
@@ -725,11 +720,9 @@ image_init_result base_sns_cart_slot_device::call_load()
//printf("Type %d\n", m_type);
internal_header_logging(ROM, len);
-
- return image_init_result::PASS;
}
- return image_init_result::PASS;
+ return std::make_pair(std::error_condition(), std::string());
}
@@ -851,37 +844,37 @@ void base_sns_cart_slot_device::setup_addon_from_fullpath()
switch (m_addon)
{
case ADDON_DSP1:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x2800);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x2800);
break;
case ADDON_DSP1B:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x2800);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x2800);
break;
case ADDON_DSP2:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x2800);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x2800);
break;
case ADDON_DSP3:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x2800);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x2800);
break;
case ADDON_DSP4:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x2800);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x2800);
break;
case ADDON_ST010:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x11000);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x11000);
break;
case ADDON_ST011:
- ROM = machine().root_device().memregion(region.c_str())->base();
+ ROM = machine().root_device().memregion(region)->base();
m_cart->addon_bios_alloc(0x11000);
memcpy(m_cart->get_addon_bios_base(), ROM, 0x11000);
break;
@@ -1051,8 +1044,7 @@ std::string base_sns_cart_slot_device::get_default_card_software(get_default_car
std::vector<uint8_t> rom(len);
int type = 0, addon = 0;
- size_t actual;
- hook.image_file()->read(&rom[0], len, actual); // FIXME: check for error result or read returning short
+ /*auto const [err, actual] =*/ read(*hook.image_file(), &rom[0], len); // FIXME: check for error result or read returning short
offset = snes_skip_header(&rom[0], len);
@@ -1176,26 +1168,12 @@ void base_sns_cart_slot_device::chip_write(offs_t offset, uint8_t data)
/* We use this to convert the company_id in the header to int value to be passed in companies[] */
static int char_to_int_conv( char id )
{
- int value;
-
- if (id == '1') value = 0x01;
- else if (id == '2') value = 0x02;
- else if (id == '3') value = 0x03;
- else if (id == '4') value = 0x04;
- else if (id == '5') value = 0x05;
- else if (id == '6') value = 0x06;
- else if (id == '7') value = 0x07;
- else if (id == '8') value = 0x08;
- else if (id == '9') value = 0x09;
- else if (id == 'A') value = 0x0a;
- else if (id == 'B') value = 0x0b;
- else if (id == 'C') value = 0x0c;
- else if (id == 'D') value = 0x0d;
- else if (id == 'E') value = 0x0e;
- else if (id == 'F') value = 0x0f;
- else value = 0x00;
-
- return value;
+ if (id >= '0' && id <= '9')
+ return id - '0';
+ else if (id >= 'A' && id <= 'F')
+ return id - 'A' + 0x0a;
+ else
+ return 0;
}
#define UNK "UNKNOWN"
@@ -1385,7 +1363,7 @@ void base_sns_cart_slot_device::internal_header_logging(uint8_t *ROM, uint32_t l
logerror( "HEADER DETAILS\n" );
logerror( "==============\n\n" );
logerror( "\tName: %.21s\n", title );
- logerror( "\tSpeed: %s [%d]\n", (ROM[hilo_mode + 0x15] & 0xf0) ? "FastROM" : "SlowROM", (ROM[hilo_mode + 0x15] & 0xf0) >> 4);
+ logerror( "\tSpeed: %s [%d]\n", (ROM[hilo_mode + 0x15] & 0x10) ? "FastROM" : "SlowROM", (ROM[hilo_mode + 0x15] & 0xf0) >> 4);
logerror( "\tBank size: %s [%d]\n", (ROM[hilo_mode + 0x15] & 0xf) ? "HiROM" : "LoROM", ROM[hilo_mode + 0x15] & 0xf);
logerror( "\tType: %s", cart_types[type]);
@@ -1403,10 +1381,10 @@ void base_sns_cart_slot_device::internal_header_logging(uint8_t *ROM, uint32_t l
logerror( "\tCountry: Unknown [%d]\n", ROM[hilo_mode + 0x19]);
logerror( "\tLicense: %s [%X]\n", companies[ROM[hilo_mode + 0x1a]], ROM[hilo_mode + 0x1a]);
logerror( "\tVersion: 1.%d\n", ROM[hilo_mode + 0x1b]);
- logerror( "\tInv Checksum: %X %X\n", ROM[hilo_mode + 0x1d], ROM[hilo_mode + 0x1c]);
- logerror( "\tChecksum: %X %X\n", ROM[hilo_mode + 0x1f], ROM[hilo_mode + 0x1e]);
- logerror( "\tNMI Address: %2X%2Xh\n", ROM[hilo_mode + 0x3b], ROM[hilo_mode + 0x3a]);
- logerror( "\tStart Address: %2X%2Xh\n\n", ROM[hilo_mode + 0x3d], ROM[hilo_mode + 0x3c]);
+ logerror( "\tInv Checksum: %02X%02Xh\n", ROM[hilo_mode + 0x1d], ROM[hilo_mode + 0x1c]);
+ logerror( "\tChecksum: %02X%02Xh\n", ROM[hilo_mode + 0x1f], ROM[hilo_mode + 0x1e]);
+ logerror( "\tNMI Address: %02X%02Xh\n", ROM[hilo_mode + 0x3b], ROM[hilo_mode + 0x3a]);
+ logerror( "\tStart Address: %02X%02Xh\n\n", ROM[hilo_mode + 0x3d], ROM[hilo_mode + 0x3c]);
logerror( "\tMode: %d\n", type);
}