mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-05 22:05:04 +00:00
(screen) Added fill() function
This commit is contained in:
parent
dd1f3e0725
commit
0d055306a8
3 changed files with 22 additions and 19 deletions
|
@ -38,6 +38,14 @@ screen_change(Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2)
|
|||
if(y2 > uxn_screen.y2) uxn_screen.y2 = y2;
|
||||
}
|
||||
|
||||
void
|
||||
screen_fill(Uint8 *layer, int color)
|
||||
{
|
||||
int i, length = uxn_screen.width * uxn_screen.height;
|
||||
for(i = 0; i < length; i++)
|
||||
layer[i] = color;
|
||||
}
|
||||
|
||||
void
|
||||
screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color)
|
||||
{
|
||||
|
@ -137,24 +145,18 @@ screen_resize(Uint16 width, Uint16 height)
|
|||
return;
|
||||
if(uxn_screen.width == width && uxn_screen.height == height)
|
||||
return;
|
||||
bg = malloc(width * height),
|
||||
fg = malloc(width * height);
|
||||
bg = malloc(width * height), fg = malloc(width * height);
|
||||
if(bg && fg)
|
||||
pixels = realloc(uxn_screen.pixels, width * height * sizeof(Uint32));
|
||||
if(!bg || !fg || !pixels) {
|
||||
free(bg);
|
||||
free(fg);
|
||||
free(bg), free(fg);
|
||||
return;
|
||||
}
|
||||
free(uxn_screen.bg);
|
||||
free(uxn_screen.fg);
|
||||
uxn_screen.bg = bg;
|
||||
uxn_screen.fg = fg;
|
||||
free(uxn_screen.bg), free(uxn_screen.fg);
|
||||
uxn_screen.bg = bg, uxn_screen.fg = fg;
|
||||
uxn_screen.pixels = pixels;
|
||||
uxn_screen.width = width;
|
||||
uxn_screen.height = height;
|
||||
screen_rect(uxn_screen.bg, 0, 0, width, height, 0);
|
||||
screen_rect(uxn_screen.fg, 0, 0, width, height, 0);
|
||||
uxn_screen.width = width, uxn_screen.height = height;
|
||||
screen_fill(uxn_screen.bg, 0), screen_fill(uxn_screen.fg, 0);
|
||||
emu_resize(width, height);
|
||||
screen_change(0, 0, width, height);
|
||||
}
|
||||
|
@ -194,13 +196,13 @@ screen_dei(Uxn *u, Uint8 addr)
|
|||
void
|
||||
screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
|
||||
{
|
||||
Uint8 *port_width, *port_height, *port_x, *port_y, *port_addr;
|
||||
Uint8 *port_height, *port_x, *port_y, *port_addr;
|
||||
Uint16 x, y, dx, dy, dxy, dyx, addr, addr_incr;
|
||||
switch(port) {
|
||||
case 0x3:
|
||||
port_width = d + 0x2;
|
||||
case 0x3: {
|
||||
Uint8 *port_width = d + 0x2;
|
||||
screen_resize(PEEK2(port_width), uxn_screen.height);
|
||||
break;
|
||||
} break;
|
||||
case 0x5:
|
||||
port_height = d + 0x4;
|
||||
screen_resize(uxn_screen.width, PEEK2(port_height));
|
||||
|
|
|
@ -22,6 +22,7 @@ typedef struct UxnScreen {
|
|||
extern UxnScreen uxn_screen;
|
||||
extern int emu_resize(int width, int height);
|
||||
|
||||
void screen_fill(Uint8 *layer, int color);
|
||||
void screen_rect(Uint8 *layer, int x1, int y1, int x2, int y2, int color);
|
||||
void screen_palette(Uint8 *addr);
|
||||
void screen_resize(Uint16 width, Uint16 height);
|
||||
|
|
|
@ -178,7 +178,7 @@ static void
|
|||
set_debugger(Uxn *u, int value)
|
||||
{
|
||||
u->dev[0x0e] = value;
|
||||
screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
||||
screen_fill(uxn_screen.fg, 0);
|
||||
screen_redraw(u);
|
||||
}
|
||||
|
||||
|
@ -253,8 +253,8 @@ static void
|
|||
emu_restart(Uxn *u, char *rom, int soft)
|
||||
{
|
||||
screen_resize(WIDTH, HEIGHT);
|
||||
screen_rect(uxn_screen.bg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
||||
screen_rect(uxn_screen.fg, 0, 0, uxn_screen.width, uxn_screen.height, 0);
|
||||
screen_fill(uxn_screen.bg, 0);
|
||||
screen_fill(uxn_screen.fg, 0);
|
||||
system_reboot(u, rom, soft);
|
||||
SDL_SetWindowTitle(emu_window, boot_rom);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue