168 bottom -= top; |
168 bottom -= top; |
169 assert(bottom > 0); |
169 assert(bottom > 0); |
170 |
170 |
171 dst = dpi->dst_ptr + top * dpi->pitch + left; |
171 dst = dpi->dst_ptr + top * dpi->pitch + left; |
172 |
172 |
173 if (!(color & PALETTE_MODIFIER_GREYOUT)) { |
173 if (!HASBIT(color, PALETTE_MODIFIER_GREYOUT)) { |
174 if (!(color & USE_COLORTABLE)) { |
174 if (!HASBIT(color, USE_COLORTABLE)) { |
175 do { |
175 do { |
176 memset(dst, color, right); |
176 memset(dst, color, right); |
177 dst += dpi->pitch; |
177 dst += dpi->pitch; |
178 } while (--bottom); |
178 } while (--bottom); |
179 } else { |
179 } else { |
180 /* use colortable mode */ |
180 /* use colortable mode */ |
181 const byte* ctab = GetNonSprite(color & COLORTABLE_MASK) + 1; |
181 const byte* ctab = GetNonSprite(GB(color, 0, PALETTE_WIDTH)) + 1; |
182 |
182 |
183 do { |
183 do { |
184 int i; |
184 int i; |
185 for (i = 0; i != right; i++) dst[i] = ctab[dst[i]]; |
185 for (i = 0; i != right; i++) dst[i] = ctab[dst[i]]; |
186 dst += dpi->pitch; |
186 dst += dpi->pitch; |
693 ttd_strlcpy(buffer, str, sizeof(buffer)); |
693 ttd_strlcpy(buffer, str, sizeof(buffer)); |
694 TruncateString(buffer, maxw); |
694 TruncateString(buffer, maxw); |
695 return DoDrawString(buffer, x, y, color); |
695 return DoDrawString(buffer, x, y, color); |
696 } |
696 } |
697 |
697 |
698 void DrawSprite(uint32 img, int x, int y) |
698 void DrawSprite(SpriteID img, SpriteID pal, int x, int y) |
699 { |
699 { |
700 if (img & PALETTE_MODIFIER_COLOR) { |
700 if (HASBIT(img, PALETTE_MODIFIER_TRANSPARENT)) { |
701 _color_remap_ptr = GetNonSprite(GB(img, PALETTE_SPRITE_START, PALETTE_SPRITE_WIDTH)) + 1; |
701 _color_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH)) + 1; |
702 GfxMainBlitter(GetSprite(img & SPRITE_MASK), x, y, BM_COLOUR_REMAP); |
702 GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH)), x, y, BM_TRANSPARENT); |
703 } else if (img & PALETTE_MODIFIER_TRANSPARENT) { |
703 } else if (pal != PAL_NONE) { |
704 _color_remap_ptr = GetNonSprite(GB(img, PALETTE_SPRITE_START, PALETTE_SPRITE_WIDTH)) + 1; |
704 _color_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH)) + 1; |
705 GfxMainBlitter(GetSprite(img & SPRITE_MASK), x, y, BM_TRANSPARENT); |
705 GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH)), x, y, BM_COLOUR_REMAP); |
706 } else { |
706 } else { |
707 GfxMainBlitter(GetSprite(img & SPRITE_MASK), x, y, BM_NORMAL); |
707 GfxMainBlitter(GetSprite(GB(img, 0, SPRITE_WIDTH)), x, y, BM_NORMAL); |
708 } |
708 } |
709 } |
709 } |
710 |
710 |
711 typedef struct BlitterParams { |
711 typedef struct BlitterParams { |
712 int start_x, start_y; |
712 int start_x, start_y; |
1737 _screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch, |
1737 _screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch, |
1738 _cursor.draw_size.x, _cursor.draw_size.y, _screen.pitch, _cursor.draw_size.x); |
1738 _cursor.draw_size.x, _cursor.draw_size.y, _screen.pitch, _cursor.draw_size.x); |
1739 |
1739 |
1740 // Draw cursor on screen |
1740 // Draw cursor on screen |
1741 _cur_dpi = &_screen; |
1741 _cur_dpi = &_screen; |
1742 DrawSprite(_cursor.sprite, _cursor.pos.x, _cursor.pos.y); |
1742 DrawSprite(_cursor.sprite, _cursor.pal, _cursor.pos.x, _cursor.pos.y); |
1743 |
1743 |
1744 _video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y); |
1744 _video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y); |
1745 |
1745 |
1746 _cursor.visible = true; |
1746 _cursor.visible = true; |
1747 _cursor.dirty = false; |
1747 _cursor.dirty = false; |
1965 n->height = height; |
1965 n->height = height; |
1966 |
1966 |
1967 return true; |
1967 return true; |
1968 } |
1968 } |
1969 |
1969 |
1970 static void SetCursorSprite(CursorID cursor) |
1970 static void SetCursorSprite(SpriteID cursor, SpriteID pal) |
1971 { |
1971 { |
1972 CursorVars *cv = &_cursor; |
1972 CursorVars *cv = &_cursor; |
1973 const Sprite *p; |
1973 const Sprite *p; |
1974 |
1974 |
1975 if (cv->sprite == cursor) return; |
1975 if (cv->sprite == cursor) return; |
1976 |
1976 |
1977 p = GetSprite(cursor & SPRITE_MASK); |
1977 p = GetSprite(GB(cursor, 0, SPRITE_WIDTH)); |
1978 cv->sprite = cursor; |
1978 cv->sprite = cursor; |
|
1979 cv->pal = pal; |
1979 cv->size.y = p->height; |
1980 cv->size.y = p->height; |
1980 cv->size.x = p->width; |
1981 cv->size.x = p->width; |
1981 cv->offs.x = p->x_offs; |
1982 cv->offs.x = p->x_offs; |
1982 cv->offs.y = p->y_offs; |
1983 cv->offs.y = p->y_offs; |
1983 |
1984 |
1995 |
1996 |
1996 sprite = cur[0]; |
1997 sprite = cur[0]; |
1997 cv->animate_timeout = cur[1]; |
1998 cv->animate_timeout = cur[1]; |
1998 cv->animate_cur = cur + 2; |
1999 cv->animate_cur = cur + 2; |
1999 |
2000 |
2000 SetCursorSprite(sprite); |
2001 SetCursorSprite(sprite, cv->pal); |
2001 } |
2002 } |
2002 |
2003 |
2003 void CursorTick(void) |
2004 void CursorTick(void) |
2004 { |
2005 { |
2005 if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0) |
2006 if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0) |
2006 SwitchAnimatedCursor(); |
2007 SwitchAnimatedCursor(); |
2007 } |
2008 } |
2008 |
2009 |
2009 void SetMouseCursor(CursorID cursor) |
2010 void SetMouseCursor(SpriteID sprite, SpriteID pal) |
2010 { |
2011 { |
2011 // Turn off animation |
2012 // Turn off animation |
2012 _cursor.animate_timeout = 0; |
2013 _cursor.animate_timeout = 0; |
2013 // Set cursor |
2014 // Set cursor |
2014 SetCursorSprite(cursor); |
2015 SetCursorSprite(sprite, pal); |
2015 } |
2016 } |
2016 |
2017 |
2017 void SetAnimatedMouseCursor(const CursorID *table) |
2018 void SetAnimatedMouseCursor(const CursorID *table) |
2018 { |
2019 { |
2019 _cursor.animate_list = table; |
2020 _cursor.animate_list = table; |
2020 _cursor.animate_cur = NULL; |
2021 _cursor.animate_cur = NULL; |
|
2022 _cursor.pal = PAL_NONE; |
2021 SwitchAnimatedCursor(); |
2023 SwitchAnimatedCursor(); |
2022 } |
2024 } |
2023 |
2025 |
2024 bool ChangeResInGame(int w, int h) |
2026 bool ChangeResInGame(int w, int h) |
2025 { |
2027 { |