diff options
Diffstat (limited to 'src/devices/bus/apf/slot.cpp')
-rw-r--r-- | src/devices/bus/apf/slot.cpp | 63 |
1 files changed, 29 insertions, 34 deletions
diff --git a/src/devices/bus/apf/slot.cpp b/src/devices/bus/apf/slot.cpp index 871c43e4655..2c5c3edb7f7 100644 --- a/src/devices/bus/apf/slot.cpp +++ b/src/devices/bus/apf/slot.cpp @@ -7,7 +7,6 @@ ***********************************************************************************************************/ - #include "emu.h" #include "slot.h" @@ -25,10 +24,10 @@ DEFINE_DEVICE_TYPE(APF_CART_SLOT, apf_cart_slot_device, "apf_cart_slot", "APF Ca // device_apf_cart_interface - constructor //------------------------------------------------- -device_apf_cart_interface::device_apf_cart_interface(const machine_config &mconfig, device_t &device) - : device_slot_card_interface(mconfig, device), - m_rom(nullptr), - m_rom_size(0) +device_apf_cart_interface::device_apf_cart_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "apfcart"), + m_rom(nullptr), + m_rom_size(0) { } @@ -45,11 +44,11 @@ device_apf_cart_interface::~device_apf_cart_interface() // rom_alloc - alloc the space for the cart //------------------------------------------------- -void device_apf_cart_interface::rom_alloc(uint32_t size, const char *tag) +void device_apf_cart_interface::rom_alloc(uint32_t size) { if (m_rom == nullptr) { - m_rom = device().machine().memory().region_alloc(std::string(tag).append(APFSLOT_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; } } @@ -74,9 +73,10 @@ void device_apf_cart_interface::ram_alloc(uint32_t size) //------------------------------------------------- apf_cart_slot_device::apf_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, APF_CART_SLOT, tag, owner, clock), - device_image_interface(mconfig, *this), - device_slot_interface(mconfig, *this), - m_type(APF_STD), m_cart(nullptr) + device_cartrom_image_interface(mconfig, *this), + device_single_card_slot_interface<device_apf_cart_interface>(mconfig, *this), + m_type(APF_STD), + m_cart(nullptr) { } @@ -95,7 +95,7 @@ apf_cart_slot_device::~apf_cart_slot_device() void apf_cart_slot_device::device_start() { - m_cart = dynamic_cast<device_apf_cart_interface *>(get_card_device()); + m_cart = get_card_device(); } @@ -121,7 +121,7 @@ static int apf_get_pcb_id(const char *slot) { for (auto & elem : slot_list) { - if (!core_stricmp(elem.slot_option, slot)) + if (!strcmp(elem.slot_option, slot)) return elem.pcb_id; } @@ -144,19 +144,16 @@ static const char *apf_get_slot(int type) call load -------------------------------------------------*/ -image_init_result apf_cart_slot_device::call_load() +std::pair<std::error_condition, std::string> apf_cart_slot_device::call_load() { if (m_cart) { - uint32_t size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); + uint32_t const size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); if (size > 0x3800) - { - seterror(IMAGE_ERROR_UNSPECIFIED, "Image extends beyond the expected size for an APF cart"); - return image_init_result::FAIL; - } + return std::make_pair(image_error::INVALIDLENGTH, "Image exceeds the expected size for an APF cartridge (14K)"); - m_cart->rom_alloc(size, tag()); + m_cart->rom_alloc(size); if (!loaded_through_softlist()) fread(m_cart->get_rom_base(), size); @@ -186,11 +183,9 @@ image_init_result apf_cart_slot_device::call_load() } //printf("Type: %s\n", apf_get_slot(m_type)); - - return image_init_result::PASS; } - return image_init_result::PASS; + return std::make_pair(std::error_condition(), std::string()); } @@ -202,17 +197,17 @@ std::string apf_cart_slot_device::get_default_card_software(get_default_card_sof { if (hook.image_file()) { - const char *slot_string; - uint32_t size = hook.image_file()->size(); - int type = APF_STD; + uint64_t size; + hook.image_file()->length(size); // FIXME: check error return // attempt to identify Space Destroyer, which needs 1K of additional RAM + int type = APF_STD; if (size == 0x1800) type = APF_SPACEDST; if (size > 0x2000) type = APF_BASIC; - slot_string = apf_get_slot(type); + char const *const slot_string = apf_get_slot(type); //printf("type: %s\n", slot_string); @@ -226,10 +221,10 @@ std::string apf_cart_slot_device::get_default_card_software(get_default_card_sof read -------------------------------------------------*/ -READ8_MEMBER(apf_cart_slot_device::read_rom) +uint8_t apf_cart_slot_device::read_rom(offs_t offset) { if (m_cart) - return m_cart->read_rom(space, offset); + return m_cart->read_rom(offset); else return 0xff; } @@ -238,10 +233,10 @@ READ8_MEMBER(apf_cart_slot_device::read_rom) read -------------------------------------------------*/ -READ8_MEMBER(apf_cart_slot_device::extra_rom) +uint8_t apf_cart_slot_device::extra_rom(offs_t offset) { if (m_cart) - return m_cart->extra_rom(space, offset); + return m_cart->extra_rom(offset); else return 0xff; } @@ -250,10 +245,10 @@ READ8_MEMBER(apf_cart_slot_device::extra_rom) read -------------------------------------------------*/ -READ8_MEMBER(apf_cart_slot_device::read_ram) +uint8_t apf_cart_slot_device::read_ram(offs_t offset) { if (m_cart) - return m_cart->read_ram(space, offset); + return m_cart->read_ram(offset); else return 0xff; } @@ -262,8 +257,8 @@ READ8_MEMBER(apf_cart_slot_device::read_ram) write -------------------------------------------------*/ -WRITE8_MEMBER(apf_cart_slot_device::write_ram) +void apf_cart_slot_device::write_ram(offs_t offset, uint8_t data) { if (m_cart) - m_cart->write_ram(space, offset, data); + m_cart->write_ram(offset, data); } |