all repos — mgba @ d7d48e605bab8dc210d6dc5fb06c26e76dd51460

mGBA Game Boy Advance Emulator

GB Audio: Fix serialization of channel 3 and NR52 properties
Jeffrey Pfau jeffrey@endrift.com
Mon, 19 Dec 2016 18:30:35 -0800
commit

d7d48e605bab8dc210d6dc5fb06c26e76dd51460

parent

bf2aa98338a163457ddbe1bea0c2e7476fd6535d

3 files changed, 17 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -36,6 +36,7 @@ - ARM7: PSR mode bits should not get sign extended

- GBA: Only unhalt CPU if appropriate bit is set in IE - GBA Video: Fix out of bounds sprite transforms - GB: Fix crash when masking savedata + - GB Audio: Fix serialization of channel 3 and NR52 properties Misc: - SDL: Remove scancode key input - GBA Video: Clean up unused timers
M src/gb/audio.csrc/gb/audio.c

@@ -893,6 +893,7 @@

memcpy(state->ch3.wavebanks, audio->ch3.wavedata32, sizeof(state->ch3.wavebanks)); STORE_16LE(audio->ch3.length, 0, &state->ch3.length); STORE_32LE(audio->nextCh3, 0, &state->ch3.nextEvent); + STORE_32LE(audio->fadeCh3, 0, &state->ch1.nextCh3Fade); flags = GBSerializedAudioFlagsSetCh4Volume(flags, audio->ch4.envelope.currentVolume); flags = GBSerializedAudioFlagsSetCh4Dead(flags, audio->ch4.envelope.dead);

@@ -911,6 +912,12 @@ uint32_t ch1Flags = 0;

uint32_t ch2Flags = 0; uint32_t ch4Flags = 0; + audio->playingCh1 = !!(*audio->nr52 & 0x0001); + audio->playingCh2 = !!(*audio->nr52 & 0x0002); + audio->playingCh3 = !!(*audio->nr52 & 0x0004); + audio->playingCh4 = !!(*audio->nr52 & 0x0008); + audio->enable = GBAudioEnableGetEnable(*audio->nr52); + LOAD_32LE(flags, 0, flagsIn); LOAD_32LE(ch1Flags, 0, &state->ch1.envelope); audio->ch1.envelope.currentVolume = GBSerializedAudioFlagsGetCh1Volume(flags);

@@ -932,10 +939,12 @@ audio->ch2.control.length = GBSerializedAudioEnvelopeGetLength(ch2Flags);

audio->ch2.envelope.nextStep = GBSerializedAudioEnvelopeGetNextStep(ch2Flags); LOAD_32LE(audio->nextCh2, 0, &state->ch2.nextEvent); + audio->ch3.readable = GBSerializedAudioFlagsGetCh3Readable(flags); // TODO: Big endian? memcpy(audio->ch3.wavedata32, state->ch3.wavebanks, sizeof(audio->ch3.wavedata32)); LOAD_16LE(audio->ch3.length, 0, &state->ch3.length); LOAD_32LE(audio->nextCh3, 0, &state->ch3.nextEvent); + LOAD_32LE(audio->fadeCh3, 0, &state->ch1.nextCh3Fade); LOAD_32LE(ch4Flags, 0, &state->ch4.envelope); audio->ch4.envelope.currentVolume = GBSerializedAudioFlagsGetCh4Volume(flags);
M src/gb/serialize.hsrc/gb/serialize.h

@@ -54,7 +54,8 @@ * | bits 7 - 9: Next step

* | bits 10 - 20: Shadow frequency register * | bits 21 - 31: Reserved * | 0x0004C - 0x0004F: Next frame - * | 0x00050 - 0x00057: Reserved + * | 0x00050 - 0x00053: Next channel 3 fade + * | 0x00054 - 0x00057: Reserved * | 0x00058 - 0x0005B: Next event * 0x0005C - 0x0006B: Audio channel 2 state * | 0x0005C - 0x0005F: Envelepe timing

@@ -96,7 +97,8 @@ * | 0x000A7: Miscellaneous audio flags

* | bits 0 - 3: Current frame * | bit 4: Is channel 1 sweep enabled? * | bit 5: Has channel 1 sweep occurred? - * | bits 6 - 7: Reserved + * | bit 6: Is channel 3's memory readable? + * | bit 7: Reserved * | 0x000A8 - 0x000AB: Next event * | 0x000AC - 0x000AF: Event diff * | 0x000B0 - 0x000B3: Next sample

@@ -172,6 +174,7 @@ DECL_BITS(GBSerializedAudioFlags, Ch4Dead, 20, 2);

DECL_BITS(GBSerializedAudioFlags, Frame, 22, 3); DECL_BIT(GBSerializedAudioFlags, Ch1SweepEnabled, 25); DECL_BIT(GBSerializedAudioFlags, Ch1SweepOccurred, 26); +DECL_BIT(GBSerializedAudioFlags, Ch3Readable, 27); DECL_BITFIELD(GBSerializedAudioEnvelope, uint32_t); DECL_BITS(GBSerializedAudioEnvelope, Length, 0, 7);

@@ -182,7 +185,8 @@ struct GBSerializedPSGState {

struct { GBSerializedAudioEnvelope envelope; int32_t nextFrame; - int32_t reserved[2]; + int32_t nextCh3Fade; + int32_t reserved; int32_t nextEvent; } ch1; struct {