Mercurial > hg > openttd
changeset 6861:972760c16e13 draft
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
author | truelight <truelight@openttd.org> |
---|---|
date | Mon, 11 Jun 2007 15:13:30 +0000 |
parents | c1b11029a5f2 |
children | 707bfe264699 |
files | projects/openttd.vcproj projects/openttd_vs80.vcproj source.list src/blitter/8bpp_simple.cpp src/blitter/8bpp_simple.hpp src/blitter/8bpp_slow.cpp src/blitter/8bpp_slow.hpp |
diffstat | 7 files changed, 99 insertions(+), 99 deletions(-) [+] |
line wrap: on
line diff
--- a/projects/openttd.vcproj +++ b/projects/openttd.vcproj @@ -974,10 +974,10 @@ RelativePath=".\..\src\blitter\8bpp_optimized.hpp"> </File> <File - RelativePath=".\..\src\blitter\8bpp_slow.cpp"> + RelativePath=".\..\src\blitter\8bpp_simple.cpp"> </File> <File - RelativePath=".\..\src\blitter\8bpp_slow.hpp"> + RelativePath=".\..\src\blitter\8bpp_simple.hpp"> </File> <File RelativePath=".\..\src\blitter\blitter.hpp">
--- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -1520,11 +1520,11 @@ > </File> <File - RelativePath=".\..\src\blitter\8bpp_slow.cpp" + RelativePath=".\..\src\blitter\8bpp_simple.cpp" > </File> <File - RelativePath=".\..\src\blitter\8bpp_slow.hpp" + RelativePath=".\..\src\blitter\8bpp_simple.hpp" > </File> <File
--- a/source.list +++ b/source.list @@ -295,8 +295,8 @@ blitter/8bpp_debug.hpp blitter/8bpp_optimized.cpp blitter/8bpp_optimized.hpp -blitter/8bpp_slow.cpp -blitter/8bpp_slow.hpp +blitter/8bpp_simple.cpp +blitter/8bpp_simple.hpp blitter/blitter.hpp # Sprite loaders
new file mode 100644 --- /dev/null +++ b/src/blitter/8bpp_simple.cpp @@ -0,0 +1,63 @@ +#include "../stdafx.h" +#include "../zoom.hpp" +#include "../gfx.h" +#include "8bpp_simple.hpp" + +static FBlitter_8bppSimple iFBlitter_8bppSimple; + +void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) +{ + const byte *src, *src_line; + Pixel8 *dst, *dst_line; + + /* Find where to start reading in the source sprite */ + src_line = (const byte *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); + dst_line = (Pixel8 *)bp->dst + bp->top * bp->pitch + bp->left; + + for (int y = 0; y < bp->height; y++) { + dst = dst_line; + dst_line += bp->pitch; + + src = src_line; + src_line += bp->sprite_width * ScaleByZoom(1, zoom); + + for (int x = 0; x < bp->width; x++) { + uint color = 0; + + switch (mode) { + case BM_COLOUR_REMAP: + color = bp->remap[*src]; + break; + + case BM_TRANSPARENT: + if (*src != 0) color = bp->remap[*dst]; + break; + + default: + color = *src; + break; + } + if (color != 0) *dst = color; + dst++; + src += ScaleByZoom(1, zoom); + } + } +} + +Sprite *Blitter_8bppSimple::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) +{ + Sprite *dest_sprite; + dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);; + + dest_sprite->height = sprite->height; + dest_sprite->width = sprite->width; + dest_sprite->x_offs = sprite->x_offs; + dest_sprite->y_offs = sprite->y_offs; + + /* Copy over only the 'remap' channel, as that is what we care about in 8bpp */ + for (int i = 0; i < sprite->height * sprite->width; i++) { + dest_sprite->data[i] = sprite->data[i].m; + } + + return dest_sprite; +}
new file mode 100644 --- /dev/null +++ b/src/blitter/8bpp_simple.hpp @@ -0,0 +1,30 @@ +/* $Id$ */ + +/** @file 8bpp.hpp */ + +#ifndef BLITTER_8BPP_SIMPLE_HPP +#define BLITTER_8BPP_SIMPLE_HPP + +#include "blitter.hpp" + +typedef Pixel Pixel8; + +class Blitter_8bppSimple : public Blitter { +public: + uint8 GetScreenDepth() { return 8; } + + void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); + + Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); +}; + +class FBlitter_8bppSimple: public BlitterFactory<FBlitter_8bppSimple> { +public: + /* virtual */ const char *GetName() { return "8bpp-simple"; } + + /* virtual */ const char *GetDescription() { return "8bpp Simple Blitter (relative slow, but never wrong)"; } + + /* virtual */ Blitter *CreateInstance() { return new Blitter_8bppSimple(); } +}; + +#endif /* BLITTER_8BPP_SIMPLE_HPP */
deleted file mode 100644 --- a/src/blitter/8bpp_slow.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "../stdafx.h" -#include "../zoom.hpp" -#include "../gfx.h" -#include "8bpp_slow.hpp" - -static FBlitter_8bppSimple iFBlitter_8bppSimple; - -void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) -{ - const byte *src, *src_line; - Pixel8 *dst, *dst_line; - - /* Find where to start reading in the source sprite */ - src_line = (const byte *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); - dst_line = (Pixel8 *)bp->dst + bp->top * bp->pitch + bp->left; - - for (int y = 0; y < bp->height; y++) { - dst = dst_line; - dst_line += bp->pitch; - - src = src_line; - src_line += bp->sprite_width * ScaleByZoom(1, zoom); - - for (int x = 0; x < bp->width; x++) { - uint color = 0; - - switch (mode) { - case BM_COLOUR_REMAP: - color = bp->remap[*src]; - break; - - case BM_TRANSPARENT: - if (*src != 0) color = bp->remap[*dst]; - break; - - default: - color = *src; - break; - } - if (color != 0) *dst = color; - dst++; - src += ScaleByZoom(1, zoom); - } - } -} - -Sprite *Blitter_8bppSimple::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) -{ - Sprite *dest_sprite; - dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);; - - dest_sprite->height = sprite->height; - dest_sprite->width = sprite->width; - dest_sprite->x_offs = sprite->x_offs; - dest_sprite->y_offs = sprite->y_offs; - - /* Copy over only the 'remap' channel, as that is what we care about in 8bpp */ - for (int i = 0; i < sprite->height * sprite->width; i++) { - dest_sprite->data[i] = sprite->data[i].m; - } - - return dest_sprite; -}
deleted file mode 100644 --- a/src/blitter/8bpp_slow.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* $Id$ */ - -/** @file 8bpp.hpp */ - -#ifndef BLITTER_8BPP_SIMPLE_HPP -#define BLITTER_8BPP_SIMPLE_HPP - -#include "blitter.hpp" - -typedef Pixel Pixel8; - -class Blitter_8bppSimple : public Blitter { -public: - uint8 GetScreenDepth() { return 8; } - - void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom); - - Sprite *Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator); -}; - -class FBlitter_8bppSimple: public BlitterFactory<FBlitter_8bppSimple> { -public: - /* virtual */ const char *GetName() { return "8bpp-simple"; } - - /* virtual */ const char *GetDescription() { return "8bpp Simple Blitter (relative slow, but never wrong)"; } - - /* virtual */ Blitter *CreateInstance() { return new Blitter_8bppSimple(); } -}; - -#endif /* BLITTER_8BPP_SIMPLE_HPP */