[Scummvm-cvs-logs] SF.net SVN: scummvm:[53674] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Thu Oct 21 19:09:57 CEST 2010


Revision: 53674
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53674&view=rev
Author:   strangerke
Date:     2010-10-21 17:09:57 +0000 (Thu, 21 Oct 2010)

Log Message:
-----------
HUGO: Moved _objects to a separate file

also suppressed some dereferencing

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/display_v1d.cpp
    scummvm/trunk/engines/hugo/display_v1w.cpp
    scummvm/trunk/engines/hugo/file.cpp
    scummvm/trunk/engines/hugo/file.h
    scummvm/trunk/engines/hugo/file_v1d.cpp
    scummvm/trunk/engines/hugo/file_v1w.cpp
    scummvm/trunk/engines/hugo/file_v2d.cpp
    scummvm/trunk/engines/hugo/file_v3d.cpp
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/hugo.h
    scummvm/trunk/engines/hugo/intro.cpp
    scummvm/trunk/engines/hugo/intro.h
    scummvm/trunk/engines/hugo/intro_v1d.cpp
    scummvm/trunk/engines/hugo/intro_v1w.cpp
    scummvm/trunk/engines/hugo/intro_v2d.cpp
    scummvm/trunk/engines/hugo/intro_v2w.cpp
    scummvm/trunk/engines/hugo/intro_v3d.cpp
    scummvm/trunk/engines/hugo/intro_v3w.cpp
    scummvm/trunk/engines/hugo/inventory.cpp
    scummvm/trunk/engines/hugo/inventory.h
    scummvm/trunk/engines/hugo/module.mk
    scummvm/trunk/engines/hugo/mouse.cpp
    scummvm/trunk/engines/hugo/mouse.h
    scummvm/trunk/engines/hugo/parser.cpp
    scummvm/trunk/engines/hugo/parser.h
    scummvm/trunk/engines/hugo/parser_v1d.cpp
    scummvm/trunk/engines/hugo/parser_v1w.cpp
    scummvm/trunk/engines/hugo/parser_v2d.cpp
    scummvm/trunk/engines/hugo/parser_v3d.cpp
    scummvm/trunk/engines/hugo/route.cpp
    scummvm/trunk/engines/hugo/route.h
    scummvm/trunk/engines/hugo/schedule.cpp
    scummvm/trunk/engines/hugo/schedule.h
    scummvm/trunk/engines/hugo/schedule_v1d.cpp
    scummvm/trunk/engines/hugo/schedule_v3d.cpp
    scummvm/trunk/engines/hugo/sound.cpp
    scummvm/trunk/engines/hugo/sound.h

Added Paths:
-----------
    scummvm/trunk/engines/hugo/object.cpp
    scummvm/trunk/engines/hugo/object.h

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/display.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -48,7 +48,7 @@
 #define INY(Y, B) (Y >= B->y && Y <= B->y + B->dy)
 #define OVERLAP(A, B) ((INX(A->x, B) || INX(A->x + A->dx, B) || INX(B->x, A) || INX(B->x + B->dx, A)) && (INY(A->y, B) || INY(A->y + A->dy, B) || INY(B->y, A) || INY(B->y + B->dy, A)))
 
-Screen::Screen(HugoEngine &vm) : _vm(vm) {
+Screen::Screen(HugoEngine *vm) : _vm(vm) {
 
 }
 
@@ -58,7 +58,7 @@
 void Screen::createPal() {
 	debugC(1, kDebugDisplay, "createPal");
 
-	g_system->setPalette(_vm._palette, 0, NUM_COLORS);
+	g_system->setPalette(_vm->_palette, 0, NUM_COLORS);
 }
 
 void Screen::initDisplay() {
@@ -135,7 +135,7 @@
 	debugC(4, kDebugDisplay, "findOvl");
 
 	for (; y < seq_p->lines; y++) {              // Each line in object
-		image_pt ovb_p = _vm.getBaseBoundaryOverlay() + ((uint16)(dst_p - _frontBuffer) >> 3);  // Ptr into overlay bits
+		image_pt ovb_p = _vm->getBaseBoundaryOverlay() + ((uint16)(dst_p - _frontBuffer) >> 3);  // Ptr into overlay bits
 		if (*ovb_p & (0x80 >> ((uint16)(dst_p - _frontBuffer) & 7))) // Overlay bit is set
 			return FG;                              // Found a bit - must be foreground
 		dst_p += XPIX;
@@ -151,7 +151,7 @@
 
 	image_pt image = seq->imagePtr;                 // Ptr to object image data
 	image_pt subFrontBuffer = &_frontBuffer[sy * XPIX + sx]; // Ptr to offset in _frontBuffer
-	image_pt overlay = &_vm.getFirstOverlay()[(sy * XPIX + sx) >> 3]; // Ptr to overlay data
+	image_pt overlay = &_vm->getFirstOverlay()[(sy * XPIX + sx) >> 3]; // Ptr to overlay data
 	int16 frontBufferwrap = XPIX - seq->x2 - 1;     // Wraps dest_p after each line
 	int16 imageWrap = seq->bytesPerLine8 - seq->x2 - 1;
 
@@ -159,7 +159,7 @@
 	for (uint16 y = 0; y < seq->lines; y++) {       // Each line in object
 		for (uint16 x = 0; x <= seq->x2; x++) {
 			if (*image) {                           // Non-transparent
-				overlay = _vm.getFirstOverlay() + ((uint16)(subFrontBuffer - _frontBuffer) >> 3);       // Ptr into overlay bits
+				overlay = _vm->getFirstOverlay() + ((uint16)(subFrontBuffer - _frontBuffer) >> 3);       // Ptr into overlay bits
 				if (*overlay & (0x80 >> ((uint16)(subFrontBuffer - _frontBuffer) & 7))) {   // Overlay bit is set
 					if (overlayState == UNDEF)      // Overlay defined yet?
 						overlayState = findOvl(seq, subFrontBuffer, y);// No, find it.
@@ -269,8 +269,8 @@
 		// Don't blit if newscreen just loaded because _frontBuffer will
 		// get blitted via InvalidateRect() at end of this cycle
 		// and blitting here causes objects to appear too soon.
-		if (_vm.getGameStatus().newScreenFl) {
-			_vm.getGameStatus().newScreenFl = false;
+		if (_vm->getGameStatus().newScreenFl) {
+			_vm->getGameStatus().newScreenFl = false;
 			break;
 		}
 
@@ -394,18 +394,18 @@
 	debugC(4, kDebugDisplay, "drawStatusText");
 
 	loadFont(U_FONT8);
-	uint16 sdx = stringLength(_vm._statusLine);
+	uint16 sdx = stringLength(_vm->_statusLine);
 	uint16 sdy = fontHeight() + 1;                 // + 1 for shadow
 	uint16 posX = 0;
 	uint16 posY = YPIX - sdy;
 
 	// Display the string and add rect to display list
-	writeStr(posX, posY, _vm._statusLine, _TLIGHTYELLOW);
+	writeStr(posX, posY, _vm->_statusLine, _TLIGHTYELLOW);
 	displayList(D_ADD, posX, posY, sdx, sdy);
 
-	sdx = stringLength(_vm._scoreLine);
+	sdx = stringLength(_vm->_scoreLine);
 	posY = 0;
-	writeStr(posX, posY, _vm._scoreLine, _TCYAN);
+	writeStr(posX, posY, _vm->_scoreLine, _TCYAN);
 	displayList(D_ADD, posX, posY, sdx, sdy);
 }
 
@@ -447,7 +447,7 @@
 	displayBackground();
 
 	// Stop premature object display in Display_list(D_DISPLAY)
-	_vm.getGameStatus().newScreenFl = true;
+	_vm->getGameStatus().newScreenFl = true;
 }
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/display.h	2010-10-21 17:09:57 UTC (rev 53674)
@@ -46,7 +46,7 @@
 
 class Screen {
 public:
-	Screen(HugoEngine &vm);
+	Screen(HugoEngine *vm);
 	virtual ~Screen();
 
 	int16    fontHeight();
@@ -93,7 +93,7 @@
 	}
 
 protected:
-	HugoEngine &_vm;
+	HugoEngine *_vm;
 
 	// Fonts used in dib (non-GDI)
 	byte _fnt;                                      // Current font number
@@ -116,7 +116,7 @@
 
 class Screen_v1d : public Screen {
 public:
-	Screen_v1d(HugoEngine &vm);
+	Screen_v1d(HugoEngine *vm);
 	~Screen_v1d();
 
 	virtual void loadFont(int16 fontId);
@@ -124,7 +124,7 @@
 
 class Screen_v1w : public Screen {
 public:
-	Screen_v1w(HugoEngine &vm);
+	Screen_v1w(HugoEngine *vm);
 	~Screen_v1w();
 
 	virtual void loadFont(int16 fontId);

Modified: scummvm/trunk/engines/hugo/display_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display_v1d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/display_v1d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -40,7 +40,7 @@
 
 namespace Hugo {
 
-Screen_v1d::Screen_v1d(HugoEngine &vm) : Screen(vm) {
+Screen_v1d::Screen_v1d(HugoEngine *vm) : Screen(vm) {
 }
 
 Screen_v1d::~Screen_v1d() {
@@ -61,7 +61,7 @@
 
 	fontLoadedFl[_fnt] = true;
 
-	memcpy(_fontdata[_fnt], _vm._arrayFont[_fnt], _vm._arrayFontSize[_fnt]);
+	memcpy(_fontdata[_fnt], _vm->_arrayFont[_fnt], _vm->_arrayFontSize[_fnt]);
 	_font[_fnt][0] = _fontdata[_fnt];               // Store height,width of fonts
 
 	int16 offset = 2;                                       // Start at fontdata[2] ([0],[1] used for height,width)

Modified: scummvm/trunk/engines/hugo/display_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display_v1w.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/display_v1w.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -41,7 +41,7 @@
 
 namespace Hugo {
 
-Screen_v1w::Screen_v1w(HugoEngine &vm) : Screen(vm) {
+Screen_v1w::Screen_v1w(HugoEngine *vm) : Screen(vm) {
 }
 
 Screen_v1w::~Screen_v1w() {
@@ -59,7 +59,7 @@
 		return;
 
 	fontLoadedFl[_fnt] = true;
-	_vm.file().readUIFItem(fontId, _fontdata[_fnt]);
+	_vm->_file->readUIFItem(fontId, _fontdata[_fnt]);
 
 	// Compile font ptrs.  Note: First ptr points to height,width of font
 	_font[_fnt][0] = _fontdata[_fnt];               // Store height,width of fonts

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/file.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -39,9 +39,10 @@
 #include "hugo/schedule.h"
 #include "hugo/display.h"
 #include "hugo/util.h"
+#include "hugo/object.h"
 
 namespace Hugo {
-FileManager::FileManager(HugoEngine &vm) : _vm(vm) {
+FileManager::FileManager(HugoEngine *vm) : _vm(vm) {
 }
 
 FileManager::~FileManager() {
@@ -143,7 +144,7 @@
 	if (!objPtr->seqNumb)                           // This object has no images
 		return;
 
-	if (_vm.isPacked()) {
+	if (_vm->isPacked()) {
 		_objectsArchive.seek((uint32)objNum * sizeof(objBlock_t), SEEK_SET);
 
 		objBlock_t objBlock;                        // Info on file within database
@@ -153,10 +154,10 @@
 		_objectsArchive.seek(objBlock.objOffset, SEEK_SET);
 	} else {
 		char *buf = (char *) malloc(2048 + 1);      // Buffer for file access
-		strcat(strcat(strcpy(buf, _vm._picDir), _vm._arrayNouns[objPtr->nounIndex][0]), OBJEXT);
+		strcat(strcat(strcpy(buf, _vm->_picDir), _vm->_arrayNouns[objPtr->nounIndex][0]), OBJEXT);
 		if (!_objectsArchive.open(buf)) {
-			warning("File %s not found, trying again with %s%s", buf, _vm._arrayNouns[objPtr->nounIndex][0], OBJEXT);
-			strcat(strcpy(buf, _vm._arrayNouns[objPtr->nounIndex][0]), OBJEXT);
+			warning("File %s not found, trying again with %s%s", buf, _vm->_arrayNouns[objPtr->nounIndex][0], OBJEXT);
+			strcat(strcpy(buf, _vm->_arrayNouns[objPtr->nounIndex][0]), OBJEXT);
 			if (!_objectsArchive.open(buf))
 				Utils::Error(FILE_ERR, "%s", buf);
 		}
@@ -170,12 +171,12 @@
 		for (int k = 0; k < objPtr->seqList[j].imageNbr; k++) { // each image
 			if (k == 0) {                           // First image
 				// Read this image - allocate both seq and image memory
-				seqPtr = readPCX(_objectsArchive, 0, 0, firstFl, _vm._arrayNouns[objPtr->nounIndex][0]);
+				seqPtr = readPCX(_objectsArchive, 0, 0, firstFl, _vm->_arrayNouns[objPtr->nounIndex][0]);
 				objPtr->seqList[j].seqPtr = seqPtr;
 				firstFl = false;
 			} else {                                // Subsequent image
 				// Read this image - allocate both seq and image memory
-				seqPtr->nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstFl, _vm._arrayNouns[objPtr->nounIndex][0]);
+				seqPtr->nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstFl, _vm->_arrayNouns[objPtr->nounIndex][0]);
 				seqPtr = seqPtr->nextSeqPtr;
 			}
 
@@ -222,7 +223,7 @@
 		warning("Unexpected cycling: %d", objPtr->cycling);
 	}
 
-	if (!_vm.isPacked())
+	if (!_vm->isPacked())
 		_objectsArchive.close();
 }
 
@@ -232,7 +233,7 @@
 	debugC(1, kDebugFile, "getSound(%d, %d)", sound, *size);
 
 	// No more to do if SILENCE (called for cleanup purposes)
-	if (sound == _vm._soundSilence)
+	if (sound == _vm->_soundSilence)
 		return 0;
 
 	// Open sounds file
@@ -283,35 +284,6 @@
 	return false;
 }
 
-void FileManager::saveSeq(object_t *obj) {
-// Save sequence number and image number in given object
-	debugC(1, kDebugFile, "saveSeq");
-
-	bool found = false;
-	for (int j = 0; !found && (j < obj->seqNumb); j++) {
-		seq_t *q = obj->seqList[j].seqPtr;
-		for (int k = 0; !found && (k < obj->seqList[j].imageNbr); k++) {
-			if (obj->currImagePtr == q) {
-				found = true;
-				obj->curSeqNum = j;
-				obj->curImageNum = k;
-			} else {
-				q = q->nextSeqPtr;
-			}
-		}
-	}
-}
-
-void FileManager::restoreSeq(object_t *obj) {
-// Set up cur_seq_p from stored sequence and image number in object
-	debugC(1, kDebugFile, "restoreSeq");
-
-	seq_t *q = obj->seqList[obj->curSeqNum].seqPtr;
-	for (int j = 0; j < obj->curImageNum; j++)
-		q = q->nextSeqPtr;
-	obj->currImagePtr = q;
-}
-
 void FileManager::saveGame(int16 slot, const char *descrip) {
 // Save game to supplied slot (-1 is INITFILE)
 	debugC(1, kDebugFile, "saveGame(%d, %s)", slot, descrip);
@@ -320,11 +292,11 @@
 	Common::String path; // Full path of saved game
 
 	if (slot == -1)
-		path = _vm._initFilename;
+		path = _vm->_initFilename;
 	else
-		path = Common::String::printf(_vm._saveFilename.c_str(), slot);
+		path = Common::String::printf(_vm->_saveFilename.c_str(), slot);
 
-	Common::WriteStream *out = _vm.getSaveFileManager()->openForSaving(path);
+	Common::WriteStream *out = _vm->getSaveFileManager()->openForSaving(path);
 	if (!out) {
 		warning("Can't create file '%s', game not saved", path.c_str());
 		return;
@@ -337,19 +309,19 @@
 	out->write(descrip, DESCRIPLEN);
 
 	// Save objects
-	for (int i = 0; i < _vm._numObj; i++) {
+	for (int i = 0; i < _vm->_numObj; i++) {
 		// Save where curr_seq_p is pointing to
-		saveSeq(&_vm._objects[i]);
-		out->write(&_vm._objects[i], sizeof(object_t));
+		_vm->_object->saveSeq(&_vm->_object->_objects[i]);
+		out->write(&_vm->_object->_objects[i], sizeof(object_t));
 	}
 
-	const status_t &gameStatus = _vm.getGameStatus();
+	const status_t &gameStatus = _vm->getGameStatus();
 
 	// Save whether hero image is swapped
-	out->write(&_vm._heroImage, sizeof(_vm._heroImage));
+	out->write(&_vm->_heroImage, sizeof(_vm->_heroImage));
 
 	// Save score
-	int score = _vm.getScore();
+	int score = _vm->getScore();
 	out->write(&score, sizeof(score));
 
 	// Save story mode
@@ -362,16 +334,16 @@
 	out->write(&gameStatus.gameOverFl, sizeof(gameStatus.gameOverFl));
 
 	// Save screen states
-	out->write(_vm._screenStates, sizeof(*_vm._screenStates) * _vm._numScreens);
+	out->write(_vm->_screenStates, sizeof(*_vm->_screenStates) * _vm->_numScreens);
 
 	// Save points table
-	out->write(_vm._points, sizeof(point_t) * _vm._numBonuses);
+	out->write(_vm->_points, sizeof(point_t) * _vm->_numBonuses);
 
 	// Now save current time and all current events in event queue
-	_vm.scheduler().saveEvents(out);
+	_vm->_scheduler->saveEvents(out);
 
 	// Save palette table
-	_vm.screen().savePal(out);
+	_vm->_screen->savePal(out);
 
 	// Save maze status
 	out->write(&_maze, sizeof(maze_t));
@@ -386,17 +358,17 @@
 	debugC(1, kDebugFile, "restoreGame(%d)", slot);
 
 	// Initialize new-game status
-	_vm.initStatus();
+	_vm->initStatus();
 
 	// Get full path of saved game file - note test for INITFILE
 	Common::String path; // Full path of saved game
 
 	if (slot == -1)
-		path = _vm._initFilename;
+		path = _vm->_initFilename;
 	else
-		path = Common::String::printf(_vm._saveFilename.c_str(), slot);
+		path = Common::String::printf(_vm->_saveFilename.c_str(), slot);
 
-	Common::SeekableReadStream *in = _vm.getSaveFileManager()->openForLoading(path);
+	Common::SeekableReadStream *in = _vm->getSaveFileManager()->openForLoading(path);
 	if (!in)
 		return;
 
@@ -412,13 +384,13 @@
 	in->seek(DESCRIPLEN, SEEK_CUR);
 
 	// If hero image is currently swapped, swap it back before restore
-	if (_vm._heroImage != HERO)
-		_vm.scheduler().swapImages(HERO, _vm._heroImage);
+	if (_vm->_heroImage != HERO)
+		_vm->_object->swapImages(HERO, _vm->_heroImage);
 
 	// Restore objects, retain current seqList which points to dynamic mem
 	// Also, retain cmnd_t pointers
-	for (int i = 0; i < _vm._numObj; i++) {
-		object_t *p = &_vm._objects[i];
+	for (int i = 0; i < _vm->_numObj; i++) {
+		object_t *p = &_vm->_object->_objects[i];
 		seqList_t seqList[MAX_SEQUENCES];
 		memcpy(seqList, p->seqList, sizeof(seqList_t));
 		uint16 cmdIndex = p->cmdIndex;
@@ -427,37 +399,37 @@
 		memcpy(p->seqList, seqList, sizeof(seqList_t));
 	}
 
-	in->read(&_vm._heroImage, sizeof(_vm._heroImage));
+	in->read(&_vm->_heroImage, sizeof(_vm->_heroImage));
 
 	// If hero swapped in saved game, swap it
-	int heroImg = _vm._heroImage;
+	int heroImg = _vm->_heroImage;
 	if (heroImg != HERO)
-		_vm.scheduler().swapImages(HERO, _vm._heroImage);
-	_vm._heroImage = heroImg;
+		_vm->_object->swapImages(HERO, _vm->_heroImage);
+	_vm->_heroImage = heroImg;
 
-	status_t &gameStatus = _vm.getGameStatus();
+	status_t &gameStatus = _vm->getGameStatus();
 
 	int score;
 	in->read(&score, sizeof(score));
-	_vm.setScore(score);
+	_vm->setScore(score);
 
 	in->read(&gameStatus.storyModeFl, sizeof(gameStatus.storyModeFl));
 	in->read(&gameStatus.jumpExitFl, sizeof(gameStatus.jumpExitFl));
 	in->read(&gameStatus.gameOverFl, sizeof(gameStatus.gameOverFl));
-	in->read(_vm._screenStates, sizeof(*_vm._screenStates) * _vm._numScreens);
+	in->read(_vm->_screenStates, sizeof(*_vm->_screenStates) * _vm->_numScreens);
 
 	// Restore points table
-	in->read(_vm._points, sizeof(point_t) * _vm._numBonuses);
+	in->read(_vm->_points, sizeof(point_t) * _vm->_numBonuses);
 
 	// Restore ptrs to currently loaded objects
-	for (int i = 0; i < _vm._numObj; i++)
-		restoreSeq(&_vm._objects[i]);
+	for (int i = 0; i < _vm->_numObj; i++)
+		_vm->_object->restoreSeq(&_vm->_object->_objects[i]);
 
 	// Now restore time of the save and the event queue
-	_vm.scheduler().restoreEvents(in);
+	_vm->_scheduler->restoreEvents(in);
 
 	// Restore palette and change it if necessary
-	_vm.screen().restorePal(in);
+	_vm->_screen->restorePal(in);
 
 	// Restore maze status
 	in->read(&_maze, sizeof(maze_t));
@@ -475,27 +447,27 @@
 	debugC(1, kDebugFile, "initSavedGame");
 
 	// Force save of initial game
-	if (_vm.getGameStatus().initSaveFl)
+	if (_vm->getGameStatus().initSaveFl)
 		saveGame(-1, "");
 
 	// If initial game doesn't exist, create it
-	Common::SeekableReadStream *in = _vm.getSaveFileManager()->openForLoading(_vm._initFilename);
+	Common::SeekableReadStream *in = _vm->getSaveFileManager()->openForLoading(_vm->_initFilename);
 	if (!in) {
 		saveGame(-1, "");
-		in = _vm.getSaveFileManager()->openForLoading(_vm._initFilename);
+		in = _vm->getSaveFileManager()->openForLoading(_vm->_initFilename);
 		if (!in) {
-			Utils::Error(WRITE_ERR, "%s", _vm._initFilename.c_str());
+			Utils::Error(WRITE_ERR, "%s", _vm->_initFilename.c_str());
 			return;
 		}
 	}
 
 	// Must have an open saved game now
-	_vm.getGameStatus().saveSize = in->size();
+	_vm->getGameStatus().saveSize = in->size();
 	delete in;
 
 	// Check sanity - maybe disk full or path set to read-only drive?
-	if (_vm.getGameStatus().saveSize == -1)
-		Utils::Error(WRITE_ERR, "%s", _vm._initFilename.c_str());
+	if (_vm->getGameStatus().saveSize == -1)
+		Utils::Error(WRITE_ERR, "%s", _vm->_initFilename.c_str());
 }
 
 void FileManager::openPlaybackFile(bool playbackFl, bool recordFl) {
@@ -520,7 +492,7 @@
 
 	Common::File ofp;
 	if (!ofp.open(BOOTFILE)) {
-		if (_vm._gameVariant == 3) {
+		if (_vm->_gameVariant == 3) {
 			//TODO initialize properly _boot structure
 			warning("printBootText - Skipping as H1 Dos may be a freeware");
 			return;
@@ -559,7 +531,7 @@
 
 	Common::File ofp;
 	if (!ofp.open(BOOTFILE)) {
-		if (_vm._gameVariant == 3) {
+		if (_vm->_gameVariant == 3) {
 			//TODO initialize properly _boot structure
 			warning("readBootFile - Skipping as H1 Dos may be a freeware");
 			return;
@@ -673,5 +645,12 @@
 	f.close();
 }
 
+// Read the uif image file (inventory icons)
+void FileManager::readUIFImages() {
+	debugC(1, kDebugFile, "readUIFImages");
+
+	readUIFItem(UIF_IMAGES, _vm->_screen->getGUIBuffer());   // Read all uif images
+}
+
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/file.h
===================================================================
--- scummvm/trunk/engines/hugo/file.h	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/file.h	2010-10-21 17:09:57 UTC (rev 53674)
@@ -57,7 +57,7 @@
 
 class FileManager {
 public:
-	FileManager(HugoEngine &vm);
+	FileManager(HugoEngine *vm);
 	virtual ~FileManager();
 
 
@@ -69,11 +69,10 @@
 	void     instructions();
 	void     readBootFile();
 	void     readImage(int objNum, object_t *objPtr);
+	void     readUIFImages();
 	void     readUIFItem(short id, byte *buf);
 	void     restoreGame(short slot);
-	void     restoreSeq(object_t *obj);
 	void     saveGame(short slot, const char *descrip);
-	void     saveSeq(object_t *obj);
 
 	virtual void openDatabaseFiles() = 0;
 	virtual void closeDatabaseFiles() = 0;
@@ -84,7 +83,7 @@
 	virtual char *fetchString(int index) = 0;
 
 protected:
-	HugoEngine &_vm;
+	HugoEngine *_vm;
 
 	Common::File _stringArchive;                    // Handle for string file
 	Common::File _sceneryArchive1;                  // Handle for scenery file
@@ -108,7 +107,7 @@
 
 class FileManager_v1d : public FileManager {
 public:
-	FileManager_v1d(HugoEngine &vm);
+	FileManager_v1d(HugoEngine *vm);
 	~FileManager_v1d();
 
 	void openDatabaseFiles();
@@ -120,7 +119,7 @@
 
 class FileManager_v2d : public FileManager {
 public:
-	FileManager_v2d(HugoEngine &vm);
+	FileManager_v2d(HugoEngine *vm);
 	~FileManager_v2d();
 
 	void openDatabaseFiles();
@@ -132,7 +131,7 @@
 
 class FileManager_v3d : public FileManager_v2d {
 public:
-	FileManager_v3d(HugoEngine &vm);
+	FileManager_v3d(HugoEngine *vm);
 	~FileManager_v3d();
 
 	void openDatabaseFiles();
@@ -145,7 +144,7 @@
 
 class FileManager_v1w : public FileManager_v2d {
 public:
-	FileManager_v1w(HugoEngine &vm);
+	FileManager_v1w(HugoEngine *vm);
 	~FileManager_v1w();
 
 	void readOverlay(int screenNum, image_pt image, ovl_t overlayType);

Modified: scummvm/trunk/engines/hugo/file_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/file_v1d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -38,7 +38,7 @@
 #include "hugo/util.h"
 
 namespace Hugo {
-FileManager_v1d::FileManager_v1d(HugoEngine &vm) : FileManager(vm) {
+FileManager_v1d::FileManager_v1d(HugoEngine *vm) : FileManager(vm) {
 }
 
 FileManager_v1d::~FileManager_v1d() {
@@ -59,7 +59,7 @@
 	const char *ovl_ext[] = {".b", ".o", ".ob"};
 	char *buf = (char *) malloc(2048 + 1);          // Buffer for file access
 
-	strcat(strcpy(buf, _vm._screenNames[screenNum]), ovl_ext[overlayType]);
+	strcat(strcpy(buf, _vm->_screenNames[screenNum]), ovl_ext[overlayType]);
 
 	if (!fileExists(buf)) {
 		for (uint32 i = 0; i < OVL_SIZE; i++)
@@ -81,12 +81,12 @@
 	debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
 
 	char *buf = (char *) malloc(2048 + 1);          // Buffer for file access
-	strcat(strcpy(buf, _vm._screenNames[screenIndex]), ".ART");
+	strcat(strcpy(buf, _vm->_screenNames[screenIndex]), ".ART");
 	if (!_sceneryArchive1.open(buf))
 		Utils::Error(FILE_ERR, "%s", buf);
 	// Read the image into dummy seq and static dib_a
 	seq_t dummySeq;                                 // Image sequence structure for Read_pcx
-	readPCX(_sceneryArchive1, &dummySeq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+	readPCX(_sceneryArchive1, &dummySeq, _vm->_screen->getFrontBuffer(), true, _vm->_screenNames[screenIndex]);
 
 	_sceneryArchive1.close();
 }
@@ -94,7 +94,7 @@
 char *FileManager_v1d::fetchString(int index) {
 	debugC(1, kDebugFile, "fetchString(%d)", index);
 
-	return _vm._stringtData[index];
+	return _vm->_stringtData[index];
 }
 
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/file_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1w.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/file_v1w.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -37,7 +37,7 @@
 #include "hugo/util.h"
 
 namespace Hugo {
-FileManager_v1w::FileManager_v1w(HugoEngine &vm) : FileManager_v2d(vm) {
+FileManager_v1w::FileManager_v1w(HugoEngine *vm) : FileManager_v2d(vm) {
 }
 
 FileManager_v1w::~FileManager_v1w() {

Modified: scummvm/trunk/engines/hugo/file_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v2d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/file_v2d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -40,7 +40,7 @@
 #include "hugo/util.h"
 
 namespace Hugo {
-FileManager_v2d::FileManager_v2d(HugoEngine &vm) : FileManager(vm) {
+FileManager_v2d::FileManager_v2d(HugoEngine *vm) : FileManager(vm) {
 }
 
 FileManager_v2d::~FileManager_v2d() {
@@ -85,7 +85,7 @@
 
 	// Read the image into dummy seq and static dib_a
 	seq_t dummySeq;                                 // Image sequence structure for Read_pcx
-	readPCX(_sceneryArchive1, &dummySeq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+	readPCX(_sceneryArchive1, &dummySeq, _vm->_screen->getFrontBuffer(), true, _vm->_screenNames[screenIndex]);
 }
 
 void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
@@ -170,7 +170,7 @@
 
 	// Null terminate, decode and return it
 	_textBoxBuffer[off2-off1] = '\0';
-	_vm.scheduler().decodeString(_textBoxBuffer);
+	_vm->_scheduler->decodeString(_textBoxBuffer);
 	return _textBoxBuffer;
 }
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/file_v3d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v3d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/file_v3d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -39,7 +39,7 @@
 #include "hugo/util.h"
 
 namespace Hugo {
-FileManager_v3d::FileManager_v3d(HugoEngine &vm) : FileManager_v2d(vm) {
+FileManager_v3d::FileManager_v3d(HugoEngine *vm) : FileManager_v2d(vm) {
 }
 
 FileManager_v3d::~FileManager_v3d() {
@@ -65,11 +65,11 @@
 	if (screenIndex < 20) {
 		_sceneryArchive1.seek(sceneBlock.scene_off, SEEK_SET);
 		// Read the image into dummy seq and static dib_a
-		readPCX(_sceneryArchive1, &dummySeq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+		readPCX(_sceneryArchive1, &dummySeq, _vm->_screen->getFrontBuffer(), true, _vm->_screenNames[screenIndex]);
 	} else {
 		_sceneryArchive2.seek(sceneBlock.scene_off, SEEK_SET);
 		// Read the image into dummy seq and static dib_a
-		readPCX(_sceneryArchive2, &dummySeq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+		readPCX(_sceneryArchive2, &dummySeq, _vm->_screen->getFrontBuffer(), true, _vm->_screenNames[screenIndex]);
 	}
 }
 

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -42,6 +42,7 @@
 #include "hugo/util.h"
 #include "hugo/sound.h"
 #include "hugo/intro.h"
+#include "hugo/object.h"
 
 #include "engines/util.h"
 
@@ -63,8 +64,8 @@
 HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd), _mouseX(0), _mouseY(0),
 	_textData(0), _stringtData(0), _screenNames(0), _textEngine(0), _textIntro(0), _textMouse(0), _textParser(0), _textSchedule(0), _textUtil(0),
 	_arrayNouns(0), _arrayVerbs(0), _arrayReqs(0), _hotspots(0), _invent(0), _uses(0), _catchallList(0), _backgroundObjects(0),
-	_points(0), _cmdList(0), _screenActs(0), _objects(0), _actListArr(0), _heroImage(0), _defltTunes(0), _palette(0), _introX(0),
-	_introY(0), _maxInvent(0), _numBonuses(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _numObj(0),
+	_points(0), _cmdList(0), _screenActs(0), _actListArr(0), _heroImage(0), _defltTunes(0), _palette(0), _introX(0), _introY(0), 
+	_maxInvent(0), _numBonuses(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _numObj(0),
 	_score(0), _maxscore(0)
 
 {
@@ -82,14 +83,15 @@
 }
 
 HugoEngine::~HugoEngine() {
-	delete _soundHandler;
+	delete _object;
+	delete _sound;
 	delete _route;
 	delete _parser;
-	delete _inventoryHandler;
-	delete _mouseHandler;
+	delete _inventory;
+	delete _mouse;
 	delete _screen;
 	delete _scheduler;
-	delete _fileManager;
+	delete _file;
 
 	free(_palette);
 	free(_introX);
@@ -161,53 +163,54 @@
 	s_Engine = this;
 	initGraphics(320, 200, false);
 
-	_mouseHandler = new MouseHandler(*this);
-	_inventoryHandler = new InventoryHandler(*this);
-	_route = new Route(*this);
-	_soundHandler = new SoundHandler(*this);
+	_mouse = new MouseHandler(this);
+	_inventory = new InventoryHandler(this);
+	_route = new Route(this);
+	_sound = new SoundHandler(this);
+	_object = new ObjectHandler(this);
 
 	switch (_gameVariant) {
 	case 0: // H1 Win
-		_fileManager = new FileManager_v1w(*this);
-		_scheduler = new Scheduler_v3d(*this);
-		_introHandler = new intro_v1w(*this);
-		_screen = new Screen_v1w(*this);
-		_parser = new Parser_v1w(*this);
+		_file = new FileManager_v1w(this);
+		_scheduler = new Scheduler_v3d(this);
+		_intro = new intro_v1w(this);
+		_screen = new Screen_v1w(this);
+		_parser = new Parser_v1w(this);
 		break;
 	case 1:
-		_fileManager = new FileManager_v2d(*this);
-		_scheduler = new Scheduler_v3d(*this);
-		_introHandler = new intro_v2w(*this);
-		_screen = new Screen_v1w(*this);
-		_parser = new Parser_v1w(*this);
+		_file = new FileManager_v2d(this);
+		_scheduler = new Scheduler_v3d(this);
+		_intro = new intro_v2w(this);
+		_screen = new Screen_v1w(this);
+		_parser = new Parser_v1w(this);
 		break;
 	case 2:
-		_fileManager = new FileManager_v2d(*this);
-		_scheduler = new Scheduler_v3d(*this);
-		_introHandler = new intro_v3w(*this);
-		_screen = new Screen_v1w(*this);
-		_parser = new Parser_v1w(*this);
+		_file = new FileManager_v2d(this);
+		_scheduler = new Scheduler_v3d(this);
+		_intro = new intro_v3w(this);
+		_screen = new Screen_v1w(this);
+		_parser = new Parser_v1w(this);
 		break;
 	case 3: // H1 DOS
-		_fileManager = new FileManager_v1d(*this);
-		_scheduler = new Scheduler_v1d(*this);
-		_introHandler = new intro_v1d(*this);
-		_screen = new Screen_v1d(*this);
-		_parser = new Parser_v1d(*this);
+		_file = new FileManager_v1d(this);
+		_scheduler = new Scheduler_v1d(this);
+		_intro = new intro_v1d(this);
+		_screen = new Screen_v1d(this);
+		_parser = new Parser_v1d(this);
 		break;
 	case 4:
-		_fileManager = new FileManager_v2d(*this);
-		_scheduler = new Scheduler_v1d(*this);
-		_introHandler = new intro_v2d(*this);
-		_screen = new Screen_v1d(*this);
-		_parser = new Parser_v2d(*this);
+		_file = new FileManager_v2d(this);
+		_scheduler = new Scheduler_v1d(this);
+		_intro = new intro_v2d(this);
+		_screen = new Screen_v1d(this);
+		_parser = new Parser_v2d(this);
 		break;
 	case 5:
-		_fileManager = new FileManager_v3d(*this);
-		_scheduler = new Scheduler_v3d(*this);
-		_introHandler = new intro_v3d(*this);
-		_screen = new Screen_v1d(*this);
-		_parser = new Parser_v3d(*this);
+		_file = new FileManager_v3d(this);
+		_scheduler = new Scheduler_v3d(this);
+		_intro = new intro_v3d(this);
+		_screen = new Screen_v1d(this);
+		_parser = new Parser_v3d(this);
 		break;
 	}
 
@@ -225,7 +228,7 @@
 	initialize();
 	initConfig(RESET);                              // Reset user's config
 
-	file().restoreGame(-1);
+	_file->restoreGame(-1);
 
 	initMachine();
 
@@ -243,7 +246,7 @@
 		while (_eventMan->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_KEYDOWN:
-				parser().keyHandler(event.kbd.keycode, 0);
+				_parser->keyHandler(event.kbd.keycode, 0);
 				break;
 			case Common::EVENT_MOUSEMOVE:
 				_mouseX = event.mouse.x;
@@ -276,10 +279,10 @@
 	if (_gameVariant == kGameVariantH1Dos)
 		readScreenFiles(0);
 	else
-		file().readBackground(_numScreens - 1);         // Splash screen
+		_file->readBackground(_numScreens - 1);     // Splash screen
 	readObjectImages();                             // Read all object images
 	if (_platform == Common::kPlatformWindows)
-		readUIFImages();                            // Read all uif images (only in Win versions)
+		_file->readUIFImages();                     // Read all uif images (only in Win versions)
 }
 
 void HugoEngine::runMachine() {
@@ -302,32 +305,32 @@
 
 	switch (gameStatus.viewState) {
 	case V_IDLE:                                    // Not processing state machine
-		intro().preNewGame();                           // Any processing before New Game selected
+		_intro->preNewGame();                       // Any processing before New Game selected
 		break;
 	case V_INTROINIT:                               // Initialization before intro begins
-		intro().introInit();
+		_intro->introInit();
 		g_system->showMouse(false);
 		gameStatus.viewState = V_INTRO;
 		break;
 	case V_INTRO:                                   // Do any game-dependant preamble
-		if (intro().introPlay())    {               // Process intro screen
-			scheduler().newScreen(0);               // Initialize first screen
+		if (_intro->introPlay())    {               // Process intro screen
+			_scheduler->newScreen(0);               // Initialize first screen
 			gameStatus.viewState = V_PLAY;
 		}
 		break;
 	case V_PLAY:                                    // Playing game
 		g_system->showMouse(true);
-		parser().charHandler();                     // Process user cmd input
-		moveObjects();                              // Process object movement
-		scheduler().runScheduler();                 // Process any actions
-		screen().displayList(D_RESTORE);            // Restore previous background
-		updateImages();                             // Draw into _frontBuffer, compile display list
-		mouse().mouseHandler();                     // Mouse activity - adds to display list
-		screen().drawStatusText();
-		screen().displayList(D_DISPLAY);            // Blit the display list to screen
+		_parser->charHandler();                     // Process user cmd input
+		_object->moveObjects();                     // Process object movement
+		_scheduler->runScheduler();                 // Process any actions
+		_screen->displayList(D_RESTORE);            // Restore previous background
+		_object->updateImages();                    // Draw into _frontBuffer, compile display list
+		_mouse->mouseHandler();                     // Mouse activity - adds to display list
+		_screen->drawStatusText();
+		_screen->displayList(D_DISPLAY);            // Blit the display list to screen
 		break;
 	case V_INVENT:                                  // Accessing inventory
-		inventory().runInventory();                 // Process Inventory state machine
+		_inventory->runInventory();                 // Process Inventory state machine
 		break;
 	case V_EXIT:                                    // Game over or user exited
 		gameStatus.viewState = V_IDLE;
@@ -642,108 +645,10 @@
 		}
 	}
 
-// TODO: For Hugo3, if not in story mode, set _objects[2].state to 3
-	for (int varnt = 0; varnt < _numVariant; varnt++) {
-		numElem = in.readUint16BE();
-		if (varnt == _gameVariant) {
-			_objects = (object_t *)malloc(sizeof(object_t) * numElem);
-			for (int i = 0; i < numElem; i++) {
-				_objects[i].nounIndex = in.readUint16BE();
-				_objects[i].dataIndex = in.readUint16BE();
-				numSubElem = in.readUint16BE();
-				if (numSubElem == 0)
-					_objects[i].stateDataIndex = 0;
-				else
-					_objects[i].stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem);
-				for (int j = 0; j < numSubElem; j++)
-					_objects[i].stateDataIndex[j] = in.readUint16BE();
-				_objects[i].pathType = (path_t) in.readSint16BE();
-				_objects[i].vxPath = in.readSint16BE();
-				_objects[i].vyPath = in.readSint16BE();
-				_objects[i].actIndex = in.readUint16BE();
-				_objects[i].seqNumb = in.readByte();
-				_objects[i].currImagePtr = 0;
-				if (_objects[i].seqNumb == 0) {
-					_objects[i].seqList[0].imageNbr = 0;
-					_objects[i].seqList[0].seqPtr = 0;
-				}
-				for (int j = 0; j < _objects[i].seqNumb; j++) {
-					_objects[i].seqList[j].imageNbr = in.readUint16BE();
-					_objects[i].seqList[j].seqPtr = 0;
-				}
-				_objects[i].cycling = (cycle_t)in.readByte();
-				_objects[i].cycleNumb = in.readByte();
-				_objects[i].frameInterval = in.readByte();
-				_objects[i].frameTimer = in.readByte();
-				_objects[i].radius = in.readByte();
-				_objects[i].screenIndex = in.readByte();
-				_objects[i].x = in.readSint16BE();
-				_objects[i].y = in.readSint16BE();
-				_objects[i].oldx = in.readSint16BE();
-				_objects[i].oldy = in.readSint16BE();
-				_objects[i].vx = in.readByte();
-				_objects[i].vy = in.readByte();
-				_objects[i].objValue = in.readByte();
-				_objects[i].genericCmd = in.readSint16BE();
-				_objects[i].cmdIndex = in.readUint16BE();
-				_objects[i].carriedFl = (in.readByte() != 0);
-				_objects[i].state = in.readByte();
-				_objects[i].verbOnlyFl = (in.readByte() != 0);
-				_objects[i].priority = in.readByte();
-				_objects[i].viewx = in.readSint16BE();
-				_objects[i].viewy = in.readSint16BE();
-				_objects[i].direction = in.readSint16BE();
-				_objects[i].curSeqNum = in.readByte();
-				_objects[i].curImageNum = in.readByte();
-				_objects[i].oldvx = in.readByte();
-				_objects[i].oldvy = in.readByte();
-			}
-		} else {
-			for (int i = 0; i < numElem; i++) {
-				in.readUint16BE();
-				in.readUint16BE();
-				numSubElem = in.readUint16BE();
-				for (int j = 0; j < numSubElem; j++)
-					in.readUint16BE();
-				in.readSint16BE();
-				in.readSint16BE();
-				in.readSint16BE();
-				in.readUint16BE();
-				numSubElem = in.readByte();
-				for (int j = 0; j < numSubElem; j++)
-					in.readUint16BE();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readSint16BE();
-				in.readSint16BE();
-				in.readSint16BE();
-				in.readSint16BE();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readSint16BE();
-				in.readUint16BE();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readSint16BE();
-				in.readSint16BE();
-				in.readUint16BE();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-				in.readByte();
-			}
-		}
-	}
+	_object->loadObject(in);
 //#define HERO 0
-	_hero = &_objects[HERO];                        // This always points to hero
-	_screen_p = &(_objects[HERO].screenIndex);      // Current screen is hero's
+	_hero = &_object->_objects[HERO];                        // This always points to hero
+	_screen_p = &(_object->_objects[HERO].screenIndex);      // Current screen is hero's
 	_heroImage = HERO;                              // Current in use hero image
 
 //read _actListArr
@@ -1599,18 +1504,18 @@
 		_config.soundVolume = 100;                  // Sound volume %
 		initPlaylist(_config.playlist);             // Initialize default tune playlist
 
-		file().readBootFile();    // Read startup structure
+		_file->readBootFile();    // Read startup structure
 		break;
 	case RESET:
 		// Find first tune and play it
 		for (int16 i = 0; i < MAX_TUNES; i++) {
 			if (_config.playlist[i]) {
-				sound().playMusic(i);
+				_sound->playMusic(i);
 				break;
 			}
 		}
 
-		file().initSavedGame();   // Initialize saved game
+		_file->initSavedGame();   // Initialize saved game
 		break;
 	case RESTORE:
 		warning("Unhandled action RESTORE");
@@ -1624,10 +1529,10 @@
 	_maze.enabledFl = false;
 	_line[0] = '\0';
 
-	sound().initSound();
-	scheduler().initEventQueue();                   // Init scheduler stuff
-	screen().initDisplay();                         // Create Dibs and palette
-	file().openDatabaseFiles();                     // Open database files
+	_sound->initSound();
+	_scheduler->initEventQueue();                   // Init scheduler stuff
+	_screen->initDisplay();                         // Create Dibs and palette
+	_file->openDatabaseFiles();                     // Open database files
 	calcMaxScore();                                 // Initialise maxscore
 
 	_rnd = new Common::RandomSource();
@@ -1657,216 +1562,30 @@
 void HugoEngine::shutdown() {
 	debugC(1, kDebugEngine, "shutdown");
 
-	file().closeDatabaseFiles();
+	_file->closeDatabaseFiles();
 	if (_status.recordFl || _status.playbackFl)
-		file().closePlaybackFile();
-	freeObjects();
+		_file->closePlaybackFile();
+	_object->freeObjects();
 }
 
 void HugoEngine::readObjectImages() {
 	debugC(1, kDebugEngine, "readObjectImages");
 
 	for (int i = 0; i < _numObj; i++)
-		file().readImage(i, &_objects[i]);
+		_file->readImage(i, &_object->_objects[i]);
 }
 
-// Read the uif image file (inventory icons)
-void HugoEngine::readUIFImages() {
-	debugC(1, kDebugEngine, "readUIFImages");
-
-	file().readUIFItem(UIF_IMAGES, screen().getGUIBuffer());   // Read all uif images
-}
-
 // Read scenery, overlay files for given screen number
 void HugoEngine::readScreenFiles(int screenNum) {
 	debugC(1, kDebugEngine, "readScreenFiles(%d)", screenNum);
 
-	file().readBackground(screenNum);               // Scenery file
-	memcpy(screen().getBackBuffer(), screen().getFrontBuffer(), sizeof(screen().getFrontBuffer()));// Make a copy
-	file().readOverlay(screenNum, _boundary, BOUNDARY); // Boundary file
-	file().readOverlay(screenNum, _overlay, OVERLAY);   // Overlay file
-	file().readOverlay(screenNum, _ovlBase, OVLBASE);   // Overlay base file
+	_file->readBackground(screenNum);               // Scenery file
+	memcpy(_screen->getBackBuffer(), _screen->getFrontBuffer(), sizeof(_screen->getFrontBuffer()));// Make a copy
+	_file->readOverlay(screenNum, _boundary, BOUNDARY); // Boundary file
+	_file->readOverlay(screenNum, _overlay, OVERLAY);   // Overlay file
+	_file->readOverlay(screenNum, _ovlBase, OVLBASE);   // Overlay base file
 }
 
-// Update all object positions.  Process object 'local' events
-// including boundary events and collisions
-void HugoEngine::moveObjects() {
-	debugC(4, kDebugEngine, "moveObjects");
-
-	// If route mode enabled, do special route processing
-	if (_status.routeIndex >= 0)
-		route().processRoute();
-
-	// Perform any adjustments to velocity based on special path types
-	// and store all (visible) object baselines into the boundary file.
-	// Don't store foreground or background objects
-	for (int i = 0; i < _numObj; i++) {
-		object_t *obj = &_objects[i];               // Get pointer to object
-		seq_t *currImage = obj->currImagePtr;       // Get ptr to current image
-		if (obj->screenIndex == *_screen_p) {
-			switch (obj->pathType) {
-			case CHASE:
-			case CHASE2: {
-				int8 radius = obj->radius;          // Default to object's radius
-				if (radius < 0)                     // If radius infinity, use closer value
-					radius = DX;
-
-				// Allowable motion wrt boundary
-				int dx = _hero->x + _hero->currImagePtr->x1 - obj->x - currImage->x1;
-				int dy = _hero->y + _hero->currImagePtr->y2 - obj->y - currImage->y2 - 1;
-				if (abs(dx) <= radius)
-					obj->vx = 0;
-				else
-					obj->vx = (dx > 0) ? MIN(dx, obj->vxPath) : MAX(dx, -obj->vxPath);
-				if (abs(dy) <= radius)
-					obj->vy = 0;
-				else
-					obj->vy = (dy > 0) ? MIN(dy, obj->vyPath) : MAX(dy, -obj->vyPath);
-
-				// Set first image in sequence (if multi-seq object)
-				switch (obj->seqNumb) {
-				case 4:
-					if (!obj->vx) {                 // Got 4 directions
-						if (obj->vx != obj->oldvx)  { // vx just stopped
-							if (dy >= 0)
-								obj->currImagePtr = obj->seqList[DOWN].seqPtr;
-							else
-								obj->currImagePtr = obj->seqList[_UP].seqPtr;
-						}
-					} else if (obj->vx != obj->oldvx) {
-						if (dx > 0)
-							obj->currImagePtr = obj->seqList[RIGHT].seqPtr;
-						else
-							obj->currImagePtr = obj->seqList[LEFT].seqPtr;
-					}
-					break;
-				case 3:
-				case 2:
-					if (obj->vx != obj->oldvx) {    // vx just stopped
-						if (dx > 0)                 // Left & right only
-							obj->currImagePtr = obj->seqList[RIGHT].seqPtr;
-						else
-							obj->currImagePtr = obj->seqList[LEFT].seqPtr;
-					}
-					break;
-				}
-
-				if (obj->vx || obj->vy)
-					obj->cycling = CYCLE_FORWARD;
-				else {
-					obj->cycling = NOT_CYCLING;
-					boundaryCollision(obj);         // Must have got hero!
-				}
-				obj->oldvx = obj->vx;
-				obj->oldvy = obj->vy;
-				currImage = obj->currImagePtr;      // Get (new) ptr to current image
-				break;
-				}
-			case WANDER2:
-			case WANDER:
-				if (!_rnd->getRandomNumber(3 * NORMAL_TPS)) {       // Kick on random interval
-					obj->vx = _rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath;
-					obj->vy = _rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath;
-
-					// Set first image in sequence (if multi-seq object)
-					if (obj->seqNumb > 1) {
-						if (!obj->vx && (obj->seqNumb >= 4)) {
-							if (obj->vx != obj->oldvx)  { // vx just stopped
-								if (obj->vy > 0)
-									obj->currImagePtr = obj->seqList[DOWN].seqPtr;
-								else
-									obj->currImagePtr = obj->seqList[_UP].seqPtr;
-							}
-						} else if (obj->vx != obj->oldvx) {
-							if (obj->vx > 0)
-								obj->currImagePtr = obj->seqList[RIGHT].seqPtr;
-							else
-								obj->currImagePtr = obj->seqList[LEFT].seqPtr;
-						}
-					}
-					obj->oldvx = obj->vx;
-					obj->oldvy = obj->vy;
-					currImage = obj->currImagePtr;  // Get (new) ptr to current image
-				}
-				if (obj->vx || obj->vy)
-					obj->cycling = CYCLE_FORWARD;
-				break;
-			default:
-				; // Really, nothing
-			}
-			// Store boundaries
-			if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
-				storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2);
-		}
-	}
-
-	// Move objects, allowing for boundaries
-	for (int i = 0; i < _numObj; i++) {
-		object_t *obj = &_objects[i];                         // Get pointer to object
-		if ((obj->screenIndex == *_screen_p) && (obj->vx || obj->vy)) {
-			// Only process if it's moving
-
-			// Do object movement.  Delta_x,y return allowed movement in x,y
-			// to move as close to a boundary as possible without crossing it.
-			seq_t *currImage = obj->currImagePtr;   // Get ptr to current image
-			// object coordinates
-			int x1 = obj->x + currImage->x1;        // Left edge of object
-			int x2 = obj->x + currImage->x2;        // Right edge
-			int y1 = obj->y + currImage->y1;        // Top edge
-			int y2 = obj->y + currImage->y2;        // Bottom edge
-
-			if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
-				clearBoundary(x1, x2, y2);          // Clear our own boundary
-
-			// Allowable motion wrt boundary
-			int dx = deltaX(x1, x2, obj->vx, y2);
-			if (dx != obj->vx) {
-				// An object boundary collision!
-				boundaryCollision(obj);
-				obj->vx = 0;
-			}
-
-			int dy = deltaY(x1, x2, obj->vy, y2);
-			if (dy != obj->vy) {
-				// An object boundary collision!
-				boundaryCollision(obj);
-				obj->vy = 0;
-			}
-
-			if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
-				storeBoundary(x1, x2, y2);          // Re-store our own boundary
-
-			obj->x += dx;                           // Update object position
-			obj->y += dy;
-
-			// Don't let object go outside screen
-			if (x1 < EDGE)
-				obj->x = EDGE2;
-			if (x2 > (XPIX - EDGE))
-				obj->x = XPIX - EDGE2 - (x2 - x1);
-			if (y1 < EDGE)
-				obj->y = EDGE2;
-			if (y2 > (YPIX - EDGE))
-				obj->y = YPIX - EDGE2 - (y2 - y1);
-
-			if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != WANDER2) && (obj->pathType != CHASE2))
-				obj->cycling = NOT_CYCLING;
-		}
-	}
-
-	// Clear all object baselines from the boundary file.
-	for (int i = 0; i < _numObj; i++) {
-		object_t *obj = &_objects[i];               // Get pointer to object
-		seq_t *currImage = obj->currImagePtr;       // Get ptr to current image
-		if ((obj->screenIndex == *_screen_p) && (obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
-			clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2);
-	}
-
-	// If maze mode is enabled, do special maze processing
-	if (_maze.enabledFl)
-		processMaze();
-}
-
 // Return maximum allowed movement (from zero to vx) such that object does
 // not cross a boundary (either background or another object)
 int HugoEngine::deltaX(int x1, int x2, int vx, int y) {
@@ -1993,218 +1712,31 @@
 		_actListArr[_alNewscrIndex][0].a2.x = _maze.x2 - SHIFT - (x2 - x1);
 		_actListArr[_alNewscrIndex][0].a2.y = _hero->y;
 		_status.routeIndex = -1;
-		scheduler().insertActionList(_alNewscrIndex);
+		_scheduler->insertActionList(_alNewscrIndex);
 	} else if (x2 > _maze.x2) {
 		// Exit east
 		_actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p + 1;
 		_actListArr[_alNewscrIndex][0].a2.x = _maze.x1 + SHIFT;
 		_actListArr[_alNewscrIndex][0].a2.y = _hero->y;
 		_status.routeIndex = -1;
-		scheduler().insertActionList(_alNewscrIndex);
+		_scheduler->insertActionList(_alNewscrIndex);
 	} else if (y1 < _maze.y1 - SHIFT) {
 		// Exit north
 		_actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p - _maze.size;
 		_actListArr[_alNewscrIndex][0].a2.x = _maze.x3;
 		_actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - SHIFT - (y2 - y1);
 		_status.routeIndex = -1;
-		scheduler().insertActionList(_alNewscrIndex);
+		_scheduler->insertActionList(_alNewscrIndex);
 	} else if (y2 > _maze.y2 - SHIFT / 2) {
 		// Exit south
 		_actListArr[_alNewscrIndex][3].a8.screenIndex = *_screen_p + _maze.size;
 		_actListArr[_alNewscrIndex][0].a2.x = _maze.x4;
 		_actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + SHIFT;
 		_status.routeIndex = -1;
-		scheduler().insertActionList(_alNewscrIndex);
+		_scheduler->insertActionList(_alNewscrIndex);
 	}
 }
 
-// Compare function for the quicksort.  The sort is to order the objects in
-// increasing vertical position, using y+y2 as the baseline
-// Returns -1 if ay2 < by2 else 1 if ay2 > by2 else 0
-int HugoEngine::y2comp(const void *a, const void *b) {
-	debugC(6, kDebugEngine, "y2comp");
-
-	const object_t *p1 = &s_Engine->_objects[*(const byte *)a];
-	const object_t *p2 = &s_Engine->_objects[*(const byte *)b];
-
-	if (p1 == p2)
-		// Why does qsort try the same indexes?
-		return 0;
-
-	if (p1->priority == BACKGROUND)
-		return -1;
-
-	if (p2->priority == BACKGROUND)
-		return 1;
-
-	if (p1->priority == FOREGROUND)
-		return 1;
-
-	if (p2->priority == FOREGROUND)
-		return -1;
-
-	int ay2 = p1->y + p1->currImagePtr->y2;
-	int by2 = p2->y + p2->currImagePtr->y2;
-
-	return ay2 - by2;
-}
-
-// Draw all objects on screen as follows:
-// 1. Sort 'FLOATING' objects in order of y2 (base of object)
-// 2. Display new object frames/positions in dib
-// Finally, cycle any animating objects to next frame
-void HugoEngine::updateImages() {
-	debugC(5, kDebugEngine, "updateImages");
-
-	// Initialise the index array to visible objects in current screen
-	int  num_objs = 0;
-	byte objindex[MAX_OBJECTS];                // Array of indeces to objects
-
-	for (int i = 0; i < _numObj; i++) {
-		object_t *obj = &_objects[i];
-		if ((obj->screenIndex == *_screen_p) && (obj->cycling >= ALMOST_INVISIBLE))
-			objindex[num_objs++] = i;
-	}
-
-	// Sort the objects into increasing y+y2 (painter's algorithm)
-	qsort(objindex, num_objs, sizeof(objindex[0]), y2comp);
-
-	// Add each visible object to display list
-	for (int i = 0; i < num_objs; i++) {
-		object_t *obj = &_objects[objindex[i]];
-		// Count down inter-frame timer
-		if (obj->frameTimer)
-			obj->frameTimer--;
-
-		if (obj->cycling > ALMOST_INVISIBLE) {      // Only if visible
-			switch (obj->cycling) {
-			case NOT_CYCLING:
-				screen().displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL);
-				break;
-			case CYCLE_FORWARD:
-				if (obj->frameTimer)                // Not time to see next frame yet
-					screen().displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL);
-				else
-					screen().displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == OVEROVL);
-				break;
-			case CYCLE_BACKWARD: {
-				seq_t *seqPtr = obj->currImagePtr;
-				if (!obj->frameTimer) {             // Show next frame
-					while (seqPtr->nextSeqPtr != obj->currImagePtr)
-						seqPtr = seqPtr->nextSeqPtr;
-				}
-				screen().displayFrame(obj->x, obj->y, seqPtr, obj->priority == OVEROVL);
-				break;
-				}
-			default:
-				break;
-			}
-		}
-	}
-
-	// Cycle any animating objects
-	for (int i = 0; i < num_objs; i++) {
-		object_t *obj = &_objects[objindex[i]];
-		if (obj->cycling != INVISIBLE) {
-			// Only if it's visible
-			if (obj->cycling == ALMOST_INVISIBLE)
-				obj->cycling = INVISIBLE;
-
-			// Now Rotate to next picture in sequence
-			switch (obj->cycling) {
-			case NOT_CYCLING:
-				break;
-			case CYCLE_FORWARD:
-				if (!obj->frameTimer) {
-					// Time to step to next frame
-					obj->currImagePtr = obj->currImagePtr->nextSeqPtr;
-					// Find out if this is last frame of sequence
-					// If so, reset frame_timer and decrement n_cycle
-					if (obj->frameInterval || obj->cycleNumb) {
-						obj->frameTimer = obj->frameInterval;
-						for (int j = 0; j < obj->seqNumb; j++) {
-							if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) {
-								if (obj->cycleNumb) { // Decr cycleNumb if Non-continous
-									if (!--obj->cycleNumb)
-										obj->cycling = NOT_CYCLING;
-								}
-							}
-						}
-					}
-				}
-				break;
-			case CYCLE_BACKWARD: {
-				if (!obj->frameTimer) {
-					// Time to step to prev frame
-					seq_t *seqPtr = obj->currImagePtr;
-					while (obj->currImagePtr->nextSeqPtr != seqPtr)
-						obj->currImagePtr = obj->currImagePtr->nextSeqPtr;
-					// Find out if this is first frame of sequence
-					// If so, reset frame_timer and decrement n_cycle
-					if (obj->frameInterval || obj->cycleNumb) {
-						obj->frameTimer = obj->frameInterval;
-						for (int j = 0; j < obj->seqNumb; j++) {
-							if (obj->currImagePtr == obj->seqList[j].seqPtr) {
-								if (obj->cycleNumb){ // Decr cycleNumb if Non-continous
-									if (!--obj->cycleNumb)
-										obj->cycling = NOT_CYCLING;
-								}
-							}
-						}
-					}
-				}
-				break;
-				}
-			default:
-				break;
-			}
-			obj->oldx = obj->x;
-			obj->oldy = obj->y;
-		}
-	}
-}
-
-// Return object index of the topmost object under the cursor, or -1 if none
-// Objects are filtered if not "useful"
-int16 HugoEngine::findObject(uint16 x, uint16 y) {
-	debugC(3, kDebugEngine, "findObject(%d, %d)", x, y);
-
-	int16     objIndex = -1;                        // Index of found object
-	uint16    y2Max = 0;                            // Greatest y2
-	object_t *obj = _objects;
-	// Check objects on screen
-	for (int i = 0; i < _numObj; i++, obj++) {
-		// Object must be in current screen and "useful"
-		if (obj->screenIndex == *_screen_p && (obj->genericCmd || obj->objValue || obj->cmdIndex)) {
-			seq_t *curImage = obj->currImagePtr;
-			// Object must have a visible image...
-			if (curImage != 0 && obj->cycling != INVISIBLE) {
-				// If cursor inside object
-				if (x >= (uint16)obj->x && x <= obj->x + curImage->x2 && y >= (uint16)obj->y && y <= obj->y + curImage->y2) {
-					// If object is closest so far
-					if (obj->y + curImage->y2 > y2Max) {
-						y2Max = obj->y + curImage->y2;
-						objIndex = i;               // Found an object!
-					}
-				}
-			} else {
-				// ...or a dummy object that has a hotspot rectangle
-				if (curImage == 0 && obj->vxPath != 0 && !obj->carriedFl) {
-					// If cursor inside special rectangle
-					if ((int16)x >= obj->oldx && (int16)x < obj->oldx + obj->vxPath && (int16)y >= obj->oldy && (int16)y < obj->oldy + obj->vyPath) {
-						// If object is closest so far
-						if (obj->oldy + obj->vyPath - 1 > (int16)y2Max) {
-							y2Max = obj->oldy + obj->vyPath - 1;
-							objIndex = i;           // Found an object!
-						}
-					}
-				}
-			}
-		}
-	}
-	return objIndex;
-}
-
 // Find a clear space around supplied object that hero can walk to
 bool HugoEngine::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
 	debugC(1, kDebugEngine, "findObjectSpace(obj, %d, %d)", *destx, *desty);
@@ -2264,97 +1796,6 @@
 	return 0;
 }
 
-// If status.objid = -1, pick up objid, else use status.objid on objid,
-// if objid can't be picked up, use it directly
-void HugoEngine::useObject(int16 objId) {
-	debugC(1, kDebugEngine, "useObject(%d)", objId);
-
-	char *verb;                                     // Background verb to use directly
-	object_t *obj = &_objects[objId];               // Ptr to object
-	if (_status.inventoryObjId == -1) {
-		// Get or use objid directly
-		if ((obj->genericCmd & TAKE) || obj->objValue)  // Get collectible item
-			sprintf(_line, "%s %s", _arrayVerbs[_take][0], _arrayNouns[obj->nounIndex][0]);
-		else if (obj->genericCmd & LOOK)            // Look item
-			sprintf(_line, "%s %s", _arrayVerbs[_look][0], _arrayNouns[obj->nounIndex][0]);
-		else if (obj->genericCmd & DROP)            // Drop item
-			sprintf(_line, "%s %s", _arrayVerbs[_drop][0], _arrayNouns[obj->nounIndex][0]);
-		else if (obj->cmdIndex != 0)                // Use non-collectible item if able
-			sprintf(_line, "%s %s", _arrayVerbs[_cmdList[obj->cmdIndex][1].verbIndex][0], _arrayNouns[obj->nounIndex][0]);
-		else if ((verb = useBG(_arrayNouns[obj->nounIndex][0])) != 0)
-			sprintf(_line, "%s %s", verb, _arrayNouns[obj->nounIndex][0]);
-		else
-			return;                                 // Can't use object directly
-	} else {
-		// Use status.objid on objid
-		// Default to first cmd verb
-		sprintf(_line, "%s %s %s", _arrayVerbs[_cmdList[_objects[_status.inventoryObjId].cmdIndex][1].verbIndex][0], _arrayNouns[_objects[_status.inventoryObjId].nounIndex][0], _arrayNouns[obj->nounIndex][0]);
-
-		// Check valid use of objects and override verb if necessary
-		for (uses_t *use = _uses; use->objId != _numObj; use++) {
-			if (_status.inventoryObjId == use->objId) {
-				// Look for secondary object, if found use matching verb
-				bool foundFl = false;
-				for (target_t *target = use->targets; _arrayNouns[target->nounIndex] != 0; target++)
-					if (_arrayNouns[target->nounIndex][0] == _arrayNouns[obj->nounIndex][0]) {
-						foundFl = true;
-						sprintf(_line, "%s %s %s", _arrayVerbs[target->verbIndex][0], _arrayNouns[_objects[_status.inventoryObjId].nounIndex][0], _arrayNouns[obj->nounIndex][0]);
-					}
-
-				// No valid use of objects found, print failure string
-				if (!foundFl) {
-					// Deselect dragged icon if inventory not active
-					if (_status.inventoryState != I_ACTIVE)
-						_status.inventoryObjId  = -1;
-					Utils::Box(BOX_ANY, "%s", _textData[use->dataIndex]);
-					return;
-				}
-			}
-		}
-	}
-
-	if (_status.inventoryState == I_ACTIVE)         // If inventory active, remove it
-		_status.inventoryState = I_UP;
-	_status.inventoryObjId  = -1;                   // Deselect any dragged icon
-	parser().lineHandler();                         // and process command
-}
-
-// Issue "Look at <object>" command
-// Note special case of swapped hero image
-void HugoEngine::lookObject(object_t *obj) {
-	debugC(1, kDebugEngine, "lookObject");
-
-	if (obj == _hero)
-		// Hero swapped - look at other
-		obj = &_objects[_heroImage];
-
-	parser().command("%s %s", _arrayVerbs[_look][0], _arrayNouns[obj->nounIndex][0]);
-}
-
-// Free all object images
-void HugoEngine::freeObjects() {
-	debugC(1, kDebugEngine, "freeObjects");
-
-	// Nothing to do if not allocated yet
-	if (_hero->seqList[0].seqPtr == 0)
-		return;
-
-	// Free all sequence lists and image data
-	for (int i = 0; i < _numObj; i++) {
-		object_t *obj = &_objects[i];
-		for (int j = 0; j < obj->seqNumb; j++) {    // for each sequence
-			seq_t *seq = obj->seqList[j].seqPtr;    // Free image
-			if (seq == 0)                           // Failure during database load
-				break;
-			do {
-				free(seq->imagePtr);
-				seq = seq->nextSeqPtr;
-			} while (seq != obj->seqList[j].seqPtr);
-			free(seq);                              // Free sequence record
-		}
-	}
-}
-
 // Add action lists for this screen to event queue
 void HugoEngine::screenActions(int screenNum) {
 	debugC(1, kDebugEngine, "screenActions(%d)", screenNum);
@@ -2362,7 +1803,7 @@
 	uint16 *screenAct = _screenActs[screenNum];
 	if (screenAct) {
 		for (int i = 0; screenAct[i]; i++)
-			scheduler().insertActionList(screenAct[i]);
+			_scheduler->insertActionList(screenAct[i]);
 	}
 }
 
@@ -2372,8 +1813,8 @@
 
 	*_screen_p = screenNum;                             // HERO object
 	for (int i = HERO + 1; i < _numObj; i++) {          // Any others
-		if (_objects[i].carriedFl)                      // being carried
-			_objects[i].screenIndex = screenNum;
+		if (_object->isCarried(i))                      // being carried
+			_object->_objects[i].screenIndex = screenNum;
 	}
 }
 
@@ -2394,7 +1835,7 @@
 			hotspot_t *hotspot = &_hotspots[i];
 			if (hotspot->screenIndex == obj->screenIndex)
 				if ((x >= hotspot->x1) && (x <= hotspot->x2) && (y >= hotspot->y1) && (y <= hotspot->y2)) {
-					scheduler().insertActionList(hotspot->actIndex);
+					_scheduler->insertActionList(hotspot->actIndex);
 					break;
 				}
 		}
@@ -2407,7 +1848,7 @@
 		if (radius < 0)
 			radius = DX * 2;
 		if ((abs(dx) <= radius) && (abs(dy) <= radius))
-			scheduler().insertActionList(obj->actIndex);
+			_scheduler->insertActionList(obj->actIndex);
 	}
 }
 
@@ -2416,7 +1857,7 @@
 	debugC(1, kDebugEngine, "calcMaxScore");
 
 	for (int i = 0; i < _numObj; i++)
-		_maxscore += _objects[i].objValue;
+		_maxscore += _object->_objects[i].objValue;
 
 	for (int i = 0; i < _numBonuses; i++)
 		_maxscore += _points[i].score;

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/hugo.h	2010-10-21 17:09:57 UTC (rev 53674)
@@ -38,7 +38,6 @@
 #define EDGE             10                         // Closest object can get to edge of screen
 #define EDGE2            (EDGE * 2)                 // Push object further back on edge collision
 #define SHIFT            8                          // Place hero this far inside bounding box
-#define MAX_OBJECTS      128                        // Used in Update_images()
 #define BOUND(X, Y)      ((_boundary[Y * XBYTES + X / 8] & (0x80 >> X % 8)) != 0)  // Boundary bit set
 
 namespace Common {
@@ -103,6 +102,7 @@
 class Route;
 class SoundHandler;
 class IntroHandler;
+class ObjectHandler;
 
 
 class HugoEngine : public Engine {
@@ -149,7 +149,6 @@
 	point_t   *_points;
 	cmd       **_cmdList;
 	uint16    **_screenActs;
-	object_t  *_objects;
 	act       **_actListArr;
 	int16     *_defltTunes;
 	uint16    _look;
@@ -181,34 +180,6 @@
 		return *s_Engine;
 	}
 
-	FileManager &file() {
-		return *_fileManager;
-	}
-	Scheduler &scheduler() {
-		return *_scheduler;
-	}
-	Screen &screen() {
-		return *_screen;
-	}
-	MouseHandler &mouse() {
-		return *_mouseHandler;
-	}
-	InventoryHandler &inventory() {
-		return *_inventoryHandler;
-	}
-	Parser &parser() {
-		return *_parser;
-	}
-	Route &route() {
-		return *_route;
-	}
-	SoundHandler &sound() {
-		return *_soundHandler;
-	}
-	IntroHandler &intro() {
-		return *_introHandler;
-	}
-
 	void initGame(const HugoGameDescription *gd);
 	void initGamePart(const HugoGameDescription *gd);
 	bool loadHugoDat();
@@ -220,23 +191,25 @@
 		return _mouseY;
 	}
 
-	void initStatus();
-	void readObjectImages();
-	void readUIFImages();
-	void updateImages();
-	void moveObjects();
-	void useObject(int16 objId);
 	bool findObjectSpace(object_t *obj, int16 *destx, int16 *desty);
-	int16 findObject(uint16 x, uint16 y);
-	void lookObject(object_t *obj);
-	void storeBoundary(int x1, int x2, int y);
+
+	void boundaryCollision(object_t *obj); 
 	void clearBoundary(int x1, int x2, int y);
 	void endGame();
+	void initStatus();
+	void processMaze();
+	void readObjectImages();
 	void readScreenFiles(int screen);
-	void setNewScreen(int screen);
 	void screenActions(int screen);
+	void setNewScreen(int screen);
 	void shutdown();
+	void storeBoundary(int x1, int x2, int y);
 
+	char *useBG(char *name);
+
+	int deltaX(int x1, int x2, int vx, int y);
+	int deltaY(int x1, int x2, int vy, int y);
+
 	overlay_t &getBoundaryOverlay() {
 		return _boundary;
 	}
@@ -271,6 +244,17 @@
 		return _introXSize;
 	}
 
+	FileManager *_file;
+	Scheduler *_scheduler;
+	Screen *_screen;
+	MouseHandler *_mouse;
+	InventoryHandler *_inventory;
+	Parser *_parser;
+	Route *_route;
+	SoundHandler *_sound;
+	IntroHandler *_intro;
+	ObjectHandler *_object;
+
 protected:
 
 	// Engine APIs
@@ -301,16 +285,6 @@
 	Common::Platform _platform;
 	bool _packedFl;
 
-	FileManager *_fileManager;
-	Scheduler *_scheduler;
-	Screen *_screen;
-	MouseHandler *_mouseHandler;
-	InventoryHandler *_inventoryHandler;
-	Parser *_parser;
-	Route *_route;
-	SoundHandler *_soundHandler;
-	IntroHandler *_introHandler;
-
 	int _score;                         // Holds current score
 	int _maxscore;                      // Holds maximum score
 
@@ -323,19 +297,10 @@
 	void initPlaylist(bool playlist[MAX_TUNES]);
 	void initConfig(inst_t action);
 	void initialize();
-	int deltaX(int x1, int x2, int vx, int y);
-	int deltaY(int x1, int x2, int vy, int y);
-	void processMaze();
-	//int y2comp (const void *a, const void *b);
-	char *useBG(char *name);
-	void freeObjects();
-	void boundaryCollision(object_t *obj);
 	void calcMaxScore();
 	void initMachine();
 	void runMachine();
 
-	static int y2comp(const void *a, const void *b);
-
 };
 
 } // End of namespace Hugo

Modified: scummvm/trunk/engines/hugo/intro.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -37,7 +37,7 @@
 
 namespace Hugo {
 
-IntroHandler::IntroHandler(HugoEngine &vm) : _vm(vm) {
+IntroHandler::IntroHandler(HugoEngine *vm) : _vm(vm) {
 }
 
 IntroHandler::~IntroHandler() {

Modified: scummvm/trunk/engines/hugo/intro.h
===================================================================
--- scummvm/trunk/engines/hugo/intro.h	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro.h	2010-10-21 17:09:57 UTC (rev 53674)
@@ -43,7 +43,7 @@
 
 class IntroHandler {
 public:
-	IntroHandler(HugoEngine &vm);
+	IntroHandler(HugoEngine *vm);
 	virtual ~IntroHandler();
 
 	virtual void preNewGame() = 0;
@@ -51,13 +51,13 @@
 	virtual bool introPlay() = 0;
 
 protected:
-	HugoEngine &_vm;
+	HugoEngine *_vm;
 	int16 introTicks;                               // Count calls to introPlay()
 };
 
 class intro_v1w : public IntroHandler {
 public:
-	intro_v1w(HugoEngine &vm);
+	intro_v1w(HugoEngine *vm);
 	~intro_v1w();
 
 	void preNewGame();
@@ -67,7 +67,7 @@
 
 class intro_v1d : public IntroHandler {
 public:
-	intro_v1d(HugoEngine &vm);
+	intro_v1d(HugoEngine *vm);
 	~intro_v1d();
 
 	void preNewGame();
@@ -77,7 +77,7 @@
 
 class intro_v2w : public IntroHandler {
 public:
-	intro_v2w(HugoEngine &vm);
+	intro_v2w(HugoEngine *vm);
 	~intro_v2w();
 
 	void preNewGame();
@@ -87,7 +87,7 @@
 
 class intro_v2d : public IntroHandler {
 public:
-	intro_v2d(HugoEngine &vm);
+	intro_v2d(HugoEngine *vm);
 	~intro_v2d();
 
 	void preNewGame();
@@ -97,7 +97,7 @@
 
 class intro_v3w : public IntroHandler {
 public:
-	intro_v3w(HugoEngine &vm);
+	intro_v3w(HugoEngine *vm);
 	~intro_v3w();
 
 	void preNewGame();
@@ -107,7 +107,7 @@
 
 class intro_v3d : public IntroHandler {
 public:
-	intro_v3d(HugoEngine &vm);
+	intro_v3d(HugoEngine *vm);
 	~intro_v3d();
 
 	void preNewGame();

Modified: scummvm/trunk/engines/hugo/intro_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro_v1d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro_v1d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -37,7 +37,7 @@
 #include "hugo/display.h"
 
 namespace Hugo {
-intro_v1d::intro_v1d(HugoEngine &vm) : IntroHandler(vm) {
+intro_v1d::intro_v1d(HugoEngine *vm) : IntroHandler(vm) {
 }
 
 intro_v1d::~intro_v1d() {
@@ -52,116 +52,116 @@
 
 bool intro_v1d::introPlay() {
 	static int state = 0;
-	byte introSize = _vm.getIntroSize();
+	byte introSize = _vm->getIntroSize();
 
 	if (introTicks < introSize) {
 		switch (state++) {
 		case 0:
-			_vm.screen().drawRectangle(true, 0, 0, 319, 199, _TMAGENTA);
-			_vm.screen().drawRectangle(true, 10, 10, 309, 189, _TBLACK);
+			_vm->_screen->drawRectangle(true, 0, 0, 319, 199, _TMAGENTA);
+			_vm->_screen->drawRectangle(true, 10, 10, 309, 189, _TBLACK);
 			break;
 
 		case 1:
-			_vm.screen().drawShape(20, 92,_TLIGHTMAGENTA,_TMAGENTA);
-			_vm.screen().drawShape(250,92,_TLIGHTMAGENTA,_TMAGENTA);
+			_vm->_screen->drawShape(20, 92,_TLIGHTMAGENTA,_TMAGENTA);
+			_vm->_screen->drawShape(250,92,_TLIGHTMAGENTA,_TMAGENTA);
 
 			// HACK: use of TROMAN, size 10-5
-			_vm.screen().loadFont(0);
+			_vm->_screen->loadFont(0);
 
 			char buffer[80];
 			if (_boot.registered)
 				strcpy(buffer, "Registered Version");
 			else
 				strcpy(buffer, "Shareware Version");
-			_vm.screen().writeStr(CENTER, 163, buffer, _TLIGHTMAGENTA);
-			_vm.screen().writeStr(CENTER, 176, COPYRIGHT, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 163, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 176, COPYRIGHT, _TLIGHTMAGENTA);
 
 			if (scumm_stricmp(_boot.distrib, "David P. Gray")) {
 				sprintf(buffer, "Distributed by %s.", _boot.distrib);
-				_vm.screen().writeStr(CENTER, 75, buffer, _TMAGENTA);
+				_vm->_screen->writeStr(CENTER, 75, buffer, _TMAGENTA);
 			}
 
 			// HACK: use of SCRIPT size 24-16
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "Hugo's");
-			_vm.screen().writeStr(CENTER, 20, buffer, _TMAGENTA);
+			_vm->_screen->writeStr(CENTER, 20, buffer, _TMAGENTA);
 
 			// HACK: use of TROMAN, size 30-24
 			strcpy(buffer, "House of Horrors !");
-			_vm.screen().writeStr(CENTER, 50, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 50, buffer, _TLIGHTMAGENTA);
 			break;
 		case 2:
-			_vm.screen().drawRectangle(true, 82, 92, 237, 138, _TBLACK);
+			_vm->_screen->drawRectangle(true, 82, 92, 237, 138, _TBLACK);
 			// HACK: use of TROMAN, size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "S t a r r i n g :");
-			_vm.screen().writeStr(CENTER, 95, buffer, _TMAGENTA);
+			_vm->_screen->writeStr(CENTER, 95, buffer, _TMAGENTA);
 			break;
 		case 3:
 			// HACK: use of TROMAN size 20-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "Hugo !");
-			_vm.screen().writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
 			break;
 		case 4:
-			_vm.screen().drawRectangle(true, 82, 92, 237, 138, _TBLACK);
+			_vm->_screen->drawRectangle(true, 82, 92, 237, 138, _TBLACK);
 			// HACK: use of TROMAN size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "P r o d u c e d  b y :");
-			_vm.screen().writeStr(CENTER, 95, buffer, _TMAGENTA);
+			_vm->_screen->writeStr(CENTER, 95, buffer, _TMAGENTA);
 			break;
 		case 5:
 			// HACK: use of TROMAN size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "David P Gray !");
-			_vm.screen().writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
 			break;
 		case 6:
-			_vm.screen().drawRectangle(true, 82, 92, 237, 138, _TBLACK);
+			_vm->_screen->drawRectangle(true, 82, 92, 237, 138, _TBLACK);
 			// HACK: use of TROMAN size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "D i r e c t e d   b y :");
-			_vm.screen().writeStr(CENTER, 95, buffer, _TMAGENTA);
+			_vm->_screen->writeStr(CENTER, 95, buffer, _TMAGENTA);
 			break;
 		case 7:
 			// HACK: use of TROMAN size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "David P Gray !");
-			_vm.screen().writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
 			break;
 		case 8:
-			_vm.screen().drawRectangle(true, 82, 92, 237, 138, _TBLACK);
+			_vm->_screen->drawRectangle(true, 82, 92, 237, 138, _TBLACK);
 			// HACK: use of TROMAN size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "M u s i c   b y :");
-			_vm.screen().writeStr(CENTER, 95, buffer, _TMAGENTA);
+			_vm->_screen->writeStr(CENTER, 95, buffer, _TMAGENTA);
 			break;
 		case 9:
 			// HACK: use of TROMAN size 16-9
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "David P Gray !");
-			_vm.screen().writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 115, buffer, _TLIGHTMAGENTA);
 			break;
 		case 10:
-			_vm.screen().drawRectangle(true, 82, 92, 237, 138, _TBLACK);
+			_vm->_screen->drawRectangle(true, 82, 92, 237, 138, _TBLACK);
 			// HACK: use of TROMAN size 20-14
-			_vm.screen().loadFont(2);
+			_vm->_screen->loadFont(2);
 
 			strcpy(buffer, "E n j o y !");
-			_vm.screen().writeStr(CENTER, 100, buffer, _TLIGHTMAGENTA);
+			_vm->_screen->writeStr(CENTER, 100, buffer, _TLIGHTMAGENTA);
 			break;
 		}
 
-		_vm.screen().displayBackground();
+		_vm->_screen->displayBackground();
 		g_system->updateScreen();
 		g_system->delayMillis(1000);
 	}

Modified: scummvm/trunk/engines/hugo/intro_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro_v1w.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro_v1w.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -39,7 +39,7 @@
 
 
 namespace Hugo {
-intro_v1w::intro_v1w(HugoEngine &vm) : IntroHandler(vm) {
+intro_v1w::intro_v1w(HugoEngine *vm) : IntroHandler(vm) {
 }
 
 intro_v1w::~intro_v1w() {
@@ -47,8 +47,8 @@
 
 void intro_v1w::preNewGame() {
 	// Auto-start a new game
-	_vm.file().restoreGame(-1);
-	_vm.getGameStatus().viewState = V_INTROINIT;
+	_vm->_file->restoreGame(-1);
+	_vm->getGameStatus().viewState = V_INTROINIT;
 }
 
 void intro_v1w::introInit() {

Modified: scummvm/trunk/engines/hugo/intro_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro_v2d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro_v2d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -39,7 +39,7 @@
 
 namespace Hugo {
 
-intro_v2d::intro_v2d(HugoEngine &vm) : IntroHandler(vm) {
+intro_v2d::intro_v2d(HugoEngine *vm) : IntroHandler(vm) {
 }
 
 intro_v2d::~intro_v2d() {
@@ -49,8 +49,8 @@
 }
 
 void intro_v2d::introInit() {
-	_vm.screen().loadFont(0);
-	_vm.file().readBackground(_vm._numScreens - 1); // display splash screen
+	_vm->_screen->loadFont(0);
+	_vm->_file->readBackground(_vm->_numScreens - 1); // display splash screen
 
 	char buffer[128];
 
@@ -58,14 +58,14 @@
 		sprintf(buffer, "%s  Registered Version", COPYRIGHT);
 	else
 		sprintf(buffer, "%s  Shareware Version", COPYRIGHT);
-	_vm.screen().writeStr(CENTER, 186, buffer, _TLIGHTRED);
+	_vm->_screen->writeStr(CENTER, 186, buffer, _TLIGHTRED);
 
 	if (scumm_stricmp(_boot.distrib, "David P. Gray")) {
 		sprintf(buffer, "Distributed by %s.", _boot.distrib);
-		_vm.screen().writeStr(CENTER, 1, buffer, _TLIGHTRED);
+		_vm->_screen->writeStr(CENTER, 1, buffer, _TLIGHTRED);
 	}
 
-	_vm.screen().displayBackground();
+	_vm->_screen->displayBackground();
 	g_system->updateScreen();
 	g_system->delayMillis(5000);
 }

Modified: scummvm/trunk/engines/hugo/intro_v2w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro_v2w.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro_v2w.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -38,7 +38,7 @@
 
 namespace Hugo {
 
-intro_v2w::intro_v2w(HugoEngine &vm) : IntroHandler(vm) {
+intro_v2w::intro_v2w(HugoEngine *vm) : IntroHandler(vm) {
 }
 
 intro_v2w::~intro_v2w() {

Modified: scummvm/trunk/engines/hugo/intro_v3d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro_v3d.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro_v3d.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -40,7 +40,7 @@
 
 
 namespace Hugo {
-intro_v3d::intro_v3d(HugoEngine &vm) : IntroHandler(vm) {
+intro_v3d::intro_v3d(HugoEngine *vm) : IntroHandler(vm) {
 }
 
 intro_v3d::~intro_v3d() {
@@ -50,8 +50,8 @@
 }
 
 void intro_v3d::introInit() {
-	_vm.screen().loadFont(0);
-	_vm.file().readBackground(_vm._numScreens - 1); // display splash screen
+	_vm->_screen->loadFont(0);
+	_vm->_file->readBackground(_vm->_numScreens - 1); // display splash screen
 
 	char buffer[128];
 	if (_boot.registered)
@@ -59,43 +59,43 @@
 	else
 		sprintf(buffer,"%s  Shareware Version", COPYRIGHT);
 
-	_vm.screen().writeStr(CENTER, 190, buffer, _TBROWN);
+	_vm->_screen->writeStr(CENTER, 190, buffer, _TBROWN);
 
 	if (scumm_stricmp(_boot.distrib, "David P. Gray")) {
 		sprintf(buffer, "Distributed by %s.", _boot.distrib);
-		_vm.screen().writeStr(CENTER, 0, buffer, _TBROWN);
+		_vm->_screen->writeStr(CENTER, 0, buffer, _TBROWN);
 	}
 
-	_vm.screen().displayBackground();
+	_vm->_screen->displayBackground();
 	g_system->updateScreen();
 	g_system->delayMillis(5000);
 	
-	_vm.file().readBackground(22); // display screen MAP_3d
-	_vm.screen().displayBackground();
+	_vm->_file->readBackground(22); // display screen MAP_3d
+	_vm->_screen->displayBackground();
 	introTicks = 0;
 }
 
 bool intro_v3d::introPlay() {
-	byte introSize = _vm.getIntroSize();
+	byte introSize = _vm->getIntroSize();
 
 // Hugo 3 - Preamble screen before going into game.  Draws path of Hugo's plane.
 // Called every tick.  Returns TRUE when complete
 //TODO : Add proper check of story mode
 //#if STORY
 	if (introTicks < introSize) {
-		_vm.screen().writeStr(_vm._introX[introTicks], _vm._introY[introTicks] - DIBOFF_Y, "x", _TBRIGHTWHITE);
-		_vm.screen().displayBackground();
+		_vm->_screen->writeStr(_vm->_introX[introTicks], _vm->_introY[introTicks] - DIBOFF_Y, "x", _TBRIGHTWHITE);
+		_vm->_screen->displayBackground();
 
 		// Text boxes at various times
 		switch (introTicks) {
 		case 4:
-			Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro1]);
+			Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro1]);
 			break;
 		case 9:
-			Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro2]);
+			Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro2]);
 			break;
 		case 35:
-			Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro3]);
+			Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro3]);
 			break;
 		}
 	}

Modified: scummvm/trunk/engines/hugo/intro_v3w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro_v3w.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/intro_v3w.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -40,7 +40,7 @@
 
 namespace Hugo {
 
-intro_v3w::intro_v3w(HugoEngine &vm) : IntroHandler(vm) {
+intro_v3w::intro_v3w(HugoEngine *vm) : IntroHandler(vm) {
 }
 
 intro_v3w::~intro_v3w() {
@@ -52,15 +52,15 @@
 void intro_v3w::introInit() {
 // Hugo 3 - show map and set up for introPlay()
 //#if STORY
-	_vm.file().readBackground(22); // display screen MAP_3w
-	_vm.screen().displayBackground();
+	_vm->_file->readBackground(22); // display screen MAP_3w
+	_vm->_screen->displayBackground();
 	introTicks = 0;
-	_vm.screen().loadFont(0);
+	_vm->_screen->loadFont(0);
 //#endif
 }
 
 bool intro_v3w::introPlay() {
-	byte introSize = _vm.getIntroSize();
+	byte introSize = _vm->getIntroSize();
 
 // Hugo 3 - Preamble screen before going into game.  Draws path of Hugo's plane.
 // Called every tick.  Returns TRUE when complete
@@ -68,20 +68,20 @@
 //#if STORY
 	if (introTicks < introSize) {
 		// Scale viewport x_intro,y_intro to screen (offsetting y)
-		_vm.screen().writeStr(_vm._introX[introTicks], _vm._introY[introTicks] - DIBOFF_Y, "x", _TBRIGHTWHITE);
-		_vm.screen().displayBackground();
+		_vm->_screen->writeStr(_vm->_introX[introTicks], _vm->_introY[introTicks] - DIBOFF_Y, "x", _TBRIGHTWHITE);
+		_vm->_screen->displayBackground();
 
 
 		// Text boxes at various times
 		switch (introTicks) {
 		case 4:
-			Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro1]);
+			Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro1]);
 			break;
 		case 9:
-			Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro2]);
+			Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro2]);
 			break;
 		case 35:
-			Utils::Box(BOX_OK, "%s", _vm._textIntro[kIntro3]);
+			Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro3]);
 			break;
 		}
 	}

Modified: scummvm/trunk/engines/hugo/inventory.cpp
===================================================================
--- scummvm/trunk/engines/hugo/inventory.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/inventory.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -40,12 +40,13 @@
 #include "hugo/mouse.h"
 #include "hugo/inventory.h"
 #include "hugo/parser.h"
+#include "hugo/object.h"
 
 namespace Hugo {
 
 #define MAX_DISP       (XPIX / INV_DX)              // Max icons displayable
 
-InventoryHandler::InventoryHandler(HugoEngine &vm) : _vm(vm) {
+InventoryHandler::InventoryHandler(HugoEngine *vm) : _vm(vm) {
 }
 
 // Construct the inventory scrollbar in dib_i
@@ -57,12 +58,12 @@
 	debugC(1, kDebugInventory, "constructInventory(%d, %d, %d, %d)", imageTotNumb, displayNumb, (scrollFl) ? 0 : 1, firstObjId);
 
 	// Clear out icon buffer
-	memset(_vm.screen().getIconBuffer(), 0, sizeof(_vm.screen().getIconBuffer()));
+	memset(_vm->_screen->getIconBuffer(), 0, sizeof(_vm->_screen->getIconBuffer()));
 
 	// If needed, copy arrows - reduce number of icons displayable
 	if (scrollFl) { // Display at first and last icon positions
-		_vm.screen().moveImage(_vm.screen().getGUIBuffer(), 0, 0, INV_DX, INV_DY, XPIX, _vm.screen().getIconBuffer(), 0, 0, XPIX);
-		_vm.screen().moveImage(_vm.screen().getGUIBuffer(), INV_DX, 0, INV_DX, INV_DY, XPIX, _vm.screen().getIconBuffer(), INV_DX *(MAX_DISP - 1), 0, XPIX);
+		_vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), 0, 0, INV_DX, INV_DY, XPIX, _vm->_screen->getIconBuffer(), 0, 0, XPIX);
+		_vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), INV_DX, 0, INV_DX, INV_DY, XPIX, _vm->_screen->getIconBuffer(), INV_DX *(MAX_DISP - 1), 0, XPIX);
 		displayNumb = MIN(displayNumb, MAX_DISP - NUM_ARROWS);
 	} else  // No, override first index - we can show 'em all!
 		firstObjId = 0;
@@ -71,7 +72,7 @@
 	int16 displayed = 0;
 	int16 carried = 0;
 	for (int16 i = 0; i < imageTotNumb; i++) {
-		if (_vm._objects[_vm._invent[i]].carriedFl) {
+		if (_vm->_object->isCarried(_vm->_invent[i])) {
 			// Check still room to display and past first scroll index
 			if (displayed < displayNumb && carried >= firstObjId) {
 				// Compute source coordinates in dib_u
@@ -83,7 +84,7 @@
 				displayed++;        // Count number displayed
 
 				// Copy the icon
-				_vm.screen().moveImage(_vm.screen().getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _vm.screen().getIconBuffer(), ix, 0, XPIX);
+				_vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _vm->_screen->getIconBuffer(), ix, 0, XPIX);
 			}
 			carried++;                              // Count number carried
 		}
@@ -100,8 +101,8 @@
 	int16 imageNumb;                                // Total number of inventory items
 	int displayNumb;                                // Total number displayed/carried
 	// Compute total number and number displayed, i.e. number carried
-	for (imageNumb = 0, displayNumb = 0; imageNumb < _vm._maxInvent && _vm._invent[imageNumb] != -1; imageNumb++) {
-		if (_vm._objects[_vm._invent[imageNumb]].carriedFl)
+	for (imageNumb = 0, displayNumb = 0; imageNumb < _vm->_maxInvent && _vm->_invent[imageNumb] != -1; imageNumb++) {
+		if (_vm->_object->isCarried(_vm->_invent[imageNumb]))
 			displayNumb++;
 	}
 
@@ -148,8 +149,8 @@
 			if (objId == -1 && i < displayNumb) {
 				// Find objid by counting # carried objects == i+1
 				int16 j;
-				for (j = 0, i++; i > 0 && j < _vm._numObj; j++) {
-					if (_vm._objects[j].carriedFl) {
+				for (j = 0, i++; i > 0 && j < _vm->_numObj; j++) {
+					if (_vm->_object->isCarried(j)) {
 						if (--i == 0)
 							objId = j;
 					}
@@ -162,7 +163,7 @@
 }
 
 void InventoryHandler::runInventory() {
-	status_t &gameStatus = _vm.getGameStatus();
+	status_t &gameStatus = _vm->getGameStatus();
 
 	debugC(1, kDebugInventory, "runInventory");
 
@@ -176,15 +177,15 @@
 			gameStatus.inventoryHeight = 0;
 
 		// Move visible portion to _frontBuffer, restore uncovered portion, display results
-		_vm.screen().moveImage(_vm.screen().getIconBuffer(), 0, 0, XPIX, gameStatus.inventoryHeight, XPIX, _vm.screen().getFrontBuffer(), 0, DIBOFF_Y, XPIX);
-		_vm.screen().moveImage(_vm.screen().getBackBufferBackup(), 0, gameStatus.inventoryHeight + DIBOFF_Y, XPIX, STEP_DY, XPIX, _vm.screen().getFrontBuffer(), 0, gameStatus.inventoryHeight + DIBOFF_Y, XPIX);
-		_vm.screen().displayRect(0, DIBOFF_Y, XPIX, gameStatus.inventoryHeight + STEP_DY);
+		_vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, XPIX, gameStatus.inventoryHeight, XPIX, _vm->_screen->getFrontBuffer(), 0, DIBOFF_Y, XPIX);
+		_vm->_screen->moveImage(_vm->_screen->getBackBufferBackup(), 0, gameStatus.inventoryHeight + DIBOFF_Y, XPIX, STEP_DY, XPIX, _vm->_screen->getFrontBuffer(), 0, gameStatus.inventoryHeight + DIBOFF_Y, XPIX);
+		_vm->_screen->displayRect(0, DIBOFF_Y, XPIX, gameStatus.inventoryHeight + STEP_DY);
 
 		if (gameStatus.inventoryHeight == 0) {      // Finished moving up?
 			// Yes, restore dibs and exit back to game state machine
-			_vm.screen().moveImage(_vm.screen().getBackBufferBackup(), 0, 0, XPIX, YPIX, XPIX, _vm.screen().getBackBuffer(), 0, 0, XPIX);
-			_vm.screen().moveImage(_vm.screen().getBackBuffer(), 0, 0, XPIX, YPIX, XPIX, _vm.screen().getFrontBuffer(), 0, 0, XPIX);
-			_vm.updateImages();                     // Add objects back into display list for restore
+			_vm->_screen->moveImage(_vm->_screen->getBackBufferBackup(), 0, 0, XPIX, YPIX, XPIX, _vm->_screen->getBackBuffer(), 0, 0, XPIX);
+			_vm->_screen->moveImage(_vm->_screen->getBackBuffer(), 0, 0, XPIX, YPIX, XPIX, _vm->_screen->getFrontBuffer(), 0, 0, XPIX);
+			_vm->_object->updateImages();            // Add objects back into display list for restore
 			gameStatus.inventoryState = I_OFF;
 			gameStatus.viewState = V_PLAY;
 		}
@@ -194,9 +195,9 @@
 		// and get any icon/text out of _frontBuffer
 		if (gameStatus.inventoryHeight == 0) {
 			processInventory(INV_INIT);             // Initialize dib_i
-			_vm.screen().displayList(D_RESTORE);    // Restore _frontBuffer
-			_vm.updateImages();                     // Rebuild _frontBuffer without icons/text
-			_vm.screen().displayList(D_DISPLAY);    // Blit display list to screen
+			_vm->_screen->displayList(D_RESTORE);    // Restore _frontBuffer
+			_vm->_object->updateImages();            // Rebuild _frontBuffer without icons/text
+			_vm->_screen->displayList(D_DISPLAY);    // Blit display list to screen
 		}
 
 		gameStatus.inventoryHeight += STEP_DY;      // Move the icon bar down
@@ -204,8 +205,8 @@
 			gameStatus.inventoryHeight = INV_DY;
 
 		// Move visible portion to _frontBuffer, display results
-		_vm.screen().moveImage(_vm.screen().getIconBuffer(), 0, 0, XPIX, gameStatus.inventoryHeight, XPIX, _vm.screen().getFrontBuffer(), 0, DIBOFF_Y, XPIX);
-		_vm.screen().displayRect(0, DIBOFF_Y, XPIX, gameStatus.inventoryHeight);
+		_vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, XPIX, gameStatus.inventoryHeight, XPIX, _vm->_screen->getFrontBuffer(), 0, DIBOFF_Y, XPIX);
+		_vm->_screen->displayRect(0, DIBOFF_Y, XPIX, gameStatus.inventoryHeight);
 
 		if (gameStatus.inventoryHeight == INV_DY) { // Finished moving down?
 			// Yes, prepare view dibs for special inventory display since
@@ -213,17 +214,17 @@
 			// 1. Save backing store _backBuffer in temporary dib_c
 			// 2. Make snapshot of _frontBuffer the new _backBuffer backing store
 			// 3. Reset the display list
-			_vm.screen().moveImage(_vm.screen().getBackBuffer(), 0, 0, XPIX, YPIX, XPIX, _vm.screen().getBackBufferBackup(), 0, 0, XPIX);
-			_vm.screen().moveImage(_vm.screen().getFrontBuffer(), 0, 0, XPIX, YPIX, XPIX, _vm.screen().getBackBuffer(), 0, 0, XPIX);
-			_vm.screen().displayList(D_INIT);
+			_vm->_screen->moveImage(_vm->_screen->getBackBuffer(), 0, 0, XPIX, YPIX, XPIX, _vm->_screen->getBackBufferBackup(), 0, 0, XPIX);
+			_vm->_screen->moveImage(_vm->_screen->getFrontBuffer(), 0, 0, XPIX, YPIX, XPIX, _vm->_screen->getBackBuffer(), 0, 0, XPIX);
+			_vm->_screen->displayList(D_INIT);
 			gameStatus.inventoryState = I_ACTIVE;
 		}
 		break;
 	case I_ACTIVE:                                  // Inventory active
-		_vm.parser().charHandler();                 // Still allow commands
-		_vm.screen().displayList(D_RESTORE);        // Restore previous background
-		_vm.mouse().mouseHandler();                 // Mouse activity - adds to display list
-		_vm.screen().displayList(D_DISPLAY);        // Blit the display list to screen
+		_vm->_parser->charHandler();                 // Still allow commands
+		_vm->_screen->displayList(D_RESTORE);        // Restore previous background
+		_vm->_mouse->mouseHandler();                 // Mouse activity - adds to display list
+		_vm->_screen->displayList(D_DISPLAY);        // Blit the display list to screen
 		break;
 	}
 }

Modified: scummvm/trunk/engines/hugo/inventory.h
===================================================================
--- scummvm/trunk/engines/hugo/inventory.h	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/inventory.h	2010-10-21 17:09:57 UTC (rev 53674)
@@ -40,13 +40,13 @@
 
 class InventoryHandler {
 public:
-	InventoryHandler(HugoEngine &vm);
+	InventoryHandler(HugoEngine *vm);
 
 	int16 processInventory(invact_t action, ...);
 	void runInventory();
 
 private:
-	HugoEngine &_vm;
+	HugoEngine *_vm;
 
 	void constructInventory(int16 imageTotNumb, int displayNumb, bool scrollFl, int16 firstObjId);
 };

Modified: scummvm/trunk/engines/hugo/module.mk
===================================================================
--- scummvm/trunk/engines/hugo/module.mk	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/module.mk	2010-10-21 17:09:57 UTC (rev 53674)
@@ -20,6 +20,7 @@
 	intro_v3w.o \
 	inventory.o \
 	mouse.o \
+	object.o \
 	parser.o \
 	parser_v1w.o \
 	parser_v1d.o \

Modified: scummvm/trunk/engines/hugo/mouse.cpp
===================================================================
--- scummvm/trunk/engines/hugo/mouse.cpp	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/mouse.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -43,6 +43,7 @@
 #include "hugo/inventory.h"
 #include "hugo/route.h"
 #include "hugo/util.h"
+#include "hugo/object.h"
 
 namespace Hugo {
 
@@ -59,24 +60,24 @@
 	kMsExit      = 1
 };
 
-MouseHandler::MouseHandler(HugoEngine &vm) : _vm(vm) {
+MouseHandler::MouseHandler(HugoEngine *vm) : _vm(vm) {
 }
 
 // Shadow-blit supplied string into dib_a at cx,cy and add to display list
 void MouseHandler::cursorText(char *buffer, int16 cx, int16 cy, uif_t fontId, int16 color) {
 	debugC(1, kDebugMouse, "cursorText(%s, %d, %d, %d, %d)", buffer, cx, cy, fontId, color);
 
-	_vm.screen().loadFont(fontId);
+	_vm->_screen->loadFont(fontId);
 
 	// Find bounding rect for string
-	int16 sdx = _vm.screen().stringLength(buffer);
-	int16 sdy = _vm.screen().fontHeight() + 1;                      // + 1 for shadow
+	int16 sdx = _vm->_screen->stringLength(buffer);
+	int16 sdy = _vm->_screen->fontHeight() + 1;                      // + 1 for shadow
 	int16 sx  = (cx < XPIX / 2) ? cx + SX_OFF : cx - sdx - SX_OFF / 2;
 	int16 sy  = cy + SY_OFF;
 
 	// Display the string and add rect to display list
-	_vm.screen().shadowStr(sx, sy, buffer, _TBRIGHTWHITE);
-	_vm.screen().displayList(D_ADD, sx, sy, sdx, sdy);
+	_vm->_screen->shadowStr(sx, sy, buffer, _TBRIGHTWHITE);
+	_vm->_screen->displayList(D_ADD, sx, sy, sdx, sdy);
 }
 
 // Find the exit hotspot containing cx, cy.
@@ -85,8 +86,8 @@
 	debugC(2, kDebugMouse, "findExit(%d, %d)", cx, cy);
 
 	int i = 0;
-	for (hotspot_t *hotspot = _vm._hotspots; hotspot->screenIndex >= 0; i++, hotspot++) {
-		if (hotspot->screenIndex == *_vm._screen_p) {
+	for (hotspot_t *hotspot = _vm->_hotspots; hotspot->screenIndex >= 0; i++, hotspot++) {
+		if (hotspot->screenIndex == *_vm->_screen_p) {
 			if (cx >= hotspot->x1 && cx <= hotspot->x2 && cy >= hotspot->y1 && cy <= hotspot->y2)
 				return i;
 		}
@@ -98,9 +99,9 @@
 void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
 	debugC(1, kDebugMouse, "Process_rclick(%d, %d, %d)", objId, cx, cy);
 
-	status_t &gameStatus = _vm.getGameStatus();
+	status_t &gameStatus = _vm->getGameStatus();
 
-	if (gameStatus.storyModeFl || _vm._hero->pathType == QUIET)     // Make sure user has control
+	if (gameStatus.storyModeFl || _vm->_hero->pathType == QUIET)     // Make sure user has control
 		return;
 
 	bool foundFl = false;                           // TRUE if route found to object
@@ -111,26 +112,26 @@
 		else if (gameStatus.inventoryObjId == objId)
 			gameStatus.inventoryObjId = -1;         // Same icon - deselect it
 		else
-			_vm.useObject(objId);                   // Use status.objid on object
+			_vm->_object->useObject(objId);                   // Use status.objid on object
 	} else {                                        // Clicked over viewport object
-		object_t *obj = &_vm._objects[objId];
+		object_t *obj = &_vm->_object->_objects[objId];
 		int16 x, y;
 		switch (obj->viewx) {                       // Where to walk to
 		case -1:                                    // Walk to object position
-			if (_vm.findObjectSpace(obj, &x, &y))
-				foundFl = _vm.route().startRoute(GO_GET, objId, x, y);
+			if (_vm->findObjectSpace(obj, &x, &y))
+				foundFl = _vm->_route->startRoute(GO_GET, objId, x, y);
 			if (!foundFl)                           // Can't get there, try to use from here
-				_vm.useObject(objId);
+				_vm->_object->useObject(objId);
 			break;
 		case 0:                                     // Immediate use
-			_vm.useObject(objId);                   // Pick up or use object
+			_vm->_object->useObject(objId);          // Pick up or use object
 			break;
 		default:                                    // Walk to view point if possible
-			if (!_vm.route().startRoute(GO_GET, objId, obj->viewx, obj->viewy)) {
-				if (_vm._hero->cycling == INVISIBLE)// If invisible do
-					_vm.useObject(objId);           // immediate use
+			if (!_vm->_route->startRoute(GO_GET, objId, obj->viewx, obj->viewy)) {
+				if (_vm->_hero->cycling == INVISIBLE)// If invisible do
+					_vm->_object->useObject(objId);           // immediate use
 				else
-					Utils::Box(BOX_ANY, "%s", _vm._textMouse[kMsNoWayText]);      // Can't get there
+					Utils::Box(BOX_ANY, "%s", _vm->_textMouse[kMsNoWayText]);      // Can't get there
 			}
 			break;
 		}
@@ -149,41 +150,41 @@
 	int16 i, x, y;
 	object_t *obj;
 
-	status_t &gameStatus = _vm.getGameStatus();
+	status_t &gameStatus = _vm->getGameStatus();
 
-	if (gameStatus.storyModeFl || _vm._hero->pathType == QUIET)     // Make sure user has control
+	if (gameStatus.storyModeFl || _vm->_hero->pathType == QUIET)     // Make sure user has control
 		return;
 
 	switch (objId) {
 	case -1:                                        // Empty space - attempt to walk there
-		_vm.route().startRoute(GO_SPACE, 0, cx, cy);
+		_vm->_route->startRoute(GO_SPACE, 0, cx, cy);
 		break;
 	case LEFT_ARROW:                                // A scroll arrow - scroll the iconbar
 	case RIGHT_ARROW:
 		// Scroll the iconbar and display results
-		_vm.inventory().processInventory((objId == LEFT_ARROW) ? INV_LEFT : INV_RIGHT);
-		_vm.screen().moveImage(_vm.screen().getIconBuffer(), 0, 0, XPIX, INV_DY, XPIX, _vm.screen().getFrontBuffer(), 0, DIBOFF_Y, XPIX);
-		_vm.screen().moveImage(_vm.screen().getIconBuffer(), 0, 0, XPIX, INV_DY, XPIX, _vm.screen().getBackBuffer(), 0, DIBOFF_Y, XPIX);
-		_vm.screen().displayList(D_ADD, 0, DIBOFF_Y, XPIX, INV_DY);
+		_vm->_inventory->processInventory((objId == LEFT_ARROW) ? INV_LEFT : INV_RIGHT);
+		_vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, XPIX, INV_DY, XPIX, _vm->_screen->getFrontBuffer(), 0, DIBOFF_Y, XPIX);
+		_vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, XPIX, INV_DY, XPIX, _vm->_screen->getBackBuffer(), 0, DIBOFF_Y, XPIX);
+		_vm->_screen->displayList(D_ADD, 0, DIBOFF_Y, XPIX, INV_DY);
 		break;
 	case EXIT_HOTSPOT:                              // Walk to exit hotspot
 		i = findExit(cx, cy);
-		x = _vm._hotspots[i].viewx;
-		y = _vm._hotspots[i].viewy;
+		x = _vm->_hotspots[i].viewx;
+		y = _vm->_hotspots[i].viewy;
 		if (x >= 0) {                               // Hotspot refers to an exit
 			// Special case of immediate exit
 			if (gameStatus.jumpExitFl) {
 				// Get rid of iconbar if necessary
 				if (gameStatus.inventoryState != I_OFF)
 					gameStatus.inventoryState = I_UP;
-				_vm.scheduler().insertActionList(_vm._hotspots[i].actIndex);
+				_vm->_scheduler->insertActionList(_vm->_hotspots[i].actIndex);
 			} else {    // Set up route to exit spot
-				if (_vm._hotspots[i].direction == Common::KEYCODE_RIGHT)
+				if (_vm->_hotspots[i].direction == Common::KEYCODE_RIGHT)
 					x -= HERO_MAX_WIDTH;
-				else if (_vm._hotspots[i].direction == Common::KEYCODE_LEFT)
+				else if (_vm->_hotspots[i].direction == Common::KEYCODE_LEFT)
 					x += HERO_MAX_WIDTH;
-				if (!_vm.route().startRoute(GO_EXIT, i, x, y))
-					Utils::Box(BOX_ANY, "%s", _vm._textMouse[kMsNoWayText]);      // Can't get there
+				if (!_vm->_route->startRoute(GO_EXIT, i, x, y))
+					Utils::Box(BOX_ANY, "%s", _vm->_textMouse[kMsNoWayText]);      // Can't get there
 			}
 
 			// Get rid of any attached icon
@@ -191,29 +192,29 @@
 		}
 		break;
 	default:                                        // Look at an icon or object
-		obj = &_vm._objects[objId];
+		obj = &_vm->_object->_objects[objId];
 
 		// Over iconbar - immediate description
 		if (gameStatus.inventoryState == I_ACTIVE && cy < INV_DY + DIBOFF_Y)
-			_vm.lookObject(obj);
+			_vm->_object->lookObject(obj);
 		else {
 			bool foundFl = false;                   // TRUE if route found to object
 			switch (obj->viewx) {                   // Clicked over viewport object
 			case -1:                                // Walk to object position
-				if (_vm.findObjectSpace(obj, &x, &y))
-					foundFl = _vm.route().startRoute(GO_LOOK, objId, x, y);
+				if (_vm->findObjectSpace(obj, &x, &y))
+					foundFl = _vm->_route->startRoute(GO_LOOK, objId, x, y);
 				if (!foundFl)                       // Can't get there, immediate description
-					_vm.lookObject(obj);
+					_vm->_object->lookObject(obj);
 				break;
 			case 0:                                 // Immediate description
-				_vm.lookObject(obj);
+				_vm->_object->lookObject(obj);
 				break;
 			default:                                // Walk to view point if possible
-				if (!_vm.route().startRoute(GO_LOOK, objId, obj->viewx, obj->viewy)) {
-					if (_vm._hero->cycling == INVISIBLE)    // If invisible do
-						_vm.lookObject(obj);        // immediate decription
+				if (!_vm->_route->startRoute(GO_LOOK, objId, obj->viewx, obj->viewy)) {
+					if (_vm->_hero->cycling == INVISIBLE)    // If invisible do
+						_vm->_object->lookObject(obj);       // immediate decription
 					else
-						Utils::Box(BOX_ANY, "%s", _vm._textMouse[kMsNoWayText]);  // Can't get there
+						Utils::Box(BOX_ANY, "%s", _vm->_textMouse[kMsNoWayText]);  // Can't get there
 				}
 				break;
 			}
@@ -226,10 +227,10 @@
 void MouseHandler::mouseHandler() {
 	debugC(2, kDebugMouse, "mouseHandler");
 
-	int16 cx = _vm.getMouseX();
-	int16 cy = _vm.getMouseY();
+	int16 cx = _vm->getMouseX();
+	int16 cy = _vm->getMouseY();
 
-	status_t &gameStatus = _vm.getGameStatus();
+	status_t &gameStatus = _vm->getGameStatus();
 
 	gameStatus.cx = cx;                             // Save cursor coords
 	gameStatus.cy = cy;
@@ -242,8 +243,8 @@
 	if (gameStatus.inventoryObjId != -1) {
 		// Find index of icon
 		int16 iconId;                               // Find index of dragged icon
-		for (iconId = 0; iconId < _vm._maxInvent; iconId++) {
-			if (gameStatus.inventoryObjId == _vm._invent[iconId])
+		for (iconId = 0; iconId < _vm->_maxInvent; iconId++) {
+			if (gameStatus.inventoryObjId == _vm->_invent[iconId])
 				break;
 		}
 
@@ -260,20 +261,20 @@
 		icony = MIN(icony, YPIX - INV_DY);
 
 		// Copy the icon and add to display list
-		_vm.screen().moveImage(_vm.screen().getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _vm.screen().getFrontBuffer(), iconx, icony, XPIX);
-		_vm.screen().displayList(D_ADD, iconx, icony, INV_DX, INV_DY);
+		_vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _vm->_screen->getFrontBuffer(), iconx, icony, XPIX);
+		_vm->_screen->displayList(D_ADD, iconx, icony, INV_DX, INV_DY);
 	}
 
 	int16 objId = -1;                               // Current source object
 	// Process cursor over an object or icon
 	if (gameStatus.inventoryState == I_ACTIVE)      // Check inventory icon bar first
-		objId = _vm.inventory().processInventory(INV_GET, cx, cy);
+		objId = _vm->_inventory->processInventory(INV_GET, cx, cy);
 	if (objId == -1)                                // No match, check rest of view
-		objId = _vm.findObject(cx, cy);
+		objId = _vm->_object->findObject(cx, cy);
 	if (objId >= 0) {                               // Got a match
 		// Display object name next to cursor (unless CURSOR_NOCHAR)
 		// Note test for swapped hero name
-		char *name = _vm._arrayNouns[_vm._objects[(objId == HERO) ? _vm._heroImage : objId].nounIndex][CURSOR_NAME];
+		char *name = _vm->_arrayNouns[_vm->_object->_objects[(objId == HERO) ? _vm->_heroImage : objId].nounIndex][CURSOR_NAME];
 		if (name[0] != CURSOR_NOCHAR)
 			cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE);
 
@@ -285,9 +286,9 @@
 	// Process cursor over an exit hotspot
 	if (objId == -1) {
 		int i = findExit(cx, cy);
-		if (i != -1 && _vm._hotspots[i].viewx >= 0) {
+		if (i != -1 && _vm->_hotspots[i].viewx >= 0) {
 			objId = EXIT_HOTSPOT;
-			cursorText(_vm._textMouse[kMsExit], cx, cy, U_FONT8, _TBRIGHTWHITE);
+			cursorText(_vm->_textMouse[kMsExit], cx, cy, U_FONT8, _TBRIGHTWHITE);
 		}
 	}
 

Modified: scummvm/trunk/engines/hugo/mouse.h
===================================================================
--- scummvm/trunk/engines/hugo/mouse.h	2010-10-21 13:13:56 UTC (rev 53673)
+++ scummvm/trunk/engines/hugo/mouse.h	2010-10-21 17:09:57 UTC (rev 53674)
@@ -36,12 +36,12 @@
 
 class MouseHandler {
 public:
-	MouseHandler(HugoEngine &vm);
+	MouseHandler(HugoEngine *vm);
 
 	void mouseHandler();
 
 private:
-	HugoEngine &_vm;
+	HugoEngine *_vm;
 
 	void  cursorText(char *buffer, int16 cx, int16 cy, uif_t fontId, int16 color);
 	int16 findExit(int16 cx, int16 cy);

Added: scummvm/trunk/engines/hugo/object.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object.cpp	                        (rev 0)
+++ scummvm/trunk/engines/hugo/object.cpp	2010-10-21 17:09:57 UTC (rev 53674)
@@ -0,0 +1,695 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+/*
+ * This code is based on original Hugo Trilogy source code
+ *
+ * Copyright (c) 1989-1995 David P. Gray
+ *
+ */
+
+#include "common/system.h"
+#include "common/random.h"
+
+#include "hugo/game.h"
+#include "hugo/hugo.h"
+#include "hugo/object.h"

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list