mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-27 03:31:49 +01:00
Allow more fine-grained overclocking
Some games can benefit from a little overclocking but start behaving strangely at 2x. Make the internal overclock ratio a fixed point number and add 3 fractional settings.
This commit is contained in:
parent
82d83c43ec
commit
f3e0641b1b
@ -441,7 +441,8 @@ LIBRETRO_CFLAGS += $(BPP_DEFINES) \
|
|||||||
$(PLATFORM_DEFINES) \
|
$(PLATFORM_DEFINES) \
|
||||||
-D__LIBRETRO__ \
|
-D__LIBRETRO__ \
|
||||||
-DM68K_ALLOW_OVERCLOCK \
|
-DM68K_ALLOW_OVERCLOCK \
|
||||||
-DZ80_ALLOW_OVERCLOCK
|
-DZ80_ALLOW_OVERCLOCK \
|
||||||
|
-DCYCLE_SHIFT=10
|
||||||
|
|
||||||
ifneq (,$(findstring msvc,$(platform)))
|
ifneq (,$(findstring msvc,$(platform)))
|
||||||
LIBRETRO_CFLAGS += -DINLINE="static _inline"
|
LIBRETRO_CFLAGS += -DINLINE="static _inline"
|
||||||
|
@ -269,7 +269,7 @@ typedef struct
|
|||||||
uint address_space; /* Current FC code */
|
uint address_space; /* Current FC code */
|
||||||
|
|
||||||
#ifdef M68K_ALLOW_OVERCLOCK
|
#ifdef M68K_ALLOW_OVERCLOCK
|
||||||
uint8 overclock_ratio;
|
int cycle_ratio;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Callbacks to host */
|
/* Callbacks to host */
|
||||||
|
@ -320,7 +320,7 @@ void m68k_init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef M68K_ALLOW_OVERCLOCK
|
#ifdef M68K_ALLOW_OVERCLOCK
|
||||||
m68k.overclock_ratio = 1;
|
m68k.cycle_ratio = 1 << CYCLE_SHIFT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if M68K_EMULATE_INT_ACK == OPT_ON
|
#if M68K_EMULATE_INT_ACK == OPT_ON
|
||||||
|
@ -515,7 +515,7 @@
|
|||||||
/* ---------------------------- Cycle Counting ---------------------------- */
|
/* ---------------------------- Cycle Counting ---------------------------- */
|
||||||
|
|
||||||
#ifdef M68K_ALLOW_OVERCLOCK
|
#ifdef M68K_ALLOW_OVERCLOCK
|
||||||
#define USE_CYCLES(A) m68ki_cpu.cycles += (A) / m68ki_cpu.overclock_ratio
|
#define USE_CYCLES(A) m68ki_cpu.cycles += ((A) * m68ki_cpu.cycle_ratio) >> CYCLE_SHIFT
|
||||||
#else
|
#else
|
||||||
#define USE_CYCLES(A) m68ki_cpu.cycles += (A)
|
#define USE_CYCLES(A) m68ki_cpu.cycles += (A)
|
||||||
#endif
|
#endif
|
||||||
|
@ -285,7 +285,7 @@ void s68k_init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef M68K_ALLOW_OVERCLOCK
|
#ifdef M68K_ALLOW_OVERCLOCK
|
||||||
s68k.overclock_ratio = 1;
|
s68k.cycle_ratio = 1 << CYCLE_SHIFT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if M68K_EMULATE_INT_ACK == OPT_ON
|
#if M68K_EMULATE_INT_ACK == OPT_ON
|
||||||
|
@ -202,7 +202,7 @@
|
|||||||
#define HALT Z80.halt
|
#define HALT Z80.halt
|
||||||
|
|
||||||
#ifdef Z80_ALLOW_OVERCLOCK
|
#ifdef Z80_ALLOW_OVERCLOCK
|
||||||
#define USE_CYCLES(A) Z80.cycles += (A) / z80_overclock_ratio
|
#define USE_CYCLES(A) Z80.cycles += ((A) * z80_cycle_ratio) >> CYCLE_SHIFT
|
||||||
#else
|
#else
|
||||||
#define USE_CYCLES(A) Z80.cycles += (A)
|
#define USE_CYCLES(A) Z80.cycles += (A)
|
||||||
#endif
|
#endif
|
||||||
@ -210,7 +210,7 @@
|
|||||||
Z80_Regs Z80;
|
Z80_Regs Z80;
|
||||||
|
|
||||||
#ifdef Z80_ALLOW_OVERCLOCK
|
#ifdef Z80_ALLOW_OVERCLOCK
|
||||||
UINT8 z80_overclock_ratio;
|
UINT32 z80_cycle_ratio;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned char *z80_readmap[64];
|
unsigned char *z80_readmap[64];
|
||||||
@ -3369,7 +3369,7 @@ void z80_init(const void *config, int (*irqcallback)(int))
|
|||||||
Z80.daisy = config;
|
Z80.daisy = config;
|
||||||
Z80.irq_callback = irqcallback;
|
Z80.irq_callback = irqcallback;
|
||||||
#ifdef Z80_ALLOW_OVERCLOCK
|
#ifdef Z80_ALLOW_OVERCLOCK
|
||||||
z80_overclock_ratio = 1;
|
z80_cycle_ratio = 1 << CYCLE_SHIFT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Clear registers values (NB: should be random on real hardware ?) */
|
/* Clear registers values (NB: should be random on real hardware ?) */
|
||||||
|
@ -52,7 +52,7 @@ typedef struct
|
|||||||
extern Z80_Regs Z80;
|
extern Z80_Regs Z80;
|
||||||
|
|
||||||
#ifdef Z80_ALLOW_OVERCLOCK
|
#ifdef Z80_ALLOW_OVERCLOCK
|
||||||
extern UINT8 z80_overclock_ratio;
|
extern UINT32 z80_cycle_ratio;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern unsigned char *z80_readmap[64];
|
extern unsigned char *z80_readmap[64];
|
||||||
|
@ -1257,10 +1257,17 @@ static void check_variables(void)
|
|||||||
var.key = "genesis_plus_gx_overclock";
|
var.key = "genesis_plus_gx_overclock";
|
||||||
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
|
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
|
||||||
{
|
{
|
||||||
if (strcmp(var.value, "1x") == 0)
|
/* Cycle ratios multiply cycle count, so use reciprocal */
|
||||||
config.overclock = 0;
|
if (strcmp(var.value, "100%") == 0)
|
||||||
else if (strcmp(var.value, "2x") == 0)
|
config.overclock = (100 << CYCLE_SHIFT)/100;
|
||||||
config.overclock = 1;
|
else if (strcmp(var.value, "125%") == 0)
|
||||||
|
config.overclock = (100 << CYCLE_SHIFT)/125;
|
||||||
|
else if (strcmp(var.value, "150%") == 0)
|
||||||
|
config.overclock = (100 << CYCLE_SHIFT)/150;
|
||||||
|
else if (strcmp(var.value, "175%") == 0)
|
||||||
|
config.overclock = (100 << CYCLE_SHIFT)/175;
|
||||||
|
else if (strcmp(var.value, "200%") == 0)
|
||||||
|
config.overclock = (100 << CYCLE_SHIFT)/200;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1709,7 +1716,7 @@ void retro_set_environment(retro_environment_t cb)
|
|||||||
{ "genesis_plus_gx_gun_cursor", "Show Lightgun crosshair; disabled|enabled" },
|
{ "genesis_plus_gx_gun_cursor", "Show Lightgun crosshair; disabled|enabled" },
|
||||||
{ "genesis_plus_gx_invert_mouse", "Invert Mouse Y-axis; disabled|enabled" },
|
{ "genesis_plus_gx_invert_mouse", "Invert Mouse Y-axis; disabled|enabled" },
|
||||||
#ifdef HAVE_OVERCLOCK
|
#ifdef HAVE_OVERCLOCK
|
||||||
{ "genesis_plus_gx_overclock", "Overclock CPU; 1x|2x" },
|
{ "genesis_plus_gx_overclock", "CPU speed; 100%|125%|150%|175%|200%" },
|
||||||
#endif
|
#endif
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
@ -2360,30 +2367,30 @@ void retro_run(void)
|
|||||||
if (system_hw == SYSTEM_MCD)
|
if (system_hw == SYSTEM_MCD)
|
||||||
{
|
{
|
||||||
#ifdef M68K_ALLOW_OVERCLOCK
|
#ifdef M68K_ALLOW_OVERCLOCK
|
||||||
if (config.overclock && overclock_delay == 0)
|
if (overclock_delay == 0)
|
||||||
m68k.overclock_ratio = 2;
|
m68k.cycle_ratio = config.overclock;
|
||||||
else
|
else
|
||||||
m68k.overclock_ratio = 1;
|
m68k.cycle_ratio = 1 << CYCLE_SHIFT;
|
||||||
#endif
|
#endif
|
||||||
system_frame_scd(0);
|
system_frame_scd(0);
|
||||||
}
|
}
|
||||||
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||||
{
|
{
|
||||||
#ifdef M68K_ALLOW_OVERCLOCK
|
#ifdef M68K_ALLOW_OVERCLOCK
|
||||||
if (config.overclock && overclock_delay == 0)
|
if (overclock_delay == 0)
|
||||||
m68k.overclock_ratio = 2;
|
m68k.cycle_ratio = config.overclock;
|
||||||
else
|
else
|
||||||
m68k.overclock_ratio = 1;
|
m68k.cycle_ratio = 1 << CYCLE_SHIFT;
|
||||||
#endif
|
#endif
|
||||||
system_frame_gen(0);
|
system_frame_gen(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef Z80_ALLOW_OVERCLOCK
|
#ifdef Z80_ALLOW_OVERCLOCK
|
||||||
if (config.overclock && overclock_delay == 0)
|
if (overclock_delay == 0)
|
||||||
z80_overclock_ratio = 2;
|
z80_cycle_ratio = config.overclock;
|
||||||
else
|
else
|
||||||
z80_overclock_ratio = 1;
|
z80_cycle_ratio = 1 << CYCLE_SHIFT;
|
||||||
#endif
|
#endif
|
||||||
system_frame_sms(0);
|
system_frame_sms(0);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ struct
|
|||||||
t_input_config input[MAX_INPUTS];
|
t_input_config input[MAX_INPUTS];
|
||||||
uint8 invert_mouse;
|
uint8 invert_mouse;
|
||||||
uint8 gun_cursor;
|
uint8 gun_cursor;
|
||||||
uint8 overclock;
|
uint32 overclock;
|
||||||
} config;
|
} config;
|
||||||
|
|
||||||
extern char GG_ROM[256];
|
extern char GG_ROM[256];
|
||||||
|
Loading…
Reference in New Issue
Block a user