From d1fce8ba757af9ecf0bf4da06c06d759adff02a6 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:22 -0300 Subject: [PATCH] chore: improve Bus log + panic messages --- src/Bus.zig | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Bus.zig b/src/Bus.zig index d253612..70ab917 100644 --- a/src/Bus.zig +++ b/src/Bus.zig @@ -58,7 +58,7 @@ pub fn read32(self: *const Self, addr: u32) u32 { 0x0C00_0000...0x0DFF_FFFF => self.pak.get32(addr - 0x0C00_0000), else => blk: { - log.warn("32-bit read from 0x{X:0>8}", .{addr}); + log.warn("Tried to read from 0x{X:0>8}", .{addr}); break :blk 0x0000_0000; }, }; @@ -78,7 +78,7 @@ pub fn write32(self: *Self, addr: u32, word: u32) void { 0x0600_0000...0x0601_7FFF => self.ppu.vram.set32(addr - 0x0600_0000, word), 0x0700_0000...0x07FF_FFFF => self.ppu.oam.set32(addr & 0x3FF, word), - else => log.warn("32-bit write of 0x{X:0>8} to 0x{X:0>8}", .{ word, addr }), + else => log.warn("Tried to write 0x{X:0>8} to 0x{X:0>8}", .{ word, addr }), } } @@ -100,7 +100,7 @@ pub fn read16(self: *const Self, addr: u32) u16 { 0x0A00_0000...0x0BFF_FFFF => self.pak.get16(addr - 0x0A00_0000), 0x0C00_0000...0x0DFF_FFFF => self.pak.get16(addr - 0x0C00_0000), - else => std.debug.panic("16-bit read from 0x{X:0>8}", .{addr}), + else => std.debug.panic("Tried to read from 0x{X:0>8}", .{addr}), }; } @@ -117,7 +117,7 @@ pub fn write16(self: *Self, addr: u32, halfword: u16) void { 0x0600_0000...0x0601_7FFF => self.ppu.vram.set16(addr - 0x0600_0000, halfword), 0x0700_0000...0x07FF_FFFF => self.ppu.oam.set16(addr & 0x3FF, halfword), - else => std.debug.panic("16-bit write of 0x{X:0>4} to 0x{X:0>8}", .{ halfword, addr }), + else => std.debug.panic("Tried to write 0x{X:0>4} to 0x{X:0>8}", .{ halfword, addr }), } } @@ -138,9 +138,9 @@ pub fn read8(self: *const Self, addr: u32) u8 { 0x0800_0000...0x09FF_FFFF => self.pak.get8(addr - 0x0800_0000), 0x0A00_0000...0x0BFF_FFFF => self.pak.get8(addr - 0x0A00_0000), 0x0C00_0000...0x0DFF_FFFF => self.pak.get8(addr - 0x0C00_0000), - 0x0E00_0000...0x0E00_FFFF => std.debug.panic("[Bus:8] read from 0x{X:} in Game Pak SRAM", .{addr}), + 0x0E00_0000...0x0E00_FFFF => std.debug.panic("Read from 0x{X:0>2} in Game Pak SRAM", .{addr}), - else => std.debug.panic("8-bit read from 0x{X:0>8}", .{addr}), + else => std.debug.panic("Tried to read from 0x{X:0>2}", .{addr}), }; } @@ -150,9 +150,10 @@ pub fn write8(self: *Self, addr: u32, byte: u8) void { 0x0200_0000...0x02FF_FFFF => self.ewram.set8(addr & 0x3FFFF, byte), 0x0300_0000...0x03FF_FFFF => self.iwram.set8(addr & 0x7FFF, byte), 0x0400_0000...0x0400_03FE => io.write8(self, addr, byte), + 0x0400_0410 => log.info("Wrote 0x{X:0>2} to 0x{X:0>8}. Ignored", .{ byte, addr }), // External Memory (Game Pak) - 0x0E00_0000...0x0E00_FFFF => std.debug.panic("[Bus:8] write 0x{X:} to 0x{X:} in Game Pak SRAM", .{ byte, addr }), - else => std.debug.panic("8-bit write of 0x{X:0>2} to 0x{X:0>8}", .{ byte, addr }), + 0x0E00_0000...0x0E00_FFFF => log.err("Wrote 0x{X:0>2} to 0x{X:0>8} in Game Pak SRAM", .{ byte, addr }), + else => std.debug.panic("Tried to write 0x{X:0>2} to 0x{X:0>8}", .{ byte, addr }), } }