From 5f324ef9f20a5a0c4ce65cea03df8be61385ea82 Mon Sep 17 00:00:00 2001 From: Trevor Finney <8711258+finneyt@users.noreply.github.com> Date: Mon, 20 Feb 2023 14:37:22 -0500 Subject: [PATCH] Some cleanup --- .../drawing/engines/opengl/TextureCache.cpp | 14 +--------- src/openrct2/drawing/Drawing.cpp | 9 ------- src/openrct2/drawing/Drawing.h | 3 +-- src/openrct2/interface/Colour.cpp | 26 +++---------------- 4 files changed, 6 insertions(+), 46 deletions(-) diff --git a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp index 4eecee8c71..ddc25942b7 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp @@ -212,7 +212,7 @@ void TextureCache::GeneratePaletteTexture() dpi.bits[i] = i; } - for (int i = 0; i < PALETTE_TO_G1_OFFSET_COUNT; ++i) + for (int i = 0; i < PALETTE_TOTAL_OFFSETS; ++i) { GLint y = PaletteToY(static_cast(i)); @@ -223,18 +223,6 @@ void TextureCache::GeneratePaletteTexture() GfxDrawSpriteSoftware(&dpi, ImageId(g1Index.value()), { -element->x_offset, y - element->y_offset }); } } - // G2 Palette textures - for (int i = PALETTE_TO_G1_OFFSET_COUNT; i < PALETTE_TOTAL_OFFSETS; ++i) - { - GLint y = PaletteToY(static_cast(i)); - - auto g2Index = GetPaletteG2Index(i); - if (g2Index.has_value()) - { - auto element = GfxGetG1Element(g2Index.value()); - GfxDrawSpriteSoftware(&dpi, ImageId(g2Index.value()), { -element->x_offset, y - element->y_offset }); - } - } glBindTexture(GL_TEXTURE_2D, _paletteTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, width, height, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits); diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index a4bc9e3370..b72e91493d 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -906,15 +906,6 @@ void GfxDrawPickedUpPeep(DrawPixelInfo* dpi) } std::optional GetPaletteG1Index(colour_t paletteId) -{ - if (paletteId < PALETTE_TO_G1_OFFSET_COUNT) - { - return palette_to_g1_offset[paletteId]; - } - return std::nullopt; -} - -std::optional GetPaletteG2Index(colour_t paletteId) { if (paletteId < PALETTE_TOTAL_OFFSETS) { diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index 2ab6638f1a..09ab4ccf0f 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -470,7 +470,7 @@ void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& pal } #define PALETTE_TO_G1_OFFSET_COUNT 144 -#define PALETTE_TOTAL_OFFSETS 192 +constexpr uint8_t PALETTE_TOTAL_OFFSETS = 192; #define INSET_RECT_F_30 (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_NONE) #define INSET_RECT_F_60 (INSET_RECT_FLAG_BORDER_INSET | INSET_RECT_FLAG_FILL_DONT_LIGHTEN) @@ -595,7 +595,6 @@ extern void (*MaskFn)( int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); std::optional GetPaletteG1Index(colour_t paletteId); -std::optional GetPaletteG2Index(colour_t paletteId); std::optional GetPaletteMapForColour(colour_t paletteId); void UpdatePalette(const uint8_t* colours, int32_t start_index, int32_t num_colours); diff --git a/src/openrct2/interface/Colour.cpp b/src/openrct2/interface/Colour.cpp index bf6acc8e77..62b723f65b 100644 --- a/src/openrct2/interface/Colour.cpp +++ b/src/openrct2/interface/Colour.cpp @@ -37,29 +37,11 @@ enum void ColoursInitMaps() { // Get colour maps from g1 - for (int32_t i = 0; i < COLOUR_NUM_ORIGINAL; i++) + for (int32_t i = 0; i < COLOUR_COUNT; i++) { - const G1Element* g1 = GfxGetG1Element(SPR_PALETTE_2_START + i); - if (g1 != nullptr) - { - ColourMapA[i].colour_0 = g1->offset[INDEX_COLOUR_0]; - ColourMapA[i].colour_1 = g1->offset[INDEX_COLOUR_1]; - ColourMapA[i].darkest = g1->offset[INDEX_DARKEST]; - ColourMapA[i].darker = g1->offset[INDEX_DARKER]; - ColourMapA[i].dark = g1->offset[INDEX_DARK]; - ColourMapA[i].mid_dark = g1->offset[INDEX_MID_DARK]; - ColourMapA[i].mid_light = g1->offset[INDEX_MID_LIGHT]; - ColourMapA[i].light = g1->offset[INDEX_LIGHT]; - ColourMapA[i].lighter = g1->offset[INDEX_LIGHTER]; - ColourMapA[i].lightest = g1->offset[INDEX_LIGHTEST]; - ColourMapA[i].colour_10 = g1->offset[INDEX_COLOUR_10]; - ColourMapA[i].colour_11 = g1->offset[INDEX_COLOUR_11]; - } - } - // G2 Palette Init - for (int32_t i = COLOUR_NUM_ORIGINAL; i < COLOUR_COUNT; i++) - { - const G1Element* g1 = GfxGetG1Element(SPR_G2_PALETTE_BEGIN + i - (COLOUR_NUM_ORIGINAL - 1)); + // Get palette index in g1 / g2 + auto paletteIndex = (i < COLOUR_NUM_ORIGINAL) ? SPR_PALETTE_2_START : SPR_G2_PALETTE_BEGIN - (COLOUR_NUM_ORIGINAL - 1); + const G1Element* g1 = GfxGetG1Element(paletteIndex + i); if (g1 != nullptr) { ColourMapA[i].colour_0 = g1->offset[INDEX_COLOUR_0];