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
05-10-2013, 12:15 AM
Post: #2
RE: Working on an custom FPS Limiter
great!!
Find all posts by this user
Quote this message in a reply
05-10-2013, 02:20 AM
Post: #3
RE: Working on an custom FPS Limiter
This feature already have on ffmpeg builds. Soon will added to master build.

Phones: Poco F3 8GB/256GB (Snapdragon 870 5G) and Redmi Note 6 Pro 4/64GB (Snapdragon 636)

PC: AMD Ryzen 5 3600 / 16GB RAM DDR4 3600MHz / NVIDIA GTX 1660 Ti 6GB / Windows 10 Pro
Find all posts by this user
Quote this message in a reply
05-10-2013, 03:47 AM
Post: #4
RE: Working on an custom FPS Limiter
(05-10-2013 02:20 AM)GuilhermeGS2 Wrote:  This feature already have on ffmpeg builds. Soon will added to master build.

Oh man, you gotta be kidding me. I spent like 5 hours on it today lmao
Find all posts by this user
Quote this message in a reply
05-10-2013, 05:43 AM (This post was last modified: 05-10-2013 05:45 AM by livisor.)
Post: #5
RE: Working on an custom FPS Limiter
I will still rep you for your effort!It's a great way to improve your skills:-)
Find all posts by this user
Quote this message in a reply
05-10-2013, 05:59 AM
Post: #6
RE: Working on an custom FPS Limiter
I think the way you implemented it is different, though.

-[Unknown]
Find all posts by this user
Quote this message in a reply
05-10-2013, 06:00 AM
Post: #7
RE: Working on an custom FPS Limiter
(05-10-2013 05:59 AM)[Unknown] Wrote:  I think the way you implemented it is different, though.

-[Unknown]

In a good or bad way?If it's better I don't see why we couldn't use his version :-p
Find all posts by this user
Quote this message in a reply
05-10-2013, 07:00 AM (This post was last modified: 05-10-2013 07:01 AM by [Unknown].)
Post: #8
RE: Working on an custom FPS Limiter
I think the other way was a fixed option. For example, you could go and select "90 vps" as "the speed the game ought to run at."

This is togglable. So, you basically set a max speed for fast forward to go at, and press the button to toggle it on/off/etc. This can actually be a nice feature for using it to play games - set it to 90 vps or 120 vps to get through slow sequences, and toggle back to regular speed for action sequences, etc. Without having to go back and forth through the menu.

That said, I'm kinda used to holding the tab button religiously while testing most games, so it'd take a lot of getting used to for me, heh. But I do think it's probably a good change for *playing* games.

-[Unknown]
Find all posts by this user
Quote this message in a reply
05-10-2013, 08:22 AM
Post: #9
RE: Working on an custom FPS Limiter
I made an issue on GitHub 11 days ago about this : https://github.com/hrydgard/ppsspp/issues/1581 Wink

♦ Intel Core i7-6700HQ | 16 GB RAM | NVIDIA GeForce GTX 960M | Debian Testing
♦ Intel Core i7-2630QM | 4 GB RAM | NVIDIA GeForce GT 540M | Debian Testing
♦ PSP-3004 | 6.60 PRO-C2
Find all posts by this user
Quote this message in a reply
05-10-2013, 01:50 PM
Post: #10
RE: Working on an custom FPS Limiter
So whats the difference between the two implementations? Should i continue developing mine? I tried to make mine like epsxe's implementation, which gives the 3 states, one to play fmvs and hard battles, second to play most of the game at, and third to just blast through everything as fast as possible Wink
Find all posts by this user
Quote this message in a reply
05-10-2013, 02:22 PM
Post: #11
RE: Working on an custom FPS Limiter
The unlocked vps will be the best friend for psx-p emulator(and not only),i can run einhander and many other ps1 games without holding tab at a decent speed(over 30-45 vps) on windows Big Grin
Find all posts by this user
Quote this message in a reply
05-10-2013, 02:57 PM
Post: #12
RE: Working on an custom FPS Limiter
(05-10-2013 02:22 PM)sfageas Wrote:  The unlocked vps will be the best friend for psx-p emulator(and not only),i can run einhander and many other ps1 games without holding tab at a decent speed(over 30-45 vps) on windows Big Grin

i cant see unlock vps feature on android,is for windows only?
Find all posts by this user
Quote this message in a reply
05-10-2013, 03:27 PM
Post: #13
RE: Working on an custom FPS Limiter
Probably windows only. I think i recall someone saying that android has locked vsync.
Find all posts by this user
Quote this message in a reply
05-10-2013, 03:35 PM
Post: #14
RE: Working on an custom FPS Limiter
so is impossible?
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: