Browse code

Removed window padding

Devine Lu Linvega authored on 23/07/2023 02:52:17
Showing 1 changed files
... ...
@@ -41,7 +41,6 @@ WITH REGARD TO THIS SOFTWARE.
41 41
 
42 42
 #define WIDTH 64 * 8
43 43
 #define HEIGHT 40 * 8
44
-#define PAD 2
45 44
 #define TIMEOUT_MS 334
46 45
 #define BENCH 0
47 46
 
... ...
@@ -176,19 +175,19 @@ set_window_size(SDL_Window *window, int w, int h)
176 175
 static int
177 176
 set_size(void)
178 177
 {
179
-	emu_frame.x = PAD;
180
-	emu_frame.y = PAD;
178
+	emu_frame.x = 0;
179
+	emu_frame.y = 0;
181 180
 	emu_frame.w = uxn_screen.width;
182 181
 	emu_frame.h = uxn_screen.height;
183 182
 	if(emu_texture != NULL)
184 183
 		SDL_DestroyTexture(emu_texture);
185
-	SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width + PAD * 2, uxn_screen.height + PAD * 2);
184
+	SDL_RenderSetLogicalSize(emu_renderer, uxn_screen.width, uxn_screen.height);
186 185
 	emu_texture = SDL_CreateTexture(emu_renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STATIC, uxn_screen.width, uxn_screen.height);
187 186
 	if(emu_texture == NULL || SDL_SetTextureBlendMode(emu_texture, SDL_BLENDMODE_NONE))
188 187
 		return system_error("SDL_SetTextureBlendMode", SDL_GetError());
189 188
 	if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, sizeof(Uint32)) != 0)
190 189
 		return system_error("SDL_UpdateTexture", SDL_GetError());
191
-	set_window_size(emu_window, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
190
+	set_window_size(emu_window, (uxn_screen.width) * zoom, (uxn_screen.height) * zoom);
192 191
 	return 1;
193 192
 }
194 193
 
... ...
@@ -217,7 +216,7 @@ init(void)
217 216
 	as.userdata = NULL;
218 217
 	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
219 218
 		return system_error("sdl", SDL_GetError());
220
-	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);
219
+	emu_window = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (WIDTH) * zoom, (HEIGHT) * zoom, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
221 220
 	if(emu_window == NULL)
222 221
 		return system_error("sdl_window", SDL_GetError());
223 222
 	emu_renderer = SDL_CreateRenderer(emu_window, -1, 0);
... ...
@@ -265,7 +264,7 @@ set_zoom(Uint8 z)
265 264
 {
266 265
 	if(z >= 1) {
267 266
 		zoom = z;
268
-		set_window_size(emu_window, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
267
+		set_window_size(emu_window, (uxn_screen.width) * zoom, (uxn_screen.height) * zoom);
269 268
 	}
270 269
 }
271 270
 
... ...
@@ -389,7 +388,7 @@ handle_events(Uxn *u)
389 388
 			uxn_eval(u, PEEK2(&u->dev[0x30 + 0x10 * (event.type - audio0_event)]));
390 389
 		/* Mouse */
391 390
 		else if(event.type == SDL_MOUSEMOTION)
392
-			mouse_pos(u, &u->dev[0x90], clamp(event.motion.x - PAD, 0, uxn_screen.width - 1), clamp(event.motion.y - PAD, 0, uxn_screen.height - 1));
391
+			mouse_pos(u, &u->dev[0x90], clamp(event.motion.x, 0, uxn_screen.width - 1), clamp(event.motion.y, 0, uxn_screen.height - 1));
393 392
 		else if(event.type == SDL_MOUSEBUTTONUP)
394 393
 			mouse_up(u, &u->dev[0x90], SDL_BUTTON(event.button.button));
395 394
 		else if(event.type == SDL_MOUSEBUTTONDOWN)