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