aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver/d_draw.h
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-10-15 06:40:31 +0000
committerTorbjörn Andersson2003-10-15 06:40:31 +0000
commit8b42d65a7e922a9b9241ebe509968331fe958fb6 (patch)
tree5dcef554baa412cf676beb11c453d54957ecaa8c /sword2/driver/d_draw.h
parentf74a0c18aa2ef244f987c31d3d146207c72e81ee (diff)
downloadscummvm-rg350-8b42d65a7e922a9b9241ebe509968331fe958fb6.tar.gz
scummvm-rg350-8b42d65a7e922a9b9241ebe509968331fe958fb6.tar.bz2
scummvm-rg350-8b42d65a7e922a9b9241ebe509968331fe958fb6.zip
Dumped most of the remaining "driver" code into a new "Display" class. This
touches a lot of the code, of course, and adds yet another global variable (temporarily, I hope), but everything still seems to work. Knock on wood. svn-id: r10806
Diffstat (limited to 'sword2/driver/d_draw.h')
-rw-r--r--sword2/driver/d_draw.h202
1 files changed, 201 insertions, 1 deletions
diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h
index a169b922e2..4d0c1d71e2 100644
--- a/sword2/driver/d_draw.h
+++ b/sword2/driver/d_draw.h
@@ -24,7 +24,40 @@
namespace Sword2 {
-extern byte *lpBackBuffer;
+// This is the maximum mouse cursor size in the SDL backend
+
+#define MAX_MOUSE_W 80
+#define MAX_MOUSE_H 80
+
+#define RENDERAVERAGETOTAL 4
+
+#define BLOCKWIDTH 64
+#define BLOCKHEIGHT 64
+#define MAXLAYERS 5
+
+#define PALTABLESIZE 64 * 64 * 64
+
+// Maximum scaled size of a sprite
+#define SCALE_MAXWIDTH 512
+#define SCALE_MAXHEIGHT 512
+
+#if !defined(__GNUC__)
+ #pragma START_PACK_STRUCTS
+#endif
+
+struct _mouseAnim {
+ uint8 runTimeComp; // type of runtime compression used for the
+ // frame data
+ uint8 noAnimFrames; // number of frames in the anim
+ int8 xHotSpot;
+ int8 yHotSpot;
+ uint8 mousew;
+ uint8 mouseh;
+} GCC_PACK;
+
+#if !defined(__GNUC__)
+ #pragma END_PACK_STRUCTS
+#endif
class MoviePlayer {
private:
@@ -38,6 +71,173 @@ public:
int32 play(char *filename, _movieTextObject *text[], uint8 *musicOut);
};
+typedef struct {
+ byte data[BLOCKWIDTH * BLOCKHEIGHT];
+ bool transparent;
+} BlockSurface;
+
+class Display {
+ friend class MoviePlayer;
+
+private:
+ byte *_buffer;
+
+ int32 _renderCaps;
+ int8 _renderLevel;
+
+ uint8 _menuStatus[2];
+ byte *_icons[2][RDMENU_MAXPOCKETS];
+ uint8 _pocketStatus[2][RDMENU_MAXPOCKETS];
+
+ uint8 _iconCount;
+
+ bool _needFullRedraw;
+
+ uint8 _paletteMatch[PALTABLESIZE];
+
+ uint8 _fadePalette[256][4];
+ uint8 _fadeStatus;
+
+ int32 _fadeStartTime;
+ int32 _fadeTotalTime;
+
+ byte _mouseData[MAX_MOUSE_W * MAX_MOUSE_H];
+
+ uint8 _mouseFrame;
+ uint8 *_mouseSprite;
+ struct _mouseAnim *_mouseAnim;
+ struct _mouseAnim *_luggageAnim;
+ int32 *_mouseOffsets;
+ int32 *_luggageOffset;
+
+ // Scroll variables. _scrollX and _scrollY hold the current scroll
+ // position, and _scrollXTarget and _scrollYTarget are the target
+ // position for the end of the game cycle.
+
+ int16 _scrollX;
+ int16 _scrollY;
+
+ int16 _scrollXTarget;
+ int16 _scrollYTarget;
+ int16 _scrollXOld;
+ int16 _scrollYOld;
+
+ int16 _parallaxScrollX; // current x offset to link a sprite to the
+ // parallax layer
+ int16 _parallaxScrollY; // current y offset to link a sprite to the
+ // parallax layer
+ int16 _locationWide;
+ int16 _locationDeep;
+
+ uint16 _layer;
+
+ int32 _initialTime;
+ int32 _startTime;
+ int32 _totalTime;
+ int32 _renderAverageTime;
+ int32 _framesPerGameCycle;
+ bool _renderTooSlow;
+
+ uint8 _xBlocks[MAXLAYERS];
+ uint8 _yBlocks[MAXLAYERS];
+
+ // An array of sub-blocks, one for each of the parallax layers.
+
+ BlockSurface **_blockSurfaces[MAXLAYERS];
+
+ uint16 _xScale[SCALE_MAXWIDTH];
+ uint16 _yScale[SCALE_MAXHEIGHT];
+
+ uint8 *_lightMask;
+
+ void clearIconArea(int menu, int pocket, Common::Rect *r);
+
+ void decompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pitch, int xOff = 0, int yOff = 0);
+ void drawMouse(void);
+
+ uint8 getMatch(uint8 r, uint8 g, uint8 b);
+ void fadeServer(void);
+
+ void squashImage(byte *dst, uint16 dstPitch, uint16 dstWidth,
+ uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
+ uint16 srcHeight, byte *backbuf);
+ void stretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth,
+ uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
+ uint16 srcHeight, byte *backbuf);
+
+ void updateRect(Common::Rect *r);
+
+ void blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *clip_rect);
+
+ void mirrorSprite(uint8 *dst, uint8 *src, int16 w, int16 h);
+ int32 decompressRLE256(uint8 *dest, uint8 *source, int32 decompSize);
+ void unwindRaw16(uint8 *dest, uint8 *source, uint8 blockSize, uint8 *colTable);
+ int32 decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable);
+
+public:
+ Display(int16 width, int16 height);
+
+ // Game screen metrics
+ int16 _screenWide;
+ int16 _screenDeep;
+
+ int16 _mouseX;
+ int16 _mouseY;
+
+ uint8 _palCopy[256][4];
+
+ int8 getRenderLevel(void);
+ void setRenderLevel(int8 level);
+
+ void clearScene(void);
+
+ void processMenu(void);
+ int32 showMenu(uint8 menu);
+ int32 hideMenu(uint8 menu);
+ int32 setMenuIcon(uint8 menu, uint8 pocket, uint8 *icon);
+ void closeMenuImmediately(void);
+
+ void updateDisplay(void);
+ void setWindowName(const char *windowName);
+ void setNeedFullRedraw(void);
+
+ void setPalette(int16 startEntry, int16 noEntries, uint8 *palette, uint8 setNow);
+ void updatePaletteMatchTable(uint8 *data);
+ uint8 quickMatch(uint8 r, uint8 g, uint8 b);
+ int32 fadeUp(float time = 0.75);
+ int32 fadeDown(float time = 0.75);
+ uint8 getFadeStatus(void);
+ void dimPalette(void);
+ void waitForFade(void);
+
+ int32 setMouseAnim(uint8 *ma, int32 size, int32 mouseFlash);
+ int32 setLuggageAnim(uint8 *la, int32 size);
+ int32 animateMouse(void);
+
+ void resetRenderEngine(void);
+
+ void setScrollTarget(int16 sx, int16 sy);
+ void initialiseRenderCycle(void);
+ void startRenderCycle(void);
+ bool endRenderCycle(void);
+ void renderParallax(_parallax *p, int16 layer);
+ void setLocationMetrics(uint16 w, uint16 h);
+ int32 initialiseBackgroundLayer(_parallax *p);
+ void closeBackgroundLayer(void);
+
+#ifdef _SWORD2_DEBUG
+ void plotPoint(uint16 x, uint16 y, uint8 colour);
+ void drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 colour);
+#endif
+
+ int32 createSurface(_spriteInfo *s, uint8 **surface);
+ void drawSurface(_spriteInfo *s, uint8 *surface, Common::Rect *clipRect = NULL);
+ void deleteSurface(uint8 *surface);
+ int32 drawSprite(_spriteInfo *s);
+ int32 openLightMask(_spriteInfo *s);
+ int32 closeLightMask(void);
+};
+
} // End of namespace Sword2
#endif