aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/hugo/display.cpp54
-rw-r--r--engines/hugo/display.h7
-rw-r--r--engines/hugo/engine.cpp50
-rw-r--r--engines/hugo/hugo.h4
-rw-r--r--engines/hugo/route.cpp37
-rw-r--r--engines/hugo/schedule.cpp4
-rw-r--r--engines/hugo/sound.cpp28
-rw-r--r--engines/hugo/sound.h2
-rw-r--r--engines/hugo/util.cpp21
9 files changed, 30 insertions, 177 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index fe30ab0edb..d80119b90d 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -68,16 +68,6 @@ void Screen::createPal() {
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 @@ void Screen::displayBackground() {
// 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 @@ void Screen::writeChar(int16 x, int16 y, char c, byte color) {
// 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 @@ void Screen::writeChr(int sx, int sy, byte color, char *local_fontdata) {
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,12 +355,6 @@ int16 Screen::fontHeight() {
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) {
@@ -467,28 +435,6 @@ void Screen::loadFont(int16 fontId) {
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() {
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index ceb87481b0..690f87339b 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -96,13 +96,6 @@ private:
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
diff --git a/engines/hugo/engine.cpp b/engines/hugo/engine.cpp
index 1033acbc19..8f8d5cfef2 100644
--- a/engines/hugo/engine.cpp
+++ b/engines/hugo/engine.cpp
@@ -131,8 +131,8 @@ void HugoEngine::initConfig(inst_t action) {
_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 @@ void HugoEngine::initConfig(inst_t action) {
break;
}
- HugoEngine::get().file().initSavedGame(); // Initialize saved game
+ file().initSavedGame(); // Initialize saved game
break;
case RESTORE:
warning("Unhandled action RESTORE");
@@ -163,9 +163,9 @@ void HugoEngine::initialize() {
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::initialize() {
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 @@ void HugoEngine::readObjectImages() {
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 @@ void HugoEngine::processMaze() {
// 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 @@ void HugoEngine::processMaze() {
// 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 @@ void HugoEngine::processMaze() {
// 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 @@ void HugoEngine::processMaze() {
// 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 @@ void HugoEngine::useObject(int16 objId) {
// 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 @@ void HugoEngine::screenActions(int screenNum) {
if (screenAct) {
for (int i = 0; screenAct[i]; i++)
- HugoEngine::get().scheduler().insertActionList(screenAct[i]);
+ scheduler().insertActionList(screenAct[i]);
}
}
@@ -941,7 +941,7 @@ void HugoEngine::boundaryCollision(object_t *obj) {
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 @@ void HugoEngine::boundaryCollision(object_t *obj) {
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 @@ void HugoEngine::endGame() {
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;
}
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index f65d271d76..9e86945910 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -300,9 +300,11 @@ private:
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
diff --git a/engines/hugo/route.cpp b/engines/hugo/route.cpp
index 88208e0034..02d7297ec8 100644
--- a/engines/hugo/route.cpp
+++ b/engines/hugo/route.cpp
@@ -164,17 +164,11 @@ void Route::segment(int16 x, int16 y) {
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 @@ void Route::segment(int16 x, int16 y) {
// 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 @@ bool Route::findRoute(int16 cx, int16 cy) {
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);
}
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index e7ebdfa7a1..b5861a2bf5 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -241,7 +241,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
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 @@ event_t *Scheduler::doAction(event_t *curEvent) {
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]))
diff --git a/engines/hugo/sound.cpp b/engines/hugo/sound.cpp
index 249d9145ce..91b3d29d4d 100644
--- a/engines/hugo/sound.cpp
+++ b/engines/hugo/sound.cpp
@@ -328,32 +328,4 @@ void SoundHandler::initSound() {
_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
diff --git a/engines/hugo/sound.h b/engines/hugo/sound.h
index 89fcf463da..ed2ee74be7 100644
--- a/engines/hugo/sound.h
+++ b/engines/hugo/sound.h
@@ -58,8 +58,6 @@ private:
void stopSound();
void stopMusic();
void playMIDI(sound_pt seq_p, uint16 size);
- void pauseSound(bool activeFl, int hTask);
-
};
} // end of namespace Hugo
diff --git a/engines/hugo/util.cpp b/engines/hugo/util.cpp
index fb3da9df88..3bd8f8100c 100644
--- a/engines/hugo/util.cpp
+++ b/engines/hugo/util.cpp
@@ -182,25 +182,4 @@ void Utils::gameOverMsg(void) {
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