From 581872f2d0c92cba4e0d09a55913ff069faaa7da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 4 Nov 2012 10:56:22 +0100 Subject: [PATCH 1/3] If filename specified on command line, jump directly to it. Retab NativeApp.cpp. --- android/jni/NativeApp.cpp | 177 ++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 86 deletions(-) diff --git a/android/jni/NativeApp.cpp b/android/jni/NativeApp.cpp index eedf3aa417..aecf96618d 100644 --- a/android/jni/NativeApp.cpp +++ b/android/jni/NativeApp.cpp @@ -6,7 +6,7 @@ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License 2.0 for more details. // A copy of the GPL 2.0 should have been included with the program. @@ -55,26 +55,26 @@ std::string config_filename; class AndroidLogger : public LogListener { public: - void Log(LogTypes::LOG_LEVELS level, const char *msg) - { - switch (level) - { - case LogTypes::LDEBUG: - case LogTypes::LINFO: - ILOG("%s", msg); - break; - case LogTypes::LERROR: - ELOG("%s", msg); - break; - case LogTypes::LWARNING: - WLOG("%s", msg); - break; - case LogTypes::LNOTICE: - default: - ILOG("%s", msg); - break; - } - } + void Log(LogTypes::LOG_LEVELS level, const char *msg) + { + switch (level) + { + case LogTypes::LDEBUG: + case LogTypes::LINFO: + ILOG("%s", msg); + break; + case LogTypes::LERROR: + ELOG("%s", msg); + break; + case LogTypes::LWARNING: + WLOG("%s", msg); + break; + case LogTypes::LNOTICE: + default: + ILOG("%s", msg); + break; + } + } }; @@ -86,30 +86,30 @@ public: // hasRendered = false; } - virtual void UpdateUI() {} + virtual void UpdateUI() {} - virtual void UpdateMemView() {} - virtual void UpdateDisassembly() {} + virtual void UpdateMemView() {} + virtual void UpdateDisassembly() {} - virtual void SetDebugMode(bool mode) { } + virtual void SetDebugMode(bool mode) { } - virtual void InitGL() {} - virtual void BeginFrame() {} - virtual void EndFrame() {} - virtual void ShutdownGL() {} + virtual void InitGL() {} + virtual void BeginFrame() {} + virtual void EndFrame() {} + virtual void ShutdownGL() {} - virtual void InitSound(PMixer *mixer); - virtual void UpdateSound() {}; - virtual void ShutdownSound(); + virtual void InitSound(PMixer *mixer); + virtual void UpdateSound() {}; + virtual void ShutdownSound(); - // this is sent from EMU thread! Make sure that Host handles it properly! - virtual void BootDone() {} - virtual void PrepareShutdown() {} + // this is sent from EMU thread! Make sure that Host handles it properly! + virtual void BootDone() {} + virtual void PrepareShutdown() {} - virtual bool IsDebuggingEnabled() {return false;} - virtual bool AttemptLoadSymbolMap() {return false;} - virtual void ResetSymbolMap() {} - virtual void AddSymbol(std::string name, u32 addr, u32 size, int type=0) {} + virtual bool IsDebuggingEnabled() {return false;} + virtual bool AttemptLoadSymbolMap() {return false;} + virtual void ResetSymbolMap() {} + virtual void AddSymbol(std::string name, u32 addr, u32 size, int type=0) {} }; // globals @@ -130,10 +130,10 @@ void NativeHost::ShutdownSound() void NativeMix(short *audio, int num_samples) { - if (g_mixer) - { - g_mixer->Mix(audio, num_samples/2); - } + if (g_mixer) + { + g_mixer->Mix(audio, num_samples/2); + } else { //memset(audio, 0, numSamples * 2); @@ -149,21 +149,21 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo void NativeInit(int argc, const char *argv[], const char *savegame_directory, const char *external_directory, const char *installID) { - std::string user_data_path = savegame_directory; + std::string user_data_path = savegame_directory; - // We want this to be FIRST. - VFSRegister("", new DirectoryAssetReader("assets/")); - VFSRegister("", new DirectoryAssetReader(user_data_path.c_str())); + // We want this to be FIRST. + VFSRegister("", new DirectoryAssetReader("assets/")); + VFSRegister("", new DirectoryAssetReader(user_data_path.c_str())); - host = new NativeHost(); + host = new NativeHost(); - logger = new AndroidLogger(); + logger = new AndroidLogger(); - LogManager::Init(); - LogManager *logman = LogManager::GetInstance(); - ILOG("Logman: %p", logman); + LogManager::Init(); + LogManager *logman = LogManager::GetInstance(); + ILOG("Logman: %p", logman); - if (argc > 1) + if (argc > 1) { boot_filename = argv[1]; @@ -186,17 +186,17 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co #endif } - for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) - { - LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; - logman->SetEnable(type, true); - logman->SetLogLevel(type, LogTypes::LDEBUG); + for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) + { + LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; + logman->SetEnable(type, true); + logman->SetLogLevel(type, LogTypes::LDEBUG); #ifdef ANDROID - logman->AddListener(type, logger); + logman->AddListener(type, logger); #endif - } - logman->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); - INFO_LOG(BOOT, "Logger inited."); + } + logman->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); + INFO_LOG(BOOT, "Logger inited."); } void NativeInitGraphics() @@ -205,7 +205,12 @@ void NativeInitGraphics() gl_lost_manager_init(); ui_draw2d.SetAtlas(&ui_atlas); - screenManager.switchScreen(new LogoScreen(boot_filename)); + if (boot_filename.empty()) { + screenManager.switchScreen(new LogoScreen(boot_filename)); + } else { + // Go directly into the game. + screenManager.switchScreen(new EmuScreen(boot_filename)); + } // screenManager.switchScreen(new FileSelectScreen()); UIShader_Init(); @@ -223,21 +228,21 @@ void NativeInitGraphics() uiTexture = new Texture(); if (!uiTexture->Load("ui_atlas.zim")) - { - ELOG("Failed to load texture"); - } - uiTexture->Bind(0); + { + ELOG("Failed to load texture"); + } + uiTexture->Bind(0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } void NativeRender() { glViewport(0, 0, pixel_xres, pixel_yres); - Matrix4x4 ortho; + Matrix4x4 ortho; ortho.setOrtho(0.0f, dp_xres, dp_yres, 0.0f, -1.0f, 1.0f); glsl_bind(UIShader_Get()); glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr()); @@ -260,20 +265,20 @@ void NativeDeviceLost() bool NativeIsAtTopLevel() { - // TODO - return false; + // TODO + return false; } void NativeTouch(int finger, float x, float y, double time, TouchEvent event) { - switch (event) { - case TOUCH_DOWN: - break; - case TOUCH_MOVE: - break; - case TOUCH_UP: - break; - } + switch (event) { + case TOUCH_DOWN: + break; + case TOUCH_MOVE: + break; + case TOUCH_UP: + break; + } } void NativeShutdownGraphics() @@ -285,14 +290,14 @@ void NativeShutdownGraphics() UIShader_Shutdown(); - gl_lost_manager_shutdown(); + gl_lost_manager_shutdown(); } void NativeShutdown() { - delete host; - host = 0; - LogManager::Shutdown(); + delete host; + host = 0; + LogManager::Shutdown(); g_Config.Save(); // This means that the activity has been completely destroyed. PPSSPP does not // boot up correctly with "dirty" global variables currently, so we hack around that From 63beeb5030c0463986d2a4f2ee56f61f66ef5fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 4 Nov 2012 11:31:06 +0100 Subject: [PATCH 2/3] Add command line flag to set log level to debug. Cleanup. --- Common/Log.h | 72 ++++++++++++++++----------------------- SDL/CMakeLists.txt | 1 + android/jni/NativeApp.cpp | 28 ++++++++++----- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/Common/Log.h b/Common/Log.h index 0bec6b6008..73775eace6 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -15,11 +15,10 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _LOG_H_ -#define _LOG_H_ +#pragma once -#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and OSReports. -#define ERROR_LEVEL 2 // Critical errors +#define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and debugprintfs from the game itself. +#define ERROR_LEVEL 2 // Important errors. #define WARNING_LEVEL 3 // Something is suspicious. #define INFO_LEVEL 4 // General information. #define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. @@ -28,28 +27,28 @@ namespace LogTypes { enum LOG_TYPE { - MASTER_LOG, - BOOT, - COMMON, - CPU, - LOADER, - IO, - PAD, - FILESYS, - DISCIO, - G3D, - DMA, - INTC, - MEMMAP, - SOUND, - HLE, - TIMER, - VIDEO, - DYNA_REC, - NETPLAY, + MASTER_LOG, + BOOT, + COMMON, + CPU, + LOADER, + IO, + PAD, + FILESYS, + DISCIO, + G3D, + DMA, + INTC, + MEMMAP, + SOUND, + HLE, + TIMER, + VIDEO, + DYNA_REC, + NETPLAY, - NUMBER_OF_LOGS, // Must be last - JIT = DYNA_REC, + NUMBER_OF_LOGS, // Must be last + JIT = DYNA_REC, }; // FIXME: should this be removed? @@ -73,30 +72,25 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, #endif ; -#if defined(LOGGING) || defined(_DEBUG) || defined(DEBUGFAST) // || defined(ANDROID) //|| defined(__APPLE__)// +#if defined(LOGGING) || defined(_DEBUG) || defined(DEBUGFAST) #define MAX_LOGLEVEL DEBUG_LEVEL #else #ifndef MAX_LOGLEVEL #define MAX_LOGLEVEL INFO_LEVEL -//#define MAX_LOGLEVEL NOTICE_LEVEL #endif // loglevel #endif // logging -#ifdef GEKKO -#define GENERIC_LOG(t, v, ...) -#else // Let the compiler optimize this out #define GENERIC_LOG(t, v, ...) { \ if (v <= MAX_LOGLEVEL) \ GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ } -#endif -#define ERROR_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } -#define WARN_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } +#define ERROR_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__) } +#define WARN_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__) } #define NOTICE_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__) } -#define INFO_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } -#define DEBUG_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } +#define INFO_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__) } +#define DEBUG_LOG(t,...) { GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__) } #if MAX_LOGLEVEL >= DEBUG_LEVEL #define _dbg_assert_(_t_, _a_) \ @@ -123,8 +117,7 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, #define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) -#ifndef GEKKO -#ifdef _WIN32 +#ifdef _MSC_VER #define _assert_msg_(_t_, _a_, _fmt_, ...) \ if (!(_a_)) {\ if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \ @@ -135,8 +128,3 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ } #endif // WIN32 -#else // GEKKO -#define _assert_msg_(_t_, _a_, _fmt_, ...) -#endif - -#endif // _LOG_H_ diff --git a/SDL/CMakeLists.txt b/SDL/CMakeLists.txt index 6f86cbbc5a..278d825dd0 100644 --- a/SDL/CMakeLists.txt +++ b/SDL/CMakeLists.txt @@ -23,6 +23,7 @@ add_definitions(-DSDL) add_definitions(-Wno-multichar) add_definitions(-fno-strict-aliasing) add_definitions(-DUSE_PROFILER) +add_definitions(-D_DEBUG) if (UNIX) if (NOT APPLE) # can't build the SDL .m file with -std=gnu++0x diff --git a/android/jni/NativeApp.cpp b/android/jni/NativeApp.cpp index aecf96618d..aa3c8e9652 100644 --- a/android/jni/NativeApp.cpp +++ b/android/jni/NativeApp.cpp @@ -163,14 +163,23 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co LogManager *logman = LogManager::GetInstance(); ILOG("Logman: %p", logman); - if (argc > 1) - { - boot_filename = argv[1]; - - if (!File::Exists(boot_filename)) - { - fprintf(stdout, "File not found: %s\n", boot_filename.c_str()); - exit(1); + // Parse command line + LogTypes::LOG_LEVELS logLevel = LogTypes::LINFO; + for (int i = 1; i < argc; i++) { + if (argv[i][0] == '-') { + switch (argv[i][1]) { + case 'd': + // Enable debug logging + logLevel = LogTypes::LDEBUG; + break; + } + } else { + boot_filename = argv[i]; + if (!File::Exists(boot_filename)) + { + fprintf(stdout, "File not found: %s\n", boot_filename.c_str()); + exit(1); + } } } @@ -190,11 +199,12 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co { LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i; logman->SetEnable(type, true); - logman->SetLogLevel(type, LogTypes::LDEBUG); + logman->SetLogLevel(type, logLevel); #ifdef ANDROID logman->AddListener(type, logger); #endif } + // Special hack for G3D as it's very spammy. Need to make a flag for this. logman->SetLogLevel(LogTypes::G3D, LogTypes::LERROR); INFO_LOG(BOOT, "Logger inited."); } From baebaaddf964ae0f463f9ae87725167d4c4cc8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 4 Nov 2012 11:54:45 +0100 Subject: [PATCH 3/3] Respect the IgnoreBadMemAccess ini option (exit on bad access if set). Fix ini save/load on SDL build. --- Core/Config.cpp | 2 ++ Core/HLE/sceGe.cpp | 5 +++-- Core/MemMapFunctions.cpp | 11 ++++++++++- android/jni/NativeApp.cpp | 27 ++++++++++++++++----------- native | 2 +- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index f54f70464e..6209dbc765 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -85,5 +85,7 @@ void CConfig::Save() iniFile.Save(iniFilename_.c_str()); NOTICE_LOG(LOADER, "Config saved: %s", iniFilename_.c_str()); + } else { + NOTICE_LOG(LOADER, "Error saving config: %s", iniFilename_.c_str()); } } diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index f2648163c5..43cd01c125 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -139,7 +139,7 @@ void sceGeContinue() u32 sceGeSetCallback(u32 structAddr) { - ERROR_LOG(HLE,"sceGeSetCallback(struct=%08x)", structAddr); + ERROR_LOG(HLE,"HALFIMPL sceGeSetCallback(struct=%08x)", structAddr); PspGeCallbackData ge_callback_data; Memory::ReadStruct(structAddr, &ge_callback_data); @@ -148,7 +148,8 @@ u32 sceGeSetCallback(u32 structAddr) sceKernelRegisterSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_FINISH, ge_callback_data.finish_func, ge_callback_data.finish_arg); if (ge_callback_data.signal_func) sceKernelRegisterSubIntrHandler(PSP_GE_INTR, PSP_GE_SUBINTR_SIGNAL, ge_callback_data.signal_func, ge_callback_data.signal_arg); - + + // TODO: This should return a callback ID return 0; } diff --git a/Core/MemMapFunctions.cpp b/Core/MemMapFunctions.cpp index c8e106f864..6aa36380df 100644 --- a/Core/MemMapFunctions.cpp +++ b/Core/MemMapFunctions.cpp @@ -19,7 +19,8 @@ #include "Atomic.h" #include "MemMap.h" -// #include "../Core.h" +#include "Config.h" + #include "MIPS/MIPS.h" // TODO: Fix this @@ -82,6 +83,10 @@ inline void ReadFromHardware(T &var, const u32 address) else { WARN_LOG(MEMMAP, "ReadFromHardware: Invalid address %08x PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]); + if (!g_Config.bIgnoreBadMemAccess) { + // TODO: Not sure what the best way to crash is... + exit(0); + } var = 0; } } @@ -106,6 +111,10 @@ inline void WriteToHardware(u32 address, const T data) else { WARN_LOG(MEMMAP, "WriteToHardware: Invalid address %08x PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]); + if (!g_Config.bIgnoreBadMemAccess) { + // TODO: Not sure what the best way to crash is... + exit(0); + } } } diff --git a/android/jni/NativeApp.cpp b/android/jni/NativeApp.cpp index aa3c8e9652..e88744575f 100644 --- a/android/jni/NativeApp.cpp +++ b/android/jni/NativeApp.cpp @@ -49,7 +49,7 @@ Texture *uiTexture; -ScreenManager screenManager; +ScreenManager *screenManager; std::string config_filename; class AndroidLogger : public LogListener @@ -183,7 +183,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co } } - config_filename = user_data_path + "/config.ini"; + config_filename = user_data_path + "ppsspp.ini"; g_Config.Load(config_filename.c_str()); @@ -215,13 +215,14 @@ void NativeInitGraphics() gl_lost_manager_init(); ui_draw2d.SetAtlas(&ui_atlas); + screenManager = new ScreenManager(); if (boot_filename.empty()) { - screenManager.switchScreen(new LogoScreen(boot_filename)); + screenManager->switchScreen(new LogoScreen(boot_filename)); } else { // Go directly into the game. - screenManager.switchScreen(new EmuScreen(boot_filename)); + screenManager->switchScreen(new EmuScreen(boot_filename)); } - // screenManager.switchScreen(new FileSelectScreen()); + // screenManager->switchScreen(new FileSelectScreen()); UIShader_Init(); @@ -256,19 +257,19 @@ void NativeRender() ortho.setOrtho(0.0f, dp_xres, dp_yres, 0.0f, -1.0f, 1.0f); glsl_bind(UIShader_Get()); glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr()); - - screenManager.render(); + + screenManager->render(); } void NativeUpdate(InputState &input) { UIUpdateMouse(0, input.pointer_x[0], input.pointer_y[0], input.pointer_down[0]); - screenManager.update(input); + screenManager->update(input); } void NativeDeviceLost() { - screenManager.deviceLost(); + screenManager->deviceLost(); gl_lost(); // Should dirty EVERYTHING } @@ -296,7 +297,9 @@ void NativeShutdownGraphics() delete uiTexture; uiTexture = NULL; - screenManager.shutdown(); + screenManager->shutdown(); + delete screenManager; + screenManager = 0; UIShader_Shutdown(); @@ -307,10 +310,12 @@ void NativeShutdown() { delete host; host = 0; - LogManager::Shutdown(); g_Config.Save(); + LogManager::Shutdown(); // This means that the activity has been completely destroyed. PPSSPP does not // boot up correctly with "dirty" global variables currently, so we hack around that // by simply exiting. +#ifdef ANDROID exit(0); +#endif } diff --git a/native b/native index d533766061..b80e99726b 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit d533766061b866d391ef80607a58d1e4b81643bf +Subproject commit b80e99726b5bda47f4a3165111295dc35337870d