mirror of https://github.com/mgba-emu/mgba.git
GB Audio: Fix NRx2 writes while active (fixes #866)
This commit is contained in:
parent
0a221d038a
commit
3ae911b829
1
CHANGES
1
CHANGES
|
@ -35,6 +35,7 @@ Bugfixes:
|
|||
- GB Memory: Actually load latch time from savestate
|
||||
- GB Serialize: Fix game title check
|
||||
- GB, GBA: Fix sync to video with frameskip
|
||||
- GB Audio: Fix NRx2 writes while active (fixes mgba.io/i/866)
|
||||
Misc:
|
||||
- GBA Timer: Use global cycles for timers
|
||||
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
|
||||
|
|
|
@ -25,7 +25,7 @@ const int GB_AUDIO_VOLUME_MAX = 0x100;
|
|||
|
||||
static bool _writeSweep(struct GBAudioSweep* sweep, uint8_t value);
|
||||
static void _writeDuty(struct GBAudioEnvelope* envelope, uint8_t value);
|
||||
static bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value);
|
||||
static bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value, enum GBAudioStyle style);
|
||||
|
||||
static void _resetSweep(struct GBAudioSweep* sweep);
|
||||
static bool _resetEnvelope(struct GBAudioEnvelope* sweep);
|
||||
|
@ -182,7 +182,7 @@ void GBAudioWriteNR11(struct GBAudio* audio, uint8_t value) {
|
|||
}
|
||||
|
||||
void GBAudioWriteNR12(struct GBAudio* audio, uint8_t value) {
|
||||
if (!_writeEnvelope(&audio->ch1.envelope, value)) {
|
||||
if (!_writeEnvelope(&audio->ch1.envelope, value, audio->style)) {
|
||||
mTimingDeschedule(audio->timing, &audio->ch1Event);
|
||||
audio->playingCh1 = false;
|
||||
*audio->nr52 &= ~0x0001;
|
||||
|
@ -240,7 +240,7 @@ void GBAudioWriteNR21(struct GBAudio* audio, uint8_t value) {
|
|||
}
|
||||
|
||||
void GBAudioWriteNR22(struct GBAudio* audio, uint8_t value) {
|
||||
if (!_writeEnvelope(&audio->ch2.envelope, value)) {
|
||||
if (!_writeEnvelope(&audio->ch2.envelope, value, audio->style)) {
|
||||
mTimingDeschedule(audio->timing, &audio->ch2Event);
|
||||
audio->playingCh2 = false;
|
||||
*audio->nr52 &= ~0x0002;
|
||||
|
@ -358,7 +358,7 @@ void GBAudioWriteNR41(struct GBAudio* audio, uint8_t value) {
|
|||
}
|
||||
|
||||
void GBAudioWriteNR42(struct GBAudio* audio, uint8_t value) {
|
||||
if (!_writeEnvelope(&audio->ch4.envelope, value)) {
|
||||
if (!_writeEnvelope(&audio->ch4.envelope, value, audio->style)) {
|
||||
mTimingDeschedule(audio->timing, &audio->ch4Event);
|
||||
audio->playingCh4 = false;
|
||||
*audio->nr52 &= ~0x0008;
|
||||
|
@ -700,17 +700,16 @@ void _writeDuty(struct GBAudioEnvelope* envelope, uint8_t value) {
|
|||
envelope->duty = GBAudioRegisterDutyGetDuty(value);
|
||||
}
|
||||
|
||||
bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value) {
|
||||
bool _writeEnvelope(struct GBAudioEnvelope* envelope, uint8_t value, enum GBAudioStyle style) {
|
||||
envelope->stepTime = GBAudioRegisterSweepGetStepTime(value);
|
||||
envelope->direction = GBAudioRegisterSweepGetDirection(value);
|
||||
envelope->initialVolume = GBAudioRegisterSweepGetInitialVolume(value);
|
||||
if (!envelope->stepTime) {
|
||||
if (style == GB_AUDIO_DMG && !envelope->stepTime) {
|
||||
// TODO: Improve "zombie" mode
|
||||
++envelope->currentVolume;
|
||||
envelope->currentVolume &= 0xF;
|
||||
}
|
||||
_updateEnvelopeDead(envelope);
|
||||
envelope->nextStep = envelope->stepTime;
|
||||
return (envelope->initialVolume || envelope->direction) && envelope->dead != 2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue