all repos — mgba @ ffef3d2486458ea56160172356de22a37fafa19a

mGBA Game Boy Advance Emulator

Preemptively mark the envelope as dead in some cases
Jeffrey Pfau jeffrey@endrift.com
Sat, 26 Oct 2013 04:23:08 -0700
commit

ffef3d2486458ea56160172356de22a37fafa19a

parent

70365782de802bcf87f0a90c2a16967c349aaf53

1 files changed, 12 insertions(+), 3 deletions(-)

jump to
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -217,12 +217,15 @@ }

void GBAAudioWriteSOUND1CNT_HI(struct GBAAudio* audio, uint16_t value) { audio->ch1.envelope.packed = value; + audio->ch1.envelope.dead = 0; if (audio->ch1.envelope.stepTime) { audio->ch1.envelope.nextStep = 0; } else { audio->ch1.envelope.nextStep = INT_MAX; + if (audio->ch1.envelope.initialVolume == 0) { + audio->ch1.envelope.dead = 1; + } } - audio->ch1.envelope.dead = 0; } void GBAAudioWriteSOUND1CNT_X(struct GBAAudio* audio, uint16_t value) {

@@ -254,12 +257,15 @@ }

void GBAAudioWriteSOUND2CNT_LO(struct GBAAudio* audio, uint16_t value) { audio->ch2.envelope.packed = value; + audio->ch2.envelope.dead = 0; if (audio->ch2.envelope.stepTime) { audio->ch2.envelope.nextStep = 0; } else { audio->ch2.envelope.nextStep = INT_MAX; + if (audio->ch2.envelope.initialVolume == 0) { + audio->ch2.envelope.dead = 1; + } } - audio->ch2.envelope.dead = 0; } void GBAAudioWriteSOUND2CNT_HI(struct GBAAudio* audio, uint16_t value) {

@@ -295,12 +301,15 @@ }

void GBAAudioWriteSOUND4CNT_LO(struct GBAAudio* audio, uint16_t value) { audio->ch4.envelope.packed = value; + audio->ch4.envelope.dead = 0; if (audio->ch4.envelope.stepTime) { audio->ch4.envelope.nextStep = 0; } else { audio->ch4.envelope.nextStep = INT_MAX; + if (audio->ch4.envelope.initialVolume == 0) { + audio->ch4.envelope.dead = 1; + } } - audio->ch4.envelope.dead = 0; } void GBAAudioWriteSOUND4CNT_HI(struct GBAAudio* audio, uint16_t value) {