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
|
||||
@gba.ppu.vram[address]
|
||||
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}"
|
||||
end
|
||||
end
|
||||
|
@ -74,7 +76,7 @@ class Bus
|
|||
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
|
||||
when 0x8, 0x9 # can't write to cartridge
|
||||
else raise "Unmapped write: #{hex_str index.to_u32}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,18 +7,16 @@ class Cartridge
|
|||
io.to_s
|
||||
}
|
||||
|
||||
def initialize(rom_path : String)
|
||||
@rom = File.open rom_path do |file|
|
||||
bytes = Bytes.new file.size
|
||||
file.read bytes
|
||||
bytes
|
||||
@rom = Bytes.new 0x02000000 do |addr|
|
||||
oob = 0xFFFF & (addr >> 1)
|
||||
(oob >> (8 * (addr & 1))).to_u8!
|
||||
end
|
||||
|
||||
def initialize(rom_path : String)
|
||||
File.open(rom_path) { |file| file.read @rom }
|
||||
end
|
||||
|
||||
def [](index : Int) : Byte
|
||||
@rom[index]
|
||||
end
|
||||
|
||||
def []=(index : Int, value : Byte) : Nil
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue