Merge branch 'master' into osystem-palette

Conflicts:
	backends/platform/wii/osystem_gfx.cpp
This commit is contained in:
Johannes Schickel 2011-02-15 23:40:06 +01:00
commit a02454644a
62 changed files with 1439 additions and 1296 deletions

1
.gitignore vendored
View file

@ -131,6 +131,7 @@ Thumbs.db
*.opensdf *.opensdf
obj/ obj/
_ReSharper*/ _ReSharper*/
ipch/
[Tt]est[Rr]esult* [Tt]est[Rr]esult*
*.vcproj *.vcproj
*.sln *.sln

View file

@ -331,14 +331,15 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) {
gfx_tex_flush_palette(&_texGame); gfx_tex_flush_palette(&_texGame);
for (uint i = 0; i < num; ++i, s += 3) {
d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]);
}
if (_cursorPaletteDisabled) { if (_cursorPaletteDisabled) {
assert(_texMouse.palette); assert(_texMouse.palette);
s = colors; memcpy((u8 *)_texMouse.palette + start * 2,
d = _texMouse.palette; (u8 *)_cursorPalette + start * 2, num * 2);
for (uint i = 0; i < num; ++i, s += 3)
d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]);
_cursorPaletteDirty = true; _cursorPaletteDirty = true;
} }

View file

@ -599,17 +599,12 @@ void Screen::loadPalette(Common::ReadStream &in) {
} }
/** /**
* Free main and current palettes * Free fonts, main and current palettes
*/ */
void Screen::freePalette() { void Screen::freeScreen() {
free(_curPalette); free(_curPalette);
free(_mainPalette); free(_mainPalette);
}
/**
* Free fonts
*/
void Screen::freeFonts() {
for (int i = 0; i < kNumFonts; i++) { for (int i = 0; i < kNumFonts; i++) {
if (_arrayFont[i]) if (_arrayFont[i])
free(_arrayFont[i]); free(_arrayFont[i]);
@ -621,11 +616,7 @@ void Screen::selectInventoryObjId(const int16 objId) {
_vm->_inventory->setInventoryObjId(objId); // Select new object _vm->_inventory->setInventoryObjId(objId); // Select new object
// Find index of icon // Find index of icon
int16 iconId = 0; // Find index of dragged icon int16 iconId = _vm->_inventory->findIconId(objId);
for (; iconId < _vm->_maxInvent; iconId++) {
if (objId == _vm->_invent[iconId])
break;
}
// Compute source coordinates in dib_u // Compute source coordinates in dib_u
int16 ux = (iconId + kArrowNumb) * kInvDx % kXPix; int16 ux = (iconId + kArrowNumb) * kInvDx % kXPix;

View file

@ -65,8 +65,7 @@ public:
void drawRectangle(const bool filledFl, const int16 x1, const int16 y1, const int16 x2, const int16 y2, const int color); void drawRectangle(const bool filledFl, const int16 x1, const int16 y1, const int16 x2, const int16 y2, const int color);
void drawShape(const int x, const int y, const int color1, const int color2); void drawShape(const int x, const int y, const int color1, const int color2);
void drawStatusText(); void drawStatusText();
void freeFonts(); void freeScreen();
void freePalette();
void hideCursor(); void hideCursor();
void initDisplay(); void initDisplay();
void initNewScreenDisplay(); void initNewScreenDisplay();

View file

@ -369,18 +369,7 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) {
for (int i = 0; i < _vm->_numScreens; i++) for (int i = 0; i < _vm->_numScreens; i++)
out->writeByte(_vm->_screenStates[i]); out->writeByte(_vm->_screenStates[i]);
// Save points table _vm->_scheduler->saveSchedulerData(out);
for (int i = 0; i < _vm->_numBonuses; i++) {
out->writeByte(_vm->_points[i].score);
out->writeByte((_vm->_points[i].scoredFl) ? 1 : 0);
}
// Now save current time and all current events in event queue
_vm->_scheduler->saveEvents(out);
// Now save current actions
_vm->_scheduler->saveActions(out);
// Save palette table // Save palette table
_vm->_screen->savePal(out); _vm->_screen->savePal(out);
@ -475,19 +464,7 @@ bool FileManager::restoreGame(const int16 slot) {
for (int i = 0; i < _vm->_numScreens; i++) for (int i = 0; i < _vm->_numScreens; i++)
_vm->_screenStates[i] = in->readByte(); _vm->_screenStates[i] = in->readByte();
// Restore points table _vm->_scheduler->restoreSchedulerData(in);
for (int i = 0; i < _vm->_numBonuses; i++) {
_vm->_points[i].score = in->readByte();
_vm->_points[i].scoredFl = (in->readByte() == 1);
}
_vm->_object->restoreAllSeq();
// Now restore time of the save and the event queue
_vm->_scheduler->restoreEvents(in);
// Now restore actions
_vm->_scheduler->restoreActions(in);
// Restore palette and change it if necessary // Restore palette and change it if necessary
_vm->_screen->restorePal(in); _vm->_screen->restorePal(in);

View file

@ -54,10 +54,8 @@ maze_t _maze; // Default to not in maze
hugo_boot_t _boot; // Boot info structure file hugo_boot_t _boot; // Boot info structure file
HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd), HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd),
_arrayReqs(0), _invent(0), _uses(0), _catchallList(0), _backgroundObjects(0), _points(0), _cmdList(0), _hero(0), _heroImage(0), _defltTunes(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0),
_screenActs(0), _hero(0), _heroImage(0), _defltTunes(0), _introX(0), _introY(0), _maxInvent(0), _numBonuses(0), _screenStates(0), _score(0), _maxscore(0), _lastTime(0), _curTime(0)
_numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _score(0), _maxscore(0),
_backgroundObjectsSize(0), _screenActsSize(0), _usesSize(0), _lastTime(0), _curTime(0)
{ {
_system = syst; _system = syst;
DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level"); DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level");
@ -76,61 +74,22 @@ HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(sy
} }
HugoEngine::~HugoEngine() { HugoEngine::~HugoEngine() {
shutdown(); _file->closeDatabaseFiles();
_screen->freePalette();
_text->freeAllTexts();
free(_introX);
free(_introY);
if (_arrayReqs) {
for (int i = 0; _arrayReqs[i] != 0; i++)
free(_arrayReqs[i]);
free(_arrayReqs);
}
_intro->freeIntroData();
_inventory->freeInvent();
_mouse->freeHotspots(); _mouse->freeHotspots();
free(_invent); _object->freeObjects();
_parser->freeParser();
if (_uses) { _scheduler->freeScheduler();
for (int i = 0; i < _usesSize; i++) _screen->freeScreen();
free(_uses[i].targets); _text->freeAllTexts();
free(_uses);
}
free(_catchallList);
if (_backgroundObjects) {
for (int i = 0; i < _backgroundObjectsSize; i++)
free(_backgroundObjects[i]);
free(_backgroundObjects);
}
free(_points);
if (_cmdList) {
for (int i = 0; i < _cmdListSize; i++)
free(_cmdList[i]);
free(_cmdList);
}
if (_screenActs) {
for (int i = 0; i < _screenActsSize; i++)
free(_screenActs[i]);
free(_screenActs);
}
_object->freeObjectArr();
_scheduler->freeActListArr();
free(_defltTunes); free(_defltTunes);
free(_screenStates); free(_screenStates);
_screen->freeFonts();
delete _topMenu; delete _topMenu;
delete _object; delete _object;
delete _sound; delete _sound;
delete _route; delete _route;
@ -236,11 +195,12 @@ Common::Error HugoEngine::run() {
_screen->setCursorPal(); _screen->setCursorPal();
_screen->resetInventoryObjId(); _screen->resetInventoryObjId();
_scheduler->initCypher();
initStatus(); // Initialize game status initStatus(); // Initialize game status
initConfig(); // Initialize user's config initConfig(); // Initialize user's config
initialize(); initialize();
resetConfig(); // Reset user's config resetConfig(); // Reset user's config
initMachine(); initMachine();
// Start the state machine // Start the state machine
@ -388,207 +348,23 @@ bool HugoEngine::loadHugoDat() {
} }
_numVariant = in.readUint16BE(); _numVariant = in.readUint16BE();
_screen->loadPalette(in); _screen->loadPalette(in);
_text->loadAllTexts(in); _text->loadAllTexts(in);
_intro->loadIntroData(in);
// Read x_intro and y_intro _parser->loadArrayReqs(in);
for (int varnt = 0; varnt < _numVariant; varnt++) {
int numRows = in.readUint16BE();
if (varnt == _gameVariant) {
_introXSize = numRows;
_introX = (byte *)malloc(sizeof(byte) * _introXSize);
_introY = (byte *)malloc(sizeof(byte) * _introXSize);
for (int i = 0; i < _introXSize; i++) {
_introX[i] = in.readByte();
_introY[i] = in.readByte();
}
} else {
for (int i = 0; i < numRows; i++) {
in.readByte();
in.readByte();
}
}
}
// Read _arrayReqs
_arrayReqs = loadLongArray(in);
_mouse->loadHotspots(in); _mouse->loadHotspots(in);
_inventory->loadInvent(in);
int numElem, numSubElem; _object->loadObjectUses(in);
//Read _invent _parser->loadCatchallList(in);
for (int varnt = 0; varnt < _numVariant; varnt++) { _parser->loadBackgroundObjects(in);
numElem = in.readUint16BE(); _scheduler->loadPoints(in);
if (varnt == _gameVariant) { _parser->loadCmdList(in);
_maxInvent = numElem; _scheduler->loadScreenAct(in);
_invent = (int16 *)malloc(sizeof(int16) * numElem);
for (int i = 0; i < numElem; i++)
_invent[i] = in.readSint16BE();
} else {
for (int i = 0; i < numElem; i++)
in.readSint16BE();
}
}
//Read _uses
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
uses_t *wrkUses = (uses_t *)malloc(sizeof(uses_t) * numElem);
for (int i = 0; i < numElem; i++) {
wrkUses[i].objId = in.readSint16BE();
wrkUses[i].dataIndex = in.readUint16BE();
numSubElem = in.readUint16BE();
wrkUses[i].targets = (target_t *)malloc(sizeof(target_t) * numSubElem);
for (int j = 0; j < numSubElem; j++) {
wrkUses[i].targets[j].nounIndex = in.readUint16BE();
wrkUses[i].targets[j].verbIndex = in.readUint16BE();
}
}
if (varnt == _gameVariant) {
_usesSize = numElem;
_uses = wrkUses;
} else {
for (int i = 0; i < numElem; i++)
free(wrkUses[i].targets);
free(wrkUses);
}
}
//Read _catchallList
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
background_t *wrkCatchallList = (background_t *)malloc(sizeof(background_t) * numElem);
for (int i = 0; i < numElem; i++) {
wrkCatchallList[i].verbIndex = in.readUint16BE();
wrkCatchallList[i].nounIndex = in.readUint16BE();
wrkCatchallList[i].commentIndex = in.readSint16BE();
wrkCatchallList[i].matchFl = (in.readByte() != 0);
wrkCatchallList[i].roomState = in.readByte();
wrkCatchallList[i].bonusIndex = in.readByte();
}
if (varnt == _gameVariant)
_catchallList = wrkCatchallList;
else
free(wrkCatchallList);
}
// Read _background_objects
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
background_t **wrkBackgroundObjects = (background_t **)malloc(sizeof(background_t *) * numElem);
for (int i = 0; i < numElem; i++) {
numSubElem = in.readUint16BE();
wrkBackgroundObjects[i] = (background_t *)malloc(sizeof(background_t) * numSubElem);
for (int j = 0; j < numSubElem; j++) {
wrkBackgroundObjects[i][j].verbIndex = in.readUint16BE();
wrkBackgroundObjects[i][j].nounIndex = in.readUint16BE();
wrkBackgroundObjects[i][j].commentIndex = in.readSint16BE();
wrkBackgroundObjects[i][j].matchFl = (in.readByte() != 0);
wrkBackgroundObjects[i][j].roomState = in.readByte();
wrkBackgroundObjects[i][j].bonusIndex = in.readByte();
}
}
if (varnt == _gameVariant) {
_backgroundObjectsSize = numElem;
_backgroundObjects = wrkBackgroundObjects;
} else {
for (int i = 0; i < numElem; i++)
free(wrkBackgroundObjects[i]);
free(wrkBackgroundObjects);
}
}
// Read _points
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
if (varnt == _gameVariant) {
_numBonuses = numElem;
_points = (point_t *)malloc(sizeof(point_t) * _numBonuses);
for (int i = 0; i < _numBonuses; i++) {
_points[i].score = in.readByte();
_points[i].scoredFl = false;
}
} else {
for (int i = 0; i < numElem; i++)
in.readByte();
}
}
// Read _cmdList
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
if (varnt == _gameVariant) {
_cmdListSize = numElem;
_cmdList = (cmd **)malloc(sizeof(cmd *) * _cmdListSize);
for (int i = 0; i < _cmdListSize; i++) {
numSubElem = in.readUint16BE();
_cmdList[i] = (cmd *)malloc(sizeof(cmd) * numSubElem);
for (int j = 0; j < numSubElem; j++) {
_cmdList[i][j].verbIndex = in.readUint16BE();
_cmdList[i][j].reqIndex = in.readUint16BE();
_cmdList[i][j].textDataNoCarryIndex = in.readUint16BE();
_cmdList[i][j].reqState = in.readByte();
_cmdList[i][j].newState = in.readByte();
_cmdList[i][j].textDataWrongIndex = in.readUint16BE();
_cmdList[i][j].textDataDoneIndex = in.readUint16BE();
_cmdList[i][j].actIndex = in.readUint16BE();
}
}
} else {
for (int i = 0; i < numElem; i++) {
numSubElem = in.readUint16BE();
for (int j = 0; j < numSubElem; j++) {
in.readUint16BE();
in.readUint16BE();
in.readUint16BE();
in.readByte();
in.readByte();
in.readUint16BE();
in.readUint16BE();
in.readUint16BE();
}
}
}
}
// Read _screenActs
for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE();
uint16 **wrkScreenActs = (uint16 **)malloc(sizeof(uint16 *) * numElem);
for (int i = 0; i < numElem; i++) {
numSubElem = in.readUint16BE();
if (numSubElem == 0) {
wrkScreenActs[i] = 0;
} else {
wrkScreenActs[i] = (uint16 *)malloc(sizeof(uint16) * numSubElem);
for (int j = 0; j < numSubElem; j++)
wrkScreenActs[i][j] = in.readUint16BE();
}
}
if (varnt == _gameVariant) {
_screenActsSize = numElem;
_screenActs = wrkScreenActs;
} else {
for (int i = 0; i < numElem; i++)
free(wrkScreenActs[i]);
free(wrkScreenActs);
}
}
_object->loadObjectArr(in); _object->loadObjectArr(in);
_hero = &_object->_objects[kHeroIndex]; // This always points to hero _hero = &_object->_objects[kHeroIndex]; // This always points to hero
_screen_p = &(_object->_objects[kHeroIndex].screenIndex); // Current screen is hero's _screen_p = &(_object->_objects[kHeroIndex].screenIndex); // Current screen is hero's
_heroImage = kHeroIndex; // Current in use hero image _heroImage = kHeroIndex; // Current in use hero image
_scheduler->loadActListArr(in); _scheduler->loadActListArr(in);
for (int varnt = 0; varnt < _numVariant; varnt++) { for (int varnt = 0; varnt < _numVariant; varnt++) {
@ -603,6 +379,8 @@ bool HugoEngine::loadHugoDat() {
} }
} }
int numElem;
//Read _defltTunes //Read _defltTunes
for (int varnt = 0; varnt < _numVariant; varnt++) { for (int varnt = 0; varnt < _numVariant; varnt++) {
numElem = in.readUint16BE(); numElem = in.readUint16BE();
@ -791,16 +569,6 @@ void HugoEngine::initialize() {
} }
} }
/**
* Restore all resources before termination
*/
void HugoEngine::shutdown() {
debugC(1, kDebugEngine, "shutdown");
_file->closeDatabaseFiles();
_object->freeObjects();
}
/** /**
* Read scenery, overlay files for given screen number * Read scenery, overlay files for given screen number
*/ */
@ -819,37 +587,6 @@ void HugoEngine::readScreenFiles(const int screenNum) {
_object->clearScreenBoundary(50, 311, 152); _object->clearScreenBoundary(50, 311, 152);
} }
/**
* Search background command list for this screen for supplied object.
* Return first associated verb (not "look") or 0 if none found.
*/
const char *HugoEngine::useBG(const char *name) {
debugC(1, kDebugEngine, "useBG(%s)", name);
objectList_t p = _backgroundObjects[*_screen_p];
for (int i = 0; p[i].verbIndex != 0; i++) {
if ((name == _text->getNoun(p[i].nounIndex, 0) &&
p[i].verbIndex != _look) &&
((p[i].roomState == kStateDontCare) || (p[i].roomState == _screenStates[*_screen_p])))
return _text->getVerb(p[i].verbIndex, 0);
}
return 0;
}
/**
* Add action lists for this screen to event queue
*/
void HugoEngine::screenActions(const int screenNum) {
debugC(1, kDebugEngine, "screenActions(%d)", screenNum);
uint16 *screenAct = _screenActs[screenNum];
if (screenAct) {
for (int i = 0; screenAct[i]; i++)
_scheduler->insertActionList(screenAct[i]);
}
}
/** /**
* Set the new screen number into the hero object and any carried objects * Set the new screen number into the hero object and any carried objects
*/ */
@ -866,10 +603,7 @@ void HugoEngine::setNewScreen(const int screenNum) {
void HugoEngine::calcMaxScore() { void HugoEngine::calcMaxScore() {
debugC(1, kDebugEngine, "calcMaxScore"); debugC(1, kDebugEngine, "calcMaxScore");
_maxscore = _object->calcMaxScore(); _maxscore = _object->calcMaxScore() + _scheduler->calcMaxPoints();
for (int i = 0; i < _numBonuses; i++)
_maxscore += _points[i].score;
} }
/** /**

View file

@ -233,8 +233,6 @@ public:
byte _numVariant; byte _numVariant;
byte _gameVariant; byte _gameVariant;
byte _maxInvent;
byte _numBonuses;
int8 _soundSilence; int8 _soundSilence;
int8 _soundTest; int8 _soundTest;
int8 _tunesNbr; int8 _tunesNbr;
@ -245,23 +243,9 @@ public:
byte *_screen_p; byte *_screen_p;
byte _heroImage; byte _heroImage;
byte *_introX;
byte *_introY;
byte *_screenStates; byte *_screenStates;
command_t _line; // Line of user text input command_t _line; // Line of user text input
config_t _config; // User's config config_t _config; // User's config
uint16 **_arrayReqs;
int16 *_invent;
uses_t *_uses;
uint16 _usesSize;
background_t *_catchallList;
background_t **_backgroundObjects;
uint16 _backgroundObjectsSize;
point_t *_points;
cmd **_cmdList;
uint16 _cmdListSize;
uint16 **_screenActs;
uint16 _screenActsSize;
int16 *_defltTunes; int16 *_defltTunes;
uint16 _look; uint16 _look;
uint16 _take; uint16 _take;
@ -295,8 +279,6 @@ public:
virtual bool canSaveGameStateCurrently(); virtual bool canSaveGameStateCurrently();
bool loadHugoDat(); bool loadHugoDat();
const char *useBG(const char *name);
int8 getTPS() const; int8 getTPS() const;
void initGame(const HugoGameDescription *gd); void initGame(const HugoGameDescription *gd);
@ -304,7 +286,6 @@ public:
void endGame(); void endGame();
void initStatus(); void initStatus();
void readScreenFiles(const int screen); void readScreenFiles(const int screen);
void screenActions(const int screen);
void setNewScreen(const int screen); void setNewScreen(const int screen);
void shutdown(); void shutdown();
void syncSoundSettings(); void syncSoundSettings();
@ -327,9 +308,6 @@ public:
void setMaxScore(const int newScore) { void setMaxScore(const int newScore) {
_maxscore = newScore; _maxscore = newScore;
} }
byte getIntroSize() {
return _introXSize;
}
Common::Error saveGameState(int slot, const char *desc) { Common::Error saveGameState(int slot, const char *desc) {
return (_file->saveGame(slot, desc) ? Common::kWritingFailed : Common::kNoError); return (_file->saveGame(slot, desc) ? Common::kWritingFailed : Common::kNoError);
} }
@ -345,6 +323,7 @@ public:
const char *getCopyrightString() const { return "Copyright 1989-1997 David P Gray, All Rights Reserved."; } const char *getCopyrightString() const { return "Copyright 1989-1997 David P Gray, All Rights Reserved."; }
Common::String getSavegameFilename(int slot); Common::String getSavegameFilename(int slot);
uint16 **loadLongArray(Common::ReadStream &in);
FileManager *_file; FileManager *_file;
Scheduler *_scheduler; Scheduler *_scheduler;
@ -357,7 +336,6 @@ public:
IntroHandler *_intro; IntroHandler *_intro;
ObjectHandler *_object; ObjectHandler *_object;
TextHandler *_text; TextHandler *_text;
TopMenu *_topMenu; TopMenu *_topMenu;
protected: protected:
@ -368,7 +346,6 @@ protected:
private: private:
static const int kTurboTps = 16; // This many in turbo mode static const int kTurboTps = 16; // This many in turbo mode
byte _introXSize;
status_t _status; // Game status structure status_t _status; // Game status structure
uint32 _lastTime; uint32 _lastTime;
uint32 _curTime; uint32 _curTime;
@ -384,8 +361,6 @@ private:
int _score; // Holds current score int _score; // Holds current score
int _maxscore; // Holds maximum score int _maxscore; // Holds maximum score
uint16 **loadLongArray(Common::ReadStream &in);
void initPlaylist(bool playlist[kMaxTunes]); void initPlaylist(bool playlist[kMaxTunes]);
void initConfig(); void initConfig();
void initialize(); void initialize();

View file

@ -41,12 +41,41 @@
namespace Hugo { namespace Hugo {
IntroHandler::IntroHandler(HugoEngine *vm) : _vm(vm) { IntroHandler::IntroHandler(HugoEngine *vm) : _vm(vm), _introX(0), _introY(0) {
_introXSize = 0;
} }
IntroHandler::~IntroHandler() { IntroHandler::~IntroHandler() {
} }
/**
* Read _introX and _introY from hugo.dat
*/
void IntroHandler::loadIntroData(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
int numRows = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_introXSize = numRows;
_introX = (byte *)malloc(sizeof(byte) * _introXSize);
_introY = (byte *)malloc(sizeof(byte) * _introXSize);
for (int i = 0; i < _introXSize; i++) {
_introX[i] = in.readByte();
_introY[i] = in.readByte();
}
} else {
for (int i = 0; i < numRows; i++) {
in.readByte();
in.readByte();
}
}
}
}
void IntroHandler::freeIntroData() {
free(_introX);
free(_introY);
}
intro_v1d::intro_v1d(HugoEngine *vm) : IntroHandler(vm) { intro_v1d::intro_v1d(HugoEngine *vm) : IntroHandler(vm) {
} }
@ -68,7 +97,7 @@ void intro_v1d::introInit() {
} }
bool intro_v1d::introPlay() { bool intro_v1d::introPlay() {
byte introSize = _vm->getIntroSize(); byte introSize = getIntroSize();
if (_vm->getGameStatus().skipIntroFl) if (_vm->getGameStatus().skipIntroFl)
return true; return true;
@ -296,8 +325,8 @@ bool intro_v3d::introPlay() {
if (_vm->getGameStatus().skipIntroFl) if (_vm->getGameStatus().skipIntroFl)
return true; return true;
if (introTicks < _vm->getIntroSize()) { if (introTicks < getIntroSize()) {
font.drawString(&surf, ".", _vm->_introX[introTicks], _vm->_introY[introTicks] - kDibOffY, 320, _TBRIGHTWHITE); font.drawString(&surf, ".", _introX[introTicks], _introY[introTicks] - kDibOffY, 320, _TBRIGHTWHITE);
_vm->_screen->displayBackground(); _vm->_screen->displayBackground();
// Text boxes at various times // Text boxes at various times
@ -314,7 +343,7 @@ bool intro_v3d::introPlay() {
} }
} }
return (++introTicks >= _vm->getIntroSize()); return (++introTicks >= getIntroSize());
} }
intro_v1w::intro_v1w(HugoEngine *vm) : IntroHandler(vm) { intro_v1w::intro_v1w(HugoEngine *vm) : IntroHandler(vm) {
@ -387,9 +416,9 @@ bool intro_v3w::introPlay() {
if (_vm->getGameStatus().skipIntroFl) if (_vm->getGameStatus().skipIntroFl)
return true; return true;
if (introTicks < _vm->getIntroSize()) { if (introTicks < getIntroSize()) {
// Scale viewport x_intro,y_intro to screen (offsetting y) // Scale viewport x_intro,y_intro to screen (offsetting y)
_vm->_screen->writeStr(_vm->_introX[introTicks], _vm->_introY[introTicks] - kDibOffY, "x", _TBRIGHTWHITE); _vm->_screen->writeStr(_introX[introTicks], _introY[introTicks] - kDibOffY, "x", _TBRIGHTWHITE);
_vm->_screen->displayBackground(); _vm->_screen->displayBackground();
// Text boxes at various times // Text boxes at various times
@ -406,6 +435,6 @@ bool intro_v3w::introPlay() {
} }
} }
return (++introTicks >= _vm->getIntroSize()); return (++introTicks >= getIntroSize());
} }
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -54,8 +54,17 @@ public:
virtual void introInit() = 0; virtual void introInit() = 0;
virtual bool introPlay() = 0; virtual bool introPlay() = 0;
void freeIntroData();
void loadIntroData(Common::ReadStream &in);
byte getIntroSize() const { return _introXSize; }
protected: protected:
HugoEngine *_vm; HugoEngine *_vm;
byte *_introX;
byte *_introY;
byte _introXSize;
int16 introTicks; // Count calls to introPlay() int16 introTicks; // Count calls to introPlay()
}; };

View file

@ -46,11 +46,30 @@ namespace Hugo {
static const int kMaxDisp = (kXPix / kInvDx); // Max icons displayable static const int kMaxDisp = (kXPix / kInvDx); // Max icons displayable
InventoryHandler::InventoryHandler(HugoEngine *vm) : _vm(vm) { InventoryHandler::InventoryHandler(HugoEngine *vm) : _vm(vm), _invent(0) {
_firstIconId = 0; _firstIconId = 0;
_inventoryState = kInventoryOff; // Inventory icon bar state _inventoryState = kInventoryOff; // Inventory icon bar state
_inventoryHeight = 0; // Inventory icon bar pos _inventoryHeight = 0; // Inventory icon bar pos
_inventoryObjId = -1; // Inventory object selected (none) _inventoryObjId = -1; // Inventory object selected (none)
_maxInvent = 0;
}
/**
* Read _invent from Hugo.dat
*/
void InventoryHandler::loadInvent(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
int16 numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_maxInvent = numElem;
_invent = (int16 *)malloc(sizeof(int16) * numElem);
for (int i = 0; i < numElem; i++)
_invent[i] = in.readSint16BE();
} else {
for (int i = 0; i < numElem; i++)
in.readSint16BE();
}
}
} }
/** /**
@ -78,7 +97,7 @@ void InventoryHandler::constructInventory(const int16 imageTotNumb, int displayN
int16 displayed = 0; int16 displayed = 0;
int16 carried = 0; int16 carried = 0;
for (int16 i = 0; (i < imageTotNumb) && (displayed < displayNumb); i++) { for (int16 i = 0; (i < imageTotNumb) && (displayed < displayNumb); i++) {
if (_vm->_object->isCarried(_vm->_invent[i])) { if (_vm->_object->isCarried(_invent[i])) {
// Check still room to display and past first scroll index // Check still room to display and past first scroll index
if (displayed < displayNumb && carried >= firstObjId) { if (displayed < displayNumb && carried >= firstObjId) {
// Compute source coordinates in dib_u // Compute source coordinates in dib_u
@ -107,8 +126,8 @@ int16 InventoryHandler::processInventory(const invact_t action, ...) {
int16 imageNumb; // Total number of inventory items int16 imageNumb; // Total number of inventory items
int displayNumb; // Total number displayed/carried int displayNumb; // Total number displayed/carried
// Compute total number and number displayed, i.e. number carried // Compute total number and number displayed, i.e. number carried
for (imageNumb = 0, displayNumb = 0; imageNumb < _vm->_maxInvent && _vm->_invent[imageNumb] != -1; imageNumb++) { for (imageNumb = 0, displayNumb = 0; imageNumb < _maxInvent && _invent[imageNumb] != -1; imageNumb++) {
if (_vm->_object->isCarried(_vm->_invent[imageNumb])) if (_vm->_object->isCarried(_invent[imageNumb]))
displayNumb++; displayNumb++;
} }
@ -236,4 +255,18 @@ void InventoryHandler::runInventory() {
} }
} }
/**
* Find index of dragged icon
*/
int16 InventoryHandler::findIconId(int16 objId) {
int16 iconId = 0;
for (; iconId < _maxInvent; iconId++) {
if (objId == _invent[iconId])
break;
}
return iconId;
}
} // End of namespace Hugo } // End of namespace Hugo

View file

@ -45,9 +45,13 @@ public:
void setInventoryObjId(int16 objId) { _inventoryObjId = objId; } void setInventoryObjId(int16 objId) { _inventoryObjId = objId; }
void setInventoryState(istate_t state) { _inventoryState = state; } void setInventoryState(istate_t state) { _inventoryState = state; }
void freeInvent() { free(_invent); }
int16 getInventoryObjId() const { return _inventoryObjId; } int16 getInventoryObjId() const { return _inventoryObjId; }
istate_t getInventoryState() const { return _inventoryState; } istate_t getInventoryState() const { return _inventoryState; }
int16 findIconId(int16 objId);
void loadInvent(Common::ReadStream &in);
int16 processInventory(const invact_t action, ...); int16 processInventory(const invact_t action, ...);
void runInventory(); void runInventory();
@ -57,9 +61,11 @@ private:
static const int kStepDy = 8; // Pixels per step movement static const int kStepDy = 8; // Pixels per step movement
int16 _firstIconId; // Index of first icon to display int16 _firstIconId; // Index of first icon to display
int16 *_invent;
istate_t _inventoryState; // Inventory icon bar state istate_t _inventoryState; // Inventory icon bar state
int16 _inventoryHeight; // Inventory icon bar height int16 _inventoryHeight; // Inventory icon bar height
int16 _inventoryObjId; // Inventory object selected, or -1 int16 _inventoryObjId; // Inventory object selected, or -1
byte _maxInvent;
void constructInventory(const int16 imageTotNumb, int displayNumb, const bool scrollFl, int16 firstObjId); void constructInventory(const int16 imageTotNumb, int displayNumb, const bool scrollFl, int16 firstObjId);
}; };

View file

@ -48,9 +48,10 @@
namespace Hugo { namespace Hugo {
ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0) { ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0), _uses(0) {
_numObj = 0; _numObj = 0;
_objCount = 0; _objCount = 0;
_usesSize = 0;
memset(_objBound, '\0', sizeof(overlay_t)); memset(_objBound, '\0', sizeof(overlay_t));
memset(_boundary, '\0', sizeof(overlay_t)); memset(_boundary, '\0', sizeof(overlay_t));
memset(_overlay, '\0', sizeof(overlay_t)); memset(_overlay, '\0', sizeof(overlay_t));
@ -108,20 +109,20 @@ void ObjectHandler::useObject(int16 objId) {
if ((obj->genericCmd & TAKE) || obj->objValue) // Get collectible item if ((obj->genericCmd & TAKE) || obj->objValue) // Get collectible item
sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_take, 0), _vm->_text->getNoun(obj->nounIndex, 0)); sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_take, 0), _vm->_text->getNoun(obj->nounIndex, 0));
else if (obj->cmdIndex != 0) // Use non-collectible item if able else if (obj->cmdIndex != 0) // Use non-collectible item if able
sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_cmdList[obj->cmdIndex][0].verbIndex, 0), _vm->_text->getNoun(obj->nounIndex, 0)); sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(obj->cmdIndex), 0), _vm->_text->getNoun(obj->nounIndex, 0));
else if ((verb = _vm->useBG(_vm->_text->getNoun(obj->nounIndex, 0))) != 0) else if ((verb = _vm->_parser->useBG(_vm->_text->getNoun(obj->nounIndex, 0))) != 0)
sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->nounIndex, 0)); sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->nounIndex, 0));
else else
return; // Can't use object directly return; // Can't use object directly
} else { } else {
// Use status.objid on objid // Use status.objid on objid
// Default to first cmd verb // Default to first cmd verb
sprintf(_vm->_line, "%s %s %s", _vm->_text->getVerb(_vm->_cmdList[_objects[inventObjId].cmdIndex][0].verbIndex, 0), sprintf(_vm->_line, "%s %s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(_objects[inventObjId].cmdIndex), 0),
_vm->_text->getNoun(_objects[inventObjId].nounIndex, 0), _vm->_text->getNoun(_objects[inventObjId].nounIndex, 0),
_vm->_text->getNoun(obj->nounIndex, 0)); _vm->_text->getNoun(obj->nounIndex, 0));
// Check valid use of objects and override verb if necessary // Check valid use of objects and override verb if necessary
for (uses_t *use = _vm->_uses; use->objId != _numObj; use++) { for (uses_t *use = _uses; use->objId != _numObj; use++) {
if (inventObjId == use->objId) { if (inventObjId == use->objId) {
// Look for secondary object, if found use matching verb // Look for secondary object, if found use matching verb
bool foundFl = false; bool foundFl = false;
@ -212,19 +213,16 @@ void ObjectHandler::lookObject(object_t *obj) {
} }
/** /**
* Free all object images * Free all object images, uses and ObjArr (before exiting)
*/ */
void ObjectHandler::freeObjects() { void ObjectHandler::freeObjects() {
debugC(1, kDebugObject, "freeObjects"); debugC(1, kDebugObject, "freeObjects");
// Nothing to do if not allocated yet if (_vm->_hero != 0 && _vm->_hero->seqList[0].seqPtr != 0) {
if (_vm->_hero == 0 || _vm->_hero->seqList[0].seqPtr == 0)
return;
// Free all sequence lists and image data // Free all sequence lists and image data
for (int i = 0; i < _numObj; i++) { for (int16 i = 0; i < _numObj; i++) {
object_t *obj = &_objects[i]; object_t *obj = &_objects[i];
for (int j = 0; j < obj->seqNumb; j++) { for (int16 j = 0; j < obj->seqNumb; j++) {
seq_t *seq = obj->seqList[j].seqPtr; seq_t *seq = obj->seqList[j].seqPtr;
seq_t *next; seq_t *next;
if (seq == 0) // Failure during database load if (seq == 0) // Failure during database load
@ -248,6 +246,21 @@ void ObjectHandler::freeObjects() {
} }
} }
if (_uses) {
for (int16 i = 0; i < _usesSize; i++)
free(_uses[i].targets);
free(_uses);
}
for(int16 i = 0; i < _objCount; i++) {
free(_objects[i].stateDataIndex);
_objects[i].stateDataIndex = 0;
}
free(_objects);
_objects = 0;
}
/** /**
* Compare function for the quicksort. The sort is to order the objects in * Compare function for the quicksort. The sort is to order the objects in
* increasing vertical position, using y+y2 as the baseline * increasing vertical position, using y+y2 as the baseline
@ -356,15 +369,34 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {
} }
/** /**
* Free ObjectArr (before exiting) * Load _uses from Hugo.dat
*/ */
void ObjectHandler::freeObjectArr() { void ObjectHandler::loadObjectUses(Common::ReadStream &in) {
for(int16 i = 0; i < _objCount; i++) { //Read _uses
free(_objects[i].stateDataIndex); for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
_objects[i].stateDataIndex = 0; uint16 numElem = in.readUint16BE();
uses_t *wrkUses = (uses_t *)malloc(sizeof(uses_t) * numElem);
for (int i = 0; i < numElem; i++) {
wrkUses[i].objId = in.readSint16BE();
wrkUses[i].dataIndex = in.readUint16BE();
uint16 numSubElem = in.readUint16BE();
wrkUses[i].targets = (target_t *)malloc(sizeof(target_t) * numSubElem);
for (int j = 0; j < numSubElem; j++) {
wrkUses[i].targets[j].nounIndex = in.readUint16BE();
wrkUses[i].targets[j].verbIndex = in.readUint16BE();
}
}
if (varnt == _vm->_gameVariant) {
_usesSize = numElem;
_uses = wrkUses;
} else {
for (int i = 0; i < numElem; i++)
free(wrkUses[i].targets);
free(wrkUses);
}
} }
free(_objects);
_objects = 0;
} }
/** /**

View file

@ -74,7 +74,7 @@ public:
int16 findObject(uint16 x, uint16 y); int16 findObject(uint16 x, uint16 y);
void freeObjects(); void freeObjects();
void loadObjectArr(Common::ReadStream &in); void loadObjectArr(Common::ReadStream &in);
void freeObjectArr(); void loadObjectUses(Common::ReadStream &in);
void loadNumObj(Common::ReadStream &in); void loadNumObj(Common::ReadStream &in);
void lookObject(object_t *obj); void lookObject(object_t *obj);
void readObjectImages(); void readObjectImages();
@ -114,6 +114,8 @@ protected:
static const int kMaxObjNumb = 128; // Used in Update_images() static const int kMaxObjNumb = 128; // Used in Update_images()
uint16 _objCount; uint16 _objCount;
uses_t *_uses;
uint16 _usesSize;
void restoreSeq(object_t *obj); void restoreSeq(object_t *obj);

View file

@ -51,17 +51,161 @@
namespace Hugo { namespace Hugo {
Parser::Parser(HugoEngine *vm) : Parser::Parser(HugoEngine *vm) : _vm(vm), _putIndex(0), _getIndex(0), _arrayReqs(0), _catchallList(0), _backgroundObjects(0), _cmdList(0) {
_vm(vm), _putIndex(0), _getIndex(0), _checkDoubleF1Fl(false) {
_cmdLineIndex = 0; _cmdLineIndex = 0;
_cmdLineTick = 0; _cmdLineTick = 0;
_cmdLineCursor = '_'; _cmdLineCursor = '_';
_cmdLine[0] = '\0'; _cmdLine[0] = '\0';
_cmdListSize = 0;
_checkDoubleF1Fl = false;
_backgroundObjectsSize = 0;
} }
Parser::~Parser() { Parser::~Parser() {
} }
/**
* Read _cmdList from Hugo.dat
*/
void Parser::loadCmdList(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_cmdListSize = numElem;
_cmdList = (cmd **)malloc(sizeof(cmd *) * _cmdListSize);
for (int i = 0; i < _cmdListSize; i++) {
uint16 numSubElem = in.readUint16BE();
_cmdList[i] = (cmd *)malloc(sizeof(cmd) * numSubElem);
for (int j = 0; j < numSubElem; j++) {
_cmdList[i][j].verbIndex = in.readUint16BE();
_cmdList[i][j].reqIndex = in.readUint16BE();
_cmdList[i][j].textDataNoCarryIndex = in.readUint16BE();
_cmdList[i][j].reqState = in.readByte();
_cmdList[i][j].newState = in.readByte();
_cmdList[i][j].textDataWrongIndex = in.readUint16BE();
_cmdList[i][j].textDataDoneIndex = in.readUint16BE();
_cmdList[i][j].actIndex = in.readUint16BE();
}
}
} else {
for (int i = 0; i < numElem; i++) {
uint16 numSubElem = in.readUint16BE();
for (int j = 0; j < numSubElem; j++) {
in.readUint16BE();
in.readUint16BE();
in.readUint16BE();
in.readByte();
in.readByte();
in.readUint16BE();
in.readUint16BE();
in.readUint16BE();
}
}
}
}
}
/**
* Read _backgrounObjects from Hugo.dat
*/
void Parser::loadBackgroundObjects(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
background_t **wrkBackgroundObjects = (background_t **)malloc(sizeof(background_t *) * numElem);
for (int i = 0; i < numElem; i++) {
uint16 numSubElem = in.readUint16BE();
wrkBackgroundObjects[i] = (background_t *)malloc(sizeof(background_t) * numSubElem);
for (int j = 0; j < numSubElem; j++) {
wrkBackgroundObjects[i][j].verbIndex = in.readUint16BE();
wrkBackgroundObjects[i][j].nounIndex = in.readUint16BE();
wrkBackgroundObjects[i][j].commentIndex = in.readSint16BE();
wrkBackgroundObjects[i][j].matchFl = (in.readByte() != 0);
wrkBackgroundObjects[i][j].roomState = in.readByte();
wrkBackgroundObjects[i][j].bonusIndex = in.readByte();
}
}
if (varnt == _vm->_gameVariant) {
_backgroundObjectsSize = numElem;
_backgroundObjects = wrkBackgroundObjects;
} else {
for (int i = 0; i < numElem; i++)
free(wrkBackgroundObjects[i]);
free(wrkBackgroundObjects);
}
}
}
/**
* Read _catchallList from Hugo.dat
*/
void Parser::loadCatchallList(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
background_t *wrkCatchallList = (background_t *)malloc(sizeof(background_t) * numElem);
for (int i = 0; i < numElem; i++) {
wrkCatchallList[i].verbIndex = in.readUint16BE();
wrkCatchallList[i].nounIndex = in.readUint16BE();
wrkCatchallList[i].commentIndex = in.readSint16BE();
wrkCatchallList[i].matchFl = (in.readByte() != 0);
wrkCatchallList[i].roomState = in.readByte();
wrkCatchallList[i].bonusIndex = in.readByte();
}
if (varnt == _vm->_gameVariant)
_catchallList = wrkCatchallList;
else
free(wrkCatchallList);
}
}
void Parser::loadArrayReqs(Common::ReadStream &in) {
_arrayReqs = _vm->loadLongArray(in);
}
/**
* Search background command list for this screen for supplied object.
* Return first associated verb (not "look") or 0 if none found.
*/
const char *Parser::useBG(const char *name) {
debugC(1, kDebugEngine, "useBG(%s)", name);
objectList_t p = _backgroundObjects[*_vm->_screen_p];
for (int i = 0; p[i].verbIndex != 0; i++) {
if ((name == _vm->_text->getNoun(p[i].nounIndex, 0) &&
p[i].verbIndex != _vm->_look) &&
((p[i].roomState == kStateDontCare) || (p[i].roomState == _vm->_screenStates[*_vm->_screen_p])))
return _vm->_text->getVerb(p[i].verbIndex, 0);
}
return 0;
}
void Parser::freeParser() {
if (_arrayReqs) {
for (int i = 0; _arrayReqs[i] != 0; i++)
free(_arrayReqs[i]);
free(_arrayReqs);
}
free(_catchallList);
if (_backgroundObjects) {
for (int i = 0; i < _backgroundObjectsSize; i++)
free(_backgroundObjects[i]);
free(_backgroundObjects);
}
if (_cmdList) {
for (int i = 0; i < _cmdListSize; i++)
free(_cmdList[i]);
free(_cmdList);
}
}
void Parser::switchTurbo() { void Parser::switchTurbo() {
_vm->_config.turboFl = !_vm->_config.turboFl; _vm->_config.turboFl = !_vm->_config.turboFl;
} }

View file

@ -49,10 +49,18 @@ public:
bool isWordPresent(char **wordArr) const; bool isWordPresent(char **wordArr) const;
uint16 getCmdDefaultVerbIdx(const uint16 index) const { return _cmdList[index][0].verbIndex; }
void charHandler(); void charHandler();
void command(const char *format, ...); void command(const char *format, ...);
void freeParser();
void keyHandler(Common::Event event); void keyHandler(Common::Event event);
void loadArrayReqs(Common::ReadStream &in);
void loadBackgroundObjects(Common::ReadStream &in);
void loadCatchallList(Common::ReadStream &in);
void loadCmdList(Common::ReadStream &in);
void switchTurbo(); void switchTurbo();
const char *useBG(const char *name);
virtual void lineHandler() = 0; virtual void lineHandler() = 0;
virtual void showInventory() const = 0; virtual void showInventory() const = 0;
@ -64,6 +72,13 @@ protected:
uint32 _cmdLineTick; // For flashing cursor uint32 _cmdLineTick; // For flashing cursor
char _cmdLineCursor; char _cmdLineCursor;
command_t _cmdLine; // Build command line command_t _cmdLine; // Build command line
uint16 _backgroundObjectsSize;
uint16 _cmdListSize;
uint16 **_arrayReqs;
background_t **_backgroundObjects;
background_t *_catchallList;
cmd **_cmdList;
const char *findNoun() const; const char *findNoun() const;
const char *findVerb() const; const char *findVerb() const;

View file

@ -192,18 +192,18 @@ bool Parser_v1d::isObjectVerb_v1(const char *word, object_t *obj) {
return false; return false;
int i; int i;
for (i = 0; _vm->_cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd
if (!strcmp(word, _vm->_text->getVerb(_vm->_cmdList[cmdIndex][i].verbIndex, 0))) // Is this verb catered for? if (!strcmp(word, _vm->_text->getVerb(_cmdList[cmdIndex][i].verbIndex, 0))) // Is this verb catered for?
break; break;
} }
if (_vm->_cmdList[cmdIndex][i].verbIndex == 0) // No if (_cmdList[cmdIndex][i].verbIndex == 0) // No
return false; return false;
// Verb match found, check all required objects are being carried // Verb match found, check all required objects are being carried
cmd *cmnd = &_vm->_cmdList[cmdIndex][i]; // ptr to struct cmd cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd
if (cmnd->reqIndex) { // At least 1 thing in list if (cmnd->reqIndex) { // At least 1 thing in list
uint16 *reqs = _vm->_arrayReqs[cmnd->reqIndex]; // ptr to list of required objects uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) { if (!_vm->_object->isCarrying(reqs[i])) {
Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex)); Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex));
@ -413,16 +413,16 @@ void Parser_v1d::lineHandler() {
return; return;
} }
} }
if ((*farComment == '\0') && isBackgroundWord_v1(noun, verb, _vm->_backgroundObjects[*_vm->_screen_p])) if ((*farComment == '\0') && isBackgroundWord_v1(noun, verb, _backgroundObjects[*_vm->_screen_p]))
return; return;
} while (noun); } while (noun);
} }
noun = findNextNoun(noun); noun = findNextNoun(noun);
if (*farComment != '\0') // An object matched but not near enough if (*farComment != '\0') // An object matched but not near enough
Utils::Box(kBoxAny, "%s", farComment); Utils::Box(kBoxAny, "%s", farComment);
else if (!isCatchallVerb_v1(true, noun, verb, _vm->_catchallList) && else if (!isCatchallVerb_v1(true, noun, verb, _catchallList) &&
!isCatchallVerb_v1(false, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p]) && !isCatchallVerb_v1(false, noun, verb, _backgroundObjects[*_vm->_screen_p]) &&
!isCatchallVerb_v1(false, noun, verb, _vm->_catchallList)) !isCatchallVerb_v1(false, noun, verb, _catchallList))
Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh_1d)); Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh_1d));
} }

View file

@ -172,14 +172,14 @@ void Parser_v1w::lineHandler() {
} }
// No objects match command line, try background and catchall commands // No objects match command line, try background and catchall commands
if (isBackgroundWord_v3(_vm->_backgroundObjects[*_vm->_screen_p])) if (isBackgroundWord_v3(_backgroundObjects[*_vm->_screen_p]))
return; return;
if (isCatchallVerb_v3(_vm->_backgroundObjects[*_vm->_screen_p])) if (isCatchallVerb_v3(_backgroundObjects[*_vm->_screen_p]))
return; return;
if (isBackgroundWord_v3(_vm->_catchallList)) if (isBackgroundWord_v3(_catchallList))
return; return;
if (isCatchallVerb_v3(_vm->_catchallList)) if (isCatchallVerb_v3(_catchallList))
return; return;
// If a not-near comment was generated, print it // If a not-near comment was generated, print it

View file

@ -165,16 +165,16 @@ void Parser_v2d::lineHandler() {
return; return;
} }
} }
if ((*farComment != '\0') && isBackgroundWord_v1(noun, verb, _vm->_backgroundObjects[*_vm->_screen_p])) if ((*farComment != '\0') && isBackgroundWord_v1(noun, verb, _backgroundObjects[*_vm->_screen_p]))
return; return;
} while (noun); } while (noun);
} }
noun = findNextNoun(noun); noun = findNextNoun(noun);
if ( !isCatchallVerb_v1(true, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p]) if ( !isCatchallVerb_v1(true, noun, verb, _backgroundObjects[*_vm->_screen_p])
&& !isCatchallVerb_v1(true, noun, verb, _vm->_catchallList) && !isCatchallVerb_v1(true, noun, verb, _catchallList)
&& !isCatchallVerb_v1(false, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p]) && !isCatchallVerb_v1(false, noun, verb, _backgroundObjects[*_vm->_screen_p])
&& !isCatchallVerb_v1(false, noun, verb, _vm->_catchallList)) { && !isCatchallVerb_v1(false, noun, verb, _catchallList)) {
if (*farComment != '\0') { // An object matched but not near enough if (*farComment != '\0') { // An object matched but not near enough
Utils::Box(kBoxAny, "%s", farComment); Utils::Box(kBoxAny, "%s", farComment);
} else if (_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { } else if (_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) {

View file

@ -174,14 +174,14 @@ void Parser_v3d::lineHandler() {
} }
// No objects match command line, try background and catchall commands // No objects match command line, try background and catchall commands
if (isBackgroundWord_v3(_vm->_backgroundObjects[*_vm->_screen_p])) if (isBackgroundWord_v3(_backgroundObjects[*_vm->_screen_p]))
return; return;
if (isCatchallVerb_v3(_vm->_backgroundObjects[*_vm->_screen_p])) if (isCatchallVerb_v3(_backgroundObjects[*_vm->_screen_p]))
return; return;
if (isBackgroundWord_v3(_vm->_catchallList)) if (isBackgroundWord_v3(_catchallList))
return; return;
if (isCatchallVerb_v3(_vm->_catchallList)) if (isCatchallVerb_v3(_catchallList))
return; return;
// If a not-near comment was generated, print it // If a not-near comment was generated, print it
@ -219,23 +219,23 @@ bool Parser_v3d::isObjectVerb_v3(object_t *obj, char *comment) {
return false; return false;
int i; int i;
for (i = 0; _vm->_cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd
if (isWordPresent(_vm->_text->getVerbArray(_vm->_cmdList[cmdIndex][i].verbIndex))) // Was this verb used? if (isWordPresent(_vm->_text->getVerbArray(_cmdList[cmdIndex][i].verbIndex))) // Was this verb used?
break; break;
} }
if (_vm->_cmdList[cmdIndex][i].verbIndex == 0) // No verbs used. if (_cmdList[cmdIndex][i].verbIndex == 0) // No verbs used.
return false; return false;
// Verb match found. Check if object is Near // Verb match found. Check if object is Near
char *verb = *_vm->_text->getVerbArray(_vm->_cmdList[cmdIndex][i].verbIndex); char *verb = *_vm->_text->getVerbArray(_cmdList[cmdIndex][i].verbIndex);
if (!isNear_v3(obj, verb, comment)) if (!isNear_v3(obj, verb, comment))
return false; return false;
// Check all required objects are being carried // Check all required objects are being carried
cmd *cmnd = &_vm->_cmdList[cmdIndex][i]; // ptr to struct cmd cmd *cmnd = &_cmdList[cmdIndex][i]; // ptr to struct cmd
if (cmnd->reqIndex) { // At least 1 thing in list if (cmnd->reqIndex) { // At least 1 thing in list
uint16 *reqs = _vm->_arrayReqs[cmnd->reqIndex]; // ptr to list of required objects uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) { if (!_vm->_object->isCarrying(reqs[i])) {
Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex)); Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex));

View file

@ -48,13 +48,19 @@
namespace Hugo { namespace Hugo {
Scheduler::Scheduler(HugoEngine *vm) : _vm(vm), _actListArr(0), _curTick(0), _oldTime(0), _refreshTimeout(0) { Scheduler::Scheduler(HugoEngine *vm) : _vm(vm), _actListArr(0), _curTick(0), _oldTime(0), _refreshTimeout(0), _points(0), _screenActs(0) {
memset(_events, 0, sizeof(_events)); memset(_events, 0, sizeof(_events));
_numBonuses = 0;
_screenActsSize = 0;
} }
Scheduler::~Scheduler() { Scheduler::~Scheduler() {
} }
void Scheduler::initCypher() {
_cypher = getCypher();
}
/** /**
* Initialise the timer event queue * Initialise the timer event queue
*/ */
@ -142,9 +148,9 @@ uint32 Scheduler::getDosTicks(const bool updateFl) {
void Scheduler::processBonus(const int bonusIndex) { void Scheduler::processBonus(const int bonusIndex) {
debugC(1, kDebugSchedule, "processBonus(%d)", bonusIndex); debugC(1, kDebugSchedule, "processBonus(%d)", bonusIndex);
if (!_vm->_points[bonusIndex].scoredFl) { if (!_points[bonusIndex].scoredFl) {
_vm->adjustScore(_vm->_points[bonusIndex].score); _vm->adjustScore(_points[bonusIndex].score);
_vm->_points[bonusIndex].scoredFl = true; _points[bonusIndex].scoredFl = true;
} }
} }
@ -186,7 +192,7 @@ void Scheduler::newScreen(const int screenIndex) {
_vm->readScreenFiles(screenIndex); _vm->readScreenFiles(screenIndex);
// 4. Schedule action list for this screen // 4. Schedule action list for this screen
_vm->screenActions(screenIndex); _vm->_scheduler->screenActions(screenIndex);
// 5. Initialise prompt line and status line // 5. Initialise prompt line and status line
_vm->_screen->initNewScreenDisplay(); _vm->_screen->initNewScreenDisplay();
@ -244,6 +250,28 @@ void Scheduler::loadAlNewscrIndex(Common::ReadStream &in) {
} }
} }
/**
* Load Points from Hugo.dat
*/
void Scheduler::loadPoints(Common::ReadStream &in) {
debugC(6, kDebugSchedule, "loadPoints(&in)");
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
if (varnt == _vm->_gameVariant) {
_numBonuses = numElem;
_points = (point_t *)malloc(sizeof(point_t) * _numBonuses);
for (int i = 0; i < _numBonuses; i++) {
_points[i].score = in.readByte();
_points[i].scoredFl = false;
}
} else {
for (int i = 0; i < numElem; i++)
in.readByte();
}
}
}
/** /**
* Load actListArr from Hugo.dat * Load actListArr from Hugo.dat
*/ */
@ -816,9 +844,47 @@ void Scheduler::loadActListArr(Common::ReadStream &in) {
} }
} }
void Scheduler::freeActListArr() { /**
* Read _screenActs
*/
void Scheduler::loadScreenAct(Common::ReadStream &in) {
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
uint16 numElem = in.readUint16BE();
uint16 **wrkScreenActs = (uint16 **)malloc(sizeof(uint16 *) * numElem);
for (int i = 0; i < numElem; i++) {
uint16 numSubElem = in.readUint16BE();
if (numSubElem == 0) {
wrkScreenActs[i] = 0;
} else {
wrkScreenActs[i] = (uint16 *)malloc(sizeof(uint16) * numSubElem);
for (int j = 0; j < numSubElem; j++)
wrkScreenActs[i][j] = in.readUint16BE();
}
}
if (varnt == _vm->_gameVariant) {
_screenActsSize = numElem;
_screenActs = wrkScreenActs;
} else {
for (int i = 0; i < numElem; i++)
free(wrkScreenActs[i]);
free(wrkScreenActs);
}
}
}
void Scheduler::freeScheduler() {
debugC(6, kDebugSchedule, "freeActListArr()"); debugC(6, kDebugSchedule, "freeActListArr()");
free(_points);
if (_screenActs) {
for (int i = 0; i < _screenActsSize; i++)
free(_screenActs[i]);
free(_screenActs);
}
if (_actListArr) { if (_actListArr) {
for (int i = 0; i < _actListArrSize; i++) { for (int i = 0; i < _actListArrSize; i++) {
for (int j = 0; _actListArr[i][j].a0.actType != ANULL; j++) { for (int j = 0; _actListArr[i][j].a0.actType != ANULL; j++) {
@ -831,6 +897,19 @@ void Scheduler::freeActListArr() {
} }
} }
/**
* Add action lists for this screen to event queue
*/
void Scheduler::screenActions(const int screenNum) {
debugC(1, kDebugEngine, "screenActions(%d)", screenNum);
uint16 *screenAct = _screenActs[screenNum];
if (screenAct) {
for (int i = 0; screenAct[i]; i++)
insertActionList(screenAct[i]);
}
}
/** /**
* Maze mode is enabled. Check to see whether hero has crossed the maze * Maze mode is enabled. Check to see whether hero has crossed the maze
* bounding box, if so, go to the next room * bounding box, if so, go to the next room
@ -935,10 +1014,16 @@ void Scheduler::restoreActions(Common::ReadStream *f) {
} }
} }
int16 Scheduler::calcMaxPoints() const {
int16 tmpScore = 0;
for (int i = 0; i < _numBonuses; i++)
tmpScore += _points[i].score;
return tmpScore;
}
/* /*
* Save the action data in the file with handle f * Save the action data in the file with handle f
*/ */
void Scheduler::saveActions(Common::WriteStream* f) const { void Scheduler::saveActions(Common::WriteStream* f) const {
for (int i = 0; i < _actListArrSize; i++) { for (int i = 0; i < _actListArrSize; i++) {
// write all the sub elems data // write all the sub elems data
@ -979,6 +1064,27 @@ void Scheduler::findAction(act* action, int16* index, int16* subElem) {
assert(0); assert(0);
} }
void Scheduler::saveSchedulerData(Common::WriteStream *out) {
savePoints(out);
// Now save current time and all current events in event queue
saveEvents(out);
// Now save current actions
saveActions(out);
}
void Scheduler::restoreSchedulerData(Common::ReadStream *in) {
restorePoints(in);
_vm->_object->restoreAllSeq();
// Now restore time of the save and the event queue
restoreEvents(in);
// Now restore actions
restoreActions(in);
}
/** /**
* Restore the event list from file with handle f * Restore the event list from file with handle f
*/ */
@ -1262,7 +1368,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {
Utils::Box(kBoxOk, "%s", _vm->_file->fetchString(action->a40.stringIndex)); Utils::Box(kBoxOk, "%s", _vm->_file->fetchString(action->a40.stringIndex));
break; break;
case COND_BONUS: // act41: Perform action if got bonus case COND_BONUS: // act41: Perform action if got bonus
if (_vm->_points[action->a41.BonusIndex].scoredFl) if (_points[action->a41.BonusIndex].scoredFl)
insertActionList(action->a41.actPassIndex); insertActionList(action->a41.actPassIndex);
else else
insertActionList(action->a41.actFailIndex); insertActionList(action->a41.actFailIndex);
@ -1354,6 +1460,9 @@ void Scheduler::delQueue(event_t *curEvent) {
_freeEvent = curEvent; _freeEvent = curEvent;
} }
/**
* Delete all the active events of a given type
*/
void Scheduler::delEventType(const action_t actTypeDel) { void Scheduler::delEventType(const action_t actTypeDel) {
// Note: actions are not deleted here, simply turned into NOPs! // Note: actions are not deleted here, simply turned into NOPs!
event_t *wrkEvent = _headEvent; // The earliest event event_t *wrkEvent = _headEvent; // The earliest event
@ -1367,6 +1476,27 @@ void Scheduler::delEventType(const action_t actTypeDel) {
} }
} }
/**
* Save the points table
*/
void Scheduler::savePoints(Common::WriteStream *out) const {
for (int i = 0; i < _numBonuses; i++) {
out->writeByte(_points[i].score);
out->writeByte((_points[i].scoredFl) ? 1 : 0);
}
}
/**
* Restore the points table
*/
void Scheduler::restorePoints(Common::ReadStream *in) {
// Restore points table
for (int i = 0; i < _numBonuses; i++) {
_points[i].score = in->readByte();
_points[i].scoredFl = (in->readByte() == 1);
}
}
Scheduler_v1d::Scheduler_v1d(HugoEngine *vm) : Scheduler(vm) { Scheduler_v1d::Scheduler_v1d(HugoEngine *vm) : Scheduler(vm) {
} }
@ -1427,11 +1557,9 @@ void Scheduler_v1d::promptAction(act *action) {
void Scheduler_v1d::decodeString(char *line) { void Scheduler_v1d::decodeString(char *line) {
debugC(1, kDebugSchedule, "decodeString(%s)", line); debugC(1, kDebugSchedule, "decodeString(%s)", line);
static const Common::String cypher = getCypher();
uint16 linelength = strlen(line); uint16 linelength = strlen(line);
for(uint16 i = 0; i < linelength; i++) { for(uint16 i = 0; i < linelength; i++) {
line[i] = (line[i] + cypher.c_str()[i % cypher.size()]) % '~'; line[i] = (line[i] + _cypher.c_str()[i % _cypher.size()]) % '~';
if (line[i] < ' ') if (line[i] < ' ')
line[i] += ' '; line[i] += ' ';
} }
@ -1480,11 +1608,10 @@ void Scheduler_v2d::promptAction(act *action) {
void Scheduler_v2d::decodeString(char *line) { void Scheduler_v2d::decodeString(char *line) {
debugC(1, kDebugSchedule, "decodeString(%s)", line); debugC(1, kDebugSchedule, "decodeString(%s)", line);
static const Common::String cypher = getCypher();
int16 lineLength = strlen(line); int16 lineLength = strlen(line);
for (uint16 i = 0; i < lineLength; i++) for (uint16 i = 0; i < lineLength; i++)
line[i] -= cypher.c_str()[i % cypher.size()]; line[i] -= _cypher.c_str()[i % _cypher.size()];
debugC(1, kDebugSchedule, "result : %s", line); debugC(1, kDebugSchedule, "result : %s", line);
} }

View file

@ -458,31 +458,40 @@ public:
virtual void decodeString(char *line) = 0; virtual void decodeString(char *line) = 0;
virtual void runScheduler() = 0; virtual void runScheduler() = 0;
void freeActListArr(); int16 calcMaxPoints() const;
void freeScheduler();
void initCypher();
void initEventQueue(); void initEventQueue();
void insertActionList(const uint16 actIndex); void insertActionList(const uint16 actIndex);
void loadActListArr(Common::ReadStream &in); void loadActListArr(Common::ReadStream &in);
void loadAlNewscrIndex(Common::ReadStream &in); void loadAlNewscrIndex(Common::ReadStream &in);
void loadPoints(Common::ReadStream &in);
void loadScreenAct(Common::ReadStream &in);
void newScreen(const int screenIndex); void newScreen(const int screenIndex);
void processBonus(const int bonusIndex); void processBonus(const int bonusIndex);
void processMaze(const int x1, const int x2, const int y1, const int y2); void processMaze(const int x1, const int x2, const int y1, const int y2);
void restoreSchedulerData(Common::ReadStream *in);
void restoreScreen(const int screenIndex); void restoreScreen(const int screenIndex);
void restoreEvents(Common::ReadStream *f); void saveSchedulerData(Common::WriteStream *out);
void saveEvents(Common::WriteStream *f);
void waitForRefresh(); void waitForRefresh();
void findAction(act* action, int16* index, int16* subElem); void findAction(act* action, int16* index, int16* subElem);
void saveActions(Common::WriteStream* f) const;
void restoreActions(Common::ReadStream *f);
protected: protected:
HugoEngine *_vm; HugoEngine *_vm;
static const int kFilenameLength = 12; // Max length of a DOS file name static const int kFilenameLength = 12; // Max length of a DOS file name
static const int kMaxEvents = 50; // Max events in event queue static const int kMaxEvents = 50; // Max events in event queue
static const int kShiftSize = 8; // Place hero this far inside bounding box static const int kShiftSize = 8; // Place hero this far inside bounding box
Common::String _cypher;
uint16 _actListArrSize; uint16 _actListArrSize;
uint16 _alNewscrIndex; uint16 _alNewscrIndex;
uint16 _screenActsSize;
uint16 **_screenActs;
byte _numBonuses;
point_t *_points;
uint32 _curTick; // Current system time in ticks uint32 _curTick; // Current system time in ticks
uint32 _oldTime; // The previous wall time in ticks uint32 _oldTime; // The previous wall time in ticks
@ -510,6 +519,14 @@ protected:
void delEventType(const action_t actTypeDel); void delEventType(const action_t actTypeDel);
void delQueue(event_t *curEvent); void delQueue(event_t *curEvent);
void insertAction(act *action); void insertAction(act *action);
void restoreActions(Common::ReadStream *f);
void restoreEvents(Common::ReadStream *f);
void restorePoints(Common::ReadStream *in);
void saveActions(Common::WriteStream* f) const;
void saveEvents(Common::WriteStream *f);
void savePoints(Common::WriteStream *out) const;
void screenActions(const int screenNum);
}; };
class Scheduler_v1d : public Scheduler { class Scheduler_v1d : public Scheduler {

View file

@ -1156,7 +1156,7 @@ static const MohawkGameDescription gameDescriptions[] = {
}, },
GType_LIVINGBOOKSV4, GType_LIVINGBOOKSV4,
0, 0,
0, 0
}, },
{ {
@ -1171,7 +1171,25 @@ static const MohawkGameDescription gameDescriptions[] = {
}, },
GType_LIVINGBOOKSV4, GType_LIVINGBOOKSV4,
0, 0,
0
},
// Rugrats Adventure Game
// French Windows
// From Strangerke
{
{
"rugrats",
"",
AD_ENTRY1("outline", "36225e0b4986a80135cfdd9643cc7030"),
Common::FR_FRA,
Common::kPlatformWindows,
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
GType_LIVINGBOOKSV4,
0, 0,
0
}, },
{ {

View file

@ -417,45 +417,45 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS
switch (_curStack) { switch (_curStack) {
case kChannelwoodStack: case kChannelwoodStack:
_gameState->_globals.currentAge = 4; _gameState->_globals.currentAge = 4;
_scriptParser = new MystScriptParser_Channelwood(this); _scriptParser = new MystStacks::Channelwood(this);
break; break;
case kCreditsStack: case kCreditsStack:
_scriptParser = new MystScriptParser_Credits(this); _scriptParser = new MystStacks::Credits(this);
break; break;
case kDemoStack: case kDemoStack:
_scriptParser = new MystScriptParser_Demo(this); _scriptParser = new MystStacks::Demo(this);
break; break;
case kDniStack: case kDniStack:
_gameState->_globals.currentAge = 6; _gameState->_globals.currentAge = 6;
_scriptParser = new MystScriptParser_Dni(this); _scriptParser = new MystStacks::Dni(this);
break; break;
case kIntroStack: case kIntroStack:
_scriptParser = new MystScriptParser_Intro(this); _scriptParser = new MystStacks::Intro(this);
break; break;
case kMakingOfStack: case kMakingOfStack:
_scriptParser = new MystScriptParser_MakingOf(this); _scriptParser = new MystStacks::MakingOf(this);
break; break;
case kMechanicalStack: case kMechanicalStack:
_gameState->_globals.currentAge = 3; _gameState->_globals.currentAge = 3;
_scriptParser = new MystScriptParser_Mechanical(this); _scriptParser = new MystStacks::Mechanical(this);
break; break;
case kMystStack: case kMystStack:
_gameState->_globals.currentAge = 2; _gameState->_globals.currentAge = 2;
_scriptParser = new MystScriptParser_Myst(this); _scriptParser = new MystStacks::Myst(this);
break; break;
case kDemoPreviewStack: case kDemoPreviewStack:
_scriptParser = new MystScriptParser_Preview(this); _scriptParser = new MystStacks::Preview(this);
break; break;
case kSeleniticStack: case kSeleniticStack:
_gameState->_globals.currentAge = 0; _gameState->_globals.currentAge = 0;
_scriptParser = new MystScriptParser_Selenitic(this); _scriptParser = new MystStacks::Selenitic(this);
break; break;
case kDemoSlidesStack: case kDemoSlidesStack:
_scriptParser = new MystScriptParser_Slides(this); _scriptParser = new MystStacks::Slides(this);
break; break;
case kStoneshipStack: case kStoneshipStack:
_gameState->_globals.currentAge = 1; _gameState->_globals.currentAge = 1;
_scriptParser = new MystScriptParser_Stoneship(this); _scriptParser = new MystStacks::Stoneship(this);
break; break;
default: default:
error("Unknown Myst stack"); error("Unknown Myst stack");

View file

@ -599,6 +599,10 @@ void MystScriptParser::o_copyBackBufferToScreen(uint16 op, uint16 var, uint16 ar
void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
uint16 imageId = argv[0]; uint16 imageId = argv[0];
// WORKAROUND wrong image id in mechanical staircase
if (imageId == 7158)
imageId = 7178;
Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]); Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333); Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);

View file

@ -35,18 +35,19 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Channelwood::MystScriptParser_Channelwood(MohawkEngine_Myst *vm) : Channelwood::Channelwood(MohawkEngine_Myst *vm) :
MystScriptParser(vm), _state(vm->_gameState->_channelwood) { MystScriptParser(vm), _state(vm->_gameState->_channelwood) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_Channelwood::~MystScriptParser_Channelwood() { Channelwood::~Channelwood() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Channelwood::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Channelwood::x, #x))
void MystScriptParser_Channelwood::setupOpcodes() { void Channelwood::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_bridgeToggle); OPCODE(100, o_bridgeToggle);
OPCODE(101, o_pipeExtend); OPCODE(101, o_pipeExtend);
@ -89,15 +90,15 @@ void MystScriptParser_Channelwood::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Channelwood::disablePersistentScripts() { void Channelwood::disablePersistentScripts() {
} }
void MystScriptParser_Channelwood::runPersistentScripts() { void Channelwood::runPersistentScripts() {
} }
uint16 MystScriptParser_Channelwood::getVar(uint16 var) { uint16 Channelwood::getVar(uint16 var) {
switch(var) { switch(var) {
case 1: // Water Pump Bridge Raised case 1: // Water Pump Bridge Raised
return _state.waterPumpBridgeState; return _state.waterPumpBridgeState;
@ -186,7 +187,7 @@ uint16 MystScriptParser_Channelwood::getVar(uint16 var) {
} }
} }
void MystScriptParser_Channelwood::toggleVar(uint16 var) { void Channelwood::toggleVar(uint16 var) {
switch(var) { switch(var) {
case 1: // Water Pump Bridge Raised case 1: // Water Pump Bridge Raised
_state.waterPumpBridgeState ^= 1; _state.waterPumpBridgeState ^= 1;
@ -219,7 +220,7 @@ void MystScriptParser_Channelwood::toggleVar(uint16 var) {
} }
} }
bool MystScriptParser_Channelwood::setVarValue(uint16 var, uint16 value) { bool Channelwood::setVarValue(uint16 var, uint16 value) {
bool refresh = false; bool refresh = false;
switch (var) { switch (var) {
@ -270,7 +271,7 @@ bool MystScriptParser_Channelwood::setVarValue(uint16 var, uint16 value) {
return refresh; return refresh;
} }
bool MystScriptParser_Channelwood::pipeChangeValve(bool open, uint16 mask) { bool Channelwood::pipeChangeValve(bool open, uint16 mask) {
if (open) { if (open) {
if (!(_state.waterValveStates & mask)) { if (!(_state.waterValveStates & mask)) {
_state.waterValveStates |= mask; _state.waterValveStates |= mask;
@ -286,7 +287,7 @@ bool MystScriptParser_Channelwood::pipeChangeValve(bool open, uint16 mask) {
return false; return false;
} }
void MystScriptParser_Channelwood::o_bridgeToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_bridgeToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Bridge rise / skink video", op); debugC(kDebugScript, "Opcode %d: Bridge rise / skink video", op);
VideoHandle bridge = _vm->_video->playMovie(_vm->wrapMovieFilename("bridge", kChannelwoodStack), 292, 203); VideoHandle bridge = _vm->_video->playMovie(_vm->wrapMovieFilename("bridge", kChannelwoodStack), 292, 203);
@ -300,7 +301,7 @@ void MystScriptParser_Channelwood::o_bridgeToggle(uint16 op, uint16 var, uint16
_vm->_video->waitUntilMovieEnds(bridge); _vm->_video->waitUntilMovieEnds(bridge);
} }
void MystScriptParser_Channelwood::o_pipeExtend(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_pipeExtend(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play Pipe Movie and Sound", op); debugC(kDebugScript, "Opcode %d: Play Pipe Movie and Sound", op);
uint16 soundId = argv[0]; uint16 soundId = argv[0];
@ -319,7 +320,7 @@ void MystScriptParser_Channelwood::o_pipeExtend(uint16 op, uint16 var, uint16 ar
_vm->_sound->resumeBackgroundMyst(); _vm->_sound->resumeBackgroundMyst();
} }
void MystScriptParser_Channelwood::o_drawImageChangeCardAndVolume(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_drawImageChangeCardAndVolume(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Draw Full Screen Image, Change Card, and change volume", op); debugC(kDebugScript, "Opcode %d: Draw Full Screen Image, Change Card, and change volume", op);
uint16 imageId = argv[0]; uint16 imageId = argv[0];
@ -340,7 +341,7 @@ void MystScriptParser_Channelwood::o_drawImageChangeCardAndVolume(uint16 op, uin
} }
void MystScriptParser_Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Do Water Tank Valve Open Animation", op); debugC(kDebugScript, "Opcode %d: Do Water Tank Valve Open Animation", op);
Common::Rect rect = _invokingResource->getRect(); Common::Rect rect = _invokingResource->getRect();
@ -354,7 +355,7 @@ void MystScriptParser_Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, u
pipeChangeValve(true, 0x80); pipeChangeValve(true, 0x80);
} }
void MystScriptParser_Channelwood::o_leverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever start move", op); debugC(kDebugScript, "Opcode %d: Generic lever start move", op);
MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
@ -363,7 +364,7 @@ void MystScriptParser_Channelwood::o_leverStartMove(uint16 op, uint16 var, uint1
_leverPulled = false; _leverPulled = false;
} }
void MystScriptParser_Channelwood::o_leverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever move", op); debugC(kDebugScript, "Opcode %d: Generic lever move", op);
MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
@ -378,7 +379,7 @@ void MystScriptParser_Channelwood::o_leverMove(uint16 op, uint16 var, uint16 arg
} }
} }
void MystScriptParser_Channelwood::o_leverMoveFail(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverMoveFail(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever move", op); debugC(kDebugScript, "Opcode %d: Generic lever move", op);
MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
@ -395,7 +396,7 @@ void MystScriptParser_Channelwood::o_leverMoveFail(uint16 op, uint16 var, uint16
} }
} }
void MystScriptParser_Channelwood::o_leverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever end move", op); debugC(kDebugScript, "Opcode %d: Generic lever end move", op);
// Get current lever frame // Get current lever frame
@ -411,12 +412,12 @@ void MystScriptParser_Channelwood::o_leverEndMove(uint16 op, uint16 var, uint16
_vm->checkCursorHints(); _vm->checkCursorHints();
} }
void MystScriptParser_Channelwood::o_leverEndMoveResumeBackground(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverEndMoveResumeBackground(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_vm->_sound->resumeBackgroundMyst(); _vm->_sound->resumeBackgroundMyst();
o_leverEndMove(op, var, argc, argv); o_leverEndMove(op, var, argc, argv);
} }
void MystScriptParser_Channelwood::o_leverEndMoveWithSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverEndMoveWithSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv); o_leverEndMove(op, var, argc, argv);
MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
@ -425,20 +426,20 @@ void MystScriptParser_Channelwood::o_leverEndMoveWithSound(uint16 op, uint16 var
_vm->_sound->replaceSoundMyst(soundId); _vm->_sound->replaceSoundMyst(soundId);
} }
void MystScriptParser_Channelwood::o_leverElev3StartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverElev3StartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_vm->_gfx->copyImageToScreen(3970, Common::Rect(544, 333)); _vm->_gfx->copyImageToScreen(3970, Common::Rect(544, 333));
_vm->_system->updateScreen(); _vm->_system->updateScreen();
o_leverStartMove(op, var, argc, argv); o_leverStartMove(op, var, argc, argv);
} }
void MystScriptParser_Channelwood::o_leverElev3EndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_leverElev3EndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv); o_leverEndMove(op, var, argc, argv);
_vm->_gfx->copyImageToScreen(3265, Common::Rect(544, 333)); _vm->_gfx->copyImageToScreen(3265, Common::Rect(544, 333));
_vm->_system->updateScreen(); _vm->_system->updateScreen();
_vm->_sound->replaceSoundMyst(5265); _vm->_sound->replaceSoundMyst(5265);
} }
void MystScriptParser_Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Pump lever move", op); debugC(kDebugScript, "Opcode %d: Pump lever move", op);
MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
@ -452,7 +453,7 @@ void MystScriptParser_Channelwood::o_pumpLeverMove(uint16 op, uint16 var, uint16
} }
} }
void MystScriptParser_Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
o_leverEndMove(op, var, argc, argv); o_leverEndMove(op, var, argc, argv);
MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
@ -461,7 +462,7 @@ void MystScriptParser_Channelwood::o_pumpLeverEndMove(uint16 op, uint16 var, uin
_vm->_sound->replaceBackgroundMyst(soundId, 36864); _vm->_sound->replaceBackgroundMyst(soundId, 36864);
} }
void MystScriptParser_Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play stairs door video", op); debugC(kDebugScript, "Opcode %d: Play stairs door video", op);
MystResourceType6 *movie = static_cast<MystResourceType6 *>(_invokingResource); MystResourceType6 *movie = static_cast<MystResourceType6 *>(_invokingResource);
@ -474,7 +475,7 @@ void MystScriptParser_Channelwood::o_stairsDoorToggle(uint16 op, uint16 var, uin
} }
} }
void MystScriptParser_Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op); debugC(kDebugScript, "Opcode %d: Valve handle move", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -490,7 +491,7 @@ void MystScriptParser_Channelwood::o_valveHandleMove1(uint16 op, uint16 var, uin
} }
} }
void MystScriptParser_Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op); debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -502,7 +503,7 @@ void MystScriptParser_Channelwood::o_valveHandleMoveStart1(uint16 op, uint16 var
o_valveHandleMove1(op, var, argc, argv); o_valveHandleMove1(op, var, argc, argv);
} }
void MystScriptParser_Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move stop", op); debugC(kDebugScript, "Opcode %d: Valve handle move stop", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -525,7 +526,7 @@ void MystScriptParser_Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var,
_vm->checkCursorHints(); _vm->checkCursorHints();
} }
void MystScriptParser_Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op); debugC(kDebugScript, "Opcode %d: Valve handle move", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -541,7 +542,7 @@ void MystScriptParser_Channelwood::o_valveHandleMove2(uint16 op, uint16 var, uin
} }
} }
void MystScriptParser_Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op); debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -553,7 +554,7 @@ void MystScriptParser_Channelwood::o_valveHandleMoveStart2(uint16 op, uint16 var
o_valveHandleMove2(op, var, argc, argv); o_valveHandleMove2(op, var, argc, argv);
} }
void MystScriptParser_Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move", op); debugC(kDebugScript, "Opcode %d: Valve handle move", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -569,7 +570,7 @@ void MystScriptParser_Channelwood::o_valveHandleMove3(uint16 op, uint16 var, uin
} }
} }
void MystScriptParser_Channelwood::o_valveHandleMoveStart3(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_valveHandleMoveStart3(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Valve handle move start", op); debugC(kDebugScript, "Opcode %d: Valve handle move start", op);
MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource);
@ -581,7 +582,7 @@ void MystScriptParser_Channelwood::o_valveHandleMoveStart3(uint16 op, uint16 var
o_valveHandleMove3(op, var, argc, argv); o_valveHandleMove3(op, var, argc, argv);
} }
void MystScriptParser_Channelwood::o_hologramMonitor(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_hologramMonitor(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram monitor", op); debugC(kDebugScript, "Opcode %d: Hologram monitor", op);
// Used on Card 3012 (Temple Hologram Monitor) // Used on Card 3012 (Temple Hologram Monitor)
@ -613,7 +614,7 @@ void MystScriptParser_Channelwood::o_hologramMonitor(uint16 op, uint16 var, uint
} }
} }
void MystScriptParser_Channelwood::o_drawerOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_drawerOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open Sirius drawer", op); debugC(kDebugScript, "Opcode %d: Open Sirius drawer", op);
_siriusDrawerState = 1; _siriusDrawerState = 1;
@ -621,7 +622,7 @@ void MystScriptParser_Channelwood::o_drawerOpen(uint16 op, uint16 var, uint16 ar
_vm->redrawArea(102, false); _vm->redrawArea(102, false);
} }
void MystScriptParser_Channelwood::o_hologramTemple(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_hologramTemple(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Temple hologram", op); debugC(kDebugScript, "Opcode %d: Temple hologram", op);
_vm->_sound->pauseBackgroundMyst(); _vm->_sound->pauseBackgroundMyst();
@ -648,14 +649,14 @@ void MystScriptParser_Channelwood::o_hologramTemple(uint16 op, uint16 var, uint1
_vm->_sound->resumeBackgroundMyst(); _vm->_sound->resumeBackgroundMyst();
} }
void MystScriptParser_Channelwood::o_executeMouseUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_executeMouseUp(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Execute mouse up", op); debugC(kDebugScript, "Opcode %d: Execute mouse up", op);
MystResourceType5 *resource = static_cast<MystResourceType5 *>(_vm->_resources[argv[0]]); MystResourceType5 *resource = static_cast<MystResourceType5 *>(_vm->_resources[argv[0]]);
resource->handleMouseUp(); resource->handleMouseUp();
} }
void MystScriptParser_Channelwood::o_waterTankValveClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_waterTankValveClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Do Water Tank Valve Close Animation", op); debugC(kDebugScript, "Opcode %d: Do Water Tank Valve Close Animation", op);
Common::Rect rect = _invokingResource->getRect(); Common::Rect rect = _invokingResource->getRect();
@ -669,7 +670,7 @@ void MystScriptParser_Channelwood::o_waterTankValveClose(uint16 op, uint16 var,
pipeChangeValve(false, 0x80); pipeChangeValve(false, 0x80);
} }
void MystScriptParser_Channelwood::o_elevatorMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_elevatorMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used by Card 3262 (Elevator) // Used by Card 3262 (Elevator)
debugC(kDebugScript, "Opcode %d: Elevator movie", op); debugC(kDebugScript, "Opcode %d: Elevator movie", op);
@ -714,7 +715,7 @@ void MystScriptParser_Channelwood::o_elevatorMovies(uint16 op, uint16 var, uint1
_vm->_sound->resumeBackgroundMyst(); _vm->_sound->resumeBackgroundMyst();
} }
void MystScriptParser_Channelwood::o_soundReplace(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_soundReplace(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play sound if not already playing", op); debugC(kDebugScript, "Opcode %d: Play sound if not already playing", op);
uint16 soundId = argv[0]; uint16 soundId = argv[0];
@ -723,19 +724,20 @@ void MystScriptParser_Channelwood::o_soundReplace(uint16 op, uint16 var, uint16
_vm->_sound->replaceSoundMyst(soundId); _vm->_sound->replaceSoundMyst(soundId);
} }
void MystScriptParser_Channelwood::o_lever_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_lever_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generic lever init", op); debugC(kDebugScript, "Opcode %d: Generic lever init", op);
_leverAction = static_cast<MystResourceType5 *>(_invokingResource); _leverAction = static_cast<MystResourceType5 *>(_invokingResource);
} }
void MystScriptParser_Channelwood::o_pipeValve_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_pipeValve_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Water valve init", op); debugC(kDebugScript, "Opcode %d: Water valve init", op);
_valveVar = var; _valveVar = var;
} }
void MystScriptParser_Channelwood::o_drawer_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Channelwood::o_drawer_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sirius's drawer init", op); debugC(kDebugScript, "Opcode %d: Sirius's drawer init", op);
_siriusDrawerState = 0; _siriusDrawerState = 0;
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Channelwood : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Channelwood : public MystScriptParser {
public: public:
MystScriptParser_Channelwood(MohawkEngine_Myst *vm); Channelwood(MohawkEngine_Myst *vm);
~MystScriptParser_Channelwood(); ~Channelwood();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -99,6 +100,7 @@ private:
bool pipeChangeValve(bool open, uint16 mask); bool pipeChangeValve(bool open, uint16 mask);
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -33,19 +33,20 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
// NOTE: Credits Start Card is 10000 // NOTE: Credits Start Card is 10000
MystScriptParser_Credits::MystScriptParser_Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) { Credits::Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_Credits::~MystScriptParser_Credits() { Credits::~Credits() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Credits::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Credits::x, #x))
void MystScriptParser_Credits::setupOpcodes() { void Credits::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_quit); OPCODE(100, o_quit);
@ -55,11 +56,11 @@ void MystScriptParser_Credits::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Credits::disablePersistentScripts() { void Credits::disablePersistentScripts() {
_creditsRunning = false; _creditsRunning = false;
} }
void MystScriptParser_Credits::runPersistentScripts() { void Credits::runPersistentScripts() {
if (!_creditsRunning) if (!_creditsRunning)
return; return;
@ -79,7 +80,7 @@ void MystScriptParser_Credits::runPersistentScripts() {
} }
} }
uint16 MystScriptParser_Credits::getVar(uint16 var) { uint16 Credits::getVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Credits Image Control case 0: // Credits Image Control
return _curImage; return _curImage;
@ -90,11 +91,12 @@ uint16 MystScriptParser_Credits::getVar(uint16 var) {
} }
} }
void MystScriptParser_Credits::o_runCredits(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Credits::o_runCredits(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Activate the credits // Activate the credits
_creditsRunning = true; _creditsRunning = true;
_curImage = 0; _curImage = 0;
_startTime = _vm->_system->getMillis(); _startTime = _vm->_system->getMillis();
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Credits : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Credits : public MystScriptParser {
public: public:
MystScriptParser_Credits(MohawkEngine_Myst *vm); Credits(MohawkEngine_Myst *vm);
~MystScriptParser_Credits(); ~Credits();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -55,6 +56,7 @@ private:
uint16 _curImage; // 56 uint16 _curImage; // 56
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -29,25 +29,26 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Demo::MystScriptParser_Demo(MohawkEngine_Myst *vm) : MystScriptParser_Intro(vm) { Demo::Demo(MohawkEngine_Myst *vm) : Intro(vm) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_Demo::~MystScriptParser_Demo() { Demo::~Demo() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Demo::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Demo::x, #x))
#define OVERRIDE_OPCODE(opcode, x) \ #define OVERRIDE_OPCODE(opcode, x) \
for (uint32 i = 0; i < _opcodes.size(); i++) \ for (uint32 i = 0; i < _opcodes.size(); i++) \
if (_opcodes[i]->op == opcode) { \ if (_opcodes[i]->op == opcode) { \
_opcodes[i]->proc = (OpcodeProcMyst) &MystScriptParser_Demo::x; \ _opcodes[i]->proc = (OpcodeProcMyst) &Demo::x; \
_opcodes[i]->desc = #x; \ _opcodes[i]->desc = #x; \
break; \ break; \
} }
void MystScriptParser_Demo::setupOpcodes() { void Demo::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OVERRIDE_OPCODE(100, opcode_100); OVERRIDE_OPCODE(100, opcode_100);
OPCODE(101, opcode_101); OPCODE(101, opcode_101);
@ -63,14 +64,14 @@ void MystScriptParser_Demo::setupOpcodes() {
#undef OPCODE #undef OPCODE
#undef OVERRIDE_OPCODE #undef OVERRIDE_OPCODE
void MystScriptParser_Demo::disablePersistentScripts() { void Demo::disablePersistentScripts() {
MystScriptParser_Intro::disablePersistentScripts(); Intro::disablePersistentScripts();
_enabled201 = false; _enabled201 = false;
} }
void MystScriptParser_Demo::runPersistentScripts() { void Demo::runPersistentScripts() {
MystScriptParser_Intro::runPersistentScripts(); Intro::runPersistentScripts();
if (_enabled201) { if (_enabled201) {
// Used on Card 2001, 2002 and 2003 // Used on Card 2001, 2002 and 2003
@ -79,11 +80,11 @@ void MystScriptParser_Demo::runPersistentScripts() {
} }
} }
void MystScriptParser_Demo::opcode_100(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Demo::opcode_100(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// TODO: Fill in Function... // TODO: Fill in Function...
} }
void MystScriptParser_Demo::opcode_101(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Demo::opcode_101(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used on Card 2000, 2002 and 2003 // Used on Card 2000, 2002 and 2003
@ -94,7 +95,7 @@ void MystScriptParser_Demo::opcode_101(uint16 op, uint16 var, uint16 argc, uint1
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Demo::opcode_102(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Demo::opcode_102(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used on Card 2002 and 2003 // Used on Card 2002 and 2003
@ -105,7 +106,7 @@ void MystScriptParser_Demo::opcode_102(uint16 op, uint16 var, uint16 argc, uint1
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Demo::opcode_201(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Demo::opcode_201(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used on Card 2001, 2002 and 2003 // Used on Card 2001, 2002 and 2003
@ -116,11 +117,12 @@ void MystScriptParser_Demo::opcode_201(uint16 op, uint16 var, uint16 argc, uint1
} }
void MystScriptParser_Demo::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Demo::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used on Card 2000 // Used on Card 2000
varUnusedCheck(op, var); varUnusedCheck(op, var);
// TODO: Fill in Function... // TODO: Fill in Function...
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Demo : public MystScriptParser_Intro { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Demo : public Intro {
public: public:
MystScriptParser_Demo(MohawkEngine_Myst *vm); Demo(MohawkEngine_Myst *vm);
~MystScriptParser_Demo(); ~Demo();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -59,6 +60,7 @@ private:
bool _enabled201; bool _enabled201;
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -32,19 +32,20 @@
#include "mohawk/myst_stacks/dni.h" #include "mohawk/myst_stacks/dni.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Dni::MystScriptParser_Dni(MohawkEngine_Myst *vm) : Dni::Dni(MohawkEngine_Myst *vm) :
MystScriptParser(vm) { MystScriptParser(vm) {
setupOpcodes(); setupOpcodes();
_notSeenAtrus = true; _notSeenAtrus = true;
} }
MystScriptParser_Dni::~MystScriptParser_Dni() { Dni::~Dni() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Dni::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Dni::x, #x))
void MystScriptParser_Dni::setupOpcodes() { void Dni::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, NOP); OPCODE(100, NOP);
OPCODE(101, o_handPage); OPCODE(101, o_handPage);
@ -58,13 +59,13 @@ void MystScriptParser_Dni::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Dni::disablePersistentScripts() { void Dni::disablePersistentScripts() {
_atrusRunning = false; _atrusRunning = false;
_waitForLoop = false; _waitForLoop = false;
_atrusLeft = false; _atrusLeft = false;
} }
void MystScriptParser_Dni::runPersistentScripts() { void Dni::runPersistentScripts() {
if (_atrusRunning) if (_atrusRunning)
atrus_run(); atrus_run();
@ -75,7 +76,7 @@ void MystScriptParser_Dni::runPersistentScripts() {
atrusLeft_run(); atrusLeft_run();
} }
uint16 MystScriptParser_Dni::getVar(uint16 var) { uint16 Dni::getVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Atrus Gone (from across room) case 0: // Atrus Gone (from across room)
return _globals.ending == 2; return _globals.ending == 2;
@ -95,7 +96,7 @@ uint16 MystScriptParser_Dni::getVar(uint16 var) {
} }
} }
void MystScriptParser_Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hand page to Atrus", op); debugC(kDebugScript, "Opcode %d: Hand page to Atrus", op);
// Used in Card 5014 (Atrus) // Used in Card 5014 (Atrus)
@ -118,7 +119,7 @@ void MystScriptParser_Dni::o_handPage(uint16 op, uint16 var, uint16 argc, uint16
} }
} }
void MystScriptParser_Dni::atrusLeft_run() { void Dni::atrusLeft_run() {
if (_vm->_system->getMillis() > _atrusLeftTime + 63333) { if (_vm->_system->getMillis() > _atrusLeftTime + 63333) {
_video = _vm->wrapMovieFilename("atrus2", kDniStack); _video = _vm->wrapMovieFilename("atrus2", kDniStack);
VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77); VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77);
@ -137,7 +138,7 @@ void MystScriptParser_Dni::atrusLeft_run() {
} }
} }
void MystScriptParser_Dni::loopVideo_run() { void Dni::loopVideo_run() {
if (!_vm->_video->isVideoPlaying()) { if (!_vm->_video->isVideoPlaying()) {
VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77); VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77);
_vm->_video->setVideoBounds(atrus, Audio::Timestamp(0, _loopStart, 600), Audio::Timestamp(0, _loopEnd, 600)); _vm->_video->setVideoBounds(atrus, Audio::Timestamp(0, _loopStart, 600), Audio::Timestamp(0, _loopEnd, 600));
@ -147,7 +148,7 @@ void MystScriptParser_Dni::loopVideo_run() {
} }
} }
void MystScriptParser_Dni::atrus_run() { void Dni::atrus_run() {
if (_globals.ending == 2) { if (_globals.ending == 2) {
// Wait for atrus to come back // Wait for atrus to come back
_atrusLeft = true; _atrusLeft = true;
@ -188,10 +189,11 @@ void MystScriptParser_Dni::atrus_run() {
} }
} }
void MystScriptParser_Dni::o_atrus_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Dni::o_atrus_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Atrus init", op); debugC(kDebugScript, "Opcode %d: Atrus init", op);
_atrusRunning = true; _atrusRunning = true;
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Dni : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Dni : public MystScriptParser {
public: public:
MystScriptParser_Dni(MohawkEngine_Myst *vm); Dni(MohawkEngine_Myst *vm);
~MystScriptParser_Dni(); ~Dni();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -67,6 +68,7 @@ private:
bool _atrusLeft; // 80 bool _atrusLeft; // 80
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -34,17 +34,18 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Intro::MystScriptParser_Intro(MohawkEngine_Myst *vm) : MystScriptParser(vm) { Intro::Intro(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_Intro::~MystScriptParser_Intro() { Intro::~Intro() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Intro::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Intro::x, #x))
void MystScriptParser_Intro::setupOpcodes() { void Intro::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_useLinkBook); OPCODE(100, o_useLinkBook);
@ -58,12 +59,12 @@ void MystScriptParser_Intro::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Intro::disablePersistentScripts() { void Intro::disablePersistentScripts() {
_introMoviesRunning = false; _introMoviesRunning = false;
_linkBookRunning = false; _linkBookRunning = false;
} }
void MystScriptParser_Intro::runPersistentScripts() { void Intro::runPersistentScripts() {
if (_introMoviesRunning) if (_introMoviesRunning)
introMovies_run(); introMovies_run();
@ -71,7 +72,7 @@ void MystScriptParser_Intro::runPersistentScripts() {
mystLinkBook_run(); mystLinkBook_run();
} }
uint16 MystScriptParser_Intro::getVar(uint16 var) { uint16 Intro::getVar(uint16 var) {
switch(var) { switch(var) {
case 0: case 0:
if (_globals.currentAge == 9 || _globals.currentAge == 10) if (_globals.currentAge == 9 || _globals.currentAge == 10)
@ -83,7 +84,7 @@ uint16 MystScriptParser_Intro::getVar(uint16 var) {
} }
} }
void MystScriptParser_Intro::o_useLinkBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Intro::o_useLinkBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Hard coded SoundId valid only for Intro Stack. // Hard coded SoundId valid only for Intro Stack.
// Other stacks use Opcode 40, which takes SoundId values as arguments. // Other stacks use Opcode 40, which takes SoundId values as arguments.
const uint16 soundIdLinkSrc = 5; const uint16 soundIdLinkSrc = 5;
@ -96,7 +97,7 @@ void MystScriptParser_Intro::o_useLinkBook(uint16 op, uint16 var, uint16 argc, u
_vm->changeToStack(_stackMap[_globals.currentAge], _startCard[_globals.currentAge], soundIdLinkSrc, soundIdLinkDst[_globals.currentAge]); _vm->changeToStack(_stackMap[_globals.currentAge], _startCard[_globals.currentAge], soundIdLinkSrc, soundIdLinkDst[_globals.currentAge]);
} }
void MystScriptParser_Intro::introMovies_run() { void Intro::introMovies_run() {
// Play Intro Movies // Play Intro Movies
// This is all quite messy... // This is all quite messy...
@ -156,12 +157,12 @@ void MystScriptParser_Intro::introMovies_run() {
} }
} }
void MystScriptParser_Intro::o_playIntroMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Intro::o_playIntroMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_introMoviesRunning = true; _introMoviesRunning = true;
_introStep = 0; _introStep = 0;
} }
void MystScriptParser_Intro::mystLinkBook_run() { void Intro::mystLinkBook_run() {
if (_startTime == 1) { if (_startTime == 1) {
_startTime = 0; _startTime = 0;
@ -175,7 +176,7 @@ void MystScriptParser_Intro::mystLinkBook_run() {
} }
} }
void MystScriptParser_Intro::o_mystLinkBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Intro::o_mystLinkBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Myst link book init", op); debugC(kDebugScript, "Opcode %d: Myst link book init", op);
_linkBookMovie = static_cast<MystResourceType6 *>(_invokingResource); _linkBookMovie = static_cast<MystResourceType6 *>(_invokingResource);
@ -183,4 +184,5 @@ void MystScriptParser_Intro::o_mystLinkBook_init(uint16 op, uint16 var, uint16 a
_linkBookRunning = true; _linkBookRunning = true;
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,16 +32,17 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
class MystResourceType6; class MystResourceType6;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Intro : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Intro : public MystScriptParser {
public: public:
MystScriptParser_Intro(MohawkEngine_Myst *vm); Intro(MohawkEngine_Myst *vm);
~MystScriptParser_Intro(); ~Intro();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -65,6 +66,7 @@ private:
MystResourceType6 *_linkBookMovie; MystResourceType6 *_linkBookMovie;
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -33,27 +33,29 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_MakingOf::MystScriptParser_MakingOf(MohawkEngine_Myst *vm) : MystScriptParser(vm) { MakingOf::MakingOf(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_MakingOf::~MystScriptParser_MakingOf() { MakingOf::~MakingOf() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_MakingOf::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MakingOf::x, #x))
void MystScriptParser_MakingOf::setupOpcodes() { void MakingOf::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_quit); OPCODE(100, o_quit);
} }
#undef OPCODE #undef OPCODE
void MystScriptParser_MakingOf::disablePersistentScripts() { void MakingOf::disablePersistentScripts() {
} }
void MystScriptParser_MakingOf::runPersistentScripts() { void MakingOf::runPersistentScripts() {
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_MakingOf : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MakingOf : public MystScriptParser {
public: public:
MystScriptParser_MakingOf(MohawkEngine_Myst *vm); MakingOf(MohawkEngine_Myst *vm);
~MystScriptParser_MakingOf(); ~MakingOf();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -49,6 +50,7 @@ private:
void setupOpcodes(); void setupOpcodes();
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -34,8 +34,9 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm) : Mechanical::Mechanical(MohawkEngine_Myst *vm) :
MystScriptParser(vm), _state(vm->_gameState->_mechanical) { MystScriptParser(vm), _state(vm->_gameState->_mechanical) {
setupOpcodes(); setupOpcodes();
@ -43,14 +44,15 @@ MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm)
_fortressPosition = 0; _fortressPosition = 0;
} }
MystScriptParser_Mechanical::~MystScriptParser_Mechanical() { Mechanical::~Mechanical() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Mechanical::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Mechanical::x, #x))
void MystScriptParser_Mechanical::setupOpcodes() { void Mechanical::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(104, opcode_104); OPCODE(100, o_throneEnablePassage);
OPCODE(104, o_snakeBoxTrigger);
OPCODE(105, o_fortressStaircaseMovie); OPCODE(105, o_fortressStaircaseMovie);
OPCODE(121, opcode_121); OPCODE(121, opcode_121);
OPCODE(122, opcode_122); OPCODE(122, opcode_122);
@ -66,10 +68,10 @@ void MystScriptParser_Mechanical::setupOpcodes() {
OPCODE(132, o_crystalLeaveRed); OPCODE(132, o_crystalLeaveRed);
// "Init" Opcodes // "Init" Opcodes
OPCODE(200, opcode_200); OPCODE(200, o_throne_init);
OPCODE(201, opcode_201); OPCODE(201, o_fortressStaircase_init);
OPCODE(202, opcode_202); OPCODE(202, opcode_202);
OPCODE(203, opcode_203); OPCODE(203, o_snakeBox_init);
OPCODE(204, opcode_204); OPCODE(204, opcode_204);
OPCODE(205, opcode_205); OPCODE(205, opcode_205);
OPCODE(206, opcode_206); OPCODE(206, opcode_206);
@ -81,29 +83,23 @@ void MystScriptParser_Mechanical::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Mechanical::disablePersistentScripts() { void Mechanical::disablePersistentScripts() {
opcode_200_disable();
opcode_201_disable();
opcode_202_disable(); opcode_202_disable();
opcode_203_disable();
opcode_204_disable(); opcode_204_disable();
opcode_205_disable(); opcode_205_disable();
opcode_206_disable(); opcode_206_disable();
opcode_209_disable(); opcode_209_disable();
} }
void MystScriptParser_Mechanical::runPersistentScripts() { void Mechanical::runPersistentScripts() {
opcode_200_run();
opcode_201_run();
opcode_202_run(); opcode_202_run();
opcode_203_run();
opcode_204_run(); opcode_204_run();
opcode_205_run(); opcode_205_run();
opcode_206_run(); opcode_206_run();
opcode_209_run(); opcode_209_run();
} }
uint16 MystScriptParser_Mechanical::getVar(uint16 var) { uint16 Mechanical::getVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Sirrus's Secret Panel State case 0: // Sirrus's Secret Panel State
return _state.sirrusPanelState; return _state.sirrusPanelState;
@ -170,8 +166,12 @@ uint16 MystScriptParser_Mechanical::getVar(uint16 var) {
} }
} }
void MystScriptParser_Mechanical::toggleVar(uint16 var) { void Mechanical::toggleVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Sirrus's Secret Panel State
_state.sirrusPanelState ^= 1;
case 1: // Achenar's Secret Panel State
_state.achenarPanelState ^= 1;
case 3: // Achenar's Secret Room Crate State case 3: // Achenar's Secret Room Crate State
_state.achenarCrateOpened ^= 1; _state.achenarCrateOpened ^= 1;
case 4: // Myst Book Room Staircase State case 4: // Myst Book Room Staircase State
@ -206,7 +206,7 @@ void MystScriptParser_Mechanical::toggleVar(uint16 var) {
} }
} }
bool MystScriptParser_Mechanical::setVarValue(uint16 var, uint16 value) { bool Mechanical::setVarValue(uint16 var, uint16 value) {
bool refresh = false; bool refresh = false;
switch (var) { switch (var) {
@ -218,20 +218,20 @@ bool MystScriptParser_Mechanical::setVarValue(uint16 var, uint16 value) {
return refresh; return refresh;
} }
void MystScriptParser_Mechanical::opcode_104(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_throneEnablePassage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); debugC(kDebugScript, "Opcode %d: Enable throne passage", op);
// Used on Mechanical Card 6043 (Weapons Rack with Snake Box)
if (argc == 0) {
debugC(kDebugScript, "Opcode %d: Trigger Playing Of Snake Movie", op);
// TODO: Trigger Type 6 To Play Snake Movie.. Resource #3 on card.
} else
unknown(op, var, argc, argv);
_vm->_resources[argv[0]]->setEnabled(getVar(var));
} }
void MystScriptParser_Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_snakeBoxTrigger(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Trigger Playing Of Snake Movie", op);
// Used on Mechanical Card 6043 (Weapons Rack with Snake Box)
_snakeBox->playMovie();
}
void Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play Stairs Movement Movie", op); debugC(kDebugScript, "Opcode %d: Play Stairs Movement Movie", op);
VideoHandle staircase = _vm->_video->playMovie(_vm->wrapMovieFilename("hhstairs", kMechanicalStack), 174, 222); VideoHandle staircase = _vm->_video->playMovie(_vm->wrapMovieFilename("hhstairs", kMechanicalStack), 174, 222);
@ -246,7 +246,7 @@ void MystScriptParser_Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var
} }
void MystScriptParser_Mechanical::opcode_121(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_121(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
if (argc == 2) { if (argc == 2) {
@ -261,7 +261,7 @@ void MystScriptParser_Mechanical::opcode_121(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Mechanical::opcode_122(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_122(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
if (argc == 0) { if (argc == 0) {
// Used on Card 6120 (Elevator) // Used on Card 6120 (Elevator)
// Called when Exit Midde Button Pressed // Called when Exit Midde Button Pressed
@ -271,7 +271,7 @@ void MystScriptParser_Mechanical::opcode_122(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Mechanical::opcode_123(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_123(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
if (argc == 2) { if (argc == 2) {
@ -288,7 +288,7 @@ void MystScriptParser_Mechanical::opcode_123(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Mechanical::opcode_124(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_124(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
if (argc == 0) { if (argc == 0) {
@ -300,13 +300,13 @@ void MystScriptParser_Mechanical::opcode_124(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Mechanical::o_mystStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_mystStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Myst book staircase video", op); debugC(kDebugScript, "Opcode %d: Myst book staircase video", op);
_vm->_video->playMovieBlocking(_vm->wrapMovieFilename("sstairs", kMechanicalStack), 199, 108); _vm->_video->playMovieBlocking(_vm->wrapMovieFilename("sstairs", kMechanicalStack), 199, 108);
} }
void MystScriptParser_Mechanical::opcode_126(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_126(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
if (argc == 0) { if (argc == 0) {
@ -319,129 +319,77 @@ void MystScriptParser_Mechanical::opcode_126(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Mechanical::o_crystalEnterYellow(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_crystalEnterYellow(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Crystal enter", op); debugC(kDebugScript, "Opcode %d: Crystal enter", op);
_crystalLit = 3; _crystalLit = 3;
_vm->redrawArea(20); _vm->redrawArea(20);
} }
void MystScriptParser_Mechanical::o_crystalEnterGreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_crystalEnterGreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Crystal enter", op); debugC(kDebugScript, "Opcode %d: Crystal enter", op);
_crystalLit = 1; _crystalLit = 1;
_vm->redrawArea(21); _vm->redrawArea(21);
} }
void MystScriptParser_Mechanical::o_crystalEnterRed(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_crystalEnterRed(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Crystal enter", op); debugC(kDebugScript, "Opcode %d: Crystal enter", op);
_crystalLit = 2; _crystalLit = 2;
_vm->redrawArea(22); _vm->redrawArea(22);
} }
void MystScriptParser_Mechanical::o_crystalLeaveYellow(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_crystalLeaveYellow(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Crystal leave", op); debugC(kDebugScript, "Opcode %d: Crystal leave", op);
_crystalLit = 0; _crystalLit = 0;
_vm->redrawArea(20); _vm->redrawArea(20);
} }
void MystScriptParser_Mechanical::o_crystalLeaveGreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_crystalLeaveGreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Crystal leave", op); debugC(kDebugScript, "Opcode %d: Crystal leave", op);
_crystalLit = 0; _crystalLit = 0;
_vm->redrawArea(21); _vm->redrawArea(21);
} }
void MystScriptParser_Mechanical::o_crystalLeaveRed(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::o_crystalLeaveRed(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Crystal leave", op); debugC(kDebugScript, "Opcode %d: Crystal leave", op);
_crystalLit = 0; _crystalLit = 0;
_vm->redrawArea(22); _vm->redrawArea(22);
} }
static struct { void Mechanical::o_throne_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
bool enabled;
uint16 var;
} g_opcode200Parameters;
void MystScriptParser_Mechanical::opcode_200_run() {
// Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne) // Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne)
// g_opcode200Parameters.var == 0 for Achenar debugC(kDebugScript, "Opcode %d: Brother throne init", op);
// g_opcode200Parameters.var == 1 for Sirrus
// TODO: Fill in Function... _invokingResource->setEnabled(getVar(var));
// Variable indicates that this is related to Secret Panel State
} }
void MystScriptParser_Mechanical::opcode_200_disable() { void Mechanical::o_fortressStaircase_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
g_opcode200Parameters.enabled = false; debugC(kDebugScript, "Opcode %d: Staircase init", op);
g_opcode200Parameters.var = 0;
}
void MystScriptParser_Mechanical::opcode_200(uint16 op, uint16 var, uint16 argc, uint16 *argv) { _vm->_resources[argv[0]]->setEnabled(!_state.staircaseState);
// Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne) _vm->_resources[argv[1]]->setEnabled(!_state.staircaseState);
if (argc == 0) { _vm->_resources[argv[2]]->setEnabled(_state.staircaseState);
g_opcode200Parameters.var = var;
g_opcode200Parameters.enabled = true;
} else
unknown(op, var, argc, argv);
}
static struct {
uint16 u0;
uint16 u1;
uint16 u2;
bool enabled;
} g_opcode201Parameters;
void MystScriptParser_Mechanical::opcode_201_run() {
// Used for Card 6159 (Facing Corridor to Fortress Elevator)
// g_opcode201Parameters.u0
// g_opcode201Parameters.u1
// g_opcode201Parameters.u2
// TODO: Fill in Function...
}
void MystScriptParser_Mechanical::opcode_201_disable() {
g_opcode201Parameters.enabled = false;
g_opcode201Parameters.u0 = 0;
g_opcode201Parameters.u1 = 0;
g_opcode201Parameters.u2 = 0;
}
void MystScriptParser_Mechanical::opcode_201(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var);
// Used for Card 6159 (Facing Corridor to Fortress Elevator)
if (argc == 3) {
g_opcode201Parameters.u0 = argv[0];
g_opcode201Parameters.u1 = argv[1];
g_opcode201Parameters.u2 = argv[2];
g_opcode201Parameters.enabled = true;
} else
unknown(op, var, argc, argv);
} }
static struct { static struct {
bool enabled; bool enabled;
} g_opcode202Parameters; } g_opcode202Parameters;
void MystScriptParser_Mechanical::opcode_202_run() { void Mechanical::opcode_202_run() {
// Used for Card 6220 (Sirrus' Mechanical Bird) // Used for Card 6220 (Sirrus' Mechanical Bird)
// TODO: Fill in Function // TODO: Fill in Function
} }
void MystScriptParser_Mechanical::opcode_202_disable() { void Mechanical::opcode_202_disable() {
g_opcode202Parameters.enabled = false; g_opcode202Parameters.enabled = false;
} }
void MystScriptParser_Mechanical::opcode_202(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_202(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used for Card 6220 (Sirrus' Mechanical Bird) // Used for Card 6220 (Sirrus' Mechanical Bird)
if (argc == 0) if (argc == 0)
g_opcode202Parameters.enabled = true; g_opcode202Parameters.enabled = true;
@ -449,29 +397,10 @@ void MystScriptParser_Mechanical::opcode_202(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
static struct { void Mechanical::o_snakeBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
bool enabled; debugC(kDebugScript, "Opcode %d: Snake box init", op);
} g_opcode203Parameters;
void MystScriptParser_Mechanical::opcode_203_run() { _snakeBox = static_cast<MystResourceType6 *>(_invokingResource);
if (g_opcode203Parameters.enabled) {
// Used for Card 6043 (Weapons Rack with Snake Box)
// TODO: Fill in Logic for Snake Box...
}
}
void MystScriptParser_Mechanical::opcode_203_disable() {
g_opcode203Parameters.enabled = false;
}
void MystScriptParser_Mechanical::opcode_203(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var);
// Used for Card 6043 (Weapons Rack with Snake Box)
if (argc == 0)
g_opcode203Parameters.enabled = true;
else
unknown(op, var, argc, argv);
} }
static struct { static struct {
@ -479,7 +408,7 @@ static struct {
uint16 soundId; uint16 soundId;
} g_opcode204Parameters; } g_opcode204Parameters;
void MystScriptParser_Mechanical::opcode_204_run() { void Mechanical::opcode_204_run() {
if (g_opcode204Parameters.enabled) { if (g_opcode204Parameters.enabled) {
// TODO: Fill in Logic. // TODO: Fill in Logic.
// Var 12 holds Large Cog Position in range 0 to 5 // Var 12 holds Large Cog Position in range 0 to 5
@ -491,11 +420,11 @@ void MystScriptParser_Mechanical::opcode_204_run() {
} }
} }
void MystScriptParser_Mechanical::opcode_204_disable() { void Mechanical::opcode_204_disable() {
g_opcode204Parameters.enabled = false; g_opcode204Parameters.enabled = false;
} }
void MystScriptParser_Mechanical::opcode_204(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_204(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used for Card 6180 (Lower Elevator Puzzle) // Used for Card 6180 (Lower Elevator Puzzle)
@ -512,17 +441,17 @@ static struct {
bool enabled; bool enabled;
} g_opcode205Parameters; } g_opcode205Parameters;
void MystScriptParser_Mechanical::opcode_205_run() { void Mechanical::opcode_205_run() {
// Used for Card 6156 (Fortress Rotation Controls) // Used for Card 6156 (Fortress Rotation Controls)
// TODO: Fill in function... // TODO: Fill in function...
// g_opcode205Parameters.soundIdPosition[4] // g_opcode205Parameters.soundIdPosition[4]
} }
void MystScriptParser_Mechanical::opcode_205_disable() { void Mechanical::opcode_205_disable() {
g_opcode205Parameters.enabled = false; g_opcode205Parameters.enabled = false;
} }
void MystScriptParser_Mechanical::opcode_205(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_205(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used for Card 6156 (Fortress Rotation Controls) // Used for Card 6156 (Fortress Rotation Controls)
@ -545,7 +474,7 @@ static struct {
bool enabled; bool enabled;
} g_opcode206Parameters; } g_opcode206Parameters;
void MystScriptParser_Mechanical::opcode_206_run() { void Mechanical::opcode_206_run() {
if (g_opcode206Parameters.enabled) { if (g_opcode206Parameters.enabled) {
// Used for Card 6044 (Fortress Rotation Simulator) // Used for Card 6044 (Fortress Rotation Simulator)
@ -556,11 +485,11 @@ void MystScriptParser_Mechanical::opcode_206_run() {
} }
} }
void MystScriptParser_Mechanical::opcode_206_disable() { void Mechanical::opcode_206_disable() {
g_opcode206Parameters.enabled = false; g_opcode206Parameters.enabled = false;
} }
void MystScriptParser_Mechanical::opcode_206(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_206(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used for Card 6044 (Fortress Rotation Simulator) // Used for Card 6044 (Fortress Rotation Simulator)
@ -582,18 +511,18 @@ static struct {
bool enabled; bool enabled;
} g_opcode209Parameters; } g_opcode209Parameters;
void MystScriptParser_Mechanical::opcode_209_run() { void Mechanical::opcode_209_run() {
// Used for Card 6044 (Fortress Rotation Simulator) // Used for Card 6044 (Fortress Rotation Simulator)
// TODO: Implement Function For Secret Panel State as // TODO: Implement Function For Secret Panel State as
// per Opcode 200 function (Mechanical) // per Opcode 200 function (Mechanical)
} }
void MystScriptParser_Mechanical::opcode_209_disable() { void Mechanical::opcode_209_disable() {
g_opcode209Parameters.enabled = false; g_opcode209Parameters.enabled = false;
} }
void MystScriptParser_Mechanical::opcode_209(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_209(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used for Card 6044 (Fortress Rotation Simulator) // Used for Card 6044 (Fortress Rotation Simulator)
@ -603,10 +532,11 @@ void MystScriptParser_Mechanical::opcode_209(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Mechanical::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Mechanical::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used in Card 6156 (Fortress Elevator View) // Used in Card 6156 (Fortress Elevator View)
varUnusedCheck(op, var); varUnusedCheck(op, var);
// TODO: Fill in Logic. Clearing Variable for View? // TODO: Fill in Logic. Clearing Variable for View?
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Mechanical : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Mechanical : public MystScriptParser {
public: public:
MystScriptParser_Mechanical(MohawkEngine_Myst *vm); Mechanical(MohawkEngine_Myst *vm);
~MystScriptParser_Mechanical(); ~Mechanical();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -51,14 +52,8 @@ private:
void toggleVar(uint16 var); void toggleVar(uint16 var);
bool setVarValue(uint16 var, uint16 value); bool setVarValue(uint16 var, uint16 value);
void opcode_200_run();
void opcode_200_disable();
void opcode_201_run();
void opcode_201_disable();
void opcode_202_run(); void opcode_202_run();
void opcode_202_disable(); void opcode_202_disable();
void opcode_203_run();
void opcode_203_disable();
void opcode_204_run(); void opcode_204_run();
void opcode_204_disable(); void opcode_204_disable();
void opcode_205_run(); void opcode_205_run();
@ -68,7 +63,8 @@ private:
void opcode_209_run(); void opcode_209_run();
void opcode_209_disable(); void opcode_209_disable();
DECLARE_OPCODE(opcode_104); DECLARE_OPCODE(o_throneEnablePassage);
DECLARE_OPCODE(o_snakeBoxTrigger);
DECLARE_OPCODE(o_fortressStaircaseMovie); DECLARE_OPCODE(o_fortressStaircaseMovie);
DECLARE_OPCODE(opcode_121); DECLARE_OPCODE(opcode_121);
DECLARE_OPCODE(opcode_122); DECLARE_OPCODE(opcode_122);
@ -83,10 +79,10 @@ private:
DECLARE_OPCODE(o_crystalLeaveGreen); DECLARE_OPCODE(o_crystalLeaveGreen);
DECLARE_OPCODE(o_crystalLeaveRed); DECLARE_OPCODE(o_crystalLeaveRed);
DECLARE_OPCODE(opcode_200); DECLARE_OPCODE(o_throne_init);
DECLARE_OPCODE(opcode_201); DECLARE_OPCODE(o_fortressStaircase_init);
DECLARE_OPCODE(opcode_202); DECLARE_OPCODE(opcode_202);
DECLARE_OPCODE(opcode_203); DECLARE_OPCODE(o_snakeBox_init);
DECLARE_OPCODE(opcode_204); DECLARE_OPCODE(opcode_204);
DECLARE_OPCODE(opcode_205); DECLARE_OPCODE(opcode_205);
DECLARE_OPCODE(opcode_206); DECLARE_OPCODE(opcode_206);
@ -101,8 +97,11 @@ private:
uint16 _fortressPosition; // 82 uint16 _fortressPosition; // 82
uint16 _crystalLit; // 130 uint16 _crystalLit; // 130
MystResourceType6 *_snakeBox; // 156
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

File diff suppressed because it is too large Load diff

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Myst : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Myst : public MystScriptParser {
public: public:
MystScriptParser_Myst(MohawkEngine_Myst *vm); Myst(MohawkEngine_Myst *vm);
~MystScriptParser_Myst(); ~Myst();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -333,6 +334,7 @@ private:
void observatoryUpdateTime(); void observatoryUpdateTime();
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -33,25 +33,26 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Preview::MystScriptParser_Preview(MohawkEngine_Myst *vm) : MystScriptParser_Myst(vm) { Preview::Preview(MohawkEngine_Myst *vm) : Myst(vm) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_Preview::~MystScriptParser_Preview() { Preview::~Preview() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Preview::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Preview::x, #x))
#define OVERRIDE_OPCODE(opcode, x) \ #define OVERRIDE_OPCODE(opcode, x) \
for (uint32 i = 0; i < _opcodes.size(); i++) \ for (uint32 i = 0; i < _opcodes.size(); i++) \
if (_opcodes[i]->op == opcode) { \ if (_opcodes[i]->op == opcode) { \
_opcodes[i]->proc = (OpcodeProcMyst) &MystScriptParser_Preview::x; \ _opcodes[i]->proc = (OpcodeProcMyst) &Preview::x; \
_opcodes[i]->desc = #x; \ _opcodes[i]->desc = #x; \
break; \ break; \
} }
void MystScriptParser_Preview::setupOpcodes() { void Preview::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OVERRIDE_OPCODE(196, opcode_196); OVERRIDE_OPCODE(196, opcode_196);
OVERRIDE_OPCODE(197, opcode_197); OVERRIDE_OPCODE(197, opcode_197);
@ -66,7 +67,7 @@ void MystScriptParser_Preview::setupOpcodes() {
#undef OPCODE #undef OPCODE
#undef OVERRIDE_OPCODE #undef OVERRIDE_OPCODE
void MystScriptParser_Preview::opcode_196(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::opcode_196(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used on Card ... // Used on Card ...
@ -74,7 +75,7 @@ void MystScriptParser_Preview::opcode_196(uint16 op, uint16 var, uint16 argc, ui
// Voice Over and Card Advance? // Voice Over and Card Advance?
} }
void MystScriptParser_Preview::opcode_197(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::opcode_197(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used on Card ... // Used on Card ...
@ -83,7 +84,7 @@ void MystScriptParser_Preview::opcode_197(uint16 op, uint16 var, uint16 argc, ui
} }
// TODO: Merge with Opcode 42? // TODO: Merge with Opcode 42?
void MystScriptParser_Preview::opcode_198(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::opcode_198(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
if (argc == 0) { if (argc == 0) {
@ -94,7 +95,7 @@ void MystScriptParser_Preview::opcode_198(uint16 op, uint16 var, uint16 argc, ui
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
void MystScriptParser_Preview::opcode_199(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::opcode_199(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used on Card ... // Used on Card ...
@ -102,7 +103,7 @@ void MystScriptParser_Preview::opcode_199(uint16 op, uint16 var, uint16 argc, ui
// Voice Over and Card Advance? // Voice Over and Card Advance?
} }
void MystScriptParser_Preview::opcode_298(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::opcode_298(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used for Card 3000 (Closed Myst Book) // Used for Card 3000 (Closed Myst Book)
@ -125,7 +126,7 @@ void MystScriptParser_Preview::opcode_298(uint16 op, uint16 var, uint16 argc, ui
} }
} }
void MystScriptParser_Preview::opcode_299(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Preview::opcode_299(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var); varUnusedCheck(op, var);
// Used for Card 3002 (Myst Island Overview) // Used for Card 3002 (Myst Island Overview)
@ -135,4 +136,5 @@ void MystScriptParser_Preview::opcode_299(uint16 op, uint16 var, uint16 argc, ui
// can change the Myst Library to Red.. // can change the Myst Library to Red..
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Preview : public MystScriptParser_Myst { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Preview : public Myst {
public: public:
MystScriptParser_Preview(MohawkEngine_Myst *vm); Preview(MohawkEngine_Myst *vm);
~MystScriptParser_Preview(); ~Preview();
private: private:
void setupOpcodes(); void setupOpcodes();
@ -54,6 +55,7 @@ private:
DECLARE_OPCODE(opcode_299); DECLARE_OPCODE(opcode_299);
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -35,8 +35,9 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) : Selenitic::Selenitic(MohawkEngine_Myst *vm) :
MystScriptParser(vm), _state(vm->_gameState->_selenitic) { MystScriptParser(vm), _state(vm->_gameState->_selenitic) {
setupOpcodes(); setupOpcodes();
_invokingResource = NULL; _invokingResource = NULL;
@ -44,12 +45,12 @@ MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) :
_mazeRunnerDirection = 8; _mazeRunnerDirection = 8;
} }
MystScriptParser_Selenitic::~MystScriptParser_Selenitic() { Selenitic::~Selenitic() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Selenitic::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Selenitic::x, #x))
void MystScriptParser_Selenitic::setupOpcodes() { void Selenitic::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_mazeRunnerMove); OPCODE(100, o_mazeRunnerMove);
OPCODE(101, o_mazeRunnerSoundRepeat); OPCODE(101, o_mazeRunnerSoundRepeat);
@ -82,16 +83,16 @@ void MystScriptParser_Selenitic::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Selenitic::disablePersistentScripts() { void Selenitic::disablePersistentScripts() {
_soundReceiverRunning = false; _soundReceiverRunning = false;
} }
void MystScriptParser_Selenitic::runPersistentScripts() { void Selenitic::runPersistentScripts() {
if (_soundReceiverRunning) if (_soundReceiverRunning)
soundReceiver_run(); soundReceiver_run();
} }
uint16 MystScriptParser_Selenitic::getVar(uint16 var) { uint16 Selenitic::getVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Sound receiver emitters enabled case 0: // Sound receiver emitters enabled
return _state.emitterEnabledWind; return _state.emitterEnabledWind;
@ -166,7 +167,7 @@ uint16 MystScriptParser_Selenitic::getVar(uint16 var) {
} }
} }
void MystScriptParser_Selenitic::toggleVar(uint16 var) { void Selenitic::toggleVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Sound receiver emitters enabled case 0: // Sound receiver emitters enabled
_state.emitterEnabledWind = (_state.emitterEnabledWind + 1) % 2; _state.emitterEnabledWind = (_state.emitterEnabledWind + 1) % 2;
@ -211,7 +212,7 @@ void MystScriptParser_Selenitic::toggleVar(uint16 var) {
} }
} }
bool MystScriptParser_Selenitic::setVarValue(uint16 var, uint16 value) { bool Selenitic::setVarValue(uint16 var, uint16 value) {
bool refresh = false; bool refresh = false;
switch (var) { switch (var) {
@ -283,7 +284,7 @@ bool MystScriptParser_Selenitic::setVarValue(uint16 var, uint16 value) {
return refresh; return refresh;
} }
void MystScriptParser_Selenitic::o_mazeRunnerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
uint16 oldPosition = _mazeRunnerPosition; uint16 oldPosition = _mazeRunnerPosition;
uint16 move = var; uint16 move = var;
@ -304,7 +305,7 @@ void MystScriptParser_Selenitic::o_mazeRunnerMove(uint16 op, uint16 var, uint16
} }
} }
void MystScriptParser_Selenitic::mazeRunnerBacktrack(uint16 &oldPosition) { void Selenitic::mazeRunnerBacktrack(uint16 &oldPosition) {
if (oldPosition == 289) if (oldPosition == 289)
_mazeRunnerDirection = 3; _mazeRunnerDirection = 3;
@ -365,7 +366,7 @@ void MystScriptParser_Selenitic::mazeRunnerBacktrack(uint16 &oldPosition) {
} }
} }
void MystScriptParser_Selenitic::mazeRunnerPlayVideo(uint16 video, uint16 pos) { void Selenitic::mazeRunnerPlayVideo(uint16 video, uint16 pos) {
Common::String file; Common::String file;
switch (video) { switch (video) {
@ -486,7 +487,7 @@ void MystScriptParser_Selenitic::mazeRunnerPlayVideo(uint16 video, uint16 pos) {
} }
} }
void MystScriptParser_Selenitic::mazeRunnerUpdateCompass() { void Selenitic::mazeRunnerUpdateCompass() {
if (_mazeRunnerPosition == 288 || _mazeRunnerPosition == 289) if (_mazeRunnerPosition == 288 || _mazeRunnerPosition == 289)
_mazeRunnerDirection = 8; _mazeRunnerDirection = 8;
else else
@ -495,12 +496,12 @@ void MystScriptParser_Selenitic::mazeRunnerUpdateCompass() {
_mazeRunnerCompass->drawConditionalDataToScreen(_mazeRunnerDirection); _mazeRunnerCompass->drawConditionalDataToScreen(_mazeRunnerDirection);
} }
bool MystScriptParser_Selenitic::mazeRunnerForwardAllowed(uint16 position) { bool Selenitic::mazeRunnerForwardAllowed(uint16 position) {
uint16 move = _mazeRunnerVideos[position][1]; uint16 move = _mazeRunnerVideos[position][1];
return move == 6 || move == 7; return move == 6 || move == 7;
} }
void MystScriptParser_Selenitic::mazeRunnerPlaySoundHelp() { void Selenitic::mazeRunnerPlaySoundHelp() {
uint16 soundId = 0; uint16 soundId = 0;
_mazeRunnerLight->drawConditionalDataToScreen(1); _mazeRunnerLight->drawConditionalDataToScreen(1);
@ -564,14 +565,14 @@ void MystScriptParser_Selenitic::mazeRunnerPlaySoundHelp() {
_mazeRunnerLight->drawConditionalDataToScreen(0); _mazeRunnerLight->drawConditionalDataToScreen(0);
} }
void MystScriptParser_Selenitic::o_mazeRunnerSoundRepeat(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerSoundRepeat(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
mazeRunnerPlaySoundHelp(); mazeRunnerPlaySoundHelp();
} }
/** /**
* Sound receiver sigma button * Sound receiver sigma button
*/ */
void MystScriptParser_Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver sigma button", op); debugC(kDebugScript, "Opcode %d: Sound receiver sigma button", op);
_vm->_cursor->hideCursor(); _vm->_cursor->hideCursor();
@ -623,7 +624,7 @@ void MystScriptParser_Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uin
/** /**
* Sound receiver right button * Sound receiver right button
*/ */
void MystScriptParser_Selenitic::o_soundReceiverRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiverRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver right", op); debugC(kDebugScript, "Opcode %d: Sound receiver right", op);
soundReceiverLeftRight(1); soundReceiverLeftRight(1);
@ -632,13 +633,13 @@ void MystScriptParser_Selenitic::o_soundReceiverRight(uint16 op, uint16 var, uin
/** /**
* Sound receiver left button * Sound receiver left button
*/ */
void MystScriptParser_Selenitic::o_soundReceiverLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiverLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver left", op); debugC(kDebugScript, "Opcode %d: Sound receiver left", op);
soundReceiverLeftRight(2); soundReceiverLeftRight(2);
} }
void MystScriptParser_Selenitic::soundReceiverLeftRight(uint direction) { void Selenitic::soundReceiverLeftRight(uint direction) {
if (_soundReceiverSigmaPressed) { if (_soundReceiverSigmaPressed) {
_soundReceiverSigmaButton->drawConditionalDataToScreen(0); _soundReceiverSigmaButton->drawConditionalDataToScreen(0);
@ -659,7 +660,7 @@ void MystScriptParser_Selenitic::soundReceiverLeftRight(uint direction) {
soundReceiverUpdate(); soundReceiverUpdate();
} }
void MystScriptParser_Selenitic::soundReceiverUpdate() { void Selenitic::soundReceiverUpdate() {
if (_soundReceiverDirection == 1) if (_soundReceiverDirection == 1)
*_soundReceiverPosition = ((*_soundReceiverPosition) + _soundReceiverSpeed) % 3600; *_soundReceiverPosition = ((*_soundReceiverPosition) + _soundReceiverSpeed) % 3600;
else if (_soundReceiverDirection == 2) else if (_soundReceiverDirection == 2)
@ -668,7 +669,7 @@ void MystScriptParser_Selenitic::soundReceiverUpdate() {
soundReceiverDrawView(); soundReceiverDrawView();
} }
void MystScriptParser_Selenitic::soundReceiverDrawView() { void Selenitic::soundReceiverDrawView() {
uint32 left = ((*_soundReceiverPosition) * 1800) / 3600; uint32 left = ((*_soundReceiverPosition) * 1800) / 3600;
_soundReceiverViewer->_subImages->rect.left = left; _soundReceiverViewer->_subImages->rect.left = left;
@ -679,7 +680,7 @@ void MystScriptParser_Selenitic::soundReceiverDrawView() {
soundReceiverDrawAngle(); soundReceiverDrawAngle();
} }
void MystScriptParser_Selenitic::soundReceiverDrawAngle() { void Selenitic::soundReceiverDrawAngle() {
_vm->redrawResource(_soundReceiverAngle1); _vm->redrawResource(_soundReceiverAngle1);
_vm->redrawResource(_soundReceiverAngle2); _vm->redrawResource(_soundReceiverAngle2);
_vm->redrawResource(_soundReceiverAngle3); _vm->redrawResource(_soundReceiverAngle3);
@ -689,7 +690,7 @@ void MystScriptParser_Selenitic::soundReceiverDrawAngle() {
/** /**
* Sound receiver source selection buttons * Sound receiver source selection buttons
*/ */
void MystScriptParser_Selenitic::o_soundReceiverSource(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiverSource(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver source", op); debugC(kDebugScript, "Opcode %d: Sound receiver source", op);
if (_soundReceiverSigmaPressed) { if (_soundReceiverSigmaPressed) {
@ -723,7 +724,7 @@ void MystScriptParser_Selenitic::o_soundReceiverSource(uint16 op, uint16 var, ui
_vm->_cursor->showCursor(); _vm->_cursor->showCursor();
} }
void MystScriptParser_Selenitic::o_mazeRunnerDoorButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerDoorButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used for Selenitic Maze Runner Exit Logic // Used for Selenitic Maze Runner Exit Logic
uint16 cardIdExit = argv[0]; uint16 cardIdExit = argv[0];
uint16 cardIdEntry = argv[1]; uint16 cardIdEntry = argv[1];
@ -739,13 +740,13 @@ void MystScriptParser_Selenitic::o_mazeRunnerDoorButton(uint16 op, uint16 var, u
} }
} }
void MystScriptParser_Selenitic::o_soundReceiverUpdateSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiverUpdateSound(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver update sound", op); debugC(kDebugScript, "Opcode %d: Sound receiver update sound", op);
soundReceiverUpdateSound(); soundReceiverUpdateSound();
} }
uint16 MystScriptParser_Selenitic::soundLockCurrentSound(uint16 position, bool pixels) { uint16 Selenitic::soundLockCurrentSound(uint16 position, bool pixels) {
if ((pixels && position < 96) || (!pixels && position == 0)) if ((pixels && position < 96) || (!pixels && position == 0))
return 289; return 289;
else if ((pixels && position < 108) || (!pixels && position == 1)) else if ((pixels && position < 108) || (!pixels && position == 1))
@ -770,7 +771,7 @@ uint16 MystScriptParser_Selenitic::soundLockCurrentSound(uint16 position, bool p
return 0; return 0;
} }
MystResourceType10 *MystScriptParser_Selenitic::soundLockSliderFromVar(uint16 var) { MystResourceType10 *Selenitic::soundLockSliderFromVar(uint16 var) {
switch (var) { switch (var) {
case 20: case 20:
return _soundLockSlider1; return _soundLockSlider1;
@ -787,7 +788,7 @@ MystResourceType10 *MystScriptParser_Selenitic::soundLockSliderFromVar(uint16 va
return 0; return 0;
} }
void MystScriptParser_Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock move", op); debugC(kDebugScript, "Opcode %d: Sound lock move", op);
MystResourceType10 *slider = soundLockSliderFromVar(var); MystResourceType10 *slider = soundLockSliderFromVar(var);
@ -799,7 +800,7 @@ void MystScriptParser_Selenitic::o_soundLockMove(uint16 op, uint16 var, uint16 a
} }
} }
void MystScriptParser_Selenitic::o_soundLockStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundLockStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock start move", op); debugC(kDebugScript, "Opcode %d: Sound lock start move", op);
MystResourceType10 *slider = soundLockSliderFromVar(var); MystResourceType10 *slider = soundLockSliderFromVar(var);
@ -811,7 +812,7 @@ void MystScriptParser_Selenitic::o_soundLockStartMove(uint16 op, uint16 var, uin
_vm->_sound->replaceSoundMyst(_soundLockSoundId, Audio::Mixer::kMaxChannelVolume, true); _vm->_sound->replaceSoundMyst(_soundLockSoundId, Audio::Mixer::kMaxChannelVolume, true);
} }
void MystScriptParser_Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock end move", op); debugC(kDebugScript, "Opcode %d: Sound lock end move", op);
MystResourceType10 *slider = soundLockSliderFromVar(var); MystResourceType10 *slider = soundLockSliderFromVar(var);
@ -855,7 +856,7 @@ void MystScriptParser_Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint1
_vm->_sound->resumeBackgroundMyst(); _vm->_sound->resumeBackgroundMyst();
} }
void MystScriptParser_Selenitic::soundLockCheckSolution(MystResourceType10 *slider, uint16 value, uint16 solution, bool &solved) { void Selenitic::soundLockCheckSolution(MystResourceType10 *slider, uint16 value, uint16 solution, bool &solved) {
slider->drawConditionalDataToScreen(2); slider->drawConditionalDataToScreen(2);
_vm->_sound->replaceSoundMyst(soundLockCurrentSound(value / 12, false)); _vm->_sound->replaceSoundMyst(soundLockCurrentSound(value / 12, false));
_vm->_system->delayMillis(1500); _vm->_system->delayMillis(1500);
@ -867,7 +868,7 @@ void MystScriptParser_Selenitic::soundLockCheckSolution(MystResourceType10 *slid
_vm->_sound->stopSound(); _vm->_sound->stopSound();
} }
void MystScriptParser_Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock button", op); debugC(kDebugScript, "Opcode %d: Sound lock button", op);
bool solved = true; bool solved = true;
@ -905,7 +906,7 @@ void MystScriptParser_Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16
_vm->_cursor->showCursor(); _vm->_cursor->showCursor();
} }
void MystScriptParser_Selenitic::o_soundReceiverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver end move", op); debugC(kDebugScript, "Opcode %d: Sound receiver end move", op);
uint16 oldDirection = _soundReceiverDirection; uint16 oldDirection = _soundReceiverDirection;
@ -922,19 +923,19 @@ void MystScriptParser_Selenitic::o_soundReceiverEndMove(uint16 op, uint16 var, u
} }
} }
void MystScriptParser_Selenitic::o_mazeRunnerCompass_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerCompass_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_mazeRunnerCompass = static_cast<MystResourceType8 *>(_invokingResource); _mazeRunnerCompass = static_cast<MystResourceType8 *>(_invokingResource);
} }
void MystScriptParser_Selenitic::o_mazeRunnerWindow_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerWindow_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_mazeRunnerWindow = static_cast<MystResourceType8 *>(_invokingResource); _mazeRunnerWindow = static_cast<MystResourceType8 *>(_invokingResource);
} }
void MystScriptParser_Selenitic::o_mazeRunnerLight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerLight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_mazeRunnerLight = static_cast<MystResourceType8 *>(_invokingResource); _mazeRunnerLight = static_cast<MystResourceType8 *>(_invokingResource);
} }
void MystScriptParser_Selenitic::soundReceiver_run() { void Selenitic::soundReceiver_run() {
if (_soundReceiverStartTime) { if (_soundReceiverStartTime) {
if (_soundReceiverDirection) { if (_soundReceiverDirection) {
uint32 currentTime = _vm->_system->getMillis(); uint32 currentTime = _vm->_system->getMillis();
@ -952,7 +953,7 @@ void MystScriptParser_Selenitic::soundReceiver_run() {
} }
} }
void MystScriptParser_Selenitic::soundReceiverIncreaseSpeed() { void Selenitic::soundReceiverIncreaseSpeed() {
switch (_soundReceiverSpeed) { switch (_soundReceiverSpeed) {
case 1: case 1:
_soundReceiverSpeed = 10; _soundReceiverSpeed = 10;
@ -966,12 +967,12 @@ void MystScriptParser_Selenitic::soundReceiverIncreaseSpeed() {
} }
} }
void MystScriptParser_Selenitic::soundReceiverUpdateSound() { void Selenitic::soundReceiverUpdateSound() {
uint16 soundId = soundReceiverCurrentSound(_state.soundReceiverCurrentSource, *_soundReceiverPosition); uint16 soundId = soundReceiverCurrentSound(_state.soundReceiverCurrentSource, *_soundReceiverPosition);
_vm->_sound->replaceSoundMyst(soundId); _vm->_sound->replaceSoundMyst(soundId);
} }
uint16 MystScriptParser_Selenitic::soundReceiverCurrentSound(uint16 source, uint16 position) { uint16 Selenitic::soundReceiverCurrentSound(uint16 source, uint16 position) {
uint16 solution = 0; uint16 solution = 0;
bool sourceEnabled = false; bool sourceEnabled = false;
soundReceiverSolution(source, solution, sourceEnabled); soundReceiverSolution(source, solution, sourceEnabled);
@ -1022,7 +1023,7 @@ uint16 MystScriptParser_Selenitic::soundReceiverCurrentSound(uint16 source, uint
return soundId; return soundId;
} }
void MystScriptParser_Selenitic::soundReceiverSolution(uint16 source, uint16 &solution, bool &enabled) { void Selenitic::soundReceiverSolution(uint16 source, uint16 &solution, bool &enabled) {
switch (source) { switch (source) {
case 0: case 0:
enabled = _state.emitterEnabledWater; enabled = _state.emitterEnabledWater;
@ -1047,7 +1048,7 @@ void MystScriptParser_Selenitic::soundReceiverSolution(uint16 source, uint16 &so
} }
} }
void MystScriptParser_Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound receiver init", op); debugC(kDebugScript, "Opcode %d: Sound receiver init", op);
// Used for Card 1245 (Sound Receiver) // Used for Card 1245 (Sound Receiver)
@ -1074,7 +1075,7 @@ void MystScriptParser_Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uin
_soundReceiverSigmaPressed = false; _soundReceiverSigmaPressed = false;
} }
void MystScriptParser_Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Sound lock init", op); debugC(kDebugScript, "Opcode %d: Sound lock init", op);
for (uint i = 0; i < _vm->_resources.size(); i++) { for (uint i = 0; i < _vm->_resources.size(); i++) {
@ -1109,15 +1110,15 @@ void MystScriptParser_Selenitic::o_soundLock_init(uint16 op, uint16 var, uint16
_soundLockSoundId = 0; _soundLockSoundId = 0;
} }
void MystScriptParser_Selenitic::o_mazeRunnerRight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerRight_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_mazeRunnerRightButton = static_cast<MystResourceType8 *>(_invokingResource); _mazeRunnerRightButton = static_cast<MystResourceType8 *>(_invokingResource);
} }
void MystScriptParser_Selenitic::o_mazeRunnerLeft_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Selenitic::o_mazeRunnerLeft_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_mazeRunnerLeftButton = static_cast<MystResourceType8 *>(_invokingResource); _mazeRunnerLeftButton = static_cast<MystResourceType8 *>(_invokingResource);
} }
const uint16 MystScriptParser_Selenitic::_mazeRunnerMap[300][4] = { const uint16 Selenitic::_mazeRunnerMap[300][4] = {
{8, 7, 1, 288}, {8, 7, 1, 288},
{1, 0, 2, 288}, {1, 0, 2, 288},
{2, 1, 3, 288}, {2, 1, 3, 288},
@ -1420,7 +1421,7 @@ const uint16 MystScriptParser_Selenitic::_mazeRunnerMap[300][4] = {
{ 0, 0, 0, 0} { 0, 0, 0, 0}
}; };
const uint8 MystScriptParser_Selenitic::_mazeRunnerVideos[300][4] = { const uint8 Selenitic::_mazeRunnerVideos[300][4] = {
{3, 6, 10, 17}, {3, 6, 10, 17},
{0, 5, 8, 17}, {0, 5, 8, 17},
{0, 4, 8, 17}, {0, 4, 8, 17},
@ -1723,4 +1724,5 @@ const uint8 MystScriptParser_Selenitic::_mazeRunnerVideos[300][4] = {
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,16 +32,17 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
class MystResourceType8; class MystResourceType8;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Selenitic : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Selenitic : public MystScriptParser {
public: public:
MystScriptParser_Selenitic(MohawkEngine_Myst *vm); Selenitic(MohawkEngine_Myst *vm);
~MystScriptParser_Selenitic(); ~Selenitic();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -135,6 +136,7 @@ private:
void mazeRunnerBacktrack(uint16 &oldPosition); void mazeRunnerBacktrack(uint16 &oldPosition);
}; };
} // End of namespace MystStacks
} }
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -33,19 +33,18 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
// NOTE: Credits Start Card is 10000 Slides::Slides(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
MystScriptParser_Slides::MystScriptParser_Slides(MohawkEngine_Myst *vm) : MystScriptParser(vm) {
setupOpcodes(); setupOpcodes();
} }
MystScriptParser_Slides::~MystScriptParser_Slides() { Slides::~Slides() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Slides::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Slides::x, #x))
void MystScriptParser_Slides::setupOpcodes() { void Slides::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_returnToMenu); OPCODE(100, o_returnToMenu);
@ -55,11 +54,11 @@ void MystScriptParser_Slides::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Slides::disablePersistentScripts() { void Slides::disablePersistentScripts() {
_cardSwapEnabled = false; _cardSwapEnabled = false;
} }
void MystScriptParser_Slides::runPersistentScripts() { void Slides::runPersistentScripts() {
if (_cardSwapEnabled) { if (_cardSwapEnabled) {
// Used on Cards... // Used on Cards...
if (_vm->_system->getMillis() - _lastCardTime >= 2 * 1000) if (_vm->_system->getMillis() - _lastCardTime >= 2 * 1000)
@ -67,11 +66,11 @@ void MystScriptParser_Slides::runPersistentScripts() {
} }
} }
void MystScriptParser_Slides::o_returnToMenu(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Slides::o_returnToMenu(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_vm->changeToStack(kDemoStack, 2001, 0, 0); _vm->changeToStack(kDemoStack, 2001, 0, 0);
} }
void MystScriptParser_Slides::o_setCardSwap(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Slides::o_setCardSwap(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used on Cards... // Used on Cards...
if (argc == 1) { if (argc == 1) {
_nextCardID = argv[0]; _nextCardID = argv[0];
@ -81,4 +80,5 @@ void MystScriptParser_Slides::o_setCardSwap(uint16 op, uint16 var, uint16 argc,
unknown(op, var, argc, argv); unknown(op, var, argc, argv);
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Slides : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Slides : public MystScriptParser {
public: public:
MystScriptParser_Slides(MohawkEngine_Myst *vm); Slides(MohawkEngine_Myst *vm);
~MystScriptParser_Slides(); ~Slides();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -57,6 +58,7 @@ private:
uint32 _lastCardTime; uint32 _lastCardTime;
}; };
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -35,8 +35,9 @@
#include "gui/message.h" #include "gui/message.h"
namespace Mohawk { namespace Mohawk {
namespace MystStacks {
MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) : Stoneship::Stoneship(MohawkEngine_Myst *vm) :
MystScriptParser(vm), _state(vm->_gameState->_stoneship) { MystScriptParser(vm), _state(vm->_gameState->_stoneship) {
setupOpcodes(); setupOpcodes();
@ -60,12 +61,12 @@ MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) :
_state.generatorPowerAvailable = 0; _state.generatorPowerAvailable = 0;
} }
MystScriptParser_Stoneship::~MystScriptParser_Stoneship() { Stoneship::~Stoneship() {
} }
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Stoneship::x, #x)) #define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Stoneship::x, #x))
void MystScriptParser_Stoneship::setupOpcodes() { void Stoneship::setupOpcodes() {
// "Stack-Specific" Opcodes // "Stack-Specific" Opcodes
OPCODE(100, o_pumpTurnOff); OPCODE(100, o_pumpTurnOff);
OPCODE(101, o_brotherDoorOpen); OPCODE(101, o_brotherDoorOpen);
@ -111,14 +112,14 @@ void MystScriptParser_Stoneship::setupOpcodes() {
#undef OPCODE #undef OPCODE
void MystScriptParser_Stoneship::disablePersistentScripts() { void Stoneship::disablePersistentScripts() {
_batteryCharging = false; _batteryCharging = false;
_batteryDepleting = false; _batteryDepleting = false;
_batteryGaugeRunning = false; _batteryGaugeRunning = false;
_telescopeRunning = false; _telescopeRunning = false;
} }
void MystScriptParser_Stoneship::runPersistentScripts() { void Stoneship::runPersistentScripts() {
if (_batteryCharging) if (_batteryCharging)
chargeBattery_run(); chargeBattery_run();
@ -135,7 +136,7 @@ void MystScriptParser_Stoneship::runPersistentScripts() {
tunnel_run(); tunnel_run();
} }
uint16 MystScriptParser_Stoneship::getVar(uint16 var) { uint16 Stoneship::getVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Water Drained From Lighthouse / Right Button Of Pump case 0: // Water Drained From Lighthouse / Right Button Of Pump
return _state.pumpState == 4; return _state.pumpState == 4;
@ -260,7 +261,7 @@ uint16 MystScriptParser_Stoneship::getVar(uint16 var) {
} }
} }
void MystScriptParser_Stoneship::toggleVar(uint16 var) { void Stoneship::toggleVar(uint16 var) {
switch(var) { switch(var) {
case 0: // Water Drained From Lighthouse / Right Button Of Pump case 0: // Water Drained From Lighthouse / Right Button Of Pump
if (_state.pumpState == 4) if (_state.pumpState == 4)
@ -326,7 +327,7 @@ void MystScriptParser_Stoneship::toggleVar(uint16 var) {
} }
} }
bool MystScriptParser_Stoneship::setVarValue(uint16 var, uint16 value) { bool Stoneship::setVarValue(uint16 var, uint16 value) {
bool refresh = false; bool refresh = false;
switch (var) { switch (var) {
@ -380,7 +381,7 @@ bool MystScriptParser_Stoneship::setVarValue(uint16 var, uint16 value) {
return refresh; return refresh;
} }
void MystScriptParser_Stoneship::o_pumpTurnOff(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_pumpTurnOff(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Turn off previous pump selection", op); debugC(kDebugScript, "Opcode %d: Turn off previous pump selection", op);
if (_state.pumpState) { if (_state.pumpState) {
@ -410,7 +411,7 @@ void MystScriptParser_Stoneship::o_pumpTurnOff(uint16 op, uint16 var, uint16 arg
} }
} }
void MystScriptParser_Stoneship::o_brotherDoorOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_brotherDoorOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open brother door", op); debugC(kDebugScript, "Opcode %d: Open brother door", op);
_brotherDoorOpen = 1; _brotherDoorOpen = 1;
@ -418,7 +419,7 @@ void MystScriptParser_Stoneship::o_brotherDoorOpen(uint16 op, uint16 var, uint16
animatedUpdate(argc, argv, 5); animatedUpdate(argc, argv, 5);
} }
void MystScriptParser_Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Play Book Room Movie", op); debugC(kDebugScript, "Opcode %d: Play Book Room Movie", op);
uint16 startTime = argv[0]; uint16 startTime = argv[0];
@ -429,7 +430,7 @@ void MystScriptParser_Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16
_vm->_video->waitUntilMovieEnds(book); _vm->_video->waitUntilMovieEnds(book);
} }
void MystScriptParser_Stoneship::o_drawerOpenSirius(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_drawerOpenSirius(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open drawer", op); debugC(kDebugScript, "Opcode %d: Open drawer", op);
MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]); MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
@ -447,18 +448,18 @@ void MystScriptParser_Stoneship::o_drawerOpenSirius(uint16 op, uint16 var, uint1
_vm->_gfx->runTransition(transition, drawer->getRect(), 25, 5); _vm->_gfx->runTransition(transition, drawer->getRect(), 25, 5);
} }
void MystScriptParser_Stoneship::o_drawerClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_drawerClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Close drawer", op); debugC(kDebugScript, "Opcode %d: Close drawer", op);
drawerClose(argv[0]); drawerClose(argv[0]);
} }
void MystScriptParser_Stoneship::o_telescopeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_telescopeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
_telescopeOldMouse = mouse.x; _telescopeOldMouse = mouse.x;
_vm->_cursor->setCursor(700); _vm->_cursor->setCursor(700);
} }
void MystScriptParser_Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Telescope move", op); debugC(kDebugScript, "Opcode %d: Telescope move", op);
MystResourceType11 *display = static_cast<MystResourceType11 *>(_invokingResource); MystResourceType11 *display = static_cast<MystResourceType11 *>(_invokingResource);
@ -477,11 +478,11 @@ void MystScriptParser_Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 a
_vm->_system->updateScreen(); _vm->_system->updateScreen();
} }
void MystScriptParser_Stoneship::o_telescopeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_telescopeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
_vm->checkCursorHints(); _vm->checkCursorHints();
} }
void MystScriptParser_Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generator start", op); debugC(kDebugScript, "Opcode %d: Generator start", op);
MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource); MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource);
@ -507,7 +508,7 @@ void MystScriptParser_Stoneship::o_generatorStart(uint16 op, uint16 var, uint16
_vm->_sound->replaceSoundMyst(soundId, Audio::Mixer::kMaxChannelVolume, true); _vm->_sound->replaceSoundMyst(soundId, Audio::Mixer::kMaxChannelVolume, true);
} }
void MystScriptParser_Stoneship::o_generatorStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_generatorStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Generator stop", op); debugC(kDebugScript, "Opcode %d: Generator stop", op);
_batteryCharging = false; _batteryCharging = false;
@ -534,7 +535,7 @@ void MystScriptParser_Stoneship::o_generatorStop(uint16 op, uint16 var, uint16 a
_vm->_sound->replaceSoundMyst(soundId); _vm->_sound->replaceSoundMyst(soundId);
} }
void MystScriptParser_Stoneship::chargeBattery_run() { void Stoneship::chargeBattery_run() {
uint32 time = _vm->_system->getMillis(); uint32 time = _vm->_system->getMillis();
if (time > _batteryNextTime) { if (time > _batteryNextTime) {
@ -543,7 +544,7 @@ void MystScriptParser_Stoneship::chargeBattery_run() {
} }
} }
uint16 MystScriptParser_Stoneship::batteryRemainingCharge() { uint16 Stoneship::batteryRemainingCharge() {
uint32 time = _vm->_system->getMillis(); uint32 time = _vm->_system->getMillis();
if (_state.generatorDepletionTime > time) { if (_state.generatorDepletionTime > time) {
@ -553,7 +554,7 @@ uint16 MystScriptParser_Stoneship::batteryRemainingCharge() {
} }
} }
void MystScriptParser_Stoneship::batteryDeplete_run() { void Stoneship::batteryDeplete_run() {
uint32 time = _vm->_system->getMillis(); uint32 time = _vm->_system->getMillis();
if (time > _batteryNextTime) { if (time > _batteryNextTime) {
@ -574,7 +575,7 @@ void MystScriptParser_Stoneship::batteryDeplete_run() {
} }
} }
void MystScriptParser_Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Open drawer", op); debugC(kDebugScript, "Opcode %d: Open drawer", op);
MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]); MystResourceType8 *drawer = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]);
@ -582,7 +583,7 @@ void MystScriptParser_Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint
_vm->_gfx->runTransition(5, drawer->getRect(), 25, 5); _vm->_gfx->runTransition(5, drawer->getRect(), 25, 5);
} }
void MystScriptParser_Stoneship::o_hologramPlayback(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramPlayback(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used for Card 2013 (Achenar's Rose-Skull Hologram) // Used for Card 2013 (Achenar's Rose-Skull Hologram)
debugC(kDebugScript, "Opcode %d: Rose-Skull Hologram Playback", op); debugC(kDebugScript, "Opcode %d: Rose-Skull Hologram Playback", op);
@ -604,12 +605,12 @@ void MystScriptParser_Stoneship::o_hologramPlayback(uint16 op, uint16 var, uint1
_vm->_video->delayUntilMovieEnds(displayMovie); _vm->_video->delayUntilMovieEnds(displayMovie);
} }
void MystScriptParser_Stoneship::o_hologramSelectionStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramSelectionStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram start move", op); debugC(kDebugScript, "Opcode %d: Hologram start move", op);
//_vm->_cursor->setCursor(0); //_vm->_cursor->setCursor(0);
} }
void MystScriptParser_Stoneship::o_hologramSelectionMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramSelectionMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram move", op); debugC(kDebugScript, "Opcode %d: Hologram move", op);
MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource); MystResourceType11 *handle = static_cast<MystResourceType11 *>(_invokingResource);
@ -636,12 +637,12 @@ void MystScriptParser_Stoneship::o_hologramSelectionMove(uint16 op, uint16 var,
} }
} }
void MystScriptParser_Stoneship::o_hologramSelectionStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramSelectionStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram stop move", op); debugC(kDebugScript, "Opcode %d: Hologram stop move", op);
_vm->checkCursorHints(); _vm->checkCursorHints();
} }
void MystScriptParser_Stoneship::o_compassButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_compassButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Compass rose button pressed", op); debugC(kDebugScript, "Opcode %d: Compass rose button pressed", op);
// Used on Card 2111 (Compass Rose) // Used on Card 2111 (Compass Rose)
// Called when Button Clicked. // Called when Button Clicked.
@ -663,7 +664,7 @@ void MystScriptParser_Stoneship::o_compassButton(uint16 op, uint16 var, uint16 a
o_redrawCard(op, var, argc, argv); o_redrawCard(op, var, argc, argv);
} }
void MystScriptParser_Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Chest valve videos", op); debugC(kDebugScript, "Opcode %d: Chest valve videos", op);
Common::String movie = _vm->wrapMovieFilename("ligspig", kStoneshipStack); Common::String movie = _vm->wrapMovieFilename("ligspig", kStoneshipStack);
@ -699,7 +700,7 @@ void MystScriptParser_Stoneship::o_chestValveVideos(uint16 op, uint16 var, uint1
} }
} }
void MystScriptParser_Stoneship::o_chestDropKey(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_chestDropKey(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: drop chest key", op); debugC(kDebugScript, "Opcode %d: drop chest key", op);
// If holding Key to Lamp Room Trapdoor, drop to bottom of // If holding Key to Lamp Room Trapdoor, drop to bottom of
@ -710,7 +711,7 @@ void MystScriptParser_Stoneship::o_chestDropKey(uint16 op, uint16 var, uint16 ar
} }
} }
void MystScriptParser_Stoneship::o_trapLockOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_trapLockOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Trap lock open video", op); debugC(kDebugScript, "Opcode %d: Trap lock open video", op);
Common::String movie = _vm->wrapMovieFilename("openloc", kStoneshipStack); Common::String movie = _vm->wrapMovieFilename("openloc", kStoneshipStack);
@ -729,7 +730,7 @@ void MystScriptParser_Stoneship::o_trapLockOpen(uint16 op, uint16 var, uint16 ar
_vm->_sound->playSound(4143); _vm->_sound->playSound(4143);
} }
void MystScriptParser_Stoneship::o_sideDoorsMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_sideDoorsMovies(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used for Cards 2285, 2289, 2247, 2251 (Side Doors in Tunnels Down To Brothers Rooms) // Used for Cards 2285, 2289, 2247, 2251 (Side Doors in Tunnels Down To Brothers Rooms)
uint16 movieId = argv[0]; uint16 movieId = argv[0];
@ -765,14 +766,14 @@ void MystScriptParser_Stoneship::o_sideDoorsMovies(uint16 op, uint16 var, uint16
_vm->_cursor->showCursor(); _vm->_cursor->showCursor();
} }
void MystScriptParser_Stoneship::o_cloudOrbEnter(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_cloudOrbEnter(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Cloud orb enter", op); debugC(kDebugScript, "Opcode %d: Cloud orb enter", op);
_vm->_sound->replaceSoundMyst(_cloudOrbSound, Audio::Mixer::kMaxChannelVolume, true); _vm->_sound->replaceSoundMyst(_cloudOrbSound, Audio::Mixer::kMaxChannelVolume, true);
_cloudOrbMovie->playMovie(); _cloudOrbMovie->playMovie();
} }
void MystScriptParser_Stoneship::o_cloudOrbLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_cloudOrbLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Cloud orb leave", op); debugC(kDebugScript, "Opcode %d: Cloud orb leave", op);
_cloudOrbMovie->pauseMovie(true); _cloudOrbMovie->pauseMovie(true);
@ -780,7 +781,7 @@ void MystScriptParser_Stoneship::o_cloudOrbLeave(uint16 op, uint16 var, uint16 a
_vm->_gfx->runTransition(5, _invokingResource->getRect(), 4, 0); _vm->_gfx->runTransition(5, _invokingResource->getRect(), 4, 0);
} }
void MystScriptParser_Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Close open drawer", op); debugC(kDebugScript, "Opcode %d: Close open drawer", op);
uint16 drawerOpen = getVar(var); uint16 drawerOpen = getVar(var);
@ -788,7 +789,7 @@ void MystScriptParser_Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint
drawerClose(argv[0] + drawerOpen - 1); drawerClose(argv[0] + drawerOpen - 1);
} }
void MystScriptParser_Stoneship::drawerClose(uint16 drawer) { void Stoneship::drawerClose(uint16 drawer) {
_chestDrawersOpen = 0; _chestDrawersOpen = 0;
_vm->drawCardBackground(); _vm->drawCardBackground();
_vm->drawResourceImages(); _vm->drawResourceImages();
@ -797,19 +798,19 @@ void MystScriptParser_Stoneship::drawerClose(uint16 drawer) {
_vm->_gfx->runTransition(6, res->getRect(), 25, 5); _vm->_gfx->runTransition(6, res->getRect(), 25, 5);
} }
void MystScriptParser_Stoneship::o_hologramDisplay_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramDisplay_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram display init", op); debugC(kDebugScript, "Opcode %d: Hologram display init", op);
_hologramDisplay = static_cast<MystResourceType6 *>(_invokingResource); _hologramDisplay = static_cast<MystResourceType6 *>(_invokingResource);
_hologramDisplayPos = 0; _hologramDisplayPos = 0;
} }
void MystScriptParser_Stoneship::o_hologramSelection_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_hologramSelection_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Hologram selection init", op); debugC(kDebugScript, "Opcode %d: Hologram selection init", op);
_hologramSelection = static_cast<MystResourceType6 *>(_invokingResource); _hologramSelection = static_cast<MystResourceType6 *>(_invokingResource);
} }
void MystScriptParser_Stoneship::batteryGaugeUpdate() { void Stoneship::batteryGaugeUpdate() {
uint16 charge = 0; uint16 charge = 0;
if (_state.generatorDepletionTime) { if (_state.generatorDepletionTime) {
@ -823,7 +824,7 @@ void MystScriptParser_Stoneship::batteryGaugeUpdate() {
_batteryGauge->setRect(rect); _batteryGauge->setRect(rect);
} }
void MystScriptParser_Stoneship::o_battery_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_battery_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used for Card 2160 (Lighthouse Battery Pack Closeup) // Used for Card 2160 (Lighthouse Battery Pack Closeup)
debugC(kDebugScript, "Opcode %d: Battery init", op); debugC(kDebugScript, "Opcode %d: Battery init", op);
@ -832,7 +833,7 @@ void MystScriptParser_Stoneship::o_battery_init(uint16 op, uint16 var, uint16 ar
batteryGaugeUpdate(); batteryGaugeUpdate();
} }
void MystScriptParser_Stoneship::o_tunnelEnter_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_tunnelEnter_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Tunnel enter", op); debugC(kDebugScript, "Opcode %d: Tunnel enter", op);
o_tunnel_init(op, var, argc, argv); o_tunnel_init(op, var, argc, argv);
@ -841,13 +842,13 @@ void MystScriptParser_Stoneship::o_tunnelEnter_init(uint16 op, uint16 var, uint1
_tunnelNextTime = _vm->_system->getMillis() + 1500; _tunnelNextTime = _vm->_system->getMillis() + 1500;
} }
void MystScriptParser_Stoneship::o_batteryGauge_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_batteryGauge_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Battery gauge init", op); debugC(kDebugScript, "Opcode %d: Battery gauge init", op);
_batteryLastCharge = batteryRemainingCharge(); _batteryLastCharge = batteryRemainingCharge();
_batteryGaugeRunning = true; _batteryGaugeRunning = true;
} }
void MystScriptParser_Stoneship::batteryGauge_run() { void Stoneship::batteryGauge_run() {
uint16 batteryCharge = batteryRemainingCharge(); uint16 batteryCharge = batteryRemainingCharge();
if (batteryCharge != _batteryLastCharge) { if (batteryCharge != _batteryLastCharge) {
@ -863,7 +864,7 @@ void MystScriptParser_Stoneship::batteryGauge_run() {
} }
} }
void MystScriptParser_Stoneship::o_tunnel_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_tunnel_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Tunnel card init", op); debugC(kDebugScript, "Opcode %d: Tunnel card init", op);
_tunnelImagesCount = argv[0]; _tunnelImagesCount = argv[0];
@ -880,7 +881,7 @@ void MystScriptParser_Stoneship::o_tunnel_init(uint16 op, uint16 var, uint16 arg
debugC(kDebugScript, "\tsoundIdAlarm: %d", _tunnelAlarmSound); debugC(kDebugScript, "\tsoundIdAlarm: %d", _tunnelAlarmSound);
} }
void MystScriptParser_Stoneship::tunnel_run() { void Stoneship::tunnel_run() {
uint32 time = _vm->_system->getMillis(); uint32 time = _vm->_system->getMillis();
if (time > _tunnelNextTime) { if (time > _tunnelNextTime) {
@ -903,19 +904,19 @@ void MystScriptParser_Stoneship::tunnel_run() {
} }
} }
void MystScriptParser_Stoneship::o_tunnelLeave_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_tunnelLeave_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Tunnel leave", op); debugC(kDebugScript, "Opcode %d: Tunnel leave", op);
_tunnelRunning = false; _tunnelRunning = false;
} }
void MystScriptParser_Stoneship::o_chest_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_chest_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Chest init", op); debugC(kDebugScript, "Opcode %d: Chest init", op);
_state.chestOpenState = 0; _state.chestOpenState = 0;
} }
void MystScriptParser_Stoneship::o_telescope_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_telescope_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Telescope init", op); debugC(kDebugScript, "Opcode %d: Telescope init", op);
// Used in Card 2218 (Telescope view) // Used in Card 2218 (Telescope view)
@ -929,7 +930,7 @@ void MystScriptParser_Stoneship::o_telescope_init(uint16 op, uint16 var, uint16
_telescopeNexTime = _vm->_system->getMillis() + 1000; _telescopeNexTime = _vm->_system->getMillis() + 1000;
} }
void MystScriptParser_Stoneship::telescope_run() { void Stoneship::telescope_run() {
uint32 time = _vm->_system->getMillis(); uint32 time = _vm->_system->getMillis();
if (time > _telescopeNexTime) { if (time > _telescopeNexTime) {
@ -942,7 +943,7 @@ void MystScriptParser_Stoneship::telescope_run() {
} }
} }
void MystScriptParser_Stoneship::telescopeLighthouseDraw() { void Stoneship::telescopeLighthouseDraw() {
if (_telescopePosition > 1137 && _telescopePosition < 1294) { if (_telescopePosition > 1137 && _telescopePosition < 1294) {
uint16 imageId = _telescopeLighthouseOff; uint16 imageId = _telescopeLighthouseOff;
@ -964,7 +965,7 @@ void MystScriptParser_Stoneship::telescopeLighthouseDraw() {
} }
} }
void MystScriptParser_Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Achenar's Room Drawers Init", op); debugC(kDebugScript, "Opcode %d: Achenar's Room Drawers Init", op);
// Used for Card 2004 (Achenar's Room Drawers) // Used for Card 2004 (Achenar's Room Drawers)
@ -982,7 +983,7 @@ void MystScriptParser_Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, ui
} }
} }
void MystScriptParser_Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { void Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Cloud orb init", op); debugC(kDebugScript, "Opcode %d: Cloud orb init", op);
_cloudOrbMovie = static_cast<MystResourceType6 *>(_invokingResource); _cloudOrbMovie = static_cast<MystResourceType6 *>(_invokingResource);
@ -990,4 +991,5 @@ void MystScriptParser_Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 a
_cloudOrbStopSound = argv[1]; _cloudOrbStopSound = argv[1];
} }
} // End of namespace MystStacks
} // End of namespace Mohawk } // End of namespace Mohawk

View file

@ -32,15 +32,16 @@
namespace Mohawk { namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
struct MystScriptEntry; struct MystScriptEntry;
class MystScriptParser_Stoneship : public MystScriptParser { namespace MystStacks {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class Stoneship : public MystScriptParser {
public: public:
MystScriptParser_Stoneship(MohawkEngine_Myst *vm); Stoneship(MohawkEngine_Myst *vm);
~MystScriptParser_Stoneship(); ~Stoneship();
void disablePersistentScripts(); void disablePersistentScripts();
void runPersistentScripts(); void runPersistentScripts();
@ -142,6 +143,7 @@ private:
uint16 batteryRemainingCharge(); uint16 batteryRemainingCharge();
}; };
} // End of namespace MystStacks
} }
#undef DECLARE_OPCODE #undef DECLARE_OPCODE

View file

@ -38,8 +38,6 @@
namespace Sci { namespace Sci {
#define SCI_VARIABLE_GAME_SPEED 3
reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) { reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
int mask = argv[0].toUint16(); int mask = argv[0].toUint16();
reg_t obj = argv[1]; reg_t obj = argv[1];
@ -188,57 +186,42 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
return s->r_acc; return s->r_acc;
} }
struct KeyDirMapping {
uint16 key;
uint16 direction;
};
const KeyDirMapping keyToDirMap[] = {
{ SCI_KEY_HOME, 8 }, { SCI_KEY_UP, 1 }, { SCI_KEY_PGUP, 2 },
{ SCI_KEY_LEFT, 7 }, { SCI_KEY_CENTER, 0 }, { SCI_KEY_RIGHT, 3 },
{ SCI_KEY_END, 6 }, { SCI_KEY_DOWN, 5 }, { SCI_KEY_PGDOWN, 4 },
};
reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) { reg_t kMapKeyToDir(EngineState *s, int argc, reg_t *argv) {
reg_t obj = argv[0]; reg_t obj = argv[0];
SegManager *segMan = s->_segMan; SegManager *segMan = s->_segMan;
if (readSelectorValue(segMan, obj, SELECTOR(type)) == SCI_EVENT_KEYBOARD) { // Keyboard if (readSelectorValue(segMan, obj, SELECTOR(type)) == SCI_EVENT_KEYBOARD) { // Keyboard
int mover = -1; uint16 message = readSelectorValue(segMan, obj, SELECTOR(message));
switch (readSelectorValue(segMan, obj, SELECTOR(message))) { uint16 eventType = SCI_EVENT_DIRECTION;
case SCI_KEY_HOME: // Check if the game is using cursor views. These games allowed control
mover = 8; // of the mouse cursor via the keyboard controls (the so called
break; // "PseudoMouse" functionality in script 933).
case SCI_KEY_UP: if (g_sci->_features->detectSetCursorType() == SCI_VERSION_1_1)
mover = 1; eventType |= SCI_EVENT_KEYBOARD;
break;
case SCI_KEY_PGUP: for (int i = 0; i < 9; i++) {
mover = 2; if (keyToDirMap[i].key == message) {
break; writeSelectorValue(segMan, obj, SELECTOR(type), eventType);
case SCI_KEY_LEFT: writeSelectorValue(segMan, obj, SELECTOR(message), keyToDirMap[i].direction);
mover = 7; return TRUE_REG; // direction mapped
break; }
case SCI_KEY_CENTER:
case 76:
mover = 0;
break;
case SCI_KEY_RIGHT:
mover = 3;
break;
case SCI_KEY_END:
mover = 6;
break;
case SCI_KEY_DOWN:
mover = 5;
break;
case SCI_KEY_PGDOWN:
mover = 4;
break;
default:
break;
} }
if (mover >= 0) { return NULL_REG; // unknown direction
if (g_sci->getEventManager()->getUsesNewKeyboardDirectionType())
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_KEYBOARD | SCI_EVENT_DIRECTION);
else
writeSelectorValue(segMan, obj, SELECTOR(type), SCI_EVENT_DIRECTION);
writeSelectorValue(segMan, obj, SELECTOR(message), mover);
return make_reg(0, 1);
} else
return NULL_REG;
} }
return s->r_acc; return s->r_acc; // no keyboard event to map, leave accumulator unchanged
} }
reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) { reg_t kGlobalToLocal(EngineState *s, int argc, reg_t *argv) {

View file

@ -362,20 +362,29 @@ reg_t kIconBar(EngineState *s, int argc, reg_t *argv) {
return NULL_REG; return NULL_REG;
switch (argv[0].toUint16()) { switch (argv[0].toUint16()) {
case 0: case 0: // InitIconBar
// Add the icons
for (int i = 0; i < argv[1].toUint16(); i++) for (int i = 0; i < argv[1].toUint16(); i++)
g_sci->_gfxMacIconBar->addIcon(argv[i + 2]); g_sci->_gfxMacIconBar->addIcon(argv[i + 2]);
g_sci->_gfxMacIconBar->drawIcons(); g_sci->_gfxMacIconBar->drawIcons();
// TODO: Should return icon bar handle
// Said handle is then used by DisposeIconBar
break; break;
case 2: case 1: // DisposeIconBar
case 3: warning("kIconBar(Dispose)");
case 4: break;
// TODO: Other calls seem to handle selecting/deselecting them case 2: // EnableIconBar (0xffff = all)
warning("kIconBar(Enable, %d)", argv[1].toUint16());
break;
case 3: // DisableIconBar (0xffff = all)
warning("kIconBar(Disable, %d)", argv[1].toUint16());
break;
case 4: // SetIconBarIcon
warning("kIconBar(SetIcon, %d, %d)", argv[1].toUint16(), argv[2].toUint16());
break; break;
default: default:
warning("Unknown kIconBar subop %d", argv[0].toUint16()); error("Unknown kIconBar(%d)", argv[0].toUint16());
} }
return NULL_REG; return NULL_REG;
@ -389,23 +398,28 @@ reg_t kMacPlatform(EngineState *s, int argc, reg_t *argv) {
switch (argv[0].toUint16()) { switch (argv[0].toUint16()) {
case 0: case 0:
// Set Mac cursor remap // Subop 0 has changed a few times
// In SCI1, its usage is still unknown
// In SCI1.1, it's NOP
// In SCI32, it's used for remapping cursor ID's
if (getSciVersion() >= SCI_VERSION_2_1) // Set Mac cursor remap
g_sci->_gfxCursor->setMacCursorRemapList(argc - 1, argv + 1); g_sci->_gfxCursor->setMacCursorRemapList(argc - 1, argv + 1);
else if (getSciVersion() != SCI_VERSION_1_1)
warning("Unknown SCI1 kMacPlatform(0) call");
break; break;
case 1: case 4: // Handle icon bar code
// Unknown
break;
case 2:
// Unknown
break;
case 3:
// Unknown
break;
case 4:
// Handle icon bar code
return kIconBar(s, argc - 1, argv + 1); return kIconBar(s, argc - 1, argv + 1);
case 7: // Unknown, but always return -1
return SIGNAL_REG;
case 1: // Unknown, calls QuickDraw region functions (KQ5, QFG1VGA)
case 2: // Unknown, "UseNextWaitEvent" (Various)
case 3: // Unknown, "ProcessOpenDocuments" (Various)
case 5: // Unknown, plays a sound (KQ7)
case 6: // Unknown, menu-related (Unused?)
warning("Unhandled kMacPlatform(%d)", argv[0].toUint16());
break;
default: default:
warning("Unknown kMacPlatform subop %d", argv[0].toUint16()); error("Unknown kMacPlatform(%d)", argv[0].toUint16());
} }
return s->r_acc; return s->r_acc;
@ -455,7 +469,8 @@ reg_t kPlatform(EngineState *s, int argc, reg_t *argv) {
warning("STUB: kPlatform(CDCheck)"); warning("STUB: kPlatform(CDCheck)");
break; break;
case kPlatformUnk0: case kPlatformUnk0:
if (g_sci->getPlatform() == Common::kPlatformMacintosh && getSciVersion() >= SCI_VERSION_1_1 && argc > 1) // For Mac versions, kPlatform(0) with other args has more functionality
if (g_sci->getPlatform() == Common::kPlatformMacintosh && argc > 1)
return kMacPlatform(s, argc - 1, argv + 1); return kMacPlatform(s, argc - 1, argv + 1);
// Otherwise, fall through // Otherwise, fall through
case kPlatformGetPlatform: case kPlatformGetPlatform:

View file

@ -47,6 +47,10 @@
#include "sci/sound/audio.h" #include "sci/sound/audio.h"
#include "sci/sound/music.h" #include "sci/sound/music.h"
#ifdef ENABLE_SCI32
#include "sci/graphics/frameout.h"
#endif
namespace Sci { namespace Sci {
@ -130,6 +134,13 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
// Reset _scriptSegMap, to be restored below // Reset _scriptSegMap, to be restored below
_scriptSegMap.clear(); _scriptSegMap.clear();
#ifdef ENABLE_SCI32
// Clear any planes/screen items currently showing so they
// don't show up after the load.
if (getSciVersion() >= SCI_VERSION_2)
g_sci->_gfxFrameout->clear();
#endif
} }
s.skip(4, VER(14), VER(18)); // OBSOLETE: Used to be _exportsAreWide s.skip(4, VER(14), VER(18)); // OBSOLETE: Used to be _exportsAreWide
@ -144,17 +155,15 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
SegmentType type = (s.isSaving() && mobj) ? mobj->getType() : SEG_TYPE_INVALID; SegmentType type = (s.isSaving() && mobj) ? mobj->getType() : SEG_TYPE_INVALID;
s.syncAsUint32LE(type); s.syncAsUint32LE(type);
if (type == SEG_TYPE_HUNK) {
// Don't save or load HunkTable segments
continue;
} else if (type == SEG_TYPE_INVALID) {
// If we were saving and mobj == 0, or if we are loading and this is an // If we were saving and mobj == 0, or if we are loading and this is an
// entry marked as empty -> skip to next // entry marked as empty -> skip to next
if (type == SEG_TYPE_INVALID)
continue; continue;
} else if (type == 5) {
// Don't save or load HunkTable segments
if (type == SEG_TYPE_HUNK)
continue;
// Don't save or load the obsolete system string segments // Don't save or load the obsolete system string segments
if (type == 5) {
if (s.isSaving()) { if (s.isSaving()) {
continue; continue;
} else { } else {
@ -168,6 +177,14 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
_heap[i] = NULL; // set as freed _heap[i] = NULL; // set as freed
continue; continue;
} }
#ifdef ENABLE_SCI32
} else if (type == SEG_TYPE_ARRAY) {
// Set the correct segment for SCI32 arrays
_arraysSegId = i;
} else if (type == SEG_TYPE_STRING) {
// Set the correct segment for SCI32 strings
_stringSegId = i;
#endif
} }
if (s.isLoading()) if (s.isLoading())
@ -178,8 +195,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
// Let the object sync custom data // Let the object sync custom data
mobj->saveLoadWithSerializer(s); mobj->saveLoadWithSerializer(s);
if (type == SEG_TYPE_SCRIPT) {
if (type == SEG_TYPE_SCRIPT && s.getVersion() >= 28) {
Script *scr = (Script *)mobj; Script *scr = (Script *)mobj;
// If we are loading a script, perform some extra steps // If we are loading a script, perform some extra steps
@ -196,6 +212,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
} }
// Sync the script's string heap // Sync the script's string heap
if (s.getVersion() >= 28)
scr->syncStringHeap(s); scr->syncStringHeap(s);
} }
} }

View file

@ -131,21 +131,6 @@ static StackPtr validate_stack_addr(EngineState *s, StackPtr sp) {
return 0; return 0;
} }
static int validate_arithmetic(reg_t reg) {
if (reg.segment) {
// The results of this are likely unpredictable... It most likely means that a kernel function is returning something wrong.
// If such an error occurs, we usually need to find the last kernel function called and check its return value.
error("[VM] Attempt to read arithmetic value from non-zero segment [%04x]. Address: %04x:%04x", reg.segment, PRINT_REG(reg));
return 0;
}
return reg.offset;
}
static int signed_validate_arithmetic(reg_t reg) {
return (int16)validate_arithmetic(reg);
}
static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, int index) { static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, int index) {
const char *names[4] = {"global", "local", "temp", "param"}; const char *names[4] = {"global", "local", "temp", "param"};
@ -176,20 +161,6 @@ static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, in
return true; return true;
} }
static bool validate_unsignedInteger(reg_t reg, uint16 &integer) {
if (reg.segment)
return false;
integer = reg.offset;
return true;
}
static bool validate_signedInteger(reg_t reg, int16 &integer) {
if (reg.segment)
return false;
integer = (int16)reg.offset;
return true;
}
extern const char *opcodeNames[]; // from scriptdebug.cpp extern const char *opcodeNames[]; // from scriptdebug.cpp
static reg_t arithmetic_lookForWorkaround(const byte opcode, const SciWorkaroundEntry *workaroundList, reg_t value1, reg_t value2) { static reg_t arithmetic_lookForWorkaround(const byte opcode, const SciWorkaroundEntry *workaroundList, reg_t value1, reg_t value2) {
@ -427,12 +398,12 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
int activeBreakpointTypes = g_sci->_debugState._activeBreakpointTypes; int activeBreakpointTypes = g_sci->_debugState._activeBreakpointTypes;
while (framesize > 0) { while (framesize > 0) {
selector = validate_arithmetic(*argp++); selector = argp->requireUint16();
argc = validate_arithmetic(*argp); argp++;
argc = argp->requireUint16();
if (argc > 0x800) { // More arguments than the stack could possibly accomodate for if (argc > 0x800) // More arguments than the stack could possibly accomodate for
error("send_selector(): More than 0x800 arguments to function call"); error("send_selector(): More than 0x800 arguments to function call");
}
#ifdef VM_DEBUG_SEND #ifdef VM_DEBUG_SEND
debugN("Send to %04x:%04x (%s), selector %04x (%s):", PRINT_REG(send_obj), debugN("Send to %04x:%04x (%s), selector %04x (%s):", PRINT_REG(send_obj),
@ -1014,8 +985,8 @@ void run_vm(EngineState *s) {
case op_bnot: { // 0x00 (00) case op_bnot: { // 0x00 (00)
// Binary not // Binary not
int16 value; int16 value = s->r_acc.toSint16();
if (validate_signedInteger(s->r_acc, value)) if (s->r_acc.isNumber())
s->r_acc = make_reg(0, 0xffff ^ value); s->r_acc = make_reg(0, 0xffff ^ value);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, NULL_REG); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, NULL_REG);
@ -1087,8 +1058,9 @@ void run_vm(EngineState *s) {
case op_mul: { // 0x03 (03) case op_mul: { // 0x03 (03)
r_temp = POP32(); r_temp = POP32();
int16 value1, value2; int16 value1 = s->r_acc.toSint16();
if (validate_signedInteger(s->r_acc, value1) && validate_signedInteger(r_temp, value2)) int16 value2 = r_temp.toSint16();
if (s->r_acc.isNumber() && r_temp.isNumber())
s->r_acc = make_reg(0, value1 * value2); s->r_acc = make_reg(0, value1 * value2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeMulWorkarounds, s->r_acc, r_temp); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeMulWorkarounds, s->r_acc, r_temp);
@ -1097,8 +1069,9 @@ void run_vm(EngineState *s) {
case op_div: { // 0x04 (04) case op_div: { // 0x04 (04)
r_temp = POP32(); r_temp = POP32();
int16 divisor, dividend; int16 divisor = s->r_acc.toSint16();
if (validate_signedInteger(s->r_acc, divisor) && validate_signedInteger(r_temp, dividend)) int16 dividend = r_temp.toSint16();
if (s->r_acc.isNumber() && r_temp.isNumber())
s->r_acc = make_reg(0, (divisor != 0 ? dividend / divisor : 0)); s->r_acc = make_reg(0, (divisor != 0 ? dividend / divisor : 0));
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeDivWorkarounds, s->r_acc, r_temp); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeDivWorkarounds, s->r_acc, r_temp);
@ -1109,8 +1082,9 @@ void run_vm(EngineState *s) {
r_temp = POP32(); r_temp = POP32();
if (getSciVersion() <= SCI_VERSION_0_LATE) { if (getSciVersion() <= SCI_VERSION_0_LATE) {
uint16 modulo, value; uint16 modulo = s->r_acc.toUint16();
if (validate_unsignedInteger(s->r_acc, modulo) && validate_unsignedInteger(r_temp, value)) uint16 value = r_temp.toUint16();
if (s->r_acc.isNumber() && r_temp.isNumber())
s->r_acc = make_reg(0, (modulo != 0 ? value % modulo : 0)); s->r_acc = make_reg(0, (modulo != 0 ? value % modulo : 0));
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, r_temp);
@ -1121,8 +1095,10 @@ void run_vm(EngineState *s) {
// for simplicity's sake and use the new code for SCI01 and newer // for simplicity's sake and use the new code for SCI01 and newer
// games. Fixes the battlecruiser mini game in SQ5 (room 850), // games. Fixes the battlecruiser mini game in SQ5 (room 850),
// bug #3035755 // bug #3035755
int16 modulo, value, result; int16 modulo = s->r_acc.toSint16();
if (validate_signedInteger(s->r_acc, modulo) && validate_signedInteger(r_temp, value)) { int16 value = r_temp.toSint16();
int16 result;
if (s->r_acc.isNumber() && r_temp.isNumber()) {
modulo = ABS(modulo); modulo = ABS(modulo);
result = (modulo != 0 ? value % modulo : 0); result = (modulo != 0 ? value % modulo : 0);
if (result < 0) if (result < 0)
@ -1137,8 +1113,9 @@ void run_vm(EngineState *s) {
case op_shr: { // 0x06 (06) case op_shr: { // 0x06 (06)
// Shift right logical // Shift right logical
r_temp = POP32(); r_temp = POP32();
uint16 value, shiftCount; uint16 value = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, value) && validate_unsignedInteger(s->r_acc, shiftCount)) uint16 shiftCount = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, value >> shiftCount); s->r_acc = make_reg(0, value >> shiftCount);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1148,8 +1125,9 @@ void run_vm(EngineState *s) {
case op_shl: { // 0x07 (07) case op_shl: { // 0x07 (07)
// Shift left logical // Shift left logical
r_temp = POP32(); r_temp = POP32();
uint16 value, shiftCount; uint16 value = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, value) && validate_unsignedInteger(s->r_acc, shiftCount)) uint16 shiftCount = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, value << shiftCount); s->r_acc = make_reg(0, value << shiftCount);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1158,8 +1136,9 @@ void run_vm(EngineState *s) {
case op_xor: { // 0x08 (08) case op_xor: { // 0x08 (08)
r_temp = POP32(); r_temp = POP32();
uint16 value1, value2; uint16 value1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, value1) && validate_unsignedInteger(s->r_acc, value2)) uint16 value2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, value1 ^ value2); s->r_acc = make_reg(0, value1 ^ value2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1168,8 +1147,9 @@ void run_vm(EngineState *s) {
case op_and: { // 0x09 (09) case op_and: { // 0x09 (09)
r_temp = POP32(); r_temp = POP32();
uint16 value1, value2; uint16 value1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, value1) && validate_unsignedInteger(s->r_acc, value2)) uint16 value2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, value1 & value2); s->r_acc = make_reg(0, value1 & value2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeAndWorkarounds, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeAndWorkarounds, r_temp, s->r_acc);
@ -1178,8 +1158,9 @@ void run_vm(EngineState *s) {
case op_or: { // 0x0a (10) case op_or: { // 0x0a (10)
r_temp = POP32(); r_temp = POP32();
uint16 value1, value2; uint16 value1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, value1) && validate_unsignedInteger(s->r_acc, value2)) uint16 value2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, value1 | value2); s->r_acc = make_reg(0, value1 | value2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeOrWorkarounds, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeOrWorkarounds, r_temp, s->r_acc);
@ -1187,8 +1168,8 @@ void run_vm(EngineState *s) {
} }
case op_neg: { // 0x0b (11) case op_neg: { // 0x0b (11)
int16 value; int16 value = s->r_acc.toSint16();
if (validate_signedInteger(s->r_acc, value)) if (s->r_acc.isNumber())
s->r_acc = make_reg(0, -value); s->r_acc = make_reg(0, -value);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, NULL_REG); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, s->r_acc, NULL_REG);
@ -1232,8 +1213,9 @@ void run_vm(EngineState *s) {
// Happens in SQ1, room 28, when throwing the water at Orat // Happens in SQ1, room 28, when throwing the water at Orat
s->r_acc = make_reg(0, 1); s->r_acc = make_reg(0, 1);
} else { } else {
int16 compare1, compare2; int16 compare1 = r_temp.toSint16();
if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) int16 compare2 = s->r_acc.toSint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 > compare2); s->r_acc = make_reg(0, compare1 > compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1249,8 +1231,9 @@ void run_vm(EngineState *s) {
warning("[VM] Comparing pointers in different segments (%04x:%04x vs. %04x:%04x)", PRINT_REG(r_temp), PRINT_REG(s->r_acc)); warning("[VM] Comparing pointers in different segments (%04x:%04x vs. %04x:%04x)", PRINT_REG(r_temp), PRINT_REG(s->r_acc));
s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset >= s->r_acc.offset); s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset >= s->r_acc.offset);
} else { } else {
int16 compare1, compare2; int16 compare1 = r_temp.toSint16();
if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) int16 compare2 = s->r_acc.toSint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 >= compare2); s->r_acc = make_reg(0, compare1 >= compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeGeWorkarounds, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeGeWorkarounds, r_temp, s->r_acc);
@ -1272,8 +1255,9 @@ void run_vm(EngineState *s) {
// Happens in SQ1, room 58, when giving id-card to robot // Happens in SQ1, room 58, when giving id-card to robot
s->r_acc = make_reg(0, 1); s->r_acc = make_reg(0, 1);
} else { } else {
int16 compare1, compare2; int16 compare1 = r_temp.toSint16();
if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) int16 compare2 = s->r_acc.toSint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 < compare2); s->r_acc = make_reg(0, compare1 < compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1289,8 +1273,9 @@ void run_vm(EngineState *s) {
warning("[VM] Comparing pointers in different segments (%04x:%04x vs. %04x:%04x)", PRINT_REG(r_temp), PRINT_REG(s->r_acc)); warning("[VM] Comparing pointers in different segments (%04x:%04x vs. %04x:%04x)", PRINT_REG(r_temp), PRINT_REG(s->r_acc));
s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset <= s->r_acc.offset); s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset <= s->r_acc.offset);
} else { } else {
int16 compare1, compare2; int16 compare1 = r_temp.toSint16();
if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) int16 compare2 = s->r_acc.toSint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 <= compare2); s->r_acc = make_reg(0, compare1 <= compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeLeWorkarounds, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeLeWorkarounds, r_temp, s->r_acc);
@ -1317,8 +1302,9 @@ void run_vm(EngineState *s) {
else if (r_temp.segment && s->r_acc.segment) else if (r_temp.segment && s->r_acc.segment)
s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset > s->r_acc.offset); s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset > s->r_acc.offset);
else { else {
uint16 compare1, compare2; uint16 compare1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) uint16 compare2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 > compare2); s->r_acc = make_reg(0, compare1 > compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1336,8 +1322,9 @@ void run_vm(EngineState *s) {
else if (r_temp.segment && s->r_acc.segment) else if (r_temp.segment && s->r_acc.segment)
s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset >= s->r_acc.offset); s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset >= s->r_acc.offset);
else { else {
uint16 compare1, compare2; uint16 compare1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) uint16 compare2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 >= compare2); s->r_acc = make_reg(0, compare1 >= compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1356,8 +1343,9 @@ void run_vm(EngineState *s) {
else if (r_temp.segment && s->r_acc.segment) else if (r_temp.segment && s->r_acc.segment)
s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset < s->r_acc.offset); s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset < s->r_acc.offset);
else { else {
uint16 compare1, compare2; uint16 compare1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) uint16 compare2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 < compare2); s->r_acc = make_reg(0, compare1 < compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeUltWorkarounds, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeUltWorkarounds, r_temp, s->r_acc);
@ -1375,8 +1363,9 @@ void run_vm(EngineState *s) {
else if (r_temp.segment && s->r_acc.segment) else if (r_temp.segment && s->r_acc.segment)
s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset <= s->r_acc.offset); s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset <= s->r_acc.offset);
else { else {
uint16 compare1, compare2; uint16 compare1 = r_temp.toUint16();
if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) uint16 compare2 = s->r_acc.toUint16();
if (r_temp.isNumber() && s->r_acc.isNumber())
s->r_acc = make_reg(0, compare1 <= compare2); s->r_acc = make_reg(0, compare1 <= compare2);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, r_temp, s->r_acc);
@ -1446,7 +1435,7 @@ void run_vm(EngineState *s) {
xs_new = add_exec_stack_entry(s->_executionStack, make_reg(s->xs->addr.pc.segment, xs_new = add_exec_stack_entry(s->_executionStack, make_reg(s->xs->addr.pc.segment,
localCallOffset), localCallOffset),
s->xs->sp, s->xs->objp, s->xs->sp, s->xs->objp,
(validate_arithmetic(*call_base)) + s->restAdjust, (call_base->requireUint16()) + s->restAdjust,
call_base, NULL_SELECTOR, -1, localCallOffset, s->xs->objp, call_base, NULL_SELECTOR, -1, localCallOffset, s->xs->objp,
s->_executionStack.size()-1, s->xs->local_segment); s->_executionStack.size()-1, s->xs->local_segment);
s->restAdjust = 0; // Used up the &rest adjustment s->restAdjust = 0; // Used up the &rest adjustment
@ -1466,7 +1455,7 @@ void run_vm(EngineState *s) {
if (!oldScriptHeader) if (!oldScriptHeader)
s->xs->sp -= s->restAdjust; s->xs->sp -= s->restAdjust;
int argc = validate_arithmetic(s->xs->sp[0]); int argc = s->xs->sp[0].requireUint16();
if (!oldScriptHeader) if (!oldScriptHeader)
argc += s->restAdjust; argc += s->restAdjust;
@ -1663,7 +1652,7 @@ void run_vm(EngineState *s) {
r_temp.offset = s->variables[var_number] - s->variablesBase[var_number]; r_temp.offset = s->variables[var_number] - s->variablesBase[var_number];
if (temp & 0x08) // Add accumulator offset if requested if (temp & 0x08) // Add accumulator offset if requested
r_temp.offset += signed_validate_arithmetic(s->r_acc); r_temp.offset += s->r_acc.requireSint16();
r_temp.offset += opparams[1]; // Add index r_temp.offset += opparams[1]; // Add index
r_temp.offset *= 2; // variables are 16 bit r_temp.offset *= 2; // variables are 16 bit
@ -1710,8 +1699,8 @@ void run_vm(EngineState *s) {
case op_ipToa: { // 0x35 (53) case op_ipToa: { // 0x35 (53)
// Increment Property and copy To Accumulator // Increment Property and copy To Accumulator
reg_t &opProperty = validate_property(s, obj, opparams[0]); reg_t &opProperty = validate_property(s, obj, opparams[0]);
uint16 valueProperty; uint16 valueProperty = opProperty.toUint16();
if (validate_unsignedInteger(opProperty, valueProperty)) if (opProperty.isNumber())
s->r_acc = make_reg(0, valueProperty + 1); s->r_acc = make_reg(0, valueProperty + 1);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG); s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG);
@ -1722,8 +1711,8 @@ void run_vm(EngineState *s) {
case op_dpToa: { // 0x36 (54) case op_dpToa: { // 0x36 (54)
// Decrement Property and copy To Accumulator // Decrement Property and copy To Accumulator
reg_t &opProperty = validate_property(s, obj, opparams[0]); reg_t &opProperty = validate_property(s, obj, opparams[0]);
uint16 valueProperty; uint16 valueProperty = opProperty.toUint16();
if (validate_unsignedInteger(opProperty, valueProperty)) if (opProperty.isNumber())
s->r_acc = make_reg(0, valueProperty - 1); s->r_acc = make_reg(0, valueProperty - 1);
else else
s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeDptoaWorkarounds, opProperty, NULL_REG); s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeDptoaWorkarounds, opProperty, NULL_REG);
@ -1734,8 +1723,8 @@ void run_vm(EngineState *s) {
case op_ipTos: { // 0x37 (55) case op_ipTos: { // 0x37 (55)
// Increment Property and push to Stack // Increment Property and push to Stack
reg_t &opProperty = validate_property(s, obj, opparams[0]); reg_t &opProperty = validate_property(s, obj, opparams[0]);
uint16 valueProperty; uint16 valueProperty = opProperty.toUint16();
if (validate_unsignedInteger(opProperty, valueProperty)) if (opProperty.isNumber())
valueProperty++; valueProperty++;
else else
valueProperty = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG).offset; valueProperty = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG).offset;
@ -1747,8 +1736,8 @@ void run_vm(EngineState *s) {
case op_dpTos: { // 0x38 (56) case op_dpTos: { // 0x38 (56)
// Decrement Property and push to Stack // Decrement Property and push to Stack
reg_t &opProperty = validate_property(s, obj, opparams[0]); reg_t &opProperty = validate_property(s, obj, opparams[0]);
uint16 valueProperty; uint16 valueProperty = opProperty.toUint16();
if (validate_unsignedInteger(opProperty, valueProperty)) if (opProperty.isNumber())
valueProperty--; valueProperty--;
else else
valueProperty = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG).offset; valueProperty = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG).offset;
@ -1871,8 +1860,8 @@ void run_vm(EngineState *s) {
// Load global, local, temp or param variable into the accumulator, // Load global, local, temp or param variable into the accumulator,
// using the accumulator as an additional index // using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
int16 value; int16 value = s->r_acc.toSint16();
if (!validate_signedInteger(s->r_acc, value)) if (!s->r_acc.isNumber())
value = arithmetic_lookForWorkaround(opcode, opcodeLaiWorkarounds, s->r_acc, NULL_REG).offset; value = arithmetic_lookForWorkaround(opcode, opcodeLaiWorkarounds, s->r_acc, NULL_REG).offset;
var_number = opparams[0] + value; var_number = opparams[0] + value;
s->r_acc = READ_VAR(var_type, var_number); s->r_acc = READ_VAR(var_type, var_number);
@ -1886,8 +1875,8 @@ void run_vm(EngineState *s) {
// Load global, local, temp or param variable into the stack, // Load global, local, temp or param variable into the stack,
// using the accumulator as an additional index // using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
int16 value; int16 value = s->r_acc.toSint16();
if (!validate_signedInteger(s->r_acc, value)) if (!s->r_acc.isNumber())
value = arithmetic_lookForWorkaround(opcode, opcodeLsiWorkarounds, s->r_acc, NULL_REG).offset; value = arithmetic_lookForWorkaround(opcode, opcodeLsiWorkarounds, s->r_acc, NULL_REG).offset;
var_number = opparams[0] + value; var_number = opparams[0] + value;
PUSH32(READ_VAR(var_type, var_number)); PUSH32(READ_VAR(var_type, var_number));
@ -1925,7 +1914,7 @@ void run_vm(EngineState *s) {
// of sense otherwise, with acc being used for two things // of sense otherwise, with acc being used for two things
// simultaneously... // simultaneously...
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); var_number = opparams[0] + s->r_acc.requireSint16();
s->r_acc = POP32(); s->r_acc = POP32();
WRITE_VAR(var_type, var_number, s->r_acc); WRITE_VAR(var_type, var_number, s->r_acc);
break; break;
@ -1937,7 +1926,7 @@ void run_vm(EngineState *s) {
// Save the stack into the global, local, temp or param variable, // Save the stack into the global, local, temp or param variable,
// using the accumulator as an additional index // using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); var_number = opparams[0] + s->r_acc.requireSint16();
WRITE_VAR(var_type, var_number, POP32()); WRITE_VAR(var_type, var_number, POP32());
break; break;
@ -1983,7 +1972,7 @@ void run_vm(EngineState *s) {
// Increment the global, local, temp or param variable and save it // Increment the global, local, temp or param variable and save it
// to the accumulator, using the accumulator as an additional index // to the accumulator, using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); var_number = opparams[0] + s->r_acc.requireSint16();
r_temp = READ_VAR(var_type, var_number); r_temp = READ_VAR(var_type, var_number);
if (r_temp.segment) { if (r_temp.segment) {
// Pointer arithmetics! // Pointer arithmetics!
@ -2000,7 +1989,7 @@ void run_vm(EngineState *s) {
// Increment the global, local, temp or param variable and save it // Increment the global, local, temp or param variable and save it
// to the stack, using the accumulator as an additional index // to the stack, using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); var_number = opparams[0] + s->r_acc.requireSint16();
r_temp = READ_VAR(var_type, var_number); r_temp = READ_VAR(var_type, var_number);
if (r_temp.segment) { if (r_temp.segment) {
// Pointer arithmetics! // Pointer arithmetics!
@ -2053,7 +2042,7 @@ void run_vm(EngineState *s) {
// Decrement the global, local, temp or param variable and save it // Decrement the global, local, temp or param variable and save it
// to the accumulator, using the accumulator as an additional index // to the accumulator, using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); var_number = opparams[0] + s->r_acc.requireSint16();
r_temp = READ_VAR(var_type, var_number); r_temp = READ_VAR(var_type, var_number);
if (r_temp.segment) { if (r_temp.segment) {
// Pointer arithmetics! // Pointer arithmetics!
@ -2070,7 +2059,7 @@ void run_vm(EngineState *s) {
// Decrement the global, local, temp or param variable and save it // Decrement the global, local, temp or param variable and save it
// to the stack, using the accumulator as an additional index // to the stack, using the accumulator as an additional index
var_type = opcode & 0x3; // Gets the variable type: g, l, t or p var_type = opcode & 0x3; // Gets the variable type: g, l, t or p
var_number = opparams[0] + signed_validate_arithmetic(s->r_acc); var_number = opparams[0] + s->r_acc.requireSint16();
r_temp = READ_VAR(var_type, var_number); r_temp = READ_VAR(var_type, var_number);
if (r_temp.segment) { if (r_temp.segment) {
// Pointer arithmetics! // Pointer arithmetics!

View file

@ -56,6 +56,32 @@ struct reg_t {
int16 toSint16() const { int16 toSint16() const {
return (int16) offset; return (int16) offset;
} }
uint16 requireUint16() const {
if (isNumber())
return toUint16();
else
// The results of this are likely unpredictable... It most likely
// means that a kernel function is returning something wrong. If
// such an error occurs, we usually need to find the last kernel
// function called and check its return value.
error("[VM] Attempt to read unsigned arithmetic value from non-zero segment %04x. Offset: %04x", segment, offset);
}
int16 requireSint16() const {
if (isNumber())
return toSint16();
else
// The results of this are likely unpredictable... It most likely
// means that a kernel function is returning something wrong. If
// such an error occurs, we usually need to find the last kernel
// function called and check its return value.
error("[VM] Attempt to read signed arithmetic value from non-zero segment %04x. Offset: %04x", segment, offset);
}
bool isNumber() const {
return !segment;
}
}; };
static inline reg_t make_reg(SegmentId segment, uint16 offset) { static inline reg_t make_reg(SegmentId segment, uint16 offset) {

View file

@ -36,31 +36,11 @@
namespace Sci { namespace Sci {
EventManager::EventManager(bool fontIsExtended) : _fontIsExtended(fontIsExtended), _modifierStates(0) { EventManager::EventManager(bool fontIsExtended) : _fontIsExtended(fontIsExtended), _modifierStates(0) {
if (getSciVersion() >= SCI_VERSION_1_MIDDLE) {
_usesNewKeyboardDirectionType = true;
} else if (getSciVersion() <= SCI_VERSION_01) {
_usesNewKeyboardDirectionType = false;
} else {
// they changed this somewhere inbetween SCI1EGA/EARLY
_usesNewKeyboardDirectionType = false;
// We are looking if script 933 exists, that one has the PseudoMouse class in it that handles it
// The good thing is that PseudoMouse seems to only exists in games that use the new method
if (g_sci->getResMan()->testResource(ResourceId(kResourceTypeScript, 933)))
_usesNewKeyboardDirectionType = true;
// Checking the keyboard driver size in here would also be a valid method, but the driver is only available
// in PC versions of the game
}
} }
EventManager::~EventManager() { EventManager::~EventManager() {
} }
bool EventManager::getUsesNewKeyboardDirectionType() {
return _usesNewKeyboardDirectionType;
}
struct ScancodeRow { struct ScancodeRow {
int offset; int offset;
const char *keys; const char *keys;

View file

@ -116,7 +116,6 @@ public:
void updateScreen(); void updateScreen();
SciEvent getSciEvent(unsigned int mask); SciEvent getSciEvent(unsigned int mask);
bool getUsesNewKeyboardDirectionType();
private: private:
SciEvent getScummVMEvent(); SciEvent getScummVMEvent();
@ -124,8 +123,6 @@ private:
const bool _fontIsExtended; const bool _fontIsExtended;
int _modifierStates; int _modifierStates;
Common::List<SciEvent> _events; Common::List<SciEvent> _events;
bool _usesNewKeyboardDirectionType;
}; };
} // End of namespace Sci } // End of namespace Sci

View file

@ -58,6 +58,12 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd
GfxFrameout::~GfxFrameout() { GfxFrameout::~GfxFrameout() {
} }
void GfxFrameout::clear() {
_screenItems.clear();
_planes.clear();
_planePictures.clear();
}
void GfxFrameout::kernelAddPlane(reg_t object) { void GfxFrameout::kernelAddPlane(reg_t object) {
PlaneEntry newPlane; PlaneEntry newPlane;
@ -584,6 +590,11 @@ void GfxFrameout::kernelFrameout() {
uint16 startX = itemEntry->x + it->planeRect.left; uint16 startX = itemEntry->x + it->planeRect.left;
uint16 curY = itemEntry->y + it->planeRect.top; uint16 curY = itemEntry->y + it->planeRect.top;
const char *txt = text.c_str(); const char *txt = text.c_str();
// HACK. The plane sometimes doesn't contain the correct width. This
// hack breaks the dialog options when speaking with Grace, but it's
// the best we got up to now.
// TODO: Remove this, and figure out why the plane in question isn't
// initialized correctly (its width is 0).
uint16 w = it->planeRect.width() >= 20 ? it->planeRect.width() : _screen->getWidth() - 10; uint16 w = it->planeRect.width() >= 20 ? it->planeRect.width() : _screen->getWidth() - 10;
int16 charCount; int16 charCount;

View file

@ -28,6 +28,8 @@
namespace Sci { namespace Sci {
class GfxPicture;
struct PlaneEntry { struct PlaneEntry {
reg_t object; reg_t object;
uint16 priority; uint16 priority;
@ -99,6 +101,7 @@ public:
void addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX); void addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX);
void deletePlanePictures(reg_t object); void deletePlanePictures(reg_t object);
void clear();
private: private:
SegManager *_segMan; SegManager *_segMan;

View file

@ -80,6 +80,7 @@ State::State(void) {
_showConversationIcons = false; _showConversationIcons = false;
_inMenu = false;
_inCloseUp = false; _inCloseUp = false;
_inConversation = false; _inConversation = false;

View file

@ -62,6 +62,7 @@ public:
int16 _confiscatedInventory[35]; int16 _confiscatedInventory[35];
int32 _numInventoryItems; int32 _numInventoryItems;
int32 _numConfiscatedInventoryItems; int32 _numConfiscatedInventoryItems;
bool _inMenu;
bool _inCloseUp; bool _inCloseUp;
bool _inCutaway; bool _inCutaway;
bool _inConversation; bool _inConversation;

View file

@ -185,7 +185,7 @@ void ToonEngine::parseInput() {
bool hasModifier = event.kbd.hasFlags(Common::KBD_ALT|Common::KBD_CTRL|Common::KBD_SHIFT); bool hasModifier = event.kbd.hasFlags(Common::KBD_ALT|Common::KBD_CTRL|Common::KBD_SHIFT);
switch (event.type) { switch (event.type) {
case Common::EVENT_KEYUP: case Common::EVENT_KEYDOWN:
if ((event.kbd.ascii == 27 || event.kbd.ascii == 32) && !hasModifier) { if ((event.kbd.ascii == 27 || event.kbd.ascii == 32) && !hasModifier) {
_audioManager->stopCurrentVoice(); _audioManager->stopCurrentVoice();
} }
@ -588,6 +588,8 @@ bool ToonEngine::showMainmenu(bool &loadedGame) {
AudioStreamInstance *mainmenuMusic = NULL; AudioStreamInstance *mainmenuMusic = NULL;
bool musicPlaying = false; bool musicPlaying = false;
_gameState->_inMenu = true;
while (!doExit) { while (!doExit) {
clickingOn = MAINMENUHOTSPOT_NONE; clickingOn = MAINMENUHOTSPOT_NONE;
clickRelease = false; clickRelease = false;
@ -700,6 +702,8 @@ bool ToonEngine::showMainmenu(bool &loadedGame) {
} }
} }
_gameState->_inMenu = false;
//delete mainmenuMusic; //delete mainmenuMusic;
for (int entryNr = 0; entryNr < MAINMENU_ENTRYCOUNT; entryNr++) for (int entryNr = 0; entryNr < MAINMENU_ENTRYCOUNT; entryNr++)
delete entries[entryNr].animation; delete entries[entryNr].animation;
@ -2947,11 +2951,11 @@ void ToonEngine::pauseEngineIntern(bool pause) {
} }
bool ToonEngine::canSaveGameStateCurrently() { bool ToonEngine::canSaveGameStateCurrently() {
return !_gameState->_inInventory && !_gameState->_inConversation && !_gameState->_inCutaway && !_gameState->_mouseHidden && !_moviePlayer->isPlaying(); return !_gameState->_inMenu && !_gameState->_inInventory && !_gameState->_inConversation && !_gameState->_inCutaway && !_gameState->_mouseHidden && !_moviePlayer->isPlaying();
} }
bool ToonEngine::canLoadGameStateCurrently() { bool ToonEngine::canLoadGameStateCurrently() {
return !_gameState->_inInventory && !_gameState->_inConversation && !_gameState->_inCutaway && !_gameState->_mouseHidden && !_moviePlayer->isPlaying(); return !_gameState->_inMenu && !_gameState->_inInventory && !_gameState->_inConversation && !_gameState->_inCutaway && !_gameState->_mouseHidden && !_moviePlayer->isPlaying();
} }
Common::String ToonEngine::getSavegameName(int nr) { Common::String ToonEngine::getSavegameName(int nr) {

View file

@ -820,19 +820,25 @@ int QuickTimeDecoder::readTKHD(MOVatom atom) {
// edit list atom // edit list atom
int QuickTimeDecoder::readELST(MOVatom atom) { int QuickTimeDecoder::readELST(MOVatom atom) {
MOVStreamContext *st = _streams[_numStreams - 1];
_fd->readByte(); // version _fd->readByte(); // version
_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags _fd->readByte(); _fd->readByte(); _fd->readByte(); // flags
uint32 editCount = _streams[_numStreams - 1]->edit_count = _fd->readUint32BE(); // entries
for (uint32 i = 0; i < editCount; i++){ st->editCount = _fd->readUint32BE();
_fd->readUint32BE(); // Track duration st->editList = new EditListEntry[st->editCount];
_fd->readUint32BE(); // Media time
_fd->readUint32BE(); // Media rate debug(2, "Track %d edit list count: %d", _numStreams - 1, st->editCount);
for (uint32 i = 0; i < st->editCount; i++){
st->editList[i].trackDuration = _fd->readUint32BE();
st->editList[i].mediaTime = _fd->readSint32BE();
st->editList[i].mediaRate = Common::Rational(_fd->readUint32BE(), 0x10000);
debugN(3, "\tDuration = %d, Media Time = %d, ", st->editList[i].trackDuration, st->editList[i].mediaTime);
st->editList[i].mediaRate.debugPrint(3, "Media Rate =");
} }
debug(0, "track[%i].edit_count = %i", _numStreams - 1, _streams[_numStreams - 1]->edit_count); if (st->editCount != 1)
if (editCount != 1)
warning("Multiple edit list entries. Things may go awry"); warning("Multiple edit list entries. Things may go awry");
return 0; return 0;
@ -1465,12 +1471,30 @@ QuickTimeDecoder::STSDEntry::~STSDEntry() {
} }
QuickTimeDecoder::MOVStreamContext::MOVStreamContext() { QuickTimeDecoder::MOVStreamContext::MOVStreamContext() {
// FIXME: Setting all members to 0 via memset is a hack -- it works chunk_count = 0;
// because the only non-POD member of MOVStreamContext is of type chunk_offsets = 0;
// Common::Rational, and that luckily has no virtual methods nor stts_count = 0;
// does it keep internal pointers or anything like that. But watch stts_data = 0;
// out if you ever extend MOVStreamContext! sample_to_chunk_sz = 0;
memset(this, 0, sizeof(MOVStreamContext)); sample_to_chunk = 0;
sample_size = 0;
sample_count = 0;
sample_sizes = 0;
keyframe_count = 0;
keyframes = 0;
time_scale = 0;
time_rate = 0;
width = 0;
height = 0;
codec_type = CODEC_TYPE_MOV_OTHER;
stsdEntryCount = 0;
stsdEntries = 0;
editCount = 0;
editList = 0;
extradata = 0;
nb_frames = 0;
duration = 0;
start_time = 0;
} }
QuickTimeDecoder::MOVStreamContext::~MOVStreamContext() { QuickTimeDecoder::MOVStreamContext::~MOVStreamContext() {
@ -1480,6 +1504,7 @@ QuickTimeDecoder::MOVStreamContext::~MOVStreamContext() {
delete[] sample_sizes; delete[] sample_sizes;
delete[] keyframes; delete[] keyframes;
delete[] stsdEntries; delete[] stsdEntries;
delete[] editList;
delete extradata; delete extradata;
} }

View file

@ -149,6 +149,12 @@ private:
uint32 id; uint32 id;
}; };
struct EditListEntry {
uint32 trackDuration;
int32 mediaTime;
Common::Rational mediaRate;
};
struct STSDEntry { struct STSDEntry {
STSDEntry(); STSDEntry();
~STSDEntry(); ~STSDEntry();
@ -183,7 +189,6 @@ private:
uint32 *chunk_offsets; uint32 *chunk_offsets;
int stts_count; int stts_count;
MOVstts *stts_data; MOVstts *stts_data;
int edit_count; /* number of 'edit' (elst atom) */
uint32 sample_to_chunk_sz; uint32 sample_to_chunk_sz;
MOVstsc *sample_to_chunk; MOVstsc *sample_to_chunk;
uint32 sample_size; uint32 sample_size;
@ -201,6 +206,9 @@ private:
uint32 stsdEntryCount; uint32 stsdEntryCount;
STSDEntry *stsdEntries; STSDEntry *stsdEntries;
uint32 editCount;
EditListEntry *editList;
Common::SeekableReadStream *extradata; Common::SeekableReadStream *extradata;
uint32 nb_frames; uint32 nb_frames;