Snake_cased some SDL variables
This commit is contained in:
parent
2810592c1b
commit
e147b46b55
56
src/uxnemu.c
56
src/uxnemu.c
|
@ -45,9 +45,9 @@ WITH REGARD TO THIS SOFTWARE.
|
||||||
#define TIMEOUT_MS 334
|
#define TIMEOUT_MS 334
|
||||||
#define BENCH 0
|
#define BENCH 0
|
||||||
|
|
||||||
static SDL_Window *gWindow;
|
static SDL_Window *emu_window;
|
||||||
static SDL_Texture *gTexture;
|
static SDL_Texture *emu_texture;
|
||||||
static SDL_Renderer *gRenderer;
|
static SDL_Renderer *emu_renderer;
|
||||||
static SDL_AudioDeviceID audio_id;
|
static SDL_AudioDeviceID audio_id;
|
||||||
static SDL_Rect gRect;
|
static SDL_Rect gRect;
|
||||||
static SDL_Thread *stdin_thread;
|
static SDL_Thread *stdin_thread;
|
||||||
|
@ -57,8 +57,7 @@ Uint16 dei_mask[] = {0x0000, 0x0000, 0x003c, 0x0014, 0x0014, 0x0014, 0x0014, 0x0
|
||||||
|
|
||||||
/* devices */
|
/* devices */
|
||||||
|
|
||||||
static Uint8 zoom = 1;
|
static Uint32 stdin_event, audio0_event, zoom = 1;
|
||||||
static Uint32 stdin_event, audio0_event;
|
|
||||||
static Uint64 exec_deadline, deadline_interval, ms_interval;
|
static Uint64 exec_deadline, deadline_interval, ms_interval;
|
||||||
|
|
||||||
char *rom_path;
|
char *rom_path;
|
||||||
|
@ -180,14 +179,15 @@ set_size(void)
|
||||||
gRect.y = PAD;
|
gRect.y = PAD;
|
||||||
gRect.w = uxn_screen.width;
|
gRect.w = uxn_screen.width;
|
||||||
gRect.h = uxn_screen.height;
|
gRect.h = uxn_screen.height;
|
||||||
if(gTexture != NULL) SDL_DestroyTexture(gTexture);
|
if(emu_texture != NULL)
|
||||||
SDL_RenderSetLogicalSize(gRenderer, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2);
|
SDL_DestroyTexture(emu_texture);
|
||||||
gTexture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC, uxn_screen.width, uxn_screen.height);
|
SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2);
|
||||||
if(gTexture == NULL || SDL_SetTextureBlendMode(gTexture, SDL_BLENDMODE_NONE))
|
emu_texture = SDL_CreateTexture(emu_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC, uxn_screen.width, uxn_screen.height);
|
||||||
return system_error("gTexture", SDL_GetError());
|
if(emu_texture == NULL || SDL_SetTextureBlendMode(emu_texture, SDL_BLENDMODE_NONE))
|
||||||
if(SDL_UpdateTexture(gTexture, NULL, uxn_screen.pixels, sizeof(Uint32)) != 0)
|
return system_error("emu_texture", SDL_GetError());
|
||||||
|
if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, sizeof(Uint32)) != 0)
|
||||||
return system_error("SDL_UpdateTexture", SDL_GetError());
|
return system_error("SDL_UpdateTexture", SDL_GetError());
|
||||||
set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
|
set_window_size(emu_window, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,11 +197,11 @@ redraw(void)
|
||||||
if(gRect.w != uxn_screen.width || gRect.h != uxn_screen.height)
|
if(gRect.w != uxn_screen.width || gRect.h != uxn_screen.height)
|
||||||
set_size();
|
set_size();
|
||||||
screen_redraw();
|
screen_redraw();
|
||||||
if(SDL_UpdateTexture(gTexture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0)
|
if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0)
|
||||||
system_error("SDL_UpdateTexture", SDL_GetError());
|
system_error("SDL_UpdateTexture", SDL_GetError());
|
||||||
SDL_RenderClear(gRenderer);
|
SDL_RenderClear(emu_renderer);
|
||||||
SDL_RenderCopy(gRenderer, gTexture, NULL, &gRect);
|
SDL_RenderCopy(emu_renderer, emu_texture, NULL, &gRect);
|
||||||
SDL_RenderPresent(gRenderer);
|
SDL_RenderPresent(emu_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -217,13 +217,13 @@ init(void)
|
||||||
as.userdata = NULL;
|
as.userdata = NULL;
|
||||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
|
||||||
return system_error("sdl", SDL_GetError());
|
return system_error("sdl", SDL_GetError());
|
||||||
gWindow = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (WIDTH + PAD * 2) * zoom, (HEIGHT + PAD * 2) * zoom, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
emu_window = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (WIDTH + PAD * 2) * zoom, (HEIGHT + PAD * 2) * zoom, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
if(gWindow == NULL)
|
if(emu_window == NULL)
|
||||||
return system_error("sdl_window", SDL_GetError());
|
return system_error("sdl_window", SDL_GetError());
|
||||||
gRenderer = SDL_CreateRenderer(gWindow, -1, 0);
|
emu_renderer = SDL_CreateRenderer(emu_window, -1, 0);
|
||||||
if(gRenderer == NULL)
|
if(emu_renderer == NULL)
|
||||||
return system_error("sdl_renderer", SDL_GetError());
|
return system_error("sdl_renderer", SDL_GetError());
|
||||||
SDL_SetRenderDrawColor(gRenderer, 0x00, 0x00, 0x00, 0xff);
|
SDL_SetRenderDrawColor(emu_renderer, 0x00, 0x00, 0x00, 0xff);
|
||||||
audio_id = SDL_OpenAudioDevice(NULL, 0, &as, NULL, 0);
|
audio_id = SDL_OpenAudioDevice(NULL, 0, &as, NULL, 0);
|
||||||
if(!audio_id)
|
if(!audio_id)
|
||||||
system_error("sdl_audio", SDL_GetError());
|
system_error("sdl_audio", SDL_GetError());
|
||||||
|
@ -256,7 +256,7 @@ start(Uxn *u, char *rom, int queue)
|
||||||
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
exec_deadline = SDL_GetPerformanceCounter() + deadline_interval;
|
||||||
if(!uxn_eval(u, PAGE_PROGRAM))
|
if(!uxn_eval(u, PAGE_PROGRAM))
|
||||||
return system_error("Boot", "Failed to eval rom.");
|
return system_error("Boot", "Failed to eval rom.");
|
||||||
SDL_SetWindowTitle(gWindow, rom);
|
SDL_SetWindowTitle(emu_window, rom);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ set_zoom(Uint8 z)
|
||||||
{
|
{
|
||||||
if(z >= 1) {
|
if(z >= 1) {
|
||||||
zoom = z;
|
zoom = z;
|
||||||
set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
|
set_window_size(emu_window, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,9 +288,9 @@ capture_screen(void)
|
||||||
char fname[64];
|
char fname[64];
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
SDL_GetRendererOutputSize(gRenderer, &w, &h);
|
SDL_GetRendererOutputSize(emu_renderer, &w, &h);
|
||||||
surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0);
|
surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0);
|
||||||
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
|
SDL_RenderReadPixels(emu_renderer, NULL, format, surface->pixels, surface->pitch);
|
||||||
strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
|
strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t));
|
||||||
SDL_SaveBMP(surface, fname);
|
SDL_SaveBMP(surface, fname);
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
|
@ -487,11 +487,13 @@ run(Uxn *u)
|
||||||
if(uxn_screen.x2)
|
if(uxn_screen.x2)
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
if(BENCH);
|
if(BENCH)
|
||||||
|
;
|
||||||
else if(screen_vector || uxn_screen.x2) {
|
else if(screen_vector || uxn_screen.x2) {
|
||||||
Uint64 delay_ms = (next_refresh - now) / ms_interval;
|
Uint64 delay_ms = (next_refresh - now) / ms_interval;
|
||||||
if(delay_ms > 0) SDL_Delay(delay_ms);
|
if(delay_ms > 0) SDL_Delay(delay_ms);
|
||||||
} else SDL_WaitEvent(NULL);
|
} else
|
||||||
|
SDL_WaitEvent(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue