[Android] Do not create system on show menu

This commit is contained in:
zilmar 2016-12-13 06:22:35 +11:00
parent f8e49dfbb8
commit 4cf5a54999
3 changed files with 42 additions and 32 deletions

View File

@ -313,8 +313,7 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_LoadGame(JNIEnv* env, jcla
{ {
const char *fileLoc = env->GetStringUTFChars(FileLoc, 0); const char *fileLoc = env->GetStringUTFChars(FileLoc, 0);
WriteTrace(TraceUserInterface, TraceDebug, "FileLoc: %s",fileLoc); WriteTrace(TraceUserInterface, TraceDebug, "FileLoc: %s",fileLoc);
g_Settings->SaveBool(Setting_AutoStart,false); CN64System::LoadFileImage(fileLoc);
CN64System::RunFileImage(fileLoc);
env->ReleaseStringUTFChars(FileLoc, fileLoc); env->ReleaseStringUTFChars(FileLoc, fileLoc);
WriteTrace(TraceUserInterface, TraceDebug, "Image loaded"); WriteTrace(TraceUserInterface, TraceDebug, "Image loaded");
} }
@ -323,7 +322,7 @@ EXPORT void CALL Java_emu_project64_jni_NativeExports_StartGame(JNIEnv* env, jcl
{ {
g_Activity = env->NewGlobalRef(activity); g_Activity = env->NewGlobalRef(activity);
g_GLThread = env->NewGlobalRef(GLThread); g_GLThread = env->NewGlobalRef(GLThread);
g_BaseSystem->StartEmulation(true); CN64System::RunLoadedImage();
} }
EXPORT void CALL Java_emu_project64_jni_NativeExports_RefreshRomDir(JNIEnv* env, jclass cls, jstring RomDir, jboolean Recursive) EXPORT void CALL Java_emu_project64_jni_NativeExports_RefreshRomDir(JNIEnv* env, jclass cls, jstring RomDir, jboolean Recursive)

View File

@ -241,9 +241,9 @@ void CN64System::ExternalEvent(SystemEvent action)
} }
} }
bool CN64System::RunFileImage(const char * FileLoc) bool CN64System::LoadFileImage(const char * FileLoc)
{ {
WriteTrace(TraceN64System, TraceDebug, "FileLoc: %s", FileLoc); WriteTrace(TraceN64System, TraceDebug, "Start (FileLoc: %s)", FileLoc);
CloseSystem(); CloseSystem();
g_Settings->SaveBool(Setting_EnableDisk, false); g_Settings->SaveBool(Setting_EnableDisk, false);
g_Settings->SaveDword(Game_CurrentSaveState, g_Settings->LoadDefaultDword(Game_CurrentSaveState)); g_Settings->SaveDword(Game_CurrentSaveState, g_Settings->LoadDefaultDword(Game_CurrentSaveState));
@ -282,6 +282,11 @@ bool CN64System::RunFileImage(const char * FileLoc)
g_DDRom->LoadN64ImageIPL(FileLoc); g_DDRom->LoadN64ImageIPL(FileLoc);
g_Settings->SaveString(File_DiskIPLPath, FileLoc); g_Settings->SaveString(File_DiskIPLPath, FileLoc);
} }
else if (g_DDRom != NULL)
{
delete g_DDRom;
g_DDRom = NULL;
}
if (g_DDRom != NULL) if (g_DDRom != NULL)
{ {
@ -294,33 +299,6 @@ bool CN64System::RunFileImage(const char * FileLoc)
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
WriteTrace(TraceN64System, TraceDebug, "Finished Loading (GoodName: %s)", g_Settings->LoadStringVal(Game_GoodName).c_str()); WriteTrace(TraceN64System, TraceDebug, "Finished Loading (GoodName: %s)", g_Settings->LoadStringVal(Game_GoodName).c_str());
g_BaseSystem = new CN64System(g_Plugins, false, false);
if (g_BaseSystem)
{
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
g_BaseSystem->StartEmulation(true);
}
else
{
bool bSetActive = true;
if (g_BaseSystem->m_SyncCPU != NULL)
{
bSetActive = g_BaseSystem->m_SyncCPU->SetActiveSystem(true);
}
if (bSetActive)
{
bSetActive = g_BaseSystem->SetActiveSystem(true);
}
}
}
else
{
WriteTrace(TraceN64System, TraceError, "Failed to create CN64System");
}
} }
else else
{ {
@ -329,11 +307,42 @@ bool CN64System::RunFileImage(const char * FileLoc)
delete g_Rom; delete g_Rom;
g_Rom = NULL; g_Rom = NULL;
g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Settings->SaveBool(GameRunning_LoadingInProgress, false);
WriteTrace(TraceN64System, TraceDebug, "Done (res: false)");
return false; return false;
} }
WriteTrace(TraceN64System, TraceDebug, "Done (res: true)");
return true; return true;
} }
bool CN64System::RunFileImage(const char * FileLoc)
{
if (!LoadFileImage(FileLoc))
{
return false;
}
if (g_Settings->LoadBool(Setting_AutoStart) != 0)
{
WriteTrace(TraceN64System, TraceDebug, "Automattically starting rom");
RunLoadedImage();
}
return true;
}
void CN64System::RunLoadedImage(void)
{
WriteTrace(TraceN64System, TraceDebug, "Start");
g_BaseSystem = new CN64System(g_Plugins, false, false);
if (g_BaseSystem)
{
g_BaseSystem->StartEmulation(true);
}
else
{
WriteTrace(TraceN64System, TraceError, "Failed to create CN64System");
}
WriteTrace(TraceN64System, TraceDebug, "Done");
}
bool CN64System::RunFileImageIPL(const char * FileLoc) bool CN64System::RunFileImageIPL(const char * FileLoc)
{ {
CloseSystem(); CloseSystem();

View File

@ -56,9 +56,11 @@ public:
SAVE_CHIP_TYPE m_SaveUsing; SAVE_CHIP_TYPE m_SaveUsing;
//Methods //Methods
static bool LoadFileImage(const char * FileLoc);
static bool RunFileImage(const char * FileLoc); static bool RunFileImage(const char * FileLoc);
static bool RunFileImageIPL(const char * FileLoc); static bool RunFileImageIPL(const char * FileLoc);
static bool RunDiskImage(const char * FileLoc); static bool RunDiskImage(const char * FileLoc);
static void RunLoadedImage(void);
static void CloseSystem(void); static void CloseSystem(void);
void CloseCpu(); void CloseCpu();