chore: attempt to debug Rhythm Heaven

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-10-21 05:12:50 -03:00
parent 42c6b21124
commit d1d32e465c
2 changed files with 11 additions and 2 deletions

View File

@ -20,7 +20,7 @@ pub fn read(comptime T: type, dma: *const DmaTuple, addr: u32) T {
u32 => switch (byte) { u32 => switch (byte) {
0xB8 => @as(T, dma.*[0].cnt.raw) << 16, 0xB8 => @as(T, dma.*[0].cnt.raw) << 16,
0xC4 => @as(T, dma.*[1].cnt.raw) << 16, 0xC4 => @as(T, dma.*[1].cnt.raw) << 16,
0xD0 => @as(T, dma.*[1].cnt.raw) << 16, 0xD0 => @as(T, dma.*[2].cnt.raw) << 16,
0xDC => @as(T, dma.*[3].cnt.raw) << 16, 0xDC => @as(T, dma.*[3].cnt.raw) << 16,
else => readUndefined(log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }), else => readUndefined(log, "Tried to perform a {} read to 0x{X:0>8}", .{ T, addr }),
}, },
@ -174,7 +174,7 @@ fn DmaController(comptime id: u2) type {
} }
pub fn setCnt(self: *Self, word: u32) void { pub fn setCnt(self: *Self, word: u32) void {
self.word_count = @truncate(@TypeOf(self.word_count), word); self.setCntL(@truncate(u16, word));
self.setCntH(@truncate(u16, word >> 16)); self.setCntH(@truncate(u16, word >> 16));
} }

View File

@ -157,6 +157,15 @@ pub fn main() anyerror!void {
SDL.SDLK_RSHIFT => io.keyinput.select.set(), SDL.SDLK_RSHIFT => io.keyinput.select.set(),
SDL.SDLK_i => log.err("Sample Count: {}", .{@intCast(u32, SDL.SDL_AudioStreamAvailable(cpu.bus.apu.stream)) / (2 * @sizeOf(u16))}), SDL.SDLK_i => log.err("Sample Count: {}", .{@intCast(u32, SDL.SDL_AudioStreamAvailable(cpu.bus.apu.stream)) / (2 * @sizeOf(u16))}),
SDL.SDLK_j => log.err("Scheduler Capacity: {} | Scheduler Event Count: {}", .{ scheduler.queue.capacity(), scheduler.queue.count() }), SDL.SDLK_j => log.err("Scheduler Capacity: {} | Scheduler Event Count: {}", .{ scheduler.queue.capacity(), scheduler.queue.count() }),
SDL.SDLK_k => {
// Dump IWRAM to file
log.info("PC: 0x{X:0>8}", .{cpu.r[15]});
log.info("LR: 0x{X:0>8}", .{cpu.r[14]});
// const iwram_file = try std.fs.cwd().createFile("iwram.bin", .{});
// defer iwram_file.close();
// try iwram_file.writeAll(cpu.bus.iwram.buf);
},
else => {}, else => {},
} }
}, },