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

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Thu Feb 3 19:25:39 CET 2011


Revision: 55758
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55758&view=rev
Author:   strangerke
Date:     2011-02-03 18:25:38 +0000 (Thu, 03 Feb 2011)

Log Message:
-----------
HUGO: Suppress static variables (except one)

This also fixes the multiple-RTL related music bug reported by D. Gray

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/file.cpp
    scummvm/trunk/engines/hugo/file.h
    scummvm/trunk/engines/hugo/file_v2d.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/inventory.cpp
    scummvm/trunk/engines/hugo/inventory.h
    scummvm/trunk/engines/hugo/object_v1d.cpp
    scummvm/trunk/engines/hugo/parser.cpp
    scummvm/trunk/engines/hugo/parser.h
    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/sound.cpp
    scummvm/trunk/engines/hugo/sound.h

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/display.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -42,11 +42,31 @@
 #include "hugo/object.h"
 
 namespace Hugo {
-Screen::Screen(HugoEngine *vm) : _vm(vm), _mainPalette(0), _curPalette(0) {
+Screen::Screen(HugoEngine *vm) : _vm(vm) {
+	_mainPalette = 0;
+	_curPalette = 0;
 	for (int i = 0; i < kNumFonts; i++) {
 		_arrayFont[i] = 0;
 		fontLoadedFl[i] = false;
 	}
+	for (int i = 0; i < kBlitListSize; i++) {
+		_dlBlistList[i].x = 0;
+		_dlBlistList[i].y = 0;
+		_dlBlistList[i].dx = 0;
+		_dlBlistList[i].dy = 0;
+	}
+	for (int i = 0; i < kRectListSize; i++) {
+		_dlRestoreList[i].x = 0;
+		_dlRestoreList[i].y = 0;
+		_dlRestoreList[i].dx = 0;
+		_dlRestoreList[i].dy = 0;
+	}
+	for (int i = 0; i < kRectListSize; i++) {
+		_dlAddList[i].x = 0;
+		_dlAddList[i].y = 0;
+		_dlAddList[i].dx = 0;
+		_dlAddList[i].dy = 0;
+	}
 }
 
 Screen::~Screen() {
@@ -58,7 +78,7 @@
 void Screen::createPal() {
 	debugC(1, kDebugDisplay, "createPal");
 
-	g_system->setPalette(_mainPalette, 0, kNumColors);
+	g_system->setPalette(_mainPalette, 0, _paletteSize / 4);
 }
 
 void Screen::setCursorPal() {
@@ -290,32 +310,28 @@
 void Screen::displayList(dupdate_t update, ...) {
 	debugC(6, kDebugDisplay, "displayList()");
 
-	static int16  addIndex, restoreIndex;           // Index into add/restore lists
-	static rect_t restoreList[kRectListSize];       // The restore list
-	static rect_t addList[kRectListSize];           // The add list
-	static rect_t blistList[kBlitListSize];         // The blit list
 	int16         blitLength = 0;                   // Length of blit list
 	va_list       marker;                           // Args used for D_ADD operation
 	rect_t       *p;                                // Ptr to dlist entry
 
 	switch (update) {
 	case kDisplayInit:                              // Init lists, restore whole screen
-		addIndex = restoreIndex = 0;
+		_dlAddIndex = _dlRestoreIndex = 0;
 		memcpy(_frontBuffer, _backBuffer, sizeof(_frontBuffer));
 		break;
 	case kDisplayAdd:                               // Add a rectangle to list
-		if (addIndex >= kRectListSize) {
+		if (_dlAddIndex >= kRectListSize) {
 			warning("Display list exceeded");
 			return;
 		}
 		va_start(marker, update);                   // Initialize variable arguments
-		p = &addList[addIndex];
+		p = &_dlAddList[_dlAddIndex];
 		p->x  = va_arg(marker, int);                // x
 		p->y  = va_arg(marker, int);                // y
 		p->dx = va_arg(marker, int);                // dx
 		p->dy = va_arg(marker, int);                // dy
 		va_end(marker);                             // Reset variable arguments
-		addIndex++;
+		_dlAddIndex++;
 		break;
 	case kDisplayDisplay:                           // Display whole list
 		// Don't blit if newscreen just loaded because _frontBuffer will
@@ -327,22 +343,22 @@
 		}
 
 		// Coalesce restore-list, add-list into combined blit-list
-		blitLength = mergeLists(restoreList, blistList, restoreIndex, blitLength);
-		blitLength = mergeLists(addList, blistList, addIndex,  blitLength);
+		blitLength = mergeLists(_dlRestoreList, _dlBlistList, _dlRestoreIndex, blitLength);
+		blitLength = mergeLists(_dlAddList, _dlBlistList, _dlAddIndex, blitLength);
 
 		// Blit the combined blit-list
-		for (restoreIndex = 0, p = blistList; restoreIndex < blitLength; restoreIndex++, p++) {
+		for (_dlRestoreIndex = 0, p = _dlBlistList; _dlRestoreIndex < blitLength; _dlRestoreIndex++, p++) {
 			if (p->dx)                              // Marks a used entry
 				displayRect(p->x, p->y, p->dx, p->dy);
 		}
 		break;
 	case kDisplayRestore:                           // Restore each rectangle
-		for (restoreIndex = 0, p = addList; restoreIndex < addIndex; restoreIndex++, p++) {
+		for (_dlRestoreIndex = 0, p = _dlAddList; _dlRestoreIndex < _dlAddIndex; _dlRestoreIndex++, p++) {
 			// Restoring from _backBuffer to _frontBuffer
-			restoreList[restoreIndex] = *p;         // Copy add-list to restore-list
+			_dlRestoreList[_dlRestoreIndex] = *p;   // Copy add-list to restore-list
 			moveImage(_backBuffer, p->x, p->y, p->dx, p->dy, kXPix, _frontBuffer, p->x, p->y, kXPix);
 		}
-		addIndex = 0;                               // Reset add-list
+		_dlAddIndex = 0;                            // Reset add-list
 		break;
 	}
 }
@@ -376,10 +392,10 @@
 /**
 * Returns height of characters in current font
 */
-int16 Screen::fontHeight() {
+int16 Screen::fontHeight() const {
 	debugC(2, kDebugDisplay, "fontHeight()");
 
-	static int16 height[kNumFonts] = {5, 7, 8};
+	static const int16 height[kNumFonts] = {5, 7, 8};
 	return height[_fnt - kFirstFont];
 }
 

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/display.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -90,16 +90,16 @@
 	virtual void loadFont(int16 fontId) = 0;
 	virtual void loadFontArr(Common::File &in) = 0;
 
-	int16    fontHeight();
+	int16    fontHeight() const;
 	int16    stringLength(const char *s) const;
 
 	void     displayBackground();
-	void     displayFrame(int sx, int sy, seq_t *seq, bool foreFl);
+	void     displayFrame(const int sx, const int sy, seq_t *seq, const bool foreFl);
 	void     displayList(dupdate_t update, ...);
-	void     displayRect(int16 x, int16 y, int16 dx, int16 dy);
+	void     displayRect(const int16 x, const int16 y, const int16 dx, const int16 dy);
 	void     drawHotspots();
-	void     drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2, int color);
-	void     drawShape(int x, int y, int color1, int color2);
+	void     drawRectangle(const bool filledFl, const int16 x1, const int16 y1, const int16 x2, const int16 y2, const int color);
+	void     drawShape(const int x, const int y, const int color1, const int color2);
 	void     drawStatusText();
 	void     freeFonts();
 	void     freePalette();
@@ -107,14 +107,14 @@
 	void     initDisplay();
 	void     initNewScreenDisplay();
 	void     loadPalette(Common::File &in);
-	void     moveImage(image_pt srcImage, int16 x1, int16 y1, int16 dx, int16 dy, int16 width1, image_pt dstImage, int16 x2, int16 y2, int16 width2);
+	void     moveImage(image_pt srcImage, const int16 x1, const int16 y1, const int16 dx, int16 dy, const int16 width1, image_pt dstImage, const int16 x2, const int16 y2, const int16 width2);
 	void     remapPal(uint16 oldIndex, uint16 newIndex);
 	void     resetInventoryObjId();
 	void     restorePal(Common::SeekableReadStream *f);
 	void     savePal(Common::WriteStream *f) const;
 	void     setBackgroundColor(const uint16 color);
 	void     setCursorPal();
-	void     selectInventoryObjId(int16 objId);
+	void     selectInventoryObjId(const int16 objId);
 	void     shadowStr(int16 sx, const int16 sy, const char *s, const byte color);
 	void     showCursor();
 	void     userHelp() const;
@@ -174,9 +174,16 @@
 
 	viewdib_t _frontBuffer;
 	viewdib_t _backBuffer;
-	viewdib_t _GUIBuffer;                           // User interface images
-	viewdib_t _backBufferBackup;                    // Backup _backBuffer during inventory
+	viewdib_t _GUIBuffer;                              // User interface images
+	viewdib_t _backBufferBackup;                       // Backup _backBuffer during inventory
 
+	// Formerly static variables used by displayList()
+	int16  _dlAddIndex, _dlRestoreIndex;               // Index into add/restore lists
+	rect_t _dlRestoreList[kRectListSize];              // The restore list
+	rect_t _dlAddList[kRectListSize];                  // The add list
+	rect_t _dlBlistList[kBlitListSize];                // The blit list
+	//
+
 	void createPal();
 	void merge(const rect_t *rectA, rect_t *rectB);
 	void writeChr(const int sx, const int sy, const byte color, const char *local_fontdata);

Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/file.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -46,6 +46,8 @@
 
 namespace Hugo {
 FileManager::FileManager(HugoEngine *vm) : _vm(vm) {
+	has_read_header = false;
+	firstUIFFl = true; 
 }
 
 FileManager::~FileManager() {
@@ -55,7 +57,7 @@
 * Convert 4 planes (RGBI) data to 8-bit DIB format
 * Return original plane data ptr
 */
-byte *FileManager::convertPCC(byte *p, const uint16 y, const uint16 bpl, image_pt dataPtr) const{
+byte *FileManager::convertPCC(byte *p, const uint16 y, const uint16 bpl, image_pt dataPtr) const {
 	debugC(2, kDebugFile, "convertPCC(byte *p, %d, %d, image_pt data_p)", y, bpl);
 
 	dataPtr += y * bpl * 8;                         // Point to correct DIB line
@@ -79,7 +81,6 @@
 	debugC(1, kDebugFile, "readPCX(..., %s)", name);
 
 	// Read in the PCC header and check consistency
-	static PCC_header_t PCC_header;
 	PCC_header.mfctr = f.readByte();
 	PCC_header.vers = f.readByte();
 	PCC_header.enc = f.readByte();
@@ -179,7 +180,7 @@
 		}
 	}
 
-	bool  firstFl = true;                           // Initializes pcx read function
+	bool  firstImgFl = true;                        // Initializes pcx read function
 	seq_t *seqPtr = 0;                              // Ptr to sequence structure
 
 	// Now read the images into an images list
@@ -187,12 +188,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->_text->getNoun(objPtr->nounIndex, 0));
+				seqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->nounIndex, 0));
 				objPtr->seqList[j].seqPtr = seqPtr;
-				firstFl = false;
+				firstImgFl = false;
 			} else {                                // Subsequent image
 				// Read this image - allocate both seq and image memory
-				seqPtr->nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstFl, _vm->_text->getNoun(objPtr->nounIndex, 0));
+				seqPtr->nextSeqPtr = readPCX(_objectsArchive, 0, 0, firstImgFl, _vm->_text->getNoun(objPtr->nounIndex, 0));
 				seqPtr = seqPtr->nextSeqPtr;
 			}
 
@@ -261,10 +262,6 @@
 		return 0;
 	}
 
-	// If this is the first call, read the lookup table
-	static bool has_read_header = false;
-	static sound_hdr_t s_hdr[kMaxSounds];           // Sound lookup table
-
 	if (!has_read_header) {
 		if (fp.read(s_hdr, sizeof(s_hdr)) != sizeof(s_hdr))
 			error("Wrong sound file format");
@@ -605,12 +602,9 @@
 uif_hdr_t *FileManager::getUIFHeader(const uif_t id) {
 	debugC(1, kDebugFile, "getUIFHeader(%d)", id);
 
-	static bool firstFl = true;
-	static uif_hdr_t UIFHeader[kMaxUifs];           // Lookup for uif fonts/images
-
 	// Initialize offset lookup if not read yet
-	if (firstFl) {
-		firstFl = false;
+	if (firstUIFFl) {
+		firstUIFFl = false;
 		// Open unbuffered to do far read
 		Common::File ip;                            // Image data file
 		if (!ip.open(getUifFilename()))

Modified: scummvm/trunk/engines/hugo/file.h
===================================================================
--- scummvm/trunk/engines/hugo/file.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/file.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -55,12 +55,12 @@
 	bool     saveGame(const int16 slot, const Common::String descrip);
 
 	// Name scenery and objects picture databases
-	const char *getBootFilename()    { return "HUGO.BSF";    }
-	const char *getObjectFilename()  { return "objects.dat"; }
-	const char *getSceneryFilename() { return "scenery.dat"; }
-	const char *getSoundFilename()   { return "sounds.dat";  }
-	const char *getStringFilename()  { return "strings.dat"; }
-	const char *getUifFilename()     { return "uif.dat";     }
+	const char *getBootFilename() const    { return "HUGO.BSF";    }
+	const char *getObjectFilename() const  { return "objects.dat"; }
+	const char *getSceneryFilename() const { return "scenery.dat"; }
+	const char *getSoundFilename() const   { return "sounds.dat";  }
+	const char *getStringFilename() const  { return "strings.dat"; }
+	const char *getUifFilename() const     { return "uif.dat";     }
 
 	virtual void openDatabaseFiles() = 0;
 	virtual void closeDatabaseFiles() = 0;
@@ -92,13 +92,34 @@
 		uint32 ob_len;
 	};
 
+	static const int kNumColors = 16;               // Num colors to save in palette
+
+	struct PCC_header_t {                           // Structure of PCX file header
+		byte   mfctr, vers, enc, bpx;
+		uint16  x1, y1, x2, y2;                     // bounding box
+		uint16  xres, yres;
+		byte   palette[3 * kNumColors];             // EGA color palette
+		byte   vmode, planes;
+		uint16 bytesPerLine;                        // Bytes per line
+		byte   fill2[60];
+	};                                              // Header of a PCC file
+
+	bool firstUIFFl;
+	uif_hdr_t UIFHeader[kMaxUifs];                  // Lookup for uif fonts/images
+
 	Common::File _stringArchive;                    // Handle for string file
 	Common::File _sceneryArchive1;                  // Handle for scenery file
 	Common::File _objectsArchive;                   // Handle for objects file
 
+	PCC_header_t PCC_header;
+
 	seq_t *readPCX(Common::File &f, seq_t *seqPtr, byte *imagePtr, const bool firstFl, const char *name);
 	const char *getBootCypher() const;
 
+	// If this is the first call, read the lookup table
+	bool has_read_header;
+	sound_hdr_t s_hdr[kMaxSounds];                  // Sound lookup table
+
 private:
 	byte *convertPCC(byte *p, const uint16 y, const uint16 bpl, image_pt dataPtr) const;
 	uif_hdr_t *getUIFHeader(const uif_t id);
@@ -130,6 +151,8 @@
 	virtual void readBackground(const int screenIndex);
 	virtual void readOverlay(const int screenNum, image_pt image, ovl_t overlayType);
 	char *fetchString(const int index);
+private:
+	char *_fetchStringBuf;
 };
 
 class FileManager_v3d : public FileManager_v2d {

Modified: scummvm/trunk/engines/hugo/file_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v2d.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/file_v2d.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -41,9 +41,11 @@
 
 namespace Hugo {
 FileManager_v2d::FileManager_v2d(HugoEngine *vm) : FileManager_v1d(vm) {
+	_fetchStringBuf = (char *)malloc(kMaxBoxChar);
 }
 
 FileManager_v2d::~FileManager_v2d() {
+	free(_fetchStringBuf);
 }
 
 /**
@@ -163,7 +165,6 @@
 */
 char *FileManager_v2d::fetchString(const int index) {
 	debugC(1, kDebugFile, "fetchString(%d)", index);
-	static char buffer[kMaxBoxChar];
 
 	// Get offset to string[index] (and next for length calculation)
 	_stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
@@ -179,13 +180,13 @@
 
 	// Position to string and read it into gen purpose _textBoxBuffer
 	_stringArchive.seek(off1, SEEK_SET);
-	if (_stringArchive.read(buffer, (uint16)(off2 - off1)) == 0)
+	if (_stringArchive.read(_fetchStringBuf, (uint16)(off2 - off1)) == 0)
 		error("An error has occurred: fetchString");
 
 	// Null terminate, decode and return it
-	buffer[off2-off1] = '\0';
-	_vm->_scheduler->decodeString(buffer);
-	return buffer;
+	_fetchStringBuf[off2-off1] = '\0';
+	_vm->_scheduler->decodeString(_fetchStringBuf);
+	return _fetchStringBuf;
 }
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -62,8 +62,7 @@
 	_arrayReqs(0), _hotspots(0), _invent(0), _uses(0), _catchallList(0), _backgroundObjects(0),	_points(0), _cmdList(0), 
 	_screenActs(0), _hero(0), _heroImage(0), _defltTunes(0), _introX(0), _introY(0), _maxInvent(0), _numBonuses(0),
 	_numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _score(0), _maxscore(0),
-	_backgroundObjectsSize(0), _screenActsSize(0), _usesSize(0)
-
+	_backgroundObjectsSize(0), _screenActsSize(0), _usesSize(0), _lastTime(0), _curTime(0)
 {
 	_system = syst;
 	DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level");
@@ -305,9 +304,6 @@
 * Hugo game state machine - called during onIdle
 */
 void HugoEngine::runMachine() {
-	static uint32 lastTime;
-	uint32 curTime;
-
 	status_t &gameStatus = getGameStatus();
 	// Don't process if we're in a textbox
 	if (gameStatus.textBoxFl)
@@ -317,13 +313,13 @@
 	if (gameStatus.gameOverFl)
 		return;
 
-	curTime = g_system->getMillis();
+	_curTime = g_system->getMillis();
 	// Process machine once every tick
-	while (curTime - lastTime < (uint32)(1000 / getTPS())) {
+	while (_curTime - _lastTime < (uint32)(1000 / getTPS())) {
 		g_system->delayMillis(5);
-		curTime = g_system->getMillis();
+		_curTime = g_system->getMillis();
 	}
-	lastTime = curTime;
+	_lastTime = _curTime;
 
 	switch (gameStatus.viewState) {
 	case kViewIdle:                                 // Not processing state machine

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/hugo.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -82,21 +82,10 @@
 static const int kMaxPath = 256;                    // Max length of a full path name
 static const int kHeroMaxWidth = 24;                // Maximum width of hero
 static const int kHeroMinWidth = 16;                // Minimum width of hero
-static const int kNumColors = 16;                   // Num colors to save in palette
 
 typedef char fpath_t[kMaxPath];                     // File path
 typedef char command_t[kMaxLineSize + 8];           // Command line (+spare for prompt,cursor)
 
-struct PCC_header_t {                               // Structure of PCX file header
-	byte   mfctr, vers, enc, bpx;
-	uint16  x1, y1, x2, y2;                         // bounding box
-	uint16  xres, yres;
-	byte   palette[3 * kNumColors];                 // EGA color palette
-	byte   vmode, planes;
-	uint16 bytesPerLine;                            // Bytes per line
-	byte   fill2[60];
-};                                                  // Header of a PCC file
-
 struct config_t {                                   // User's config (saved)
 	bool musicFl;                                   // State of Music button/menu item
 	bool soundFl;                                   // State of Sound button/menu item
@@ -424,6 +413,8 @@
 	int _mouseY;
 	byte _introXSize;
 	status_t _status;                               // Game status structure
+	uint32 _lastTime;
+	uint32 _curTime;
 
 	static HugoEngine *s_Engine;
 

Modified: scummvm/trunk/engines/hugo/intro.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/intro.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -57,6 +57,7 @@
 }
 
 void intro_v1d::introInit() {
+	_introState = 0;
 	introTicks = 0;
 	surf.w = 320;
 	surf.h = 200;
@@ -66,14 +67,13 @@
 }
 
 bool intro_v1d::introPlay() {
-	static int state = 0;
 	byte introSize = _vm->getIntroSize();
 
 	if (_vm->getGameStatus().skipIntroFl)
 		return true;
 
 	if (introTicks < introSize) {
-		switch (state++) {
+		switch (_introState++) {
 		case 0:
 			_vm->_screen->drawRectangle(true, 0, 0, 319, 199, _TMAGENTA);
 			_vm->_screen->drawRectangle(true, 10, 10, 309, 189, _TBLACK);

Modified: scummvm/trunk/engines/hugo/intro.h
===================================================================
--- scummvm/trunk/engines/hugo/intro.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/intro.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -77,6 +77,8 @@
 	void preNewGame();
 	void introInit();
 	bool introPlay();
+private:
+	int _introState;
 };
 
 class intro_v2w : public IntroHandler {

Modified: scummvm/trunk/engines/hugo/inventory.cpp
===================================================================
--- scummvm/trunk/engines/hugo/inventory.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/inventory.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -47,6 +47,7 @@
 static const int kMaxDisp = (kXPix / kInvDx);       // Max icons displayable
 
 InventoryHandler::InventoryHandler(HugoEngine *vm) : _vm(vm) {
+	_firstIconId = 0;
 }
 
 /**
@@ -100,8 +101,6 @@
 int16 InventoryHandler::processInventory(const invact_t action, ...) {
 	debugC(1, kDebugInventory, "processInventory(invact_t action, ...)");
 
-	static int16 firstIconId = 0;                   // Index of first icon to display
-
 	int16 imageNumb;                                // Total number of inventory items
 	int displayNumb;                                // Total number displayed/carried
 	// Compute total number and number displayed, i.e. number carried
@@ -118,15 +117,15 @@
 
 	switch (action) {
 	case kInventoryActionInit:                      // Initialize inventory display
-		constructInventory(imageNumb, displayNumb, scrollFl, firstIconId);
+		constructInventory(imageNumb, displayNumb, scrollFl, _firstIconId);
 		break;
 	case kInventoryActionLeft:                      // Scroll left by one icon
-		firstIconId = MAX(0, firstIconId - 1);
-		constructInventory(imageNumb, displayNumb, scrollFl, firstIconId);
+		_firstIconId = MAX(0, _firstIconId - 1);
+		constructInventory(imageNumb, displayNumb, scrollFl, _firstIconId);
 		break;
 	case kInventoryActionRight:                     // Scroll right by one icon
-		firstIconId = MIN(displayNumb, firstIconId + 1);
-		constructInventory(imageNumb, displayNumb, scrollFl, firstIconId);
+		_firstIconId = MIN(displayNumb, _firstIconId + 1);
+		constructInventory(imageNumb, displayNumb, scrollFl, _firstIconId);
 		break;
 	case kInventoryActionGet:                       // Return object id under cursor
 		// Get cursor position from variable argument list
@@ -145,7 +144,7 @@
 					if (i == kMaxDisp - 1)          // Right scroll button
 						objId = kRightArrow;
 					else                            // Adjust for scroll
-						i += firstIconId - 1;       // i is icon index
+						i += _firstIconId - 1;      // i is icon index
 				}
 			}
 

Modified: scummvm/trunk/engines/hugo/inventory.h
===================================================================
--- scummvm/trunk/engines/hugo/inventory.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/inventory.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -50,6 +50,8 @@
 	HugoEngine *_vm;
 
 	static const int kStepDy = 8;                   // Pixels per step movement
+	
+	int16 _firstIconId;                             // Index of first icon to display
 
 	void constructInventory(const int16 imageTotNumb, int displayNumb, const bool scrollFl, int16 firstObjId);
 };

Modified: scummvm/trunk/engines/hugo/object_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object_v1d.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/object_v1d.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -177,8 +177,6 @@
 void ObjectHandler_v1d::moveObjects() {
 	debugC(4, kDebugObject, "moveObjects");
 
-	static int dxOld;                               // previous direction for CHASEing
-
 	// Added to DOS version in order to handle mouse properly
 	// If route mode enabled, do special route processing
 	if (_vm->getGameStatus().routeIndex >= 0)
@@ -208,13 +206,13 @@
 				// Set first image in sequence (if multi-seq object)
 				if (obj->seqNumb == 4) {
 					if (!obj->vx) {                 // Got 4 directions
-						if (obj->vx != dxOld) {     // vx just stopped
+						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 != dxOld) {
+					} else if (obj->vx != obj->oldvx) {
 						if (dx > 0)
 							obj->currImagePtr = obj->seqList[RIGHT].seqPtr;
 						else
@@ -229,7 +227,8 @@
 					obj->cycling = kCycleNotCycling;
 					_vm->boundaryCollision(obj);    // Must have got hero!
 				}
-				dxOld = obj->vx;
+				obj->oldvx = obj->vx;
+				obj->oldvy = obj->vy;
 				currImage = obj->currImagePtr;      // Get (new) ptr to current image
 				break;
 				}
@@ -241,13 +240,13 @@
 					// Set first image in sequence (if multi-seq object)
 					if (obj->seqNumb > 1) {
 						if (!obj->vx && (obj->seqNumb > 2)) {
-							if (obj->vx != dxOld) {  // vx just stopped
+							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 != dxOld) {
+						} else if (obj->vx != obj->oldvx) {
 							if (obj->vx > 0)
 								obj->currImagePtr = obj->seqList[RIGHT].seqPtr;
 							else
@@ -259,7 +258,8 @@
 						else
 							obj->cycling = kCycleNotCycling;
 					}
-					dxOld = obj->vx;
+					obj->oldvx = obj->vx;
+					obj->oldvy = obj->vy;
 					currImage = obj->currImagePtr;  // Get (new) ptr to current image
 				}
 				break;

Modified: scummvm/trunk/engines/hugo/parser.cpp
===================================================================
--- scummvm/trunk/engines/hugo/parser.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/parser.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -52,6 +52,10 @@
 
 Parser::Parser(HugoEngine *vm) :
 	_vm(vm), _putIndex(0), _getIndex(0), _checkDoubleF1Fl(false) {
+	_cmdLineIndex = 0;
+	_cmdLineTick = 0;
+	_cmdLineCursor = '_';
+	_cmdLine[0] = '\0';
 }
 
 Parser::~Parser() {
@@ -68,11 +72,7 @@
 void Parser::charHandler() {
 	debugC(4, kDebugParser, "charHandler");
 
-	static int16  lineIndex = 0;                    // Index into line
-	static uint32 tick = 0;                         // For flashing cursor
-	static char   cursor = '_';
-	static        command_t cmdLine;                // Build command line
-	status_t     &gameStatus = _vm->getGameStatus();
+	status_t &gameStatus = _vm->getGameStatus();
 
 	// Check for one or more characters in ring buffer
 	while (_getIndex != _putIndex) {
@@ -82,44 +82,44 @@
 
 		switch (c) {
 		case Common::KEYCODE_BACKSPACE:             // Rubout key
-			if (lineIndex)
-				cmdLine[--lineIndex] = '\0';
+			if (_cmdLineIndex)
+				_cmdLine[--_cmdLineIndex] = '\0';
 			break;
 		case Common::KEYCODE_RETURN:                // EOL, pass line to line handler
-			if (lineIndex && (_vm->_hero->pathType != kPathQuiet)) {
+			if (_cmdLineIndex && (_vm->_hero->pathType != kPathQuiet)) {
 				// Remove inventory bar if active
 				if (gameStatus.inventoryState == kInventoryActive)
 					gameStatus.inventoryState = kInventoryUp;
 				// Call Line handler and reset line
-				command(cmdLine);
-				cmdLine[lineIndex = 0] = '\0';
+				command(_cmdLine);
+				_cmdLine[_cmdLineIndex = 0] = '\0';
 			}
 			break;
 		default:                                    // Normal text key, add to line
-			if (lineIndex >= kMaxLineSize) {
+			if (_cmdLineIndex >= kMaxLineSize) {
 				//MessageBeep(MB_ICONASTERISK);
 				warning("STUB: MessageBeep() - Command line too long");
 			} else if (isprint(c)) {
-				cmdLine[lineIndex++] = c;
-				cmdLine[lineIndex] = '\0';
+				_cmdLine[_cmdLineIndex++] = c;
+				_cmdLine[_cmdLineIndex] = '\0';
 			}
 			break;
 		}
 	}
 
 	// See if time to blink cursor, set cursor character
-	if ((tick++ % (_vm->getTPS() / kBlinksPerSec)) == 0)
-		cursor = (cursor == '_') ? ' ' : '_';
+	if ((_cmdLineTick++ % (_vm->getTPS() / kBlinksPerSec)) == 0)
+		_cmdLineCursor = (_cmdLineCursor == '_') ? ' ' : '_';
 
 	// See if recall button pressed
 	if (gameStatus.recallFl) {
 		// Copy previous line to current cmdline
 		gameStatus.recallFl = false;
-		strcpy(cmdLine, _vm->_line);
-		lineIndex = strlen(cmdLine);
+		strcpy(_cmdLine, _vm->_line);
+		_cmdLineIndex = strlen(_cmdLine);
 	}
 
-	sprintf(_vm->_statusLine, ">%s%c", cmdLine, cursor);
+	sprintf(_vm->_statusLine, ">%s%c", _cmdLine, _cmdLineCursor);
 	sprintf(_vm->_scoreLine, "F1-Help  %s  Score: %d of %d Sound %s", (_vm->_config.turboFl) ? "T" : " ", _vm->getScore(), _vm->getMaxScore(), (_vm->_config.soundFl) ? "On" : "Off");
 
 	// See if "look" button pressed

Modified: scummvm/trunk/engines/hugo/parser.h
===================================================================
--- scummvm/trunk/engines/hugo/parser.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/parser.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -60,6 +60,11 @@
 protected:
 	HugoEngine *_vm;
 
+	int16     _cmdLineIndex;                        // Index into line
+	uint32    _cmdLineTick;                         // For flashing cursor
+	char      _cmdLineCursor;
+	command_t _cmdLine;                             // Build command line
+
 	char *findNoun() const;
 	char *findVerb() const;
 	void  showDosInventory() const;

Modified: scummvm/trunk/engines/hugo/route.cpp
===================================================================
--- scummvm/trunk/engines/hugo/route.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/route.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -41,6 +41,7 @@
 
 namespace Hugo {
 Route::Route(HugoEngine *vm) : _vm(vm) {
+	_oldWalkDirection = 0;
 }
 
 /**
@@ -95,16 +96,15 @@
 void Route::setWalk(const uint16 direction) {
 	debugC(1, kDebugRoute, "setWalk(%d)", direction);
 
-	static uint16 oldDirection = 0;                 // Last direction char
 	object_t *obj = _vm->_hero;                     // Pointer to hero object
 
 	if (_vm->getGameStatus().storyModeFl || obj->pathType != kPathUser) // Make sure user has control
 		return;
 
 	if (!obj->vx && !obj->vy)
-		oldDirection = 0;                           // Fix for consistant restarts
+		_oldWalkDirection = 0;                      // Fix for consistant restarts
 
-	if (direction != oldDirection) {
+	if (direction != _oldWalkDirection) {
 		// Direction has changed
 		setDirection(direction);                    // Face new direction
 		obj->vx = obj->vy = 0;
@@ -150,13 +150,13 @@
 			obj->vy =  kStepDy / 2;
 			break;
 		}
-		oldDirection = direction;
+		_oldWalkDirection = direction;
 		obj->cycling = kCycleForward;
 	} else {
 		// Same key twice - halt hero
 		obj->vy = 0;
 		obj->vx = 0;
-		oldDirection = 0;
+		_oldWalkDirection = 0;
 		obj->cycling = kCycleNotCycling;
 	}
 }

Modified: scummvm/trunk/engines/hugo/route.h
===================================================================
--- scummvm/trunk/engines/hugo/route.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/route.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -62,6 +62,8 @@
 	static const int kMaxSeg = 256;                 // Maximum number of segments
 	static const int kMaxNodes = 256;               // Maximum nodes in route
 
+	uint16 _oldWalkDirection;                       // Last direction char
+
 	byte _boundaryMap[kYPix][kXPix];                // Boundary byte map
 	segment_t _segment[kMaxSeg];                    // List of points in fill-path
 	Point _route[kMaxNodes];                        // List of nodes in route (global)

Modified: scummvm/trunk/engines/hugo/schedule.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/schedule.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -46,7 +46,7 @@
 
 namespace Hugo {
 
-Scheduler::Scheduler(HugoEngine *vm) : _vm(vm), _actListArr(0) {
+Scheduler::Scheduler(HugoEngine *vm) : _vm(vm), _actListArr(0), _curTick(0), _oldTime(0), _refreshTimeout(0) {
 	memset(_events, 0, sizeof(_events));
 }
 
@@ -117,24 +117,21 @@
 uint32 Scheduler::getDosTicks(const bool updateFl) {
 	debugC(5, kDebugSchedule, "getDosTicks(%s)", (updateFl) ? "TRUE" : "FALSE");
 
-	static  uint32 tick = 0;                        // Current system time in ticks
-	static  uint32 t_old = 0;                       // The previous wall time in ticks
-
 	uint32 t_now;                                   // Current wall time in ticks
 
 	if (!updateFl)
-		return(tick);
+		return(_curTick);
 
-	if (t_old == 0)
-		t_old = (uint32) floor((double) (g_system->getMillis() * _vm->getTPS() / 1000));
+	if (_oldTime == 0)
+		_oldTime = (uint32) floor((double) (g_system->getMillis() * _vm->getTPS() / 1000));
 	// Calculate current wall time in ticks
 	t_now = g_system->getMillis() * _vm->getTPS() / 1000	;
 
-	if ((t_now - t_old) > 0) {
-		t_old = t_now;
-		tick++;
+	if ((t_now - _oldTime) > 0) {
+		_oldTime = t_now;
+		_curTick++;
 	}
-	return(tick);
+	return(_curTick);
 }
 
 /**
@@ -221,15 +218,14 @@
 void Scheduler::waitForRefresh() {
 	debugC(5, kDebugSchedule, "waitForRefresh()");
 
-	static uint32 timeout = 0;
 	uint32 t;
 
-	if (timeout == 0)
-		timeout = getDosTicks(true);
+	if (_refreshTimeout == 0)
+		_refreshTimeout = getDosTicks(true);
 
-	while ((t = getDosTicks(true)) < timeout)
+	while ((t = getDosTicks(true)) < _refreshTimeout)
 		;
-	timeout = ++t;
+	_refreshTimeout = ++t;
 }
 
 /**

Modified: scummvm/trunk/engines/hugo/schedule.h
===================================================================
--- scummvm/trunk/engines/hugo/schedule.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/schedule.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -477,18 +477,22 @@
 
 protected:
 	HugoEngine *_vm;
-	static const int kFilenameLength = 12;              // Max length of a DOS file name
-	static const int kMaxEvents = 50;                   // Max events in event queue
-	static const int kShiftSize = 8;                    // Place hero this far inside bounding box
+	static const int kFilenameLength = 12;          // Max length of a DOS file name
+	static const int kMaxEvents = 50;               // Max events in event queue
+	static const int kShiftSize = 8;                // Place hero this far inside bounding box
 
 	uint16   _actListArrSize;
 	uint16   _alNewscrIndex;
 
-	event_t *_freeEvent;                                // Free list of event structures
-	event_t *_headEvent;                                // Head of list (earliest time)
-	event_t *_tailEvent;                                // Tail of list (latest time)
-	event_t  _events[kMaxEvents];                       // Statically declare event structures
+	uint32 _curTick;                                // Current system time in ticks
+	uint32 _oldTime;                                // The previous wall time in ticks
+	uint32 _refreshTimeout;
 
+	event_t *_freeEvent;                            // Free list of event structures
+	event_t *_headEvent;                            // Head of list (earliest time)
+	event_t *_tailEvent;                            // Tail of list (latest time)
+	event_t  _events[kMaxEvents];                   // Statically declare event structures
+
 	act    **_actListArr;
 
 	virtual const char *getCypher() const = 0;
@@ -518,9 +522,7 @@
 
 protected:
 	virtual const char *getCypher() const;
-
 	virtual uint32 getTicks();
-
 	virtual void promptAction(act *action);
 };
 

Modified: scummvm/trunk/engines/hugo/sound.cpp
===================================================================
--- scummvm/trunk/engines/hugo/sound.cpp	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/sound.cpp	2011-02-03 18:25:38 UTC (rev 55758)
@@ -47,12 +47,16 @@
 namespace Hugo {
 
 MidiPlayer::MidiPlayer(MidiDriver *driver)
-	: _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _paused(false), _masterVolume(0) {
+	: _driver(driver), _parser(0), _midiData(0) {
 	assert(_driver);
 	memset(_channelsTable, 0, sizeof(_channelsTable));
 	for (int i = 0; i < kNumbChannels; i++) {
 		_channelsVolume[i] = 127;
 	}
+	_isLooping = false;
+	_isPlaying = false;
+	_paused = false;
+	_masterVolume = 0; 
 }
 
 MidiPlayer::~MidiPlayer() {
@@ -236,6 +240,10 @@
 	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
 						_speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
 	DOSSongPtr = 0;
+	curPriority = 0;
+	pcspkrTimer = 0;
+	pcspkrOctave = 3;
+	pcspkrNoteDuration = 2;	
 }
 
 SoundHandler::~SoundHandler() {
@@ -309,7 +317,6 @@
 	// uint32 dwVolume;                             // Left, right volume of sound
 	sound_pt sound_p;                               // Sound data
 	uint16 size;                                    // Size of data
-	static byte curPriority = 0;                    // Priority of currently playing sound
 
 	// Sound disabled
 	if (!_vm->_config.soundFl || !_vm->_mixer->isReady())
@@ -374,12 +381,9 @@
 * Timer: >0 - song still going, 0 - Stop note, -1 - Set next note
 */
 void SoundHandler::pcspkr_player() {
-	static int8 pcspkrTimer = 0;                    // Timer (ticks) for note being played
-	static int8 pcspkrOctave = 3;                   // Current octave 1..7
-	static int8 pcspkrNoteDuration = 2;             // Current length of note (ticks)
-	static uint16 pcspkrNotes[8] =  {1352, 1205, 2274, 2026, 1805, 1704, 1518}; // The 3rd octave note counts A..G
-	static uint16 pcspkrSharps[8] = {1279, 1171, 2150, 1916, 1755, 1611, 1435}; // The sharps, A# to B#
-	static uint16 pcspkrFlats[8] =  {1435, 1279, 2342, 2150, 1916, 1755, 1611}; // The flats, Ab to Bb
+	static const uint16 pcspkrNotes[8] =  {1352, 1205, 2274, 2026, 1805, 1704, 1518}; // The 3rd octave note counts A..G
+	static const uint16 pcspkrSharps[8] = {1279, 1171, 2150, 1916, 1755, 1611, 1435}; // The sharps, A# to B#
+	static const uint16 pcspkrFlats[8] =  {1435, 1279, 2342, 2150, 1916, 1755, 1611}; // The flats, Ab to Bb
 
 	_vm->getTimerManager()->removeTimerProc(&loopPlayer);
 	_vm->getTimerManager()->installTimerProc(&loopPlayer, 1000000 / 9, this);

Modified: scummvm/trunk/engines/hugo/sound.h
===================================================================
--- scummvm/trunk/engines/hugo/sound.h	2011-02-03 18:24:55 UTC (rev 55757)
+++ scummvm/trunk/engines/hugo/sound.h	2011-02-03 18:25:38 UTC (rev 55758)
@@ -96,6 +96,10 @@
 
 	static const int kHugoCNT = 1190000;
 
+	int8 pcspkrTimer;                               // Timer (ticks) for note being played
+	int8 pcspkrOctave;                              // Current octave 1..7
+	int8 pcspkrNoteDuration;                        // Current length of note (ticks)
+
 	char *DOSSongPtr;
 	char *DOSIntroSong;
 
@@ -111,6 +115,9 @@
 	void checkMusic();
 	void loadIntroSong(Common::File &in);
 	void initPcspkrPlayer();
+protected:
+	byte curPriority;                               // Priority of currently playing sound
+
 private:
 	HugoEngine *_vm;
 	Audio::SoundHandle _soundHandle;


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