From 084d4b28dde1394e462462cddc2e10fe8ea666ec Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:38 -0300 Subject: [PATCH] chore: implement I/O regsister for Minish Cap --- src/apu.zig | 12 ++++++------ src/bus/io.zig | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/apu.zig b/src/apu.zig index 4db97bc..656ec39 100644 --- a/src/apu.zig +++ b/src/apu.zig @@ -105,13 +105,13 @@ pub const Apu = struct { } /// NR52 - pub fn soundCntX(self: *const Self) u32 { - const apu_enable = @boolToInt(self.cnt.apu_enable.read()); + pub fn soundCntX(self: *const Self) u8 { + const apu_enable: u8 = @boolToInt(self.cnt.apu_enable.read()); - const ch1_enable = @boolToInt(self.ch1.enabled); - const ch2_enable = @boolToInt(self.ch2.enabled); - const ch3_enable = @boolToInt(self.ch3.enabled); - const ch4_enable = @boolToInt(self.ch4.enabled); + const ch1_enable: u8 = @boolToInt(self.ch1.enabled); + const ch2_enable: u8 = @boolToInt(self.ch2.enabled); + const ch3_enable: u8 = @boolToInt(self.ch3.enabled); + const ch4_enable: u8 = @boolToInt(self.ch4.enabled); return apu_enable << 7 | ch4_enable << 3 | ch3_enable << 2 | ch2_enable << 1 | ch1_enable; } diff --git a/src/bus/io.zig b/src/bus/io.zig index 763c54b..a3f01ee 100644 --- a/src/bus/io.zig +++ b/src/bus/io.zig @@ -124,6 +124,7 @@ pub fn read(bus: *const Bus, comptime T: type, address: u32) T { 0x0400_0079 => bus.apu.ch4.envelope.raw, 0x0400_007C => bus.apu.ch4.poly.raw, 0x0400_0081 => @truncate(T, bus.apu.psg_cnt.raw >> 8), + 0x0400_0084 => bus.apu.soundCntX(), 0x0400_0089 => @truncate(T, bus.apu.bias.raw >> 8), // Serial Communication 1