mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-27 00:03:00 +00:00
Removed mono mode to screen
This commit is contained in:
parent
847b3f2b56
commit
11e9b635c8
3 changed files with 15 additions and 33 deletions
|
@ -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},
|
||||
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
|
||||
|
||||
static Uint32 palette_mono[] = {
|
||||
0x0f000000, 0x0fffffff};
|
||||
static int
|
||||
clamp(int val, int min, int max)
|
||||
{
|
||||
return (val >= min) ? (val <= max) ? val : max : min;
|
||||
}
|
||||
|
||||
static void
|
||||
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(h = x1; h < x2; h++)
|
||||
screen_write(p, layer, h, v, color);
|
||||
layer->changed = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -111,31 +113,11 @@ screen_redraw(UxnScreen *p)
|
|||
Uint32 i, size = p->width * p->height, palette[16];
|
||||
for(i = 0; i < 16; i++)
|
||||
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
|
||||
if(p->mono) {
|
||||
for(i = 0; i < size; 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]];
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
screen_dei(Uxn *u, Uint8 addr)
|
||||
{
|
||||
|
|
|
@ -28,8 +28,6 @@ extern UxnScreen uxn_screen;
|
|||
void screen_palette(UxnScreen *p, Uint8 *addr);
|
||||
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
|
||||
void screen_redraw(UxnScreen *p);
|
||||
void screen_mono(UxnScreen *p);
|
||||
|
||||
Uint8 screen_dei(Uxn *u, Uint8 addr);
|
||||
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
|
||||
int clamp(int val, int min, int max);
|
||||
|
|
14
src/uxnemu.c
14
src/uxnemu.c
|
@ -79,6 +79,12 @@ console_input(Uxn *u, char c)
|
|||
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
|
||||
console_deo(Uint8 *d, Uint8 port)
|
||||
{
|
||||
|
@ -286,7 +292,7 @@ start(Uxn *u, char *rom)
|
|||
static void
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -368,17 +374,13 @@ static void
|
|||
do_shortcut(Uxn *u, SDL_Event *event)
|
||||
{
|
||||
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)
|
||||
system_inspect(u);
|
||||
else if(event->key.keysym.sym == SDLK_F3)
|
||||
capture_screen();
|
||||
else if(event->key.keysym.sym == SDLK_F4)
|
||||
restart(u);
|
||||
else if(event->key.keysym.sym == SDLK_F5) {
|
||||
screen_mono(&uxn_screen);
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in a new issue