mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
moved save mirroring to each save impl
This commit is contained in:
parent
7679e985d6
commit
f4a5564639
3 changed files with 7 additions and 7 deletions
|
@ -23,7 +23,7 @@ class Bus
|
|||
when 0x8, 0x9,
|
||||
0xA, 0xB,
|
||||
0xC, 0xD then @gba.cartridge.rom[index & 0x01FFFFFF]
|
||||
when 0xE, 0xF then @gba.storage[index & 0xFFFF]
|
||||
when 0xE, 0xF then @gba.storage[index]
|
||||
else abort "Unmapped read: #{hex_str index.to_u32}"
|
||||
end
|
||||
end
|
||||
|
@ -123,7 +123,7 @@ class Bus
|
|||
when 0x8, 0x9,
|
||||
0xA, 0xB,
|
||||
0xC, 0xD then log "Writing to cart - #{hex_str index.to_u32}: #{hex_str value}"
|
||||
when 0xE then @gba.storage[index & 0xFFFF] = value
|
||||
when 0xE then @gba.storage[index] = value
|
||||
else abort "Unmapped write: #{hex_str index.to_u32}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,6 +32,7 @@ class Flash < Storage
|
|||
end
|
||||
|
||||
def [](index : Int) : Byte
|
||||
index &= 0xFFFF
|
||||
if @state.includes?(State::IDENTIFICATION) && 0 <= index <= 1
|
||||
(@id >> (8 * index) & 0xFF).to_u8!
|
||||
else
|
||||
|
@ -40,6 +41,7 @@ class Flash < Storage
|
|||
end
|
||||
|
||||
def []=(index : Int, value : Byte) : Nil
|
||||
index &= 0xFFFF
|
||||
case @state
|
||||
when .includes? State::PREPARE_WRITE
|
||||
@memory[0x10000 * @bank + index] &= value
|
||||
|
|
|
@ -2,13 +2,11 @@ class SRAM < Storage
|
|||
@memory = Bytes.new(Type::SRAM.bytes, 0xFF)
|
||||
|
||||
def [](index : Int) : Byte
|
||||
index < @memory.size ? @memory[index] : 0_u8
|
||||
@memory[index & 0x7FFF]
|
||||
end
|
||||
|
||||
def []=(index : Int, value : Byte) : Nil
|
||||
if index < @memory.size
|
||||
@memory[index] = value
|
||||
@dirty = true
|
||||
end
|
||||
@memory[index & 0x7FFF] = value
|
||||
@dirty = true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue