chore(io): rewrite certain error messages
We can do this now that we know that it won't be because of any unimplemented feature in some circumstances
This commit is contained in:
		| @@ -31,7 +31,7 @@ pub fn read(comptime T: type, dma: *const DmaTuple, addr: u32) ?T { | ||||
|             0xD0 => @as(T, dma.*[2].cnt.raw) << 16, // DMA2CNT_L is write-only | ||||
|             0xD4, 0xD8 => null, // DMA3SAD, DMA3DAD | ||||
|             0xDC => @as(T, dma.*[3].cnt.raw) << 16, // DMA3CNT_L is write-only | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         u16 => switch (byte) { | ||||
|             0xB0...0xB8 => null, // DMA0SAD, DMA0DAD, DMA0CNT_L | ||||
| @@ -42,18 +42,18 @@ pub fn read(comptime T: type, dma: *const DmaTuple, addr: u32) ?T { | ||||
|             0xD2 => dma.*[2].cnt.raw, | ||||
|             0xD4...0xDC => null, // DMA3SAD, DMA3DAD, DMA3CNT_L | ||||
|             0xDE => dma.*[3].cnt.raw, | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         u8 => switch (byte) { | ||||
|             0xB0...0xB9 => null, // DMA0SAD, DMA0DAD, DMA0CNT_L | ||||
|             0xBA...0xBB => @truncate(T, dma.*[0].cnt.raw >> shift(byte)), | ||||
|             0xBA, 0xBB => @truncate(T, dma.*[0].cnt.raw >> shift(byte)), | ||||
|             0xBC...0xC5 => null, // DMA1SAD, DMA1DAD, DMA1CNT_L | ||||
|             0xC6...0xC7 => @truncate(T, dma.*[1].cnt.raw >> shift(byte)), | ||||
|             0xC6, 0xC7 => @truncate(T, dma.*[1].cnt.raw >> shift(byte)), | ||||
|             0xC8...0xD1 => null, // DMA2SAD, DMA2DAD, DMA2CNT_L | ||||
|             0xD2...0xD3 => @truncate(T, dma.*[2].cnt.raw >> shift(byte)), | ||||
|             0xD2, 0xD3 => @truncate(T, dma.*[2].cnt.raw >> shift(byte)), | ||||
|             0xD4...0xDD => null, // DMA3SAD, DMA3DAD, DMA3CNT_L | ||||
|             0xDE...0xDF => @truncate(T, dma.*[3].cnt.raw >> shift(byte)), | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             0xDE, 0xDF => @truncate(T, dma.*[3].cnt.raw >> shift(byte)), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         else => @compileError("DMA: Unsupported read width"), | ||||
|     }; | ||||
|   | ||||
| @@ -23,7 +23,7 @@ pub fn read(comptime T: type, tim: *const TimerTuple, addr: u32) ?T { | ||||
|             0x4 => @as(T, tim.*[1].cnt.raw) << 16 | tim.*[1].timcntL(), | ||||
|             0x8 => @as(T, tim.*[2].cnt.raw) << 16 | tim.*[2].timcntL(), | ||||
|             0xC => @as(T, tim.*[3].cnt.raw) << 16 | tim.*[3].timcntL(), | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         u16 => switch (nybble) { | ||||
|             0x0 => tim.*[0].timcntL(), | ||||
| @@ -34,7 +34,7 @@ pub fn read(comptime T: type, tim: *const TimerTuple, addr: u32) ?T { | ||||
|             0xA => tim.*[2].cnt.raw, | ||||
|             0xC => tim.*[3].timcntL(), | ||||
|             0xE => tim.*[3].cnt.raw, | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         u8 => switch (nybble) { | ||||
|             0x0, 0x1 => @truncate(T, tim.*[0].timcntL() >> shift(nybble)), | ||||
| @@ -45,7 +45,6 @@ pub fn read(comptime T: type, tim: *const TimerTuple, addr: u32) ?T { | ||||
|             0xA, 0xB => @truncate(T, tim.*[2].cnt.raw >> shift(nybble)), | ||||
|             0xC, 0xD => @truncate(T, tim.*[3].timcntL() >> shift(nybble)), | ||||
|             0xE, 0xF => @truncate(T, tim.*[3].cnt.raw >> shift(nybble)), | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         else => @compileError("TIM: Unsupported read width"), | ||||
|     }; | ||||
|   | ||||
| @@ -36,7 +36,7 @@ pub fn read(comptime T: type, ppu: *const Ppu, addr: u32) ?T { | ||||
|             0x4C => null, // MOSAIC, undefined in high byte | ||||
|             0x50 => @as(T, ppu.bldalpha.raw) << 16 | ppu.bldcnt.raw, | ||||
|             0x54 => null, // BLDY, undefined in high half-wrd | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         u16 => switch (byte) { | ||||
|             0x00 => ppu.dispcnt.raw, | ||||
| @@ -56,27 +56,27 @@ pub fn read(comptime T: type, ppu: *const Ppu, addr: u32) ?T { | ||||
|             0x50 => ppu.bldcnt.raw, | ||||
|             0x52 => ppu.bldalpha.raw, | ||||
|             0x54 => null, // BLDY | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         u8 => switch (byte) { | ||||
|             0x00...0x01 => @truncate(T, ppu.dispcnt.raw >> shift(byte)), | ||||
|             0x00, 0x01 => @truncate(T, ppu.dispcnt.raw >> shift(byte)), | ||||
|             0x02...0x03 => null, | ||||
|             0x04...0x05 => @truncate(T, ppu.dispstat.raw >> shift(byte)), | ||||
|             0x06...0x07 => @truncate(T, ppu.vcount.raw >> shift(byte)), | ||||
|             0x08...0x09 => @truncate(T, ppu.bg[0].cnt.raw >> shift(byte)), | ||||
|             0x0A...0x0B => @truncate(T, ppu.bg[1].cnt.raw >> shift(byte)), | ||||
|             0x0C...0x0D => @truncate(T, ppu.bg[2].cnt.raw >> shift(byte)), | ||||
|             0x0E...0x0F => @truncate(T, ppu.bg[3].cnt.raw >> shift(byte)), | ||||
|             0x04, 0x05 => @truncate(T, ppu.dispstat.raw >> shift(byte)), | ||||
|             0x06, 0x07 => @truncate(T, ppu.vcount.raw >> shift(byte)), | ||||
|             0x08, 0x09 => @truncate(T, ppu.bg[0].cnt.raw >> shift(byte)), | ||||
|             0x0A, 0x0B => @truncate(T, ppu.bg[1].cnt.raw >> shift(byte)), | ||||
|             0x0C, 0x0D => @truncate(T, ppu.bg[2].cnt.raw >> shift(byte)), | ||||
|             0x0E, 0x0F => @truncate(T, ppu.bg[3].cnt.raw >> shift(byte)), | ||||
|             0x10...0x1F => null, // BGXHOFS/VOFS | ||||
|             0x20...0x3F => null, // BG2/3 Rot Scaling Registers | ||||
|             0x40...0x47 => null, // WINXH/V Registers | ||||
|             0x48...0x49 => @truncate(T, ppu.win.in.raw >> shift(byte)), | ||||
|             0x4A...0x4B => @truncate(T, ppu.win.out.raw >> shift(byte)), | ||||
|             0x48, 0x49 => @truncate(T, ppu.win.in.raw >> shift(byte)), | ||||
|             0x4A, 0x4B => @truncate(T, ppu.win.out.raw >> shift(byte)), | ||||
|             0x4C...0x4D => null, // MOSAIC | ||||
|             0x50...0x51 => @truncate(T, ppu.bldcnt.raw >> shift(byte)), | ||||
|             0x52...0x53 => @truncate(T, ppu.bldalpha.raw >> shift(byte)), | ||||
|             0x50, 0x51 => @truncate(T, ppu.bldcnt.raw >> shift(byte)), | ||||
|             0x52, 0x53 => @truncate(T, ppu.bldalpha.raw >> shift(byte)), | ||||
|             0x54...0x55 => null, // BLDY | ||||
|             else => util.io.read.undef(T, log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), | ||||
|             else => util.io.read.err(T, log, "unaligned {} read from 0x{X:0>8}", .{ T, addr }), | ||||
|         }, | ||||
|         else => @compileError("PPU: Unsupported read width"), | ||||
|     }; | ||||
|   | ||||
| @@ -143,7 +143,7 @@ pub const io = struct { | ||||
|             return 0; | ||||
|         } | ||||
|  | ||||
|         pub fn undef(comptime T: type, log: anytype, comptime format: []const u8, args: anytype) ?T { | ||||
|         pub fn undef(comptime T: type, comptime log: anytype, comptime format: []const u8, args: anytype) ?T { | ||||
|             @setCold(true); | ||||
|  | ||||
|             const unhandled_io = config.config().debug.unhandled_io; | ||||
| @@ -153,6 +153,13 @@ pub const io = struct { | ||||
|  | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         pub fn err(comptime T: type, comptime log: anytype, comptime format: []const u8, args: anytype) ?T { | ||||
|             @setCold(true); | ||||
|  | ||||
|             log.err(format, args); | ||||
|             return null; | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     pub const write = struct { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user