vram writes

This commit is contained in:
Matthew Berry 2020-10-02 00:00:21 -07:00
parent 1d148c3ea7
commit 67c58e5f2b
2 changed files with 16 additions and 4 deletions

View file

@ -1,4 +1,5 @@
class Bus
BIOS = 0x00000000..0x00003FFF
WRAM_BOARD = 0x02000000..0x0203FFFF
WRAM_CHIP = 0x03000000..0x03007FFF
PPU_IO = 0x04000000..0x0400005F
@ -9,6 +10,7 @@ class Bus
KEYPAD_IO = 0x04000130..0x04000133
SERIAL_IO_2 = 0x04000134..0x040001FF
INTERRUPT_IO = 0x04000200..0x0400FFFF
PPU = 0x05000000..0x07FFFFFF
CARTRIDGE = 0x08000000..0x0FFFFFFF
UNUSED = 0x10000000..0xFFFFFFFF
@ -23,7 +25,8 @@ class Bus
case index
when WRAM_BOARD then @wram_board[index - WRAM_BOARD.begin]
when WRAM_CHIP then @wram_chip[index - WRAM_CHIP.begin]
when PPU_IO then @gba.ppu[index]
when PPU_IO then @gba.ppu[index]
when PPU then @gba.ppu[index]
when CARTRIDGE then @gba.cartridge[index - CARTRIDGE.begin]
when UNUSED then 0xFF
else 0xFF
@ -47,7 +50,8 @@ class Bus
case index
when WRAM_BOARD then @wram_board[index - WRAM_BOARD.begin] = value
when WRAM_CHIP then @wram_chip[index - WRAM_CHIP.begin] = value
when PPU_IO then @gba.ppu[index] = value
when PPU_IO then @gba.ppu[index] = value
when PPU then @gba.ppu[index] = value
when CARTRIDGE then @gba.cartridge[index - CARTRIDGE.begin] = value # todo is this meant to be writable?
when UNUSED then nil
else raise "Unimplemented write ~ addr:#{hex_str index.to_u32}, val:#{value}"

View file

@ -1,4 +1,8 @@
class PPU
BG_OBJ_PALETTE = 0x05000000..0x050003FF
VRAM = 0x06000000..0x06017FFF
OAM = 0x07000000..0x070003FF
# LCD Control
class DISPCNT < BitField(UInt16)
bool obj_window_display
@ -17,6 +21,8 @@ class PPU
num bg_mode, 3 # (0-5=Video Mode 0-5, 6-7=Prohibited)
end
@vram = Bytes.new VRAM.size
@dispcnt : DISPCNT = DISPCNT.new 0
def initialize(@gba : GBA)
@ -28,7 +34,8 @@ class PPU
when 0x04000001 then @dispcnt.value.to_u8!
when 0x04000002 then 0_u8
when 0x04000003 then 0_u8
else raise "Unimplemented PPU read ~ addr:#{hex_str index.to_u32}"
when VRAM then @vram[index = VRAM.begin]
else raise "Unimplemented PPU read ~ addr:#{hex_str index.to_u32}"
end
end
@ -38,7 +45,8 @@ class PPU
when 0x04000001 then @dispcnt.value = (@dispcnt.value & 0xFF00) | value
when 0x04000002
when 0x04000003
else raise "Unimplemented PPU write ~ addr:#{hex_str index.to_u32}, val:#{value}"
when VRAM then @vram[index - VRAM.begin] = value
else raise "Unimplemented PPU write ~ addr:#{hex_str index.to_u32}, val:#{value}"
end
end
end