summaryrefslogtreecommitdiff
path: root/gfx.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-07-03 10:22:20 +0000
committertron <tron@openttd.org>2005-07-03 10:22:20 +0000
commit6c5df28d7c353ccbeef6220b06bb6d64b08f3061 (patch)
tree5bdaabd03e6ad369817aa4603b9d4b2f8ce3e173 /gfx.c
parentae032390e2840d165550693cbd8f94c39ab3653b (diff)
downloadopenttd-6c5df28d7c353ccbeef6220b06bb6d64b08f3061.tar.xz
(svn r2512) Small cleanup
Diffstat (limited to 'gfx.c')
-rw-r--r--gfx.c131
1 files changed, 52 insertions, 79 deletions
diff --git a/gfx.c b/gfx.c
index e7724462d..b75541782 100644
--- a/gfx.c
+++ b/gfx.c
@@ -765,7 +765,8 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp)
} else {
do {
int n = width;
- while (n >= 4) {
+
+ 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];
@@ -773,19 +774,16 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp)
dst += 4;
src += 4;
- n -= 4;
}
- while (n) {
+ for (; n != 0; n--) {
if (src[0] != 0) dst[0] = src[0];
src++;
dst++;
- n--;
}
src += bp->width_org - width;
dst += bp->pitch - width;
-
} while (--height);
}
}
@@ -815,8 +813,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
if (skip & 1) {
skip++;
src++;
- if (!--num)
- continue;
+ if (--num == 0) continue;
}
if ( (skip -= bp->start_x) > 0) {
@@ -845,8 +842,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
}
} while (!(done & 0x80));
bp->dst += bp->pitch;
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
@@ -866,8 +862,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
if (skip & 1) {
skip++;
- if (!--num)
- continue;
+ if (--num == 0) continue;
}
if ( (skip -= bp->start_x) > 0) {
@@ -894,8 +889,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
}
} while (!(done & 0x80));
bp->dst += bp->pitch;
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
@@ -918,8 +912,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
if (skip & 1) {
skip++;
src++;
- if (!--num)
- continue;
+ if (--num == 0) continue;
}
if ( (skip -= bp->start_x) > 0) {
@@ -950,8 +943,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
} while (!(done & 0x80));
bp->dst += bp->pitch;
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
@@ -1034,15 +1026,14 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
if (skip & 1) {
skip++;
src++;
- if (!--num)
- continue;
+ if (--num == 0) continue;
}
if (skip & 2) {
- skip+=2;
- src+=2;
- if ((num-=2) <= 0)
- continue;
+ skip += 2;
+ src += 2;
+ num -= 2;
+ if (num <= 0) continue;
}
if ( (skip -= bp->start_x) > 0) {
@@ -1050,16 +1041,14 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
} else {
src -= skip;
num += skip;
- if (num <= 0)
- continue;
+ if (num <= 0) continue;
skip = 0;
}
skip = skip + num - bp->width;
if (skip > 0) {
num -= skip;
- if (num <= 0)
- continue;
+ if (num <= 0) continue;
}
ctab = _color_remap_ptr;
@@ -1071,29 +1060,25 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
}
} while (!(done & 0x80));
bp->dst += bp->pitch;
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
}
} else if (bp->mode & 2) {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
@@ -1108,30 +1093,27 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
if (skip & 1) {
skip++;
- if (!--num)
- continue;
+ if (--num == 0) continue;
}
if (skip & 2) {
- skip+=2;
- if ((num-=2) <= 0)
- continue;
+ skip += 2;
+ num -= 2;
+ if (num <= 0) continue;
}
if ( (skip -= bp->start_x) > 0) {
dst += skip >> 2;
} else {
num += skip;
- if (num <= 0)
- continue;
+ if (num <= 0) continue;
skip = 0;
}
skip = skip + num - bp->width;
if (skip > 0) {
num -= skip;
- if (num <= 0)
- continue;
+ if (num <= 0) continue;
}
ctab = _color_remap_ptr;
@@ -1143,29 +1125,25 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
} while (!(done & 0x80));
bp->dst += bp->pitch;
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
}
} else {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
@@ -1182,15 +1160,14 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
if (skip & 1) {
skip++;
src++;
- if (!--num)
- continue;
+ if (--num == 0) continue;
}
if (skip & 2) {
- skip+=2;
- src+=2;
- if ((num-=2) <= 0)
- continue;
+ skip += 2;
+ src += 2;
+ num -= 2;
+ if (num <= 0) continue;
}
if ( (skip -= bp->start_x) > 0) {
@@ -1198,16 +1175,14 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
} else {
src -= skip;
num += skip;
- if (num <= 0)
- continue;
+ if (num <= 0) continue;
skip = 0;
}
skip = skip + num - bp->width;
if (skip > 0) {
num -= skip;
- if (num <= 0)
- continue;
+ if (num <= 0) continue;
}
num = (num + 3) >> 2;
@@ -1220,29 +1195,25 @@ static void GfxBlitTileZoomOut(BlitterParams *bp)
} while (!(done & 0x80));
bp->dst += bp->pitch;
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
do {
done = src_o[0];
src_o += (done & 0x7F) + 2;
} while (!(done & 0x80));
- if (!--bp->height)
- return;
+ if (--bp->height == 0) return;
}
}
}
@@ -1423,27 +1394,29 @@ static void GfxMainBlitter(const Sprite* sprite, int x, int y, int mode)
int totpix = bp.height_org * bp.width_org;
byte *dst = (byte*)alloca(totpix);
const byte *src = bp.sprite_org;
- signed char b;
bp.sprite = dst + (bp.sprite - bp.sprite_org);
while (totpix != 0) {
+ signed char b;
+
assert(totpix > 0);
+
b = *src++;
if (b >= 0) {
- int i, count=b;
- for(i=0; i!=count; i++)
- dst[i] = src[i];
+ uint count = b;
+ uint i;
+
+ for (i = 0; i != count; i++) dst[i] = src[i];
dst += count;
src += count;
totpix -= count;
} else {
- byte *tmp = dst- (((b&7)<<8)|(*src++));
- int i;
- int count = -(b >> 3);
+ const byte *tmp = dst - (((b & 7) << 8) | *src++);
+ uint count = -(b >> 3);
+ uint i;
- for(i=0; i!=count; i++)
- dst[i] = tmp[i];
+ for (i = 0; i != count; i++) dst[i] = tmp[i];
dst += count;
totpix -= count;
}