diff options
author | João Silva | 2017-08-13 03:54:24 +0100 |
---|---|---|
committer | João Silva | 2017-08-13 03:54:24 +0100 |
commit | e18e3e55bbe96eb2e415ef0ba0ea743460ec0b7b (patch) | |
tree | 57a6be092ef3d39b714de8aab96ac5a05c8676e8 | |
parent | 62be8bed4dc3dc7793f1df1391f153436e4ea949 (diff) | |
download | snes9x2005-e18e3e55bbe96eb2e415ef0ba0ea743460ec0b7b.tar.gz snes9x2005-e18e3e55bbe96eb2e415ef0ba0ea743460ec0b7b.tar.bz2 snes9x2005-e18e3e55bbe96eb2e415ef0ba0ea743460ec0b7b.zip |
Sound fixes (including a savestate loading crash fix on 64-bit).
-rw-r--r-- | libretro.c | 2 | ||||
-rw-r--r-- | source/apu.c | 14 | ||||
-rw-r--r-- | source/soundux.c | 21 | ||||
-rw-r--r-- | source/spc700.c | 4 | ||||
-rw-r--r-- | source/spc700.h | 4 |
5 files changed, 17 insertions, 28 deletions
@@ -662,7 +662,7 @@ bool retro_unserialize(const void* data, size_t size) S9xReset(); #ifndef USE_BLARGG_APU uint8_t* IAPU_RAM_current = IAPU.RAM; - uint32_t IAPU_RAM_offset; + uintptr_t IAPU_RAM_offset; #endif memcpy(&CPU, buffer, sizeof(CPU)); buffer += sizeof(CPU); diff --git a/source/apu.c b/source/apu.c index 9d18242..28214e1 100644 --- a/source/apu.c +++ b/source/apu.c @@ -61,8 +61,8 @@ void S9xResetAPU() APU.Cycles = 0; IAPU.Registers.YA.W = 0; IAPU.Registers.X = 0; - IAPU.Registers.S = 0xff; - IAPU.Registers.P = 0; + IAPU.Registers.S = 0xef; + IAPU.Registers.P = 0x02; S9xAPUUnpackStatus(); IAPU.Registers.PC = 0; IAPU.APUExecuting = Settings.APUEnabled; @@ -211,7 +211,8 @@ void S9xSetAPUDSP(uint8_t byte) APU.DSP [APU_ENDX] &= ~mask; S9xPlaySample(c); } - else KeyOn |= mask; + else + KeyOn |= mask; } } } @@ -244,7 +245,7 @@ void S9xSetAPUDSP(uint8_t byte) case APU_P_LOW + 0x50: case APU_P_LOW + 0x60: case APU_P_LOW + 0x70: - S9xSetSoundHertz(reg >> 4, (((int16_t) byte + ((int16_t) APU.DSP [reg + 1] << 8)) & FREQUENCY_MASK) / 8); + S9xSetSoundHertz(reg >> 4, ((((int16_t) byte + ((int16_t) APU.DSP [reg + 1] << 8)) & FREQUENCY_MASK) * 32000) >> 12); break; case APU_P_HIGH + 0x00: case APU_P_HIGH + 0x10: @@ -442,7 +443,10 @@ uint8_t S9xGetAPUDSP() case APU_ENVX + 0x50: case APU_ENVX + 0x60: case APU_ENVX + 0x70: - return 0; + { + int32_t eVal = SoundData.channels [reg >> 4].envx; + return (eVal > 0x7F) ? 0x7F : (eVal < 0 ? 0 : eVal); + } default: break; } diff --git a/source/soundux.c b/source/soundux.c index 86db199..3f1a1fa 100644 --- a/source/soundux.c +++ b/source/soundux.c @@ -81,8 +81,6 @@ uint32_t KeyOffERate [10]; #define VOL_DIV16 0x0080 #define ENVX_SHIFT 24 -void DecodeBlockAsm(int8_t*, int16_t*, int32_t*, int32_t*); - // F is channel's current frequency and M is the 16-bit modulation waveform // from the previous channel multiplied by the current envelope volume level. #define PITCH_MOD(F,M) ((F) * ((((uint32_t) (M)) + 0x800000) >> 16) >> 7) @@ -211,7 +209,8 @@ void S9xSetEchoFeedback(int32_t feedback) void S9xSetEchoDelay(int32_t delay) { - SoundData.echo_buffer_size = (delay * so.playback_rate) >> 5; + SoundData.echo_buffer_size = (512 * delay * so.playback_rate) / 32000; + SoundData.echo_buffer_size <<= 1; if (SoundData.echo_buffer_size) SoundData.echo_ptr %= SoundData.echo_buffer_size; else @@ -323,20 +322,6 @@ void S9xSetEnvelopeHeight(int32_t channel, int32_t level) S9xAPUSetEndOfSample(channel, ch); } -int32_t S9xGetEnvelopeHeight(int32_t channel) -{ - if ((Settings.SoundEnvelopeHeightReading || - SNESGameFixes.SoundEnvelopeHeightReading2) && - SoundData.channels[channel].state != SOUND_SILENT && - SoundData.channels[channel].state != SOUND_GAIN) - return SoundData.channels[channel].envx; - - if (SNESGameFixes.SoundEnvelopeHeightReading2 && SoundData.channels[channel].state != SOUND_SILENT) - return SoundData.channels[channel].envx; - - return 0; -} - void S9xSetSoundFrequency(int32_t channel, int32_t hertz) // hertz [0~64K<<1] { if (SoundData.channels[channel].type == SOUND_NOISE) @@ -362,7 +347,7 @@ void DecodeBlock(Channel* ch) uint8_t shift; int8_t sample1, sample2; - if (ch->block_pointer >= 0x10000 - 9) + if (ch->block_pointer > 0x10000 - 9) { ch->last_block = true; ch->loop = false; diff --git a/source/spc700.c b/source/spc700.c index 53bbb1b..6737e30 100644 --- a/source/spc700.c +++ b/source/spc700.c @@ -28,9 +28,9 @@ uint32_t Work32 = 0; if (IAPU.WaitCounter == 0) \ { \ if (!ICPU.CPUExecuting) \ - APU.Cycles = CPU.Cycles = CPU.NextEvent; \ + APU.Cycles = CPU.Cycles = CPU.NextEvent; \ else \ - IAPU.APUExecuting = false; \ + IAPU.APUExecuting = false; \ } \ else if (IAPU.WaitCounter >= 2) \ IAPU.WaitCounter = 1; \ diff --git a/source/spc700.h b/source/spc700.h index 53bc1b6..8d8740d 100644 --- a/source/spc700.h +++ b/source/spc700.h @@ -71,8 +71,8 @@ typedef struct #define APU_EXECUTE() \ if (IAPU.APUExecuting) \ {\ - while (APU.Cycles <= CPU.Cycles) \ - APU_EXECUTE1(); \ + while (APU.Cycles <= CPU.Cycles) \ + APU_EXECUTE1(); \ } #endif |