X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fmisc.c;h=56b7552f70bdbe50a7a4de0be1d193e245a73122;hb=87cc59de47301ff0a2e71b5ece28447ec77b0153;hp=14f68ec85c25b2827609926bb8ab4316ddda1c3b;hpb=e06ee7f47a951fd8abe122969bedeb2983bf8dc2;p=pcsx_rearmed.git diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 14f68ec8..56b7552f 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -73,7 +73,7 @@ void mmssdd( char *b, char *p ) m = ((m / 10) << 4) | m % 10; s = ((s / 10) << 4) | s % 10; - d = ((d / 10) << 4) | d % 10; + d = ((d / 10) << 4) | d % 10; p[0] = m; p[1] = s; @@ -180,7 +180,7 @@ int LoadCdrom() { // is just below, do it here fake_bios_gpu_setup(); - if (!Config.HLE) { + if (!Config.HLE && !Config.SlowBoot) { // skip BIOS logos psxRegs.pc = psxRegs.GPR.n.ra; return 0; @@ -191,7 +191,7 @@ int LoadCdrom() { READTRACK(); // skip head and sub, and go to the root directory record - dir = (struct iso_directory_record*) &buf[12+156]; + dir = (struct iso_directory_record*) &buf[12+156]; mmssdd(dir->extent, (char*)time); @@ -208,9 +208,9 @@ int LoadCdrom() { // read the SYSTEM.CNF READTRACK(); - sscanf((char *)buf + 12, "BOOT = cdrom:\\%256s", exename); + sscanf((char *)buf + 12, "BOOT = cdrom:\\%255s", exename); if (GetCdromFile(mdir, time, exename) == -1) { - sscanf((char *)buf + 12, "BOOT = cdrom:%256s", exename); + sscanf((char *)buf + 12, "BOOT = cdrom:%255s", exename); if (GetCdromFile(mdir, time, exename) == -1) { char *ptr = strstr((char *)buf + 12, "cdrom:"); if (ptr != NULL) { @@ -236,7 +236,7 @@ int LoadCdrom() { psxRegs.pc = SWAP32(tmpHead.pc0); psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0); - psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); + psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00; tmpHead.t_size = SWAP32(tmpHead.t_size); @@ -268,14 +268,14 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) { u32 size, addr; void *mem; - sscanf(filename, "cdrom:\\%256s", exename); + sscanf(filename, "cdrom:\\%255s", exename); time[0] = itob(0); time[1] = itob(2); time[2] = itob(0x10); READTRACK(); // skip head and sub, and go to the root directory record - dir = (struct iso_directory_record *)&buf[12 + 156]; + dir = (struct iso_directory_record *)&buf[12 + 156]; mmssdd(dir->extent, (char*)time); @@ -329,7 +329,7 @@ int CheckCdrom() { strncpy(CdromLabel, buf + 52, 32); // skip head and sub, and go to the root directory record - dir = (struct iso_directory_record *)&buf[12 + 156]; + dir = (struct iso_directory_record *)&buf[12 + 156]; mmssdd(dir->extent, (char *)time); @@ -338,9 +338,9 @@ int CheckCdrom() { if (GetCdromFile(mdir, time, "SYSTEM.CNF;1") != -1) { READTRACK(); - sscanf(buf + 12, "BOOT = cdrom:\\%256s", exename); + sscanf(buf + 12, "BOOT = cdrom:\\%255s", exename); if (GetCdromFile(mdir, time, exename) == -1) { - sscanf(buf + 12, "BOOT = cdrom:%256s", exename); + sscanf(buf + 12, "BOOT = cdrom:%255s", exename); if (GetCdromFile(mdir, time, exename) == -1) { char *ptr = strstr(buf + 12, "cdrom:"); // possibly the executable is in some subdir if (ptr != NULL) { @@ -357,6 +357,14 @@ int CheckCdrom() { return -1; } } + /* Workaround for Wild Arms EU/US which has non-standard string causing incorrect region detection */ + if (exename[0] == 'E' && exename[1] == 'X' && exename[2] == 'E' && exename[3] == '\\') { + size_t offset = 4; + size_t i, len = strlen(exename) - offset; + for (i = 0; i < len; i++) + exename[i] = exename[i + offset]; + exename[i] = '\0'; + } } else if (GetCdromFile(mdir, time, "PSX.EXE;1") != -1) { strcpy(exename, "PSX.EXE;1"); strcpy(CdromId, "SLUS99999"); @@ -426,7 +434,7 @@ size_t fread_to_ram(void *ptr, size_t size, size_t nmemb, FILE *stream) { void *tmp; size_t ret = 0; - + tmp = malloc(size * nmemb); if (tmp) { ret = fread(tmp, size, nmemb, stream); @@ -445,8 +453,8 @@ int Load(const char *ExePath) { u32 section_address, section_size; void *mem; - strncpy(CdromId, "SLUS99999", 9); - strncpy(CdromLabel, "SLUS_999.99", 11); + strcpy(CdromId, "SLUS99999"); + strcpy(CdromLabel, "SLUS_999.99"); tmpFile = fopen(ExePath, "rb"); if (tmpFile == NULL) { @@ -461,14 +469,14 @@ int Load(const char *ExePath) { section_size = SWAP32(tmpHead.t_size); mem = PSXM(section_address); if (mem != NULL) { - fseek(tmpFile, 0x800, SEEK_SET); + fseek(tmpFile, 0x800, SEEK_SET); fread_to_ram(mem, section_size, 1, tmpFile); psxCpu->Clear(section_address, section_size / 4); } fclose(tmpFile); psxRegs.pc = SWAP32(tmpHead.pc0); psxRegs.GPR.n.gp = SWAP32(tmpHead.gp0); - psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); + psxRegs.GPR.n.sp = SWAP32(tmpHead.s_addr); if (psxRegs.GPR.n.sp == 0) psxRegs.GPR.n.sp = 0x801fff00; retval = 0; @@ -557,7 +565,7 @@ struct PcsxSaveFuncs SaveFuncs = { zlib_open, zlib_read, zlib_write, zlib_seek, zlib_close }; -static const char PcsxHeader[32] = "STv4 PCSX v" PACKAGE_VERSION; +static const char PcsxHeader[32] = "STv4 PCSX v" PCSX_VERSION; // Savestate Versioning! // If you make changes to the savestate version, please increment the value below. @@ -573,7 +581,7 @@ int SaveState(const char *file) { f = SaveFuncs.open(file, "wb"); if (f == NULL) return -1; - new_dyna_save(); + new_dyna_before_save(); SaveFuncs.write(f, (void *)PcsxHeader, 32); SaveFuncs.write(f, (void *)&SaveVersion, sizeof(u32)); @@ -615,6 +623,7 @@ int SaveState(const char *file) { psxHwFreeze(f, 1); psxRcntFreeze(f, 1); mdecFreeze(f, 1); + new_dyna_freeze(f, 1); SaveFuncs.close(f); @@ -679,9 +688,9 @@ int LoadState(const char *file) { psxHwFreeze(f, 0); psxRcntFreeze(f, 0); mdecFreeze(f, 0); + new_dyna_freeze(f, 0); SaveFuncs.close(f); - new_dyna_restore(); return 0; } @@ -741,7 +750,7 @@ int RecvPcsxInfo() { NET_recvData(&Config.Cpu, sizeof(Config.Cpu), PSE_NET_BLOCKING); if (tmp != Config.Cpu) { psxCpu->Shutdown(); -#ifdef PSXREC +#if defined(NEW_DYNAREC) || defined(LIGHTREC) if (Config.Cpu == CPU_INTERPRETER) psxCpu = &psxInt; else psxCpu = &psxRec; #else