commit bd00cb6
Devine Lu Linvega
·
2025-08-14 00:44:06 +0000 UTC
parent 42e87b0
Do not recalculate color in pixel port inside tight loop
1 files changed,
+3,
-3
+3,
-3
1@@ -523,9 +523,9 @@ static void
2 screen_draw_pixel(void)
3 {
4 const int ctrl = dev[0x2e];
5- const int color = ctrl & 0x3;
6 const int len = MAR2(uxn_screen.width);
7 const int above = ctrl & 0x40;
8+ const int color = above ? (ctrl & 0x3) << 2 : ctrl & 0x3;
9 /* fill mode */
10 if(ctrl & 0x80) {
11 int x1, y1, x2, y2, ax, bx, ay, by, hor, ver;
12@@ -543,7 +543,7 @@ screen_draw_pixel(void)
13 for(ay = y1 * len, by = ay + ver * len; ay < by; ay += len)
14 for(ax = ay + x1, bx = ax + hor; ax < bx; ax++) {
15 const int src = uxn_screen.bg[ax];
16- uxn_screen.bg[ax] = above ? (src & 0x3) | color << 2 : (src & 0xc) | color;
17+ uxn_screen.bg[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
18 }
19 }
20 /* pixel mode */
21@@ -551,7 +551,7 @@ screen_draw_pixel(void)
22 if(rX >= 0 && rY >= 0 && rX < len && rY < uxn_screen.height) {
23 const int ax = MAR(rX) + MAR(rY) * len;
24 const int src = uxn_screen.bg[ax];
25- uxn_screen.bg[ax] = above ? (src & 0x3) | color << 2 : (src & 0xc) | color;
26+ uxn_screen.bg[ax] = above ? (src & 0x3) | color : (src & 0xc) | color;
27 }
28 screen_change(rX, rY, rX + 1, rY + 1);
29 if(rMX) rX++;