diff options
Diffstat (limited to 'engines/saga')
| -rw-r--r-- | engines/saga/actor.cpp | 208 | ||||
| -rw-r--r-- | engines/saga/actor.h | 13 | ||||
| -rw-r--r-- | engines/saga/detection.cpp (renamed from engines/saga/game.cpp) | 30 | ||||
| -rw-r--r-- | engines/saga/detection_tables.h (renamed from engines/saga/sagagame.cpp) | 323 | ||||
| -rw-r--r-- | engines/saga/displayinfo.h | 422 | ||||
| -rw-r--r-- | engines/saga/events.cpp | 9 | ||||
| -rw-r--r-- | engines/saga/events.h | 2 | ||||
| -rw-r--r-- | engines/saga/gfx.h | 2 | ||||
| -rw-r--r-- | engines/saga/interface.cpp | 78 | ||||
| -rw-r--r-- | engines/saga/interface.h | 1 | ||||
| -rw-r--r-- | engines/saga/module.mk | 2 | ||||
| -rw-r--r-- | engines/saga/music.cpp | 40 | ||||
| -rw-r--r-- | engines/saga/music.h | 2 | ||||
| -rw-r--r-- | engines/saga/saga.cpp | 2 | ||||
| -rw-r--r-- | engines/saga/saga.h | 244 | ||||
| -rw-r--r-- | engines/saga/sagagame.h | 332 | ||||
| -rw-r--r-- | engines/saga/scene.cpp | 64 | ||||
| -rw-r--r-- | engines/saga/scene.h | 58 | ||||
| -rw-r--r-- | engines/saga/script.cpp | 27 |
19 files changed, 1007 insertions, 852 deletions
diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index 9f8b767c75..c26f06b33a 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -88,6 +88,45 @@ static int tileCommonObjectCompare(const CommonObjectDataPointer& obj1, const Co return 1; } +inline int16 int16Compare(int16 i1, int16 i2) { + return ((i1) > (i2) ? 1 : ((i1) < (i2) ? -1 : 0)); +} + +inline int16 quickDistance(const Point &point1, const Point &point2) { + Point delta; + delta.x = ABS(point1.x - point2.x) / 2; + delta.y = ABS(point1.y - point2.y); + return ((delta.x < delta.y) ? (delta.y + delta.x / 2) : (delta.x + delta.y / 2)); +} + +inline void calcDeltaS(const Point &point1, const Point &point2, Point &delta, Point &s) { + + delta.x = point2.x - point1.x; + if (delta.x == 0) { + s.x = 0; + } else { + if (delta.x > 0) { + s.x = 1; + } else { + s.x = -1; + delta.x = -delta.x; + } + } + + + delta.y = point2.y - point1.y; + if (delta.y == 0) { + s.y = 0; + } else { + if (delta.y > 0) { + s.y = 1; + } else { + s.y = -1; + delta.y = -delta.y; + } + } +} + // Lookup table to convert 8 cardinal directions to 4 static const int actorDirectectionsLUT[8] = { ACTOR_DIRECTION_BACK, // kDirUp @@ -101,14 +140,14 @@ static const int actorDirectectionsLUT[8] = { }; static const PathDirectionData pathDirectionLUT[8][3] = { - { { 0, 0, -1 }, { 7, -1, -1 }, { 4, 1, -1 } }, - { { 1, 1, 0 }, { 4, 1, -1 }, { 5, 1, 1 } }, - { { 2, 0, 1 }, { 5, 1, 1 }, { 6, -1, 1 } }, - { { 3, -1, 0 }, { 6, -1, 1 }, { 7, -1, -1 } }, - { { 0, 0, -1 }, { 1, 1, 0 }, { 4, 1, -1 } }, - { { 1, 1, 0 }, { 2, 0, 1 }, { 5, 1, 1 } }, - { { 2, 0, 1 }, { 3, -1, 0 }, { 6, -1, 1 } }, - { { 3, -1, 0 }, { 0, 0, -1 }, { 7, -1, -1 } } + { { 0, Point( 0, -1) }, { 7, Point(-1, -1) }, { 4, Point( 1, -1) } }, + { { 1, Point( 1, 0) }, { 4, Point( 1, -1) }, { 5, Point( 1, 1) } }, + { { 2, Point( 0, 1) }, { 5, Point( 1, 1) }, { 6, Point(-1, 1) } }, + { { 3, Point(-1, 0) }, { 6, Point(-1, 1) }, { 7, Point(-1, -1) } }, + { { 0, Point( 0, -1) }, { 1, Point( 1, 0) }, { 4, Point( 1, -1) } }, + { { 1, Point( 1, 0) }, { 2, Point( 0, 1) }, { 5, Point( 1, 1) } }, + { { 2, Point( 0, 1) }, { 3, Point(-1, 0) }, { 6, Point(-1, 1) } }, + { { 3, Point(-1, 0) }, { 0, Point( 0, -1) }, { 7, Point(-1, -1) } } }; static const int pathDirectionLUT2[8][2] = { @@ -2605,51 +2644,57 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point bool Actor::scanPathLine(const Point &point1, const Point &point2) { Point point; Point delta; - bool interchange = false; + Point s; Point fDelta; - int errterm; - int s1; - int s2; - int i; + int16 errterm; + calcDeltaS(point1, point2, delta, s); point = point1; - delta.x = ABS(point1.x - point2.x); - delta.y = ABS(point1.y - point2.y); - s1 = integerCompare(point2.x, point1.x); - s2 = integerCompare(point2.y, point1.y); - - if (delta.y > delta.x) { - SWAP(delta.y, delta.x); - interchange = true; - } fDelta.x = delta.x * 2; fDelta.y = delta.y * 2; - errterm = fDelta.y - delta.x; + if (delta.y > delta.x) { - for (i = 0; i < delta.x; i++) { - while (errterm >= 0) { - if (interchange) { - point.x += s1; - } else { - point.y += s2; + errterm = fDelta.x - delta.y; + + while (delta.y > 0) { + while (errterm >= 0) { + point.x += s.x; + errterm -= fDelta.y; } - errterm -= fDelta.x; + + point.y += s.y; + errterm += fDelta.x; + + if (!validPathCellPoint(point)) { + return false; + } + if (getPathCell(point) == kPathCellBarrier) { + return false; + } + delta.y--; } + } else { - if (interchange) - point.y += s2; - else - point.x += s1; + errterm = fDelta.y - delta.x; - errterm += fDelta.y; + while (delta.x > 0) { + while (errterm >= 0) { + point.y += s.y; + errterm -= fDelta.x; + } + + point.x += s.x; + errterm += fDelta.y; - if (!validPathCellPoint(point)) { - return false; - } - if (getPathCell(point) == kPathCellBarrier) { - return false; + if (!validPathCellPoint(point)) { + return false; + } + if (getPathCell(point) == kPathCellBarrier) { + return false; + } + delta.x--; } } return true; @@ -2675,8 +2720,7 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be for (startDirection = 0; startDirection < 4; startDirection++) { newPathDirection = addPathDirectionListData(); - newPathDirection->x = fromPoint.x; - newPathDirection->y = fromPoint.y; + newPathDirection->coord = fromPoint; newPathDirection->direction = startDirection; } @@ -2694,8 +2738,9 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be pathDirection = &_pathDirectionList[i]; for (directionCount = 0; directionCount < 3; directionCount++) { samplePathDirection = &pathDirectionLUT[pathDirection->direction][directionCount]; - nextPoint.x = samplePathDirection->x + pathDirection->x; - nextPoint.y = samplePathDirection->y + pathDirection->y; + nextPoint = pathDirection->coord; + nextPoint.x += samplePathDirection->coord.x; + nextPoint.y += samplePathDirection->coord.y; if (!validPathCellPoint(nextPoint)) { continue; @@ -2711,8 +2756,7 @@ int Actor::fillPathArray(const Point &fromPoint, const Point &toPoint, Point &be addDebugPoint(nextPoint, samplePathDirection->direction + 96); #endif newPathDirection = addPathDirectionListData(); - newPathDirection->x = nextPoint.x; - newPathDirection->y = nextPoint.y; + newPathDirection->coord = nextPoint; newPathDirection->direction = samplePathDirection->direction; ++pointCounter; if (nextPoint == toPoint) { @@ -2783,8 +2827,8 @@ void Actor::pathToNode() { --point; point2 = *point; if (direction == 0) { - delta.x = integerCompare(point2.x, point1.x); - delta.y = integerCompare(point2.y, point1.y); + delta.x = int16Compare(point2.x, point1.x); + delta.y = int16Compare(point2.y, point1.y); direction++; } if ((point1.x + delta.x != point2.x) || (point1.y + delta.y != point2.y)) { @@ -2801,47 +2845,55 @@ int pathLine(Point *pointList, const Point &point1, const Point &point2) { Point point; Point delta; Point tempPoint; - int s1; - int s2; - bool interchange = false; - int errterm; - int i; + Point s; + int16 errterm; + int16 res; - delta.x = ABS(point2.x - point1.x); - delta.y = ABS(point2.y - point1.y); - point = point1; - s1 = integerCompare(point2.x, point1.x); - s2 = integerCompare(point2.y, point1.y); + calcDeltaS(point1, point2, delta, s); - if (delta.y > delta.x) { - SWAP(delta.y, delta.x); - interchange = true; - } + point = point1; tempPoint.x = delta.x * 2; tempPoint.y = delta.y * 2; - errterm = tempPoint.y - delta.x; + if (delta.y > delta.x) { + + errterm = tempPoint.x - delta.y; + res = delta.y; - for (i = 0; i < delta.x; i++) { - while (errterm >= 0) { - if (interchange) { - point.x += s1; - } else { - point.y += s2; + while (delta.y > 0) { + while (errterm >= 0) { + point.x += s.x; + errterm -= tempPoint.y; } - errterm -= tempPoint.x; - } - if (interchange) { - point.y += s2; - } else { - point.x += s1; + + point.y += s.y; + errterm += tempPoint.x; + + *pointList = point; + pointList++; + delta.y--; } - errterm += tempPoint.y; + } else { + + errterm = tempPoint.y - delta.x; + res = delta.x; + + while (delta.x > 0) { + while (errterm >= 0) { + point.y += s.y; + errterm -= tempPoint.x; + } + + point.x += s.x; + errterm += tempPoint.y; - pointList[i] = point; + *pointList = point; + pointList++; + delta.x--; + } } - return delta.x; + return res; } void Actor::nodeToPath() { diff --git a/engines/saga/actor.h b/engines/saga/actor.h index 2c247d7bba..d6ca4c4f41 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -147,8 +147,7 @@ enum DragonMoveTypes { struct PathDirectionData { int8 direction; - int16 x; - int16 y; + Point coord; }; struct ActorFrameRange { @@ -622,15 +621,19 @@ private: (testPoint.y < 0) || (testPoint.y >= _yCellCount)); } void setPathCell(const Point &testPoint, int8 value) { +#ifdef ACTOR_DEBUG if (!validPathCellPoint(testPoint)) { error("Actor::setPathCell wrong point"); } +#endif _pathCell[testPoint.x + testPoint.y * _xCellCount] = value; } int8 getPathCell(const Point &testPoint) { +#ifdef ACTOR_DEBUG if (!validPathCellPoint(testPoint)) { error("Actor::getPathCell wrong point"); } +#endif return _pathCell[testPoint.x + testPoint.y * _xCellCount]; } bool scanPathLine(const Point &point1, const Point &point2); @@ -767,12 +770,6 @@ public: #endif }; -inline int16 quickDistance(const Point &point1, const Point &point2) { - Point delta; - delta.x = ABS(point1.x - point2.x) / 2; - delta.y = ABS(point1.y - point2.y); - return ((delta.x < delta.y) ? (delta.y + delta.x / 2) : (delta.x + delta.y / 2)); -} } // End of namespace Saga #endif diff --git a/engines/saga/game.cpp b/engines/saga/detection.cpp index 820331b9c7..15c6a47682 100644 --- a/engines/saga/game.cpp +++ b/engines/saga/detection.cpp @@ -1,5 +1,5 @@ /* ScummVM - Scumm Interpreter - * Copyright (C) 2004-2006 The ScummVM project + * Copyright (C) 2004-2007 The ScummVM project * * The ReInherit Engine is (C)2000-2003 by Daniel Balsom. * @@ -29,12 +29,12 @@ #include "common/config-manager.h" #include "common/advancedDetector.h" +#include "saga/displayinfo.h" #include "saga/rscfile.h" #include "saga/interface.h" #include "saga/scene.h" #include "saga/sagaresnames.h" - namespace Saga { struct SAGAGameDescription { Common::ADGameDescription desc; @@ -42,7 +42,6 @@ struct SAGAGameDescription { int gameType; int gameId; uint32 features; - const GameDisplayInfo *gameDisplayInfo; int startSceneNumber; const GameResourceDescription *resourceDescription; int fontsCount; @@ -94,11 +93,7 @@ static const Common::ADObsoleteGameID obsoleteGameIDsTable[] = { {0, 0, Common::kPlatformUnknown} }; -namespace Saga { - -#include "sagagame.cpp" - -} +#include "saga/detection_tables.h" static const Common::ADParams detectionParams = { // Pointer to ADGameDescription or its superset structure @@ -132,11 +127,24 @@ bool SagaEngine::initGame() { if (_gameDescription == 0) return false; - _gameDisplayInfo = *_gameDescription->gameDisplayInfo; - _displayClip.right = _gameDisplayInfo.logicalWidth; - _displayClip.bottom = _gameDisplayInfo.logicalHeight; + _displayClip.right = getDisplayInfo().logicalWidth; + _displayClip.bottom = getDisplayInfo().logicalHeight; return _resource->createContexts(); } +const GameDisplayInfo &SagaEngine::getDisplayInfo() { + return _gameDescription->gameType == GType_ITE ? ITE_DisplayInfo : IHNM_DisplayInfo; +} + +int SagaEngine::getDisplayWidth() const { + const GameDisplayInfo &di = _gameDescription->gameType == GType_ITE ? ITE_DisplayInfo : IHNM_DisplayInfo; + return di.logicalWidth; +} + +int SagaEngine::getDisplayHeight() const { + const GameDisplayInfo &di = _gameDescription->gameType == GType_ITE ? ITE_DisplayInfo : IHNM_DisplayInfo; + return di.logicalHeight; +} + } // End of namespace Saga diff --git a/engines/saga/sagagame.cpp b/engines/saga/detection_tables.h index db13831669..404ef783c1 100644 --- a/engines/saga/sagagame.cpp +++ b/engines/saga/detection_tables.h @@ -1,154 +1,28 @@ -#define ITE_CONVERSE_MAX_TEXT_WIDTH (256 - 60) -#define ITE_CONVERSE_TEXT_HEIGHT 10 -#define ITE_CONVERSE_TEXT_LINES 4 - -//TODO: ihnm -#define IHNM_CONVERSE_MAX_TEXT_WIDTH (256 - 60) -#define IHNM_CONVERSE_TEXT_HEIGHT 10 -#define IHNM_CONVERSE_TEXT_LINES 10 - -// ITE section -static PanelButton ITE_MainPanelButtons[] = { - {kPanelButtonVerb, 52,4, 57,10, kVerbITEWalkTo,'w',0, 0,1,0}, - {kPanelButtonVerb, 52,15, 57,10, kVerbITELookAt,'l',0, 2,3,0}, - {kPanelButtonVerb, 52,26, 57,10, kVerbITEPickUp,'p',0, 4,5,0}, - {kPanelButtonVerb, 52,37, 57,10, kVerbITETalkTo,'t',0, 0,1,0}, - {kPanelButtonVerb, 110,4, 56,10, kVerbITEOpen,'o',0, 6,7,0}, - {kPanelButtonVerb, 110,15, 56,10, kVerbITEClose,'c',0, 8,9,0}, - {kPanelButtonVerb, 110,26, 56,10, kVerbITEUse,'u',0, 10,11,0}, - {kPanelButtonVerb, 110,37, 56,10, kVerbITEGive,'g',0, 12,13,0}, - {kPanelButtonArrow, 306,6, 8,5, -1,'U',0, 0,4,2}, - {kPanelButtonArrow, 306,41, 8,5, 1,'D',0, 1,5,3}, - - {kPanelButtonInventory, 181 + 32*0,6, 27,18, 0,'-',0, 0,0,0}, - {kPanelButtonInventory, 181 + 32*1,6, 27,18, 1,'-',0, 0,0,0}, - {kPanelButtonInventory, 181 + 32*2,6, 27,18, 2,'-',0, 0,0,0}, - {kPanelButtonInventory, 181 + 32*3,6, 27,18, 3,'-',0, 0,0,0}, - - {kPanelButtonInventory, 181 + 32*0,27, 27,18, 4,'-',0, 0,0,0}, - {kPanelButtonInventory, 181 + 32*1,27, 27,18, 5,'-',0, 0,0,0}, - {kPanelButtonInventory, 181 + 32*2,27, 27,18, 6,'-',0, 0,0,0}, - {kPanelButtonInventory, 181 + 32*3,27, 27,18, 7,'-',0, 0,0,0} -}; - -static PanelButton ITE_ConversePanelButtons[] = { - {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 0, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 0,'1',0, 0,0,0}, - {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 1, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 1,'2',0, 0,0,0}, - {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 2, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 2,'3',0, 0,0,0}, - {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 3, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 3,'4',0, 0,0,0}, - {kPanelButtonArrow, 257,6, 9,6, -1,'u',0, 0,4,2}, - {kPanelButtonArrow, 257,41, 9,6, 1,'d',0, 1,5,3}, -}; - -static PanelButton ITE_OptionPanelButtons[] = { - {kPanelButtonOptionSlider, 284,19, 13,75, 0,'-',0, 0,0,0}, //slider-scroller - {kPanelButtonOption, 113,18, 45,17, kTextReadingSpeed,'r',0, 0,0,0}, //read speed - {kPanelButtonOption, 113,37, 45,17, kTextMusic,'m',0, 0,0,0}, //music - {kPanelButtonOption, 113,56, 45,17, kTextSound,'n',0, 0,0,0}, //sound-noise - {kPanelButtonOption, 13,79, 135,17, kTextQuitGame,'q',0, 0,0,0}, //quit - {kPanelButtonOption, 13,98, 135,17, kTextContinuePlaying,'c',0, 0,0,0}, //continue - {kPanelButtonOption, 164,98, 57,17, kTextLoad,'l',0, 0,0,0}, //load - {kPanelButtonOption, 241,98, 57,17, kTextSave,'s',0, 0,0,0}, //save - {kPanelButtonOptionSaveFiles, 166,20, 112,74, 0,'-',0, 0,0,0}, //savefiles - - {kPanelButtonOptionText,106,4, 0,0, kTextGameOptions,'-',0, 0,0,0}, // text: game options - {kPanelButtonOptionText,11,22, 0,0, kTextReadingSpeed,'-',0, 0,0,0}, // text: read speed - {kPanelButtonOptionText,28,22, 0,0, kTextShowDialog,'-',0, 0,0,0}, // text: read speed - {kPanelButtonOptionText,73,41, 0,0, kTextMusic,'-',0, 0,0,0}, // text: music - {kPanelButtonOptionText,69,60, 0,0, kTextSound,'-',0, 0,0,0}, // text: noise -}; - -static PanelButton ITE_QuitPanelButtons[] = { - {kPanelButtonQuit, 11,17, 60,16, kTextQuit,'q',0, 0,0,0}, - {kPanelButtonQuit, 121,17, 60,16, kTextCancel,'c',0, 0,0,0}, - {kPanelButtonQuitText, -1,5, 0,0, kTextQuitTheGameQuestion,'-',0, 0,0,0}, -}; - -static PanelButton ITE_LoadPanelButtons[] = { - {kPanelButtonLoad, 101,19, 60,16, kTextOK,'o',0, 0,0,0}, - {kPanelButtonLoadText, -1,5, 0,0, kTextLoadSuccessful,'-',0, 0,0,0}, -}; - -static PanelButton ITE_SavePanelButtons[] = { - {kPanelButtonSave, 11,37, 60,16, kTextSave,'s',0, 0,0,0}, - {kPanelButtonSave, 101,37, 60,16, kTextCancel,'c',0, 0,0,0}, - {kPanelButtonSaveEdit, 26,17, 119,17, 0,'-',0, 0,0,0}, - {kPanelButtonSaveText, -1,5, 0,0, kTextEnterSaveGameName,'-',0, 0,0,0}, -}; - -static PanelButton ITE_ProtectPanelButtons[] = { - {kPanelButtonProtectEdit, 26,17, 119,17, 0,'-',0, 0,0,0}, - {kPanelButtonProtectText, -1,5, 0,0, kTextEnterProtectAnswer,'-',0, 0,0,0}, -}; - -/* -static PanelButton ITE_ProtectionPanelButtons[] = { - {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO -};*/ - -static const GameDisplayInfo ITE_DisplayInfo = { - 320, 200, // logical width&height - - 35, // scene path y offset - 137, // scene height - - 0, // status x offset - 137, // status y offset - 320, // status width - 11, // status height - 2, // status text y offset - 186, // status text color - 15, // status BG color - 308,137, // save reminder pos - 12,12, // save reminder w & h - 6,7, // save reminder sprite numbers - - 5, 4, // left portrait x, y offset - 274, 4, // right portrait x, y offset - - 8, 9, // inventory Up & Down button indexies - 2, 4, // inventory rows, columns - - 0, 148, // main panel offsets - ARRAYSIZE(ITE_MainPanelButtons), - ITE_MainPanelButtons, - - ITE_CONVERSE_MAX_TEXT_WIDTH, - ITE_CONVERSE_TEXT_HEIGHT, - ITE_CONVERSE_TEXT_LINES, - 4, 5, // converse Up & Down button indexies - 0, 148, // converse panel offsets - ARRAYSIZE(ITE_ConversePanelButtons), - ITE_ConversePanelButtons, - - 8, 0, // save file index - 8, // optionSaveFileVisible - 8, 8, // option panel offsets - ARRAYSIZE(ITE_OptionPanelButtons), - ITE_OptionPanelButtons, - - 64,54, // quit panel offsets - 192,38, // quit panel width & height - ARRAYSIZE(ITE_QuitPanelButtons), - ITE_QuitPanelButtons, - - 74, 53, // load panel offsets - 172, 40, // load panel width & height - ARRAYSIZE(ITE_LoadPanelButtons), - ITE_LoadPanelButtons, - - 2, // save edit index - 74, 44, // save panel offsets - 172, 58, // save panel width & height - ARRAYSIZE(ITE_SavePanelButtons), - ITE_SavePanelButtons, - - 0, // protect edit index - 74, 44, // protect panel offsets - 172, 58, // protect panel width & height - ARRAYSIZE(ITE_ProtectPanelButtons), - ITE_ProtectPanelButtons -}; +/* ScummVM - Scumm Interpreter + * Copyright (C) 2004-2007 The ScummVM project + * + * The ReInherit Engine is (C)2000-2003 by Daniel Balsom. + * + * 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$ + * + */ + +namespace Saga { static const GameResourceDescription ITE_Resources = { RID_ITE_SCENE_LUT, // Scene lookup table RN @@ -406,122 +280,6 @@ static const GamePatchDescription ITELinPatch_Files[] = { // IHNM section -static PanelButton IHNM_MainPanelButtons[] = { - {kPanelButtonVerb, 106,12, 114,30, kVerbIHNMWalk,'w',0, 0,1,0}, - {kPanelButtonVerb, 106,44, 114,30, kVerbIHNMLookAt,'l',0, 2,3,0}, - {kPanelButtonVerb, 106,76, 114,30, kVerbIHNMTake,'k',0, 4,5,0}, - {kPanelButtonVerb, 106,108, 114,30, kVerbIHNMUse,'u',0, 6,7,0}, - {kPanelButtonVerb, 223,12, 114,30, kVerbIHNMTalkTo,'t',0, 8,9,0}, - {kPanelButtonVerb, 223,44, 114,30, kVerbIHNMSwallow,'s',0, 10,11,0}, - {kPanelButtonVerb, 223,76, 114,30, kVerbIHNMGive,'g',0, 12,13,0}, - {kPanelButtonVerb, 223,108, 114,30, kVerbIHNMPush,'p',0, 14,15,0}, - {kPanelButtonArrow, 606,22, 20,25, -1,'[',0, 0,0,0}, //TODO: arrow Sprite Numbers - {kPanelButtonArrow, 606,108, 20,25, 1,']',0, 0,0,0}, - - {kPanelButtonInventory, 357 + 64*0,18, 54,54, 0,'-',0, 0,0,0}, - {kPanelButtonInventory, 357 + 64*1,18, 54,54, 1,'-',0, 0,0,0}, - {kPanelButtonInventory, 357 + 64*2,18, 54,54, 2,'-',0, 0,0,0}, - {kPanelButtonInventory, 357 + 64*3,18, 54,54, 3,'-',0, 0,0,0}, - - {kPanelButtonInventory, 357 + 64*0,80, 54,54, 4,'-',0, 0,0,0}, - {kPanelButtonInventory, 357 + 64*1,80, 54,54, 5,'-',0, 0,0,0}, - {kPanelButtonInventory, 357 + 64*2,80, 54,54, 6,'-',0, 0,0,0}, - {kPanelButtonInventory, 357 + 64*3,80, 54,54, 7,'-',0, 0,0,0} -}; - -static PanelButton IHNM_ConversePanelButtons[] = { - {kPanelButtonConverseText, 117,18 + IHNM_CONVERSE_TEXT_HEIGHT * 0, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 0,'1',0, 0,0,0}, - {kPanelButtonConverseText, 52,18 + IHNM_CONVERSE_TEXT_HEIGHT * 1, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 1,'2',0, 0,0,0}, - {kPanelButtonConverseText, 52,18 + IHNM_CONVERSE_TEXT_HEIGHT * 2, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 2,'3',0, 0,0,0}, - {kPanelButtonConverseText, 52,18 + IHNM_CONVERSE_TEXT_HEIGHT * 3, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 3,'4',0, 0,0,0}, - //..... - {kPanelButtonArrow, 606,22, 20,25, -1,'[',0, 0,0,0}, //TODO: arrow Sprite Numbers - {kPanelButtonArrow, 606,108, 20,25, 1,']',0, 0,0,0} -}; - -static PanelButton IHNM_OptionPanelButtons[] = { - {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO -}; - -static PanelButton IHNM_QuitPanelButtons[] = { - {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO -}; - -static PanelButton IHNM_LoadPanelButtons[] = { - {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO -}; - -static PanelButton IHNM_SavePanelButtons[] = { - {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO -}; - - -static const GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all - 640, 480, // logical width&height - - 0, // scene path y offset - 304, // scene height - - 0, // status x offset - 304, // status y offset - 616, // status width - 24, // status height - 8, // status text y offset - 253, // status text color - 250, // status BG color - 616, 303, // save reminder pos - 24, 24, // save reminder w&h - 0,1, // save reminder sprite numbers - - 11, 12, // left portrait x, y offset - -1, -1, // right portrait x, y offset - - -1, -1, // inventory Up & Down button indexies - 2, 4, // inventory rows, columns - - 0, 328, // main panel offsets - ARRAYSIZE(IHNM_MainPanelButtons), - IHNM_MainPanelButtons, - - -1, -1, // converse Up & Down button indexies - - IHNM_CONVERSE_MAX_TEXT_WIDTH, - IHNM_CONVERSE_TEXT_HEIGHT, - IHNM_CONVERSE_TEXT_LINES, - 0, 328, // converse panel offsets - ARRAYSIZE(IHNM_ConversePanelButtons), - IHNM_ConversePanelButtons, - - -1, -1, // save file index - 0, // optionSaveFileVisible - 0, 0, // option panel offsets - ARRAYSIZE(IHNM_OptionPanelButtons), - IHNM_OptionPanelButtons, - - 0,0, // quit panel offsets - 0,0, // quit panel width & height - ARRAYSIZE(IHNM_QuitPanelButtons), - IHNM_QuitPanelButtons, - - 0, 0, // load panel offsets - 0, 0, // load panel width & height - ARRAYSIZE(IHNM_LoadPanelButtons), - IHNM_LoadPanelButtons, - - -1, // save edit index - 0, 0, // save panel offsets - 0, 0, // save panel width & height - ARRAYSIZE(IHNM_SavePanelButtons), - IHNM_SavePanelButtons, - - // No protection panel in IHNM - -1, // protect edit index - 0, 0, // protect panel offsets - 0, 0, // protect panel width & height - ARRAYSIZE(IHNM_SavePanelButtons), - IHNM_SavePanelButtons -}; - static const GameResourceDescription IHNM_Resources = { RID_IHNM_SCENE_LUT, // Scene lookup table RN RID_IHNM_SCRIPT_LUT, // Script lookup table RN @@ -581,7 +339,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_DEMO_G, // Game id 0, // features - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, // Starting scene number &ITEDemo_Resources, ARRAYSIZE(ITEDEMO_GameFonts), @@ -613,7 +370,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_MACDEMO2, GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -645,7 +401,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_MACDEMO1, GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -677,7 +432,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_MACCD_G, GF_BIG_ENDIAN_DATA | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -709,7 +463,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_MACCD, GF_BIG_ENDIAN_DATA | GF_WYRMKEEP | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -742,7 +495,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_LINDEMO, GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -774,7 +526,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_WINDEMO3, GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -805,7 +556,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_WINDEMO2, GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -836,7 +586,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_WINDEMO1, GF_WYRMKEEP | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEWINDEMO_GameFonts), @@ -873,7 +622,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_MULTICD, GF_WYRMKEEP | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -905,7 +653,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_LINCD, GF_WYRMKEEP | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -936,7 +683,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_WINCD, GF_WYRMKEEP | GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -967,7 +713,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_CD_G, GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -999,7 +744,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_CD_G2, GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1031,7 +775,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_CD_DE, GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1063,7 +806,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_CD_DE2, GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1094,7 +836,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_CD, GF_CD_FX, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITECD_GameFonts), @@ -1124,7 +865,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_DISK_DE, 0, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1155,7 +895,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_DISK_DE2, 0, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1185,7 +924,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_DISK_G, 0, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1216,7 +954,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_ITE, GID_ITE_DISK_G2, 0, - &ITE_DisplayInfo, ITE_DEFAULT_SCENE, &ITE_Resources, ARRAYSIZE(ITEDISK_GameFonts), @@ -1247,7 +984,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_DEMO, 0, - &IHNM_DisplayInfo, 0, &IHNM_Resources, ARRAYSIZE(IHNMDEMO_GameFonts), @@ -1287,7 +1023,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_CD, 0, - &IHNM_DisplayInfo, IHNM_DEFAULT_SCENE, &IHNM_Resources, ARRAYSIZE(IHNMCD_GameFonts), @@ -1328,7 +1063,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_CD_DE, 0, - &IHNM_DisplayInfo, IHNM_DEFAULT_SCENE, &IHNM_Resources, ARRAYSIZE(IHNMCD_GameFonts), @@ -1368,7 +1102,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_CD_ES, 0, - &IHNM_DisplayInfo, IHNM_DEFAULT_SCENE, &IHNM_Resources, ARRAYSIZE(IHNMCD_GameFonts), @@ -1408,7 +1141,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_CD_RU, 0, - &IHNM_DisplayInfo, IHNM_DEFAULT_SCENE, &IHNM_Resources, ARRAYSIZE(IHNMCD_GameFonts), @@ -1447,7 +1179,6 @@ static const SAGAGameDescription gameDescriptions[] = { GType_IHNM, GID_IHNM_CD_FR, 0, - &IHNM_DisplayInfo, IHNM_DEFAULT_SCENE, &IHNM_Resources, ARRAYSIZE(IHNMCD_GameFonts), @@ -1458,5 +1189,7 @@ static const SAGAGameDescription gameDescriptions[] = { 0, NULL, }, - { AD_TABLE_END_MARKER, 0, 0, 0, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0, NULL } + { AD_TABLE_END_MARKER, 0, 0, 0, 0, NULL, 0, NULL, NULL, NULL, NULL, 0, NULL } }; + +} // End of namespace Saga diff --git a/engines/saga/displayinfo.h b/engines/saga/displayinfo.h new file mode 100644 index 0000000000..6bf58eca9b --- /dev/null +++ b/engines/saga/displayinfo.h @@ -0,0 +1,422 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2004-2007 The ScummVM project + * + * The ReInherit Engine is (C)2000-2003 by Daniel Balsom. + * + * 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$ + * + */ + +#ifndef SAGA_DISPLAYINFO_H +#define SAGA_DISPLAYINFO_H + +namespace Saga { + +struct PanelButton { + PanelButtonType type; + int xOffset; + int yOffset; + int width; + int height; + int id; + uint16 ascii; + int state; + int upSpriteNumber; + int downSpriteNumber; + int overSpriteNumber; +}; + +struct GameDisplayInfo { + int logicalWidth; + int logicalHeight; + + int pathStartY; + int sceneHeight; + + int statusXOffset; + int statusYOffset; + int statusWidth; + int statusHeight; + int statusTextY; + int statusTextColor; + int statusBGColor; + + int saveReminderXOffset; + int saveReminderYOffset; + int saveReminderWidth; + int saveReminderHeight; + int saveReminderFirstSpriteNumber; + int saveReminderSecondSpriteNumber; + + int leftPortraitXOffset; + int leftPortraitYOffset; + int rightPortraitXOffset; + int rightPortraitYOffset; + + int inventoryUpButtonIndex; + int inventoryDownButtonIndex; + int inventoryRows; + int inventoryColumns; + + int mainPanelXOffset; + int mainPanelYOffset; + int mainPanelButtonsCount; + PanelButton *mainPanelButtons; + + int converseMaxTextWidth; + int converseTextHeight; + int converseTextLines; + int converseUpButtonIndex; + int converseDownButtonIndex; + + int conversePanelXOffset; + int conversePanelYOffset; + int conversePanelButtonsCount; + PanelButton *conversePanelButtons; + + int optionSaveFilePanelIndex; + int optionSaveFileSliderIndex; + uint32 optionSaveFileVisible; + + int optionPanelXOffset; + int optionPanelYOffset; + int optionPanelButtonsCount; + PanelButton *optionPanelButtons; + + int quitPanelXOffset; + int quitPanelYOffset; + int quitPanelWidth; + int quitPanelHeight; + int quitPanelButtonsCount; + PanelButton *quitPanelButtons; + + int loadPanelXOffset; + int loadPanelYOffset; + int loadPanelWidth; + int loadPanelHeight; + int loadPanelButtonsCount; + PanelButton *loadPanelButtons; + + int saveEditIndex; + int savePanelXOffset; + int savePanelYOffset; + int savePanelWidth; + int savePanelHeight; + int savePanelButtonsCount; + PanelButton *savePanelButtons; + + int protectEditIndex; + int protectPanelXOffset; + int protectPanelYOffset; + int protectPanelWidth; + int protectPanelHeight; + int protectPanelButtonsCount; + PanelButton *protectPanelButtons; +}; + +#define ITE_CONVERSE_MAX_TEXT_WIDTH (256 - 60) +#define ITE_CONVERSE_TEXT_HEIGHT 10 +#define ITE_CONVERSE_TEXT_LINES 4 + +// ITE section +static PanelButton ITE_MainPanelButtons[] = { + {kPanelButtonVerb, 52,4, 57,10, kVerbITEWalkTo,'w',0, 0,1,0}, + {kPanelButtonVerb, 52,15, 57,10, kVerbITELookAt,'l',0, 2,3,0}, + {kPanelButtonVerb, 52,26, 57,10, kVerbITEPickUp,'p',0, 4,5,0}, + {kPanelButtonVerb, 52,37, 57,10, kVerbITETalkTo,'t',0, 0,1,0}, + {kPanelButtonVerb, 110,4, 56,10, kVerbITEOpen,'o',0, 6,7,0}, + {kPanelButtonVerb, 110,15, 56,10, kVerbITEClose,'c',0, 8,9,0}, + {kPanelButtonVerb, 110,26, 56,10, kVerbITEUse,'u',0, 10,11,0}, + {kPanelButtonVerb, 110,37, 56,10, kVerbITEGive,'g',0, 12,13,0}, + {kPanelButtonArrow, 306,6, 8,5, -1,'U',0, 0,4,2}, + {kPanelButtonArrow, 306,41, 8,5, 1,'D',0, 1,5,3}, + + {kPanelButtonInventory, 181 + 32*0,6, 27,18, 0,'-',0, 0,0,0}, + {kPanelButtonInventory, 181 + 32*1,6, 27,18, 1,'-',0, 0,0,0}, + {kPanelButtonInventory, 181 + 32*2,6, 27,18, 2,'-',0, 0,0,0}, + {kPanelButtonInventory, 181 + 32*3,6, 27,18, 3,'-',0, 0,0,0}, + + {kPanelButtonInventory, 181 + 32*0,27, 27,18, 4,'-',0, 0,0,0}, + {kPanelButtonInventory, 181 + 32*1,27, 27,18, 5,'-',0, 0,0,0}, + {kPanelButtonInventory, 181 + 32*2,27, 27,18, 6,'-',0, 0,0,0}, + {kPanelButtonInventory, 181 + 32*3,27, 27,18, 7,'-',0, 0,0,0} +}; + +static PanelButton ITE_ConversePanelButtons[] = { + {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 0, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 0,'1',0, 0,0,0}, + {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 1, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 1,'2',0, 0,0,0}, + {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 2, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 2,'3',0, 0,0,0}, + {kPanelButtonConverseText, 52,6 + ITE_CONVERSE_TEXT_HEIGHT * 3, ITE_CONVERSE_MAX_TEXT_WIDTH,ITE_CONVERSE_TEXT_HEIGHT, 3,'4',0, 0,0,0}, + {kPanelButtonArrow, 257,6, 9,6, -1,'u',0, 0,4,2}, + {kPanelButtonArrow, 257,41, 9,6, 1,'d',0, 1,5,3}, +}; + +static PanelButton ITE_OptionPanelButtons[] = { + {kPanelButtonOptionSlider, 284,19, 13,75, 0,'-',0, 0,0,0}, //slider-scroller + {kPanelButtonOption, 113,18, 45,17, kTextReadingSpeed,'r',0, 0,0,0}, //read speed + {kPanelButtonOption, 113,37, 45,17, kTextMusic,'m',0, 0,0,0}, //music + {kPanelButtonOption, 113,56, 45,17, kTextSound,'n',0, 0,0,0}, //sound-noise + {kPanelButtonOption, 13,79, 135,17, kTextQuitGame,'q',0, 0,0,0}, //quit + {kPanelButtonOption, 13,98, 135,17, kTextContinuePlaying,'c',0, 0,0,0}, //continue + {kPanelButtonOption, 164,98, 57,17, kTextLoad,'l',0, 0,0,0}, //load + {kPanelButtonOption, 241,98, 57,17, kTextSave,'s',0, 0,0,0}, //save + {kPanelButtonOptionSaveFiles, 166,20, 112,74, 0,'-',0, 0,0,0}, //savefiles + + {kPanelButtonOptionText,106,4, 0,0, kTextGameOptions,'-',0, 0,0,0}, // text: game options + {kPanelButtonOptionText,11,22, 0,0, kTextReadingSpeed,'-',0, 0,0,0}, // text: read speed + {kPanelButtonOptionText,28,22, 0,0, kTextShowDialog,'-',0, 0,0,0}, // text: read speed + {kPanelButtonOptionText,73,41, 0,0, kTextMusic,'-',0, 0,0,0}, // text: music + {kPanelButtonOptionText,69,60, 0,0, kTextSound,'-',0, 0,0,0}, // text: noise +}; + +static PanelButton ITE_QuitPanelButtons[] = { + {kPanelButtonQuit, 11,17, 60,16, kTextQuit,'q',0, 0,0,0}, + {kPanelButtonQuit, 121,17, 60,16, kTextCancel,'c',0, 0,0,0}, + {kPanelButtonQuitText, -1,5, 0,0, kTextQuitTheGameQuestion,'-',0, 0,0,0}, +}; + +static PanelButton ITE_LoadPanelButtons[] = { + {kPanelButtonLoad, 101,19, 60,16, kTextOK,'o',0, 0,0,0}, + {kPanelButtonLoadText, -1,5, 0,0, kTextLoadSuccessful,'-',0, 0,0,0}, +}; + +static PanelButton ITE_SavePanelButtons[] = { + {kPanelButtonSave, 11,37, 60,16, kTextSave,'s',0, 0,0,0}, + {kPanelButtonSave, 101,37, 60,16, kTextCancel,'c',0, 0,0,0}, + {kPanelButtonSaveEdit, 26,17, 119,17, 0,'-',0, 0,0,0}, + {kPanelButtonSaveText, -1,5, 0,0, kTextEnterSaveGameName,'-',0, 0,0,0}, +}; + +static PanelButton ITE_ProtectPanelButtons[] = { + {kPanelButtonProtectEdit, 26,17, 119,17, 0,'-',0, 0,0,0}, + {kPanelButtonProtectText, -1,5, 0,0, kTextEnterProtectAnswer,'-',0, 0,0,0}, +}; + +/* +static PanelButton ITE_ProtectionPanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +};*/ + +static const GameDisplayInfo ITE_DisplayInfo = { + 320, 200, // logical width&height + + 35, // scene path y offset + 137, // scene height + + 0, // status x offset + 137, // status y offset + 320, // status width + 11, // status height + 2, // status text y offset + 186, // status text color + 15, // status BG color + 308,137, // save reminder pos + 12,12, // save reminder w & h + 6,7, // save reminder sprite numbers + + 5, 4, // left portrait x, y offset + 274, 4, // right portrait x, y offset + + 8, 9, // inventory Up & Down button indexies + 2, 4, // inventory rows, columns + + 0, 148, // main panel offsets + ARRAYSIZE(ITE_MainPanelButtons), + ITE_MainPanelButtons, + + ITE_CONVERSE_MAX_TEXT_WIDTH, + ITE_CONVERSE_TEXT_HEIGHT, + ITE_CONVERSE_TEXT_LINES, + 4, 5, // converse Up & Down button indexies + 0, 148, // converse panel offsets + ARRAYSIZE(ITE_ConversePanelButtons), + ITE_ConversePanelButtons, + + 8, 0, // save file index + 8, // optionSaveFileVisible + 8, 8, // option panel offsets + ARRAYSIZE(ITE_OptionPanelButtons), + ITE_OptionPanelButtons, + + 64,54, // quit panel offsets + 192,38, // quit panel width & height + ARRAYSIZE(ITE_QuitPanelButtons), + ITE_QuitPanelButtons, + + 74, 53, // load panel offsets + 172, 40, // load panel width & height + ARRAYSIZE(ITE_LoadPanelButtons), + ITE_LoadPanelButtons, + + 2, // save edit index + 74, 44, // save panel offsets + 172, 58, // save panel width & height + ARRAYSIZE(ITE_SavePanelButtons), + ITE_SavePanelButtons, + + 0, // protect edit index + 74, 44, // protect panel offsets + 172, 58, // protect panel width & height + ARRAYSIZE(ITE_ProtectPanelButtons), + ITE_ProtectPanelButtons +}; + + +//TODO: ihnm +#define IHNM_CONVERSE_MAX_TEXT_WIDTH (256 - 60) +#define IHNM_CONVERSE_TEXT_HEIGHT 10 +#define IHNM_CONVERSE_TEXT_LINES 10 + +static PanelButton IHNM_MainPanelButtons[] = { + // TODO: The +2's are needed here to fix the verbs, investigate why + // The computation of textid in Interface::drawVerbPanelText has also been changed accordingly + {kPanelButtonVerb, 106,12, 114,30, kVerbIHNMWalk + 2,'w',0, 0,1,0}, + {kPanelButtonVerb, 106,44, 114,30, kVerbIHNMLookAt + 2,'l',0, 2,3,0}, + {kPanelButtonVerb, 106,76, 114,30, kVerbIHNMTake + 2,'k',0, 4,5,0}, + {kPanelButtonVerb, 106,108, 114,30, kVerbIHNMUse + 2,'u',0, 6,7,0}, + {kPanelButtonVerb, 223,12, 114,30, kVerbIHNMTalkTo + 2,'t',0, 8,9,0}, + {kPanelButtonVerb, 223,44, 114,30, kVerbIHNMSwallow + 2,'s',0, 10,11,0}, + {kPanelButtonVerb, 223,76, 114,30, kVerbIHNMGive + 2,'g',0, 12,13,0}, + {kPanelButtonVerb, 223,108, 114,30, kVerbIHNMPush + 2,'p',0, 14,15,0}, + {kPanelButtonArrow, 606,22, 20,25, -1,'[',0, 0,0,0}, //TODO: arrow Sprite Numbers + {kPanelButtonArrow, 606,108, 20,25, 1,']',0, 0,0,0}, + + {kPanelButtonInventory, 357 + 64*0,18, 54,54, 0,'-',0, 0,0,0}, + {kPanelButtonInventory, 357 + 64*1,18, 54,54, 1,'-',0, 0,0,0}, + {kPanelButtonInventory, 357 + 64*2,18, 54,54, 2,'-',0, 0,0,0}, + {kPanelButtonInventory, 357 + 64*3,18, 54,54, 3,'-',0, 0,0,0}, + + {kPanelButtonInventory, 357 + 64*0,80, 54,54, 4,'-',0, 0,0,0}, + {kPanelButtonInventory, 357 + 64*1,80, 54,54, 5,'-',0, 0,0,0}, + {kPanelButtonInventory, 357 + 64*2,80, 54,54, 6,'-',0, 0,0,0}, + {kPanelButtonInventory, 357 + 64*3,80, 54,54, 7,'-',0, 0,0,0} +}; + +static PanelButton IHNM_ConversePanelButtons[] = { + {kPanelButtonConverseText, 117,18 + IHNM_CONVERSE_TEXT_HEIGHT * 0, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 0,'1',0, 0,0,0}, + {kPanelButtonConverseText, 52,18 + IHNM_CONVERSE_TEXT_HEIGHT * 1, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 1,'2',0, 0,0,0}, + {kPanelButtonConverseText, 52,18 + IHNM_CONVERSE_TEXT_HEIGHT * 2, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 2,'3',0, 0,0,0}, + {kPanelButtonConverseText, 52,18 + IHNM_CONVERSE_TEXT_HEIGHT * 3, IHNM_CONVERSE_MAX_TEXT_WIDTH,IHNM_CONVERSE_TEXT_HEIGHT, 3,'4',0, 0,0,0}, + //..... + {kPanelButtonArrow, 606,22, 20,25, -1,'[',0, 0,0,0}, //TODO: arrow Sprite Numbers + {kPanelButtonArrow, 606,108, 20,25, 1,']',0, 0,0,0} +}; + +static PanelButton IHNM_OptionPanelButtons[] = { + //TODO: Add the rest of the buttons + {kPanelButtonOptionText,28,36, 0,0, kTextReadingSpeed,'-',0, 0,0,0}, // text: read speed + {kPanelButtonOptionText,60,61, 0,0, kTextMusic,'-',0, 0,0,0}, // text: music + {kPanelButtonOptionText,60,86, 0,0, kTextSound,'-',0, 0,0,0}, // text: noise + // TODO: Add Voices text here + {kPanelButtonOption, 154,30, 79,23, kTextReadingSpeed,'r',0, 0,0,0}, //read speed + {kPanelButtonOption, 154,55, 79,23, kTextMusic,'m',0, 0,0,0}, //music + {kPanelButtonOption, 154,80, 79,23, kTextSound,'n',0, 0,0,0}, //sound-noise + // TODO: Add Voices widget here + {kPanelButtonOption, 19,149, 200,25, kTextQuitGame,'q',0, 0,0,0}, //quit + {kPanelButtonOption, 19,177, 200,25, kTextContinuePlaying,'c',0, 0,0,0}, //continue + // TODO: Implement load/save + {kPanelButtonOption, 244,164, 79,23, kTextLoad,'l',0, 0,0,0}, //load + {kPanelButtonOption, 335,164, 79,23, kTextSave,'s',0, 0,0,0}, //save +}; + +static PanelButton IHNM_QuitPanelButtons[] = { + //FIXME: Show the correct quit dialog background + //TODO: Those coordinates might not be pixel perfect, check with the original interpreter + {kPanelButtonQuit, 25,80, 80,25, kTextQuit,'q',0, 0,0,0}, + {kPanelButtonQuit, 155,80, 80,25, kTextCancel,'c',0, 0,0,0}, + {kPanelButtonQuitText, -1,5, 0,0, kTextQuitTheGameQuestion,'-',0, 0,0,0}, +}; + +static PanelButton IHNM_LoadPanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + +static PanelButton IHNM_SavePanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + + +static const GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all + 640, 480, // logical width&height + + 0, // scene path y offset + 304, // scene height + + 0, // status x offset + 304, // status y offset + 616, // status width + 24, // status height + 8, // status text y offset + 253, // status text color + 250, // status BG color + 616, 303, // save reminder pos + 24, 24, // save reminder w&h + 0,1, // save reminder sprite numbers + + 11, 12, // left portrait x, y offset + -1, -1, // right portrait x, y offset + + -1, -1, // inventory Up & Down button indexies + 2, 4, // inventory rows, columns + + 0, 328, // main panel offsets + ARRAYSIZE(IHNM_MainPanelButtons), + IHNM_MainPanelButtons, + + -1, -1, // converse Up & Down button indexies + + IHNM_CONVERSE_MAX_TEXT_WIDTH, + IHNM_CONVERSE_TEXT_HEIGHT, + IHNM_CONVERSE_TEXT_LINES, + 0, 328, // converse panel offsets + ARRAYSIZE(IHNM_ConversePanelButtons), + IHNM_ConversePanelButtons, + + -1, -1, // save file index + 0, // optionSaveFileVisible + 92, 46, // option panel offsets + ARRAYSIZE(IHNM_OptionPanelButtons), + IHNM_OptionPanelButtons, + + 190,180, // quit panel offsets + 260,115, // quit panel width & height + ARRAYSIZE(IHNM_QuitPanelButtons), + IHNM_QuitPanelButtons, + + 0, 0, // load panel offsets + 0, 0, // load panel width & height + ARRAYSIZE(IHNM_LoadPanelButtons), + IHNM_LoadPanelButtons, + + -1, // save edit index + 0, 0, // save panel offsets + 0, 0, // save panel width & height + ARRAYSIZE(IHNM_SavePanelButtons), + IHNM_SavePanelButtons, + + // No protection panel in IHNM + -1, // protect edit index + 0, 0, // protect panel offsets + 0, 0, // protect panel width & height + ARRAYSIZE(IHNM_SavePanelButtons), + IHNM_SavePanelButtons +}; + +} // End of namespace Saga + +#endif diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp index b3e2230c5b..f58b17ca17 100644 --- a/engines/saga/events.cpp +++ b/engines/saga/events.cpp @@ -437,6 +437,15 @@ int Events::handleOneShot(Event *event) { case kEventHide: _vm->_gfx->showCursor(false); break; + case kEventSetNormalCursor: + // in ITE there is just one cursor + if (_vm->getGameType() == GType_IHNM) + _vm->_gfx->setCursor(kCursorNormal); + break; + case kEventSetBusyCursor: + if (_vm->getGameType() == GType_IHNM) + _vm->_gfx->setCursor(kCursorBusy); + break; default: break; } diff --git a/engines/saga/events.h b/engines/saga/events.h index d89b3d89f5..2e4d9cf987 100644 --- a/engines/saga/events.h +++ b/engines/saga/events.h @@ -97,6 +97,8 @@ enum EventOps { // CURSOR events kEventShow = 1, // kEventHide = 2, // reused + kEventSetNormalCursor = 3, + kEventSetBusyCursor = 4, // GRAPHICS events kEventFillRect = 1, // kEventSetFlag = 4, // reused diff --git a/engines/saga/gfx.h b/engines/saga/gfx.h index 0ffd0ea434..ab161a9420 100644 --- a/engines/saga/gfx.h +++ b/engines/saga/gfx.h @@ -148,9 +148,9 @@ public: void palToBlack(PalEntry *src_pal, double percent); void blackToPal(PalEntry *src_pal, double percent); void showCursor(bool state); + void setCursor(CursorType cursorType = kCursorNormal); private: - void setCursor(CursorType cursorType = kCursorNormal); int _init; Surface _backBuffer; byte _currentPal[PAL_ENTRIES * 4]; diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 7c37126d59..2d15db80ee 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -28,6 +28,7 @@ #include "saga/gfx.h" #include "saga/actor.h" #include "saga/console.h" +#include "saga/displayinfo.h" #include "saga/events.h" #include "saga/font.h" #include "saga/objectmap.h" @@ -68,14 +69,14 @@ static int verbTypeToTextStringsIdLUT[2][kVerbTypeIdsMax] = { -1, -1}, {-1, - 3, //TODO:check - 2, - 1, - 5, - 6, //TODO:check - 8, //TODO:check - 7, - 4} + kVerbIHNMWalk, + kVerbIHNMLookAt, + kVerbIHNMTake, + kVerbIHNMUse, + kVerbIHNMTalkTo, + kVerbIHNMSwallow, + kVerbIHNMGive, + kVerbIHNMPush} }; Interface::Interface(SagaEngine *vm) : _vm(vm) { @@ -535,6 +536,10 @@ void Interface::setStatusText(const char *text, int statusColor) { assert(text != NULL); assert(strlen(text) < STATUS_TEXT_LEN); + // Disable the status text in IHNM when the chapter is 8 + if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8) + return; + if (_vm->_render->getFlags() & (RF_PLACARD | RF_MAP)) return; @@ -696,14 +701,20 @@ void Interface::drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *p text = _vm->getTextString(panelButton->id); panel->calcPanelButtonRect(panelButton, rect); if (panelButton->xOffset < 0) { - textWidth = _vm->_font->getStringWidth(kKnownFontMedium, text, 0, kFontNormal); + if (_vm->getGameType() == GType_ITE) + textWidth = _vm->_font->getStringWidth(kKnownFontMedium, text, 0, kFontNormal); + else + textWidth = _vm->_font->getStringWidth(kKnownFontVerb, text, 0, kFontNormal); rect.left += 2 + (panel->imageWidth - 1 - textWidth) / 2; } textPoint.x = rect.left; textPoint.y = rect.top + 1; - _vm->_font->textDraw(kKnownFontMedium, ds, text, textPoint, _vm->KnownColor2ColorId(kKnownColorVerbText), _vm->KnownColor2ColorId(kKnownColorVerbTextShadow), kFontShadow); + if (_vm->getGameType() == GType_ITE) + _vm->_font->textDraw(kKnownFontMedium, ds, text, textPoint, _vm->KnownColor2ColorId(kKnownColorVerbText), _vm->KnownColor2ColorId(kKnownColorVerbTextShadow), kFontShadow); + else + _vm->_font->textDraw(kKnownFontVerb, ds, text, textPoint, _vm->KnownColor2ColorId(kKnownColorVerbText), _vm->KnownColor2ColorId(kKnownColorVerbTextShadow), kFontShadow); } void Interface::drawOption() { @@ -718,7 +729,7 @@ void Interface::drawOption() { Rect rect2; PanelButton *panelButton; Point textPoint; - if (_optionSaveFileSlider == NULL) return;//TODO:REMOVE + Point point; backBuffer = _vm->_gfx->getBackBuffer(); @@ -727,6 +738,15 @@ void Interface::drawOption() { for (i = 0; i < _optionPanel.buttonsCount; i++) { panelButton = &_optionPanel.buttons[i]; + + // TODO: This probably works for the button background, but the resources are still not loeaded + // (_optionPanel.sprites) + /* + point.x = _optionPanel.x + panelButton->xOffset; + point.y = _optionPanel.y + panelButton->yOffset; + _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _optionPanel.sprites, i, point, 256); + */ + if (panelButton->type == kPanelButtonOption) { drawPanelButtonText(backBuffer, &_optionPanel, panelButton); } @@ -736,9 +756,17 @@ void Interface::drawOption() { } if (_optionSaveRectTop.height() > 0) { - backBuffer->drawRect(_optionSaveRectTop, kITEColorDarkGrey); + if (_vm->getGameType() == GType_ITE) { + backBuffer->drawRect(_optionSaveRectTop, kITEColorDarkGrey); + } else { + // TODO: Draw the button graphic properly for IHNM + } } + // FIXME: The _optionSaveFileSlider checks exist for IHNM, where + // _optionSaveFileSlider is not initialized correctly yet + if (_optionSaveFileSlider == NULL) return; //TODO:REMOVE + drawButtonBox(backBuffer, _optionSaveRectSlider, kSlider, _optionSaveFileSlider->state > 0); if (_optionSaveRectBottom.height() > 0) { @@ -1496,14 +1524,12 @@ void Interface::drawStatusBar() { int stringWidth; int color; - if (_panelMode == kPanelChapterSelection) + // Disable the status text in IHNM when the chapter is 8 + if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8) return; backBuffer = _vm->_gfx->getBackBuffer(); - // Disable this for IHNM for now, since that game uses the full screen - // in some cases. - // Erase background of status bar rect.left = _vm->getDisplayInfo().statusXOffset; rect.top = _vm->getDisplayInfo().statusYOffset; @@ -1889,8 +1915,13 @@ void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelBut } text = _vm->getTextString(textId); - textWidth = _vm->_font->getStringWidth(kKnownFontMedium, text, 0, kFontNormal); - textHeight = _vm->_font->getHeight(kKnownFontMedium); + if (_vm->getGameType() == GType_ITE) { + textWidth = _vm->_font->getStringWidth(kKnownFontMedium, text, 0, kFontNormal); + textHeight = _vm->_font->getHeight(kKnownFontMedium); + } else { + textWidth = _vm->_font->getStringWidth(kKnownFontVerb, text, 0, kFontNormal); + textHeight = _vm->_font->getHeight(kKnownFontVerb); + } point.x = panel->x + panelButton->xOffset + (panelButton->width / 2) - (textWidth / 2); point.y = panel->y + panelButton->yOffset + (panelButton->height / 2) - (textHeight / 2); @@ -1904,8 +1935,12 @@ void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelBut panel->calcPanelButtonRect(panelButton, rect); drawButtonBox(ds, rect, kButton, panelButton->state > 0); - _vm->_font->textDraw(kKnownFontMedium, ds, text, point, - _vm->KnownColor2ColorId(textColor), _vm->KnownColor2ColorId(kKnownColorVerbTextShadow), kFontShadow); + if (_vm->getGameType() == GType_ITE) + _vm->_font->textDraw(kKnownFontMedium, ds, text, point, + _vm->KnownColor2ColorId(textColor), _vm->KnownColor2ColorId(kKnownColorVerbTextShadow), kFontShadow); + else + _vm->_font->textDraw(kKnownFontVerb, ds, text, point, + _vm->KnownColor2ColorId(textColor), _vm->KnownColor2ColorId(kKnownColorVerbTextShadow), kFontShadow); } void Interface::drawPanelButtonArrow(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) { @@ -1938,7 +1973,8 @@ void Interface::drawVerbPanelText(Surface *ds, PanelButton *panelButton, KnownCo textId = verbTypeToTextStringsIdLUT[0][panelButton->id]; text = _vm->getTextString(textId); } else { - textId = verbTypeToTextStringsIdLUT[1][panelButton->id]; + // This -2 has been placed because of the changes in the ids in IHNM_MainPanelButtons + textId = verbTypeToTextStringsIdLUT[1][panelButton->id - 2]; text = _vm->_script->_mainStrings.getString(textId + 1); textShadowKnownColor = kKnownColorTransparent; } diff --git a/engines/saga/interface.h b/engines/saga/interface.h index 6dfaaa4984..a69d94b6b9 100644 --- a/engines/saga/interface.h +++ b/engines/saga/interface.h @@ -29,6 +29,7 @@ #include "common/savefile.h" +#include "saga/displayinfo.h" #include "saga/sprite.h" #include "saga/script.h" diff --git a/engines/saga/module.mk b/engines/saga/module.mk index 205e243a72..6c1812ad23 100644 --- a/engines/saga/module.mk +++ b/engines/saga/module.mk @@ -4,10 +4,10 @@ MODULE_OBJS := \ actor.o \ animation.o \ console.o \ + detection.o \ events.o \ font.o \ font_map.o \ - game.o \ gfx.o \ ihnm_introproc.o \ image.o \ diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index fc031c07ce..0126e79b6b 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -30,9 +30,6 @@ #include "sound/audiostream.h" #include "sound/mididrv.h" #include "sound/midiparser.h" -#include "sound/mp3.h" -#include "sound/vorbis.h" -#include "sound/flac.h" #include "common/config-manager.h" #include "common/file.h" @@ -40,24 +37,6 @@ namespace Saga { #define BUFFER_SIZE 4096 -struct TrackFormat { - Audio::DigitalTrackInfo* (*openTrackFunction)(int); -}; - -static const TrackFormat TRACK_FORMATS[] = { -#ifdef USE_FLAC - { Audio::getFlacTrack }, -#endif -#ifdef USE_VORBIS - { Audio::getVorbisTrack }, -#endif -#ifdef USE_MAD - { Audio::getMP3Track }, -#endif - - { NULL } // Terminator -}; - // I haven't decided yet if it's a good idea to make looping part of the audio // stream class, or if I should use a "wrapper" class, like I did for Broken // Sword 2, to make it easier to add support for compressed music... but I'll @@ -307,8 +286,6 @@ Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enable _songTableLen = 0; _songTable = 0; - _track = NULL; - _midiMusicData = NULL; } @@ -411,13 +388,18 @@ void Music::play(uint32 resourceId, MusicFlags flags) { } // Try to open standalone digital track - for (int i = 0; i < ARRAYSIZE(TRACK_FORMATS) - 1; ++i) - if ((_track = TRACK_FORMATS[i].openTrackFunction(realTrackNumber))) { - break; + char trackName[2][16]; + sprintf(trackName[0], "track%d", realTrackNumber); + sprintf(trackName[1], "track%02d", realTrackNumber); + Audio::AudioStream *stream = 0; + for (int i = 0; i < 2; ++i) { + // We multiply by 40 / 3 = 1000 / 75 to convert frames to milliseconds + // FIXME: Do we really want a duration of 10000 frames = 133 seconds, or is that just a random value? + stream = Audio::AudioStream::openStreamFile(trackName[i], 0, 10000 * 40 / 3, (flags == MUSIC_LOOP) ? 0 : 1); + if (stream) { + _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_musicHandle, stream); + return; } - if (_track) { - _track->play(_mixer, &_musicHandle, (flags == MUSIC_LOOP) ? -1 : 1, 0, 10000); - return; } if (_vm->getGameType() == GType_ITE) { diff --git a/engines/saga/music.h b/engines/saga/music.h index b02c8c9eb1..4e14f3fc01 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -137,8 +137,6 @@ private: MidiParser *xmidiParser; MidiParser *smfParser; - Audio::DigitalTrackInfo *_track; - byte *_midiMusicData; static void musicVolumeGaugeCallback(void *refCon); diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 6094bc4387..264863d043 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -156,7 +156,7 @@ int SagaEngine::init() { // Detect game and open resource files if (!initGame()) { - GUIErrorMessage("No valid games were found in the specified directory."); + GUIErrorMessage("Error loading game resources."); return FAILURE; } diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 832d5292bc..0d9a464e19 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -87,8 +87,237 @@ enum ERRORCODE { SUCCESS = 0 }; -#include "sagagame.h" +enum SAGAGameType { + GType_ITE = 0, + GType_IHNM = 1 +}; + +enum GameIds { + // Dreamers Guild + GID_ITE_DEMO_G = 0, + GID_ITE_DISK_G, + GID_ITE_DISK_G2, + GID_ITE_CD_G, + GID_ITE_CD_G2, + GID_ITE_MACCD_G, + + // Wyrmkeep + GID_ITE_CD, // data for Win rerelease is same as in old DOS + GID_ITE_WINCD, // but it has a bunch of patch files + GID_ITE_MACCD, + GID_ITE_LINCD, + GID_ITE_MULTICD, // Wyrmkeep combined Windows/Mac/Linux version + GID_ITE_WINDEMO1, // older Wyrmkeep windows demo + GID_ITE_MACDEMO1, // older Wyrmkeep mac demo + GID_ITE_LINDEMO, + GID_ITE_WINDEMO2, + GID_ITE_WINDEMO3, + GID_ITE_MACDEMO2, + + // German + GID_ITE_DISK_DE, + GID_ITE_DISK_DE2, + GID_ITE_AMIGACD_DE, // TODO + GID_ITE_OLDMAC_DE, // TODO + GID_ITE_AMIGA_FL_DE,// TODO + GID_ITE_CD_DE, // reported by mld. Bestsellergamers cover disk + GID_ITE_CD_DE2, + GID_ITE_AMIGA_AGA_DEMO, // TODO + GID_ITE_AMIGA_ECS_DEMO, // TODO + + GID_IHNM_DEMO, + GID_IHNM_CD, + GID_IHNM_CD_DE, // reported by mld. German retail + GID_IHNM_CD_ES, + GID_IHNM_CD_RU, + GID_IHNM_CD_FR +}; + +enum GameFileTypes { + GAME_RESOURCEFILE = 1 << 0, + GAME_SCRIPTFILE = 1 << 1, + GAME_SOUNDFILE = 1 << 2, + GAME_VOICEFILE = 1 << 3, + GAME_DEMOFILE = 1 << 4, + GAME_MUSICFILE = 1 << 5, + GAME_MUSICFILE_GM = 1 << 6, + GAME_MUSICFILE_FM = 1 << 7, + GAME_PATCHFILE = 1 << 8, + GAME_MACBINARY = 1 << 9, + GAME_SWAPENDIAN = 1 << 10 +}; + +enum GameFeatures { + GF_BIG_ENDIAN_DATA = 1 << 0, + GF_WYRMKEEP = 1 << 1, + GF_CD_FX = 1 << 2, + GF_SCENE_SUBSTITUTES = 1 << 3 +}; + +enum VerbTypeIds { + kVerbITENone = 0, + kVerbITEPickUp = 1, + kVerbITELookAt = 2, + kVerbITEWalkTo = 3, + kVerbITETalkTo = 4, + kVerbITEOpen = 5, + kVerbITEClose = 6, + kVerbITEGive = 7, + kVerbITEUse = 8, + kVerbITEOptions = 9, + kVerbITEEnter = 10, + kVerbITELeave = 11, + kVerbITEBegin = 12, + kVerbITEWalkOnly = 13, + kVerbITELookOnly = 14, + + + kVerbIHNMNone = 0, + kVerbIHNMWalk = 1, + kVerbIHNMLookAt = 2, + kVerbIHNMTake = 3, + kVerbIHNMUse = 4, + kVerbIHNMTalkTo = 5, + kVerbIHNMSwallow = 6, + kVerbIHNMGive = 7, + kVerbIHNMPush = 8, + kVerbIHNMOptions = 9, + kVerbIHNMEnter = 10, + kVerbIHNMLeave = 11, + kVerbIHNMBegin = 12, + kVerbIHNMWalkOnly = 13, + kVerbIHNMLookOnly = 14, + + kVerbTypeIdsMax = kVerbITELookOnly + 1 +}; +enum PanelButtonType { + kPanelButtonVerb = 1 << 0, + kPanelButtonArrow = 1 << 1, + kPanelButtonConverseText = 1 << 2, + kPanelButtonInventory = 1 << 3, + + kPanelButtonOption = 1 << 4, + kPanelButtonOptionSlider = 1 << 5, + kPanelButtonOptionSaveFiles = 1 << 6, + kPanelButtonOptionText = 1 << 7, + + kPanelButtonQuit = 1 << 8, + kPanelButtonQuitText = 1 << 9, + + kPanelButtonLoad = 1 << 10, + kPanelButtonLoadText = 1 << 11, + + kPanelButtonSave = 1 << 12, + kPanelButtonSaveText = 1 << 13, + kPanelButtonSaveEdit = 1 << 14, + + kPanelButtonProtectText = 1 << 15, + kPanelButtonProtectEdit = 1 << 16, + + kPanelAllButtons = 0xFFFFF +}; + +enum GameSoundTypes { + kSoundPCM = 0, + kSoundVOX = 1, + kSoundVOC = 2, + kSoundWAV = 3, + kSoundMacPCM = 4 +}; + +enum TextStringIds { + kTextWalkTo, + kTextLookAt, + kTextPickUp, + kTextTalkTo, + kTextOpen, + kTextClose, + kTextUse, + kTextGive, + kTextOptions, + kTextTest, + kTextDemo, + kTextHelp, + kTextQuitGame, + kTextFast, + kTextSlow, + kTextOn, + kTextOff, + kTextContinuePlaying, + kTextLoad, + kTextSave, + kTextGameOptions, + kTextReadingSpeed, + kTextMusic, + kTextSound, + kTextCancel, + kTextQuit, + kTextOK, + kTextMid, + kTextClick, + kText10Percent, + kText20Percent, + kText30Percent, + kText40Percent, + kText50Percent, + kText60Percent, + kText70Percent, + kText80Percent, + kText90Percent, + kTextMax, + kTextQuitTheGameQuestion, + kTextLoadSuccessful, + kTextEnterSaveGameName, + kTextGiveTo, + kTextUseWidth, + kTextNewSave, + kTextICantPickup, + kTextNothingSpecial, + kTextNoPlaceToOpen, + kTextNoOpening, + kTextDontKnow, + kTextShowDialog, + kTextEnterProtectAnswer +}; + + +struct GameResourceDescription { + uint32 sceneLUTResourceId; + uint32 moduleLUTResourceId; + uint32 mainPanelResourceId; + uint32 conversePanelResourceId; + uint32 optionPanelResourceId; + uint32 mainSpritesResourceId; + uint32 mainPanelSpritesResourceId; + uint32 defaultPortraitsResourceId; + uint32 mainStringsResourceId; + uint32 actorsStringsResourceId; +}; + +struct GameFontDescription { + uint32 fontResourceId; +}; + +struct GameDisplayInfo; + +struct GameSoundInfo { + GameSoundTypes resourceType; + long frequency; + int sampleBits; + bool stereo; + bool isBigEndian; + bool isSigned; +}; + +struct GamePatchDescription { + const char *fileName; + uint16 fileType; + uint32 resourceId; + const GameSoundInfo *soundInfo; +}; + +struct SAGAGameDescription; enum GameObjectTypes { kGameObjectNone = 0, @@ -234,10 +463,6 @@ inline int clamp(int minValue, int value, int maxValue) { } } -inline int integerCompare(int i1, int i2) { - return ((i1) > (i2) ? 1 : ((i1) < (i2) ? -1 : 0)); -} - inline int objectTypeId(uint16 objectId) { return objectId >> OBJECT_TYPE_SHIFT; } @@ -363,9 +588,6 @@ public: Common::String _gameTitle; Common::Rect _displayClip; -protected: - GameDisplayInfo _gameDisplayInfo; - public: int32 _frameCount; @@ -396,9 +618,9 @@ public: const Common::ADGameFileDescription *getFilesDescriptions() const; const Common::Rect &getDisplayClip() const { return _displayClip;} - int getDisplayWidth() const { return _gameDisplayInfo.logicalWidth; } - int getDisplayHeight() const { return _gameDisplayInfo.logicalHeight;} - const GameDisplayInfo & getDisplayInfo() { return _gameDisplayInfo; } + int getDisplayWidth() const; + int getDisplayHeight() const; + const GameDisplayInfo &getDisplayInfo(); const char *getTextString(int textStringId); void getExcuseInfo(int verb, const char *&textString, int &soundResourceId); diff --git a/engines/saga/sagagame.h b/engines/saga/sagagame.h deleted file mode 100644 index cd4aa48faf..0000000000 --- a/engines/saga/sagagame.h +++ /dev/null @@ -1,332 +0,0 @@ -enum SAGAGameType { - GType_ITE = 0, - GType_IHNM = 1 -}; - -enum GameIds { - // Dreamers Guild - GID_ITE_DEMO_G = 0, - GID_ITE_DISK_G, - GID_ITE_DISK_G2, - GID_ITE_CD_G, - GID_ITE_CD_G2, - GID_ITE_MACCD_G, - - // Wyrmkeep - GID_ITE_CD, // data for Win rerelease is same as in old DOS - GID_ITE_WINCD, // but it has a bunch of patch files - GID_ITE_MACCD, - GID_ITE_LINCD, - GID_ITE_MULTICD, // Wyrmkeep combined Windows/Mac/Linux version - GID_ITE_WINDEMO1, // older Wyrmkeep windows demo - GID_ITE_MACDEMO1, // older Wyrmkeep mac demo - GID_ITE_LINDEMO, - GID_ITE_WINDEMO2, - GID_ITE_WINDEMO3, - GID_ITE_MACDEMO2, - - // German - GID_ITE_DISK_DE, - GID_ITE_DISK_DE2, - GID_ITE_AMIGACD_DE, // TODO - GID_ITE_OLDMAC_DE, // TODO - GID_ITE_AMIGA_FL_DE,// TODO - GID_ITE_CD_DE, // reported by mld. Bestsellergamers cover disk - GID_ITE_CD_DE2, - GID_ITE_AMIGA_AGA_DEMO, // TODO - GID_ITE_AMIGA_ECS_DEMO, // TODO - - GID_IHNM_DEMO, - GID_IHNM_CD, - GID_IHNM_CD_DE, // reported by mld. German retail - GID_IHNM_CD_ES, - GID_IHNM_CD_RU, - GID_IHNM_CD_FR -}; - -enum GameFileTypes { - GAME_RESOURCEFILE = 1 << 0, - GAME_SCRIPTFILE = 1 << 1, - GAME_SOUNDFILE = 1 << 2, - GAME_VOICEFILE = 1 << 3, - GAME_DEMOFILE = 1 << 4, - GAME_MUSICFILE = 1 << 5, - GAME_MUSICFILE_GM = 1 << 6, - GAME_MUSICFILE_FM = 1 << 7, - GAME_PATCHFILE = 1 << 8, - GAME_MACBINARY = 1 << 9, - GAME_SWAPENDIAN = 1 << 10 -}; - -enum GameFeatures { - GF_BIG_ENDIAN_DATA = 1 << 0, - GF_WYRMKEEP = 1 << 1, - GF_CD_FX = 1 << 2, - GF_SCENE_SUBSTITUTES = 1 << 3 -}; - -enum VerbTypeIds { - kVerbITENone = 0, - kVerbITEPickUp = 1, - kVerbITELookAt = 2, - kVerbITEWalkTo = 3, - kVerbITETalkTo = 4, - kVerbITEOpen = 5, - kVerbITEClose = 6, - kVerbITEGive = 7, - kVerbITEUse = 8, - kVerbITEOptions = 9, - kVerbITEEnter = 10, - kVerbITELeave = 11, - kVerbITEBegin = 12, - kVerbITEWalkOnly = 13, - kVerbITELookOnly = 14, - - - kVerbIHNMNone = 0, - kVerbIHNMWalk = 1, - kVerbIHNMLookAt = 2, - kVerbIHNMTake = 3, - kVerbIHNMUse = 4, - kVerbIHNMTalkTo = 5, - kVerbIHNMSwallow = 6, - kVerbIHNMGive = 7, - kVerbIHNMPush = 8, - kVerbIHNMOptions = 9, - kVerbIHNMEnter = 10, - kVerbIHNMLeave = 11, - kVerbIHNMBegin = 12, - kVerbIHNMWalkOnly = 13, - kVerbIHNMLookOnly = 14, - - kVerbTypeIdsMax = kVerbITELookOnly + 1 -}; -enum PanelButtonType { - kPanelButtonVerb = 1 << 0, - kPanelButtonArrow = 1 << 1, - kPanelButtonConverseText = 1 << 2, - kPanelButtonInventory = 1 << 3, - - kPanelButtonOption = 1 << 4, - kPanelButtonOptionSlider = 1 << 5, - kPanelButtonOptionSaveFiles = 1 << 6, - kPanelButtonOptionText = 1 << 7, - - kPanelButtonQuit = 1 << 8, - kPanelButtonQuitText = 1 << 9, - - kPanelButtonLoad = 1 << 10, - kPanelButtonLoadText = 1 << 11, - - kPanelButtonSave = 1 << 12, - kPanelButtonSaveText = 1 << 13, - kPanelButtonSaveEdit = 1 << 14, - - kPanelButtonProtectText = 1 << 15, - kPanelButtonProtectEdit = 1 << 16, - - kPanelAllButtons = 0xFFFFF -}; - -enum GameSoundTypes { - kSoundPCM = 0, - kSoundVOX = 1, - kSoundVOC = 2, - kSoundWAV = 3, - kSoundMacPCM = 4 -}; - -enum TextStringIds { - kTextWalkTo, - kTextLookAt, - kTextPickUp, - kTextTalkTo, - kTextOpen, - kTextClose, - kTextUse, - kTextGive, - kTextOptions, - kTextTest, - kTextDemo, - kTextHelp, - kTextQuitGame, - kTextFast, - kTextSlow, - kTextOn, - kTextOff, - kTextContinuePlaying, - kTextLoad, - kTextSave, - kTextGameOptions, - kTextReadingSpeed, - kTextMusic, - kTextSound, - kTextCancel, - kTextQuit, - kTextOK, - kTextMid, - kTextClick, - kText10Percent, - kText20Percent, - kText30Percent, - kText40Percent, - kText50Percent, - kText60Percent, - kText70Percent, - kText80Percent, - kText90Percent, - kTextMax, - kTextQuitTheGameQuestion, - kTextLoadSuccessful, - kTextEnterSaveGameName, - kTextGiveTo, - kTextUseWidth, - kTextNewSave, - kTextICantPickup, - kTextNothingSpecial, - kTextNoPlaceToOpen, - kTextNoOpening, - kTextDontKnow, - kTextShowDialog, - kTextEnterProtectAnswer -}; - - -struct GameResourceDescription { - uint32 sceneLUTResourceId; - uint32 moduleLUTResourceId; - uint32 mainPanelResourceId; - uint32 conversePanelResourceId; - uint32 optionPanelResourceId; - uint32 mainSpritesResourceId; - uint32 mainPanelSpritesResourceId; - uint32 defaultPortraitsResourceId; - uint32 mainStringsResourceId; - uint32 actorsStringsResourceId; -}; - -struct GameFontDescription { - uint32 fontResourceId; -}; - -struct PanelButton { - PanelButtonType type; - int xOffset; - int yOffset; - int width; - int height; - int id; - uint16 ascii; - int state; - int upSpriteNumber; - int downSpriteNumber; - int overSpriteNumber; -}; - -struct GameDisplayInfo { - int logicalWidth; - int logicalHeight; - - int pathStartY; - int sceneHeight; - - int statusXOffset; - int statusYOffset; - int statusWidth; - int statusHeight; - int statusTextY; - int statusTextColor; - int statusBGColor; - - int saveReminderXOffset; - int saveReminderYOffset; - int saveReminderWidth; - int saveReminderHeight; - int saveReminderFirstSpriteNumber; - int saveReminderSecondSpriteNumber; - - int leftPortraitXOffset; - int leftPortraitYOffset; - int rightPortraitXOffset; - int rightPortraitYOffset; - - int inventoryUpButtonIndex; - int inventoryDownButtonIndex; - int inventoryRows; - int inventoryColumns; - - int mainPanelXOffset; - int mainPanelYOffset; - int mainPanelButtonsCount; - PanelButton *mainPanelButtons; - - int converseMaxTextWidth; - int converseTextHeight; - int converseTextLines; - int converseUpButtonIndex; - int converseDownButtonIndex; - - int conversePanelXOffset; - int conversePanelYOffset; - int conversePanelButtonsCount; - PanelButton *conversePanelButtons; - - int optionSaveFilePanelIndex; - int optionSaveFileSliderIndex; - uint32 optionSaveFileVisible; - - int optionPanelXOffset; - int optionPanelYOffset; - int optionPanelButtonsCount; - PanelButton *optionPanelButtons; - - int quitPanelXOffset; - int quitPanelYOffset; - int quitPanelWidth; - int quitPanelHeight; - int quitPanelButtonsCount; - PanelButton *quitPanelButtons; - - int loadPanelXOffset; - int loadPanelYOffset; - int loadPanelWidth; - int loadPanelHeight; - int loadPanelButtonsCount; - PanelButton *loadPanelButtons; - - int saveEditIndex; - int savePanelXOffset; - int savePanelYOffset; - int savePanelWidth; - int savePanelHeight; - int savePanelButtonsCount; - PanelButton *savePanelButtons; - - int protectEditIndex; - int protectPanelXOffset; - int protectPanelYOffset; - int protectPanelWidth; - int protectPanelHeight; - int protectPanelButtonsCount; - PanelButton *protectPanelButtons; -}; - -struct GameSoundInfo { - GameSoundTypes resourceType; - long frequency; - int sampleBits; - bool stereo; - bool isBigEndian; - bool isSigned; -}; - -struct GamePatchDescription { - const char *fileName; - uint16 fileType; - uint32 resourceId; - const GameSoundInfo *soundInfo; -}; - -struct SAGAGameDescription; - -#define FILE_MD5_BYTES 5000 diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 8311308018..74cae1f4cf 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -45,7 +45,7 @@ #include "saga/rscfile.h" #include "saga/sagaresnames.h" -#include "graphics/ilbm.h" +#include "graphics/iff.h" #include "common/util.h" namespace Saga { @@ -437,7 +437,7 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy _vm->_interface->setMode(kPanelSceneSubstitute); if (file.open(sceneSubstitutes[i].image)) { - Graphics::decodeILBM(file, bbmBuffer, pal); + Graphics::decodePBM(file, bbmBuffer, pal); colors = pal; rect.setWidth(bbmBuffer.w); rect.setHeight(bbmBuffer.h); @@ -502,28 +502,6 @@ void Scene::getBGInfo(BGInfo &bgInfo) { bgInfo.bounds.setHeight(_bg.h); } -int Scene::getBGMaskType(const Point &testPoint) { - uint offset; - if (!_bgMask.loaded) { - return 0; - } - offset = testPoint.x + testPoint.y * _bgMask.w; - if (offset >= _bgMask.buf_len) { - error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, (int)_bgMask.buf_len); - } - - return (_bgMask.buf[offset] >> 4) & 0x0f; -} - -bool Scene::validBGMaskPoint(const Point &testPoint) { - if (!_bgMask.loaded) { - error("Scene::validBGMaskPoint _bgMask not loaded"); - } - - return !((testPoint.x < 0) || (testPoint.x >= _bgMask.w) || - (testPoint.y < 0) || (testPoint.y >= _bgMask.h)); -} - bool Scene::canWalk(const Point &testPoint) { int maskType; @@ -571,20 +549,6 @@ void Scene::getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &buffer bufferLength = _bgMask.buf_len; } -void Scene::setDoorState(int doorNumber, int doorState) { - if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) - error("Scene::setDoorState wrong doorNumber"); - - _sceneDoors[doorNumber] = doorState; -} - -int Scene::getDoorState(int doorNumber) { - if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) - error("Scene::getDoorState wrong doorNumber"); - - return _sceneDoors[doorNumber]; -} - void Scene::initDoorsState() { memcpy(_sceneDoors, initSceneDoors, sizeof (_sceneDoors) ); } @@ -594,7 +558,14 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { Event event; Event *q_event; static PalEntry current_pal[PAL_ENTRIES]; - + + // Change the cursor to an hourglass in IHNM + event.type = kEvTOneshot; + event.code = kCursorEvent; + event.op = kEventSetBusyCursor; + event.time = 0; + _vm->_events->queue(&event); + if ((_vm->getGameType() == GType_IHNM) && (loadSceneParams->chapter != NO_CHAPTER_CHANGE)) { if (loadSceneParams->loadFlag != kLoadBySceneNumber) { error("loadScene wrong usage"); @@ -680,7 +651,7 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { _vm->_resource->loadResource(_sceneContext, _resourceList[i].resourceId, _resourceList[i].buffer, _resourceList[i].size); - + if (_resourceList[i].size >= 6) { if (!memcmp(_resourceList[i].buffer, "DUMMY!", 6)) { _resourceList[i].invalid = true; @@ -874,8 +845,6 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { loadSceneParams->sceneProc(SCENE_BEGIN, this); } - - // We probably don't want "followers" to go into scene -1 , 0. At the very // least we don't want garbage to be drawn that early in the ITE intro. if (_sceneNumber > 0 && _sceneNumber != ITE_SCENE_PUZZLE) @@ -892,12 +861,19 @@ void Scene::loadScene(LoadSceneParams *loadSceneParams) { event.time = 0; _vm->_events->queue(&event); } + + // Change the cursor back to a crosshair in IHNM + event.type = kEvTOneshot; + event.code = kCursorEvent; + event.op = kEventSetNormalCursor; + event.time = 0; + _vm->_events->queue(&event); } void Scene::loadSceneDescriptor(uint32 resourceId) { byte *sceneDescriptorData; size_t sceneDescriptorDataLength; - + memset(&_sceneDescription, 0, sizeof(_sceneDescription)); if (resourceId == 0) { @@ -970,7 +946,7 @@ void Scene::processSceneResources() { SAGAResourceTypes resType; getResourceTypes(types, typesCount); - + // Process the scene resource list for (i = 0; i < _resourceListCount; i++) { if (_resourceList[i].invalid) { diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 7f99140d10..ce76bde4a2 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -34,6 +34,8 @@ namespace Saga { +//#define SCENE_DEBUG // for scene debugging + #define SCENE_DOORS_MAX 16 #define NO_CHAPTER_CHANGE -2 @@ -233,13 +235,55 @@ class Scene { void getBGMaskInfo(int &width, int &height, byte *&buffer, size_t &bufferLength); int isBGMaskPresent() { return _bgMask.loaded; } - int getBGMaskType(const Point &testPoint); - bool validBGMaskPoint(const Point &testPoint); + + int getBGMaskType(const Point &testPoint) { + uint offset; + if (!_bgMask.loaded) { + return 0; + } + offset = testPoint.x + testPoint.y * _bgMask.w; + + #ifdef SCENE_DEBUG + if (offset >= _bgMask.buf_len) { + error("Scene::getBGMaskType offset 0x%X exceed bufferLength 0x%X", offset, (int)_bgMask.buf_len); + } + #endif + + return (_bgMask.buf[offset] >> 4) & 0x0f; + } + + bool validBGMaskPoint(const Point &testPoint) { + #ifdef SCENE_DEBUG + if (!_bgMask.loaded) { + error("Scene::validBGMaskPoint _bgMask not loaded"); + } + #endif + + return !((testPoint.x < 0) || (testPoint.x >= _bgMask.w) || + (testPoint.y < 0) || (testPoint.y >= _bgMask.h)); + } + bool canWalk(const Point &testPoint); bool offscreenPath(Point &testPoint); - void setDoorState(int doorNumber, int doorState); - int getDoorState(int doorNumber); + void setDoorState(int doorNumber, int doorState) { + #ifdef SCENE_DEBUG + if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) + error("Scene::setDoorState wrong doorNumber"); + #endif + + _sceneDoors[doorNumber] = doorState; + } + + int getDoorState(int doorNumber) { + #ifdef SCENE_DEBUG + if ((doorNumber < 0) || (doorNumber >= SCENE_DOORS_MAX)) + error("Scene::getDoorState wrong doorNumber"); + #endif + + return _sceneDoors[doorNumber]; + } + void initDoorsState(); void getBGInfo(BGInfo &bgInfo); @@ -257,9 +301,11 @@ class Scene { bool isSceneLoaded() const { return _sceneLoaded; } int getSceneResourceId(int sceneNumber) { + #ifdef SCENE_DEBUG if ((sceneNumber < 0) || (sceneNumber >= _sceneCount)) { error("getSceneResourceId: wrong sceneNumber %i", sceneNumber); } + #endif return _sceneLUT[sceneNumber]; } int currentSceneNumber() const { return _sceneNumber; } @@ -278,9 +324,9 @@ class Scene { int getHeight() const { if (_vm->_interface->getMode() == kPanelChapterSelection) - return _vm->_gameDisplayInfo.logicalHeight; + return _vm->getDisplayInfo().logicalHeight; else - return _vm->_gameDisplayInfo.sceneHeight; + return _vm->getDisplayInfo().sceneHeight; } private: diff --git a/engines/saga/script.cpp b/engines/saga/script.cpp index 7c203605ee..8a1e61cd46 100644 --- a/engines/saga/script.cpp +++ b/engines/saga/script.cpp @@ -479,18 +479,21 @@ void Script::doVerb() { if (scriptEntrypointNumber > 0) { - event.type = kEvTOneshot; - event.code = kScriptEvent; - event.op = kEventExecNonBlocking; - event.time = 0; - event.param = scriptModuleNumber; - event.param2 = scriptEntrypointNumber; - event.param3 = _pendingVerb; // Action - event.param4 = _pendingObject[0]; // Object - event.param5 = _pendingObject[1]; // With Object - event.param6 = (objectType == kGameObjectActor) ? _pendingObject[0] : ID_PROTAG; // Actor - - _vm->_events->queue(&event); + // WORKAROUND: Fixes bug #1690045 "ITE: Item description missing / ScummVM crash" + if (!(_vm->_scene->currentSceneNumber() == 278 && (_pendingObject[0] == 16419 || _pendingObject[1] == 16419) && _vm->getGameType() == GType_ITE)) { + event.type = kEvTOneshot; + event.code = kScriptEvent; + event.op = kEventExecNonBlocking; + event.time = 0; + event.param = scriptModuleNumber; + event.param2 = scriptEntrypointNumber; + event.param3 = _pendingVerb; // Action + event.param4 = _pendingObject[0]; // Object + event.param5 = _pendingObject[1]; // With Object + event.param6 = (objectType == kGameObjectActor) ? _pendingObject[0] : ID_PROTAG; // Actor + + _vm->_events->queue(&event); + } } else { _vm->getExcuseInfo(_pendingVerb, excuseText, excuseSampleResourceId); |
