laanwj / sundog

A port of the Atari ST game SunDog: Frozen Legacy (1984) by FTL software

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go back to msleep

laanwj opened this issue · comments

Recently I implemented my own util_usleep function as it seems fine enough precision, but usleep is deprecated in POSIX. In POSIX it can be easily implemented in terms of nanosleep.

However, usleep implementation on Windows is absolutely bonkers. I'm not sure it actually works that well.

We don't really need sub-millisecond precision waiting. Waiting is used for:

  • Input delays (to compensate for the speed of the emulation). These are larger delays, in terms of milliseconds.
  • Wowzo animation, to make the speed of the hyperspace animation approximate the Atari ST speed. These are smaller delays (in terms of 68000 DIV instructions). it's pointless to wait less than a frame. It would be better solved by accumulating delays and waiting a frame when needed. Or some fraction of a frame.