From d1d32e465ca9048e9d684a2b88d37badf9a75b80 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:50 -0300 Subject: [PATCH] chore: attempt to debug Rhythm Heaven --- src/bus/dma.zig | 4 ++-- src/main.zig | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/bus/dma.zig b/src/bus/dma.zig index 4a7bfd0..3b3e7b0 100644 --- a/src/bus/dma.zig +++ b/src/bus/dma.zig @@ -20,7 +20,7 @@ pub fn read(comptime T: type, dma: *const DmaTuple, addr: u32) T { u32 => switch (byte) { 0xB8 => @as(T, dma.*[0].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, 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 { - self.word_count = @truncate(@TypeOf(self.word_count), word); + self.setCntL(@truncate(u16, word)); self.setCntH(@truncate(u16, word >> 16)); } diff --git a/src/main.zig b/src/main.zig index d320ce1..e617c6b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -157,6 +157,15 @@ pub fn main() anyerror!void { 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_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 => {}, } },