diff --git a/gfx.c b/gfx.c index fdb49353bd..61b3c0a262 100644 --- a/gfx.c +++ b/gfx.c @@ -675,126 +675,129 @@ static void GfxBlitTileZoomIn(BlitterParams *bp) Pixel *dst; const byte *ctab; - if (bp->mode & 1) { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - - do { + src_o += ReadLE16Aligned(src_o + bp->start_y * 2); + switch (bp->mode) { + case 1: do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src = src_o + 2; - src_o += num + 2; + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src = src_o + 2; + src_o += num + 2; - dst = bp->dst; + dst = bp->dst; - if ( (skip -= bp->start_x) > 0) { - dst += skip; - } else { - src -= skip; - num += skip; - if (num <= 0) continue; - skip = 0; - } + if ( (skip -= bp->start_x) > 0) { + dst += skip; + } else { + src -= skip; + num += skip; + if (num <= 0) continue; + skip = 0; + } - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } - ctab = _color_remap_ptr; + ctab = _color_remap_ptr; - for (; num >= 4; num -=4) { - dst[3] = ctab[src[3]]; - dst[2] = ctab[src[2]]; - dst[1] = ctab[src[1]]; - dst[0] = ctab[src[0]]; - dst += 4; - src += 4; - } - for (; num != 0; num--) *dst++ = ctab[*src++]; - } while (!(done & 0x80)); - - bp->dst += bp->pitch; - } while (--bp->height != 0); - } else if (bp->mode & 2) { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - do { - do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src_o += num + 2; - - dst = bp->dst; - - if ( (skip -= bp->start_x) > 0) { - dst += skip; - } else { - num += skip; - if (num <= 0) continue; - skip = 0; - } - - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } - - ctab = _color_remap_ptr; - for (; num != 0; num--) { - *dst = ctab[*dst]; - dst++; - } - } while (!(done & 0x80)); - - bp->dst += bp->pitch; - } while (--bp->height != 0); - } else { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - do { - do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src = src_o + 2; - src_o += num + 2; - - dst = bp->dst; - - if ( (skip -= bp->start_x) > 0) { - dst += skip; - } else { - src -= skip; - num += skip; - if (num <= 0) continue; - skip = 0; - } - - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } -#if defined(_WIN32) - if (num & 1) *dst++ = *src++; - if (num & 2) { *(uint16*)dst = *(uint16*)src; dst += 2; src += 2; } - if (num >>= 2) { - do { - *(uint32*)dst = *(uint32*)src; + for (; num >= 4; num -=4) { + dst[3] = ctab[src[3]]; + dst[2] = ctab[src[2]]; + dst[1] = ctab[src[1]]; + dst[0] = ctab[src[0]]; dst += 4; src += 4; - } while (--num != 0); - } -#else - memcpy(dst, src, num); -#endif - } while (!(done & 0x80)); + } + for (; num != 0; num--) *dst++ = ctab[*src++]; + } while (!(done & 0x80)); - bp->dst += bp->pitch; - } while (--bp->height != 0); + bp->dst += bp->pitch; + } while (--bp->height != 0); + break; + + case 2: + do { + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src_o += num + 2; + + dst = bp->dst; + + if ( (skip -= bp->start_x) > 0) { + dst += skip; + } else { + num += skip; + if (num <= 0) continue; + skip = 0; + } + + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } + + ctab = _color_remap_ptr; + for (; num != 0; num--) { + *dst = ctab[*dst]; + dst++; + } + } while (!(done & 0x80)); + + bp->dst += bp->pitch; + } while (--bp->height != 0); + break; + + default: + do { + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src = src_o + 2; + src_o += num + 2; + + dst = bp->dst; + + if ( (skip -= bp->start_x) > 0) { + dst += skip; + } else { + src -= skip; + num += skip; + if (num <= 0) continue; + skip = 0; + } + + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } +#if defined(_WIN32) + if (num & 1) *dst++ = *src++; + if (num & 2) { *(uint16*)dst = *(uint16*)src; dst += 2; src += 2; } + if (num >>= 2) { + do { + *(uint32*)dst = *(uint32*)src; + dst += 4; + src += 4; + } while (--num != 0); + } +#else + memcpy(dst, src, num); +#endif + } while (!(done & 0x80)); + + bp->dst += bp->pitch; + } while (--bp->height != 0); + break; } } @@ -809,62 +812,68 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp) assert(height > 0); assert(width > 0); - if (bp->mode & 1) { - if (bp->info & 1) { - const byte *ctab = _color_remap_ptr; + switch (bp->mode) { + case 1: + if (bp->info & 1) { + const byte *ctab = _color_remap_ptr; - do { - for (i = 0; i != width; i++) { - byte b = ctab[src[i]]; + do { + for (i = 0; i != width; i++) { + byte b = ctab[src[i]]; - if (b != 0) dst[i] = b; - } - src += bp->width_org; - dst += bp->pitch; - } while (--height != 0); - } - } else if (bp->mode & 2) { - if (bp->info & 1) { - const byte *ctab = _color_remap_ptr; + if (b != 0) dst[i] = b; + } + src += bp->width_org; + dst += bp->pitch; + } while (--height != 0); + } + break; - do { - for (i = 0; i != width; i++) - if (src[i] != 0) dst[i] = ctab[dst[i]]; - src += bp->width_org; - dst += bp->pitch; - } while (--height != 0); - } - } else { - if (!(bp->info & 1)) { - do { - memcpy(dst, src, width); - src += bp->width_org; - dst += bp->pitch; - } while (--height != 0); - } else { - do { - int n = width; + case 2: + if (bp->info & 1) { + const byte *ctab = _color_remap_ptr; - for (; n >= 4; n -= 4) { - if (src[0] != 0) dst[0] = src[0]; - if (src[1] != 0) dst[1] = src[1]; - if (src[2] != 0) dst[2] = src[2]; - if (src[3] != 0) dst[3] = src[3]; + do { + for (i = 0; i != width; i++) + if (src[i] != 0) dst[i] = ctab[dst[i]]; + src += bp->width_org; + dst += bp->pitch; + } while (--height != 0); + } + break; - dst += 4; - src += 4; - } + default: + if (!(bp->info & 1)) { + do { + memcpy(dst, src, width); + src += bp->width_org; + dst += bp->pitch; + } while (--height != 0); + } else { + do { + int n = width; - for (; n != 0; n--) { - if (src[0] != 0) dst[0] = src[0]; - src++; - dst++; - } + for (; n >= 4; n -= 4) { + if (src[0] != 0) dst[0] = src[0]; + if (src[1] != 0) dst[1] = src[1]; + if (src[2] != 0) dst[2] = src[2]; + if (src[3] != 0) dst[3] = src[3]; - src += bp->width_org - width; - dst += bp->pitch - width; - } while (--height != 0); - } + dst += 4; + src += 4; + } + + for (; n != 0; n--) { + if (src[0] != 0) dst[0] = src[0]; + src++; + dst++; + } + + src += bp->width_org - width; + dst += bp->pitch - width; + } while (--height != 0); + } + break; } } @@ -877,151 +886,155 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp) Pixel *dst; const byte *ctab; - if (bp->mode & 1) { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - do { + src_o += ReadLE16Aligned(src_o + bp->start_y * 2); + switch (bp->mode) { + case 1: do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src = src_o + 2; - src_o += num + 2; + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src = src_o + 2; + src_o += num + 2; - dst = bp->dst; + dst = bp->dst; - if (skip & 1) { - skip++; - src++; - if (--num == 0) continue; - } + if (skip & 1) { + skip++; + src++; + if (--num == 0) continue; + } - if ( (skip -= bp->start_x) > 0) { - dst += skip >> 1; - } else { - src -= skip; - num += skip; - if (num <= 0) continue; - skip = 0; - } + if ( (skip -= bp->start_x) > 0) { + dst += skip >> 1; + } else { + src -= skip; + num += skip; + if (num <= 0) continue; + skip = 0; + } - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } - ctab = _color_remap_ptr; - num = (num + 1) >> 1; - for (; num != 0; num--) { - *dst = ctab[*src]; - dst++; - src += 2; - } - } while (!(done & 0x80)); - bp->dst += bp->pitch; - if (--bp->height == 0) return; + ctab = _color_remap_ptr; + num = (num + 1) >> 1; + for (; num != 0; num--) { + *dst = ctab[*src]; + dst++; + src += 2; + } + } while (!(done & 0x80)); + bp->dst += bp->pitch; + if (--bp->height == 0) return; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + } while (--bp->height != 0); + break; + + case 2: do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - } while (--bp->height != 0); - } else if (bp->mode & 2) { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - do { + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src_o += num + 2; + + dst = bp->dst; + + if (skip & 1) { + skip++; + if (--num == 0) continue; + } + + if ( (skip -= bp->start_x) > 0) { + dst += skip >> 1; + } else { + num += skip; + if (num <= 0) continue; + skip = 0; + } + + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } + + ctab = _color_remap_ptr; + num = (num + 1) >> 1; + for (; num != 0; num--) { + *dst = ctab[*dst]; + dst++; + } + } while (!(done & 0x80)); + bp->dst += bp->pitch; + if (--bp->height == 0) return; + + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + } while (--bp->height != 0); + break; + + default: do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src_o += num + 2; + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src = src_o + 2; + src_o += num + 2; - dst = bp->dst; + dst = bp->dst; - if (skip & 1) { - skip++; - if (--num == 0) continue; - } + if (skip & 1) { + skip++; + src++; + if (--num == 0) continue; + } - if ( (skip -= bp->start_x) > 0) { - dst += skip >> 1; - } else { - num += skip; - if (num <= 0) continue; - skip = 0; - } + if ( (skip -= bp->start_x) > 0) { + dst += skip >> 1; + } else { + src -= skip; + num += skip; + if (num <= 0) continue; + skip = 0; + } - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } - ctab = _color_remap_ptr; - num = (num + 1) >> 1; - for (; num != 0; num--) { - *dst = ctab[*dst]; - dst++; - } - } while (!(done & 0x80)); - bp->dst += bp->pitch; - if (--bp->height == 0) return; + num = (num + 1) >> 1; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - } while (--bp->height != 0); - } else { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - do { - do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src = src_o + 2; - src_o += num + 2; + for (; num != 0; num--) { + *dst = *src; + dst++; + src += 2; + } - dst = bp->dst; + } while (!(done & 0x80)); - if (skip & 1) { - skip++; - src++; - if (--num == 0) continue; - } + bp->dst += bp->pitch; + if (--bp->height == 0) return; - if ( (skip -= bp->start_x) > 0) { - dst += skip >> 1; - } else { - src -= skip; - num += skip; - if (num <= 0) continue; - skip = 0; - } - - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } - - num = (num + 1) >> 1; - - for (; num != 0; num--) { - *dst = *src; - dst++; - src += 2; - } - - } while (!(done & 0x80)); - - bp->dst += bp->pitch; - if (--bp->height == 0) return; - - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - } while (--bp->height != 0); + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + } while (--bp->height != 0); + break; } } @@ -1036,40 +1049,46 @@ static void GfxBlitZoomMediumUncomp(BlitterParams *bp) assert(height > 0); assert(width > 0); - if (bp->mode & 1) { - if (bp->info & 1) { - const byte *ctab = _color_remap_ptr; + switch (bp->mode) { + case 1: + if (bp->info & 1) { + const byte *ctab = _color_remap_ptr; - for (height >>= 1; height != 0; height--) { - for (i = 0; i != width >> 1; i++) { - byte b = ctab[src[i * 2]]; + for (height >>= 1; height != 0; height--) { + for (i = 0; i != width >> 1; i++) { + byte b = ctab[src[i * 2]]; - if (b != 0) dst[i] = b; + if (b != 0) dst[i] = b; + } + src += bp->width_org * 2; + dst += bp->pitch; } - src += bp->width_org * 2; - dst += bp->pitch; } - } - } else if (bp->mode & 2) { - if (bp->info & 1) { - const byte *ctab = _color_remap_ptr; + break; - for (height >>= 1; height != 0; height--) { - for (i = 0; i != width >> 1; i++) - if (src[i * 2] != 0) dst[i] = ctab[dst[i]]; - src += bp->width_org * 2; - dst += bp->pitch; + case 2: + if (bp->info & 1) { + const byte *ctab = _color_remap_ptr; + + for (height >>= 1; height != 0; height--) { + for (i = 0; i != width >> 1; i++) + if (src[i * 2] != 0) dst[i] = ctab[dst[i]]; + src += bp->width_org * 2; + dst += bp->pitch; + } } - } - } else { - if (bp->info & 1) { - for (height >>= 1; height != 0; height--) { - for (i = 0; i != width >> 1; i++) - if (src[i * 2] != 0) dst[i] = src[i * 2]; - src += bp->width_org * 2; - dst += bp->pitch; + break; + + default: + if (bp->info & 1) { + for (height >>= 1; height != 0; height--) { + for (i = 0; i != width >> 1; i++) + if (src[i * 2] != 0) dst[i] = src[i * 2]; + src += bp->width_org * 2; + dst += bp->pitch; + } } - } + break; } } @@ -1082,210 +1101,214 @@ static void GfxBlitTileZoomOut(BlitterParams *bp) Pixel *dst; const byte *ctab; - if (bp->mode & 1) { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - for (;;) { - do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src = src_o + 2; - src_o += num + 2; + src_o += ReadLE16Aligned(src_o + bp->start_y * 2); + switch (bp->mode) { + case 1: + for (;;) { + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src = src_o + 2; + src_o += num + 2; - dst = bp->dst; + dst = bp->dst; - if (skip & 1) { - skip++; - src++; - if (--num == 0) continue; - } + if (skip & 1) { + skip++; + src++; + if (--num == 0) continue; + } - if (skip & 2) { - skip += 2; - src += 2; - num -= 2; - if (num <= 0) continue; - } + if (skip & 2) { + skip += 2; + src += 2; + num -= 2; + if (num <= 0) continue; + } - if ( (skip -= bp->start_x) > 0) { - dst += skip >> 2; - } else { - src -= skip; - num += skip; - if (num <= 0) continue; - skip = 0; - } + if ( (skip -= bp->start_x) > 0) { + dst += skip >> 2; + } else { + src -= skip; + num += skip; + if (num <= 0) continue; + skip = 0; + } - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } - ctab = _color_remap_ptr; - num = (num + 3) >> 2; - for (; num != 0; num--) { - *dst = ctab[*src]; - dst++; - src += 4; - } - } while (!(done & 0x80)); - bp->dst += bp->pitch; - if (--bp->height == 0) return; + ctab = _color_remap_ptr; + num = (num + 3) >> 2; + for (; num != 0; num--) { + *dst = ctab[*src]; + dst++; + src += 4; + } + } while (!(done & 0x80)); + bp->dst += bp->pitch; + if (--bp->height == 0) return; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; - } - } else if (bp->mode & 2) { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - for (;;) { - do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src_o += num + 2; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; + } + break; - dst = bp->dst; + case 2: + for (;;) { + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src_o += num + 2; - if (skip & 1) { - skip++; - if (--num == 0) continue; - } + dst = bp->dst; - if (skip & 2) { - skip += 2; - num -= 2; - if (num <= 0) continue; - } + if (skip & 1) { + skip++; + if (--num == 0) continue; + } - if ( (skip -= bp->start_x) > 0) { - dst += skip >> 2; - } else { - num += skip; - if (num <= 0) continue; - skip = 0; - } + if (skip & 2) { + skip += 2; + num -= 2; + if (num <= 0) continue; + } - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } + if ( (skip -= bp->start_x) > 0) { + dst += skip >> 2; + } else { + num += skip; + if (num <= 0) continue; + skip = 0; + } - ctab = _color_remap_ptr; - num = (num + 3) >> 2; - for (; num != 0; num--) { - *dst = ctab[*dst]; - dst++; - } + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } - } while (!(done & 0x80)); - bp->dst += bp->pitch; - if (--bp->height == 0) return; + ctab = _color_remap_ptr; + num = (num + 3) >> 2; + for (; num != 0; num--) { + *dst = ctab[*dst]; + dst++; + } - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; + } while (!(done & 0x80)); + bp->dst += bp->pitch; + if (--bp->height == 0) return; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; - } - } else { - src_o += ReadLE16Aligned(src_o + bp->start_y * 2); - for (;;) { - do { - done = src_o[0]; - num = done & 0x7F; - skip = src_o[1]; - src = src_o + 2; - src_o += num + 2; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; - dst = bp->dst; + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; + } + break; - if (skip & 1) { - skip++; - src++; - if (--num == 0) continue; - } + default: + for (;;) { + do { + done = src_o[0]; + num = done & 0x7F; + skip = src_o[1]; + src = src_o + 2; + src_o += num + 2; - if (skip & 2) { - skip += 2; - src += 2; - num -= 2; - if (num <= 0) continue; - } + dst = bp->dst; - if ( (skip -= bp->start_x) > 0) { - dst += skip >> 2; - } else { - src -= skip; - num += skip; - if (num <= 0) continue; - skip = 0; - } + if (skip & 1) { + skip++; + src++; + if (--num == 0) continue; + } - skip = skip + num - bp->width; - if (skip > 0) { - num -= skip; - if (num <= 0) continue; - } + if (skip & 2) { + skip += 2; + src += 2; + num -= 2; + if (num <= 0) continue; + } - num = (num + 3) >> 2; + if ( (skip -= bp->start_x) > 0) { + dst += skip >> 2; + } else { + src -= skip; + num += skip; + if (num <= 0) continue; + skip = 0; + } - for (; num != 0; num--) { - *dst = *src; - dst++; - src += 4; - } - } while (!(done & 0x80)); + skip = skip + num - bp->width; + if (skip > 0) { + num -= skip; + if (num <= 0) continue; + } - bp->dst += bp->pitch; - if (--bp->height == 0) return; + num = (num + 3) >> 2; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; + for (; num != 0; num--) { + *dst = *src; + dst++; + src += 4; + } + } while (!(done & 0x80)); - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; + bp->dst += bp->pitch; + if (--bp->height == 0) return; - do { - done = src_o[0]; - src_o += (done & 0x7F) + 2; - } while (!(done & 0x80)); - if (--bp->height == 0) return; - } + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; + + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; + + do { + done = src_o[0]; + src_o += (done & 0x7F) + 2; + } while (!(done & 0x80)); + if (--bp->height == 0) return; + } + break; } } @@ -1300,44 +1323,49 @@ static void GfxBlitZoomOutUncomp(BlitterParams *bp) assert(height > 0); assert(width > 0); - if (bp->mode & 1) { - if (bp->info & 1) { - const byte *ctab = _color_remap_ptr; + switch (bp->mode) { + case 1: + if (bp->info & 1) { + const byte *ctab = _color_remap_ptr; - for (height >>= 2; height != 0; height--) { - for (i = 0; i != width >> 2; i++) { - byte b = ctab[src[i * 4]]; + for (height >>= 2; height != 0; height--) { + for (i = 0; i != width >> 2; i++) { + byte b = ctab[src[i * 4]]; - if (b != 0) dst[i] = b; + if (b != 0) dst[i] = b; + } + src += bp->width_org * 4; + dst += bp->pitch; } - src += bp->width_org * 4; - dst += bp->pitch; } - } - } else if (bp->mode & 2) { - if (bp->info & 1) { - const byte *ctab = _color_remap_ptr; + break; - for (height >>= 2; height != 0; height--) { - for (i = 0; i != width >> 2; i++) - if (src[i * 4] != 0) dst[i] = ctab[dst[i]]; - src += bp->width_org * 4; - dst += bp->pitch; + case 2: + if (bp->info & 1) { + const byte *ctab = _color_remap_ptr; + + for (height >>= 2; height != 0; height--) { + for (i = 0; i != width >> 2; i++) + if (src[i * 4] != 0) dst[i] = ctab[dst[i]]; + src += bp->width_org * 4; + dst += bp->pitch; + } } - } - } else { - if (bp->info & 1) { - for (height >>= 2; height != 0; height--) { - for (i = 0; i != width >> 2; i++) - if (src[i * 4] != 0) dst[i] = src[i * 4]; - src += bp->width_org * 4; - dst += bp->pitch; + break; + + default: + if (bp->info & 1) { + for (height >>= 2; height != 0; height--) { + for (i = 0; i != width >> 2; i++) + if (src[i * 4] != 0) dst[i] = src[i * 4]; + src += bp->width_org * 4; + dst += bp->pitch; + } } - } + break; } } -typedef void (*BlitZoomFunc)(BlitterParams *bp); static void GfxMainBlitter(const Sprite *sprite, int x, int y, int mode) {