|
@@ -452,11 +452,94 @@ static const SDL_BlitFunc colorkey_blit[] = {
|
|
|
(SDL_BlitFunc) NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+static void
|
|
|
+Blit4bto4(SDL_BlitInfo * info)
|
|
|
+{
|
|
|
+ int width = info->dst_w;
|
|
|
+ int height = info->dst_h;
|
|
|
+ Uint8 *src = info->src;
|
|
|
+ Uint32 *dst = (Uint32 *) info->dst;
|
|
|
+ int srcskip = info->src_skip;
|
|
|
+ int dstskip = info->dst_skip;
|
|
|
+ Uint32 *map = (Uint32 *) info->table;
|
|
|
+ int c;
|
|
|
+
|
|
|
+ /* Set up some basic variables */
|
|
|
+ srcskip += width - (width + 1) / 2;
|
|
|
+
|
|
|
+ while (height--) {
|
|
|
+ Uint8 byte = 0, bit;
|
|
|
+ for (c = 0; c < width; ++c) {
|
|
|
+ if ((c & 0x1) == 0) {
|
|
|
+ byte = *src++;
|
|
|
+ }
|
|
|
+ bit = (byte & 0xF0) >> 4;
|
|
|
+ if (1) {
|
|
|
+ *dst = map[bit];
|
|
|
+ }
|
|
|
+ byte <<= 4;
|
|
|
+ dst++;
|
|
|
+ }
|
|
|
+ src += srcskip;
|
|
|
+ dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+static void
|
|
|
+Blit4bto4Key(SDL_BlitInfo * info)
|
|
|
+{
|
|
|
+ int width = info->dst_w;
|
|
|
+ int height = info->dst_h;
|
|
|
+ Uint8 *src = info->src;
|
|
|
+ Uint32 *dst = (Uint32 *) info->dst;
|
|
|
+ int srcskip = info->src_skip;
|
|
|
+ int dstskip = info->dst_skip;
|
|
|
+ Uint32 ckey = info->colorkey;
|
|
|
+ Uint32 *map = (Uint32 *) info->table;
|
|
|
+ int c;
|
|
|
+
|
|
|
+ /* Set up some basic variables */
|
|
|
+ srcskip += width - (width + 1) / 2;
|
|
|
+
|
|
|
+ while (height--) {
|
|
|
+ Uint8 byte = 0, bit;
|
|
|
+ for (c = 0; c < width; ++c) {
|
|
|
+ if ((c & 0x1) == 0) {
|
|
|
+ byte = *src++;
|
|
|
+ }
|
|
|
+ bit = (byte & 0xF0) >> 4;
|
|
|
+ if (bit != ckey) {
|
|
|
+ *dst = map[bit];
|
|
|
+ }
|
|
|
+ byte <<= 4;
|
|
|
+ dst++;
|
|
|
+ }
|
|
|
+ src += srcskip;
|
|
|
+ dst = (Uint32 *) ((Uint8 *) dst + dstskip);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
SDL_BlitFunc
|
|
|
SDL_CalculateBlit0(SDL_Surface * surface)
|
|
|
{
|
|
|
int which;
|
|
|
|
|
|
+ /* 4bits to 32bits */
|
|
|
+ if (surface->format->BitsPerPixel == 4) {
|
|
|
+ if (surface->map->dst->format->BytesPerPixel == 4) {
|
|
|
+ switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
|
|
+ case 0:
|
|
|
+ return Blit4bto4;
|
|
|
+
|
|
|
+ case SDL_COPY_COLORKEY:
|
|
|
+ return Blit4bto4Key;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* We don't fully support 4-bit packed pixel modes */
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
if (surface->format->BitsPerPixel != 1) {
|
|
|
/* We don't support sub 8-bit packed pixel modes */
|
|
|
return (SDL_BlitFunc) NULL;
|