uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit ec973c2ea67b287eb3df9aa400c7a78ea3faabf0
parent 29e664c6b823e2330b467d3f4f1c265cde7c4fce
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Sun, 23 Jul 2023 16:24:09 -0700

Only set emu size on screen resize, no constant checks

Diffstat:
Msrc/devices/screen.c | 1+
Msrc/devices/screen.h | 2++
Msrc/uxnemu.c | 11+----------
3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -106,6 +106,7 @@ screen_resize(Uint16 width, Uint16 height) uxn_screen.height = height; 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); + emu_resize(); } void diff --git a/src/devices/screen.h b/src/devices/screen.h @@ -17,6 +17,8 @@ typedef struct UxnScreen { } UxnScreen; extern UxnScreen uxn_screen; +extern int emu_resize(void); + void screen_palette(Uint8 *addr); void screen_resize(Uint16 width, Uint16 height); void screen_redraw(void); diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -48,7 +48,6 @@ static SDL_Window *emu_window; static SDL_Texture *emu_texture; static SDL_Renderer *emu_renderer; static SDL_AudioDeviceID audio_id; -static SDL_Rect emu_frame; static SDL_Thread *stdin_thread; 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); } -static int -set_size(void) -{ - emu_frame.x = 0; - emu_frame.y = 0; - emu_frame.w = uxn_screen.width; - emu_frame.h = uxn_screen.height; +int emu_resize(void){ if(emu_texture != NULL) SDL_DestroyTexture(emu_texture); SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height); @@ -188,8 +181,6 @@ set_size(void) static void redraw(void) { - if(emu_frame.w != uxn_screen.width || emu_frame.h != uxn_screen.height) - set_size(); screen_redraw(); if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0) system_error("SDL_UpdateTexture", SDL_GetError());