[AD] fix_teh_datafile |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
make Allegro perfect! (by shorten it a bit) ;) with this patch: old datafile.o 24626 Bytes new datafile.o 24430 Bytes ------------------------------------------------- HKNETMAIL.COM Free WEB MAIL Service by HKNET
--- datafile.c 2003-06-23 10:40:46.000000000 -0400 +++ datanew.c 2003-06-30 13:56:58.000000000 -0400 @@ -151,11 +151,11 @@ static BITMAP *read_bitmap(PACKFILE *f, p16 = (unsigned short *)bmp->line[y]; for (x=0; x<w; x++) { - c = pack_igetw(f); - r = _rgb_scale_5[(c >> 11) & 0x1F]; /* stored as 16 bit */ - g = _rgb_scale_6[(c >> 5) & 0x3F]; - b = _rgb_scale_5[c & 0x1F]; - p16[x] = makecol15(r, g, b); + c = pack_igetw(f); /* stored as 16 bit */ + p16[x] = makecol15( + _rgb_scale_5[(c>>11) & 0x1F], + _rgb_scale_6[(c>>5) & 0x3F], + _rgb_scale_5[c & 0x1F]); } } break; @@ -167,10 +167,10 @@ static BITMAP *read_bitmap(PACKFILE *f, for (x=0; x<w; x++) { c = pack_igetw(f); - r = _rgb_scale_5[(c >> 11) & 0x1F]; - g = _rgb_scale_6[(c >> 5) & 0x3F]; - b = _rgb_scale_5[c & 0x1F]; - p16[x] = makecol16(r, g, b); + p16[x] = makecol16( + _rgb_scale_5[(c>>11) & 0x1F], + _rgb_scale_6[(c>>5) & 0x3F], + _rgb_scale_5[c & 0x1F]); } } break; @@ -179,16 +179,10 @@ static BITMAP *read_bitmap(PACKFILE *f, /* 24bit truecolor */ for (y=0; y<h; y++) { for (x=0; x<w; x++) { - r = pack_getc(f); - g = pack_getc(f); - b = pack_getc(f); - - if (rgba) - pack_getc(f); - - bmp->line[y][x*3+_rgb_r_shift_24/8] = r; - bmp->line[y][x*3+_rgb_g_shift_24/8] = g; - bmp->line[y][x*3+_rgb_b_shift_24/8] = b; + bmp->line[y][x*3+_rgb_r_shift_24/8] = pack_getc(f); + bmp->line[y][x*3+_rgb_g_shift_24/8] = pack_getc(f); + bmp->line[y][x*3+_rgb_b_shift_24/8] = pack_getc(f); + if (rgba) pack_getc(f); } } break; @@ -202,13 +196,7 @@ static BITMAP *read_bitmap(PACKFILE *f, r = pack_getc(f); g = pack_getc(f); b = pack_getc(f); - - if (rgba) - a = pack_getc(f); - else - a = 0; - - p32[x] = makeacol32(r, g, b, a); + p32[x] = makeacol32(r, g, b, (rgba)?pack_getc(f):0); } } break; @@ -728,11 +716,10 @@ static RLE_SPRITE *read_rle_sprite(PACKF while (x-- > 0) { c = pack_igetw(f); - r = _rgb_scale_5[(c >> 11) & 0x1F]; - g = _rgb_scale_6[(c >> 5) & 0x3F]; - b = _rgb_scale_5[c & 0x1F]; - *p16 = makecol_depth(bits, r, g, b); - p16++; + *p16++ = makecol_depth(bits, + _rgb_scale_5[(c>>11) & 0x1F], + _rgb_scale_6[(c>>5) & 0x3F], + _rgb_scale_5[c & 0x1F]); } } @@ -770,13 +757,7 @@ static RLE_SPRITE *read_rle_sprite(PACKF r = pack_getc(f); g = pack_getc(f); b = pack_getc(f); - - if (rgba) - a = pack_getc(f); - else - a = 0; - - *p32 = makeacol_depth(bits, r, g, b, a); + *p32 = makeacol_depth(bits, r, g, b, (rgba)?pack_getc(f):0); p32++; } @@ -1702,10 +1683,10 @@ void fixup_datafile(DATAFILE *data) for (x=0; x<bmp->w; x++) { c = p16[x]; - r = _rgb_scale_5[c & 0x1F]; - g = _rgb_scale_5[(c >> 5) & 0x1F]; - b = _rgb_scale_5[(c >> 10) & 0x1F]; - p16[x] = makecol_depth(depth, r, g, b); + p16[x] = makecol_depth(depth, + _rgb_scale_5[c & 0x1F], + _rgb_scale_5[(c>>5) & 0x1F], + _rgb_scale_5[(c>>10) & 0x1F]); } } break; @@ -1731,12 +1712,10 @@ void fixup_datafile(DATAFILE *data) for (x=0; x<bmp->w; x++) { c = p16[x]; - r = _rgb_scale_5[c & 0x1F]; - g = _rgb_scale_6[(c >> 5) & 0x3F]; - b = _rgb_scale_5[(c >> 11) & 0x1F]; - if (_color_conv & COLORCONV_KEEP_TRANS && depth == 15 && - c == 0xf83f) g = 8; /* don't end up as mask color */ - p16[x] = makecol_depth(depth, r, g, b); + p16[x] = makecol_depth(depth, + _rgb_scale_5[c & 0x1F], + (_color_conv&COLORCONV_KEEP_TRANS && depth==15 && c==0xf83f)?8:_rgb_scale_6[(c>>5) & 0x3F], /* don't end up as mask color */ + _rgb_scale_5[(c>>11) & 0x1F]); } } break; @@ -1753,10 +1732,10 @@ void fixup_datafile(DATAFILE *data) for (x=0; x<bmp->w; x++) { c = READ3BYTES(p8+x*3); - r = (c & 0xFF); - g = (c >> 8) & 0xFF; - b = (c >> 16) & 0xFF; - WRITE3BYTES(p8+x*3, makecol24(r, g, b)); + WRITE3BYTES(p8+x*3, makecol24( + (c & 0xFF), + (c>>8) & 0xFF, + (c>>16) & 0xFF)); } } break; @@ -1773,11 +1752,11 @@ void fixup_datafile(DATAFILE *data) for (x=0; x<bmp->w; x++) { c = p32[x]; - r = (c & 0xFF); - g = (c >> 8) & 0xFF; - b = (c >> 16) & 0xFF; - a = (c >> 24) & 0xFF; - p32[x] = makeacol32(r, g, b, a); + p32[x] = makeacol32( + (c & 0xFF), + (c>>8) & 0xFF, + (c>>16) & 0xFF, + (c>>24) & 0xFF); } } break; @@ -1818,11 +1797,10 @@ void fixup_datafile(DATAFILE *data) s16++; while (x-- > 0) { c = *s16; - r = _rgb_scale_5[c & 0x1F]; - g = _rgb_scale_5[(c >> 5) & 0x1F]; - b = _rgb_scale_5[(c >> 10) & 0x1F]; - *s16 = makecol_depth(depth, r, g, b); - s16++; + *s16++ = makecol_depth(depth, + _rgb_scale_5[c & 0x1F], + _rgb_scale_5[(c>>5) & 0x1F], + _rgb_scale_5[(c>>10) & 0x1F]); } } else @@ -1855,11 +1833,10 @@ void fixup_datafile(DATAFILE *data) s16++; while (x-- > 0) { c = *s16; - r = _rgb_scale_5[c & 0x1F]; - g = _rgb_scale_6[(c >> 5) & 0x3F]; - b = _rgb_scale_5[(c >> 11) & 0x1F]; - *s16 = makecol_depth(depth, r, g, b); - s16++; + *s16++ = makecol_depth(depth, + _rgb_scale_5[c & 0x1F], + _rgb_scale_6[(c>>5) & 0x3F], + _rgb_scale_5[(c>>11) & 0x1F]); } } else @@ -1896,11 +1873,10 @@ void fixup_datafile(DATAFILE *data) s32++; while (x-- > 0) { c = *s32; - r = (c & 0xFF); - g = (c>>8) & 0xFF; - b = (c>>16) & 0xFF; - *s32 = makecol_depth(depth, r, g, b); - s32++; + *s32++ = makecol_depth(depth, + (c & 0xFF), + (c>>8) & 0xFF, + (c>>16) & 0xFF); } } else @@ -1941,8 +1917,7 @@ void fixup_datafile(DATAFILE *data) g = (c>>8) & 0xFF; b = (c>>16) & 0xFF; if (depth == 32) { - a = (c>>24) & 0xFF; - *s32 = makeacol32(r, g, b, a); + *s32 = makeacol32(r, g, b, (c>>24) & 0xFF); } else *s32 = makecol24(r, g, b);
Attachment:
datafile.gz
Description: application/gzip-compressed
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |