From 98da3a28dccb455b890c6b375b139c5a729f5519 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 23 Sep 2018 12:04:07 +0200 Subject: [PATCH] rec-x86: Load PC from sh4 context in ngen_mainloop Fixes load state freeze and problems when pausing the emu thread --- core/rec-x86/rec_lin86_asm.S | 5 ++++- core/rec-x86/rec_x86_asm.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/rec-x86/rec_lin86_asm.S b/core/rec-x86/rec_lin86_asm.S index cfb1c800f..a8d8d42a6 100644 --- a/core/rec-x86/rec_lin86_asm.S +++ b/core/rec-x86/rec_lin86_asm.S @@ -93,7 +93,10 @@ ngen_mainloop: push ebp push ebx - mov ecx,[0xA0000000] # PC + mov ecx, [p_sh4rcb] + add ecx, [nextpc_offset] + mov ecx, [ecx] + mov dword ptr cycle_counter, 448 #SH4_TIMESLICE lea eax, no_update diff --git a/core/rec-x86/rec_x86_asm.cpp b/core/rec-x86/rec_x86_asm.cpp index a780b94b4..2572b7f3f 100644 --- a/core/rec-x86/rec_x86_asm.cpp +++ b/core/rec-x86/rec_x86_asm.cpp @@ -60,6 +60,7 @@ naked void ngen_FailedToFindBlock_() } const u32 cpurun_offset=offsetof(Sh4RCB,cntx.CpuRunning); +const u32 nextpc_offset=offsetof(Sh4RCB,cntx.pc); void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; naked void ngen_mainloop(void* cntx) @@ -71,7 +72,10 @@ naked void ngen_mainloop(void* cntx) push ebp; push ebx; - mov ecx,0xA0000000; + mov ecx, [p_sh4rcb]; + add ecx, [nextpc_offset]; + mov ecx, [ecx]; + mov [cycle_counter],SH4_TIMESLICE; mov [loop_no_update],offset no_update; @@ -133,6 +137,7 @@ naked void DYNACALL ngen_blockcheckfail2(u32 addr) #else u32 gas_offs=offsetof(Sh4RCB,cntx.jdyn); u32 cpurun_offset=offsetof(Sh4RCB,cntx.CpuRunning); + u32 nextpc_offset=offsetof(Sh4RCB,cntx.pc); void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; #endif #endif