From 4e9dcd7fcb8c6710b343f81ff89d691a0fd1a5e6 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 25 Oct 2011 01:44:12 +0300 Subject: [PATCH] drc: fix cycle multiplier code rounding wrong way is enough to cause nasty timing problems --- libpcsxcore/new_dynarec/new_dynarec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 5e6e66e6..fb39cf09 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -44,9 +44,6 @@ #define MAXBLOCK 4096 #define MAX_OUTPUT_BLOCK_SIZE 262144 -int cycle_multiplier; // 100 for 1.0 -#define CLOCK_ADJUST(x) (((x) * cycle_multiplier + 50) / 100) - struct regstat { signed char regmap_entry[HOST_REGS]; @@ -279,6 +276,14 @@ int tracedebug=0; //#define DEBUG_CYCLE_COUNT 1 +int cycle_multiplier; // 100 for 1.0 + +static int CLOCK_ADJUST(int x) +{ + int s=(x>>31)|1; + return (x * cycle_multiplier + s * 50) / 100; +} + static void tlb_hacks() { #ifndef DISABLE_TLB -- 2.39.5