More accurate FPS measurement

This commit is contained in:
Pazaz 2022-04-27 15:11:28 -04:00
parent 0f5da09916
commit 918177a059
3 changed files with 10 additions and 12 deletions

View file

@ -113,7 +113,7 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene
public static int partialRedraws = 500;
@OriginalMember(owner = "client!tk", name = "v", descriptor = "I")
public static int framesPerSecond = 0;
public static double framesPerSecond = 0;
@OriginalMember(owner = "client!te", name = "C", descriptor = "I")
public static int maxMemory = 64;
@ -390,8 +390,6 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene
focus = focusIn;
}
this.mainLoop();
if (previous != 0L && now <= previous) {
}
}
public static GraphicsDevice getCurrentDevice() {
@ -407,16 +405,16 @@ public abstract class GameShell extends Applet implements Runnable, FocusListene
return null;
}
long lastFpsUpdate = 0;
@OriginalMember(owner = "client!rc", name = "e", descriptor = "(I)V")
private void mainRedrawWrapper() {
@Pc(2) long now = MonotonicClock.currentTimeMillis();
@Pc(6) long previous = redrawTimes[redrawTimePointer];
redrawTimes[redrawTimePointer] = now;
redrawTimePointer = redrawTimePointer + 1 & 0x1F;
if (previous != 0L && now > previous) {
@Pc(41) int duration = (int) (now - previous);
framesPerSecond = ((duration >> 1) + 32000) / duration;
long now = System.currentTimeMillis();
if (now - lastFpsUpdate > 250) {
framesPerSecond = 1_000_000_000.0d / (double)renderDelta;
lastFpsUpdate = now;
}
if (partialRedraws++ > 50) {
fullRedraw = true;
partialRedraws -= 50;

View file

@ -290,7 +290,7 @@ public final class Static269 {
if (Cheat.displayFps) {
@Pc(405) int local405 = arg1 + arg2 - 8;
@Pc(412) int local412 = arg0 + arg3 - 5;
Fonts.p12Full.renderRight(JagString.concatenate(new JagString[]{Cheat.DEBUG_FPS, Static123.parseInt(GameShell.framesPerSecond)}), local412, local405, 16776960, -1);
Fonts.p12Full.renderRight(JagString.concatenate(new JagString[]{Cheat.DEBUG_FPS, Static123.parseInt((int)GameShell.framesPerSecond)}), local412, local405, 16776960, -1);
@Pc(434) Runtime runtime = Runtime.getRuntime();
@Pc(443) int memory = (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024L / 1024L);
@Pc(445) int color = 16776960;

View file

@ -304,7 +304,7 @@ public final class Static87 {
}
local270 = local30.anInt445 + local123;
local276 = local114 + 15;
Fonts.p12Full.renderRight(JagString.concatenate(new JagString[] { Cheat.DEBUG_FPS2, Static123.parseInt(GameShell.framesPerSecond) }), local270, local276, 16776960, 0);
Fonts.p12Full.renderRight(JagString.concatenate(new JagString[] { Cheat.DEBUG_FPS2, Static123.parseInt((int)GameShell.framesPerSecond) }), local270, local276, 16776960, 0);
local276 += 15;
@Pc(795) Runtime runtime = Runtime.getRuntime();
memory = (int) ((runtime.totalMemory() - runtime.freeMemory()) / 1024L / 1024L);