Author Topic: Precise timer for gaming applications?  (Read 1997 times)


  • Full Member
  • ***
  • Posts: 160
Precise timer for gaming applications?
« on: March 10, 2018, 01:40:01 pm »
Don't propose EpikTimer, I've already checked it and it's really obtuse to use for what I want it to use.

I need something like TTimer, but one that can execute stuff faster than 1000 times per second, at least 1500000 times per second, with a convenient OnTimer interface. Why? I'm building an emulator so the precise timing is kinda important.


  • Hero Member
  • *****
  • Posts: 867
    • Burdjia
Re: Precise timer for gaming applications?
« Reply #1 on: March 13, 2018, 01:58:45 pm »
1500000 ticks per second is too much and I doubt you'll find a timer with such precision today.  For example, from the Allegro documentation, you can select microseconds (1000000tps) but most drivers allows milliseconds only (1000tps).  Anyway you can't expect to emulate with such precision in modern systems due to multithread and such.

I recommend you to use another event to time your emulation instead of the clock.  For example, most game and home computer emulators use screen retrace (i.e. frames per second) because in most cases you know how many clock cycles executes in each one and it is a rather low frequency (50fps in Europe, 60fps in USA and Japan, etc).
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal


  • Hero Member
  • *****
  • Posts: 1779
    • Nxpascal home
Re: Precise timer for gaming applications?
« Reply #2 on: March 15, 2018, 04:25:52 am »
You don't have to wait a timed event for every emulated tick. Instead you can do them in large bunches based on time that is elapsed between events. One option is to just have a thread running continuously. A timer component is only optional.