fixed SDL_GetTicks var types
This commit is contained in:
parent
35626e7689
commit
10dd0fe66a
3 changed files with 17 additions and 22 deletions
|
|
@ -136,7 +136,7 @@ int main(int argc , char* argv[]) {
|
||||||
int dirty = 1;
|
int dirty = 1;
|
||||||
int show_setting = 0;
|
int show_setting = 0;
|
||||||
while(!quit) {
|
while(!quit) {
|
||||||
unsigned long frame_start = SDL_GetTicks();
|
uint32_t frame_start = SDL_GetTicks();
|
||||||
|
|
||||||
PAD_poll();
|
PAD_poll();
|
||||||
|
|
||||||
|
|
@ -293,7 +293,7 @@ int main(int argc , char* argv[]) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// slow down to 60fps
|
// slow down to 60fps
|
||||||
unsigned long frame_duration = SDL_GetTicks() - frame_start;
|
uint32_t frame_duration = SDL_GetTicks() - frame_start;
|
||||||
#define kTargetFrameDuration 17
|
#define kTargetFrameDuration 17
|
||||||
if (frame_duration<kTargetFrameDuration) SDL_Delay(kTargetFrameDuration-frame_duration);
|
if (frame_duration<kTargetFrameDuration) SDL_Delay(kTargetFrameDuration-frame_duration);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ void GFX_clearAll(void) {
|
||||||
memset(gfx.map, 0, gfx.map_size);
|
memset(gfx.map, 0, gfx.map_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int frame_start = 0;
|
static uint32_t frame_start = 0;
|
||||||
void GFX_startFrame(void) {
|
void GFX_startFrame(void) {
|
||||||
frame_start = SDL_GetTicks();
|
frame_start = SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
|
@ -784,7 +784,7 @@ static struct PAD_Context {
|
||||||
int just_pressed;
|
int just_pressed;
|
||||||
int just_released;
|
int just_released;
|
||||||
int just_repeated;
|
int just_repeated;
|
||||||
int repeat_at[BTN_ID_COUNT];
|
uint32_t repeat_at[BTN_ID_COUNT];
|
||||||
} pad;
|
} pad;
|
||||||
#define PAD_REPEAT_DELAY 300
|
#define PAD_REPEAT_DELAY 300
|
||||||
#define PAD_REPEAT_INTERVAL 100
|
#define PAD_REPEAT_INTERVAL 100
|
||||||
|
|
@ -799,7 +799,7 @@ void PAD_poll(void) {
|
||||||
pad.just_released = BTN_NONE;
|
pad.just_released = BTN_NONE;
|
||||||
pad.just_repeated = BTN_NONE;
|
pad.just_repeated = BTN_NONE;
|
||||||
|
|
||||||
int tick = SDL_GetTicks();
|
uint32_t tick = SDL_GetTicks();
|
||||||
for (int i=0; i<BTN_ID_COUNT; i++) {
|
for (int i=0; i<BTN_ID_COUNT; i++) {
|
||||||
int btn = 1 << i;
|
int btn = 1 << i;
|
||||||
if ((pad.is_pressed & btn) && (tick>=pad.repeat_at[i])) {
|
if ((pad.is_pressed & btn) && (tick>=pad.repeat_at[i])) {
|
||||||
|
|
@ -865,15 +865,15 @@ void POW_update(int* _dirty, int* _show_setting, POW_callback_t before_sleep, PO
|
||||||
int dirty = _dirty ? *_dirty : 0;
|
int dirty = _dirty ? *_dirty : 0;
|
||||||
int show_setting = _show_setting ? *_show_setting : 0;
|
int show_setting = _show_setting ? *_show_setting : 0;
|
||||||
|
|
||||||
static unsigned long cancel_start = 0;
|
static uint32_t cancel_start = 0;
|
||||||
static unsigned long power_start = 0;
|
static uint32_t power_start = 0;
|
||||||
|
|
||||||
static unsigned long setting_start = 0;
|
static uint32_t setting_start = 0;
|
||||||
static unsigned long charge_start = 0;
|
static uint32_t charge_start = 0;
|
||||||
static int was_charging = -1;
|
static int was_charging = -1;
|
||||||
if (was_charging==-1) was_charging = POW_isCharging();
|
if (was_charging==-1) was_charging = POW_isCharging();
|
||||||
|
|
||||||
unsigned long now = SDL_GetTicks();
|
uint32_t now = SDL_GetTicks();
|
||||||
if (cancel_start==0) cancel_start = now;
|
if (cancel_start==0) cancel_start = now;
|
||||||
if (charge_start==0) charge_start = now;
|
if (charge_start==0) charge_start = now;
|
||||||
|
|
||||||
|
|
@ -976,7 +976,7 @@ static void POW_exitSleep(void) {
|
||||||
static void POW_waitForWake(void) {
|
static void POW_waitForWake(void) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
int wake = 0;
|
int wake = 0;
|
||||||
unsigned long sleep_ticks = SDL_GetTicks();
|
uint32_t sleep_ticks = SDL_GetTicks();
|
||||||
while (!wake) {
|
while (!wake) {
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
if (event.type==SDL_KEYUP) {
|
if (event.type==SDL_KEYUP) {
|
||||||
|
|
|
||||||
|
|
@ -590,7 +590,7 @@ static bool environment_callback(unsigned cmd, void *data) { // copied from pico
|
||||||
|
|
||||||
static int cpu_ticks = 0;
|
static int cpu_ticks = 0;
|
||||||
static int fps_ticks = 0;
|
static int fps_ticks = 0;
|
||||||
static int sec_start = 0;
|
static uint32_t sec_start = 0;
|
||||||
|
|
||||||
// TODO: flesh out
|
// TODO: flesh out
|
||||||
static scale_neon_t scaler;
|
static scale_neon_t scaler;
|
||||||
|
|
@ -1098,10 +1098,10 @@ static void video_refresh_callback(const void *data, unsigned width, unsigned he
|
||||||
return; // TODO: tmp
|
return; // TODO: tmp
|
||||||
|
|
||||||
// measure framerate
|
// measure framerate
|
||||||
static int start = -1;
|
|
||||||
static int ticks = 0;
|
static int ticks = 0;
|
||||||
|
static uint32_t start = -1;
|
||||||
ticks += 1;
|
ticks += 1;
|
||||||
int now = SDL_GetTicks();
|
uint32_t now = SDL_GetTicks();
|
||||||
if (start==-1) start = now;
|
if (start==-1) start = now;
|
||||||
if (now-start>=1000) {
|
if (now-start>=1000) {
|
||||||
start = now;
|
start = now;
|
||||||
|
|
@ -1444,11 +1444,6 @@ void Menu_loop(void) {
|
||||||
sprintf(slot_path, "%s/%s.txt", minui_dir, game.name);
|
sprintf(slot_path, "%s/%s.txt", minui_dir, game.name);
|
||||||
getDisplayName(game.name, rom_name);
|
getDisplayName(game.name, rom_name);
|
||||||
|
|
||||||
puts("slot_path");
|
|
||||||
puts(slot_path);
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
//
|
|
||||||
int selected = 0; // resets every launch
|
int selected = 0; // resets every launch
|
||||||
if (exists(slot_path)) menu.slot = getInt(slot_path);
|
if (exists(slot_path)) menu.slot = getInt(slot_path);
|
||||||
if (menu.slot==8) menu.slot = 0;
|
if (menu.slot==8) menu.slot = 0;
|
||||||
|
|
@ -1464,7 +1459,7 @@ void Menu_loop(void) {
|
||||||
int dirty = 1;
|
int dirty = 1;
|
||||||
while (show_menu) {
|
while (show_menu) {
|
||||||
GFX_startFrame();
|
GFX_startFrame();
|
||||||
int frame_start = SDL_GetTicks();
|
uint32_t frame_start = SDL_GetTicks();
|
||||||
|
|
||||||
PAD_poll();
|
PAD_poll();
|
||||||
|
|
||||||
|
|
@ -1732,7 +1727,7 @@ void Menu_loop(void) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// slow down to 60fps
|
// slow down to 60fps
|
||||||
unsigned long frame_duration = SDL_GetTicks() - frame_start;
|
uint32_t frame_duration = SDL_GetTicks() - frame_start;
|
||||||
#define kTargetFrameDuration 17
|
#define kTargetFrameDuration 17
|
||||||
if (frame_duration<kTargetFrameDuration) SDL_Delay(kTargetFrameDuration-frame_duration);
|
if (frame_duration<kTargetFrameDuration) SDL_Delay(kTargetFrameDuration-frame_duration);
|
||||||
}
|
}
|
||||||
|
|
@ -1786,7 +1781,7 @@ int main(int argc , char* argv[]) {
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
cpu_ticks += 1;
|
cpu_ticks += 1;
|
||||||
int now = SDL_GetTicks();
|
uint32_t now = SDL_GetTicks();
|
||||||
if (now - sec_start>=1000) {
|
if (now - sec_start>=1000) {
|
||||||
printf("fps: %i (%i)\n", cpu_ticks, fps_ticks);
|
printf("fps: %i (%i)\n", cpu_ticks, fps_ticks);
|
||||||
sec_start = now;
|
sec_start = now;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue