From 7679e985d67e570751b305ad922bc96cbb5f9f44 Mon Sep 17 00:00:00 2001 From: Matthew Berry Date: Mon, 22 Feb 2021 23:24:47 -0800 Subject: [PATCH] save memory 0x0F mirroring, default sram to 0xFF, less restrictive save type search --- src/crab/bus.cr | 8 ++++---- src/crab/storage.cr | 4 ++-- src/crab/storage/sram.cr | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/crab/bus.cr b/src/crab/bus.cr index fab983c..4147572 100644 --- a/src/crab/bus.cr +++ b/src/crab/bus.cr @@ -23,8 +23,8 @@ class Bus when 0x8, 0x9, 0xA, 0xB, 0xC, 0xD then @gba.cartridge.rom[index & 0x01FFFFFF] - when 0xE then @gba.storage[index & 0xFFFF] - else abort "Unmapped read: #{hex_str index.to_u32}" + when 0xE, 0xF then @gba.storage[index & 0xFFFF] + else abort "Unmapped read: #{hex_str index.to_u32}" end end @@ -49,8 +49,8 @@ class Bus when 0x8, 0x9, 0xA, 0xB, 0xC, 0xD then (@gba.cartridge.rom.to_unsafe + (index & 0x01FFFFFF)).as(HalfWord*).value - when 0xE then read_half_slow(index) - else abort "Unmapped read: #{hex_str index.to_u32}" + when 0xE, 0xF then read_half_slow(index) + else abort "Unmapped read: #{hex_str index.to_u32}" end end diff --git a/src/crab/storage.cr b/src/crab/storage.cr index bb9af99..88a5677 100644 --- a/src/crab/storage.cr +++ b/src/crab/storage.cr @@ -6,8 +6,8 @@ abstract class Storage FLASH512 FLASH1M - def regex : Regex - /#{self}_V\d{3}/ + def regex : Regex # don't rely on the 3 digits after this string + /#{self}_V/ end def bytes : Int diff --git a/src/crab/storage/sram.cr b/src/crab/storage/sram.cr index b411288..a6a7252 100644 --- a/src/crab/storage/sram.cr +++ b/src/crab/storage/sram.cr @@ -1,5 +1,5 @@ class SRAM < Storage - @memory = Bytes.new(Type::SRAM.bytes, 0x00) + @memory = Bytes.new(Type::SRAM.bytes, 0xFF) def [](index : Int) : Byte index < @memory.size ? @memory[index] : 0_u8