From 31d5f080dc5456d83b081635ca2869ea88fd5dce Mon Sep 17 00:00:00 2001 From: gocha Date: Sun, 6 Sep 2009 00:16:20 +0000 Subject: [PATCH] add hidden LagReduction option --- src/armcpu.cpp | 43 +++++++++++++++++++++++-------------------- src/windows/main.cpp | 6 ++++++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/armcpu.cpp b/src/armcpu.cpp index aea747307..757024471 100644 --- a/src/armcpu.cpp +++ b/src/armcpu.cpp @@ -494,46 +494,49 @@ armcpu_flagIrq( armcpu_t *armcpu) { return TRUE; } +bool fixCycleCount = false; template u32 armcpu_exec() { - u32 c = 1; + u32 c = fixCycleCount ? 0 : 1; - //this assert is annoying. but sometimes it is handy. - //assert(ARMPROC.instruct_adr!=0x00000000); + //this assert is annoying. but sometimes it is handy. + //assert(ARMPROC.instruct_adr!=0x00000000); #ifdef GDB_STUB - if (ARMPROC.stalled) - return STALLED_CYCLE_COUNT; + if (ARMPROC.stalled) + return STALLED_CYCLE_COUNT; - /* check for interrupts */ - if ( ARMPROC.irq_flag) { - armcpu_irqException( &ARMPROC); - } + /* check for interrupts */ + if ( ARMPROC.irq_flag) { + armcpu_irqException( &ARMPROC); + } - c = armcpu_prefetch(&ARMPROC); + c += armcpu_prefetch(&ARMPROC); - if ( ARMPROC.stalled) { - return c; - } + if ( ARMPROC.stalled) { + return c; + } #endif if(ARMPROC.CPSR.bits.T == 0) { - if((TEST_COND(CONDITION(ARMPROC.instruction), CODE(ARMPROC.instruction), ARMPROC.CPSR))) + if((TEST_COND(CONDITION(ARMPROC.instruction), CODE(ARMPROC.instruction), ARMPROC.CPSR))) { if(PROCNUM==0) { #ifdef WANTASMLISTING - char txt[128]; + char txt[128]; des_arm_instructions_set[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruct_adr,ARMPROC.instruction,txt); printf("%X: %X - %s\n", ARMPROC.instruct_adr,ARMPROC.instruction, txt); #endif c += arm_instructions_set_0[INSTRUCTION_INDEX(ARMPROC.instruction)](); - } + } else c += arm_instructions_set_1[INSTRUCTION_INDEX(ARMPROC.instruction)](); } + else if (fixCycleCount) + c++; #ifdef GDB_STUB if ( ARMPROC.post_ex_fn != NULL) { /* call the external post execute function */ @@ -552,10 +555,10 @@ u32 armcpu_exec() c += thumb_instructions_set_1[ARMPROC.instruction>>6](); #ifdef GDB_STUB - if ( ARMPROC.post_ex_fn != NULL) { - /* call the external post execute function */ - ARMPROC.post_ex_fn( ARMPROC.post_ex_fn_data, ARMPROC.instruct_adr, 1); - } + if ( ARMPROC.post_ex_fn != NULL) { + /* call the external post execute function */ + ARMPROC.post_ex_fn( ARMPROC.post_ex_fn_data, ARMPROC.instruct_adr, 1); + } #else c += armcpu_prefetch(); #endif diff --git a/src/windows/main.cpp b/src/windows/main.cpp index 2b392da79..dae0c235c 100644 --- a/src/windows/main.cpp +++ b/src/windows/main.cpp @@ -1508,6 +1508,9 @@ int _main() GetPrivateProfileString("Watches", str, "", &rw_recent_files[i][0], 1024, IniName); } + extern bool fixCycleCount; + fixCycleCount = GetPrivateProfileInt("Timings", "LagReduction", 0, IniName) != 0; + //i think we should override the ini file with anything from the commandline CommandLine cmdline; cmdline.loadCommonOptions(); @@ -2684,6 +2687,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM sprintf(str, "Recent Watch %d", i+1); WritePrivateProfileString("Watches", str, &rw_recent_files[i][0], IniName); } + + extern bool fixCycleCount; + WritePrivateProfileInt("Timings", "LagReduction", fixCycleCount, IniName); ExitRunLoop(); }