#include #include #include #include #include #include #include #include #include #include #include "defines.h" #include "utils.h" #include "api.h" /////////////////////////////////////// #include static uint64_t GFX_getTicks(void) { uint64_t ret; struct timeval tv; gettimeofday(&tv, NULL); ret = (uint64_t)tv.tv_sec * 1000000; ret += (uint64_t)tv.tv_usec; return ret; } int main (int argc, char *argv[]) { SDL_Surface* screen = GFX_init(); PAD_reset(); int quit = 0; while (!quit) { // unsigned long frame_start = SDL_GetTicks(); uint64_t frame_start_us = GFX_getTicks(); PAD_poll(); if (PAD_anyPressed()) break; // TODO: diagnosing framepacing issues static int frame = 0; int x = frame * 8; void* dst; dst = screen->pixels; memset(dst, (frame%2)?0x00:0xff, (SCREEN_HEIGHT * SCREEN_PITCH)); // memset(dst, 0, (16 * SCREEN_PITCH)); // for (int y=0; y<16; y++) { // memset(dst+(8 * 60 * SCREEN_BPP), 0xff, SCREEN_BPP); // dst += SCREEN_PITCH; // } // // dst = screen->pixels; // dst += (x * SCREEN_BPP); // // for (int y=0; y<16; y++) { // memset(dst, 0xff, 8 * SCREEN_BPP); // dst += SCREEN_PITCH; // } frame += 1; if (frame>=60) frame -= 60; GFX_flip(screen); // SDL_Delay(500); // slow down to 60fps // unsigned long frame_duration = SDL_GetTicks() - frame_start; uint64_t frame_duration_us = GFX_getTicks() - frame_start_us; // #define TARGET_FRAME_DURATION 17 #define TARGET_FRAME_DURATION_US 16666 // if (frame_duration