[Scummvm-cvs-logs] CVS: scummvm/sword2 anims.cpp,1.43,1.44 build_display.cpp,1.45,1.46 console.cpp,1.31,1.32 controls.cpp,1.48,1.49 debug.cpp,1.27,1.28 function.cpp,1.39,1.40 icons.cpp,1.24,1.25 layers.cpp,1.20,1.21 logic.cpp,1.30,1.31 maketext.cpp,1.28,1.29 mouse.cpp,1.40,1.41 resman.cpp,1.65,1.66 router.cpp,1.29,1.30 speech.cpp,1.48,1.49 sword2.cpp,1.81,1.82 sword2.h,1.36,1.37 walker.cpp,1.27,1.28

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


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

Modified Files:
	anims.cpp build_display.cpp console.cpp controls.cpp debug.cpp 
	function.cpp icons.cpp layers.cpp logic.cpp maketext.cpp 
	mouse.cpp resman.cpp router.cpp speech.cpp sword2.cpp sword2.h 
	walker.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: anims.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/anims.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- anims.cpp	10 Nov 2003 07:52:15 -0000	1.43
+++ anims.cpp	11 Nov 2003 07:43:02 -0000	1.44
@@ -751,14 +751,14 @@
 	// now clear the screen in case the Sequence was quitted (using ESC)
 	// rather than fading down to black
 
-	g_display->clearScene();
+	g_graphics->clearScene();
 
 	// zero the entire palette in case we're about to fade up!
 
 	_palEntry pal[256];
 
 	memset(pal, 0, 256 * sizeof(_palEntry));
-	g_display->setPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT);
+	g_graphics->setPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT);
 
 	debug(5, "fnPlaySequence FINISHED");
 

Index: build_display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/build_display.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- build_display.cpp	10 Nov 2003 07:52:15 -0000	1.45
+++ build_display.cpp	11 Nov 2003 07:43:02 -0000	1.46
@@ -54,11 +54,11 @@
 	// there is a valid screen to run
 	if (_thisScreen.background_layer_id) {
 		// set the scroll position
-		g_display->setScrollTarget(_thisScreen.scroll_offset_x, _thisScreen.scroll_offset_y);
+		g_graphics->setScrollTarget(_thisScreen.scroll_offset_x, _thisScreen.scroll_offset_y);
 		// increment the mouse frame
-		g_display->animateMouse();
+		g_graphics->animateMouse();
 
-		g_display->startRenderCycle();
+		g_graphics->startRenderCycle();
 
 		while (1) {
 			// clear the back buffer, before building up the new
@@ -67,7 +67,7 @@
 			// FIXME: I'm not convinced that this is needed. Isn't
 			// the whole screen redrawn each time?
 
-			// g_display->clearScene();
+			// g_graphics->clearScene();
 
 			// first background parallax + related anims
 
@@ -76,7 +76,7 @@
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->bg_parallax[0]) {
-				g_display->renderParallax(fetchBackgroundParallaxLayer(file, 0), 0);
+				g_graphics->renderParallax(fetchBackgroundParallaxLayer(file, 0), 0);
 				// release the screen resource before cacheing
 				// the sprites
 	 			res_man->closeResource(_thisScreen.background_layer_id);
@@ -93,7 +93,7 @@
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->bg_parallax[1]) {
-				g_display->renderParallax(fetchBackgroundParallaxLayer(file, 1), 1);
+				g_graphics->renderParallax(fetchBackgroundParallaxLayer(file, 1), 1);
 				// release the screen resource before cacheing
 				// the sprites
 	 			res_man->closeResource(_thisScreen.background_layer_id);
@@ -107,7 +107,7 @@
 
 			// open the screen resource
 			file = res_man->openResource(_thisScreen.background_layer_id);
-			g_display->renderParallax(fetchBackgroundLayer(file), 2);
+			g_graphics->renderParallax(fetchBackgroundLayer(file), 2);
 			// release the screen resource
 			res_man->closeResource(_thisScreen.background_layer_id);
 
@@ -125,7 +125,7 @@
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->fg_parallax[0]) {
-				g_display->renderParallax(fetchForegroundParallaxLayer(file, 0), 3);
+				g_graphics->renderParallax(fetchForegroundParallaxLayer(file, 0), 3);
 				// release the screen resource before cacheing
 				// the sprites
 	 			res_man->closeResource(_thisScreen.background_layer_id);
@@ -142,7 +142,7 @@
 			screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
 
 			if (screenLayerTable->fg_parallax[1]) {
-				g_display->renderParallax(fetchForegroundParallaxLayer(file, 1), 4);
+				g_graphics->renderParallax(fetchForegroundParallaxLayer(file, 1), 4);
 				// release the screen resource before cacheing
 				// the sprites
 	 			res_man->closeResource(_thisScreen.background_layer_id);
@@ -164,11 +164,11 @@
 
 			// menu bar & icons
 
-			g_display->processMenu();
+			g_graphics->processMenu();
 
 			// ready - blit to screen
 
-			g_display->updateDisplay();
+			g_graphics->updateDisplay();
 
 			// update our fps reading
 
@@ -187,7 +187,7 @@
 			// If we haven't got time to render again this cycle,
 			// drop out of 'render cycle' while-loop
 
-			if (g_display->endRenderCycle())
+			if (g_graphics->endRenderCycle())
 				break;
 		}
 	}
@@ -207,24 +207,24 @@
 
 	debug(2, "DisplayMsg: %s", (char *) text);
 	
-	if (g_display->getFadeStatus() != RDFADE_BLACK) {
-		g_display->fadeDown();
-		g_display->waitForFade();
+	if (g_graphics->getFadeStatus() != RDFADE_BLACK) {
+		g_graphics->fadeDown();
+		g_graphics->waitForFade();
 	}
 
 	setMouse(0);
 	setLuggage(0);
 
-	g_display->closeMenuImmediately();
-	g_display->clearScene();
+	g_graphics->closeMenuImmediately();
+	g_graphics->clearScene();
 
 	text_spr = fontRenderer->makeTextSprite(text, 640, 187, _speechFontId);
 
 	frame = (_frameHeader *) text_spr->ad;
 
-	spriteInfo.x = g_display->_screenWide / 2 - frame->width / 2;
+	spriteInfo.x = g_graphics->_screenWide / 2 - frame->width / 2;
 	if (!time)
-		spriteInfo.y = g_display->_screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP;
+		spriteInfo.y = g_graphics->_screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP;
 	else
 		spriteInfo.y = 400 - frame->height;
 	spriteInfo.w = frame->width;
@@ -237,34 +237,34 @@
 	spriteInfo.data = text_spr->ad + sizeof(_frameHeader);
 	spriteInfo.colourTable = 0;
 
-	rv = g_display->drawSprite(&spriteInfo);
+	rv = g_graphics->drawSprite(&spriteInfo);
 	if (rv)
 		error("Driver Error %.8x (in DisplayMsg)", rv);
 
-	memcpy((char *) oldPal, (char *) g_display->_palCopy, 256 * sizeof(_palEntry));
+	memcpy((char *) oldPal, (char *) g_graphics->_palCopy, 256 * sizeof(_palEntry));
 
 	memset(pal, 0, 256 * sizeof(_palEntry));
 	pal[187].red = 255;
 	pal[187].green = 255;
 	pal[187].blue = 255;
-	g_display->setPalette(0, 256, (uint8 *) pal, RDPAL_FADE);
+	g_graphics->setPalette(0, 256, (uint8 *) pal, RDPAL_FADE);
 
-	g_display->fadeUp();
+	g_graphics->fadeUp();
 
 	memory->freeMemory(text_spr);
 
-	g_display->waitForFade();
+	g_graphics->waitForFade();
 
 	uint32 targetTime = SVM_timeGetTime() + (time * 1000);
 
 	// Keep the message there even when the user task swaps.
-	rv = g_display->drawSprite(&spriteInfo);
+	rv = g_graphics->drawSprite(&spriteInfo);
 	if (rv)
 		error("Driver Error %.8x (in DisplayMsg)", rv);
 
 	sleepUntil(targetTime);
 
-	g_display->setPalette(0, 256, (uint8 *) oldPal, RDPAL_FADE);
+	g_graphics->setPalette(0, 256, (uint8 *) oldPal, RDPAL_FADE);
 }
 
 //
@@ -272,11 +272,11 @@
 //
 
 void Sword2Engine::removeMsg(void) {
-	g_display->fadeDown();
-	g_display->waitForFade();
-	g_display->clearScene();
+	g_graphics->fadeDown();
+	g_graphics->waitForFade();
+	g_graphics->clearScene();
 
-	// g_display->fadeUp();	
+	// g_graphics->fadeUp();	
 	// removed by JEL (08oct97) to prevent "eye" smacker corruption when
 	// restarting game from CD2 and also to prevent palette flicker when
 	// restoring game to a different CD since the "insert CD" message uses
@@ -385,7 +385,7 @@
 			layer_number, layer_head->width, layer_head->height);
 	}
 
-	rv = g_display->drawSprite(&spriteInfo);
+	rv = g_graphics->drawSprite(&spriteInfo);
 	if (rv)
 		error("Driver Error %.8x in Process_layer(%d)", rv, layer_number);
 
@@ -511,7 +511,7 @@
 //	}
 // #endif
 
-	rv = g_display->drawSprite(&spriteInfo);
+	rv = g_graphics->drawSprite(&spriteInfo);
 	if (rv)
 		error("Driver Error %.8x with sprite %s (%d) in processImage",
 			rv, fetchObjectName(build_unit->anim_resource),
@@ -761,14 +761,14 @@
 
 	// if the screen is still fading down then wait for black - could
 	// happen when everythings cached into a large memory model
-	g_display->waitForFade();
+	g_graphics->waitForFade();
 
 	// open the screen file
 	screenFile = res_man->openResource(_thisScreen.background_layer_id);
 
-	g_display->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(screenFile));
+	g_graphics->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(screenFile));
 
-	g_display->setPalette(0, 256, fetchPalette(screenFile), RDPAL_FADE);
+	g_graphics->setPalette(0, 256, fetchPalette(screenFile), RDPAL_FADE);
 
 	// indicating that it's a screen palette
 	_lastPaletteRes = 0;
@@ -777,7 +777,7 @@
   	res_man->closeResource(_thisScreen.background_layer_id);
 
 	// start fade up
-	g_display->fadeUp();
+	g_graphics->fadeUp();
 
 	// reset
  	_thisScreen.new_palette = 0;
@@ -811,8 +811,8 @@
 
 	// params:	none
 
-	if (g_display->getFadeStatus() == RDFADE_NONE)
-		g_display->fadeDown();
+	if (g_graphics->getFadeStatus() == RDFADE_NONE)
+		g_graphics->fadeDown();
 
 	return IR_CONT;
 }
@@ -820,10 +820,10 @@
 int32 Logic::fnFadeUp(int32 *params) {
 	// params:	none
 
-	g_display->waitForFade();
+	g_graphics->waitForFade();
 
-	if (g_display->getFadeStatus() == RDFADE_BLACK)
-		g_display->fadeUp();
+	if (g_graphics->getFadeStatus() == RDFADE_BLACK)
+		g_graphics->fadeUp();
 
 	return IR_CONT;
 }
@@ -888,9 +888,9 @@
 		file[3] = 0;
 
 		// not yet in separate palette files
-		// g_display->updatePaletteMatchTable(file + (256 * 4));
+		// g_graphics->updatePaletteMatchTable(file + (256 * 4));
 
-		g_display->setPalette(0, 256, file, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 256, file, RDPAL_INSTANT);
 
 		if (palRes != CONTROL_PANEL_PALETTE) {	// (James 03sep97)
 			// indicating that it's a separate palette resource
@@ -904,9 +904,9 @@
 		if (_thisScreen.background_layer_id) {
 			// open the screen file
 			file = res_man->openResource(_thisScreen.background_layer_id);
-			g_display->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(file));
+			g_graphics->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(file));
 
-			g_display->setPalette(0, 256, fetchPalette(file), RDPAL_INSTANT);
+			g_graphics->setPalette(0, 256, fetchPalette(file), RDPAL_INSTANT);
 
 			// indicating that it's a screen palette
 			_lastPaletteRes = 0;
@@ -928,7 +928,7 @@
 
 	// if last screen was using a shading mask (see below)
 	if (_vm->_thisScreen.mask_flag) {
-		uint32 rv = g_display->closeLightMask();
+		uint32 rv = g_graphics->closeLightMask();
 
 		if (rv)
 			error("Driver Error %.8x [%s line %u]", rv);

Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/console.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- console.cpp	8 Nov 2003 18:15:33 -0000	1.31
+++ console.cpp	11 Nov 2003 07:43:02 -0000	1.32
@@ -144,7 +144,7 @@
 	g_sound->unpauseMusic();
 
 	// Restore old mouse cursor
-	g_display->drawMouse();
+	g_graphics->drawMouse();
 
 }
 
@@ -209,7 +209,7 @@
 	}
 
 	g_logic->conStart(atoi(argv[1]));
-	g_display->setPalette(187, 1, pal, RDPAL_INSTANT);
+	g_graphics->setPalette(187, 1, pal, RDPAL_INSTANT);
 	return true;
 }
 
@@ -451,14 +451,14 @@
 // FIXME: Replace these with a command to modify the graphics detail setting
 
 bool Debugger::Cmd_BltFxOn(int argc, const char **argv) {
-	// g_display->setBltFx();
+	// g_graphics->setBltFx();
 	// DebugPrintf("Blit fx enabled\n");
 	DebugPrintf("FIXME: The setBltFx() function no longer exists\n");
 	return true;
 }
 
 bool Debugger::Cmd_BltFxOff(int argc, const char **argv) {
-	// g_display->clearBltFx();
+	// g_graphics->clearBltFx();
 	// DebugPrintf("Blit fx disabled\n");
 	DebugPrintf("FIXME: The clearBltFx() function no longer exists\n");
 	return true;

Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- controls.cpp	8 Nov 2003 15:47:51 -0000	1.48
+++ controls.cpp	11 Nov 2003 07:43:02 -0000	1.49
@@ -43,7 +43,7 @@
 #define CHARACTER_OVERLAP	 2	// overlap characters by 3 pixels
 
 // our fonts start on SPACE character (32)
-#define SIZE_OF_CHAR_SET (256 - 32)
+#define SIZE_OF_CHAR_SET	(256 - 32)
 
 Gui *gui;
 
@@ -75,7 +75,7 @@
 			sprite.data = (uint8 *) (head + 1);
 			sprite.w = head->width;
 			sprite.h = head->height;
-			g_display->createSurface(&sprite, &_glyph[i]._data);
+			g_graphics->createSurface(&sprite, &_glyph[i]._data);
 			_glyph[i]._width = head->width;
 			_glyph[i]._height = head->height;
 		}
@@ -85,7 +85,7 @@
 
 	~FontRendererGui() {
 		for (int i = 0; i < SIZE_OF_CHAR_SET; i++)
-			g_display->deleteSurface(_glyph[i]._data);
+			g_graphics->deleteSurface(_glyph[i]._data);
 	}
 
 	void fetchText(int textId, char *buf) {
@@ -144,7 +144,7 @@
 		sprite.w = _glyph[text[i] - 32]._width;
 		sprite.h = _glyph[text[i] - 32]._height;
 
-		g_display->drawSurface(&sprite, _glyph[text[i] - 32]._data);
+		g_graphics->drawSurface(&sprite, _glyph[text[i] - 32]._data);
 
 		sprite.x += (_glyph[(int) text[i] - 32]._width - CHARACTER_OVERLAP);
 	}
@@ -187,7 +187,7 @@
 	virtual ~Widget() {
 		for (int i = 0; i < _numStates; i++) {
 			if (_surfaces[i]._original)
-				g_display->deleteSurface(_surfaces[i]._surface);
+				g_graphics->deleteSurface(_surfaces[i]._surface);
 		}
 		free(_sprites);
 		free(_surfaces);
@@ -229,7 +229,7 @@
 	}
 
 	virtual void paint(Common::Rect *clipRect = NULL) {
-		g_display->drawSurface(&_sprites[_state], _surfaces[_state]._surface, clipRect);
+		g_graphics->drawSurface(&_sprites[_state], _surfaces[_state]._surface, clipRect);
 	}
 
 	virtual void onMouseEnter() {}
@@ -292,7 +292,7 @@
 	// Points to just after frame header, ie. start of sprite data
 	_sprites[state].data = (uint8 *) (frame_head + 1);
 
-	g_display->createSurface(&_sprites[state], &_surfaces[state]._surface);
+	g_graphics->createSurface(&_sprites[state], &_surfaces[state]._surface);
 	_surfaces[state]._original = true;
 
 	// Release the anim resource
@@ -340,7 +340,7 @@
 	virtual void onAction(Widget *widget, int result = 0) {}
 
 	virtual void paint() {
-		g_display->clearScene();
+		g_graphics->clearScene();
 		for (int i = 0; i < _numWidgets; i++)
 			_widgets[i]->paint();
 	}
@@ -363,15 +363,15 @@
 
 	while (!_finish) {
 		// So that the menu icons will reach their full size
-		g_display->processMenu();
-		g_display->updateDisplay();
+		g_graphics->processMenu();
+		g_graphics->updateDisplay();
 
-		int16 newMouseX = g_display->_mouseX;
-		int16 newMouseY = g_display->_mouseY + 40;
+		int16 newMouseX = g_input->_mouseX;
+		int16 newMouseY = g_input->_mouseY + 40;
 
-		_mouseEvent *me = MouseEvent();
+		_mouseEvent *me = g_input->mouseEvent();
 		_keyboardEvent ke;
-		int32 keyboardStatus = ReadKey(&ke);
+		int32 keyboardStatus = g_input->readKey(&ke);
 
 		if (keyboardStatus == RD_OK) {
 			if (ke.keycode == 27)
@@ -388,7 +388,7 @@
 				_widgets[i]->onMouseEnter();
 			if (oldHit && !newHit)
 				_widgets[i]->onMouseExit();
-			if (g_display->_mouseX != oldMouseX || g_display->_mouseY != oldMouseY)
+			if (g_input->_mouseX != oldMouseX || g_input->_mouseY != oldMouseY)
 				_widgets[i]->onMouseMove(newMouseX, newMouseY);
 
 			if (me) {
@@ -786,8 +786,8 @@
 		_musicSlider->setValue(g_sound->getMusicVolume());
 		_speechSlider->setValue(g_sound->getSpeechVolume());
 		_fxSlider->setValue(g_sound->getFxVolume());
-		_gfxSlider->setValue(g_display->getRenderLevel());
-		_gfxPreview->setState(g_display->getRenderLevel());
+		_gfxSlider->setValue(g_graphics->getRenderLevel());
+		_gfxPreview->setState(g_graphics->getRenderLevel());
 	}
 
 	~OptionsDialog() {
@@ -1312,17 +1312,17 @@
 	while (1) {
 		_mouseEvent *me;
 
-		g_display->updateDisplay();
+		g_graphics->updateDisplay();
 
-		if (KeyWaiting()) {
+		if (g_input->keyWaiting()) {
 			_keyboardEvent ke;
 
-			ReadKey(&ke);
+			g_input->readKey(&ke);
 			if (ke.keycode == 27)
 				break;
 		}
 
-		me = MouseEvent();
+		me = g_input->mouseEvent();
 		if (me && (me->buttons & RD_LEFTBUTTONDOWN))
 			break;
 
@@ -1383,7 +1383,7 @@
 	ConfMan.set("music_mute", g_sound->isMusicMute());
 	ConfMan.set("speech_mute", g_sound->isSpeechMute());
 	ConfMan.set("sfx_mute", g_sound->isFxMute());
-	ConfMan.set("gfx_details", g_display->getRenderLevel());
+	ConfMan.set("gfx_details", g_graphics->getRenderLevel());
 	ConfMan.set("nosubtitles", !_subtitles);
 	ConfMan.set("object_labels", _pointerTextSelected);
 	ConfMan.set("reverse_stereo", _stereoReversed);
@@ -1432,7 +1432,7 @@
 	//in case we were dead - well we're not anymore!
 	DEAD = 0;
 
-	g_display->clearScene();
+	g_graphics->clearScene();
 
 	// restart the game
 	// clear all memory and reset the globals
@@ -1466,7 +1466,7 @@
 	// fnRegisterFrame)
 	_vm->resetMouseList();
 
-	g_display->closeMenuImmediately();
+	g_graphics->closeMenuImmediately();
 
 	// FOR THE DEMO - FORCE THE SCROLLING TO BE RESET!
 	// - this is taken from fnInitBackground
@@ -1496,7 +1496,7 @@
 	else if (newLevel > 3)
 		newLevel = 3;
 
-	g_display->setRenderLevel(newLevel);
+	g_graphics->setRenderLevel(newLevel);
 
 	// update our global variable - which needs to be checked when dimming
 	// the palette in PauseGame() in sword2.cpp (since palette-matching

Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/debug.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- debug.cpp	8 Nov 2003 18:15:33 -0000	1.27
+++ debug.cpp	11 Nov 2003 07:43:02 -0000	1.28
@@ -186,14 +186,14 @@
 
 		if (_vm->_mouseTouching)
 			sprintf(buf, "mouse %d,%d (id %d: %s)",
-				g_display->_mouseX + _vm->_thisScreen.scroll_offset_x,
-				g_display->_mouseY + _vm->_thisScreen.scroll_offset_y,
+				g_input->_mouseX + _vm->_thisScreen.scroll_offset_x,
+				g_input->_mouseY + _vm->_thisScreen.scroll_offset_y,
 				_vm->_mouseTouching,
 				_vm->fetchObjectName(_vm->_mouseTouching));
 		else
 			sprintf(buf, "mouse %d,%d (not touching)",
-				g_display->_mouseX + _vm->_thisScreen.scroll_offset_x,
-				g_display->_mouseY + _vm->_thisScreen.scroll_offset_y);
+				g_input->_mouseX + _vm->_thisScreen.scroll_offset_x,
+				g_input->_mouseY + _vm->_thisScreen.scroll_offset_y);
 
 		makeDebugTextBlock(buf, 0, 30);
 
@@ -319,7 +319,7 @@
 	// mouse marker & coords
 
 	if (_displayMouseMarker)
-		plotCrossHair(g_display->_mouseX + _vm->_thisScreen.scroll_offset_x, g_display->_mouseY + _vm->_thisScreen.scroll_offset_y, 215);
+		plotCrossHair(g_input->_mouseX + _vm->_thisScreen.scroll_offset_x, g_input->_mouseY + _vm->_thisScreen.scroll_offset_y, 215);
 
    	// mouse area rectangle / sprite box rectangle when testing anims
 
@@ -335,20 +335,20 @@
 }
 
 void Debugger::plotCrossHair(int16 x, int16 y, uint8 pen) {
-	g_display->plotPoint(x, y, pen);		// driver function
+	g_graphics->plotPoint(x, y, pen);		// driver function
 
-	g_display->drawLine(x - 2, y, x - 5, y, pen);	// driver function
-	g_display->drawLine(x + 2, y, x + 5, y, pen);
+	g_graphics->drawLine(x - 2, y, x - 5, y, pen);	// driver function
+	g_graphics->drawLine(x + 2, y, x + 5, y, pen);
 
-	g_display->drawLine(x, y - 2, x, y - 5, pen);
-	g_display->drawLine(x, y + 2, x, y + 5, pen);
+	g_graphics->drawLine(x, y - 2, x, y - 5, pen);
+	g_graphics->drawLine(x, y + 2, x, y + 5, pen);
 }
 
 void Debugger::drawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
-	g_display->drawLine(x1, y1, x2, y1, pen);	// top edge
-	g_display->drawLine(x1, y2, x2, y2, pen);	// bottom edge
-	g_display->drawLine(x1, y1, x1, y2, pen);	// left edge
-	g_display->drawLine(x2, y1, x2, y2, pen);	// right edge
+	g_graphics->drawLine(x1, y1, x2, y1, pen);	// top edge
+	g_graphics->drawLine(x1, y2, x2, y2, pen);	// bottom edge
+	g_graphics->drawLine(x1, y1, x1, y2, pen);	// left edge
+	g_graphics->drawLine(x2, y1, x2, y2, pen);	// right edge
 }
 
 void Debugger::printCurrentInfo(void) {

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- function.cpp	10 Nov 2003 07:52:15 -0000	1.39
+++ function.cpp	11 Nov 2003 07:43:02 -0000	1.40
@@ -266,25 +266,25 @@
 	// what colour?
 	switch (params[0]) {
 	case WHITE:
-		g_display->setPalette(0, 1, white, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
 		break;
 	case RED:
-		g_display->setPalette(0, 1, red, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, red, RDPAL_INSTANT);
 		break;
 	case GREEN:
-		g_display->setPalette(0, 1, green, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, green, RDPAL_INSTANT);
 		break;
 	case BLUE:
-		g_display->setPalette(0, 1, blue, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, blue, RDPAL_INSTANT);
 		break;
 	}
 
 	// There used to be a busy-wait loop here, so I don't know how long
 	// the delay was meant to be. Probably doesn't matter much.
 
-	g_display->updateDisplay();
+	g_graphics->updateDisplay();
 	g_system->delay_msecs(250);
-	g_display->setPalette(0, 1, black, RDPAL_INSTANT);
+	g_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
 #endif
 
 	return IR_CONT;
@@ -302,19 +302,19 @@
 	// what colour?
 	switch (params[0]) {
 	case BLACK:
-		g_display->setPalette(0, 1, black, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
 		break;
 	case WHITE:
-		g_display->setPalette(0, 1, white, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
 		break;
 	case RED:
-		g_display->setPalette(0, 1, red, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, red, RDPAL_INSTANT);
 		break;
 	case GREEN:
-		g_display->setPalette(0, 1, green, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, green, RDPAL_INSTANT);
 		break;
 	case BLUE:
-		g_display->setPalette(0, 1, blue, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, blue, RDPAL_INSTANT);
 		break;
 	}
 #endif
@@ -393,17 +393,17 @@
 		g_sound->muteSpeech(true);
 		g_sound->stopMusic();
 
-		memcpy(oldPal, g_display->_palCopy, 1024);
+		memcpy(oldPal, g_graphics->_palCopy, 1024);
 		memset(tmpPal, 0, 1024);
 
-		g_display->waitForFade();
-		g_display->fadeDown();
-		g_display->waitForFade();
+		g_graphics->waitForFade();
+		g_graphics->fadeDown();
+		g_graphics->waitForFade();
 
 		tmpPal[4] = 255;
 		tmpPal[5] = 255;
 		tmpPal[6] = 255;
-		g_display->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
 
 		// Play the credits music. Is it enough with just one
 		// repetition of it?
@@ -416,21 +416,21 @@
 
 		debug(0, "Credits music length: ~%d ms", music_length);
 
-		g_display->closeMenuImmediately();
+		g_graphics->closeMenuImmediately();
 
 		while (g_sound->musicTimeRemaining()) {
-			g_display->clearScene();
-			g_display->setNeedFullRedraw();
+			g_graphics->clearScene();
+			g_graphics->setNeedFullRedraw();
 
 			// FIXME: Draw the credits text. The actual text
 			// messages are stored in credits.clu, and I'm guessing
 			// that credits.bmp or font.clu may be the font.
 
-			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)
 				break;
 
 			g_system->delay_msecs(30);
@@ -439,11 +439,11 @@
 		fnStopMusic(NULL);
 		g_sound->restoreMusicState();
 
-		g_display->setPalette(0, 256, oldPal, RDPAL_FADE);
-		g_display->fadeUp();
-		g_display->updateDisplay();
+		g_graphics->setPalette(0, 256, oldPal, RDPAL_FADE);
+		g_graphics->fadeUp();
+		g_graphics->updateDisplay();
 		_vm->buildDisplay();
-		g_display->waitForFade();
+		g_graphics->waitForFade();
 
 		g_sound->muteFx(false);
 		g_sound->muteSpeech(false);

Index: icons.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/icons.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- icons.cpp	10 Nov 2003 07:52:15 -0000	1.24
+++ icons.cpp	11 Nov 2003 07:43:02 -0000	1.25
@@ -199,16 +199,16 @@
 			if (icon_coloured)
 				icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
 
-			g_display->setMenuIcon(RDMENU_BOTTOM, j, icon);
+			g_graphics->setMenuIcon(RDMENU_BOTTOM, j, icon);
 			res_man->closeResource(res);
 		} else {
 			// no icon here
-			g_display->setMenuIcon(RDMENU_BOTTOM, j, NULL);
+			g_graphics->setMenuIcon(RDMENU_BOTTOM, j, NULL);
 			debug(5, " NULL for %d", j);
 		}
 	}
 
-	g_display->showMenu(RDMENU_BOTTOM);
+	g_graphics->showMenu(RDMENU_BOTTOM);
 }
 
 void Sword2Engine::buildSystemMenu(void) {
@@ -236,11 +236,11 @@
 		if (!DEAD || icon_list[i] != SAVE_ICON)
 			icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
 
-		g_display->setMenuIcon(RDMENU_TOP, i, icon);
+		g_graphics->setMenuIcon(RDMENU_TOP, i, icon);
 		res_man->closeResource(icon_list[i]);
 	}
 
-	g_display->showMenu(RDMENU_TOP);
+	g_graphics->showMenu(RDMENU_TOP);
 }
 
 } // End of namespace Sword2

Index: layers.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/layers.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- layers.cpp	8 Nov 2003 15:47:51 -0000	1.20
+++ layers.cpp	11 Nov 2003 07:43:02 -0000	1.21
@@ -69,11 +69,11 @@
 #endif
 
 	// if the screen is still fading down then wait for black
-	g_display->waitForFade();
+	g_graphics->waitForFade();
 
 	// if last screen was using a shading mask (see below)
 	if (_thisScreen.mask_flag) {
-		rv = g_display->closeLightMask();
+		rv = g_graphics->closeLightMask();
 		if (rv)
 			error("Driver Error %.8x", rv);
 	}
@@ -82,7 +82,7 @@
 
 	// for drivers: close the previous screen if one is open
 	if (_thisScreen.background_layer_id)
-		g_display->closeBackgroundLayer();
+		g_graphics->closeBackgroundLayer();
 
 	_thisScreen.background_layer_id = res;
 	_thisScreen.new_palette = new_palette;
@@ -104,7 +104,7 @@
 	debug(5, "res test layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height);
 
 	//initialise the driver back buffer
-	g_display->setLocationMetrics(screen_head->width, screen_head->height);
+	g_graphics->setLocationMetrics(screen_head->width, screen_head->height);
 
 	if (screen_head->noLayers) {
 		for (int i = 0; i < screen_head->noLayers; i++) {
@@ -126,7 +126,7 @@
 	// using the screen size setup the scrolling variables
 
 	// if layer is larger than physical screen
-	if (screen_head->width > g_display->_screenWide || screen_head->height > g_display->_screenDeep) {
+	if (screen_head->width > g_graphics->_screenWide || screen_head->height > g_graphics->_screenDeep) {
 		// switch on scrolling (2 means first time on screen)
 		_thisScreen.scroll_flag = 2;
 
@@ -141,9 +141,9 @@
 		// calc max allowed offsets (to prevent scrolling off edge) -
 		// MOVE TO NEW_SCREEN in GTM_CORE.C !!
 		// NB. min scroll offsets are both zero
-		_thisScreen.max_scroll_offset_x = screen_head->width - g_display->_screenWide;
+		_thisScreen.max_scroll_offset_x = screen_head->width - g_graphics->_screenWide;
 		// 'screenDeep' includes the menu's, so take away 80 pixels
-		_thisScreen.max_scroll_offset_y = screen_head->height - (g_display->_screenDeep - (RDMENU_MENUDEEP * 2));
+		_thisScreen.max_scroll_offset_y = screen_head->height - (g_graphics->_screenDeep - (RDMENU_MENUDEEP * 2));
 	} else {
 		// layer fits on physical screen - scrolling not required
 		_thisScreen.scroll_flag = 0;		// switch off scrolling
@@ -153,7 +153,7 @@
 
 	// no inter-cycle scroll between new screens (see setScrollTarget in
 	// build display)
-	g_display->resetRenderEngine();
+	g_graphics->resetRenderEngine();
 
 	// these are the physical screen coords where the system
 	// will try to maintain George's actual feet coords
@@ -177,7 +177,7 @@
 		spriteInfo.data = fetchShadingMask(file);
 		spriteInfo.colourTable = 0;
 
-		rv = g_display->openLightMask(&spriteInfo);
+		rv = g_graphics->openLightMask(&spriteInfo);
 		if (rv)
 			error("Driver Error %.8x", rv);
 
@@ -221,22 +221,22 @@
 
 		for (i = 0; i < 2; i++) {
 			if (screenLayerTable->bg_parallax[i])
-				g_display->initialiseBackgroundLayer(fetchBackgroundParallaxLayer(file, i));
+				g_graphics->initialiseBackgroundLayer(fetchBackgroundParallaxLayer(file, i));
 			else
-				g_display->initialiseBackgroundLayer(NULL);
+				g_graphics->initialiseBackgroundLayer(NULL);
 		}
 
 		// Normal backround layer
 
-		g_display->initialiseBackgroundLayer(fetchBackgroundLayer(file));
+		g_graphics->initialiseBackgroundLayer(fetchBackgroundLayer(file));
 
 		// Foreground parallax layers
 
 		for (i = 0; i < 2; i++) {
 			if (screenLayerTable->fg_parallax[i])
-				g_display->initialiseBackgroundLayer(fetchForegroundParallaxLayer(file, i));
+				g_graphics->initialiseBackgroundLayer(fetchForegroundParallaxLayer(file, i));
 			else
-				g_display->initialiseBackgroundLayer(NULL);
+				g_graphics->initialiseBackgroundLayer(NULL);
 		}
 
 		// close the screen file

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- logic.cpp	8 Nov 2003 18:15:33 -0000	1.30
+++ logic.cpp	11 Nov 2003 07:43:02 -0000	1.31
@@ -30,7 +30,7 @@
 
 namespace Sword2 {
 
-Logic *g_logic;
+Logic *g_logic = NULL;
 
 #define LEVEL (_curObjectHub->logic_level)
 

Index: maketext.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/maketext.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- maketext.cpp	8 Nov 2003 15:47:51 -0000	1.28
+++ maketext.cpp	11 Nov 2003 07:43:02 -0000	1.29
@@ -525,7 +525,7 @@
 			spriteInfo.data = _blocList[j].text_mem->ad + sizeof(_frameHeader);
 			spriteInfo.colourTable = 0;
 
-			rv = g_display->drawSprite(&spriteInfo);
+			rv = g_graphics->drawSprite(&spriteInfo);
 			if (rv)
 				error("Driver Error %.8x in Print_text_blocs", rv);
 		}
@@ -603,7 +603,7 @@
 	// GERMAN:   "Baphomet's Fluch II"
 	// default:  "Some game or other, part 86"
 
-	g_display->setWindowName((char *) textLine);
+	g_graphics->setWindowName((char *) textLine);
 
 	// now ok to close the text file
 	res_man->closeResource(TEXT_RES);

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mouse.cpp	10 Nov 2003 07:52:15 -0000	1.40
+++ mouse.cpp	11 Nov 2003 07:43:02 -0000	1.41
@@ -110,7 +110,7 @@
 		systemMenuMouse();
 		break;
 	case MOUSE_holding:
-		if (g_display->_mouseY < 400) {
+		if (_input->_mouseY < 400) {
 			_mouseMode = MOUSE_normal;
 			debug(5, "   releasing");
 		}
@@ -135,21 +135,21 @@
 	};
 
 	// can't close when player is dead
-	if (g_display->_mouseY > 0 && !DEAD) {
+	if (_input->_mouseY > 0 && !DEAD) {
 		// close menu
 		_mouseMode = MOUSE_normal;
-		g_display->hideMenu(RDMENU_TOP);
+		g_graphics->hideMenu(RDMENU_TOP);
 		return;
 	}
 
-	me = MouseEvent();
+	me = g_input->mouseEvent();
 
 	if (me && (me->buttons & RD_LEFTBUTTONDOWN)) {
 		// clicked on a top mouse pointer?
 
-		if (g_display->_mouseX >= 24 && g_display->_mouseX < 640 - 24 && g_display->_mouseY < 0) {
+		if (_input->_mouseX >= 24 && _input->_mouseX < 640 - 24 && _input->_mouseY < 0) {
 			// which are we over?
-			hit = (g_display->_mouseX - 24) / 40;
+			hit = (_input->_mouseX - 24) / 40;
 
 			// no save when dead
 			if (icon_list[hit] == SAVE_ICON && DEAD)
@@ -163,7 +163,7 @@
 					// change all others to grey
 					if (j != hit) {
 						icon = res_man->openResource(icon_list[j]) + sizeof(_standardHeader);
-						g_display->setMenuIcon(RDMENU_TOP, j, icon);
+						g_graphics->setMenuIcon(RDMENU_TOP, j, icon);
 						res_man->closeResource(icon_list[j]);
 					}
 				}
@@ -188,9 +188,9 @@
 				// clear the screen & set up the new palette
 				// for the menus
 
-				g_display->clearScene();
-				g_display->processMenu();
-				g_display->resetRenderEngine();
+				g_graphics->clearScene();
+				g_graphics->processMenu();
+				g_graphics->resetRenderEngine();
 
 				// call the relevent screen
 				switch (hit) {
@@ -214,7 +214,7 @@
 				// Menu stays open on death screen
 				if (!DEAD) {
 					_mouseMode = MOUSE_normal;
-					g_display->hideMenu(RDMENU_TOP);
+					g_graphics->hideMenu(RDMENU_TOP);
 				} else {
 					setMouse(NORMAL_MOUSE_ID);
 					buildSystemMenu();
@@ -223,8 +223,8 @@
 				// clear the screen & restore the location
 				// palette
 
-				g_display->clearScene();
-				g_display->processMenu();
+				g_graphics->clearScene();
+				g_graphics->processMenu();
 
 				// reset game palette, but not after a
 				// successful restore or restart!
@@ -272,10 +272,10 @@
 	_mouseEvent *me;
 	uint32 pos;
 
-	if (g_display->_mouseY < 400) {
+	if (_input->_mouseY < 400) {
 		// close menu
 		_mouseMode = MOUSE_normal;
-		g_display->hideMenu(RDMENU_BOTTOM);
+		g_graphics->hideMenu(RDMENU_BOTTOM);
 		return;
 	}
 
@@ -284,7 +284,7 @@
 
 	// now do the normal click stuff
 
-	me = MouseEvent();
+	me = g_input->mouseEvent();
 
 	// we only care about left clicks when the mouse is over an object
 	// we ignore mouse releases
@@ -311,8 +311,8 @@
 			// these might be required by the action script about
 			// to be run
 
-			MOUSE_X = (uint32) g_display->_mouseX + _thisScreen.scroll_offset_x;
-			MOUSE_Y = (uint32) g_display->_mouseY + _thisScreen.scroll_offset_y;
+			MOUSE_X = (uint32) _input->_mouseX + _thisScreen.scroll_offset_x;
+			MOUSE_Y = (uint32) _input->_mouseY + _thisScreen.scroll_offset_y;
 
 			// for scripts to know what's been clicked (21jan97).
 			// First used for 'room_13_turning_script' in object
@@ -326,14 +326,14 @@
 
 			// Hide menu - back to normal menu mode
 
-			g_display->hideMenu(RDMENU_BOTTOM);
+			g_graphics->hideMenu(RDMENU_BOTTOM);
 			_mouseMode = MOUSE_normal;
 		} else {
 			// better check for combine/cancel
 			// cancel puts us back in Menu_mouse mode
-			if (g_display->_mouseX >= 24 && g_display->_mouseX < 640 - 24) {
+			if (_input->_mouseX >= 24 && _input->_mouseX < 640 - 24) {
 				// which are we over?
-				pos = (g_display->_mouseX - 24) / 40;
+				pos = (_input->_mouseX - 24) / 40;
 
 				//clicked on something - what button?
 				if (_masterMenuList[pos].icon_resource) {
@@ -385,14 +385,14 @@
 	_mouseEvent *me;
 	uint32 pos;
 
-	if (g_display->_mouseY < 400) {
+	if (_input->_mouseY < 400) {
 		// close menu
 		_mouseMode = MOUSE_normal;
-		g_display->hideMenu(RDMENU_BOTTOM);
+		g_graphics->hideMenu(RDMENU_BOTTOM);
 		return;
 	}
 
-	me = MouseEvent();
+	me = g_input->mouseEvent();
 
 	// we only care about left clicks when the mouse is over an object
 	// we ignore mouse releases
@@ -401,9 +401,9 @@
 		// there's a mouse event to be processed
 		// now check if we've clicked on an actual icon
 
-		if (g_display->_mouseX >= 24 && g_display->_mouseX < 640 - 24) {
+		if (_input->_mouseX >= 24 && _input->_mouseX < 640 - 24) {
 			// which are we over?
-			pos = (g_display->_mouseX - 24) / 40;
+			pos = (_input->_mouseX - 24) / 40;
 
 			// clicked on something - what button?
 			if (_masterMenuList[pos].icon_resource) {
@@ -471,7 +471,7 @@
 	_mouseEvent *me;
 
 	// no save in big-object menu lock situation
-	if (g_display->_mouseY < 0 && !_mouseModeLocked && !OBJECT_HELD) {
+	if (_input->_mouseY < 0 && !_mouseModeLocked && !OBJECT_HELD) {
 		_mouseMode = MOUSE_system_menu;
 
 		if (_mouseTouching) {
@@ -486,7 +486,7 @@
 		return;
 	}
 
-	if (g_display->_mouseY > 399 && !_mouseModeLocked) {
+	if (_input->_mouseY > 399 && !_mouseModeLocked) {
 		// If an object is being held, i.e. if the mouse cursor has a
 		// luggage, we should be use dragging mode instead of inventory
 		// menu mode.
@@ -522,7 +522,7 @@
 
 	// now do the normal click stuff
 
-	me = MouseEvent();
+	me = g_input->mouseEvent();
 
 	if (_debugger->_definingRectangles) {
 		if (_debugger->_draggingRectangle == 0) {
@@ -530,8 +530,8 @@
 
 			if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) {
 				// set both (x1,y1) and (x2,y2) to this point
-				_debugger->_rectX1 = _debugger->_rectX2 = (uint32) g_display->_mouseX + _thisScreen.scroll_offset_x;
-				_debugger->_rectY1 = _debugger->_rectY2 = (uint32) g_display->_mouseY + _thisScreen.scroll_offset_y;
+				_debugger->_rectX1 = _debugger->_rectX2 = (uint32) _input->_mouseX + _thisScreen.scroll_offset_x;
+				_debugger->_rectY1 = _debugger->_rectY2 = (uint32) _input->_mouseY + _thisScreen.scroll_offset_y;
 				_debugger->_draggingRectangle = 1;
 			}
 		} else if (_debugger->_draggingRectangle == 1) {
@@ -543,8 +543,8 @@
 				_debugger->_draggingRectangle = 2;
 			} else {
 				// drag rectangle
-				_debugger->_rectX2 = (uint32) g_display->_mouseX + _thisScreen.scroll_offset_x;
-				_debugger->_rectY2 = (uint32) g_display->_mouseY + _thisScreen.scroll_offset_y;
+				_debugger->_rectX2 = (uint32) _input->_mouseX + _thisScreen.scroll_offset_x;
+				_debugger->_rectY2 = (uint32) _input->_mouseY + _thisScreen.scroll_offset_y;
 			}
 		} else {
 			// currently locked to avoid knocking out of place
@@ -594,8 +594,8 @@
 
 			// these might be required by the action script about
 			// to be run
-			MOUSE_X = (uint32) g_display->_mouseX + _thisScreen.scroll_offset_x;
-			MOUSE_Y = (uint32) g_display->_mouseY + _thisScreen.scroll_offset_y;
+			MOUSE_X = (uint32) _input->_mouseX + _thisScreen.scroll_offset_x;
+			MOUSE_Y = (uint32) _input->_mouseY + _thisScreen.scroll_offset_y;
 
 			// only left button
 			if (_mouseTouching == EXIT_CLICK_ID && (me->buttons & RD_LEFTBUTTONDOWN)) {
@@ -650,7 +650,7 @@
 	// don't detect objects that are hidden behind the menu bars (ie. in
 	// the scrolled-off areas of the screen)
 
-	if (g_display->_mouseY < 0 || g_display->_mouseY > 399)	{	
+	if (_input->_mouseY < 0 || _input->_mouseY > 399) {
 		pointer_type = 0;
 		_mouseTouching = 0;
 	} else {
@@ -747,14 +747,14 @@
 		// loop
 
 		if (res == NORMAL_MOUSE_ID)
-			g_display->setMouseAnim(icon, len, RDMOUSE_NOFLASH);
+			g_graphics->setMouseAnim(icon, len, RDMOUSE_NOFLASH);
 		else
- 			g_display->setMouseAnim(icon, len, RDMOUSE_FLASH);
+ 			g_graphics->setMouseAnim(icon, len, RDMOUSE_FLASH);
 
 		res_man->closeResource(res);
 	} else {
 		// blank cursor
-		g_display->setMouseAnim(NULL, 0, 0);
+		g_graphics->setMouseAnim(NULL, 0, 0);
 	}
 }
 
@@ -768,11 +768,11 @@
 		icon = res_man->openResource(res) + sizeof(_standardHeader);
 		len = res_man->_resList[res]->size - sizeof(_standardHeader);
 
-		g_display->setLuggageAnim(icon, len);
+		g_graphics->setLuggageAnim(icon, len);
 
 		res_man->closeResource(res);
 	} else
-		g_display->setLuggageAnim(NULL, 0);
+		g_graphics->setLuggageAnim(NULL, 0);
 }
 
 uint32 Sword2Engine::checkMouseList(void) {
@@ -786,10 +786,10 @@
 			// mouse-detection-box
 
 			if (_mouseList[j].priority == priority &&
-				g_display->_mouseX + _thisScreen.scroll_offset_x >= _mouseList[j].x1 &&
-				g_display->_mouseX + _thisScreen.scroll_offset_x <= _mouseList[j].x2 &&
-				g_display->_mouseY + _thisScreen.scroll_offset_y >= _mouseList[j].y1 &&
-				g_display->_mouseY + _thisScreen.scroll_offset_y <= _mouseList[j].y2) {
+				_input->_mouseX + _thisScreen.scroll_offset_x >= _mouseList[j].x1 &&
+				_input->_mouseX + _thisScreen.scroll_offset_x <= _mouseList[j].x2 &&
+				_input->_mouseY + _thisScreen.scroll_offset_y >= _mouseList[j].y1 &&
+				_input->_mouseY + _thisScreen.scroll_offset_y <= _mouseList[j].y2) {
 				// record id
 				_mouseTouching = _mouseList[j].id;
 
@@ -965,8 +965,8 @@
 			// line reference number
 
 			_pointerTextBlocNo = fontRenderer->buildNewBloc(
-				text + 2, g_display->_mouseX + xOffset,
-				g_display->_mouseY + yOffset,
+				text + 2, _input->_mouseX + xOffset,
+				_input->_mouseY + yOffset,
 				POINTER_TEXT_WIDTH, POINTER_TEXT_PEN,
 				RDSPR_TRANS | RDSPR_DISPLAYALIGN,
 				_speechFontId, justification);
@@ -1042,7 +1042,7 @@
 
 void Sword2Engine::monitorPlayerActivity(void) {
 	// if there is at least one mouse event outstanding
-	if (CheckForMouseEvents()) {
+	if (g_input->checkForMouseEvents()) {
 		// reset activity delay counter
 		_playerActivityDelay = 0;
 	} else {
@@ -1062,12 +1062,12 @@
 
 	// dont hide menu in conversations
 	if (TALK_FLAG == 0)
-		g_display->hideMenu(RDMENU_BOTTOM);
+		g_graphics->hideMenu(RDMENU_BOTTOM);
 
 	if (_vm->_mouseMode == MOUSE_system_menu) {
 		// close menu
 		_vm->_mouseMode = MOUSE_normal;
-		g_display->hideMenu(RDMENU_TOP);
+		g_graphics->hideMenu(RDMENU_TOP);
 	}
 
 	// script continue
@@ -1110,7 +1110,7 @@
 	}
 
 	// if mouse is over menu area
-	if (g_display->_mouseY > 399) {
+	if (g_input->_mouseY > 399) {
 		if (_vm->_mouseMode != MOUSE_holding) {
 			// VITAL - reset things & rebuild the menu
 			_vm->_mouseMode = MOUSE_normal;
@@ -1129,7 +1129,7 @@
 		// testing logic scripts by simulating an instant Save &
 		// Restore
 
-		g_display->setPalette(0, 1, white, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
 
 		// stops all fx & clears the queue - eg. when leaving a
 		// location
@@ -1141,7 +1141,7 @@
 
 		res_man->killAllObjects(false);
 
-		g_display->setPalette(0, 1, black, RDPAL_INSTANT);
+		g_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
 	}
 
 	return IR_CONT;
@@ -1228,7 +1228,7 @@
 
 	// Highest priority
 
-	ob_mouse->x1 = _vm->_thisScreen.scroll_offset_x + g_display->_screenWide - SCROLL_MOUSE_WIDTH;
+	ob_mouse->x1 = _vm->_thisScreen.scroll_offset_x + g_graphics->_screenWide - SCROLL_MOUSE_WIDTH;
 	ob_mouse->y1 = 0;
 	ob_mouse->x2 = _vm->_thisScreen.screen_wide - 1;
 	ob_mouse->y2 = _vm->_thisScreen.screen_deep - 1;
@@ -1265,7 +1265,7 @@
 int32 Logic::fnRemoveChooser(int32 *params) {
 	// params:	none
 
-	g_display->hideMenu(RDMENU_BOTTOM);
+	g_graphics->hideMenu(RDMENU_BOTTOM);
 	return IR_CONT;
 }
 

Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- resman.cpp	8 Nov 2003 18:15:34 -0000	1.65
+++ resman.cpp	11 Nov 2003 07:43:02 -0000	1.66
@@ -1019,28 +1019,28 @@
 	char buf[1024];
 	sprintf(buf, "%sClusters\\%s", _cdPath, _resourceFiles[newCluster]);
 
-	g_display->waitForFade();
+	g_graphics->waitForFade();
 
-	if (g_display->getFadeStatus() != RDFADE_BLACK) {
-		g_display->fadeDown();
-		g_display->waitForFade();
+	if (g_graphics->getFadeStatus() != RDFADE_BLACK) {
+		g_graphics->fadeDown();
+		g_graphics->waitForFade();
 	}
 
-	g_display->clearScene();
+	g_graphics->clearScene();
 
 	_vm->setMouse(0);
 	_vm->setLuggage(0);
 
 	uint8 *bgfile;
 	bgfile = openResource(2950);	// open the screen resource
-	g_display->initialiseBackgroundLayer(NULL);
-	g_display->initialiseBackgroundLayer(NULL);
-	g_display->initialiseBackgroundLayer(_vm->fetchBackgroundLayer(bgfile));
-	g_display->initialiseBackgroundLayer(NULL);
-	g_display->initialiseBackgroundLayer(NULL);
-	g_display->setPalette(0, 256, _vm->fetchPalette(bgfile), RDPAL_FADE);
+	g_graphics->initialiseBackgroundLayer(NULL);
+	g_graphics->initialiseBackgroundLayer(NULL);
+	g_graphics->initialiseBackgroundLayer(_vm->fetchBackgroundLayer(bgfile));
+	g_graphics->initialiseBackgroundLayer(NULL);
+	g_graphics->initialiseBackgroundLayer(NULL);
+	g_graphics->setPalette(0, 256, _vm->fetchPalette(bgfile), RDPAL_FADE);
 
-	g_display->renderParallax(_vm->fetchBackgroundLayer(bgfile), 2);
+	g_graphics->renderParallax(_vm->fetchBackgroundLayer(bgfile), 2);
 	closeResource(2950);		// release the screen resource
 
 	// Git rid of read-only status, if it is set.
@@ -1066,8 +1066,8 @@
 
 	frame = (_frameHeader*) text_spr->ad;
 
-	textSprite.x = g_display->_screenWide /2 - frame->width / 2;
-	textSprite.y = g_display->_screenDeep /2 - frame->height / 2 - RDMENU_MENUDEEP;
+	textSprite.x = g_graphics->_screenWide /2 - frame->width / 2;
+	textSprite.y = g_graphics->_screenDeep /2 - frame->height / 2 - RDMENU_MENUDEEP;
 	textSprite.w = frame->width;
 	textSprite.h = frame->height;
 	textSprite.scale = 0;
@@ -1107,17 +1107,17 @@
 	int16 textX = textSprite.x;
 	int16 textY = textSprite.y;
 
-	g_display->drawSprite(&barSprite);
+	g_graphics->drawSprite(&barSprite);
 	barSprite.x = barX;
 	barSprite.y = barY;
 
 	textSprite.data	= text_spr->ad + sizeof(_frameHeader);
-	g_display->drawSprite(&textSprite);
+	g_graphics->drawSprite(&textSprite);
 	textSprite.x = textX;
 	textSprite.y = textY;
 
-	g_display->fadeUp();
-	g_display->waitForFade();
+	g_graphics->fadeUp();
+	g_graphics->waitForFade();
 
 	uint32 size = inFile.size();
 
@@ -1139,19 +1139,19 @@
 			step = 0;
 			// open the screen resource
 			bgfile = openResource(2950);
-			g_display->renderParallax(_vm->fetchBackgroundLayer(bgfile), 2);
+			g_graphics->renderParallax(_vm->fetchBackgroundLayer(bgfile), 2);
 			// release the screen resource
 			closeResource(2950);
 			loadingBar = openResource(2951);
 			frame = _vm->fetchFrameHeader(loadingBar, fr);
 			barSprite.data = (uint8 *) (frame + 1);
 			closeResource(2951);
-			g_display->drawSprite(&barSprite);
+			g_graphics->drawSprite(&barSprite);
 			barSprite.x = barX;
 			barSprite.y = barY;
 
 			textSprite.data	= text_spr->ad + sizeof(_frameHeader);
-			g_display->drawSprite(&textSprite);
+			g_graphics->drawSprite(&textSprite);
 			textSprite.x = textX;
 			textSprite.y = textY;
 
@@ -1159,7 +1159,7 @@
 		} else
 			step++;
 
-		g_display->updateDisplay();
+		g_graphics->updateDisplay();
 	} while ((read % BUFFERSIZE) == 0);
 
 	if (read != size) {
@@ -1170,11 +1170,11 @@
 	outFile.close();
 	memory->freeMemory(text_spr);
 
-	g_display->clearScene();
+	g_graphics->clearScene();
 
-	g_display->fadeDown();
-	g_display->waitForFade();
-	g_display->fadeUp();
+	g_graphics->fadeDown();
+	g_graphics->waitForFade();
+	g_graphics->fadeUp();
 
 	// Git rid of read-only status.
 	SVM_SetFileAttributes(_resourceFiles[newCluster], FILE_ATTRIBUTE_NORMAL);
@@ -1291,8 +1291,8 @@
 
 	frame = (_frameHeader*) text_spr->ad;
 
-	spriteInfo.x = g_display->_screenWide / 2 - frame->width / 2;
-	spriteInfo.y = g_display->_screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP;
+	spriteInfo.x = g_graphics->_screenWide / 2 - frame->width / 2;
+	spriteInfo.y = g_graphics->_screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP;
 	spriteInfo.w = frame->width;
 	spriteInfo.h = frame->height;
 	spriteInfo.scale = 0;
@@ -1330,10 +1330,10 @@
 			}
 		}
 		
-		g_display->updateDisplay();
+		g_graphics->updateDisplay();
 
-		g_display->clearScene();
-		g_display->drawSprite(&spriteInfo);	// Keep the message there even when the user task swaps.
+		g_graphics->clearScene();
+		g_graphics->drawSprite(&spriteInfo);	// Keep the message there even when the user task swaps.
 		spriteInfo.y = oldY;		// Drivers change the y co-ordinate, don't know why...
 		spriteInfo.x = oldX;
 	} while (!done);

Index: router.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/router.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- router.cpp	8 Nov 2003 15:47:51 -0000	1.29
+++ router.cpp	11 Nov 2003 07:43:02 -0000	1.30
@@ -2530,7 +2530,7 @@
 	// lines
 
 	for (i = 0; i < _nbars; i++)
-		g_display->drawLine(_bars[i].x1, _bars[i].y1, _bars[i].x2, _bars[i].y2, 254);
+		g_graphics->drawLine(_bars[i].x1, _bars[i].y1, _bars[i].x2, _bars[i].y2, 254);
 
 	// nodes
 
@@ -2540,8 +2540,8 @@
 }
 
 void Router::plotCross(int16 x, int16 y, uint8 colour) {
-	g_display->drawLine(x - 1, y - 1, x + 1, y + 1, colour);
-	g_display->drawLine(x + 1, y - 1, x - 1, y + 1, colour);	
+	g_graphics->drawLine(x - 1, y - 1, x + 1, y + 1, colour);
+	g_graphics->drawLine(x + 1, y - 1, x - 1, y + 1, colour);	
 }
 
 void Router::loadWalkGrid(void) {

Index: speech.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/speech.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- speech.cpp	10 Nov 2003 07:52:15 -0000	1.48
+++ speech.cpp	11 Nov 2003 07:43:02 -0000	1.49
@@ -172,17 +172,17 @@
 			if (j < IN_SUBJECT) {
 				debug(5, " ICON res %d for %d", _subjectList[j].res, j);
 				icon = res_man->openResource(_subjectList[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
-				g_display->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
+				g_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
 				res_man->closeResource(_subjectList[j].res);
 			} else {
 				//no icon here
 				debug(5, " NULL for %d", j);
-				g_display->setMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL);
+				g_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL);
 			}
 		}
 
 		// start menus appearing
-		g_display->showMenu(RDMENU_BOTTOM);
+		g_graphics->showMenu(RDMENU_BOTTOM);
 
 		// lets have the mouse pointer back
 		_vm->setMouse(NORMAL_MOUSE_ID);
@@ -195,7 +195,7 @@
 		// menu is there - we're just waiting for a click
 		debug(5, "choosing");
 
-		me = MouseEvent();
+		me = g_input->mouseEvent();
 
 		// we only care about left clicks
 		// we ignore mouse releases
@@ -205,9 +205,9 @@
 			// if so then end the choose, highlight only the
 			// chosen, blank the mouse and return the ref code * 8
 
-			if (g_display->_mouseY > 399 && g_display->_mouseX >= 24 && g_display->_mouseX < 640 - 24) {
+			if (g_input->_mouseY > 399 && g_input->_mouseX >= 24 && g_input->_mouseX < 640 - 24) {
 				//which are we over?
-				hit = (g_display->_mouseX - 24) / 40;
+				hit = (g_input->_mouseX - 24) / 40;
 
 				//clicked on something - what button?
 				if (hit < IN_SUBJECT) {
@@ -220,7 +220,7 @@
 						// change all others to grey
 						if (j != hit) {
 							icon = res_man->openResource( _subjectList[j].res ) + sizeof(_standardHeader);
-							g_display->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
+							g_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
 							res_man->closeResource(_subjectList[j].res);
 						}
 					}
@@ -279,9 +279,9 @@
 
 	// params:	none
 
-	g_display->hideMenu(RDMENU_BOTTOM);
+	g_graphics->hideMenu(RDMENU_BOTTOM);
 
-	if (g_display->_mouseY > 399) {
+	if (g_input->_mouseY > 399) {
 		// will wait for cursor to move off the bottom menu
 		_vm->_mouseMode = MOUSE_holding;
 		debug(5, "   holding");
@@ -1233,8 +1233,8 @@
 
 	// so that we can go to the options panel while text & speech is
 	// being tested
-	if (SYSTEM_TESTING_TEXT == 0 || g_display->_mouseY > 0) {
-		me = MouseEvent();
+	if (SYSTEM_TESTING_TEXT == 0 || g_input->_mouseY > 0) {
+		me = g_input->mouseEvent();
 
 		// Note that we now have TWO click-delays - one for LEFT
 		// button, one for RIGHT BUTTON
@@ -1258,7 +1258,7 @@
 
 			do {
 				// trash anything thats buffered
-				me = MouseEvent();
+				me = g_input->mouseEvent();
 			} while (me);
 
 			speechFinished = 1;

Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- sword2.cpp	10 Nov 2003 01:04:12 -0000	1.81
+++ sword2.cpp	11 Nov 2003 07:43:02 -0000	1.82
@@ -98,8 +98,9 @@
 namespace Sword2 {
 
 Sword2Engine *g_sword2 = NULL;
+Input *g_input = NULL;
 Sound *g_sound = NULL;
-Display *g_display = NULL;
+Graphics *g_graphics = NULL;
 
 Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
 	: Engine(syst) {
@@ -130,8 +131,9 @@
 	g_logic = new Logic(this);
 	fontRenderer = new FontRenderer();
 	gui = new Gui(this);
+	g_input = _input = new Input();
 	g_sound = _sound = new Sound(_mixer);
-	g_display = _display = new Display(640, 480);
+	g_graphics = _graphics = new Graphics(640, 480);
 	_debugger = new Debugger(this);
 
 	_lastPaletteRes = 0;
@@ -187,8 +189,9 @@
 Sword2Engine::~Sword2Engine() {
 	free(_targetName);
 	delete _debugger;
-	delete _display;
+	delete _graphics;
 	delete _sound;
+	delete _input;
 	delete gui;
 	delete fontRenderer;
 	delete g_logic;
@@ -323,7 +326,7 @@
 		startGame();
 
 	debug(5, "CALLING: initialiseRenderCycle");
-	g_display->initialiseRenderCycle();
+	_graphics->initialiseRenderCycle();
 
 	_renderSkip = false;		// Toggled on 'S' key, to render only
 					// 1 in 4 frames, to speed up game
@@ -334,7 +337,7 @@
 		if (_debugger->isAttached())
 			_debugger->onFrame();
 
-		g_display->updateDisplay();
+		_graphics->updateDisplay();
 
 #ifdef _SWORD2_DEBUG
 // FIXME: If we want this, we should re-work it to use the backend's
@@ -356,8 +359,8 @@
 		}
 #endif
 
-		if (KeyWaiting()) {
-			ReadKey(&ke);
+		if (g_input->keyWaiting()) {
+			g_input->readKey(&ke);
 
 			char c = toupper(ke.ascii);
 
@@ -476,13 +479,11 @@
 
 void Sword2Engine::sleepUntil(int32 time) {
 	while ((int32) SVM_timeGetTime() < time) {
-		parseEvents();
-
 		// Make sure menu animations and fades don't suffer
-		g_display->processMenu();
-		g_display->updateDisplay();
+		_graphics->processMenu();
+		_graphics->updateDisplay();
 
-		g_system->delay_msecs(10);
+		_system->delay_msecs(10);
 	}
 }
 
@@ -496,7 +497,7 @@
 	// res_man->closeResource(3258);
 
 	// don't allow Pause while screen fading or while black
-	if (g_display->getFadeStatus() != RDFADE_NONE)
+	if (_graphics->getFadeStatus() != RDFADE_NONE)
 		return;
 	
 	pauseAllSound();
@@ -507,7 +508,7 @@
 	// mouse_mode=MOUSE_normal;
 
 	// this is the only place allowed to do it this way
-	g_display->setLuggageAnim(NULL, 0);
+	_graphics->setLuggageAnim(NULL, 0);
 
 	// blank cursor
 	setMouse(0);
@@ -527,7 +528,7 @@
 	// dim the palette during the pause
 
 	if (!_stepOneCycle)
-		g_display->dimPalette();
+		_graphics->dimPalette();
 
 	_gamePaused = true;
 }

Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- sword2.h	10 Nov 2003 01:04:12 -0000	1.36
+++ sword2.h	11 Nov 2003 07:43:02 -0000	1.37
@@ -146,8 +146,9 @@
 	uint32 _features;
 	char *_targetName; // target name for saves
 
+	Input *_input;
 	Sound *_sound;
-	Display *_display;
+	Graphics *_graphics;
 
 	Debugger *_debugger;
 
@@ -373,8 +374,9 @@
 };
 
 extern Sword2Engine *g_sword2;
+extern Input *g_input; 
 extern Sound *g_sound;
-extern Display *g_display; 
+extern Graphics *g_graphics; 
 
 } // End of namespace Sword2
 

Index: walker.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/walker.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- walker.cpp	10 Nov 2003 07:52:15 -0000	1.27
+++ walker.cpp	11 Nov 2003 07:43:02 -0000	1.28
@@ -131,7 +131,7 @@
 		// resource
 
 		ob_graph->anim_resource = ob_mega->megaset_res;
-	} else if (EXIT_FADING && g_display->getFadeStatus() == RDFADE_BLACK) {
+	} else if (EXIT_FADING && g_graphics->getFadeStatus() == RDFADE_BLACK) {
 		// double clicked an exit so quit the walk when screen is black
 
 		// ok, thats it - back to script and change screen





More information about the Scummvm-git-logs mailing list