aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-02-19 14:02:16 +0000
committerTorbjörn Andersson2005-02-19 14:02:16 +0000
commit43cfe01f3d8d2307a23933920cce43740871f367 (patch)
treefe56072f944bc980981d5f0cfe1683116645d076 /sword2/driver
parent0de5fa2f33147529edcf4dccd24a2750b23a2867 (diff)
downloadscummvm-rg350-43cfe01f3d8d2307a23933920cce43740871f367.tar.gz
scummvm-rg350-43cfe01f3d8d2307a23933920cce43740871f367.tar.bz2
scummvm-rg350-43cfe01f3d8d2307a23933920cce43740871f367.zip
This is the second part of the BS2 restructuring. There are two new
classes: Screen and Mouse. Screen handles most of the drawing, except the mouse cursor and in-game menus. The old Graphics class is no more. I've also fixed some "reverse stereo" regressions from the first part of the restructuring. I'm not sure what the next step will be, but hopefully it will be smaller than this one was. svn-id: r16812
Diffstat (limited to 'sword2/driver')
-rw-r--r--sword2/driver/_mouse.cpp17
-rw-r--r--sword2/driver/animation.cpp67
-rw-r--r--sword2/driver/animation.h16
-rw-r--r--sword2/driver/d_draw.cpp58
-rw-r--r--sword2/driver/d_draw.h242
-rw-r--r--sword2/driver/d_sound.cpp6
-rw-r--r--sword2/driver/driver96.h30
-rw-r--r--sword2/driver/menu.cpp40
-rw-r--r--sword2/driver/palette.cpp112
-rw-r--r--sword2/driver/rdwin.cpp7
-rw-r--r--sword2/driver/render.cpp46
-rw-r--r--sword2/driver/sprite.cpp94
12 files changed, 253 insertions, 482 deletions
diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp
index 42ee42872c..606d362767 100644
--- a/sword2/driver/_mouse.cpp
+++ b/sword2/driver/_mouse.cpp
@@ -20,14 +20,19 @@
#include "common/stdafx.h"
#include "common/system.h"
+
#include "sword2/sword2.h"
-#include "sword2/driver/d_draw.h"
+#include "sword2/mouse.h"
namespace Sword2 {
+// This is the maximum mouse cursor size in the SDL backend
+#define MAX_MOUSE_W 80
+#define MAX_MOUSE_H 80
+
#define MOUSEFLASHFRAME 6
-void Graphics::decompressMouse(byte *decomp, byte *comp, int width, int height, int pitch, int xOff, int yOff) {
+void Mouse::decompressMouse(byte *decomp, byte *comp, int width, int height, int pitch, int xOff, int yOff) {
int32 size = width * height;
int32 i = 0;
int x = 0;
@@ -52,7 +57,7 @@ void Graphics::decompressMouse(byte *decomp, byte *comp, int width, int height,
}
}
-void Graphics::drawMouse(void) {
+void Mouse::drawMouse() {
byte mouseData[MAX_MOUSE_W * MAX_MOUSE_H];
if (!_mouseAnim && !_luggageAnim)
@@ -129,7 +134,7 @@ void Graphics::drawMouse(void) {
* Animates the current mouse pointer
*/
-int32 Graphics::animateMouse(void) {
+int32 Mouse::animateMouse() {
uint8 prevMouseFrame = _mouseFrame;
if (!_mouseAnim)
@@ -154,7 +159,7 @@ int32 Graphics::animateMouse(void) {
* or not there is a lead-in animation
*/
-int32 Graphics::setMouseAnim(byte *ma, int32 size, int32 mouseFlash) {
+int32 Mouse::setMouseAnim(byte *ma, int32 size, int32 mouseFlash) {
if (_mouseAnim) {
free(_mouseAnim);
_mouseAnim = NULL;
@@ -194,7 +199,7 @@ int32 Graphics::setMouseAnim(byte *ma, int32 size, int32 mouseFlash) {
* @param size the size of the animation data
*/
-int32 Graphics::setLuggageAnim(byte *ma, int32 size) {
+int32 Mouse::setLuggageAnim(byte *ma, int32 size) {
if (_luggageAnim) {
free(_luggageAnim);
_luggageAnim = NULL;
diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp
index d6d58e856d..260d42f454 100644
--- a/sword2/driver/animation.cpp
+++ b/sword2/driver/animation.cpp
@@ -31,7 +31,6 @@
#include "sword2/resman.h"
#include "sword2/sound.h"
#include "sword2/driver/animation.h"
-#include "sword2/driver/d_draw.h"
#include "sword2/driver/menu.h"
#include "sword2/driver/render.h"
@@ -47,7 +46,7 @@ AnimationState::~AnimationState() {
#ifdef BACKEND_8BIT
void AnimationState::setPalette(byte *pal) {
- _vm->_graphics->setPalette(0, 256, pal, RDPAL_INSTANT);
+ _vm->_screen->setPalette(0, 256, pal, RDPAL_INSTANT);
}
#else
@@ -82,7 +81,7 @@ void AnimationState::drawTextObject(SpriteInfo *s, byte *src) {
void AnimationState::clearScreen(void) {
#ifdef BACKEND_8BIT
- memset(_vm->_graphics->getScreen(), 0, MOVIE_WIDTH * MOVIE_HEIGHT);
+ memset(_vm->_screen->getScreen(), 0, MOVIE_WIDTH * MOVIE_HEIGHT);
#else
OverlayColor black = _sys->RGBToColor(0, 0, 0);
@@ -93,7 +92,7 @@ void AnimationState::clearScreen(void) {
void AnimationState::updateScreen(void) {
#ifdef BACKEND_8BIT
- byte *buf = _vm->_graphics->getScreen() + ((480 - MOVIE_HEIGHT) / 2) * RENDERWIDE + (640 - MOVIE_WIDTH) / 2;
+ byte *buf = _vm->_screen->getScreen() + ((480 - MOVIE_HEIGHT) / 2) * RENDERWIDE + (640 - MOVIE_WIDTH) / 2;
_vm->_system->copyRectToScreen(buf, MOVIE_WIDTH, (640 - MOVIE_WIDTH) / 2, (480 - MOVIE_HEIGHT) / 2, MOVIE_WIDTH, MOVIE_HEIGHT);
#else
@@ -104,7 +103,7 @@ void AnimationState::updateScreen(void) {
void AnimationState::drawYUV(int width, int height, byte *const *dat) {
#ifdef BACKEND_8BIT
- _vm->_graphics->plotYUV(lut, width, height, dat);
+ _vm->_screen->plotYUV(lut, width, height, dat);
#else
plotYUV(lookup, width, height, dat);
#endif
@@ -138,12 +137,12 @@ MoviePlayer::MoviePlayer(Sword2Engine *vm)
void MoviePlayer::openTextObject(MovieTextObject *obj) {
if (obj->textSprite)
- _vm->_graphics->createSurface(obj->textSprite, &_textSurface);
+ _vm->_screen->createSurface(obj->textSprite, &_textSurface);
}
void MoviePlayer::closeTextObject(MovieTextObject *obj) {
if (_textSurface) {
- _vm->_graphics->deleteSurface(_textSurface);
+ _vm->_screen->deleteSurface(_textSurface);
_textSurface = NULL;
}
}
@@ -151,12 +150,12 @@ void MoviePlayer::closeTextObject(MovieTextObject *obj) {
void MoviePlayer::drawTextObject(AnimationState *anim, MovieTextObject *obj) {
if (obj->textSprite && _textSurface) {
#ifdef BACKEND_8BIT
- _vm->_graphics->drawSurface(obj->textSprite, _textSurface);
+ _vm->_screen->drawSurface(obj->textSprite, _textSurface);
#else
if (anim)
anim->drawTextObject(obj->textSprite, _textSurface);
else
- _vm->_graphics->drawSurface(obj->textSprite, _textSurface);
+ _vm->_screen->drawSurface(obj->textSprite, _textSurface);
#endif
}
}
@@ -211,7 +210,7 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], int32 lea
// Wait for the lead-out to stop, if there is any.
while (_leadOutHandle.isActive()) {
- _vm->_graphics->updateDisplay();
+ _vm->_screen->updateDisplay();
_vm->_system->delayMillis(30);
}
@@ -232,7 +231,7 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
bool startNextText = false;
byte oldPal[256 * 4];
- memcpy(oldPal, _vm->_graphics->_palette, sizeof(oldPal));
+ memcpy(oldPal, _vm->_screen->getPalette(), sizeof(oldPal));
AnimationState *anim = new AnimationState(_vm);
@@ -246,8 +245,8 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
#ifndef BACKEND_8BIT
// Clear the screen, because whatever is on it will be visible when the
// overlay is removed.
- _vm->_graphics->clearScene();
- _vm->_graphics->updateDisplay();
+ _vm->_screen->clearScene();
+ _vm->_screen->updateDisplay();
#endif
#ifndef SCUMM_BIG_ENDIAN
@@ -357,7 +356,7 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
_snd->stopHandle(handle);
while (handle.isActive()) {
- _vm->_graphics->updateDisplay(false);
+ _vm->_screen->updateDisplay(false);
_sys->delayMillis(100);
}
@@ -365,7 +364,7 @@ void MoviePlayer::playMPEG(const char *filename, MovieTextObject *text[], byte *
anim->clearScreen();
anim->updateScreen();
- _vm->_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT);
+ _vm->_screen->setPalette(0, 256, oldPal, RDPAL_INSTANT);
delete anim;
}
@@ -384,14 +383,14 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
byte oldPal[256 * 4];
byte tmpPal[256 * 4];
- _vm->_graphics->clearScene();
+ _vm->_screen->clearScene();
// HACK: Draw instructions
//
// I'm using the the menu area, because that's unlikely to be touched
// by anything else during the cutscene.
- memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
+ memset(_vm->_screen->getScreen(), 0, _vm->_screen->getScreenWide() * MENUDEEP);
byte *data;
@@ -415,16 +414,16 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
SpriteInfo msgSprite;
byte *msgSurface;
- msgSprite.x = _vm->_graphics->_screenWide / 2 - frame->width / 2;
+ msgSprite.x = _vm->_screen->getScreenWide() / 2 - frame->width / 2;
msgSprite.y = RDMENU_MENUDEEP / 2 - frame->height / 2;
msgSprite.w = frame->width;
msgSprite.h = frame->height;
msgSprite.type = RDSPR_NOCOMPRESSION;
msgSprite.data = data + sizeof(FrameHeader);
- _vm->_graphics->createSurface(&msgSprite, &msgSurface);
- _vm->_graphics->drawSurface(&msgSprite, msgSurface);
- _vm->_graphics->deleteSurface(msgSurface);
+ _vm->_screen->createSurface(&msgSprite, &msgSurface);
+ _vm->_screen->drawSurface(&msgSprite, msgSurface);
+ _vm->_screen->deleteSurface(msgSurface);
free(data);
@@ -436,12 +435,12 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
// Fake a palette that will hopefully make the text visible. In the
// opening cutscene it seems to use colours 1 (black) and 255 (white).
- memcpy(oldPal, _vm->_graphics->_palette, sizeof(oldPal));
+ memcpy(oldPal, _vm->_screen->getPalette(), sizeof(oldPal));
memset(tmpPal, 0, sizeof(tmpPal));
tmpPal[255 * 4 + 0] = 255;
tmpPal[255 * 4 + 1] = 255;
tmpPal[255 * 4 + 2] = 255;
- _vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
+ _vm->_screen->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
PlayingSoundHandle handle;
@@ -458,7 +457,7 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
break;
if (frameCounter == text[textCounter]->startFrame) {
- _vm->_graphics->clearScene();
+ _vm->_screen->clearScene();
openTextObject(text[textCounter]);
drawTextObject(NULL, text[textCounter]);
if (text[textCounter]->speech) {
@@ -468,13 +467,13 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
if (frameCounter == text[textCounter]->endFrame) {
closeTextObject(text[textCounter]);
- _vm->_graphics->clearScene();
- _vm->_graphics->setNeedFullRedraw();
+ _vm->_screen->clearScene();
+ _vm->_screen->setNeedFullRedraw();
textCounter++;
}
frameCounter++;
- _vm->_graphics->updateDisplay();
+ _vm->_screen->updateDisplay();
KeyboardEvent *ke = _vm->keyboardEvent();
@@ -496,23 +495,23 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
// importantly - that we don't free the sound buffer while it's in use.
while (handle.isActive()) {
- _vm->_graphics->updateDisplay(false);
+ _vm->_screen->updateDisplay(false);
_sys->delayMillis(100);
}
closeTextObject(text[textCounter]);
- _vm->_graphics->clearScene();
- _vm->_graphics->setNeedFullRedraw();
+ _vm->_screen->clearScene();
+ _vm->_screen->setNeedFullRedraw();
// HACK: Remove the instructions created above
Common::Rect r;
- memset(_vm->_graphics->_buffer, 0, _vm->_graphics->_screenWide * MENUDEEP);
+ memset(_vm->_screen->getScreen(), 0, _vm->_screen->getScreenWide() * MENUDEEP);
r.left = r.top = 0;
- r.right = _vm->_graphics->_screenWide;
+ r.right = _vm->_screen->getScreenWide();
r.bottom = MENUDEEP;
- _vm->_graphics->updateRect(&r);
+ _vm->_screen->updateRect(&r);
// FIXME: For now, only play the lead-out music for cutscenes that have
// subtitles.
@@ -520,7 +519,7 @@ void MoviePlayer::playDummy(const char *filename, MovieTextObject *text[], byte
if (!skipCutscene && leadOut)
_vm->_sound->playFx(&_leadOutHandle, leadOut, leadOutLen, SoundMixer::kMaxChannelVolume, 0, false, SoundMixer::kMusicAudioDataType);
- _vm->_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT);
+ _vm->_screen->setPalette(0, 256, oldPal, RDPAL_INSTANT);
}
} // End of namespace Sword2
diff --git a/sword2/driver/animation.h b/sword2/driver/animation.h
index f34d8c8b06..0dcac3fc81 100644
--- a/sword2/driver/animation.h
+++ b/sword2/driver/animation.h
@@ -23,12 +23,24 @@
#define ANIMATION_H
#include "graphics/animation.h"
-
#include "sound/mixer.h"
-
namespace Sword2 {
+struct SpriteInfo;
+
+// This is the structure which is passed to the sequence player. It includes
+// the smack to play, and any text lines which are to be displayed over the top
+// of the sequence.
+
+struct MovieTextObject {
+ uint16 startFrame;
+ uint16 endFrame;
+ SpriteInfo *textSprite;
+ uint32 speechBufferSize;
+ uint16 *speech;
+};
+
class AnimationState : public ::Graphics::BaseAnimationState {
private:
Sword2Engine *_vm;
diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp
index cee13d5d06..b20123e4b5 100644
--- a/sword2/driver/d_draw.cpp
+++ b/sword2/driver/d_draw.cpp
@@ -21,72 +21,20 @@
#include "common/stdafx.h"
#include "common/system.h"
#include "sword2/sword2.h"
-#include "sword2/driver/d_draw.h"
#include "sword2/driver/menu.h"
#include "sword2/driver/render.h"
namespace Sword2 {
-Graphics::Graphics(Sword2Engine *vm, int16 width, int16 height)
- : _vm(vm), _iconCount(0), _needFullRedraw(false),
- _fadeStatus(RDFADE_NONE), _mouseSprite(NULL), _mouseAnim(NULL),
- _luggageAnim(NULL), _layer(0), _renderAverageTime(60),
- _lightMask(NULL), _screenWide(width), _screenDeep(height) {
-
- int i, j;
-
- _buffer = _dirtyGrid = NULL;
-
- _buffer = (byte *) malloc(width * height);
- if (!_buffer)
- error("Could not initialise display");
-
- _vm->_system->initSize(width, height);
-
- _gridWide = width / CELLWIDE;
- _gridDeep = height / CELLDEEP;
-
- if ((width % CELLWIDE) || (height % CELLDEEP))
- error("Bad cell size");
-
- _dirtyGrid = (byte *) calloc(_gridWide, _gridDeep);
- if (!_buffer)
- error("Could not initialise dirty grid");
-
- for (i = 0; i < ARRAYSIZE(_blockSurfaces); i++)
- _blockSurfaces[i] = NULL;
-
- for (i = 0; i < 2; i++) {
- for (j = 0; j < RDMENU_MAXPOCKETS; j++) {
- _icons[i][j] = NULL;
- _pocketStatus[i][j] = 0;
- }
-
- _menuStatus[i] = RDMENU_HIDDEN;
- }
-}
-
-Graphics::~Graphics() {
- free(_buffer);
- free(_dirtyGrid);
- closeBackgroundLayer();
- free(_lightMask);
- free(_mouseAnim);
- free(_luggageAnim);
- for (int i = 0; i < 2; i++)
- for (int j = 0; j < RDMENU_MAXPOCKETS; j++)
- free(_icons[i][j]);
-}
-
/**
* @return the graphics detail setting
*/
-int8 Graphics::getRenderLevel(void) {
+int8 Screen::getRenderLevel() {
return _renderLevel;
}
-void Graphics::setRenderLevel(int8 level) {
+void Screen::setRenderLevel(int8 level) {
_renderLevel = level;
switch (_renderLevel) {
@@ -115,7 +63,7 @@ void Graphics::setRenderLevel(int8 level) {
* touch the menu areas of the screen.
*/
-void Graphics::clearScene(void) {
+void Screen::clearScene() {
memset(_buffer + MENUDEEP * _screenWide, 0, _screenWide * RENDERDEEP);
_needFullRedraw = true;
}
diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h
deleted file mode 100644
index e9b27c7f2c..0000000000
--- a/sword2/driver/d_draw.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/* Copyright (C) 1994-1998 Revolution Software Ltd.
- * Copyright (C) 2003-2005 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Header$
- */
-
-#ifndef D_DRAW_H
-#define D_DRAW_H
-
-#include "common/rect.h"
-
-namespace Sword2 {
-
-// 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
-
-// Dirty grid cell size
-#define CELLWIDE 10
-#define CELLDEEP 20
-
-#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
-
-struct BlockSurface {
- byte data[BLOCKWIDTH * BLOCKHEIGHT];
- bool transparent;
-};
-
-class Graphics {
- friend class MoviePlayer;
-
-private:
- Sword2Engine *_vm;
-
- byte *_buffer;
- byte *_dirtyGrid;
-
- uint16 _gridWide;
- uint16 _gridDeep;
-
- int32 _renderCaps;
- int8 _renderLevel;
-
- uint8 _menuStatus[2];
- byte *_icons[2][RDMENU_MAXPOCKETS];
- uint8 _pocketStatus[2][RDMENU_MAXPOCKETS];
-
- uint8 _iconCount;
-
- bool _needFullRedraw;
-
- byte _paletteMatch[PALTABLESIZE];
-
- uint8 _fadeStatus;
-
- int32 _fadeStartTime;
- int32 _fadeTotalTime;
-
- uint8 _mouseFrame;
- byte *_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];
-
- byte *_lightMask;
-
- void clearIconArea(int menu, int pocket, Common::Rect *r);
-
- void decompressMouse(byte *decomp, byte *comp, int width, int height, int pitch, int xOff = 0, int yOff = 0);
-
- void fadeServer(void);
-
- void scaleImageFast(byte *dst, uint16 dstPitch, uint16 dstWidth,
- uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
- uint16 srcHeight);
- void scaleImageGood(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 *clipRect);
-
- void mirrorSprite(byte *dst, byte *src, int16 w, int16 h);
- int32 decompressRLE256(byte *dest, byte *source, int32 decompSize);
- void unwindRaw16(byte *dest, byte *source, uint8 blockSize, byte *colTable);
- int32 decompressRLE16(byte *dest, byte *source, int32 decompSize, byte *colTable);
-
-
-public:
- Graphics(Sword2Engine *vm, int16 width, int16 height);
- ~Graphics();
-
- // Game screen metrics
- int16 _screenWide;
- int16 _screenDeep;
-
- byte _palette[256 * 4];
-
- byte *getScreen(void) { return _buffer; }
-
- 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, byte *icon);
- void closeMenuImmediately(void);
-
- void markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1);
- void updateDisplay(bool redrawScene = true);
- void setNeedFullRedraw(void);
-
- void setPalette(int16 startEntry, int16 noEntries, byte *palette, uint8 setNow);
- void updatePaletteMatchTable(byte *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(byte *ma, int32 size, int32 mouseFlash);
- int32 setLuggageAnim(byte *la, int32 size);
- int32 animateMouse(void);
-
- void drawMouse(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);
-
- void plotPoint(int16 x, int16 y, uint8 colour);
- void drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 colour);
-#ifdef BACKEND_8BIT
- void plotYUV(byte *lut, int width, int height, byte *const *dat);
-#endif
-
-
- int32 createSurface(SpriteInfo *s, byte **surface);
- void drawSurface(SpriteInfo *s, byte *surface, Common::Rect *clipRect = NULL);
- void deleteSurface(byte *surface);
- int32 drawSprite(SpriteInfo *s);
- int32 openLightMask(SpriteInfo *s);
- int32 closeLightMask(void);
-};
-
-} // End of namespace Sword2
-
-#endif
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 39992b18d6..a8e3d444e0 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -35,7 +35,6 @@
#include "sword2/sword2.h"
#include "sword2/resman.h"
#include "sword2/sound.h"
-#include "sword2/driver/d_draw.h"
namespace Sword2 {
@@ -790,8 +789,11 @@ int32 Sound::setFxIdVolumePan(int32 i, int vol, int pan) {
_fxQueue[i].volume = (vol * SoundMixer::kMaxChannelVolume) / 16;
- if (pan != -1)
+ if (pan != 255) {
+ if (isReverseStereo())
+ pan = -pan;
_fxQueue[i].pan = (pan * 127) / 16;
+ }
if (!_fxMuted && _fxQueue[i].handle.isActive()) {
_vm->_mixer->setChannelVolume(_fxQueue[i].handle, _fxQueue[i].volume);
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h
index a10c4652f1..43acd6e7b2 100644
--- a/sword2/driver/driver96.h
+++ b/sword2/driver/driver96.h
@@ -177,36 +177,6 @@ struct Parallax {
#pragma END_PACK_STRUCTS
#endif
-// The SpriteInfo structure is used to tell the driver96 code what attributes
-// are linked to a sprite for drawing. These include position, scaling and
-// compression.
-
-struct SpriteInfo {
- int16 x; // coords for top-left of sprite
- int16 y;
- uint16 w; // dimensions of sprite (before scaling)
- uint16 h;
- uint16 scale; // scale at which to draw, given in 256ths ['0' or '256' MEANS DON'T SCALE]
- uint16 scaledWidth; // new dimensions (we calc these for the mouse area, so may as well pass to you to save time)
- uint16 scaledHeight; //
- uint16 type; // mask containing 'RDSPR_' bits specifying compression type, flip, transparency, etc
- uint16 blend; // holds the blending values.
- byte *data; // pointer to the sprite data
- byte *colourTable; // pointer to 16-byte colour table, only applicable to 16-col compression type
-};
-
-// This is the structure which is passed to the sequence player. It includes
-// the smack to play, and any text lines which are to be displayed over the top
-// of the sequence.
-
-struct MovieTextObject {
- uint16 startFrame;
- uint16 endFrame;
- SpriteInfo *textSprite;
- uint32 speechBufferSize;
- uint16 *speech;
-};
-
} // End of namespace Sword2
#endif
diff --git a/sword2/driver/menu.cpp b/sword2/driver/menu.cpp
index 4929a97696..267a254a4d 100644
--- a/sword2/driver/menu.cpp
+++ b/sword2/driver/menu.cpp
@@ -20,7 +20,7 @@
#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/driver/d_draw.h"
+#include "sword2/mouse.h"
#include "sword2/driver/render.h"
namespace Sword2 {
@@ -28,17 +28,20 @@ namespace Sword2 {
#define MENUDEEP 40
#define MAXMENUANIMS 8
-void Graphics::clearIconArea(int menu, int pocket, Common::Rect *r) {
+void Mouse::clearIconArea(int menu, int pocket, Common::Rect *r) {
+ byte *buf = _vm->_screen->getScreen();
+ int16 screenWide = _vm->_screen->getScreenWide();
+
r->top = menu * (RENDERDEEP + MENUDEEP) + (MENUDEEP - RDMENU_ICONDEEP) / 2;
r->bottom = r->top + RDMENU_ICONDEEP;
r->left = RDMENU_ICONSTART + pocket * (RDMENU_ICONWIDE + RDMENU_ICONSPACING);
r->right = r->left + RDMENU_ICONWIDE;
- byte *dst = _buffer + r->top * _screenWide + r->left;
+ byte *dst = buf + r->top * screenWide + r->left;
for (int i = 0; i < RDMENU_ICONDEEP; i++) {
memset(dst, 0, RDMENU_ICONWIDE);
- dst += _screenWide;
+ dst += screenWide;
}
}
@@ -48,13 +51,16 @@ void Graphics::clearIconArea(int menu, int pocket, Common::Rect *r) {
* system is.
*/
-void Graphics::processMenu(void) {
+void Mouse::processMenu() {
uint8 menu;
uint8 i, j;
uint8 frameCount;
Common::Rect r1, r2;
static int32 lastTime = 0;
+ byte *buf = _vm->_screen->getScreen();
+ int16 screenWide = _vm->_screen->getScreenWide();
+
if (lastTime == 0) {
lastTime = _vm->getMillis();
frameCount = 1;
@@ -153,22 +159,22 @@ void Graphics::processMenu(void) {
}
if (xoff != 0 && yoff != 0) {
- byte *dst = _buffer + r2.top * _screenWide + r2.left;
+ byte *dst = buf + r2.top * screenWide + r2.left;
byte *src = _icons[menu][i];
if (_pocketStatus[menu][i] != MAXMENUANIMS) {
- scaleImageFast(
- dst, _screenWide, r2.right - r2.left, r2.bottom - r2.top,
+ _vm->_screen->scaleImageFast(
+ dst, screenWide, r2.right - r2.left, r2.bottom - r2.top,
src, RDMENU_ICONWIDE, RDMENU_ICONWIDE, RDMENU_ICONDEEP);
} else {
for (j = 0; j < RDMENU_ICONDEEP; j++) {
memcpy(dst, src, RDMENU_ICONWIDE);
src += RDMENU_ICONWIDE;
- dst += _screenWide;
+ dst += screenWide;
}
}
}
- updateRect(&r1);
+ _vm->_screen->updateRect(&r1);
}
curx += (RDMENU_ICONSPACING + RDMENU_ICONWIDE);
}
@@ -181,7 +187,7 @@ void Graphics::processMenu(void) {
* @return RD_OK, or an error code
*/
-int32 Graphics::showMenu(uint8 menu) {
+int32 Mouse::showMenu(uint8 menu) {
// Check for invalid menu parameter
if (menu > RDMENU_BOTTOM)
return RDERR_INVALIDMENU;
@@ -201,7 +207,7 @@ int32 Graphics::showMenu(uint8 menu) {
* @return RD_OK, or an error code
*/
-int32 Graphics::hideMenu(uint8 menu) {
+int32 Mouse::hideMenu(uint8 menu) {
// Check for invalid menu parameter
if (menu > RDMENU_BOTTOM)
return RDERR_INVALIDMENU;
@@ -219,7 +225,7 @@ int32 Graphics::hideMenu(uint8 menu) {
* This function hides both menus immediately.
*/
-void Graphics::closeMenuImmediately(void) {
+void Mouse::closeMenuImmediately() {
Common::Rect r;
int i;
@@ -229,11 +235,11 @@ void Graphics::closeMenuImmediately(void) {
for (i = 0; i < RDMENU_MAXPOCKETS; i++) {
if (_icons[RDMENU_TOP][i]) {
clearIconArea(RDMENU_TOP, i, &r);
- updateRect(&r);
+ _vm->_screen->updateRect(&r);
}
if (_icons[RDMENU_BOTTOM][i]) {
clearIconArea(RDMENU_BOTTOM, i, &r);
- updateRect(&r);
+ _vm->_screen->updateRect(&r);
}
}
@@ -248,7 +254,7 @@ void Graphics::closeMenuImmediately(void) {
* @return RD_OK, or an error code
*/
-int32 Graphics::setMenuIcon(uint8 menu, uint8 pocket, byte *icon) {
+int32 Mouse::setMenuIcon(uint8 menu, uint8 pocket, byte *icon) {
Common::Rect r;
// Check for invalid menu parameter.
@@ -265,7 +271,7 @@ int32 Graphics::setMenuIcon(uint8 menu, uint8 pocket, byte *icon) {
free(_icons[menu][pocket]);
_icons[menu][pocket] = NULL;
clearIconArea(menu, pocket, &r);
- updateRect(&r);
+ _vm->_screen->updateRect(&r);
}
// Only put the icon in the pocket if it is not NULL
diff --git a/sword2/driver/palette.cpp b/sword2/driver/palette.cpp
index 754a3564ce..3e42cef493 100644
--- a/sword2/driver/palette.cpp
+++ b/sword2/driver/palette.cpp
@@ -21,19 +21,101 @@
#include "common/stdafx.h"
#include "common/system.h"
#include "sword2/sword2.h"
-#include "sword2/driver/d_draw.h"
+#include "sword2/defs.h"
+#include "sword2/logic.h"
+#include "sword2/resman.h"
namespace Sword2 {
/**
- * Sets a table of palette indices which will be searched later for a quick
- * palette match.
- * @param data the palette match table
+ * Start layer palette fading up
*/
-void Graphics::updatePaletteMatchTable(byte *data) {
- assert(data);
- memcpy(_paletteMatch, data, PALTABLESIZE);
+void Screen::startNewPalette() {
+ // If the screen is still fading down then wait for black - could
+ // happen when everythings cached into a large memory model
+ waitForFade();
+
+ byte *screenFile = _vm->_resman->openResource(_thisScreen.background_layer_id);
+
+ memcpy(_paletteMatch, _vm->fetchPaletteMatchTable(screenFile), PALTABLESIZE);
+ setPalette(0, 256, _vm->fetchPalette(screenFile), RDPAL_FADE);
+
+ // Indicating that it's a screen palette
+ _lastPaletteRes = 0;
+
+ _vm->_resman->closeResource(_thisScreen.background_layer_id);
+ fadeUp();
+ _thisScreen.new_palette = 0;
+}
+
+void Screen::setFullPalette(int32 palRes) {
+ // fudge for hut interior
+ // - unpausing should restore last palette as normal (could be screen
+ // palette or 'dark_palette_13')
+ // - but restoring the screen palette after 'dark_palette_13' should
+ // now work properly too!
+
+ // "Hut interior" refers to the watchman's hut in Marseille, and this
+ // is apparently needed for the palette to be restored properly when
+ // you turn the light off. (I didn't even notice the light switch!)
+
+ if (Logic::_scriptVars[LOCATION] == 13) {
+ // unpausing
+ if (palRes == -1) {
+ // restore whatever palette was last set (screen
+ // palette or 'dark_palette_13')
+ palRes = _lastPaletteRes;
+ }
+ } else {
+ // check if we're just restoring the current screen palette
+ // because we might actually need to use a separate palette
+ // file anyway eg. for pausing & unpausing during the eclipse
+
+ // unpausing (fudged for location 13)
+ if (palRes == -1) {
+ // we really meant '0'
+ palRes = 0;
+ }
+
+ if (palRes == 0 && _lastPaletteRes)
+ palRes = _lastPaletteRes;
+ }
+
+ // If non-zero, set palette to this separate palette file. Otherwise,
+ // set palette to current screen palette.
+
+ if (palRes) {
+ byte *pal = _vm->_resman->openResource(palRes);
+
+ StandardHeader *head = (StandardHeader *) pal;
+ assert(head->fileType == PALETTE_FILE);
+
+ pal += sizeof(StandardHeader);
+
+ // always set colour 0 to black because most background screen
+ // palettes have a bright colour 0 although it should come out
+ // as black in the game!
+
+ pal[0] = 0;
+ pal[1] = 0;
+ pal[2] = 0;
+ pal[3] = 0;
+
+ setPalette(0, 256, pal, RDPAL_INSTANT);
+ _vm->_resman->closeResource(palRes);
+ } else {
+ if (_thisScreen.background_layer_id) {
+ byte *data = _vm->_resman->openResource(_thisScreen.background_layer_id);
+ memcpy(_paletteMatch, _vm->fetchPaletteMatchTable(data), PALTABLESIZE);
+ setPalette(0, 256, _vm->fetchPalette(data), RDPAL_INSTANT);
+ _vm->_resman->closeResource(_thisScreen.background_layer_id);
+ } else
+ error("setFullPalette(0) called, but no current screen available!");
+ }
+
+ if (palRes != CONTROL_PANEL_PALETTE)
+ _lastPaletteRes = palRes;
}
/**
@@ -47,7 +129,7 @@ void Graphics::updatePaletteMatchTable(byte *data) {
// FIXME: This used to be inlined - probably a good idea - but the
// linker complained when I tried to use it in sprite.cpp.
-uint8 Graphics::quickMatch(uint8 r, uint8 g, uint8 b) {
+uint8 Screen::quickMatch(uint8 r, uint8 g, uint8 b) {
return _paletteMatch[((int32) (r >> 2) << 12) + ((int32) (g >> 2) << 6) + (b >> 2)];
}
@@ -59,7 +141,7 @@ uint8 Graphics::quickMatch(uint8 r, uint8 g, uint8 b) {
* @param fadeNow whether to perform the change immediately or delayed
*/
-void Graphics::setPalette(int16 startEntry, int16 noEntries, byte *colourTable, uint8 fadeNow) {
+void Screen::setPalette(int16 startEntry, int16 noEntries, byte *colourTable, uint8 fadeNow) {
assert(noEntries > 0);
memcpy(&_palette[4 * startEntry], colourTable, noEntries * 4);
@@ -70,7 +152,7 @@ void Graphics::setPalette(int16 startEntry, int16 noEntries, byte *colourTable,
}
}
-void Graphics::dimPalette(void) {
+void Screen::dimPalette() {
byte *p = _palette;
for (int i = 0; i < 256; i++) {
@@ -88,7 +170,7 @@ void Graphics::dimPalette(void) {
* @param time the time it will take the palette to fade up
*/
-int32 Graphics::fadeUp(float time) {
+int32 Screen::fadeUp(float time) {
if (getFadeStatus() != RDFADE_BLACK && getFadeStatus() != RDFADE_NONE)
return RDERR_FADEINCOMPLETE;
@@ -104,7 +186,7 @@ int32 Graphics::fadeUp(float time) {
* @param time the time it will take the palette to fade down
*/
-int32 Graphics::fadeDown(float time) {
+int32 Screen::fadeDown(float time) {
if (getFadeStatus() != RDFADE_BLACK && getFadeStatus() != RDFADE_NONE)
return RDERR_FADEINCOMPLETE;
@@ -121,18 +203,18 @@ int32 Graphics::fadeDown(float time) {
* (not faded), or RDFADE_BLACK (completely faded down)
*/
-uint8 Graphics::getFadeStatus(void) {
+uint8 Screen::getFadeStatus() {
return _fadeStatus;
}
-void Graphics::waitForFade(void) {
+void Screen::waitForFade() {
while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK) {
updateDisplay();
_vm->_system->delayMillis(20);
}
}
-void Graphics::fadeServer(void) {
+void Screen::fadeServer() {
static int32 previousTime = 0;
byte fadePalette[256 * 4];
byte *newPalette = fadePalette;
diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp
index 14d4e144f5..d74cc89bc8 100644
--- a/sword2/driver/rdwin.cpp
+++ b/sword2/driver/rdwin.cpp
@@ -21,7 +21,6 @@
#include "common/stdafx.h"
#include "common/system.h"
#include "sword2/sword2.h"
-#include "sword2/driver/d_draw.h"
#include "sword2/driver/menu.h"
namespace Sword2 {
@@ -30,7 +29,7 @@ namespace Sword2 {
* Tell updateDisplay() that the scene needs to be completely updated.
*/
-void Graphics::setNeedFullRedraw(void) {
+void Screen::setNeedFullRedraw() {
_needFullRedraw = true;
}
@@ -38,7 +37,7 @@ void Graphics::setNeedFullRedraw(void) {
* Mark an area of the screen as dirty, first generation.
*/
-void Graphics::markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1) {
+void Screen::markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1) {
int16 gridX0 = x0 / CELLWIDE;
int16 gridY0 = y0 / CELLDEEP;
int16 gridX1 = x1 / CELLWIDE;
@@ -58,7 +57,7 @@ void Graphics::markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1) {
* @param redrawScene If true, redraw the scene.
*/
-void Graphics::updateDisplay(bool redrawScene) {
+void Screen::updateDisplay(bool redrawScene) {
_vm->parseEvents();
fadeServer();
diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp
index 5ea1c63b06..ff0dcab5a9 100644
--- a/sword2/driver/render.cpp
+++ b/sword2/driver/render.cpp
@@ -21,22 +21,23 @@
#include "common/stdafx.h"
#include "common/system.h"
#include "sword2/sword2.h"
+#include "sword2/build_display.h"
#include "sword2/driver/animation.h"
-#include "sword2/driver/d_draw.h"
#include "sword2/driver/menu.h"
#include "sword2/driver/render.h"
namespace Sword2 {
-#define MILLISECSPERCYCLE 83
+#define MILLISECSPERCYCLE 83
+#define RENDERAVERAGETOTAL 4
-void Graphics::updateRect(Common::Rect *r) {
+void Screen::updateRect(Common::Rect *r) {
_vm->_system->copyRectToScreen(_buffer + r->top * _screenWide + r->left,
_screenWide, r->left, r->top, r->right - r->left,
r->bottom - r->top);
}
-void Graphics::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *clipRect) {
+void Screen::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *clipRect) {
if (!r->intersects(*clipRect))
return;
@@ -85,7 +86,7 @@ void Graphics::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *
// This code isn't quite like the original DrawSprite(), but should be close
// enough.
-void Graphics::scaleImageFast(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight) {
+void Screen::scaleImageFast(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight) {
int x, y;
for (x = 0; x < dstWidth; x++)
@@ -102,7 +103,7 @@ void Graphics::scaleImageFast(byte *dst, uint16 dstPitch, uint16 dstWidth, uint1
}
}
-void Graphics::scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
+void Screen::scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
for (int y = 0; y < dstHeight; y++) {
for (int x = 0; x < dstWidth; x++) {
uint8 c1, c2, c3, c4;
@@ -194,7 +195,7 @@ void Graphics::scaleImageGood(byte *dst, uint16 dstPitch, uint16 dstWidth, uint1
* @param colour colour of the point
*/
-void Graphics::plotPoint(int16 x, int16 y, uint8 colour) {
+void Screen::plotPoint(int16 x, int16 y, uint8 colour) {
byte *buf = _buffer + MENUDEEP * RENDERWIDE;
x -= _scrollX;
@@ -217,7 +218,7 @@ void Graphics::plotPoint(int16 x, int16 y, uint8 colour) {
// Uses Bresenham's incremental algorithm!
-void Graphics::drawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
+void Screen::drawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
int dxmod, dymod;
int ince, incne;
int d;
@@ -363,7 +364,7 @@ void Graphics::drawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
* @param h height of the current location
*/
-void Graphics::setLocationMetrics(uint16 w, uint16 h) {
+void Screen::setLocationMetrics(uint16 w, uint16 h) {
_locationWide = w;
_locationDeep = h;
setNeedFullRedraw();
@@ -374,7 +375,7 @@ void Graphics::setLocationMetrics(uint16 w, uint16 h) {
* parallax can be either foreground, background or the main screen.
*/
-void Graphics::renderParallax(Parallax *p, int16 l) {
+void Screen::renderParallax(Parallax *p, int16 l) {
int16 x, y;
Common::Rect r;
@@ -420,7 +421,7 @@ void Graphics::renderParallax(Parallax *p, int16 l) {
* Initialises the timers before the render loop is entered.
*/
-void Graphics::initialiseRenderCycle(void) {
+void Screen::initialiseRenderCycle(void) {
_initialTime = _vm->_system->getMillis();
_totalTime = _initialTime + MILLISECSPERCYCLE;
}
@@ -430,7 +431,7 @@ void Graphics::initialiseRenderCycle(void) {
* render cycle.
*/
-void Graphics::startRenderCycle(void) {
+void Screen::startRenderCycle(void) {
_scrollXOld = _scrollX;
_scrollYOld = _scrollY;
@@ -458,7 +459,7 @@ void Graphics::startRenderCycle(void) {
* or false if it should continue
*/
-bool Graphics::endRenderCycle(void) {
+bool Screen::endRenderCycle(void) {
static int32 renderTimeLog[4] = { 60, 60, 60, 60 };
static int32 renderCountIndex = 0;
int32 time;
@@ -524,7 +525,7 @@ bool Graphics::endRenderCycle(void) {
* Reset scrolling stuff. This function is called from initBackground()
*/
-void Graphics::resetRenderEngine(void) {
+void Screen::resetRenderEngine(void) {
_parallaxScrollX = 0;
_parallaxScrollY = 0;
_scrollX = 0;
@@ -532,22 +533,11 @@ void Graphics::resetRenderEngine(void) {
}
/**
- * Sets the scroll target position for the end of the game cycle. The driver
- * will then automatically scroll as many times as it can to reach this
- * position in the allotted time.
- */
-
-void Graphics::setScrollTarget(int16 sx, int16 sy) {
- _scrollXTarget = sx;
- _scrollYTarget = sy;
-}
-
-/**
* This function should be called five times with either the parallax layer
* or a NULL pointer in order of background parallax to foreground parallax.
*/
-int32 Graphics::initialiseBackgroundLayer(Parallax *p) {
+int32 Screen::initialiseBackgroundLayer(Parallax *p) {
uint16 i, j, k;
byte *data;
byte *dst;
@@ -666,7 +656,7 @@ int32 Graphics::initialiseBackgroundLayer(Parallax *p) {
* Should be called once after leaving the room to free up memory.
*/
-void Graphics::closeBackgroundLayer(void) {
+void Screen::closeBackgroundLayer(void) {
debug(2, "CloseBackgroundLayer");
for (int i = 0; i < MAXLAYERS; i++) {
@@ -683,7 +673,7 @@ void Graphics::closeBackgroundLayer(void) {
}
#ifdef BACKEND_8BIT
-void Graphics::plotYUV(byte *lut, int width, int height, byte *const *dat) {
+void Screen::plotYUV(byte *lut, int width, int height, byte *const *dat) {
byte *buf = _buffer + ((480 - height) / 2) * RENDERWIDE + (640 - width) / 2;
int x, y;
diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp
index e6c1ffe0e8..7c96df75c2 100644
--- a/sword2/driver/sprite.cpp
+++ b/sword2/driver/sprite.cpp
@@ -20,7 +20,7 @@
#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/driver/d_draw.h"
+#include "sword2/build_display.h"
namespace Sword2 {
@@ -32,7 +32,7 @@ namespace Sword2 {
* @param h height of the sprite
*/
-void Graphics::mirrorSprite(byte *dst, byte *src, int16 w, int16 h) {
+void Screen::mirrorSprite(byte *dst, byte *src, int16 w, int16 h) {
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
*dst++ = *(src + w - x - 1);
@@ -44,12 +44,12 @@ void Graphics::mirrorSprite(byte *dst, byte *src, int16 w, int16 h) {
/**
* This function takes a compressed frame of a sprite with up to 256 colours
* and decompresses it.
- * @param dest destination buffer
- * @param source source buffer
+ * @param dst destination buffer
+ * @param src source buffer
* @param decompSize the expected size of the decompressed sprite
*/
-int32 Graphics::decompressRLE256(byte *dest, byte *source, int32 decompSize) {
+int32 Screen::decompressRLE256(byte *dst, byte *src, int32 decompSize) {
// PARAMETERS:
// source points to the start of the sprite data for input
// decompSize gives size of decompressed data in bytes
@@ -57,35 +57,35 @@ int32 Graphics::decompressRLE256(byte *dest, byte *source, int32 decompSize) {
// data
byte headerByte; // block header byte
- byte *endDest = dest + decompSize; // pointer to byte after end of decomp buffer
+ byte *endDest = dst + decompSize; // pointer to byte after end of decomp buffer
int32 rv;
- while(1) {
+ while (1) {
// FLAT block
// read FLAT block header & increment 'scan' to first pixel
// of block
- headerByte = *source++;
+ headerByte = *src++;
// if this isn't a zero-length block
if (headerByte) {
- if (dest + headerByte > endDest) {
+ if (dst + headerByte > endDest) {
rv = 1;
break;
}
// set the next 'headerByte' pixels to the next colour
// at 'source'
- memset(dest, *source, headerByte);
+ memset(dst, *src, headerByte);
// increment destination pointer to just after this
// block
- dest += headerByte;
+ dst += headerByte;
// increment source pointer to just after this colour
- source++;
+ src++;
// if we've decompressed all of the data
- if (dest == endDest) {
+ if (dst == endDest) {
rv = 0; // return "OK"
break;
}
@@ -94,28 +94,28 @@ int32 Graphics::decompressRLE256(byte *dest, byte *source, int32 decompSize) {
// RAW block
// read RAW block header & increment 'scan' to first pixel of
// block
- headerByte = *source++;
+ headerByte = *src++;
// if this isn't a zero-length block
if (headerByte) {
- if (dest + headerByte > endDest) {
+ if (dst + headerByte > endDest) {
rv = 1;
break;
}
// copy the next 'headerByte' pixels from source to
// destination
- memcpy(dest,source,headerByte);
+ memcpy(dst, src, headerByte);
// increment destination pointer to just after this
// block
- dest += headerByte;
+ dst += headerByte;
// increment source pointer to just after this block
- source += headerByte;
+ src += headerByte;
// if we've decompressed all of the data
- if (dest == endDest) {
+ if (dst == endDest) {
rv = 0; // return "OK"
break;
}
@@ -129,19 +129,19 @@ int32 Graphics::decompressRLE256(byte *dest, byte *source, int32 decompSize) {
* Unwinds a run of 16-colour data into 256-colour palette data.
*/
-void Graphics::unwindRaw16(byte *dest, byte *source, uint8 blockSize, byte *colTable) {
+void Screen::unwindRaw16(byte *dst, byte *src, uint8 blockSize, byte *colTable) {
// for each pair of pixels
while (blockSize > 1) {
// 1st colour = number in table at position given by upper
// nibble of source byte
- *dest++ = colTable[(*source) >> 4];
+ *dst++ = colTable[(*src) >> 4];
// 2nd colour = number in table at position given by lower
// nibble of source byte
- *dest++ = colTable[(*source) & 0x0f];
+ *dst++ = colTable[(*src) & 0x0f];
// point to next source byte
- source++;
+ src++;
// decrement count of how many pixels left to read
blockSize -= 2;
@@ -151,50 +151,50 @@ void Graphics::unwindRaw16(byte *dest, byte *source, uint8 blockSize, byte *colT
if (blockSize) {
// colour = number in table at position given by upper nibble
// of source byte
- *dest++ = colTable[(*source) >> 4];
+ *dst++ = colTable[(*src) >> 4];
}
}
/**
* This function takes a compressed frame of a sprite (with up to 16 colours)
* and decompresses it.
- * @param dest destination buffer
- * @param source source buffer
+ * @param dst destination buffer
+ * @param src source buffer
* @param decompSize the expected size of the uncompressed sprite
* @param colTable mapping from the 16 encoded colours to the current palette
*/
-int32 Graphics::decompressRLE16(byte *dest, byte *source, int32 decompSize, byte *colTable) {
+int32 Screen::decompressRLE16(byte *dst, byte *src, int32 decompSize, byte *colTable) {
byte headerByte; // block header byte
- byte *endDest = dest + decompSize; // pointer to byte after end of decomp buffer
+ byte *endDest = dst + decompSize; // pointer to byte after end of decomp buffer
int32 rv;
- while(1) {
+ while (1) {
// FLAT block
// read FLAT block header & increment 'scan' to first pixel
// of block
- headerByte = *source++;
+ headerByte = *src++;
// if this isn't a zero-length block
if (headerByte) {
- if (dest + headerByte > endDest) {
+ if (dst + headerByte > endDest) {
rv = 1;
break;
}
// set the next 'headerByte' pixels to the next
// colour at 'source'
- memset(dest, *source, headerByte);
+ memset(dst, *src, headerByte);
// increment destination pointer to just after this
// block
- dest += headerByte;
+ dst += headerByte;
// increment source pointer to just after this colour
- source++;
+ src++;
// if we've decompressed all of the data
- if (dest == endDest) {
+ if (dst == endDest) {
rv = 0; // return "OK"
break;
}
@@ -203,29 +203,29 @@ int32 Graphics::decompressRLE16(byte *dest, byte *source, int32 decompSize, byte
// RAW block
// read RAW block header & increment 'scan' to first pixel of
// block
- headerByte = *source++;
+ headerByte = *src++;
// if this isn't a zero-length block
if (headerByte) {
- if (dest + headerByte > endDest) {
+ if (dst + headerByte > endDest) {
rv = 1;
break;
}
// copy the next 'headerByte' pixels from source to
// destination (NB. 2 pixels per byte)
- unwindRaw16(dest, source, headerByte, colTable);
+ unwindRaw16(dst, src, headerByte, colTable);
// increment destination pointer to just after this
// block
- dest += headerByte;
+ dst += headerByte;
// increment source pointer to just after this block
// (NB. headerByte gives pixels, so /2 for bytes)
- source += (headerByte + 1) / 2;
+ src += (headerByte + 1) / 2;
// if we've decompressed all of the data
- if (dest >= endDest) {
+ if (dst >= endDest) {
rv = 0; // return "OK"
break;
}
@@ -244,7 +244,7 @@ int32 Graphics::decompressRLE16(byte *dest, byte *source, int32 decompSize, byte
* @return RD_OK, or an error code
*/
-int32 Graphics::createSurface(SpriteInfo *s, byte **sprite) {
+int32 Screen::createSurface(SpriteInfo *s, byte **sprite) {
*sprite = (byte *) malloc(s->w * s->h);
if (!*sprite)
return RDERR_OUTOFMEMORY;
@@ -269,7 +269,7 @@ int32 Graphics::createSurface(SpriteInfo *s, byte **sprite) {
* @param clipRect the clipping rectangle
*/
-void Graphics::drawSurface(SpriteInfo *s, byte *surface, Common::Rect *clipRect) {
+void Screen::drawSurface(SpriteInfo *s, byte *surface, Common::Rect *clipRect) {
Common::Rect rd, rs;
uint16 x, y;
byte *src, *dst;
@@ -328,7 +328,7 @@ void Graphics::drawSurface(SpriteInfo *s, byte *surface, Common::Rect *clipRect)
* Destroys a surface.
*/
-void Graphics::deleteSurface(byte *surface) {
+void Screen::deleteSurface(byte *surface) {
free(surface);
}
@@ -353,7 +353,7 @@ void Graphics::deleteSurface(byte *surface) {
// FIXME: I'm sure this could be optimized. There's plenty of data copying and
// mallocing here.
-int32 Graphics::drawSprite(SpriteInfo *s) {
+int32 Screen::drawSprite(SpriteInfo *s) {
byte *src, *dst;
byte *sprite, *newSprite;
uint16 scale;
@@ -610,7 +610,7 @@ int32 Graphics::drawSprite(SpriteInfo *s) {
* Opens the light masking sprite for a room.
*/
-int32 Graphics::openLightMask(SpriteInfo *s) {
+int32 Screen::openLightMask(SpriteInfo *s) {
// FIXME: The light mask is only needed on higher graphics detail
// settings, so to save memory we could simply ignore it on lower
// settings. But then we need to figure out how to ensure that it
@@ -633,7 +633,7 @@ int32 Graphics::openLightMask(SpriteInfo *s) {
* Closes the light masking sprite for a room.
*/
-int32 Graphics::closeLightMask(void) {
+int32 Screen::closeLightMask(void) {
if (!_lightMask)
return RDERR_NOTOPEN;