| ... | ... |
@@ -24,6 +24,9 @@ static Uint8 blending[5][16] = {
|
| 24 | 24 |
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2},
|
| 25 | 25 |
{1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0}};
|
| 26 | 26 |
|
| 27 |
+static Uint32 palette_mono[] = {
|
|
| 28 |
+ 0x0f000000, 0x0fffffff}; |
|
| 29 |
+ |
|
| 27 | 30 |
static void |
| 28 | 31 |
screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color) |
| 29 | 32 |
{
|
| ... | ... |
@@ -103,8 +106,14 @@ screen_redraw(UxnScreen *p, Uint32 *pixels) |
| 103 | 106 |
Uint32 i, size = p->width * p->height, palette[16]; |
| 104 | 107 |
for(i = 0; i < 16; i++) |
| 105 | 108 |
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)]; |
| 106 |
- for(i = 0; i < size; i++) |
|
| 107 |
- pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]]; |
|
| 109 |
+ if(p->mono) {
|
|
| 110 |
+ for(i = 0; i < size; i++) |
|
| 111 |
+ pixels[i] = palette_mono[(p->fg.pixels[i] << 2 | p->bg.pixels[i]) & 0x1]; |
|
| 112 |
+ } else {
|
|
| 113 |
+ for(i = 0; i < size; i++) |
|
| 114 |
+ pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]]; |
|
| 115 |
+ } |
|
| 116 |
+ |
|
| 108 | 117 |
p->fg.changed = p->bg.changed = 0; |
| 109 | 118 |
} |
| 110 | 119 |
|
| ... | ... |
@@ -114,6 +123,13 @@ clamp(int val, int min, int max) |
| 114 | 123 |
return (val >= min) ? (val <= max) ? val : max : min; |
| 115 | 124 |
} |
| 116 | 125 |
|
| 126 |
+void |
|
| 127 |
+screen_mono(UxnScreen *p, Uint32 *pixels) |
|
| 128 |
+{
|
|
| 129 |
+ p->mono = !p->mono; |
|
| 130 |
+ screen_redraw(p, pixels); |
|
| 131 |
+} |
|
| 132 |
+ |
|
| 117 | 133 |
/* IO */ |
| 118 | 134 |
|
| 119 | 135 |
Uint8 |
| ... | ... |
@@ -20,6 +20,7 @@ typedef struct UxnScreen {
|
| 20 | 20 |
Uint32 palette[4], *pixels; |
| 21 | 21 |
Uint16 width, height; |
| 22 | 22 |
Layer fg, bg; |
| 23 |
+ Uint8 mono; |
|
| 23 | 24 |
} UxnScreen; |
| 24 | 25 |
|
| 25 | 26 |
extern UxnScreen uxn_screen; |
| ... | ... |
@@ -28,6 +29,7 @@ void screen_palette(UxnScreen *p, Uint8 *addr); |
| 28 | 29 |
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height); |
| 29 | 30 |
void screen_clear(UxnScreen *p, Layer *layer); |
| 30 | 31 |
void screen_redraw(UxnScreen *p, Uint32 *pixels); |
| 32 |
+void screen_mono(UxnScreen *p, Uint32 *pixels); |
|
| 31 | 33 |
|
| 32 | 34 |
Uint8 screen_dei(Device *d, Uint8 port); |
| 33 | 35 |
void screen_deo(Device *d, Uint8 port); |
| ... | ... |
@@ -363,6 +363,10 @@ do_shortcut(Uxn *u, SDL_Event *event) |
| 363 | 363 |
capture_screen(); |
| 364 | 364 |
else if(event->key.keysym.sym == SDLK_F4) |
| 365 | 365 |
restart(u); |
| 366 |
+ else if(event->key.keysym.sym == SDLK_F5) {
|
|
| 367 |
+ screen_mono(&uxn_screen, uxn_screen.pixels); |
|
| 368 |
+ redraw(); |
|
| 369 |
+ } |
|
| 366 | 370 |
} |
| 367 | 371 |
|
| 368 | 372 |
static int |