From a119b3c74bdb2734cf2ba955ffc000f64d456574 Mon Sep 17 00:00:00 2001 From: cirdan Date: Fri, 7 Apr 2017 20:51:14 +0200 Subject: [PATCH] Recycle Palette identifier Change Palette to refer to an array of Colour, as the old Palette struct was no longer used after last commits. --- src/blitter/32bpp_anim.cpp | 2 +- src/blitter/32bpp_anim.hpp | 6 +++--- src/blitter/blitter.cpp | 2 +- src/blitter/blitter.h | 2 +- src/gfx.cpp | 2 +- src/gfx_func.h | 2 +- src/gfx_type.h | 6 +----- src/screenshot.cpp | 2 +- src/table/palettes.h | 2 +- src/video/sdl_v.cpp | 2 +- src/video/video_driver.hpp | 2 +- src/video/win32_v.cpp | 2 +- 12 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index d26e6465e..800aa481b 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -460,7 +460,7 @@ void Blitter_32bppAnimBase::Surface::scroll (void *video, int &left, int &top, i this->Blitter_32bppBase::Surface::scroll (video, left, top, width, height, scroll_x, scroll_y); } -bool Blitter_32bppAnimBase::Surface::palette_animate (const Colour (&palette) [256]) +bool Blitter_32bppAnimBase::Surface::palette_animate (const Palette &palette) { this->set_palette (palette); diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp index 27ff5e54d..5f2f96fb0 100644 --- a/src/blitter/32bpp_anim.hpp +++ b/src/blitter/32bpp_anim.hpp @@ -25,10 +25,10 @@ public: /** Blitting surface. */ struct Surface : Blitter_32bppBase::Surface { - Colour palette[256]; ///< The current palette. + Palette palette; ///< The current palette. uint16 *const anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation - void set_palette (const Colour (&palette) [256]) + void set_palette (const Palette &palette) { assert_compile (sizeof(this->palette) == sizeof(palette)); memcpy (this->palette, palette, sizeof(this->palette)); @@ -64,7 +64,7 @@ public: void scroll (void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) OVERRIDE; - bool palette_animate (const Colour (&palette) [256]) OVERRIDE; + bool palette_animate (const Palette &palette) OVERRIDE; void copy (Buffer *dst, int x, int y, uint width, uint height) OVERRIDE; diff --git a/src/blitter/blitter.cpp b/src/blitter/blitter.cpp index 7527bb706..9639244bc 100644 --- a/src/blitter/blitter.cpp +++ b/src/blitter/blitter.cpp @@ -162,7 +162,7 @@ void Blitter::list (stringb *buf) } -bool Blitter::Surface::palette_animate (const Colour (&palette) [256]) +bool Blitter::Surface::palette_animate (const Palette &palette) { /* The null driver does not need to animate anything, for the 8bpp * blitters the video backend takes care of the palette animation diff --git a/src/blitter/blitter.h b/src/blitter/blitter.h index fbe606a77..77309ffa4 100644 --- a/src/blitter/blitter.h +++ b/src/blitter/blitter.h @@ -252,7 +252,7 @@ public: * @param palette The new palette. * @return Whether the screen should be invalidated. */ - virtual bool palette_animate (const Colour (&palette) [256]); + virtual bool palette_animate (const Palette &palette); /** Draw an image to the screen, given an amount of params defined above. */ virtual void draw (const BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) = 0; diff --git a/src/gfx.cpp b/src/gfx.cpp index 6f2be3024..f4aa749d6 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -51,7 +51,7 @@ bool _exit_game; GameMode _game_mode; SwitchMode _switch_mode; ///< The next mainloop command. PauseModeByte _pause_mode; -Colour _cur_palette[256]; +Palette _cur_palette; int _cur_palette_first_dirty; int _cur_palette_count_dirty; diff --git a/src/gfx_func.h b/src/gfx_func.h index f840ea730..814afbf72 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -81,7 +81,7 @@ extern int _screen_width, _screen_height; extern int _num_resolutions; extern Dimension _resolutions[32]; extern Dimension _cur_resolution; -extern Colour _cur_palette[256]; ///< Current palette +extern Palette _cur_palette; ///< Current palette extern int _cur_palette_first_dirty; ///< First palette dirty element. extern int _cur_palette_count_dirty; ///< Number of palette dirty elements. diff --git a/src/gfx_type.h b/src/gfx_type.h index fe2a4c6e1..9c8fab04c 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -294,11 +294,7 @@ enum SpriteType { static const uint MILLISECONDS_PER_TICK = 30; /** Information about the currently used palette. */ -struct Palette { - Colour palette[256]; ///< Current palette. Entry 0 has to be always fully transparent! - int first_dirty; ///< The first dirty element. - int count_dirty; ///< The number of dirty elements. -}; +typedef Colour Palette[256]; /** Modes for 8bpp support */ enum Support8bpp { diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 67e3d2e05..24bb41955 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -809,7 +809,7 @@ static void HeightmapCallback(void *userdata, void *buffer, uint y, uint pitch, */ bool MakeHeightmapScreenshot(const char *filename) { - Colour palette[256]; + Palette palette; for (uint i = 0; i < lengthof(palette); i++) { palette[i].a = 0xff; palette[i].r = i; diff --git a/src/table/palettes.h b/src/table/palettes.h index 6df6c739b..b947475db 100644 --- a/src/table/palettes.h +++ b/src/table/palettes.h @@ -14,7 +14,7 @@ #define M(r, g, b) Colour(r, g, b) /** Colour palette (DOS) */ -static const Colour _palette[256] = { +static const Palette _palette = { /* transparent */ Colour(0, 0, 0, 0), /* grey scale */ diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 3487b9752..47a1588ec 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -44,7 +44,7 @@ static ThreadMutex *_draw_mutex = NULL; /** Should we keep continue drawing? */ static volatile bool _draw_continue; /** Local palette. */ -static Colour _local_palette[256]; +static Palette _local_palette; /** First palette dirty element. */ static int _local_palette_first_dirty; /** Number of palette dirty elements. */ diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index 26b9b166a..e84368dbf 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -43,7 +43,7 @@ public: virtual void MainLoop() = 0; /** Helper function to handle palette animation. */ - static void PaletteAnimate (const Colour (&palette) [256]) + static void PaletteAnimate (const Palette &palette) { if (_screen_surface->palette_animate (palette)) { GetActiveDriver()->MakeDirty (0, 0, _screen_width, _screen_height); diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 6c6525679..789bb14b4 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -67,7 +67,7 @@ static HANDLE _draw_thread_initialized = NULL; /** Should we keep continue drawing? */ static volatile bool _draw_continue; /** Local copy of the palette for use in the drawing thread. */ -static Colour _local_palette[256]; +static Palette _local_palette; /** First palette dirty element. */ static int _local_palette_first_dirty; /** Number of palette dirty elements. */ -- 2.11.4.GIT