NESe (pronounced "Nessie") is a NES emulator based on the e6502 emulator, also written in C with a focus on speed and portability for use on embedded platforms, especially ARM.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 line
376B

  1. #include "timer.h"
  2. #include <SDL2/SDL.h>
  3. time_us time_now(void) {
  4. return (SDL_GetTicks64() * 1000U);
  5. }
  6. void time_sleep(time_us sleep_us) {
  7. SDL_Delay(sleep_us / 1000U);
  8. }
  9. time_us time_sleep_until(time_us t_target) {
  10. time_us t_now = time_now();
  11. time_us t_diff = t_target - t_now;
  12. if (t_diff > 0) {
  13. time_sleep(t_diff);
  14. }
  15. return t_diff;
  16. }