Browse code

Only set emu size on screen resize, no constant checks

Devine Lu Linvega authored on 23/07/2023 23:24:09
Showing 3 changed files
... ...
@@ -106,6 +106,7 @@ screen_resize(Uint16 width, Uint16 height)
106 106
 	uxn_screen.height = height;
107 107
 	screen_fill(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
108 108
 	screen_fill(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
109
+	emu_resize();
109 110
 }
110 111
 
111 112
 void
... ...
@@ -17,6 +17,8 @@ typedef struct UxnScreen {
17 17
 } UxnScreen;
18 18
 
19 19
 extern UxnScreen uxn_screen;
20
+extern int emu_resize(void);
21
+
20 22
 void screen_palette(Uint8 *addr);
21 23
 void screen_resize(Uint16 width, Uint16 height);
22 24
 void screen_redraw(void);
... ...
@@ -48,7 +48,6 @@ static SDL_Window *emu_window;
48 48
 static SDL_Texture *emu_texture;
49 49
 static SDL_Renderer *emu_renderer;
50 50
 static SDL_AudioDeviceID audio_id;
51
-static SDL_Rect emu_frame;
52 51
 static SDL_Thread *stdin_thread;
53 52
 
54 53
 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)
166 165
 	SDL_SetWindowSize(window, w, h);
167 166
 }
168 167
 
169
-static int
170
-set_size(void)
171
-{
172
-	emu_frame.x = 0;
173
-	emu_frame.y = 0;
174
-	emu_frame.w = uxn_screen.width;
175
-	emu_frame.h = uxn_screen.height;
168
+int emu_resize(void){
176 169
 	if(emu_texture != NULL)
177 170
 		SDL_DestroyTexture(emu_texture);
178 171
 	SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height);
... ...
@@ -188,8 +181,6 @@ set_size(void)
188 181
 static void
189 182
 redraw(void)
190 183
 {
191
-	if(emu_frame.w != uxn_screen.width || emu_frame.h != uxn_screen.height)
192
-		set_size();
193 184
 	screen_redraw();
194 185
 	if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0)
195 186
 		system_error("SDL_UpdateTexture", SDL_GetError());