mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-26 07:35:40 +00:00
Refactor code from previous svn768 (Note : break old savestate compatibility)
This commit is contained in:
parent
90faeafbc4
commit
bb89bc8e54
|
@ -778,6 +778,7 @@ void CDSB2::WriteMPEGFIFO(UINT8 byte)
|
||||||
// default to full stereo
|
// default to full stereo
|
||||||
//mixer_set_stereo_volume(0, 255, 255);
|
//mixer_set_stereo_volume(0, 255, 255);
|
||||||
//mixer_set_stereo_pan(0, MIXER_PAN_RIGHT, MIXER_PAN_LEFT);
|
//mixer_set_stereo_pan(0, MIXER_PAN_RIGHT, MIXER_PAN_LEFT);
|
||||||
|
stereo = StereoMode::Stereo;
|
||||||
mpegState = ST_IDLE;
|
mpegState = ST_IDLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -786,14 +787,7 @@ void CDSB2::WriteMPEGFIFO(UINT8 byte)
|
||||||
//mixer_set_stereo_volume(0, 0, 255);
|
//mixer_set_stereo_volume(0, 0, 255);
|
||||||
//printf("ch 0 mono\n");
|
//printf("ch 0 mono\n");
|
||||||
//mixer_set_stereo_pan(0, MIXER_PAN_CENTER, MIXER_PAN_CENTER);
|
//mixer_set_stereo_pan(0, MIXER_PAN_CENTER, MIXER_PAN_CENTER);
|
||||||
|
stereo = (byte != 0x00) ? StereoMode::MonoRight : StereoMode::Stereo;
|
||||||
if (byte == 0) {
|
|
||||||
audioChannel = AudioChannel::stereo;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
audioChannel = AudioChannel::channel0;
|
|
||||||
}
|
|
||||||
|
|
||||||
mpegState = ST_IDLE;
|
mpegState = ST_IDLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -818,12 +812,7 @@ void CDSB2::WriteMPEGFIFO(UINT8 byte)
|
||||||
//printf("ch 1 mono\n");
|
//printf("ch 1 mono\n");
|
||||||
//mixer_set_stereo_volume(0, 255, 0);
|
//mixer_set_stereo_volume(0, 255, 0);
|
||||||
//mixer_set_stereo_pan(0, MIXER_PAN_CENTER, MIXER_PAN_CENTER);
|
//mixer_set_stereo_pan(0, MIXER_PAN_CENTER, MIXER_PAN_CENTER);
|
||||||
if (byte == 0) {
|
stereo = (byte != 0x00) ? StereoMode::MonoLeft : StereoMode::Stereo;
|
||||||
audioChannel = AudioChannel::stereo;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
audioChannel = AudioChannel::channel1;
|
|
||||||
}
|
|
||||||
mpegState = ST_IDLE;
|
mpegState = ST_IDLE;
|
||||||
break;
|
break;
|
||||||
case ST_GOTB4:
|
case ST_GOTB4:
|
||||||
|
@ -1046,23 +1035,26 @@ void CDSB2::RunFrame(INT16 *audioL, INT16 *audioR)
|
||||||
// Decode MPEG for this frame
|
// Decode MPEG for this frame
|
||||||
INT16 *mpegFill[2] = { &mpegL[retainedSamples], &mpegR[retainedSamples] };
|
INT16 *mpegFill[2] = { &mpegL[retainedSamples], &mpegR[retainedSamples] };
|
||||||
MPEG_Decode(mpegFill, 32000/60-retainedSamples+2);
|
MPEG_Decode(mpegFill, 32000/60-retainedSamples+2);
|
||||||
//retainedSamples = Resampler.UpSampleAndMix(audioL, audioR, mpegL, mpegR, volume[0], volume[1], 44100/60, 32000/60+2, 44100, 32000);
|
|
||||||
switch (audioChannel)
|
INT16 *leftChannelSource = nullptr;
|
||||||
|
INT16 *rightChannelSource = nullptr;
|
||||||
|
switch (stereo)
|
||||||
{
|
{
|
||||||
case AudioChannel::stereo:
|
|
||||||
retainedSamples = Resampler.UpSampleAndMix(audioL, audioR, mpegL, mpegR, volume[0], volume[1], 44100 / 60, 32000 / 60 + 2, 44100, 32000);
|
|
||||||
break;
|
|
||||||
case AudioChannel::channel0:
|
|
||||||
retainedSamples = Resampler.UpSampleAndMix(audioL, audioR, mpegR, mpegR, volume[0], volume[0], 44100 / 60, 32000 / 60 + 2, 44100, 32000);
|
|
||||||
break;
|
|
||||||
case AudioChannel::channel1:
|
|
||||||
retainedSamples = Resampler.UpSampleAndMix(audioL, audioR, mpegL, mpegL, volume[1], volume[1], 44100 / 60, 32000 / 60 + 2, 44100, 32000);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
//retainedSamples = Resampler.UpSampleAndMix(audioL, audioR, mpegL, mpegR, volume[0], volume[1], 44100 / 60, 32000 / 60 + 2, 44100, 32000);
|
case StereoMode::Stereo:
|
||||||
|
leftChannelSource = mpegL;
|
||||||
|
rightChannelSource = mpegR;
|
||||||
|
break;
|
||||||
|
case StereoMode::MonoLeft:
|
||||||
|
leftChannelSource = mpegL;
|
||||||
|
rightChannelSource = mpegL;
|
||||||
|
break;
|
||||||
|
case StereoMode::MonoRight:
|
||||||
|
leftChannelSource = mpegR;
|
||||||
|
rightChannelSource = mpegR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
retainedSamples = Resampler.UpSampleAndMix(audioL, audioR, leftChannelSource, rightChannelSource, volume[0], volume[1], 44100/60, 32000/60+2, 44100, 32000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDSB2::Reset(void)
|
void CDSB2::Reset(void)
|
||||||
|
@ -1080,6 +1072,7 @@ void CDSB2::Reset(void)
|
||||||
playing = 0;
|
playing = 0;
|
||||||
volume[0] = 0xFF; // set to max volume in case we miss the volume commands
|
volume[0] = 0xFF; // set to max volume in case we miss the volume commands
|
||||||
volume[1] = 0xFF;
|
volume[1] = 0xFF;
|
||||||
|
stereo = StereoMode::Stereo;
|
||||||
|
|
||||||
// Even if DSB emulation is disabled, must reset to establish valid Z80 state
|
// Even if DSB emulation is disabled, must reset to establish valid Z80 state
|
||||||
M68KSetContext(&M68K);
|
M68KSetContext(&M68K);
|
||||||
|
@ -1122,6 +1115,7 @@ void CDSB2::SaveState(CBlockFile *StateFile)
|
||||||
StateFile->Write(&mpegEnd, sizeof(mpegEnd));
|
StateFile->Write(&mpegEnd, sizeof(mpegEnd));
|
||||||
StateFile->Write(&playing, sizeof(playing));
|
StateFile->Write(&playing, sizeof(playing));
|
||||||
StateFile->Write(volume, sizeof(volume));
|
StateFile->Write(volume, sizeof(volume));
|
||||||
|
StateFile->Write(&stereo, sizeof(stereo));
|
||||||
|
|
||||||
// 68K CPU state
|
// 68K CPU state
|
||||||
M68KSetContext(&M68K);
|
M68KSetContext(&M68K);
|
||||||
|
@ -1163,6 +1157,7 @@ void CDSB2::LoadState(CBlockFile *StateFile)
|
||||||
StateFile->Read(&mpegEnd, sizeof(mpegEnd));
|
StateFile->Read(&mpegEnd, sizeof(mpegEnd));
|
||||||
StateFile->Read(&playing, sizeof(playing));
|
StateFile->Read(&playing, sizeof(playing));
|
||||||
StateFile->Read(volume, sizeof(volume));
|
StateFile->Read(volume, sizeof(volume));
|
||||||
|
StateFile->Read(&stereo, sizeof(stereo));
|
||||||
|
|
||||||
M68KSetContext(&M68K);
|
M68KSetContext(&M68K);
|
||||||
M68KLoadState(StateFile, "DSB2 68K");
|
M68KLoadState(StateFile, "DSB2 68K");
|
||||||
|
|
|
@ -283,6 +283,14 @@ private:
|
||||||
// MPEG decode buffers (48KHz, 1/60th second + 2 extra padding samples)
|
// MPEG decode buffers (48KHz, 1/60th second + 2 extra padding samples)
|
||||||
INT16 *mpegL, *mpegR;
|
INT16 *mpegL, *mpegR;
|
||||||
|
|
||||||
|
// Stereo mode (do not change values because they are used in save states!)
|
||||||
|
enum StereoMode: uint8_t
|
||||||
|
{
|
||||||
|
Stereo = 0, // both channels
|
||||||
|
MonoLeft = 1, // mono, using left stream as source data
|
||||||
|
MonoRight = 2 // mono, using right stream as source data
|
||||||
|
};
|
||||||
|
|
||||||
// DSB memory
|
// DSB memory
|
||||||
const UINT8 *progROM; // 68K program ROM (passed in from parent object)
|
const UINT8 *progROM; // 68K program ROM (passed in from parent object)
|
||||||
const UINT8 *mpegROM; // MPEG music ROM
|
const UINT8 *mpegROM; // MPEG music ROM
|
||||||
|
@ -299,6 +307,7 @@ private:
|
||||||
int mpegState;
|
int mpegState;
|
||||||
int mpegStart, mpegEnd, playing;
|
int mpegStart, mpegEnd, playing;
|
||||||
UINT8 volume[2]; // left, right volume (0x00-0xFF)
|
UINT8 volume[2]; // left, right volume (0x00-0xFF)
|
||||||
|
StereoMode stereo;
|
||||||
|
|
||||||
// Settings of currently playing stream (may not match the playback register variables above)
|
// Settings of currently playing stream (may not match the playback register variables above)
|
||||||
UINT32 usingLoopStart; // what was last set by MPEG_SetLoop() or MPEG_PlayMemory()
|
UINT32 usingLoopStart; // what was last set by MPEG_SetLoop() or MPEG_PlayMemory()
|
||||||
|
@ -308,9 +317,6 @@ private:
|
||||||
|
|
||||||
// M68K CPU
|
// M68K CPU
|
||||||
M68KCtx M68K;
|
M68KCtx M68K;
|
||||||
|
|
||||||
enum class AudioChannel { stereo, channel0, channel1 };
|
|
||||||
AudioChannel audioChannel = AudioChannel::stereo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,7 @@ static void TestPolygonHeaderBits(IEmulator *Emu)
|
||||||
Different subsystems output their own blocks.
|
Different subsystems output their own blocks.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
static const int STATE_FILE_VERSION = 2; // save state file version
|
static const int STATE_FILE_VERSION = 3; // save state file version
|
||||||
static const int NVRAM_FILE_VERSION = 0; // NVRAM file version
|
static const int NVRAM_FILE_VERSION = 0; // NVRAM file version
|
||||||
static unsigned s_saveSlot = 0; // save state slot #
|
static unsigned s_saveSlot = 0; // save state slot #
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue