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

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Fri Aug 27 01:41:40 CEST 2010


Revision: 52404
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52404&view=rev
Author:   vinterstum
Date:     2010-08-26 23:41:39 +0000 (Thu, 26 Aug 2010)

Log Message:
-----------
HUGO: Removed some dead code and redundant indirection

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/engine.cpp
    scummvm/trunk/engines/hugo/hugo.h
    scummvm/trunk/engines/hugo/route.cpp
    scummvm/trunk/engines/hugo/schedule.cpp
    scummvm/trunk/engines/hugo/sound.cpp
    scummvm/trunk/engines/hugo/sound.h
    scummvm/trunk/engines/hugo/util.cpp

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/display.cpp	2010-08-26 23:41:39 UTC (rev 52404)
@@ -68,16 +68,6 @@
 	g_system->setPalette(_vm._palette, 0, NUM_COLORS);
 }
 
-// Translate from our 16-color palette to Windows logical palette index
-uint32 Screen::GetPalIndex(byte color) {
-	debugC(1, kDebugDisplay, "getPalIndex(%d)", color);
-
-	warning("STUB: GetPalIndex()");
-	return 0;
-	//return(PALETTEINDEX(ctab[color]));
-}
-
-// Create DIB headers and init palette
 void Screen::initDisplay() {
 	debugC(1, kDebugDisplay, "initDisplay");
 	// Create logical palette
@@ -111,14 +101,6 @@
 
 // Blit the supplied rectangle from _frontBuffer to the screen
 void Screen::displayRect(int16 x, int16 y, int16 dx, int16 dy) {
-
-	/* TODO: Suppress this commented block if it's confirmed to be useless
-	    // Find destination rectangle from current scaling
-	    int16 sx =  (int16)((int32)config.cx * x  / XPIX);
-	    int16 sy =  (int16)((int32)config.cy * (y - DIBOFF_Y) / VIEW_DY);
-	    int16 dsx = (int16)((int32)config.cx * dx / XPIX);
-	    int16 dsy = (int16)((int32)config.cy * dy / VIEW_DY);
-	*/
 	debugC(3, kDebugDisplay, "displayRect(%d, %d, %d, %d)", x, y, dx, dy);
 
 	g_system->copyRectToScreen(&_frontBuffer[x + y * 320], 320, x, y, dx, dy);
@@ -165,12 +147,6 @@
 	// TextOut(hDC, x, y, &c, 1);
 }
 
-// Clear prompt line for next command
-void Screen::clearPromptLine() {
-	debugC(1, kDebugDisplay, "clearPromptLine");
-}
-
-
 // Return the overlay state (Foreground/Background) of the currently
 // processed object by looking down the current column for an overlay
 // base bit set (in which case the object is foreground).
@@ -358,8 +334,6 @@
 	byte height = local_fontdata[0];
 	byte width = 8; //local_fontdata[1];
 
-	//warning("STUB: writechr(sx %u, sy %u, color %u, height %u, width %u)", sx, sy, color, height, width);
-
 	// This can probably be optimized quite a bit...
 	for (int y = 0; y < height; ++y)
 		for (int x = 0; x < width; ++x) {
@@ -381,13 +355,7 @@
 	return(height[_fnt - FIRST_FONT]);
 }
 
-/* TODO: Suppress block if it's confirmed to be useless */
-// static int16 Char_len (char c) {
-// /* Returns length of single character in pixels */
-//	return (*(_font[_fnt][c] + 1) + 1);
-// }
 
-
 // Returns length of supplied string in pixels
 int16 Screen::stringLength(char *s) {
 	int16 sum;
@@ -467,28 +435,6 @@
 
 		offset += 2 + size;
 	}
-
-	// for (i = 0; i < 128; ++i) {
-	//      if( (char)i != 'f' && (char)i != '\\'){
-	//          continue;
-	//      }
-	//      int myHeight = _font[_fnt][i][0];
-	//      int myWidth = _font[_fnt][i][1];
-	//      printf("\n\nFor the letter %c, (%u, %u):\n", i, myWidth, myHeight);
-	//      for (int y = 0; y < myHeight; ++y) {
-	//          for (int x = 0; x < 8; ++x) {
-	//              int pixel = y * (8) + x;
-	//              int bitpos = pixel % 8;
-	//              int offset = pixel / 8;
-	//              byte bitTest = (1 << bitpos);
-	//              if ((_font[_fnt][i][2 + offset] & bitTest) == bitTest)
-	//                  printf("1");
-	//              else
-	//                  printf("0");
-	//          }
-	//          printf("\n");
-	//      }
-	//  }
 }
 
 void Screen::userHelp() {

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/display.h	2010-08-26 23:41:39 UTC (rev 52404)
@@ -96,13 +96,6 @@
 	int16 mergeLists(rect_t *list, rect_t *blist, int16 len, int16 blen, int16 bmax);
 	void writeChr(int sx, int sy, byte color, char *local_fontdata);
 	int16 center(char *s);
-
-// Also used in rout.cpp when DEBUG_ROUTE is defined
-	unsigned int GetPalIndex(byte color);
-
-// Useless ?
-	void     clearPromptLine();
-
 };
 
 } // end of namespace Hugo

Modified: scummvm/trunk/engines/hugo/engine.cpp
===================================================================
--- scummvm/trunk/engines/hugo/engine.cpp	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/engine.cpp	2010-08-26 23:41:39 UTC (rev 52404)
@@ -131,8 +131,8 @@
 		_config.soundVolume = 100;                  // Sound volume %
 		initPlaylist(_config.playlist);             // Initialize default tune playlist
 
-		HugoEngine::get().file().readBootFile();    // Read startup structure
-		HugoEngine::get().file().readConfig();      // Read user's saved config
+		file().readBootFile();    // Read startup structure
+		file().readConfig();      // Read user's saved config
 
 		cx = _config.cx;                            // Save these around OnFileNew()
 		cy = _config.cy;
@@ -152,7 +152,7 @@
 				break;
 			}
 
-		HugoEngine::get().file().initSavedGame();   // Initialize saved game
+		file().initSavedGame();   // Initialize saved game
 		break;
 	case RESTORE:
 		warning("Unhandled action RESTORE");
@@ -163,9 +163,9 @@
 	debugC(1, kDebugEngine, "initialize");
 
 	sound().initSound();
-	HugoEngine::get().scheduler().initEventQueue(); // Init scheduler stuff
+	scheduler().initEventQueue(); // Init scheduler stuff
 	screen().initDisplay();                         // Create Dibs and palette
-	HugoEngine::get().file().openDatabaseFiles();   // Open database files
+	file().openDatabaseFiles();   // Open database files
 	calcMaxScore();                                 // Initialise maxscore
 
 	_rnd = new Common::RandomSource();
@@ -195,9 +195,9 @@
 void HugoEngine::shutdown() {
 	debugC(1, kDebugEngine, "shutdown");
 
-	HugoEngine::get().file().closeDatabaseFiles();
+	file().closeDatabaseFiles();
 	if (_status.recordFl || _status.playbackFl)
-		HugoEngine::get().file().closePlaybackFile();
+		file().closePlaybackFile();
 	freeObjects();
 }
 
@@ -205,25 +205,25 @@
 	debugC(1, kDebugEngine, "readObjectImages");
 
 	for (int i = 0; i < _numObj; i++)
-		HugoEngine::get().file().readImage(i, &_objects[i]);
+		file().readImage(i, &_objects[i]);
 }
 
 // Read the uif image file (inventory icons)
 void HugoEngine::readUIFImages() {
 	debugC(1, kDebugEngine, "readUIFImages");
 
-	HugoEngine::get().file().readUIFItem(UIF_IMAGES, screen().getGUIBuffer());              // Read all uif images
+	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);
 
-	HugoEngine::get().file().readBackground(screenNum);                     // Scenery file
+	file().readBackground(screenNum);                     // Scenery file
 	memcpy(screen().getBackBuffer(), screen().getFrontBuffer(), sizeof(screen().getFrontBuffer()));// Make a copy
-	HugoEngine::get().file().readOverlay(screenNum, _boundary, BOUNDARY);       // Boundary file
-	HugoEngine::get().file().readOverlay(screenNum, _overlay, OVERLAY);         // Overlay file
-	HugoEngine::get().file().readOverlay(screenNum, _ovlBase, OVLBASE);         // Overlay base file
+	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
@@ -541,7 +541,7 @@
 //		aheroxy.y = _hero_p->y;
 		_actListArr[_alNewscrIndex][0].a2.y = _hero->y;
 		_status.routeIndex = -1;
-		HugoEngine::get().scheduler().insertActionList(_alNewscrIndex);
+		scheduler().insertActionList(_alNewscrIndex);
 	} else if (x2 > _maze.x2) {
 		// Exit east
 //			anewscr.screen = *_screen_p + 1;
@@ -551,7 +551,7 @@
 //			aheroxy.y = _hero_p->y;
 		_actListArr[_alNewscrIndex][0].a2.y = _hero->y;
 		_status.routeIndex = -1;
-		HugoEngine::get().scheduler().insertActionList(_alNewscrIndex);
+		scheduler().insertActionList(_alNewscrIndex);
 	} else if (y1 < _maze.y1 - SHIFT) {
 		// Exit north
 //				anewscr.screen = *_screen_p - _maze.size;
@@ -561,7 +561,7 @@
 //				aheroxy.y = _maze.y2 - SHIFT - (y2 - y1);
 		_actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - SHIFT - (y2 - y1);
 		_status.routeIndex = -1;
-		HugoEngine::get().scheduler().insertActionList(_alNewscrIndex);
+		scheduler().insertActionList(_alNewscrIndex);
 	} else if (y2 > _maze.y2 - SHIFT / 2) {
 		// Exit south
 //					anewscr.screen = *_screen_p + _maze.size;
@@ -571,20 +571,20 @@
 //					aheroxy.y = _maze.y1 + SHIFT;
 		_actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + SHIFT;
 		_status.routeIndex = -1;
-		HugoEngine::get().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 y2comp(const void *a, const void *b) {
+int HugoEngine::y2comp(const void *a, const void *b) {
 	int       ay2, by2;
 
 	debugC(6, kDebugEngine, "y2comp");
 
-	const object_t *p1 = &HugoEngine::get()._objects[*(const byte *)a];
-	const object_t *p2 = &HugoEngine::get()._objects[*(const byte *)b];
+	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?
@@ -848,7 +848,7 @@
 					// Deselect dragged icon if inventory not active
 					if (_status.inventoryState != I_ACTIVE)
 						_status.inventoryObjId  = -1;
-					Utils::Box(BOX_ANY, HugoEngine::get()._textData[use->dataIndex]);
+					Utils::Box(BOX_ANY, _textData[use->dataIndex]);
 					return;
 				}
 			}
@@ -907,7 +907,7 @@
 
 	if (screenAct) {
 		for (int i = 0; screenAct[i]; i++)
-			HugoEngine::get().scheduler().insertActionList(screenAct[i]);
+			scheduler().insertActionList(screenAct[i]);
 	}
 }
 
@@ -941,7 +941,7 @@
 			hotspot = &_hotspots[i];
 			if (hotspot->screenIndex == obj->screenIndex)
 				if ((x >= hotspot->x1) && (x <= hotspot->x2) && (y >= hotspot->y1) && (y <= hotspot->y2)) {
-					HugoEngine::get().scheduler().insertActionList(hotspot->actIndex);
+					scheduler().insertActionList(hotspot->actIndex);
 					break;
 				}
 		}
@@ -954,7 +954,7 @@
 		if (radius < 0)
 			radius = DX * 2;
 		if ((abs(dx) <= radius) && (abs(dy) <= radius))
-			HugoEngine::get().scheduler().insertActionList(obj->actIndex);
+			scheduler().insertActionList(obj->actIndex);
 	}
 }
 
@@ -988,7 +988,7 @@
 	debugC(1, kDebugEngine, "endGame");
 
 	if (!_boot.registered)
-		Utils::Box(BOX_ANY, HugoEngine::get()._textEngine[kEsAdvertise]);
+		Utils::Box(BOX_ANY, _textEngine[kEsAdvertise]);
 	Utils::Box(BOX_ANY, "%s\n%s", _episode, COPYRIGHT);
 	_status.viewState = V_EXIT;
 }

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/hugo.h	2010-08-26 23:41:39 UTC (rev 52404)
@@ -300,9 +300,11 @@
 	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/route.cpp
===================================================================
--- scummvm/trunk/engines/hugo/route.cpp	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/route.cpp	2010-08-26 23:41:39 UTC (rev 52404)
@@ -164,17 +164,11 @@
 	p = _boundaryMap[y];
 	for (x1 = x; x1 > 0; x1--)
 		if (p[x1] == 0) {
-#if DEBUG_ROUTE
-			SetPixel(hDC, (int16)((long)config.cx * x1  / XPIX), (int16)((long)config.cy *(y - DIBOFF_Y) / VIEW_DY), GetPalIndex(_TLIGHTMAGENTA));
-#endif
 			p[x1] = kMapFill;
 		} else
 			break;
 	for (x2 = x + 1; x2 < XPIX; x2++)
 		if (p[x2] == 0) {
-#if DEBUG_ROUTE
-			SetPixel(hDC, (int16)((long)config.cx * x2  / XPIX), (int16)((long)config.cy *(y - DIBOFF_Y) / VIEW_DY), GetPalIndex(_TLIGHTGREEN));
-#endif
 			p[x2] = kMapFill;
 		} else
 			break;
@@ -192,21 +186,7 @@
 	// Bounds check y in case no boundary around screen
 	if (y <= 0 || y >= YPIX - 1)
 		return;
-#if FALSE
-	// Find all segments above and below current
-	if (hero_p->x < x1 || hero_p->x + HERO_MAX_WIDTH > x2) {
-		// Hero x not in segment, search x1..x2
-		// Find all segments above current
-		for (x = x1; !(_routeFoundFl | _fullStackFl | _fullSegmentFl) && x <= x2; x++)
-			if (_boundaryMap[y - 1][x] == 0)
-				segment(x, y - 1);
 
-		// Find all segments below current
-		for (x = x1; !(_routeFoundFl | _fullStackFl | _fullSegmentFl) && x <= x2; x++)
-			if (_boundaryMap[y + 1][x] == 0)
-				segment(x, y + 1);
-	}
-#endif
 	if (_vm._hero->x < x1) {
 		// Hero x not in segment, search x1..x2
 		// Find all segments above current
@@ -316,28 +296,11 @@
 		if ((obj->screenIndex == *_vm._screen_p) && (obj->cycling != INVISIBLE) && (obj->priority == FLOATING))
 			_vm.clearBoundary(obj->oldx + obj->currImagePtr->x1, obj->oldx + obj->currImagePtr->x2, obj->oldy + obj->currImagePtr->y2);
 
-#if DEBUG_ROUTE
-	{
-//	hDC = GetDC(hview);
-		for (y = 0; y < YPIX; y++)
-			for (x = 0; x < XPIX; x++)
-				if (_boundaryMap[y][x])
-					SetPixel(hDC, (int16)((long)config.cx * x  / XPIX), (int16)((long)config.cy *(y - DIBOFF_Y) / VIEW_DY), GetPalIndex(_TBRIGHTWHITE));
-	}
-#endif
-
 	// Search from hero to destination
 	segment(herox1, heroy);
 
-//#if DEBUG_ROUTE
-//	ReleaseDC(hview, hDC);
-//#endif
-
 	// Not found or not enough stack or MAX_SEG exceeded
 	if (!_routeFoundFl || _fullStackFl || _fullSegmentFl) {
-#if DEBUG_ROUTE
-		Box(BOX_ANY, "%s", (_fullStackFl) ? "Stack blown!" : (_fullSegmentFl) ? "Ran out of segments!" : "No Route!");
-#endif
 		return(false);
 	}
 

Modified: scummvm/trunk/engines/hugo/schedule.cpp
===================================================================
--- scummvm/trunk/engines/hugo/schedule.cpp	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/schedule.cpp	2010-08-26 23:41:39 UTC (rev 52404)
@@ -241,7 +241,7 @@
 		insertActionList(action->a3.actPassIndex);
 		break;
 	case BKGD_COLOR:                                // act4: Set new background color
-		HugoEngine::get().screen().setBackgroundColor(action->a4.newBackgroundColor);
+		_vm.screen().setBackgroundColor(action->a4.newBackgroundColor);
 		break;
 	case INIT_OBJVXY:                               // act5: Initialise an object
 		_vm._objects[action->a5.objNumb].vx = action->a5.vx;        // velocities
@@ -400,7 +400,7 @@
 		insertActionList(action->a34.actIndex);
 		break;
 	case REMAPPAL:                                  // act35: Remap a palette color
-		HugoEngine::get().screen().remapPal(action->a35.oldColorIndex, action->a35.newColorIndex);
+		_vm.screen().remapPal(action->a35.oldColorIndex, action->a35.newColorIndex);
 		break;
 	case COND_NOUN:                                 // act36: Conditional on noun mentioned
 		if (_vm.parser().isWordPresent(_vm._arrayNouns[action->a36.nounIndex]))

Modified: scummvm/trunk/engines/hugo/sound.cpp
===================================================================
--- scummvm/trunk/engines/hugo/sound.cpp	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/sound.cpp	2010-08-26 23:41:39 UTC (rev 52404)
@@ -328,32 +328,4 @@
 	_midiPlayer->open();
 }
 
-void SoundHandler::pauseSound(bool activeFl, int hTask) {
-	static bool firstFl = true;
-	static bool musicFl, soundFl;
-
-	if (firstFl) {
-		firstFl = false;
-		musicFl = _config.musicFl;
-		soundFl = _config.soundFl;
-	}
-
-	// Kill or restore music, sound
-	if (activeFl) { // Remember states, reset WinHelp flag
-		_config.musicFl = musicFl;
-		_config.soundFl = soundFl;
-		_vm.getGameStatus().helpFl = false;
-	} else {    // Store states and disable
-		musicFl = _config.musicFl;
-		soundFl = _config.soundFl;
-
-		// Don't disable music during WinHelp() or config.music_bkg
-		if (!_vm.getGameStatus().helpFl && !_config.backgroundMusicFl) {
-			_config.musicFl = false;
-			_config.soundFl = false;
-		}
-	}
-	initSound();
-}
-
 } // end of namespace Hugo

Modified: scummvm/trunk/engines/hugo/sound.h
===================================================================
--- scummvm/trunk/engines/hugo/sound.h	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/sound.h	2010-08-26 23:41:39 UTC (rev 52404)
@@ -58,8 +58,6 @@
 	void stopSound();
 	void stopMusic();
 	void playMIDI(sound_pt seq_p, uint16 size);
-	void pauseSound(bool activeFl, int hTask);
-
 };
 
 } // end of namespace Hugo

Modified: scummvm/trunk/engines/hugo/util.cpp
===================================================================
--- scummvm/trunk/engines/hugo/util.cpp	2010-08-26 23:13:17 UTC (rev 52403)
+++ scummvm/trunk/engines/hugo/util.cpp	2010-08-26 23:41:39 UTC (rev 52404)
@@ -182,25 +182,4 @@
 	warning("STUB: Gameover_msg(): %s", HugoEngine::get()._textUtil[kGameOver]);
 }
 
-#if 0
-// Strangerke: Useless?
-void Utils::Debug_out(char *format, ...) {
-	/* Write debug info to file */
-	static FILE *fp = NULL;
-	va_list marker;
-
-	if (HugoEngine::get().getGameStatus().debugFl) {
-		/* Create/truncate if first call, else append */
-		if ((fp = fopen("debug.txt", (fp == NULL) ? "w" : "a")) == NULL) {
-			Error(WRITE_ERR, "debug.txt");
-			return;
-		}
-
-		va_start(marker, format);
-		vfprintf(fp, format, marker);
-		va_end(marker);
-		fclose(fp);
-	}
-}
-#endif
 } // end of namespace Hugo


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