mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
add dispstat + reads/writes
This commit is contained in:
parent
705113eae2
commit
cf156829e5
1 changed files with 18 additions and 2 deletions
|
@ -25,10 +25,22 @@ class PPU
|
|||
num bg_mode, 3 # (0-5=Video Mode 0-5, 6-7=Prohibited)
|
||||
end
|
||||
|
||||
class DISPSTAT < BitField(UInt16)
|
||||
num vcount_setting, 8
|
||||
num not_used, 2
|
||||
bool vcounter_irq_enable
|
||||
bool hblank_irq_enable
|
||||
bool vblank_irq_enable
|
||||
bool vcounter # todo update bitfield macro to make values read-only when writing to value
|
||||
bool hblank # todo update bitfield macro to make values read-only when writing to value
|
||||
bool vblank # todo update bitfield macro to make values read-only when writing to value
|
||||
end
|
||||
|
||||
getter pram = Bytes.new 0x400
|
||||
getter vram = Bytes.new 0x18000
|
||||
|
||||
getter dispcnt : DISPCNT = DISPCNT.new 0
|
||||
getter dispstat : DISPSTAT = DISPSTAT.new 0
|
||||
|
||||
@cycles = 0
|
||||
|
||||
|
@ -45,8 +57,10 @@ class PPU
|
|||
|
||||
def read_io(io_addr : Int) : Byte
|
||||
case io_addr
|
||||
when 0x000 then (@dispcnt.value >> 8).to_u8
|
||||
when 0x001 then @dispcnt.value.to_u8!
|
||||
when 0x000 then 0xFF_u8 & @dispcnt.value >> 8
|
||||
when 0x001 then 0xFF_u8 & @dispcnt.value
|
||||
when 0x004 then 0xFF_u8 & @dispstat.value >> 8
|
||||
when 0x005 then 0xFF_u8 & @dispstat.value
|
||||
else raise "Unimplemented PPU read ~ addr:#{hex_str io_addr.to_u8}"
|
||||
end
|
||||
end
|
||||
|
@ -57,6 +71,8 @@ class PPU
|
|||
when 0x001 then @dispcnt.value = (@dispcnt.value & 0xFF00) | value
|
||||
when 0x002 # undocumented - green swap
|
||||
when 0x003 # undocumented - green swap
|
||||
when 0x004 then @dispstat.value = (@dispstat.value & 0x00FF) | value.to_u16 << 8
|
||||
when 0x005 then @dispstat.value = (@dispstat.value & 0xFF00) | value
|
||||
else raise "Unimplemented PPU write ~ addr:#{hex_str io_addr.to_u8}, val:#{value}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue