[Scummvm-cvs-logs] SF.net SVN: scummvm:[55451] scummvm/trunk/engines/hugo
strangerke at users.sourceforge.net
strangerke at users.sourceforge.net
Sun Jan 23 01:05:52 CET 2011
Revision: 55451
http://scummvm.svn.sourceforge.net/scummvm/?rev=55451&view=rev
Author: strangerke
Date: 2011-01-23 00:05:52 +0000 (Sun, 23 Jan 2011)
Log Message:
-----------
HUGO: Cleanup
Suppress almost all defines, rename constants
Modified Paths:
--------------
scummvm/trunk/engines/hugo/display.cpp
scummvm/trunk/engines/hugo/display.h
scummvm/trunk/engines/hugo/file.cpp
scummvm/trunk/engines/hugo/file.h
scummvm/trunk/engines/hugo/file_v1d.cpp
scummvm/trunk/engines/hugo/file_v1w.cpp
scummvm/trunk/engines/hugo/file_v2d.cpp
scummvm/trunk/engines/hugo/file_v2w.cpp
scummvm/trunk/engines/hugo/file_v3d.cpp
scummvm/trunk/engines/hugo/game.h
scummvm/trunk/engines/hugo/hugo.cpp
scummvm/trunk/engines/hugo/hugo.h
scummvm/trunk/engines/hugo/intro.cpp
scummvm/trunk/engines/hugo/inventory.cpp
scummvm/trunk/engines/hugo/inventory.h
scummvm/trunk/engines/hugo/menu.cpp
scummvm/trunk/engines/hugo/mouse.cpp
scummvm/trunk/engines/hugo/mouse.h
scummvm/trunk/engines/hugo/object.cpp
scummvm/trunk/engines/hugo/object.h
scummvm/trunk/engines/hugo/object_v1d.cpp
scummvm/trunk/engines/hugo/object_v1w.cpp
scummvm/trunk/engines/hugo/object_v2d.cpp
scummvm/trunk/engines/hugo/object_v3d.cpp
scummvm/trunk/engines/hugo/parser.cpp
scummvm/trunk/engines/hugo/parser.h
scummvm/trunk/engines/hugo/parser_v1d.cpp
scummvm/trunk/engines/hugo/parser_v1w.cpp
scummvm/trunk/engines/hugo/parser_v2d.cpp
scummvm/trunk/engines/hugo/parser_v3d.cpp
scummvm/trunk/engines/hugo/route.cpp
scummvm/trunk/engines/hugo/route.h
scummvm/trunk/engines/hugo/schedule.cpp
scummvm/trunk/engines/hugo/schedule.h
scummvm/trunk/engines/hugo/sound.cpp
scummvm/trunk/engines/hugo/sound.h
scummvm/trunk/engines/hugo/util.cpp
scummvm/trunk/engines/hugo/util.h
Removed Paths:
-------------
scummvm/trunk/engines/hugo/global.h
Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/display.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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 @@
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 @@
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 @@
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 @@
}
// 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 @@
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 @@
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 @@
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 @@
}
// 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 @@
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 @@
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::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 @@
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::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 @@
* 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 @@
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 @@
* Initialize screen components and display results
*/
void Screen::initNewScreenDisplay() {
- displayList(D_INIT);
+ displayList(kDisplayInit);
setBackgroundColor(_TBLACK);
displayBackground();
@@ -547,7 +544,7 @@
* 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 @@
}
// 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 @@
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 @@
* 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 @@
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 @@
* 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();
Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/display.h 2011-01-23 00:05:52 UTC (rev 55451)
@@ -34,9 +34,14 @@
#define HUGO_DISPLAY_H
namespace Hugo {
-#define shapeSize 24
+enum overlayState_t {UNDEF, FG, BG}; // Overlay state
-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 @@
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
Modified: scummvm/trunk/engines/hugo/file.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
*/
void FileManager::printBootText() {
debugC(1, kDebugFile, "printBootText");
+ static const char *cypher = getBootCypher();
Common::File ofp;
if (!ofp.open(BOOTFILE)) {
@@ -541,10 +541,10 @@
// 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::readBootFile() {
debugC(1, kDebugFile, "readBootFile");
+ static const char *cypher = getBootCypher();
Common::File ofp;
if (!ofp.open(BOOTFILE)) {
@@ -583,7 +584,7 @@
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 @@
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 @@
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 @@
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
Modified: scummvm/trunk/engines/hugo/file.h
===================================================================
--- scummvm/trunk/engines/hugo/file.h 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file.h 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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 @@
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);
+ const char *FileManager::getBootCypher();
+
private:
-
byte *convertPCC(byte *p, uint16 y, uint16 bpl, image_pt data_p);
uif_hdr_t *getUIFHeader(uif_t id);
Modified: scummvm/trunk/engines/hugo/file_v1d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1d.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file_v1d.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -64,7 +64,7 @@
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 @@
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 @@
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
}
Modified: scummvm/trunk/engines/hugo/file_v1w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v1w.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file_v1w.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -64,15 +64,15 @@
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 @@
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
Modified: scummvm/trunk/engines/hugo/file_v2d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v2d.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file_v2d.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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 @@
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 @@
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 @@
for (i = 0; i < (byte)(-data + 1); i++, k++)
*tmpImage++ = j;
}
- } while (k < OVL_SIZE);
+ } while (k < kOvlSize);
}
/**
@@ -163,6 +162,7 @@
*/
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 @@
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
Modified: scummvm/trunk/engines/hugo/file_v2w.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v2w.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file_v2w.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -48,7 +48,7 @@
* 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
Modified: scummvm/trunk/engines/hugo/file_v3d.cpp
===================================================================
--- scummvm/trunk/engines/hugo/file_v3d.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/file_v3d.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
for (i = 0; i < (byte)(-data + 1); i++, k++)
*tmpImage++ = j;
}
- } while (k < OVL_SIZE);
+ } while (k < kOvlSize);
}
}
} // End of namespace Hugo
Modified: scummvm/trunk/engines/hugo/game.h
===================================================================
--- scummvm/trunk/engines/hugo/game.h 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/game.h 2011-01-23 00:05:52 UTC (rev 55451)
@@ -46,65 +46,37 @@
// 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"
-#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
+// 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 CRYPT "Copyright 1992, David P Gray, Gray Design Associates"
+enum {LOOK_NAME = 1, TAKE_NAME}; // Index of name used in showing takeables and in confirming take
+// 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,
_TRED, _TMAGENTA, _TBROWN, _TWHITE,
@@ -113,94 +85,34 @@
};
enum uif_t {U_FONT5, U_FONT6, U_FONT8, UIF_IMAGES, NUM_UIF_ITEMS};
+static const int kFirstFont = U_FONT5;
/**
-* Enumerate overlay file types
-*/
-enum ovl_t {BOUNDARY, OVERLAY, OVLBASE};
-
-/**
* 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};
+enum font_t {LARGE_ROMAN, MED_ROMAN, NUM_GDI_FONTS, INIT_FONTS, DEL_FONTS};
/**
-* Priority for sound effect
-*/
-enum priority_t {LOW_PRI, MED_PRI, HIGH_PRI};
-
-/**
* 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 @@
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 @@
};
/**
-* 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 @@
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,26 +271,9 @@
};
// 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
uint16 size; // Size of sound data in bytes
@@ -890,6 +281,44 @@
} 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
Deleted: scummvm/trunk/engines/hugo/global.h
===================================================================
--- scummvm/trunk/engines/hugo/global.h 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/global.h 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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
Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/hugo.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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::_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 @@
_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 @@
}
}
_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 @@
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 @@
_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 @@
/**
* 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 @@
// 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 @@
/**
* 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);
+void HugoEngine::initConfig() {
+ debugC(1, kDebugEngine, "initConfig()");
- 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;
- }
+ _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 @@
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 @@
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 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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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::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() {
Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/hugo.h 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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,7 +59,55 @@
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,
kGameTypeHugo1,
@@ -92,6 +137,47 @@
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 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 @@
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 @@
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 @@
Common::Error run();
private:
+ static const int kTurboTps = 16; // This many in turbo mode
+
int _mouseX;
int _mouseY;
byte _introXSize;
@@ -320,15 +456,17 @@
char **loadTextsVariante(Common::File &in, uint16 *arraySize);
char ***loadTextsArray(Common::File &in);
+ char **loadTexts(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);
+ void initPlaylist(bool playlist[kMaxTunes]);
+ void initConfig();
void initialize();
+ void initMachine();
void calcMaxScore();
- void initMachine();
+ void resetConfig();
void runMachine();
};
Modified: scummvm/trunk/engines/hugo/intro.cpp
===================================================================
--- scummvm/trunk/engines/hugo/intro.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/intro.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -108,7 +108,7 @@
} 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 @@
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 @@
}
void intro_v1w::preNewGame() {
- _vm->getGameStatus().viewState = V_INTROINIT;
+ _vm->getGameStatus().viewState = kViewIntroInit;
}
void intro_v1w::introInit() {
@@ -386,19 +386,19 @@
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;
}
}
Modified: scummvm/trunk/engines/hugo/inventory.cpp
===================================================================
--- scummvm/trunk/engines/hugo/inventory.cpp 2011-01-22 23:31:21 UTC (rev 55450)
+++ scummvm/trunk/engines/hugo/inventory.cpp 2011-01-23 00:05:52 UTC (rev 55451)
@@ -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 @@
// 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 @@
// 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 @@
}
// 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
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list