all repos — mgba @ df619d4b56a2a3b83f718ae0a7b4440e913d9df0

mGBA Game Boy Advance Emulator

GB Audio: Fix channel 1 shadow register
Jeffrey Pfau jeffrey@endrift.com
Tue, 16 Feb 2016 00:23:45 -0800
commit

df619d4b56a2a3b83f718ae0a7b4440e913d9df0

parent

0a6b66248b516dff0a0451b24d5676707260ad1c

1 files changed, 7 insertions(+), 7 deletions(-)

jump to
M src/gb/audio.csrc/gb/audio.c

@@ -118,13 +118,13 @@ }

} void GBAudioWriteNR13(struct GBAudio* audio, uint8_t value) { - audio->ch1.realFrequency &= 0x700; - audio->ch1.realFrequency |= GBAudioRegisterControlGetFrequency(value); + audio->ch1.control.frequency &= 0x700; + audio->ch1.control.frequency |= GBAudioRegisterControlGetFrequency(value); } void GBAudioWriteNR14(struct GBAudio* audio, uint8_t value) { - audio->ch1.realFrequency &= 0xFF; - audio->ch1.realFrequency |= GBAudioRegisterControlGetFrequency(value << 8); + audio->ch1.control.frequency &= 0xFF; + audio->ch1.control.frequency |= GBAudioRegisterControlGetFrequency(value << 8); bool wasStop = audio->ch1.control.stop; audio->ch1.control.stop = GBAudioRegisterControlGetStop(value << 8); if (!wasStop && audio->ch1.control.stop && audio->ch1.control.length && !(audio->frame & 1)) {

@@ -145,7 +145,7 @@ audio->ch1.envelope.currentVolume = audio->ch1.envelope.initialVolume;

if (audio->ch1.envelope.currentVolume > 0 && audio->ch1.envelope.stepTime) { audio->ch1.envelope.dead = 0; } - audio->ch1.control.frequency = audio->ch1.realFrequency; + audio->ch1.realFrequency = audio->ch1.control.frequency; audio->ch1.sweepStep = audio->ch1.time; audio->ch1.sweepEnable = (audio->ch1.sweepStep != 8) || audio->ch1.shift; audio->ch1.sweepOccurred = false;

@@ -753,7 +753,7 @@ }

static bool _updateSweep(struct GBAudioChannel1* ch, bool initial) { if (initial || ch->time != 8) { - int frequency = ch->control.frequency; + int frequency = ch->realFrequency; if (ch->direction) { frequency -= frequency >> ch->shift; if (!initial && frequency >= 0) {

@@ -765,10 +765,10 @@ frequency += frequency >> ch->shift;

if (frequency < 2048) { if (!initial && ch->shift) { ch->control.frequency = frequency; + ch->realFrequency = frequency; if (!_updateSweep(ch, true)) { return false; } - ch->realFrequency = frequency; } } else { return false;