Toggle monochromatic mode
This commit is contained in:
parent
c8707a8cca
commit
ac6e4fed10
|
@ -24,6 +24,9 @@ static Uint8 blending[5][16] = {
|
||||||
{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},
|
||||||
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0}};
|
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0}};
|
||||||
|
|
||||||
|
static Uint32 palette_mono[] = {
|
||||||
|
0x0f000000, 0x0fffffff};
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -103,8 +106,14 @@ screen_redraw(UxnScreen *p, Uint32 *pixels)
|
||||||
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++)
|
||||||
|
pixels[i] = palette_mono[(p->fg.pixels[i] << 2 | p->bg.pixels[i]) & 0x1];
|
||||||
|
} else {
|
||||||
for(i = 0; i < size; i++)
|
for(i = 0; i < size; i++)
|
||||||
pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +123,13 @@ clamp(int val, int min, int max)
|
||||||
return (val >= min) ? (val <= max) ? val : max : min;
|
return (val >= min) ? (val <= max) ? val : max : min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
screen_mono(UxnScreen *p, Uint32 *pixels)
|
||||||
|
{
|
||||||
|
p->mono = !p->mono;
|
||||||
|
screen_redraw(p, pixels);
|
||||||
|
}
|
||||||
|
|
||||||
/* IO */
|
/* IO */
|
||||||
|
|
||||||
Uint8
|
Uint8
|
||||||
|
|
|
@ -20,6 +20,7 @@ typedef struct UxnScreen {
|
||||||
Uint32 palette[4], *pixels;
|
Uint32 palette[4], *pixels;
|
||||||
Uint16 width, height;
|
Uint16 width, height;
|
||||||
Layer fg, bg;
|
Layer fg, bg;
|
||||||
|
Uint8 mono;
|
||||||
} UxnScreen;
|
} UxnScreen;
|
||||||
|
|
||||||
extern UxnScreen uxn_screen;
|
extern UxnScreen uxn_screen;
|
||||||
|
@ -28,6 +29,7 @@ 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_clear(UxnScreen *p, Layer *layer);
|
void screen_clear(UxnScreen *p, Layer *layer);
|
||||||
void screen_redraw(UxnScreen *p, Uint32 *pixels);
|
void screen_redraw(UxnScreen *p, Uint32 *pixels);
|
||||||
|
void screen_mono(UxnScreen *p, Uint32 *pixels);
|
||||||
|
|
||||||
Uint8 screen_dei(Device *d, Uint8 port);
|
Uint8 screen_dei(Device *d, Uint8 port);
|
||||||
void screen_deo(Device *d, Uint8 port);
|
void screen_deo(Device *d, Uint8 port);
|
||||||
|
|
|
@ -363,6 +363,10 @@ do_shortcut(Uxn *u, SDL_Event *event)
|
||||||
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, uxn_screen.pixels);
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue