summaryrefslogtreecommitdiff
path: root/libpcsxcore/misc.c
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-08-22 15:05:59 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2009-08-22 15:05:59 +0000
commitc9b34c524d3fea849eef4066b8fa77497c1b2597 (patch)
treed2c5abfda3c737145e2a9146679a577677f85c87 /libpcsxcore/misc.c
parent54e6ea3610e17cf16fde1472f73864db3b3b3cf5 (diff)
downloadpcsxr-c9b34c524d3fea849eef4066b8fa77497c1b2597.tar.gz
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@27235 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'libpcsxcore/misc.c')
-rw-r--r--libpcsxcore/misc.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c
index e49be10c..f1392299 100644
--- a/libpcsxcore/misc.c
+++ b/libpcsxcore/misc.c
@@ -369,14 +369,16 @@ int Load(char *ExePath) {
EXE_HEADER tmpHead;
int type;
int retval = 0;
+ u8 opcode;
+ u32 section_address, section_size;
strncpy(CdromId, "SLUS99999", 9);
strncpy(CdromLabel, "SLUS_999.99", 11);
- tmpFile = fopen(ExePath,"rb");
+ tmpFile = fopen(ExePath, "rb");
if (tmpFile == NULL) {
- SysMessage(_("Error opening file: %s"), ExePath);
- retval = 0;
+ SysPrintf(_("Error opening file: %s.\n"), ExePath);
+ retval = -1;
} else {
type = PSXGetFileType(tmpFile);
switch (type) {
@@ -393,19 +395,50 @@ int Load(char *ExePath) {
retval = 0;
break;
case CPE_EXE:
- SysMessage(_("CPE files not supported."));
- retval = -1;
+ fseek(tmpFile, 6, SEEK_SET); /* Something tells me we should go to 4 and read the "08 00" here... */
+ do {
+ fread(&opcode, 1, 1, tmpFile);
+ switch (opcode) {
+ case 1: /* Section loading */
+ fread(&section_address, 4, 1, tmpFile);
+ fread(&section_size, 4, 1, tmpFile);
+ section_address = SWAPu32(section_address);
+ section_size = SWAPu32(section_size);
+#ifdef EMU_LOG
+ EMU_LOG("Loading %08X bytes from %08X to %08X\n", section_size, ftell(tmpFile), section_address);
+#endif
+ fread(PSXM(section_address), section_size, 1, tmpFile);
+ break;
+ case 3: /* register loading (PC only?) */
+ fseek(tmpFile, 2, SEEK_CUR); /* unknown field */
+ fread(&psxRegs.pc, 4, 1, tmpFile);
+ psxRegs.pc = SWAPu32(psxRegs.pc);
+ break;
+ case 0: /* End of file */
+ break;
+ default:
+ SysPrintf(_("Unknown CPE opcode %02x at position %08x.\n"), opcode, ftell(tmpFile) - 1);
+ retval = -1;
+ break;
+ }
+ } while (opcode != 0 && retval == 0);
break;
case COFF_EXE:
- SysMessage(_("COFF files not supported."));
+ SysPrintf(_("COFF files not supported.\n"));
retval = -1;
break;
case INVALID_EXE:
- SysMessage(_("This file does not appear to be a valid PSX file."));
+ SysPrintf(_("This file does not appear to be a valid PSX file.\n"));
retval = -1;
break;
}
}
+
+ if (retval != 0) {
+ CdromId[0] = '\0';
+ CdromLabel[0] = '\0';
+ }
+
return retval;
}