Forum > Games

High precision timing

(1/2) > >>

Rave:
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.

taazz:
That's impossible as far as I know. Even the hardware PIT on intel CPUs is around 1.2Mhz which is lower than your current requirements, I doubt you will find anything less than 10ms (aka 100hz) interval. You probably should change your requirements from executing 1.5 millions time a second, to swap the execution 100 times a second.

Rave:
How will I emulate properly a 1.5MHz system properly then?

rvk:
On Windows you can go somewhat more accurate (to 1ms) than TTimer with timeSetEvent() (it's defined in mmsystem).

You also might whip up your own timer in a thread using QueryPerformanceFrequency and QueryPerformanceCounter. Although I'm not sure how accurate you can go (could depend on the cpu) and how cpu-intensive that will be.

marcov:

--- Quote from: Rave on March 10, 2018, 03:17:38 pm ---How will I emulate properly a 1.5MHz system properly then?

--- End quote ---

Time sequences large than 1 instruction, and pause after them to make the timing work.

This will require to identify writes to memory mapped memory hardware (like keyboard/mouse/joystick handling and audio/video) and emulate them, but usually these are known for old systems

Navigation

[0] Message Index

[#] Next page

Go to full version