switch between interpreter and dynarec at runtime
This commit is contained in:
parent
fb92d8d8c5
commit
9ccf0efdea
|
@ -47,6 +47,7 @@ extern bool naomi_test_button;
|
|||
void dc_stop(void);
|
||||
bool dc_loadstate(void);
|
||||
bool dc_savestate(void);
|
||||
void dc_enable_dynarec(bool enable);
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -446,6 +447,10 @@ void input_x11_handle()
|
|||
naomi_test_button = e.type == KeyPress;
|
||||
}
|
||||
#endif
|
||||
else if (e.type == KeyRelease && e.xkey.keycode == KEY_F6)
|
||||
{
|
||||
dc_enable_dynarec(settings.dynarec.Enable == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int dc_key = x11_keymap[e.xkey.keycode];
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
void FlushCache();
|
||||
|
||||
settings_t settings;
|
||||
static bool performed_serialization = false;
|
||||
static bool continue_running = false;
|
||||
static cMutex mtx_serialization ;
|
||||
static cMutex mtx_mainloop ;
|
||||
static int new_dynarec_setting = -1;
|
||||
|
||||
/*
|
||||
libndc
|
||||
|
@ -356,21 +357,24 @@ int dc_init()
|
|||
#endif
|
||||
|
||||
#if FEAT_SHREC != DYNAREC_NONE
|
||||
Get_Sh4Recompiler(&sh4_cpu);
|
||||
sh4_cpu.Init(); // Also initialize the interpreter
|
||||
if(settings.dynarec.Enable)
|
||||
{
|
||||
Get_Sh4Recompiler(&sh4_cpu);
|
||||
printf("Using Recompiler\n");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Get_Sh4Interpreter(&sh4_cpu);
|
||||
#if FEAT_SHREC == DYNAREC_NONE
|
||||
sh4_cpu.Init();
|
||||
#endif
|
||||
printf("Using Interpreter\n");
|
||||
}
|
||||
|
||||
InitAudio();
|
||||
|
||||
sh4_cpu.Init();
|
||||
mem_Init();
|
||||
|
||||
mem_map_default();
|
||||
|
@ -398,7 +402,7 @@ void dc_run()
|
|||
{
|
||||
while ( true )
|
||||
{
|
||||
performed_serialization = false ;
|
||||
continue_running = false ;
|
||||
mtx_mainloop.Lock() ;
|
||||
sh4_cpu.Run();
|
||||
mtx_mainloop.Unlock() ;
|
||||
|
@ -406,7 +410,22 @@ void dc_run()
|
|||
mtx_serialization.Lock() ;
|
||||
mtx_serialization.Unlock() ;
|
||||
|
||||
if (!performed_serialization)
|
||||
if (new_dynarec_setting != -1 && new_dynarec_setting != settings.dynarec.Enable)
|
||||
{
|
||||
settings.dynarec.Enable = new_dynarec_setting;
|
||||
if (settings.dynarec.Enable)
|
||||
{
|
||||
Get_Sh4Recompiler(&sh4_cpu);
|
||||
printf("Using Recompiler\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Get_Sh4Interpreter(&sh4_cpu);
|
||||
printf("Using Interpreter\n");
|
||||
}
|
||||
sh4_cpu.ResetCache();
|
||||
}
|
||||
if (!continue_running)
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
@ -620,13 +639,21 @@ bool acquire_mainloop_lock()
|
|||
return result ;
|
||||
}
|
||||
|
||||
void dc_enable_dynarec(bool enable)
|
||||
{
|
||||
#if FEAT_SHREC != DYNAREC_NONE
|
||||
continue_running = true;
|
||||
new_dynarec_setting = enable;
|
||||
dc_stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
void cleanup_serialize(void *data)
|
||||
{
|
||||
if ( data != NULL )
|
||||
free(data) ;
|
||||
|
||||
performed_serialization = true ;
|
||||
dc_start() ;
|
||||
continue_running = true ;
|
||||
mtx_serialization.Unlock() ;
|
||||
mtx_mainloop.Unlock() ;
|
||||
|
||||
|
@ -667,8 +694,7 @@ void* dc_savestate_thread(void* p)
|
|||
if ( !acquire_mainloop_lock() )
|
||||
{
|
||||
printf("Failed to save state - could not acquire main loop lock\n") ;
|
||||
performed_serialization = true ;
|
||||
dc_start() ;
|
||||
continue_running = true ;
|
||||
mtx_serialization.Unlock() ;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -736,8 +762,7 @@ void* dc_loadstate_thread(void* p)
|
|||
if ( !acquire_mainloop_lock() )
|
||||
{
|
||||
printf("Failed to load state - could not acquire main loop lock\n") ;
|
||||
performed_serialization = true ;
|
||||
dc_start() ;
|
||||
continue_running = true ;
|
||||
mtx_serialization.Unlock() ;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -104,6 +104,9 @@ PCHAR*
|
|||
}
|
||||
|
||||
void dc_stop(void);
|
||||
void dc_savestate();
|
||||
void dc_loadstate();
|
||||
void dc_enable_dynarec(bool enable);
|
||||
|
||||
bool VramLockedWrite(u8* address);
|
||||
bool ngen_Rewrite(unat& addr,unat retadr,unat acc);
|
||||
|
@ -253,8 +256,13 @@ void UpdateInputState(u32 port)
|
|||
if (GetAsyncKeyState(VK_F1))
|
||||
settings.pvr.ta_skip = 100;
|
||||
|
||||
// if (GetAsyncKeyState(VK_F2))
|
||||
// settings.pvr.ta_skip = 0;
|
||||
if (GetAsyncKeyState(VK_F2))
|
||||
settings.pvr.ta_skip = 0;
|
||||
dc_savestate();
|
||||
if (GetAsyncKeyState(VK_F4))
|
||||
dc_loadstate();
|
||||
|
||||
|
||||
if (GetAsyncKeyState(VK_F10))
|
||||
DiscSwap();
|
||||
|
@ -264,9 +272,8 @@ void UpdateInputState(u32 port)
|
|||
coin_chute = GetAsyncKeyState(VK_F8);
|
||||
naomi_test_button = GetAsyncKeyState(VK_F7);
|
||||
#endif
|
||||
// also Naomi service button
|
||||
if (GetAsyncKeyState(VK_F6))
|
||||
kcode[port] &= ~key_CONT_C;
|
||||
dc_enable_dynarec(settings.dynarec.Enable == 0);
|
||||
}
|
||||
|
||||
void UpdateController(u32 port)
|
||||
|
|
Loading…
Reference in New Issue