GB Audio: Channel 3 cleanup
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Feb 2016 00:55:23 -0800
1 files changed,
10 insertions(+),
11 deletions(-)
jump to
M
src/gb/audio.c
→
src/gb/audio.c
@@ -231,8 +231,7 @@ }
} void GBAudioWriteNR31(struct GBAudio* audio, uint8_t value) { - audio->ch3.length = value; - audio->ch3.lengthShadow = 256 - value; + audio->ch3.length = 256 - value; } void GBAudioWriteNR32(struct GBAudio* audio, uint8_t value) {@@ -249,18 +248,18 @@ audio->ch3.rate &= 0xFF;
audio->ch3.rate |= GBAudioRegisterControlGetRate(value << 8); bool wasStop = audio->ch3.stop; audio->ch3.stop = GBAudioRegisterControlGetStop(value << 8); - if (!wasStop && audio->ch3.stop && audio->ch3.lengthShadow && !(audio->frame & 1)) { - --audio->ch3.lengthShadow; - if (audio->ch3.lengthShadow == 0) { + if (!wasStop && audio->ch3.stop && audio->ch3.length && !(audio->frame & 1)) { + --audio->ch3.length; + if (audio->ch3.length == 0) { audio->playingCh3 = false; } } if (GBAudioRegisterControlIsRestart(value << 8)) { audio->playingCh3 = audio->ch3.enable; - if (!audio->ch3.lengthShadow) { - audio->ch3.lengthShadow = 256; + if (!audio->ch3.length) { + audio->ch3.length = 256; if (audio->ch3.stop && !(audio->frame & 1)) { - --audio->ch3.lengthShadow; + --audio->ch3.length; } } }@@ -504,9 +503,9 @@ audio->nextEvent = audio->nextCh3;
} } - if (audio->ch3.lengthShadow && audio->ch3.stop && !(frame & 1)) { - --audio->ch3.lengthShadow; - if (audio->ch3.lengthShadow == 0) { + if (audio->ch3.length && audio->ch3.stop && !(frame & 1)) { + --audio->ch3.length; + if (audio->ch3.length == 0) { audio->playingCh3 = 0; } }