(screen.c) Merge all checks

This commit is contained in:
Devine Lu Linvega 2023-04-12 20:00:17 -07:00
parent 8aae16a9d0
commit a44dbd9696
2 changed files with 10 additions and 11 deletions

View File

@ -86,15 +86,15 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height)
bg = realloc(p->bg.pixels, width * height),
fg = realloc(p->fg.pixels, width * height);
pixels = realloc(p->pixels, width * height * sizeof(Uint32));
if(bg) p->bg.pixels = bg;
if(fg) p->fg.pixels = fg;
if(pixels) p->pixels = pixels;
if(bg && fg && pixels) {
p->width = width;
p->height = height;
screen_fill(p, &p->bg, 0, 0, p->width, p->height, 0);
screen_fill(p, &p->fg, 0, 0, p->width, p->height, 0);
}
if(!bg || !fg || !pixels)
return;
p->bg.pixels = bg;
p->fg.pixels = fg;
p->pixels = pixels;
p->width = width;
p->height = height;
screen_fill(p, &p->bg, 0, 0, p->width, p->height, 0);
screen_fill(p, &p->fg, 0, 0, p->width, p->height, 0);
}
void

View File

@ -399,9 +399,8 @@ handle_events(Uxn *u)
SDL_free(event.drop.file);
}
/* Audio */
else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) {
else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY)
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 - PAD, 0, uxn_screen.width - 1), clamp(event.motion.y - PAD, 0, uxn_screen.height - 1));