diff options
author | Vas Crabb <vas@vastheman.com> | 2019-11-11 01:35:40 +1100 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2019-11-11 01:35:40 +1100 |
commit | 774cc7ce43783df900cbb32b9b6b7ac6426d3d41 (patch) | |
tree | 82a2024d2cc6b59adf1a0a20a1ac6fb33a90cb4a /src/devices/bus | |
parent | b9afe742e641e4f35b5568330de241b62c1be3ca (diff) |
bus/vboy: cartridge is 16 bits wide (not 32) but we'll keep pretending for program ROM (nw)
Diffstat (limited to 'src/devices/bus')
-rw-r--r-- | src/devices/bus/vboy/rom.cpp | 52 | ||||
-rw-r--r-- | src/devices/bus/vboy/slot.cpp | 3 |
2 files changed, 21 insertions, 34 deletions
diff --git a/src/devices/bus/vboy/rom.cpp b/src/devices/bus/vboy/rom.cpp index 3e050f70196..991206bd1c6 100644 --- a/src/devices/bus/vboy/rom.cpp +++ b/src/devices/bus/vboy/rom.cpp @@ -51,6 +51,12 @@ image_init_result vboy_flat_rom_device::load() // this should fail a validity check assert(!(rom_base() & 0x00ff'ffff)); + // This is a simplification that improves performance. In + // reality, cartridge ROM is 16 bits wide and 32-bit accesses + // are split up automatically. MAME doesn't really support + // dynamic bus sizing, and it's a lot faster to execute from a + // ROM handler than to go through the trampolines necessary to + // emulate 16-bit accesses. device_generic_cart_interface::install_non_power_of_two<2>( romregion->bytes() >> 2, 0x00ff'ffff >> 2, @@ -108,7 +114,7 @@ image_init_result vboy_flat_rom_sram_device::load() if (chip_space()) { device_generic_cart_interface::install_non_power_of_two<2>( - sramregion->bytes(), + sramregion->bytes() >> 1, 0x00ff'ffff >> 2, 0, 0, @@ -117,18 +123,18 @@ image_init_result vboy_flat_rom_sram_device::load() { LOG( "Install SRAM 0x%08X-0x%08X at 0x%08X-0x%08X mirror %08X\n", - src, - src + ((end - begin) >> 2), + src << 1, + (src << 1) + ((end - begin) >> 1), begin, end, mirror); - u8 *const base(&reinterpret_cast<u8 *>(sramregion->base())[src]); + u8 *const base(&reinterpret_cast<u8 *>(sramregion->base())[src << 1]); chip_space()->install_readwrite_handler( begin, end, read8sm_delegate(*this, NAME([base] (offs_t offset) { return base[offset]; })), write8sm_delegate(*this, NAME([base] (offs_t offset, u8 data) { base[offset] = data; })), - 0x0000'00ff); + 0x00ff'00ff); }); } save_pointer(NAME(&sramregion->as_u8()), sramregion->bytes()); @@ -138,7 +144,7 @@ image_init_result vboy_flat_rom_sram_device::load() if (chip_space()) { device_generic_cart_interface::install_non_power_of_two<2>( - sramregion->bytes() >> 1, + sramregion->bytes() >> 2, 0x00ff'ffff >> 2, 0, 0, @@ -147,47 +153,23 @@ image_init_result vboy_flat_rom_sram_device::load() { LOG( "Install SRAM 0x%08X-0x%08X at 0x%08X-0x%08X mirror %08X\n", - src << 1, - (src << 1) + ((end - begin) >> 1), + src << 2, + (src << 2) + (end - begin), begin, end, mirror); - u16 *const base(&reinterpret_cast<u16 *>(sramregion->base())[src]); + u16 *const base(&reinterpret_cast<u16 *>(sramregion->base())[src << 1]); chip_space()->install_readwrite_handler( begin, end, read16s_delegate(*this, NAME([base] (offs_t offset, u16 mem_mask) { return base[offset]; })), write16s_delegate(*this, NAME([base] (offs_t offset, u16 data, u16 mem_mask) { COMBINE_DATA(base + offset); })), - 0x0000'ffff); + 0xffff'ffff); }); } save_pointer(NAME(&sramregion->as_u16()), sramregion->bytes() >> 1); break; - case 32: - if (chip_space()) - { - device_generic_cart_interface::install_non_power_of_two<2>( - sramregion->bytes() >> 2, - 0x00ff'ffff >> 2, - 0, - 0, - chip_base(), - [this, sram = reinterpret_cast<u32 *>(sramregion->base())] (offs_t begin, offs_t end, offs_t mirror, offs_t src) - { - LOG( - "Install SRAM 0x%08X-0x%08X at 0x%08X-0x%08X mirror %08X\n", - src << 2, - (src << 2) + (end - begin), - begin, - end, - mirror); - chip_space()->install_ram(begin, end, mirror, &sram[src]); - }); - } - save_pointer(NAME(&sramregion->as_u32()), sramregion->bytes() >> 2); - break; - default: throw emu_fatalerror("Unsupported Virtual Boy cartridge backup RAM width\n"); } @@ -201,6 +183,8 @@ image_init_result vboy_flat_rom_sram_device::load() void vboy_flat_rom_sram_device::unload() { + vboy_flat_rom_device::unload(); + memory_region *const sramregion(memregion("^sram")); if (sramregion) battery_save(sramregion->base(), sramregion->bytes()); diff --git a/src/devices/bus/vboy/slot.cpp b/src/devices/bus/vboy/slot.cpp index c30ec18e34c..083c0db745b 100644 --- a/src/devices/bus/vboy/slot.cpp +++ b/src/devices/bus/vboy/slot.cpp @@ -2,6 +2,9 @@ // copyright-holders:Vas Crabb /*************************************************************************** Virtual Boy cartridge slot + + TODO: + - Sound capabilities ***************************************************************************/ #include "emu.h" |