Do not re-set window size when unchanged
This commit is contained in:
parent
4db53c1cc6
commit
29e664c6b8
|
@ -86,6 +86,8 @@ screen_resize(Uint16 width, Uint16 height)
|
||||||
Uint32 *pixels = NULL;
|
Uint32 *pixels = NULL;
|
||||||
if(width < 0x8 || height < 0x8 || width >= 0x400 || height >= 0x400)
|
if(width < 0x8 || height < 0x8 || width >= 0x400 || height >= 0x400)
|
||||||
return;
|
return;
|
||||||
|
if(uxn_screen.width == width && uxn_screen.height == height)
|
||||||
|
return;
|
||||||
bg = malloc(width * height),
|
bg = malloc(width * height),
|
||||||
fg = malloc(width * height);
|
fg = malloc(width * height);
|
||||||
if(bg && fg)
|
if(bg && fg)
|
||||||
|
@ -123,8 +125,7 @@ screen_redraw(void)
|
||||||
i = x + y * w;
|
i = x + y * w;
|
||||||
pixels[i] = palette[fg[i] << 2 | bg[i]];
|
pixels[i] = palette[fg[i] << 2 | bg[i]];
|
||||||
}
|
}
|
||||||
uxn_screen.x1 = uxn_screen.y1 = 0xffff;
|
uxn_screen.x1 = uxn_screen.y1 = uxn_screen.x2 = uxn_screen.y2 = 0;
|
||||||
uxn_screen.x2 = uxn_screen.y2 = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
|
|
12
src/uxnemu.c
12
src/uxnemu.c
|
@ -61,12 +61,6 @@ static Uint64 exec_deadline, deadline_interval, ms_interval;
|
||||||
|
|
||||||
char *rom_path;
|
char *rom_path;
|
||||||
|
|
||||||
static int
|
|
||||||
clamp(int val, int min, int max)
|
|
||||||
{
|
|
||||||
return (val >= min) ? (val <= max) ? val : max : min;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Uint8
|
static Uint8
|
||||||
audio_dei(int instance, Uint8 *d, Uint8 port)
|
audio_dei(int instance, Uint8 *d, Uint8 port)
|
||||||
{
|
{
|
||||||
|
@ -199,7 +193,7 @@ redraw(void)
|
||||||
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());
|
||||||
SDL_RenderCopy(emu_renderer, emu_texture, NULL, &emu_frame);
|
SDL_RenderCopy(emu_renderer, emu_texture, NULL, NULL);
|
||||||
SDL_RenderPresent(emu_renderer);
|
SDL_RenderPresent(emu_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +210,7 @@ init(void)
|
||||||
as.userdata = NULL;
|
as.userdata = NULL;
|
||||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0)
|
||||||
return system_error("sdl", SDL_GetError());
|
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)
|
if(emu_window == NULL)
|
||||||
return system_error("sdl_window", SDL_GetError());
|
return system_error("sdl_window", SDL_GetError());
|
||||||
emu_renderer = SDL_CreateRenderer(emu_window, -1, 0);
|
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)]));
|
uxn_eval(u, PEEK2(&u->dev[0x30 + 0x10 * (event.type - audio0_event)]));
|
||||||
/* Mouse */
|
/* Mouse */
|
||||||
else if(event.type == SDL_MOUSEMOTION)
|
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)
|
else if(event.type == SDL_MOUSEBUTTONUP)
|
||||||
mouse_up(u, &u->dev[0x90], SDL_BUTTON(event.button.button));
|
mouse_up(u, &u->dev[0x90], SDL_BUTTON(event.button.button));
|
||||||
else if(event.type == SDL_MOUSEBUTTONDOWN)
|
else if(event.type == SDL_MOUSEBUTTONDOWN)
|
||||||
|
|
Loading…
Reference in New Issue