diff options
Diffstat (limited to 'src/devices/bus/crvision/slot.cpp')
-rw-r--r-- | src/devices/bus/crvision/slot.cpp | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/src/devices/bus/crvision/slot.cpp b/src/devices/bus/crvision/slot.cpp index a0398840f00..0b28124eb5b 100644 --- a/src/devices/bus/crvision/slot.cpp +++ b/src/devices/bus/crvision/slot.cpp @@ -7,7 +7,6 @@ ***********************************************************************************************************/ - #include "emu.h" #include "slot.h" @@ -25,10 +24,10 @@ DEFINE_DEVICE_TYPE(CRVISION_CART_SLOT, crvision_cart_slot_device, "crvision_cart // device_crvision_cart_interface - constructor //------------------------------------------------- -device_crvision_cart_interface::device_crvision_cart_interface(const machine_config &mconfig, device_t &device) - : device_slot_card_interface(mconfig, device), - m_rom(nullptr), - m_rom_size(0) +device_crvision_cart_interface::device_crvision_cart_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "crvisioncart"), + m_rom(nullptr), + m_rom_size(0) { } @@ -45,11 +44,11 @@ device_crvision_cart_interface::~device_crvision_cart_interface() // rom_alloc - alloc the space for the cart //------------------------------------------------- -void device_crvision_cart_interface::rom_alloc(uint32_t size, const char *tag) +void device_crvision_cart_interface::rom_alloc(uint32_t size) { if (m_rom == nullptr) { - m_rom = device().machine().memory().region_alloc(std::string(tag).append(CRVSLOT_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; } } @@ -64,8 +63,8 @@ void device_crvision_cart_interface::rom_alloc(uint32_t size, const char *tag) //------------------------------------------------- crvision_cart_slot_device::crvision_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CRVISION_CART_SLOT, tag, owner, clock), - device_image_interface(mconfig, *this), - device_slot_interface(mconfig, *this), + device_cartrom_image_interface(mconfig, *this), + device_single_card_slot_interface<device_crvision_cart_interface>(mconfig, *this), m_type(CRV_4K), m_cart(nullptr) { } @@ -85,7 +84,7 @@ crvision_cart_slot_device::~crvision_cart_slot_device() void crvision_cart_slot_device::device_start() { - m_cart = dynamic_cast<device_crvision_cart_interface *>(get_card_device()); + m_cart = get_card_device(); } @@ -115,7 +114,7 @@ static int crvision_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; } @@ -138,19 +137,16 @@ static const char *crvision_get_slot(int type) call load -------------------------------------------------*/ -image_init_result crvision_cart_slot_device::call_load() +std::pair<std::error_condition, std::string> crvision_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 > 0x4800) - { - 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 a CreatiVision cartridge (18K)"); - m_cart->rom_alloc(size, tag()); + m_cart->rom_alloc(size); if (!loaded_through_softlist()) fread(m_cart->get_rom_base(), size); @@ -193,12 +189,10 @@ image_init_result crvision_cart_slot_device::call_load() m_type = crvision_get_pcb_id(pcb_name); } - printf("Type: %s\n", crvision_get_slot(m_type)); - - return image_init_result::PASS; + logerror("Type: %s\n", crvision_get_slot(m_type)); } - return image_init_result::PASS; + return std::make_pair(std::error_condition(), std::string()); } @@ -210,10 +204,10 @@ std::string crvision_cart_slot_device::get_default_card_software(get_default_car { if (hook.image_file()) { - const char *slot_string; - uint32_t size = hook.image_file()->size(); - int type = CRV_4K; + uint64_t size; + hook.image_file()->length(size); // FIXME: check error return + int type = CRV_4K; switch (size) { case 0x4800: @@ -239,7 +233,7 @@ std::string crvision_cart_slot_device::get_default_card_software(get_default_car break; } - slot_string = crvision_get_slot(type); + char const *const slot_string = crvision_get_slot(type); //printf("type: %s\n", slot_string); @@ -253,18 +247,18 @@ std::string crvision_cart_slot_device::get_default_card_software(get_default_car read_rom -------------------------------------------------*/ -READ8_MEMBER(crvision_cart_slot_device::read_rom40) +uint8_t crvision_cart_slot_device::read_rom40(offs_t offset) { if (m_cart) - return m_cart->read_rom40(space, offset); + return m_cart->read_rom40(offset); else return 0xff; } -READ8_MEMBER(crvision_cart_slot_device::read_rom80) +uint8_t crvision_cart_slot_device::read_rom80(offs_t offset) { if (m_cart) - return m_cart->read_rom80(space, offset); + return m_cart->read_rom80(offset); else return 0xff; } |