commit b1f81dc

Devine Lu Linvega  ·  2024-01-21 01:00:05 +0000 UTC
parent 12cb8e2
Converter twos() to a macro
2 files changed,  +4, -11
+2, -11
 1@@ -25,15 +25,6 @@ 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 int
 6-twos(Uint16 value)
 7-{
 8-	if(value & (1 << (sizeof(Uint16) * 8 - 1)))
 9-		return (int)value - (1 << sizeof(Uint16) * 8);
10-	else
11-		return (int)value;
12-}
13-
14 static void
15 screen_2bpp(Uint8 *layer, Uint8 *addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy)
16 {
17@@ -271,9 +262,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
18 	case 0x5: screen_resize(uxn_screen.width, PEEK2(d + 4), uxn_screen.scale); return;
19 	case 0x6: rMX = d[0x6] & 0x1, rMY = d[0x6] & 0x2, rMA = d[0x6] & 0x4, rML = d[0x6] >> 4, rDX = rMX << 3, rDY = rMY << 2; return;
20 	case 0x8:
21-	case 0x9: rX = twos((d[0x8] << 8) | d[0x9]); return;
22+	case 0x9: rX = (d[0x8] << 8) | d[0x9], rX = twos(rX); return;
23 	case 0xa:
24-	case 0xb: rY = twos((d[0xa] << 8) | d[0xb]); return;
25+	case 0xb: rY = (d[0xa] << 8) | d[0xb], rY = twos(rY); return;
26 	case 0xc:
27 	case 0xd: rA = (d[0xc] << 8) | d[0xd]; return;
28 	case 0xe: {
+2, -0
1@@ -31,3 +31,5 @@ void screen_redraw(Uxn *u);
2 
3 Uint8 screen_dei(Uxn *u, Uint8 addr);
4 void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port);
5+
6+#define twos(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)