#include "gpu.h"
#include "ppf.h"
#include "database.h"
+#include "lightrec/plugin.h"
#include <zlib.h>
char CdromId[10] = "";
char name [1];
};
-void mmssdd( char *b, char *p )
+static void mmssdd( char *b, char *p )
{
int m, s, d;
-#if defined(__arm__)
- unsigned char *u = (void *)b;
- int block = (u[3] << 24) | (u[2] << 16) | (u[1] << 8) | u[0];
-#elif defined(__BIGENDIAN__)
- int block = (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | (b[3] << 24);
-#else
- int block = *((int*)b);
-#endif
+ unsigned char *ub = (void *)b;
+ int block = (ub[3] << 24) | (ub[2] << 16) | (ub[1] << 8) | ub[0];
block += 150;
m = block / 4500; // minutes
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;
READTRACK();
mem = PSXM(addr);
- if (mem)
+ if (mem != INVALID_PTR)
memcpy(mem, buf + 12, 2048);
size -= 2048;
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);
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);
}
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));
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);
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);
GPU_freeze(0, gpufP);
free(gpufP);
if (HW_GPU_STATUS == 0)
- HW_GPU_STATUS = GPU_readStatus();
+ HW_GPU_STATUS = SWAP32(GPU_readStatus());
// spu
SaveFuncs.read(f, &Size, 4);