[Scummvm-cvs-logs] CVS: scummvm/sword2/driver _mouse.cpp,1.26,1.27 d_draw.cpp,1.43,1.44 d_draw.h,1.14,1.15 d_sound.cpp,1.80,1.81 driver96.h,1.57,1.58 keyboard.cpp,1.12,1.13 menu.cpp,1.20,1.21 palette.cpp,1.23,1.24 rdwin.cpp,1.36,1.37 render.cpp,1.40,1.41 sprite.cpp,1.31,1.32

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Mon Nov 10 23:44:05 CET 2003


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1:/tmp/cvs-serv28759/driver

Modified Files:
	_mouse.cpp d_draw.cpp d_draw.h d_sound.cpp driver96.h 
	keyboard.cpp menu.cpp palette.cpp rdwin.cpp render.cpp 
	sprite.cpp 
Log Message:
Moved low-level keyboard and mouse handling to a new Input class, and
renamed the Display class Graphics for no better reason than me liking the
phrase "sound and graphics" better than "sound and display".


Index: _mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/_mouse.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- _mouse.cpp	8 Nov 2003 19:47:20 -0000	1.26
+++ _mouse.cpp	11 Nov 2003 07:43:02 -0000	1.27
@@ -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++;
 }
 
-// --------------------------------------------------------------------------
-// Logs the mouse button event passed in buttons.  The button events are 
-// defined as RD_LEFTBUTTONDOWN, RD_LEFTBUTTONUP, RD_RIGHTBUTTONDOWN and
-// RD_RIGHTBUTTONUP.
-// --------------------------------------------------------------------------
+bool Input::checkForMouseEvents(void) {
+	return _mouseBacklog != 0;
+}
 
-void LogMouseEvent(uint16 buttons) {
+/**
+ * Get the next pending mouse event.
+ * @return a pointer to the mouse event, or NULL of there is none
+ */
+
+_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::drawMouse(void) {
+void Graphics::drawMouse(void) {
 	if (!_mouseAnim && !_luggageAnim)
 		return;
 
@@ -159,34 +175,10 @@
 }
 
 /**
- * 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 @@
  * 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 @@
  * @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;

Index: d_draw.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_draw.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- d_draw.cpp	8 Nov 2003 19:47:20 -0000	1.43
+++ d_draw.cpp	11 Nov 2003 07:43:02 -0000	1.44
@@ -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 @@
  * @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 @@
  * 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 @@
 		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 @@
 		_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 @@
 		// 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 @@
 				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 @@
 
 			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 @@
 
 		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 @@
 		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

Index: d_draw.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_draw.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- d_draw.h	8 Nov 2003 19:47:20 -0000	1.14
+++ d_draw.h	11 Nov 2003 07:43:02 -0000	1.15
@@ -76,7 +76,7 @@
 	bool transparent;
 } BlockSurface;
 
-class Display {
+class Graphics {
 	friend class MoviePlayer;
 
 private:
@@ -174,14 +174,11 @@
 	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];
 

Index: d_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_sound.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- d_sound.cpp	8 Nov 2003 19:47:20 -0000	1.80
+++ d_sound.cpp	11 Nov 2003 07:43:02 -0000	1.81
@@ -248,7 +248,7 @@
 	}
 
 	while (_fx[i]._handle) {
-		g_display->updateDisplay();
+		g_graphics->updateDisplay();
 		g_system->delay_msecs(30);
 	}
 }

Index: driver96.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/driver96.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- driver96.h	8 Nov 2003 19:47:20 -0000	1.57
+++ driver96.h	11 Nov 2003 07:43:02 -0000	1.58
@@ -274,20 +274,6 @@
 //-----------------------------------------------------------------------------
 
 //-----------------------------------------------------------------------------
-//	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_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

Index: keyboard.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/keyboard.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- keyboard.cpp	28 Oct 2003 19:51:30 -0000	1.12
+++ keyboard.cpp	11 Nov 2003 07:43:02 -0000	1.13
@@ -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 @@
  * @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 @@
  * @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;
 }
 

Index: menu.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/menu.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- menu.cpp	28 Oct 2003 19:51:30 -0000	1.20
+++ menu.cpp	11 Nov 2003 07:43:02 -0000	1.21
@@ -29,7 +29,7 @@
 #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 @@
  * system is.
  */
 
-void Display::processMenu(void) {
+void Graphics::processMenu(void) {
 	byte *src, *dst;
 	uint8 menu;
 	uint8 i, j;
@@ -199,7 +199,7 @@
  * @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 @@
  * @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 @@
  * This function hides both menus immediately.
  */
 
-void Display::closeMenuImmediately(void) {
+void Graphics::closeMenuImmediately(void) {
 	Common::Rect r;
 	int i;
 
@@ -266,7 +266,7 @@
  * @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.

Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/palette.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- palette.cpp	28 Oct 2003 19:51:30 -0000	1.23
+++ palette.cpp	11 Nov 2003 07:43:02 -0000	1.24
@@ -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 @@
  * 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 @@
 // 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 @@
  * @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 @@
 		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 @@
  * @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 @@
  * @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 @@
  * (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;

Index: rdwin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/rdwin.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- rdwin.cpp	8 Nov 2003 18:15:35 -0000	1.36
+++ rdwin.cpp	11 Nov 2003 07:43:02 -0000	1.37
@@ -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 @@
 // 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 Display::setNeedFullRedraw() {
+void Graphics::setNeedFullRedraw() {
 	_needFullRedraw = true;
 }
 
@@ -75,8 +73,8 @@
  * 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 @@
  * Set the window title
  */
 
-void Display::setWindowName(const char *windowName) {
+void Graphics::setWindowName(const char *windowName) {
 	OSystem::Property prop;
 
 	prop.caption = windowName;

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/render.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- render.cpp	8 Nov 2003 18:15:35 -0000	1.40
+++ render.cpp	11 Nov 2003 07:43:02 -0000	1.41
@@ -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 @@
 #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 @@
 	}
 
 	// UploadRect(r);
-	g_display->setNeedFullRedraw();
+	setNeedFullRedraw();
 }
 
 // I've made the scaling two separate functions because there were cases from
@@ -94,7 +93,7 @@
 // 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::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 @@
  * @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 @@
  */
 
 // 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 @@
  * @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 @@
  * 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 @@
  * 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 @@
  * render cycle.
  */
 
-void Display::startRenderCycle(void) {
+void Graphics::startRenderCycle(void) {
 	_scrollXOld = _scrollX;
 	_scrollYOld = _scrollY;
 
@@ -610,7 +609,7 @@
  * 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 @@
  * 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 @@
  * 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 @@
  * 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++) {

Index: sprite.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/sprite.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- sprite.cpp	8 Nov 2003 18:15:35 -0000	1.31
+++ sprite.cpp	11 Nov 2003 07:43:02 -0000	1.32
@@ -32,7 +32,7 @@
  * @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 @@
  * @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 @@
  * 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 @@
  * @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 @@
  * @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 @@
  * @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 @@
  * Destroys a surface.
  */
 
-void Display::deleteSurface(uint8 *surface) {
+void Graphics::deleteSurface(uint8 *surface) {
 	free(surface);
 }
 
@@ -381,7 +381,7 @@
 // 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 @@
  * 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 @@
  * Closes the light masking sprite for a room.
  */
 
-int32 Display::closeLightMask(void) {
+int32 Graphics::closeLightMask(void) {
 	if (!_lightMask)
 		return RDERR_NOTOPEN;
 





More information about the Scummvm-git-logs mailing list