Trying to get the FPS limit

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Trying to get the FPS limit

Post by MihaiGamerXD » August 24th, 2019, 4:02 am

Hi PSXDev!
I'm trying to get the FPS limit, and I can't find out in "LIBREF46.PDF".
Just use something like this: "FntPrint("%s",getFPS())".
Is it possible?

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » August 24th, 2019, 8:20 am

Found out for myself how to get.

Code: Select all

"FntPrint(~c666%d",VSync(0));
And it gives me 14 FPS?! :shock: How can I set it back to 60 FPS?

User avatar
LameGuy64
Verified
Psy-Q Enthusiast
Psy-Q Enthusiast
Posts: 388
Joined: Apr 10, 2013
I am a: Hobbyist Game Developer
Motto: Commercial or not, play it!
PlayStation Model: H2000/7000
Location: Philippines
Contact:

Post by LameGuy64 » August 24th, 2019, 12:33 pm

You need to install a VSync callback which will run a counter, and update a variable that will be your FPS from a variable that is updated constantly on every screen update.

Code: Select all

volatile int fps;
volatile int fps_counter;
volatile int fps_measure;

void vsync_cb(void) {

    fps_counter++;
    if( fps_counter > 60 ) {
        fps = fps_measure;
        fps_measure = 0;
        fps_counter = 0;
    }

}

int main() {

    ...
    
    VSyncCallback(vsync_cb);

    while(1) {

        ...

        < your display update code >

        fps_measure++;

        ...

    }
    ...
}

fps will contain the frames per second your application is running at, updated every second.
Please don't forget to include my name if you share my work around. Credit where it is due.

Dev. Console: SCPH-7000 with SCPH-7501 ROM, MM3, PAL color fix, Direct AV ports, DB-9 port for Serial I/O, and a Xplorer FX with Caetla 0.35.

DTL-H2000 PC: Dell Optiplex GX110, Windows 98SE & Windows XP, Pentium III 933MHz, 384MB SDRAM, ATI Radeon 7000 VE 64MB, Soundblaster Audigy, 40GB Seagate HDD, Hitachi Lite-on CD-RW Drive, ZIP 250 and 3.5" Floppy.

User avatar
MihaiGamerXD
Active PSXDEV User
Active PSXDEV User
Posts: 38
Joined: Mar 09, 2019
I am a: Programmer
PlayStation Model: SCPH-1001

Post by MihaiGamerXD » August 24th, 2019, 10:56 pm

LameGuy64 wrote: August 24th, 2019, 12:33 pm You need to install a VSync callback which will run a counter, and update a variable that will be your FPS from a variable that is updated constantly on every screen update.

Code: Select all

volatile int fps;
volatile int fps_counter;
volatile int fps_measure;

void vsync_cb(void) {

    fps_counter++;
    if( fps_counter > 60 ) {
        fps = fps_measure;
        fps_measure = 0;
        fps_counter = 0;
    }

}

int main() {

    ...
    
    VSyncCallback(vsync_cb);

    while(1) {

        ...

        < your display update code >

        fps_measure++;

        ...

    }
    ...
}

fps will contain the frames per second your application is running at, updated every second.
Thanks Lameguy64! It worked, but It works at max 61 FPS, So you'll have to do is to change:

Code: Select all

if( fps_counter > 60 ) {
to:

Code: Select all

if( fps_counter >= 60 ) {
So It will work exactly to 60 FPS. Anyway, thanks.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests