Mercurial > repos > blastem
comparison render_sdl.c @ 1103:22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 09 Dec 2016 09:48:48 -0800 |
parents | c15896605bf2 |
children | 928a65750345 |
comparison
equal
deleted
inserted
replaced
1102:c15896605bf2 | 1103:22e87b739ad6 |
---|---|
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include "render.h" | 10 #include "render.h" |
11 #include "blastem.h" | 11 #include "blastem.h" |
12 #include "genesis.h" | |
12 #include "io.h" | 13 #include "io.h" |
13 #include "util.h" | 14 #include "util.h" |
14 | 15 |
15 #ifndef DISABLE_OPENGL | 16 #ifndef DISABLE_OPENGL |
16 #include <GL/glew.h> | 17 #include <GL/glew.h> |
29 | 30 |
30 static uint8_t render_gl = 1; | 31 static uint8_t render_gl = 1; |
31 static uint8_t scanlines = 0; | 32 static uint8_t scanlines = 0; |
32 | 33 |
33 static uint32_t last_frame = 0; | 34 static uint32_t last_frame = 0; |
34 | |
35 static uint32_t min_delay; | |
36 static uint32_t frame_delay = 1000/60; | |
37 | 35 |
38 static int16_t * current_psg = NULL; | 36 static int16_t * current_psg = NULL; |
39 static int16_t * current_ym = NULL; | 37 static int16_t * current_ym = NULL; |
40 | 38 |
41 static uint32_t buffer_samples, sample_rate; | 39 static uint32_t buffer_samples, sample_rate; |
243 SDL_DestroyTexture(sdl_textures[i]); | 241 SDL_DestroyTexture(sdl_textures[i]); |
244 } | 242 } |
245 } | 243 } |
246 } | 244 } |
247 | 245 |
248 void render_init(int width, int height, char * title, uint32_t fps, uint8_t fullscreen) | 246 void render_init(int width, int height, char * title, uint8_t fullscreen) |
249 { | 247 { |
250 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) { | 248 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) { |
251 fatal_error("Unable to init SDL: %s\n", SDL_GetError()); | 249 fatal_error("Unable to init SDL: %s\n", SDL_GetError()); |
252 } | 250 } |
253 atexit(SDL_Quit); | 251 atexit(SDL_Quit); |
360 render_alloc_surfaces(); | 358 render_alloc_surfaces(); |
361 def.ptrval = "off"; | 359 def.ptrval = "off"; |
362 scanlines = !strcmp(tern_find_path_default(config, "video\0scanlines\0", def).ptrval, "on"); | 360 scanlines = !strcmp(tern_find_path_default(config, "video\0scanlines\0", def).ptrval, "on"); |
363 | 361 |
364 caption = title; | 362 caption = title; |
365 min_delay = 0; | |
366 for (int i = 0; i < 100; i++) { | |
367 uint32_t start = SDL_GetTicks(); | |
368 SDL_Delay(1); | |
369 uint32_t delay = SDL_GetTicks()-start; | |
370 if (delay > min_delay) { | |
371 min_delay = delay; | |
372 } | |
373 } | |
374 if (!min_delay) { | |
375 min_delay = 1; | |
376 } | |
377 printf("minimum delay: %d\n", min_delay); | |
378 | |
379 frame_delay = 1000/fps; | |
380 | 363 |
381 audio_mutex = SDL_CreateMutex(); | 364 audio_mutex = SDL_CreateMutex(); |
382 psg_cond = SDL_CreateCond(); | 365 psg_cond = SDL_CreateCond(); |
383 ym_cond = SDL_CreateCond(); | 366 ym_cond = SDL_CreateCond(); |
384 audio_ready = SDL_CreateCond(); | 367 audio_ready = SDL_CreateCond(); |