uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 11e9b635c80faebf1059b1ef27eee3819f246514
parent 847b3f2b56afed2b6207b78ec5ce3e43a712255d
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Wed, 12 Apr 2023 11:58:32 -0700

Removed mono mode to screen

Diffstat:
Msrc/devices/screen.c | 32+++++++-------------------------
Msrc/devices/screen.h | 2--
Msrc/uxnemu.c | 14++++++++------
3 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -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) { diff --git a/src/devices/screen.h b/src/devices/screen.h @@ -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); diff --git a/src/uxnemu.c b/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