From e7027b6c9cb8c002f8ca11d803babfc4a4faa8b4 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 28 Mar 2013 20:17:45 +0100 Subject: [PATCH] win32: Add menu option to open memory stick directory --- Core/HLE/sceIo.cpp | 43 ++++++++------------------------------- Core/HLE/sceUmd.cpp | 1 + Core/System.cpp | 35 +++++++++++++++++++++++++++++++ Core/System.h | 3 +++ Windows/WndMainWindow.cpp | 8 ++++++++ Windows/ppsspp.rc | 2 ++ Windows/resource.h | 3 ++- 7 files changed, 60 insertions(+), 35 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 04fa2a07b3..939ffe320f 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -15,16 +15,13 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#ifdef _WIN32 -#include -#endif - -#include "../Config.h" -#include "../Host.h" -#include "../SaveState.h" +#include "Core/Config.h" +#include "Core/System.h" +#include "Core/Host.h" +#include "Core/SaveState.h" #include "HLE.h" -#include "../MIPS/MIPS.h" -#include "../HW/MemoryStick.h" +#include "Core/MIPS/MIPS.h" +#include "Core/HW/MemoryStick.h" #include "Core/CoreTiming.h" #include "Core/Reporting.h" @@ -244,31 +241,9 @@ void __IoInit() { asyncNotifyEvent = CoreTiming::RegisterEvent("IoAsyncNotify", __IoAsyncNotify); -#ifdef _WIN32 - - char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; - char memstickpath[_MAX_PATH]; - char flash0path[_MAX_PATH]; - - GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); - - char *winpos = strstr(path_buffer, "Windows"); - if (winpos) - *winpos = 0; - strcat(path_buffer, "dummy.txt"); - - _splitpath_s(path_buffer, drive, dir, file, ext ); - - // Mount a couple of filesystems - sprintf(memstickpath, "%s%smemstick\\", drive, dir); - sprintf(flash0path, "%s%sflash0\\", drive, dir); - -#else - // TODO - std::string memstickpath = g_Config.memCardDirectory; - std::string flash0path = g_Config.flashDirectory; -#endif - + std::string memstickpath; + std::string flash0path; + GetSysDirectories(memstickpath, flash0path); DirectoryFileSystem *memstick = new DirectoryFileSystem(&pspFileSystem, memstickpath); #ifdef ANDROID diff --git a/Core/HLE/sceUmd.cpp b/Core/HLE/sceUmd.cpp index 129a23bb53..0907e6418d 100644 --- a/Core/HLE/sceUmd.cpp +++ b/Core/HLE/sceUmd.cpp @@ -390,6 +390,7 @@ const HLEFunction sceUmdUser[] = {0xBD2BDE07,&WrapI_I,"sceUmdUnRegisterUMDCallBack"}, {0x87533940,WrapU_V,"sceUmdReplaceProhibit"}, {0xCBE9F02A,WrapU_V,"sceUmdReplacePermit"}, + {0x20628E6F, 0, "sceUmdGetErrorStatFunction"}, }; void Register_sceUmdUser() diff --git a/Core/System.cpp b/Core/System.cpp index 2f63c1b30b..7da0b27381 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -15,6 +15,12 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#ifdef _WIN32 +#define NOMINMAX +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include "MemMap.h" #include "MIPS/MIPS.h" @@ -122,3 +128,32 @@ CoreParameter &PSP_CoreParameter() { return coreParameter; } + + +void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { +#ifdef _WIN32 + char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; + char memstickpath_buf[_MAX_PATH]; + char flash0path_buf[_MAX_PATH]; + + GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); + + char *winpos = strstr(path_buffer, "Windows"); + if (winpos) + *winpos = 0; + strcat(path_buffer, "dummy.txt"); + + _splitpath_s(path_buffer, drive, dir, file, ext ); + + // Mount a couple of filesystems + sprintf(memstickpath_buf, "%s%smemstick\\", drive, dir); + sprintf(flash0path_buf, "%s%sflash0\\", drive, dir); + + memstickpath = memstickpath_buf; + flash0path = flash0path_buf; +#else + // TODO + memstickpath = g_Config.memCardDirectory; + flash0path = g_Config.flashDirectory; +#endif +} diff --git a/Core/System.h b/Core/System.h index a47d1622fe..b0fb633abe 100644 --- a/Core/System.h +++ b/Core/System.h @@ -31,4 +31,7 @@ bool PSP_IsInited(); void PSP_Shutdown(); void PSP_HWAdvance(int cycles); void PSP_SWI(); + +void GetSysDirectories(std::string &memstickpath, std::string &flash0path); + CoreParameter &PSP_CoreParameter(); \ No newline at end of file diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index d95f0cbd91..a4ab02a6f7 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -288,6 +288,14 @@ namespace MainWindow case ID_FILE_REFRESHGAMELIST: break; + case ID_FILE_MEMSTICK: + { + std::string memStickDir, flash0dir; + GetSysDirectories(memStickDir, flash0dir); + ShellExecuteA(NULL, "open", memStickDir.c_str(), 0, 0, SW_SHOW); + } + break; + case ID_EMULATION_RUN: if (g_State.bEmuThreadStarted) { diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 7e9370410d..282d807e98 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -206,6 +206,8 @@ BEGIN MENUITEM "&Open...", ID_FILE_LOAD MENUITEM "&Close", ID_EMULATION_STOP MENUITEM SEPARATOR + MENUITEM "Open &Memory Stick", ID_FILE_MEMSTICK + MENUITEM SEPARATOR MENUITEM "Quickload state\tF4", ID_FILE_QUICKLOADSTATE MENUITEM "Quicksave state\tF2", ID_FILE_QUICKSAVESTATE MENUITEM "&Load State File...", ID_FILE_LOADSTATEFILE diff --git a/Windows/resource.h b/Windows/resource.h index 01f93a0a46..0650575f72 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -264,6 +264,7 @@ #define ID_OPTIONS_FRAMESKIP 40139 #define IDC_MEMCHECK 40140 #define ID_OPTIONS_USEMEDIAENGINE 40141 +#define ID_FILE_MEMSTICK 40142 #define IDC_STATIC -1 // Next default values for new objects @@ -271,7 +272,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 233 -#define _APS_NEXT_COMMAND_VALUE 40141 +#define _APS_NEXT_COMMAND_VALUE 40143 #define _APS_NEXT_CONTROL_VALUE 1163 #define _APS_NEXT_SYMED_VALUE 101 #endif