chore: make use of scoped logging
This commit is contained in:
13
src/Bus.zig
13
src/Bus.zig
@@ -9,6 +9,7 @@ const Ppu = @import("ppu.zig").Ppu;
|
||||
const Scheduler = @import("scheduler.zig").Scheduler;
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
const log = std.log.scoped(.Bus);
|
||||
const Self = @This();
|
||||
|
||||
pak: GamePak,
|
||||
@@ -56,7 +57,7 @@ pub fn read32(self: *const Self, addr: u32) u32 {
|
||||
0x0C00_0000...0x0DFF_FFFF => self.pak.get32(addr - 0x0C00_0000),
|
||||
|
||||
else => {
|
||||
std.log.warn("[Bus:32] ZBA tried to read from 0x{X:}", .{addr});
|
||||
log.warn("32-bit read from 0x{X:0>8}", .{addr});
|
||||
return 0x0000_0000;
|
||||
},
|
||||
};
|
||||
@@ -76,7 +77,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...0x0700_03FF => std.debug.panic("[Bus:32] wrote 0x{X:} to 0x{X:} in OAM", .{ word, addr }),
|
||||
|
||||
else => std.log.warn("[Bus:32] ZBA tried to write 0x{X:} to 0x{X:}", .{ word, addr }),
|
||||
else => log.warn("32-bit write of 0x{X:0>8} to 0x{X:0>8}", .{ word, addr }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +100,7 @@ pub fn read16(self: *const Self, addr: u32) u16 {
|
||||
0x0C00_0000...0x0DFF_FFFF => self.pak.get16(addr - 0x0C00_0000),
|
||||
|
||||
else => {
|
||||
std.log.warn("[Bus:16] ZBA tried to read from 0x{X:}", .{addr});
|
||||
log.warn("16-bit read from 0x{X:0>8}", .{addr});
|
||||
return 0x0000;
|
||||
},
|
||||
};
|
||||
@@ -118,7 +119,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...0x0700_03FF => std.debug.panic("[Bus:16] write 0x{X:} to 0x{X:} in OAM", .{ halfword, addr }),
|
||||
|
||||
else => std.log.warn("[Bus:16] ZBA tried to write 0x{X:} to 0x{X:}", .{ halfword, addr }),
|
||||
else => log.warn("16-bit write of 0x{X:0>4} to 0x{X:0>8}", .{ halfword, addr }),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ pub fn read8(self: *const Self, addr: u32) u8 {
|
||||
0x0E00_0000...0x0E00_FFFF => std.debug.panic("[Bus:8] read from 0x{X:} in Game Pak SRAM", .{addr}),
|
||||
|
||||
else => {
|
||||
std.log.warn("[Bus:8] ZBA tried to read from 0x{X:}", .{addr});
|
||||
log.warn("8-bit read from 0x{X:0>8}", .{addr});
|
||||
return 0x00;
|
||||
},
|
||||
};
|
||||
@@ -157,6 +158,6 @@ pub fn write8(self: *Self, addr: u32, byte: u8) void {
|
||||
|
||||
// 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.log.warn("[Bus:8] ZBA tried to write 0x{X:} to 0x{X:}", .{ byte, addr }),
|
||||
else => log.warn("8-bit write of 0x{X:0>2} to 0x{X:0>8}", .{ byte, addr }),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user