aboutsummaryrefslogtreecommitdiff
path: root/sword2/driver
diff options
context:
space:
mode:
Diffstat (limited to 'sword2/driver')
-rw-r--r--sword2/driver/_mouse.cpp92
-rw-r--r--sword2/driver/d_draw.cpp50
-rw-r--r--sword2/driver/d_draw.h7
-rw-r--r--sword2/driver/d_sound.cpp2
-rw-r--r--sword2/driver/driver96.h54
-rw-r--r--sword2/driver/keyboard.cpp39
-rw-r--r--sword2/driver/menu.cpp12
-rw-r--r--sword2/driver/palette.cpp20
-rw-r--r--sword2/driver/rdwin.cpp30
-rw-r--r--sword2/driver/render.cpp31
-rw-r--r--sword2/driver/sprite.cpp20
11 files changed, 180 insertions, 177 deletions
diff --git a/sword2/driver/_mouse.cpp b/sword2/driver/_mouse.cpp
index 8216c5fa07..bce554a3f3 100644
--- a/sword2/driver/_mouse.cpp
+++ b/sword2/driver/_mouse.cpp
@@ -26,43 +26,59 @@
namespace Sword2 {
-#define MAX_MOUSE_EVENTS 16
#define MOUSEFLASHFRAME 6
-static uint8 mouseBacklog = 0;
-static uint8 mouseLogPos = 0;
-static _mouseEvent mouseLog[MAX_MOUSE_EVENTS];
+/**
+ * Logs the mouse button event passed in buttons. The button events are
+ * defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and
+ * RD_RIGHTBUTTONUP.
+ */
-void Display::resetRenderEngine(void) {
- _parallaxScrollX = 0;
- _parallaxScrollY = 0;
- _scrollX = 0;
- _scrollY = 0;
+void Input::logMouseEvent(uint16 buttons) {
+ // We need to leave the one, which is the current event, alone!
+ if (_mouseBacklog == MAX_MOUSE_EVENTS - 1)
+ return;
+
+ _mouseLog[(_mouseBacklog + _mouseLogPos) % MAX_MOUSE_EVENTS].buttons = buttons;
+ _mouseBacklog++;
+}
+
+bool Input::checkForMouseEvents(void) {
+ return _mouseBacklog != 0;
}
-// --------------------------------------------------------------------------
-// Logs the mouse button event passed in buttons. The button events are
-// defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and
-// RD_RIGHTBUTTONUP.
-// --------------------------------------------------------------------------
+/**
+ * Get the next pending mouse event.
+ * @return a pointer to the mouse event, or NULL of there is none
+ */
-void LogMouseEvent(uint16 buttons) {
+_mouseEvent *Input::mouseEvent(void) {
_mouseEvent *me;
- // We need to leave the one, which is the current event, alone!
- if (mouseBacklog == MAX_MOUSE_EVENTS - 1)
- return;
+ if (_mouseBacklog) {
+ me = &_mouseLog[_mouseLogPos];
+ if (++_mouseLogPos == MAX_MOUSE_EVENTS)
+ _mouseLogPos = 0;
- me = &mouseLog[(mouseBacklog + mouseLogPos) % MAX_MOUSE_EVENTS];
- me->buttons = buttons;
- mouseBacklog++;
+ _mouseBacklog--;
+ return me;
+ }
+
+ return NULL;
+}
+
+void Graphics::resetRenderEngine(void) {
+ _parallaxScrollX = 0;
+ _parallaxScrollY = 0;
+ _scrollX = 0;
+ _scrollY = 0;
}
// FIXME: The original code used 0 for transparency, while our backend uses
// 0xFF. That means that parts of the mouse cursor that weren't meant to be
// transparent may be now.
-void Display::decompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pitch, int xOff, int yOff) {
+void Graphics::decompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pitch, int xOff, int yOff) {
int32 size = width * height;
int32 i = 0;
int x = 0;
@@ -87,7 +103,7 @@ void Display::decompressMouse(uint8 *decomp, uint8 *comp, int width, int height,
}
}
-void Display::drawMouse(void) {
+void Graphics::drawMouse(void) {
if (!_mouseAnim && !_luggageAnim)
return;
@@ -159,34 +175,10 @@ void Display::drawMouse(void) {
}
/**
- * Get the next pending mouse event.
- * @return a pointer to the mouse event, or NULL of there is none
- */
-
-_mouseEvent *MouseEvent(void) {
- _mouseEvent *me;
-
- if (mouseBacklog) {
- me = &mouseLog[mouseLogPos];
- if (++mouseLogPos == MAX_MOUSE_EVENTS)
- mouseLogPos = 0;
-
- mouseBacklog--;
- return me;
- }
-
- return NULL;
-}
-
-uint8 CheckForMouseEvents(void) {
- return mouseBacklog; // return the number of mouse events waiting
-}
-
-/**
* Animates the current mouse pointer
*/
-int32 Display::animateMouse(void) {
+int32 Graphics::animateMouse(void) {
uint8 prevMouseFrame = _mouseFrame;
if (!_mouseAnim)
@@ -211,7 +203,7 @@ int32 Display::animateMouse(void) {
* or not there is a lead-in animation
*/
-int32 Display::setMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) {
+int32 Graphics::setMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) {
if (_mouseAnim) {
free(_mouseAnim);
_mouseAnim = NULL;
@@ -251,7 +243,7 @@ int32 Display::setMouseAnim(uint8 *ma, int32 size, int32 mouseFlash) {
* @param size the size of the animation data
*/
-int32 Display::setLuggageAnim(uint8 *ma, int32 size) {
+int32 Graphics::setLuggageAnim(uint8 *ma, int32 size) {
if (_luggageAnim) {
free(_luggageAnim);
_luggageAnim = NULL;
diff --git a/sword2/driver/d_draw.cpp b/sword2/driver/d_draw.cpp
index 8ccb28ab56..1db17dd974 100644
--- a/sword2/driver/d_draw.cpp
+++ b/sword2/driver/d_draw.cpp
@@ -28,7 +28,7 @@
namespace Sword2 {
-Display::Display(int16 width, int16 height)
+Graphics::Graphics(int16 width, int16 height)
: _iconCount(0), _needFullRedraw(false), _fadeStatus(RDFADE_NONE),
_mouseSprite(NULL), _mouseAnim(NULL), _luggageAnim(NULL),
_layer(0), _renderAverageTime(60), _lightMask(NULL),
@@ -59,11 +59,11 @@ Display::Display(int16 width, int16 height)
* @return the graphics detail setting
*/
-int8 Display::getRenderLevel(void) {
+int8 Graphics::getRenderLevel(void) {
return _renderLevel;
}
-void Display::setRenderLevel(int8 level) {
+void Graphics::setRenderLevel(int8 level) {
_renderLevel = level;
switch (_renderLevel) {
@@ -92,25 +92,25 @@ void Display::setRenderLevel(int8 level) {
* touch the menu areas of the screen.
*/
-void Display::clearScene(void) {
+void Graphics::clearScene(void) {
memset(_buffer + MENUDEEP * _screenWide, 0, _screenWide * RENDERDEEP);
}
void MoviePlayer::openTextObject(_movieTextObject *obj) {
if (obj->textSprite)
- g_display->createSurface(obj->textSprite, &_textSurface);
+ g_graphics->createSurface(obj->textSprite, &_textSurface);
}
void MoviePlayer::closeTextObject(_movieTextObject *obj) {
if (_textSurface) {
- g_display->deleteSurface(_textSurface);
+ g_graphics->deleteSurface(_textSurface);
_textSurface = NULL;
}
}
void MoviePlayer::drawTextObject(_movieTextObject *obj) {
if (obj->textSprite && _textSurface)
- g_display->drawSurface(obj->textSprite, _textSurface);
+ g_graphics->drawSurface(obj->textSprite, _textSurface);
}
/**
@@ -130,14 +130,14 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
uint8 oldPal[1024];
uint8 tmpPal[1024];
- g_display->clearScene();
+ g_graphics->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(g_display->_buffer, 0, g_display->_screenWide * MENUDEEP);
+ memset(g_graphics->_buffer, 0, g_graphics->_screenWide * MENUDEEP);
uint8 msg[] = "Cutscene - Press ESC to exit";
mem *data = fontRenderer->makeTextSprite(msg, 640, 255, g_sword2->_speechFontId);
@@ -145,16 +145,16 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
_spriteInfo msgSprite;
uint8 *msgSurface;
- msgSprite.x = g_display->_screenWide / 2 - frame->width / 2;
+ msgSprite.x = g_graphics->_screenWide / 2 - frame->width / 2;
msgSprite.y = RDMENU_MENUDEEP / 2 - frame->height / 2;
msgSprite.w = frame->width;
msgSprite.h = frame->height;
msgSprite.type = RDSPR_DISPLAYALIGN | RDSPR_NOCOMPRESSION | RDSPR_TRANS;
msgSprite.data = data->ad + sizeof(_frameHeader);
- g_display->createSurface(&msgSprite, &msgSurface);
- g_display->drawSurface(&msgSprite, msgSurface);
- g_display->deleteSurface(msgSurface);
+ g_graphics->createSurface(&msgSprite, &msgSurface);
+ g_graphics->drawSurface(&msgSprite, msgSurface);
+ g_graphics->deleteSurface(msgSurface);
memory->freeMemory(data);
// In case the cutscene has a long lead-in, start just before
@@ -170,12 +170,12 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
// The text should probably be colored the same as the rest of
// the in-game text.
- memcpy(oldPal, g_display->_palCopy, 1024);
+ memcpy(oldPal, g_graphics->_palCopy, 1024);
memset(tmpPal, 0, 1024);
tmpPal[255 * 4 + 0] = 255;
tmpPal[255 * 4 + 1] = 255;
tmpPal[255 * 4 + 2] = 255;
- g_display->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
+ g_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
PlayingSoundHandle handle = 0;
@@ -186,7 +186,7 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
break;
if (frameCounter == text[textCounter]->startFrame) {
- g_display->clearScene();
+ g_graphics->clearScene();
openTextObject(text[textCounter]);
drawTextObject(text[textCounter]);
if (text[textCounter]->speech) {
@@ -196,17 +196,17 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
if (frameCounter == text[textCounter]->endFrame) {
closeTextObject(text[textCounter]);
- g_display->clearScene();
+ g_graphics->clearScene();
textCounter++;
}
frameCounter++;
- g_display->updateDisplay();
+ g_graphics->updateDisplay();
_keyboardEvent ke;
- if (ReadKey(&ke) == RD_OK && ke.keycode == 27) {
+ if (g_input->readKey(&ke) == RD_OK && ke.keycode == 27) {
g_sword2->_mixer->stopHandle(handle);
skipCutscene = true;
break;
@@ -221,17 +221,17 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
closeTextObject(text[textCounter]);
- g_display->clearScene();
- g_display->setNeedFullRedraw();
+ g_graphics->clearScene();
+ g_graphics->setNeedFullRedraw();
// HACK: Remove the instructions created above
Common::Rect r;
- memset(g_display->_buffer, 0, g_display->_screenWide * MENUDEEP);
+ memset(g_graphics->_buffer, 0, g_graphics->_screenWide * MENUDEEP);
r.left = r.top = 0;
- r.right = g_display->_screenWide;
+ r.right = g_graphics->_screenWide;
r.bottom = MENUDEEP;
- g_display->updateRect(&r);
+ g_graphics->updateRect(&r);
// FIXME: For now, only play the lead-out music for cutscenes
// that have subtitles.
@@ -239,7 +239,7 @@ int32 MoviePlayer::play(char *filename, _movieTextObject *text[], uint8 *musicOu
if (!skipCutscene)
g_sound->playLeadOut(musicOut);
- g_display->setPalette(0, 256, oldPal, RDPAL_INSTANT);
+ g_graphics->setPalette(0, 256, oldPal, RDPAL_INSTANT);
}
// Lead-in and lead-out music are, as far as I can tell, only used for
diff --git a/sword2/driver/d_draw.h b/sword2/driver/d_draw.h
index cea1941ad6..f3c0a055ee 100644
--- a/sword2/driver/d_draw.h
+++ b/sword2/driver/d_draw.h
@@ -76,7 +76,7 @@ typedef struct {
bool transparent;
} BlockSurface;
-class Display {
+class Graphics {
friend class MoviePlayer;
private:
@@ -174,15 +174,12 @@ private:
int32 decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable);
public:
- Display(int16 width, int16 height);
+ Graphics(int16 width, int16 height);
// Game screen metrics
int16 _screenWide;
int16 _screenDeep;
- int16 _mouseX;
- int16 _mouseY;
-
uint8 _palCopy[256][4];
int8 getRenderLevel(void);
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index c86a14193a..8235d25934 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -248,7 +248,7 @@ void Sound::playLeadOut(uint8 *leadOut) {
}
while (_fx[i]._handle) {
- g_display->updateDisplay();
+ g_graphics->updateDisplay();
g_system->delay_msecs(30);
}
}
diff --git a/sword2/driver/driver96.h b/sword2/driver/driver96.h
index fde513ba77..4ecf614da9 100644
--- a/sword2/driver/driver96.h
+++ b/sword2/driver/driver96.h
@@ -274,20 +274,6 @@ extern int32 SetLanguageVersion(uint8 version);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-// Mouse functions - from mouse.c
-//-----------------------------------------------------------------------------
-extern _mouseEvent *MouseEvent(void);
-uint8 CheckForMouseEvents(void);
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
-// Keyboard functions - from keyboard.c
-//-----------------------------------------------------------------------------
-extern bool KeyWaiting(void);
-extern int32 ReadKey(_keyboardEvent *ke);
-//-----------------------------------------------------------------------------
-
-//-----------------------------------------------------------------------------
// Misc functions - from misc.cpp
//-----------------------------------------------------------------------------
extern uint32 SVM_timeGetTime(void);
@@ -295,6 +281,46 @@ extern void SVM_SetFileAttributes(char *file, uint32 atrib);
extern void SVM_DeleteFile(char *file);
extern int32 SVM_GetVolumeInformation(char *cdPath, char *sCDName, uint32 maxPath, uint8 *, uint32 *dwMaxCompLength, uint32 *dwFSFlags, uint8 *, uint32 a);
+#define MAX_MOUSE_EVENTS 16
+
+// Key buffer size
+#define MAX_KEY_BUFFER 32
+
+class Input {
+ uint8 _mouseBacklog;
+ uint8 _mouseLogPos;
+ _mouseEvent _mouseLog[MAX_MOUSE_EVENTS];
+
+ void logMouseEvent(uint16 buttons);
+
+ // The number of key presses waiting to be processed.
+ uint8 _keyBacklog;
+
+ // Index of the next key to read from the buffer.
+ uint8 _keyLogPos;
+
+ // The keyboard buffer
+ _keyboardEvent _keyBuffer[MAX_KEY_BUFFER];
+
+ void writeKey(uint16 ascii, int keycode, int modifiers);
+
+public:
+ int16 _mouseX;
+ int16 _mouseY;
+
+ Input() :
+ _mouseBacklog(0), _mouseLogPos(0), _keyBacklog(0),
+ _keyLogPos(0) {};
+
+ void parseEvents(void);
+
+ _mouseEvent *mouseEvent(void);
+ bool checkForMouseEvents(void);
+
+ bool keyWaiting(void);
+ int32 readKey(_keyboardEvent *ev);
+};
+
} // End of namespace Sword2
#endif
diff --git a/sword2/driver/keyboard.cpp b/sword2/driver/keyboard.cpp
index d5f5e90f0c..8645f5b10d 100644
--- a/sword2/driver/keyboard.cpp
+++ b/sword2/driver/keyboard.cpp
@@ -22,22 +22,14 @@
namespace Sword2 {
-// Key buffer size
-#define MAX_KEY_BUFFER 32
-
-uint8 keyBacklog = 0; // The number of key presses waiting to be processed.
-uint8 keyPointer = 0; // Index of the next key to read from the buffer.
-
-_keyboardEvent keyBuffer[MAX_KEY_BUFFER]; // The keyboard buffer
-
-void WriteKey(uint16 ascii, int keycode, int modifiers) {
- if (keyBuffer && keyBacklog < MAX_KEY_BUFFER) {
- _keyboardEvent *slot = &keyBuffer[(keyPointer + keyBacklog) % MAX_KEY_BUFFER];
+void Input::writeKey(uint16 ascii, int keycode, int modifiers) {
+ if (_keyBuffer && _keyBacklog < MAX_KEY_BUFFER) {
+ _keyboardEvent *slot = &_keyBuffer[(_keyLogPos + _keyBacklog) % MAX_KEY_BUFFER];
slot->ascii = ascii;
slot->keycode = keycode;
slot->modifiers = modifiers;
- keyBacklog++;
+ _keyBacklog++;
}
}
@@ -45,8 +37,8 @@ void WriteKey(uint16 ascii, int keycode, int modifiers) {
* @return true if there is an unprocessed key waiting in the queue
*/
-bool KeyWaiting(void) {
- return keyBacklog != 0;
+bool Input::keyWaiting(void) {
+ return _keyBacklog != 0;
}
/**
@@ -54,24 +46,23 @@ bool KeyWaiting(void) {
* @return RD_OK, or an error code to indicate there is no key waiting.
*/
-int32 ReadKey(_keyboardEvent *ev) {
- if (!keyBacklog)
+int32 Input::readKey(_keyboardEvent *ev) {
+ if (!_keyBacklog)
return RDERR_NOKEYWAITING;
if (ev == NULL)
return RDERR_INVALIDPOINTER;
- ev->ascii = keyBuffer[keyPointer].ascii;
- ev->keycode = keyBuffer[keyPointer].keycode;
- ev->modifiers = keyBuffer[keyPointer].modifiers;
-
- keyPointer++;
+ ev->ascii = _keyBuffer[_keyLogPos].ascii;
+ ev->keycode = _keyBuffer[_keyLogPos].keycode;
+ ev->modifiers = _keyBuffer[_keyLogPos].modifiers;
- if (keyPointer == MAX_KEY_BUFFER)
- keyPointer = 0;
+ _keyLogPos++;
- keyBacklog--;
+ if (_keyLogPos == MAX_KEY_BUFFER)
+ _keyLogPos = 0;
+ _keyBacklog--;
return RD_OK;
}
diff --git a/sword2/driver/menu.cpp b/sword2/driver/menu.cpp
index 54a87c20ac..341fb85de9 100644
--- a/sword2/driver/menu.cpp
+++ b/sword2/driver/menu.cpp
@@ -29,7 +29,7 @@ namespace Sword2 {
#define MENUDEEP 40
#define MAXMENUANIMS 8
-void Display::clearIconArea(int menu, int pocket, Common::Rect *r) {
+void Graphics::clearIconArea(int menu, int pocket, Common::Rect *r) {
byte *dst;
int i;
@@ -52,7 +52,7 @@ void Display::clearIconArea(int menu, int pocket, Common::Rect *r) {
* system is.
*/
-void Display::processMenu(void) {
+void Graphics::processMenu(void) {
byte *src, *dst;
uint8 menu;
uint8 i, j;
@@ -199,7 +199,7 @@ void Display::processMenu(void) {
* @return RD_OK, or an error code
*/
-int32 Display::showMenu(uint8 menu) {
+int32 Graphics::showMenu(uint8 menu) {
// Check for invalid menu parameter
if (menu > RDMENU_BOTTOM)
return RDERR_INVALIDMENU;
@@ -219,7 +219,7 @@ int32 Display::showMenu(uint8 menu) {
* @return RD_OK, or an error code
*/
-int32 Display::hideMenu(uint8 menu) {
+int32 Graphics::hideMenu(uint8 menu) {
// Check for invalid menu parameter
if (menu > RDMENU_BOTTOM)
return RDERR_INVALIDMENU;
@@ -237,7 +237,7 @@ int32 Display::hideMenu(uint8 menu) {
* This function hides both menus immediately.
*/
-void Display::closeMenuImmediately(void) {
+void Graphics::closeMenuImmediately(void) {
Common::Rect r;
int i;
@@ -266,7 +266,7 @@ void Display::closeMenuImmediately(void) {
* @return RD_OK, or an error code
*/
-int32 Display::setMenuIcon(uint8 menu, uint8 pocket, uint8 *icon) {
+int32 Graphics::setMenuIcon(uint8 menu, uint8 pocket, uint8 *icon) {
Common::Rect r;
// Check for invalid menu parameter.
diff --git a/sword2/driver/palette.cpp b/sword2/driver/palette.cpp
index aa0f860a62..a4098426b3 100644
--- a/sword2/driver/palette.cpp
+++ b/sword2/driver/palette.cpp
@@ -26,7 +26,7 @@
namespace Sword2 {
-uint8 Display::getMatch(uint8 r, uint8 g, uint8 b) {
+uint8 Graphics::getMatch(uint8 r, uint8 g, uint8 b) {
int32 diff;
int32 min;
int16 diffred, diffgreen, diffblue;
@@ -67,7 +67,7 @@ uint8 Display::getMatch(uint8 r, uint8 g, uint8 b) {
* from the current palCopy
*/
-void Display::updatePaletteMatchTable(uint8 *data) {
+void Graphics::updatePaletteMatchTable(uint8 *data) {
if (!data) {
int16 red, green, blue;
uint8 *p;
@@ -101,7 +101,7 @@ void Display::updatePaletteMatchTable(uint8 *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 Display::quickMatch(uint8 r, uint8 g, uint8 b) {
+uint8 Graphics::quickMatch(uint8 r, uint8 g, uint8 b) {
return _paletteMatch[((int32) (r >> 2) << 12) + ((int32) (g >> 2) << 6) + (b >> 2)];
}
@@ -112,7 +112,7 @@ uint8 Display::quickMatch(uint8 r, uint8 g, uint8 b) {
* @param colourTable the new colour entries
*/
-void Display::setPalette(int16 startEntry, int16 noEntries, uint8 *colourTable, uint8 fadeNow) {
+void Graphics::setPalette(int16 startEntry, int16 noEntries, uint8 *colourTable, uint8 fadeNow) {
if (noEntries) {
memcpy(&_palCopy[startEntry][0], colourTable, noEntries * 4);
if (fadeNow == RDPAL_INSTANT)
@@ -121,7 +121,7 @@ void Display::setPalette(int16 startEntry, int16 noEntries, uint8 *colourTable,
g_system->set_palette((const byte *) _palCopy, 0, 256);
}
-void Display::dimPalette(void) {
+void Graphics::dimPalette(void) {
byte *p = (byte *) _palCopy;
for (int i = 0; i < 256 * 4; i++)
@@ -135,7 +135,7 @@ void Display::dimPalette(void) {
* @param time the time it will take the palette to fade up
*/
-int32 Display::fadeUp(float time) {
+int32 Graphics::fadeUp(float time) {
if (getFadeStatus() != RDFADE_BLACK && getFadeStatus() != RDFADE_NONE)
return RDERR_FADEINCOMPLETE;
@@ -151,7 +151,7 @@ int32 Display::fadeUp(float time) {
* @param time the time it will take the palette to fade down
*/
-int32 Display::fadeDown(float time) {
+int32 Graphics::fadeDown(float time) {
if (getFadeStatus() != RDFADE_BLACK && getFadeStatus() != RDFADE_NONE)
return RDERR_FADEINCOMPLETE;
@@ -168,18 +168,18 @@ int32 Display::fadeDown(float time) {
* (not faded), or RDFADE_BLACK (completely faded down)
*/
-uint8 Display::getFadeStatus(void) {
+uint8 Graphics::getFadeStatus(void) {
return _fadeStatus;
}
-void Display::waitForFade(void) {
+void Graphics::waitForFade(void) {
while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK) {
updateDisplay();
g_system->delay_msecs(20);
}
}
-void Display::fadeServer(void) {
+void Graphics::fadeServer(void) {
static int32 previousTime = 0;
const byte *newPalette = (const byte *) _fadePalette;
int32 currentTime;
diff --git a/sword2/driver/rdwin.cpp b/sword2/driver/rdwin.cpp
index 911bc1b646..050e8b3021 100644
--- a/sword2/driver/rdwin.cpp
+++ b/sword2/driver/rdwin.cpp
@@ -20,8 +20,6 @@
#include "common/stdafx.h"
#include "sword2/sword2.h"
#include "sword2/driver/driver96.h"
-#include "sword2/driver/_mouse.h"
-#include "sword2/driver/keyboard.h"
#include "sword2/driver/d_draw.h"
#include "sword2/driver/render.h"
#include "sword2/driver/menu.h"
@@ -33,29 +31,29 @@ namespace Sword2 {
// OSystem Event Handler. Full of cross platform goodness and 99% fat free!
// ---------------------------------------------------------------------------
-void Sword2Engine::parseEvents() {
+void Input::parseEvents(void) {
OSystem::Event event;
- while (_system->poll_event(&event)) {
- switch(event.event_code) {
+ while (g_system->poll_event(&event)) {
+ switch (event.event_code) {
case OSystem::EVENT_KEYDOWN:
- WriteKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
+ writeKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
break;
case OSystem::EVENT_MOUSEMOVE:
- g_display->_mouseX = event.mouse.x;
- g_display->_mouseY = event.mouse.y - MENUDEEP;
+ _mouseX = event.mouse.x;
+ _mouseY = event.mouse.y - MENUDEEP;
break;
case OSystem::EVENT_LBUTTONDOWN:
- LogMouseEvent(RD_LEFTBUTTONDOWN);
+ logMouseEvent(RD_LEFTBUTTONDOWN);
break;
case OSystem::EVENT_RBUTTONDOWN:
- LogMouseEvent(RD_RIGHTBUTTONDOWN);
+ logMouseEvent(RD_RIGHTBUTTONDOWN);
break;
case OSystem::EVENT_LBUTTONUP:
- LogMouseEvent(RD_LEFTBUTTONUP);
+ logMouseEvent(RD_LEFTBUTTONUP);
break;
case OSystem::EVENT_RBUTTONUP:
- LogMouseEvent(RD_RIGHTBUTTONUP);
+ logMouseEvent(RD_RIGHTBUTTONUP);
break;
case OSystem::EVENT_QUIT:
g_sword2->closeGame();
@@ -66,7 +64,7 @@ void Sword2Engine::parseEvents() {
}
}
-void Display::setNeedFullRedraw() {
+void Graphics::setNeedFullRedraw() {
_needFullRedraw = true;
}
@@ -75,8 +73,8 @@ void Display::setNeedFullRedraw() {
* windows and the interface it provides.
*/
-void Display::updateDisplay(void) {
- g_sword2->parseEvents();
+void Graphics::updateDisplay(void) {
+ g_input->parseEvents();
fadeServer();
// FIXME: We re-render the entire picture area of the screen for each
@@ -95,7 +93,7 @@ void Display::updateDisplay(void) {
* Set the window title
*/
-void Display::setWindowName(const char *windowName) {
+void Graphics::setWindowName(const char *windowName) {
OSystem::Property prop;
prop.caption = windowName;
diff --git a/sword2/driver/render.cpp b/sword2/driver/render.cpp
index eb58c9b96d..71f01befea 100644
--- a/sword2/driver/render.cpp
+++ b/sword2/driver/render.cpp
@@ -20,7 +20,6 @@
#include "stdafx.h"
#include "sword2/driver/driver96.h"
#include "sword2/driver/d_draw.h"
-#include "sword2/driver/_mouse.h"
#include "sword2/driver/render.h"
#include "sword2/driver/menu.h"
#include "sword2/sword2.h"
@@ -32,13 +31,13 @@ namespace Sword2 {
#define BLOCKWBITS 6
#define BLOCKHBITS 6
-void Display::updateRect(Common::Rect *r) {
+void Graphics::updateRect(Common::Rect *r) {
g_system->copy_rect(_buffer + r->top * _screenWide + r->left,
_screenWide, r->left, r->top, r->right - r->left,
r->bottom - r->top);
}
-void Display::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *clip_rect) {
+void Graphics::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *clip_rect) {
if (r->top > clip_rect->bottom || r->left > clip_rect->right || r->bottom <= clip_rect->top || r->right <= clip_rect->left)
return;
@@ -78,7 +77,7 @@ void Display::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *c
}
// UploadRect(r);
- g_display->setNeedFullRedraw();
+ setNeedFullRedraw();
}
// I've made the scaling two separate functions because there were cases from
@@ -94,7 +93,7 @@ void Display::blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *c
// be drawn. This is only used at the highest graphics detail setting (and not
// always even then) and is used to help anti-alias the image.
-void Display::squashImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
+void Graphics::squashImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
int32 ince, incne, d;
int16 x, y;
@@ -189,7 +188,7 @@ void Display::squashImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 ds
}
}
-void Display::stretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
+void Graphics::stretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth, uint16 srcHeight, byte *backbuf) {
byte *origDst = dst;
int32 ince, incne, d;
int16 x, y, i, j, k;
@@ -335,7 +334,7 @@ void Display::stretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth, uint16 d
* @param colour colour of the point
*/
-void Display::plotPoint(uint16 x, uint16 y, uint8 colour) {
+void Graphics::plotPoint(uint16 x, uint16 y, uint8 colour) {
uint8 *buf = _buffer + 40 * RENDERWIDE;
int16 newx, newy;
@@ -356,7 +355,7 @@ void Display::plotPoint(uint16 x, uint16 y, uint8 colour) {
*/
// Uses Bressnham's incremental algorithm!
-void Display::drawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
+void Graphics::drawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
uint8 *buf = _buffer + 40 * RENDERWIDE;
int dx, dy;
int dxmod, dymod;
@@ -519,7 +518,7 @@ void Display::drawLine(int16 x0, int16 y0, int16 x1, int16 y1, uint8 colour) {
* @param h height of the current location
*/
-void Display::setLocationMetrics(uint16 w, uint16 h) {
+void Graphics::setLocationMetrics(uint16 w, uint16 h) {
_locationWide = w;
_locationDeep = h;
}
@@ -529,7 +528,7 @@ void Display::setLocationMetrics(uint16 w, uint16 h) {
* parallax can be either foreground, background or the main screen.
*/
-void Display::renderParallax(_parallax *p, int16 l) {
+void Graphics::renderParallax(_parallax *p, int16 l) {
int16 x, y;
Common::Rect r;
@@ -575,7 +574,7 @@ void Display::renderParallax(_parallax *p, int16 l) {
* Initialises the timers before the render loop is entered.
*/
-void Display::initialiseRenderCycle(void) {
+void Graphics::initialiseRenderCycle(void) {
_initialTime = SVM_timeGetTime();
_totalTime = _initialTime + MILLISECSPERCYCLE;
}
@@ -585,7 +584,7 @@ void Display::initialiseRenderCycle(void) {
* render cycle.
*/
-void Display::startRenderCycle(void) {
+void Graphics::startRenderCycle(void) {
_scrollXOld = _scrollX;
_scrollYOld = _scrollY;
@@ -610,7 +609,7 @@ void Display::startRenderCycle(void) {
* terminated, or false if it should continue
*/
-bool Display::endRenderCycle(void) {
+bool Graphics::endRenderCycle(void) {
static int32 renderTimeLog[4] = { 60, 60, 60, 60 };
static int32 renderCountIndex = 0;
int32 time;
@@ -668,7 +667,7 @@ bool Display::endRenderCycle(void) {
* position in the allotted time.
*/
-void Display::setScrollTarget(int16 sx, int16 sy) {
+void Graphics::setScrollTarget(int16 sx, int16 sy) {
_scrollXTarget = sx;
_scrollYTarget = sy;
}
@@ -678,7 +677,7 @@ void Display::setScrollTarget(int16 sx, int16 sy) {
* or a NULL pointer in order of background parallax to foreground parallax.
*/
-int32 Display::initialiseBackgroundLayer(_parallax *p) {
+int32 Graphics::initialiseBackgroundLayer(_parallax *p) {
uint8 *memchunk;
uint8 zeros;
uint16 count;
@@ -804,7 +803,7 @@ int32 Display::initialiseBackgroundLayer(_parallax *p) {
* Should be called once after leaving the room to free up memory.
*/
-void Display::closeBackgroundLayer(void) {
+void Graphics::closeBackgroundLayer(void) {
debug(2, "CloseBackgroundLayer");
for (int j = 0; j < MAXLAYERS; j++) {
diff --git a/sword2/driver/sprite.cpp b/sword2/driver/sprite.cpp
index c7bf74177f..c9e21f6639 100644
--- a/sword2/driver/sprite.cpp
+++ b/sword2/driver/sprite.cpp
@@ -32,7 +32,7 @@ namespace Sword2 {
* @param h height of the sprite
*/
-void Display::mirrorSprite(uint8 *dst, uint8 *src, int16 w, int16 h) {
+void Graphics::mirrorSprite(uint8 *dst, uint8 *src, int16 w, int16 h) {
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
*dst++ = *(src + w - x - 1);
@@ -49,7 +49,7 @@ void Display::mirrorSprite(uint8 *dst, uint8 *src, int16 w, int16 h) {
* @param decompSize the expected size of the decompressed sprite
*/
-int32 Display::decompressRLE256(uint8 *dest, uint8 *source, int32 decompSize) {
+int32 Graphics::decompressRLE256(uint8 *dest, uint8 *source, int32 decompSize) {
// PARAMETERS:
// source points to the start of the sprite data for input
// decompSize gives size of decompressed data in bytes
@@ -129,7 +129,7 @@ int32 Display::decompressRLE256(uint8 *dest, uint8 *source, int32 decompSize) {
* Unwinds a run of 16-colour data into 256-colour palette data.
*/
-void Display::unwindRaw16(uint8 *dest, uint8 *source, uint8 blockSize, uint8 *colTable) {
+void Graphics::unwindRaw16(uint8 *dest, uint8 *source, uint8 blockSize, uint8 *colTable) {
// for each pair of pixels
while (blockSize > 1) {
// 1st colour = number in table at position given by upper
@@ -164,7 +164,7 @@ void Display::unwindRaw16(uint8 *dest, uint8 *source, uint8 blockSize, uint8 *co
* @param colTable mapping from the 16 encoded colours to the current palette
*/
-int32 Display::decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable) {
+int32 Graphics::decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable) {
uint8 headerByte; // block header byte
uint8 *endDest = dest + decompSize; // pointer to byte after end of decomp buffer
int32 rv;
@@ -244,7 +244,7 @@ int32 Display::decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uin
* @return RD_OK, or an error code
*/
-int32 Display::createSurface(_spriteInfo *s, uint8 **sprite) {
+int32 Graphics::createSurface(_spriteInfo *s, uint8 **sprite) {
uint8 *newSprite;
*sprite = (uint8 *) malloc(s->w * s->h);
@@ -288,7 +288,7 @@ int32 Display::createSurface(_spriteInfo *s, uint8 **sprite) {
* @param clipRect the clipping rectangle
*/
-void Display::drawSurface(_spriteInfo *s, uint8 *surface, Common::Rect *clipRect) {
+void Graphics::drawSurface(_spriteInfo *s, uint8 *surface, Common::Rect *clipRect) {
Common::Rect rd, rs;
uint16 x, y, srcPitch;
uint8 *src, *dst;
@@ -356,7 +356,7 @@ void Display::drawSurface(_spriteInfo *s, uint8 *surface, Common::Rect *clipRect
* Destroys a surface.
*/
-void Display::deleteSurface(uint8 *surface) {
+void Graphics::deleteSurface(uint8 *surface) {
free(surface);
}
@@ -381,7 +381,7 @@ void Display::deleteSurface(uint8 *surface) {
// FIXME: I'm sure this could be optimized. There's plenty of data copying and
// mallocing here.
-int32 Display::drawSprite(_spriteInfo *s) {
+int32 Graphics::drawSprite(_spriteInfo *s) {
uint8 *src, *dst;
uint8 *sprite, *newSprite;
uint8 *backbuf = NULL;
@@ -676,7 +676,7 @@ int32 Display::drawSprite(_spriteInfo *s) {
* Opens the light masking sprite for a room.
*/
-int32 Display::openLightMask(_spriteInfo *s) {
+int32 Graphics::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
@@ -699,7 +699,7 @@ int32 Display::openLightMask(_spriteInfo *s) {
* Closes the light masking sprite for a room.
*/
-int32 Display::closeLightMask(void) {
+int32 Graphics::closeLightMask(void) {
if (!_lightMask)
return RDERR_NOTOPEN;