... | ... |
@@ -22,8 +22,11 @@ static Uint8 blending[4][16] = { |
22 | 22 |
{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1}, |
23 | 23 |
{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}}; |
24 | 24 |
|
25 |
-static Uint32 palette_mono[] = { |
|
26 |
- 0x0f000000, 0x0fffffff}; |
|
25 |
+static int |
|
26 |
+clamp(int val, int min, int max) |
|
27 |
+{ |
|
28 |
+ return (val >= min) ? (val <= max) ? val : max : min; |
|
29 |
+} |
|
27 | 30 |
|
28 | 31 |
static void |
29 | 32 |
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 |
44 | 47 |
for(v = y1; v < y2; v++) |
45 | 48 |
for(h = x1; h < x2; h++) |
46 | 49 |
screen_write(p, layer, h, v, color); |
47 |
- layer->changed = 1; |
|
48 | 50 |
} |
49 | 51 |
|
50 | 52 |
static void |
... | ... |
@@ -111,31 +113,11 @@ screen_redraw(UxnScreen *p) |
111 | 113 |
Uint32 i, size = p->width * p->height, palette[16]; |
112 | 114 |
for(i = 0; i < 16; i++) |
113 | 115 |
palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)]; |
114 |
- if(p->mono) { |
|
115 |
- for(i = 0; i < size; i++) |
|
116 |
- p->pixels[i] = palette_mono[(p->fg.pixels[i] ? p->fg.pixels[i] : p->bg.pixels[i]) & 0x1]; |
|
117 |
- } else { |
|
118 |
- for(i = 0; i < size; i++) |
|
119 |
- p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]]; |
|
120 |
- } |
|
116 |
+ for(i = 0; i < size; i++) |
|
117 |
+ p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]]; |
|
121 | 118 |
p->fg.changed = p->bg.changed = 0; |
122 | 119 |
} |
123 | 120 |
|
124 |
-int |
|
125 |
-clamp(int val, int min, int max) |
|
126 |
-{ |
|
127 |
- return (val >= min) ? (val <= max) ? val : max : min; |
|
128 |
-} |
|
129 |
- |
|
130 |
-void |
|
131 |
-screen_mono(UxnScreen *p) |
|
132 |
-{ |
|
133 |
- p->mono = !p->mono; |
|
134 |
- screen_redraw(p); |
|
135 |
-} |
|
136 |
- |
|
137 |
-/* IO */ |
|
138 |
- |
|
139 | 121 |
Uint8 |
140 | 122 |
screen_dei(Uxn *u, Uint8 addr) |
141 | 123 |
{ |
... | ... |
@@ -28,8 +28,6 @@ extern UxnScreen uxn_screen; |
28 | 28 |
void screen_palette(UxnScreen *p, Uint8 *addr); |
29 | 29 |
void screen_resize(UxnScreen *p, Uint16 width, Uint16 height); |
30 | 30 |
void screen_redraw(UxnScreen *p); |
31 |
-void screen_mono(UxnScreen *p); |
|
32 | 31 |
|
33 | 32 |
Uint8 screen_dei(Uxn *u, Uint8 addr); |
34 | 33 |
void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port); |
35 |
-int clamp(int val, int min, int max); |
... | ... |
@@ -79,6 +79,12 @@ console_input(Uxn *u, char c) |
79 | 79 |
return uxn_eval(u, PEEK2(d)); |
80 | 80 |
} |
81 | 81 |
|
82 |
+static int |
|
83 |
+clamp(int val, int min, int max) |
|
84 |
+{ |
|
85 |
+ return (val >= min) ? (val <= max) ? val : max : min; |
|
86 |
+} |
|
87 |
+ |
|
82 | 88 |
static void |
83 | 89 |
console_deo(Uint8 *d, Uint8 port) |
84 | 90 |
{ |
... | ... |
@@ -286,7 +292,7 @@ start(Uxn *u, char *rom) |
286 | 292 |
static void |
287 | 293 |
set_zoom(Uint8 scale) |
288 | 294 |
{ |
289 |
- zoom = clamp(scale, 1, 3); |
|
295 |
+ zoom = zoom > 2 ? 1 : zoom + 1; |
|
290 | 296 |
set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom); |
291 | 297 |
} |
292 | 298 |
|
... | ... |
@@ -368,17 +374,13 @@ static void |
368 | 374 |
do_shortcut(Uxn *u, SDL_Event *event) |
369 | 375 |
{ |
370 | 376 |
if(event->key.keysym.sym == SDLK_F1) |
371 |
- set_zoom(zoom > 2 ? 1 : zoom + 1); |
|
377 |
+ set_zoom(zoom); |
|
372 | 378 |
else if(event->key.keysym.sym == SDLK_F2) |
373 | 379 |
system_inspect(u); |
374 | 380 |
else if(event->key.keysym.sym == SDLK_F3) |
375 | 381 |
capture_screen(); |
376 | 382 |
else if(event->key.keysym.sym == SDLK_F4) |
377 | 383 |
restart(u); |
378 |
- else if(event->key.keysym.sym == SDLK_F5) { |
|
379 |
- screen_mono(&uxn_screen); |
|
380 |
- redraw(); |
|
381 |
- } |
|
382 | 384 |
} |
383 | 385 |
|
384 | 386 |
static int |