static bool show_advanced_gpu_unai_settings = true;
#endif
static float mouse_sensitivity = 1.0f;
+static unsigned int disk_current_index;
typedef enum
{
bool retro_serialize(void *data, size_t size)
{
- int ret = SaveState(data);
+ int ret;
+ CdromFrontendId = disk_current_index;
+ ret = SaveState(data);
return ret == 0 ? true : false;
}
+static bool disk_set_image_index(unsigned int index);
+
bool retro_unserialize(const void *data, size_t size)
{
- int ret = LoadState(data);
- return ret == 0 ? true : false;
+ int ret;
+ CdromFrontendId = -1;
+ ret = LoadState(data);
+ if (ret)
+ return false;
+ if (CdromFrontendId != -1 && CdromFrontendId != disk_current_index)
+ disk_set_image_index(CdromFrontendId);
+ return true;
}
/* cheats */
static unsigned int disk_initial_index;
static char disk_initial_path[PATH_MAX];
static bool disk_ejected;
-static unsigned int disk_current_index;
static unsigned int disk_count;
static struct disks_state
{
char CdromId[10] = "";
char CdromLabel[33] = "";
+int CdromFrontendId; // for frontend use
// PSX Executable types
#define PSX_EXE 1
// If you make changes to the savestate version, please increment the value below.
static const u32 SaveVersion = 0x8b410006;
+#define MISC_MAGIC 0x4353494d
+struct misc_save_data {
+ u32 magic;
+ u32 gteBusyCycle;
+ u32 muldivBusyCycle;
+ u32 biuReg;
+ u32 biosBranchCheck;
+ u32 gpuIdleAfter;
+ u32 gpuSr;
+ u32 frame_counter;
+ int CdromFrontendId;
+};
+
int SaveState(const char *file) {
+ struct misc_save_data *misc = (void *)(psxH + 0xf000);
void *f;
GPUFreeze_t *gpufP = NULL;
SPUFreezeHdr_t spufH;
int result = -1;
int Size;
+ assert(!psxRegs.branching);
+ assert(!psxRegs.cpuInRecursion);
+ assert(!misc->magic);
+ misc->magic = MISC_MAGIC;
+ misc->gteBusyCycle = psxRegs.gteBusyCycle;
+ misc->muldivBusyCycle = psxRegs.muldivBusyCycle;
+ misc->biuReg = psxRegs.biuReg;
+ misc->biosBranchCheck = psxRegs.biosBranchCheck;
+ misc->gpuIdleAfter = psxRegs.gpuIdleAfter;
+ misc->gpuSr = HW_GPU_STATUS;
+ misc->frame_counter = frame_counter;
+ misc->CdromFrontendId = CdromFrontendId;
+
f = SaveFuncs.open(file, "wb");
if (f == NULL) return -1;
result = 0;
cleanup:
+ memset(misc, 0, sizeof(*misc));
SaveFuncs.close(f);
return result;
}
int LoadState(const char *file) {
+ struct misc_save_data *misc = (void *)(psxH + 0xf000);
u32 biosBranchCheckOld = psxRegs.biosBranchCheck;
void *f;
GPUFreeze_t *gpufP = NULL;
psxRegs.biosBranchCheck = ~0;
psxRegs.gpuIdleAfter = psxRegs.cycle - 1;
HW_GPU_STATUS &= SWAP32(~PSXGPU_nBUSY);
+ if (misc->magic == MISC_MAGIC) {
+ psxRegs.gteBusyCycle = misc->gteBusyCycle;
+ psxRegs.muldivBusyCycle = misc->muldivBusyCycle;
+ psxRegs.biuReg = misc->biuReg;
+ psxRegs.biosBranchCheck = misc->biosBranchCheck;
+ psxRegs.gpuIdleAfter = misc->gpuIdleAfter;
+ HW_GPU_STATUS = misc->gpuSr;
+ frame_counter = misc->frame_counter;
+ CdromFrontendId = misc->CdromFrontendId;
+ }
psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL);
result = 0;
cleanup:
+ memset(misc, 0, sizeof(*misc));
SaveFuncs.close(f);
return result;
}