diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index a9a464bf74466..6364be8266e3e 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -15,6 +15,7 @@ #include "../safeguards.h" +/** Instantiation of the 32bpp with animation blitter factory. */ static FBlitter_32bppAnim iFBlitter_32bppAnim; template diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp index 5967ea4025d1d..c3c6b172cdd1d 100644 --- a/src/blitter/32bpp_anim.hpp +++ b/src/blitter/32bpp_anim.hpp @@ -8,11 +8,12 @@ #include "32bpp_optimized.hpp" #include "factory.hpp" +/** The optimised 32 bpp blitter with palette animation. */ class Blitter_32bppAnim : public Blitter_32bppOptimized { private: - uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation - int anim_buf_width; - int anim_buf_height; + uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation + int anim_buf_width; ///< The width of the animation buffer. + int anim_buf_height; ///< The height of the animation buffer. public: Blitter_32bppAnim() : @@ -38,6 +39,7 @@ class Blitter_32bppAnim : public Blitter_32bppOptimized { template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); }; +/** Factory for the 32bpp blitter with animation. */ class FBlitter_32bppAnim: public BlitterFactory { public: /* virtual */ const char *GetName() { return "32bpp-anim"; } diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 4a1b6f3b5b4aa..8335d04dc774c 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -8,12 +8,10 @@ #include "base.hpp" #include "../core/bitmath_func.hpp" +/** Base for all 32bpp blitters. */ class Blitter_32bppBase : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 32; } -// /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); -// /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); -// /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator); /* virtual */ void *MoveTo(const void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 color); /* virtual */ void DrawRect(void *video, int width, int height, uint8 color); diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index 1fd4f7a5c0fe5..ac6e7d099f0c3 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -12,6 +12,7 @@ #include "../safeguards.h" +/** Instantiation of the optimized 32bpp blitter factory. */ static FBlitter_32bppOptimized iFBlitter_32bppOptimized; /** diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp index 4d6fb9dfd8ddf..67f63e39a8f7f 100644 --- a/src/blitter/32bpp_optimized.hpp +++ b/src/blitter/32bpp_optimized.hpp @@ -8,11 +8,13 @@ #include "32bpp_simple.hpp" #include "factory.hpp" +/** The optimised 32 bpp blitter (without palette animation). */ class Blitter_32bppOptimized : public Blitter_32bppSimple { public: + /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_COUNT][2]; - byte data[VARARRAY_SIZE]; + uint32 offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. + byte data[VARARRAY_SIZE]; ///< Data, all zoomlevels. }; /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -23,6 +25,7 @@ class Blitter_32bppOptimized : public Blitter_32bppSimple { template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); }; +/** Factory for the optimised 32 bpp blitter (without palette animation). */ class FBlitter_32bppOptimized: public BlitterFactory { public: /* virtual */ const char *GetName() { return "32bpp-optimized"; } diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp index 46e1371ac9d8f..0335d75ddd6bf 100644 --- a/src/blitter/32bpp_simple.cpp +++ b/src/blitter/32bpp_simple.cpp @@ -12,6 +12,7 @@ #include "../safeguards.h" +/** Instantiation of the simple 32bpp blitter factory. */ static FBlitter_32bppSimple iFBlitter_32bppSimple; void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/32bpp_simple.hpp b/src/blitter/32bpp_simple.hpp index 059bb139498b9..8142bb889b30c 100644 --- a/src/blitter/32bpp_simple.hpp +++ b/src/blitter/32bpp_simple.hpp @@ -8,6 +8,7 @@ #include "32bpp_base.hpp" #include "factory.hpp" +/** The most trivial 32 bpp blitter (without palette animation). */ class Blitter_32bppSimple : public Blitter_32bppBase { public: /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -17,6 +18,7 @@ class Blitter_32bppSimple : public Blitter_32bppBase { /* virtual */ const char *GetName() { return "32bpp-simple"; } }; +/** Factory for the simple 32 bpp blitter. */ class FBlitter_32bppSimple: public BlitterFactory { public: /* virtual */ const char *GetName() { return "32bpp-simple"; } diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp index dfe7e2b91a874..15b4cd9f6f05e 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -7,12 +7,11 @@ #include "base.hpp" +/** Base for all 8bpp blitters. */ class Blitter_8bppBase : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 8; } -// /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); -// /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator); /* virtual */ void *MoveTo(const void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 color); /* virtual */ void DrawRect(void *video, int width, int height, uint8 color); diff --git a/src/blitter/8bpp_debug.cpp b/src/blitter/8bpp_debug.cpp index 374a1df31a5d3..d411173b527e6 100644 --- a/src/blitter/8bpp_debug.cpp +++ b/src/blitter/8bpp_debug.cpp @@ -7,6 +7,7 @@ #include "../core/random_func.hpp" #include "8bpp_debug.hpp" +/** Instantiation of the 8bpp debug blitter factory. */ static FBlitter_8bppDebug iFBlitter_8bppDebug; void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/8bpp_debug.hpp b/src/blitter/8bpp_debug.hpp index 6c30bc61eb727..5dd7548a4bd70 100644 --- a/src/blitter/8bpp_debug.hpp +++ b/src/blitter/8bpp_debug.hpp @@ -8,6 +8,7 @@ #include "8bpp_base.hpp" #include "factory.hpp" +/** 8bpp debug blitter; colours each sprite differently. */ class Blitter_8bppDebug : public Blitter_8bppBase { public: /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -16,6 +17,7 @@ class Blitter_8bppDebug : public Blitter_8bppBase { /* virtual */ const char *GetName() { return "8bpp-debug"; } }; +/** Factory for the 8bpp debug blitter. */ class FBlitter_8bppDebug: public BlitterFactory { public: /* virtual */ const char *GetName() { return "8bpp-debug"; } diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp index 883a8aee917a5..761192ee1ed11 100644 --- a/src/blitter/8bpp_optimized.cpp +++ b/src/blitter/8bpp_optimized.cpp @@ -11,6 +11,7 @@ #include "../safeguards.h" +/** Instantiation of the 8bpp optimised blitter factory. */ static FBlitter_8bppOptimized iFBlitter_8bppOptimized; void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp index 9d46624ad4aee..6bd0dc4e28301 100644 --- a/src/blitter/8bpp_optimized.hpp +++ b/src/blitter/8bpp_optimized.hpp @@ -8,11 +8,13 @@ #include "8bpp_base.hpp" #include "factory.hpp" +/** 8bpp blitter optimised for speed. */ class Blitter_8bppOptimized : public Blitter_8bppBase { public: + /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_COUNT]; ///< offsets (from .data) to streams for different zoom levels - byte data[VARARRAY_SIZE]; ///< data, all zoomlevels + uint32 offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels. + byte data[VARARRAY_SIZE]; ///< Data, all zoomlevels. }; /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -21,6 +23,7 @@ class Blitter_8bppOptimized : public Blitter_8bppBase { /* virtual */ const char *GetName() { return "8bpp-optimized"; } }; +/** Factory for the 8bpp blitter optimised for speed. */ class FBlitter_8bppOptimized: public BlitterFactory { public: /* virtual */ const char *GetName() { return "8bpp-optimized"; } diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index 9166fc929f6e0..dd8fc145a421e 100644 --- a/src/blitter/8bpp_simple.cpp +++ b/src/blitter/8bpp_simple.cpp @@ -8,6 +8,7 @@ #include "../safeguards.h" +/** Instantiation of the simple 8bpp blitter factory. */ static FBlitter_8bppSimple iFBlitter_8bppSimple; void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) diff --git a/src/blitter/8bpp_simple.hpp b/src/blitter/8bpp_simple.hpp index 5624c9c7f88fd..8cacc93878bc2 100644 --- a/src/blitter/8bpp_simple.hpp +++ b/src/blitter/8bpp_simple.hpp @@ -8,6 +8,7 @@ #include "8bpp_base.hpp" #include "factory.hpp" +/** Most trivial 8bpp blitter. */ class Blitter_8bppSimple : public Blitter_8bppBase { public: /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); @@ -16,6 +17,7 @@ class Blitter_8bppSimple : public Blitter_8bppBase { /* virtual */ const char *GetName() { return "8bpp-simple"; } }; +/** Factory for the most trivial 8bpp blitter. */ class FBlitter_8bppSimple: public BlitterFactory { public: /* virtual */ const char *GetName() { return "8bpp-simple"; } diff --git a/src/blitter/base.cpp b/src/blitter/base.cpp index d8e33cedec589..1e6afdad518e2 100644 --- a/src/blitter/base.cpp +++ b/src/blitter/base.cpp @@ -13,18 +13,6 @@ #include "base.hpp" #include "../core/math_func.hpp" -/** - * Draw a line with a given colour. - * @param video The destination pointer (video-buffer). - * @param x The x coordinate from where the line starts. - * @param y The y coordinate from where the line starts. - * @param x2 The x coordinate to where the line goes. - * @param y2 The y coordinate to where the lines goes. - * @param screen_width The width of the screen you are drawing in (to avoid buffer-overflows). - * @param screen_height The height of the screen you are drawing in (to avoid buffer-overflows). - * @param colour A 8bpp mapping colour. - * @param width Line width. - */ void Blitter::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width) { int dy; diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp index d57e26df970e6..59671159052a2 100644 --- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -9,10 +9,11 @@ #include "../spriteloader/spriteloader.hpp" #include "../zoom_type.h" +/** The modes of blitting we can do. */ enum BlitterMode { - BM_NORMAL, - BM_COLOUR_REMAP, - BM_TRANSPARENT, + BM_NORMAL, ///< Perform the simple blitting. + BM_COLOUR_REMAP, ///< Perform a colour remapping. + BM_TRANSPARENT, ///< Perform transparency colour remapping. }; /** @@ -20,20 +21,25 @@ enum BlitterMode { */ class Blitter { public: + /** Parameters related to blitting. */ struct BlitterParams { - const void *sprite; ///< Pointer to the sprite how ever the encoder stored it - const byte *remap; ///< XXX -- Temporary storage for remap array - - int skip_left, skip_top; ///< How much pixels of the source to skip on the left and top (based on zoom of dst) - int width, height; ///< The width and height in pixels that needs to be drawn to dst - int sprite_width; ///< Real width of the sprite - int sprite_height; ///< Real height of the sprite - int left, top; ///< The offset in the 'dst' in pixels to start drawing - - void *dst; ///< Destination buffer - int pitch; ///< The pitch of the destination buffer + const void *sprite; ///< Pointer to the sprite how ever the encoder stored it + const byte *remap; ///< XXX -- Temporary storage for remap array + + int skip_left; ///< How much pixels of the source to skip on the left (based on zoom of dst) + int skip_top; ///< How much pixels of the source to skip on the top (based on zoom of dst) + int width; ///< The width in pixels that needs to be drawn to dst + int height; ///< The height in pixels that needs to be drawn to dst + int sprite_width; ///< Real width of the sprite + int sprite_height; ///< Real height of the sprite + int left; ///< The left offset in the 'dst' in pixels to start drawing + int top; ///< The top offset in the 'dst' in pixels to start drawing + + void *dst; ///< Destination buffer + int pitch; ///< The pitch of the destination buffer }; + /** Types of palette animation. */ enum PaletteAnimation { PALETTE_ANIMATION_NONE, ///< No palette animation PALETTE_ANIMATION_VIDEO_BACKEND, ///< Palette animation should be done by video backend (8bpp only!) @@ -104,9 +110,9 @@ class Blitter { * @param screen_width The width of the screen you are drawing in (to avoid buffer-overflows). * @param screen_height The height of the screen you are drawing in (to avoid buffer-overflows). * @param colour A 8bpp mapping colour. - * @param width The width of line to draw. + * @param width Line width. */ - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width); + virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width); /** * Copy from a buffer to the screen. diff --git a/src/blitter/factory.hpp b/src/blitter/factory.hpp index c9650a7b40dbd..46d12f9c9ec77 100644 --- a/src/blitter/factory.hpp +++ b/src/blitter/factory.hpp @@ -19,7 +19,7 @@ bool QZ_CanDisplay8bpp(); */ class BlitterFactoryBase { private: - const char *name; + const char *name; ///< The name of the blitter factory. struct StringCompare { bool operator () (const char *a, const char *b) const @@ -28,14 +28,22 @@ class BlitterFactoryBase { } }; - typedef std::map Blitters; + typedef std::map Blitters; ///< Map of blitter factories. + /** + * Get the map with currently known blitters. + * @return The known blitters. + */ static Blitters &GetBlitters() { static Blitters &s_blitters = *new Blitters(); return s_blitters; } + /** + * Get the currently active blitter. + * @return The currently active blitter. + */ static Blitter **GetActiveBlitter() { static Blitter *s_blitter = NULL; @@ -123,7 +131,12 @@ class BlitterFactoryBase { return *GetActiveBlitter(); } - + /** + * Fill a buffer with information about the blitters. + * @param p The buffer to fill. + * @param last The last element of the buffer. + * @return p The location till where we filled the buffer. + */ static char *GetBlittersInfo(char *p, const char *last) { p += seprintf(p, last, "List of blitters:\n"); diff --git a/src/blitter/null.cpp b/src/blitter/null.cpp index 335c6f8100e6a..916a9db1b9d81 100644 --- a/src/blitter/null.cpp +++ b/src/blitter/null.cpp @@ -7,6 +7,7 @@ #include "../safeguards.h" +/** Instantiation of the null blitter factory. */ static FBlitter_Null iFBlitter_Null; Sprite *Blitter_Null::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator) diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index d234660a5c3de..f52ce7d504cf3 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -8,6 +8,7 @@ #include "base.hpp" #include "factory.hpp" +/** Blitter that does nothing. */ class Blitter_Null : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 0; } @@ -15,9 +16,9 @@ class Blitter_Null : public Blitter { /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) {}; /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator); /* virtual */ void *MoveTo(const void *video, int x, int y) { return NULL; }; - /* virtual */ void SetPixel(void *video, int x, int y, uint8 color) {}; - /* virtual */ void DrawRect(void *video, int width, int height, uint8 color) {}; - /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 color) {}; + /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {}; + /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {}; + /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width) {}; /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height) {}; /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height) {}; /* virtual */ void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) {}; @@ -29,6 +30,7 @@ class Blitter_Null : public Blitter { /* virtual */ const char *GetName() { return "null"; } }; +/** Factory for the blitter that doesn nothing. */ class FBlitter_Null: public BlitterFactory { public: /* virtual */ const char *GetName() { return "null"; } diff --git a/src/driver.cpp b/src/driver.cpp index 6bcba25b9f16c..2011e6b524a63 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -13,19 +13,19 @@ #include "safeguards.h" -VideoDriver *_video_driver; -char *_ini_videodriver; -int _num_resolutions; -uint16 _resolutions[32][2]; -uint16 _cur_resolution[2]; +VideoDriver *_video_driver; ///< The currently active video driver. +char *_ini_videodriver; ///< The video driver a stored in the configuration file. +int _num_resolutions; ///< The number of resolutions. +uint16 _resolutions[32][2]; ///< List of resolutions. +uint16 _cur_resolution[2]; ///< The current resolution. -SoundDriver *_sound_driver; -char *_ini_sounddriver; +SoundDriver *_sound_driver; ///< The currently active sound driver. +char *_ini_sounddriver; ///< The sound driver a stored in the configuration file. -MusicDriver *_music_driver; -char *_ini_musicdriver; +MusicDriver *_music_driver; ///< The currently active music driver. +char *_ini_musicdriver; ///< The music driver a stored in the configuration file. -char *_ini_blitter; +char *_ini_blitter; ///< The blitter as stored in the configuration file. static const char* GetDriverParam(const char* const* parm, const char* name) {