Skip to content

Commit 4569d36

Browse files
committed
rg_system: Added a better workaround to correctly calculate statistics when overclocked
This is still a bad/lazy fix, the real solution is to add a function that always returns wall time and use it instead of rg_system_timer() where appropriate. But the few ways I found to do this within esp-idf are very surprisingly slow to call.
1 parent 327a588 commit 4569d36

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

components/retro-go/rg_system.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ static void update_statistics(void)
199199

200200
if (counters.ticks && previous.ticks)
201201
{
202+
const float usPerSecond = 1000000.f * (overclockMhz ? overclockMhz / 240.f : 1.f);
202203
float totalTime = counters.updateTime - previous.updateTime;
203-
float totalTimeSecs = totalTime / 1000000.f;
204+
float totalTimeSecs = totalTime / usPerSecond;
204205
float busyTime = counters.busyTime - previous.busyTime;
205206
float ticks = counters.ticks - previous.ticks;
206207
float fullFrames = counters.fullFrames - previous.fullFrames;
@@ -1197,11 +1198,6 @@ void rg_system_set_overclock(int level)
11971198
// ets_update_cpu_frequency(real_mhz);
11981199
#endif
11991200

1200-
// This is a lazy hack to report a more accurate emulation speed. Obviously this isn't a real solution.
1201-
static int original_tickRate = 0;
1202-
if (!original_tickRate)
1203-
original_tickRate = app.tickRate;
1204-
app.tickRate = original_tickRate * (240.f / real_mhz);
12051201
app.frameskip = 1;
12061202

12071203
overclockLevel = level;

0 commit comments

Comments
 (0)