diff --git a/src/devices/screen.c b/src/devices/screen.c index 2cae34c..cad9b10 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -25,15 +25,6 @@ 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 int -twos(Uint16 value) -{ - if(value & (1 << (sizeof(Uint16) * 8 - 1))) - return (int)value - (1 << sizeof(Uint16) * 8); - else - return (int)value; -} - static void screen_2bpp(Uint8 *layer, Uint8 *addr, Uint16 x1, Uint16 y1, Uint16 color, int fx, int fy) { @@ -271,9 +262,9 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) case 0x5: screen_resize(uxn_screen.width, PEEK2(d + 4), uxn_screen.scale); return; 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; case 0x8: - case 0x9: rX = twos((d[0x8] << 8) | d[0x9]); return; + case 0x9: rX = (d[0x8] << 8) | d[0x9], rX = twos(rX); return; case 0xa: - case 0xb: rY = twos((d[0xa] << 8) | d[0xb]); return; + case 0xb: rY = (d[0xa] << 8) | d[0xb], rY = twos(rY); return; case 0xc: case 0xd: rA = (d[0xc] << 8) | d[0xd]; return; case 0xe: { diff --git a/src/devices/screen.h b/src/devices/screen.h index 5a1a309..7045286 100644 --- a/src/devices/screen.h +++ b/src/devices/screen.h @@ -31,3 +31,5 @@ void screen_redraw(Uxn *u); Uint8 screen_dei(Uxn *u, Uint8 addr); void screen_deo(Uint8 *ram, Uint8 *d, Uint8 port); + +#define twos(v) (v & 0x8000 ? (int)v - 0x10000 : (int)v)