summaryrefslogtreecommitdiff
path: root/libpcsxcore
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-07-24 07:31:51 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-07-24 07:31:51 +0000
commite15c96a69d3c3e5b7461423f0218110b8071dec1 (patch)
treeedcf9122c710d7915b919dbf09ef1cbdfae31009 /libpcsxcore
parent7a2c104a8b8545f45abef4c2510db6a8fb5a5c1e (diff)
downloadpcsxr-e15c96a69d3c3e5b7461423f0218110b8071dec1.tar.gz
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@24054 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'libpcsxcore')
-rw-r--r--libpcsxcore/cdriso.c77
-rw-r--r--libpcsxcore/cheat.c50
2 files changed, 91 insertions, 36 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index d6f17ab0..dbcf5147 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -83,7 +83,7 @@ unsigned int ISOgetTrackLength(unsigned int s) {
}
// divide a string of xx:yy:zz into m, s, f
-static void tok2msf(const char *time, char *msf) {
+static void tok2msf(char *time, char *msf) {
char *token;
token = strtok(time, ":");
@@ -160,16 +160,16 @@ static int parsetoc(const char *isofile) {
}
}
else if (!strcmp(token, "DATAFILE")) {
- sscanf(linebuf, "DATAFILE %s %s", name, time);
+ sscanf(linebuf, "DATAFILE %s %8s", name, time);
tok2msf((char *)&time, (char *)&ti[numtracks].length);
}
else if (!strcmp(token, "FILE")) {
- sscanf(linebuf, "FILE %s %s %s %s", name, dummy, time, time2);
+ sscanf(linebuf, "FILE %s %s %8s %8s", name, dummy, time, time2);
tok2msf((char *)&time, (char *)&ti[numtracks].start);
tok2msf((char *)&time2, (char *)&ti[numtracks].length);
}
else if (!strcmp(token, "START")) {
- sscanf(linebuf, "START %s", time);
+ sscanf(linebuf, "START %8s", time);
tok2msf((char *)&time, (char *)&ti[numtracks].gap);
}
}
@@ -192,7 +192,6 @@ static int parsecue(const char *isofile) {
char cuename[MAXPATHLEN];
FILE *fi;
char *token;
- char name[256];
char time[20];
char *tmp;
char linebuf[256], dummy[256];
@@ -235,7 +234,7 @@ static int parsecue(const char *isofile) {
if (tmp != NULL) {
tmp += strlen("PREGAP");
while (*tmp == ' ') tmp++;
- if (*tmp != '\n') sscanf(tmp, "%s", time);
+ if (*tmp != '\n') sscanf(tmp, "%8s", time);
}
tok2msf((char *)&time, (char *)&ti[numtracks].gap);
}
@@ -244,7 +243,7 @@ static int parsecue(const char *isofile) {
if (tmp != NULL) {
tmp += strlen("INDEX") + 3; // 3 - space + numeric index
while (*tmp == ' ') tmp++;
- if (*tmp != '\n') sscanf(tmp, "%s", time);
+ if (*tmp != '\n') sscanf(tmp, "%8s", time);
}
tok2msf((char *)&time, (char *)&ti[numtracks].start);
@@ -275,7 +274,10 @@ static int parsecue(const char *isofile) {
// this function tries to get the .ccd file of the given .img
// the necessary data is put into the ti (trackinformation)-array
static int parseccd(const char *isofile) {
- char ccdname[MAXPATHLEN];
+ char ccdname[MAXPATHLEN];
+ FILE *fi;
+ char linebuf[256];
+ unsigned int t;
numtracks = 0;
@@ -289,7 +291,56 @@ static int parseccd(const char *isofile) {
return -1;
}
- return -1; // TODO
+ if ((fi = fopen(ccdname, "r")) == NULL) {
+ return -1;
+ }
+
+ memset(&ti, 0, sizeof(ti));
+
+ while (fgets(linebuf, sizeof(linebuf), fi) != NULL) {
+ if (!strncmp(linebuf, "[TRACK", 6)){
+ numtracks++;
+ }
+ else if (!strncmp(linebuf, "MODE=", 5)) {
+ sscanf(linebuf, "MODE=%d", &t);
+ ti[numtracks].type = ((t == 0) ? CDDA : DATA);
+ }
+ else if (!strncmp(linebuf, "INDEX 0=", 8)) {
+ sscanf(linebuf, "INDEX 0=%d", &t);
+ sec2msf(t, ti[numtracks].gap);
+ }
+ else if (!strncmp(linebuf, "INDEX 1=", 8)) {
+ sscanf(linebuf, "INDEX 1=%d", &t);
+
+ if (numtracks <= 1) {
+ t += 2 * 75;
+ }
+
+ if (msf2sec(ti[numtracks].gap) != 0) {
+ sec2msf(t - msf2sec(ti[numtracks].gap), ti[numtracks].gap);
+ }
+
+ t += msf2sec(ti[numtracks].gap);
+ sec2msf(t, ti[numtracks].start);
+
+ // If we've already seen another track, this is its end
+ if (numtracks > 1) {
+ t = msf2sec(ti[numtracks].start) - msf2sec(ti[numtracks - 1].start) + msf2sec(ti[numtracks - 1].gap) - msf2sec(ti[numtracks].gap);
+ sec2msf(t, ti[numtracks - 1].length);
+ }
+ }
+ }
+
+ fclose(fi);
+
+ // Fill out the last track's end based on size
+ if (numtracks >= 1) {
+ fseek(cdHandle, 0, SEEK_END);
+ t = ftell(cdHandle) / 2352 - msf2sec(ti[numtracks].start) + 2 * 75;
+ sec2msf(t, ti[numtracks].length);
+ }
+
+ return 0;
}
// this function tries to get the .sub file of the given .img
@@ -348,17 +399,17 @@ static long CALLBACK ISOopen(void) {
SysPrintf(_("Loaded CD Image: %s"), cdrfilename);
if (parsetoc(cdrfilename) == 0) {
- SysPrintf(" [+toc]");
+ SysPrintf("[+toc]");
}
else if (parsecue(cdrfilename) == 0) {
- SysPrintf(" [+cue]");
+ SysPrintf("[+cue]");
}
else if (parseccd(cdrfilename) == 0) {
- SysPrintf(" [+ccd]");
+ SysPrintf("[+ccd]");
}
if (opensubfile(cdrfilename) == 0) {
- SysPrintf(" [+sub]");
+ SysPrintf("[+sub]");
}
SysPrintf(".\n");
diff --git a/libpcsxcore/cheat.c b/libpcsxcore/cheat.c
index 763c8d01..d743e145 100644
--- a/libpcsxcore/cheat.c
+++ b/libpcsxcore/cheat.c
@@ -145,7 +145,7 @@ void LoadCheats(const char *filename) {
fclose(fp);
- SysPrintf("Cheats loaded from: %s\n", filename);
+ SysPrintf(_("Cheats loaded from: %s\n"), filename);
}
// save all cheats to the specified filename
@@ -177,7 +177,7 @@ void SaveCheats(const char *filename) {
fclose(fp);
- SysPrintf("Cheats saved to: %s\n", filename);
+ SysPrintf(_("Cheats saved to: %s\n"), filename);
}
// apply all enabled cheats
@@ -200,27 +200,27 @@ void ApplyCheats() {
switch (type) {
case CHEAT_CONST8:
- psxMemWrite8(addr, (u8)val);
+ psxMu8ref(addr) = (u8)val;
break;
case CHEAT_CONST16:
- psxMemWrite16(addr, (u16)val);
+ psxMu16ref(addr) = val;
break;
case CHEAT_INC16:
- psxMemWrite16(addr, psxMemRead16(addr) + val);
+ psxMu16ref(addr) += val;
break;
case CHEAT_DEC16:
- psxMemWrite16(addr, psxMemRead16(addr) - val);
+ psxMu16ref(addr) -= val;
break;
case CHEAT_INC8:
- psxMemWrite8(addr, psxMemRead8(addr) + (u8)val);
+ psxMu8ref(addr) += (u8)val;
break;
case CHEAT_DEC8:
- psxMemWrite8(addr, psxMemRead8(addr) - (u8)val);
+ psxMu8ref(addr) -= (u8)val;
break;
case CHEAT_SLIDE:
@@ -234,13 +234,14 @@ void ApplyCheats() {
if (type == CHEAT_CONST8) {
for (k = 0; k < ((addr >> 8) & 0xFF); k++) {
- psxMemWrite8(taddr, (u8)val);
+ psxMu8ref(taddr) = (u8)val;
taddr += (s8)(addr & 0xFF);
val += (s8)(CheatCodes[j - 1].Val & 0xFF);
}
- } else if (type == CHEAT_CONST16) {
+ }
+ else if (type == CHEAT_CONST16) {
for (k = 0; k < ((addr >> 8) & 0xFF); k++) {
- psxMemWrite16(taddr, val);
+ psxMu16ref(taddr) = val;
taddr += (s8)(addr & 0xFF);
val += (s8)(CheatCodes[j - 1].Val & 0xFF);
}
@@ -254,47 +255,47 @@ void ApplyCheats() {
taddr = (CheatCodes[j].Addr & 0x001FFFFF);
for (k = 0; k < val; k++) {
- psxMemWrite8(taddr + k, psxMemRead8(addr + k));
+ psxMu8ref(taddr + k) = PSXMu8(addr + k);
}
break;
case CHEAT_EQU8:
- if (psxMemRead8(addr) != (u8)val)
+ if (PSXMu8(addr) != (u8)val)
j++; // skip the next code
break;
case CHEAT_NOTEQU8:
- if (psxMemRead8(addr) == (u8)val)
+ if (PSXMu8(addr) == (u8)val)
j++; // skip the next code
break;
case CHEAT_LESSTHAN8:
- if (psxMemRead8(addr) >= (u8)val)
+ if (PSXMu8(addr) >= (u8)val)
j++; // skip the next code
break;
case CHEAT_GREATERTHAN8:
- if (psxMemRead8(addr) <= (u8)val)
+ if (PSXMu8(addr) <= (u8)val)
j++; // skip the next code
break;
case CHEAT_EQU16:
- if (psxMemRead16(addr) != val)
+ if (PSXMu16(addr) != val)
j++; // skip the next code
break;
case CHEAT_NOTEQU16:
- if (psxMemRead16(addr) == val)
+ if (PSXMu16(addr) == val)
j++; // skip the next code
break;
case CHEAT_LESSTHAN16:
- if (psxMemRead16(addr) >= val)
+ if (PSXMu16(addr) >= val)
j++; // skip the next code
break;
case CHEAT_GREATERTHAN16:
- if (psxMemRead16(addr) <= val)
+ if (PSXMu16(addr) <= val)
j++; // skip the next code
break;
}
@@ -313,7 +314,8 @@ int AddCheat(const char *descr, char *code) {
assert(NumCheats == 0);
assert(NumCheatsAllocated == ALLOC_INCREMENT);
Cheats = (Cheat *)malloc(sizeof(Cheat) * NumCheatsAllocated);
- } else {
+ }
+ else {
Cheats = (Cheat *)realloc(Cheats, sizeof(Cheat) * NumCheatsAllocated);
}
}
@@ -350,7 +352,8 @@ int AddCheat(const char *descr, char *code) {
assert(NumCodes == 0);
assert(NumCodesAllocated == ALLOC_INCREMENT);
CheatCodes = (CheatCode *)malloc(sizeof(CheatCode) * NumCodesAllocated);
- } else {
+ }
+ else {
CheatCodes = (CheatCode *)realloc(CheatCodes, sizeof(CheatCode) * NumCodesAllocated);
}
}
@@ -419,7 +422,8 @@ int EditCheat(int index, const char *descr, char *code) {
assert(NumCodes == 0);
assert(NumCodesAllocated == ALLOC_INCREMENT);
CheatCodes = (CheatCode *)malloc(sizeof(CheatCode) * NumCodesAllocated);
- } else {
+ }
+ else {
CheatCodes = (CheatCode *)realloc(CheatCodes, sizeof(CheatCode) * NumCodesAllocated);
}
}