Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add channel 1 duty delay test #59

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Test status of [Same Suite](https://github.com/YushiOMOTE/SameSuite/tree/430ab7f
* [x] `apu/div_trigger_volume_10.gb`
* Channel 1
* [x] `apu/channel_1/channel_1_delay.gb`
* [x] `apu/channel_1/channel_1_duty_delay.gb`
* Channel 4
* [x] `apu/channel_4/channel_4_lfsr.gb`
* [x] `apu/channel_4/channel_4_lfsr15.gb`
Expand Down
8 changes: 7 additions & 1 deletion core/src/apu/tone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Tone {
dac: Dac,
index: usize,
after_power_on: bool,
current_duty: usize,
}

#[bitfield(u8)]
Expand Down Expand Up @@ -109,6 +110,7 @@ impl Tone {
dac: Dac::new(),
index: 0,
after_power_on: true,
current_duty: 0,
}
}

Expand Down Expand Up @@ -217,6 +219,7 @@ impl Tone {
self.load_initial_timer();
self.envelope
.update(self.nr12.init(), self.nr12.count(), self.nr12.increase());
self.current_duty = self.nr11.wave_duty();
}

self.nr14.trigger()
Expand Down Expand Up @@ -284,6 +287,9 @@ impl Tone {

self.index = (self.index + 1) % 8;

// Changing the duty becomes effective only after the current sample finishes.
self.current_duty = self.nr11.wave_duty();

self.after_power_on = false;
}

Expand All @@ -294,7 +300,7 @@ impl Tone {
// 1 10000001 25%
// 2 10000111 50%
// 3 01111110 75%
let wave = match self.nr11.wave_duty() {
let wave = match self.current_duty {
0 => [0, 0, 0, 0, 0, 0, 0, 1],
1 => [1, 0, 0, 0, 0, 0, 0, 1],
2 => [1, 0, 0, 0, 0, 1, 1, 1],
Expand Down
Loading
Loading