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