Skip to content

Commit

Permalink
Wave RAM
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Jan 4, 2024
1 parent a12de3b commit be6426b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/sound/apu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Memory for APU {
0xFF10..=0xFF14 => self.sc1.read(a),
0xFF15..=0xFF19 => self.sc2.read(a),
0xFF1A..=0xFF1E => self.sc3.read(a),
0xFF30..=0xFF3F => self.sc3.read(a),
0xFF20..=0xFF24 => self.sc4.read(a),
_ => 0xFF
}
Expand Down Expand Up @@ -98,6 +99,7 @@ impl Memory for APU {
self.sc3.write(a, v)
}
},
0xFF30..=0xFF3F => self.sc3.write(a, v),
0xFF20..=0xFF24 => {
if self.audio_enabled {
self.sc4.write(a, v)
Expand Down
6 changes: 5 additions & 1 deletion src/sound/sc3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ pub struct SC3 {
output_level: OutputLevel,
period: u16,
pub trigger: bool,
length_enabled: bool
length_enabled: bool,
wave_ram: [u8; 16]
}

bitflags! {
Expand All @@ -29,6 +30,7 @@ impl SC3 {
period: 0,
trigger: false,
length_enabled: false,
wave_ram: [0; 16]
}
}

Expand All @@ -55,6 +57,7 @@ impl Memory for SC3 {
0xFF1D => 0xFF,
// NR34: Period High & Control
0xFF1E => (self.length_enabled as u8) << 6 | 0xBF,
0xFF30..=0xFF3F => self.wave_ram[a as usize - 0xFF30],
_ => 0xFF,
}
}
Expand All @@ -79,6 +82,7 @@ impl Memory for SC3 {
self.period &= 0b0000_0000_1111_1111;
self.period |= ((v & 0b0000_0111) as u16) << 8;
},
0xFF30..=0xFF3F => self.wave_ram[a as usize - 0xFF30] = v,
_ => panic!("Write to unsupported SC3 address ({:#06x})!", a),
}
}
Expand Down

0 comments on commit be6426b

Please sign in to comment.