commit
e09f269914
|
@ -603,11 +603,9 @@ std::string CFIRMWARE::GetExternalFilePath()
|
|||
{
|
||||
std::string fwPath = CommonSettings.Firmware;
|
||||
std::string fwFileName = Path::GetFileNameFromPathWithoutExt(fwPath);
|
||||
char configPath[MAX_PATH] = {0};
|
||||
path.getpath(path.BATTERY, configPath);
|
||||
if (configPath[strlen(configPath)-1] == DIRECTORY_DELIMITER_CHAR)
|
||||
configPath[strlen(configPath)-1] = 0;
|
||||
std::string finalPath = std::string(configPath) + DIRECTORY_DELIMITER_CHAR + fwFileName + FILE_EXT_DELIMITER_CHAR + FW_CONFIG_FILE_EXT;
|
||||
|
||||
std::string configPath = path.getpath(path.BATTERY);
|
||||
std::string finalPath = configPath + DIRECTORY_DELIMITER_CHAR + fwFileName + FILE_EXT_DELIMITER_CHAR + FW_CONFIG_FILE_EXT;
|
||||
|
||||
return finalPath;
|
||||
}
|
||||
|
|
|
@ -232,11 +232,11 @@ void HK_QuickScreenShot(int param, bool justPressed)
|
|||
void HK_PrintScreen(int param, bool justPressed)
|
||||
{
|
||||
if(!justPressed) return;
|
||||
if(!romloaded) return;
|
||||
if(!romloaded) return;
|
||||
|
||||
bool unpause = NDS_Pause(false);
|
||||
|
||||
char outFilename[MAX_PATH];
|
||||
char outFilename[MAX_PATH] = "";
|
||||
|
||||
OPENFILENAME ofn;
|
||||
ZeroMemory(&ofn,sizeof(ofn));
|
||||
|
@ -249,30 +249,30 @@ void HK_PrintScreen(int param, bool justPressed)
|
|||
ofn.lpstrDefExt = "png";
|
||||
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
|
||||
|
||||
std::string filename = path.getpath(path.SCREENSHOTS);
|
||||
|
||||
char file[MAX_PATH];
|
||||
ZeroMemory(file, sizeof(file));
|
||||
path.formatname(file);
|
||||
filename += file;
|
||||
std::string dir = path.getpath(path.SCREENSHOTS);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
path.formatname(outFilename);
|
||||
if(path.imageformat() == PathInfo::PNG)
|
||||
{
|
||||
filename += ".png";
|
||||
strcat(outFilename, ".png");
|
||||
ofn.lpstrDefExt = "png";
|
||||
ofn.nFilterIndex = 1;
|
||||
}
|
||||
else if(path.imageformat() == PathInfo::BMP)
|
||||
{
|
||||
filename += ".bmp";
|
||||
strcat(outFilename, ".bmp");
|
||||
ofn.lpstrDefExt = "bmp";
|
||||
ofn.nFilterIndex = 2;
|
||||
}
|
||||
|
||||
strcpy(outFilename,filename.c_str());
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
DoScreenshot(outFilename);
|
||||
|
||||
dir = Path::GetFileDirectoryPath(outFilename);
|
||||
path.setpath(path.SCREENSHOTS, dir);
|
||||
WritePrivateProfileString(SECTION, SCREENSHOTKEY, dir.c_str(), IniName);
|
||||
}
|
||||
|
||||
if(unpause) NDS_UnPause(false);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "resource.h"
|
||||
|
||||
char ImportSavFName[MAX_PATH] = {0};
|
||||
char SavFName[MAX_PATH] = {0};
|
||||
u32 fileSaveSize = 0;
|
||||
u32 fileSaveType = 0xFF;
|
||||
|
||||
|
@ -79,7 +79,7 @@ BOOL CALLBACK ImportSizeSelect_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
|
|||
}
|
||||
SendDlgItemMessage(hDlg, IDC_IMP_MANUAL_SIZE, CB_SETCURSEL, fileInfo.type, 0);
|
||||
|
||||
fileSaveSize = MMU_new.backupDevice.importDataSize(ImportSavFName);
|
||||
fileSaveSize = MMU_new.backupDevice.importDataSize(SavFName);
|
||||
|
||||
if (fileSaveSize > 0)
|
||||
{
|
||||
|
@ -174,15 +174,13 @@ bool importSave(HWND hwnd, HINSTANCE hAppInst)
|
|||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFilter = "All supported types\0*.sav;*.duc;*.dss\0Raw/No$GBA Save format (*.sav)\0*.sav\0Action Replay DS Save (*.duc,*.dss)\0*.duc;*.dss\0\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFile = ImportSavFName;
|
||||
ofn.lpstrFile = SavFName;
|
||||
SavFName[0] = 0; // lpstrFile overrides lpstsrInitialDir if lpstrFile contains a path
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrDefExt = "sav";
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
||||
|
||||
char buffer[MAX_PATH] = {0};
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
path.getpath(path.BATTERY, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
std::string dir = path.getpath(path.BATTERY);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if(!GetOpenFileName(&ofn))
|
||||
return true;
|
||||
|
@ -190,7 +188,11 @@ bool importSave(HWND hwnd, HINSTANCE hAppInst)
|
|||
u32 res = DialogBoxW(hAppInst, MAKEINTRESOURCEW(IDD_IMPORT_SAVE_SIZE), hwnd, (DLGPROC)ImportSizeSelect_Proc);
|
||||
if (res < MAX_SAVE_TYPES)
|
||||
{
|
||||
res = MMU_new.backupDevice.importData(ImportSavFName, save_types[res+1].size);
|
||||
std::string dir = Path::GetFileDirectoryPath(SavFName);
|
||||
path.setpath(path.BATTERY, dir);
|
||||
WritePrivateProfileString(SECTION, BATTERYKEY, dir.c_str(), IniName);
|
||||
|
||||
res = MMU_new.backupDevice.importData(SavFName, save_types[res+1].size);
|
||||
if (res)
|
||||
{
|
||||
printf("Save was successfully imported\n");
|
||||
|
@ -200,6 +202,34 @@ bool importSave(HWND hwnd, HINSTANCE hAppInst)
|
|||
printf("Save was not successfully imported");
|
||||
return res;
|
||||
}
|
||||
else // user canceled
|
||||
return (res == (MAX_SAVE_TYPES + 1));
|
||||
}
|
||||
|
||||
return (res == (MAX_SAVE_TYPES + 1));
|
||||
}
|
||||
bool exportSave(HWND hwnd, HINSTANCE hAppInst)
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFilter = "Raw Save format (*.sav)\0*.sav\0No$GBA Save format (*.sav)\0*.sav\0\0";
|
||||
ofn.nFilterIndex = 0;
|
||||
ofn.lpstrFile = SavFName;
|
||||
SavFName[0] = 0; // lpstrFile overrides lpstsrInitialDir if lpstrFile contains a path
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrDefExt = "sav";
|
||||
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
|
||||
std::string dir = path.getpath(path.BATTERY);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if (!GetSaveFileName(&ofn))
|
||||
return true;
|
||||
|
||||
dir = Path::GetFileDirectoryPath(SavFName);
|
||||
path.setpath(path.BATTERY, dir);
|
||||
WritePrivateProfileString(SECTION, BATTERYKEY, dir.c_str(), IniName);
|
||||
|
||||
if (ofn.nFilterIndex == 2) strcat(SavFName, "*");
|
||||
|
||||
return !MMU_new.backupDevice.exportData(SavFName);
|
||||
}
|
||||
|
|
|
@ -22,5 +22,6 @@
|
|||
#include <windows.h>
|
||||
|
||||
extern bool importSave(HWND hwnd, HINSTANCE hAppInst);
|
||||
extern bool exportSave(HWND hwnd, HINSTANCE hAppInst);
|
||||
|
||||
#endif
|
|
@ -2854,6 +2854,7 @@ void AviRecordTo()
|
|||
//}
|
||||
|
||||
// avi record file browser
|
||||
char outFilename[MAX_PATH] = "";
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = MainWindow->getHWnd();
|
||||
|
@ -2861,22 +2862,15 @@ void AviRecordTo()
|
|||
ofn.lpstrDefExt = "avi";
|
||||
ofn.lpstrTitle = "Save AVI as";
|
||||
|
||||
char folder[MAX_PATH];
|
||||
ZeroMemory(folder, sizeof(folder));
|
||||
path.getpath(path.AVI_FILES, folder);
|
||||
|
||||
char file[MAX_PATH];
|
||||
ZeroMemory(file, sizeof(file));
|
||||
path.formatname(file);
|
||||
|
||||
strcat(folder, file);
|
||||
int len = strlen(folder);
|
||||
if(len > MAX_PATH - 4)
|
||||
folder[MAX_PATH - 4] = '\0';
|
||||
|
||||
strcat(folder, ".avi");
|
||||
ofn.lpstrFile = folder;
|
||||
std::string dir = path.getpath(path.AVI_FILES);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
path.formatname(outFilename);
|
||||
ofn.lpstrFile = outFilename;
|
||||
|
||||
int len = strlen(outFilename);
|
||||
if(len + dir.length() > MAX_PATH - 4)
|
||||
outFilename[MAX_PATH - dir.length() - 4] = '\0';
|
||||
strcat(outFilename, ".avi");
|
||||
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
|
||||
|
@ -2890,12 +2884,16 @@ void AviRecordTo()
|
|||
driver->AddLine("AVI recording ended.");
|
||||
}
|
||||
|
||||
bool result = DRV_AviBegin(folder);
|
||||
bool result = DRV_AviBegin(outFilename);
|
||||
if (result)
|
||||
{
|
||||
LOG("AVI recording started.");
|
||||
driver->AddLine("AVI recording started.");
|
||||
}
|
||||
|
||||
dir = Path::GetFileDirectoryPath(outFilename);
|
||||
path.setpath(path.AVI_FILES, dir);
|
||||
WritePrivateProfileString(SECTION, AVIKEY, dir.c_str(), IniName);
|
||||
}
|
||||
|
||||
NDS_UnPause();
|
||||
|
@ -2923,7 +2921,6 @@ void WavRecordTo(int wavmode)
|
|||
NDS_Pause();
|
||||
|
||||
OPENFILENAME ofn;
|
||||
char szChoice[MAX_PATH] = {0};
|
||||
|
||||
////if we are playing a movie, construct the filename from the current movie.
|
||||
////else construct it from the filename.
|
||||
|
@ -2947,20 +2944,34 @@ void WavRecordTo(int wavmode)
|
|||
//}
|
||||
|
||||
// wav record file browser
|
||||
char outFilename[MAX_PATH] = "";
|
||||
memset(&ofn, 0, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = MainWindow->getHWnd();
|
||||
ofn.lpstrFilter = "WAV Files (*.wav)\0*.wav\0\0";
|
||||
ofn.lpstrFile = szChoice;
|
||||
ofn.lpstrDefExt = "wav";
|
||||
ofn.lpstrTitle = "Save WAV as";
|
||||
|
||||
std::string dir = path.getpath(path.AVI_FILES);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
path.formatname(outFilename);
|
||||
ofn.lpstrFile = outFilename;
|
||||
|
||||
int len = strlen(outFilename);
|
||||
if (len + dir.length() > MAX_PATH - 4)
|
||||
outFilename[MAX_PATH - dir.length() - 4] = '\0';
|
||||
strcat(outFilename, ".wav");
|
||||
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
|
||||
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
WAV_Begin(szChoice, (WAVMode)wavmode);
|
||||
WAV_Begin(outFilename, (WAVMode)wavmode);
|
||||
|
||||
dir = Path::GetFileDirectoryPath(outFilename);
|
||||
path.setpath(path.AVI_FILES, dir);
|
||||
WritePrivateProfileString(SECTION, AVIKEY, dir.c_str(), IniName);
|
||||
}
|
||||
|
||||
NDS_UnPause();
|
||||
|
@ -3070,11 +3081,8 @@ LRESULT OpenFile()
|
|||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrDefExt = "nds";
|
||||
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
path.getpath(path.ROMS, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
std::string dir = path.getpath(path.ROMS);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if (GetOpenFileName(&ofn) == NULL)
|
||||
{
|
||||
|
@ -3085,14 +3093,9 @@ LRESULT OpenFile()
|
|||
{
|
||||
if(path.savelastromvisit)
|
||||
{
|
||||
char *lchr, buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
|
||||
lchr = strrchr(filename, '\\');
|
||||
strncpy(buffer, filename, strlen(filename) - strlen(lchr));
|
||||
|
||||
path.setpath(path.ROMS, buffer);
|
||||
WritePathSettings();
|
||||
std::string dir = Path::GetFileDirectoryPath(filename);
|
||||
path.setpath(path.ROMS, dir);
|
||||
WritePrivateProfileString(SECTION, ROMKEY, dir.c_str(), IniName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4660,11 +4663,8 @@ DOKEYDOWN:
|
|||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrDefExt = "dst";
|
||||
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
path.getpath(path.STATES, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
std::string dir = path.getpath(path.STATES);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if(!GetOpenFileName(&ofn))
|
||||
{
|
||||
|
@ -4672,6 +4672,10 @@ DOKEYDOWN:
|
|||
return 0;
|
||||
}
|
||||
|
||||
dir = Path::GetFileDirectoryPath(SavName);
|
||||
path.setpath(path.STATES, dir);
|
||||
WritePrivateProfileString(SECTION, STATEKEY, dir.c_str(), IniName);
|
||||
|
||||
savestate_load(SavName);
|
||||
UpdateToolWindows();
|
||||
NDS_UnPause();
|
||||
|
@ -4690,17 +4694,19 @@ DOKEYDOWN:
|
|||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrDefExt = "dst";
|
||||
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST;
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
path.getpath(path.STATES, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
std::string dir = path.getpath(path.STATES);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if(GetSaveFileName(&ofn))
|
||||
{
|
||||
savestate_save(SavName);
|
||||
LoadSaveStateInfo();
|
||||
}
|
||||
|
||||
dir = Path::GetFileDirectoryPath(SavName);
|
||||
path.setpath(path.STATES, dir);
|
||||
WritePrivateProfileString(SECTION, STATEKEY, dir.c_str(), IniName);
|
||||
|
||||
if(unpause) NDS_UnPause();
|
||||
return 0;
|
||||
}
|
||||
|
@ -4741,27 +4747,8 @@ DOKEYDOWN:
|
|||
}
|
||||
case IDM_EXPORTBACKUPMEMORY:
|
||||
{
|
||||
OPENFILENAME ofn;
|
||||
NDS_Pause();
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = hwnd;
|
||||
ofn.lpstrFilter = "Raw Save format (*.sav)\0*.sav\0No$GBA Save format (*.sav)\0*.sav\0\0";
|
||||
ofn.nFilterIndex = 0;
|
||||
ofn.lpstrFile = ImportSavName;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.lpstrDefExt = "sav";
|
||||
ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
|
||||
|
||||
if(!GetSaveFileName(&ofn))
|
||||
{
|
||||
NDS_UnPause();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ofn.nFilterIndex == 2) strcat(ImportSavName, "*");
|
||||
|
||||
if (!MMU_new.backupDevice.exportData(ImportSavName))
|
||||
if (!exportSave(hwnd, hAppInst))
|
||||
MessageBox(hwnd,"Save was not successfully exported","Error",MB_OK);
|
||||
NDS_UnPause();
|
||||
return 0;
|
||||
|
@ -5996,14 +5983,15 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L
|
|||
ofn.nMaxFile = 256;
|
||||
ofn.lpstrDefExt = "bin";
|
||||
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
path.getpath(path.FIRMWARE, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
std::string dir = path.getpath(path.FIRMWARE);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
std::string dir = Path::GetFileDirectoryPath(fileName);
|
||||
path.setpath(path.FIRMWARE, dir);
|
||||
WritePrivateProfileString(SECTION, FIRMWAREKEY, dir.c_str(), IniName);
|
||||
|
||||
HWND cur;
|
||||
|
||||
switch(LOWORD(wParam))
|
||||
|
@ -6115,14 +6103,15 @@ LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
|
|||
ofn.nMaxFile = 256;
|
||||
ofn.lpstrDefExt = "wav";
|
||||
ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
|
||||
|
||||
char buffer[MAX_PATH];
|
||||
ZeroMemory(buffer, sizeof(buffer));
|
||||
path.getpath(path.SOUNDS, buffer);
|
||||
ofn.lpstrInitialDir = buffer;
|
||||
std::string dir = path.getpath(path.SOUNDS);
|
||||
ofn.lpstrInitialDir = dir.c_str();
|
||||
|
||||
if(GetOpenFileName(&ofn))
|
||||
{
|
||||
std::string dir = Path::GetFileDirectoryPath(fileName);
|
||||
path.setpath(path.SOUNDS, dir);
|
||||
WritePrivateProfileString(SECTION, SOUNDKEY, dir.c_str(), IniName);
|
||||
|
||||
HWND cur;
|
||||
|
||||
switch(LOWORD(wParam))
|
||||
|
|
|
@ -108,6 +108,7 @@ void WritePathSettings()
|
|||
WritePrivateProfileString(SECTION, ROMKEY, path.pathToRoms, IniName);
|
||||
WritePrivateProfileString(SECTION, BATTERYKEY, path.pathToBattery, IniName);
|
||||
WritePrivateProfileString(SECTION, STATEKEY, path.pathToStates, IniName);
|
||||
WritePrivateProfileString(SECTION, STATESLOTKEY, path.pathToStateSlots, IniName);
|
||||
WritePrivateProfileString(SECTION, SCREENSHOTKEY, path.pathToScreenshots, IniName);
|
||||
WritePrivateProfileString(SECTION, AVIKEY, path.pathToAviFiles, IniName);
|
||||
WritePrivateProfileString(SECTION, CHEATKEY, path.pathToCheats, IniName);
|
||||
|
|
|
@ -39,23 +39,17 @@ static const char InvalidPathChars[] = {
|
|||
|
||||
//but it is sort of windows-specific. Does it work in linux? Maybe we'll have to make it smarter
|
||||
static const char VolumeSeparatorChar = ':';
|
||||
static const char AltDirectorySeparatorChar = '/';
|
||||
static bool dirEqualsVolume = (DIRECTORY_DELIMITER_CHAR == VolumeSeparatorChar);
|
||||
|
||||
|
||||
bool Path::IsPathRooted (const std::string &path)
|
||||
bool Path::IsPathRooted(const std::string &path)
|
||||
{
|
||||
if (path.empty()) {
|
||||
if (path.empty())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path.find_first_of(InvalidPathChars) != std::string::npos) {
|
||||
if (path.find_first_of(InvalidPathChars) != std::string::npos)
|
||||
return false;
|
||||
}
|
||||
|
||||
char c = path[0];
|
||||
return (c == DIRECTORY_DELIMITER_CHAR ||
|
||||
c == AltDirectorySeparatorChar ||
|
||||
std::string delimiters = ALL_DIRECTORY_DELIMITER_STRING;
|
||||
return (delimiters.find(path[0]) != std::string::npos ||
|
||||
(!dirEqualsVolume && path.size() > 1 && path[1] == VolumeSeparatorChar));
|
||||
}
|
||||
|
||||
|
@ -199,6 +193,211 @@ void PathInfo::init(const char *filename)
|
|||
|
||||
}
|
||||
|
||||
void PathInfo::LoadModulePath()
|
||||
{
|
||||
#if defined(HOST_WINDOWS)
|
||||
|
||||
char *p;
|
||||
ZeroMemory(pathToModule, sizeof(pathToModule));
|
||||
|
||||
GetModuleFileName(NULL, pathToModule, sizeof(pathToModule));
|
||||
p = pathToModule + lstrlen(pathToModule);
|
||||
while (p >= pathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
|
||||
if (++p >= pathToModule) *p = 0;
|
||||
|
||||
extern char* _hack_alternateModulePath;
|
||||
if (_hack_alternateModulePath)
|
||||
{
|
||||
strcpy(pathToModule, _hack_alternateModulePath);
|
||||
}
|
||||
#elif defined(DESMUME_COCOA)
|
||||
std::string pathStr = Path::GetFileDirectoryPath(path);
|
||||
|
||||
strncpy(pathToModule, pathStr.c_str(), MAX_PATH);
|
||||
#else
|
||||
char *cwd = g_build_filename(g_get_user_config_dir(), "desmume", NULL);
|
||||
g_mkdir_with_parents(cwd, 0755);
|
||||
strncpy(pathToModule, cwd, MAX_PATH);
|
||||
g_free(cwd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PathInfo::GetDefaultPath(char *pathToDefault, const char *key, int maxCount)
|
||||
{
|
||||
#ifdef HOST_WINDOWS
|
||||
std::string temp = (std::string)"." + DIRECTORY_DELIMITER_CHAR + pathToDefault;
|
||||
strncpy(pathToDefault, temp.c_str(), maxCount);
|
||||
#else
|
||||
strncpy(pathToDefault, pathToModule, maxCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PathInfo::ReadKey(char *pathToRead, const char *key)
|
||||
{
|
||||
#ifdef HOST_WINDOWS
|
||||
GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName);
|
||||
if (strcmp(pathToRead, key) == 0) {
|
||||
//since the variables are all intialized in this file they all use MAX_PATH
|
||||
GetDefaultPath(pathToRead, key, MAX_PATH);
|
||||
}
|
||||
#else
|
||||
//since the variables are all intialized in this file they all use MAX_PATH
|
||||
GetDefaultPath(pathToRead, key, MAX_PATH);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PathInfo::ReadPathSettings()
|
||||
{
|
||||
if ((strcmp(pathToModule, "") == 0) || !pathToModule)
|
||||
LoadModulePath();
|
||||
|
||||
ReadKey(pathToRoms, ROMKEY);
|
||||
ReadKey(pathToBattery, BATTERYKEY);
|
||||
ReadKey(pathToStates, STATEKEY);
|
||||
ReadKey(pathToStateSlots, STATESLOTKEY);
|
||||
ReadKey(pathToScreenshots, SCREENSHOTKEY);
|
||||
ReadKey(pathToAviFiles, AVIKEY);
|
||||
ReadKey(pathToCheats, CHEATKEY);
|
||||
ReadKey(pathToSounds, SOUNDKEY);
|
||||
ReadKey(pathToFirmware, FIRMWAREKEY);
|
||||
ReadKey(pathToLua, LUAKEY);
|
||||
ReadKey(pathToSlot1D, SLOT1DKEY);
|
||||
#ifdef HOST_WINDOWS
|
||||
GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName);
|
||||
savelastromvisit = GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName);
|
||||
currentimageformat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName);
|
||||
r4Format = (R4Format)GetPrivateProfileInt(SECTION, R4FORMATKEY, R4_CHEAT_DAT, IniName);
|
||||
if ((r4Format != R4_CHEAT_DAT) && (r4Format != R4_USRCHEAT_DAT))
|
||||
{
|
||||
r4Format = R4_USRCHEAT_DAT;
|
||||
WritePrivateProfileInt(SECTION, R4FORMATKEY, r4Format, IniName);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
needsSaving = GetPrivateProfileInt(SECTION, NEEDSSAVINGKEY, TRUE, IniName);
|
||||
if(needsSaving)
|
||||
{
|
||||
needsSaving = FALSE;
|
||||
WritePathSettings();
|
||||
}*/
|
||||
}
|
||||
|
||||
void PathInfo::SwitchPath(Action action, KnownPath path, char *buffer)
|
||||
{
|
||||
char *pathToCopy = 0;
|
||||
switch (path)
|
||||
{
|
||||
case ROMS:
|
||||
pathToCopy = pathToRoms;
|
||||
break;
|
||||
case BATTERY:
|
||||
pathToCopy = pathToBattery;
|
||||
break;
|
||||
case STATES:
|
||||
pathToCopy = pathToStates;
|
||||
break;
|
||||
case STATE_SLOTS:
|
||||
pathToCopy = pathToStateSlots;
|
||||
break;
|
||||
case SCREENSHOTS:
|
||||
pathToCopy = pathToScreenshots;
|
||||
break;
|
||||
case AVI_FILES:
|
||||
pathToCopy = pathToAviFiles;
|
||||
break;
|
||||
case CHEATS:
|
||||
pathToCopy = pathToCheats;
|
||||
break;
|
||||
case SOUNDS:
|
||||
pathToCopy = pathToSounds;
|
||||
break;
|
||||
case FIRMWARE:
|
||||
pathToCopy = pathToFirmware;
|
||||
break;
|
||||
case MODULE:
|
||||
pathToCopy = pathToModule;
|
||||
break;
|
||||
case SLOT1D:
|
||||
pathToCopy = pathToSlot1D;
|
||||
break;
|
||||
}
|
||||
|
||||
if (action == GET)
|
||||
{
|
||||
std::string thePath = pathToCopy;
|
||||
std::string relativePath = (std::string)"." + DIRECTORY_DELIMITER_CHAR;
|
||||
|
||||
int len = (int)thePath.size() - 1;
|
||||
|
||||
if (len == -1)
|
||||
thePath = relativePath;
|
||||
else
|
||||
if (thePath[len] != DIRECTORY_DELIMITER_CHAR)
|
||||
thePath += DIRECTORY_DELIMITER_CHAR;
|
||||
|
||||
if (!Path::IsPathRooted(thePath))
|
||||
{
|
||||
thePath = (std::string)pathToModule + thePath;
|
||||
}
|
||||
|
||||
strncpy(buffer, thePath.c_str(), MAX_PATH);
|
||||
#ifdef HOST_WINDOWS
|
||||
FCEUD_MakePathDirs(buffer);
|
||||
#endif
|
||||
}
|
||||
else if (action == SET)
|
||||
{
|
||||
int len = strlen(buffer) - 1;
|
||||
if (std::string(ALL_DIRECTORY_DELIMITER_STRING).find(buffer[len]) != std::string::npos)
|
||||
buffer[len] = '\0';
|
||||
|
||||
strncpy(pathToCopy, buffer, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
std::string PathInfo::getpath(KnownPath path)
|
||||
{
|
||||
char temp[MAX_PATH];
|
||||
SwitchPath(GET, path, temp);
|
||||
return temp;
|
||||
}
|
||||
void PathInfo::getpath(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(GET, path, buffer);
|
||||
}
|
||||
|
||||
void PathInfo::setpath(KnownPath path, std::string value)
|
||||
{
|
||||
SwitchPath(SET, path, (char*)value.c_str());
|
||||
}
|
||||
void PathInfo::setpath(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(SET, path, buffer);
|
||||
}
|
||||
|
||||
void PathInfo::getfilename(char *buffer, int maxCount)
|
||||
{
|
||||
strcpy(buffer, noextension().c_str());
|
||||
}
|
||||
|
||||
void PathInfo::getpathnoext(KnownPath path, char *buffer)
|
||||
{
|
||||
getpath(path, buffer);
|
||||
strcat(buffer, GetRomNameWithoutExtension().c_str());
|
||||
}
|
||||
|
||||
std::string PathInfo::extension()
|
||||
{
|
||||
return Path::GetFileExt(path);
|
||||
}
|
||||
|
||||
std::string PathInfo::noextension()
|
||||
{
|
||||
std::string romNameWithPath = Path::GetFileDirectoryPath(path) + DIRECTORY_DELIMITER_CHAR + Path::GetFileNameWithoutExt(RomName);
|
||||
|
||||
return romNameWithPath;
|
||||
}
|
||||
|
||||
void PathInfo::formatname(char *output)
|
||||
{
|
||||
// Except 't' for tick and 'r' for random.
|
||||
|
@ -211,10 +410,10 @@ void PathInfo::formatname(char *output)
|
|||
srand((unsigned)now);
|
||||
|
||||
for (char* p = screenshotFormat,
|
||||
*end = p + sizeof(screenshotFormat); p < end; p++)
|
||||
{
|
||||
*end = p + sizeof(screenshotFormat); p < end; p++)
|
||||
{
|
||||
if (*p != '%')
|
||||
{
|
||||
{
|
||||
file.append(1, *p);
|
||||
}
|
||||
else
|
||||
|
@ -228,18 +427,18 @@ void PathInfo::formatname(char *output)
|
|||
else if (*p == 'r')
|
||||
{
|
||||
file.append(stditoa(rand()));
|
||||
}
|
||||
}
|
||||
else if (*p == 't')
|
||||
{
|
||||
{
|
||||
file.append(stditoa(clock() >> 5));
|
||||
}
|
||||
}
|
||||
else if (strchr(strftimeArgs, *p))
|
||||
{
|
||||
char tmp[MAX_PATH];
|
||||
char format[] = { '%', *p, '\0' };
|
||||
strftime(tmp, MAX_PATH, format, time_struct);
|
||||
file.append(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,4 +455,44 @@ void PathInfo::formatname(char *output)
|
|||
#endif
|
||||
|
||||
strncpy(output, file.c_str(), MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
PathInfo::ImageFormat PathInfo::imageformat() {
|
||||
return currentimageformat;
|
||||
}
|
||||
|
||||
void PathInfo::SetRomName(const char *filename)
|
||||
{
|
||||
std::string romPath = filename;
|
||||
|
||||
RomName = Path::GetFileNameFromPath(romPath);
|
||||
RomName = Path::ScrubInvalid(RomName);
|
||||
RomDirectory = Path::GetFileDirectoryPath(romPath);
|
||||
}
|
||||
|
||||
const char *PathInfo::GetRomName()
|
||||
{
|
||||
return RomName.c_str();
|
||||
}
|
||||
|
||||
std::string PathInfo::GetRomNameWithoutExtension()
|
||||
{
|
||||
if (RomName.c_str() == NULL)
|
||||
return "";
|
||||
return Path::GetFileNameWithoutExt(RomName);
|
||||
}
|
||||
|
||||
bool PathInfo::isdsgba(std::string fileName)
|
||||
{
|
||||
size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
|
||||
|
||||
if (i != std::string::npos) {
|
||||
fileName = fileName.substr(i - 2);
|
||||
}
|
||||
|
||||
if (fileName == "ds.gba") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
#define ROMKEY "Roms"
|
||||
#define BATTERYKEY "Battery"
|
||||
#define STATEKEY "States"
|
||||
#define STATESLOTKEY "StateSlots"
|
||||
#define SCREENSHOTKEY "Screenshots"
|
||||
#define AVIKEY "AviFiles"
|
||||
#define CHEATKEY "Cheats"
|
||||
|
@ -93,7 +94,8 @@ public:
|
|||
FIRSTKNOWNPATH = 0,
|
||||
ROMS = 0,
|
||||
BATTERY,
|
||||
STATES,
|
||||
STATES,
|
||||
STATE_SLOTS,
|
||||
SCREENSHOTS,
|
||||
AVI_FILES,
|
||||
CHEATS,
|
||||
|
@ -107,6 +109,7 @@ public:
|
|||
char pathToRoms[MAX_PATH];
|
||||
char pathToBattery[MAX_PATH];
|
||||
char pathToStates[MAX_PATH];
|
||||
char pathToStateSlots[MAX_PATH];
|
||||
char pathToScreenshots[MAX_PATH];
|
||||
char pathToAviFiles[MAX_PATH];
|
||||
char pathToCheats[MAX_PATH];
|
||||
|
@ -118,34 +121,7 @@ public:
|
|||
|
||||
void init(const char *filename);
|
||||
|
||||
void LoadModulePath()
|
||||
{
|
||||
#if defined(HOST_WINDOWS)
|
||||
|
||||
char *p;
|
||||
ZeroMemory(pathToModule, sizeof(pathToModule));
|
||||
|
||||
GetModuleFileName(NULL, pathToModule, sizeof(pathToModule));
|
||||
p = pathToModule + lstrlen(pathToModule);
|
||||
while (p >= pathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
|
||||
if (++p >= pathToModule) *p = 0;
|
||||
|
||||
extern char* _hack_alternateModulePath;
|
||||
if(_hack_alternateModulePath)
|
||||
{
|
||||
strcpy(pathToModule,_hack_alternateModulePath);
|
||||
}
|
||||
#elif defined(DESMUME_COCOA)
|
||||
std::string pathStr = Path::GetFileDirectoryPath(path);
|
||||
|
||||
strncpy(pathToModule, pathStr.c_str(), MAX_PATH);
|
||||
#else
|
||||
char *cwd = g_build_filename(g_get_user_config_dir(), "desmume", NULL);
|
||||
g_mkdir_with_parents(cwd, 0755);
|
||||
strncpy(pathToModule, cwd, MAX_PATH);
|
||||
g_free(cwd);
|
||||
#endif
|
||||
}
|
||||
void LoadModulePath();
|
||||
|
||||
enum Action
|
||||
{
|
||||
|
@ -153,174 +129,27 @@ public:
|
|||
SET
|
||||
};
|
||||
|
||||
void GetDefaultPath(char *pathToDefault, const char *key, int maxCount)
|
||||
{
|
||||
#ifdef HOST_WINDOWS
|
||||
std::string temp = (std::string)"." + DIRECTORY_DELIMITER_CHAR + pathToDefault;
|
||||
strncpy(pathToDefault, temp.c_str(), maxCount);
|
||||
#else
|
||||
strncpy(pathToDefault, pathToModule, maxCount);
|
||||
#endif
|
||||
}
|
||||
void GetDefaultPath(char *pathToDefault, const char *key, int maxCount);
|
||||
|
||||
void ReadKey(char *pathToRead, const char *key)
|
||||
{
|
||||
#ifdef HOST_WINDOWS
|
||||
GetPrivateProfileString(SECTION, key, key, pathToRead, MAX_PATH, IniName);
|
||||
if(strcmp(pathToRead, key) == 0) {
|
||||
//since the variables are all intialized in this file they all use MAX_PATH
|
||||
GetDefaultPath(pathToRead, key, MAX_PATH);
|
||||
}
|
||||
#else
|
||||
//since the variables are all intialized in this file they all use MAX_PATH
|
||||
GetDefaultPath(pathToRead, key, MAX_PATH);
|
||||
#endif
|
||||
}
|
||||
void ReadKey(char *pathToRead, const char *key);
|
||||
|
||||
void ReadPathSettings()
|
||||
{
|
||||
if( ( strcmp(pathToModule, "") == 0) || !pathToModule)
|
||||
LoadModulePath();
|
||||
void ReadPathSettings();
|
||||
|
||||
ReadKey(pathToRoms, ROMKEY);
|
||||
ReadKey(pathToBattery, BATTERYKEY);
|
||||
ReadKey(pathToStates, STATEKEY);
|
||||
ReadKey(pathToScreenshots, SCREENSHOTKEY);
|
||||
ReadKey(pathToAviFiles, AVIKEY);
|
||||
ReadKey(pathToCheats, CHEATKEY);
|
||||
ReadKey(pathToSounds, SOUNDKEY);
|
||||
ReadKey(pathToFirmware, FIRMWAREKEY);
|
||||
ReadKey(pathToLua, LUAKEY);
|
||||
ReadKey(pathToSlot1D, SLOT1DKEY);
|
||||
#ifdef HOST_WINDOWS
|
||||
GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName);
|
||||
savelastromvisit = GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName);
|
||||
currentimageformat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName);
|
||||
r4Format = (R4Format)GetPrivateProfileInt(SECTION, R4FORMATKEY, R4_CHEAT_DAT, IniName);
|
||||
if ((r4Format != R4_CHEAT_DAT) && (r4Format != R4_USRCHEAT_DAT))
|
||||
{
|
||||
r4Format = R4_USRCHEAT_DAT;
|
||||
WritePrivateProfileInt(SECTION, R4FORMATKEY, r4Format, IniName);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
needsSaving = GetPrivateProfileInt(SECTION, NEEDSSAVINGKEY, TRUE, IniName);
|
||||
if(needsSaving)
|
||||
{
|
||||
needsSaving = FALSE;
|
||||
WritePathSettings();
|
||||
}*/
|
||||
}
|
||||
void SwitchPath(Action action, KnownPath path, char *buffer);
|
||||
|
||||
void SwitchPath(Action action, KnownPath path, char *buffer)
|
||||
{
|
||||
char *pathToCopy = 0;
|
||||
switch(path)
|
||||
{
|
||||
case ROMS:
|
||||
pathToCopy = pathToRoms;
|
||||
break;
|
||||
case BATTERY:
|
||||
pathToCopy = pathToBattery;
|
||||
break;
|
||||
case STATES:
|
||||
pathToCopy = pathToStates;
|
||||
break;
|
||||
case SCREENSHOTS:
|
||||
pathToCopy = pathToScreenshots;
|
||||
break;
|
||||
case AVI_FILES:
|
||||
pathToCopy = pathToAviFiles;
|
||||
break;
|
||||
case CHEATS:
|
||||
pathToCopy = pathToCheats;
|
||||
break;
|
||||
case SOUNDS:
|
||||
pathToCopy = pathToSounds;
|
||||
break;
|
||||
case FIRMWARE:
|
||||
pathToCopy = pathToFirmware;
|
||||
break;
|
||||
case MODULE:
|
||||
pathToCopy = pathToModule;
|
||||
break;
|
||||
case SLOT1D:
|
||||
pathToCopy = pathToSlot1D;
|
||||
break;
|
||||
}
|
||||
std::string getpath(KnownPath path);
|
||||
void getpath(KnownPath path, char *buffer);
|
||||
|
||||
if(action == GET)
|
||||
{
|
||||
std::string thePath = pathToCopy;
|
||||
std::string relativePath = (std::string)"." + DIRECTORY_DELIMITER_CHAR;
|
||||
|
||||
int len = (int)thePath.size()-1;
|
||||
void setpath(KnownPath path, std::string value);
|
||||
void setpath(KnownPath path, char *buffer);
|
||||
|
||||
if(len == -1)
|
||||
thePath = relativePath;
|
||||
else
|
||||
if(thePath[len] != DIRECTORY_DELIMITER_CHAR)
|
||||
thePath += DIRECTORY_DELIMITER_CHAR;
|
||||
|
||||
if(!Path::IsPathRooted(thePath))
|
||||
{
|
||||
thePath = (std::string)pathToModule + thePath;
|
||||
}
|
||||
void getfilename(char *buffer, int maxCount);
|
||||
|
||||
strncpy(buffer, thePath.c_str(), MAX_PATH);
|
||||
#ifdef HOST_WINDOWS
|
||||
FCEUD_MakePathDirs(buffer);
|
||||
#endif
|
||||
}
|
||||
else if(action == SET)
|
||||
{
|
||||
int len = strlen(buffer)-1;
|
||||
if(buffer[len] == DIRECTORY_DELIMITER_CHAR)
|
||||
buffer[len] = '\0';
|
||||
void getpathnoext(KnownPath path, char *buffer);
|
||||
|
||||
strncpy(pathToCopy, buffer, MAX_PATH);
|
||||
}
|
||||
}
|
||||
std::string extension();
|
||||
|
||||
std::string getpath(KnownPath path)
|
||||
{
|
||||
char temp[MAX_PATH];
|
||||
SwitchPath(GET, path, temp);
|
||||
return temp;
|
||||
}
|
||||
|
||||
void getpath(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(GET, path, buffer);
|
||||
}
|
||||
|
||||
void setpath(KnownPath path, char *buffer)
|
||||
{
|
||||
SwitchPath(SET, path, buffer);
|
||||
}
|
||||
|
||||
void getfilename(char *buffer, int maxCount)
|
||||
{
|
||||
strcpy(buffer,noextension().c_str());
|
||||
}
|
||||
|
||||
void getpathnoext(KnownPath path, char *buffer)
|
||||
{
|
||||
getpath(path, buffer);
|
||||
strcat(buffer, GetRomNameWithoutExtension().c_str());
|
||||
}
|
||||
|
||||
std::string extension()
|
||||
{
|
||||
return Path::GetFileExt(path);
|
||||
}
|
||||
|
||||
std::string noextension()
|
||||
{
|
||||
std::string romNameWithPath = Path::GetFileDirectoryPath(path) + DIRECTORY_DELIMITER_CHAR + Path::GetFileNameWithoutExt(RomName);
|
||||
|
||||
return romNameWithPath;
|
||||
}
|
||||
std::string noextension();
|
||||
|
||||
void formatname(char *output);
|
||||
|
||||
|
@ -339,45 +168,15 @@ public:
|
|||
|
||||
ImageFormat currentimageformat;
|
||||
|
||||
ImageFormat imageformat() {
|
||||
return currentimageformat;
|
||||
}
|
||||
ImageFormat imageformat();
|
||||
|
||||
void SetRomName(const char *filename)
|
||||
{
|
||||
std::string romPath = filename;
|
||||
void SetRomName(const char *filename);
|
||||
|
||||
RomName = Path::GetFileNameFromPath(romPath);
|
||||
RomName = Path::ScrubInvalid(RomName);
|
||||
RomDirectory = Path::GetFileDirectoryPath(romPath);
|
||||
}
|
||||
const char *GetRomName();
|
||||
|
||||
const char *GetRomName()
|
||||
{
|
||||
return RomName.c_str();
|
||||
}
|
||||
std::string GetRomNameWithoutExtension();
|
||||
|
||||
std::string GetRomNameWithoutExtension()
|
||||
{
|
||||
if (RomName.c_str() == NULL)
|
||||
return "";
|
||||
return Path::GetFileNameWithoutExt(RomName);
|
||||
}
|
||||
|
||||
bool isdsgba(std::string fileName)
|
||||
{
|
||||
size_t i = fileName.find_last_of(FILE_EXT_DELIMITER_CHAR);
|
||||
|
||||
if (i != std::string::npos) {
|
||||
fileName = fileName.substr(i - 2);
|
||||
}
|
||||
|
||||
if(fileName == "ds.gba") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
bool isdsgba(std::string fileName);
|
||||
};
|
||||
|
||||
extern PathInfo path;
|
||||
|
|
|
@ -166,7 +166,7 @@ SFORMAT SF_MEM[]={
|
|||
{ "ITCM", 1, sizeof(MMU.ARM9_ITCM), MMU.ARM9_ITCM},
|
||||
{ "DTCM", 1, sizeof(MMU.ARM9_DTCM), MMU.ARM9_DTCM},
|
||||
|
||||
//for legacy purposes, WRAX is a separate variable. shouldnt be a problem.
|
||||
//for legacy purposes, WRAX is a separate variable. shouldnt be a problem.
|
||||
{ "WRAM", 1, 0x400000, MMU.MAIN_MEM},
|
||||
{ "WRAX", 1, 0x400000, MMU.MAIN_MEM+0x400000},
|
||||
|
||||
|
@ -413,17 +413,17 @@ static bool s_slot1_loadstate(EMUFILE &is, int size)
|
|||
u32 version = is.read_u32LE();
|
||||
|
||||
/* version 0: */
|
||||
u8 slotID = is.read_u32LE();
|
||||
slot1Type = NDS_SLOT1_RETAIL_AUTO;
|
||||
if (version >= 1)
|
||||
slot1_getTypeByID(slotID, slot1Type);
|
||||
u8 slotID = is.read_u32LE();
|
||||
slot1Type = NDS_SLOT1_RETAIL_AUTO;
|
||||
if (version >= 1)
|
||||
slot1_getTypeByID(slotID, slot1Type);
|
||||
|
||||
slot1_Change(slot1Type);
|
||||
slot1_Change(slot1Type);
|
||||
|
||||
EMUFILE_MEMORY temp;
|
||||
is.read_MemoryStream(temp);
|
||||
temp.fseek(0,SEEK_SET);
|
||||
slot1_Loadstate(temp);
|
||||
EMUFILE_MEMORY temp;
|
||||
is.read_MemoryStream(temp);
|
||||
temp.fseek(0, SEEK_SET);
|
||||
slot1_Loadstate(temp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -446,16 +446,16 @@ static bool s_slot2_loadstate(EMUFILE &is, int size)
|
|||
u32 version = is.read_u32LE();
|
||||
|
||||
/* version 0: */
|
||||
slot2Type = NDS_SLOT2_AUTO;
|
||||
u8 slotID = is.read_u32LE();
|
||||
if (version == 0)
|
||||
slot2_getTypeByID(slotID, slot2Type);
|
||||
slot2_Change(slot2Type);
|
||||
slot2Type = NDS_SLOT2_AUTO;
|
||||
u8 slotID = is.read_u32LE();
|
||||
if (version == 0)
|
||||
slot2_getTypeByID(slotID, slot2Type);
|
||||
slot2_Change(slot2Type);
|
||||
|
||||
EMUFILE_MEMORY temp;
|
||||
is.read_MemoryStream(temp);
|
||||
temp.fseek(0,SEEK_SET);
|
||||
slot2_Loadstate(temp);
|
||||
EMUFILE_MEMORY temp;
|
||||
is.read_MemoryStream(temp);
|
||||
temp.fseek(0, SEEK_SET);
|
||||
slot2_Loadstate(temp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -645,100 +645,100 @@ static bool cp15_loadstate(EMUFILE &is, int size)
|
|||
/* Format time and convert to string */
|
||||
static char * format_time(time_t cal_time)
|
||||
{
|
||||
struct tm *time_struct;
|
||||
static char str[64];
|
||||
struct tm *time_struct;
|
||||
static char str[64];
|
||||
|
||||
time_struct=localtime(&cal_time);
|
||||
strftime(str, sizeof str, "%d-%b-%Y %H:%M:%S", time_struct);
|
||||
time_struct = localtime(&cal_time);
|
||||
strftime(str, sizeof str, "%d-%b-%Y %H:%M:%S", time_struct);
|
||||
|
||||
return(str);
|
||||
return(str);
|
||||
}
|
||||
|
||||
void clear_savestates()
|
||||
{
|
||||
u8 i;
|
||||
for( i = 0; i < NB_STATES; i++ )
|
||||
savestates[i].exists = FALSE;
|
||||
u8 i;
|
||||
for (i = 0; i < NB_STATES; i++)
|
||||
savestates[i].exists = FALSE;
|
||||
}
|
||||
|
||||
// Scan for existing savestates and update struct
|
||||
void scan_savestates()
|
||||
{
|
||||
struct stat sbuf;
|
||||
char filename[MAX_PATH+1];
|
||||
struct stat sbuf;
|
||||
char filename[MAX_PATH + 1];
|
||||
|
||||
clear_savestates();
|
||||
clear_savestates();
|
||||
|
||||
for(int i = 0; i < NB_STATES; i++ )
|
||||
{
|
||||
path.getpathnoext(path.STATES, filename);
|
||||
|
||||
if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ;
|
||||
sprintf(filename+strlen(filename), ".ds%d", i);
|
||||
if( stat(filename,&sbuf) == -1 ) continue;
|
||||
savestates[i].exists = TRUE;
|
||||
strncpy(savestates[i].date, format_time(sbuf.st_mtime),40);
|
||||
savestates[i].date[40-1] = '\0';
|
||||
}
|
||||
for (int i = 0; i < NB_STATES; i++)
|
||||
{
|
||||
path.getpathnoext(path.STATE_SLOTS, filename);
|
||||
|
||||
return ;
|
||||
if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ > MAX_PATH) return;
|
||||
sprintf(filename + strlen(filename), ".ds%d", i);
|
||||
if (stat(filename, &sbuf) == -1) continue;
|
||||
savestates[i].exists = TRUE;
|
||||
strncpy(savestates[i].date, format_time(sbuf.st_mtime), 40);
|
||||
savestates[i].date[40 - 1] = '\0';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void savestate_slot(int num)
|
||||
{
|
||||
struct stat sbuf;
|
||||
char filename[MAX_PATH+1];
|
||||
struct stat sbuf;
|
||||
char filename[MAX_PATH + 1];
|
||||
|
||||
lastSaveState = num; //Set last savestate used
|
||||
|
||||
path.getpathnoext(path.STATES, filename);
|
||||
path.getpathnoext(path.STATE_SLOTS, filename);
|
||||
|
||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ;
|
||||
sprintf(filename+strlen(filename), ".ds%d", num);
|
||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ > MAX_PATH) return;
|
||||
sprintf(filename + strlen(filename), ".ds%d", num);
|
||||
|
||||
if (savestate_save(filename))
|
||||
{
|
||||
driver->SetLineColor(255, 255, 255);
|
||||
driver->AddLine("Saved to %i slot", num);
|
||||
}
|
||||
else
|
||||
{
|
||||
driver->SetLineColor(255, 0, 0);
|
||||
driver->AddLine("Error saving %i slot", num);
|
||||
return;
|
||||
}
|
||||
if (savestate_save(filename))
|
||||
{
|
||||
driver->SetLineColor(255, 255, 255);
|
||||
driver->AddLine("Saved to %i slot", num);
|
||||
}
|
||||
else
|
||||
{
|
||||
driver->SetLineColor(255, 0, 0);
|
||||
driver->AddLine("Error saving %i slot", num);
|
||||
return;
|
||||
}
|
||||
|
||||
if (num >= 0 && num < NB_STATES)
|
||||
{
|
||||
if (stat(filename,&sbuf) != -1)
|
||||
{
|
||||
savestates[num].exists = TRUE;
|
||||
strncpy(savestates[num].date, format_time(sbuf.st_mtime),40);
|
||||
savestates[num].date[40-1] = '\0';
|
||||
}
|
||||
}
|
||||
if (num >= 0 && num < NB_STATES)
|
||||
{
|
||||
if (stat(filename, &sbuf) != -1)
|
||||
{
|
||||
savestates[num].exists = TRUE;
|
||||
strncpy(savestates[num].date, format_time(sbuf.st_mtime), 40);
|
||||
savestates[num].date[40 - 1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadstate_slot(int num)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
char filename[MAX_PATH];
|
||||
|
||||
lastSaveState = num; //Set last savestate used
|
||||
lastSaveState = num; //Set last savestate used
|
||||
|
||||
path.getpathnoext(path.STATES, filename);
|
||||
path.getpathnoext(path.STATE_SLOTS, filename);
|
||||
|
||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ;
|
||||
sprintf(filename+strlen(filename), ".ds%d", num);
|
||||
if (savestate_load(filename))
|
||||
{
|
||||
driver->SetLineColor(255, 255, 255);
|
||||
driver->AddLine("Loaded from %i slot", num);
|
||||
}
|
||||
else
|
||||
{
|
||||
driver->SetLineColor(255, 0, 0);
|
||||
driver->AddLine("Error loading %i slot", num);
|
||||
}
|
||||
if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ > MAX_PATH) return;
|
||||
sprintf(filename + strlen(filename), ".ds%d", num);
|
||||
if (savestate_load(filename))
|
||||
{
|
||||
driver->SetLineColor(255, 255, 255);
|
||||
driver->AddLine("Loaded from %i slot", num);
|
||||
}
|
||||
else
|
||||
{
|
||||
driver->SetLineColor(255, 0, 0);
|
||||
driver->AddLine("Error loading %i slot", num);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue