|
|
@@ -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);
|
|
|
@@ -178,7 +178,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;
|
|
|
@@ -236,7 +236,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;
|
|
|
@@ -354,7 +354,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;
|
|
|
@@ -695,17 +695,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;
|
|
|
}
|
|
|
|
|
|
|
0 comments on commit
f5bf854