The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (Linux)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working on an custom FPS Limiter
05-09-2013, 10:42 PM (This post was last modified: 05-09-2013 10:55 PM by makotech222.)
Post: #1
Working on an custom FPS Limiter
Started today on my first project for PPSSPP, which is a user-set fps limiter. I'm somewhat of a beginner with C++, and this is my first time contributing to an open source project. So please, give me a lot of feedback on my problem. Here goes:

My first step is to toggle between 3 different states for the fps limiter: #1 is default 60 fps, #2 is user set limit, #3 is unlimited (unthrottle). I re-purposed the code for the unthrottle button (which involved pressing 'tab') to toggle between the states.

The problem arises with pressed the tab button and toggling the states. At the moment, it is very unreliable, and i can't figure out why. If i press the tab button, it will SOMETIMES toggle between the states, in a random order. For example, it will switch from 1 to 3, or 2 to 1, when it should be 1 ->2 -> 3. Sometimes, the button doesn't do anything at all. My initial assumption is that every time i press the button, the emulator doesn't necessarily update, or it takes the input once and counts it more than once. So, without furthur ado, here's my code so far:

Quote:
in EmuScreen.cpp
under void EmuScreen::update(InputState &input)

// Make sure fpsLimit starts at 0
if (PSP_CoreParameter().fpsLimit != 0 && PSP_CoreParameter().fpsLimit != 1 && PSP_CoreParameter().fpsLimit != 2) {
PSP_CoreParameter().fpsLimit = 0;
}

//Toggle between 3 different states of fpsLimit
if (input.pad_buttons & PAD_BUTTON_LEFT_THUMB) {
if (PSP_CoreParameter().fpsLimit == 0){
PSP_CoreParameter().fpsLimit = 1;
}
else if (PSP_CoreParameter().fpsLimit == 1){
PSP_CoreParameter().fpsLimit = 2;
}
else if (PSP_CoreParameter().fpsLimit == 2){
PSP_CoreParameter().fpsLimit = 0;
}
}

and also

Quote:in sceDisplay.cpp
under void DoFrameTiming(bool &throttle, bool &skipFrame, int &fpsLimiter)

if (fpsLimiter == 0) {
nextFrameTime = std::max(nextFrameTime + 1.0 / 60.0, time_now_d() - maxFallBehindFrames / 60.0);
} else if (fpsLimiter == 1) {
nextFrameTime = std::max(nextFrameTime + 1.0 / 120.0, time_now_d() - maxFallBehindFrames / 120.0);
} else if (fpsLimiter == 2) {
nextFrameTime = std::max(nextFrameTime + 1.0 / 200.0, time_now_d() - maxFallBehindFrames / 200.0);
}
else {
nextFrameTime = nextFrameTime + 1.0 / 60;
}

I think if i can change "if (input.pad_buttons & PAD_BUTTON_LEFT_THUMB) "

to something that only triggers only once when pressed (this triggers when held) that it might fix it.


Edit: Aha yes! I was right, changed input.pad_buttons to input.pad_buttons_down. Works perfect now Smile

Next step is to add a UI option to enter an fps limit. Not sure where to start, but i'm sure ill get there eventually. Some help would be nice though Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Working on an custom FPS Limiter - makotech222 - 05-09-2013 10:42 PM

Forum Jump: