mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-15 03:40:56 +01:00
cartridge oob data, wait states 1/2
This commit is contained in:
parent
8e21578553
commit
502df9b634
2 changed files with 14 additions and 14 deletions
|
@ -20,7 +20,9 @@ class Bus
|
||||||
address -= 0x8000 if address > 0x17FFF
|
address -= 0x8000 if address > 0x17FFF
|
||||||
@gba.ppu.vram[address]
|
@gba.ppu.vram[address]
|
||||||
when 0x7 then @gba.ppu.oam[index & 0x3FF]
|
when 0x7 then @gba.ppu.oam[index & 0x3FF]
|
||||||
when 0x8, 0x9 then @gba.cartridge[index & 0x7FFFFFF]
|
when 0x8, 0x9,
|
||||||
|
0xA, 0xB,
|
||||||
|
0xC, 0xD then @gba.cartridge[index & 0x01FFFFFF]
|
||||||
else raise "Unmapped read: #{hex_str index.to_u32}"
|
else raise "Unmapped read: #{hex_str index.to_u32}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,7 +76,7 @@ class Bus
|
||||||
address -= 0x8000 if address > 0x17FFF
|
address -= 0x8000 if address > 0x17FFF
|
||||||
@gba.ppu.vram[address] = value
|
@gba.ppu.vram[address] = value
|
||||||
when 0x7 then @gba.ppu.oam[index & 0x3FF]
|
when 0x7 then @gba.ppu.oam[index & 0x3FF]
|
||||||
when 0x8, 0x9 then @gba.cartridge[index & 0x7FFFFFF] = value
|
when 0x8, 0x9 # can't write to cartridge
|
||||||
else raise "Unmapped write: #{hex_str index.to_u32}"
|
else raise "Unmapped write: #{hex_str index.to_u32}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,18 +7,16 @@ class Cartridge
|
||||||
io.to_s
|
io.to_s
|
||||||
}
|
}
|
||||||
|
|
||||||
def initialize(rom_path : String)
|
@rom = Bytes.new 0x02000000 do |addr|
|
||||||
@rom = File.open rom_path do |file|
|
oob = 0xFFFF & (addr >> 1)
|
||||||
bytes = Bytes.new file.size
|
(oob >> (8 * (addr & 1))).to_u8!
|
||||||
file.read bytes
|
|
||||||
bytes
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize(rom_path : String)
|
||||||
|
File.open(rom_path) { |file| file.read @rom }
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](index : Int) : Byte
|
def [](index : Int) : Byte
|
||||||
@rom[index]
|
@rom[index]
|
||||||
end
|
end
|
||||||
|
|
||||||
def []=(index : Int, value : Byte) : Nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue