chore: properly write to VOFS and HOFS in 32-bit bus

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-02-16 23:23:41 -04:00
parent 034f2e8d1d
commit 4018f3875b
1 changed files with 16 additions and 8 deletions

View File

@ -142,14 +142,22 @@ pub fn read32(bus: *const Bus, addr: u32) u32 {
pub fn write32(bus: *Bus, addr: u32, word: u32) void { pub fn write32(bus: *Bus, addr: u32, word: u32) void {
switch (addr) { switch (addr) {
0x0400_0000 => bus.ppu.dispcnt.raw = @truncate(u16, word), 0x0400_0000 => bus.ppu.dispcnt.raw = @truncate(u16, word),
0x0400_0010 => bus.ppu.bg[0].hofs.raw = @truncate(u16, word), // TODO: Don't write out every HOFS / VOFS? 0x0400_0010 => {
0x0400_0012 => bus.ppu.bg[0].vofs.raw = @truncate(u16, word), bus.ppu.bg[0].hofs.raw = @truncate(u16, word);
0x0400_0014 => bus.ppu.bg[1].hofs.raw = @truncate(u16, word), bus.ppu.bg[0].vofs.raw = @truncate(u16, word >> 16);
0x0400_0016 => bus.ppu.bg[1].vofs.raw = @truncate(u16, word), },
0x0400_0018 => bus.ppu.bg[2].hofs.raw = @truncate(u16, word), 0x0400_0014 => {
0x0400_001A => bus.ppu.bg[2].vofs.raw = @truncate(u16, word), bus.ppu.bg[1].hofs.raw = @truncate(u16, word);
0x0400_001C => bus.ppu.bg[3].hofs.raw = @truncate(u16, word), bus.ppu.bg[1].vofs.raw = @truncate(u16, word >> 16);
0x0400_001E => bus.ppu.bg[3].vofs.raw = @truncate(u16, word), },
0x0400_0018 => {
bus.ppu.bg[2].hofs.raw = @truncate(u16, word);
bus.ppu.bg[2].vofs.raw = @truncate(u16, word >> 16);
},
0x0400_001C => {
bus.ppu.bg[3].hofs.raw = @truncate(u16, word);
bus.ppu.bg[3].vofs.raw = @truncate(u16, word >> 16);
},
0x0400_0200 => bus.io.ie.raw = @truncate(u16, word), 0x0400_0200 => bus.io.ie.raw = @truncate(u16, word),
0x0400_0208 => bus.io.ime = word & 1 == 1, 0x0400_0208 => bus.io.ime = word & 1 == 1,
else => std.debug.panic("[I/O:32] tried to write 0x{X:} to 0x{X:}", .{ word, addr }), else => std.debug.panic("[I/O:32] tried to write 0x{X:} to 0x{X:}", .{ word, addr }),