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.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

22 linhas
499B

  1. #include <time.h>
  2. #include "time.h"
  3. #include <SDL2/SDL.h>
  4. void time_get(struct timespec* ts) {
  5. uint64_t time = SDL_GetTicks64();
  6. ts->tv_sec = time / 1000U;
  7. ts->tv_nsec = (time % 1000U) * 1000U * 1000U;
  8. }
  9. void time_sleep_until(const struct timespec* ts) {
  10. uint64_t t_target = ( (ts->tv_sec * 1000ULL) +
  11. (ts->tv_nsec / (1000U * 1000U)));
  12. uint64_t t_now = SDL_GetTicks64();
  13. if (t_target > t_now) {
  14. SDL_Delay(t_target - t_now);
  15. }
  16. }