From 1588218f6f7f3c23d8c4d4b4186c51b1bae1100b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 30 Aug 2019 19:36:02 -0700 Subject: XEEN: Further sprite drawer mode code --- engines/xeen/sprites.cpp | 15 +++++++++++++++ engines/xeen/sprites.h | 29 +++++++++++++++++++---------- 2 files changed, 34 insertions(+), 10 deletions(-) (limited to 'engines/xeen') diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp index fed8b6a410..fc2159bca9 100644 --- a/engines/xeen/sprites.cpp +++ b/engines/xeen/sprites.cpp @@ -137,6 +137,8 @@ void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPo case SPRFLAG_DRAWER1: draw = new SpriteDrawer1(_data, _filesize, flags & 0x1F); break; + case SPRFLAG_DRAWER2: + error("TODO: Sprite drawer mode 2"); case SPRFLAG_DRAWER3: draw = new SpriteDrawer3(_data, _filesize, flags & 0x1F); break; @@ -460,6 +462,19 @@ void SpriteDrawer3::drawPixel(byte *dest, byte pixel) { /*------------------------------------------------------------------------*/ +const byte DRAWER4_THRESHOLD[4] = { 4, 7, 10, 13 }; + +SpriteDrawer4::SpriteDrawer4(byte *data, size_t filesize, int index) : SpriteDrawer(data, filesize) { + _threshold = DRAWER4_THRESHOLD[index]; +} + +void SpriteDrawer4::drawPixel(byte *dest, byte pixel) { + if ((pixel & 0xf) >= _threshold) + *dest = pixel; +} + +/*------------------------------------------------------------------------*/ + const uint16 DRAWER5_MASK[4] = { 0x3333, 0x6666, 0x999A, 0xCCCD }; SpriteDrawer5::SpriteDrawer5(byte *data, size_t filesize, int index) : SpriteDrawer(data, filesize) { diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h index beb310e193..e8d83e1054 100644 --- a/engines/xeen/sprites.h +++ b/engines/xeen/sprites.h @@ -40,10 +40,10 @@ enum { }; enum SpriteFlags { - SPRFLAG_MODE_MASK = 0xF00, SPRFLAG_DRAWER1 = 0x100, SPRFLAG_DRAWER3 = 0X300, - SPRFLAG_DRAWER5 = 0x500, SPRFLAG_DRAWER6 = 0x600, SPRFLAG_800 = 0x800, - SPRFLAG_SCENE_CLIPPED = 0x2000, SPRFLAG_BOTTOM_CLIPPED = 0x4000, - SPRFLAG_HORIZ_FLIPPED = 0x8000, SPRFLAG_RESIZE = 0x10000 + SPRFLAG_MODE_MASK = 0xF00, SPRFLAG_DRAWER1 = 0x100, SPRFLAG_DRAWER2 = 0x200, + SPRFLAG_DRAWER3 = 0x300, SPRFLAG_DRAWER4 = 0x400, SPRFLAG_DRAWER5 = 0x500, SPRFLAG_DRAWER6 = 0x600, + SPRFLAG_DRAWER7 = 0x700, SPRFLAG_800 = 0x800, SPRFLAG_SCENE_CLIPPED = 0x2000, + SPRFLAG_BOTTOM_CLIPPED = 0x4000, SPRFLAG_HORIZ_FLIPPED = 0x8000, SPRFLAG_RESIZE = 0x10000 }; class SpriteResource { @@ -203,9 +203,6 @@ public: const Common::Rect &clipRect, uint flags, int scale); }; -/** - * Handles drawing a sprite as masked/offset - */ class SpriteDrawer1 : public SpriteDrawer { private: byte _offset, _mask; @@ -236,6 +233,21 @@ public: SpriteDrawer3(byte *data, size_t filesize, int index); }; +class SpriteDrawer4 : public SpriteDrawer { +private: + byte _threshold; +protected: + /** + * Output a pixel + */ + virtual void drawPixel(byte *dest, byte pixel) override; +public: + /** + * Constructor + */ + SpriteDrawer4(byte *data, size_t filesize, int index); +}; + class SpriteDrawer5 : public SpriteDrawer { private: uint16 _mask, _random1, _random2; @@ -256,9 +268,6 @@ public: SpriteDrawer5(byte *data, size_t filesize, int index); }; -/** - * Handles drawing a sprite as a solid color - */ class SpriteDrawer6 : public SpriteDrawer { private: byte _color; -- cgit v1.2.3