commit 0123b40
neauoire
·
2023-11-12 19:49:21 +0000 UTC
parent 224202e
Faster 2bpp function
1 files changed,
+6,
-8
+6,
-8
1@@ -58,18 +58,16 @@ screen_rect(Uint8 *layer, Uint16 x1, Uint16 y1, Uint16 x2, Uint16 y2, int color)
2 static void
3 screen_2bpp(Uint8 *layer, Uint8 *ram, Uint16 addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
4 {
5- int h, width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
6- Uint8 *ch1 = &ram[addr], *ch2 = ch1 + 8, mx = (fx > 0 ? 8 : 0);
7+ int width = uxn_screen.width, height = uxn_screen.height, opaque = (color % 5);
8+ Uint8 *ch1 = &ram[addr], *ch2 = ch1 + 8;
9 Uint16 y, ymod = (fy < 0 ? 8 : 0), ymax = y1 + ymod + fy * 8;
10- // Uint16 x, xmod = (fx < 0 ? 8 : 0), xmax = x1 + xmod + fx * 8;
11+ Uint16 x, xmod = (fx > 0 ? 8 : 0), xmax = x1 + xmod - fx * 8;
12 for(y = y1 + ymod; y != ymax; y += fy) {
13 Uint16 c = *ch1++ | (*ch2++ << 8);
14- Uint16 xx = x1 + mx;
15- for(h = 7; h >= 0; --h, c >>= 1) {
16+ for(x = x1 + xmod; x != xmax; x -= fx, c >>= 1) {
17 Uint8 ch = (c & 1) | ((c >> 7) & 2);
18- xx += -fx;
19- if((opaque || ch) && xx < width && y < height)
20- layer[xx + y * width] = blending[ch][color];
21+ if((opaque || ch) && x < width && y < height)
22+ layer[x + y * width] = blending[ch][color];
23 }
24 }
25 }