From 89d8c08cd17304661a0cfa5bd68347652945f61f Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:44 -0300 Subject: [PATCH] chore: implement apu u16 reads --- src/apu.zig | 2 +- src/bus/io.zig | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/apu.zig b/src/apu.zig index 5c5334e..ea9148a 100644 --- a/src/apu.zig +++ b/src/apu.zig @@ -24,7 +24,7 @@ pub const Apu = struct { chB: DmaSound(.B), bias: io.SoundBias, - /// NR51 + /// NR50, NR51 psg_cnt: io.ChannelVolumeControl, dma_cnt: io.DmaSoundControl, cnt: io.SoundControl, diff --git a/src/bus/io.zig b/src/bus/io.zig index 019c59d..c817a7d 100644 --- a/src/bus/io.zig +++ b/src/bus/io.zig @@ -83,6 +83,16 @@ pub fn read(bus: *const Bus, comptime T: type, address: u32) T { 0x0400_004C => unimplementedRead("Read {} from MOSAIC", .{T}), // Sound + 0x0400_0060 => bus.apu.ch1.sweep.raw, + 0x0400_0062 => @as(u16, bus.apu.ch1.envelope.raw) << 8 | bus.apu.ch1.duty.raw, + 0x0400_0064 => bus.apu.ch1.freq.raw, + 0x0400_0068 => @as(u16, bus.apu.ch2.envelope.raw) << 8 | bus.apu.ch2.duty.raw, + 0x0400_006C => bus.apu.ch2.freq.raw, + 0x0400_0070 => bus.apu.ch3.select.raw, + 0x0400_0074 => bus.apu.ch3.freq.raw, + 0x0400_0078 => @as(u16, bus.apu.ch4.envelope.raw) << 8 | bus.apu.ch4.len, + 0x0400_007C => @as(u16, bus.apu.ch4.poly.raw) << 8 | bus.apu.ch4.cnt.raw, + 0x0400_0080 => bus.apu.dma_cnt.raw, 0x0400_0088 => bus.apu.bias.raw, // DMA Transfers