From 7e5a013c092e7adb621b6580fa0a4bc3e6ec3520 Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Sat, 13 Feb 2021 20:12:23 +0100 Subject: bus/c64: fixed MT07867 --- src/devices/bus/c64/exp.cpp | 6 ++++++ src/devices/bus/c64/exp.h | 3 +++ src/devices/bus/c64/ocean.cpp | 4 ++-- src/devices/bus/c64/std.cpp | 6 +++--- src/devices/bus/c64/westermann.cpp | 6 +++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/devices/bus/c64/exp.cpp b/src/devices/bus/c64/exp.cpp index 8304a7be6b7..9d7ab9649dc 100644 --- a/src/devices/bus/c64/exp.cpp +++ b/src/devices/bus/c64/exp.cpp @@ -29,6 +29,8 @@ DEFINE_DEVICE_TYPE(C64_EXPANSION_SLOT, c64_expansion_slot_device, "c64_expansion device_c64_expansion_card_interface::device_c64_expansion_card_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "c64exp"), + m_roml_size(0), + m_romh_size(0), m_game(1), m_exrom(1) { @@ -166,6 +168,8 @@ image_init_result c64_expansion_slot_device::call_load() // Ultimax (VIC-10) cartridge load_software_region("lorom", m_card->m_roml); load_software_region("uprom", m_card->m_romh); + m_card->m_roml_size = get_software_region_length("roml"); + m_card->m_romh_size = get_software_region_length("romh"); m_card->m_exrom = 1; m_card->m_game = 0; @@ -177,6 +181,8 @@ image_init_result c64_expansion_slot_device::call_load() load_software_region("romh", m_card->m_romh); load_software_region("romx", m_card->m_romx); load_software_region("nvram", m_card->m_nvram); + m_card->m_roml_size = get_software_region_length("roml"); + m_card->m_romh_size = get_software_region_length("romh"); if (get_feature("exrom") != nullptr) m_card->m_exrom = atol(get_feature("exrom")); if (get_feature("game") != nullptr) m_card->m_game = atol(get_feature("game")); diff --git a/src/devices/bus/c64/exp.h b/src/devices/bus/c64/exp.h index 29e79fb1ff8..ed0beb8caa2 100644 --- a/src/devices/bus/c64/exp.h +++ b/src/devices/bus/c64/exp.h @@ -153,6 +153,9 @@ protected: std::unique_ptr m_romx; std::unique_ptr m_nvram; + uint32_t m_roml_size; + uint32_t m_romh_size; + int m_game; int m_exrom; diff --git a/src/devices/bus/c64/ocean.cpp b/src/devices/bus/c64/ocean.cpp index d267a9912fa..3e134d9449b 100644 --- a/src/devices/bus/c64/ocean.cpp +++ b/src/devices/bus/c64/ocean.cpp @@ -87,12 +87,12 @@ uint8_t c64_ocean_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int sp if (!roml && m_roml) { offs_t addr = (m_bank << 13) | (offset & 0x1fff); - data = m_roml[addr]; + data = m_roml[addr & (m_roml_size - 1)]; } else if (!romh && m_romh) { offs_t addr = (m_bank << 13) | (offset & 0x1fff); - data = m_romh[addr]; + data = m_romh[addr & (m_romh_size - 1)]; } else if (!io1) { diff --git a/src/devices/bus/c64/std.cpp b/src/devices/bus/c64/std.cpp index 95d472bfbfd..127f0bf235c 100644 --- a/src/devices/bus/c64/std.cpp +++ b/src/devices/bus/c64/std.cpp @@ -51,17 +51,17 @@ uint8_t c64_standard_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, int { if (!roml && m_roml) { - data = m_roml[offset]; + data = m_roml[offset & (m_roml_size - 1)]; } else if (!romh) { if (m_romh) { - data = m_romh[offset]; + data = m_romh[offset & (m_romh_size - 1)]; } else if (m_roml) { - data = m_roml[offset]; + data = m_roml[offset & (m_roml_size - 1)]; } } diff --git a/src/devices/bus/c64/westermann.cpp b/src/devices/bus/c64/westermann.cpp index 33b22c06942..57a752c8fe2 100644 --- a/src/devices/bus/c64/westermann.cpp +++ b/src/devices/bus/c64/westermann.cpp @@ -61,17 +61,17 @@ uint8_t c64_westermann_cartridge_device::c64_cd_r(offs_t offset, uint8_t data, i { if (!roml) { - data = m_roml[offset]; + data = m_roml[offset & (m_roml_size - 1)]; } else if (!romh) { if (m_romh) { - data = m_romh[offset]; + data = m_romh[offset & (m_romh_size - 1)]; } else { - data = m_roml[offset]; + data = m_roml[offset & (m_roml_size - 1)]; } } else if (!io2) -- cgit v1.2.3