comparison src/video/SDL_RLEaccel.c @ 1428:5f52867ba65c

Update for Visual C++ 6.0
author Sam Lantinga <slouken@libsdl.org>
date Fri, 24 Feb 2006 18:24:57 +0000
parents d910939febfa
children 84de7511f79f
comparison
equal deleted inserted replaced
1427:5f5a74d29d18 1428:5f52867ba65c
108 #endif 108 #endif
109 109
110 #define PIXEL_COPY(to, from, len, bpp) \ 110 #define PIXEL_COPY(to, from, len, bpp) \
111 do { \ 111 do { \
112 if(bpp == 4) { \ 112 if(bpp == 4) { \
113 SDL_memcpy4(to, from, (unsigned)(len)); \ 113 SDL_memcpy4(to, from, (size_t)(len)); \
114 } else { \ 114 } else { \
115 SDL_memcpy(to, from, (unsigned)(len) * (bpp)); \ 115 SDL_memcpy(to, from, (size_t)(len) * (bpp)); \
116 } \ 116 } \
117 } while(0) 117 } while(0)
118 118
119 /* 119 /*
120 * Various colorkey blit methods, for opaque and per-surface alpha 120 * Various colorkey blit methods, for opaque and per-surface alpha
421 Uint32 d = *dst; \ 421 Uint32 d = *dst; \
422 s = (s | s << 16) & 0x07e0f81f; \ 422 s = (s | s << 16) & 0x07e0f81f; \
423 d = (d | d << 16) & 0x07e0f81f; \ 423 d = (d | d << 16) & 0x07e0f81f; \
424 d += (s - d) * ALPHA >> 5; \ 424 d += (s - d) * ALPHA >> 5; \
425 d &= 0x07e0f81f; \ 425 d &= 0x07e0f81f; \
426 *dst++ = d | d >> 16; \ 426 *dst++ = (Uint16)(d | d >> 16); \
427 } \ 427 } \
428 } while(0) 428 } while(0)
429 429
430 #define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \ 430 #define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \
431 do { \ 431 do { \
438 Uint32 d = *dst; \ 438 Uint32 d = *dst; \
439 s = (s | s << 16) & 0x03e07c1f; \ 439 s = (s | s << 16) & 0x03e07c1f; \
440 d = (d | d << 16) & 0x03e07c1f; \ 440 d = (d | d << 16) & 0x03e07c1f; \
441 d += (s - d) * ALPHA >> 5; \ 441 d += (s - d) * ALPHA >> 5; \
442 d &= 0x03e07c1f; \ 442 d &= 0x03e07c1f; \
443 *dst++ = d | d >> 16; \ 443 *dst++ = (Uint16)(d | d >> 16); \
444 } \ 444 } \
445 } while(0) 445 } while(0)
446 446
447 /* 447 /*
448 * The general slow catch-all function, for remaining depths and formats 448 * The general slow catch-all function, for remaining depths and formats
480 gd += (gs - gd) * alpha >> 8; \ 480 gd += (gs - gd) * alpha >> 8; \
481 bd += (bs - bd) * alpha >> 8; \ 481 bd += (bs - bd) * alpha >> 8; \
482 PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \ 482 PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \
483 switch(bpp) { \ 483 switch(bpp) { \
484 case 2: \ 484 case 2: \
485 *(Uint16 *)dst = d; \ 485 *(Uint16 *)dst = (Uint16)d; \
486 break; \ 486 break; \
487 case 3: \ 487 case 3: \
488 if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ 488 if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { \
489 dst[0] = d >> 16; \ 489 dst[0] = (Uint8)(d >> 16); \
490 dst[1] = d >> 8; \ 490 dst[1] = (Uint8)(d >> 8); \
491 dst[2] = d; \ 491 dst[2] = (Uint8)(d); \
492 } else { \ 492 } else { \
493 dst[0] = d; \ 493 dst[0] = (Uint8)d; \
494 dst[1] = d >> 8; \ 494 dst[1] = (Uint8)(d >> 8); \
495 dst[2] = d >> 16; \ 495 dst[2] = (Uint8)(d >> 16); \
496 } \ 496 } \
497 break; \ 497 break; \
498 case 4: \ 498 case 4: \
499 *(Uint32 *)dst = d; \ 499 *(Uint32 *)dst = d; \
500 break; \ 500 break; \
573 */ 573 */
574 574
575 /* helper: blend a single 16 bit pixel at 50% */ 575 /* helper: blend a single 16 bit pixel at 50% */
576 #define BLEND16_50(dst, src, mask) \ 576 #define BLEND16_50(dst, src, mask) \
577 do { \ 577 do { \
578 Uint32 s = *src++; \ 578 Uint32 s = *src++; \
579 Uint32 d = *dst; \ 579 Uint32 d = *dst; \
580 *dst++ = (((s & mask) + (d & mask)) >> 1) \ 580 *dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \
581 + (s & d & (~mask & 0xffff)); \ 581 (s & d & (~mask & 0xffff))); \
582 } while(0) 582 } while(0)
583 583
584 /* basic 16bpp blender. mask is the pixels to keep when adding. */ 584 /* basic 16bpp blender. mask is the pixels to keep when adding. */
585 #define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \ 585 #define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \
586 do { \ 586 do { \
969 * For 16bpp pixels, we have stored the 5 most significant alpha bits in 969 * For 16bpp pixels, we have stored the 5 most significant alpha bits in
970 * bits 5-10. As before, we can process all 3 RGB components at the same time. 970 * bits 5-10. As before, we can process all 3 RGB components at the same time.
971 */ 971 */
972 #define BLIT_TRANSL_565(src, dst) \ 972 #define BLIT_TRANSL_565(src, dst) \
973 do { \ 973 do { \
974 Uint32 s = src; \ 974 Uint32 s = src; \
975 Uint32 d = dst; \ 975 Uint32 d = dst; \
976 unsigned alpha = (s & 0x3e0) >> 5; \ 976 unsigned alpha = (s & 0x3e0) >> 5; \
977 s &= 0x07e0f81f; \ 977 s &= 0x07e0f81f; \
978 d = (d | d << 16) & 0x07e0f81f; \ 978 d = (d | d << 16) & 0x07e0f81f; \
979 d += (s - d) * alpha >> 5; \ 979 d += (s - d) * alpha >> 5; \
980 d &= 0x07e0f81f; \ 980 d &= 0x07e0f81f; \
981 dst = d | d >> 16; \ 981 dst = (Uint16)(d | d >> 16); \
982 } while(0) 982 } while(0)
983 983
984 #define BLIT_TRANSL_555(src, dst) \ 984 #define BLIT_TRANSL_555(src, dst) \
985 do { \ 985 do { \
986 Uint32 s = src; \ 986 Uint32 s = src; \
987 Uint32 d = dst; \ 987 Uint32 d = dst; \
988 unsigned alpha = (s & 0x3e0) >> 5; \ 988 unsigned alpha = (s & 0x3e0) >> 5; \
989 s &= 0x03e07c1f; \ 989 s &= 0x03e07c1f; \
990 d = (d | d << 16) & 0x03e07c1f; \ 990 d = (d | d << 16) & 0x03e07c1f; \
991 d += (s - d) * alpha >> 5; \ 991 d += (s - d) * alpha >> 5; \
992 d &= 0x03e07c1f; \ 992 d &= 0x03e07c1f; \
993 dst = d | d >> 16; \ 993 dst = (Uint16)(d | d >> 16); \
994 } while(0) 994 } while(0)
995 995
996 /* used to save the destination format in the encoding. Designed to be 996 /* used to save the destination format in the encoding. Designed to be
997 macro-compatible with SDL_PixelFormat but without the unneeded fields */ 997 macro-compatible with SDL_PixelFormat but without the unneeded fields */
998 typedef struct { 998 typedef struct {
999 Uint8 BytesPerPixel; 999 Uint8 BytesPerPixel;
1000 Uint8 Rloss; 1000 Uint8 Rloss;
1001 Uint8 Gloss; 1001 Uint8 Gloss;
1002 Uint8 Bloss; 1002 Uint8 Bloss;
1003 Uint8 Rshift; 1003 Uint8 Rshift;
1004 Uint8 Gshift; 1004 Uint8 Gshift;