X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fmisc.c;h=f820868d2a5193938b9e53005a9a8468e7928efb;hb=ffe97735d2c5683cb3ebc91299c047c417d2322d;hp=be501a2c028bcdc85510aaee8bacb4cd2ffeb144;hpb=630b122be82914a74fac752688abe5d5dd798aa8;p=pcsx_rearmed.git diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index be501a2c..f820868d 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -61,7 +61,7 @@ void mmssdd( char *b, char *p ) #if defined(__arm__) unsigned char *u = (void *)b; int block = (u[3] << 24) | (u[2] << 16) | (u[1] << 8) | u[0]; -#elif defined(__BIGENDIAN__) +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ int block = (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | (b[3] << 24); #else int block = *((int*)b); @@ -254,7 +254,7 @@ int LoadCdrom() { incTime(); READTRACK(); - if (ptr != NULL) memcpy(ptr, buf+12, 2048); + if (ptr != INVALID_PTR) memcpy(ptr, buf+12, 2048); tmpHead.t_size -= 2048; tmpHead.t_addr += 2048; @@ -300,7 +300,7 @@ int LoadCdromFile(const char *filename, EXE_HEADER *head) { READTRACK(); mem = PSXM(addr); - if (mem) + if (mem != INVALID_PTR) memcpy(mem, buf + 12, 2048); size -= 2048; @@ -489,7 +489,7 @@ int Load(const char *ExePath) { section_address = SWAP32(tmpHead.t_addr); section_size = SWAP32(tmpHead.t_size); mem = PSXM(section_address); - if (mem != NULL) { + if (mem != INVALID_PTR) { fseek(tmpFile, 0x800, SEEK_SET); fread_to_ram(mem, section_size, 1, tmpFile); psxCpu->Clear(section_address, section_size / 4); @@ -518,7 +518,7 @@ int Load(const char *ExePath) { EMU_LOG("Loading %08X bytes from %08X to %08X\n", section_size, ftell(tmpFile), section_address); #endif mem = PSXM(section_address); - if (mem != NULL) { + if (mem != INVALID_PTR) { fread_to_ram(mem, section_size, 1, tmpFile); psxCpu->Clear(section_address, section_size / 4); } @@ -603,6 +603,15 @@ static const char PcsxHeader[32] = "STv4 PCSX v" PCSX_VERSION; // If you make changes to the savestate version, please increment the value below. static const u32 SaveVersion = 0x8b410006; +static int drc_is_lightrec(void) +{ +#if defined(LIGHTREC) + return 1; +#else + return 0; +#endif +} + int SaveState(const char *file) { void *f; GPUFreeze_t *gpufP; @@ -615,6 +624,9 @@ int SaveState(const char *file) { new_dyna_before_save(); + if (drc_is_lightrec() && Config.Cpu != CPU_INTERPRETER) + lightrec_plugin_prepare_save_state(); + SaveFuncs.write(f, (void *)PcsxHeader, 32); SaveFuncs.write(f, (void *)&SaveVersion, sizeof(u32)); SaveFuncs.write(f, (void *)&Config.HLE, sizeof(boolean)); @@ -690,12 +702,8 @@ int LoadState(const char *file) { if (Config.HLE) psxBiosInit(); -#if defined(LIGHTREC) - if (Config.Cpu != CPU_INTERPRETER) - psxCpu->Clear(0, UINT32_MAX); //clear all - else -#endif - psxCpu->Reset(); + if (!drc_is_lightrec() || Config.Cpu == CPU_INTERPRETER) + psxCpu->Reset(); SaveFuncs.seek(f, 128 * 96 * 3, SEEK_CUR); SaveFuncs.read(f, psxM, 0x00200000); @@ -704,6 +712,9 @@ int LoadState(const char *file) { SaveFuncs.read(f, &psxRegs, offsetof(psxRegisters, gteBusyCycle)); psxRegs.gteBusyCycle = psxRegs.cycle; + if (drc_is_lightrec() && Config.Cpu != CPU_INTERPRETER) + lightrec_plugin_prepare_load_state(); + if (Config.HLE) psxBiosFreeze(0);