mirror of https://github.com/OpenRCT2/OpenRCT2.git
* Fix #12020 - Use ScreenCoordsXY on gfx_draw_sprite_palette_set_software Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
parent
80efc26a80
commit
4a17d1d64e
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
# include <algorithm>
|
# include <algorithm>
|
||||||
# include <openrct2/drawing/Drawing.h>
|
# include <openrct2/drawing/Drawing.h>
|
||||||
|
# include <openrct2/world/Location.hpp>
|
||||||
# include <stdexcept>
|
# include <stdexcept>
|
||||||
# include <vector>
|
# include <vector>
|
||||||
|
|
||||||
|
@ -320,7 +321,9 @@ rct_drawpixelinfo TextureCache::GetGlyphAsDPI(uint32_t image, const PaletteMap&
|
||||||
int32_t height = g1Element->height;
|
int32_t height = g1Element->height;
|
||||||
|
|
||||||
rct_drawpixelinfo dpi = CreateDPI(width, height);
|
rct_drawpixelinfo dpi = CreateDPI(width, height);
|
||||||
gfx_draw_sprite_palette_set_software(&dpi, ImageId::FromUInt32(image), -g1Element->x_offset, -g1Element->y_offset, palette);
|
|
||||||
|
const auto glyphCoords = ScreenCoordsXY{ -g1Element->x_offset, -g1Element->y_offset };
|
||||||
|
gfx_draw_sprite_palette_set_software(&dpi, ImageId::FromUInt32(image), glyphCoords, palette);
|
||||||
return dpi;
|
return dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,9 @@ void FASTCALL gfx_draw_sprite_software(rct_drawpixelinfo* dpi, ImageId imageId,
|
||||||
{
|
{
|
||||||
palette = PaletteMap::GetDefault();
|
palette = PaletteMap::GetDefault();
|
||||||
}
|
}
|
||||||
gfx_draw_sprite_palette_set_software(dpi, imageId, x, y, *palette);
|
|
||||||
|
const auto spriteCoords = ScreenCoordsXY{ x, y };
|
||||||
|
gfx_draw_sprite_palette_set_software(dpi, imageId, spriteCoords, *palette);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,8 +426,11 @@ void FASTCALL gfx_draw_sprite_software(rct_drawpixelinfo* dpi, ImageId imageId,
|
||||||
* y (dx)
|
* y (dx)
|
||||||
*/
|
*/
|
||||||
void FASTCALL gfx_draw_sprite_palette_set_software(
|
void FASTCALL gfx_draw_sprite_palette_set_software(
|
||||||
rct_drawpixelinfo* dpi, ImageId imageId, int32_t x, int32_t y, const PaletteMap& paletteMap)
|
rct_drawpixelinfo* dpi, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap)
|
||||||
{
|
{
|
||||||
|
int32_t x = coords.x;
|
||||||
|
int32_t y = coords.y;
|
||||||
|
|
||||||
const auto* g1 = gfx_get_g1_element(imageId);
|
const auto* g1 = gfx_get_g1_element(imageId);
|
||||||
if (g1 == nullptr)
|
if (g1 == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -442,8 +447,10 @@ void FASTCALL gfx_draw_sprite_palette_set_software(
|
||||||
zoomed_dpi.width = dpi->width >> 1;
|
zoomed_dpi.width = dpi->width >> 1;
|
||||||
zoomed_dpi.pitch = dpi->pitch;
|
zoomed_dpi.pitch = dpi->pitch;
|
||||||
zoomed_dpi.zoom_level = dpi->zoom_level - 1;
|
zoomed_dpi.zoom_level = dpi->zoom_level - 1;
|
||||||
|
|
||||||
|
const auto spriteCoords = ScreenCoordsXY{ x >> 1, y >> 1 };
|
||||||
gfx_draw_sprite_palette_set_software(
|
gfx_draw_sprite_palette_set_software(
|
||||||
&zoomed_dpi, imageId.WithIndex(imageId.GetIndex() - g1->zoomed_offset), x >> 1, y >> 1, paletteMap);
|
&zoomed_dpi, imageId.WithIndex(imageId.GetIndex() - g1->zoomed_offset), spriteCoords, paletteMap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -636,7 +636,7 @@ void FASTCALL gfx_draw_sprite_solid(rct_drawpixelinfo* dpi, int32_t image, const
|
||||||
|
|
||||||
void FASTCALL gfx_draw_sprite_software(rct_drawpixelinfo* dpi, ImageId imageId, int32_t x, int32_t y);
|
void FASTCALL gfx_draw_sprite_software(rct_drawpixelinfo* dpi, ImageId imageId, int32_t x, int32_t y);
|
||||||
void FASTCALL gfx_draw_sprite_palette_set_software(
|
void FASTCALL gfx_draw_sprite_palette_set_software(
|
||||||
rct_drawpixelinfo* dpi, ImageId imageId, int32_t x, int32_t y, const PaletteMap& paletteMap);
|
rct_drawpixelinfo* dpi, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap);
|
||||||
void FASTCALL
|
void FASTCALL
|
||||||
gfx_draw_sprite_raw_masked_software(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32_t maskImage, int32_t colourImage);
|
gfx_draw_sprite_raw_masked_software(rct_drawpixelinfo* dpi, int32_t x, int32_t y, int32_t maskImage, int32_t colourImage);
|
||||||
|
|
||||||
|
|
|
@ -743,13 +743,15 @@ void X8DrawingContext::DrawSpriteSolid(uint32_t image, int32_t x, int32_t y, uin
|
||||||
uint8_t palette[256];
|
uint8_t palette[256];
|
||||||
std::fill_n(palette, sizeof(palette), colour);
|
std::fill_n(palette, sizeof(palette), colour);
|
||||||
palette[0] = 0;
|
palette[0] = 0;
|
||||||
|
|
||||||
|
const auto spriteCoords = ScreenCoordsXY{ x, y };
|
||||||
gfx_draw_sprite_palette_set_software(
|
gfx_draw_sprite_palette_set_software(
|
||||||
_dpi, ImageId::FromUInt32((image & 0x7FFFF) | IMAGE_TYPE_REMAP), x, y, PaletteMap(palette));
|
_dpi, ImageId::FromUInt32((image & 0x7FFFF) | IMAGE_TYPE_REMAP), spriteCoords, PaletteMap(palette));
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& paletteMap)
|
void X8DrawingContext::DrawGlyph(uint32_t image, int32_t x, int32_t y, const PaletteMap& paletteMap)
|
||||||
{
|
{
|
||||||
gfx_draw_sprite_palette_set_software(_dpi, ImageId::FromUInt32(image), x, y, paletteMap);
|
gfx_draw_sprite_palette_set_software(_dpi, ImageId::FromUInt32(image), { x, y }, paletteMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X8DrawingContext::SetDPI(rct_drawpixelinfo* dpi)
|
void X8DrawingContext::SetDPI(rct_drawpixelinfo* dpi)
|
||||||
|
|
Loading…
Reference in New Issue