From 2861a21658fe2780b62f2c19a69373a51116e212 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Dec 2012 23:47:09 -0800 Subject: [PATCH 1/5] Fix a couple typos in headless. --- headless/Headless.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 7510f6527e..dabd2586e7 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -74,8 +74,8 @@ void printUsage(const char *progname, const char *reason) if (reason != NULL) fprintf(stderr, "Error: %s\n\n", reason); fprintf(stderr, "PPSSPP Headless\n"); - fprintf(stderr, "This is primarily meant for non-inactive test tool.\n\n"); - fprintf(stderr, "Usage: %s [options] file.elf\n\n", progname); + fprintf(stderr, "This is primarily meant as a non-interactive test tool.\n\n"); + fprintf(stderr, "Usage: %s file.elf [options]\n\n", progname); fprintf(stderr, "Options:\n"); fprintf(stderr, " -m, --mount umd.cso mount iso on umd:\n"); fprintf(stderr, " -l, --log full log output, not just emulated printfs\n"); From d745bddc236afc29d57e4779d51ad43600fedabf Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Dec 2012 09:21:23 -0800 Subject: [PATCH 2/5] Enable a few command line switches on Windows. --- Windows/WndMainWindow.cpp | 12 ++++++-- Windows/WndMainWindow.h | 3 ++ Windows/main.cpp | 64 +++++++++++++++++++++++++++++++-------- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 7e20d7c1cf..1309ebddb3 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -46,6 +46,7 @@ namespace MainWindow HWND hwndGameList; HMENU menu; BOOL skinMode = FALSE; + CoreState nextState = CORE_POWERDOWN; HINSTANCE hInst; @@ -244,7 +245,6 @@ namespace MainWindow switch (message) { case WM_CREATE: - PostMessage(hWnd, WM_COMMAND, ID_FILE_LOAD, 0); break; case WM_MOVE: @@ -467,7 +467,7 @@ namespace MainWindow memoryWindow[0]->Show(true); break; case ID_DEBUG_LOG: - LogManager::GetInstance()->GetConsoleListener()->Show(LogManager::GetInstance()->GetConsoleListener()->Hidden()); + LogManager::GetInstance()->GetConsoleListener()->Show(LogManager::GetInstance()->GetConsoleListener()->Hidden()); break; ////////////////////////////////////////////////////////////////////////// @@ -617,6 +617,9 @@ namespace MainWindow disasmWindow[0]->NotifyMapLoaded(); if (memoryWindow[0]) memoryWindow[0]->NotifyMapLoaded(); + + if (nextState == CORE_RUNNING) + PostMessage(hwndMain, WM_COMMAND, ID_EMULATION_RUN, 0); break; default: @@ -762,6 +765,11 @@ namespace MainWindow } } + void SetNextState(CoreState state) + { + nextState = state; + } + HINSTANCE GetHInstance() { return hInst; diff --git a/Windows/WndMainWindow.h b/Windows/WndMainWindow.h index 0e01330bc4..7aaaaab423 100644 --- a/Windows/WndMainWindow.h +++ b/Windows/WndMainWindow.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace MainWindow { @@ -14,6 +15,8 @@ namespace MainWindow HINSTANCE GetHInstance(); HWND GetDisplayHWND(); void SetPlaying(const char*text); + void BrowseAndBoot(); + void SetNextState(CoreState state); void _ViewFullScreen(HWND hWnd); void _ViewNormal(HWND hWnd); } diff --git a/Windows/main.cpp b/Windows/main.cpp index 1a859b1a89..0facb4845b 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -21,6 +21,7 @@ #include "file/zip_read.h" #include "../Core/Config.h" +#include "EmuThread.h" #include "LogManager.h" #include "ConsoleListener.h" @@ -50,23 +51,51 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin { Common::EnableCrashingOnCrashes(); - char *token = szCmdLine; - char fileToLoad[256] = ""; - - token = strtok(szCmdLine," "); + const char *fileToStart = NULL; + bool showLog = false; + bool autoRun = true; g_Config.Load(); VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); - while (token) + for (int i = 1; i < __argc; i++) { - if (strcmp(token,"-run")) - { - //run immediately - } + if (__targv[i][0] == '\0') + continue; - token = strtok(NULL," "); + if (__targv[i][0] == '-') + { + switch (__targv[i][1]) + { + case 'j': + g_Config.iCpuCore = CPU_JIT; + break; + case 'i': + g_Config.iCpuCore = CPU_INTERPRETER; + break; + case 'l': + showLog = true; + break; + case 's': + autoRun = false; + break; + } + } + else if (fileToStart == NULL) + { + fileToStart = __targv[i]; + if (!File::Exists(fileToStart)) + { + fprintf(stderr, "File not found: %s\n", fileToStart); + exit(1); + } + } + else + { + fprintf(stderr, "Can only boot one file"); + exit(1); + } } //Windows, API init stuff @@ -104,10 +133,21 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin #endif LogManager::GetInstance()->GetConsoleListener()->Open(hidden, 150, 120, "PPSSPP Debug Console"); LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); - if (strlen(fileToLoad)) + if (fileToStart != NULL) { - // TODO: load the thing + MainWindow::SetPlaying(fileToStart); + MainWindow::Update(); + MainWindow::UpdateMenus(); + + EmuThread_Start(fileToStart); } + else + MainWindow::BrowseAndBoot(); + + if (showLog) + PostMessage(hwndMain, WM_COMMAND, ID_DEBUG_LOG, 0); + if (autoRun) + MainWindow::SetNextState(CORE_RUNNING); //so.. we're at the message pump of the GUI thread MSG msg; From 7fb65a59977b157e9806206fadd0cc9db1d1ddca Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Dec 2012 09:49:29 -0800 Subject: [PATCH 3/5] Add a switch to Windows to save to a log file. --- Common/CommonPaths.h | 2 +- Common/LogManager.cpp | 25 +++++++++++++++++++++++-- Common/LogManager.h | 2 ++ Windows/main.cpp | 19 ++++++++++++++----- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Common/CommonPaths.h b/Common/CommonPaths.h index 0fdf5f887c..949c8d390b 100644 --- a/Common/CommonPaths.h +++ b/Common/CommonPaths.h @@ -100,7 +100,7 @@ #define LOGGER_CONFIG "Logger.ini" // Files in the directory returned by GetUserPath(D_LOGS_IDX) -#define MAIN_LOG "dolphin.log" +#define MAIN_LOG "ppsspp.log" // Sys files #define TOTALDB "totaldb.dsy" diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index 0918cebf9d..64da7ff032 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -68,6 +68,8 @@ LogManager::LogManager() m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str()); m_consoleLog = new ConsoleListener(); m_debuggerLog = new DebuggerLogListener(); +#else + m_fileLog = NULL; #endif for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) @@ -88,8 +90,9 @@ LogManager::~LogManager() { for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { + if (m_fileLog != NULL) + m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog); #if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY) - m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog); m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog); m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog); #endif @@ -97,12 +100,30 @@ LogManager::~LogManager() for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) delete m_Log[i]; + if (m_fileLog != NULL) + delete m_fileLog; #if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY) - delete m_fileLog; delete m_consoleLog; #endif } +void LogManager::ChangeFileLog(const char *filename) +{ + if (m_fileLog != NULL) + { + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog); + delete m_fileLog; + } + + if (filename != NULL) + { + m_fileLog = new FileLogListener(filename); + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) + m_Log[i]->AddListener(m_fileLog); + } +} + void LogManager::SaveConfig(IniFile::Section *section) { for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) diff --git a/Common/LogManager.h b/Common/LogManager.h index 9b6614e696..faef623276 100644 --- a/Common/LogManager.h +++ b/Common/LogManager.h @@ -179,6 +179,8 @@ public: static void Init(); static void Shutdown(); + void ChangeFileLog(const char *filename); + void SaveConfig(IniFile::Section *section); void LoadConfig(IniFile::Section *section); }; diff --git a/Windows/main.cpp b/Windows/main.cpp index 0facb4845b..c840312467 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -52,6 +52,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin Common::EnableCrashingOnCrashes(); const char *fileToStart = NULL; + const char *fileToLog = NULL; bool showLog = false; bool autoRun = true; @@ -59,14 +60,14 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); - for (int i = 1; i < __argc; i++) + for (int i = 1; i < __argc; ++i) { - if (__targv[i][0] == '\0') + if (__argv[i][0] == '\0') continue; - if (__targv[i][0] == '-') + if (__argv[i][0] == '-') { - switch (__targv[i][1]) + switch (__argv[i][1]) { case 'j': g_Config.iCpuCore = CPU_JIT; @@ -80,11 +81,17 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin case 's': autoRun = false; break; + case '-': + if (!strcmp(__argv[i], "--log") && i < __argc - 1) + fileToLog = __argv[++i]; + if (!strncmp(__argv[i], "--log=", strlen("--log=")) && strlen(__argv[i]) > strlen("--log=")) + fileToLog = __argv[i] + strlen("--log="); + break; } } else if (fileToStart == NULL) { - fileToStart = __targv[i]; + fileToStart = __argv[i]; if (!File::Exists(fileToStart)) { fprintf(stderr, "File not found: %s\n", fileToStart); @@ -127,6 +134,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin MainWindow::UpdateMenus(); LogManager::Init(); + if (fileToLog != NULL) + LogManager::GetInstance()->ChangeFileLog(fileToLog); bool hidden = false; #ifndef _DEBUG hidden = true; From 7aa7640e879e28a36da8d4b8d550bf488d840fcd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Dec 2012 09:49:59 -0800 Subject: [PATCH 4/5] Add -f switch for parody with Headless. --- Windows/main.cpp | 3 +++ android/jni/NativeApp.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Windows/main.cpp b/Windows/main.cpp index c840312467..b4131d81d9 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -75,6 +75,9 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin case 'i': g_Config.iCpuCore = CPU_INTERPRETER; break; + case 'f': + g_Config.iCpuCore = CPU_FASTINTERPRETER; + break; case 'l': showLog = true; break; diff --git a/android/jni/NativeApp.cpp b/android/jni/NativeApp.cpp index 8f6b959cc4..4b749797c1 100644 --- a/android/jni/NativeApp.cpp +++ b/android/jni/NativeApp.cpp @@ -185,6 +185,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co case 'j': g_Config.iCpuCore = CPU_JIT; break; + case 'f': + g_Config.iCpuCore = CPU_FASTINTERPRETER; + break; case 'i': g_Config.iCpuCore = CPU_INTERPRETER; break; From ecffa492f698b5163a8cdee84f77c54cdb4c15ff Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Dec 2012 09:54:07 -0800 Subject: [PATCH 5/5] Refactor Windows show log switch. --- Windows/main.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Windows/main.cpp b/Windows/main.cpp index b4131d81d9..d2f9b186ac 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -53,9 +53,13 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin const char *fileToStart = NULL; const char *fileToLog = NULL; - bool showLog = false; + bool hideLog = true; bool autoRun = true; +#ifdef _DEBUG + hideLog = false; +#endif + g_Config.Load(); VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader("")); @@ -79,7 +83,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin g_Config.iCpuCore = CPU_FASTINTERPRETER; break; case 'l': - showLog = true; + hideLog = false; break; case 's': autoRun = false; @@ -139,11 +143,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin LogManager::Init(); if (fileToLog != NULL) LogManager::GetInstance()->ChangeFileLog(fileToLog); - bool hidden = false; -#ifndef _DEBUG - hidden = true; -#endif - LogManager::GetInstance()->GetConsoleListener()->Open(hidden, 150, 120, "PPSSPP Debug Console"); + LogManager::GetInstance()->GetConsoleListener()->Open(hideLog, 150, 120, "PPSSPP Debug Console"); LogManager::GetInstance()->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); if (fileToStart != NULL) { @@ -156,8 +156,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin else MainWindow::BrowseAndBoot(); - if (showLog) - PostMessage(hwndMain, WM_COMMAND, ID_DEBUG_LOG, 0); if (autoRun) MainWindow::SetNextState(CORE_RUNNING);