When closing or rebooting a ROM, reset emulation settings that were set by a movie.

This commit is contained in:
SuuperW 2018-09-01 12:05:21 -05:00
parent 4a844b2394
commit 80047bff91
3 changed files with 37 additions and 4 deletions

View File

@ -781,6 +781,7 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
cheats->init(buf);
}
//UnloadMovieEmulationSettings(); called in NDS_Reset()
NDS_Reset();
return ret;
@ -790,6 +791,7 @@ void NDS_FreeROM(void)
{
FCEUI_StopMovie();
gameInfo.closeROM();
UnloadMovieEmulationSettings();
}
void NDS_Sleep() { nds.sleeping = TRUE; }
@ -2567,6 +2569,8 @@ bool NDS_FakeBoot()
bool _HACK_DONT_STOPMOVIE = false;
void NDS_Reset()
{
UnloadMovieEmulationSettings();
//reload last paths if needed
if(!gameInfo.reader)
{

View File

@ -66,6 +66,10 @@ bool movie_readonly = true;
char curMovieFilename[512] = {0};
MovieData currMovieData;
MovieData oldSettings = NULL;
// Loading a movie calls NDS_Reset, which calls UnloadMovieEmulationSettings. Don't unload settings on that call.
bool firstReset = false;
int currRerecordCount;
bool movie_reset_command = false;
//--------------
@ -195,7 +199,7 @@ DateTime FCEUI_MovieGetRTCDefault()
return DateTime(2009,1,1,0,0,0);
}
MovieData::MovieData()
MovieData::MovieData(bool fromCurrentSettings)
: version(MOVIE_VERSION)
, emuVersion(EMU_DESMUME_VERSION_NUMERIC())
, romChecksum(0)
@ -203,6 +207,28 @@ MovieData::MovieData()
, binaryFlag(false)
, rtcStart(FCEUI_MovieGetRTCDefault())
{
if (fromCurrentSettings)
{
useExtBios = CommonSettings.UseExtBIOS;
if (useExtFirmware != -1)
useExtFirmware = CommonSettings.UseExtFirmware;
if (!CommonSettings.UseExtFirmware)
{
firmNickname.resize(CommonSettings.fw_config.nickname_len);
for (int i = 0; i < CommonSettings.fw_config.nickname_len; i++)
firmNickname[i] = CommonSettings.fw_config.nickname[i];
firmMessage.resize(CommonSettings.fw_config.message_len);
for (int i = 0; i < CommonSettings.fw_config.message_len; i++)
firmMessage[i] = CommonSettings.fw_config.message[i];
firmFavColour = CommonSettings.fw_config.fav_colour;
firmBirthMonth = CommonSettings.fw_config.birth_month;
firmBirthDay = CommonSettings.fw_config.birth_day;
firmLanguage = CommonSettings.fw_config.language;
}
advancedTiming = CommonSettings.advanced_timing;
jitBlockSize = CommonSettings.use_jit ? CommonSettings.jit_max_block_size : 0;
}
}
void MovieData::truncateAt(int frame)
@ -529,7 +555,7 @@ static void LoadSettingsFromMovie(MovieData movieData)
}
void UnloadMovieEmulationSettings()
{
if (&oldSettings)
if (&oldSettings && !firstReset)
{
LoadSettingsFromMovie(oldSettings);
oldSettings = NULL;
@ -596,9 +622,12 @@ const char* _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tas
//poweron(true);
// set emulation/firmware settings
oldSettings = MovieData(true);
LoadSettingsFromMovie(currMovieData);
firstReset = true;
NDS_Reset();
firstReset = false;
////WE NEED TO LOAD A SAVESTATE
//if(currMovieData.savestate.size() != 0)

View File

@ -132,8 +132,7 @@ private:
class MovieData
{
public:
MovieData();
MovieData(bool fromCurrentSettings = false);
int version;
int emuVersion;
@ -273,6 +272,7 @@ extern bool movie_reset_command;
bool FCEUI_MovieGetInfo(EMUFILE &fp, MOVIE_INFO &info, bool skipFrameCount);
void FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname, const DateTime &rtcstart);
const char* _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe); // returns NULL on success, errmsg on failure
void UnloadMovieEmulationSettings();
void FCEUI_StopMovie();
void FCEUMOV_AddInputState();
void FCEUMOV_HandlePlayback();