Removed mono mode to screen

This commit is contained in:
Devine Lu Linvega 2023-04-12 11:58:32 -07:00
parent 847b3f2b56
commit 11e9b635c8
3 changed files with 15 additions and 33 deletions

View File

@ -22,8 +22,11 @@ static Uint8 blending[4][16] = {
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1}, {1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1},
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}}; {2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
static Uint32 palette_mono[] = { static int
0x0f000000, 0x0fffffff}; clamp(int val, int min, int max)
{
return (val >= min) ? (val <= max) ? val : max : min;
}
static void static void
screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color) screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
@ -44,7 +47,6 @@ screen_fill(UxnScreen *p, Layer *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16
for(v = y1; v < y2; v++) for(v = y1; v < y2; v++)
for(h = x1; h < x2; h++) for(h = x1; h < x2; h++)
screen_write(p, layer, h, v, color); screen_write(p, layer, h, v, color);
layer->changed = 1;
} }
static void static void
@ -111,31 +113,11 @@ screen_redraw(UxnScreen *p)
Uint32 i, size = p->width * p->height, palette[16]; Uint32 i, size = p->width * p->height, palette[16];
for(i = 0; i < 16; i++) for(i = 0; i < 16; i++)
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)]; palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
if(p->mono) { for(i = 0; i < size; i++)
for(i = 0; i < size; i++) p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
p->pixels[i] = palette_mono[(p->fg.pixels[i] ? p->fg.pixels[i] : p->bg.pixels[i]) & 0x1];
} else {
for(i = 0; i < size; i++)
p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
}
p->fg.changed = p->bg.changed = 0; p->fg.changed = p->bg.changed = 0;
} }
int
clamp(int val, int min, int max)
{
return (val >= min) ? (val <= max) ? val : max : min;
}
void
screen_mono(UxnScreen *p)
{
p->mono = !p->mono;
screen_redraw(p);
}
/* IO */
Uint8 Uint8
screen_dei(Uxn *u, Uint8 addr) screen_dei(Uxn *u, Uint8 addr)
{ {

View File

@ -28,8 +28,6 @@ extern UxnScreen uxn_screen;
void screen_palette(UxnScreen *p, Uint8 *addr); void screen_palette(UxnScreen *p, Uint8 *addr);
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height); void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
void screen_redraw(UxnScreen *p); void screen_redraw(UxnScreen *p);
void screen_mono(UxnScreen *p);
Uint8 screen_dei(Uxn *u, Uint8 addr); Uint8 screen_dei(Uxn *u, Uint8 addr);
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port); void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
int clamp(int val, int min, int max);

View File

@ -79,6 +79,12 @@ console_input(Uxn *u, char c)
return uxn_eval(u, PEEK2(d)); return uxn_eval(u, PEEK2(d));
} }
static int
clamp(int val, int min, int max)
{
return (val >= min) ? (val <= max) ? val : max : min;
}
static void static void
console_deo(Uint8 *d, Uint8 port) console_deo(Uint8 *d, Uint8 port)
{ {
@ -286,7 +292,7 @@ start(Uxn *u, char *rom)
static void static void
set_zoom(Uint8 scale) set_zoom(Uint8 scale)
{ {
zoom = clamp(scale, 1, 3); zoom = zoom > 2 ? 1 : zoom + 1;
set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom); set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom);
} }
@ -368,17 +374,13 @@ static void
do_shortcut(Uxn *u, SDL_Event *event) do_shortcut(Uxn *u, SDL_Event *event)
{ {
if(event->key.keysym.sym == SDLK_F1) if(event->key.keysym.sym == SDLK_F1)
set_zoom(zoom > 2 ? 1 : zoom + 1); set_zoom(zoom);
else if(event->key.keysym.sym == SDLK_F2) else if(event->key.keysym.sym == SDLK_F2)
system_inspect(u); system_inspect(u);
else if(event->key.keysym.sym == SDLK_F3) else if(event->key.keysym.sym == SDLK_F3)
capture_screen(); capture_screen();
else if(event->key.keysym.sym == SDLK_F4) else if(event->key.keysym.sym == SDLK_F4)
restart(u); restart(u);
else if(event->key.keysym.sym == SDLK_F5) {
screen_mono(&uxn_screen);
redraw();
}
} }
static int static int