mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
More GetPointer cleanup. memCardDirectory->memStickDirectory.
This commit is contained in:
parent
d17aa4738a
commit
d24abb3af0
@ -332,7 +332,7 @@ public:
|
||||
|
||||
std::string currentDirectory;
|
||||
std::string externalDirectory;
|
||||
std::string memCardDirectory;
|
||||
std::string memStickDirectory;
|
||||
std::string flash0Directory;
|
||||
std::string internalDataDirectory;
|
||||
|
||||
|
@ -443,7 +443,7 @@ void __IoInit() {
|
||||
asyncNotifyEvent = CoreTiming::RegisterEvent("IoAsyncNotify", __IoAsyncNotify);
|
||||
syncNotifyEvent = CoreTiming::RegisterEvent("IoSyncNotify", __IoSyncNotify);
|
||||
|
||||
memstickSystem = new DirectoryFileSystem(&pspFileSystem, g_Config.memCardDirectory, FILESYSTEM_SIMULATE_FAT32);
|
||||
memstickSystem = new DirectoryFileSystem(&pspFileSystem, g_Config.memStickDirectory, FILESYSTEM_SIMULATE_FAT32);
|
||||
#if defined(USING_WIN_UI) || defined(APPLE)
|
||||
flash0System = new DirectoryFileSystem(&pspFileSystem, g_Config.flash0Directory);
|
||||
#else
|
||||
|
@ -634,8 +634,8 @@ u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||
// Technically should crash if these are invalid and size > 0...
|
||||
if (!skip && Memory::IsValidAddress(dst) && Memory::IsValidAddress(src) && Memory::IsValidAddress(dst + size - 1) && Memory::IsValidAddress(src + size - 1))
|
||||
{
|
||||
u8 *dstp = Memory::GetPointer(dst);
|
||||
u8 *srcp = Memory::GetPointer(src);
|
||||
u8 *dstp = Memory::GetPointerUnchecked(dst);
|
||||
u8 *srcp = Memory::GetPointerUnchecked(src);
|
||||
|
||||
// If it's non-overlapping, just do it in one go.
|
||||
if (dst + size < src || src + size < dst)
|
||||
|
@ -89,6 +89,7 @@ void VagDecoder::DecodeBlock(u8 *&read_pointer) {
|
||||
int coef1 = f[predict_nr][0];
|
||||
int coef2 = -f[predict_nr][1];
|
||||
|
||||
// TODO: Unroll once more and interleave the unpacking with the decoding more?
|
||||
for (int i = 0; i < 28; i += 2) {
|
||||
u8 d = *readp++;
|
||||
int sample1 = (short)((d & 0xf) << 12) >> shift_factor;
|
||||
@ -115,11 +116,11 @@ void VagDecoder::GetSamples(s16 *outSamples, int numSamples) {
|
||||
memset(outSamples, 0, numSamples * sizeof(s16));
|
||||
return;
|
||||
}
|
||||
u8 *readp = Memory::GetPointer(read_);
|
||||
if (!readp) {
|
||||
if (!Memory::IsValidAddress(read_)) {
|
||||
WARN_LOG(SASMIX, "Bad VAG samples address?");
|
||||
return;
|
||||
}
|
||||
u8 *readp = Memory::GetPointerUnchecked(read_);
|
||||
u8 *origp = readp;
|
||||
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
|
@ -466,30 +466,30 @@ CoreParameter &PSP_CoreParameter() {
|
||||
std::string GetSysDirectory(PSPDirectories directoryType) {
|
||||
switch (directoryType) {
|
||||
case DIRECTORY_CHEATS:
|
||||
return g_Config.memCardDirectory + "PSP/Cheats/";
|
||||
return g_Config.memStickDirectory + "PSP/Cheats/";
|
||||
case DIRECTORY_GAME:
|
||||
return g_Config.memCardDirectory + "PSP/GAME/";
|
||||
return g_Config.memStickDirectory + "PSP/GAME/";
|
||||
case DIRECTORY_SAVEDATA:
|
||||
return g_Config.memCardDirectory + "PSP/SAVEDATA/";
|
||||
return g_Config.memStickDirectory + "PSP/SAVEDATA/";
|
||||
case DIRECTORY_SCREENSHOT:
|
||||
return g_Config.memCardDirectory + "PSP/SCREENSHOT/";
|
||||
return g_Config.memStickDirectory + "PSP/SCREENSHOT/";
|
||||
case DIRECTORY_SYSTEM:
|
||||
return g_Config.memCardDirectory + "PSP/SYSTEM/";
|
||||
return g_Config.memStickDirectory + "PSP/SYSTEM/";
|
||||
case DIRECTORY_PAUTH:
|
||||
return g_Config.memCardDirectory + "PAUTH/";
|
||||
return g_Config.memStickDirectory + "PAUTH/";
|
||||
case DIRECTORY_DUMP:
|
||||
return g_Config.memCardDirectory + "PSP/SYSTEM/DUMP/";
|
||||
return g_Config.memStickDirectory + "PSP/SYSTEM/DUMP/";
|
||||
// Just return the memory stick root if we run into some sort of problem.
|
||||
default:
|
||||
ERROR_LOG(FILESYS, "Unknown directory type.");
|
||||
return g_Config.memCardDirectory;
|
||||
return g_Config.memStickDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
// Run this at startup time. Please use GetSysDirectory if you need to query where folders are.
|
||||
void InitSysDirectories() {
|
||||
if (!g_Config.memCardDirectory.empty() && !g_Config.flash0Directory.empty())
|
||||
if (!g_Config.memStickDirectory.empty() && !g_Config.flash0Directory.empty())
|
||||
return;
|
||||
|
||||
const std::string path = File::GetExeDirectory();
|
||||
@ -518,38 +518,38 @@ void InitSysDirectories() {
|
||||
if (tempString.substr(0, 3) == "\xEF\xBB\xBF")
|
||||
tempString = tempString.substr(3);
|
||||
|
||||
g_Config.memCardDirectory = tempString;
|
||||
g_Config.memStickDirectory = tempString;
|
||||
}
|
||||
inputFile.close();
|
||||
|
||||
// Check if the file is empty first, before appending the slash.
|
||||
if (g_Config.memCardDirectory.empty())
|
||||
g_Config.memCardDirectory = myDocsPath;
|
||||
if (g_Config.memStickDirectory.empty())
|
||||
g_Config.memStickDirectory = myDocsPath;
|
||||
|
||||
size_t lastSlash = g_Config.memCardDirectory.find_last_of("/");
|
||||
if (lastSlash != (g_Config.memCardDirectory.length() - 1))
|
||||
g_Config.memCardDirectory.append("/");
|
||||
size_t lastSlash = g_Config.memStickDirectory.find_last_of("/");
|
||||
if (lastSlash != (g_Config.memStickDirectory.length() - 1))
|
||||
g_Config.memStickDirectory.append("/");
|
||||
} else {
|
||||
g_Config.memCardDirectory = path + "memstick/";
|
||||
g_Config.memStickDirectory = path + "memstick/";
|
||||
}
|
||||
|
||||
// Create the memstickpath before trying to write to it, and fall back on Documents yet again
|
||||
// if we can't make it.
|
||||
if (!File::Exists(g_Config.memCardDirectory)) {
|
||||
if (!File::CreateDir(g_Config.memCardDirectory))
|
||||
g_Config.memCardDirectory = myDocsPath;
|
||||
if (!File::Exists(g_Config.memStickDirectory)) {
|
||||
if (!File::CreateDir(g_Config.memStickDirectory))
|
||||
g_Config.memStickDirectory = myDocsPath;
|
||||
}
|
||||
|
||||
const std::string testFile = "/_writable_test.$$$";
|
||||
|
||||
// If any directory is read-only, fall back to the Documents directory.
|
||||
// We're screwed anyway if we can't write to Documents, or can't detect it.
|
||||
if (!File::CreateEmptyFile(g_Config.memCardDirectory + testFile))
|
||||
g_Config.memCardDirectory = myDocsPath;
|
||||
if (!File::CreateEmptyFile(g_Config.memStickDirectory + testFile))
|
||||
g_Config.memStickDirectory = myDocsPath;
|
||||
|
||||
// Clean up our mess.
|
||||
if (File::Exists(g_Config.memCardDirectory + testFile))
|
||||
File::Delete(g_Config.memCardDirectory + testFile);
|
||||
if (File::Exists(g_Config.memStickDirectory + testFile))
|
||||
File::Delete(g_Config.memStickDirectory + testFile);
|
||||
|
||||
if (g_Config.currentDirectory.empty()) {
|
||||
g_Config.currentDirectory = GetSysDirectory(DIRECTORY_GAME);
|
||||
|
@ -106,7 +106,7 @@ void LoadPostShaderInfo(std::vector<std::string> directories) {
|
||||
void LoadAllPostShaderInfo() {
|
||||
std::vector<std::string> directories;
|
||||
directories.push_back("shaders");
|
||||
directories.push_back(g_Config.memCardDirectory + "PSP/shaders");
|
||||
directories.push_back(g_Config.memStickDirectory + "PSP/shaders");
|
||||
LoadPostShaderInfo(directories);
|
||||
}
|
||||
|
||||
|
@ -772,7 +772,7 @@ void DeveloperToolsScreen::CreateViews() {
|
||||
#ifdef IOS
|
||||
const std::string testDirectory = g_Config.flash0Directory + "../";
|
||||
#else
|
||||
const std::string testDirectory = g_Config.memCardDirectory;
|
||||
const std::string testDirectory = g_Config.memStickDirectory;
|
||||
#endif
|
||||
if (!File::Exists(testDirectory + "pspautotests/tests/")) {
|
||||
cpuTests->SetEnabled(false);
|
||||
|
@ -439,7 +439,7 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
|
||||
|
||||
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
|
||||
#ifdef ANDROID
|
||||
path_.SetPath(g_Config.memCardDirectory);
|
||||
path_.SetPath(g_Config.memStickDirectory);
|
||||
#elif defined(USING_QT_UI)
|
||||
I18NCategory *m = GetI18NCategory("MainMenu");
|
||||
QString fileName = QFileDialog::getExistingDirectory(NULL, "Browse for Folder", g_Config.currentDirectory.c_str());
|
||||
|
@ -337,7 +337,7 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
|
||||
bool iniLoadedSuccessfully = false;
|
||||
// Allow the lang directory to be overridden for testing purposes (e.g. Android, where it's hard to
|
||||
// test new languages without recompiling the entire app, which is a hassle).
|
||||
const std::string langOverridePath = g_Config.memCardDirectory + "PSP/SYSTEM/lang/";
|
||||
const std::string langOverridePath = g_Config.memStickDirectory + "PSP/SYSTEM/lang/";
|
||||
|
||||
// If we run into the unlikely case that "lang" is actually a file, just use the built-in translations.
|
||||
if (!File::Exists(langOverridePath) || !File::IsDirectory(langOverridePath))
|
||||
|
@ -294,10 +294,10 @@ void NativeInit(int argc, const char *argv[],
|
||||
// Maybe there should be an option to use internal memory instead, but I think
|
||||
// that for most people, using external memory (SDCard/USB Storage) makes the
|
||||
// most sense.
|
||||
g_Config.memCardDirectory = std::string(external_directory) + "/";
|
||||
g_Config.memStickDirectory = std::string(external_directory) + "/";
|
||||
g_Config.flash0Directory = std::string(external_directory) + "/flash0/";
|
||||
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__) || defined(MAEMO) || defined(IOS)
|
||||
g_Config.memCardDirectory = user_data_path;
|
||||
g_Config.memStickDirectory = user_data_path;
|
||||
g_Config.flash0Directory = std::string(external_directory) + "/flash0/";
|
||||
#elif !defined(_WIN32)
|
||||
std::string config;
|
||||
@ -308,7 +308,7 @@ void NativeInit(int argc, const char *argv[],
|
||||
else // Just in case
|
||||
config = "./config";
|
||||
|
||||
g_Config.memCardDirectory = config + "/ppsspp/";
|
||||
g_Config.memStickDirectory = config + "/ppsspp/";
|
||||
g_Config.flash0Directory = File::GetExeDirectory() + "/flash0/";
|
||||
#endif
|
||||
|
||||
@ -319,8 +319,8 @@ void NativeInit(int argc, const char *argv[],
|
||||
LogManager *logman = LogManager::GetInstance();
|
||||
|
||||
g_Config.AddSearchPath(user_data_path);
|
||||
g_Config.AddSearchPath(g_Config.memCardDirectory + "PSP/SYSTEM/");
|
||||
g_Config.SetDefaultPath(g_Config.memCardDirectory + "PSP/SYSTEM/");
|
||||
g_Config.AddSearchPath(g_Config.memStickDirectory + "PSP/SYSTEM/");
|
||||
g_Config.SetDefaultPath(g_Config.memStickDirectory + "PSP/SYSTEM/");
|
||||
g_Config.Load();
|
||||
g_Config.externalDirectory = external_directory;
|
||||
#endif
|
||||
@ -328,10 +328,10 @@ void NativeInit(int argc, const char *argv[],
|
||||
#ifdef ANDROID
|
||||
// On Android, create a PSP directory tree in the external_directory,
|
||||
// to hopefully reduce confusion a bit.
|
||||
ILOG("Creating %s", (g_Config.memCardDirectory + "PSP").c_str());
|
||||
mkDir((g_Config.memCardDirectory + "PSP").c_str());
|
||||
mkDir((g_Config.memCardDirectory + "PSP/SAVEDATA").c_str());
|
||||
mkDir((g_Config.memCardDirectory + "PSP/GAME").c_str());
|
||||
ILOG("Creating %s", (g_Config.memStickDirectory + "PSP").c_str());
|
||||
mkDir((g_Config.memStickDirectory + "PSP").c_str());
|
||||
mkDir((g_Config.memStickDirectory + "PSP/SAVEDATA").c_str());
|
||||
mkDir((g_Config.memStickDirectory + "PSP/GAME").c_str());
|
||||
#endif
|
||||
|
||||
const char *fileToLog = 0;
|
||||
@ -419,7 +419,7 @@ void NativeInit(int argc, const char *argv[],
|
||||
#endif
|
||||
// Allow the lang directory to be overridden for testing purposes (e.g. Android, where it's hard to
|
||||
// test new languages without recompiling the entire app, which is a hassle).
|
||||
const std::string langOverridePath = g_Config.memCardDirectory + "PSP/SYSTEM/lang/";
|
||||
const std::string langOverridePath = g_Config.memStickDirectory + "PSP/SYSTEM/lang/";
|
||||
|
||||
// If we run into the unlikely case that "lang" is actually a file, just use the built-in translations.
|
||||
if (!File::Exists(langOverridePath) || !File::IsDirectory(langOverridePath))
|
||||
@ -596,7 +596,7 @@ void TakeScreenshot() {
|
||||
g_TakeScreenshot = false;
|
||||
|
||||
#if defined(_WIN32) || (defined(USING_QT_UI) && !defined(MOBILE_DEVICE))
|
||||
mkDir(g_Config.memCardDirectory + "/PSP/SCREENSHOT");
|
||||
mkDir(g_Config.memStickDirectory + "/PSP/SCREENSHOT");
|
||||
|
||||
// First, find a free filename.
|
||||
int i = 0;
|
||||
@ -609,9 +609,9 @@ void TakeScreenshot() {
|
||||
char filename[2048];
|
||||
while (i < 10000){
|
||||
if (g_Config.bScreenshotsAsPNG)
|
||||
snprintf(filename, sizeof(filename), "%s/PSP/SCREENSHOT/%s_%05d.png", g_Config.memCardDirectory.c_str(), gameId.c_str(), i);
|
||||
snprintf(filename, sizeof(filename), "%s/PSP/SCREENSHOT/%s_%05d.png", g_Config.memStickDirectory.c_str(), gameId.c_str(), i);
|
||||
else
|
||||
snprintf(filename, sizeof(filename), "%s/PSP/SCREENSHOT/%s_%05d.jpg", g_Config.memCardDirectory.c_str(), gameId.c_str(), i);
|
||||
snprintf(filename, sizeof(filename), "%s/PSP/SCREENSHOT/%s_%05d.jpg", g_Config.memStickDirectory.c_str(), gameId.c_str(), i);
|
||||
FileInfo info;
|
||||
if (!getFileInfo(filename, &info))
|
||||
break;
|
||||
|
@ -1187,7 +1187,7 @@ namespace MainWindow
|
||||
break;
|
||||
|
||||
case ID_FILE_MEMSTICK:
|
||||
ShellExecute(NULL, L"open", ConvertUTF8ToWString(g_Config.memCardDirectory).c_str(), 0, 0, SW_SHOW);
|
||||
ShellExecute(NULL, L"open", ConvertUTF8ToWString(g_Config.memStickDirectory).c_str(), 0, 0, SW_SHOW);
|
||||
break;
|
||||
|
||||
case ID_TOGGLE_PAUSE:
|
||||
|
@ -67,7 +67,7 @@ void RunTests()
|
||||
#ifdef IOS
|
||||
const std::string baseDirectory = g_Config.flash0Directory + "../";
|
||||
#else
|
||||
const std::string baseDirectory = g_Config.memCardDirectory;
|
||||
const std::string baseDirectory = g_Config.memStickDirectory;
|
||||
#endif
|
||||
|
||||
CoreParameter coreParam;
|
||||
|
@ -361,7 +361,7 @@ int main(int argc, const char* argv[])
|
||||
#if defined(ANDROID)
|
||||
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
|
||||
#elif !defined(_WIN32)
|
||||
g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
|
||||
g_Config.memStickDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
|
||||
#endif
|
||||
|
||||
// Try to find the flash0 directory. Often this is from a subdirectory.
|
||||
|
Loading…
Reference in New Issue
Block a user