Only set emu size on screen resize, no constant checks

This commit is contained in:
Devine Lu Linvega 2023-07-23 16:24:09 -07:00
parent 29e664c6b8
commit ec973c2ea6
3 changed files with 4 additions and 10 deletions

View File

@ -106,6 +106,7 @@ screen_resize(Uint16 width, Uint16 height)
uxn_screen.height = height; uxn_screen.height = height;
screen_fill(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0); screen_fill(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
screen_fill(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0); screen_fill(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
emu_resize();
} }
void void

View File

@ -17,6 +17,8 @@ typedef struct UxnScreen {
} UxnScreen; } UxnScreen;
extern UxnScreen uxn_screen; extern UxnScreen uxn_screen;
extern int emu_resize(void);
void screen_palette(Uint8 *addr); void screen_palette(Uint8 *addr);
void screen_resize(Uint16 width, Uint16 height); void screen_resize(Uint16 width, Uint16 height);
void screen_redraw(void); void screen_redraw(void);

View File

@ -48,7 +48,6 @@ static SDL_Window *emu_window;
static SDL_Texture *emu_texture; static SDL_Texture *emu_texture;
static SDL_Renderer *emu_renderer; static SDL_Renderer *emu_renderer;
static SDL_AudioDeviceID audio_id; static SDL_AudioDeviceID audio_id;
static SDL_Rect emu_frame;
static SDL_Thread *stdin_thread; static SDL_Thread *stdin_thread;
Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000}; Uint16 deo_mask[] = {0xff28, 0x0300, 0xc028, 0x8000, 0x8000, 0x8000, 0x8000, 0x0000, 0x0000, 0x0000, 0xa260, 0xa260, 0x0000, 0x0000, 0x0000, 0x0000};
@ -166,13 +165,7 @@ set_window_size(SDL_Window *window, int w, int h)
SDL_SetWindowSize(window, w, h); SDL_SetWindowSize(window, w, h);
} }
static int int emu_resize(void){
set_size(void)
{
emu_frame.x = 0;
emu_frame.y = 0;
emu_frame.w = uxn_screen.width;
emu_frame.h = uxn_screen.height;
if(emu_texture != NULL) if(emu_texture != NULL)
SDL_DestroyTexture(emu_texture); SDL_DestroyTexture(emu_texture);
SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height); SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height);
@ -188,8 +181,6 @@ set_size(void)
static void static void
redraw(void) redraw(void)
{ {
if(emu_frame.w != uxn_screen.width || emu_frame.h != uxn_screen.height)
set_size();
screen_redraw(); screen_redraw();
if(SDL_UpdateTexture(emu_texture, 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());