mirror of https://github.com/mgba-emu/mgba.git
GB Audio: Fix channel 1 shadow register
This commit is contained in:
parent
0a6b66248b
commit
df619d4b56
|
@ -118,13 +118,13 @@ void GBAudioWriteNR12(struct GBAudio* audio, uint8_t value) {
|
|||
}
|
||||
|
||||
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 @@ void GBAudioWriteNR14(struct GBAudio* audio, uint8_t value) {
|
|||
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 void _updateEnvelope(struct GBAudioEnvelope* envelope) {
|
|||
|
||||
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 @@ static bool _updateSweep(struct GBAudioChannel1* ch, bool initial) {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue