Skip to content

Commit

Permalink
ym2612: immediately update key state on keyOn/keyOff
Browse files Browse the repository at this point in the history
Fixes Puyo Puyo Tsuu theme
  • Loading branch information
LukeUsher committed Oct 20, 2023
1 parent 62f5c36 commit 785edf6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ares/component/audio/ym2612/channel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
auto YM2612::Channel::Operator::updateKeyState(bool state) -> void {
if(keyOn == state) return; //no change
keyOn = state;
auto YM2612::Channel::Operator::updateKeyState() -> void {
if(keyOn == keyLine) return; //no change
keyOn = keyLine;

if(keyOn) {
//restart phase and envelope generators
Expand All @@ -27,7 +27,7 @@ auto YM2612::Channel::Operator::updateKeyState(bool state) -> void {
}

auto YM2612::Channel::Operator::runEnvelope() -> void {
updateKeyState(keyLine);
updateKeyState();
if(ym2612.envelope.clock & (1 << envelope.divider) - 1) return;

u32 value = ym2612.envelope.clock >> envelope.divider;
Expand Down
1 change: 1 addition & 0 deletions ares/component/audio/ym2612/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ auto YM2612::writeData(n8 data) -> void {
channels[index][2].keyLine = data.bit(6);
channels[index][3].keyLine = data.bit(7);

for(u32 n : range(4)) channels[index][n].updateKeyState();
break;
}

Expand Down
2 changes: 1 addition & 1 deletion ares/component/audio/ym2612/ym2612.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct YM2612 {
Operator(Channel& channel) : channel(channel), ym2612(channel.ym2612) {}

//channel.cpp
auto updateKeyState(bool) -> void;
auto updateKeyState() -> void;

auto runEnvelope() -> void;
auto runPhase() -> void;
Expand Down

0 comments on commit 785edf6

Please sign in to comment.