Remove redundant writes to support reverse stereo. Define FOREVER_FORWARD_STEREO.

This commit is contained in:
Nebuleon Fumika 2013-01-12 01:09:59 -05:00
parent e3bb4a5f62
commit 40d30e35ca
6 changed files with 49 additions and 5 deletions

View File

@ -69,7 +69,8 @@ CFLAGS := -mips32 -mno-abicalls -fno-pic -fno-builtin \
DEFS := -DSPC700_C -DEXECUTE_SUPERFX_PER_LINE -DSDD1_DECOMP \
-DVAR_CYCLES -DCPU_SHUTDOWN -DSPC700_SHUTDOWN \
-DNO_INLINE_SET_GET -DNOASM -DHAVE_MKSTEMP '-DACCEPT_SIZE_T=size_t' \
-DUNZIP_SUPPORT -DFOREVER_16_BIT_SOUND -DFOREVER_STEREO
-DUNZIP_SUPPORT -DFOREVER_16_BIT_SOUND -DFOREVER_STEREO \
-DFOREVER_FORWARD_STEREO
# -DSYNC_JOYPAD_AT_HBLANK
.PHONY: clean makedirs

View File

@ -386,10 +386,17 @@ static int ReadOrigSnapshot (STREAM snap)
sizeof (SOrigSoundData), snap)) != SUCCESS)
return (result);
#ifndef FOREVER_FORWARD_STEREO
SoundData.master_volume_left = OrigSoundData.master_volume_left;
SoundData.master_volume_right = OrigSoundData.master_volume_right;
SoundData.echo_volume_left = OrigSoundData.echo_volume_left;
SoundData.echo_volume_right = OrigSoundData.echo_volume_right;
#else
SoundData.master_volume [0] = OrigSoundData.master_volume_left;
SoundData.master_volume [1] = OrigSoundData.master_volume_right;
SoundData.echo_volume [0] = OrigSoundData.echo_volume_left;
SoundData.echo_volume [1] = OrigSoundData.echo_volume_right;
#endif
SoundData.echo_enable = OrigSoundData.echo_enable;
SoundData.echo_feedback = OrigSoundData.echo_feedback;
SoundData.echo_ptr = OrigSoundData.echo_ptr;

View File

@ -377,10 +377,17 @@ static FreezeData SnapAPURegisters [] = {
#define OFFSET(f) Offset(f,SSoundData *)
static FreezeData SnapSoundData [] = {
#ifndef FOREVER_FORWARD_STEREO
{OFFSET (master_volume_left), 2, INT_V},
{OFFSET (master_volume_right), 2, INT_V},
{OFFSET (echo_volume_left), 2, INT_V},
{OFFSET (echo_volume_right), 2, INT_V},
#else
{OFFSET (master_volume [0]), 2, INT_V},
{OFFSET (master_volume [1]), 2, INT_V},
{OFFSET (echo_volume [0]), 2, INT_V},
{OFFSET (echo_volume [1]), 2, INT_V},
#endif
{OFFSET (echo_enable), 4, INT_V},
{OFFSET (echo_feedback), 4, INT_V},
{OFFSET (echo_ptr), 4, INT_V},

View File

@ -331,7 +331,9 @@ struct SSettings{
#ifndef FOREVER_STEREO
bool8 Stereo;
#endif
#ifndef FOREVER_FORWARD_STEREO
bool8 ReverseStereo;
#endif
#ifndef FOREVER_16_BIT_SOUND
bool8 SixteenBitSound;
#endif

View File

@ -261,8 +261,10 @@ void S9xSetMasterVolume (short volume_left, short volume_right)
{
if (Settings.DisableMasterVolume || SNESGameFixes.EchoOnlyOutput)
{
#ifndef FOREVER_FORWARD_STEREO
SoundData.master_volume_left = 127;
SoundData.master_volume_right = 127;
#endif
SoundData.master_volume [0] = SoundData.master_volume [1] = 127;
}
else
@ -271,10 +273,15 @@ void S9xSetMasterVolume (short volume_left, short volume_right)
if (!so.stereo)
volume_left = (ABS (volume_right) + ABS (volume_left)) / 2;
#endif
#ifndef FOREVER_FORWARD_STEREO
SoundData.master_volume_left = volume_left;
SoundData.master_volume_right = volume_right;
SoundData.master_volume [Settings.ReverseStereo] = volume_left;
SoundData.master_volume [1 ^ Settings.ReverseStereo] = volume_right;
#else
SoundData.master_volume [0] = volume_left;
SoundData.master_volume [1] = volume_right;
#endif
}
}
@ -284,10 +291,15 @@ void S9xSetEchoVolume (short volume_left, short volume_right)
if (!so.stereo)
volume_left = (ABS (volume_right) + ABS (volume_left)) / 2;
#endif
#ifndef FOREVER_FORWARD_STEREO
SoundData.echo_volume_left = volume_left;
SoundData.echo_volume_right = volume_right;
SoundData.echo_volume [Settings.ReverseStereo] = volume_left;
SoundData.echo_volume [1 ^ Settings.ReverseStereo] = volume_right;
#else
SoundData.echo_volume [0] = volume_left;
SoundData.echo_volume [1] = volume_right;
#endif
}
void S9xSetEchoEnable (uint8 byte)
@ -378,10 +390,12 @@ void S9xFixSoundAfterSnapshotLoad ()
SoundData.channels [i].previous [0] = (int32) SoundData.channels [i].previous16 [0];
SoundData.channels [i].previous [1] = (int32) SoundData.channels [i].previous16 [1];
}
#ifndef FOREVER_FORWARD_STEREO
SoundData.master_volume [Settings.ReverseStereo] = SoundData.master_volume_left;
SoundData.master_volume [1 ^ Settings.ReverseStereo] = SoundData.master_volume_right;
SoundData.echo_volume [Settings.ReverseStereo] = SoundData.echo_volume_left;
SoundData.echo_volume [1 ^ Settings.ReverseStereo] = SoundData.echo_volume_right;
#endif
IAPU.Scanline = 0;
}
@ -1157,12 +1171,19 @@ void MixStereo (int sample_count)
}
if (pitch_mod & (1 << (J + 1)))
wave [I / 2] = ch->sample * ch->envx;
wave [I / 2] = ch->sample * ch->envx;
#ifndef FOREVER_FORWARD_STEREO
MixBuffer [I ^ Settings.ReverseStereo] += VL;
MixBuffer [I + (1 ^ Settings.ReverseStereo)] += VR;
ch->echo_buf_ptr [I ^ Settings.ReverseStereo] += VL;
ch->echo_buf_ptr [I + (1 ^ Settings.ReverseStereo)] += VR;
#else
MixBuffer [I ] += VL;
MixBuffer [I + 1] += VR;
ch->echo_buf_ptr [I ] += VL;
ch->echo_buf_ptr [I + 1] += VR;
#endif
}
stereo_exit: ;
}
@ -1840,10 +1861,12 @@ void S9xResetSound (bool8 full)
if (full)
{
#ifndef FOREVER_FORWARD_STEREO
SoundData.master_volume_left = 0;
SoundData.master_volume_right = 0;
SoundData.echo_volume_left = 0;
SoundData.echo_volume_right = 0;
#endif
SoundData.echo_enable = 0;
SoundData.echo_write_enabled = 0;
SoundData.echo_channel_enable = 0;
@ -1857,9 +1880,11 @@ void S9xResetSound (bool8 full)
SoundData.echo_volume[1] = 0;
SoundData.noise_hertz = 0;
}
#ifndef FOREVER_FORWARD_STEREO
SoundData.master_volume_left = 127;
SoundData.master_volume_right = 127;
#endif
SoundData.master_volume [0] = SoundData.master_volume [1] = 127;
if (so.playback_rate)
so.err_rate = (uint32) (FIXED_POINT * SNES_SCANLINE_TIME / (1.0 / so.playback_rate));

View File

@ -188,10 +188,12 @@ typedef struct {
typedef struct
{
#ifndef FOREVER_FORWARD_STEREO
short master_volume_left; /* range is -128 .. 127 */
short master_volume_right; /* range is -128 .. 127 */
short echo_volume_left; /* range is -128 .. 127 */
short echo_volume_right; /* range is -128 .. 127 */
#endif
int echo_enable;
int echo_feedback; /* range is -128 .. 127 */
int echo_ptr;
@ -203,8 +205,8 @@ typedef struct
uint32 dummy [3];
Channel channels [NUM_CHANNELS];
bool8 no_filter;
int master_volume [2]; /* for reverse stereo */
int echo_volume [2]; /* for reverse stereo */
int master_volume [2]; /* range is -128 .. 127 */
int echo_volume [2]; /* range is -128 .. 127 */
int noise_hertz;
} SSoundData;