commit 29e664c6b823e2330b467d3f4f1c265cde7c4fce
parent 4db53c1cc62d7d89c6460b1fd5469c1c92928023
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Sun, 23 Jul 2023 16:10:48 -0700
Do not re-set window size when unchanged
Diffstat:
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/devices/screen.c b/src/devices/screen.c
@@ -86,6 +86,8 @@ screen_resize(Uint16 width, Uint16 height)
Uint32 *pixels = NULL;
if(width < 0x8 || height < 0x8 || width >= 0x400 || height >= 0x400)
return;
+ if(uxn_screen.width == width && uxn_screen.height == height)
+ return;
bg = malloc(width * height),
fg = malloc(width * height);
if(bg && fg)
@@ -123,8 +125,7 @@ screen_redraw(void)
i = x + y * w;
pixels[i] = palette[fg[i] << 2 | bg[i]];
}
- uxn_screen.x1 = uxn_screen.y1 = 0xffff;
- uxn_screen.x2 = uxn_screen.y2 = 0;
+ uxn_screen.x1 = uxn_screen.y1 = uxn_screen.x2 = uxn_screen.y2 = 0;
}
Uint8
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -61,12 +61,6 @@ static Uint64 exec_deadline, deadline_interval, ms_interval;
char *rom_path;
-static int
-clamp(int val, int min, int max)
-{
- return (val >= min) ? (val <= max) ? val : max : min;
-}
-
static Uint8
audio_dei(int instance, Uint8 *d, Uint8 port)
{
@@ -199,7 +193,7 @@ redraw(void)
screen_redraw();
if(SDL_UpdateTexture(emu_texture, NULL, uxn_screen.pixels, uxn_screen.width * sizeof(Uint32)) != 0)
system_error("SDL_UpdateTexture", SDL_GetError());
- SDL_RenderCopy(emu_renderer, emu_texture, NULL, &emu_frame);
+ SDL_RenderCopy(emu_renderer, emu_texture, NULL, NULL);
SDL_RenderPresent(emu_renderer);
}
@@ -216,7 +210,7 @@ init(void)
as.userdata = NULL;
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
return system_error("sdl", SDL_GetError());
- emu_window = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (WIDTH) * zoom, (HEIGHT) * zoom, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
+ emu_window = SDL_CreateWindow("Uxn", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (WIDTH)*zoom, (HEIGHT)*zoom, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI);
if(emu_window == NULL)
return system_error("sdl_window", SDL_GetError());
emu_renderer = SDL_CreateRenderer(emu_window, -1, 0);
@@ -388,7 +382,7 @@ handle_events(Uxn *u)
uxn_eval(u, PEEK2(&u->dev[0x30 + 0x10 * (event.type - audio0_event)]));
/* Mouse */
else if(event.type == SDL_MOUSEMOTION)
- mouse_pos(u, &u->dev[0x90], clamp(event.motion.x, 0, uxn_screen.width - 1), clamp(event.motion.y, 0, uxn_screen.height - 1));
+ mouse_pos(u, &u->dev[0x90], event.motion.x, event.motion.y);
else if(event.type == SDL_MOUSEBUTTONUP)
mouse_up(u, &u->dev[0x90], SDL_BUTTON(event.button.button));
else if(event.type == SDL_MOUSEBUTTONDOWN)