Lazarus

Miscellaneous => Other => Topic started by: Rave on March 10, 2018, 01:40:01 pm

Title: Precise timer for gaming applications?
Post by: Rave 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.
Title: Re: Precise timer for gaming applications?
Post by: Ñuño_Martínez 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 (http://allegro-pas.sourceforge.net/docs/5.2/lib/Allegro5.html#al_create_timer), 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).
Title: Re: Precise timer for gaming applications?
Post by: User137 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.
TinyPortal © 2005-2018