Merge pull request #614 from fzurita/store_stop_after_jal_in_save

Make stop_after_jal a save state parameter instead of configuration
This commit is contained in:
Gilles Siberlin 2019-01-30 15:23:20 +01:00 committed by GitHub
commit e898991b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 18 deletions

View File

@ -59,10 +59,6 @@ These are standard parameters which are used by the Mupen64Plus Core library. T
|M64TYPE_INT
|Force number of cycles per emulated instruction when set greater than 0.
|-
|DisableSpecRecomp
|M64TYPE_BOOL
|Disable speculative precompilation in new dynarec.
|-
|}
These configuration parameters are used in the Core's event loop to detect keyboard and joystick commands. They are stored in a configuration section called "CoreEvents" and may be altered by the front-end in order to adjust the behaviour of the emulator. These may be adjusted at any time and the effect of the change should occur immediately. The Keysym value stored is actually <tt>(SDLMod << 16) || SDLKey</tt>, so that keypresses with modifiers like shift, control, or alt may be used.

View File

@ -7613,6 +7613,7 @@ void new_dynarec_init(void)
// Copy this into local area so we don't have to put it in every literal pool
g_dev.r4300.new_dynarec_hot_state.invc_ptr=g_dev.r4300.cached_interp.invalid_code;
#endif
stop_after_jal=0;
// TLB
using_tlb=0;
for(n=0;n<524288;n++) // 0 .. 0x7FFFFFFF

View File

@ -306,7 +306,6 @@ int main_set_core_defaults(void)
ConfigSetDefaultString(g_CoreConfig, "SaveSRAMPath", "", "Path to directory where SRAM/EEPROM data (in-game saves) are stored. If this is blank, the default value of ${UserDataPath}/save will be used");
ConfigSetDefaultString(g_CoreConfig, "SharedDataPath", "", "Path to a directory to search when looking for shared data files");
ConfigSetDefaultInt(g_CoreConfig, "CountPerOp", 0, "Force number of cycles per emulated instruction");
ConfigSetDefaultBool(g_CoreConfig, "DisableSpecRecomp", 1, "Disable speculative precompilation in new dynarec");
ConfigSetDefaultBool(g_CoreConfig, "RandomizeInterrupt", 1, "Randomize PI/SI Interrupt Timing");
ConfigSetDefaultInt(g_CoreConfig, "SiDmaDuration", -1, "Duration of SI DMA (-1: use per game settings)");
ConfigSetDefaultString(g_CoreConfig, "GbCameraVideoCaptureBackend1", DEFAULT_VIDEO_CAPTURE_BACKEND, "Gameboy Camera Video Capture backend");
@ -1306,10 +1305,6 @@ m64p_error main_run(void)
savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot"));
no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump");
randomize_interrupt = ConfigGetParamBool(g_CoreConfig, "RandomizeInterrupt");
#ifdef NEW_DYNAREC
stop_after_jal = ConfigGetParamBool(g_CoreConfig, "DisableSpecRecomp");
#endif
count_per_op = ConfigGetParamInt(g_CoreConfig, "CountPerOp");
if (ROM_PARAMS.disableextramem)

View File

@ -57,7 +57,7 @@ enum { GB_CART_FINGERPRINT_OFFSET = 0x134 };
enum { DD_DISK_ID_OFFSET = 0x43670 };
static const char* savestate_magic = "M64+SAVE";
static const int savestate_latest_version = 0x00010400; /* 1.4 */
static const int savestate_latest_version = 0x00010500; /* 1.5 */
static const unsigned char pj64_magic[4] = { 0xC8, 0xA6, 0xD8, 0x23 };
static savestates_job job = savestates_job_nothing;
@ -193,8 +193,9 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
size_t savestateSize;
unsigned char *savestateData, *curr;
char queue[1024];
unsigned char additionalData[4];
unsigned char using_tlb_data[4];
unsigned char data_0001_0200[4096]; // 4k for extra state from v1.2
unsigned char stop_after_jal_data[4];
uint64_t flashram_status;
uint32_t* cp0_regs = r4300_cp0_regs(&dev->r4300.cp0);
@ -275,7 +276,7 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
{
if (gzread(f, savestateData, savestateSize) != (int)savestateSize ||
gzread(f, queue, sizeof(queue)) != sizeof(queue) ||
gzread(f, additionalData, sizeof(additionalData)) != sizeof(additionalData))
gzread(f, using_tlb_data, sizeof(using_tlb_data)) != sizeof(using_tlb_data))
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not read Mupen64Plus savestate 1.1 data from %s", filepath);
free(savestateData);
@ -284,14 +285,14 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
return 0;
}
}
else // version >= 0x00010200 saves entire eventqueue, 4-byte using_tlb flags and extra state
else if (version >= 0x00010200 && version < 0x00010500) // saves entire eventqueue, 4-byte using_tlb flags and extra state
{
if (gzread(f, savestateData, savestateSize) != (int)savestateSize ||
gzread(f, queue, sizeof(queue)) != sizeof(queue) ||
gzread(f, additionalData, sizeof(additionalData)) != sizeof(additionalData) ||
gzread(f, using_tlb_data, sizeof(using_tlb_data)) != sizeof(using_tlb_data) ||
gzread(f, data_0001_0200, sizeof(data_0001_0200)) != sizeof(data_0001_0200))
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not read Mupen64Plus savestate 1.2 data from %s", filepath);
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not read Mupen64Plus savestate 1.2 to 1.4 data from %s", filepath);
free(savestateData);
gzclose(f);
SDL_UnlockMutex(savestates_lock);
@ -299,6 +300,30 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
}
}
else if (version == 0x00010500) // saves entire eventqueue, 4-byte using_tlb flags and extra state and stop_after_jal_state
{
if (gzread(f, savestateData, savestateSize) != (int)savestateSize ||
gzread(f, queue, sizeof(queue)) != sizeof(queue) ||
gzread(f, using_tlb_data, sizeof(using_tlb_data)) != sizeof(using_tlb_data) ||
gzread(f, data_0001_0200, sizeof(data_0001_0200)) != sizeof(data_0001_0200) ||
gzread(f, stop_after_jal_data, sizeof(stop_after_jal_data)) != sizeof(stop_after_jal_data))
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not read Mupen64Plus savestate 1.5 data from %s", filepath);
free(savestateData);
gzclose(f);
SDL_UnlockMutex(savestates_lock);
return 0;
}
}
else
{
main_message(M64MSG_STATUS, OSD_BOTTOM_LEFT, "Could not read Mupen64Plus savestate %#010x data from %s", version, filepath);
free(savestateData);
gzclose(f);
SDL_UnlockMutex(savestates_lock);
return 0;
}
gzclose(f);
SDL_UnlockMutex(savestates_lock);
@ -486,7 +511,7 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
#ifdef NEW_DYNAREC
if (version >= 0x00010100)
{
curr = additionalData;
curr = using_tlb_data;
using_tlb = GETDATA(curr, unsigned int);
}
#endif
@ -827,8 +852,17 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
curr += (3+DD_ASIC_REGS_COUNT)*sizeof(uint32_t) + 0x100 + 0x40 + 2*sizeof(int64_t) + 2*sizeof(unsigned int);
}
}
#ifdef NEW_DYNAREC
if (version >= 0x00010500)
{
curr = stop_after_jal_data;
stop_after_jal = GETDATA(curr, unsigned int);
}
#endif
}
else {
else
{
/* extra ai state */
dev->ai.last_read = 0;
dev->ai.delayed_carry = 0;
@ -890,6 +924,13 @@ static int savestates_load_m64p(struct device* dev, char *filepath)
}
}
#ifdef NEW_DYNAREC
if (version < 0x00010500)
{
stop_after_jal = 1;
}
#endif
/* Zilmar-Spec plugin expect a call with control_id = -1 when RAM processing is done */
if (input.controllerCommand) {
input.controllerCommand(-1, NULL);
@ -1492,7 +1533,7 @@ static int savestates_save_m64p(const struct device* dev, char *filepath)
save_eventqueue_infos(&dev->r4300.cp0, queue);
// Allocate memory for the save state data
save->size = 16788288 + sizeof(queue) + 4 + 4096;
save->size = 16788288 + sizeof(queue) + 4 + 4096 + 4;
save->data = curr = malloc(save->size);
if (save->data == NULL)
{
@ -1840,6 +1881,12 @@ static int savestates_save_m64p(const struct device* dev, char *filepath)
PUTDATA(curr, unsigned int, dev->dd.bm_track_offset);
}
#ifdef NEW_DYNAREC
PUTDATA(curr, unsigned int, stop_after_jal);
#else
PUTDATA(curr, unsigned int, 0);
#endif
init_work(&save->work, savestates_save_m64p_work);
queue_work(&save->work);