Jump to content
  • 0
Sign in to follow this  
CursorKeys

How to detect FPS

Question

Hi!

I am playing with a new little demo and it's running pretty slow now, so optimizations is what I am working on.

So right now I like to check (in numbers) how many FPS (frame per second), I am actually getting.  How do I get a system clock or so, to see how much time has passed?   I haven't done that before on c64/x16 hardware.

Or is there an other way of getting the FPS, something build into the emulator?

 

Sorry if the question is stupid, but it's what I am trying to figure out just now.

Thanks

CC

 

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

The X16 (like many older systems) runs at a constant 60 fps (the emulator may run slower; if so, a percentage of the target speed is displayed in the window title). However, if you aren't using the VSYNC interrupt to drive your code, its speed is not tied to the system framerate. The frame count can be obtained using the TI variable in BASIC, or the RDTIM KERNAL routine.

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Elektron72 said:

The X16 (like many older systems) runs at a constant 60 fps (the emulator may run slower; if so, a percentage of the target speed is displayed in the window title). However, if you aren't using the VSYNC interrupt to drive your code, its speed is not tied to the system framerate. The frame count can be obtained using the TI variable in BASIC, or the RDTIM KERNAL routine.

It's C code mixed with assembly right now, so I'll check out the RDTIM kernal routine.  Just have to see what is stored in the a,x,y registers for result.  I'll play with that,
Thanks for the tip!

 

Edit: Ok, got it, (a+x*256+y*256*256) * 10 => milliseconds since machine was powered on, it seems.

So 1 frame takes me 50 ms to draw it seems, which means I am running at 20 FPS...
Ok, back to optimizing then 🙂

Edited by CursorKeys

Share this post


Link to post
Share on other sites
  • 0
12 minutes ago, CursorKeys said:

Edit: Ok, got it, (a+x*256+y*256*256) * 10 => milliseconds since machine was powered on, it seems.

RDTIM returns in jiffies, or 60ths of a second. If you wanted to convert to milliseconds, you would need to divide by 60 and multiply by 1000.

Share this post


Link to post
Share on other sites
  • 0
8 minutes ago, Elektron72 said:

RDTIM returns in jiffies, or 60ths of a second.

And since OP wants FPS anyway, all he has to do is use the jiffies directly, since they inc++ once per frame anyway.

starttime = RDTIM
<render a few dozen frames (nFrames)>
fps = RDTIM-starttime / nFrames
I'd suggest 64 frames, so you can just do RDTIM-starttime >> 6 to compute FPS

 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

Please review our Terms of Use