+ } else if (surface->bpp == 16)
+ {
+ opcode=2;
+ for (int i=0; i<16; ++i)
+ {
+#define BLEND(y, x, a) (y + (((x-y) * a)>>8))
+ unsigned char da = background.a, dr = background.r, dg = background.g, db = background.b;
+ int sa = i * 16;
+ if (sa < 256)
+ {
+ dr = BLEND(background.r, foreground.r, sa) & 0xFF;
+ dg = BLEND(background.g, foreground.g, sa) & 0xFF;
+ db = BLEND(background.b, foreground.b, sa) & 0xFF;
+ }
+#undef BLEND
+#if BYTE_ORDER == LITTLE_ENDIAN
+ lookup16_normal[i] = bswap_16(((db >> 3) << 11) | ((dg >> 2) << 5) | (dr >> 3));
+#else
+ lookup16_normal[i] = ((db >> 3) << 11) | ((dg >> 2) << 5) | (dr >> 3);
+#endif
+ da ^= 0xFF;
+ }
+ for (int i=0; i<16; ++i)
+ lookup16_invert[i]=lookup16_normal[i^0xF];