aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/display.cpp101
-rw-r--r--engines/hugo/display.h24
-rw-r--r--engines/hugo/file.cpp42
-rw-r--r--engines/hugo/file.h39
-rw-r--r--engines/hugo/file_v1d.cpp6
-rw-r--r--engines/hugo/file_v1w.cpp10
-rw-r--r--engines/hugo/file_v2d.cpp22
-rw-r--r--engines/hugo/file_v2w.cpp2
-rw-r--r--engines/hugo/file_v3d.cpp21
-rw-r--r--engines/hugo/game.h705
-rw-r--r--engines/hugo/global.h50
-rw-r--r--engines/hugo/hugo.cpp129
-rw-r--r--engines/hugo/hugo.h160
-rw-r--r--engines/hugo/intro.cpp20
-rw-r--r--engines/hugo/inventory.cpp94
-rw-r--r--engines/hugo/inventory.h9
-rw-r--r--engines/hugo/menu.cpp10
-rw-r--r--engines/hugo/mouse.cpp103
-rw-r--r--engines/hugo/mouse.h12
-rw-r--r--engines/hugo/object.cpp45
-rw-r--r--engines/hugo/object.h8
-rw-r--r--engines/hugo/object_v1d.cpp77
-rw-r--r--engines/hugo/object_v1w.cpp93
-rw-r--r--engines/hugo/object_v2d.cpp89
-rw-r--r--engines/hugo/object_v3d.cpp55
-rw-r--r--engines/hugo/parser.cpp46
-rw-r--r--engines/hugo/parser.h4
-rw-r--r--engines/hugo/parser_v1d.cpp80
-rw-r--r--engines/hugo/parser_v1w.cpp62
-rw-r--r--engines/hugo/parser_v2d.cpp50
-rw-r--r--engines/hugo/parser_v3d.cpp102
-rw-r--r--engines/hugo/route.cpp73
-rw-r--r--engines/hugo/route.h13
-rw-r--r--engines/hugo/schedule.cpp30
-rw-r--r--engines/hugo/schedule.h409
-rw-r--r--engines/hugo/sound.cpp22
-rw-r--r--engines/hugo/sound.h42
-rw-r--r--engines/hugo/util.cpp20
-rw-r--r--engines/hugo/util.h2
39 files changed, 1414 insertions, 1467 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index f55d2ede2a..d0f45cb2e1 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -42,15 +42,12 @@
namespace Hugo {
-#define DMAX 16 // Size of add/restore rect lists
-#define BMAX (DMAX * 2) // Size of dirty rect blit list
-
#define INX(X, B) (X >= B->x && X <= B->x + B->dx)
#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), _mainPalette(0), _curPalette(0) {
- for (int i = 0; i < NUM_FONTS; i++) {
+ for (int i = 0; i < kNumFonts; i++) {
_arrayFont[i] = 0;
fontLoadedFl[i] = false;
}
@@ -65,7 +62,7 @@ Screen::~Screen() {
void Screen::createPal() {
debugC(1, kDebugDisplay, "createPal");
- g_system->setPalette(_mainPalette, 0, NUM_COLORS);
+ g_system->setPalette(_mainPalette, 0, kNumColors);
}
void Screen::setCursorPal() {
@@ -189,7 +186,7 @@ overlayState_t Screen::findOvl(seq_t *seq_p, image_pt dst_p, uint16 y) {
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;
+ dst_p += kXPix;
}
return BG; // No bits set, must be background
@@ -203,9 +200,9 @@ void Screen::displayFrame(int sx, int sy, seq_t *seq, bool foreFl) {
debugC(3, kDebugDisplay, "displayFrame(%d, %d, seq, %d)", sx, sy, (foreFl) ? 1 : 0);
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
- int16 frontBufferwrap = XPIX - seq->x2 - 1; // Wraps dest_p after each line
+ image_pt subFrontBuffer = &_frontBuffer[sy * kXPix + sx]; // Ptr to offset in _frontBuffer
+ image_pt overlay = &_vm->getFirstOverlay()[(sy * kXPix + sx) >> 3]; // Ptr to overlay data
+ int16 frontBufferwrap = kXPix - seq->x2 - 1; // Wraps dest_p after each line
int16 imageWrap = seq->bytesPerLine8 - seq->x2 - 1;
overlayState_t overlayState = UNDEF; // Overlay state of object
@@ -230,7 +227,7 @@ void Screen::displayFrame(int sx, int sy, seq_t *seq, bool foreFl) {
}
// Add this rectangle to the display list
- displayList(D_ADD, sx, sy, seq->x2 + 1, seq->lines);
+ displayList(kDisplayAdd, sx, sy, seq->x2 + 1, seq->lines);
}
/**
@@ -259,7 +256,7 @@ void Screen::merge(rect_t *rectA, rect_t *rectB) {
int16 Screen::mergeLists(rect_t *list, rect_t *blist, int16 len, int16 blen, int16 bmax) {
debugC(4, kDebugDisplay, "mergeLists");
- int16 coalesce[BMAX]; // List of overlapping rects
+ int16 coalesce[kBlitListSize]; // List of overlapping rects
// Process the list
for (int16 a = 0; a < len; a++, list++) {
// Compile list of overlapping rectangles in blit list
@@ -298,20 +295,20 @@ void Screen::displayList(dupdate_t update, ...) {
debugC(6, kDebugDisplay, "displayList");
static int16 addIndex, restoreIndex; // Index into add/restore lists
- static rect_t restoreList[DMAX]; // The restore list
- static rect_t addList[DMAX]; // The add list
- static rect_t blistList[BMAX]; // The blit list
+ 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 D_INIT: // Init lists, restore whole screen
+ case kDisplayInit: // Init lists, restore whole screen
addIndex = restoreIndex = 0;
memcpy(_frontBuffer, _backBuffer, sizeof(_frontBuffer));
break;
- case D_ADD: // Add a rectangle to list
- if (addIndex >= DMAX) {
+ case kDisplayAdd: // Add a rectangle to list
+ if (addIndex >= kRectListSize) {
warning("Display list exceeded");
return;
}
@@ -324,7 +321,7 @@ void Screen::displayList(dupdate_t update, ...) {
va_end(marker); // Reset variable arguments
addIndex++;
break;
- case D_DISPLAY: // Display whole list
+ case kDisplayDisplay: // Display whole list
// 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.
@@ -334,8 +331,8 @@ void Screen::displayList(dupdate_t update, ...) {
}
// Coalesce restore-list, add-list into combined blit-list
- blitLength = mergeLists(restoreList, blistList, restoreIndex, blitLength, BMAX);
- blitLength = mergeLists(addList, blistList, addIndex, blitLength, BMAX);
+ blitLength = mergeLists(restoreList, blistList, restoreIndex, blitLength, kBlitListSize);
+ blitLength = mergeLists(addList, blistList, addIndex, blitLength, kBlitListSize);
// Blit the combined blit-list
for (restoreIndex = 0, p = blistList; restoreIndex < blitLength; restoreIndex++, p++) {
@@ -343,11 +340,11 @@ void Screen::displayList(dupdate_t update, ...) {
displayRect(p->x, p->y, p->dx, p->dy);
}
break;
- case D_RESTORE: // Restore each rectangle
+ case kDisplayRestore: // Restore each rectangle
for (restoreIndex = 0, p = addList; restoreIndex < addIndex; restoreIndex++, p++) {
// Restoring from _backBuffer to _frontBuffer
restoreList[restoreIndex] = *p; // Copy add-list to restore-list
- moveImage(_backBuffer, p->x, p->y, p->dx, p->dy, XPIX, _frontBuffer, p->x, p->y, XPIX);
+ moveImage(_backBuffer, p->x, p->y, p->dx, p->dy, kXPix, _frontBuffer, p->x, p->y, kXPix);
}
addIndex = 0; // Reset add-list
break;
@@ -386,8 +383,8 @@ void Screen::writeChr(int sx, int sy, byte color, char *local_fontdata) {
int16 Screen::fontHeight() {
debugC(2, kDebugDisplay, "fontHeight");
- static int16 height[NUM_FONTS] = {5, 7, 8};
- return height[_fnt - FIRST_FONT];
+ static int16 height[kNumFonts] = {5, 7, 8};
+ return height[_fnt - kFirstFont];
}
/**
@@ -410,7 +407,7 @@ int16 Screen::stringLength(const char *s) {
int16 Screen::center(const char *s) {
debugC(1, kDebugDisplay, "center(%s)", s);
- return (int16)((XPIX - stringLength(s)) >> 1);
+ return (int16)((kXPix - stringLength(s)) >> 1);
}
/**
@@ -420,7 +417,7 @@ int16 Screen::center(const char *s) {
void Screen::writeStr(int16 sx, int16 sy, const char *s, byte color) {
debugC(2, kDebugDisplay, "writeStr(%d, %d, %s, %d)", sx, sy, s, color);
- if (sx == CENTER)
+ if (sx == kCenter)
sx = center(s);
byte **font = _font[_fnt];
@@ -436,7 +433,7 @@ void Screen::writeStr(int16 sx, int16 sy, const char *s, byte color) {
void Screen::shadowStr(int16 sx, int16 sy, const char *s, byte color) {
debugC(1, kDebugDisplay, "shadowStr(%d, %d, %s, %d)", sx, sy, s, color);
- if (sx == CENTER)
+ if (sx == kCenter)
sx = center(s);
writeStr(sx + 1, sy + 1, s, _TBLACK);
@@ -448,7 +445,7 @@ void Screen::shadowStr(int16 sx, int16 sy, const char *s, byte color) {
* present in the DOS versions
*/
void Screen::userHelp() {
- Utils::Box(BOX_ANY , "%s",
+ Utils::Box(kBoxAny , "%s",
"F1 - Press F1 again\n"
" for instructions\n"
"F2 - Sound on/off\n"
@@ -468,29 +465,29 @@ void Screen::drawStatusText() {
uint16 sdx = stringLength(_vm->_statusLine);
uint16 sdy = fontHeight() + 1; // + 1 for shadow
uint16 posX = 0;
- uint16 posY = YPIX - sdy;
+ uint16 posY = kYPix - sdy;
// Display the string and add rect to display list
writeStr(posX, posY, _vm->_statusLine, _TLIGHTYELLOW);
- displayList(D_ADD, posX, posY, sdx, sdy);
+ displayList(kDisplayAdd, posX, posY, sdx, sdy);
sdx = stringLength(_vm->_scoreLine);
posY = 0;
writeStr(posX, posY, _vm->_scoreLine, _TCYAN);
- displayList(D_ADD, posX, posY, sdx, sdy);
+ displayList(kDisplayAdd, posX, posY, sdx, sdy);
}
void Screen::drawShape(int x, int y, int color1, int color2) {
- for (int i = 0; i < shapeSize; i++) {
+ for (int i = 0; i < kShapeSize; i++) {
for (int j = 0; j < i; j++) {
- _backBuffer[320 * (y + i) + (x + shapeSize + j - i)] = color1;
- _frontBuffer[320 * (y + i) + (x + shapeSize + j - i)] = color1;
- _backBuffer[320 * (y + i) + (x + shapeSize + j)] = color2;
- _frontBuffer[320 * (y + i) + (x + shapeSize + j)] = color2;
- _backBuffer[320 * (y + (2 * shapeSize - 1) - i) + (x + shapeSize + j - i)] = color1;
- _frontBuffer[320 * (y + (2 * shapeSize - 1) - i) + (x + shapeSize + j - i)] = color1;
- _backBuffer[320 * (y + (2 * shapeSize - 1) - i) + (x + shapeSize + j)] = color2;
- _frontBuffer[320 * (y + (2 * shapeSize - 1) - i) + (x + shapeSize + j)] = color2;
+ _backBuffer[320 * (y + i) + (x + kShapeSize + j - i)] = color1;
+ _frontBuffer[320 * (y + i) + (x + kShapeSize + j - i)] = color1;
+ _backBuffer[320 * (y + i) + (x + kShapeSize + j)] = color2;
+ _frontBuffer[320 * (y + i) + (x + kShapeSize + j)] = color2;
+ _backBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j - i)] = color1;
+ _frontBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j - i)] = color1;
+ _backBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j)] = color2;
+ _frontBuffer[320 * (y + (2 * kShapeSize - 1) - i) + (x + kShapeSize + j)] = color2;
}
}
}
@@ -515,7 +512,7 @@ void Screen::drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2
* Initialize screen components and display results
*/
void Screen::initNewScreenDisplay() {
- displayList(D_INIT);
+ displayList(kDisplayInit);
setBackgroundColor(_TBLACK);
displayBackground();
@@ -547,7 +544,7 @@ void Screen::freePalette() {
* Free fonts
*/
void Screen::freeFonts() {
- for (int i = 0; i < NUM_FONTS; i++) {
+ for (int i = 0; i < kNumFonts; i++) {
if (_arrayFont[i])
free(_arrayFont[i]);
}
@@ -567,19 +564,19 @@ void Screen::selectInventoryObjId(int16 objId) {
}
// Compute source coordinates in dib_u
- int16 ux = (iconId + NUM_ARROWS) * INV_DX % XPIX;
- int16 uy = (iconId + NUM_ARROWS) * INV_DX / XPIX * INV_DY;
+ int16 ux = (iconId + kArrowNumb) * kInvDx % kXPix;
+ int16 uy = (iconId + kArrowNumb) * kInvDx / kXPix * kInvDy;
// Copy the icon and add to display list
- moveImage(getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _iconImage, 0, 0, 32);
+ moveImage(getGUIBuffer(), ux, uy, kInvDx, kInvDy, kXPix, _iconImage, 0, 0, 32);
for (int i = 0; i < stdMouseCursorHeight; i++) {
for (int j = 0; j < stdMouseCursorWidth; j++) {
- _iconImage[(i * INV_DX) + j] = (stdMouseCursor[(i * stdMouseCursorWidth) + j] == 1) ? _iconImage[(i * INV_DX) + j] : stdMouseCursor[(i * stdMouseCursorWidth) + j];
+ _iconImage[(i * kInvDx) + j] = (stdMouseCursor[(i * stdMouseCursorWidth) + j] == 1) ? _iconImage[(i * kInvDx) + j] : stdMouseCursor[(i * stdMouseCursorWidth) + j];
}
}
- CursorMan.replaceCursor(_iconImage, INV_DX, INV_DY, 1, 1, 1);
+ CursorMan.replaceCursor(_iconImage, kInvDx, kInvDy, 1, 1, 1);
}
void Screen::resetInventoryObjId() {
@@ -609,9 +606,9 @@ Screen_v1d::~Screen_v1d() {
void Screen_v1d::loadFont(int16 fontId) {
debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
- assert(fontId < NUM_FONTS);
+ assert(fontId < kNumFonts);
- _fnt = fontId - FIRST_FONT; // Set current font number
+ _fnt = fontId - kFirstFont; // Set current font number
if (fontLoadedFl[_fnt]) // If already loaded, return
return;
@@ -643,7 +640,7 @@ void Screen_v1d::loadFont(int16 fontId) {
* TODO: Properly handle the vector based font files (win31)
*/
void Screen_v1d::loadFontArr(Common::File &in) {
- for (int i = 0; i < NUM_FONTS; i++) {
+ for (int i = 0; i < kNumFonts; i++) {
_arrayFontSize[i] = in.readUint16BE();
_arrayFont[i] = (byte *)malloc(sizeof(byte) * _arrayFontSize[i]);
for (int j = 0; j < _arrayFontSize[i]; j++) {
@@ -664,7 +661,7 @@ Screen_v1w::~Screen_v1w() {
void Screen_v1w::loadFont(int16 fontId) {
debugC(2, kDebugDisplay, "loadFont(%d)", fontId);
- _fnt = fontId - FIRST_FONT; // Set current font number
+ _fnt = fontId - kFirstFont; // Set current font number
if (fontLoadedFl[_fnt]) // If already loaded, return
return;
@@ -695,7 +692,7 @@ void Screen_v1w::loadFont(int16 fontId) {
* Skips the fonts used by the DOS versions
*/
void Screen_v1w::loadFontArr(Common::File &in) {
- for (int i = 0; i < NUM_FONTS; i++) {
+ for (int i = 0; i < kNumFonts; i++) {
uint16 numElem = in.readUint16BE();
for (int j = 0; j < numElem; j++)
in.readByte();
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index 9e86399e14..4e2a01c763 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -34,9 +34,14 @@
#define HUGO_DISPLAY_H
namespace Hugo {
-#define shapeSize 24
-
enum overlayState_t {UNDEF, FG, BG}; // Overlay state
+
+static const int kShapeSize = 24;
+static const int kFontLength = 128; // Number of chars in font
+static const int kFontSize = 1200; // Max size of font data
+static const int kNumFonts = 3; // Number of dib fonts
+static const int kCenter = -1; // Used to center text in x
+
struct rect_t { // Rectangle used in Display list
int16 x; // Position in dib
int16 y; // Position in dib
@@ -137,19 +142,22 @@ public:
protected:
HugoEngine *_vm;
- bool fontLoadedFl[NUM_FONTS];
+ static const int kRectListSize = 16; // Size of add/restore rect lists
+ static const int kBlitListSize = kRectListSize * 2; // Size of dirty rect blit list
+
+ bool fontLoadedFl[kNumFonts];
// Fonts used in dib (non-GDI)
- byte *_arrayFont[NUM_FONTS];
+ byte *_arrayFont[kNumFonts];
byte _fnt; // Current font number
- byte _fontdata[NUM_FONTS][FONTSIZE]; // Font data
- byte *_font[NUM_FONTS][FONT_LEN]; // Ptrs to each char
+ byte _fontdata[kNumFonts][kFontSize]; // Font data
+ byte *_font[kNumFonts][kFontLength]; // Ptrs to each char
byte *_mainPalette;
- int16 _arrayFontSize[NUM_FONTS];
+ int16 _arrayFontSize[kNumFonts];
private:
byte *_curPalette;
- byte _iconImage[INV_DX * INV_DY];
+ byte _iconImage[kInvDx * kInvDy];
byte _paletteSize;
icondib_t _iconBuffer; // Inventory icon DIB
diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp
index 0f7e2c8f89..b481219bb9 100644
--- a/engines/hugo/file.cpp
+++ b/engines/hugo/file.cpp
@@ -38,7 +38,6 @@
#include "hugo/hugo.h"
#include "hugo/file.h"
-#include "hugo/global.h"
#include "hugo/schedule.h"
#include "hugo/display.h"
#include "hugo/util.h"
@@ -124,13 +123,13 @@ seq_t *FileManager::readPCX(Common::File &f, seq_t *seqPtr, byte *imagePtr, bool
// Process the image data, converting to 8-bit DIB format
uint16 y = 0; // Current line index
- byte pline[XPIX]; // Hold 4 planes of data
+ byte pline[kXPix]; // Hold 4 planes of data
byte *p = pline; // Ptr to above
while (y < seqPtr->lines) {
byte c = f.readByte();
- if ((c & REP_MASK) == REP_MASK) {
+ if ((c & kRepeatMask) == kRepeatMask) {
byte d = f.readByte(); // Read data byte
- for (int i = 0; i < (c & LEN_MASK); i++) {
+ for (int i = 0; i < (c & kLengthMask); i++) {
*p++ = d;
if ((uint16)(p - pline) == bytesPerLine4)
p = convertPCC(pline, y++, PCC_header.bytesPerLine, imagePtr);
@@ -228,13 +227,13 @@ void FileManager::readImage(int objNum, object_t *objPtr) {
// Set the current image sequence to first or last
switch (objPtr->cycling) {
- case INVISIBLE: // (May become visible later)
- case ALMOST_INVISIBLE:
- case NOT_CYCLING:
- case CYCLE_FORWARD:
+ case kCycleInvisible: // (May become visible later)
+ case kCycleAlmostInvisible:
+ case kCycleNotCycling:
+ case kCycleForward:
objPtr->currImagePtr = objPtr->seqList[0].seqPtr;
break;
- case CYCLE_BACKWARD:
+ case kCycleBackward:
objPtr->currImagePtr = seqPtr;
break;
default:
@@ -265,7 +264,7 @@ sound_pt FileManager::getSound(int16 sound, uint16 *size) {
// If this is the first call, read the lookup table
static bool has_read_header = false;
- static sound_hdr_t s_hdr[MAX_SOUNDS]; // Sound lookup table
+ 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))
@@ -460,8 +459,8 @@ bool FileManager::restoreGame(int16 slot) {
in->skip(6); // Skip date & time
// If hero image is currently swapped, swap it back before restore
- if (_vm->_heroImage != HERO)
- _vm->_object->swapImages(HERO, _vm->_heroImage);
+ if (_vm->_heroImage != kHeroIndex)
+ _vm->_object->swapImages(kHeroIndex, _vm->_heroImage);
_vm->_object->restoreObjects(in);
@@ -469,8 +468,8 @@ bool FileManager::restoreGame(int16 slot) {
// If hero swapped in saved game, swap it
byte heroImg = _vm->_heroImage;
- if (heroImg != HERO)
- _vm->_object->swapImages(HERO, _vm->_heroImage);
+ if (heroImg != kHeroIndex)
+ _vm->_object->swapImages(kHeroIndex, _vm->_heroImage);
_vm->_heroImage = heroImg;
status_t &gameStatus = _vm->getGameStatus();
@@ -518,6 +517,7 @@ bool FileManager::restoreGame(int16 slot) {
*/
void FileManager::printBootText() {
debugC(1, kDebugFile, "printBootText");
+ static const char *cypher = getBootCypher();
Common::File ofp;
if (!ofp.open(BOOTFILE)) {
@@ -541,10 +541,10 @@ void FileManager::printBootText() {
// Decrypt the exit text, using CRYPT substring
int i;
for (i = 0; i < _boot.exit_len; i++)
- buf[i] ^= CRYPT[i % strlen(CRYPT)];
+ buf[i] ^= cypher[i % strlen(cypher)];
buf[i] = '\0';
- Utils::Box(BOX_OK, "%s", buf);
+ Utils::Box(kBoxOk, "%s", buf);
}
free(buf);
@@ -557,6 +557,7 @@ void FileManager::printBootText() {
*/
void FileManager::readBootFile() {
debugC(1, kDebugFile, "readBootFile");
+ static const char *cypher = getBootCypher();
Common::File ofp;
if (!ofp.open(BOOTFILE)) {
@@ -583,7 +584,7 @@ void FileManager::readBootFile() {
byte checksum = 0;
for (uint32 i = 0; i < sizeof(_boot); i++) {
checksum ^= p[i];
- p[i] ^= CRYPT[i % strlen(CRYPT)];
+ p[i] ^= cypher[i % strlen(cypher)];
}
ofp.close();
@@ -598,7 +599,7 @@ uif_hdr_t *FileManager::getUIFHeader(uif_t id) {
debugC(1, kDebugFile, "getUIFHeader(%d)", id);
static bool firstFl = true;
- static uif_hdr_t UIFHeader[MAX_UIFS]; // Lookup for uif fonts/images
+ static uif_hdr_t UIFHeader[kMaxUifs]; // Lookup for uif fonts/images
// Initialize offset lookup if not read yet
if (firstFl) {
@@ -611,7 +612,7 @@ uif_hdr_t *FileManager::getUIFHeader(uif_t id) {
if (ip.size() < (int32)sizeof(UIFHeader))
error("Wrong file format: %s", UIF_FILE);
- for (int i = 0; i < MAX_UIFS; ++i) {
+ for (int i = 0; i < kMaxUifs; ++i) {
UIFHeader[i].size = ip.readUint16LE();
UIFHeader[i].offset = ip.readUint32LE();
}
@@ -661,5 +662,8 @@ void FileManager::readUIFImages() {
readUIFItem(UIF_IMAGES, _vm->_screen->getGUIBuffer()); // Read all uif images
}
+const char *FileManager::getBootCypher() {
+ return "Copyright 1992, David P Gray, Gray Design Associates";
+}
} // End of namespace Hugo
diff --git a/engines/hugo/file.h b/engines/hugo/file.h
index e288b27a02..7b093c68ec 100644
--- a/engines/hugo/file.h
+++ b/engines/hugo/file.h
@@ -35,26 +35,22 @@
// TODO get rid of those defines
#define HELPFILE "help.dat"
+#define BOOTFILE "HUGO.BSF" // Name of boot structure file
#define EOP '#' // Marks end of a page in help file
-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 * NUM_COLORS]; // EGA color palette
- byte vmode, planes;
- uint16 bytesPerLine; // Bytes per line
- byte fill2[60];
-}; // Header of a PCC file
-
namespace Hugo {
+
+/**
+* Enumerate overlay file types
+*/
+enum ovl_t {kOvlBoundary, kOvlOverlay, kOvlBase};
+
class FileManager {
public:
FileManager(HugoEngine *vm);
virtual ~FileManager();
-
bool fileExists(char *filename);
sound_pt getSound(int16 sound, uint16 *size);
@@ -76,14 +72,33 @@ public:
protected:
HugoEngine *_vm;
+ static const int kMaxUifs = 32; // Max possible uif items in hdr
+ static const int kMaxSounds = 64; // Max number of sounds
+ static const int kRepeatMask = 0xC0; // Top 2 bits mean a repeat code
+ static const int kLengthMask = 0x3F; // Lower 6 bits are length
+
+ /**
+ * Structure of scenery file lookup entry
+ */
+ struct sceneBlock_t {
+ uint32 scene_off;
+ uint32 scene_len;
+ uint32 b_off;
+ uint32 b_len;
+ uint32 o_off;
+ uint32 o_len;
+ uint32 ob_off;
+ uint32 ob_len;
+ };
Common::File _stringArchive; // Handle for string file
Common::File _sceneryArchive1; // Handle for scenery file
Common::File _objectsArchive; // Handle for objects file
seq_t *readPCX(Common::File &f, seq_t *seqPtr, byte *imagePtr, bool firstFl, const char *name);
-private:
+ const char *FileManager::getBootCypher();
+private:
byte *convertPCC(byte *p, uint16 y, uint16 bpl, image_pt data_p);
uif_hdr_t *getUIFHeader(uif_t id);
diff --git a/engines/hugo/file_v1d.cpp b/engines/hugo/file_v1d.cpp
index 9d764df1f4..e61d6a029c 100644
--- a/engines/hugo/file_v1d.cpp
+++ b/engines/hugo/file_v1d.cpp
@@ -64,7 +64,7 @@ void FileManager_v1d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
strcat(strcpy(buf, _vm->_screenNames[screenNum]), ovl_ext[overlayType]);
if (!fileExists(buf)) {
- for (uint32 i = 0; i < OVL_SIZE; i++)
+ for (uint32 i = 0; i < kOvlSize; i++)
image[i] = 0;
warning("File not found: %s", buf);
return;
@@ -75,7 +75,7 @@ void FileManager_v1d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
image_pt tmpImage = image; // temp ptr to overlay file
- _sceneryArchive1.read(tmpImage, OVL_SIZE);
+ _sceneryArchive1.read(tmpImage, kOvlSize);
_sceneryArchive1.close();
free(buf);
}
@@ -125,7 +125,7 @@ void FileManager_v1d::instructions() {
f.read(wrkLine, 1);
} while (*wrkLine++ != EOP);
wrkLine[-2] = '\0'; // Remove EOP and previous CR
- Utils::Box(BOX_ANY, "%s", line);
+ Utils::Box(kBoxAny, "%s", line);
wrkLine = line;
f.read(readBuf, 2); // Remove CRLF after EOP
}
diff --git a/engines/hugo/file_v1w.cpp b/engines/hugo/file_v1w.cpp
index 2033f17620..2701b67c2b 100644
--- a/engines/hugo/file_v1w.cpp
+++ b/engines/hugo/file_v1w.cpp
@@ -64,15 +64,15 @@ void FileManager_v1w::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
uint32 i = 0;
switch (overlayType) {
- case BOUNDARY:
+ case kOvlBoundary:
_sceneryArchive1.seek(sceneBlock.b_off, SEEK_SET);
i = sceneBlock.b_len;
break;
- case OVERLAY:
+ case kOvlOverlay:
_sceneryArchive1.seek(sceneBlock.o_off, SEEK_SET);
i = sceneBlock.o_len;
break;
- case OVLBASE:
+ case kOvlBase:
_sceneryArchive1.seek(sceneBlock.ob_off, SEEK_SET);
i = sceneBlock.ob_len;
break;
@@ -81,11 +81,11 @@ void FileManager_v1w::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
break;
}
if (i == 0) {
- for (i = 0; i < OVL_SIZE; i++)
+ for (i = 0; i < kOvlSize; i++)
image[i] = 0;
return;
}
- _sceneryArchive1.read(tmpImage, OVL_SIZE);
+ _sceneryArchive1.read(tmpImage, kOvlSize);
}
} // End of namespace Hugo
diff --git a/engines/hugo/file_v2d.cpp b/engines/hugo/file_v2d.cpp
index d7d4593945..a935977a7e 100644
--- a/engines/hugo/file_v2d.cpp
+++ b/engines/hugo/file_v2d.cpp
@@ -34,7 +34,6 @@
#include "hugo/hugo.h"
#include "hugo/file.h"
-#include "hugo/global.h"
#include "hugo/schedule.h"
#include "hugo/display.h"
#include "hugo/util.h"
@@ -118,15 +117,15 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
uint32 i = 0;
switch (overlayType) {
- case BOUNDARY:
+ case kOvlBoundary:
_sceneryArchive1.seek(sceneBlock.b_off, SEEK_SET);
i = sceneBlock.b_len;
break;
- case OVERLAY:
+ case kOvlOverlay:
_sceneryArchive1.seek(sceneBlock.o_off, SEEK_SET);
i = sceneBlock.o_len;
break;
- case OVLBASE:
+ case kOvlBase:
_sceneryArchive1.seek(sceneBlock.ob_off, SEEK_SET);
i = sceneBlock.ob_len;
break;
@@ -135,7 +134,7 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
break;
}
if (i == 0) {
- for (i = 0; i < OVL_SIZE; i++)
+ for (i = 0; i < kOvlSize; i++)
image[i] = 0;
return;
}
@@ -155,7 +154,7 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
for (i = 0; i < (byte)(-data + 1); i++, k++)
*tmpImage++ = j;
}
- } while (k < OVL_SIZE);
+ } while (k < kOvlSize);
}
/**
@@ -163,6 +162,7 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
*/
char *FileManager_v2d::fetchString(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);
@@ -173,18 +173,18 @@ char *FileManager_v2d::fetchString(int index) {
error("An error has occurred: bad String offset");
// Check size of string
- if ((off2 - off1) >= MAX_BOX)
+ if ((off2 - off1) >= kMaxBoxChar)
error("Fetched string too long!");
// Position to string and read it into gen purpose _textBoxBuffer
_stringArchive.seek(off1, SEEK_SET);
- if (_stringArchive.read(_textBoxBuffer, (uint16)(off2 - off1)) == 0)
+ if (_stringArchive.read(buffer, (uint16)(off2 - off1)) == 0)
error("An error has occurred: fetchString");
// Null terminate, decode and return it
- _textBoxBuffer[off2-off1] = '\0';
- _vm->_scheduler->decodeString(_textBoxBuffer);
- return _textBoxBuffer;
+ buffer[off2-off1] = '\0';
+ _vm->_scheduler->decodeString(buffer);
+ return buffer;
}
} // End of namespace Hugo
diff --git a/engines/hugo/file_v2w.cpp b/engines/hugo/file_v2w.cpp
index d25d6f9312..3b632247d2 100644
--- a/engines/hugo/file_v2w.cpp
+++ b/engines/hugo/file_v2w.cpp
@@ -48,7 +48,7 @@ FileManager_v2w::~FileManager_v2w() {
* Same comment than in SCI: maybe in the future we can implement this, but for now this message should suffice
*/
void FileManager_v2w::instructions() {
- Utils::Box(BOX_ANY, "Please use an external viewer to open the game's help file: HUGOWIN%d.HLP", _vm->_gameVariant + 1);
+ Utils::Box(kBoxAny, "Please use an external viewer to open the game's help file: HUGOWIN%d.HLP", _vm->_gameVariant + 1);
}
} // End of namespace Hugo
diff --git a/engines/hugo/file_v3d.cpp b/engines/hugo/file_v3d.cpp
index 036b46f1f3..a0a5bc1119 100644
--- a/engines/hugo/file_v3d.cpp
+++ b/engines/hugo/file_v3d.cpp
@@ -34,7 +34,6 @@
#include "hugo/hugo.h"
#include "hugo/file.h"
-#include "hugo/global.h"
#include "hugo/display.h"
#include "hugo/util.h"
@@ -127,15 +126,15 @@ void FileManager_v3d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
if (screenNum < 20) {
switch (overlayType) {
- case BOUNDARY:
+ case kOvlBoundary:
_sceneryArchive1.seek(sceneBlock.b_off, SEEK_SET);
i = sceneBlock.b_len;
break;
- case OVERLAY:
+ case kOvlOverlay:
_sceneryArchive1.seek(sceneBlock.o_off, SEEK_SET);
i = sceneBlock.o_len;
break;
- case OVLBASE:
+ case kOvlBase:
_sceneryArchive1.seek(sceneBlock.ob_off, SEEK_SET);
i = sceneBlock.ob_len;
break;
@@ -144,7 +143,7 @@ void FileManager_v3d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
break;
}
if (i == 0) {
- for (i = 0; i < OVL_SIZE; i++)
+ for (i = 0; i < kOvlSize; i++)
image[i] = 0;
return;
}
@@ -164,18 +163,18 @@ void FileManager_v3d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
for (i = 0; i < (byte)(-data + 1); i++, k++)
*tmpImage++ = j;
}
- } while (k < OVL_SIZE);
+ } while (k < kOvlSize);
} else {
switch (overlayType) {
- case BOUNDARY:
+ case kOvlBoundary:
_sceneryArchive2.seek(sceneBlock.b_off, SEEK_SET);
i = sceneBlock.b_len;
break;
- case OVERLAY:
+ case kOvlOverlay:
_sceneryArchive2.seek(sceneBlock.o_off, SEEK_SET);
i = sceneBlock.o_len;
break;
- case OVLBASE:
+ case kOvlBase:
_sceneryArchive2.seek(sceneBlock.ob_off, SEEK_SET);
i = sceneBlock.ob_len;
break;
@@ -184,7 +183,7 @@ void FileManager_v3d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
break;
}
if (i == 0) {
- for (i = 0; i < OVL_SIZE; i++)
+ for (i = 0; i < kOvlSize; i++)
image[i] = 0;
return;
}
@@ -204,7 +203,7 @@ void FileManager_v3d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
for (i = 0; i < (byte)(-data + 1); i++, k++)
*tmpImage++ = j;
}
- } while (k < OVL_SIZE);
+ } while (k < kOvlSize);
}
}
} // End of namespace Hugo
diff --git a/engines/hugo/game.h b/engines/hugo/game.h
index 398d0459c0..b742d3653f 100644
--- a/engines/hugo/game.h
+++ b/engines/hugo/game.h
@@ -46,64 +46,36 @@ namespace Hugo {
// Type "PPG" in the game to enter cheat mode.
#define COPYRIGHT "Copyright 1989-1997 David P Gray, All Rights Reserved."
+
// Started code on 04/01/95
-//#define VER "1.0" // 10/01/95 Initial Release
-//#define VER "1.1" // 10/06/95 Restore system volume levels on exit
-//#define VER "v1.2"// 10/12/95 Added "background music" checkbox in volume dlg
-//#define VER "v1.3"// 10/23/95 Support game 1 as shareware
-//#define VER "v1.4"// 12/06/95 Faster graphics, logical palette
-//#define VER "v1.5" // 10/07/97 Added order form, new web site
+// VER "1.0" // 10/01/95 Initial Release
+// VER "1.1" // 10/06/95 Restore system volume levels on exit
+// VER "v1.2" // 10/12/95 Added "background music" checkbox in volume dlg
+// VER "v1.3" // 10/23/95 Support game 1 as shareware
+// VER "v1.4" // 12/06/95 Faster graphics, logical palette
+// VER "v1.5" // 10/07/97 Added order form, new web site
// Game specific equates
-#define MAX_TUNES 16 // Max number of tunes
-#define TURBO_TPS 16 // This many in turbo mode
-#define DX 5 // Num pixels moved in x by HERO per step
-#define DY 4 // Num pixels moved in y by HERO per step
-#define XBYTES 40 // number of bytes in a compressed line
-#define XPIX 320 // Width of pcx background file
-#define YPIX 200 // Height of pcx background file
-#define VIEW_DX XPIX // Width of window view
-#define VIEW_DY 184 // Height of window view
-#define INV_DX 32 // Width of an inventory icon
-#define INV_DY 32 // Height of inventory icon
-#define DIBOFF_Y 0 // Offset into dib SrcY (old status line area). In original game: 8
-#define OVL_SIZE (XBYTES * YPIX) // Size of an overlay file
-#define MAX_SEQUENCES 4 // Number of sequences of images in object
-#define MAX_CHARS (XBYTES - 2) // Max length of user input line
-#define NUM_ROWS 25 // Number of text lines in display
-#define MAX_BOX (MAX_CHARS * NUM_ROWS) // Max chars on screen
-#define DONT_CARE 0xFF // Any state allowed in command verb
-#define MAX_FPATH 256 // Max length of a full path name
-#define HERO_MAX_WIDTH 24 // Maximum width of hero
-#define HERO_MIN_WIDTH 16 // Minimum width of hero
-#define LOOK_NAME 1 // Index of name used in showing takeables
-#define TAKE_NAME 2 // Index of name used in confirming take
#define TAKE_TEXT "Picked up the %s ok."
-#define REP_MASK 0xC0 // Top 2 bits mean a repeat code
-#define MAX_STRLEN 1024
-#define STEP_DY 8 // Pixels per step movement
-#define CENTER -1 // Used to center text in x
// Only for non-database
#define BKGEXT ".PCX" // Extension of background files
#define OBJEXT ".PIX" // Extension of object picture files
-#define NAME_LEN 12 // Max length of a DOS file name
-// Definitions of 'generic' commands: Max # depends on size of gencmd in
-// the object_t record since each requires 1 bit. Currently up to 16
-#define LOOK 1
-#define TAKE 2
-#define DROP 4
-#define LOOK_S 8 // Description depends on state of object
+// Name scenery and objects picture databases
+#define OBJECTS_FILE "objects.dat"
+#define STRING_FILE "strings.dat"
+#define SOUND_FILE "sounds.dat"
+
+// User interface database (Windows Only)
+// This file contains, between others, the bitmaps of the fonts used in the application
+#define UIF_FILE "uif.dat"
-#define NUM_COLORS 16 // Num colors to save in palette
-#define MAX_UIFS 32 // Max possible uif items in hdr
-#define NUM_FONTS 3 // Number of dib fonts
-#define FIRST_FONT U_FONT5
-#define FONT_LEN 128 // Number of chars in font
-#define FONTSIZE 1200 // Max size of font data
+enum {LOOK_NAME = 1, TAKE_NAME}; // Index of name used in showing takeables and in confirming take
-#define CRYPT "Copyright 1992, David P Gray, Gray Design Associates"
+// Definitions of 'generic' commands: Max # depends on size of gencmd in
+// the object_t record since each requires 1 bit. Currently up to 16
+enum {LOOK = 1, TAKE = 2, DROP = 4, LOOK_S = 8};
enum TEXTCOLORS {
_TBLACK, _TBLUE, _TGREEN, _TCYAN,
@@ -113,94 +85,34 @@ enum TEXTCOLORS {
};
enum uif_t {U_FONT5, U_FONT6, U_FONT8, UIF_IMAGES, NUM_UIF_ITEMS};
-
-/**
-* Enumerate overlay file types
-*/
-enum ovl_t {BOUNDARY, OVERLAY, OVLBASE};
+static const int kFirstFont = U_FONT5;
/**
* Enumerate ways of cycling a sequence of frames
*/
-enum cycle_t {INVISIBLE, ALMOST_INVISIBLE, NOT_CYCLING, CYCLE_FORWARD, CYCLE_BACKWARD};
+enum cycle_t {kCycleInvisible, kCycleAlmostInvisible, kCycleNotCycling, kCycleForward, kCycleBackward};
/**
* Enumerate sequence index matching direction of travel
*/
enum {RIGHT, LEFT, DOWN, _UP};
-/**
-* Channel requirement during sound effect
-*/
-enum stereo_t {BOTH_CHANNELS, RIGHT_CHANNEL, LEFT_CHANNEL};
-
-/**
-* Priority for sound effect
-*/
-enum priority_t {LOW_PRI, MED_PRI, HIGH_PRI};
+enum font_t {LARGE_ROMAN, MED_ROMAN, NUM_GDI_FONTS, INIT_FONTS, DEL_FONTS};
/**
* Enumerate the different path types for an object
*/
enum path_t {
- USER, // User has control of object via cursor keys
- AUTO, // Computer has control, controlled by action lists
- QUIET, // Computer has control and no commands allowed
- CHASE, // Computer has control, object is chasing hero
- CHASE2, // Same as CHASE, except keeps cycling when stationary
- WANDER, // Computer has control, object is wandering randomly
- WANDER2 // Same as WANDER, except keeps cycling when stationary
+ kPathUser, // User has control of object via cursor keys
+ kPathAuto, // Computer has control, controlled by action lists
+ kPathQuiet, // Computer has control and no commands allowed
+ kPathChase, // Computer has control, object is chasing hero
+ kPathChase2, // Same as CHASE, except keeps cycling when stationary
+ kPathWander, // Computer has control, object is wandering randomly
+ kPathWander2 // Same as WANDER, except keeps cycling when stationary
};
/**
-* Enumerate whether object is foreground, background or 'floating'
-* If floating, HERO can collide with it and fore/back ground is determined
-* by relative y-coord of object base. This is the general case.
-* If fore or background, no collisions can take place and object is either
-* behind or in front of all others, although can still be hidden by the
-* the overlay plane. OVEROVL means the object is FLOATING (to other
-* objects) but is never hidden by the overlay plane
-*/
-enum {FOREGROUND, BACKGROUND, FLOATING, OVEROVL};
-
-/**
-* Game view state machine
-*/
-enum vstate_t {V_IDLE, V_INTROINIT, V_INTRO, V_PLAY, V_INVENT, V_EXIT};
-
-enum font_t {LARGE_ROMAN, MED_ROMAN, NUM_GDI_FONTS, INIT_FONTS, DEL_FONTS};
-
-/**
-* Ways to dismiss a text/prompt box
-*/
-enum box_t {BOX_ANY, BOX_OK, BOX_PROMPT, BOX_YESNO};
-
-/**
-* Display list functions
-*/
-enum dupdate_t {D_INIT, D_ADD, D_DISPLAY, D_RESTORE};
-
-/**
-* General device installation commands
-*/
-enum inst_t {INSTALL, RESTORE, RESET};
-
-/**
-* Inventory icon bar states
-*/
-enum istate_t {I_OFF, I_UP, I_DOWN, I_ACTIVE};
-
-/**
-* Actions for Process_inventory()
-*/
-enum invact_t {INV_INIT, INV_LEFT, INV_RIGHT, INV_GET};
-
-/**
-* Purpose of an automatic route
-*/
-enum go_t {GO_SPACE, GO_EXIT, GO_LOOK, GO_GET};
-
-/**
* Following defines the action types and action list
*/
enum action_t { // Parameters:
@@ -296,412 +208,6 @@ struct maze_t {
byte firstScreenIndex; // index of first screen in maze
};
-struct act0 { // Type 0 - Schedule
- action_t actType; // The type of action
- int timer; // Time to set off the action
- uint16 actIndex; // Ptr to an action list
-};
-
-struct act1 { // Type 1 - Start an object
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int cycleNumb; // Number of times to cycle
- cycle_t cycle; // Direction to start cycling
-};
-
-struct act2 { // Type 2 - Initialise an object coords
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int x, y; // Coordinates
-};
-
-struct act3 { // Type 3 - Prompt user for text
- action_t actType; // The type of action
- int timer; // Time to set off the action
- uint16 promptIndex; // Index of prompt string
- int *responsePtr; // Array of indexes to valid response
- // string(s) (terminate list with -1)
- uint16 actPassIndex; // Ptr to action list if success
- uint16 actFailIndex; // Ptr to action list if failure
- bool encodedFl; // (HUGO 1 DOS ONLY) Whether response is encoded or not
-};
-
-struct act4 { // Type 4 - Set new background color
- action_t actType; // The type of action
- int timer; // Time to set off the action
- long newBackgroundColor; // New color
-};
-
-struct act5 { // Type 5 - Initialise an object velocity
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int vx, vy; // velocity
-};
-
-struct act6 { // Type 6 - Initialise an object carrying
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- bool carriedFl; // carrying
-};
-
-struct act7 { // Type 7 - Initialise an object to hero's coords
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
-};
-
-struct act8 { // Type 8 - switch to new screen
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int screenIndex; // The new screen number
-};
-
-struct act9 { // Type 9 - Initialise an object state
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- byte newState; // New state
-};
-
-struct act10 { // Type 10 - Initialise an object path type
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int newPathType; // New path type
- int8 vxPath, vyPath; // Max delta velocities e.g. for CHASE
-};
-
-struct act11 { // Type 11 - Conditional on object's state
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- byte stateReq; // Required state
- uint16 actPassIndex; // Ptr to action list if success
- uint16 actFailIndex; // Ptr to action list if failure
-};
-
-struct act12 { // Type 12 - Simple text box
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int stringIndex; // Index (enum) of string in strings.dat
-};
-
-struct act13 { // Type 13 - Swap first object image with second
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex1; // Index of first object
- int objIndex2; // 2nd
-};
-
-struct act14 { // Type 14 - Conditional on current screen
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The required object
- int screenReq; // The required screen number
- uint16 actPassIndex; // Ptr to action list if success
- uint16 actFailIndex; // Ptr to action list if failure
-};
-
-struct act15 { // Type 15 - Home in on an object
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex1; // The object number homing in
- int objIndex2; // The object number to home in on
- int8 dx, dy; // Max delta velocities
-};
-// Note: Don't set a sequence at time 0 of a new screen, it causes
-// problems clearing the boundary bits of the object! timer > 0 is safe
-struct act16 { // Type 16 - Set curr_seq_p to seq
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int seqIndex; // The index of seq array to set to
-};
-
-struct act17 { // Type 17 - SET obj individual state bits
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int stateMask; // The mask to OR with current obj state
-};
-
-struct act18 { // Type 18 - CLEAR obj individual state bits
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int stateMask; // The mask to ~AND with current obj state
-};
-
-struct act19 { // Type 19 - TEST obj individual state bits
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int stateMask; // The mask to AND with current obj state
- uint16 actPassIndex; // Ptr to action list (all bits set)
- uint16 actFailIndex; // Ptr to action list (not all set)
-};
-
-struct act20 { // Type 20 - Remove all events with this type of action
- action_t actType; // The type of action
- int timer; // Time to set off the action
- action_t actTypeDel; // The action type to remove
-};
-
-struct act21 { // Type 21 - Gameover. Disable hero & commands
- action_t actType; // The type of action
- int timer; // Time to set off the action
-};
-
-struct act22 { // Type 22 - Initialise an object to hero's coords
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
-};
-
-struct act23 { // Type 23 - Exit game back to DOS
- action_t actType; // The type of action
- int timer; // Time to set off the action
-};
-
-struct act24 { // Type 24 - Get bonus score
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int pointIndex; // Index into points array
-};
-
-struct act25 { // Type 25 - Conditional on bounding box
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The required object number
- int x1, y1, x2, y2; // The bounding box
- uint16 actPassIndex; // Ptr to action list if success
- uint16 actFailIndex; // Ptr to action list if failure
-};
-
-struct act26 { // Type 26 - Play a sound
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int16 soundIndex; // Sound index in data file
-};
-
-struct act27 { // Type 27 - Add object's value to score
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // object number
-};
-
-struct act28 { // Type 28 - Subtract object's value from score
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // object number
-};
-
-struct act29 { // Type 29 - Conditional on object carried
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The required object number
- uint16 actPassIndex; // Ptr to action list if success
- uint16 actFailIndex; // Ptr to action list if failure
-};
-
-struct act30 { // Type 30 - Start special maze processing
- action_t actType; // The type of action
- int timer; // Time to set off the action
- byte mazeSize; // Size of (square) maze
- int x1, y1, x2, y2; // Bounding box of maze
- int x3, x4; // Extra x points for perspective correction
- byte firstScreenIndex; // First (top left) screen of maze
-};
-
-struct act31 { // Type 31 - Exit special maze processing
- action_t actType; // The type of action
- int timer; // Time to set off the action
-};
-
-struct act32 { // Type 32 - Init fbg field of object
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- byte priority; // Value of foreground/background field
-};
-
-struct act33 { // Type 33 - Init screen field of object
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int screenIndex; // Screen number
-};
-
-struct act34 { // Type 34 - Global Schedule
- action_t actType; // The type of action
- int timer; // Time to set off the action
- uint16 actIndex; // Ptr to an action list
-};
-
-struct act35 { // Type 35 - Remappe palette
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int16 oldColorIndex; // Old color index, 0..15
- int16 newColorIndex; // New color index, 0..15
-};
-
-struct act36 { // Type 36 - Conditional on noun mentioned
- action_t actType; // The type of action
- int timer; // Time to set off the action
- uint16 nounIndex; // The required noun (list)
- uint16 actPassIndex; // Ptr to action list if success
- uint16 actFailIndex; // Ptr to action list if failure
-};
-
-struct act37 { // Type 37 - Set new screen state
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int screenIndex; // The screen number
- byte newState; // The new state
-};
-
-struct act38 { // Type 38 - Position lips
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int lipsObjIndex; // The LIPS object
- int objIndex; // The object to speak
- byte dxLips; // Relative offset of x
- byte dyLips; // Relative offset of y
-};
-
-struct act39 { // Type 39 - Init story mode
- action_t actType; // The type of action
- int timer; // Time to set off the action
- bool storyModeFl; // New state of story_mode flag
-};
-
-struct act40 { // Type 40 - Unsolicited text box
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int stringIndex; // Index (enum) of string in strings.dat
-};
-
-struct act41 { // Type 41 - Conditional on bonus scored
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int BonusIndex; // Index into bonus list
- uint16 actPassIndex; // Index of the action list if scored for the first time
- uint16 actFailIndex; // Index of the action list if already scored
-};
-
-struct act42 { // Type 42 - Text box with "take" string
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object taken
-};
-
-struct act43 { // Type 43 - Prompt user for Yes or No
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int promptIndex; // index of prompt string
- uint16 actYesIndex; // Ptr to action list if YES
- uint16 actNoIndex; // Ptr to action list if NO
-};
-
-struct act44 { // Type 44 - Stop any route in progress
- action_t actType; // The type of action
- int timer; // Time to set off the action
-};
-
-struct act45 { // Type 45 - Conditional on route in progress
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int routeIndex; // Must be >= current status.rindex
- uint16 actPassIndex; // Ptr to action list if en-route
- uint16 actFailIndex; // Ptr to action list if not
-};
-
-struct act46 { // Type 46 - Init status.jumpexit
- action_t actType; // The type of action
- int timer; // Time to set off the action
- bool jumpExitFl; // New state of jumpexit flag
-};
-
-struct act47 { // Type 47 - Init viewx,viewy,dir
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object
- int16 viewx; // object.viewx
- int16 viewy; // object.viewy
- int16 direction; // object.dir
-};
-
-struct act48 { // Type 48 - Set curr_seq_p to frame n
- action_t actType; // The type of action
- int timer; // Time to set off the action
- int objIndex; // The object number
- int seqIndex; // The index of seq array to set to
- int frameIndex; // The index of frame to set to
-};
-
-struct act49 { // Added by Strangerke - Type 79 - Play a song (DOS way)
- action_t actType; // The type of action
- int timer; // Time to set off the action
- uint16 songIndex; // Song index in string array
-};
-
-union act {
- act0 a0;
- act1 a1;
- act2 a2;
- act3 a3;
- act4 a4;
- act5 a5;
- act6 a6;
- act7 a7;
- act8 a8;
- act9 a9;
- act10 a10;
- act11 a11;
- act12 a12;
- act13 a13;
- act14 a14;
- act15 a15;
- act16 a16;
- act17 a17;
- act18 a18;
- act19 a19;
- act20 a20;
- act21 a21;
- act22 a22;
- act23 a23;
- act24 a24;
- act25 a25;
- act26 a26;
- act27 a27;
- act28 a28;
- act29 a29;
- act30 a30;
- act31 a31;
- act32 a32;
- act33 a33;
- act34 a34;
- act35 a35;
- act36 a36;
- act37 a37;
- act38 a38;
- act39 a39;
- act40 a40;
- act41 a41;
- act42 a42;
- act43 a43;
- act44 a44;
- act45 a45;
- act46 a46;
- act47 a47;
- act48 a48;
- act49 a49;
-};
-
/**
* The following determines how a verb is acted on, for an object
*/
@@ -737,43 +243,6 @@ struct seqList_t {
};
/**
-* Following is definition of object attributes
-*/
-struct object_t {
- uint16 nounIndex; // String identifying object
- uint16 dataIndex; // String describing the object
- uint16 *stateDataIndex; // Added by Strangerke to handle the LOOK_S state-dependant descriptions
- path_t pathType; // Describe path object follows
- int vxPath, vyPath; // Delta velocities (e.g. for CHASE)
- uint16 actIndex; // Action list to do on collision with hero
- byte seqNumb; // Number of sequences in list
- seq_t *currImagePtr; // Sequence image currently in use
- seqList_t seqList[MAX_SEQUENCES]; // Array of sequence structure ptrs and lengths
- cycle_t cycling; // Whether cycling, forward or backward
- byte cycleNumb; // No. of times to cycle
- byte frameInterval; // Interval (in ticks) between frames
- byte frameTimer; // Decrementing timer for above
- int8 radius; // Defines sphere of influence by hero
- byte screenIndex; // Screen in which object resides
- int x, y; // Current coordinates of object
- int oldx, oldy; // Previous coordinates of object
- int8 vx, vy; // Velocity
- byte objValue; // Value of object
- int genericCmd; // Bit mask of 'generic' commands for object
- uint16 cmdIndex; // ptr to list of cmd structures for verbs
- bool carriedFl; // TRUE if object being carried
- byte state; // state referenced in cmd list
- bool verbOnlyFl; // TRUE if verb-only cmds allowed e.g. sit,look
- byte priority; // Whether object fore, background or floating
- int16 viewx, viewy; // Position to view object from (or 0 or -1)
- int16 direction; // Direction to view object from
- byte curSeqNum; // Save which seq number currently in use
- byte curImageNum; // Save which image of sequence currently in use
- int8 oldvx; // Previous vx (used in wandering)
- int8 oldvy; // Previous vy
-};
-
-/**
* Following is structure of verbs and nouns for 'background' objects
* These are objects that appear in the various screens, but nothing
* interesting ever happens with them. Rather than just be dumb and say
@@ -790,67 +259,6 @@ struct background_t {
typedef background_t *objectList_t;
-typedef byte overlay_t[OVL_SIZE]; // Overlay file
-typedef byte viewdib_t[(long)XPIX *YPIX]; // Viewport dib
-typedef byte icondib_t[XPIX *INV_DY]; // Icon bar dib
-
-typedef char command_t[MAX_CHARS + 8]; // Command line (+spare for prompt,cursor)
-typedef char fpath_t[MAX_FPATH]; // File path
-
-/**
-* Structure to define an EXIT or other collision-activated hotspot
-*/
-struct hotspot_t {
- int screenIndex; // Screen in which hotspot appears
- int x1, y1, x2, y2; // Bounding box of hotspot
- uint16 actIndex; // Actions to carry out if a 'hit'
- int16 viewx, viewy, direction; // Used in auto-route mode
-};
-
-struct status_t { // Game status (not saved)
- bool storyModeFl; // Game is telling story - no commands
- bool gameOverFl; // Game is over - hero knobbled
- bool demoFl; // Game is in demo mode
- bool textBoxFl; // Game is (halted) in text box
- bool lookFl; // Toolbar "look" button pressed
- bool recallFl; // Toolbar "recall" button pressed
- bool leftButtonFl; // Left mouse button pressed
- bool rightButtonFl; // Right button pressed
- bool newScreenFl; // New screen just loaded in dib_a
- bool jumpExitFl; // Allowed to jump to a screen exit
- bool godModeFl; // Allow DEBUG features in live version
- bool helpFl; // Calling WinHelp (don't disable music)
- bool doQuitFl;
- bool skipIntroFl;
- uint32 tick; // Current time in ticks
- vstate_t viewState; // View state machine
- istate_t inventoryState; // Inventory icon bar state
- int16 inventoryHeight; // Inventory icon bar height
- int16 inventoryObjId; // Inventory object selected, or -1
- int16 routeIndex; // Index into route list, or -1
- go_t go_for; // Purpose of an automatic route
- int16 go_id; // Index of exit of object walking to
- fpath_t path; // Alternate path for saved files
- int16 song; // Current song
- int16 cx, cy; // Cursor position (dib coords)
-
-// Strangerke - Suppress as related to playback
-// bool playbackFl; // Game is in playback mode
-// bool recordFl; // Game is in record mode
-// Strangerke - Not used ?
-// bool mmtimeFl; // Multimedia timer supported
-// int16 screenWidth; // Desktop screen width
-// uint32 saveTick; // Time of last save in ticks
-// int16 saveSlot; // Current slot to save/restore game
-};
-
-struct config_t { // User's config (saved)
- bool musicFl; // State of Music button/menu item
- bool soundFl; // State of Sound button/menu item
- bool turboFl; // State of Turbo button/menu item
- bool playlist[MAX_TUNES]; // Tune playlist
-};
-
struct target_t { // Secondary target for action
uint16 nounIndex; // Secondary object
uint16 verbIndex; // Action on secondary object
@@ -863,25 +271,8 @@ struct uses_t { // Define uses of certain ob
};
// Global externs
-extern config_t _config; // User's config
extern maze_t _maze; // Maze control structure
extern hugo_boot_t _boot; // Boot info structure
-extern char _textBoxBuffer[]; // Useful box text buffer
-extern command_t _line; // Line of user text input
-
-/**
-* Structure of scenery file lookup entry
-*/
-struct sceneBlock_t {
- uint32 scene_off;
- uint32 scene_len;
- uint32 b_off;
- uint32 b_len;
- uint32 o_off;
- uint32 o_len;
- uint32 ob_off;
- uint32 ob_len;
-};
#include "common/pack-start.h" // START STRUCT PACKING
struct sound_hdr_t { // Sound file lookup entry
@@ -890,6 +281,44 @@ struct sound_hdr_t { // Sound file lookup entry
} PACKED_STRUCT;
#include "common/pack-end.h" // END STRUCT PACKING
+static const int kMaxSeqNumb = 4; // Number of sequences of images in object
+
+/**
+* Following is definition of object attributes
+*/
+struct object_t {
+ uint16 nounIndex; // String identifying object
+ uint16 dataIndex; // String describing the object
+ uint16 *stateDataIndex; // Added by Strangerke to handle the LOOK_S state-dependant descriptions
+ path_t pathType; // Describe path object follows
+ int vxPath, vyPath; // Delta velocities (e.g. for CHASE)
+ uint16 actIndex; // Action list to do on collision with hero
+ byte seqNumb; // Number of sequences in list
+ seq_t *currImagePtr; // Sequence image currently in use
+ seqList_t seqList[kMaxSeqNumb]; // Array of sequence structure ptrs and lengths
+ cycle_t cycling; // Whether cycling, forward or backward
+ byte cycleNumb; // No. of times to cycle
+ byte frameInterval; // Interval (in ticks) between frames
+ byte frameTimer; // Decrementing timer for above
+ int8 radius; // Defines sphere of influence by hero
+ byte screenIndex; // Screen in which object resides
+ int x, y; // Current coordinates of object
+ int oldx, oldy; // Previous coordinates of object
+ int8 vx, vy; // Velocity
+ byte objValue; // Value of object
+ int genericCmd; // Bit mask of 'generic' commands for object
+ uint16 cmdIndex; // ptr to list of cmd structures for verbs
+ bool carriedFl; // TRUE if object being carried
+ byte state; // state referenced in cmd list
+ bool verbOnlyFl; // TRUE if verb-only cmds allowed e.g. sit,look
+ byte priority; // Whether object fore, background or floating
+ int16 viewx, viewy; // Position to view object from (or 0 or -1)
+ int16 direction; // Direction to view object from
+ byte curSeqNum; // Save which seq number currently in use
+ byte curImageNum; // Save which image of sequence currently in use
+ int8 oldvx; // Previous vx (used in wandering)
+ int8 oldvy; // Previous vy
+};
} // End of namespace Hugo
#endif
diff --git a/engines/hugo/global.h b/engines/hugo/global.h
deleted file mode 100644
index d44b5cb44f..0000000000
--- a/engines/hugo/global.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 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
- *
- */
-
-namespace Hugo {
-
-#define HERO 0 // In all enums, HERO is the first element
-
-#define DESCRIPLEN 32 // Length of description string
-#define MAX_SOUNDS 64 // Max number of sounds
-#define BOOTFILE "HUGO.BSF" // Name of boot structure file
-#define LEN_MASK 0x3F // Lower 6 bits are length
-
-// Name scenery and objects picture databases
-#define OBJECTS_FILE "objects.dat"
-#define STRING_FILE "strings.dat"
-#define SOUND_FILE "sounds.dat"
-
-// User interface database (Windows Only)
-// This file contains, between others, the bitmaps of the fonts used in the application
-#define UIF_FILE "uif.dat"
-} // End of namespace Hugo
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index dd26f21b51..45bd520167 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -30,7 +30,6 @@
#include "common/debug-channels.h"
#include "hugo/hugo.h"
-#include "hugo/global.h"
#include "hugo/game.h"
#include "hugo/file.h"
#include "hugo/schedule.h"
@@ -55,11 +54,8 @@ overlay_t HugoEngine::_overlay;
overlay_t HugoEngine::_ovlBase;
overlay_t HugoEngine::_objBound;
-config_t _config; // User's config
-maze_t _maze; // Default to not in maze
+maze_t _maze; // Default to not in maze
hugo_boot_t _boot; // Boot info structure file
-char _textBoxBuffer[MAX_BOX]; // Buffer for text box
-command_t _line; // Line of user text input
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), _textUtil(0),
@@ -264,14 +260,14 @@ Common::Error HugoEngine::run() {
_screen->resetInventoryObjId();
initStatus(); // Initialize game status
- initConfig(INSTALL); // Initialize user's config
+ initConfig(); // Initialize user's config
initialize();
- initConfig(RESET); // Reset user's config
+ resetConfig(); // Reset user's config
initMachine();
// Start the state machine
- _status.viewState = V_INTROINIT;
+ _status.viewState = kViewIntroInit;
_status.doQuitFl = false;
@@ -314,7 +310,7 @@ Common::Error HugoEngine::run() {
}
}
_mouse->mouseHandler(); // Mouse activity - adds to display list
- _screen->displayList(D_DISPLAY); // Blit the display list to screen
+ _screen->displayList(kDisplayDisplay); // Blit the display list to screen
_status.doQuitFl |= shouldQuit(); // update game quit flag
}
@@ -356,36 +352,36 @@ void HugoEngine::runMachine() {
lastTime = curTime;
switch (gameStatus.viewState) {
- case V_IDLE: // Not processing state machine
+ case kViewIdle: // Not processing state machine
_screen->hideCursor();
_intro->preNewGame(); // Any processing before New Game selected
break;
- case V_INTROINIT: // Initialization before intro begins
+ case kViewIntroInit: // Initialization before intro begins
_intro->introInit();
- gameStatus.viewState = V_INTRO;
+ gameStatus.viewState = kViewIntro;
break;
- case V_INTRO: // Do any game-dependant preamble
+ case kViewIntro: // Do any game-dependant preamble
if (_intro->introPlay()) { // Process intro screen
_scheduler->newScreen(0); // Initialize first screen
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
}
break;
- case V_PLAY: // Playing game
+ case kViewPlay: // Playing game
_screen->showCursor();
_parser->charHandler(); // Process user cmd input
_object->moveObjects(); // Process object movement
_scheduler->runScheduler(); // Process any actions
- _screen->displayList(D_RESTORE); // Restore previous background
+ _screen->displayList(kDisplayRestore); // Restore previous background
_object->updateImages(); // Draw into _frontBuffer, compile display list
_screen->drawStatusText();
- _screen->displayList(D_DISPLAY); // Blit the display list to screen
+ _screen->displayList(kDisplayDisplay); // Blit the display list to screen
_sound->checkMusic();
break;
- case V_INVENT: // Accessing inventory
+ case kViewInvent: // Accessing inventory
_inventory->runInventory(); // Process Inventory state machine
break;
- case V_EXIT: // Game over or user exited
- gameStatus.viewState = V_IDLE;
+ case kViewExit: // Game over or user exited
+ gameStatus.viewState = kViewIdle;
_status.doQuitFl = true;
break;
}
@@ -698,9 +694,9 @@ bool HugoEngine::loadHugoDat() {
_object->loadObjectArr(in);
- _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
+ _hero = &_object->_objects[kHeroIndex]; // This always points to hero
+ _screen_p = &(_object->_objects[kHeroIndex].screenIndex); // Current screen is hero's
+ _heroImage = kHeroIndex; // Current in use hero image
_scheduler->loadActListArr(in);
@@ -908,10 +904,10 @@ void HugoEngine::freeTexts(char **ptr) {
/**
* Sets the playlist to be the default tune selection
*/
-void HugoEngine::initPlaylist(bool playlist[MAX_TUNES]) {
+void HugoEngine::initPlaylist(bool playlist[kMaxTunes]) {
debugC(1, kDebugEngine, "initPlaylist");
- for (int16 i = 0; i < MAX_TUNES; i++)
+ for (int16 i = 0; i < kMaxTunes; i++)
playlist[i] = false;
for (int16 i = 0; _defltTunes[i] != -1; i++)
playlist[_defltTunes[i]] = true;
@@ -940,12 +936,12 @@ void HugoEngine::initStatus() {
// Initialize every start of new game
_status.tick = 0; // Tick count
- _status.viewState = V_IDLE; // View state
- _status.inventoryState = I_OFF; // Inventory icon bar state
+ _status.viewState = kViewIdle; // View state
+ _status.inventoryState = kInventoryOff; // Inventory icon bar state
_status.inventoryHeight = 0; // Inventory icon bar pos
_status.inventoryObjId = -1; // Inventory object selected (none)
_status.routeIndex = -1; // Hero not following a route
- _status.go_for = GO_SPACE; // Hero walking to space
+ _status.go_for = kRouteSpace; // Hero walking to space
_status.go_id = -1; // Hero not walking to anything
// Strangerke - Suppress as related to playback
@@ -960,31 +956,29 @@ void HugoEngine::initStatus() {
/**
* Initialize default config values. Must be done before Initialize().
-* Reset needed to save config.cx,cy which get splatted during OnFileNew()
*/
-void HugoEngine::initConfig(inst_t action) {
- debugC(1, kDebugEngine, "initConfig(%d)", action);
-
- switch (action) {
- case INSTALL:
- _config.musicFl = true; // Music state initially on
- _config.soundFl = true; // Sound state initially on
- _config.turboFl = false; // Turbo state initially off
- initPlaylist(_config.playlist); // Initialize default tune playlist
- _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);
- break;
- }
+void HugoEngine::initConfig() {
+ debugC(1, kDebugEngine, "initConfig()");
+
+ _config.musicFl = true; // Music state initially on
+ _config.soundFl = true; // Sound state initially on
+ _config.turboFl = false; // Turbo state initially off
+ initPlaylist(_config.playlist); // Initialize default tune playlist
+ _file->readBootFile(); // Read startup structure
+}
+
+/**
+* Reset config parts. Currently only reset music played based on playlist
+*/
+void HugoEngine::resetConfig() {
+ debugC(1, kDebugEngine, "resetConfig()");
+
+ // Find first tune and play it
+ for (int16 i = 0; i < kMaxTunes; i++) {
+ if (_config.playlist[i]) {
+ _sound->playMusic(i);
+ break;
}
- break;
- case RESTORE:
- warning("Unhandled action RESTORE");
- break;
}
}
@@ -1051,16 +1045,15 @@ 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
+ memcpy(_screen->getBackBuffer(), _screen->getFrontBuffer(), sizeof(_screen->getFrontBuffer())); // Make a copy
+ _file->readOverlay(screenNum, _boundary, kOvlBoundary); // Boundary file
+ _file->readOverlay(screenNum, _overlay, kOvlOverlay); // Overlay file
+ _file->readOverlay(screenNum, _ovlBase, kOvlBase); // Overlay base file
// Suppress a boundary used in H3 DOS in 'Crash' screen, which blocks
// pathfinding and is useless.
if ((screenNum == 0) && (_gameVariant == kGameVariantH3Dos))
clearScreenBoundary(50, 311, 152);
-
}
/**
@@ -1088,7 +1081,7 @@ int HugoEngine::deltaX(int x1, int x2, int vx, int y) {
if (vx == 0)
return 0 ; // Object stationary
- y *= XBYTES; // Offset into boundary file
+ y *= kCompLineSize; // Offset into boundary file
if (vx > 0) {
// Moving to right
for (int i = x1 >> 3; i <= (x2 + vx) >> 3; i++) {// Search by byte
@@ -1129,7 +1122,7 @@ int HugoEngine::deltaY(int x1, int x2, int vy, int y) {
int inc = (vy > 0) ? 1 : -1;
for (int j = y + inc; j != (y + vy + inc); j += inc) { //Search by byte
for (int i = x1 >> 3; i <= x2 >> 3; i++) {
- int b = _boundary[j * XBYTES + i] | _objBound[j * XBYTES + i];
+ int b = _boundary[j * kCompLineSize + i] | _objBound[j * kCompLineSize + i];
if (b != 0) { // Any bit set
// Make sure boundary bits fall on line segment
if (i == (x2 >> 3)) // Adjust right end
@@ -1151,7 +1144,7 @@ void HugoEngine::storeBoundary(int x1, int x2, int y) {
debugC(5, kDebugEngine, "storeBoundary(%d, %d, %d)", x1, x2, y);
for (int i = x1 >> 3; i <= x2 >> 3; i++) { // For each byte in line
- byte *b = &_objBound[y * XBYTES + i]; // get boundary byte
+ byte *b = &_objBound[y * kCompLineSize + i];// get boundary byte
if (i == x2 >> 3) // Adjust right end
*b |= 0xff << ((i << 3) + 7 - x2);
else if (i == x1 >> 3) // Adjust left end
@@ -1168,7 +1161,7 @@ void HugoEngine::clearBoundary(int x1, int x2, int y) {
debugC(5, kDebugEngine, "clearBoundary(%d, %d, %d)", x1, x2, y);
for (int i = x1 >> 3; i <= x2 >> 3; i++) { // For each byte in line
- byte *b = &_objBound[y * XBYTES + i]; // get boundary byte
+ byte *b = &_objBound[y * kCompLineSize + i];// get boundary byte
if (i == x2 >> 3) // Adjust right end
*b &= ~(0xff << ((i << 3) + 7 - x2));
else if (i == x1 >> 3) // Adjust left end
@@ -1186,7 +1179,7 @@ void HugoEngine::clearScreenBoundary(int x1, int x2, int y) {
debugC(5, kDebugEngine, "clearScreenBoundary(%d, %d, %d)", x1, x2, y);
for (int i = x1 >> 3; i <= x2 >> 3; i++) { // For each byte in line
- byte *b = &_boundary[y * XBYTES + i]; // get boundary byte
+ byte *b = &_boundary[y * kCompLineSize + i];// get boundary byte
if (i == x2 >> 3) // Adjust right end
*b &= ~(0xff << ((i << 3) + 7 - x2));
else if (i == x1 >> 3) // Adjust left end
@@ -1207,7 +1200,7 @@ char *HugoEngine::useBG(char *name) {
for (int i = 0; p[i].verbIndex != 0; i++) {
if ((name == _arrayNouns[p[i].nounIndex][0] &&
p[i].verbIndex != _look) &&
- ((p[i].roomState == DONT_CARE) || (p[i].roomState == _screenStates[*_screen_p])))
+ ((p[i].roomState == kStateDontCare) || (p[i].roomState == _screenStates[*_screen_p])))
return _arrayVerbs[p[i].verbIndex][0];
}
@@ -1267,7 +1260,7 @@ void HugoEngine::boundaryCollision(object_t *obj) {
// If object's radius is infinity, use a closer value
int8 radius = obj->radius;
if (radius < 0)
- radius = DX * 2;
+ radius = kStepDx * 2;
if ((abs(dx) <= radius) && (abs(dy) <= radius))
_scheduler->insertActionList(obj->actIndex);
}
@@ -1292,9 +1285,9 @@ void HugoEngine::endGame() {
debugC(1, kDebugEngine, "endGame");
if (!_boot.registered)
- Utils::Box(BOX_ANY, "%s", _textEngine[kEsAdvertise]);
- Utils::Box(BOX_ANY, "%s\n%s", _episode, COPYRIGHT);
- _status.viewState = V_EXIT;
+ Utils::Box(kBoxAny, "%s", _textEngine[kEsAdvertise]);
+ Utils::Box(kBoxAny, "%s\n%s", _episode, COPYRIGHT);
+ _status.viewState = kViewExit;
}
bool HugoEngine::canLoadGameStateCurrently() {
@@ -1302,11 +1295,11 @@ bool HugoEngine::canLoadGameStateCurrently() {
}
bool HugoEngine::canSaveGameStateCurrently() {
- return (_status.viewState == V_PLAY);
+ return (_status.viewState == kViewPlay);
}
int8 HugoEngine::getTPS() {
- return ((_config.turboFl) ? TURBO_TPS : _normalTPS);
+ return ((_config.turboFl) ? kTurboTps : _normalTPS);
}
void HugoEngine::syncSoundSettings() {
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index d41a23a037..a3dd20fe27 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -38,9 +38,6 @@
#define HUGO_DAT_VER_MAJ 0 // 1 byte
#define HUGO_DAT_VER_MIN 40 // 1 byte
#define DATAALIGNMENT 4
-#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
namespace Common {
class RandomSource;
@@ -62,6 +59,54 @@ class RandomSource;
namespace Hugo {
static const int kSavegameVersion = 2;
+static const int kInvDx = 32; // Width of an inventory icon
+static const int kInvDy = 32; // Height of inventory icon
+static const int kMaxTunes = 16; // Max number of tunes
+static const int kStepDx = 5; // Num pixels moved in x by HERO per step
+static const int kStepDy = 4; // Num pixels moved in y by HERO per step
+static const int kXPix = 320; // Width of pcx background file
+static const int kYPix = 200; // Height of pcx background file
+static const int kViewSizeX = kXPix; // Width of window view
+static const int kViewSizeY = 184; // Height of window view
+static const int kDibOffY = 0; // Offset into dib SrcY (old status line area). In original game: 8
+static const int kCompLineSize = 40; // number of bytes in a compressed line
+static const int kMaxLineSize = kCompLineSize - 2; // Max length of user input line
+static const int kMaxTextRows = 25; // Number of text lines in display
+static const int kMaxBoxChar = kMaxLineSize * kMaxTextRows; // Max chars on screen
+static const int kOvlSize = kCompLineSize * kYPix; // Size of an overlay file
+static const int kStateDontCare = 0xFF; // Any state allowed in command verb
+static const int kHeroIndex = 0; // In all enums, HERO is the first element
+static const int kArrowNumb = 2; // Number of arrows (left/right)
+static const int kLeftArrow = -2; // Cursor over Left arrow in inventory icon bar
+static const int kRightArrow = -3; // Cursor over Right arrow in inventory icon bar
+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
+ bool turboFl; // State of Turbo button/menu item
+ bool playlist[kMaxTunes]; // Tune playlist
+};
+
+typedef byte icondib_t[kXPix * kInvDy]; // Icon bar dib
+typedef byte viewdib_t[(long)kXPix * kYPix]; // Viewport dib
+typedef byte overlay_t[kOvlSize]; // Overlay file
enum GameType {
kGameTypeNone = 0,
@@ -92,6 +137,47 @@ enum HugoDebugChannels {
kDebugMusic = 1 << 9
};
+/**
+* Ways to dismiss a text/prompt box
+*/
+enum box_t {kBoxAny, kBoxOk, kBoxPrompt, kBoxYesNo};
+
+/**
+* Inventory icon bar states
+*/
+enum istate_t {kInventoryOff, kInventoryUp, kInventoryDown, kInventoryActive};
+
+/**
+* Game view state machine
+*/
+enum vstate_t {kViewIdle, kViewIntroInit, kViewIntro, kViewPlay, kViewInvent, kViewExit};
+
+/**
+* Purpose of an automatic route
+*/
+enum go_t {kRouteSpace, kRouteExit, kRouteLook, kRouteGet};
+
+/**
+* Enumerate whether object is foreground, background or 'floating'
+* If floating, HERO can collide with it and fore/back ground is determined
+* by relative y-coord of object base. This is the general case.
+* If fore or background, no collisions can take place and object is either
+* behind or in front of all others, although can still be hidden by the
+* the overlay plane. OVEROVL means the object is FLOATING (to other
+* objects) but is never hidden by the overlay plane
+*/
+enum {kPriorityForeground, kPriorityBackground, kPriorityFloating, kPriorityOverOverlay};
+
+/**
+* Display list functions
+*/
+enum dupdate_t {kDisplayInit, kDisplayAdd, kDisplayDisplay, kDisplayRestore};
+
+/**
+* Priority for sound effect
+*/
+enum priority_t {kSoundPriorityLow, kSoundPriorityMedium, kSoundPriorityHigh};
+
enum HugoGameFeatures {
GF_PACKED = (1 << 0) // Database
};
@@ -100,8 +186,56 @@ enum HugoGameFeatures {
enum seqTextEngine {
kEsAdvertise = 0
};
+
struct HugoGameDescription;
+struct status_t { // Game status (not saved)
+ bool storyModeFl; // Game is telling story - no commands
+ bool gameOverFl; // Game is over - hero knobbled
+ bool demoFl; // Game is in demo mode
+ bool textBoxFl; // Game is (halted) in text box
+ bool lookFl; // Toolbar "look" button pressed
+ bool recallFl; // Toolbar "recall" button pressed
+ bool leftButtonFl; // Left mouse button pressed
+ bool rightButtonFl; // Right button pressed
+ bool newScreenFl; // New screen just loaded in dib_a
+ bool jumpExitFl; // Allowed to jump to a screen exit
+ bool godModeFl; // Allow DEBUG features in live version
+ bool helpFl; // Calling WinHelp (don't disable music)
+ bool doQuitFl;
+ bool skipIntroFl;
+ uint32 tick; // Current time in ticks
+ vstate_t viewState; // View state machine
+ istate_t inventoryState; // Inventory icon bar state
+ int16 inventoryHeight; // Inventory icon bar height
+ int16 inventoryObjId; // Inventory object selected, or -1
+ int16 routeIndex; // Index into route list, or -1
+ go_t go_for; // Purpose of an automatic route
+ int16 go_id; // Index of exit of object walking to
+ fpath_t path; // Alternate path for saved files
+ int16 song; // Current song
+ int16 cx, cy; // Cursor position (dib coords)
+
+// Strangerke - Suppress as related to playback
+// bool playbackFl; // Game is in playback mode
+// bool recordFl; // Game is in record mode
+// Strangerke - Not used ?
+// bool mmtimeFl; // Multimedia timer supported
+// int16 screenWidth; // Desktop screen width
+// uint32 saveTick; // Time of last save in ticks
+// int16 saveSlot; // Current slot to save/restore game
+};
+
+/**
+* Structure to define an EXIT or other collision-activated hotspot
+*/
+struct hotspot_t {
+ int screenIndex; // Screen in which hotspot appears
+ int x1, y1, x2, y2; // Bounding box of hotspot
+ uint16 actIndex; // Actions to carry out if a 'hit'
+ int16 viewx, viewy, direction; // Used in auto-route mode
+};
+
class FileManager;
class Scheduler;
class Screen;
@@ -130,9 +264,7 @@ public:
int8 _tunesNbr;
uint16 _numScreens;
int8 _normalTPS; // Number of ticks (frames) per second.
- //8 for Win versions, 9 for DOS versions
-
-
+ // 8 for Win versions, 9 for DOS versions
object_t *_hero;
byte *_screen_p;
byte _heroImage;
@@ -150,6 +282,8 @@ public:
char **_textUtil;
char ***_arrayNouns;
char ***_arrayVerbs;
+ command_t _line; // Line of user text input
+ config_t _config; // User's config
uint16 **_arrayReqs;
hotspot_t *_hotspots;
int16 *_invent;
@@ -290,6 +424,8 @@ protected:
Common::Error run();
private:
+ static const int kTurboTps = 16; // This many in turbo mode
+
int _mouseX;
int _mouseY;
byte _introXSize;
@@ -320,15 +456,17 @@ private:
char **loadTextsVariante(Common::File &in, uint16 *arraySize);
char ***loadTextsArray(Common::File &in);
- uint16 **loadLongArray(Common::File &in);
char **loadTexts(Common::File &in);
- void freeTexts(char **ptr);
- void initPlaylist(bool playlist[MAX_TUNES]);
- void initConfig(inst_t action);
+ uint16 **loadLongArray(Common::File &in);
+
+ void freeTexts(char **ptr);
+ void initPlaylist(bool playlist[kMaxTunes]);
+ void initConfig();
void initialize();
- void calcMaxScore();
void initMachine();
+ void calcMaxScore();
+ void resetConfig();
void runMachine();
};
diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp
index 9294c9a6af..1c930e1074 100644
--- a/engines/hugo/intro.cpp
+++ b/engines/hugo/intro.cpp
@@ -108,7 +108,7 @@ bool intro_v1d::introPlay() {
} else {
// Workaround: SCRIPT.FON doesn't load properly at the moment
_vm->_screen->loadFont(2);
- _vm->_screen->writeStr(CENTER, 20, buffer, _TMAGENTA);
+ _vm->_screen->writeStr(kCenter, 20, buffer, _TMAGENTA);
}
// TROMAN, size 30-24
@@ -293,19 +293,19 @@ bool intro_v3d::introPlay() {
return true;
if (introTicks < _vm->getIntroSize()) {
- font.drawString(&surf, ".", _vm->_introX[introTicks], _vm->_introY[introTicks] - DIBOFF_Y, 320, _TBRIGHTWHITE);
+ font.drawString(&surf, ".", _vm->_introX[introTicks], _vm->_introY[introTicks] - kDibOffY, 320, _TBRIGHTWHITE);
_vm->_screen->displayBackground();
// Text boxes at various times
switch (introTicks) {
case 4:
- Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro1]);
+ Utils::Box(kBoxOk, "%s", _vm->_textIntro[kIntro1]);
break;
case 9:
- Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro2]);
+ Utils::Box(kBoxOk, "%s", _vm->_textIntro[kIntro2]);
break;
case 35:
- Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro3]);
+ Utils::Box(kBoxOk, "%s", _vm->_textIntro[kIntro3]);
break;
}
}
@@ -320,7 +320,7 @@ intro_v1w::~intro_v1w() {
}
void intro_v1w::preNewGame() {
- _vm->getGameStatus().viewState = V_INTROINIT;
+ _vm->getGameStatus().viewState = kViewIntroInit;
}
void intro_v1w::introInit() {
@@ -386,19 +386,19 @@ bool intro_v3w::introPlay() {
if (introTicks < _vm->getIntroSize()) {
// 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->writeStr(_vm->_introX[introTicks], _vm->_introY[introTicks] - kDibOffY, "x", _TBRIGHTWHITE);
_vm->_screen->displayBackground();
// Text boxes at various times
switch (introTicks) {
case 4:
- Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro1]);
+ Utils::Box(kBoxOk, "%s", _vm->_textIntro[kIntro1]);
break;
case 9:
- Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro2]);
+ Utils::Box(kBoxOk, "%s", _vm->_textIntro[kIntro2]);
break;
case 35:
- Utils::Box(BOX_OK, "%s", _vm->_textIntro[kIntro3]);
+ Utils::Box(kBoxOk, "%s", _vm->_textIntro[kIntro3]);
break;
}
}
diff --git a/engines/hugo/inventory.cpp b/engines/hugo/inventory.cpp
index 980ffd2be8..5d45a3bd35 100644
--- a/engines/hugo/inventory.cpp
+++ b/engines/hugo/inventory.cpp
@@ -44,7 +44,7 @@
namespace Hugo {
-#define MAX_DISP (XPIX / INV_DX) // Max icons displayable
+static const int kMaxDisp = (kXPix / kInvDx); // Max icons displayable
InventoryHandler::InventoryHandler(HugoEngine *vm) : _vm(vm) {
}
@@ -64,9 +64,9 @@ void InventoryHandler::constructInventory(int16 imageTotNumb, int displayNumb, b
// 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);
- displayNumb = MIN(displayNumb, MAX_DISP - NUM_ARROWS);
+ _vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), 0, 0, kInvDx, kInvDy, kXPix, _vm->_screen->getIconBuffer(), 0, 0, kXPix);
+ _vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), kInvDx, 0, kInvDx, kInvDy, kXPix, _vm->_screen->getIconBuffer(), kInvDx *(kMaxDisp - 1), 0, kXPix);
+ displayNumb = MIN(displayNumb, kMaxDisp - kArrowNumb);
} else // No, override first index - we can show 'em all!
firstObjId = 0;
@@ -78,15 +78,15 @@ void InventoryHandler::constructInventory(int16 imageTotNumb, int displayNumb, b
// Check still room to display and past first scroll index
if (displayed < displayNumb && carried >= firstObjId) {
// Compute source coordinates in dib_u
- int16 ux = (i + NUM_ARROWS) * INV_DX % XPIX;
- int16 uy = (i + NUM_ARROWS) * INV_DX / XPIX * INV_DY;
+ int16 ux = (i + kArrowNumb) * kInvDx % kXPix;
+ int16 uy = (i + kArrowNumb) * kInvDx / kXPix * kInvDy;
// Compute dest coordinates in dib_i
- int16 ix = ((scrollFl) ? displayed + 1 : displayed) * INV_DX;
+ int16 ix = ((scrollFl) ? displayed + 1 : displayed) * kInvDx;
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, kInvDx, kInvDy, kXPix, _vm->_screen->getIconBuffer(), ix, 0, kXPix);
}
carried++; // Count number carried
}
@@ -111,39 +111,39 @@ int16 InventoryHandler::processInventory(invact_t action, ...) {
}
// Will we need the scroll arrows?
- bool scrollFl = displayNumb > MAX_DISP;
+ bool scrollFl = displayNumb > kMaxDisp;
va_list marker; // Args used for D_ADD operation
int16 cursorx, cursory; // Current cursor position
int16 objId = -1; // Return objid under cursor
switch (action) {
- case INV_INIT: // Initialize inventory display
+ case kInventoryActionInit: // Initialize inventory display
constructInventory(imageNumb, displayNumb, scrollFl, firstIconId);
break;
- case INV_LEFT: // Scroll left by one icon
+ case kInventoryActionLeft: // Scroll left by one icon
firstIconId = MAX(0, firstIconId - 1);
constructInventory(imageNumb, displayNumb, scrollFl, firstIconId);
break;
- case INV_RIGHT: // Scroll right by one icon
+ case kInventoryActionRight: // Scroll right by one icon
firstIconId = MIN(displayNumb, firstIconId + 1);
constructInventory(imageNumb, displayNumb, scrollFl, firstIconId);
break;
- case INV_GET: // Return object id under cursor
+ case kInventoryActionGet: // Return object id under cursor
// Get cursor position from variable argument list
va_start(marker, action); // Initialize variable arguments
cursorx = va_arg(marker, int); // Cursor x
cursory = va_arg(marker, int); // Cursor y
va_end(marker); // Reset variable arguments
- cursory -= DIBOFF_Y; // Icon bar is at true zero
- if (cursory > 0 && cursory < INV_DY) { // Within icon bar?
- int16 i = cursorx / INV_DX; // Compute icon index
+ cursory -= kDibOffY; // Icon bar is at true zero
+ if (cursory > 0 && cursory < kInvDy) { // Within icon bar?
+ int16 i = cursorx / kInvDx; // Compute icon index
if (scrollFl) { // Scroll buttons displayed
if (i == 0) { // Left scroll button
- objId = LEFT_ARROW;
+ objId = kLeftArrow;
} else {
- if (i == MAX_DISP - 1) // Right scroll button
- objId = RIGHT_ARROW;
+ if (i == kMaxDisp - 1) // Right scroll button
+ objId = kRightArrow;
else // Adjust for scroll
i += firstIconId - 1; // i is icon index
}
@@ -175,61 +175,61 @@ void InventoryHandler::runInventory() {
debugC(1, kDebugInventory, "runInventory");
switch (gameStatus.inventoryState) {
- case I_OFF: // Icon bar off screen
+ case kInventoryOff: // Icon bar off screen
break;
- case I_UP: // Icon bar moving up
- gameStatus.inventoryHeight -= STEP_DY; // Move the icon bar up
+ case kInventoryUp: // Icon bar moving up
+ gameStatus.inventoryHeight -= kStepDy; // Move the icon bar up
if (gameStatus.inventoryHeight <= 0) // Limit travel
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, kXPix, gameStatus.inventoryHeight, kXPix, _vm->_screen->getFrontBuffer(), 0, kDibOffY, kXPix);
+ _vm->_screen->moveImage(_vm->_screen->getBackBufferBackup(), 0, gameStatus.inventoryHeight + kDibOffY, kXPix, kStepDy, kXPix, _vm->_screen->getFrontBuffer(), 0, gameStatus.inventoryHeight + kDibOffY, kXPix);
+ _vm->_screen->displayRect(0, kDibOffY, kXPix, gameStatus.inventoryHeight + kStepDy);
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->_object->updateImages(); // Add objects back into display list for restore
- gameStatus.inventoryState = I_OFF;
- gameStatus.viewState = V_PLAY;
+ _vm->_screen->moveImage(_vm->_screen->getBackBufferBackup(), 0, 0, kXPix, kYPix, kXPix, _vm->_screen->getBackBuffer(), 0, 0, kXPix);
+ _vm->_screen->moveImage(_vm->_screen->getBackBuffer(), 0, 0, kXPix, kYPix, kXPix, _vm->_screen->getFrontBuffer(), 0, 0, kXPix);
+ _vm->_object->updateImages(); // Add objects back into display list for restore
+ gameStatus.inventoryState = kInventoryOff;
+ gameStatus.viewState = kViewPlay;
}
break;
- case I_DOWN: // Icon bar moving down
+ case kInventoryDown: // Icon bar moving down
// If this is the first step, initialize dib_i
// 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
+ processInventory(kInventoryActionInit); // Initialize dib_i
+ _vm->_screen->displayList(kDisplayRestore); // Restore _frontBuffer
_vm->_object->updateImages(); // Rebuild _frontBuffer without icons/text
- _vm->_screen->displayList(D_DISPLAY); // Blit display list to screen
+ _vm->_screen->displayList(kDisplayDisplay); // Blit display list to screen
}
- gameStatus.inventoryHeight += STEP_DY; // Move the icon bar down
- if (gameStatus.inventoryHeight > INV_DY) // Limit travel
- gameStatus.inventoryHeight = INV_DY;
+ gameStatus.inventoryHeight += kStepDy; // Move the icon bar down
+ if (gameStatus.inventoryHeight > kInvDy) // Limit travel
+ gameStatus.inventoryHeight = kInvDy;
// 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, kXPix, gameStatus.inventoryHeight, kXPix, _vm->_screen->getFrontBuffer(), 0, kDibOffY, kXPix);
+ _vm->_screen->displayRect(0, kDibOffY, kXPix, gameStatus.inventoryHeight);
- if (gameStatus.inventoryHeight == INV_DY) { // Finished moving down?
+ if (gameStatus.inventoryHeight == kInvDy) { // Finished moving down?
// Yes, prepare view dibs for special inventory display since
// we can't refresh objects while icon bar overlayed...
// 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);
- gameStatus.inventoryState = I_ACTIVE;
+ _vm->_screen->moveImage(_vm->_screen->getBackBuffer(), 0, 0, kXPix, kYPix, kXPix, _vm->_screen->getBackBufferBackup(), 0, 0, kXPix);
+ _vm->_screen->moveImage(_vm->_screen->getFrontBuffer(), 0, 0, kXPix, kYPix, kXPix, _vm->_screen->getBackBuffer(), 0, 0, kXPix);
+ _vm->_screen->displayList(kDisplayInit);
+ gameStatus.inventoryState = kInventoryActive;
}
break;
- case I_ACTIVE: // Inventory active
+ case kInventoryActive: // Inventory active
_vm->_parser->charHandler(); // Still allow commands
- _vm->_screen->displayList(D_RESTORE); // Restore previous background
- _vm->_screen->displayList(D_DISPLAY); // Blit the display list to screen
+ _vm->_screen->displayList(kDisplayRestore); // Restore previous background
+ _vm->_screen->displayList(kDisplayDisplay); // Blit the display list to screen
break;
}
}
diff --git a/engines/hugo/inventory.h b/engines/hugo/inventory.h
index 36fca71a43..f786897ba1 100644
--- a/engines/hugo/inventory.h
+++ b/engines/hugo/inventory.h
@@ -34,9 +34,10 @@
#define HUGO_INVENTORY_H
namespace Hugo {
-#define NUM_ARROWS 2 // Number of arrows (left/right)
-#define LEFT_ARROW -2 // Cursor over Left arrow in inventory icon bar
-#define RIGHT_ARROW -3 // Cursor over Right arrow in inventory icon bar
+/**
+* Actions for Process_inventory()
+*/
+enum invact_t {kInventoryActionInit, kInventoryActionLeft, kInventoryActionRight, kInventoryActionGet};
class InventoryHandler {
public:
@@ -48,6 +49,8 @@ public:
private:
HugoEngine *_vm;
+ static const int kStepDy = 8; // Pixels per step movement
+
void constructInventory(int16 imageTotNumb, int displayNumb, bool scrollFl, int16 firstObjId);
};
diff --git a/engines/hugo/menu.cpp b/engines/hugo/menu.cpp
index f1dd281d12..cd70fc1056 100644
--- a/engines/hugo/menu.cpp
+++ b/engines/hugo/menu.cpp
@@ -132,12 +132,12 @@ void TopMenu::reflowLayout() {
// Set the graphics to the 'on' buttons, except for the variable ones
_whatButton->setGfx(arrayBmp[4 * kMenuWhat + scale - 1]);
- _musicButton->setGfx(arrayBmp[4 * kMenuMusic + scale - 1 + ((_config.musicFl) ? 0 : 2)]);
- _soundFXButton->setGfx(arrayBmp[4 * kMenuSoundFX + scale - 1 + ((_config.soundFl) ? 0 : 2)]);
+ _musicButton->setGfx(arrayBmp[4 * kMenuMusic + scale - 1 + ((_vm->_config.musicFl) ? 0 : 2)]);
+ _soundFXButton->setGfx(arrayBmp[4 * kMenuSoundFX + scale - 1 + ((_vm->_config.soundFl) ? 0 : 2)]);
_loadButton->setGfx(arrayBmp[4 * kMenuLoad + scale - 1]);
_saveButton->setGfx(arrayBmp[4 * kMenuSave + scale - 1]);
_recallButton->setGfx(arrayBmp[4 * kMenuRecall + scale - 1]);
- _turboButton->setGfx(arrayBmp[4 * kMenuTurbo + scale - 1 + ((_config.turboFl) ? 0 : 2)]);
+ _turboButton->setGfx(arrayBmp[4 * kMenuTurbo + scale - 1 + ((_vm->_config.turboFl) ? 0 : 2)]);
_lookButton->setGfx(arrayBmp[4 * kMenuLook + scale - 1]);
_inventButton->setGfx(arrayBmp[4 * kMenuInventory + scale - 1]);
}
@@ -199,11 +199,11 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d
close();
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- _vm->getGameStatus().viewState = V_PLAY;
+ _vm->getGameStatus().viewState = kViewPlay;
break;
case kCmdSave:
close();
- if (_vm->getGameStatus().viewState == V_PLAY) {
+ if (_vm->getGameStatus().viewState == kViewPlay) {
if (_vm->getGameStatus().gameOverFl)
Utils::gameOverMsg();
else
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index 039f33b324..0caa17ea6e 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -34,10 +34,9 @@
#include "common/system.h"
-#include "hugo/game.h"
#include "hugo/hugo.h"
+#include "hugo/game.h"
#include "hugo/mouse.h"
-#include "hugo/global.h"
#include "hugo/schedule.h"
#include "hugo/display.h"
#include "hugo/inventory.h"
@@ -47,19 +46,6 @@
namespace Hugo {
-#define EXIT_HOTSPOT -4 // Cursor over Exit hotspot
-#define CURSOR_NAME 2 // Index of name used under cursor
-#define CURSOR_NOCHAR '~' // Don't show name of object under cursor
-#define SX_OFF 10 // Cursor offset to name string
-#define SY_OFF -2 // Cursor offset to name string
-#define IX_OFF 8 // Cursor to icon image (dib coords)
-#define IY_OFF 10 // Cursor to icon image (dib coords)
-
-enum seqTextMouse {
- kMsNoWayText = 0,
- kMsExit = 1
-};
-
MouseHandler::MouseHandler(HugoEngine *vm) : _vm(vm) {
}
@@ -73,19 +59,19 @@ void MouseHandler::cursorText(char *buffer, int16 cx, int16 cy, uif_t fontId, in
// Find bounding rect for string
int16 sdx = _vm->_screen->stringLength(buffer);
- int16 sdy = _vm->_screen->fontHeight() + 1; // + 1 for shadow
+ int16 sdy = _vm->_screen->fontHeight() + 1; // + 1 for shadow
int16 sx, sy;
- if (cx < XPIX / 2) {
- sx = cx + SX_OFF;
- sy = (_vm->getGameStatus().inventoryObjId == -1) ? cy + SY_OFF : cy + SY_OFF - (_vm->_screen->fontHeight() + 1);
+ if (cx < kXPix / 2) {
+ sx = cx + kCursorNameOffX;
+ sy = (_vm->getGameStatus().inventoryObjId == -1) ? cy + kCursorNameOffY : cy + kCursorNameOffY - (_vm->_screen->fontHeight() + 1);
} else {
- sx = cx - sdx - SX_OFF / 2;
- sy = cy + SY_OFF;
+ sx = cx - sdx - kCursorNameOffX / 2;
+ sy = cy + kCursorNameOffY;
}
// 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->displayList(kDisplayAdd, sx, sy, sdx, sdy);
}
/**
@@ -113,12 +99,12 @@ void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
status_t &gameStatus = _vm->getGameStatus();
- if (gameStatus.storyModeFl || _vm->_hero->pathType == QUIET) // Make sure user has control
+ if (gameStatus.storyModeFl || _vm->_hero->pathType == kPathQuiet) // Make sure user has control
return;
bool foundFl = false; // TRUE if route found to object
// Check if this was over iconbar
- if (gameStatus.inventoryState == I_ACTIVE && cy < INV_DY + DIBOFF_Y) { // Clicked over iconbar object
+ if ((gameStatus.inventoryState == kInventoryActive) && (cy < kInvDy + kDibOffY)) { // Clicked over iconbar object
if (gameStatus.inventoryObjId == -1)
_vm->_screen->selectInventoryObjId(objId);
else if (gameStatus.inventoryObjId == objId)
@@ -131,7 +117,7 @@ void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
switch (obj->viewx) { // Where to walk to
case -1: // Walk to object position
if (_vm->_object->findObjectSpace(obj, &x, &y))
- foundFl = _vm->_route->startRoute(GO_GET, objId, x, y);
+ foundFl = _vm->_route->startRoute(kRouteGet, objId, x, y);
if (!foundFl) // Can't get there, try to use from here
_vm->_object->useObject(objId);
break;
@@ -139,11 +125,11 @@ void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
_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
+ if (!_vm->_route->startRoute(kRouteGet, objId, obj->viewx, obj->viewy)) {
+ if (_vm->_hero->cycling == kCycleInvisible) // If invisible do
_vm->_object->useObject(objId); // immediate use
else
- Utils::Box(BOX_ANY, "%s", _vm->_textMouse[kMsNoWayText]); // Can't get there
+ Utils::Box(kBoxAny, "%s", _vm->_textMouse[kMsNoWayText]); // Can't get there
}
break;
}
@@ -165,22 +151,22 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
status_t &gameStatus = _vm->getGameStatus();
- if (gameStatus.storyModeFl || _vm->_hero->pathType == QUIET) // Make sure user has control
+ if (gameStatus.storyModeFl || _vm->_hero->pathType == kPathQuiet) // 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(kRouteSpace, 0, cx, cy);
break;
- case LEFT_ARROW: // A scroll arrow - scroll the iconbar
- case RIGHT_ARROW:
+ case kLeftArrow: // A scroll arrow - scroll the iconbar
+ case kRightArrow:
// 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 == kLeftArrow) ? kInventoryActionLeft : kInventoryActionRight);
+ _vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, kXPix, kInvDy, kXPix, _vm->_screen->getFrontBuffer(), 0, kDibOffY, kXPix);
+ _vm->_screen->moveImage(_vm->_screen->getIconBuffer(), 0, 0, kXPix, kInvDy, kXPix, _vm->_screen->getBackBuffer(), 0, kDibOffY, kXPix);
+ _vm->_screen->displayList(kDisplayAdd, 0, kDibOffY, kXPix, kInvDy);
break;
- case EXIT_HOTSPOT: // Walk to exit hotspot
+ case kExitHotspot: // Walk to exit hotspot
i = findExit(cx, cy);
x = _vm->_hotspots[i].viewx;
y = _vm->_hotspots[i].viewy;
@@ -188,16 +174,16 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
// Special case of immediate exit
if (gameStatus.jumpExitFl) {
// Get rid of iconbar if necessary
- if (gameStatus.inventoryState != I_OFF)
- gameStatus.inventoryState = I_UP;
+ if (gameStatus.inventoryState != kInventoryOff)
+ gameStatus.inventoryState = kInventoryUp;
_vm->_scheduler->insertActionList(_vm->_hotspots[i].actIndex);
} else { // Set up route to exit spot
if (_vm->_hotspots[i].direction == Common::KEYCODE_RIGHT)
- x -= HERO_MAX_WIDTH;
+ x -= kHeroMaxWidth;
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
+ x += kHeroMaxWidth;
+ if (!_vm->_route->startRoute(kRouteExit, i, x, y))
+ Utils::Box(kBoxAny, "%s", _vm->_textMouse[kMsNoWayText]); // Can't get there
}
// Get rid of any attached icon
@@ -208,14 +194,14 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
obj = &_vm->_object->_objects[objId];
// Over iconbar - immediate description
- if (gameStatus.inventoryState == I_ACTIVE && cy < INV_DY + DIBOFF_Y)
+ if ((gameStatus.inventoryState == kInventoryActive) && (cy < kInvDy + kDibOffY)) {
_vm->_object->lookObject(obj);
- else {
+ } 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->_object->findObjectSpace(obj, &x, &y))
- foundFl = _vm->_route->startRoute(GO_LOOK, objId, x, y);
+ foundFl = _vm->_route->startRoute(kRouteLook, objId, x, y);
if (!foundFl) // Can't get there, immediate description
_vm->_object->lookObject(obj);
break;
@@ -223,11 +209,11 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
_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->_object->lookObject(obj); // immediate decription
+ if (!_vm->_route->startRoute(kRouteLook, objId, obj->viewx, obj->viewy)) {
+ if (_vm->_hero->cycling == kCycleInvisible) // If invisible do
+ _vm->_object->lookObject(obj); // immediate decription
else
- Utils::Box(BOX_ANY, "%s", _vm->_textMouse[kMsNoWayText]); // Can't get there
+ Utils::Box(kBoxAny, "%s", _vm->_textMouse[kMsNoWayText]); // Can't get there
}
break;
}
@@ -244,7 +230,7 @@ void MouseHandler::mouseHandler() {
status_t &gameStatus = _vm->getGameStatus();
- if ((gameStatus.viewState != V_PLAY) && (gameStatus.inventoryState != I_ACTIVE))
+ if ((gameStatus.viewState != kViewPlay) && (gameStatus.inventoryState != kInventoryActive))
return;
int16 cx = _vm->getMouseX();
@@ -254,13 +240,13 @@ void MouseHandler::mouseHandler() {
gameStatus.cy = cy;
// Don't process if outside client area
- if (cx < 0 || cx > XPIX || cy < DIBOFF_Y || cy > VIEW_DY + DIBOFF_Y)
+ if ((cx < 0) || (cx > kXPix) || (cy < kDibOffY) || (cy > kViewSizeY + kDibOffY))
return;
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);
+ if (gameStatus.inventoryState == kInventoryActive) { // Check inventory icon bar first
+ objId = _vm->_inventory->processInventory(kInventoryActionGet, cx, cy);
} else {
if (cy < 5 && cy > 0) {
_vm->_topMenu->runModal();
@@ -268,12 +254,13 @@ void MouseHandler::mouseHandler() {
}
if (!gameStatus.gameOverFl) {
- if (objId == -1) // No match, check rest of view
+ if (objId == -1) // No match, check rest of view
objId = _vm->_object->findObject(cx, cy);
- if (objId >= 0) { // Got a match
+
+ 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->_object->_objects[(objId == HERO) ? _vm->_heroImage : objId].nounIndex][CURSOR_NAME];
+ char *name = _vm->_arrayNouns[_vm->_object->_objects[(objId == kHeroIndex) ? _vm->_heroImage : objId].nounIndex][kCursorNameIndex];
if (name[0] != CURSOR_NOCHAR)
cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE);
@@ -286,7 +273,7 @@ void MouseHandler::mouseHandler() {
if (objId == -1) {
int i = findExit(cx, cy);
if (i != -1 && _vm->_hotspots[i].viewx >= 0) {
- objId = EXIT_HOTSPOT;
+ objId = kExitHotspot;
cursorText(_vm->_textMouse[kMsExit], cx, cy, U_FONT8, _TBRIGHTWHITE);
}
}
diff --git a/engines/hugo/mouse.h b/engines/hugo/mouse.h
index 0fcb651b3a..76990e83da 100644
--- a/engines/hugo/mouse.h
+++ b/engines/hugo/mouse.h
@@ -43,6 +43,18 @@ public:
private:
HugoEngine *_vm;
+ #define CURSOR_NOCHAR '~' // Don't show name of object under cursor
+
+ static const int kExitHotspot = -4; // Cursor over Exit hotspot
+ static const int kCursorNameIndex = 2; // Index of name used under cursor
+ static const int kCursorNameOffX = 10; // Cursor offset to name string
+ static const int kCursorNameOffY = -2; // Cursor offset to name string
+
+ enum seqTextMouse {
+ kMsNoWayText = 0,
+ kMsExit = 1
+ };
+
void cursorText(char *buffer, int16 cx, int16 cy, uif_t fontId, int16 color);
int16 findExit(int16 cx, int16 cy);
void processRightClick(int16 objId, int16 cx, int16 cy);
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 7200b1ce05..d90067036d 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -33,10 +33,9 @@
#include "common/system.h"
#include "common/random.h"
-#include "hugo/game.h"
#include "hugo/hugo.h"
+#include "hugo/game.h"
#include "hugo/object.h"
-#include "hugo/global.h"
#include "hugo/display.h"
#include "hugo/file.h"
#include "hugo/route.h"
@@ -99,17 +98,17 @@ void ObjectHandler::useObject(int16 objId) {
if (_vm->getGameStatus().inventoryObjId == -1) {
// Get or use objid directly
if ((obj->genericCmd & TAKE) || obj->objValue) // Get collectible item
- sprintf(_line, "%s %s", _vm->_arrayVerbs[_vm->_take][0], _vm->_arrayNouns[obj->nounIndex][0]);
+ sprintf(_vm->_line, "%s %s", _vm->_arrayVerbs[_vm->_take][0], _vm->_arrayNouns[obj->nounIndex][0]);
else if (obj->cmdIndex != 0) // Use non-collectible item if able
- sprintf(_line, "%s %s", _vm->_arrayVerbs[_vm->_cmdList[obj->cmdIndex][0].verbIndex][0], _vm->_arrayNouns[obj->nounIndex][0]);
+ sprintf(_vm->_line, "%s %s", _vm->_arrayVerbs[_vm->_cmdList[obj->cmdIndex][0].verbIndex][0], _vm->_arrayNouns[obj->nounIndex][0]);
else if ((verb = _vm->useBG(_vm->_arrayNouns[obj->nounIndex][0])) != 0)
- sprintf(_line, "%s %s", verb, _vm->_arrayNouns[obj->nounIndex][0]);
+ sprintf(_vm->_line, "%s %s", verb, _vm->_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", _vm->_arrayVerbs[_vm->_cmdList[_objects[_vm->getGameStatus().inventoryObjId].cmdIndex][0].verbIndex][0],
+ sprintf(_vm->_line, "%s %s %s", _vm->_arrayVerbs[_vm->_cmdList[_objects[_vm->getGameStatus().inventoryObjId].cmdIndex][0].verbIndex][0],
_vm->_arrayNouns[_objects[_vm->getGameStatus().inventoryObjId].nounIndex][0],
_vm->_arrayNouns[obj->nounIndex][0]);
@@ -122,7 +121,7 @@ void ObjectHandler::useObject(int16 objId) {
for (target_t *target = use->targets; target->nounIndex != 0; target++)
if (target->nounIndex == obj->nounIndex) {
foundFl = true;
- sprintf(_line, "%s %s %s", _vm->_arrayVerbs[target->verbIndex][0],
+ sprintf(_vm->_line, "%s %s %s", _vm->_arrayVerbs[target->verbIndex][0],
_vm->_arrayNouns[_objects[_vm->getGameStatus().inventoryObjId].nounIndex][0],
_vm->_arrayNouns[obj->nounIndex][0]);
}
@@ -130,17 +129,17 @@ void ObjectHandler::useObject(int16 objId) {
// No valid use of objects found, print failure string
if (!foundFl) {
// Deselect dragged icon if inventory not active
- if (_vm->getGameStatus().inventoryState != I_ACTIVE)
+ if (_vm->getGameStatus().inventoryState != kInventoryActive)
_vm->_screen->resetInventoryObjId();
- Utils::Box(BOX_ANY, "%s", _vm->_textData[use->dataIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[use->dataIndex]);
return;
}
}
}
}
- if (_vm->getGameStatus().inventoryState == I_ACTIVE) // If inventory active, remove it
- _vm->getGameStatus().inventoryState = I_UP;
+ if (_vm->getGameStatus().inventoryState == kInventoryActive) // If inventory active, remove it
+ _vm->getGameStatus().inventoryState = kInventoryUp;
_vm->_screen->resetInventoryObjId();
@@ -163,7 +162,7 @@ int16 ObjectHandler::findObject(uint16 x, uint16 y) {
if (obj->screenIndex == *_vm->_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 (curImage != 0 && obj->cycling != kCycleInvisible) {
// 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
@@ -256,16 +255,16 @@ int ObjectHandler::y2comp(const void *a, const void *b) {
// Why does qsort try the same indexes?
return 0;
- if (p1->priority == BACKGROUND)
+ if (p1->priority == kPriorityBackground)
return -1;
- if (p2->priority == BACKGROUND)
+ if (p2->priority == kPriorityBackground)
return 1;
- if (p1->priority == FOREGROUND)
+ if (p1->priority == kPriorityForeground)
return 1;
- if (p2->priority == FOREGROUND)
+ if (p2->priority == kPriorityForeground)
return -1;
int ay2 = p1->y + p1->currImagePtr->y2;
@@ -295,10 +294,10 @@ void ObjectHandler::showTakeables() {
for (int j = 0; j < _numObj; j++) {
object_t *obj = &_objects[j];
- if ((obj->cycling != INVISIBLE) &&
+ if ((obj->cycling != kCycleInvisible) &&
(obj->screenIndex == *_vm->_screen_p) &&
(((TAKE & obj->genericCmd) == TAKE) || obj->objValue)) {
- Utils::Box(BOX_ANY, "You can also see:\n%s.", _vm->_arrayNouns[obj->nounIndex][LOOK_NAME]);
+ Utils::Box(kBoxAny, "You can also see:\n%s.", _vm->_arrayNouns[obj->nounIndex][LOOK_NAME]);
}
}
}
@@ -314,14 +313,14 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
bool foundFl = true;
// Try left rear corner
- for (int16 x = *destx = obj->x + curImage->x1; x < *destx + HERO_MAX_WIDTH; x++) {
+ for (int16 x = *destx = obj->x + curImage->x1; x < *destx + kHeroMaxWidth; x++) {
if (BOUND(x, y))
foundFl = false;
}
if (!foundFl) { // Try right rear corner
foundFl = true;
- for (int16 x = *destx = obj->x + curImage->x2 - HERO_MAX_WIDTH + 1; x <= obj->x + (int16)curImage->x2; x++) {
+ for (int16 x = *destx = obj->x + curImage->x2 - kHeroMaxWidth + 1; x <= obj->x + (int16)curImage->x2; x++) {
if (BOUND(x, y))
foundFl = false;
}
@@ -330,7 +329,7 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
if (!foundFl) { // Try left front corner
foundFl = true;
y += 2;
- for (int16 x = *destx = obj->x + curImage->x1; x < *destx + HERO_MAX_WIDTH; x++) {
+ for (int16 x = *destx = obj->x + curImage->x1; x < *destx + kHeroMaxWidth; x++) {
if (BOUND(x, y))
foundFl = false;
}
@@ -338,7 +337,7 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
if (!foundFl) { // Try right rear corner
foundFl = true;
- for (int16 x = *destx = obj->x + curImage->x2 - HERO_MAX_WIDTH + 1; x <= obj->x + (int16)curImage->x2; x++) {
+ for (int16 x = *destx = obj->x + curImage->x2 - kHeroMaxWidth + 1; x <= obj->x + (int16)curImage->x2; x++) {
if (BOUND(x, y))
foundFl = false;
}
@@ -472,7 +471,7 @@ void ObjectHandler::loadObjectArr(Common::File &in) {
* number
*/
void ObjectHandler::setCarriedScreen(int screenNum) {
- for (int i = HERO + 1; i < _numObj; i++) { // Any others
+ for (int i = kHeroIndex + 1; i < _numObj; i++) {// Any others
if (isCarried(i)) // being carried
_objects[i].screenIndex = screenNum;
}
diff --git a/engines/hugo/object.h b/engines/hugo/object.h
index 5e468ffcbb..1de2fb1621 100644
--- a/engines/hugo/object.h
+++ b/engines/hugo/object.h
@@ -35,8 +35,7 @@
#include "common/file.h"
-#define MAXOBJECTS 128 // Used in Update_images()
-#define BOUND(X, Y) ((_vm->getBoundaryOverlay()[Y * XBYTES + X / 8] & (0x80 >> X % 8)) != 0) // Boundary bit set
+#define BOUND(X, Y) ((_vm->getBoundaryOverlay()[Y * kCompLineSize + X / 8] & (0x80 >> X % 8)) != 0) // Boundary bit set
namespace Hugo {
@@ -94,6 +93,11 @@ public:
}
protected:
HugoEngine *_vm;
+
+ static const int kEdge = 10; // Closest object can get to edge of screen
+ static const int kEdge2 = kEdge * 2; // Push object further back on edge collision
+ static const int kMaxObjNumb = 128; // Used in Update_images()
+
uint16 _objCount;
void restoreSeq(object_t *obj);
diff --git a/engines/hugo/object_v1d.cpp b/engines/hugo/object_v1d.cpp
index 6eb44fcaa0..1d50eb1a6e 100644
--- a/engines/hugo/object_v1d.cpp
+++ b/engines/hugo/object_v1d.cpp
@@ -33,10 +33,9 @@
#include "common/system.h"
#include "common/random.h"
-#include "hugo/game.h"
#include "hugo/hugo.h"
+#include "hugo/game.h"
#include "hugo/object.h"
-#include "hugo/global.h"
#include "hugo/display.h"
#include "hugo/file.h"
#include "hugo/route.h"
@@ -63,11 +62,11 @@ void ObjectHandler_v1d::updateImages() {
// Initialise the index array to visible objects in current screen
int num_objs = 0;
- byte objindex[MAXOBJECTS]; // Array of indeces to objects
+ byte objindex[kMaxObjNumb]; // Array of indeces to objects
for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i];
- if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= ALMOST_INVISIBLE))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible))
objindex[num_objs++] = i;
}
@@ -81,18 +80,18 @@ void ObjectHandler_v1d::updateImages() {
if (obj->frameTimer)
obj->frameTimer--;
- if (obj->cycling > ALMOST_INVISIBLE) { // Only if visible
+ if (obj->cycling > kCycleAlmostInvisible) { // Only if visible
switch (obj->cycling) {
- case NOT_CYCLING:
+ case kCycleNotCycling:
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, false);
break;
- case CYCLE_FORWARD:
+ case kCycleForward:
if (obj->frameTimer) // Not time to see next frame yet
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, false);
else
_vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, false);
break;
- case CYCLE_BACKWARD: {
+ case kCycleBackward: {
seq_t *seqPtr = obj->currImagePtr;
if (!obj->frameTimer) { // Show next frame
while (seqPtr->nextSeqPtr != obj->currImagePtr)
@@ -112,16 +111,16 @@ void ObjectHandler_v1d::updateImages() {
// Cycle any animating objects
for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]];
- if (obj->cycling != INVISIBLE) {
+ if (obj->cycling != kCycleInvisible) {
// Only if it's visible
- if (obj->cycling == ALMOST_INVISIBLE)
- obj->cycling = INVISIBLE;
+ if (obj->cycling == kCycleAlmostInvisible)
+ obj->cycling = kCycleInvisible;
// Now Rotate to next picture in sequence
switch (obj->cycling) {
- case NOT_CYCLING:
+ case kCycleNotCycling:
break;
- case CYCLE_FORWARD:
+ case kCycleForward:
if (!obj->frameTimer) {
// Time to step to next frame
obj->currImagePtr = obj->currImagePtr->nextSeqPtr;
@@ -133,14 +132,14 @@ void ObjectHandler_v1d::updateImages() {
if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) {
if (obj->cycleNumb) { // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb)
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
}
}
}
break;
- case CYCLE_BACKWARD: {
+ case kCycleBackward: {
if (!obj->frameTimer) {
// Time to step to prev frame
seq_t *seqPtr = obj->currImagePtr;
@@ -154,7 +153,7 @@ void ObjectHandler_v1d::updateImages() {
if (obj->currImagePtr == obj->seqList[j].seqPtr) {
if (obj->cycleNumb){ // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb)
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
}
@@ -193,7 +192,7 @@ void ObjectHandler_v1d::moveObjects() {
seq_t *currImage = obj->currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) {
switch (obj->pathType) {
- case CHASE: {
+ case kPathChase: {
// Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1;
int dy = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - obj->y - currImage->y2 - 1;
@@ -225,16 +224,16 @@ void ObjectHandler_v1d::moveObjects() {
if (obj->vx || obj->vy) {
if (obj->seqNumb > 1)
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
} else {
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
_vm->boundaryCollision(obj); // Must have got hero!
}
dxOld = obj->vx;
currImage = obj->currImagePtr; // Get (new) ptr to current image
break;
}
- case WANDER:
+ case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath;
@@ -256,9 +255,9 @@ void ObjectHandler_v1d::moveObjects() {
}
if (obj->vx || obj->vy)
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
else
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
dxOld = obj->vx;
currImage = obj->currImagePtr; // Get (new) ptr to current image
@@ -268,7 +267,7 @@ void ObjectHandler_v1d::moveObjects() {
; // Really, nothing
}
// Store boundaries
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2);
}
}
@@ -288,7 +287,7 @@ void ObjectHandler_v1d::moveObjects() {
int y1 = obj->y + currImage->y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom edge
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary
@@ -306,24 +305,24 @@ void ObjectHandler_v1d::moveObjects() {
obj->vy = 0;
}
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->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 (x1 < kEdge)
+ obj->x = kEdge2;
+ if (x2 > (kXPix - kEdge))
+ obj->x = kXPix - kEdge2 - (x2 - x1);
+ if (y1 < kEdge)
+ obj->y = kEdge2;
+ if (y2 > (kYPix - kEdge))
+ obj->y = kYPix - kEdge2 - (y2 - y1);
if ((obj->vx == 0) && (obj->vy == 0))
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
@@ -331,7 +330,7 @@ void ObjectHandler_v1d::moveObjects() {
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 == *_vm->_screen_p) && (obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2);
}
@@ -356,22 +355,22 @@ void ObjectHandler_v1d::moveObjects() {
void ObjectHandler_v1d::swapImages(int objIndex1, int objIndex2) {
debugC(1, kDebugObject, "swapImages(%d, %d)", objIndex1, objIndex2);
- seqList_t tmpSeqList[MAX_SEQUENCES];
- int seqListSize = sizeof(seqList_t) * MAX_SEQUENCES;
+ seqList_t tmpSeqList[kMaxSeqNumb];
+ int seqListSize = sizeof(seqList_t) * kMaxSeqNumb;
memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize);
memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize);
memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize);
_objects[objIndex1].currImagePtr = _objects[objIndex1].seqList[0].seqPtr;
_objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr;
- _vm->_heroImage = (_vm->_heroImage == HERO) ? objIndex2 : HERO;
+ _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex;
}
void ObjectHandler_v1d::homeIn(int objIndex1, int objIndex2, int8 objDx, int8 objDy) {
// object obj1 will home in on object obj2
object_t *obj1 = &_objects[objIndex1];
object_t *obj2 = &_objects[objIndex2];
- obj1->pathType = AUTO;
+ obj1->pathType = kPathAuto;
int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1;
int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1;
diff --git a/engines/hugo/object_v1w.cpp b/engines/hugo/object_v1w.cpp
index e5716f8b8c..e93244536f 100644
--- a/engines/hugo/object_v1w.cpp
+++ b/engines/hugo/object_v1w.cpp
@@ -33,10 +33,9 @@
#include "common/system.h"
#include "common/random.h"
-#include "hugo/game.h"
#include "hugo/hugo.h"
+#include "hugo/game.h"
#include "hugo/object.h"
-#include "hugo/global.h"
#include "hugo/display.h"
#include "hugo/file.h"
#include "hugo/route.h"
@@ -63,11 +62,11 @@ void ObjectHandler_v1w::updateImages() {
// Initialise the index array to visible objects in current screen
int num_objs = 0;
- byte objindex[MAXOBJECTS]; // Array of indeces to objects
+ byte objindex[kMaxObjNumb]; // Array of indeces to objects
for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i];
- if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= ALMOST_INVISIBLE))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible))
objindex[num_objs++] = i;
}
@@ -81,24 +80,24 @@ void ObjectHandler_v1w::updateImages() {
if (obj->frameTimer)
obj->frameTimer--;
- if (obj->cycling > ALMOST_INVISIBLE) { // Only if visible
+ if (obj->cycling > kCycleAlmostInvisible) { // Only if visible
switch (obj->cycling) {
- case NOT_CYCLING:
- _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL);
+ case kCycleNotCycling:
+ _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay);
break;
- case CYCLE_FORWARD:
+ case kCycleForward:
if (obj->frameTimer) // Not time to see next frame yet
- _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL);
+ _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay);
else
- _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == OVEROVL);
+ _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == kPriorityOverOverlay);
break;
- case CYCLE_BACKWARD: {
+ case kCycleBackward: {
seq_t *seqPtr = obj->currImagePtr;
if (!obj->frameTimer) { // Show next frame
while (seqPtr->nextSeqPtr != obj->currImagePtr)
seqPtr = seqPtr->nextSeqPtr;
}
- _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == OVEROVL);
+ _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == kPriorityOverOverlay);
break;
}
default:
@@ -110,16 +109,16 @@ void ObjectHandler_v1w::updateImages() {
// Cycle any animating objects
for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]];
- if (obj->cycling != INVISIBLE) {
+ if (obj->cycling != kCycleInvisible) {
// Only if it's visible
- if (obj->cycling == ALMOST_INVISIBLE)
- obj->cycling = INVISIBLE;
+ if (obj->cycling == kCycleAlmostInvisible)
+ obj->cycling = kCycleInvisible;
// Now Rotate to next picture in sequence
switch (obj->cycling) {
- case NOT_CYCLING:
+ case kCycleNotCycling:
break;
- case CYCLE_FORWARD:
+ case kCycleForward:
if (!obj->frameTimer) {
// Time to step to next frame
obj->currImagePtr = obj->currImagePtr->nextSeqPtr;
@@ -131,14 +130,14 @@ void ObjectHandler_v1w::updateImages() {
if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) {
if (obj->cycleNumb) { // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb)
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
}
}
}
break;
- case CYCLE_BACKWARD: {
+ case kCycleBackward: {
if (!obj->frameTimer) {
// Time to step to prev frame
seq_t *seqPtr = obj->currImagePtr;
@@ -152,7 +151,7 @@ void ObjectHandler_v1w::updateImages() {
if (obj->currImagePtr == obj->seqList[j].seqPtr) {
if (obj->cycleNumb){ // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb)
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
}
@@ -188,11 +187,11 @@ void ObjectHandler_v1w::moveObjects() {
seq_t *currImage = obj->currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) {
switch (obj->pathType) {
- case CHASE:
- case CHASE2: {
+ case kPathChase:
+ case kPathChase2: {
int8 radius = obj->radius; // Default to object's radius
if (radius < 0) // If radius infinity, use closer value
- radius = DX;
+ radius = kStepDx;
// Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1;
@@ -235,18 +234,18 @@ void ObjectHandler_v1w::moveObjects() {
}
if (obj->vx || obj->vy) {
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
} else {
- obj->cycling = NOT_CYCLING;
- _vm->boundaryCollision(obj); // Must have got hero!
+ obj->cycling = kCycleNotCycling;
+ _vm->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:
+ case kPathWander2:
+ case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath;
@@ -272,13 +271,13 @@ void ObjectHandler_v1w::moveObjects() {
currImage = obj->currImagePtr; // Get (new) ptr to current image
}
if (obj->vx || obj->vy)
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
break;
default:
; // Really, nothing
}
// Store boundaries
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2);
}
}
@@ -298,7 +297,7 @@ void ObjectHandler_v1w::moveObjects() {
int y1 = obj->y + currImage->y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom edge
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary
@@ -316,24 +315,24 @@ void ObjectHandler_v1w::moveObjects() {
obj->vy = 0;
}
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->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;
+ if (x1 < kEdge)
+ obj->x = kEdge2;
+ if (x2 > (kXPix - kEdge))
+ obj->x = kXPix - kEdge2 - (x2 - x1);
+ if (y1 < kEdge)
+ obj->y = kEdge2;
+ if (y2 > (kYPix - kEdge))
+ obj->y = kYPix - kEdge2 - (y2 - y1);
+
+ if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2))
+ obj->cycling = kCycleNotCycling;
}
}
@@ -341,7 +340,7 @@ void ObjectHandler_v1w::moveObjects() {
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 == *_vm->_screen_p) && (obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2);
}
@@ -368,15 +367,15 @@ void ObjectHandler_v1w::swapImages(int objIndex1, int objIndex2) {
saveSeq(&_objects[objIndex1]);
- seqList_t tmpSeqList[MAX_SEQUENCES];
- int seqListSize = sizeof(seqList_t) * MAX_SEQUENCES;
+ seqList_t tmpSeqList[kMaxSeqNumb];
+ int seqListSize = sizeof(seqList_t) * kMaxSeqNumb;
memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize);
memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize);
memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize);
restoreSeq(&_objects[objIndex1]);
_objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr;
- _vm->_heroImage = (_vm->_heroImage == HERO) ? objIndex2 : HERO;
+ _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex;
// Make sure baseline stays constant
_objects[objIndex1].y += _objects[objIndex2].currImagePtr->y2 - _objects[objIndex1].currImagePtr->y2;
diff --git a/engines/hugo/object_v2d.cpp b/engines/hugo/object_v2d.cpp
index f2b7fb3cda..b02d03c646 100644
--- a/engines/hugo/object_v2d.cpp
+++ b/engines/hugo/object_v2d.cpp
@@ -33,10 +33,9 @@
#include "common/system.h"
#include "common/random.h"
-#include "hugo/game.h"
#include "hugo/hugo.h"
+#include "hugo/game.h"
#include "hugo/object.h"
-#include "hugo/global.h"
#include "hugo/display.h"
#include "hugo/file.h"
#include "hugo/route.h"
@@ -63,11 +62,11 @@ void ObjectHandler_v2d::updateImages() {
// Initialise the index array to visible objects in current screen
int num_objs = 0;
- byte objindex[MAXOBJECTS]; // Array of indeces to objects
+ byte objindex[kMaxObjNumb]; // Array of indeces to objects
for (int i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i];
- if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= ALMOST_INVISIBLE))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling >= kCycleAlmostInvisible))
objindex[num_objs++] = i;
}
@@ -81,24 +80,24 @@ void ObjectHandler_v2d::updateImages() {
if (obj->frameTimer)
obj->frameTimer--;
- if (obj->cycling > ALMOST_INVISIBLE) { // Only if visible
+ if (obj->cycling > kCycleAlmostInvisible) { // Only if visible
switch (obj->cycling) {
- case NOT_CYCLING:
- _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL);
+ case kCycleNotCycling:
+ _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay);
break;
- case CYCLE_FORWARD:
+ case kCycleForward:
if (obj->frameTimer) // Not time to see next frame yet
- _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == OVEROVL);
+ _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr, obj->priority == kPriorityOverOverlay);
else
- _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == OVEROVL);
+ _vm->_screen->displayFrame(obj->x, obj->y, obj->currImagePtr->nextSeqPtr, obj->priority == kPriorityOverOverlay);
break;
- case CYCLE_BACKWARD: {
+ case kCycleBackward: {
seq_t *seqPtr = obj->currImagePtr;
if (!obj->frameTimer) { // Show next frame
while (seqPtr->nextSeqPtr != obj->currImagePtr)
seqPtr = seqPtr->nextSeqPtr;
}
- _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == OVEROVL);
+ _vm->_screen->displayFrame(obj->x, obj->y, seqPtr, obj->priority == kPriorityOverOverlay);
break;
}
default:
@@ -112,16 +111,16 @@ void ObjectHandler_v2d::updateImages() {
// Cycle any animating objects
for (int i = 0; i < num_objs; i++) {
object_t *obj = &_objects[objindex[i]];
- if (obj->cycling != INVISIBLE) {
+ if (obj->cycling != kCycleInvisible) {
// Only if it's visible
- if (obj->cycling == ALMOST_INVISIBLE)
- obj->cycling = INVISIBLE;
+ if (obj->cycling == kCycleAlmostInvisible)
+ obj->cycling = kCycleInvisible;
// Now Rotate to next picture in sequence
switch (obj->cycling) {
- case NOT_CYCLING:
+ case kCycleNotCycling:
break;
- case CYCLE_FORWARD:
+ case kCycleForward:
if (!obj->frameTimer) {
// Time to step to next frame
obj->currImagePtr = obj->currImagePtr->nextSeqPtr;
@@ -133,14 +132,14 @@ void ObjectHandler_v2d::updateImages() {
if (obj->currImagePtr->nextSeqPtr == obj->seqList[j].seqPtr) {
if (obj->cycleNumb) { // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb)
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
}
}
}
break;
- case CYCLE_BACKWARD: {
+ case kCycleBackward: {
if (!obj->frameTimer) {
// Time to step to prev frame
seq_t *seqPtr = obj->currImagePtr;
@@ -154,7 +153,7 @@ void ObjectHandler_v2d::updateImages() {
if (obj->currImagePtr == obj->seqList[j].seqPtr) {
if (obj->cycleNumb){ // Decr cycleNumb if Non-continous
if (!--obj->cycleNumb)
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
}
@@ -191,11 +190,11 @@ void ObjectHandler_v2d::moveObjects() {
seq_t *currImage = obj->currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) {
switch (obj->pathType) {
- case CHASE:
- case CHASE2: {
+ case kPathChase:
+ case kPathChase2: {
int8 radius = obj->radius; // Default to object's radius
if (radius < 0) // If radius infinity, use closer value
- radius = DX;
+ radius = kStepDx;
// Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1;
@@ -238,18 +237,18 @@ void ObjectHandler_v2d::moveObjects() {
}
if (obj->vx || obj->vy) {
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
} else {
- obj->cycling = NOT_CYCLING;
- _vm->boundaryCollision(obj); // Must have got hero!
+ obj->cycling = kCycleNotCycling;
+ _vm->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:
+ case kPathWander2:
+ case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath;
@@ -275,13 +274,13 @@ void ObjectHandler_v2d::moveObjects() {
currImage = obj->currImagePtr; // Get (new) ptr to current image
}
if (obj->vx || obj->vy)
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
break;
default:
; // Really, nothing
}
// Store boundaries
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2);
}
}
@@ -301,7 +300,7 @@ void ObjectHandler_v2d::moveObjects() {
int y1 = obj->y + currImage->y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom edge
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary
@@ -319,24 +318,24 @@ void ObjectHandler_v2d::moveObjects() {
obj->vy = 0;
}
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->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;
+ if (x1 < kEdge)
+ obj->x = kEdge2;
+ if (x2 > (kXPix - kEdge))
+ obj->x = kXPix - kEdge2 - (x2 - x1);
+ if (y1 < kEdge)
+ obj->y = kEdge2;
+ if (y2 > (kYPix - kEdge))
+ obj->y = kYPix - kEdge2 - (y2 - y1);
+
+ if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2))
+ obj->cycling = kCycleNotCycling;
}
}
@@ -344,7 +343,7 @@ void ObjectHandler_v2d::moveObjects() {
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 == *_vm->_screen_p) && (obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2);
}
@@ -365,7 +364,7 @@ void ObjectHandler_v2d::homeIn(int objIndex1, int objIndex2, int8 objDx, int8 ob
// object obj1 will home in on object obj2
object_t *obj1 = &_objects[objIndex1];
object_t *obj2 = &_objects[objIndex2];
- obj1->pathType = AUTO;
+ obj1->pathType = kPathAuto;
int dx = obj1->x + obj1->currImagePtr->x1 - obj2->x - obj2->currImagePtr->x1;
int dy = obj1->y + obj1->currImagePtr->y1 - obj2->y - obj2->currImagePtr->y1;
diff --git a/engines/hugo/object_v3d.cpp b/engines/hugo/object_v3d.cpp
index 1954830d81..16ef9f5649 100644
--- a/engines/hugo/object_v3d.cpp
+++ b/engines/hugo/object_v3d.cpp
@@ -33,10 +33,9 @@
#include "common/system.h"
#include "common/random.h"
-#include "hugo/game.h"
#include "hugo/hugo.h"
+#include "hugo/game.h"
#include "hugo/object.h"
-#include "hugo/global.h"
#include "hugo/display.h"
#include "hugo/file.h"
#include "hugo/route.h"
@@ -72,11 +71,11 @@ void ObjectHandler_v3d::moveObjects() {
seq_t *currImage = obj->currImagePtr; // Get ptr to current image
if (obj->screenIndex == *_vm->_screen_p) {
switch (obj->pathType) {
- case CHASE:
- case CHASE2: {
+ case kPathChase:
+ case kPathChase2: {
int8 radius = obj->radius; // Default to object's radius
if (radius < 0) // If radius infinity, use closer value
- radius = DX;
+ radius = kStepDx;
// Allowable motion wrt boundary
int dx = _vm->_hero->x + _vm->_hero->currImagePtr->x1 - obj->x - currImage->x1;
@@ -119,9 +118,9 @@ void ObjectHandler_v3d::moveObjects() {
}
if (obj->vx || obj->vy) {
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
} else {
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
_vm->boundaryCollision(obj); // Must have got hero!
}
obj->oldvx = obj->vx;
@@ -129,8 +128,8 @@ void ObjectHandler_v3d::moveObjects() {
currImage = obj->currImagePtr; // Get (new) ptr to current image
break;
}
- case WANDER2:
- case WANDER:
+ case kPathWander2:
+ case kPathWander:
if (!_vm->_rnd->getRandomNumber(3 * _vm->_normalTPS)) { // Kick on random interval
obj->vx = _vm->_rnd->getRandomNumber(obj->vxPath << 1) - obj->vxPath;
obj->vy = _vm->_rnd->getRandomNumber(obj->vyPath << 1) - obj->vyPath;
@@ -156,14 +155,14 @@ void ObjectHandler_v3d::moveObjects() {
currImage = obj->currImagePtr; // Get (new) ptr to current image
}
if (obj->vx || obj->vy)
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
break;
default:
; // Really, nothing
}
// Store boundaries
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->storeBoundary(obj->x + currImage->x1, obj->x + currImage->x2, obj->y + currImage->y2);
}
}
@@ -183,7 +182,7 @@ void ObjectHandler_v3d::moveObjects() {
int y1 = obj->y + currImage->y1; // Top edge
int y2 = obj->y + currImage->y2; // Bottom edge
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(x1, x2, y2); // Clear our own boundary
// Allowable motion wrt boundary
@@ -201,24 +200,24 @@ void ObjectHandler_v3d::moveObjects() {
obj->vy = 0;
}
- if ((obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->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;
+ if (x1 < kEdge)
+ obj->x = kEdge2;
+ if (x2 > (kXPix - kEdge))
+ obj->x = kXPix - kEdge2 - (x2 - x1);
+ if (y1 < kEdge)
+ obj->y = kEdge2;
+ if (y2 > (kYPix - kEdge))
+ obj->y = kYPix - kEdge2 - (y2 - y1);
+
+ if ((obj->vx == 0) && (obj->vy == 0) && (obj->pathType != kPathWander2) && (obj->pathType != kPathChase2))
+ obj->cycling = kCycleNotCycling;
}
}
@@ -226,7 +225,7 @@ void ObjectHandler_v3d::moveObjects() {
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 == *_vm->_screen_p) && (obj->cycling > ALMOST_INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling > kCycleAlmostInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(obj->oldx + currImage->x1, obj->oldx + currImage->x2, obj->oldy + currImage->y2);
}
@@ -253,15 +252,15 @@ void ObjectHandler_v3d::swapImages(int objIndex1, int objIndex2) {
saveSeq(&_objects[objIndex1]);
- seqList_t tmpSeqList[MAX_SEQUENCES];
- int seqListSize = sizeof(seqList_t) * MAX_SEQUENCES;
+ seqList_t tmpSeqList[kMaxSeqNumb];
+ int seqListSize = sizeof(seqList_t) * kMaxSeqNumb;
memmove(tmpSeqList, _objects[objIndex1].seqList, seqListSize);
memmove(_objects[objIndex1].seqList, _objects[objIndex2].seqList, seqListSize);
memmove(_objects[objIndex2].seqList, tmpSeqList, seqListSize);
restoreSeq(&_objects[objIndex1]);
_objects[objIndex2].currImagePtr = _objects[objIndex2].seqList[0].seqPtr;
- _vm->_heroImage = (_vm->_heroImage == HERO) ? objIndex2 : HERO;
+ _vm->_heroImage = (_vm->_heroImage == kHeroIndex) ? objIndex2 : kHeroIndex;
// Make sure baseline stays constant
_objects[objIndex1].y += _objects[objIndex2].currImagePtr->y2 - _objects[objIndex1].currImagePtr->y2;
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 9c2a57286f..98d85b888b 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -45,10 +45,6 @@
namespace Hugo {
-#define BLINKS 2 // Cursor blinks per second
-#define CX(X) LOWORD(X)
-#define CY(Y) HIWORD(Y)
-
Parser::Parser(HugoEngine *vm) :
_vm(vm), _putIndex(0), _getIndex(0), _checkDoubleF1Fl(false) {
}
@@ -57,7 +53,7 @@ Parser::~Parser() {
}
void Parser::switchTurbo() {
- _config.turboFl = !_config.turboFl;
+ _vm->_config.turboFl = !_vm->_config.turboFl;
}
/**
@@ -85,17 +81,17 @@ void Parser::charHandler() {
cmdLine[--lineIndex] = '\0';
break;
case Common::KEYCODE_RETURN: // EOL, pass line to line handler
- if (lineIndex && (_vm->_hero->pathType != QUIET)) {
+ if (lineIndex && (_vm->_hero->pathType != kPathQuiet)) {
// Remove inventory bar if active
- if (gameStatus.inventoryState == I_ACTIVE)
- gameStatus.inventoryState = I_UP;
+ if (gameStatus.inventoryState == kInventoryActive)
+ gameStatus.inventoryState = kInventoryUp;
// Call Line handler and reset line
command(cmdLine);
cmdLine[lineIndex = 0] = '\0';
}
break;
default: // Normal text key, add to line
- if (lineIndex >= MAX_CHARS) {
+ if (lineIndex >= kMaxLineSize) {
//MessageBeep(MB_ICONASTERISK);
warning("STUB: MessageBeep() - Command line too long");
} else if (isprint(c)) {
@@ -107,19 +103,19 @@ void Parser::charHandler() {
}
// See if time to blink cursor, set cursor character
- if ((tick++ % (_vm->getTPS() / BLINKS)) == 0)
+ if ((tick++ % (_vm->getTPS() / kBlinksPerSec)) == 0)
cursor = (cursor == '_') ? ' ' : '_';
// See if recall button pressed
if (gameStatus.recallFl) {
// Copy previous line to current cmdline
gameStatus.recallFl = false;
- strcpy(cmdLine, _line);
+ strcpy(cmdLine, _vm->_line);
lineIndex = strlen(cmdLine);
}
sprintf(_vm->_statusLine, ">%s%c", cmdLine, cursor);
- sprintf(_vm->_scoreLine, "F1-Help %s Score: %d of %d Sound %s", (_config.turboFl) ? "T" : " ", _vm->getScore(), _vm->getMaxScore(), (_config.soundFl) ? "On" : "Off");
+ 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
if (gameStatus.lookFl) {
@@ -137,11 +133,11 @@ void Parser::keyHandler(Common::Event event) {
// Process key down event - called from OnKeyDown()
switch (nChar) { // Set various toggle states
case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT
- if (gameStatus.viewState == V_INTRO)
+ if (gameStatus.viewState == kViewIntro)
gameStatus.skipIntroFl = true;
else {
- if (gameStatus.inventoryState == I_ACTIVE) // Remove inventory, if displayed
- gameStatus.inventoryState = I_UP;
+ if (gameStatus.inventoryState == kInventoryActive) // Remove inventory, if displayed
+ gameStatus.inventoryState = kInventoryUp;
_vm->_screen->resetInventoryObjId();
}
break;
@@ -179,7 +175,7 @@ void Parser::keyHandler(Common::Event event) {
gameStatus.recallFl = true;
break;
case Common::KEYCODE_F4: // Save game
- if (gameStatus.viewState == V_PLAY) {
+ if (gameStatus.viewState == kViewPlay) {
if (gameStatus.gameOverFl)
Utils::gameOverMsg();
else
@@ -189,7 +185,7 @@ void Parser::keyHandler(Common::Event event) {
case Common::KEYCODE_F5: // Restore game
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
break;
case Common::KEYCODE_F6: // Inventory
showInventory();
@@ -204,7 +200,7 @@ void Parser::keyHandler(Common::Event event) {
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
} else {
if (!gameStatus.storyModeFl) { // Keyboard disabled
// Add printable keys to ring buffer
@@ -236,7 +232,7 @@ void Parser::keyHandler(Common::Event event) {
break;
case Common::KEYCODE_s:
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
- if (gameStatus.viewState == V_PLAY) {
+ if (gameStatus.viewState == kViewPlay) {
if (gameStatus.gameOverFl)
Utils::gameOverMsg();
else
@@ -281,7 +277,7 @@ void Parser::command(const char *format, ...) {
va_list marker;
va_start(marker, format);
- vsprintf(_line, format, marker);
+ vsprintf(_vm->_line, format, marker);
va_end(marker);
lineHandler();
@@ -295,7 +291,7 @@ bool Parser::isWordPresent(char **wordArr) {
if (wordArr != 0) {
for (int i = 0; strlen(wordArr[i]); i++) {
- if (strstr(_line, wordArr[i]))
+ if (strstr(_vm->_line, wordArr[i]))
return true;
}
}
@@ -310,7 +306,7 @@ char *Parser::findNoun() {
for (int i = 0; _vm->_arrayNouns[i]; i++) {
for (int j = 0; strlen(_vm->_arrayNouns[i][j]); j++) {
- if (strstr(_line, _vm->_arrayNouns[i][j]))
+ if (strstr(_vm->_line, _vm->_arrayNouns[i][j]))
return _vm->_arrayNouns[i][0];
}
}
@@ -325,7 +321,7 @@ char *Parser::findVerb() {
for (int i = 0; _vm->_arrayVerbs[i]; i++) {
for (int j = 0; strlen(_vm->_arrayVerbs[i][j]); j++) {
- if (strstr(_line, _vm->_arrayVerbs[i][j]))
+ if (strstr(_vm->_line, _vm->_arrayVerbs[i][j]))
return _vm->_arrayVerbs[i][0];
}
}
@@ -354,7 +350,7 @@ void Parser::showDosInventory() {
if (len1 + len2 < (uint16)strlen(_vm->_textParser[kTBOutro]))
len1 = strlen(_vm->_textParser[kTBOutro]);
- char buffer[XBYTES *NUM_ROWS] = "\0";
+ char buffer[kCompLineSize * kMaxTextRows] = "\0";
strncat(buffer, blanks, (len1 + len2 - strlen(_vm->_textParser[kTBIntro])) / 2);
strcat(strcat(buffer, _vm->_textParser[kTBIntro]), "\n");
index = 0;
@@ -370,7 +366,7 @@ void Parser::showDosInventory() {
strcat(buffer, "\n");
strcat(buffer, _vm->_textParser[kTBOutro]);
- Utils::Box(BOX_ANY, "%s", buffer);
+ Utils::Box(kBoxAny, "%s", buffer);
}
} // End of namespace Hugo
diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h
index b227f2ab4f..31572344a6 100644
--- a/engines/hugo/parser.h
+++ b/engines/hugo/parser.h
@@ -60,7 +60,6 @@ public:
protected:
HugoEngine *_vm;
-protected:
char *findNoun();
char *findVerb();
void showDosInventory();
@@ -69,6 +68,9 @@ protected:
uint16 _getIndex; // Index into ring buffer
uint16 _putIndex;
char _ringBuffer[32]; // Ring buffer
+
+private:
+ static const int kBlinksPerSec = 2; // Cursor blinks per second
};
class Parser_v1d : public Parser {
diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp
index 1539dfb4c0..5d78a3d8be 100644
--- a/engines/hugo/parser_v1d.cpp
+++ b/engines/hugo/parser_v1d.cpp
@@ -66,7 +66,7 @@ char *Parser_v1d::findNextNoun(char *noun) {
}
for (int i = currNounIndex + 1; _vm->_arrayNouns[i]; i++) {
for (int j = 0; strlen(_vm->_arrayNouns[i][j]); j++) {
- if (strstr(_line, _vm->_arrayNouns[i][j]))
+ if (strstr(_vm->_line, _vm->_arrayNouns[i][j]))
return _vm->_arrayNouns[i][0];
}
}
@@ -94,7 +94,7 @@ bool Parser_v1d::isNear(char *verb, char *noun, object_t *obj, char *comment) {
return false;
}
- if (obj->cycling == INVISIBLE) {
+ if (obj->cycling == kCycleInvisible) {
if (obj->seqNumb) { // There is an image
strcpy(comment, _vm->_textParser[kCmtAny5]);
return false;
@@ -150,25 +150,25 @@ bool Parser_v1d::isGenericVerb(char *word, object_t *obj) {
// Following is equivalent to switch, but couldn't do one
if (word == _vm->_arrayVerbs[_vm->_look][0]) {
if ((LOOK & obj->genericCmd) == LOOK)
- Utils::Box(BOX_ANY, "%s", _vm->_textData[obj->dataIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[obj->dataIndex]);
else
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBUnusual_1d]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBUnusual_1d]);
} else if (word == _vm->_arrayVerbs[_vm->_take][0]) {
if (obj->carriedFl)
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBHave]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBHave]);
else if ((TAKE & obj->genericCmd) == TAKE)
takeObject(obj);
else if (!obj->verbOnlyFl) // Make sure not taking object in context!
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoUse]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoUse]);
else
return false;
} else if (word == _vm->_arrayVerbs[_vm->_drop][0]) {
if (!obj->carriedFl)
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBDontHave]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBDontHave]);
else if ((DROP & obj->genericCmd) == DROP)
dropObject(obj);
else
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNeed]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNeed]);
} else { // It was not a generic cmd
return false;
}
@@ -205,22 +205,22 @@ bool Parser_v1d::isObjectVerb(char *word, object_t *obj) {
uint16 *reqs = _vm->_arrayReqs[cmnd->reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) {
- Utils::Box(BOX_ANY, "%s", _vm->_textData[cmnd->textDataNoCarryIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataNoCarryIndex]);
return true;
}
}
}
// Required objects are present, now check state is correct
- if ((obj->state != cmnd->reqState) && (cmnd->reqState != DONT_CARE)){
- Utils::Box(BOX_ANY, "%s", _vm->_textData[cmnd->textDataWrongIndex]);
+ if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)){
+ Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataWrongIndex]);
return true;
}
// Everything checked. Change the state and carry out any actions
- if (cmnd->reqState != DONT_CARE) // Don't change new state if required state didn't care
+ if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care
obj->state = cmnd->newState;
- Utils::Box(BOX_ANY, "%s", _vm->_textData[cmnd->textDataDoneIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataDoneIndex]);
_vm->_scheduler->insertActionList(cmnd->actIndex);
// Special case if verb is Take or Drop. Assume additional generic actions
if ((word == _vm->_arrayVerbs[_vm->_take][0]) || (word == _vm->_arrayVerbs[_vm->_drop][0]))
@@ -240,7 +240,7 @@ bool Parser_v1d::isBackgroundWord(char *noun, char *verb, objectList_t obj) {
for (int i = 0; obj[i].verbIndex; i++) {
if ((verb == _vm->_arrayVerbs[obj[i].verbIndex][0]) && (noun == _vm->_arrayNouns[obj[i].nounIndex][0])) {
- Utils::Box(BOX_ANY, "%s", _vm->_file->fetchString(obj[i].commentIndex));
+ Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex));
return true;
}
}
@@ -255,11 +255,11 @@ void Parser_v1d::takeObject(object_t *obj) {
obj->carriedFl = true;
if (obj->seqNumb) // Don't change if no image to display
- obj->cycling = ALMOST_INVISIBLE;
+ obj->cycling = kCycleAlmostInvisible;
_vm->adjustScore(obj->objValue);
- Utils::Box(BOX_ANY, TAKE_TEXT, _vm->_arrayNouns[obj->nounIndex][TAKE_NAME]);
+ Utils::Box(kBoxAny, TAKE_TEXT, _vm->_arrayNouns[obj->nounIndex][TAKE_NAME]);
}
/**
@@ -271,11 +271,11 @@ void Parser_v1d::dropObject(object_t *obj) {
obj->carriedFl = false;
obj->screenIndex = *_vm->_screen_p;
if (obj->seqNumb) // Don't change if no image to display
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
obj->x = _vm->_hero->x - 1;
obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1;
_vm->adjustScore(-obj->objValue);
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBOk]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBOk]);
}
/**
@@ -290,7 +290,7 @@ bool Parser_v1d::isCatchallVerb(bool testNounFl, char *noun, char *verb, objectL
for (int i = 0; obj[i].verbIndex; i++) {
if ((verb == _vm->_arrayVerbs[obj[i].verbIndex][0]) && ((noun == _vm->_arrayNouns[obj[i].nounIndex][0]) || (obj[i].nounIndex == 0))) {
- Utils::Box(BOX_ANY, "%s", _vm->_file->fetchString(obj[i].commentIndex));
+ Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex));
return true;
}
}
@@ -306,13 +306,13 @@ void Parser_v1d::lineHandler() {
status_t &gameStatus = _vm->getGameStatus();
// Toggle God Mode
- if (!strncmp(_line, "PPG", 3)) {
- _vm->_sound->playSound(!_vm->_soundTest, BOTH_CHANNELS, HIGH_PRI);
+ if (!strncmp(_vm->_line, "PPG", 3)) {
+ _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl;
return;
}
- Utils::strlwr(_line); // Convert to lower case
+ Utils::strlwr(_vm->_line); // Convert to lower case
// God Mode cheat commands:
// goto <screen> Takes hero to named screen
@@ -321,9 +321,9 @@ void Parser_v1d::lineHandler() {
// find <object name> Takes hero to screen containing named object
if (gameStatus.godModeFl) {
// Special code to allow me to go straight to any screen
- if (strstr(_line, "goto")) {
+ if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) {
- if (!scumm_stricmp(&_line[strlen("goto") + 1], _vm->_screenNames[i])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("goto") + 1], _vm->_screenNames[i])) {
_vm->_scheduler->newScreen(i);
return;
}
@@ -331,7 +331,7 @@ void Parser_v1d::lineHandler() {
}
// Special code to allow me to get objects from anywhere
- if (strstr(_line, "fetch all")) {
+ if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
if (_vm->_object->_objects[i].genericCmd & TAKE)
takeObject(&_vm->_object->_objects[i]);
@@ -339,9 +339,9 @@ void Parser_v1d::lineHandler() {
return;
}
- if (strstr(_line, "fetch")) {
+ if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
takeObject(&_vm->_object->_objects[i]);
return;
}
@@ -349,9 +349,9 @@ void Parser_v1d::lineHandler() {
}
// Special code to allow me to goto objects
- if (strstr(_line, "find")) {
+ if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
_vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex);
return;
}
@@ -359,14 +359,14 @@ void Parser_v1d::lineHandler() {
}
}
- if (!strcmp("exit", _line) || strstr(_line, "quit")) {
- if (Utils::Box(BOX_YESNO, "%s", _vm->_textParser[kTBExit_1d]) != 0)
+ if (!strcmp("exit", _vm->_line) || strstr(_vm->_line, "quit")) {
+ if (Utils::Box(kBoxYesNo, "%s", _vm->_textParser[kTBExit_1d]) != 0)
_vm->endGame();
return;
}
// SAVE/RESTORE
- if (!strcmp("save", _line)) {
+ if (!strcmp("save", _vm->_line)) {
if (gameStatus.gameOverFl)
Utils::gameOverMsg();
else
@@ -374,17 +374,17 @@ void Parser_v1d::lineHandler() {
return;
}
- if (!strcmp("restore", _line)) {
+ if (!strcmp("restore", _vm->_line)) {
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
return;
}
- if (*_line == '\0') // Empty line
+ if (*_vm->_line == '\0') // Empty line
return;
- if (strspn(_line, " ") == strlen(_line)) // Nothing but spaces!
+ if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return;
if (gameStatus.gameOverFl) { // No commands allowed!
@@ -395,7 +395,7 @@ void Parser_v1d::lineHandler() {
// Find the first verb in the line
char *verb = findVerb();
char *noun = 0; // Noun not found yet
- char farComment[XBYTES * 5] = ""; // hold 5 line comment if object not nearby
+ char farComment[kCompLineSize * 5] = ""; // hold 5 line comment if object not nearby
if (verb) { // OK, verb found. Try to match with object
do {
@@ -415,16 +415,16 @@ void Parser_v1d::lineHandler() {
}
noun = findNextNoun(noun);
if (*farComment != '\0') // An object matched but not near enough
- Utils::Box(BOX_ANY, "%s", farComment);
+ Utils::Box(kBoxAny, "%s", farComment);
else if (!isCatchallVerb(true, noun, verb, _vm->_catchallList) &&
!isCatchallVerb(false, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p]) &&
!isCatchallVerb(false, noun, verb, _vm->_catchallList))
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBEh_1d]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBEh_1d]);
}
void Parser_v1d::showInventory() {
status_t &gameStatus = _vm->getGameStatus();
- if (gameStatus.viewState == V_PLAY) {
+ if (gameStatus.viewState == kViewPlay) {
if (gameStatus.gameOverFl)
Utils::gameOverMsg();
else
diff --git a/engines/hugo/parser_v1w.cpp b/engines/hugo/parser_v1w.cpp
index 6bca77560d..8bceaeb144 100644
--- a/engines/hugo/parser_v1w.cpp
+++ b/engines/hugo/parser_v1w.cpp
@@ -61,13 +61,13 @@ void Parser_v1w::lineHandler() {
status_t &gameStatus = _vm->getGameStatus();
// Toggle God Mode
- if (!strncmp(_line, "PPG", 3)) {
- _vm->_sound->playSound(!_vm->_soundTest, BOTH_CHANNELS, HIGH_PRI);
+ if (!strncmp(_vm->_line, "PPG", 3)) {
+ _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl;
return;
}
- Utils::strlwr(_line); // Convert to lower case
+ Utils::strlwr(_vm->_line); // Convert to lower case
// God Mode cheat commands:
// goto <screen> Takes hero to named screen
@@ -76,9 +76,9 @@ void Parser_v1w::lineHandler() {
// find <object name> Takes hero to screen containing named object
if (gameStatus.godModeFl) {
// Special code to allow me to go straight to any screen
- if (strstr(_line, "goto")) {
+ if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) {
- if (!scumm_stricmp(&_line[strlen("goto") + 1], _vm->_screenNames[i])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("goto") + 1], _vm->_screenNames[i])) {
_vm->_scheduler->newScreen(i);
return;
}
@@ -86,7 +86,7 @@ void Parser_v1w::lineHandler() {
}
// Special code to allow me to get objects from anywhere
- if (strstr(_line, "fetch all")) {
+ if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
if (_vm->_object->_objects[i].genericCmd & TAKE)
takeObject(&_vm->_object->_objects[i]);
@@ -94,9 +94,9 @@ void Parser_v1w::lineHandler() {
return;
}
- if (strstr(_line, "fetch")) {
+ if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
takeObject(&_vm->_object->_objects[i]);
return;
}
@@ -104,9 +104,9 @@ void Parser_v1w::lineHandler() {
}
// Special code to allow me to goto objects
- if (strstr(_line, "find")) {
+ if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
_vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex);
return;
}
@@ -116,28 +116,28 @@ void Parser_v1w::lineHandler() {
// Special meta commands
// EXIT/QUIT
- if (!strcmp("exit", _line) || strstr(_line, "quit")) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBExit]);
+ if (!strcmp("exit", _vm->_line) || strstr(_vm->_line, "quit")) {
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBExit]);
return;
}
// SAVE/RESTORE
- if (!strcmp("save", _line) && gameStatus.viewState == V_PLAY) {
+ if (!strcmp("save", _vm->_line) && gameStatus.viewState == kViewPlay) {
_vm->_file->saveGame(-1, Common::String());
return;
}
- if (!strcmp("restore", _line) && (gameStatus.viewState == V_PLAY || gameStatus.viewState == V_IDLE)) {
+ if (!strcmp("restore", _vm->_line) && (gameStatus.viewState == kViewPlay || gameStatus.viewState == kViewIdle)) {
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
return;
}
// Empty line
- if (*_line == '\0') // Empty line
+ if (*_vm->_line == '\0') // Empty line
return;
- if (strspn(_line, " ") == strlen(_line)) // Nothing but spaces!
+ if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return;
if (gameStatus.gameOverFl) {
@@ -146,7 +146,7 @@ void Parser_v1w::lineHandler() {
return;
}
- char farComment[XBYTES * 5] = ""; // hold 5 line comment if object not nearby
+ char farComment[kCompLineSize * 5] = ""; // hold 5 line comment if object not nearby
// Test for nearby objects referenced explicitly
for (int i = 0; i < _vm->_object->_numObj; i++) {
@@ -162,7 +162,7 @@ void Parser_v1w::lineHandler() {
for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[i];
if (obj->verbOnlyFl) {
- char contextComment[XBYTES * 5] = ""; // Unused comment for context objects
+ char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects
if (isObjectVerb(obj, contextComment) || isGenericVerb(obj, contextComment))
return;
}
@@ -180,7 +180,7 @@ void Parser_v1w::lineHandler() {
// If a not-near comment was generated, print it
if (*farComment != '\0') {
- Utils::Box(BOX_ANY, "%s", farComment);
+ Utils::Box(kBoxAny, "%s", farComment);
return;
}
@@ -188,16 +188,16 @@ void Parser_v1w::lineHandler() {
char *verb = findVerb();
char *noun = findNoun();
if (verb == _vm->_arrayVerbs[_vm->_look][0] && _maze.enabledFl) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBMaze]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBMaze]);
_vm->_object->showTakeables();
} else if (verb && noun) { // A combination I didn't think of
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoPoint]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoPoint]);
} else if (noun) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoun]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoun]);
} else if (verb) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBVerb]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBVerb]);
} else {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBEh]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBEh]);
}
}
@@ -205,12 +205,12 @@ void Parser_v1w::showInventory() {
status_t &gameStatus = _vm->getGameStatus();
if (gameStatus.gameOverFl) {
Utils::gameOverMsg();
- } else if ((gameStatus.inventoryState == I_OFF) && (gameStatus.viewState == V_PLAY)) {
- gameStatus.inventoryState = I_DOWN;
- gameStatus.viewState = V_INVENT;
- } else if (gameStatus.inventoryState == I_ACTIVE) {
- gameStatus.inventoryState = I_UP;
- gameStatus.viewState = V_INVENT;
+ } else if ((gameStatus.inventoryState == kInventoryOff) && (gameStatus.viewState == kViewPlay)) {
+ gameStatus.inventoryState = kInventoryDown;
+ gameStatus.viewState = kViewInvent;
+ } else if (gameStatus.inventoryState == kInventoryActive) {
+ gameStatus.inventoryState = kInventoryUp;
+ gameStatus.viewState = kViewInvent;
}
}
diff --git a/engines/hugo/parser_v2d.cpp b/engines/hugo/parser_v2d.cpp
index 30ac8a765a..c2a5704a49 100644
--- a/engines/hugo/parser_v2d.cpp
+++ b/engines/hugo/parser_v2d.cpp
@@ -59,13 +59,13 @@ void Parser_v2d::lineHandler() {
status_t &gameStatus = _vm->getGameStatus();
// Toggle God Mode
- if (!strncmp(_line, "PPG", 3)) {
- _vm->_sound->playSound(!_vm->_soundTest, BOTH_CHANNELS, HIGH_PRI);
+ if (!strncmp(_vm->_line, "PPG", 3)) {
+ _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl;
return;
}
- Utils::strlwr(_line); // Convert to lower case
+ Utils::strlwr(_vm->_line); // Convert to lower case
// God Mode cheat commands:
// goto <screen> Takes hero to named screen
@@ -74,9 +74,9 @@ void Parser_v2d::lineHandler() {
// find <object name> Takes hero to screen containing named object
if (gameStatus.godModeFl) {
// Special code to allow me to go straight to any screen
- if (strstr(_line, "goto")) {
+ if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) {
- if (!scumm_stricmp(&_line[strlen("goto") + 1], _vm->_screenNames[i])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("goto") + 1], _vm->_screenNames[i])) {
_vm->_scheduler->newScreen(i);
return;
}
@@ -84,7 +84,7 @@ void Parser_v2d::lineHandler() {
}
// Special code to allow me to get objects from anywhere
- if (strstr(_line, "fetch all")) {
+ if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
if (_vm->_object->_objects[i].genericCmd & TAKE)
takeObject(&_vm->_object->_objects[i]);
@@ -92,9 +92,9 @@ void Parser_v2d::lineHandler() {
return;
}
- if (strstr(_line, "fetch")) {
+ if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
takeObject(&_vm->_object->_objects[i]);
return;
}
@@ -102,9 +102,9 @@ void Parser_v2d::lineHandler() {
}
// Special code to allow me to goto objects
- if (strstr(_line, "find")) {
+ if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
_vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex);
return;
}
@@ -112,16 +112,16 @@ void Parser_v2d::lineHandler() {
}
}
- if (!strcmp("exit", _line) || strstr(_line, "quit")) {
- if (Utils::Box(BOX_YESNO, "%s", _vm->_textParser[kTBExit_1d]) != 0)
+ if (!strcmp("exit", _vm->_line) || strstr(_vm->_line, "quit")) {
+ if (Utils::Box(kBoxYesNo, "%s", _vm->_textParser[kTBExit_1d]) != 0)
_vm->endGame();
else
return;
}
// SAVE/RESTORE
- if (!strcmp("save", _line)) {
- _config.soundFl = false;
+ if (!strcmp("save", _vm->_line)) {
+ _vm->_config.soundFl = false;
if (gameStatus.gameOverFl)
Utils::gameOverMsg();
else
@@ -129,18 +129,18 @@ void Parser_v2d::lineHandler() {
return;
}
- if (!strcmp("restore", _line)) {
- _config.soundFl = false;
+ if (!strcmp("restore", _vm->_line)) {
+ _vm->_config.soundFl = false;
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
return;
}
- if (*_line == '\0') // Empty line
+ if (*_vm->_line == '\0') // Empty line
return;
- if (strspn(_line, " ") == strlen(_line)) // Nothing but spaces!
+ if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return;
if (gameStatus.gameOverFl) { // No commands allowed!
@@ -151,7 +151,7 @@ void Parser_v2d::lineHandler() {
// Find the first verb in the line
char *verb = findVerb();
char *noun = 0; // Noun not found yet
- char farComment[XBYTES * 5] = ""; // hold 5 line comment if object not nearby
+ char farComment[kCompLineSize * 5] = ""; // hold 5 line comment if object not nearby
if (verb) { // OK, verb found. Try to match with object
do {
@@ -176,16 +176,16 @@ void Parser_v2d::lineHandler() {
&& !isCatchallVerb(false, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p])
&& !isCatchallVerb(false, noun, verb, _vm->_catchallList)) {
if (*farComment != '\0') { // An object matched but not near enough
- Utils::Box(BOX_ANY, "%s", farComment);
+ Utils::Box(kBoxAny, "%s", farComment);
} else if (_maze.enabledFl && (verb == _vm->_arrayVerbs[_vm->_look][0])) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBMaze]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBMaze]);
_vm->_object->showTakeables();
} else if (verb && noun) { // A combination I didn't think of
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoUse_2d]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoUse_2d]);
} else if (verb || noun) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoun]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoun]);
} else {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBEh_2d]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBEh_2d]);
}
}
}
diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp
index 395dc2a16b..2ab13eaed3 100644
--- a/engines/hugo/parser_v3d.cpp
+++ b/engines/hugo/parser_v3d.cpp
@@ -59,13 +59,13 @@ void Parser_v3d::lineHandler() {
status_t &gameStatus = _vm->getGameStatus();
// Toggle God Mode
- if (!strncmp(_line, "PPG", 3)) {
- _vm->_sound->playSound(!_vm->_soundTest, BOTH_CHANNELS, HIGH_PRI);
+ if (!strncmp(_vm->_line, "PPG", 3)) {
+ _vm->_sound->playSound(!_vm->_soundTest, kSoundPriorityHigh);
gameStatus.godModeFl = !gameStatus.godModeFl;
return;
}
- Utils::strlwr(_line); // Convert to lower case
+ Utils::strlwr(_vm->_line); // Convert to lower case
// God Mode cheat commands:
// goto <screen> Takes hero to named screen
@@ -74,9 +74,9 @@ void Parser_v3d::lineHandler() {
// find <object name> Takes hero to screen containing named object
if (gameStatus.godModeFl) {
// Special code to allow me to go straight to any screen
- if (strstr(_line, "goto")) {
+ if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) {
- if (!scumm_stricmp(&_line[strlen("goto") + 1], _vm->_screenNames[i])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("goto") + 1], _vm->_screenNames[i])) {
_vm->_scheduler->newScreen(i);
return;
}
@@ -84,7 +84,7 @@ void Parser_v3d::lineHandler() {
}
// Special code to allow me to get objects from anywhere
- if (strstr(_line, "fetch all")) {
+ if (strstr(_vm->_line, "fetch all")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
if (_vm->_object->_objects[i].genericCmd & TAKE)
takeObject(&_vm->_object->_objects[i]);
@@ -92,9 +92,9 @@ void Parser_v3d::lineHandler() {
return;
}
- if (strstr(_line, "fetch")) {
+ if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
takeObject(&_vm->_object->_objects[i]);
return;
}
@@ -102,9 +102,9 @@ void Parser_v3d::lineHandler() {
}
// Special code to allow me to goto objects
- if (strstr(_line, "find")) {
+ if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
_vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex);
return;
}
@@ -114,16 +114,16 @@ void Parser_v3d::lineHandler() {
// Special meta commands
// EXIT/QUIT
- if (!strcmp("exit", _line) || strstr(_line, "quit")) {
- if (Utils::Box(BOX_YESNO, "%s", _vm->_textParser[kTBExit_1d]) != 0)
+ if (!strcmp("exit", _vm->_line) || strstr(_vm->_line, "quit")) {
+ if (Utils::Box(kBoxYesNo, "%s", _vm->_textParser[kTBExit_1d]) != 0)
_vm->endGame();
else
return;
}
// SAVE/RESTORE
- if (!strcmp("save", _line)) {
- _config.soundFl = false;
+ if (!strcmp("save", _vm->_line)) {
+ _vm->_config.soundFl = false;
if (gameStatus.gameOverFl)
Utils::gameOverMsg();
else
@@ -131,18 +131,18 @@ void Parser_v3d::lineHandler() {
return;
}
- if (!strcmp("restore", _line)) {
- _config.soundFl = false;
+ if (!strcmp("restore", _vm->_line)) {
+ _vm->_config.soundFl = false;
_vm->_file->restoreGame(-1);
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
- gameStatus.viewState = V_PLAY;
+ gameStatus.viewState = kViewPlay;
return;
}
// Empty line
- if (*_line == '\0') // Empty line
+ if (*_vm->_line == '\0') // Empty line
return;
- if (strspn(_line, " ") == strlen(_line)) // Nothing but spaces!
+ if (strspn(_vm->_line, " ") == strlen(_vm->_line)) // Nothing but spaces!
return;
if (gameStatus.gameOverFl) {
@@ -151,7 +151,7 @@ void Parser_v3d::lineHandler() {
return;
}
- char farComment[XBYTES * 5] = ""; // hold 5 line comment if object not nearby
+ char farComment[kCompLineSize * 5] = ""; // hold 5 line comment if object not nearby
// Test for nearby objects referenced explicitly
for (int i = 0; i < _vm->_object->_numObj; i++) {
@@ -167,7 +167,7 @@ void Parser_v3d::lineHandler() {
for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[i];
if (obj->verbOnlyFl) {
- char contextComment[XBYTES * 5] = ""; // Unused comment for context objects
+ char contextComment[kCompLineSize * 5] = ""; // Unused comment for context objects
if (isObjectVerb(obj, contextComment) || isGenericVerb(obj, contextComment))
return;
}
@@ -185,7 +185,7 @@ void Parser_v3d::lineHandler() {
// If a not-near comment was generated, print it
if (*farComment != '\0') {
- Utils::Box(BOX_ANY, "%s", farComment);
+ Utils::Box(kBoxAny, "%s", farComment);
return;
}
@@ -194,13 +194,13 @@ void Parser_v3d::lineHandler() {
char *noun = findNoun();
if (verb && noun) { // A combination I didn't think of
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoPoint]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoPoint]);
} else if (noun) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoun]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoun]);
} else if (verb) {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBVerb]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBVerb]);
} else {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBEh]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBEh]);
}
}
@@ -237,22 +237,22 @@ bool Parser_v3d::isObjectVerb(object_t *obj, char *comment) {
uint16 *reqs = _vm->_arrayReqs[cmnd->reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) {
- Utils::Box(BOX_ANY, "%s", _vm->_textData[cmnd->textDataNoCarryIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataNoCarryIndex]);
return true;
}
}
}
// Required objects are present, now check state is correct
- if ((obj->state != cmnd->reqState) && (cmnd->reqState != DONT_CARE)) {
- Utils::Box(BOX_ANY, "%s", _vm->_textData[cmnd->textDataWrongIndex]);
+ if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)) {
+ Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataWrongIndex]);
return true;
}
// Everything checked. Change the state and carry out any actions
- if (cmnd->reqState != DONT_CARE) // Don't change new state if required state didn't care
+ if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care
obj->state = cmnd->newState;
- Utils::Box(BOX_ANY, "%s", _vm->_textData[cmnd->textDataDoneIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataDoneIndex]);
_vm->_scheduler->insertActionList(cmnd->actIndex);
// See if any additional generic actions
@@ -274,35 +274,35 @@ bool Parser_v3d::isGenericVerb(object_t *obj, char *comment) {
if (isWordPresent(_vm->_arrayVerbs[_vm->_look]) && isNear(obj, _vm->_arrayVerbs[_vm->_look][0], comment)) {
// Test state-dependent look before general look
if ((obj->genericCmd & LOOK_S) == LOOK_S) {
- Utils::Box(BOX_ANY, "%s", _vm->_textData[obj->stateDataIndex[obj->state]]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[obj->stateDataIndex[obj->state]]);
} else {
if ((LOOK & obj->genericCmd) == LOOK) {
if (obj->dataIndex != 0)
- Utils::Box(BOX_ANY, "%s", _vm->_textData[obj->dataIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_textData[obj->dataIndex]);
else
return false;
} else {
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBUnusual]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBUnusual]);
}
}
} else if (isWordPresent(_vm->_arrayVerbs[_vm->_take]) && isNear(obj, _vm->_arrayVerbs[_vm->_take][0], comment)) {
if (obj->carriedFl)
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBHave]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBHave]);
else if ((TAKE & obj->genericCmd) == TAKE)
takeObject(obj);
else if (obj->cmdIndex) // No comment if possible commands
return false;
else if (!obj->verbOnlyFl && (TAKE & obj->genericCmd) == TAKE) // Make sure not taking object in context!
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNoUse]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoUse]);
else
return false;
} else if (isWordPresent(_vm->_arrayVerbs[_vm->_drop])) {
if (!obj->carriedFl && ((DROP & obj->genericCmd) == DROP))
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBDontHave]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBDontHave]);
else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP))
dropObject(obj);
else if (obj->cmdIndex == 0)
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBNeed]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNeed]);
else
return false;
} else { // It was not a generic cmd
@@ -333,7 +333,7 @@ bool Parser_v3d::isNear(object_t *obj, char *verb, char *comment) {
return false;
}
- if (obj->cycling == INVISIBLE) {
+ if (obj->cycling == kCycleInvisible) {
if (obj->seqNumb) {
// There is an image
strcpy(comment, _vm->_textParser[kCmtAny3]);
@@ -378,13 +378,13 @@ void Parser_v3d::takeObject(object_t *obj) {
obj->carriedFl = true;
if (obj->seqNumb) { // Don't change if no image to display
- obj->cycling = INVISIBLE;
+ obj->cycling = kCycleInvisible;
}
_vm->adjustScore(obj->objValue);
- if (obj->seqNumb > 0) // If object has an image, force walk to dropped
- obj->viewx = -1; // (possibly moved) object next time taken!
- Utils::Box(BOX_ANY, TAKE_TEXT, _vm->_arrayNouns[obj->nounIndex][TAKE_NAME]);
+ if (obj->seqNumb > 0) // If object has an image, force walk to dropped
+ obj->viewx = -1; // (possibly moved) object next time taken!
+ Utils::Box(kBoxAny, TAKE_TEXT, _vm->_arrayNouns[obj->nounIndex][TAKE_NAME]);
}
/**
@@ -396,14 +396,14 @@ void Parser_v3d::dropObject(object_t *obj) {
obj->carriedFl = false;
obj->screenIndex = *_vm->_screen_p;
if ((obj->seqNumb > 1) || (obj->seqList[0].imageNbr > 1))
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
else
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
obj->x = _vm->_hero->x - 1;
obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1;
- obj->y = (obj->y + obj->currImagePtr->y2 < YPIX) ? obj->y : YPIX - obj->currImagePtr->y2 - 10;
+ obj->y = (obj->y + obj->currImagePtr->y2 < kYPix) ? obj->y : kYPix - obj->currImagePtr->y2 - 10;
_vm->adjustScore(-obj->objValue);
- Utils::Box(BOX_ANY, "%s", _vm->_textParser[kTBOk]);
+ Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBOk]);
}
/**
@@ -418,9 +418,9 @@ bool Parser_v3d::isCatchallVerb(objectList_t obj) {
for (int i = 0; obj[i].verbIndex != 0; i++) {
if (isWordPresent(_vm->_arrayVerbs[obj[i].verbIndex]) && obj[i].nounIndex == 0 &&
(!obj[i].matchFl || !findNoun()) &&
- ((obj[i].roomState == DONT_CARE) ||
+ ((obj[i].roomState == kStateDontCare) ||
(obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) {
- Utils::Box(BOX_ANY, "%s", _vm->_file->fetchString(obj[i].commentIndex));
+ Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex));
_vm->_scheduler->processBonus(obj[i].bonusIndex);
// If this is LOOK (without a noun), show any takeable objects
@@ -443,9 +443,9 @@ bool Parser_v3d::isBackgroundWord(objectList_t obj) {
for (int i = 0; obj[i].verbIndex != 0; i++) {
if (isWordPresent(_vm->_arrayVerbs[obj[i].verbIndex]) &&
isWordPresent(_vm->_arrayNouns[obj[i].nounIndex]) &&
- ((obj[i].roomState == DONT_CARE) ||
+ ((obj[i].roomState == kStateDontCare) ||
(obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) {
- Utils::Box(BOX_ANY, "%s", _vm->_file->fetchString(obj[i].commentIndex));
+ Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex));
_vm->_scheduler->processBonus(obj[i].bonusIndex);
return true;
}
diff --git a/engines/hugo/route.cpp b/engines/hugo/route.cpp
index e8ecf0796b..206bd9c47b 100644
--- a/engines/hugo/route.cpp
+++ b/engines/hugo/route.cpp
@@ -37,7 +37,6 @@
#include "hugo/hugo.h"
#include "hugo/game.h"
#include "hugo/route.h"
-#include "hugo/global.h"
#include "hugo/object.h"
namespace Hugo {
@@ -99,7 +98,7 @@ void Route::setWalk(uint16 direction) {
static uint16 oldDirection = 0; // Last direction char
object_t *obj = _vm->_hero; // Pointer to hero object
- if (_vm->getGameStatus().storyModeFl || obj->pathType != USER) // Make sure user has control
+ if (_vm->getGameStatus().storyModeFl || obj->pathType != kPathUser) // Make sure user has control
return;
if (!obj->vx && !obj->vy)
@@ -112,53 +111,53 @@ void Route::setWalk(uint16 direction) {
switch (direction) { // And set correct velocity
case Common::KEYCODE_UP:
case Common::KEYCODE_KP8:
- obj->vy = -DY;
+ obj->vy = -kStepDy;
break;
case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2:
- obj->vy = DY;
+ obj->vy = kStepDy;
break;
case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4:
- obj->vx = -DX;
+ obj->vx = -kStepDx;
break;
case Common::KEYCODE_RIGHT:
case Common::KEYCODE_KP6:
- obj->vx = DX;
+ obj->vx = kStepDx;
break;
case Common::KEYCODE_HOME:
case Common::KEYCODE_KP7:
- obj->vx = -DX;
+ obj->vx = -kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to DY
- obj->vy = -DY / 2;
+ obj->vy = -kStepDy / 2;
break;
case Common::KEYCODE_END:
case Common::KEYCODE_KP1:
- obj->vx = -DX;
+ obj->vx = -kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to -DY
- obj->vy = DY / 2;
+ obj->vy = kStepDy / 2;
break;
case Common::KEYCODE_PAGEUP:
case Common::KEYCODE_KP9:
- obj->vx = DX;
+ obj->vx = kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to -DY
- obj->vy = -DY / 2;
+ obj->vy = -kStepDy / 2;
break;
case Common::KEYCODE_PAGEDOWN:
case Common::KEYCODE_KP3:
- obj->vx = DX;
+ obj->vx = kStepDx;
// Note: in v1 Dos and v2 Dos, obj->vy is set to DY
- obj->vy = DY / 2;
+ obj->vy = kStepDy / 2;
break;
}
oldDirection = direction;
- obj->cycling = CYCLE_FORWARD;
+ obj->cycling = kCycleForward;
} else {
// Same key twice - halt hero
obj->vy = 0;
obj->vx = 0;
oldDirection = 0;
- obj->cycling = NOT_CYCLING;
+ obj->cycling = kCycleNotCycling;
}
}
@@ -196,7 +195,7 @@ void Route::segment(int16 x, int16 y) {
break;
}
}
- for (x2 = x + 1; x2 < XPIX; x2++) {
+ for (x2 = x + 1; x2 < kXPix; x2++) {
if (p[x2] == 0) {
p[x2] = kMapFill;
} else {
@@ -215,7 +214,7 @@ void Route::segment(int16 x, int16 y) {
_routeFoundFl = true;
// Bounds check y in case no boundary around screen
- if (y <= 0 || y >= YPIX - 1)
+ if (y <= 0 || y >= kYPix - 1)
return;
if (_vm->_hero->x < x1) {
@@ -231,7 +230,7 @@ void Route::segment(int16 x, int16 y) {
if (_boundaryMap[y + 1][x] == 0)
segment(x, y + 1);
}
- } else if (_vm->_hero->x + HERO_MAX_WIDTH > x2) {
+ } else if (_vm->_hero->x + kHeroMaxWidth > x2) {
// Hero x not in segment, search x1..x2
// Find all segments above current
for (x = x2; !(_routeFoundFl | _fullStackFl | _fullSegmentFl) && x >= x1; x--) {
@@ -313,7 +312,7 @@ bool Route::findRoute(int16 cx, int16 cy) {
_fullStackFl = false; // Stack not exhausted
_fullSegmentFl = false; // Segments not exhausted
_segmentNumb = 0; // Segment index
- _heroWidth = HERO_MIN_WIDTH; // Minimum width of hero
+ _heroWidth = kHeroMinWidth; // Minimum width of hero
_destY = cy; // Destination coords
_destX = cx; // Destination coords
@@ -325,21 +324,21 @@ bool Route::findRoute(int16 cx, int16 cy) {
object_t *obj; // Ptr to object
int i;
for (i = 1, obj = &_vm->_object->_objects[i]; i < _vm->_object->_numObj; i++, obj++) {
- if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling != INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling != kCycleInvisible) && (obj->priority == kPriorityFloating))
_vm->storeBoundary(obj->oldx + obj->currImagePtr->x1, obj->oldx + obj->currImagePtr->x2, obj->oldy + obj->currImagePtr->y2);
}
// Combine objbound and boundary bitmaps to local byte map
- for (int16 y = 0; y < YPIX; y++) {
- for (int16 x = 0; x < XBYTES; x++) {
+ for (int16 y = 0; y < kYPix; y++) {
+ for (int16 x = 0; x < kCompLineSize; x++) {
for (i = 0; i < 8; i++)
- _boundaryMap[y][x * 8 + i] = ((_vm->getObjectBoundaryOverlay()[y * XBYTES + x] | _vm->getBoundaryOverlay()[y * XBYTES + x]) & (0x80 >> i)) ? kMapBound : 0;
+ _boundaryMap[y][x * 8 + i] = ((_vm->getObjectBoundaryOverlay()[y * kCompLineSize + x] | _vm->getBoundaryOverlay()[y * kCompLineSize + x]) & (0x80 >> i)) ? kMapBound : 0;
}
}
// Clear all object baselines from objbound
for (i = 0, obj = _vm->_object->_objects; i < _vm->_object->_numObj; i++, obj++) {
- if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling != INVISIBLE) && (obj->priority == FLOATING))
+ if ((obj->screenIndex == *_vm->_screen_p) && (obj->cycling != kCycleInvisible) && (obj->priority == kPriorityFloating))
_vm->clearBoundary(obj->oldx + obj->currImagePtr->x1, obj->oldx + obj->currImagePtr->x2, obj->oldy + obj->currImagePtr->y2);
}
@@ -385,7 +384,7 @@ bool Route::findRoute(int16 cx, int16 cy) {
int16 x2 = MIN(_segment[j - 1].x2, seg_p->x2);
// If room, add a little offset to reduce staircase effect
- int16 dx = HERO_MAX_WIDTH >> 1;
+ int16 dx = kHeroMaxWidth >> 1;
if (x2 - x1 < _heroWidth + dx)
dx = 0;
@@ -425,22 +424,22 @@ void Route::processRoute() {
Point *routeNode = &_route[gameStatus.routeIndex];
// Arrived at node?
- if (abs(herox - routeNode->x) < DX + 1 && abs(heroy - routeNode->y) < DY) {
- // DX too low
+ if (abs(herox - routeNode->x) < kStepDx + 1 && abs(heroy - routeNode->y) < kStepDy) {
+ // kStepDx too low
// Close enough - position hero exactly
_vm->_hero->x = _vm->_hero->oldx = routeNode->x - _vm->_hero->currImagePtr->x1;
_vm->_hero->y = _vm->_hero->oldy = routeNode->y - _vm->_hero->currImagePtr->y2;
_vm->_hero->vx = _vm->_hero->vy = 0;
- _vm->_hero->cycling = NOT_CYCLING;
+ _vm->_hero->cycling = kCycleNotCycling;
// Arrived at final node?
if (--gameStatus.routeIndex < 0) {
// See why we walked here
switch (gameStatus.go_for) {
- case GO_EXIT: // Walked to an exit, proceed into it
+ case kRouteExit: // Walked to an exit, proceed into it
setWalk(_vm->_hotspots[gameStatus.go_id].direction);
break;
- case GO_LOOK: // Look at an object
+ case kRouteLook: // Look at an object
if (turnedFl) {
_vm->_object->lookObject(&_vm->_object->_objects[gameStatus.go_id]);
turnedFl = false;
@@ -450,7 +449,7 @@ void Route::processRoute() {
turnedFl = true;
}
break;
- case GO_GET: // Get (or use) an object
+ case kRouteGet: // Get (or use) an object
if (turnedFl) {
_vm->_object->useObject(gameStatus.go_id);
turnedFl = false;
@@ -491,20 +490,20 @@ bool Route::startRoute(go_t go_for, int16 id, int16 cx, int16 cy) {
debugC(1, kDebugRoute, "startRoute(%d, %d, %d, %d)", go_for, id, cx, cy);
// Don't attempt to walk if user does not have control
- if (_vm->_hero->pathType != USER)
+ if (_vm->_hero->pathType != kPathUser)
return false;
status_t &gameStatus = _vm->getGameStatus();
// if inventory showing, make it go away
- if (gameStatus.inventoryState != I_OFF)
- gameStatus.inventoryState = I_UP;
+ if (gameStatus.inventoryState != kInventoryOff)
+ gameStatus.inventoryState = kInventoryUp;
gameStatus.go_for = go_for; // Purpose of trip
gameStatus.go_id = id; // Index of exit/object
// Adjust destination to center hero if walking to cursor
- if (gameStatus.go_for == GO_SPACE)
- cx -= HERO_MIN_WIDTH / 2;
+ if (gameStatus.go_for == kRouteSpace)
+ cx -= kHeroMinWidth / 2;
bool foundFl = false; // TRUE if route found ok
if ((foundFl = findRoute(cx, cy))) { // Found a route?
diff --git a/engines/hugo/route.h b/engines/hugo/route.h
index 6aeb1a0b29..d09d19d3dd 100644
--- a/engines/hugo/route.h
+++ b/engines/hugo/route.h
@@ -35,12 +35,6 @@
namespace Hugo {
-#define kMapBound 1 // Mark a boundary outline
-#define kMapFill 2 // Mark a boundary filled
-#define kMaxSeg 256 // Maximum number of segments
-#define kMaxNodes 256 // Maximum nodes in route
-#define DEBUG_ROUTE FALSE
-
struct Point {
int x;
int y;
@@ -63,7 +57,12 @@ public:
private:
HugoEngine *_vm;
- byte _boundaryMap[YPIX][XPIX]; // Boundary byte map
+ static const int kMapBound = 1; // Mark a boundary outline
+ static const int kMapFill = 2; // Mark a boundary filled
+ static const int kMaxSeg = 256; // Maximum number of segments
+ static const int kMaxNodes = 256; // Maximum nodes in route
+
+ 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)
int16 _segmentNumb; // Count number of segments
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index 715084d615..b75a38c882 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -161,7 +161,7 @@ void Scheduler::newScreen(int screenIndex) {
// Make sure the background file exists!
if (!_vm->isPacked()) {
char line[32];
- if (!_vm->_file->fileExists(strcat(strncat(strcpy(line, _vm->_picDir), _vm->_screenNames[screenIndex], NAME_LEN), BKGEXT)) &&
+ if (!_vm->_file->fileExists(strcat(strncat(strcpy(line, _vm->_picDir), _vm->_screenNames[screenIndex], kFilenameLength), BKGEXT)) &&
!_vm->_file->fileExists(strcat(strcpy(line, _vm->_screenNames[screenIndex]), ".ART"))) {
error("Unable to find background file for %s", _vm->_screenNames[screenIndex]);
return;
@@ -843,29 +843,29 @@ void Scheduler::processMaze(int x1, int x2, int y1, int y2) {
if (x1 < _maze.x1) {
// Exit west
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - 1;
- _actListArr[_alNewscrIndex][0].a2.x = _maze.x2 - SHIFT - (x2 - x1);
+ _actListArr[_alNewscrIndex][0].a2.x = _maze.x2 - kShiftSize - (x2 - x1);
_actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y;
gameStatus.routeIndex = -1;
insertActionList(_alNewscrIndex);
} else if (x2 > _maze.x2) {
// Exit east
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + 1;
- _actListArr[_alNewscrIndex][0].a2.x = _maze.x1 + SHIFT;
+ _actListArr[_alNewscrIndex][0].a2.x = _maze.x1 + kShiftSize;
_actListArr[_alNewscrIndex][0].a2.y = _vm->_hero->y;
gameStatus.routeIndex = -1;
insertActionList(_alNewscrIndex);
- } else if (y1 < _maze.y1 - SHIFT) {
+ } else if (y1 < _maze.y1 - kShiftSize) {
// Exit north
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p - _maze.size;
_actListArr[_alNewscrIndex][0].a2.x = _maze.x3;
- _actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - SHIFT - (y2 - y1);
+ _actListArr[_alNewscrIndex][0].a2.y = _maze.y2 - kShiftSize - (y2 - y1);
gameStatus.routeIndex = -1;
insertActionList(_alNewscrIndex);
- } else if (y2 > _maze.y2 - SHIFT / 2) {
+ } else if (y2 > _maze.y2 - kShiftSize / 2) {
// Exit south
_actListArr[_alNewscrIndex][3].a8.screenIndex = *_vm->_screen_p + _maze.size;
_actListArr[_alNewscrIndex][0].a2.x = _maze.x4;
- _actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + SHIFT;
+ _actListArr[_alNewscrIndex][0].a2.y = _maze.y1 + kShiftSize;
gameStatus.routeIndex = -1;
insertActionList(_alNewscrIndex);
}
@@ -1051,7 +1051,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a11.actFailIndex);
break;
case TEXT: // act12: Text box (CF WARN)
- Utils::Box(BOX_ANY, "%s", _vm->_file->fetchString(action->a12.stringIndex)); // Fetch string from file
+ Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(action->a12.stringIndex)); // Fetch string from file
break;
case SWAP_IMAGES: // act13: Swap 2 object images
_vm->_object->swapImages(action->a13.objIndex1, action->a13.objIndex2);
@@ -1115,7 +1115,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
if (action->a26.soundIndex < _vm->_tunesNbr)
_vm->_sound->playMusic(action->a26.soundIndex);
else
- _vm->_sound->playSound(action->a26.soundIndex, BOTH_CHANNELS, MED_PRI);
+ _vm->_sound->playSound(action->a26.soundIndex, kSoundPriorityMedium);
break;
case ADD_SCORE: // act27: Add object's value to score
_vm->adjustScore(_vm->_object->_objects[action->a27.objIndex].objValue);
@@ -1168,7 +1168,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm->_object->_objects[action->a38.lipsObjIndex].x = _vm->_object->_objects[action->a38.objIndex].x + action->a38.dxLips;
_vm->_object->_objects[action->a38.lipsObjIndex].y = _vm->_object->_objects[action->a38.objIndex].y + action->a38.dyLips;
_vm->_object->_objects[action->a38.lipsObjIndex].screenIndex = *_vm->_screen_p; // Don't forget screen!
- _vm->_object->_objects[action->a38.lipsObjIndex].cycling = CYCLE_FORWARD;
+ _vm->_object->_objects[action->a38.lipsObjIndex].cycling = kCycleForward;
break;
case INIT_STORY_MODE: // act39: Init story_mode flag
// This is similar to the QUIET path mode, except that it is
@@ -1180,7 +1180,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
_vm->endGame();
break;
case WARN: // act40: Text box (CF TEXT)
- Utils::Box(BOX_OK, "%s", _vm->_file->fetchString(action->a40.stringIndex));
+ Utils::Box(kBoxOk, "%s", _vm->_file->fetchString(action->a40.stringIndex));
break;
case COND_BONUS: // act41: Perform action if got bonus
if (_vm->_points[action->a41.BonusIndex].scoredFl)
@@ -1189,10 +1189,10 @@ event_t *Scheduler::doAction(event_t *curEvent) {
insertActionList(action->a41.actFailIndex);
break;
case TEXT_TAKE: // act42: Text box with "take" message
- Utils::Box(BOX_ANY, TAKE_TEXT, _vm->_arrayNouns[_vm->_object->_objects[action->a42.objIndex].nounIndex][TAKE_NAME]);
+ Utils::Box(kBoxAny, TAKE_TEXT, _vm->_arrayNouns[_vm->_object->_objects[action->a42.objIndex].nounIndex][TAKE_NAME]);
break;
case YESNO: // act43: Prompt user for Yes or No
- if (Utils::Box(BOX_YESNO, "%s", _vm->_file->fetchString(action->a43.promptIndex)) != 0)
+ if (Utils::Box(kBoxYesNo, "%s", _vm->_file->fetchString(action->a43.promptIndex)) != 0)
insertActionList(action->a43.actYesIndex);
else
insertActionList(action->a43.actNoIndex);
@@ -1305,7 +1305,7 @@ void Scheduler_v1d::delEventType(action_t actTypeDel) {
}
void Scheduler_v1d::promptAction(act *action) {
- Utils::Box(BOX_PROMPT, "%s", _vm->_file->fetchString(action->a3.promptIndex));
+ Utils::Box(kBoxPrompt, "%s", _vm->_file->fetchString(action->a3.promptIndex));
warning("STUB: doAction(act3)");
// TODO: The answer of the player is not handled currently! Once it'll be read in the messageBox, uncomment this block
@@ -1401,7 +1401,7 @@ void Scheduler_v2d::delEventType(action_t actTypeDel) {
}
void Scheduler_v2d::promptAction(act *action) {
- Utils::Box(BOX_PROMPT, "%s", _vm->_file->fetchString(action->a3.promptIndex));
+ Utils::Box(kBoxPrompt, "%s", _vm->_file->fetchString(action->a3.promptIndex));
warning("STUB: doAction(act3), expecting answer %s", _vm->_file->fetchString(action->a3.responsePtr[0]));
// TODO: The answer of the player is not handled currently! Once it'll be read in the messageBox, uncomment this block
diff --git a/engines/hugo/schedule.h b/engines/hugo/schedule.h
index cea825490e..b0a1dac921 100644
--- a/engines/hugo/schedule.h
+++ b/engines/hugo/schedule.h
@@ -38,7 +38,411 @@
namespace Hugo {
#define SIGN(X) ((X < 0) ? -1 : 1)
-#define kMaxEvents 50 // Max events in event queue
+
+struct act0 { // Type 0 - Schedule
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ uint16 actIndex; // Ptr to an action list
+};
+
+struct act1 { // Type 1 - Start an object
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int cycleNumb; // Number of times to cycle
+ cycle_t cycle; // Direction to start cycling
+};
+
+struct act2 { // Type 2 - Initialise an object coords
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int x, y; // Coordinates
+};
+
+struct act3 { // Type 3 - Prompt user for text
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ uint16 promptIndex; // Index of prompt string
+ int *responsePtr; // Array of indexes to valid response string(s) (terminate list with -1)
+ uint16 actPassIndex; // Ptr to action list if success
+ uint16 actFailIndex; // Ptr to action list if failure
+ bool encodedFl; // (HUGO 1 DOS ONLY) Whether response is encoded or not
+};
+
+struct act4 { // Type 4 - Set new background color
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ long newBackgroundColor; // New color
+};
+
+struct act5 { // Type 5 - Initialise an object velocity
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int vx, vy; // velocity
+};
+
+struct act6 { // Type 6 - Initialise an object carrying
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ bool carriedFl; // carrying
+};
+
+struct act7 { // Type 7 - Initialise an object to hero's coords
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+};
+
+struct act8 { // Type 8 - switch to new screen
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int screenIndex; // The new screen number
+};
+
+struct act9 { // Type 9 - Initialise an object state
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ byte newState; // New state
+};
+
+struct act10 { // Type 10 - Initialise an object path type
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int newPathType; // New path type
+ int8 vxPath, vyPath; // Max delta velocities e.g. for CHASE
+};
+
+struct act11 { // Type 11 - Conditional on object's state
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ byte stateReq; // Required state
+ uint16 actPassIndex; // Ptr to action list if success
+ uint16 actFailIndex; // Ptr to action list if failure
+};
+
+struct act12 { // Type 12 - Simple text box
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int stringIndex; // Index (enum) of string in strings.dat
+};
+
+struct act13 { // Type 13 - Swap first object image with second
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex1; // Index of first object
+ int objIndex2; // 2nd
+};
+
+struct act14 { // Type 14 - Conditional on current screen
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The required object
+ int screenReq; // The required screen number
+ uint16 actPassIndex; // Ptr to action list if success
+ uint16 actFailIndex; // Ptr to action list if failure
+};
+
+struct act15 { // Type 15 - Home in on an object
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex1; // The object number homing in
+ int objIndex2; // The object number to home in on
+ int8 dx, dy; // Max delta velocities
+};
+// Note: Don't set a sequence at time 0 of a new screen, it causes
+// problems clearing the boundary bits of the object! timer > 0 is safe
+struct act16 { // Type 16 - Set curr_seq_p to seq
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int seqIndex; // The index of seq array to set to
+};
+
+struct act17 { // Type 17 - SET obj individual state bits
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int stateMask; // The mask to OR with current obj state
+};
+
+struct act18 { // Type 18 - CLEAR obj individual state bits
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int stateMask; // The mask to ~AND with current obj state
+};
+
+struct act19 { // Type 19 - TEST obj individual state bits
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int stateMask; // The mask to AND with current obj state
+ uint16 actPassIndex; // Ptr to action list (all bits set)
+ uint16 actFailIndex; // Ptr to action list (not all set)
+};
+
+struct act20 { // Type 20 - Remove all events with this type of action
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ action_t actTypeDel; // The action type to remove
+};
+
+struct act21 { // Type 21 - Gameover. Disable hero & commands
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+};
+
+struct act22 { // Type 22 - Initialise an object to hero's coords
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+};
+
+struct act23 { // Type 23 - Exit game back to DOS
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+};
+
+struct act24 { // Type 24 - Get bonus score
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int pointIndex; // Index into points array
+};
+
+struct act25 { // Type 25 - Conditional on bounding box
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The required object number
+ int x1, y1, x2, y2; // The bounding box
+ uint16 actPassIndex; // Ptr to action list if success
+ uint16 actFailIndex; // Ptr to action list if failure
+};
+
+struct act26 { // Type 26 - Play a sound
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int16 soundIndex; // Sound index in data file
+};
+
+struct act27 { // Type 27 - Add object's value to score
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // object number
+};
+
+struct act28 { // Type 28 - Subtract object's value from score
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // object number
+};
+
+struct act29 { // Type 29 - Conditional on object carried
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The required object number
+ uint16 actPassIndex; // Ptr to action list if success
+ uint16 actFailIndex; // Ptr to action list if failure
+};
+
+struct act30 { // Type 30 - Start special maze processing
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ byte mazeSize; // Size of (square) maze
+ int x1, y1, x2, y2; // Bounding box of maze
+ int x3, x4; // Extra x points for perspective correction
+ byte firstScreenIndex; // First (top left) screen of maze
+};
+
+struct act31 { // Type 31 - Exit special maze processing
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+};
+
+struct act32 { // Type 32 - Init fbg field of object
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ byte priority; // Value of foreground/background field
+};
+
+struct act33 { // Type 33 - Init screen field of object
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int screenIndex; // Screen number
+};
+
+struct act34 { // Type 34 - Global Schedule
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ uint16 actIndex; // Ptr to an action list
+};
+
+struct act35 { // Type 35 - Remappe palette
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int16 oldColorIndex; // Old color index, 0..15
+ int16 newColorIndex; // New color index, 0..15
+};
+
+struct act36 { // Type 36 - Conditional on noun mentioned
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ uint16 nounIndex; // The required noun (list)
+ uint16 actPassIndex; // Ptr to action list if success
+ uint16 actFailIndex; // Ptr to action list if failure
+};
+
+struct act37 { // Type 37 - Set new screen state
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int screenIndex; // The screen number
+ byte newState; // The new state
+};
+
+struct act38 { // Type 38 - Position lips
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int lipsObjIndex; // The LIPS object
+ int objIndex; // The object to speak
+ byte dxLips; // Relative offset of x
+ byte dyLips; // Relative offset of y
+};
+
+struct act39 { // Type 39 - Init story mode
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ bool storyModeFl; // New state of story_mode flag
+};
+
+struct act40 { // Type 40 - Unsolicited text box
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int stringIndex; // Index (enum) of string in strings.dat
+};
+
+struct act41 { // Type 41 - Conditional on bonus scored
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int BonusIndex; // Index into bonus list
+ uint16 actPassIndex; // Index of the action list if scored for the first time
+ uint16 actFailIndex; // Index of the action list if already scored
+};
+
+struct act42 { // Type 42 - Text box with "take" string
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object taken
+};
+
+struct act43 { // Type 43 - Prompt user for Yes or No
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int promptIndex; // index of prompt string
+ uint16 actYesIndex; // Ptr to action list if YES
+ uint16 actNoIndex; // Ptr to action list if NO
+};
+
+struct act44 { // Type 44 - Stop any route in progress
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+};
+
+struct act45 { // Type 45 - Conditional on route in progress
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int routeIndex; // Must be >= current status.rindex
+ uint16 actPassIndex; // Ptr to action list if en-route
+ uint16 actFailIndex; // Ptr to action list if not
+};
+
+struct act46 { // Type 46 - Init status.jumpexit
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ bool jumpExitFl; // New state of jumpexit flag
+};
+
+struct act47 { // Type 47 - Init viewx,viewy,dir
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object
+ int16 viewx; // object.viewx
+ int16 viewy; // object.viewy
+ int16 direction; // object.dir
+};
+
+struct act48 { // Type 48 - Set curr_seq_p to frame n
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ int objIndex; // The object number
+ int seqIndex; // The index of seq array to set to
+ int frameIndex; // The index of frame to set to
+};
+
+struct act49 { // Added by Strangerke - Type 79 - Play a song (DOS way)
+ action_t actType; // The type of action
+ int timer; // Time to set off the action
+ uint16 songIndex; // Song index in string array
+};
+
+union act {
+ act0 a0;
+ act1 a1;
+ act2 a2;
+ act3 a3;
+ act4 a4;
+ act5 a5;
+ act6 a6;
+ act7 a7;
+ act8 a8;
+ act9 a9;
+ act10 a10;
+ act11 a11;
+ act12 a12;
+ act13 a13;
+ act14 a14;
+ act15 a15;
+ act16 a16;
+ act17 a17;
+ act18 a18;
+ act19 a19;
+ act20 a20;
+ act21 a21;
+ act22 a22;
+ act23 a23;
+ act24 a24;
+ act25 a25;
+ act26 a26;
+ act27 a27;
+ act28 a28;
+ act29 a29;
+ act30 a30;
+ act31 a31;
+ act32 a32;
+ act33 a33;
+ act34 a34;
+ act35 a35;
+ act36 a36;
+ act37 a37;
+ act38 a38;
+ act39 a39;
+ act40 a40;
+ act41 a41;
+ act42 a42;
+ act43 a43;
+ act44 a44;
+ act45 a45;
+ act46 a46;
+ act47 a47;
+ act48 a48;
+ act49 a49;
+};
struct event_t {
act *action; // Ptr to action to perform
@@ -71,6 +475,9 @@ public:
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
uint16 _actListArrSize;
uint16 _alNewscrIndex;
diff --git a/engines/hugo/sound.cpp b/engines/hugo/sound.cpp
index f59a121e00..3099cd3866 100644
--- a/engines/hugo/sound.cpp
+++ b/engines/hugo/sound.cpp
@@ -49,7 +49,7 @@ MidiPlayer::MidiPlayer(MidiDriver *driver)
: _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _paused(false), _masterVolume(0) {
assert(_driver);
memset(_channelsTable, 0, sizeof(_channelsTable));
- for (int i = 0; i < NUM_CHANNELS; i++) {
+ for (int i = 0; i < kNumbChannels; i++) {
_channelsVolume[i] = 127;
}
}
@@ -94,7 +94,7 @@ void MidiPlayer::stop() {
void MidiPlayer::pause(bool p) {
_paused = p;
- for (int i = 0; i < NUM_CHANNELS; ++i) {
+ for (int i = 0; i < kNumbChannels; ++i) {
if (_channelsTable[i]) {
_channelsTable[i]->volume(_paused ? 0 : _channelsVolume[i] * _masterVolume / 255);
}
@@ -131,7 +131,7 @@ void MidiPlayer::setVolume(int volume) {
debugC(3, kDebugMusic, "MidiPlayer::setVolume");
_masterVolume = CLIP(volume, 0, 255);
_mutex.lock();
- for (int i = 0; i < NUM_CHANNELS; ++i) {
+ for (int i = 0; i < kNumbChannels; ++i) {
if (_channelsTable[i]) {
_channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255);
}
@@ -268,16 +268,16 @@ void SoundHandler::stopMusic() {
* Turn music on and off
*/
void SoundHandler::toggleMusic() {
- _config.musicFl = !_config.musicFl;
+ _vm->_config.musicFl = !_vm->_config.musicFl;
- _midiPlayer->pause(!_config.musicFl);
+ _midiPlayer->pause(!_vm->_config.musicFl);
}
/**
* Turn digitized sound on and off
*/
void SoundHandler::toggleSound() {
- _config.soundFl = !_config.soundFl;
+ _vm->_config.soundFl = !_vm->_config.soundFl;
}
void SoundHandler::playMIDI(sound_pt seq_p, uint16 size) {
@@ -291,7 +291,7 @@ void SoundHandler::playMusic(int16 tune) {
sound_pt seqPtr; // Sequence data from file
uint16 size; // Size of sequence data
- if (_config.musicFl) {
+ if (_vm->_config.musicFl) {
_vm->getGameStatus().song = tune;
seqPtr = _vm->_file->getSound(tune, &size);
playMIDI(seqPtr, size);
@@ -303,14 +303,14 @@ void SoundHandler::playMusic(int16 tune) {
* Produce various sound effects on supplied stereo channel(s)
* Override currently playing sound only if lower or same priority
*/
-void SoundHandler::playSound(int16 sound, stereo_t channel, byte priority) {
+void SoundHandler::playSound(int16 sound, byte priority) {
// 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 (!_config.soundFl || !_vm->_mixer->isReady())
+ if (!_vm->_config.soundFl || !_vm->_mixer->isReady())
return;
syncVolume();
@@ -386,7 +386,7 @@ void SoundHandler::pcspkr_player() {
uint16 count; // Value to set timer chip to for note
bool cmd_note;
- if (!_config.soundFl || !_vm->_mixer->isReady())
+ if (!_vm->_config.soundFl || !_vm->_mixer->isReady())
return; // Poo! User doesn't want sound!
if (!DOSSongPtr)
@@ -469,6 +469,8 @@ void SoundHandler::pcspkr_player() {
pcspkrTimer = pcspkrNoteDuration;
DOSSongPtr++;
break;
+ default:
+ warning("pcspkr_player() - Unhandled note");
}
}
diff --git a/engines/hugo/sound.h b/engines/hugo/sound.h
index 096c66be15..249ea2e6e9 100644
--- a/engines/hugo/sound.h
+++ b/engines/hugo/sound.h
@@ -40,43 +40,43 @@
namespace Hugo {
-#define kHugoCNT 1190000
-
class MidiPlayer : public MidiDriver {
public:
-
- enum {
- NUM_CHANNELS = 16
- };
-
MidiPlayer(MidiDriver *driver);
~MidiPlayer();
- void play(uint8 *stream, uint16 size);
- void stop();
- void pause(bool p);
- void updateTimer();
+ bool isPlaying() { return _isPlaying; }
+
+ int getVolume() const { return _masterVolume; }
+
void adjustVolume(int diff);
+ void pause(bool p);
+ void play(uint8 *stream, uint16 size);
void setChannelVolume(int channel);
+ void setLooping(bool loop) { _isLooping = loop; }
void setVolume(int volume);
+ void stop();
void syncVolume();
- int getVolume() const { return _masterVolume; }
- void setLooping(bool loop) { _isLooping = loop; }
- bool isPlaying() { return _isPlaying; }
+ void updateTimer();
// MidiDriver interface
int open();
+
+ MidiChannel *allocateChannel() { return 0; }
+ MidiChannel *getPercussionChannel() { return 0; }
+
void close();
- void send(uint32 b);
void metaEvent(byte type, byte *data, uint16 length);
+ void send(uint32 b);
void setTimerCallback(void *timerParam, void (*timerProc)(void *)) { }
+
uint32 getBaseTempo() { return _driver ? _driver->getBaseTempo() : 0; }
- MidiChannel *allocateChannel() { return 0; }
- MidiChannel *getPercussionChannel() { return 0; }
private:
static void timerCallback(void *p);
+ static const int kNumbChannels = 16;
+
MidiDriver *_driver;
MidiParser *_parser;
uint8 *_midiData;
@@ -84,8 +84,8 @@ private:
bool _isPlaying;
bool _paused;
int _masterVolume;
- MidiChannel *_channelsTable[NUM_CHANNELS];
- uint8 _channelsVolume[NUM_CHANNELS];
+ MidiChannel *_channelsTable[kNumbChannels];
+ uint8 _channelsVolume[kNumbChannels];
Common::Mutex _mutex;
};
@@ -94,6 +94,8 @@ public:
SoundHandler(HugoEngine *vm);
~SoundHandler();
+ static const int kHugoCNT = 1190000;
+
char *DOSSongPtr;
char *DOSIntroSong;
@@ -102,7 +104,7 @@ public:
void setMusicVolume();
void pcspkr_player();
void playMusic(int16 tune);
- void playSound(int16 sound, stereo_t channel, byte priority);
+ void playSound(int16 sound, byte priority);
void initSound();
void syncVolume();
void checkMusic();
diff --git a/engines/hugo/util.cpp b/engines/hugo/util.cpp
index ab9fcb0c2b..212f10b36d 100644
--- a/engines/hugo/util.cpp
+++ b/engines/hugo/util.cpp
@@ -89,7 +89,7 @@ void Utils::reverseByte(byte *data) {
}
char *Utils::Box(box_t dismiss, const char *s, ...) {
- static char buffer[MAX_STRLEN + 1]; // Format text into this
+ static char buffer[kMaxStrLength + 1]; // Format text into this
if (!s)
return 0; // NULL strings catered for
@@ -97,7 +97,7 @@ char *Utils::Box(box_t dismiss, const char *s, ...) {
if (s[0] == '\0')
return 0;
- if (strlen(s) > MAX_STRLEN - 100) { // Test length
+ if (strlen(s) > kMaxStrLength - 100) { // Test length
warning("String too long: '%s'", s);
return 0;
}
@@ -111,25 +111,29 @@ char *Utils::Box(box_t dismiss, const char *s, ...) {
return 0;
switch(dismiss) {
- case BOX_ANY:
- case BOX_OK: {
+ case kBoxAny:
+ case kBoxOk: {
GUI::MessageDialog dialog(buffer, "OK");
dialog.runModal();
break;
}
- case BOX_YESNO: {
+ case kBoxYesNo: {
GUI::MessageDialog dialog(buffer, "YES", "NO");
if (dialog.runModal() == GUI::kMessageOK)
return buffer;
return 0;
break;
}
- case BOX_PROMPT:
+ case kBoxPrompt: {
+ // TODO: Some boxes (i.e. the combination code for the shed), needs to return an input.
warning("Box: unhandled BOX_PROMPT");
int boxTime = strlen(buffer) * 30;
GUI::TimedMessageDialog dialog(buffer, MAX(1500, boxTime));
dialog.runModal();
- // TODO: Some boxes (i.e. the combination code for the shed), needs to return an input.
+ break;
+ }
+ default:
+ error("Unknown BOX Type %d", dismiss);
}
return buffer;
@@ -139,7 +143,7 @@ char *Utils::Box(box_t dismiss, const char *s, ...) {
* Print options for user when dead
*/
void Utils::gameOverMsg(void) {
- Utils::Box(BOX_OK, "%s", HugoEngine::get()._textUtil[kGameOver]);
+ Utils::Box(kBoxOk, "%s", HugoEngine::get()._textUtil[kGameOver]);
}
char *Utils::strlwr(char *buffer) {
diff --git a/engines/hugo/util.h b/engines/hugo/util.h
index 4cf30b1903..65164bbe3c 100644
--- a/engines/hugo/util.h
+++ b/engines/hugo/util.h
@@ -39,6 +39,8 @@ enum seqTextUtil {
kGameOver = 0
};
+static const int kMaxStrLength = 1024;
+
namespace Utils {
int firstBit(byte data);
int lastBit(byte data);