summaryrefslogtreecommitdiff
path: root/libpcsxcore/misc.c
diff options
context:
space:
mode:
authorStelios Tsampas <loathingkernel@gmail.com>2017-07-30 13:57:47 +0300
committerStelios Tsampas <loathingkernel@gmail.com>2017-07-30 17:18:07 +0300
commitdcf718bdd96c3bbe27e18200f6384cd43c95c111 (patch)
tree140b77d9d9e4dd940d85daf080cdc944f14984dd /libpcsxcore/misc.c
parentb117a70fd03d780b5817c635d5c337c6ecc36d94 (diff)
* Revert parts of the per game memory card patch.
The previous implementation was doing file paths manipulation deep inside sio.c, and it was hardcoding windows style paths. This was breaking on linux in more than one ways and it is incompatible with the dynamic apppath handling from codeplex branch. Moreover, SaveMcd and LoadMcd functions already take memory card file paths as arguments, making any such logic redundant. This patch rewrites the global Config.Mcd# variables during game startup, which makes it more compatible across all platforms. It also has the added benefit that it doesn't update the configuration file with the each game's memory cards, i.e. at PCSXR startup the default memory cards will be loaded.
Diffstat (limited to 'libpcsxcore/misc.c')
-rwxr-xr-xlibpcsxcore/misc.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c
index f54abeb6..d8a7805c 100755
--- a/libpcsxcore/misc.c
+++ b/libpcsxcore/misc.c
@@ -356,13 +356,9 @@ int CheckCdrom() {
else Config.PsxType = PSX_TYPE_NTSC; // ntsc
}
-
- if (Config.OverClock == 0)
- {
+ if (Config.OverClock == 0) {
PsxClockSpeed = 33868800; // 33.8688 MHz (stock)
- }
- else
- {
+ } else {
PsxClockSpeed = 33868800 * Config.PsxClock;
}
@@ -376,9 +372,22 @@ int CheckCdrom() {
memset(Config.PsxExeName, 0, sizeof(Config.PsxExeName));
strncpy(Config.PsxExeName, exename, 11);
- if(Config.PerGameMcd)
- LoadMcds(Config.Mcd1, Config.Mcd2);
-
+ if(Config.PerGameMcd) {
+ char mcd1path[MAXPATHLEN] = { '\0' };
+ char mcd2path[MAXPATHLEN] = { '\0' };
+#ifdef _WINDOWS
+ sprintf(mcd1path, "memcards\\games\\%s-%02d.mcd", Config.PsxExeName, 1);
+ sprintf(mcd2path, "memcards\\games\\%s-%02d.mcd", Config.PsxExeName, 2);
+#else
+ //lk: dot paths should not be hardcoded here, this is for testing only
+ sprintf(mcd1path, "%s/.pcsxr/memcards/games/%s-%02d.mcd", getenv("HOME"), Config.PsxExeName, 1);
+ sprintf(mcd2path, "%s/.pcsxr/memcards/games/%s-%02d.mcd", getenv("HOME"), Config.PsxExeName, 2);
+#endif
+ strcpy(Config.Mcd1, mcd1path);
+ strcpy(Config.Mcd2, mcd2path);
+ LoadMcds(Config.Mcd1, Config.Mcd2);
+ }
+
BuildPPFCache();
LoadSBI(NULL);
@@ -612,7 +621,7 @@ int SaveStateMem(const u32 id) {
char name[32];
int ret = -1;
- snprintf(name, 32, SHM_SS_NAME_TEMPLATE, id);
+ snprintf(name, sizeof(name), SHM_SS_NAME_TEMPLATE, id);
int fd = shm_open(name, O_CREAT | O_RDWR | O_TRUNC, 0666);
if (fd >= 0) {
@@ -635,7 +644,7 @@ int LoadStateMem(const u32 id) {
char name[32];
int ret = -1;
- snprintf(name, 32, SHM_SS_NAME_TEMPLATE, id);
+ snprintf(name, sizeof(name), SHM_SS_NAME_TEMPLATE, id);
int fd = shm_open(name, O_RDONLY, 0444);
if (fd >= 0) {