chore: implement I/O regsister for Minish Cap
This commit is contained in:
parent
ed6e83b121
commit
084d4b28dd
12
src/apu.zig
12
src/apu.zig
|
@ -105,13 +105,13 @@ pub const Apu = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NR52
|
/// NR52
|
||||||
pub fn soundCntX(self: *const Self) u32 {
|
pub fn soundCntX(self: *const Self) u8 {
|
||||||
const apu_enable = @boolToInt(self.cnt.apu_enable.read());
|
const apu_enable: u8 = @boolToInt(self.cnt.apu_enable.read());
|
||||||
|
|
||||||
const ch1_enable = @boolToInt(self.ch1.enabled);
|
const ch1_enable: u8 = @boolToInt(self.ch1.enabled);
|
||||||
const ch2_enable = @boolToInt(self.ch2.enabled);
|
const ch2_enable: u8 = @boolToInt(self.ch2.enabled);
|
||||||
const ch3_enable = @boolToInt(self.ch3.enabled);
|
const ch3_enable: u8 = @boolToInt(self.ch3.enabled);
|
||||||
const ch4_enable = @boolToInt(self.ch4.enabled);
|
const ch4_enable: u8 = @boolToInt(self.ch4.enabled);
|
||||||
|
|
||||||
return apu_enable << 7 | ch4_enable << 3 | ch3_enable << 2 | ch2_enable << 1 | ch1_enable;
|
return apu_enable << 7 | ch4_enable << 3 | ch3_enable << 2 | ch2_enable << 1 | ch1_enable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ pub fn read(bus: *const Bus, comptime T: type, address: u32) T {
|
||||||
0x0400_0079 => bus.apu.ch4.envelope.raw,
|
0x0400_0079 => bus.apu.ch4.envelope.raw,
|
||||||
0x0400_007C => bus.apu.ch4.poly.raw,
|
0x0400_007C => bus.apu.ch4.poly.raw,
|
||||||
0x0400_0081 => @truncate(T, bus.apu.psg_cnt.raw >> 8),
|
0x0400_0081 => @truncate(T, bus.apu.psg_cnt.raw >> 8),
|
||||||
|
0x0400_0084 => bus.apu.soundCntX(),
|
||||||
0x0400_0089 => @truncate(T, bus.apu.bias.raw >> 8),
|
0x0400_0089 => @truncate(T, bus.apu.bias.raw >> 8),
|
||||||
|
|
||||||
// Serial Communication 1
|
// Serial Communication 1
|
||||||
|
|
Loading…
Reference in New Issue