src/video/SDL_blit_1.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 01 Feb 2006 06:32:25 +0000
changeset 1312 c9b51268668f
parent 769 b8d311d90021
child 1330 450721ad5436
permissions -rw-r--r--
Updated copyright information and removed rcs id lines (problematic in branch merges)
I batch edited these files, so please let me know if I've accidentally removed anybody's
credit here.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#include <stdio.h>
slouken@0
    24
slouken@0
    25
#include "SDL_types.h"
slouken@0
    26
#include "SDL_video.h"
slouken@0
    27
#include "SDL_blit.h"
slouken@0
    28
#include "SDL_sysvideo.h"
slouken@0
    29
#include "SDL_endian.h"
slouken@0
    30
slouken@0
    31
/* Functions to blit from 8-bit surfaces to other surfaces */
slouken@0
    32
slouken@0
    33
static void Blit1to1(SDL_BlitInfo *info)
slouken@0
    34
{
slouken@0
    35
#ifndef USE_DUFFS_LOOP
slouken@0
    36
	int c;
slouken@0
    37
#endif
slouken@0
    38
	int width, height;
slouken@0
    39
	Uint8 *src, *map, *dst;
slouken@0
    40
	int srcskip, dstskip;
slouken@0
    41
slouken@0
    42
	/* Set up some basic variables */
slouken@0
    43
	width = info->d_width;
slouken@0
    44
	height = info->d_height;
slouken@0
    45
	src = info->s_pixels;
slouken@0
    46
	srcskip = info->s_skip;
slouken@0
    47
	dst = info->d_pixels;
slouken@0
    48
	dstskip = info->d_skip;
slouken@0
    49
	map = info->table;
slouken@0
    50
slouken@0
    51
	while ( height-- ) {
slouken@0
    52
#ifdef USE_DUFFS_LOOP
slouken@0
    53
		DUFFS_LOOP(
slouken@0
    54
			{
slouken@0
    55
			  *dst = map[*src];
slouken@0
    56
			}
slouken@0
    57
			dst++;
slouken@0
    58
			src++;
slouken@0
    59
		, width);
slouken@0
    60
#else
slouken@0
    61
		for ( c=width; c; --c ) {
slouken@0
    62
		        *dst = map[*src];
slouken@0
    63
			dst++;
slouken@0
    64
			src++;
slouken@0
    65
		}
slouken@0
    66
#endif
slouken@0
    67
		src += srcskip;
slouken@0
    68
		dst += dstskip;
slouken@0
    69
	}
slouken@0
    70
}
slouken@0
    71
/* This is now endian dependent */
slouken@0
    72
#if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
slouken@0
    73
#define HI	1
slouken@0
    74
#define LO	0
slouken@0
    75
#else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
slouken@0
    76
#define HI	0
slouken@0
    77
#define LO	1
slouken@0
    78
#endif
slouken@0
    79
static void Blit1to2(SDL_BlitInfo *info)
slouken@0
    80
{
slouken@0
    81
#ifndef USE_DUFFS_LOOP
slouken@0
    82
	int c;
slouken@0
    83
#endif
slouken@0
    84
	int width, height;
slouken@0
    85
	Uint8 *src, *dst;
slouken@0
    86
	Uint16 *map;
slouken@0
    87
	int srcskip, dstskip;
slouken@0
    88
slouken@0
    89
	/* Set up some basic variables */
slouken@0
    90
	width = info->d_width;
slouken@0
    91
	height = info->d_height;
slouken@0
    92
	src = info->s_pixels;
slouken@0
    93
	srcskip = info->s_skip;
slouken@0
    94
	dst = info->d_pixels;
slouken@0
    95
	dstskip = info->d_skip;
slouken@0
    96
	map = (Uint16 *)info->table;
slouken@0
    97
slouken@0
    98
#ifdef USE_DUFFS_LOOP
slouken@0
    99
	while ( height-- ) {
slouken@0
   100
		DUFFS_LOOP(
slouken@0
   101
		{
slouken@0
   102
			*(Uint16 *)dst = map[*src++];
slouken@0
   103
			dst += 2;
slouken@0
   104
		},
slouken@0
   105
		width);
slouken@0
   106
		src += srcskip;
slouken@0
   107
		dst += dstskip;
slouken@0
   108
	}
slouken@0
   109
#else
slouken@0
   110
	/* Memory align at 4-byte boundary, if necessary */
slouken@0
   111
	if ( (long)dst & 0x03 ) {
slouken@0
   112
		/* Don't do anything if width is 0 */
slouken@0
   113
		if ( width == 0 ) {
slouken@0
   114
			return;
slouken@0
   115
		}
slouken@0
   116
		--width;
slouken@0
   117
slouken@0
   118
		while ( height-- ) {
slouken@0
   119
			/* Perform copy alignment */
slouken@0
   120
			*(Uint16 *)dst = map[*src++];
slouken@0
   121
			dst += 2;
slouken@0
   122
slouken@0
   123
			/* Copy in 4 pixel chunks */
slouken@0
   124
			for ( c=width/4; c; --c ) {
slouken@0
   125
				*(Uint32 *)dst =
slouken@0
   126
					(map[src[HI]]<<16)|(map[src[LO]]);
slouken@0
   127
				src += 2;
slouken@0
   128
				dst += 4;
slouken@0
   129
				*(Uint32 *)dst =
slouken@0
   130
					(map[src[HI]]<<16)|(map[src[LO]]);
slouken@0
   131
				src += 2;
slouken@0
   132
				dst += 4;
slouken@0
   133
			}
slouken@0
   134
			/* Get any leftovers */
slouken@91
   135
			switch (width & 3) {
slouken@0
   136
				case 3:
slouken@0
   137
					*(Uint16 *)dst = map[*src++];
slouken@0
   138
					dst += 2;
slouken@0
   139
				case 2:
slouken@0
   140
					*(Uint32 *)dst =
slouken@0
   141
					  (map[src[HI]]<<16)|(map[src[LO]]);
slouken@0
   142
					src += 2;
slouken@0
   143
					dst += 4;
slouken@0
   144
					break;
slouken@0
   145
				case 1:
slouken@0
   146
					*(Uint16 *)dst = map[*src++];
slouken@0
   147
					dst += 2;
slouken@0
   148
					break;
slouken@0
   149
			}
slouken@0
   150
			src += srcskip;
slouken@0
   151
			dst += dstskip;
slouken@0
   152
		}
slouken@0
   153
	} else { 
slouken@0
   154
		while ( height-- ) {
slouken@0
   155
			/* Copy in 4 pixel chunks */
slouken@0
   156
			for ( c=width/4; c; --c ) {
slouken@0
   157
				*(Uint32 *)dst =
slouken@0
   158
					(map[src[HI]]<<16)|(map[src[LO]]);
slouken@0
   159
				src += 2;
slouken@0
   160
				dst += 4;
slouken@0
   161
				*(Uint32 *)dst =
slouken@0
   162
					(map[src[HI]]<<16)|(map[src[LO]]);
slouken@0
   163
				src += 2;
slouken@0
   164
				dst += 4;
slouken@0
   165
			}
slouken@0
   166
			/* Get any leftovers */
slouken@91
   167
			switch (width & 3) {
slouken@0
   168
				case 3:
slouken@0
   169
					*(Uint16 *)dst = map[*src++];
slouken@0
   170
					dst += 2;
slouken@0
   171
				case 2:
slouken@0
   172
					*(Uint32 *)dst =
slouken@0
   173
					  (map[src[HI]]<<16)|(map[src[LO]]);
slouken@0
   174
					src += 2;
slouken@0
   175
					dst += 4;
slouken@0
   176
					break;
slouken@0
   177
				case 1:
slouken@0
   178
					*(Uint16 *)dst = map[*src++];
slouken@0
   179
					dst += 2;
slouken@0
   180
					break;
slouken@0
   181
			}
slouken@0
   182
			src += srcskip;
slouken@0
   183
			dst += dstskip;
slouken@0
   184
		}
slouken@0
   185
	}
slouken@0
   186
#endif /* USE_DUFFS_LOOP */
slouken@0
   187
}
slouken@0
   188
static void Blit1to3(SDL_BlitInfo *info)
slouken@0
   189
{
slouken@0
   190
#ifndef USE_DUFFS_LOOP
slouken@0
   191
	int c;
slouken@0
   192
#endif
slouken@0
   193
	int o;
slouken@0
   194
	int width, height;
slouken@0
   195
	Uint8 *src, *map, *dst;
slouken@0
   196
	int srcskip, dstskip;
slouken@0
   197
slouken@0
   198
	/* Set up some basic variables */
slouken@0
   199
	width = info->d_width;
slouken@0
   200
	height = info->d_height;
slouken@0
   201
	src = info->s_pixels;
slouken@0
   202
	srcskip = info->s_skip;
slouken@0
   203
	dst = info->d_pixels;
slouken@0
   204
	dstskip = info->d_skip;
slouken@0
   205
	map = info->table;
slouken@0
   206
slouken@0
   207
	while ( height-- ) {
slouken@0
   208
#ifdef USE_DUFFS_LOOP
slouken@0
   209
		DUFFS_LOOP(
slouken@0
   210
			{
slouken@0
   211
				o = *src * 4;
slouken@0
   212
				dst[0] = map[o++];
slouken@0
   213
				dst[1] = map[o++];
slouken@0
   214
				dst[2] = map[o++];
slouken@0
   215
			}
slouken@0
   216
			src++;
slouken@0
   217
			dst += 3;
slouken@0
   218
		, width);
slouken@0
   219
#else
slouken@0
   220
		for ( c=width; c; --c ) {
slouken@0
   221
			o = *src * 4;
slouken@0
   222
			dst[0] = map[o++];
slouken@0
   223
			dst[1] = map[o++];
slouken@0
   224
			dst[2] = map[o++];
slouken@0
   225
			src++;
slouken@0
   226
			dst += 3;
slouken@0
   227
		}
slouken@0
   228
#endif /* USE_DUFFS_LOOP */
slouken@0
   229
		src += srcskip;
slouken@0
   230
		dst += dstskip;
slouken@0
   231
	}
slouken@0
   232
}
slouken@0
   233
static void Blit1to4(SDL_BlitInfo *info)
slouken@0
   234
{
slouken@0
   235
#ifndef USE_DUFFS_LOOP
slouken@0
   236
	int c;
slouken@0
   237
#endif
slouken@0
   238
	int width, height;
slouken@0
   239
	Uint8 *src;
slouken@0
   240
	Uint32 *map, *dst;
slouken@0
   241
	int srcskip, dstskip;
slouken@0
   242
slouken@0
   243
	/* Set up some basic variables */
slouken@0
   244
	width = info->d_width;
slouken@0
   245
	height = info->d_height;
slouken@0
   246
	src = info->s_pixels;
slouken@0
   247
	srcskip = info->s_skip;
slouken@0
   248
	dst = (Uint32 *)info->d_pixels;
slouken@0
   249
	dstskip = info->d_skip/4;
slouken@0
   250
	map = (Uint32 *)info->table;
slouken@0
   251
slouken@0
   252
	while ( height-- ) {
slouken@0
   253
#ifdef USE_DUFFS_LOOP
slouken@0
   254
		DUFFS_LOOP(
slouken@0
   255
			*dst++ = map[*src++];
slouken@0
   256
		, width);
slouken@0
   257
#else
slouken@0
   258
		for ( c=width/4; c; --c ) {
slouken@0
   259
			*dst++ = map[*src++];
slouken@0
   260
			*dst++ = map[*src++];
slouken@0
   261
			*dst++ = map[*src++];
slouken@0
   262
			*dst++ = map[*src++];
slouken@0
   263
		}
slouken@91
   264
		switch ( width & 3 ) {
slouken@0
   265
			case 3:
slouken@0
   266
				*dst++ = map[*src++];
slouken@0
   267
			case 2:
slouken@0
   268
				*dst++ = map[*src++];
slouken@0
   269
			case 1:
slouken@0
   270
				*dst++ = map[*src++];
slouken@0
   271
		}
slouken@0
   272
#endif /* USE_DUFFS_LOOP */
slouken@0
   273
		src += srcskip;
slouken@0
   274
		dst += dstskip;
slouken@0
   275
	}
slouken@0
   276
}
slouken@0
   277
slouken@0
   278
static void Blit1to1Key(SDL_BlitInfo *info)
slouken@0
   279
{
slouken@0
   280
	int width = info->d_width;
slouken@0
   281
	int height = info->d_height;
slouken@0
   282
	Uint8 *src = info->s_pixels;
slouken@0
   283
	int srcskip = info->s_skip;
slouken@0
   284
	Uint8 *dst = info->d_pixels;
slouken@0
   285
	int dstskip = info->d_skip;
slouken@0
   286
	Uint8 *palmap = info->table;
slouken@0
   287
	Uint32 ckey = info->src->colorkey;
slouken@0
   288
        
slouken@0
   289
	if ( palmap ) {
slouken@0
   290
		while ( height-- ) {
slouken@0
   291
			DUFFS_LOOP(
slouken@0
   292
			{
slouken@0
   293
				if ( *src != ckey ) {
slouken@0
   294
				  *dst = palmap[*src];
slouken@0
   295
				}
slouken@0
   296
				dst++;
slouken@0
   297
				src++;
slouken@0
   298
			},
slouken@0
   299
			width);
slouken@0
   300
			src += srcskip;
slouken@0
   301
			dst += dstskip;
slouken@0
   302
		}
slouken@0
   303
	} else {
slouken@0
   304
		while ( height-- ) {
slouken@0
   305
			DUFFS_LOOP(
slouken@0
   306
			{
slouken@0
   307
				if ( *src != ckey ) {
slouken@0
   308
				  *dst = *src;
slouken@0
   309
				}
slouken@0
   310
				dst++;
slouken@0
   311
				src++;
slouken@0
   312
			},
slouken@0
   313
			width);
slouken@0
   314
			src += srcskip;
slouken@0
   315
			dst += dstskip;
slouken@0
   316
		}
slouken@0
   317
	}
slouken@0
   318
}
slouken@0
   319
slouken@0
   320
static void Blit1to2Key(SDL_BlitInfo *info)
slouken@0
   321
{
slouken@0
   322
	int width = info->d_width;
slouken@0
   323
	int height = info->d_height;
slouken@0
   324
	Uint8 *src = info->s_pixels;
slouken@0
   325
	int srcskip = info->s_skip;
slouken@0
   326
	Uint16 *dstp = (Uint16 *)info->d_pixels;
slouken@0
   327
	int dstskip = info->d_skip;
slouken@0
   328
	Uint16 *palmap = (Uint16 *)info->table;
slouken@0
   329
	Uint32 ckey = info->src->colorkey;
slouken@0
   330
slouken@0
   331
	/* Set up some basic variables */
slouken@0
   332
	dstskip /= 2;
slouken@0
   333
slouken@0
   334
	while ( height-- ) {
slouken@0
   335
		DUFFS_LOOP(
slouken@0
   336
		{
slouken@0
   337
			if ( *src != ckey ) {
slouken@0
   338
				*dstp=palmap[*src];
slouken@0
   339
			}
slouken@0
   340
			src++;
slouken@0
   341
			dstp++;
slouken@0
   342
		},
slouken@0
   343
		width);
slouken@0
   344
		src += srcskip;
slouken@0
   345
		dstp += dstskip;
slouken@0
   346
	}
slouken@0
   347
}
slouken@0
   348
slouken@0
   349
static void Blit1to3Key(SDL_BlitInfo *info)
slouken@0
   350
{
slouken@0
   351
	int width = info->d_width;
slouken@0
   352
	int height = info->d_height;
slouken@0
   353
	Uint8 *src = info->s_pixels;
slouken@0
   354
	int srcskip = info->s_skip;
slouken@0
   355
	Uint8 *dst = info->d_pixels;
slouken@0
   356
	int dstskip = info->d_skip;
slouken@0
   357
	Uint8 *palmap = info->table;
slouken@0
   358
	Uint32 ckey = info->src->colorkey;
slouken@0
   359
	int o;
slouken@0
   360
slouken@0
   361
	while ( height-- ) {
slouken@0
   362
		DUFFS_LOOP(
slouken@0
   363
		{
slouken@0
   364
			if ( *src != ckey ) {
slouken@0
   365
				o = *src * 4;
slouken@0
   366
				dst[0] = palmap[o++];
slouken@0
   367
				dst[1] = palmap[o++];
slouken@0
   368
				dst[2] = palmap[o++];
slouken@0
   369
			}
slouken@0
   370
			src++;
slouken@0
   371
			dst += 3;
slouken@0
   372
		},
slouken@0
   373
		width);
slouken@0
   374
		src += srcskip;
slouken@0
   375
		dst += dstskip;
slouken@0
   376
	}
slouken@0
   377
}
slouken@0
   378
slouken@0
   379
static void Blit1to4Key(SDL_BlitInfo *info)
slouken@0
   380
{
slouken@0
   381
	int width = info->d_width;
slouken@0
   382
	int height = info->d_height;
slouken@0
   383
	Uint8 *src = info->s_pixels;
slouken@0
   384
	int srcskip = info->s_skip;
slouken@0
   385
	Uint32 *dstp = (Uint32 *)info->d_pixels;
slouken@0
   386
	int dstskip = info->d_skip;
slouken@0
   387
	Uint32 *palmap = (Uint32 *)info->table;
slouken@0
   388
	Uint32 ckey = info->src->colorkey;
slouken@0
   389
slouken@0
   390
	/* Set up some basic variables */
slouken@0
   391
	dstskip /= 4;
slouken@0
   392
slouken@0
   393
	while ( height-- ) {
slouken@0
   394
		DUFFS_LOOP(
slouken@0
   395
		{
slouken@0
   396
			if ( *src != ckey ) {
slouken@0
   397
				*dstp = palmap[*src];
slouken@0
   398
			}
slouken@0
   399
			src++;
slouken@0
   400
			dstp++;
slouken@0
   401
		},
slouken@0
   402
		width);
slouken@0
   403
		src += srcskip;
slouken@0
   404
		dstp += dstskip;
slouken@0
   405
	}
slouken@0
   406
}
slouken@0
   407
slouken@0
   408
static void Blit1toNAlpha(SDL_BlitInfo *info)
slouken@0
   409
{
slouken@0
   410
	int width = info->d_width;
slouken@0
   411
	int height = info->d_height;
slouken@0
   412
	Uint8 *src = info->s_pixels;
slouken@0
   413
	int srcskip = info->s_skip;
slouken@0
   414
	Uint8 *dst = info->d_pixels;
slouken@0
   415
	int dstskip = info->d_skip;
slouken@0
   416
	SDL_PixelFormat *dstfmt = info->dst;
slouken@0
   417
	const SDL_Color *srcpal	= info->src->palette->colors;
slouken@0
   418
	int dstbpp;
slouken@0
   419
	const int A = info->src->alpha;
slouken@0
   420
slouken@0
   421
	/* Set up some basic variables */
slouken@0
   422
	dstbpp = dstfmt->BytesPerPixel;
slouken@0
   423
slouken@0
   424
	while ( height-- ) {
slouken@0
   425
	        int sR, sG, sB;
slouken@0
   426
		int dR, dG, dB;
slouken@0
   427
	    	DUFFS_LOOP4(
slouken@0
   428
			{
slouken@0
   429
			        Uint32 pixel;
slouken@0
   430
				sR = srcpal[*src].r;
slouken@0
   431
				sG = srcpal[*src].g;
slouken@0
   432
				sB = srcpal[*src].b;
slouken@0
   433
				DISEMBLE_RGB(dst, dstbpp, dstfmt,
slouken@0
   434
					     pixel, dR, dG, dB);
slouken@0
   435
				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
slouken@0
   436
			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
slouken@0
   437
				src++;
slouken@0
   438
				dst += dstbpp;
slouken@0
   439
			},
slouken@0
   440
			width);
slouken@0
   441
		src += srcskip;
slouken@0
   442
		dst += dstskip;
slouken@0
   443
	}
slouken@0
   444
}
slouken@0
   445
slouken@0
   446
static void Blit1toNAlphaKey(SDL_BlitInfo *info)
slouken@0
   447
{
slouken@0
   448
	int width = info->d_width;
slouken@0
   449
	int height = info->d_height;
slouken@0
   450
	Uint8 *src = info->s_pixels;
slouken@0
   451
	int srcskip = info->s_skip;
slouken@0
   452
	Uint8 *dst = info->d_pixels;
slouken@0
   453
	int dstskip = info->d_skip;
slouken@0
   454
	SDL_PixelFormat *srcfmt = info->src;
slouken@0
   455
	SDL_PixelFormat *dstfmt = info->dst;
slouken@0
   456
	const SDL_Color *srcpal	= info->src->palette->colors;
slouken@0
   457
	Uint32 ckey = srcfmt->colorkey;
slouken@0
   458
	int dstbpp;
slouken@0
   459
	const int A = srcfmt->alpha;
slouken@0
   460
slouken@0
   461
	/* Set up some basic variables */
slouken@0
   462
	dstbpp = dstfmt->BytesPerPixel;
slouken@0
   463
slouken@0
   464
	while ( height-- ) {
slouken@0
   465
	        int sR, sG, sB;
slouken@0
   466
		int dR, dG, dB;
slouken@0
   467
		DUFFS_LOOP(
slouken@0
   468
		{
slouken@0
   469
			if ( *src != ckey ) {
slouken@0
   470
			        Uint32 pixel;
slouken@0
   471
				sR = srcpal[*src].r;
slouken@0
   472
				sG = srcpal[*src].g;
slouken@0
   473
				sB = srcpal[*src].b;
slouken@0
   474
				DISEMBLE_RGB(dst, dstbpp, dstfmt,
slouken@0
   475
							pixel, dR, dG, dB);
slouken@0
   476
				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
slouken@0
   477
			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
slouken@0
   478
			}
slouken@0
   479
			src++;
slouken@0
   480
			dst += dstbpp;
slouken@0
   481
		},
slouken@0
   482
		width);
slouken@0
   483
		src += srcskip;
slouken@0
   484
		dst += dstskip;
slouken@0
   485
	}
slouken@0
   486
}
slouken@0
   487
slouken@0
   488
static SDL_loblit one_blit[] = {
slouken@0
   489
	NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
slouken@0
   490
};
slouken@0
   491
slouken@0
   492
static SDL_loblit one_blitkey[] = {
slouken@0
   493
        NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
slouken@0
   494
};
slouken@0
   495
slouken@0
   496
SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int blit_index)
slouken@0
   497
{
slouken@0
   498
	int which;
slouken@0
   499
	SDL_PixelFormat *dstfmt;
slouken@0
   500
slouken@0
   501
	dstfmt = surface->map->dst->format;
slouken@0
   502
	if ( dstfmt->BitsPerPixel < 8 ) {
slouken@0
   503
		which = 0;
slouken@0
   504
	} else {
slouken@0
   505
		which = dstfmt->BytesPerPixel;
slouken@0
   506
	}
slouken@0
   507
	switch(blit_index) {
slouken@0
   508
	case 0:			/* copy */
slouken@0
   509
	    return one_blit[which];
slouken@0
   510
slouken@0
   511
	case 1:			/* colorkey */
slouken@0
   512
	    return one_blitkey[which];
slouken@0
   513
slouken@0
   514
	case 2:			/* alpha */
slouken@0
   515
	    /* Supporting 8bpp->8bpp alpha is doable but requires lots of
slouken@0
   516
	       tables which consume space and takes time to precompute,
slouken@0
   517
	       so is better left to the user */
slouken@0
   518
	    return which >= 2 ? Blit1toNAlpha : NULL;
slouken@0
   519
slouken@0
   520
	case 3:			/* alpha + colorkey */
slouken@0
   521
	    return which >= 2 ? Blit1toNAlphaKey : NULL;
slouken@0
   522
slouken@0
   523
	}
slouken@0
   524
	return NULL;
slouken@0
   525
}