1
0
Fork 0

(svn r2518) Small cleanup

release/0.4.5
tron 2005-07-05 11:09:18 +00:00
parent 5fb14350a0
commit 42d086b212
1 changed files with 123 additions and 126 deletions

249
gfx.c
View File

@ -16,7 +16,7 @@ static Rect _invalid_rect;
static const byte *_color_remap_ptr; static const byte *_color_remap_ptr;
static byte _string_colorremap[3]; static byte _string_colorremap[3];
#define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH/64) #define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH / 64)
static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8]; static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8];
@ -35,16 +35,16 @@ void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch)
} }
void GfxScroll(int left, int top, int width, int height, int xo, int yo) { void GfxScroll(int left, int top, int width, int height, int xo, int yo)
byte *src, *dst; {
byte *src;
byte *dst;
int p; int p;
int ht; int ht;
if (xo == 0 && yo == 0) if (xo == 0 && yo == 0) return;
return;
if (_cursor.visible) if (_cursor.visible) UndrawMouseCursor();
UndrawMouseCursor();
UndrawTextMessage(); UndrawTextMessage();
p = _screen.pitch; p = _screen.pitch;
@ -106,33 +106,27 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo) {
} }
void GfxFillRect(int left, int top, int right, int bottom, int color) { void GfxFillRect(int left, int top, int right, int bottom, int color)
{
DrawPixelInfo *dpi = _cur_dpi; DrawPixelInfo *dpi = _cur_dpi;
byte *dst; byte *dst;
const int otop = top; const int otop = top;
const int oleft = left; const int oleft = left;
if (dpi->zoom != 0) if (dpi->zoom != 0) return;
return; if (left > right || top > bottom) return;
if (right < dpi->left || left >= dpi->left + dpi->width) return;
if (left > right || top > bottom) if (bottom < dpi->top || top >= dpi->top + dpi->height) return;
return;
if (right < dpi->left || left >= dpi->left + dpi->width)
return;
if (bottom < dpi->top || top >= dpi->top + dpi->height)
return;
if ( (left -= dpi->left) < 0) left = 0; if ( (left -= dpi->left) < 0) left = 0;
right = right - dpi->left + 1; right = right - dpi->left + 1;
if (right > dpi->width) right=dpi->width; if (right > dpi->width) right = dpi->width;
right -= left; right -= left;
assert(right > 0); assert(right > 0);
if ( (top -= dpi->top) < 0) top = 0; if ( (top -= dpi->top) < 0) top = 0;
bottom = bottom - dpi->top + 1; bottom = bottom - dpi->top + 1;
if (bottom > dpi->height) bottom=dpi->height; if (bottom > dpi->height) bottom = dpi->height;
bottom -= top; bottom -= top;
assert(bottom > 0); assert(bottom > 0);
@ -169,14 +163,15 @@ static void GfxSetPixel(int x, int y, int color)
DrawPixelInfo *dpi = _cur_dpi; DrawPixelInfo *dpi = _cur_dpi;
if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height) if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height)
return; return;
dpi->dst_ptr[y*dpi->pitch+x] = color; dpi->dst_ptr[y * dpi->pitch + x] = color;
} }
void GfxDrawLine(int x, int y, int x2, int y2, int color) void GfxDrawLine(int x, int y, int x2, int y2, int color)
{ {
int dy; int dy;
int dx; int dx;
int stepx, stepy; int stepx;
int stepy;
int frac; int frac;
// Check clipping first // Check clipping first
@ -184,26 +179,32 @@ void GfxDrawLine(int x, int y, int x2, int y2, int color)
DrawPixelInfo *dpi = _cur_dpi; DrawPixelInfo *dpi = _cur_dpi;
int t; int t;
if (x < dpi->left && x2 < dpi->left) if (x < dpi->left && x2 < dpi->left) return;
return;
if (y < dpi->top && y2 < dpi->top) if (y < dpi->top && y2 < dpi->top) return;
return;
t = dpi->left + dpi->width; t = dpi->left + dpi->width;
if (x > t && x2 > t) if (x > t && x2 > t) return;
return;
t = dpi->top + dpi->height; t = dpi->top + dpi->height;
if (y > t && y2 > t) if (y > t && y2 > t) return;
return;
} }
dy = (y2 - y) * 2; dy = (y2 - y) * 2;
if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } if (dy < 0) {
dy = -dy;
stepy = -1;
} else {
stepy = 1;
}
dx = (x2 - x) * 2; dx = (x2 - x) * 2;
if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } if (dx < 0) {
dx = -dx;
stepx = -1;
} else {
stepx = 1;
}
GfxSetPixel(x, y, color); GfxSetPixel(x, y, color);
if (dx > dy) { if (dx > dy) {
@ -290,7 +291,7 @@ int DrawStringCentered(int x, int y, uint16 str, uint16 color)
void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color) void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color)
{ {
int w = DrawStringCentered(x, y, str, color); int w = DrawStringCentered(x, y, str, color);
GfxFillRect(x-(w>>1), y+10, x-(w>>1)+w, y+10, _string_colorremap[1]); GfxFillRect(x - (w >> 1), y + 10, x - (w >> 1) + w, y + 10, _string_colorremap[1]);
} }
static uint32 FormatStringLinebreaks(char *str, int maxw) static uint32 FormatStringLinebreaks(char *str, int maxw)
@ -381,7 +382,8 @@ void DrawStringMultiCenter(int x, int y, uint16 str, int maxw)
} }
} }
void DrawStringMultiLine(int x, int y, uint16 str, int maxw) { void DrawStringMultiLine(int x, int y, uint16 str, int maxw)
{
char buffer[512]; char buffer[512];
uint32 tmp; uint32 tmp;
int num, w, mt, t; int num, w, mt, t;
@ -442,7 +444,8 @@ int GetStringWidth(const char *str)
return w; return w;
} }
void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags) { void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags)
{
byte color_2 = _color_list[ctab].window_color_1a; byte color_2 = _color_list[ctab].window_color_1a;
byte color_interior = _color_list[ctab].window_color_bga; byte color_interior = _color_list[ctab].window_color_bga;
byte color_3 = _color_list[ctab].window_color_bgb; byte color_3 = _color_list[ctab].window_color_bgb;
@ -450,21 +453,21 @@ void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags
if (!(flags & 0x8)) { if (!(flags & 0x8)) {
if (!(flags & 0x20)) { if (!(flags & 0x20)) {
GfxFillRect(left, top, left, bottom-1, color); GfxFillRect(left, top, left, bottom - 1, color);
GfxFillRect(left+1, top, right-1, top, color); GfxFillRect(left + 1, top, right - 1, top, color);
GfxFillRect(right, top, right, bottom-1, color_2); GfxFillRect(right, top, right, bottom - 1, color_2);
GfxFillRect(left, bottom, right, bottom, color_2); GfxFillRect(left, bottom, right, bottom, color_2);
if (!(flags & 0x10)) { if (!(flags & 0x10)) {
GfxFillRect(left+1, top+1, right-1, bottom-1, color_interior); GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, color_interior);
} }
} else { } else {
GfxFillRect(left, top, left, bottom, color_2); GfxFillRect(left, top, left, bottom, color_2);
GfxFillRect(left+1, top, right, top, color_2); GfxFillRect(left + 1, top, right, top, color_2);
GfxFillRect(right, top+1, right, bottom-1, color); GfxFillRect(right, top + 1, right, bottom - 1, color);
GfxFillRect(left+1, bottom, right, bottom, color); GfxFillRect(left + 1, bottom, right, bottom, color);
if (!(flags & 0x10)) { if (!(flags & 0x10)) {
GfxFillRect(left+1, top+1, right-1, bottom-1, GfxFillRect(left + 1, top + 1, right - 1, bottom - 1,
flags&0x40 ? color_interior : color_3); flags & 0x40 ? color_interior : color_3);
} }
} }
} else if (flags & 0x1) { } else if (flags & 0x1) {
@ -554,7 +557,8 @@ skip_cont:;
} }
} }
void DrawSprite(uint32 img, int x, int y) { void DrawSprite(uint32 img, int x, int y)
{
if (img & 0x8000) { if (img & 0x8000) {
_color_remap_ptr = GetNonSprite(img >> 16) + 1; _color_remap_ptr = GetNonSprite(img >> 16) + 1;
GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 1); GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 1);
@ -573,7 +577,8 @@ typedef struct BlitterParams {
byte *dst; byte *dst;
int mode; int mode;
int width, height; int width, height;
int width_org, height_org; int width_org;
int height_org;
int pitch; int pitch;
byte info; byte info;
} BlitterParams; } BlitterParams;
@ -605,16 +610,14 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
} else { } else {
src -= skip; src -= skip;
num += skip; num += skip;
if (num <= 0) if (num <= 0) continue;
continue;
skip = 0; skip = 0;
} }
skip = skip + num - bp->width; skip = skip + num - bp->width;
if (skip > 0) { if (skip > 0) {
num -= skip; num -= skip;
if (num <= 0) if (num <= 0) continue;
continue;
} }
ctab = _color_remap_ptr; ctab = _color_remap_ptr;
@ -631,7 +634,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
} while (!(done & 0x80)); } while (!(done & 0x80));
bp->dst += bp->pitch; bp->dst += bp->pitch;
} while (--bp->height); } while (--bp->height != 0);
} else if (bp->mode & 2) { } else if (bp->mode & 2) {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
do { do {
@ -647,16 +650,14 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
dst += skip; dst += skip;
} else { } else {
num += skip; num += skip;
if (num <= 0) if (num <= 0) continue;
continue;
skip = 0; skip = 0;
} }
skip = skip + num - bp->width; skip = skip + num - bp->width;
if (skip > 0) { if (skip > 0) {
num -= skip; num -= skip;
if (num <= 0) if (num <= 0) continue;
continue;
} }
ctab = _color_remap_ptr; ctab = _color_remap_ptr;
@ -667,8 +668,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
} while (!(done & 0x80)); } while (!(done & 0x80));
bp->dst += bp->pitch; bp->dst += bp->pitch;
} while (--bp->height); } while (--bp->height != 0);
} else { } else {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
do { do {
@ -686,16 +686,14 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
} else { } else {
src -= skip; src -= skip;
num += skip; num += skip;
if (num <= 0) if (num <= 0) continue;
continue;
skip = 0; skip = 0;
} }
skip = skip + num - bp->width; skip = skip + num - bp->width;
if (skip > 0) { if (skip > 0) {
num -= skip; num -= skip;
if (num <= 0) if (num <= 0) continue;
continue;
} }
#if defined(_WIN32) #if defined(_WIN32)
if (num & 1) *dst++ = *src++; if (num & 1) *dst++ = *src++;
@ -705,7 +703,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
*(uint32*)dst = *(uint32*)src; *(uint32*)dst = *(uint32*)src;
dst += 4; dst += 4;
src += 4; src += 4;
} while (--num); } while (--num != 0);
} }
#else #else
memcpy(dst, src, num); memcpy(dst, src, num);
@ -713,7 +711,7 @@ static void GfxBlitTileZoomIn(BlitterParams *bp)
} while (!(done & 0x80)); } while (!(done & 0x80));
bp->dst += bp->pitch; bp->dst += bp->pitch;
} while (--bp->height); } while (--bp->height != 0);
} }
} }
@ -740,7 +738,7 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp)
} }
src += bp->width_org; src += bp->width_org;
dst += bp->pitch; dst += bp->pitch;
} while (--height); } while (--height != 0);
} }
} else if (bp->mode & 2) { } else if (bp->mode & 2) {
if (bp->info & 1) { if (bp->info & 1) {
@ -751,7 +749,7 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp)
if (src[i] != 0) dst[i] = ctab[dst[i]]; if (src[i] != 0) dst[i] = ctab[dst[i]];
src += bp->width_org; src += bp->width_org;
dst += bp->pitch; dst += bp->pitch;
} while (--height); } while (--height != 0);
} }
} else { } else {
if (!(bp->info & 1)) { if (!(bp->info & 1)) {
@ -759,7 +757,7 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp)
memcpy(dst, src, width); memcpy(dst, src, width);
src += bp->width_org; src += bp->width_org;
dst += bp->pitch; dst += bp->pitch;
} while (--height); } while (--height != 0);
} else { } else {
do { do {
int n = width; int n = width;
@ -782,7 +780,7 @@ static void GfxBlitZoomInUncomp(BlitterParams *bp)
src += bp->width_org - width; src += bp->width_org - width;
dst += bp->pitch - width; dst += bp->pitch - width;
} while (--height); } while (--height != 0);
} }
} }
} }
@ -819,16 +817,14 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
} else { } else {
src -= skip; src -= skip;
num += skip; num += skip;
if (num <= 0) if (num <= 0) continue;
continue;
skip = 0; skip = 0;
} }
skip = skip + num - bp->width; skip = skip + num - bp->width;
if (skip > 0) { if (skip > 0) {
num -= skip; num -= skip;
if (num <= 0) if (num <= 0) continue;
continue;
} }
ctab = _color_remap_ptr; ctab = _color_remap_ptr;
@ -846,7 +842,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
done = src_o[0]; done = src_o[0];
src_o += (done & 0x7F) + 2; src_o += (done & 0x7F) + 2;
} while (!(done & 0x80)); } while (!(done & 0x80));
} while (--bp->height); } while (--bp->height != 0);
} else if (bp->mode & 2) { } else if (bp->mode & 2) {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
do { do {
@ -867,16 +863,14 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
dst += skip >> 1; dst += skip >> 1;
} else { } else {
num += skip; num += skip;
if (num <= 0) if (num <= 0) continue;
continue;
skip = 0; skip = 0;
} }
skip = skip + num - bp->width; skip = skip + num - bp->width;
if (skip > 0) { if (skip > 0) {
num -= skip; num -= skip;
if (num <= 0) if (num <= 0) continue;
continue;
} }
ctab = _color_remap_ptr; ctab = _color_remap_ptr;
@ -893,8 +887,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
done = src_o[0]; done = src_o[0];
src_o += (done & 0x7F) + 2; src_o += (done & 0x7F) + 2;
} while (!(done & 0x80)); } while (!(done & 0x80));
} while (--bp->height); } while (--bp->height != 0);
} else { } else {
src_o += READ_LE_UINT16(src_o + bp->start_y * 2); src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
do { do {
@ -918,16 +911,14 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
} else { } else {
src -= skip; src -= skip;
num += skip; num += skip;
if (num <= 0) if (num <= 0) continue;
continue;
skip = 0; skip = 0;
} }
skip = skip + num - bp->width; skip = skip + num - bp->width;
if (skip > 0) { if (skip > 0) {
num -= skip; num -= skip;
if (num <= 0) if (num <= 0) continue;
continue;
} }
num = (num + 1) >> 1; num = (num + 1) >> 1;
@ -947,8 +938,7 @@ static void GfxBlitTileZoomMedium(BlitterParams *bp)
done = src_o[0]; done = src_o[0];
src_o += (done & 0x7F) + 2; src_o += (done & 0x7F) + 2;
} while (!(done & 0x80)); } while (!(done & 0x80));
} while (--bp->height != 0);
} while (--bp->height);
} }
} }
@ -1450,8 +1440,8 @@ void GfxInitPalettes(void)
DoPaletteAnimations(); DoPaletteAnimations();
} }
#define EXTR(p,q) (((uint16)(_timer_counter * (p)) * (q)) >> 16) #define EXTR(p, q) (((uint16)(_timer_counter * (p)) * (q)) >> 16)
#define EXTR2(p,q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16) #define EXTR2(p, q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16)
void DoPaletteAnimations(void) void DoPaletteAnimations(void)
{ {
@ -1608,32 +1598,40 @@ void UndrawMouseCursor(void)
void DrawMouseCursor(void) void DrawMouseCursor(void)
{ {
int x,y,w,h; int x;
int y;
int w;
int h;
// Don't draw the mouse cursor if it's already drawn // Don't draw the mouse cursor if it's already drawn
if (_cursor.visible) { if (_cursor.visible) {
if (!_cursor.dirty) if (!_cursor.dirty) return;
return;
UndrawMouseCursor(); UndrawMouseCursor();
} }
w = _cursor.size.x; w = _cursor.size.x;
x = _cursor.pos.x + _cursor.offs.x; x = _cursor.pos.x + _cursor.offs.x;
if (x < 0) { w += x; x=0; } if (x < 0) {
if (w>_screen.width-x) { w = _screen.width-x; } w += x;
x = 0;
}
if (w > _screen.width - x) w = _screen.width - x;
if (w <= 0) return; if (w <= 0) return;
_cursor.draw_pos.x = x; _cursor.draw_pos.x = x;
_cursor.draw_size.x = w; _cursor.draw_size.x = w;
h = _cursor.size.y; h = _cursor.size.y;
y = _cursor.pos.y + _cursor.offs.y; y = _cursor.pos.y + _cursor.offs.y;
if (y < 0) { h += y; y=0; } if (y < 0) {
if (h>_screen.height-y) { h = _screen.height-y; } h += y;
y = 0;
}
if (h > _screen.height - y) h = _screen.height - y;
if (h <= 0) return; if (h <= 0) return;
_cursor.draw_pos.y = y; _cursor.draw_pos.y = y;
_cursor.draw_size.y = h; _cursor.draw_size.y = h;
assert(w*h < (int) sizeof(_cursor_backup)); assert(w * h < (int)sizeof(_cursor_backup));
// Make backup of stuff below cursor // Make backup of stuff below cursor
memcpy_pitch( memcpy_pitch(
@ -1654,12 +1652,13 @@ void DrawMouseCursor(void)
#if defined(_DEBUG) #if defined(_DEBUG)
static void DbgScreenRect(int left, int top, int right, int bottom) static void DbgScreenRect(int left, int top, int right, int bottom)
{ {
DrawPixelInfo dp,*old; DrawPixelInfo dp;
DrawPixelInfo* old;
old = _cur_dpi; old = _cur_dpi;
_cur_dpi = &dp; _cur_dpi = &dp;
dp = _screen; dp = _screen;
GfxFillRect(left, top, right-1, bottom-1, rand() & 255); GfxFillRect(left, top, right - 1, bottom - 1, rand() & 255);
_cur_dpi = old; _cur_dpi = old;
} }
#endif #endif
@ -1686,13 +1685,14 @@ void RedrawScreenRect(int left, int top, int right, int bottom)
#endif #endif
DrawOverlappedWindowForAll(left, top, right, bottom); DrawOverlappedWindowForAll(left, top, right, bottom);
_video_driver->make_dirty(left, top, right-left, bottom-top); _video_driver->make_dirty(left, top, right - left, bottom - top);
} }
void DrawDirtyBlocks(void) void DrawDirtyBlocks(void)
{ {
byte *b = _dirty_blocks; byte *b = _dirty_blocks;
int x=0,y=0; int x = 0;
int y = 0;
const int w = (_screen.width + 63) & ~63; const int w = (_screen.width + 63) & ~63;
const int h = (_screen.height + 7) & ~7; const int h = (_screen.height + 7) & ~7;
@ -1762,37 +1762,38 @@ void DrawDirtyBlocks(void)
void SetDirtyBlocks(int left, int top, int right, int bottom) void SetDirtyBlocks(int left, int top, int right, int bottom)
{ {
byte *b; byte *b;
int width,height,i; int width;
int height;
if (left < 0) left = 0; if (left < 0) left = 0;
if (top < 0) top = 0; if (top < 0) top = 0;
if (right > _screen.width) right = _screen.width; if (right > _screen.width) right = _screen.width;
if (bottom > _screen.height) bottom = _screen.height; if (bottom > _screen.height) bottom = _screen.height;
if (left >= right || top >= bottom) if (left >= right || top >= bottom) return;
return;
if (left < _invalid_rect.left) _invalid_rect.left = left; if (left < _invalid_rect.left ) _invalid_rect.left = left;
if (top < _invalid_rect.top) _invalid_rect.top = top; if (top < _invalid_rect.top ) _invalid_rect.top = top;
if (right > _invalid_rect.right)_invalid_rect.right = right; if (right > _invalid_rect.right ) _invalid_rect.right = right;
if (bottom > _invalid_rect.bottom)_invalid_rect.bottom = bottom; if (bottom > _invalid_rect.bottom) _invalid_rect.bottom = bottom;
left >>= 6; left >>= 6;
top >>= 3; top >>= 3;
b = _dirty_blocks + top * DIRTY_BYTES_PER_LINE + left; b = _dirty_blocks + top * DIRTY_BYTES_PER_LINE + left;
width = ((right-1) >> 6) - left + 1; width = ((right - 1) >> 6) - left + 1;
height = ((bottom-1) >> 3) - top + 1; height = ((bottom - 1) >> 3) - top + 1;
assert(width > 0 && height > 0); assert(width > 0 && height > 0);
do { do {
i=width; int i = width;
do b[--i] = 0xFF; while (i); do b[--i] = 0xFF; while (i);
b += DIRTY_BYTES_PER_LINE; b += DIRTY_BYTES_PER_LINE;
} while (--height); } while (--height != 0);
} }
void MarkWholeScreenDirty(void) void MarkWholeScreenDirty(void)
@ -1804,8 +1805,7 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, in
{ {
int t; int t;
if (o == NULL) if (o == NULL) o = _cur_dpi;
o = _cur_dpi;
n->zoom = 0; n->zoom = 0;
@ -1814,22 +1814,22 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, in
n->left = 0; n->left = 0;
if ((left -= o->left) < 0) { if ((left -= o->left) < 0) {
if ((width += left) < 0) width += left;
return false; if (width < 0) return false;
n->left = -left; n->left = -left;
left = 0; left = 0;
} }
if ((t=width + left - o->width) > 0) { if ((t=width + left - o->width) > 0) {
if ((width -= t) < 0) width -= t;
return false; if (width < 0) return false;
} }
n->width = width; n->width = width;
n->top = 0; n->top = 0;
if ((top -= o->top) < 0) { if ((top -= o->top) < 0) {
if ((height += top) < 0) height += top;
return false; if (height < 0) return false;
n->top = -top; n->top = -top;
top = 0; top = 0;
} }
@ -1837,12 +1837,11 @@ bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, in
n->dst_ptr = o->dst_ptr + left + top * (n->pitch = o->pitch); n->dst_ptr = o->dst_ptr + left + top * (n->pitch = o->pitch);
if ((t=height + top - o->height) > 0) { if ((t=height + top - o->height) > 0) {
if ((height-=t) < 0) height -= t;
return false; if (height < 0) return false;
} }
n->height = height; n->height = height;
return true; return true;
} }
@ -1851,8 +1850,7 @@ static void SetCursorSprite(CursorID cursor)
CursorVars *cv = &_cursor; CursorVars *cv = &_cursor;
const Sprite *p; const Sprite *p;
if (cv->sprite == cursor) if (cv->sprite == cursor) return;
return;
p = GetSprite(cursor & 0x3FFF); p = GetSprite(cursor & 0x3FFF);
cv->sprite = cursor; cv->sprite = cursor;
@ -1882,8 +1880,7 @@ static void SwitchAnimatedCursor(void)
void CursorTick(void) void CursorTick(void)
{ {
CursorVars *cv = &_cursor; if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0)
if (cv->animate_timeout && !--cv->animate_timeout)
SwitchAnimatedCursor(); SwitchAnimatedCursor();
} }