cartridge oob data, wait states 1/2

This commit is contained in:
Matthew Berry 2020-11-07 19:40:29 -08:00
parent 8e21578553
commit 502df9b634
2 changed files with 14 additions and 14 deletions

View file

@ -19,9 +19,11 @@ class Bus
address = 0x1FFFF_u32 & index
address -= 0x8000 if address > 0x17FFF
@gba.ppu.vram[address]
when 0x7 then @gba.ppu.oam[index & 0x3FF]
when 0x8, 0x9 then @gba.cartridge[index & 0x7FFFFFF]
else raise "Unmapped read: #{hex_str index.to_u32}"
when 0x7 then @gba.ppu.oam[index & 0x3FF]
when 0x8, 0x9,
0xA, 0xB,
0xC, 0xD then @gba.cartridge[index & 0x01FFFFFF]
else raise "Unmapped read: #{hex_str index.to_u32}"
end
end
@ -73,9 +75,9 @@ class Bus
address = 0x1FFFF_u32 & index
address -= 0x8000 if address > 0x17FFF
@gba.ppu.vram[address] = value
when 0x7 then @gba.ppu.oam[index & 0x3FF]
when 0x8, 0x9 then @gba.cartridge[index & 0x7FFFFFF] = value
else raise "Unmapped write: #{hex_str index.to_u32}"
when 0x7 then @gba.ppu.oam[index & 0x3FF]
when 0x8, 0x9 # can't write to cartridge
else raise "Unmapped write: #{hex_str index.to_u32}"
end
end

View file

@ -7,18 +7,16 @@ class Cartridge
io.to_s
}
@rom = Bytes.new 0x02000000 do |addr|
oob = 0xFFFF & (addr >> 1)
(oob >> (8 * (addr & 1))).to_u8!
end
def initialize(rom_path : String)
@rom = File.open rom_path do |file|
bytes = Bytes.new file.size
file.read bytes
bytes
end
File.open(rom_path) { |file| file.read @rom }
end
def [](index : Int) : Byte
@rom[index]
end
def []=(index : Int, value : Byte) : Nil
end
end