commit 5b59215

Devine Lu Linvega  ·  2023-04-12 19:44:49 +0000 UTC
parent ac4ec09
Removed mono mode
2 files changed,  +14, -39
+14, -34
 1@@ -22,8 +22,11 @@ static Uint8 blending[4][16] = {
 2 	{1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1, 1, 2, 3, 1},
 3 	{2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2}};
 4 
 5-static Uint32 palette_mono[] = {
 6-	0x0f000000, 0x0fffffff};
 7+static int
 8+clamp(int val, int min, int max)
 9+{
10+	return (val >= min) ? (val <= max) ? val : max : min;
11+}
12 
13 static void
14 screen_write(UxnScreen *p, Layer *layer, Uint16 x, Uint16 y, Uint8 color)
15@@ -44,7 +47,6 @@ screen_fill(UxnScreen *p, Layer *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16
16 	for(v = y1; v < y2; v++)
17 		for(h = x1; h < x2; h++)
18 			screen_write(p, layer, h, v, color);
19-	layer->changed = 1;
20 }
21 
22 static void
23@@ -111,31 +113,11 @@ screen_redraw(UxnScreen *p)
24 	Uint32 i, size = p->width * p->height, palette[16];
25 	for(i = 0; i < 16; i++)
26 		palette[i] = p->palette[(i >> 2) ? (i >> 2) : (i & 3)];
27-	if(p->mono) {
28-		for(i = 0; i < size; i++)
29-			p->pixels[i] = palette_mono[(p->fg.pixels[i] ? p->fg.pixels[i] : p->bg.pixels[i]) & 0x1];
30-	} else {
31-		for(i = 0; i < size; i++)
32-			p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
33-	}
34+	for(i = 0; i < size; i++)
35+		p->pixels[i] = palette[p->fg.pixels[i] << 2 | p->bg.pixels[i]];
36 	p->fg.changed = p->bg.changed = 0;
37 }
38 
39-int
40-clamp(int val, int min, int max)
41-{
42-	return (val >= min) ? (val <= max) ? val : max : min;
43-}
44-
45-void
46-screen_mono(UxnScreen *p)
47-{
48-	p->mono = !p->mono;
49-	screen_redraw(p);
50-}
51-
52-/* IO */
53-
54 Uint8
55 screen_dei(Uxn *u, Uint8 addr)
56 {
57@@ -153,12 +135,10 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
58 {
59 	switch(port) {
60 	case 0x3:
61-		if(!FIXED_SIZE)
62-			screen_resize(&uxn_screen, clamp(PEEK2(d + 2), 1, 1024), uxn_screen.height);
63+		screen_resize(&uxn_screen, clamp(PEEK2(d + 2), 1, 1024), uxn_screen.height);
64 		break;
65 	case 0x5:
66-		if(!FIXED_SIZE)
67-			screen_resize(&uxn_screen, uxn_screen.width, clamp(PEEK2(d + 4), 1, 1024));
68+		screen_resize(&uxn_screen, uxn_screen.width, clamp(PEEK2(d + 4), 1, 1024));
69 		break;
70 	case 0xe: {
71 		Uint16 x = PEEK2(d + 0x8), y = PEEK2(d + 0xa);
72@@ -167,8 +147,8 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
73 			screen_fill(&uxn_screen, layer, (d[0xe] & 0x10) ? 0 : x, (d[0xe] & 0x20) ? 0 : y, (d[0xe] & 0x10) ? x : uxn_screen.width, (d[0xe] & 0x20) ? y : uxn_screen.height, d[0xe] & 0x3);
74 		else {
75 			screen_write(&uxn_screen, layer, x, y, d[0xe] & 0x3);
76-			if(d[0x6] & 0x01) POKE2(d + 0x8, x + 1); /* auto x+1 */
77-			if(d[0x6] & 0x02) POKE2(d + 0xa, y + 1); /* auto y+1 */
78+			if(d[0x6] & 0x1) POKE2(d + 0x8, x + 1); /* auto x+1 */
79+			if(d[0x6] & 0x2) POKE2(d + 0xa, y + 1); /* auto y+1 */
80 		}
81 		break;
82 	}
83@@ -189,9 +169,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
84 				addr += (d[0x6] & 0x04) << (1 + twobpp);
85 			}
86 		}
87-		POKE2(d + 0xc, addr);   /* auto addr+length */
88-		POKE2(d + 0x8, x + dx); /* auto x+8 */
89-		POKE2(d + 0xa, y + dy); /* auto y+8 */
90+		if(d[0x6] & 0x1) POKE2(d + 0x8, x + dx); /* auto x+8 */
91+		if(d[0x6] & 0x2) POKE2(d + 0xa, y + dy); /* auto y+8 */
92+		if(d[0x6] & 0x4) POKE2(d + 0xc, addr);   /* auto addr+length */
93 		break;
94 	}
95 	}
+0, -5
 1@@ -10,8 +10,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 2 WITH REGARD TO THIS SOFTWARE.
 3 */
 4 
 5-#define FIXED_SIZE 0
 6-
 7 typedef struct Layer {
 8 	Uint8 *pixels, changed;
 9 } Layer;
10@@ -20,7 +18,6 @@ typedef struct UxnScreen {
11 	Uint32 palette[4], *pixels;
12 	Uint16 width, height;
13 	Layer fg, bg;
14-	Uint8 mono;
15 } UxnScreen;
16 
17 extern UxnScreen uxn_screen;
18@@ -28,8 +25,6 @@ extern UxnScreen uxn_screen;
19 void screen_palette(UxnScreen *p, Uint8 *addr);
20 void screen_resize(UxnScreen *p, Uint16 width, Uint16 height);
21 void screen_redraw(UxnScreen *p);
22-void screen_mono(UxnScreen *p);
23 
24 Uint8 screen_dei(Uxn *u, Uint8 addr);
25 void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
26-int clamp(int val, int min, int max);