chore: implement apu u16 reads

This commit is contained in:
Rekai Nyangadzayi Musuka 2022-05-21 15:09:32 -03:00
parent 109561310e
commit a2d2a84850
2 changed files with 11 additions and 1 deletions

View File

@ -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,

View File

@ -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