diff options
108 files changed, 2235 insertions, 2197 deletions
diff --git a/.gitignore b/.gitignore index 74b4cc56f5..6e3e61134c 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,7 @@ Thumbs.db  *.opensdf  obj/  _ReSharper*/ +ipch/  [Tt]est[Rr]esult*  *.vcproj  *.sln diff --git a/backends/platform/n64/osys_n64.h b/backends/platform/n64/osys_n64.h index 5264a8a82e..e5ffc7f3bc 100644 --- a/backends/platform/n64/osys_n64.h +++ b/backends/platform/n64/osys_n64.h @@ -111,7 +111,10 @@ protected:  	bool _cursorPaletteDisabled;  	bool _dirtyPalette; -	uint _cursorWidth, _cursorHeight; +	// FIXME: This must be left as "int" for now, to fix the sign-comparison problem +	// there is a little more work involved than an int->uint change +	int _cursorWidth, _cursorHeight; +	  	int _cursorKeycolor;  	uint16	_overlayHeight, _overlayWidth; diff --git a/backends/platform/wii/osystem_gfx.cpp b/backends/platform/wii/osystem_gfx.cpp index 09575bb83d..4a925a60c9 100644 --- a/backends/platform/wii/osystem_gfx.cpp +++ b/backends/platform/wii/osystem_gfx.cpp @@ -333,16 +333,19 @@ void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) {  	gfx_tex_flush_palette(&_texGame); +	s = colors; +	d = _cursorPalette; + +	for (uint i = 0; i < num; ++i) { +		d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); +		s += 4; +	} +  	if (_cursorPaletteDisabled) {  		assert(_texMouse.palette); -		s = colors; -		d = _texMouse.palette; - -		for (uint i = 0; i < num; ++i) { -			d[start + i] = Graphics::ARGBToColor<Graphics::ColorMasks<3444> >(0xff, s[0], s[1], s[2]); -			s += 4; -		} +		memcpy((u8 *)_texMouse.palette + start * 2, +			(u8 *)_cursorPalette + start * 2, num * 2);  		_cursorPaletteDirty = true;  	} diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index a2902e3b9d..fffa5b207d 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -194,7 +194,7 @@ void Screen::savePal(Common::WriteStream *f) const {  /**   * Restore the current palette from a savegame   */ -void Screen::restorePal(Common::SeekableReadStream *f) { +void Screen::restorePal(Common::ReadStream *f) {  	debugC(1, kDebugDisplay, "restorePal()");  	byte pal[4]; @@ -585,17 +585,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(_mainPalette); -} -/** - * Free fonts - */ -void Screen::freeFonts() {  	for (int i = 0; i < kNumFonts; i++) {  		if (_arrayFont[i])  			free(_arrayFont[i]); @@ -607,11 +602,7 @@ void Screen::selectInventoryObjId(const int16 objId) {  	_vm->_inventory->setInventoryObjId(objId);      // Select new object  	// Find index of icon -	int16 iconId = 0;                               // Find index of dragged icon -	for (; iconId < _vm->_maxInvent; iconId++) { -		if (objId == _vm->_invent[iconId]) -			break; -	} +	int16 iconId = _vm->_inventory->findIconId(objId);  	// Compute source coordinates in dib_u  	int16 ux = (iconId + kArrowNumb) * kInvDx % kXPix; diff --git a/engines/hugo/display.h b/engines/hugo/display.h index 21e9fe2e9c..8c504cead4 100644 --- a/engines/hugo/display.h +++ b/engines/hugo/display.h @@ -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     drawShape(const int x, const int y, const int color1, const int color2);  	void     drawStatusText(); -	void     freeFonts(); -	void     freePalette(); +	void     freeScreen();  	void     hideCursor();  	void     initDisplay();  	void     initNewScreenDisplay(); @@ -74,7 +73,7 @@ public:  	void     moveImage(image_pt srcImage, const int16 x1, const int16 y1, const int16 dx, int16 dy, const int16 width1, image_pt dstImage, const int16 x2, const int16 y2, const int16 width2);  	void     remapPal(uint16 oldIndex, uint16 newIndex);  	void     resetInventoryObjId(); -	void     restorePal(Common::SeekableReadStream *f); +	void     restorePal(Common::ReadStream *f);  	void     savePal(Common::WriteStream *f) const;  	void     setBackgroundColor(const uint16 color);  	void     setCursorPal(); diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index 7427771906..a0602f0636 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -369,18 +369,7 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) {  	for (int i = 0; i < _vm->_numScreens; i++)  		out->writeByte(_vm->_screenStates[i]); -	// Save points table -	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); - +	_vm->_scheduler->saveSchedulerData(out);  	// Save palette table  	_vm->_screen->savePal(out); @@ -475,19 +464,7 @@ bool FileManager::restoreGame(const int16 slot) {  	for (int i = 0; i < _vm->_numScreens; i++)  		_vm->_screenStates[i] = in->readByte(); -	// Restore points table -	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); +	_vm->_scheduler->restoreSchedulerData(in);  	// Restore palette and change it if necessary  	_vm->_screen->restorePal(in); diff --git a/engines/hugo/file_v1d.cpp b/engines/hugo/file_v1d.cpp index be23edb7b4..d8b3fa494f 100644 --- a/engines/hugo/file_v1d.cpp +++ b/engines/hugo/file_v1d.cpp @@ -63,8 +63,7 @@ void FileManager_v1d::readOverlay(const int screenNum, image_pt image, const ovl  	Common::String buf = Common::String(_vm->_text->getScreenNames(screenNum)) + Common::String(ovl_ext[overlayType]);  	if (!Common::File::exists(buf)) { -		for (int i = 0; i < kOvlSize; i++) -			image[i] = 0; +		memset(image, 0, sizeof(image));  		warning("File not found: %s", buf.c_str());  		return;  	} diff --git a/engines/hugo/file_v1w.cpp b/engines/hugo/file_v1w.cpp index b902e50f15..dbb093752a 100644 --- a/engines/hugo/file_v1w.cpp +++ b/engines/hugo/file_v1w.cpp @@ -81,8 +81,7 @@ void FileManager_v1w::readOverlay(const int screenNum, image_pt image, ovl_t ove  		break;  	}  	if (i == 0) { -		for (int idx = 0; idx < kOvlSize; idx++) -			image[idx] = 0; +		memset(image, 0, sizeof(image));  		return;  	}  	_sceneryArchive1.read(tmpImage, kOvlSize); diff --git a/engines/hugo/file_v2d.cpp b/engines/hugo/file_v2d.cpp index 9c66f6375f..ffadd17481 100644 --- a/engines/hugo/file_v2d.cpp +++ b/engines/hugo/file_v2d.cpp @@ -137,8 +137,7 @@ void FileManager_v2d::readOverlay(const int screenNum, image_pt image, ovl_t ove  		break;  	}  	if (i == 0) { -		for (int idx = 0; idx < kOvlSize; idx++) -			image[idx] = 0; +		memset(image, 0, sizeof(image));  		return;  	} diff --git a/engines/hugo/file_v3d.cpp b/engines/hugo/file_v3d.cpp index ec0d736bb9..2f3e5af3f0 100644 --- a/engines/hugo/file_v3d.cpp +++ b/engines/hugo/file_v3d.cpp @@ -144,8 +144,7 @@ void FileManager_v3d::readOverlay(const int screenNum, image_pt image, ovl_t ove  			break;  		}  		if (i == 0) { -			for (int idx = 0; idx < kOvlSize; idx++) -				image[idx] = 0; +			memset(image, 0, sizeof(image));  			return;  		} @@ -158,7 +157,7 @@ void FileManager_v3d::readOverlay(const int screenNum, image_pt image, ovl_t ove  			else if (data >= 0) {                   // Copy next data+1 literally  				for (i = 0; i <= (byte)data; i++, k++)  					*tmpImage++ = _sceneryArchive1.readByte(); -			} else {                            // Repeat next byte -data+1 times +			} else {                                // Repeat next byte -data+1 times  				int16 j = _sceneryArchive1.readByte();  				for (i = 0; i < (byte)(-data + 1); i++, k++) @@ -184,8 +183,7 @@ void FileManager_v3d::readOverlay(const int screenNum, image_pt image, ovl_t ove  			break;  		}  		if (i == 0) { -			for (int idx = 0; idx < kOvlSize; idx++) -				image[idx] = 0; +			memset(image, 0, sizeof(image));  			return;  		} diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index 4a8b74fc1c..831fd36a9f 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -54,10 +54,8 @@ maze_t      _maze;                              // Default to not in maze  hugo_boot_t _boot;                              // Boot info structure file  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),  -	_screenActs(0), _hero(0), _heroImage(0), _defltTunes(0), _introX(0), _introY(0), _maxInvent(0), _numBonuses(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) +	_hero(0), _heroImage(0), _defltTunes(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), +	_screenStates(0), _score(0), _maxscore(0), _lastTime(0), _curTime(0)  {  	_system = syst;  	DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level"); @@ -76,61 +74,22 @@ HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(sy  }  HugoEngine::~HugoEngine() { -	shutdown(); - -	_screen->freePalette(); -	_text->freeAllTexts(); - -	free(_introX); -	free(_introY); - -	if (_arrayReqs) { -		for (int i = 0; _arrayReqs[i] != 0; i++) -			free(_arrayReqs[i]); -		free(_arrayReqs); -	} +	_file->closeDatabaseFiles(); +	_intro->freeIntroData(); +	_inventory->freeInvent();  	_mouse->freeHotspots(); -	free(_invent); - -	if (_uses) { -		for (int i = 0; i < _usesSize; i++) -			free(_uses[i].targets); -		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(); +	_object->freeObjects(); +	_parser->freeParser(); +	_scheduler->freeScheduler(); +	_screen->freeScreen(); +	_text->freeAllTexts();  	free(_defltTunes);  	free(_screenStates); -	_screen->freeFonts();  	delete _topMenu; -  	delete _object;  	delete _sound;  	delete _route; @@ -236,11 +195,12 @@ Common::Error HugoEngine::run() {  	_screen->setCursorPal();  	_screen->resetInventoryObjId(); +	_scheduler->initCypher(); +  	initStatus();                                   // Initialize game status  	initConfig();                                   // Initialize user's config  	initialize();  	resetConfig();                                  // Reset user's config -  	initMachine();  	// Start the state machine @@ -388,207 +348,23 @@ bool HugoEngine::loadHugoDat() {  	}  	_numVariant = in.readUint16BE(); +  	_screen->loadPalette(in);  	_text->loadAllTexts(in); - -	// Read x_intro and y_intro -	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); - +	_intro->loadIntroData(in); +	_parser->loadArrayReqs(in);  	_mouse->loadHotspots(in); - -	int numElem, numSubElem; -	//Read _invent -	for (int varnt = 0; varnt < _numVariant; varnt++) { -		numElem = in.readUint16BE(); -		if (varnt == _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(); -		} -	} - -	//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); -		} -	} +	_inventory->loadInvent(in); +	_object->loadObjectUses(in); +	_parser->loadCatchallList(in); +	_parser->loadBackgroundObjects(in); +	_scheduler->loadPoints(in); +	_parser->loadCmdList(in); +	_scheduler->loadScreenAct(in);  	_object->loadObjectArr(in); -  	_hero = &_object->_objects[kHeroIndex];         // This always points to hero  	_screen_p = &(_object->_objects[kHeroIndex].screenIndex); // Current screen is hero's  	_heroImage = kHeroIndex;                        // Current in use hero image -  	_scheduler->loadActListArr(in);  	for (int varnt = 0; varnt < _numVariant; varnt++) { @@ -603,6 +379,8 @@ bool HugoEngine::loadHugoDat() {  		}  	} +	int numElem; +  	//Read _defltTunes  	for (int varnt = 0; varnt < _numVariant; varnt++) {  		numElem = in.readUint16BE(); @@ -621,8 +399,7 @@ bool HugoEngine::loadHugoDat() {  		numElem = in.readUint16BE();  		if (varnt == _gameVariant) {  			_screenStates = (byte *)malloc(sizeof(byte) * numElem); -			for (int i = 0; i < numElem; i++) -				_screenStates[i] = 0; +			memset(_screenStates, 0, sizeof(_screenStates));  		}  	} @@ -648,7 +425,7 @@ bool HugoEngine::loadHugoDat() {  	return true;  } -uint16 **HugoEngine::loadLongArray(Common::ReadStream &in) { +uint16 **HugoEngine::loadLongArray(Common::SeekableReadStream &in) {  	uint16 **resArray = 0;  	for (int varnt = 0; varnt < _numVariant; varnt++) { @@ -665,8 +442,7 @@ uint16 **HugoEngine::loadLongArray(Common::ReadStream &in) {  					resRow[j] = in.readUint16BE();  				resArray[i] = resRow;  			} else { -				for (int j = 0; j < numElems; j++) -					in.readUint16BE(); +				in.skip(numElems * sizeof(uint16));  			}  		}  	} @@ -792,16 +568,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   */  void HugoEngine::readScreenFiles(const int screenNum) { @@ -820,37 +586,6 @@ void HugoEngine::readScreenFiles(const int screenNum) {  }  /** - * 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   */  void HugoEngine::setNewScreen(const int screenNum) { @@ -866,10 +601,7 @@ void HugoEngine::setNewScreen(const int screenNum) {  void HugoEngine::calcMaxScore() {  	debugC(1, kDebugEngine, "calcMaxScore"); -	_maxscore = _object->calcMaxScore(); - -	for (int i = 0; i < _numBonuses; i++) -		_maxscore += _points[i].score; +	_maxscore = _object->calcMaxScore() + _scheduler->calcMaxPoints();  }  /** diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h index b73b24eccf..848001c4ef 100644 --- a/engines/hugo/hugo.h +++ b/engines/hugo/hugo.h @@ -233,8 +233,6 @@ public:  	byte   _numVariant;  	byte   _gameVariant; -	byte   _maxInvent; -	byte   _numBonuses;  	int8   _soundSilence;  	int8   _soundTest;  	int8   _tunesNbr; @@ -245,23 +243,9 @@ public:  	byte  *_screen_p;  	byte  _heroImage; -	byte  *_introX; -	byte  *_introY;  	byte  *_screenStates;  	command_t _line;                                // Line of user text input  	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;  	uint16    _look;  	uint16    _take; @@ -295,8 +279,6 @@ public:  	virtual bool canSaveGameStateCurrently();  	bool loadHugoDat(); -	const char *useBG(const char *name); -  	int8 getTPS() const;  	void initGame(const HugoGameDescription *gd); @@ -304,7 +286,6 @@ public:  	void endGame();  	void initStatus();  	void readScreenFiles(const int screen); -	void screenActions(const int screen);  	void setNewScreen(const int screen);  	void shutdown();  	void syncSoundSettings(); @@ -327,9 +308,6 @@ public:  	void setMaxScore(const int newScore) {  		_maxscore = newScore;  	} -	byte getIntroSize() { -		return _introXSize; -	}  	Common::Error saveGameState(int slot, const char *desc) {  		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."; }  	Common::String getSavegameFilename(int slot); +	uint16 **loadLongArray(Common::SeekableReadStream &in);  	FileManager *_file;  	Scheduler *_scheduler; @@ -357,7 +336,6 @@ public:  	IntroHandler *_intro;  	ObjectHandler *_object;  	TextHandler *_text; -  	TopMenu *_topMenu;  protected: @@ -368,7 +346,6 @@ protected:  private:  	static const int kTurboTps = 16;                // This many in turbo mode -	byte _introXSize;  	status_t _status;                               // Game status structure  	uint32 _lastTime;  	uint32 _curTime; @@ -384,8 +361,6 @@ private:  	int _score;                                     // Holds current score  	int _maxscore;                                  // Holds maximum score -	uint16 **loadLongArray(Common::ReadStream &in); -  	void initPlaylist(bool playlist[kMaxTunes]);  	void initConfig();  	void initialize(); diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp index 02fb94c83d..3a11baf620 100644 --- a/engines/hugo/intro.cpp +++ b/engines/hugo/intro.cpp @@ -41,12 +41,38 @@  namespace Hugo { -IntroHandler::IntroHandler(HugoEngine *vm) : _vm(vm) { +IntroHandler::IntroHandler(HugoEngine *vm) : _vm(vm), _introX(0), _introY(0) { +	_introXSize = 0;  }  IntroHandler::~IntroHandler() {  } +/** + * Read _introX and _introY from hugo.dat + */ +void IntroHandler::loadIntroData(Common::SeekableReadStream &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 { +			in.skip(numRows * 2); +		} +	} +} + +void IntroHandler::freeIntroData() { +	free(_introX); +	free(_introY); +} +  intro_v1d::intro_v1d(HugoEngine *vm) : IntroHandler(vm) {  } @@ -68,7 +94,7 @@ void intro_v1d::introInit() {  }  bool intro_v1d::introPlay() { -	byte introSize = _vm->getIntroSize(); +	byte introSize = getIntroSize();  	if (_vm->getGameStatus().skipIntroFl)  		return true; @@ -296,8 +322,8 @@ bool intro_v3d::introPlay() {  	if (_vm->getGameStatus().skipIntroFl)  		return true; -	if (introTicks < _vm->getIntroSize()) { -		font.drawString(&surf, ".", _vm->_introX[introTicks], _vm->_introY[introTicks] - kDibOffY, 320, _TBRIGHTWHITE); +	if (introTicks < getIntroSize()) { +		font.drawString(&surf, ".", _introX[introTicks], _introY[introTicks] - kDibOffY, 320, _TBRIGHTWHITE);  		_vm->_screen->displayBackground();  		// Text boxes at various times @@ -314,7 +340,7 @@ bool intro_v3d::introPlay() {  		}  	} -	return (++introTicks >= _vm->getIntroSize()); +	return (++introTicks >= getIntroSize());  }  intro_v1w::intro_v1w(HugoEngine *vm) : IntroHandler(vm) { @@ -387,9 +413,9 @@ bool intro_v3w::introPlay() {  	if (_vm->getGameStatus().skipIntroFl)  		return true; -	if (introTicks < _vm->getIntroSize()) { +	if (introTicks < getIntroSize()) {  		// 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();  		// Text boxes at various times @@ -406,6 +432,6 @@ bool intro_v3w::introPlay() {  		}  	} -	return (++introTicks >= _vm->getIntroSize()); +	return (++introTicks >= getIntroSize());  }  } // End of namespace Hugo diff --git a/engines/hugo/intro.h b/engines/hugo/intro.h index 37c846fc10..c743475644 100644 --- a/engines/hugo/intro.h +++ b/engines/hugo/intro.h @@ -54,9 +54,18 @@ public:  	virtual void introInit() = 0;  	virtual bool introPlay() = 0; +	void freeIntroData(); +	void loadIntroData(Common::SeekableReadStream &in); + +	byte getIntroSize() const { return _introXSize; } +  protected:  	HugoEngine *_vm; -	int16 introTicks;                               // Count calls to introPlay() + +	byte *_introX; +	byte *_introY; +	byte  _introXSize; +	int16  introTicks;                              // Count calls to introPlay()  };  class intro_v1w : public IntroHandler { diff --git a/engines/hugo/inventory.cpp b/engines/hugo/inventory.cpp index 4bf107575e..7862805d8b 100644 --- a/engines/hugo/inventory.cpp +++ b/engines/hugo/inventory.cpp @@ -46,11 +46,29 @@ namespace Hugo {  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;  	_inventoryState  = kInventoryOff;               // Inventory icon bar state  	_inventoryHeight = 0;                           // Inventory icon bar pos  	_inventoryObjId  = -1;                          // Inventory object selected (none) +	_maxInvent = 0; +} + +/** + * Read _invent from Hugo.dat + */ +void InventoryHandler::loadInvent(Common::SeekableReadStream &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 { +			in.skip(numElem * sizeof(int16)); +		} +	}  }  /** @@ -78,7 +96,7 @@ void InventoryHandler::constructInventory(const int16 imageTotNumb, int displayN  	int16 displayed = 0;  	int16 carried = 0;  	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  			if (displayed < displayNumb && carried >= firstObjId) {  				// Compute source coordinates in dib_u @@ -107,8 +125,8 @@ int16 InventoryHandler::processInventory(const invact_t action, ...) {  	int16 imageNumb;                                // Total number of inventory items  	int displayNumb;                                // Total number displayed/carried  	// Compute total number and number displayed, i.e. number carried -	for (imageNumb = 0, displayNumb = 0; imageNumb < _vm->_maxInvent && _vm->_invent[imageNumb] != -1; imageNumb++) { -		if (_vm->_object->isCarried(_vm->_invent[imageNumb])) +	for (imageNumb = 0, displayNumb = 0; imageNumb < _maxInvent && _invent[imageNumb] != -1; imageNumb++) { +		if (_vm->_object->isCarried(_invent[imageNumb]))  			displayNumb++;  	} @@ -236,4 +254,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 diff --git a/engines/hugo/inventory.h b/engines/hugo/inventory.h index deb22cf9aa..7b1390a3ce 100644 --- a/engines/hugo/inventory.h +++ b/engines/hugo/inventory.h @@ -45,11 +45,15 @@ public:  	void     setInventoryObjId(int16 objId)    { _inventoryObjId = objId; }  	void     setInventoryState(istate_t state) { _inventoryState = state; } +	void     freeInvent()                      { free(_invent);           } +  	int16    getInventoryObjId() const         { return _inventoryObjId;  }  	istate_t getInventoryState() const         { return _inventoryState;  } +	int16 findIconId(int16 objId); +	void  loadInvent(Common::SeekableReadStream &in);  	int16 processInventory(const invact_t action, ...); -	void runInventory(); +	void  runInventory();  private:  	HugoEngine *_vm; @@ -57,9 +61,11 @@ private:  	static const int kStepDy = 8;                   // Pixels per step movement  	int16    _firstIconId;                          // Index of first icon to display +	int16   *_invent;  	istate_t _inventoryState;                       // Inventory icon bar state  	int16    _inventoryHeight;                      // Inventory icon bar height  	int16    _inventoryObjId;                       // Inventory object selected, or -1 +	byte     _maxInvent;  	void constructInventory(const int16 imageTotNumb, int displayNumb, const bool scrollFl, int16 firstObjId);  }; diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp index 9bbc60f04b..3464fea869 100644 --- a/engines/hugo/mouse.cpp +++ b/engines/hugo/mouse.cpp @@ -293,31 +293,31 @@ void MouseHandler::mouseHandler() {  	resetRightButton();  } +void MouseHandler::readHotspot(Common::ReadStream &in, hotspot_t &hotspot) { +	hotspot.screenIndex = in.readSint16BE(); +	hotspot.x1 = in.readSint16BE(); +	hotspot.y1 = in.readSint16BE(); +	hotspot.x2 = in.readSint16BE(); +	hotspot.y2 = in.readSint16BE(); +	hotspot.actIndex = in.readUint16BE(); +	hotspot.viewx = in.readSint16BE(); +	hotspot.viewy = in.readSint16BE(); +	hotspot.direction = in.readSint16BE(); +} +  /**   * Load hotspots data from hugo.dat   */  void MouseHandler::loadHotspots(Common::ReadStream &in) { -	// Read _hotspots +	hotspot_t *wrkHotspots = 0; +	hotspot_t tmp;  	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {  		int numRows = in.readUint16BE(); -		hotspot_t *wrkHotspots = (hotspot_t *)malloc(sizeof(hotspot_t) * numRows); - -		for (int i = 0; i < numRows; i++) { -			wrkHotspots[i].screenIndex = in.readSint16BE(); -			wrkHotspots[i].x1 = in.readSint16BE(); -			wrkHotspots[i].y1 = in.readSint16BE(); -			wrkHotspots[i].x2 = in.readSint16BE(); -			wrkHotspots[i].y2 = in.readSint16BE(); -			wrkHotspots[i].actIndex = in.readUint16BE(); -			wrkHotspots[i].viewx = in.readSint16BE(); -			wrkHotspots[i].viewy = in.readSint16BE(); -			wrkHotspots[i].direction = in.readSint16BE(); -		} -  		if (varnt == _vm->_gameVariant) -			_hotspots = wrkHotspots; -		else -			free(wrkHotspots); +			_hotspots = wrkHotspots = (hotspot_t *)malloc(sizeof(hotspot_t) * numRows); + +		for (int i = 0; i < numRows; i++) +			readHotspot(in, (varnt == _vm->_gameVariant) ? wrkHotspots[i] : tmp);  	}  } diff --git a/engines/hugo/mouse.h b/engines/hugo/mouse.h index eae13b48fb..d43ca054dd 100644 --- a/engines/hugo/mouse.h +++ b/engines/hugo/mouse.h @@ -83,6 +83,7 @@ private:  	void  cursorText(const char *buffer, const int16 cx, const int16 cy, const uif_t fontId, const int16 color);  	void  processRightClick(const int16 objId, const int16 cx, const int16 cy);  	void  processLeftClick(const int16 objId, const int16 cx, const int16 cy); +	void  readHotspot(Common::ReadStream &in, hotspot_t &hotspot);  };  } // End of namespace Hugo diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp index b909df45bb..f9364a8781 100644 --- a/engines/hugo/object.cpp +++ b/engines/hugo/object.cpp @@ -48,9 +48,10 @@  namespace Hugo { -ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0) { +ObjectHandler::ObjectHandler(HugoEngine *vm) : _vm(vm), _objects(0), _uses(0) {  	_numObj = 0;  	_objCount = 0; +	_usesSize = 0;  	memset(_objBound, '\0', sizeof(overlay_t));  	memset(_boundary, '\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  			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 -			sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_cmdList[obj->cmdIndex][0].verbIndex, 0), _vm->_text->getNoun(obj->nounIndex, 0)); -		else if ((verb = _vm->useBG(_vm->_text->getNoun(obj->nounIndex, 0))) != 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->_parser->useBG(_vm->_text->getNoun(obj->nounIndex, 0))) != 0)  			sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->nounIndex, 0));  		else  			return;                                 // Can't use object directly  	} else {  		// Use status.objid on objid  		// 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(obj->nounIndex, 0));  		// 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) {  				// Look for secondary object, if found use matching verb  				bool foundFl = false; @@ -212,40 +213,52 @@ void ObjectHandler::lookObject(object_t *obj) {  }  /** - * Free all object images + * Free all object images, uses and ObjArr (before exiting)   */  void ObjectHandler::freeObjects() {  	debugC(1, kDebugObject, "freeObjects"); -	// Nothing to do if not allocated yet -	if (_vm->_hero == 0 || _vm->_hero->seqList[0].seqPtr == 0) -		return; - -	// Free all sequence lists and image data -	for (int i = 0; i < _numObj; i++) { -		object_t *obj = &_objects[i]; -		for (int j = 0; j < obj->seqNumb; j++) { -			seq_t *seq = obj->seqList[j].seqPtr; -			seq_t *next; -			if (seq == 0) // Failure during database load -				break; -			if (seq->imagePtr != 0) { -				free(seq->imagePtr); -				seq->imagePtr = 0; -			} -			seq = seq->nextSeqPtr; -			while (seq != obj->seqList[j].seqPtr) { +	if (_vm->_hero != 0 && _vm->_hero->seqList[0].seqPtr != 0) { +		// Free all sequence lists and image data +		for (int16 i = 0; i < _numObj; i++) { +			object_t *obj = &_objects[i]; +			for (int16 j = 0; j < obj->seqNumb; j++) { +				seq_t *seq = obj->seqList[j].seqPtr; +				seq_t *next; +				if (seq == 0) // Failure during database load +					break;  				if (seq->imagePtr != 0) {  					free(seq->imagePtr);  					seq->imagePtr = 0;  				} -				next = seq->nextSeqPtr; +				seq = seq->nextSeqPtr; +				while (seq != obj->seqList[j].seqPtr) { +					if (seq->imagePtr != 0) { +						free(seq->imagePtr); +						seq->imagePtr = 0; +					} +					next = seq->nextSeqPtr; +					free(seq); +					seq = next; +				}  				free(seq); -				seq = next;  			} -			free(seq);  		}  	} + +	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;  }  /** @@ -355,122 +368,114 @@ bool ObjectHandler::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) {  	return foundFl;  } +void ObjectHandler::readUse(Common::ReadStream &in, uses_t &curUse) { +	curUse.objId = in.readSint16BE(); +	curUse.dataIndex = in.readUint16BE(); +	uint16 numSubElem = in.readUint16BE(); +	curUse.targets = (target_t *)malloc(sizeof(target_t) * numSubElem); +	for (int j = 0; j < numSubElem; j++) { +		curUse.targets[j].nounIndex = in.readUint16BE(); +		curUse.targets[j].verbIndex = in.readUint16BE(); +	} +}  /** - * Free ObjectArr (before exiting) + * Load _uses from Hugo.dat   */ -void ObjectHandler::freeObjectArr() { -	for(int16 i = 0; i < _objCount; i++) { -		free(_objects[i].stateDataIndex); -		_objects[i].stateDataIndex = 0; +void ObjectHandler::loadObjectUses(Common::ReadStream &in) { +	uses_t tmpUse; +	//Read _uses +	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { +		tmpUse.targets = 0; +		uint16 numElem = in.readUint16BE(); +		if (varnt == _vm->_gameVariant) { +			_usesSize = numElem; +			_uses = (uses_t *)malloc(sizeof(uses_t) * numElem); +		} + +		for (int i = 0; i < numElem; i++) +			readUse(in, (varnt == _vm->_gameVariant) ? _uses[i] : tmpUse); + +		if (tmpUse.targets) +			free(tmpUse.targets);  	} -	free(_objects); -	_objects = 0;  } +void ObjectHandler::readObject(Common::ReadStream &in, object_t &curObject) { +	curObject.nounIndex = in.readUint16BE(); +	curObject.dataIndex = in.readUint16BE(); +	uint16 numSubElem = in.readUint16BE(); + +	if (numSubElem == 0) +		curObject.stateDataIndex = 0; +	else +		curObject.stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem); +	for (int j = 0; j < numSubElem; j++) +		curObject.stateDataIndex[j] = in.readUint16BE(); + +	curObject.pathType = (path_t) in.readSint16BE(); +	curObject.vxPath = in.readSint16BE(); +	curObject.vyPath = in.readSint16BE(); +	curObject.actIndex = in.readUint16BE(); +	curObject.seqNumb = in.readByte(); +	curObject.currImagePtr = 0; + +	if (curObject.seqNumb == 0) { +		curObject.seqList[0].imageNbr = 0; +		curObject.seqList[0].seqPtr = 0; +	} + +	for (int j = 0; j < curObject.seqNumb; j++) { +		curObject.seqList[j].imageNbr = in.readUint16BE(); +		curObject.seqList[j].seqPtr = 0; +	} + +	curObject.cycling = (cycle_t)in.readByte(); +	curObject.cycleNumb = in.readByte(); +	curObject.frameInterval = in.readByte(); +	curObject.frameTimer = in.readByte(); +	curObject.radius = in.readByte(); +	curObject.screenIndex = in.readByte(); +	curObject.x = in.readSint16BE(); +	curObject.y = in.readSint16BE(); +	curObject.oldx = in.readSint16BE(); +	curObject.oldy = in.readSint16BE(); +	curObject.vx = in.readByte(); +	curObject.vy = in.readByte(); +	curObject.objValue = in.readByte(); +	curObject.genericCmd = in.readSint16BE(); +	curObject.cmdIndex = in.readUint16BE(); +	curObject.carriedFl = (in.readByte() != 0); +	curObject.state = in.readByte(); +	curObject.verbOnlyFl = (in.readByte() != 0); +	curObject.priority = in.readByte(); +	curObject.viewx = in.readSint16BE(); +	curObject.viewy = in.readSint16BE(); +	curObject.direction = in.readSint16BE(); +	curObject.curSeqNum = in.readByte(); +	curObject.curImageNum = in.readByte(); +	curObject.oldvx = in.readByte(); +	curObject.oldvy = in.readByte(); +}  /**   * Load ObjectArr from Hugo.dat   */  void ObjectHandler::loadObjectArr(Common::ReadStream &in) {  	debugC(6, kDebugObject, "loadObject(&in)"); +	object_t tmpObject;  	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {  		uint16 numElem = in.readUint16BE(); +		tmpObject.stateDataIndex = 0;  		if (varnt == _vm->_gameVariant) {  			_objCount = numElem;  			_objects = (object_t *)malloc(sizeof(object_t) * numElem); -			for (int i = 0; i < numElem; i++) { -				_objects[i].nounIndex = in.readUint16BE(); -				_objects[i].dataIndex = in.readUint16BE(); -				uint16 numSubElem = in.readUint16BE(); -				if (numSubElem == 0) -					_objects[i].stateDataIndex = 0; -				else -					_objects[i].stateDataIndex = (uint16 *)malloc(sizeof(uint16) * numSubElem); -				for (int j = 0; j < numSubElem; j++) -					_objects[i].stateDataIndex[j] = in.readUint16BE(); -				_objects[i].pathType = (path_t) in.readSint16BE(); -				_objects[i].vxPath = in.readSint16BE(); -				_objects[i].vyPath = in.readSint16BE(); -				_objects[i].actIndex = in.readUint16BE(); -				_objects[i].seqNumb = in.readByte(); -				_objects[i].currImagePtr = 0; -				if (_objects[i].seqNumb == 0) { -					_objects[i].seqList[0].imageNbr = 0; -					_objects[i].seqList[0].seqPtr = 0; -				} -				for (int j = 0; j < _objects[i].seqNumb; j++) { -					_objects[i].seqList[j].imageNbr = in.readUint16BE(); -					_objects[i].seqList[j].seqPtr = 0; -				} -				_objects[i].cycling = (cycle_t)in.readByte(); -				_objects[i].cycleNumb = in.readByte(); -				_objects[i].frameInterval = in.readByte(); -				_objects[i].frameTimer = in.readByte(); -				_objects[i].radius = in.readByte(); -				_objects[i].screenIndex = in.readByte(); -				_objects[i].x = in.readSint16BE(); -				_objects[i].y = in.readSint16BE(); -				_objects[i].oldx = in.readSint16BE(); -				_objects[i].oldy = in.readSint16BE(); -				_objects[i].vx = in.readByte(); -				_objects[i].vy = in.readByte(); -				_objects[i].objValue = in.readByte(); -				_objects[i].genericCmd = in.readSint16BE(); -				_objects[i].cmdIndex = in.readUint16BE(); -				_objects[i].carriedFl = (in.readByte() != 0); -				_objects[i].state = in.readByte(); -				_objects[i].verbOnlyFl = (in.readByte() != 0); -				_objects[i].priority = in.readByte(); -				_objects[i].viewx = in.readSint16BE(); -				_objects[i].viewy = in.readSint16BE(); -				_objects[i].direction = in.readSint16BE(); -				_objects[i].curSeqNum = in.readByte(); -				_objects[i].curImageNum = in.readByte(); -				_objects[i].oldvx = in.readByte(); -				_objects[i].oldvy = in.readByte(); -			} -		} else { -			for (int i = 0; i < numElem; i++) { -				in.readUint16BE(); -				in.readUint16BE(); -				uint16 numSubElem = in.readUint16BE(); -				for (int j = 0; j < numSubElem; j++) -					in.readUint16BE(); -				in.readSint16BE(); -				in.readSint16BE(); -				in.readSint16BE(); -				in.readUint16BE(); -				numSubElem = in.readByte(); -				for (int j = 0; j < numSubElem; j++) -					in.readUint16BE(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readSint16BE(); -				in.readSint16BE(); -				in.readSint16BE(); -				in.readSint16BE(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readSint16BE(); -				in.readUint16BE(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readSint16BE(); -				in.readSint16BE(); -				in.readUint16BE(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -				in.readByte(); -			}  		} + +		for (int i = 0; i < numElem; i++) +			readObject(in, (varnt == _vm->_gameVariant) ? _objects[i] : tmpObject); + +		if (tmpObject.stateDataIndex) +			free(tmpObject.stateDataIndex);  	}  } diff --git a/engines/hugo/object.h b/engines/hugo/object.h index aa2ed9ba9f..dc69411bfa 100644 --- a/engines/hugo/object.h +++ b/engines/hugo/object.h @@ -74,10 +74,12 @@ public:  	int16 findObject(uint16 x, uint16 y);  	void freeObjects();  	void loadObjectArr(Common::ReadStream &in); -	void freeObjectArr(); +	void loadObjectUses(Common::ReadStream &in);  	void loadNumObj(Common::ReadStream &in);  	void lookObject(object_t *obj);  	void readObjectImages(); +	void readObject(Common::ReadStream &in, object_t &curObject); +	void readUse(Common::ReadStream &in, uses_t &curUse);  	void restoreAllSeq();  	void restoreObjects(Common::SeekableReadStream *in);  	void saveObjects(Common::WriteStream *out); @@ -114,6 +116,8 @@ protected:  	static const int kMaxObjNumb = 128;             // Used in Update_images()  	uint16     _objCount; +	uses_t    *_uses; +	uint16     _usesSize;  	void restoreSeq(object_t *obj); diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp index 001ddac8e4..2d5f6c99bb 100644 --- a/engines/hugo/parser.cpp +++ b/engines/hugo/parser.cpp @@ -51,17 +51,152 @@  namespace Hugo { -Parser::Parser(HugoEngine *vm) : -	_vm(vm), _putIndex(0), _getIndex(0), _checkDoubleF1Fl(false) { +Parser::Parser(HugoEngine *vm) : _vm(vm), _putIndex(0), _getIndex(0), _arrayReqs(0), _catchallList(0), _backgroundObjects(0), _cmdList(0) {  	_cmdLineIndex = 0;  	_cmdLineTick = 0;  	_cmdLineCursor = '_';  	_cmdLine[0] = '\0'; +	_cmdListSize = 0; +	_checkDoubleF1Fl = false; +	_backgroundObjectsSize = 0;  }  Parser::~Parser() {  } +/** + * Read a cmd structure from Hugo.dat + */ +void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) { +	curCmd.verbIndex = in.readUint16BE(); +	curCmd.reqIndex = in.readUint16BE(); +	curCmd.textDataNoCarryIndex = in.readUint16BE(); +	curCmd.reqState = in.readByte(); +	curCmd.newState = in.readByte(); +	curCmd.textDataWrongIndex = in.readUint16BE(); +	curCmd.textDataDoneIndex = in.readUint16BE(); +	curCmd.actIndex = in.readUint16BE(); +} + +/** + * Load _cmdList from Hugo.dat + */ +void Parser::loadCmdList(Common::ReadStream &in) { +	cmd tmpCmd; +	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 (int16 i = 0; i < numElem; i++) { +			uint16 numSubElem = in.readUint16BE(); +			if (varnt == _vm->_gameVariant) +				_cmdList[i] = (cmd *)malloc(sizeof(cmd) * numSubElem); +			for (int16 j = 0; j < numSubElem; j++) +				readCmd(in, (varnt == _vm->_gameVariant) ? _cmdList[i][j] : tmpCmd); +		} +	} +} + + +void Parser::readBG(Common::ReadStream &in, background_t &curBG) { +	curBG.verbIndex = in.readUint16BE(); +	curBG.nounIndex = in.readUint16BE(); +	curBG.commentIndex = in.readSint16BE(); +	curBG.matchFl = (in.readByte() != 0); +	curBG.roomState = in.readByte(); +	curBG.bonusIndex = in.readByte(); +} + +/** + * Read _backgrounObjects from Hugo.dat + */ +void Parser::loadBackgroundObjects(Common::ReadStream &in) { +	background_t tmpBG; + +	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { +		uint16 numElem = in.readUint16BE(); + +		if (varnt == _vm->_gameVariant) { +			_backgroundObjectsSize = numElem; +			_backgroundObjects = (background_t **)malloc(sizeof(background_t *) * numElem); +		} + +		for (int i = 0; i < numElem; i++) { +			uint16 numSubElem = in.readUint16BE(); +			if (varnt == _vm->_gameVariant) +				_backgroundObjects[i] = (background_t *)malloc(sizeof(background_t) * numSubElem); + +			for (int j = 0; j < numSubElem; j++) +				readBG(in, (varnt == _vm->_gameVariant) ? _backgroundObjects[i][j] : tmpBG); +		} +	} +} + +/** + * Read _catchallList from Hugo.dat + */ +void Parser::loadCatchallList(Common::ReadStream &in) { +	background_t *wrkCatchallList = 0; +	background_t tmpBG; + +	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { +		uint16 numElem = in.readUint16BE(); + +		if (varnt == _vm->_gameVariant) +			_catchallList = wrkCatchallList = (background_t *)malloc(sizeof(background_t) * numElem); + +		for (int i = 0; i < numElem; i++) +			readBG(in, (varnt == _vm->_gameVariant) ? wrkCatchallList[i] : tmpBG); +	} +} + +void Parser::loadArrayReqs(Common::SeekableReadStream &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() {  	_vm->_config.turboFl = !_vm->_config.turboFl;  } diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h index 2e807e543f..41b40f0527 100644 --- a/engines/hugo/parser.h +++ b/engines/hugo/parser.h @@ -48,11 +48,19 @@ public:  	virtual ~Parser();  	bool isWordPresent(char **wordArr) const; - +	 +	uint16 getCmdDefaultVerbIdx(const uint16 index) const { return _cmdList[index][0].verbIndex; } +	  	void charHandler();  	void command(const char *format, ...); +	void freeParser();  	void keyHandler(Common::Event event); +	void loadArrayReqs(Common::SeekableReadStream &in); +	void loadBackgroundObjects(Common::ReadStream &in); +	void loadCatchallList(Common::ReadStream &in); +	void loadCmdList(Common::ReadStream &in);  	void switchTurbo(); +	const char *useBG(const char *name);  	virtual void lineHandler() = 0;  	virtual void showInventory() const = 0; @@ -64,9 +72,18 @@ protected:  	uint32    _cmdLineTick;                         // For flashing cursor  	char      _cmdLineCursor;  	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 *findVerb() const; +	void  readBG(Common::ReadStream &in, background_t &curBG); +	void  readCmd(Common::ReadStream &in, cmd &curCmd);  	void  showDosInventory() const;  	bool   _checkDoubleF1Fl;                        // Flag used to display user help or instructions diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp index 1565490ce3..5796749354 100644 --- a/engines/hugo/parser_v1d.cpp +++ b/engines/hugo/parser_v1d.cpp @@ -192,18 +192,18 @@ bool Parser_v1d::isObjectVerb_v1(const char *word, object_t *obj) {  		return false;  	int i; -	for (i = 0; _vm->_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? +	for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd +		if (!strcmp(word, _vm->_text->getVerb(_cmdList[cmdIndex][i].verbIndex, 0))) // Is this verb catered for?  			break;  	} -	if (_vm->_cmdList[cmdIndex][i].verbIndex == 0)  // No +	if (_cmdList[cmdIndex][i].verbIndex == 0)       // No  		return false;  	// 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 -		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  			if (!_vm->_object->isCarrying(reqs[i])) {  				Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex)); @@ -413,16 +413,16 @@ void Parser_v1d::lineHandler() {  						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;  		} while (noun);  	}  	noun = findNextNoun(noun);  	if (*farComment != '\0')                        // An object matched but not near enough  		Utils::Box(kBoxAny, "%s", farComment); -	else if (!isCatchallVerb_v1(true, noun, verb, _vm->_catchallList) && -		     !isCatchallVerb_v1(false, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p])  && -		     !isCatchallVerb_v1(false, noun, verb, _vm->_catchallList)) +	else if (!isCatchallVerb_v1(true, noun, verb, _catchallList) && +		     !isCatchallVerb_v1(false, noun, verb, _backgroundObjects[*_vm->_screen_p])  && +		     !isCatchallVerb_v1(false, noun, verb, _catchallList))  		Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh_1d));  } diff --git a/engines/hugo/parser_v1w.cpp b/engines/hugo/parser_v1w.cpp index 2b6741d440..ad00549dcc 100644 --- a/engines/hugo/parser_v1w.cpp +++ b/engines/hugo/parser_v1w.cpp @@ -172,14 +172,14 @@ void Parser_v1w::lineHandler() {  	}  	// 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; -	if (isCatchallVerb_v3(_vm->_backgroundObjects[*_vm->_screen_p])) +	if (isCatchallVerb_v3(_backgroundObjects[*_vm->_screen_p]))  		return; -	if (isBackgroundWord_v3(_vm->_catchallList)) +	if (isBackgroundWord_v3(_catchallList))  		return; -	if (isCatchallVerb_v3(_vm->_catchallList)) +	if (isCatchallVerb_v3(_catchallList))  		return;  	// If a not-near comment was generated, print it diff --git a/engines/hugo/parser_v2d.cpp b/engines/hugo/parser_v2d.cpp index cd7928e069..c963441481 100644 --- a/engines/hugo/parser_v2d.cpp +++ b/engines/hugo/parser_v2d.cpp @@ -165,16 +165,16 @@ void Parser_v2d::lineHandler() {  						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;  		} while (noun);  	}  	noun = findNextNoun(noun); -	if (   !isCatchallVerb_v1(true, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p]) -		&& !isCatchallVerb_v1(true, noun, verb, _vm->_catchallList) -		&& !isCatchallVerb_v1(false, noun, verb, _vm->_backgroundObjects[*_vm->_screen_p]) -		&& !isCatchallVerb_v1(false, noun, verb, _vm->_catchallList)) { +	if (   !isCatchallVerb_v1(true, noun, verb, _backgroundObjects[*_vm->_screen_p]) +		&& !isCatchallVerb_v1(true, noun, verb, _catchallList) +		&& !isCatchallVerb_v1(false, noun, verb, _backgroundObjects[*_vm->_screen_p]) +		&& !isCatchallVerb_v1(false, noun, verb, _catchallList)) {  		if (*farComment != '\0') {                  // An object matched but not near enough  			Utils::Box(kBoxAny, "%s", farComment);  		} else if (_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp index 532b1f92d1..670f6efb73 100644 --- a/engines/hugo/parser_v3d.cpp +++ b/engines/hugo/parser_v3d.cpp @@ -174,14 +174,14 @@ void Parser_v3d::lineHandler() {  	}  	// 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; -	if (isCatchallVerb_v3(_vm->_backgroundObjects[*_vm->_screen_p])) +	if (isCatchallVerb_v3(_backgroundObjects[*_vm->_screen_p]))  		return; -	if (isBackgroundWord_v3(_vm->_catchallList)) +	if (isBackgroundWord_v3(_catchallList))  		return; -	if (isCatchallVerb_v3(_vm->_catchallList)) +	if (isCatchallVerb_v3(_catchallList))  		return;  	// 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;  	int i; -	for (i = 0; _vm->_cmdList[cmdIndex][i].verbIndex != 0; i++) {                 // For each cmd -		if (isWordPresent(_vm->_text->getVerbArray(_vm->_cmdList[cmdIndex][i].verbIndex)))        // Was this verb used? +	for (i = 0; _cmdList[cmdIndex][i].verbIndex != 0; i++) {                           // For each cmd +		if (isWordPresent(_vm->_text->getVerbArray(_cmdList[cmdIndex][i].verbIndex)))  // Was this verb used?  			break;  	} -	if (_vm->_cmdList[cmdIndex][i].verbIndex == 0)   // No verbs used. +	if (_cmdList[cmdIndex][i].verbIndex == 0)       // No verbs used.  		return false;  	// 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))  		return false;  	// 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 -		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  			if (!_vm->_object->isCarrying(reqs[i])) {  				Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex)); diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index b36ce70847..93b1a75a5b 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -48,13 +48,19 @@  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)); +	_numBonuses = 0; +	_screenActsSize = 0;  }  Scheduler::~Scheduler() {  } +void Scheduler::initCypher() { +	_cypher = getCypher(); +} +  /**   * Initialise the timer event queue   */ @@ -142,9 +148,9 @@ uint32 Scheduler::getDosTicks(const bool updateFl) {  void Scheduler::processBonus(const int bonusIndex) {  	debugC(1, kDebugSchedule, "processBonus(%d)", bonusIndex); -	if (!_vm->_points[bonusIndex].scoredFl) { -		_vm->adjustScore(_vm->_points[bonusIndex].score); -		_vm->_points[bonusIndex].scoredFl = true; +	if (!_points[bonusIndex].scoredFl) { +		_vm->adjustScore(_points[bonusIndex].score); +		_points[bonusIndex].scoredFl = true;  	}  } @@ -186,7 +192,7 @@ void Scheduler::newScreen(const int screenIndex) {  	_vm->readScreenFiles(screenIndex);  	// 4. Schedule action list for this screen -	_vm->screenActions(screenIndex); +	_vm->_scheduler->screenActions(screenIndex);  	// 5. Initialise prompt line and status line  	_vm->_screen->initNewScreenDisplay(); @@ -245,580 +251,380 @@ void Scheduler::loadAlNewscrIndex(Common::ReadStream &in) {  }  /** + * Load Points from Hugo.dat + */ +void Scheduler::loadPoints(Common::SeekableReadStream &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 { +			in.skip(numElem); +		} +	} +} + +void Scheduler::readAct(Common::ReadStream &in, act &curAct) { +	uint16 numSubAct; + +	curAct.a0.actType = (action_t) in.readByte(); +	switch (curAct.a0.actType) { +	case ANULL:              // -1 +		break; +	case ASCHEDULE:          // 0 +		curAct.a0.timer = in.readSint16BE(); +		curAct.a0.actIndex = in.readUint16BE(); +		break; +	case START_OBJ:          // 1 +		curAct.a1.timer = in.readSint16BE(); +		curAct.a1.objIndex = in.readSint16BE(); +		curAct.a1.cycleNumb = in.readSint16BE(); +		curAct.a1.cycle = (cycle_t) in.readByte(); +		break; +	case INIT_OBJXY:         // 2 +		curAct.a2.timer = in.readSint16BE(); +		curAct.a2.objIndex = in.readSint16BE(); +		curAct.a2.x = in.readSint16BE(); +		curAct.a2.y = in.readSint16BE(); +		break; +	case PROMPT:             // 3 +		curAct.a3.timer = in.readSint16BE(); +		curAct.a3.promptIndex = in.readSint16BE(); +		numSubAct = in.readUint16BE(); +		curAct.a3.responsePtr = (int *) malloc(sizeof(int) * numSubAct); +		for (int k = 0; k < numSubAct; k++) +			curAct.a3.responsePtr[k] = in.readSint16BE(); +		curAct.a3.actPassIndex = in.readUint16BE(); +		curAct.a3.actFailIndex = in.readUint16BE(); +		curAct.a3.encodedFl = (in.readByte() == 1) ? true : false; +		break; +	case BKGD_COLOR:         // 4 +		curAct.a4.timer = in.readSint16BE(); +		curAct.a4.newBackgroundColor = in.readUint32BE(); +		break; +	case INIT_OBJVXY:        // 5 +		curAct.a5.timer = in.readSint16BE(); +		curAct.a5.objIndex = in.readSint16BE(); +		curAct.a5.vx = in.readSint16BE(); +		curAct.a5.vy = in.readSint16BE(); +		break; +	case INIT_CARRY:         // 6 +		curAct.a6.timer = in.readSint16BE(); +		curAct.a6.objIndex = in.readSint16BE(); +		curAct.a6.carriedFl = (in.readByte() == 1) ? true : false; +		break; +	case INIT_HF_COORD:      // 7 +		curAct.a7.timer = in.readSint16BE(); +		curAct.a7.objIndex = in.readSint16BE(); +		break; +	case NEW_SCREEN:         // 8 +		curAct.a8.timer = in.readSint16BE(); +		curAct.a8.screenIndex = in.readSint16BE(); +		break; +	case INIT_OBJSTATE:      // 9 +		curAct.a9.timer = in.readSint16BE(); +		curAct.a9.objIndex = in.readSint16BE(); +		curAct.a9.newState = in.readByte(); +		break; +	case INIT_PATH:          // 10 +		curAct.a10.timer = in.readSint16BE(); +		curAct.a10.objIndex = in.readSint16BE(); +		curAct.a10.newPathType = in.readSint16BE(); +		curAct.a10.vxPath = in.readByte(); +		curAct.a10.vyPath = in.readByte(); +		break; +	case COND_R:             // 11 +		curAct.a11.timer = in.readSint16BE(); +		curAct.a11.objIndex = in.readSint16BE(); +		curAct.a11.stateReq = in.readByte(); +		curAct.a11.actPassIndex = in.readUint16BE(); +		curAct.a11.actFailIndex = in.readUint16BE(); +		break; +	case TEXT:               // 12 +		curAct.a12.timer = in.readSint16BE(); +		curAct.a12.stringIndex = in.readSint16BE(); +		break; +	case SWAP_IMAGES:        // 13 +		curAct.a13.timer = in.readSint16BE(); +		curAct.a13.objIndex1 = in.readSint16BE(); +		curAct.a13.objIndex2 = in.readSint16BE(); +		break; +	case COND_SCR:           // 14 +		curAct.a14.timer = in.readSint16BE(); +		curAct.a14.objIndex = in.readSint16BE(); +		curAct.a14.screenReq = in.readSint16BE(); +		curAct.a14.actPassIndex = in.readUint16BE(); +		curAct.a14.actFailIndex = in.readUint16BE(); +		break; +	case AUTOPILOT:          // 15 +		curAct.a15.timer = in.readSint16BE(); +		curAct.a15.objIndex1 = in.readSint16BE(); +		curAct.a15.objIndex2 = in.readSint16BE(); +		curAct.a15.dx = in.readByte(); +		curAct.a15.dy = in.readByte(); +		break; +	case INIT_OBJ_SEQ:       // 16 +		curAct.a16.timer = in.readSint16BE(); +		curAct.a16.objIndex = in.readSint16BE(); +		curAct.a16.seqIndex = in.readSint16BE(); +		break; +	case SET_STATE_BITS:     // 17 +		curAct.a17.timer = in.readSint16BE(); +		curAct.a17.objIndex = in.readSint16BE(); +		curAct.a17.stateMask = in.readSint16BE(); +		break; +	case CLEAR_STATE_BITS:   // 18 +		curAct.a18.timer = in.readSint16BE(); +		curAct.a18.objIndex = in.readSint16BE(); +		curAct.a18.stateMask = in.readSint16BE(); +		break; +	case TEST_STATE_BITS:    // 19 +		curAct.a19.timer = in.readSint16BE(); +		curAct.a19.objIndex = in.readSint16BE(); +		curAct.a19.stateMask = in.readSint16BE(); +		curAct.a19.actPassIndex = in.readUint16BE(); +		curAct.a19.actFailIndex = in.readUint16BE(); +		break; +	case DEL_EVENTS:         // 20 +		curAct.a20.timer = in.readSint16BE(); +		curAct.a20.actTypeDel = (action_t) in.readByte(); +		break; +	case GAMEOVER:           // 21 +		curAct.a21.timer = in.readSint16BE(); +		break; +	case INIT_HH_COORD:      // 22 +		curAct.a22.timer = in.readSint16BE(); +		curAct.a22.objIndex = in.readSint16BE(); +		break; +	case EXIT:               // 23 +		curAct.a23.timer = in.readSint16BE(); +		break; +	case BONUS:              // 24 +		curAct.a24.timer = in.readSint16BE(); +		curAct.a24.pointIndex = in.readSint16BE(); +		break; +	case COND_BOX:           // 25 +		curAct.a25.timer = in.readSint16BE(); +		curAct.a25.objIndex = in.readSint16BE(); +		curAct.a25.x1 = in.readSint16BE(); +		curAct.a25.y1 = in.readSint16BE(); +		curAct.a25.x2 = in.readSint16BE(); +		curAct.a25.y2 = in.readSint16BE(); +		curAct.a25.actPassIndex = in.readUint16BE(); +		curAct.a25.actFailIndex = in.readUint16BE(); +		break; +	case SOUND:              // 26 +		curAct.a26.timer = in.readSint16BE(); +		curAct.a26.soundIndex = in.readSint16BE(); +		break; +	case ADD_SCORE:          // 27 +		curAct.a27.timer = in.readSint16BE(); +		curAct.a27.objIndex = in.readSint16BE(); +		break; +	case SUB_SCORE:          // 28 +		curAct.a28.timer = in.readSint16BE(); +		curAct.a28.objIndex = in.readSint16BE(); +		break; +	case COND_CARRY:         // 29 +		curAct.a29.timer = in.readSint16BE(); +		curAct.a29.objIndex = in.readSint16BE(); +		curAct.a29.actPassIndex = in.readUint16BE(); +		curAct.a29.actFailIndex = in.readUint16BE(); +		break; +	case INIT_MAZE:          // 30 +		curAct.a30.timer = in.readSint16BE(); +		curAct.a30.mazeSize = in.readByte(); +		curAct.a30.x1 = in.readSint16BE(); +		curAct.a30.y1 = in.readSint16BE(); +		curAct.a30.x2 = in.readSint16BE(); +		curAct.a30.y2 = in.readSint16BE(); +		curAct.a30.x3 = in.readSint16BE(); +		curAct.a30.x4 = in.readSint16BE(); +		curAct.a30.firstScreenIndex = in.readByte(); +		break; +	case EXIT_MAZE:          // 31 +		curAct.a31.timer = in.readSint16BE(); +		break; +	case INIT_PRIORITY:      // 32 +		curAct.a32.timer = in.readSint16BE(); +		curAct.a32.objIndex = in.readSint16BE(); +		curAct.a32.priority = in.readByte(); +		break; +	case INIT_SCREEN:        // 33 +		curAct.a33.timer = in.readSint16BE(); +		curAct.a33.objIndex = in.readSint16BE(); +		curAct.a33.screenIndex = in.readSint16BE(); +		break; +	case AGSCHEDULE:         // 34 +		curAct.a34.timer = in.readSint16BE(); +		curAct.a34.actIndex = in.readUint16BE(); +		break; +	case REMAPPAL:           // 35 +		curAct.a35.timer = in.readSint16BE(); +		curAct.a35.oldColorIndex = in.readSint16BE(); +		curAct.a35.newColorIndex = in.readSint16BE(); +		break; +	case COND_NOUN:          // 36 +		curAct.a36.timer = in.readSint16BE(); +		curAct.a36.nounIndex = in.readUint16BE(); +		curAct.a36.actPassIndex = in.readUint16BE(); +		curAct.a36.actFailIndex = in.readUint16BE(); +		break; +	case SCREEN_STATE:       // 37 +		curAct.a37.timer = in.readSint16BE(); +		curAct.a37.screenIndex = in.readSint16BE(); +		curAct.a37.newState = in.readByte(); +		break; +	case INIT_LIPS:          // 38 +		curAct.a38.timer = in.readSint16BE(); +		curAct.a38.lipsObjIndex = in.readSint16BE(); +		curAct.a38.objIndex = in.readSint16BE(); +		curAct.a38.dxLips = in.readByte(); +		curAct.a38.dyLips = in.readByte(); +		break; +	case INIT_STORY_MODE:    // 39 +		curAct.a39.timer = in.readSint16BE(); +		curAct.a39.storyModeFl = (in.readByte() == 1); +		break; +	case WARN:               // 40 +		curAct.a40.timer = in.readSint16BE(); +		curAct.a40.stringIndex = in.readSint16BE(); +		break; +	case COND_BONUS:         // 41 +		curAct.a41.timer = in.readSint16BE(); +		curAct.a41.BonusIndex = in.readSint16BE(); +		curAct.a41.actPassIndex = in.readUint16BE(); +		curAct.a41.actFailIndex = in.readUint16BE(); +		break; +	case TEXT_TAKE:          // 42 +		curAct.a42.timer = in.readSint16BE(); +		curAct.a42.objIndex = in.readSint16BE(); +		break; +	case YESNO:              // 43 +		curAct.a43.timer = in.readSint16BE(); +		curAct.a43.promptIndex = in.readSint16BE(); +		curAct.a43.actYesIndex = in.readUint16BE(); +		curAct.a43.actNoIndex = in.readUint16BE(); +		break; +	case STOP_ROUTE:         // 44 +		curAct.a44.timer = in.readSint16BE(); +		break; +	case COND_ROUTE:         // 45 +		curAct.a45.timer = in.readSint16BE(); +		curAct.a45.routeIndex = in.readSint16BE(); +		curAct.a45.actPassIndex = in.readUint16BE(); +		curAct.a45.actFailIndex = in.readUint16BE(); +		break; +	case INIT_JUMPEXIT:      // 46 +		curAct.a46.timer = in.readSint16BE(); +		curAct.a46.jumpExitFl = (in.readByte() == 1); +		break; +	case INIT_VIEW:          // 47 +		curAct.a47.timer = in.readSint16BE(); +		curAct.a47.objIndex = in.readSint16BE(); +		curAct.a47.viewx = in.readSint16BE(); +		curAct.a47.viewy = in.readSint16BE(); +		curAct.a47.direction = in.readSint16BE(); +		break; +	case INIT_OBJ_FRAME:     // 48 +		curAct.a48.timer = in.readSint16BE(); +		curAct.a48.objIndex = in.readSint16BE(); +		curAct.a48.seqIndex = in.readSint16BE(); +		curAct.a48.frameIndex = in.readSint16BE(); +		break; +	case OLD_SONG:           //49 +		curAct.a49.timer = in.readSint16BE(); +		curAct.a49.songIndex = in.readUint16BE(); +		break; +	default: +		error("Engine - Unknown action type encountered: %d", curAct.a0.actType); +	} +} + +/**   * Load actListArr from Hugo.dat   */  void Scheduler::loadActListArr(Common::ReadStream &in) {  	debugC(6, kDebugSchedule, "loadActListArr(&in)"); -	int numElem, numSubElem, numSubAct; +	act tmpAct; + +	int numElem, numSubElem;  	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {  		numElem = in.readUint16BE();  		if (varnt == _vm->_gameVariant) {  			_actListArrSize = numElem;  			_actListArr = (act **)malloc(sizeof(act *) * _actListArrSize); -			for (int i = 0; i < _actListArrSize; i++) { -				numSubElem = in.readUint16BE(); +		} + +		for (int i = 0; i < numElem; i++) { +			numSubElem = in.readUint16BE(); +			if (varnt == _vm->_gameVariant)  				_actListArr[i] = (act *) malloc(sizeof(act) * (numSubElem + 1)); -				for (int j = 0; j < numSubElem; j++) { -					_actListArr[i][j].a0.actType = (action_t) in.readByte(); -					switch (_actListArr[i][j].a0.actType) { -					case ANULL:              // -1 -						break; -					case ASCHEDULE:          // 0 -						_actListArr[i][j].a0.timer = in.readSint16BE(); -						_actListArr[i][j].a0.actIndex = in.readUint16BE(); -						break; -					case START_OBJ:          // 1 -						_actListArr[i][j].a1.timer = in.readSint16BE(); -						_actListArr[i][j].a1.objIndex = in.readSint16BE(); -						_actListArr[i][j].a1.cycleNumb = in.readSint16BE(); -						_actListArr[i][j].a1.cycle = (cycle_t) in.readByte(); -						break; -					case INIT_OBJXY:         // 2 -						_actListArr[i][j].a2.timer = in.readSint16BE(); -						_actListArr[i][j].a2.objIndex = in.readSint16BE(); -						_actListArr[i][j].a2.x = in.readSint16BE(); -						_actListArr[i][j].a2.y = in.readSint16BE(); -						break; -					case PROMPT:             // 3 -						_actListArr[i][j].a3.timer = in.readSint16BE(); -						_actListArr[i][j].a3.promptIndex = in.readSint16BE(); -						numSubAct = in.readUint16BE(); -						_actListArr[i][j].a3.responsePtr = (int *) malloc(sizeof(int) * numSubAct); -						for (int k = 0; k < numSubAct; k++) -							_actListArr[i][j].a3.responsePtr[k] = in.readSint16BE(); -						_actListArr[i][j].a3.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a3.actFailIndex = in.readUint16BE(); -						_actListArr[i][j].a3.encodedFl = (in.readByte() == 1) ? true : false; -						break; -					case BKGD_COLOR:         // 4 -						_actListArr[i][j].a4.timer = in.readSint16BE(); -						_actListArr[i][j].a4.newBackgroundColor = in.readUint32BE(); -						break; -					case INIT_OBJVXY:        // 5 -						_actListArr[i][j].a5.timer = in.readSint16BE(); -						_actListArr[i][j].a5.objIndex = in.readSint16BE(); -						_actListArr[i][j].a5.vx = in.readSint16BE(); -						_actListArr[i][j].a5.vy = in.readSint16BE(); -						break; -					case INIT_CARRY:         // 6 -						_actListArr[i][j].a6.timer = in.readSint16BE(); -						_actListArr[i][j].a6.objIndex = in.readSint16BE(); -						_actListArr[i][j].a6.carriedFl = (in.readByte() == 1) ? true : false; -						break; -					case INIT_HF_COORD:      // 7 -						_actListArr[i][j].a7.timer = in.readSint16BE(); -						_actListArr[i][j].a7.objIndex = in.readSint16BE(); -						break; -					case NEW_SCREEN:         // 8 -						_actListArr[i][j].a8.timer = in.readSint16BE(); -						_actListArr[i][j].a8.screenIndex = in.readSint16BE(); -						break; -					case INIT_OBJSTATE:      // 9 -						_actListArr[i][j].a9.timer = in.readSint16BE(); -						_actListArr[i][j].a9.objIndex = in.readSint16BE(); -						_actListArr[i][j].a9.newState = in.readByte(); -						break; -					case INIT_PATH:          // 10 -						_actListArr[i][j].a10.timer = in.readSint16BE(); -						_actListArr[i][j].a10.objIndex = in.readSint16BE(); -						_actListArr[i][j].a10.newPathType = in.readSint16BE(); -						_actListArr[i][j].a10.vxPath = in.readByte(); -						_actListArr[i][j].a10.vyPath = in.readByte(); -						break; -					case COND_R:             // 11 -						_actListArr[i][j].a11.timer = in.readSint16BE(); -						_actListArr[i][j].a11.objIndex = in.readSint16BE(); -						_actListArr[i][j].a11.stateReq = in.readByte(); -						_actListArr[i][j].a11.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a11.actFailIndex = in.readUint16BE(); -						break; -					case TEXT:               // 12 -						_actListArr[i][j].a12.timer = in.readSint16BE(); -						_actListArr[i][j].a12.stringIndex = in.readSint16BE(); -						break; -					case SWAP_IMAGES:        // 13 -						_actListArr[i][j].a13.timer = in.readSint16BE(); -						_actListArr[i][j].a13.objIndex1 = in.readSint16BE(); -						_actListArr[i][j].a13.objIndex2 = in.readSint16BE(); -						break; -					case COND_SCR:           // 14 -						_actListArr[i][j].a14.timer = in.readSint16BE(); -						_actListArr[i][j].a14.objIndex = in.readSint16BE(); -						_actListArr[i][j].a14.screenReq = in.readSint16BE(); -						_actListArr[i][j].a14.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a14.actFailIndex = in.readUint16BE(); -						break; -					case AUTOPILOT:          // 15 -						_actListArr[i][j].a15.timer = in.readSint16BE(); -						_actListArr[i][j].a15.objIndex1 = in.readSint16BE(); -						_actListArr[i][j].a15.objIndex2 = in.readSint16BE(); -						_actListArr[i][j].a15.dx = in.readByte(); -						_actListArr[i][j].a15.dy = in.readByte(); -						break; -					case INIT_OBJ_SEQ:       // 16 -						_actListArr[i][j].a16.timer = in.readSint16BE(); -						_actListArr[i][j].a16.objIndex = in.readSint16BE(); -						_actListArr[i][j].a16.seqIndex = in.readSint16BE(); -						break; -					case SET_STATE_BITS:     // 17 -						_actListArr[i][j].a17.timer = in.readSint16BE(); -						_actListArr[i][j].a17.objIndex = in.readSint16BE(); -						_actListArr[i][j].a17.stateMask = in.readSint16BE(); -						break; -					case CLEAR_STATE_BITS:   // 18 -						_actListArr[i][j].a18.timer = in.readSint16BE(); -						_actListArr[i][j].a18.objIndex = in.readSint16BE(); -						_actListArr[i][j].a18.stateMask = in.readSint16BE(); -						break; -					case TEST_STATE_BITS:    // 19 -						_actListArr[i][j].a19.timer = in.readSint16BE(); -						_actListArr[i][j].a19.objIndex = in.readSint16BE(); -						_actListArr[i][j].a19.stateMask = in.readSint16BE(); -						_actListArr[i][j].a19.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a19.actFailIndex = in.readUint16BE(); -						break; -					case DEL_EVENTS:         // 20 -						_actListArr[i][j].a20.timer = in.readSint16BE(); -						_actListArr[i][j].a20.actTypeDel = (action_t) in.readByte(); -						break; -					case GAMEOVER:           // 21 -						_actListArr[i][j].a21.timer = in.readSint16BE(); -						break; -					case INIT_HH_COORD:      // 22 -						_actListArr[i][j].a22.timer = in.readSint16BE(); -						_actListArr[i][j].a22.objIndex = in.readSint16BE(); -						break; -					case EXIT:               // 23 -						_actListArr[i][j].a23.timer = in.readSint16BE(); -						break; -					case BONUS:              // 24 -						_actListArr[i][j].a24.timer = in.readSint16BE(); -						_actListArr[i][j].a24.pointIndex = in.readSint16BE(); -						break; -					case COND_BOX:           // 25 -						_actListArr[i][j].a25.timer = in.readSint16BE(); -						_actListArr[i][j].a25.objIndex = in.readSint16BE(); -						_actListArr[i][j].a25.x1 = in.readSint16BE(); -						_actListArr[i][j].a25.y1 = in.readSint16BE(); -						_actListArr[i][j].a25.x2 = in.readSint16BE(); -						_actListArr[i][j].a25.y2 = in.readSint16BE(); -						_actListArr[i][j].a25.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a25.actFailIndex = in.readUint16BE(); -						break; -					case SOUND:              // 26 -						_actListArr[i][j].a26.timer = in.readSint16BE(); -						_actListArr[i][j].a26.soundIndex = in.readSint16BE(); -						break; -					case ADD_SCORE:          // 27 -						_actListArr[i][j].a27.timer = in.readSint16BE(); -						_actListArr[i][j].a27.objIndex = in.readSint16BE(); -						break; -					case SUB_SCORE:          // 28 -						_actListArr[i][j].a28.timer = in.readSint16BE(); -						_actListArr[i][j].a28.objIndex = in.readSint16BE(); -						break; -					case COND_CARRY:         // 29 -						_actListArr[i][j].a29.timer = in.readSint16BE(); -						_actListArr[i][j].a29.objIndex = in.readSint16BE(); -						_actListArr[i][j].a29.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a29.actFailIndex = in.readUint16BE(); -						break; -					case INIT_MAZE:          // 30 -						_actListArr[i][j].a30.timer = in.readSint16BE(); -						_actListArr[i][j].a30.mazeSize = in.readByte(); -						_actListArr[i][j].a30.x1 = in.readSint16BE(); -						_actListArr[i][j].a30.y1 = in.readSint16BE(); -						_actListArr[i][j].a30.x2 = in.readSint16BE(); -						_actListArr[i][j].a30.y2 = in.readSint16BE(); -						_actListArr[i][j].a30.x3 = in.readSint16BE(); -						_actListArr[i][j].a30.x4 = in.readSint16BE(); -						_actListArr[i][j].a30.firstScreenIndex = in.readByte(); -						break; -					case EXIT_MAZE:          // 31 -						_actListArr[i][j].a31.timer = in.readSint16BE(); -						break; -					case INIT_PRIORITY:      // 32 -						_actListArr[i][j].a32.timer = in.readSint16BE(); -						_actListArr[i][j].a32.objIndex = in.readSint16BE(); -						_actListArr[i][j].a32.priority = in.readByte(); -						break; -					case INIT_SCREEN:        // 33 -						_actListArr[i][j].a33.timer = in.readSint16BE(); -						_actListArr[i][j].a33.objIndex = in.readSint16BE(); -						_actListArr[i][j].a33.screenIndex = in.readSint16BE(); -						break; -					case AGSCHEDULE:         // 34 -						_actListArr[i][j].a34.timer = in.readSint16BE(); -						_actListArr[i][j].a34.actIndex = in.readUint16BE(); -						break; -					case REMAPPAL:           // 35 -						_actListArr[i][j].a35.timer = in.readSint16BE(); -						_actListArr[i][j].a35.oldColorIndex = in.readSint16BE(); -						_actListArr[i][j].a35.newColorIndex = in.readSint16BE(); -						break; -					case COND_NOUN:          // 36 -						_actListArr[i][j].a36.timer = in.readSint16BE(); -						_actListArr[i][j].a36.nounIndex = in.readUint16BE(); -						_actListArr[i][j].a36.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a36.actFailIndex = in.readUint16BE(); -						break; -					case SCREEN_STATE:       // 37 -						_actListArr[i][j].a37.timer = in.readSint16BE(); -						_actListArr[i][j].a37.screenIndex = in.readSint16BE(); -						_actListArr[i][j].a37.newState = in.readByte(); -						break; -					case INIT_LIPS:          // 38 -						_actListArr[i][j].a38.timer = in.readSint16BE(); -						_actListArr[i][j].a38.lipsObjIndex = in.readSint16BE(); -						_actListArr[i][j].a38.objIndex = in.readSint16BE(); -						_actListArr[i][j].a38.dxLips = in.readByte(); -						_actListArr[i][j].a38.dyLips = in.readByte(); -						break; -					case INIT_STORY_MODE:    // 39 -						_actListArr[i][j].a39.timer = in.readSint16BE(); -						_actListArr[i][j].a39.storyModeFl = (in.readByte() == 1); -						break; -					case WARN:               // 40 -						_actListArr[i][j].a40.timer = in.readSint16BE(); -						_actListArr[i][j].a40.stringIndex = in.readSint16BE(); -						break; -					case COND_BONUS:         // 41 -						_actListArr[i][j].a41.timer = in.readSint16BE(); -						_actListArr[i][j].a41.BonusIndex = in.readSint16BE(); -						_actListArr[i][j].a41.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a41.actFailIndex = in.readUint16BE(); -						break; -					case TEXT_TAKE:          // 42 -						_actListArr[i][j].a42.timer = in.readSint16BE(); -						_actListArr[i][j].a42.objIndex = in.readSint16BE(); -						break; -					case YESNO:              // 43 -						_actListArr[i][j].a43.timer = in.readSint16BE(); -						_actListArr[i][j].a43.promptIndex = in.readSint16BE(); -						_actListArr[i][j].a43.actYesIndex = in.readUint16BE(); -						_actListArr[i][j].a43.actNoIndex = in.readUint16BE(); -						break; -					case STOP_ROUTE:         // 44 -						_actListArr[i][j].a44.timer = in.readSint16BE(); -						break; -					case COND_ROUTE:         // 45 -						_actListArr[i][j].a45.timer = in.readSint16BE(); -						_actListArr[i][j].a45.routeIndex = in.readSint16BE(); -						_actListArr[i][j].a45.actPassIndex = in.readUint16BE(); -						_actListArr[i][j].a45.actFailIndex = in.readUint16BE(); -						break; -					case INIT_JUMPEXIT:      // 46 -						_actListArr[i][j].a46.timer = in.readSint16BE(); -						_actListArr[i][j].a46.jumpExitFl = (in.readByte() == 1); -						break; -					case INIT_VIEW:          // 47 -						_actListArr[i][j].a47.timer = in.readSint16BE(); -						_actListArr[i][j].a47.objIndex = in.readSint16BE(); -						_actListArr[i][j].a47.viewx = in.readSint16BE(); -						_actListArr[i][j].a47.viewy = in.readSint16BE(); -						_actListArr[i][j].a47.direction = in.readSint16BE(); -						break; -					case INIT_OBJ_FRAME:     // 48 -						_actListArr[i][j].a48.timer = in.readSint16BE(); -						_actListArr[i][j].a48.objIndex = in.readSint16BE(); -						_actListArr[i][j].a48.seqIndex = in.readSint16BE(); -						_actListArr[i][j].a48.frameIndex = in.readSint16BE(); -						break; -					case OLD_SONG:           //49 -						_actListArr[i][j].a49.timer = in.readSint16BE(); -						_actListArr[i][j].a49.songIndex = in.readUint16BE(); -						break; -					default: -						error("Engine - Unknown action type encountered: %d", _actListArr[i][j].a0.actType); -					} +			for (int j = 0; j < numSubElem; j++) { +				if (varnt == _vm->_gameVariant) { +					readAct(in, _actListArr[i][j]); +				} else { +					readAct(in, tmpAct); +					if (tmpAct.a0.actType == PROMPT) +						free(tmpAct.a3.responsePtr);   				} +			} + +			if (varnt == _vm->_gameVariant)  				_actListArr[i][numSubElem].a0.actType = ANULL; +		} +	} +} + + +/** + * Read _screenActs + */ +void Scheduler::loadScreenAct(Common::SeekableReadStream &in) { +	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { +		uint16 numElem = in.readUint16BE(); + +		if (varnt == _vm->_gameVariant) { +			_screenActsSize = numElem; +			_screenActs = (uint16 **)malloc(sizeof(uint16 *) * numElem); +			for (int i = 0; i < numElem; i++) { +				uint16 numSubElem = in.readUint16BE(); +				if (numSubElem == 0) { +					_screenActs[i] = 0; +				} else { +					_screenActs[i] = (uint16 *)malloc(sizeof(uint16) * numSubElem); +					for (int j = 0; j < numSubElem; j++) +						_screenActs[i][j] = in.readUint16BE(); +				}  			}  		} else {  			for (int i = 0; i < numElem; i++) { -				numSubElem = in.readUint16BE(); -				for (int j = 0; j < numSubElem; j++) { -					numSubAct = in.readByte(); -					switch (numSubAct) { -					case ANULL:              // -1 -						break; -					case ASCHEDULE:          // 0 -						in.readSint16BE(); -						in.readUint16BE(); -						break; -					case START_OBJ:          // 1 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						break; -					case INIT_OBJXY:         // 2 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case PROMPT:             // 3 -						in.readSint16BE(); -						in.readSint16BE(); -						numSubAct = in.readUint16BE(); -						for (int k = 0; k < numSubAct; k++) -							in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						in.readByte(); -						break; -					case BKGD_COLOR:         // 4 -						in.readSint16BE(); -						in.readUint32BE(); -						break; -					case INIT_OBJVXY:        // 5 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case INIT_CARRY:         // 6 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						break; -					case INIT_HF_COORD:      // 7 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case NEW_SCREEN:         // 8 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case INIT_OBJSTATE:      // 9 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						break; -					case INIT_PATH:          // 10 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						in.readByte(); -						break; -					case COND_R:             // 11 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case TEXT:               // 12 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case SWAP_IMAGES:        // 13 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case COND_SCR:           // 14 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case AUTOPILOT:          // 15 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						in.readByte(); -						break; -					case INIT_OBJ_SEQ:       // 16 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case SET_STATE_BITS:     // 17 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case CLEAR_STATE_BITS:   // 18 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case TEST_STATE_BITS:    // 19 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case DEL_EVENTS:         // 20 -						in.readSint16BE(); -						in.readByte(); -						break; -					case GAMEOVER:           // 21 -						in.readSint16BE(); -						break; -					case INIT_HH_COORD:      // 22 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case EXIT:               // 23 -						in.readSint16BE(); -						break; -					case BONUS:              // 24 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case COND_BOX:           // 25 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case SOUND:              // 26 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case ADD_SCORE:          // 27 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case SUB_SCORE:          // 28 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case COND_CARRY:         // 29 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case INIT_MAZE:          // 30 -						in.readSint16BE(); -						in.readByte(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						break; -					case EXIT_MAZE:          // 31 -						in.readSint16BE(); -						break; -					case INIT_PRIORITY:      // 32 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						break; -					case INIT_SCREEN:        // 33 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case AGSCHEDULE:         // 34 -						in.readSint16BE(); -						in.readUint16BE(); -						break; -					case REMAPPAL:           // 35 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case COND_NOUN:          // 36 -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case SCREEN_STATE:       // 37 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						break; -					case INIT_LIPS:          // 38 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readByte(); -						in.readByte(); -						break; -					case INIT_STORY_MODE:    // 39 -						in.readSint16BE(); -						in.readByte(); -						break; -					case WARN:               // 40 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case COND_BONUS:         // 41 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case TEXT_TAKE:          // 42 -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case YESNO:              // 43 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case STOP_ROUTE:         // 44 -						in.readSint16BE(); -						break; -					case COND_ROUTE:         // 45 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readUint16BE(); -						in.readUint16BE(); -						break; -					case INIT_JUMPEXIT:      // 46 -						in.readSint16BE(); -						in.readByte(); -						break; -					case INIT_VIEW:          // 47 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case INIT_OBJ_FRAME:     // 48 -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						in.readSint16BE(); -						break; -					case OLD_SONG:           //49 -						in.readSint16BE(); -						in.readUint16BE(); -						break; -					default: -						error("Engine - Unknown action type encountered %d - variante %d pos %d.%d", numSubAct, varnt, i, j); -					} -				} +				uint16 numSubElem = in.readUint16BE(); +				in.skip(numSubElem * sizeof(uint16));  			}  		}  	}  } -void Scheduler::freeActListArr() { +void Scheduler::freeScheduler() {  	debugC(6, kDebugSchedule, "freeActListArr()"); +	free(_points); + +	if (_screenActs) { +		for (int i = 0; i < _screenActsSize; i++) +			free(_screenActs[i]); +		free(_screenActs); +	} +  	if (_actListArr) {  		for (int i = 0; i < _actListArrSize; i++) {  			for (int j = 0; _actListArr[i][j].a0.actType != ANULL; j++) { @@ -832,6 +638,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   * bounding box, if so, go to the next room   */ @@ -935,10 +754,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  */ -  void Scheduler::saveActions(Common::WriteStream* f) const {  	for (int i = 0; i < _actListArrSize; i++) {  		// write all the sub elems data @@ -979,6 +804,27 @@ void Scheduler::findAction(act* action, int16* index, int16* subElem) {  	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   */ @@ -1262,7 +1108,7 @@ event_t *Scheduler::doAction(event_t *curEvent) {  		Utils::Box(kBoxOk, "%s", _vm->_file->fetchString(action->a40.stringIndex));  		break;  	case COND_BONUS:                                // act41: Perform action if got bonus -		if (_vm->_points[action->a41.BonusIndex].scoredFl) +		if (_points[action->a41.BonusIndex].scoredFl)  			insertActionList(action->a41.actPassIndex);  		else  			insertActionList(action->a41.actFailIndex); @@ -1354,6 +1200,9 @@ void Scheduler::delQueue(event_t *curEvent) {  	_freeEvent = curEvent;  } +/** + * Delete all the active events of a given type + */  void Scheduler::delEventType(const action_t actTypeDel) {  	// Note: actions are not deleted here, simply turned into NOPs!  	event_t *wrkEvent = _headEvent;                 // The earliest event @@ -1367,6 +1216,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) {  } @@ -1427,11 +1297,9 @@ void Scheduler_v1d::promptAction(act *action) {  void Scheduler_v1d::decodeString(char *line) {  	debugC(1, kDebugSchedule, "decodeString(%s)", line); -	static const Common::String cypher = getCypher(); -  	uint16 linelength = strlen(line);  	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] < ' ')  			line[i] += ' ';  	} @@ -1480,11 +1348,10 @@ void Scheduler_v2d::promptAction(act *action) {  void Scheduler_v2d::decodeString(char *line) {  	debugC(1, kDebugSchedule, "decodeString(%s)", line); -	static const Common::String cypher = getCypher(); -  	int16 lineLength = strlen(line);  	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);  } diff --git a/engines/hugo/schedule.h b/engines/hugo/schedule.h index b4889aa728..c7a6003ddf 100644 --- a/engines/hugo/schedule.h +++ b/engines/hugo/schedule.h @@ -458,31 +458,41 @@ public:  	virtual void decodeString(char *line) = 0;  	virtual void runScheduler() = 0; -	void freeActListArr(); +	int16 calcMaxPoints() const; + +	void freeScheduler(); +	void initCypher();  	void initEventQueue();  	void insertActionList(const uint16 actIndex);  	void loadActListArr(Common::ReadStream &in);  	void loadAlNewscrIndex(Common::ReadStream &in); +	void loadPoints(Common::SeekableReadStream &in); +	void loadScreenAct(Common::SeekableReadStream &in);  	void newScreen(const int screenIndex);  	void processBonus(const int bonusIndex);  	void processMaze(const int x1, const int x2, const int y1, const int y2); +	void readAct(Common::ReadStream &in, act &curAct); +	void restoreSchedulerData(Common::ReadStream *in);  	void restoreScreen(const int screenIndex); -	void restoreEvents(Common::ReadStream *f); -	void saveEvents(Common::WriteStream *f); +	void saveSchedulerData(Common::WriteStream *out);  	void waitForRefresh();  	void findAction(act* action, int16* index, int16* subElem); -	void saveActions(Common::WriteStream* f) const; -	void restoreActions(Common::ReadStream *f); -  protected:  	HugoEngine *_vm;  	static const int kFilenameLength = 12;          // Max length of a DOS file name  	static const int kMaxEvents = 50;               // Max events in event queue  	static const int kShiftSize = 8;                // Place hero this far inside bounding box +	Common::String _cypher; +  	uint16   _actListArrSize;  	uint16   _alNewscrIndex; +	uint16   _screenActsSize; +	uint16 **_screenActs; + +	byte     _numBonuses; +	point_t *_points;  	uint32 _curTick;                                // Current system time in ticks  	uint32 _oldTime;                                // The previous wall time in ticks @@ -510,6 +520,14 @@ protected:  	void delEventType(const action_t actTypeDel);  	void delQueue(event_t *curEvent);  	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 { diff --git a/engines/hugo/text.h b/engines/hugo/text.h index cf728f6ad4..ec4001567d 100644 --- a/engines/hugo/text.h +++ b/engines/hugo/text.h @@ -42,8 +42,8 @@ public:  	const char  *getTextParser(int parserIndex) const  { return _textParser[parserIndex];  }  	const char  *getTextUtil(int utilIndex) const      { return _textUtil[utilIndex];      }  	const char  *getVerb(int idx1, int idx2) const     { return _arrayVerbs[idx1][idx2];   } -	char **getNounArray(int idx1) { return _arrayNouns[idx1]; } -	char **getVerbArray(int idx1) { return _arrayVerbs[idx1]; } +	char **getNounArray(int idx1) const { return _arrayNouns[idx1]; } +	char **getVerbArray(int idx1) const { return _arrayVerbs[idx1]; }  	void loadAllTexts(Common::ReadStream &in);  	void freeAllTexts(); diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index 5c471a8c8b..990e55bcf2 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -504,6 +504,14 @@ void KyraEngine_HoF::runLoop() {  		int inputFlag = checkInput(_buttonList, true);  		removeInputTop(); +		if (_updateHandItemCursor) { +			// This works around an issue which would occur when setHandItem(_itemInHand) +			// was called from inside loadGameState(). When loading via GMM the +			// mouse cursor would not be set correctly. +			_updateHandItemCursor = false; +			setHandItem(_itemInHand); +		} +  		update();  		if (inputFlag == 198 || inputFlag == 199) { diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index d46fc2d502..7526216066 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -819,6 +819,14 @@ void KyraEngine_LoK::updateMousePointer(bool forceUpdate) {  		newY = 4;  	} +	if (_updateHandItemCursor) { +		// This works around an issue which would occur when setHandItem(_itemInHand) +		// was called from inside loadGameState(). When loading via GMM the +		// mouse cursor would not be set correctly. +		_updateHandItemCursor = false; +		setHandItem(_itemInHand); +	} +  	if ((newMouseState && _mouseState != newMouseState) || (newMouseState && forceUpdate)) {  		_mouseState = newMouseState;  		_screen->hideMouse(); diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index a6b99fffbf..b863ef5725 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -966,6 +966,14 @@ void KyraEngine_MR::runLoop() {  		int inputFlag = checkInput(_mainButtonList, true);  		removeInputTop(); +		if (_updateHandItemCursor) { +			// This works around an issue which would occur when setHandItem(_itemInHand) +			// was called from inside loadGameState(). When loading via GMM the +			// mouse cursor would not be set correctly. +			_updateHandItemCursor = false; +			setHandItem(_itemInHand); +		} +  		update();  		_timer->update(); diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index f5b96410e8..3a5d21196b 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -65,6 +65,7 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)  	_gameToLoad = -1;  	_mouseState = -1; +	_updateHandItemCursor = false;  	_deathHandler = -1;  	memset(_flagsTable, 0, sizeof(_flagsTable)); @@ -128,10 +129,11 @@ Common::Error KyraEngine_v1::init() {  			_sound = new SoundAdLibPC(this, _mixer);  		} else {  			Sound::kType type; +			const MusicType midiType = MidiDriver::getMusicType(dev); -			if (MidiDriver::getMusicType(dev) == MT_PCSPK) +			if (midiType == MT_PCSPK || midiType == MT_NULL)  				type = Sound::kPCSpkr; -			else if (MidiDriver::getMusicType(dev) == MT_MT32 || ConfMan.getBool("native_mt32")) +			else if (midiType == MT_MT32 || ConfMan.getBool("native_mt32"))  				type = Sound::kMidiMT32;  			else  				type = Sound::kMidiGM; diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h index 12b9fb5942..cf51774b0f 100644 --- a/engines/kyra/kyra_v1.h +++ b/engines/kyra/kyra_v1.h @@ -343,6 +343,9 @@ protected:  	virtual void setHandItem(Item item) = 0;  	virtual void removeHandItem() = 0; +	void setDelayedCursorUpdate() { _updateHandItemCursor = true; } +	bool _updateHandItemCursor; +  	// game flags  	uint8 _flagsTable[100]; // TODO: check this value diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 36bc0c99d7..7003d8c38f 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -931,6 +931,14 @@ void LoLEngine::runLoop() {  		checkFloatingPointerRegions();  		gui_updateInput(); +		if (_updateHandItemCursor) { +			// This works around an issue which would occur when setHandItem(_itemInHand) +			// was called from inside loadGameState(). When loading via GMM the +			// mouse cursor would not be set correctly. +			_updateHandItemCursor = false; +			setHandItem(_itemInHand); +		} +  		update();  		if (_sceneUpdateRequired) diff --git a/engines/kyra/saveload_hof.cpp b/engines/kyra/saveload_hof.cpp index ced103b7e3..7a487dcf7b 100644 --- a/engines/kyra/saveload_hof.cpp +++ b/engines/kyra/saveload_hof.cpp @@ -311,7 +311,7 @@ Common::Error KyraEngine_HoF::loadGameState(int slot) {  	_mainCharacter.facing = 4;  	enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1); -	setHandItem(_itemInHand); +	setDelayedCursorUpdate();  	if (_lastMusicCommand >= 0 && !_unkSceneScreenFlag1)  		snd_playWanderScoreViaMap(_lastMusicCommand, 1); diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp index 3e11d3dad3..012ff138b5 100644 --- a/engines/kyra/saveload_lok.cpp +++ b/engines/kyra/saveload_lok.cpp @@ -176,7 +176,7 @@ Common::Error KyraEngine_LoK::loadGameState(int slot) {  		_screen->copyRegion(8, 8, 8, 8, 304, 212, 10, 0);  	} -	setHandItem(_itemInHand); +	setDelayedCursorUpdate();  	// Will-O-Wisp uses a different shape size than Brandon's usual  	// shape, thus we need to setup the correct size depending on diff --git a/engines/kyra/saveload_lol.cpp b/engines/kyra/saveload_lol.cpp index ee4fbf4dc1..b6c0693a16 100644 --- a/engines/kyra/saveload_lol.cpp +++ b/engines/kyra/saveload_lol.cpp @@ -263,7 +263,7 @@ Common::Error LoLEngine::loadGameState(int slot) {  	int t = _credits;  	_credits = 0;  	giveCredits(t, 0); -	setHandItem(_itemInHand); +	setDelayedCursorUpdate();  	loadLevel(_currentLevel);  	gui_drawPlayField();  	timerSpecialCharacterUpdate(0); diff --git a/engines/kyra/saveload_mr.cpp b/engines/kyra/saveload_mr.cpp index 7c583f95ee..a5e9b9e0f5 100644 --- a/engines/kyra/saveload_mr.cpp +++ b/engines/kyra/saveload_mr.cpp @@ -308,7 +308,7 @@ Common::Error KyraEngine_MR::loadGameState(int slot) {  	_goodConsciencePosition = false;  	enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1); -	setHandItem(_itemInHand); +	setDelayedCursorUpdate();  	if (_lastMusicCommand >= 0 && !_unkSceneScreenFlag1)  		snd_playWanderScoreViaMap(_lastMusicCommand, 1); diff --git a/engines/mohawk/detection_tables.h b/engines/mohawk/detection_tables.h index ae37a22dd3..92333f5fde 100644 --- a/engines/mohawk/detection_tables.h +++ b/engines/mohawk/detection_tables.h @@ -1156,7 +1156,7 @@ static const MohawkGameDescription gameDescriptions[] = {  		},  		GType_LIVINGBOOKSV4,  		0, -		0, +		0  	},  	{ @@ -1171,7 +1171,25 @@ static const MohawkGameDescription gameDescriptions[] = {  		},  		GType_LIVINGBOOKSV4,  		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  	},  	{ diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index d8c9786fcf..f842269893 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -417,45 +417,45 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS  	switch (_curStack) {  	case kChannelwoodStack:  		_gameState->_globals.currentAge = 4; -		_scriptParser = new MystScriptParser_Channelwood(this); +		_scriptParser = new MystStacks::Channelwood(this);  		break;  	case kCreditsStack: -		_scriptParser = new MystScriptParser_Credits(this); +		_scriptParser = new MystStacks::Credits(this);  		break;  	case kDemoStack: -		_scriptParser = new MystScriptParser_Demo(this); +		_scriptParser = new MystStacks::Demo(this);  		break;  	case kDniStack:  		_gameState->_globals.currentAge = 6; -		_scriptParser = new MystScriptParser_Dni(this); +		_scriptParser = new MystStacks::Dni(this);  		break;  	case kIntroStack: -		_scriptParser = new MystScriptParser_Intro(this); +		_scriptParser = new MystStacks::Intro(this);  		break;  	case kMakingOfStack: -		_scriptParser = new MystScriptParser_MakingOf(this); +		_scriptParser = new MystStacks::MakingOf(this);  		break;  	case kMechanicalStack:  		_gameState->_globals.currentAge = 3; -		_scriptParser = new MystScriptParser_Mechanical(this); +		_scriptParser = new MystStacks::Mechanical(this);  		break;  	case kMystStack:  		_gameState->_globals.currentAge = 2; -		_scriptParser = new MystScriptParser_Myst(this); +		_scriptParser = new MystStacks::Myst(this);  		break;  	case kDemoPreviewStack: -		_scriptParser = new MystScriptParser_Preview(this); +		_scriptParser = new MystStacks::Preview(this);  		break;  	case kSeleniticStack:  		_gameState->_globals.currentAge = 0; -		_scriptParser = new MystScriptParser_Selenitic(this); +		_scriptParser = new MystStacks::Selenitic(this);  		break;  	case kDemoSlidesStack: -		_scriptParser = new MystScriptParser_Slides(this); +		_scriptParser = new MystStacks::Slides(this);  		break;  	case kStoneshipStack:  		_gameState->_globals.currentAge = 1; -		_scriptParser = new MystScriptParser_Stoneship(this); +		_scriptParser = new MystStacks::Stoneship(this);  		break;  	default:  		error("Unknown Myst stack"); diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index 25eeac0a6c..17a2c66091 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -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) {  	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 dstRect = Common::Rect(argv[5], argv[6], 544, 333); diff --git a/engines/mohawk/myst_stacks/channelwood.cpp b/engines/mohawk/myst_stacks/channelwood.cpp index 6e367d0167..26267cfbda 100644 --- a/engines/mohawk/myst_stacks/channelwood.cpp +++ b/engines/mohawk/myst_stacks/channelwood.cpp @@ -35,18 +35,19 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Channelwood::MystScriptParser_Channelwood(MohawkEngine_Myst *vm) : +Channelwood::Channelwood(MohawkEngine_Myst *vm) :  		MystScriptParser(vm), _state(vm->_gameState->_channelwood) {  	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  	OPCODE(100, o_bridgeToggle);  	OPCODE(101, o_pipeExtend); @@ -89,15 +90,15 @@ void MystScriptParser_Channelwood::setupOpcodes() {  #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) {  	case 1: // Water Pump Bridge Raised  		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) {  	case 1: // Water Pump Bridge Raised  		_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;  	switch (var) { @@ -270,7 +271,7 @@ bool MystScriptParser_Channelwood::setVarValue(uint16 var, uint16 value) {  	return refresh;  } -bool MystScriptParser_Channelwood::pipeChangeValve(bool open, uint16 mask) { +bool Channelwood::pipeChangeValve(bool open, uint16 mask) {  	if (open) {  		if (!(_state.waterValveStates & mask)) {  			_state.waterValveStates |= mask; @@ -286,7 +287,7 @@ bool MystScriptParser_Channelwood::pipeChangeValve(bool open, uint16 mask) {  	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);  	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);  } -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);  	uint16 soundId = argv[0]; @@ -319,7 +320,7 @@ void MystScriptParser_Channelwood::o_pipeExtend(uint16 op, uint16 var, uint16 ar  	_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);  	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);  	Common::Rect rect = _invokingResource->getRect(); @@ -354,7 +355,7 @@ void MystScriptParser_Channelwood::o_waterTankValveOpen(uint16 op, uint16 var, u  	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);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -363,7 +364,7 @@ void MystScriptParser_Channelwood::o_leverStartMove(uint16 op, uint16 var, uint1  	_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);  	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);  	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);  	// Get current lever frame @@ -411,12 +412,12 @@ void MystScriptParser_Channelwood::o_leverEndMove(uint16 op, uint16 var, uint16  	_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();  	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);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -425,20 +426,20 @@ void MystScriptParser_Channelwood::o_leverEndMoveWithSound(uint16 op, uint16 var  		_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->_system->updateScreen();  	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);  	_vm->_gfx->copyImageToScreen(3265, Common::Rect(544, 333));  	_vm->_system->updateScreen();  	_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);  	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);  	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);  } -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);  	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);  	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);  	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);  } -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);  	MystResourceType12 *handle = static_cast<MystResourceType12 *>(_invokingResource); @@ -525,7 +526,7 @@ void MystScriptParser_Channelwood::o_valveHandleMoveStop(uint16 op, uint16 var,  	_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);  	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);  	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);  } -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);  	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);  	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);  } -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);  	// 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);  	_siriusDrawerState = 1; @@ -621,7 +622,7 @@ void MystScriptParser_Channelwood::o_drawerOpen(uint16 op, uint16 var, uint16 ar  	_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);  	_vm->_sound->pauseBackgroundMyst(); @@ -648,14 +649,14 @@ void MystScriptParser_Channelwood::o_hologramTemple(uint16 op, uint16 var, uint1  	_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);  	MystResourceType5 *resource = static_cast<MystResourceType5 *>(_vm->_resources[argv[0]]);  	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);  	Common::Rect rect = _invokingResource->getRect(); @@ -669,7 +670,7 @@ void MystScriptParser_Channelwood::o_waterTankValveClose(uint16 op, uint16 var,  	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)  	debugC(kDebugScript, "Opcode %d: Elevator movie", op); @@ -714,7 +715,7 @@ void MystScriptParser_Channelwood::o_elevatorMovies(uint16 op, uint16 var, uint1  	_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);  	uint16 soundId = argv[0]; @@ -723,19 +724,20 @@ void MystScriptParser_Channelwood::o_soundReplace(uint16 op, uint16 var, uint16  	_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);  	_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);  	_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);  	_siriusDrawerState = 0;  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/channelwood.h b/engines/mohawk/myst_stacks/channelwood.h index 8c52f864cd..5eeaa63e23 100644 --- a/engines/mohawk/myst_stacks/channelwood.h +++ b/engines/mohawk/myst_stacks/channelwood.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Channelwood(MohawkEngine_Myst *vm); -	~MystScriptParser_Channelwood(); +	Channelwood(MohawkEngine_Myst *vm); +	~Channelwood();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -99,6 +100,7 @@ private:  	bool pipeChangeValve(bool open, uint16 mask);  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/credits.cpp b/engines/mohawk/myst_stacks/credits.cpp index 6c0b2c2951..61772eda4d 100644 --- a/engines/mohawk/myst_stacks/credits.cpp +++ b/engines/mohawk/myst_stacks/credits.cpp @@ -33,19 +33,20 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks {  // NOTE: Credits Start Card is 10000 -MystScriptParser_Credits::MystScriptParser_Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +Credits::Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) {  	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  	OPCODE(100, o_quit); @@ -55,11 +56,11 @@ void MystScriptParser_Credits::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Credits::disablePersistentScripts() { +void Credits::disablePersistentScripts() {  	_creditsRunning = false;  } -void MystScriptParser_Credits::runPersistentScripts() { +void Credits::runPersistentScripts() {  	if (!_creditsRunning)  		return; @@ -79,7 +80,7 @@ void MystScriptParser_Credits::runPersistentScripts() {  	}  } -uint16 MystScriptParser_Credits::getVar(uint16 var) { +uint16 Credits::getVar(uint16 var) {  	switch(var) {  	case 0: // Credits Image Control  		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  	_creditsRunning = true;  	_curImage = 0;  	_startTime = _vm->_system->getMillis();  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/credits.h b/engines/mohawk/myst_stacks/credits.h index 46d23c67ca..4f9eaa2944 100644 --- a/engines/mohawk/myst_stacks/credits.h +++ b/engines/mohawk/myst_stacks/credits.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Credits(MohawkEngine_Myst *vm); -	~MystScriptParser_Credits(); +	Credits(MohawkEngine_Myst *vm); +	~Credits();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -55,6 +56,7 @@ private:  	uint16 _curImage; // 56  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/demo.cpp b/engines/mohawk/myst_stacks/demo.cpp index 548a2d5390..a2dd148b22 100644 --- a/engines/mohawk/myst_stacks/demo.cpp +++ b/engines/mohawk/myst_stacks/demo.cpp @@ -29,25 +29,26 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Demo::MystScriptParser_Demo(MohawkEngine_Myst *vm) : MystScriptParser_Intro(vm) { +Demo::Demo(MohawkEngine_Myst *vm) : Intro(vm) {  	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) \  	for (uint32 i = 0; i < _opcodes.size(); i++) \  		if (_opcodes[i]->op == opcode) { \ -			_opcodes[i]->proc = (OpcodeProcMyst) &MystScriptParser_Demo::x; \ +			_opcodes[i]->proc = (OpcodeProcMyst) &Demo::x; \  			_opcodes[i]->desc = #x; \  			break; \  		} -void MystScriptParser_Demo::setupOpcodes() { +void Demo::setupOpcodes() {  	// "Stack-Specific" Opcodes  	OVERRIDE_OPCODE(100, opcode_100);  	OPCODE(101, opcode_101); @@ -63,14 +64,14 @@ void MystScriptParser_Demo::setupOpcodes() {  #undef OPCODE  #undef OVERRIDE_OPCODE -void MystScriptParser_Demo::disablePersistentScripts() { -	MystScriptParser_Intro::disablePersistentScripts(); +void Demo::disablePersistentScripts() { +	Intro::disablePersistentScripts();  	_enabled201 = false;  } -void MystScriptParser_Demo::runPersistentScripts() { -	MystScriptParser_Intro::runPersistentScripts(); +void Demo::runPersistentScripts() { +	Intro::runPersistentScripts();  	if (_enabled201) {  		// 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...  } -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);  	// 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);  } -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);  	// 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);  } -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);  	// 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  	varUnusedCheck(op, var);  	// TODO: Fill in Function...  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/demo.h b/engines/mohawk/myst_stacks/demo.h index f693ea4c35..054dc7befe 100644 --- a/engines/mohawk/myst_stacks/demo.h +++ b/engines/mohawk/myst_stacks/demo.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Demo(MohawkEngine_Myst *vm); -	~MystScriptParser_Demo(); +	Demo(MohawkEngine_Myst *vm); +	~Demo();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -59,6 +60,7 @@ private:  	bool _enabled201;  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/dni.cpp b/engines/mohawk/myst_stacks/dni.cpp index 47382b7b81..ffbf9c991f 100644 --- a/engines/mohawk/myst_stacks/dni.cpp +++ b/engines/mohawk/myst_stacks/dni.cpp @@ -32,19 +32,20 @@  #include "mohawk/myst_stacks/dni.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Dni::MystScriptParser_Dni(MohawkEngine_Myst *vm) : +Dni::Dni(MohawkEngine_Myst *vm) :  		MystScriptParser(vm) {  	setupOpcodes();  	_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  	OPCODE(100, NOP);  	OPCODE(101, o_handPage); @@ -58,13 +59,13 @@ void MystScriptParser_Dni::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Dni::disablePersistentScripts() { +void Dni::disablePersistentScripts() {  	_atrusRunning = false;  	_waitForLoop = false;  	_atrusLeft = false;  } -void MystScriptParser_Dni::runPersistentScripts() { +void Dni::runPersistentScripts() {  	if (_atrusRunning)  		atrus_run(); @@ -75,7 +76,7 @@ void MystScriptParser_Dni::runPersistentScripts() {  		atrusLeft_run();  } -uint16 MystScriptParser_Dni::getVar(uint16 var) { +uint16 Dni::getVar(uint16 var) {  	switch(var) {  	case 0: // Atrus Gone (from across room)  		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);  	// 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) {  		_video = _vm->wrapMovieFilename("atrus2", kDniStack);  		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()) {  		VideoHandle atrus = _vm->_video->playMovie(_video, 215, 77);  		_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) {  		// Wait for atrus to come back  		_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);  	_atrusRunning = true;  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/dni.h b/engines/mohawk/myst_stacks/dni.h index 85900ad562..b50f018d3e 100644 --- a/engines/mohawk/myst_stacks/dni.h +++ b/engines/mohawk/myst_stacks/dni.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Dni(MohawkEngine_Myst *vm); -	~MystScriptParser_Dni(); +	Dni(MohawkEngine_Myst *vm); +	~Dni();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -67,6 +68,7 @@ private:  	bool _atrusLeft; // 80  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp index a4a8cf2a89..0d8f67a85b 100644 --- a/engines/mohawk/myst_stacks/intro.cpp +++ b/engines/mohawk/myst_stacks/intro.cpp @@ -34,17 +34,18 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Intro::MystScriptParser_Intro(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +Intro::Intro(MohawkEngine_Myst *vm) : MystScriptParser(vm) {  	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  	OPCODE(100, o_useLinkBook); @@ -58,12 +59,12 @@ void MystScriptParser_Intro::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Intro::disablePersistentScripts() { +void Intro::disablePersistentScripts() {  	_introMoviesRunning = false;  	_linkBookRunning = false;  } -void MystScriptParser_Intro::runPersistentScripts() { +void Intro::runPersistentScripts() {  	if (_introMoviesRunning)  		introMovies_run(); @@ -71,7 +72,7 @@ void MystScriptParser_Intro::runPersistentScripts() {  		mystLinkBook_run();  } -uint16 MystScriptParser_Intro::getVar(uint16 var) { +uint16 Intro::getVar(uint16 var) {  	switch(var) {  	case 0:  		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.  	// Other stacks use Opcode 40, which takes SoundId values as arguments.  	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]);  } -void MystScriptParser_Intro::introMovies_run() { +void Intro::introMovies_run() {  	// Play Intro Movies  	// 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;  	_introStep = 0;  } -void MystScriptParser_Intro::mystLinkBook_run() { +void Intro::mystLinkBook_run() {  	if (_startTime == 1) {  		_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);  	_linkBookMovie = static_cast<MystResourceType6 *>(_invokingResource); @@ -183,4 +184,5 @@ void MystScriptParser_Intro::o_mystLinkBook_init(uint16 op, uint16 var, uint16 a  	_linkBookRunning = true;  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/intro.h b/engines/mohawk/myst_stacks/intro.h index a40d268d7d..0ecd9e6883 100644 --- a/engines/mohawk/myst_stacks/intro.h +++ b/engines/mohawk/myst_stacks/intro.h @@ -32,16 +32,17 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  class MystResourceType6;  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: -	MystScriptParser_Intro(MohawkEngine_Myst *vm); -	~MystScriptParser_Intro(); +	Intro(MohawkEngine_Myst *vm); +	~Intro();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -65,6 +66,7 @@ private:  	MystResourceType6 *_linkBookMovie;  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/makingof.cpp b/engines/mohawk/myst_stacks/makingof.cpp index 28b8665f52..e639092ed4 100644 --- a/engines/mohawk/myst_stacks/makingof.cpp +++ b/engines/mohawk/myst_stacks/makingof.cpp @@ -33,27 +33,29 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_MakingOf::MystScriptParser_MakingOf(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +MakingOf::MakingOf(MohawkEngine_Myst *vm) : MystScriptParser(vm) {  	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  	OPCODE(100, o_quit);  }  #undef OPCODE -void MystScriptParser_MakingOf::disablePersistentScripts() { +void MakingOf::disablePersistentScripts() {  } -void MystScriptParser_MakingOf::runPersistentScripts() { +void MakingOf::runPersistentScripts() {  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/makingof.h b/engines/mohawk/myst_stacks/makingof.h index ab919fd174..3033bb851e 100644 --- a/engines/mohawk/myst_stacks/makingof.h +++ b/engines/mohawk/myst_stacks/makingof.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_MakingOf(MohawkEngine_Myst *vm); -	~MystScriptParser_MakingOf(); +	MakingOf(MohawkEngine_Myst *vm); +	~MakingOf();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -49,6 +50,7 @@ private:  	void setupOpcodes();  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index add87694a8..0ae9078974 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -34,8 +34,9 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm) : +Mechanical::Mechanical(MohawkEngine_Myst *vm) :  		MystScriptParser(vm), _state(vm->_gameState->_mechanical) {  	setupOpcodes(); @@ -43,14 +44,15 @@ MystScriptParser_Mechanical::MystScriptParser_Mechanical(MohawkEngine_Myst *vm)  	_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 -	OPCODE(104, opcode_104); +	OPCODE(100, o_throneEnablePassage); +	OPCODE(104, o_snakeBoxTrigger);  	OPCODE(105, o_fortressStaircaseMovie);  	OPCODE(121, opcode_121);  	OPCODE(122, opcode_122); @@ -66,10 +68,10 @@ void MystScriptParser_Mechanical::setupOpcodes() {  	OPCODE(132, o_crystalLeaveRed);  	// "Init" Opcodes -	OPCODE(200, opcode_200); -	OPCODE(201, opcode_201); +	OPCODE(200, o_throne_init); +	OPCODE(201, o_fortressStaircase_init);  	OPCODE(202, opcode_202); -	OPCODE(203, opcode_203); +	OPCODE(203, o_snakeBox_init);  	OPCODE(204, opcode_204);  	OPCODE(205, opcode_205);  	OPCODE(206, opcode_206); @@ -81,29 +83,23 @@ void MystScriptParser_Mechanical::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Mechanical::disablePersistentScripts() { -	opcode_200_disable(); -	opcode_201_disable(); +void Mechanical::disablePersistentScripts() {  	opcode_202_disable(); -	opcode_203_disable();  	opcode_204_disable();  	opcode_205_disable();  	opcode_206_disable();  	opcode_209_disable();  } -void MystScriptParser_Mechanical::runPersistentScripts() { -	opcode_200_run(); -	opcode_201_run(); +void Mechanical::runPersistentScripts() {  	opcode_202_run(); -	opcode_203_run();  	opcode_204_run();  	opcode_205_run();  	opcode_206_run();  	opcode_209_run();  } -uint16 MystScriptParser_Mechanical::getVar(uint16 var) { +uint16 Mechanical::getVar(uint16 var) {  	switch(var) {  	case 0: // Sirrus's Secret Panel State  		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) { +	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  		_state.achenarCrateOpened ^= 1;  	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;  	switch (var) { @@ -218,20 +218,20 @@ bool MystScriptParser_Mechanical::setVarValue(uint16 var, uint16 value) {  	return refresh;  } -void MystScriptParser_Mechanical::opcode_104(uint16 op, uint16 var, uint16 argc, uint16 *argv) { -	varUnusedCheck(op, var); +void Mechanical::o_throneEnablePassage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +	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); +	_vm->_resources[argv[0]]->setEnabled(getVar(var)); +} -		// TODO: Trigger Type 6 To Play Snake Movie.. Resource #3 on card. -	} else -		unknown(op, var, argc, 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 MystScriptParser_Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Play Stairs Movement Movie", op);  	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);  	if (argc == 2) { @@ -261,7 +261,7 @@ void MystScriptParser_Mechanical::opcode_121(uint16 op, uint16 var, uint16 argc,  		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) {  		// Used on Card 6120 (Elevator)  		// 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);  } -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);  	if (argc == 2) { @@ -288,7 +288,7 @@ void MystScriptParser_Mechanical::opcode_123(uint16 op, uint16 var, uint16 argc,  		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);  	if (argc == 0) { @@ -300,13 +300,13 @@ void MystScriptParser_Mechanical::opcode_124(uint16 op, uint16 var, uint16 argc,  		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);  	_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);  	if (argc == 0) { @@ -319,129 +319,77 @@ void MystScriptParser_Mechanical::opcode_126(uint16 op, uint16 var, uint16 argc,  		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);  	_crystalLit = 3;  	_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);  	_crystalLit = 1;  	_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);  	_crystalLit = 2;  	_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);  	_crystalLit = 0;  	_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);  	_crystalLit = 0;  	_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);  	_crystalLit = 0;  	_vm->redrawArea(22);  } -static struct { -	bool enabled; -	uint16 var; -} g_opcode200Parameters; - -void MystScriptParser_Mechanical::opcode_200_run() { +void Mechanical::o_throne_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne) -	// g_opcode200Parameters.var == 0 for Achenar -	// g_opcode200Parameters.var == 1 for Sirrus - -	// TODO: Fill in Function... -	// Variable indicates that this is related to Secret Panel State -} - -void MystScriptParser_Mechanical::opcode_200_disable() { -	g_opcode200Parameters.enabled = false; -	g_opcode200Parameters.var = 0; -} - -void MystScriptParser_Mechanical::opcode_200(uint16 op, uint16 var, uint16 argc, uint16 *argv) { -	// Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne) -	if (argc == 0) { -		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... -} +	debugC(kDebugScript, "Opcode %d: Brother throne init", op); -void MystScriptParser_Mechanical::opcode_201_disable() { -	g_opcode201Parameters.enabled = false; -	g_opcode201Parameters.u0 = 0; -	g_opcode201Parameters.u1 = 0; -	g_opcode201Parameters.u2 = 0; +	_invokingResource->setEnabled(getVar(var));  } -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]; +void Mechanical::o_fortressStaircase_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +	debugC(kDebugScript, "Opcode %d: Staircase init", op); -		g_opcode201Parameters.enabled = true; -	} else -		unknown(op, var, argc, argv); +	_vm->_resources[argv[0]]->setEnabled(!_state.staircaseState); +	_vm->_resources[argv[1]]->setEnabled(!_state.staircaseState); +	_vm->_resources[argv[2]]->setEnabled(_state.staircaseState);  }  static struct {  	bool enabled;  } g_opcode202Parameters; -void MystScriptParser_Mechanical::opcode_202_run() { +void Mechanical::opcode_202_run() {  	// Used for Card 6220 (Sirrus' Mechanical Bird)  	// TODO: Fill in Function  } -void MystScriptParser_Mechanical::opcode_202_disable() { +void Mechanical::opcode_202_disable() {  	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)  	if (argc == 0)  		g_opcode202Parameters.enabled = true; @@ -449,29 +397,10 @@ void MystScriptParser_Mechanical::opcode_202(uint16 op, uint16 var, uint16 argc,  		unknown(op, var, argc, argv);  } -static struct { -	bool enabled; -} g_opcode203Parameters; - -void MystScriptParser_Mechanical::opcode_203_run() { -	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 Mechanical::o_snakeBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +	debugC(kDebugScript, "Opcode %d: Snake box init", op); -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); +	_snakeBox = static_cast<MystResourceType6 *>(_invokingResource);  }  static struct { @@ -479,7 +408,7 @@ static struct {  	uint16 soundId;  } g_opcode204Parameters; -void MystScriptParser_Mechanical::opcode_204_run() { +void Mechanical::opcode_204_run() {  	if (g_opcode204Parameters.enabled) {  		// TODO: Fill in Logic.  		// 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;  } -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);  	// Used for Card 6180 (Lower Elevator Puzzle) @@ -512,17 +441,17 @@ static struct {  	bool enabled;  } g_opcode205Parameters; -void MystScriptParser_Mechanical::opcode_205_run() { +void Mechanical::opcode_205_run() {  	// Used for Card 6156 (Fortress Rotation Controls)  	// TODO: Fill in function...  	// g_opcode205Parameters.soundIdPosition[4]  } -void MystScriptParser_Mechanical::opcode_205_disable() { +void Mechanical::opcode_205_disable() {  	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);  	// Used for Card 6156 (Fortress Rotation Controls) @@ -545,7 +474,7 @@ static struct {  	bool enabled;  } g_opcode206Parameters; -void MystScriptParser_Mechanical::opcode_206_run() { +void Mechanical::opcode_206_run() {  	if (g_opcode206Parameters.enabled) {  		// 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;  } -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);  	// Used for Card 6044 (Fortress Rotation Simulator) @@ -582,18 +511,18 @@ static struct {  	bool enabled;  } g_opcode209Parameters; -void MystScriptParser_Mechanical::opcode_209_run() { +void Mechanical::opcode_209_run() {  	// Used for Card 6044 (Fortress Rotation Simulator)  	// TODO: Implement Function For Secret Panel State as  	//       per Opcode 200 function (Mechanical)  } -void MystScriptParser_Mechanical::opcode_209_disable() { +void Mechanical::opcode_209_disable() {  	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);  	// 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);  } -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)  	varUnusedCheck(op, var);  	// TODO: Fill in Logic. Clearing Variable for View?  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h index 3c7701c12d..7142425eb4 100644 --- a/engines/mohawk/myst_stacks/mechanical.h +++ b/engines/mohawk/myst_stacks/mechanical.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Mechanical(MohawkEngine_Myst *vm); -	~MystScriptParser_Mechanical(); +	Mechanical(MohawkEngine_Myst *vm); +	~Mechanical();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -51,14 +52,8 @@ private:  	void toggleVar(uint16 var);  	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_disable(); -	void opcode_203_run(); -	void opcode_203_disable();  	void opcode_204_run();  	void opcode_204_disable();  	void opcode_205_run(); @@ -68,7 +63,8 @@ private:  	void opcode_209_run();  	void opcode_209_disable(); -	DECLARE_OPCODE(opcode_104); +	DECLARE_OPCODE(o_throneEnablePassage); +	DECLARE_OPCODE(o_snakeBoxTrigger);  	DECLARE_OPCODE(o_fortressStaircaseMovie);  	DECLARE_OPCODE(opcode_121);  	DECLARE_OPCODE(opcode_122); @@ -83,10 +79,10 @@ private:  	DECLARE_OPCODE(o_crystalLeaveGreen);  	DECLARE_OPCODE(o_crystalLeaveRed); -	DECLARE_OPCODE(opcode_200); -	DECLARE_OPCODE(opcode_201); +	DECLARE_OPCODE(o_throne_init); +	DECLARE_OPCODE(o_fortressStaircase_init);  	DECLARE_OPCODE(opcode_202); -	DECLARE_OPCODE(opcode_203); +	DECLARE_OPCODE(o_snakeBox_init);  	DECLARE_OPCODE(opcode_204);  	DECLARE_OPCODE(opcode_205);  	DECLARE_OPCODE(opcode_206); @@ -101,8 +97,11 @@ private:  	uint16 _fortressPosition; // 82  	uint16 _crystalLit; // 130 + +	MystResourceType6 *_snakeBox; // 156  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index 3bcc83527b..5f05a8dded 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -37,10 +37,9 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -// NOTE: Credits Start Card is 10000 - -MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : +Myst::Myst(MohawkEngine_Myst *vm) :  		MystScriptParser(vm), _state(_vm->_gameState->_myst) {  	setupOpcodes(); @@ -62,12 +61,12 @@ MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) :  	_state.treeLastMoveTime = _vm->_system->getMillis();  } -MystScriptParser_Myst::~MystScriptParser_Myst() { +Myst::~Myst() {  } -#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &MystScriptParser_Myst::x, #x)) +#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Myst::x, #x)) -void MystScriptParser_Myst::setupOpcodes() { +void Myst::setupOpcodes() {  	// "Stack-Specific" Opcodes  	OPCODE(100, NOP);  	OPCODE(101, o_libraryBookPageTurnLeft); @@ -211,7 +210,7 @@ void MystScriptParser_Myst::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Myst::disablePersistentScripts() { +void Myst::disablePersistentScripts() {  	_libraryBookcaseMoving = false;  	_generatorControlRoomRunning = false;  	_libraryCombinationBookPagesTurning = false; @@ -235,7 +234,7 @@ void MystScriptParser_Myst::disablePersistentScripts() {  	_gullsFlying3 = false;  } -void MystScriptParser_Myst::runPersistentScripts() { +void Myst::runPersistentScripts() {  	if (_towerRotationMapRunning)  		towerRotationMap_run(); @@ -306,7 +305,7 @@ void MystScriptParser_Myst::runPersistentScripts() {  		gullsFly3_run();  } -uint16 MystScriptParser_Myst::getVar(uint16 var) { +uint16 Myst::getVar(uint16 var) {  	switch(var) {  	case 0: // Myst Library Bookcase Closed  		return _state.libraryBookcaseDoor; @@ -630,7 +629,7 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {  	}  } -void MystScriptParser_Myst::toggleVar(uint16 var) { +void Myst::toggleVar(uint16 var) {  	switch(var) {  	case 2: // Marker Switch Near Cabin  		_state.cabinMarkerSwitch = (_state.cabinMarkerSwitch + 1) % 2; @@ -720,7 +719,7 @@ void MystScriptParser_Myst::toggleVar(uint16 var) {  	}  } -bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) { +bool Myst::setVarValue(uint16 var, uint16 value) {  	bool refresh = false;  	switch (var) { @@ -775,7 +774,7 @@ bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) {  	return refresh;  } -uint16 MystScriptParser_Myst::bookCountPages(uint16 var) { +uint16 Myst::bookCountPages(uint16 var) {  	uint16 pages = 0;  	uint16 cnt = 0; @@ -808,7 +807,7 @@ uint16 MystScriptParser_Myst::bookCountPages(uint16 var) {  	return cnt;  } -void MystScriptParser_Myst::o_libraryBookPageTurnLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryBookPageTurnLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Turn book page left", op);  	if (_libraryBookPage - 1 >= 0) { @@ -826,7 +825,7 @@ void MystScriptParser_Myst::o_libraryBookPageTurnLeft(uint16 op, uint16 var, uin  	}  } -void MystScriptParser_Myst::o_libraryBookPageTurnRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryBookPageTurnRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Turn book page right", op);  	if (_libraryBookPage + 1 < _libraryBookNumPages) { @@ -844,7 +843,7 @@ void MystScriptParser_Myst::o_libraryBookPageTurnRight(uint16 op, uint16 var, ui  	}  } -void MystScriptParser_Myst::o_fireplaceToggleButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_fireplaceToggleButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Myst Card 4162 (Fireplace Grid)  	debugC(kDebugScript, "Opcode %d: Fireplace grid toggle button", op); @@ -873,7 +872,7 @@ void MystScriptParser_Myst::o_fireplaceToggleButton(uint16 op, uint16 var, uint1  	}  } -void MystScriptParser_Myst::o_fireplaceRotation(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_fireplaceRotation(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Myst Card 4162 and 4166 (Fireplace Puzzle Rotation Movies)  	uint16 movieNum = argv[0];  	debugC(kDebugScript, "Opcode %d: Play Fireplace Puzzle Rotation Movies", op); @@ -885,7 +884,7 @@ void MystScriptParser_Myst::o_fireplaceRotation(uint16 op, uint16 var, uint16 ar  		_vm->_video->playMovieBlocking(_vm->wrapMovieFilename("fpin", kMystStack), 167, 4);  } -void MystScriptParser_Myst::o_courtyardBoxesCheckSolution(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_courtyardBoxesCheckSolution(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	uint16 soundId = argv[0];  	debugC(kDebugScript, "Opcode %d: Ship Puzzle Logic", op); @@ -905,7 +904,7 @@ void MystScriptParser_Myst::o_courtyardBoxesCheckSolution(uint16 op, uint16 var,  	}  } -void MystScriptParser_Myst::o_towerRotationStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_towerRotationStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	_towerRotationBlinkLabel = false;  	_towerRotationMapClicked = true;  	_towerRotationSpeed = 0; @@ -920,7 +919,7 @@ void MystScriptParser_Myst::o_towerRotationStart(uint16 op, uint16 var, uint16 a  	_vm->_sound->replaceSoundMyst(5378, Audio::Mixer::kMaxChannelVolume, true);  } -void MystScriptParser_Myst::o_towerRotationEnd(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_towerRotationEnd(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	_towerRotationMapClicked = false;  	// Set angle value to expected value @@ -948,7 +947,7 @@ void MystScriptParser_Myst::o_towerRotationEnd(uint16 op, uint16 var, uint16 arg  	_towerRotationBlinkLabelCount = 0;  } -void MystScriptParser_Myst::o_imagerChangeSelection(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_imagerChangeSelection(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Dock imager change selection", op);  	if (_imagerValidationStep != 10) { @@ -974,7 +973,7 @@ void MystScriptParser_Myst::o_imagerChangeSelection(uint16 op, uint16 var, uint1  	}  } -void MystScriptParser_Myst::o_dockVaultOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_dockVaultOpen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Myst 4143 (Dock near Marker Switch)  	uint16 soundId = argv[0];  	uint16 delay = argv[1]; @@ -1003,7 +1002,7 @@ void MystScriptParser_Myst::o_dockVaultOpen(uint16 op, uint16 var, uint16 argc,  	}  } -void MystScriptParser_Myst::o_dockVaultClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_dockVaultClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Myst 4143 (Dock near Marker Switch)  	uint16 soundId = argv[0];  	uint16 delay = argv[1]; @@ -1030,7 +1029,7 @@ void MystScriptParser_Myst::o_dockVaultClose(uint16 op, uint16 var, uint16 argc,  	}  } -void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	uint16 cardIdLose = argv[0];  	uint16 cardIdBookCover = argv[1];  	uint16 soundIdAddPage = argv[2]; @@ -1117,7 +1116,7 @@ void MystScriptParser_Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, u  	}  } -void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Card 4006 (Clock Tower Time Controls)  	uint16 soundId = argv[0]; @@ -1153,7 +1152,7 @@ void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 a  	}  } -void MystScriptParser_Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Imager play button", op);  	uint16 video = getVar(51); @@ -1232,7 +1231,7 @@ void MystScriptParser_Myst::o_imagerPlayButton(uint16 op, uint16 var, uint16 arg  	_vm->_cursor->showCursor();  } -void MystScriptParser_Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Imager erase button", op);  	_imagerRedButton = static_cast<MystResourceType8 *>(_invokingResource->_parent); @@ -1279,7 +1278,7 @@ void MystScriptParser_Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 ar  	}  } -void MystScriptParser_Myst::imagerValidation_run() { +void Myst::imagerValidation_run() {  	uint32 time = _vm->_system->getMillis();  	if (time > _startTime) { @@ -1307,7 +1306,7 @@ void MystScriptParser_Myst::imagerValidation_run() {  	}  } -void MystScriptParser_Myst::o_towerElevatorAnimation(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_towerElevatorAnimation(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Tower elevator animation", op);  	_treeStopped = true; @@ -1332,7 +1331,7 @@ void MystScriptParser_Myst::o_towerElevatorAnimation(uint16 op, uint16 var, uint  	_treeStopped = false;  } -void MystScriptParser_Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Generator button pressed", op);  	MystResource *button = _invokingResource->_parent; @@ -1374,13 +1373,13 @@ void MystScriptParser_Myst::o_generatorButtonPressed(uint16 op, uint16 var, uint  		_state.generatorBreakers = _vm->_rnd->getRandomNumberRng(1, 2);  } -void MystScriptParser_Myst::generatorRedrawRocket() { +void Myst::generatorRedrawRocket() {  	_vm->redrawArea(64);  	_vm->redrawArea(65);  	_vm->redrawArea(97);  } -void MystScriptParser_Myst::generatorButtonValue(MystResource *button, uint16 &mask, uint16 &value) { +void Myst::generatorButtonValue(MystResource *button, uint16 &mask, uint16 &value) {  	switch (button->getType8Var()) {  	case 52: // Generator Switch #1  		mask = 1; @@ -1425,7 +1424,7 @@ void MystScriptParser_Myst::generatorButtonValue(MystResource *button, uint16 &m  	}  } -void MystScriptParser_Myst::o_cabinSafeChangeDigit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_cabinSafeChangeDigit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Cabin safe change digit", op);  	uint16 d1 = _state.cabinSafeCombination / 100; @@ -1444,7 +1443,7 @@ void MystScriptParser_Myst::o_cabinSafeChangeDigit(uint16 op, uint16 var, uint16  	_vm->redrawArea(var);  } -void MystScriptParser_Myst::o_cabinSafeHandleStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_cabinSafeHandleStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Cabin safe handle start move", op);  	// Used on Card 4100 @@ -1454,7 +1453,7 @@ void MystScriptParser_Myst::o_cabinSafeHandleStartMove(uint16 op, uint16 var, ui  	_tempVar = 0;  } -void MystScriptParser_Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Cabin safe handle move", op);  	// Used on Card 4100 @@ -1484,7 +1483,7 @@ void MystScriptParser_Myst::o_cabinSafeHandleMove(uint16 op, uint16 var, uint16  	}  } -void MystScriptParser_Myst::o_cabinSafeHandleEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_cabinSafeHandleEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Cabin safe handle end move", op);  	// Used on Card 4100 @@ -1493,7 +1492,7 @@ void MystScriptParser_Myst::o_cabinSafeHandleEndMove(uint16 op, uint16 var, uint  	_vm->checkCursorHints();  } -void MystScriptParser_Myst::o_observatoryMonthChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryMonthChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Observatory month change start", op);  	_vm->_sound->pauseBackgroundMyst(); @@ -1528,7 +1527,7 @@ void MystScriptParser_Myst::o_observatoryMonthChangeStart(uint16 op, uint16 var,  	_observatoryMonthChanging = true;  } -void MystScriptParser_Myst::observatoryIncrementMonth(int16 increment) { +void Myst::observatoryIncrementMonth(int16 increment) {  	int16 newMonth = _state.observatoryMonthSetting + increment;  	if (newMonth >= 0 && newMonth <= 11) { @@ -1547,12 +1546,12 @@ void MystScriptParser_Myst::observatoryIncrementMonth(int16 increment) {  	_vm->_sound->replaceSoundMyst(8500);  } -void MystScriptParser_Myst::observatoryMonthChange_run() { +void Myst::observatoryMonthChange_run() {  	if (_startTime + 500 < _vm->_system->getMillis())  		observatoryIncrementMonth(_observatoryIncrement);  } -void MystScriptParser_Myst::o_observatoryDayChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryDayChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Observatory day change start", op);  	_vm->_sound->pauseBackgroundMyst(); @@ -1587,7 +1586,7 @@ void MystScriptParser_Myst::o_observatoryDayChangeStart(uint16 op, uint16 var, u  	_observatoryDayChanging = true;  } -void MystScriptParser_Myst::observatoryIncrementDay(int16 increment) { +void Myst::observatoryIncrementDay(int16 increment) {  	int16 newDay = _state.observatoryDaySetting + increment;  	if (newDay >= 1 && newDay <= 31) { @@ -1607,12 +1606,12 @@ void MystScriptParser_Myst::observatoryIncrementDay(int16 increment) {  	_vm->_sound->replaceSoundMyst(8500);  } -void MystScriptParser_Myst::observatoryDayChange_run() { +void Myst::observatoryDayChange_run() {  	if (_startTime + 500 < _vm->_system->getMillis())  		observatoryIncrementDay(_observatoryIncrement);  } -void MystScriptParser_Myst::o_observatoryYearChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryYearChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Observatory year change start", op);  	_vm->_sound->pauseBackgroundMyst(); @@ -1639,7 +1638,7 @@ void MystScriptParser_Myst::o_observatoryYearChangeStart(uint16 op, uint16 var,  	_observatoryYearChanging = true;  } -void MystScriptParser_Myst::observatoryIncrementYear(int16 increment) { +void Myst::observatoryIncrementYear(int16 increment) {  	int16 newYear = _state.observatoryYearSetting + increment;  	if (newYear >= 0 && newYear <= 9999) { @@ -1661,12 +1660,12 @@ void MystScriptParser_Myst::observatoryIncrementYear(int16 increment) {  	_vm->_sound->replaceSoundMyst(8500);  } -void MystScriptParser_Myst::observatoryYearChange_run() { +void Myst::observatoryYearChange_run() {  	if (_startTime + 500 < _vm->_system->getMillis())  		observatoryIncrementYear(_observatoryIncrement);  } -void MystScriptParser_Myst::o_observatoryTimeChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryTimeChangeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Observatory time change start", op);  	_vm->_sound->pauseBackgroundMyst(); @@ -1693,7 +1692,7 @@ void MystScriptParser_Myst::o_observatoryTimeChangeStart(uint16 op, uint16 var,  	_observatoryTimeChanging = true;  } -void MystScriptParser_Myst::observatoryIncrementTime(int16 increment) { +void Myst::observatoryIncrementTime(int16 increment) {  	int16 newTime = _state.observatoryTimeSetting + increment;  	if (newTime >= 0 && newTime <= 1439) { @@ -1720,12 +1719,12 @@ void MystScriptParser_Myst::observatoryIncrementTime(int16 increment) {  	_vm->_sound->replaceSoundMyst(8500);  } -void MystScriptParser_Myst::observatoryTimeChange_run() { +void Myst::observatoryTimeChange_run() {  	if (_startTime + 500 < _vm->_system->getMillis())  		observatoryIncrementTime(_observatoryIncrement);  } -void MystScriptParser_Myst::o_observatoryGoButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryGoButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Observatory go button", op);  	// Setting not at target @@ -1759,31 +1758,31 @@ void MystScriptParser_Myst::o_observatoryGoButton(uint16 op, uint16 var, uint16  	}  } -void MystScriptParser_Myst::o_observatoryMonthSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryMonthSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Month slider move", op);  	observatoryUpdateMonth();  } -void MystScriptParser_Myst::o_observatoryDaySliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryDaySliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Day slider move", op);  	observatoryUpdateDay();  } -void MystScriptParser_Myst::o_observatoryYearSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryYearSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Year slider move", op);  	observatoryUpdateYear();  } -void MystScriptParser_Myst::o_observatoryTimeSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryTimeSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Time slider move", op);  	observatoryUpdateTime();  } -void MystScriptParser_Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Circuit breaker start move", op);  	MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource); @@ -1792,7 +1791,7 @@ void MystScriptParser_Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uin  	_tempVar = 0;  } -void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Circuit breaker move", op);  	MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource); @@ -1843,7 +1842,7 @@ void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 a  	}  } -void MystScriptParser_Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Circuit breaker end move", op);  	MystResourceType12 *breaker = static_cast<MystResourceType12 *>(_invokingResource); @@ -1851,7 +1850,7 @@ void MystScriptParser_Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint1  	_vm->checkCursorHints();  } -void MystScriptParser_Myst::o_boilerIncreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_boilerIncreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Boiler increase pressure start", op);  	_treeStopped = true; @@ -1861,7 +1860,7 @@ void MystScriptParser_Myst::o_boilerIncreasePressureStart(uint16 op, uint16 var,  	_boilerPressureIncreasing = true;  } -void MystScriptParser_Myst::o_boilerLightPilot(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_boilerLightPilot(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Boiler light pilot", op);  	// Match is lit @@ -1882,7 +1881,7 @@ void MystScriptParser_Myst::o_boilerLightPilot(uint16 op, uint16 var, uint16 arg  	}  } -void MystScriptParser_Myst::o_boilerIncreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_boilerIncreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Boiler increase pressure stop", op);  	_treeStopped = false; @@ -1898,7 +1897,7 @@ void MystScriptParser_Myst::o_boilerIncreasePressureStop(uint16 op, uint16 var,  		_vm->_sound->replaceBackgroundMyst(4098, _state.cabinValvePosition << 10);  } -void MystScriptParser_Myst::boilerPressureIncrease_run() { +void Myst::boilerPressureIncrease_run() {  	// Allow increasing pressure if sound has stopped  	if (!_vm->_sound->isPlaying(5098) && _state.cabinValvePosition < 25) {  		_state.cabinValvePosition++; @@ -1922,7 +1921,7 @@ void MystScriptParser_Myst::boilerPressureIncrease_run() {  	}  } -void MystScriptParser_Myst::boilerPressureDecrease_run() { +void Myst::boilerPressureDecrease_run() {  	// Allow decreasing pressure if sound has stopped  	if (!_vm->_sound->isPlaying(5098) && _state.cabinValvePosition > 0) {  		_state.cabinValvePosition--; @@ -1941,7 +1940,7 @@ void MystScriptParser_Myst::boilerPressureDecrease_run() {  	}  } -void MystScriptParser_Myst::o_boilerDecreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_boilerDecreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Boiler decrease pressure start", op);  	_treeStopped = true; @@ -1950,7 +1949,7 @@ void MystScriptParser_Myst::o_boilerDecreasePressureStart(uint16 op, uint16 var,  	_boilerPressureDecreasing = true;  } -void MystScriptParser_Myst::o_boilerDecreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_boilerDecreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Boiler decrease pressure stop", op);  	_treeStopped = false; @@ -1968,14 +1967,14 @@ void MystScriptParser_Myst::o_boilerDecreasePressureStop(uint16 op, uint16 var,  	}  } -void MystScriptParser_Myst::o_basementIncreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_basementIncreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Basement increase pressure start", op);  	_treeStopped = true;  	_basementPressureIncreasing = true;  } -void MystScriptParser_Myst::o_basementIncreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_basementIncreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Basement increase pressure stop", op);  	_treeStopped = false; @@ -1983,7 +1982,7 @@ void MystScriptParser_Myst::o_basementIncreasePressureStop(uint16 op, uint16 var  	_state.treeLastMoveTime = _vm->_system->getMillis();  } -void MystScriptParser_Myst::basementPressureIncrease_run() { +void Myst::basementPressureIncrease_run() {  	// Allow increasing pressure if sound has stopped  	if (!_vm->_sound->isPlaying(4642) && _state.cabinValvePosition < 25) {  		_state.cabinValvePosition++; @@ -1996,7 +1995,7 @@ void MystScriptParser_Myst::basementPressureIncrease_run() {  	}  } -void MystScriptParser_Myst::basementPressureDecrease_run() { +void Myst::basementPressureDecrease_run() {  	// Allow decreasing pressure if sound has stopped  	if (!_vm->_sound->isPlaying(4642) && _state.cabinValvePosition > 0) {  		_state.cabinValvePosition--; @@ -2009,14 +2008,14 @@ void MystScriptParser_Myst::basementPressureDecrease_run() {  	}  } -void MystScriptParser_Myst::o_basementDecreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_basementDecreasePressureStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Basement decrease pressure start", op);  	_treeStopped = true;  	_basementPressureDecreasing = true;  } -void MystScriptParser_Myst::o_basementDecreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_basementDecreasePressureStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Basement decrease pressure stop", op);  	_treeStopped = false; @@ -2024,7 +2023,7 @@ void MystScriptParser_Myst::o_basementDecreasePressureStop(uint16 op, uint16 var  	_state.treeLastMoveTime = _vm->_system->getMillis();  } -void MystScriptParser_Myst::tree_run() { +void Myst::tree_run() {  	uint16 pressure;  	if (_state.cabinPilotLightLit)  		pressure = _state.cabinValvePosition; @@ -2073,7 +2072,7 @@ void MystScriptParser_Myst::tree_run() {  	}  } -void MystScriptParser_Myst::treeSetAlcoveAccessible() { +void Myst::treeSetAlcoveAccessible() {  	if (_treeAlcove) {  		// Make alcove accessible if the tree is in the correct position  		_treeAlcove->setEnabled(_state.treePosition >= _treeMinAccessiblePosition @@ -2081,14 +2080,14 @@ void MystScriptParser_Myst::treeSetAlcoveAccessible() {  	}  } -uint32 MystScriptParser_Myst::treeNextMoveDelay(uint16 pressure) { +uint32 Myst::treeNextMoveDelay(uint16 pressure) {  	if (pressure >= 12)  		return 25000 * (13 - (pressure - 12)) / 12 + 3000;  	else  		return 25000 * pressure / 13 + 3000;  } -void MystScriptParser_Myst::o_rocketSoundSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketSoundSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket slider start move", op);  	_rocketSliderSound = 0; @@ -2097,13 +2096,13 @@ void MystScriptParser_Myst::o_rocketSoundSliderStartMove(uint16 op, uint16 var,  	rocketSliderMove();  } -void MystScriptParser_Myst::o_rocketSoundSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketSoundSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket slider move", op);  	rocketSliderMove();  } -void MystScriptParser_Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket slider end move", op);  	_vm->checkCursorHints(); @@ -2125,7 +2124,7 @@ void MystScriptParser_Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, ui  	_vm->_sound->resumeBackgroundMyst();  } -void MystScriptParser_Myst::rocketSliderMove() { +void Myst::rocketSliderMove() {  	MystResourceType10 *slider = static_cast<MystResourceType10 *>(_invokingResource);  	if (_state.generatorVoltage == 59 && !_state.generatorBreakers) { @@ -2137,11 +2136,11 @@ void MystScriptParser_Myst::rocketSliderMove() {  	}  } -uint16 MystScriptParser_Myst::rocketSliderGetSound(uint16 pos) { +uint16 Myst::rocketSliderGetSound(uint16 pos) {  	return (uint16)(9530 + (pos - 216) * 35.0 * 0.01639344262295082);  } -void MystScriptParser_Myst::rocketCheckSolution() { +void Myst::rocketCheckSolution() {  	_vm->_cursor->hideCursor();  	uint16 soundId; @@ -2211,7 +2210,7 @@ void MystScriptParser_Myst::rocketCheckSolution() {  	_vm->_cursor->showCursor();  } -void MystScriptParser_Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket piano start move", op);  	MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource); @@ -2234,7 +2233,7 @@ void MystScriptParser_Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 arg  	}  } -void MystScriptParser_Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket piano move", op);  	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); @@ -2280,7 +2279,7 @@ void MystScriptParser_Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc  	_vm->_system->updateScreen();  } -void MystScriptParser_Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket piano end move", op);  	MystResourceType8 *key = static_cast<MystResourceType8 *>(_invokingResource); @@ -2298,7 +2297,7 @@ void MystScriptParser_Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc  	_vm->_sound->resumeBackgroundMyst();  } -void MystScriptParser_Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket lever start move", op);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -2308,7 +2307,7 @@ void MystScriptParser_Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16  	lever->drawFrame(0);  } -void MystScriptParser_Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket open link book", op);  	// Flyby movie @@ -2318,7 +2317,7 @@ void MystScriptParser_Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc,  	_tempVar = 2;  } -void MystScriptParser_Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket lever move", op);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -2347,7 +2346,7 @@ void MystScriptParser_Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc  	_rocketLeverPosition = step;  } -void MystScriptParser_Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket lever end move", op);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -2357,7 +2356,7 @@ void MystScriptParser_Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 a  	lever->drawFrame(0);  } -void MystScriptParser_Myst::o_cabinLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_cabinLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Leave cabin", op);  	// If match is lit, put out @@ -2369,7 +2368,7 @@ void MystScriptParser_Myst::o_cabinLeave(uint16 op, uint16 var, uint16 argc, uin  	}  } -void MystScriptParser_Myst::o_treePressureReleaseStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_treePressureReleaseStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Tree pressure release start", op);  	Common::Rect src = Common::Rect(0, 0, 49, 86); @@ -2386,7 +2385,7 @@ void MystScriptParser_Myst::o_treePressureReleaseStart(uint16 op, uint16 var, ui  	}  } -void MystScriptParser_Myst::o_treePressureReleaseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_treePressureReleaseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Tree pressure release stop", op);  	Common::Rect rect = Common::Rect(78, 46, 127, 132); @@ -2397,7 +2396,7 @@ void MystScriptParser_Myst::o_treePressureReleaseStop(uint16 op, uint16 var, uin  	_treeMinPosition = 0;  } -void MystScriptParser_Myst::o_observatoryMonthSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryMonthSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Month slider start move", op);  	_vm->_cursor->setCursor(700); @@ -2406,7 +2405,7 @@ void MystScriptParser_Myst::o_observatoryMonthSliderStartMove(uint16 op, uint16  	observatoryUpdateMonth();  } -void MystScriptParser_Myst::o_observatoryMonthSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryMonthSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Month slider end move", op);  	_vm->checkCursorHints(); @@ -2415,7 +2414,7 @@ void MystScriptParser_Myst::o_observatoryMonthSliderEndMove(uint16 op, uint16 va  	observatoryUpdateMonth();  } -void MystScriptParser_Myst::observatoryUpdateMonth() { +void Myst::observatoryUpdateMonth() {  	int16 month = (_observatoryMonthSlider->_pos.y - 94) / 8;  	if (month != _state.observatoryMonthSetting) { @@ -2428,7 +2427,7 @@ void MystScriptParser_Myst::observatoryUpdateMonth() {  	}  } -void MystScriptParser_Myst::o_observatoryDaySliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryDaySliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Day slider start move", op);  	_vm->_cursor->setCursor(700); @@ -2437,7 +2436,7 @@ void MystScriptParser_Myst::o_observatoryDaySliderStartMove(uint16 op, uint16 va  	observatoryUpdateDay();  } -void MystScriptParser_Myst::o_observatoryDaySliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryDaySliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Day slider end move", op);  	_vm->checkCursorHints(); @@ -2446,7 +2445,7 @@ void MystScriptParser_Myst::o_observatoryDaySliderEndMove(uint16 op, uint16 var,  	observatoryUpdateDay();  } -void MystScriptParser_Myst::observatoryUpdateDay() { +void Myst::observatoryUpdateDay() {  	int16 day = (_observatoryDaySlider->_pos.y - 94) * 30 / 94 + 1;  	if (day != _state.observatoryDaySetting) { @@ -2460,7 +2459,7 @@ void MystScriptParser_Myst::observatoryUpdateDay() {  	}  } -void MystScriptParser_Myst::o_observatoryYearSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryYearSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Year slider start move", op);  	_vm->_cursor->setCursor(700); @@ -2469,7 +2468,7 @@ void MystScriptParser_Myst::o_observatoryYearSliderStartMove(uint16 op, uint16 v  	observatoryUpdateYear();  } -void MystScriptParser_Myst::o_observatoryYearSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryYearSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Year slider end move", op);  	_vm->checkCursorHints(); @@ -2478,7 +2477,7 @@ void MystScriptParser_Myst::o_observatoryYearSliderEndMove(uint16 op, uint16 var  	observatoryUpdateYear();  } -void MystScriptParser_Myst::observatoryUpdateYear() { +void Myst::observatoryUpdateYear() {  	int16 year = (_observatoryYearSlider->_pos.y - 94) * 9999 / 94;  	if (year != _state.observatoryYearSetting) { @@ -2494,7 +2493,7 @@ void MystScriptParser_Myst::observatoryUpdateYear() {  	}  } -void MystScriptParser_Myst::o_observatoryTimeSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryTimeSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Time slider start move", op);  	_vm->_cursor->setCursor(700); @@ -2503,7 +2502,7 @@ void MystScriptParser_Myst::o_observatoryTimeSliderStartMove(uint16 op, uint16 v  	observatoryUpdateTime();  } -void MystScriptParser_Myst::o_observatoryTimeSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryTimeSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Time slider end move", op);  	_vm->checkCursorHints(); @@ -2512,7 +2511,7 @@ void MystScriptParser_Myst::o_observatoryTimeSliderEndMove(uint16 op, uint16 var  	observatoryUpdateTime();  } -void MystScriptParser_Myst::observatoryUpdateTime() { +void Myst::observatoryUpdateTime() {  	int16 time = (_observatoryTimeSlider->_pos.y - 94) * 1439 / 94;  	if (time != _state.observatoryTimeSetting) { @@ -2532,12 +2531,12 @@ void MystScriptParser_Myst::observatoryUpdateTime() {  	}  } -void MystScriptParser_Myst::o_libraryCombinationBookStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryCombinationBookStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Combination book stop turning pages", op);  	_libraryCombinationBookPagesTurning = false;  } -void MystScriptParser_Myst::o_cabinMatchLight(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_cabinMatchLight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	if (!_cabinMatchState) {  		_vm->_sound->replaceSoundMyst(4103); @@ -2552,7 +2551,7 @@ void MystScriptParser_Myst::o_cabinMatchLight(uint16 op, uint16 var, uint16 argc  	}  } -void MystScriptParser_Myst::matchBurn_run() { +void Myst::matchBurn_run() {  	uint32 time = _vm->_system->getMillis();  	if (time > _matchGoOutTime) { @@ -2576,41 +2575,41 @@ void MystScriptParser_Myst::matchBurn_run() {  	}  } -void MystScriptParser_Myst::o_courtyardBoxEnter(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_courtyardBoxEnter(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Mouse enters courtyard box", op);  	_tempVar = 1;  	_vm->_sound->playSound(_courtyardBoxSound);  	_vm->redrawArea(var);  } -void MystScriptParser_Myst::o_courtyardBoxLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_courtyardBoxLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Mouse leaves courtyard box", op);  	_tempVar = 0;  	_vm->redrawArea(var);  } -void MystScriptParser_Myst::o_clockMinuteWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockMinuteWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Card 4006  	debugC(kDebugScript, "Opcode %d: Minute wheel start turn", op);  	clockWheelStartTurn(2);  } -void MystScriptParser_Myst::o_clockWheelEndTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockWheelEndTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Card 4006  	debugC(kDebugScript, "Opcode %d: Wheel end turn", op);  	_clockTurningWheel = 0;  } -void MystScriptParser_Myst::o_clockHourWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockHourWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Card 4006  	debugC(kDebugScript, "Opcode %d: Hour wheel start turn", op);  	clockWheelStartTurn(1);  } -void MystScriptParser_Myst::clockWheel_run() { +void Myst::clockWheel_run() {  	// Turn wheel one step each second  	uint32 time = _vm->_system->getMillis(); @@ -2626,7 +2625,7 @@ void MystScriptParser_Myst::clockWheel_run() {  	}  } -void MystScriptParser_Myst::clockWheelStartTurn(uint16 wheel) { +void Myst::clockWheelStartTurn(uint16 wheel) {  	MystResourceType11 *resource = static_cast<MystResourceType11 *>(_invokingResource);  	uint16 soundId = resource->getList1(0); @@ -2646,7 +2645,7 @@ void MystScriptParser_Myst::clockWheelStartTurn(uint16 wheel) {  	_startTime = _vm->_system->getMillis();  } -void MystScriptParser_Myst::clockWheelTurn(uint16 var) { +void Myst::clockWheelTurn(uint16 var) {  	if (var == 38) {  		// Hours  		_state.clockTowerHourPosition = (_state.clockTowerHourPosition + 1) % 12; @@ -2656,7 +2655,7 @@ void MystScriptParser_Myst::clockWheelTurn(uint16 var) {  	}  } -void MystScriptParser_Myst::o_libraryCombinationBookStartRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryCombinationBookStartRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Combination book start turning pages right", op);  	_tempVar = 0; @@ -2665,7 +2664,7 @@ void MystScriptParser_Myst::o_libraryCombinationBookStartRight(uint16 op, uint16  	_libraryCombinationBookPagesTurning = true;  } -void MystScriptParser_Myst::o_libraryCombinationBookStartLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryCombinationBookStartLeft(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Combination book start turning pages left", op);  	_tempVar = 0; @@ -2674,7 +2673,7 @@ void MystScriptParser_Myst::o_libraryCombinationBookStartLeft(uint16 op, uint16  	_libraryCombinationBookPagesTurning = true;  } -void MystScriptParser_Myst::libraryCombinationBookTurnLeft() { +void Myst::libraryCombinationBookTurnLeft() {  	// Turn page left  	if (_libraryBookPage - 1 >= 0) {  		_tempVar--; @@ -2700,7 +2699,7 @@ void MystScriptParser_Myst::libraryCombinationBookTurnLeft() {  	}  } -void MystScriptParser_Myst::libraryCombinationBookTurnRight() { +void Myst::libraryCombinationBookTurnRight() {  	// Turn page right  	if (_libraryBookPage + 1 < _libraryBookNumPages) {  		_tempVar++; @@ -2726,7 +2725,7 @@ void MystScriptParser_Myst::libraryCombinationBookTurnRight() {  	}  } -void MystScriptParser_Myst::libraryCombinationBook_run() { +void Myst::libraryCombinationBook_run() {  	uint32 time = _vm->_system->getMillis();  	if (time >= _startTime + 500) {  		if (_tempVar > 0) { @@ -2739,7 +2738,7 @@ void MystScriptParser_Myst::libraryCombinationBook_run() {  	}  } -void MystScriptParser_Myst::o_observatoryChangeSettingStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatoryChangeSettingStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Observatory change setting stop", op);  	// Stop persistent scripts @@ -2758,7 +2757,7 @@ void MystScriptParser_Myst::o_observatoryChangeSettingStop(uint16 op, uint16 var  	_vm->_sound->resumeBackgroundMyst();  } -void MystScriptParser_Myst::o_dockVaultForceClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_dockVaultForceClose(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used on Myst 4143 (Dock near Marker Switch)  	uint16 soundId = argv[0];  	uint16 delay = argv[1]; @@ -2782,12 +2781,12 @@ void MystScriptParser_Myst::o_dockVaultForceClose(uint16 op, uint16 var, uint16  	}  } -void MystScriptParser_Myst::o_imagerEraseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_imagerEraseStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Imager stop erase", op);  	_imagerValidationRunning = false;  } -void MystScriptParser_Myst::o_clockLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Clock lever start move", op);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);  	lever->drawFrame(0); @@ -2796,7 +2795,7 @@ void MystScriptParser_Myst::o_clockLeverStartMove(uint16 op, uint16 var, uint16  	_clockLeverPulled = false;  } -void MystScriptParser_Myst::o_clockLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Clock left lever move", op);  	if (!_clockLeverPulled) { @@ -2822,7 +2821,7 @@ void MystScriptParser_Myst::o_clockLeverMove(uint16 op, uint16 var, uint16 argc,  	}  } -void MystScriptParser_Myst::clockGearForwardOneStep(uint16 gear) { +void Myst::clockGearForwardOneStep(uint16 gear) {  	static const uint16 startTime[] = { 0, 324, 618 };  	static const uint16 endTime[] = { 324, 618, 950 };  	static const char *videos[] = { "cl1wg1", "cl1wg2", "cl1wg3" }; @@ -2840,7 +2839,7 @@ void MystScriptParser_Myst::clockGearForwardOneStep(uint16 gear) {  			Audio::Timestamp(0, endTime[gearPosition], 600));  } -void MystScriptParser_Myst::clockWeightDownOneStep() { +void Myst::clockWeightDownOneStep() {  	// Set video bounds  	_clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack) , 124, 0);  	_vm->_video->setVideoBounds(_clockWeightVideo, @@ -2851,7 +2850,7 @@ void MystScriptParser_Myst::clockWeightDownOneStep() {  	_clockWeightPosition += 246;  } -void MystScriptParser_Myst::clockGears_run() { +void Myst::clockGears_run() {  	if (!_vm->_video->isVideoPlaying() && _clockWeightPosition < 2214) {  		_clockMiddleGearMovedAlone = true;  		_vm->_sound->replaceSoundMyst(5113); @@ -2860,7 +2859,7 @@ void MystScriptParser_Myst::clockGears_run() {  	}  } -void MystScriptParser_Myst::o_clockLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Clock lever end move", op);  	static const char *videos[] = { "cl1wg1", "cl1wg2", "cl1wg3", "cl1wlfch" }; @@ -2887,7 +2886,7 @@ void MystScriptParser_Myst::o_clockLeverEndMove(uint16 op, uint16 var, uint16 ar  	_vm->_cursor->showCursor();  } -void MystScriptParser_Myst::clockGearsCheckSolution() { +void Myst::clockGearsCheckSolution() {  	if (_clockGearsPositions[0] == 2  			&& _clockGearsPositions[1] == 2  			&& _clockGearsPositions[2] == 1 @@ -2915,7 +2914,7 @@ void MystScriptParser_Myst::clockGearsCheckSolution() {  	}  } -void MystScriptParser_Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Clock reset lever start move", op);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -2923,7 +2922,7 @@ void MystScriptParser_Myst::o_clockResetLeverStartMove(uint16 op, uint16 var, ui  	_vm->_cursor->setCursor(700);  } -void MystScriptParser_Myst::o_clockResetLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockResetLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Clock reset lever move", op);  	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); @@ -2933,7 +2932,7 @@ void MystScriptParser_Myst::o_clockResetLeverMove(uint16 op, uint16 var, uint16  		clockReset();  } -void MystScriptParser_Myst::clockReset() { +void Myst::clockReset() {  	static const char *videos[] = { "cl1wg1", "cl1wg2", "cl1wg3", "cl1wlfch" };  	_vm->_cursor->hideCursor(); @@ -2971,7 +2970,7 @@ void MystScriptParser_Myst::clockReset() {  	_vm->_cursor->showCursor();  } -void MystScriptParser_Myst::clockResetWeight() { +void Myst::clockResetWeight() {  	// Set video bounds, weight going up  	if (!(_vm->getFeatures() & GF_ME)) {  		_clockWeightVideo = _vm->_video->playMovie(_vm->wrapMovieFilename("cl1wlfch", kMystStack) , 124, 0); @@ -2987,7 +2986,7 @@ void MystScriptParser_Myst::clockResetWeight() {  	_clockWeightPosition = 0;  } -void MystScriptParser_Myst::clockResetGear(uint16 gear) { +void Myst::clockResetGear(uint16 gear) {  	static const uint16 time[] = { 324, 618, 950 };  	static const char *videos[] = { "cl1wg1", "cl1wg2", "cl1wg3" };  	static const uint16 x[] = { 224, 224, 224 }; @@ -3006,7 +3005,7 @@ void MystScriptParser_Myst::clockResetGear(uint16 gear) {  	_clockGearsPositions[gear] = 3;  } -void MystScriptParser_Myst::o_clockResetLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockResetLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Clock reset lever end move", op);  	// Get current lever frame @@ -3017,7 +3016,7 @@ void MystScriptParser_Myst::o_clockResetLeverEndMove(uint16 op, uint16 var, uint  	_vm->checkCursorHints();  } -void MystScriptParser_Myst::o_libraryBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	_libraryBookPage = 0;  	_libraryBookNumPages = argv[0];  	_libraryBookBaseImage = argv[1]; @@ -3025,13 +3024,13 @@ void MystScriptParser_Myst::o_libraryBook_init(uint16 op, uint16 var, uint16 arg  	_libraryBookSound2 = argv[3];  } -void MystScriptParser_Myst::o_courtyardBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_courtyardBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Courtyard box init", op);  	_courtyardBoxSound = argv[0];  } -void MystScriptParser_Myst::towerRotationMap_run() { +void Myst::towerRotationMap_run() {  	if (!_towerRotationMapInitialized) {  		_towerRotationMapInitialized = true;  		_vm->_sound->replaceSoundMyst(4378); @@ -3072,7 +3071,7 @@ void MystScriptParser_Myst::towerRotationMap_run() {  	}  } -void MystScriptParser_Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	_towerRotationMapRunning = true;  	_towerRotationMapTower = static_cast<MystResourceType11 *>(_invokingResource);  	_towerRotationMapLabel = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]); @@ -3081,7 +3080,7 @@ void MystScriptParser_Myst::o_towerRotationMap_init(uint16 op, uint16 var, uint1  	_towerRotationMapClicked = false;  } -void MystScriptParser_Myst::towerRotationDrawBuildings() { +void Myst::towerRotationDrawBuildings() {  	// Draw library  	_vm->redrawArea(304, false); @@ -3092,7 +3091,7 @@ void MystScriptParser_Myst::towerRotationDrawBuildings() {  	}  } -uint16 MystScriptParser_Myst::towerRotationMapComputeAngle() { +uint16 Myst::towerRotationMapComputeAngle() {  	_towerRotationSpeed++;  	if (_towerRotationSpeed >= 7)  		_towerRotationSpeed = 7; @@ -3128,7 +3127,7 @@ uint16 MystScriptParser_Myst::towerRotationMapComputeAngle() {  	return angle;  } -Common::Point MystScriptParser_Myst::towerRotationMapComputeCoords(const Common::Point ¢er, uint16 angle) { +Common::Point Myst::towerRotationMapComputeCoords(const Common::Point ¢er, uint16 angle) {  	Common::Point end;  	// Polar to rect coords @@ -3139,7 +3138,7 @@ Common::Point MystScriptParser_Myst::towerRotationMapComputeCoords(const Common:  	return end;  } -void MystScriptParser_Myst::towerRotationMapDrawLine(const Common::Point ¢er, const Common::Point &end) { +void Myst::towerRotationMapDrawLine(const Common::Point ¢er, const Common::Point &end) {  	Graphics::PixelFormat pf = _vm->_system->getScreenFormat();  	uint32 color = 0; @@ -3174,27 +3173,27 @@ void MystScriptParser_Myst::towerRotationMapDrawLine(const Common::Point ¢er  	_vm->_system->updateScreen();  } -void MystScriptParser_Myst::towerRotationMapRotate() { +void Myst::towerRotationMapRotate() {  	const Common::Point center = Common::Point(383, 124);  	uint16 angle = towerRotationMapComputeAngle();  	Common::Point end = towerRotationMapComputeCoords(center, angle);  	towerRotationMapDrawLine(center, end);  } -void MystScriptParser_Myst::o_forechamberDoor_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_forechamberDoor_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used for Card 4138 (Dock Forechamber Door)  	// Set forechamber door to closed  	_tempVar = 0;  } -void MystScriptParser_Myst::o_shipAccess_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_shipAccess_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Enable acces to the ship  	if (_state.shipFloating) {  		_invokingResource->setEnabled(true);  	}  } -void MystScriptParser_Myst::o_butterflies_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_butterflies_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Butterflies movie init", op);  	// Used for Card 4256 (Butterfly Movie Activation) @@ -3206,7 +3205,7 @@ void MystScriptParser_Myst::o_butterflies_init(uint16 op, uint16 var, uint16 arg  	}  } -void MystScriptParser_Myst::o_imager_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_imager_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Imager init", op);  	debugC(kDebugScript, "Var: %d", var); @@ -3215,7 +3214,7 @@ void MystScriptParser_Myst::o_imager_init(uint16 op, uint16 var, uint16 argc, ui  	_imagerRunning = true;  } -void MystScriptParser_Myst::imager_run() { +void Myst::imager_run() {  	_imagerRunning = false;  	if (_state.imagerActive && _state.imagerSelection == 67) { @@ -3225,7 +3224,7 @@ void MystScriptParser_Myst::imager_run() {  	}  } -void MystScriptParser_Myst::libraryBookcaseTransform_run(void) { +void Myst::libraryBookcaseTransform_run(void) {  	if (_libraryBookcaseChanged) {  		_libraryBookcaseChanged = false;  		_libraryBookcaseMoving = false; @@ -3252,7 +3251,7 @@ void MystScriptParser_Myst::libraryBookcaseTransform_run(void) {  	}  } -void MystScriptParser_Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	if (_libraryBookcaseChanged) {  		MystResourceType7 *resource = static_cast<MystResourceType7 *>(_invokingResource);  		_libraryBookcaseMovie = static_cast<MystResourceType6 *>(resource->getSubResource(getVar(0))); @@ -3261,7 +3260,7 @@ void MystScriptParser_Myst::o_libraryBookcaseTransform_init(uint16 op, uint16 va  	}  } -void MystScriptParser_Myst::generatorControlRoom_run(void) { +void Myst::generatorControlRoom_run(void) {  	if (_generatorVoltage == _state.generatorVoltage) {  		generatorRedrawRocket();  	} else { @@ -3278,14 +3277,14 @@ void MystScriptParser_Myst::generatorControlRoom_run(void) {  	}  } -void MystScriptParser_Myst::o_generatorControlRoom_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_generatorControlRoom_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Generator control room init", op);  	_generatorVoltage = _state.generatorVoltage;  	_generatorControlRoomRunning = true;  } -void MystScriptParser_Myst::o_fireplace_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_fireplace_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Fireplace grid init", op);  	// Clear fireplace grid @@ -3293,7 +3292,7 @@ void MystScriptParser_Myst::o_fireplace_init(uint16 op, uint16 var, uint16 argc,  		_fireplaceLines[i] = 0;  } -void MystScriptParser_Myst::o_clockGears_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_clockGears_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used for Card 4113 (Clock Tower Cog Puzzle)  	debugC(kDebugScript, "Opcode %d: Gears puzzle init", op); @@ -3311,7 +3310,7 @@ void MystScriptParser_Myst::o_clockGears_init(uint16 op, uint16 var, uint16 argc  	}  } -void MystScriptParser_Myst::o_gulls1_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_gulls1_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Gulls init", op);  	if (!_state.shipFloating) { @@ -3320,7 +3319,7 @@ void MystScriptParser_Myst::o_gulls1_init(uint16 op, uint16 var, uint16 argc, ui  	}  } -void MystScriptParser_Myst::gullsFly1_run() { +void Myst::gullsFly1_run() {  	static const char* gulls[] = { "birds1", "birds2", "birds3" };  	uint32 time = _vm->_system->getMillis(); @@ -3340,7 +3339,7 @@ void MystScriptParser_Myst::gullsFly1_run() {  	}  } -void MystScriptParser_Myst::o_observatory_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_observatory_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Stellar observatory init", op);  	_tempVar = 0; @@ -3370,13 +3369,13 @@ void MystScriptParser_Myst::o_observatory_init(uint16 op, uint16 var, uint16 arg  	_observatoryRunning = true;  } -bool MystScriptParser_Myst::observatoryIsDDMMYYYY2400() { +bool Myst::observatoryIsDDMMYYYY2400() {  	// TODO: Auto-detect based on the month rect position  	return !(_vm->getFeatures() & GF_ME) && (_vm->getLanguage() == Common::FR_FRA  			|| _vm->getLanguage() == Common::DE_DEU);  } -void MystScriptParser_Myst::observatoryUpdateVisualizer(uint16 x, uint16 y) { +void Myst::observatoryUpdateVisualizer(uint16 x, uint16 y) {  	Common::Rect &visu0 = _observatoryVisualizer->_subImages[0].rect;  	Common::Rect &visu1 = _observatoryVisualizer->_subImages[1].rect; @@ -3391,7 +3390,7 @@ void MystScriptParser_Myst::observatoryUpdateVisualizer(uint16 x, uint16 y) {  	visu1.bottom = visu0.bottom;  } -void MystScriptParser_Myst::observatorySetTargetToSetting() { +void Myst::observatorySetTargetToSetting() {  	uint32 visuX = _state.observatoryTimeSetting * 7 / 25;  	uint32 visuY = 250 * _state.observatoryYearSetting  			+ 65 * (_state.observatoryMonthSetting + 1) @@ -3405,7 +3404,7 @@ void MystScriptParser_Myst::observatorySetTargetToSetting() {  	_state.observatoryTimeTarget = _state.observatoryTimeSetting;  } -void MystScriptParser_Myst::observatory_run() { +void Myst::observatory_run() {  	if (_observatoryNotInitialized) {  		_observatoryNotInitialized = false; @@ -3463,7 +3462,7 @@ void MystScriptParser_Myst::observatory_run() {  	}  } -void MystScriptParser_Myst::o_gulls2_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_gulls2_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Gulls init", op);  	if (!_state.shipFloating) { @@ -3472,7 +3471,7 @@ void MystScriptParser_Myst::o_gulls2_init(uint16 op, uint16 var, uint16 argc, ui  	}  } -void MystScriptParser_Myst::gullsFly2_run() { +void Myst::gullsFly2_run() {  	static const char* gulls[] = { "birds1", "birds2", "birds3" };  	uint32 time = _vm->_system->getMillis(); @@ -3486,13 +3485,13 @@ void MystScriptParser_Myst::gullsFly2_run() {  	}  } -void MystScriptParser_Myst::o_treeCard_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_treeCard_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Enter tree card", op);  	_tree = static_cast<MystResourceType8 *>(_invokingResource);  } -void MystScriptParser_Myst::o_treeEntry_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_treeEntry_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Enter tree card with entry", op);  	_treeAlcove = static_cast<MystResourceType5 *>(_invokingResource); @@ -3502,7 +3501,7 @@ void MystScriptParser_Myst::o_treeEntry_init(uint16 op, uint16 var, uint16 argc,  	treeSetAlcoveAccessible();  } -void MystScriptParser_Myst::opcode_218(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::opcode_218(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	varUnusedCheck(op, var);  	// Used for Card 4097 (Cabin Boiler) @@ -3520,7 +3519,7 @@ void MystScriptParser_Myst::opcode_218(uint16 op, uint16 var, uint16 argc, uint1  	}  } -void MystScriptParser_Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket sliders init", op);  	_rocketSlider1 = static_cast<MystResourceType10 *>(_vm->_resources[argv[0]]); @@ -3541,12 +3540,12 @@ void MystScriptParser_Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 a  	_rocketSlider5->setPosition(_state.rocketSliderPosition[4]);  } -void MystScriptParser_Myst::o_rocketLinkVideo_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_rocketLinkVideo_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Rocket link video init", op);  	_tempVar = 0;  } -void MystScriptParser_Myst::o_greenBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_greenBook_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	// Used for Card 4168 (Green Book Movies)  	debugC(kDebugScript, "Opcode %d: Green book init", op); @@ -3554,7 +3553,7 @@ void MystScriptParser_Myst::o_greenBook_init(uint16 op, uint16 var, uint16 argc,  	_tempVar = 1;  } -void MystScriptParser_Myst::greenBook_run() { +void Myst::greenBook_run() {  	uint loopStart = 0;  	uint loopEnd = 0;  	Common::String file; @@ -3589,7 +3588,7 @@ void MystScriptParser_Myst::greenBook_run() {  	}  } -void MystScriptParser_Myst::o_gulls3_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_gulls3_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Gulls init", op);  	if (!_state.shipFloating) { @@ -3598,7 +3597,7 @@ void MystScriptParser_Myst::o_gulls3_init(uint16 op, uint16 var, uint16 argc, ui  	}  } -void MystScriptParser_Myst::gullsFly3_run() { +void Myst::gullsFly3_run() {  	static const char* gulls[] = { "birds1", "birds2", "birds3" };  	uint32 time = _vm->_system->getMillis(); @@ -3614,7 +3613,7 @@ void MystScriptParser_Myst::gullsFly3_run() {  	}  } -void MystScriptParser_Myst::o_bookAddSpecialPage_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_bookAddSpecialPage_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Book Exit Function", op);  	uint16 numPages = bookCountPages(var); @@ -3628,22 +3627,23 @@ void MystScriptParser_Myst::o_bookAddSpecialPage_exit(uint16 op, uint16 var, uin  	}  } -void MystScriptParser_Myst::o_treeCard_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_treeCard_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Exit tree card", op);  	_tree = 0;  } -void MystScriptParser_Myst::o_treeEntry_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_treeEntry_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Exit tree card with entry", op);  	_treeAlcove = 0;  } -void MystScriptParser_Myst::o_generatorControlRoom_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { +void Myst::o_generatorControlRoom_exit(uint16 op, uint16 var, uint16 argc, uint16 *argv) {  	debugC(kDebugScript, "Opcode %d: Generator room exit", op);  	_generatorVoltage = _state.generatorVoltage;  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h index e41527a5b8..51dffd0abe 100644 --- a/engines/mohawk/myst_stacks/myst.h +++ b/engines/mohawk/myst_stacks/myst.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Myst(MohawkEngine_Myst *vm); -	~MystScriptParser_Myst(); +	Myst(MohawkEngine_Myst *vm); +	~Myst();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -333,6 +334,7 @@ private:  	void observatoryUpdateTime();  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/preview.cpp b/engines/mohawk/myst_stacks/preview.cpp index bbf324714b..dc491c7573 100644 --- a/engines/mohawk/myst_stacks/preview.cpp +++ b/engines/mohawk/myst_stacks/preview.cpp @@ -33,25 +33,26 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Preview::MystScriptParser_Preview(MohawkEngine_Myst *vm) : MystScriptParser_Myst(vm) { +Preview::Preview(MohawkEngine_Myst *vm) : Myst(vm) {  	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) \  	for (uint32 i = 0; i < _opcodes.size(); i++) \  		if (_opcodes[i]->op == opcode) { \ -			_opcodes[i]->proc = (OpcodeProcMyst) &MystScriptParser_Preview::x; \ +			_opcodes[i]->proc = (OpcodeProcMyst) &Preview::x; \  			_opcodes[i]->desc = #x; \  			break; \  		} -void MystScriptParser_Preview::setupOpcodes() { +void Preview::setupOpcodes() {  	// "Stack-Specific" Opcodes  	OVERRIDE_OPCODE(196, opcode_196);  	OVERRIDE_OPCODE(197, opcode_197); @@ -66,7 +67,7 @@ void MystScriptParser_Preview::setupOpcodes() {  #undef 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);  	// Used on Card ... @@ -74,7 +75,7 @@ void MystScriptParser_Preview::opcode_196(uint16 op, uint16 var, uint16 argc, ui  	// 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);  	// Used on Card ... @@ -83,7 +84,7 @@ void MystScriptParser_Preview::opcode_197(uint16 op, uint16 var, uint16 argc, ui  }  // 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);  	if (argc == 0) { @@ -94,7 +95,7 @@ void MystScriptParser_Preview::opcode_198(uint16 op, uint16 var, uint16 argc, ui  		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);  	// Used on Card ... @@ -102,7 +103,7 @@ void MystScriptParser_Preview::opcode_199(uint16 op, uint16 var, uint16 argc, ui  	// 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);  	// 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);  	// 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..  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/preview.h b/engines/mohawk/myst_stacks/preview.h index 25f0ab514f..870e4b9272 100644 --- a/engines/mohawk/myst_stacks/preview.h +++ b/engines/mohawk/myst_stacks/preview.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Preview(MohawkEngine_Myst *vm); -	~MystScriptParser_Preview(); +	Preview(MohawkEngine_Myst *vm); +	~Preview();  private:  	void setupOpcodes(); @@ -54,6 +55,7 @@ private:  	DECLARE_OPCODE(opcode_299);  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp index 3e00d242be..f485bab2f9 100644 --- a/engines/mohawk/myst_stacks/selenitic.cpp +++ b/engines/mohawk/myst_stacks/selenitic.cpp @@ -35,8 +35,9 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) : +Selenitic::Selenitic(MohawkEngine_Myst *vm) :  		MystScriptParser(vm), _state(vm->_gameState->_selenitic) {  	setupOpcodes();  	_invokingResource = NULL; @@ -44,12 +45,12 @@ MystScriptParser_Selenitic::MystScriptParser_Selenitic(MohawkEngine_Myst *vm) :  	_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  	OPCODE(100, o_mazeRunnerMove);  	OPCODE(101, o_mazeRunnerSoundRepeat); @@ -82,16 +83,16 @@ void MystScriptParser_Selenitic::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Selenitic::disablePersistentScripts() { +void Selenitic::disablePersistentScripts() {  	_soundReceiverRunning = false;  } -void MystScriptParser_Selenitic::runPersistentScripts() { +void Selenitic::runPersistentScripts() {  	if (_soundReceiverRunning)  		soundReceiver_run();  } -uint16 MystScriptParser_Selenitic::getVar(uint16 var) { +uint16 Selenitic::getVar(uint16 var) {  	switch(var) {  	case 0: // Sound receiver emitters enabled  		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) {  	case 0: // Sound receiver emitters enabled  		_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;  	switch (var) { @@ -283,7 +284,7 @@ bool MystScriptParser_Selenitic::setVarValue(uint16 var, uint16 value) {  	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 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)  		_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;  	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)  		_mazeRunnerDirection = 8;  	else @@ -495,12 +496,12 @@ void MystScriptParser_Selenitic::mazeRunnerUpdateCompass() {  	_mazeRunnerCompass->drawConditionalDataToScreen(_mazeRunnerDirection);  } -bool MystScriptParser_Selenitic::mazeRunnerForwardAllowed(uint16 position) { +bool Selenitic::mazeRunnerForwardAllowed(uint16 position) {  	uint16 move = _mazeRunnerVideos[position][1];  	return move == 6 || move == 7;  } -void MystScriptParser_Selenitic::mazeRunnerPlaySoundHelp() { +void Selenitic::mazeRunnerPlaySoundHelp() {  	uint16 soundId = 0;  	_mazeRunnerLight->drawConditionalDataToScreen(1); @@ -564,14 +565,14 @@ void MystScriptParser_Selenitic::mazeRunnerPlaySoundHelp() {  	_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();  }  /**   * 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);  	_vm->_cursor->hideCursor(); @@ -623,7 +624,7 @@ void MystScriptParser_Selenitic::o_soundReceiverSigma(uint16 op, uint16 var, uin  /**   * 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);  	soundReceiverLeftRight(1); @@ -632,13 +633,13 @@ void MystScriptParser_Selenitic::o_soundReceiverRight(uint16 op, uint16 var, uin  /**   * 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);  	soundReceiverLeftRight(2);  } -void MystScriptParser_Selenitic::soundReceiverLeftRight(uint direction) { +void Selenitic::soundReceiverLeftRight(uint direction) {  	if (_soundReceiverSigmaPressed) {  		_soundReceiverSigmaButton->drawConditionalDataToScreen(0); @@ -659,7 +660,7 @@ void MystScriptParser_Selenitic::soundReceiverLeftRight(uint direction) {  	soundReceiverUpdate();  } -void MystScriptParser_Selenitic::soundReceiverUpdate() { +void Selenitic::soundReceiverUpdate() {  	if (_soundReceiverDirection == 1)  		*_soundReceiverPosition = ((*_soundReceiverPosition) + _soundReceiverSpeed) % 3600;  	else if (_soundReceiverDirection == 2) @@ -668,7 +669,7 @@ void MystScriptParser_Selenitic::soundReceiverUpdate() {  	soundReceiverDrawView();  } -void MystScriptParser_Selenitic::soundReceiverDrawView() { +void Selenitic::soundReceiverDrawView() {  	uint32 left = ((*_soundReceiverPosition) * 1800) / 3600;  	_soundReceiverViewer->_subImages->rect.left = left; @@ -679,7 +680,7 @@ void MystScriptParser_Selenitic::soundReceiverDrawView() {  	soundReceiverDrawAngle();  } -void MystScriptParser_Selenitic::soundReceiverDrawAngle() { +void Selenitic::soundReceiverDrawAngle() {  	_vm->redrawResource(_soundReceiverAngle1);  	_vm->redrawResource(_soundReceiverAngle2);  	_vm->redrawResource(_soundReceiverAngle3); @@ -689,7 +690,7 @@ void MystScriptParser_Selenitic::soundReceiverDrawAngle() {  /**   * 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);  	if (_soundReceiverSigmaPressed) { @@ -723,7 +724,7 @@ void MystScriptParser_Selenitic::o_soundReceiverSource(uint16 op, uint16 var, ui  	_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  	uint16 cardIdExit = argv[0];  	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);  	soundReceiverUpdateSound();  } -uint16 MystScriptParser_Selenitic::soundLockCurrentSound(uint16 position, bool pixels) { +uint16 Selenitic::soundLockCurrentSound(uint16 position, bool pixels) {  	if ((pixels && position < 96) || (!pixels && position == 0))  		return 289;  	else if ((pixels && position < 108) || (!pixels && position == 1)) @@ -770,7 +771,7 @@ uint16 MystScriptParser_Selenitic::soundLockCurrentSound(uint16 position, bool p  	return 0;  } -MystResourceType10 *MystScriptParser_Selenitic::soundLockSliderFromVar(uint16 var) { +MystResourceType10 *Selenitic::soundLockSliderFromVar(uint16 var) {  	switch (var) {  	case 20:  		return _soundLockSlider1; @@ -787,7 +788,7 @@ MystResourceType10 *MystScriptParser_Selenitic::soundLockSliderFromVar(uint16 va  	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);  	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);  	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);  } -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);  	MystResourceType10 *slider = soundLockSliderFromVar(var); @@ -855,7 +856,7 @@ void MystScriptParser_Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint1  	_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);  	_vm->_sound->replaceSoundMyst(soundLockCurrentSound(value / 12, false));  	_vm->_system->delayMillis(1500); @@ -867,7 +868,7 @@ void MystScriptParser_Selenitic::soundLockCheckSolution(MystResourceType10 *slid  	_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);  	bool solved = true; @@ -905,7 +906,7 @@ void MystScriptParser_Selenitic::o_soundLockButton(uint16 op, uint16 var, uint16  	_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);  	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);  } -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);  } -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);  } -void MystScriptParser_Selenitic::soundReceiver_run() { +void Selenitic::soundReceiver_run() {  	if (_soundReceiverStartTime) {  		if (_soundReceiverDirection) {  			uint32 currentTime = _vm->_system->getMillis(); @@ -952,7 +953,7 @@ void MystScriptParser_Selenitic::soundReceiver_run() {  	}  } -void MystScriptParser_Selenitic::soundReceiverIncreaseSpeed() { +void Selenitic::soundReceiverIncreaseSpeed() {  	switch (_soundReceiverSpeed) {  	case 1:  		_soundReceiverSpeed = 10; @@ -966,12 +967,12 @@ void MystScriptParser_Selenitic::soundReceiverIncreaseSpeed() {  	}  } -void MystScriptParser_Selenitic::soundReceiverUpdateSound() { +void Selenitic::soundReceiverUpdateSound() {  	uint16 soundId = soundReceiverCurrentSound(_state.soundReceiverCurrentSource, *_soundReceiverPosition);  	_vm->_sound->replaceSoundMyst(soundId);  } -uint16 MystScriptParser_Selenitic::soundReceiverCurrentSound(uint16 source, uint16 position) { +uint16 Selenitic::soundReceiverCurrentSound(uint16 source, uint16 position) {  	uint16 solution = 0;  	bool sourceEnabled = false;  	soundReceiverSolution(source, solution, sourceEnabled); @@ -1022,7 +1023,7 @@ uint16 MystScriptParser_Selenitic::soundReceiverCurrentSound(uint16 source, uint  	return soundId;  } -void MystScriptParser_Selenitic::soundReceiverSolution(uint16 source, uint16 &solution, bool &enabled) { +void Selenitic::soundReceiverSolution(uint16 source, uint16 &solution, bool &enabled) {  	switch (source) {  	case 0:  		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);  	// Used for Card 1245 (Sound Receiver) @@ -1074,7 +1075,7 @@ void MystScriptParser_Selenitic::o_soundReceiver_init(uint16 op, uint16 var, uin  	_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);  	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;  } -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);  } -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);  } -const uint16 MystScriptParser_Selenitic::_mazeRunnerMap[300][4] = { +const uint16 Selenitic::_mazeRunnerMap[300][4] = {  	{8, 7, 1, 288},  	{1, 0, 2, 288},  	{2, 1, 3, 288}, @@ -1420,7 +1421,7 @@ const uint16 MystScriptParser_Selenitic::_mazeRunnerMap[300][4] = {  	{ 0, 0, 0, 0}  }; -const uint8 MystScriptParser_Selenitic::_mazeRunnerVideos[300][4] = { +const uint8 Selenitic::_mazeRunnerVideos[300][4] = {  	{3, 6, 10, 17},  	{0, 5, 8, 17},  	{0, 4, 8, 17}, @@ -1723,4 +1724,5 @@ const uint8 MystScriptParser_Selenitic::_mazeRunnerVideos[300][4] = {  	{0, 0, 0, 0}  }; +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/selenitic.h b/engines/mohawk/myst_stacks/selenitic.h index 54e9db4d66..4ec92b9869 100644 --- a/engines/mohawk/myst_stacks/selenitic.h +++ b/engines/mohawk/myst_stacks/selenitic.h @@ -32,16 +32,17 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  class MystResourceType8;  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: -	MystScriptParser_Selenitic(MohawkEngine_Myst *vm); -	~MystScriptParser_Selenitic(); +	Selenitic(MohawkEngine_Myst *vm); +	~Selenitic();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -135,6 +136,7 @@ private:  	void mazeRunnerBacktrack(uint16 &oldPosition);  }; +} // End of namespace MystStacks  }  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/slides.cpp b/engines/mohawk/myst_stacks/slides.cpp index 128505d266..e664081c96 100644 --- a/engines/mohawk/myst_stacks/slides.cpp +++ b/engines/mohawk/myst_stacks/slides.cpp @@ -33,19 +33,18 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -// NOTE: Credits Start Card is 10000 - -MystScriptParser_Slides::MystScriptParser_Slides(MohawkEngine_Myst *vm) : MystScriptParser(vm) { +Slides::Slides(MohawkEngine_Myst *vm) : MystScriptParser(vm) {  	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  	OPCODE(100, o_returnToMenu); @@ -55,11 +54,11 @@ void MystScriptParser_Slides::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Slides::disablePersistentScripts() { +void Slides::disablePersistentScripts() {  	_cardSwapEnabled = false;  } -void MystScriptParser_Slides::runPersistentScripts() { +void Slides::runPersistentScripts() {  	if (_cardSwapEnabled) {  		// Used on Cards...  		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);  } -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...  	if (argc == 1) {  		_nextCardID = argv[0]; @@ -81,4 +80,5 @@ void MystScriptParser_Slides::o_setCardSwap(uint16 op, uint16 var, uint16 argc,  		unknown(op, var, argc, argv);  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/slides.h b/engines/mohawk/myst_stacks/slides.h index 7230eead25..1e0504a665 100644 --- a/engines/mohawk/myst_stacks/slides.h +++ b/engines/mohawk/myst_stacks/slides.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Slides(MohawkEngine_Myst *vm); -	~MystScriptParser_Slides(); +	Slides(MohawkEngine_Myst *vm); +	~Slides();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -57,6 +58,7 @@ private:  	uint32 _lastCardTime;  }; +} // End of namespace MystStacks  } // End of namespace Mohawk  #undef DECLARE_OPCODE diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp index ebf7f75d88..b5b403dad8 100644 --- a/engines/mohawk/myst_stacks/stoneship.cpp +++ b/engines/mohawk/myst_stacks/stoneship.cpp @@ -35,8 +35,9 @@  #include "gui/message.h"  namespace Mohawk { +namespace MystStacks { -MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) : +Stoneship::Stoneship(MohawkEngine_Myst *vm) :  		MystScriptParser(vm), _state(vm->_gameState->_stoneship) {  	setupOpcodes(); @@ -60,12 +61,12 @@ MystScriptParser_Stoneship::MystScriptParser_Stoneship(MohawkEngine_Myst *vm) :  		_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  	OPCODE(100, o_pumpTurnOff);  	OPCODE(101, o_brotherDoorOpen); @@ -111,14 +112,14 @@ void MystScriptParser_Stoneship::setupOpcodes() {  #undef OPCODE -void MystScriptParser_Stoneship::disablePersistentScripts() { +void Stoneship::disablePersistentScripts() {  	_batteryCharging = false;  	_batteryDepleting = false;  	_batteryGaugeRunning = false;  	_telescopeRunning = false;  } -void MystScriptParser_Stoneship::runPersistentScripts() { +void Stoneship::runPersistentScripts() {  	if (_batteryCharging)  		chargeBattery_run(); @@ -135,7 +136,7 @@ void MystScriptParser_Stoneship::runPersistentScripts() {  		tunnel_run();  } -uint16 MystScriptParser_Stoneship::getVar(uint16 var) { +uint16 Stoneship::getVar(uint16 var) {  	switch(var) {  	case 0: // Water Drained From Lighthouse / Right Button Of Pump  		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) {  	case 0: // Water Drained From Lighthouse / Right Button Of Pump  		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;  	switch (var) { @@ -380,7 +381,7 @@ bool MystScriptParser_Stoneship::setVarValue(uint16 var, uint16 value) {  	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);  	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);  	_brotherDoorOpen = 1; @@ -418,7 +419,7 @@ void MystScriptParser_Stoneship::o_brotherDoorOpen(uint16 op, uint16 var, uint16  	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);  	uint16 startTime = argv[0]; @@ -429,7 +430,7 @@ void MystScriptParser_Stoneship::o_cabinBookMovie(uint16 op, uint16 var, uint16  	_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);  	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);  } -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);  	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();  	_telescopeOldMouse = mouse.x;  	_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);  	MystResourceType11 *display = static_cast<MystResourceType11 *>(_invokingResource); @@ -477,11 +478,11 @@ void MystScriptParser_Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 a      _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();  } -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);  	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);  } -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);  	_batteryCharging = false; @@ -534,7 +535,7 @@ void MystScriptParser_Stoneship::o_generatorStop(uint16 op, uint16 var, uint16 a  		_vm->_sound->replaceSoundMyst(soundId);  } -void MystScriptParser_Stoneship::chargeBattery_run() { +void Stoneship::chargeBattery_run() {  	uint32 time = _vm->_system->getMillis();  	if (time > _batteryNextTime) { @@ -543,7 +544,7 @@ void MystScriptParser_Stoneship::chargeBattery_run() {  	}  } -uint16 MystScriptParser_Stoneship::batteryRemainingCharge() { +uint16 Stoneship::batteryRemainingCharge() {  	uint32 time = _vm->_system->getMillis();  	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();  	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);  	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);  } -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)  	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);  } -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);  	//_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);  	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);  	_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);  	// Used on Card 2111 (Compass Rose)  	// 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);  } -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);  	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);  	// 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);  	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);  } -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)  	uint16 movieId = argv[0]; @@ -765,14 +766,14 @@ void MystScriptParser_Stoneship::o_sideDoorsMovies(uint16 op, uint16 var, uint16  	_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);  	_vm->_sound->replaceSoundMyst(_cloudOrbSound, Audio::Mixer::kMaxChannelVolume, true);  	_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);  	_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);  } -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);  	uint16 drawerOpen = getVar(var); @@ -788,7 +789,7 @@ void MystScriptParser_Stoneship::o_drawerCloseOpened(uint16 op, uint16 var, uint  		drawerClose(argv[0] + drawerOpen - 1);  } -void MystScriptParser_Stoneship::drawerClose(uint16 drawer) { +void Stoneship::drawerClose(uint16 drawer) {  	_chestDrawersOpen = 0;  	_vm->drawCardBackground();  	_vm->drawResourceImages(); @@ -797,19 +798,19 @@ void MystScriptParser_Stoneship::drawerClose(uint16 drawer) {  	_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);  	_hologramDisplay = static_cast<MystResourceType6 *>(_invokingResource);  	_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);  	_hologramSelection = static_cast<MystResourceType6 *>(_invokingResource);  } -void MystScriptParser_Stoneship::batteryGaugeUpdate() { +void Stoneship::batteryGaugeUpdate() {  	uint16 charge = 0;  	if (_state.generatorDepletionTime) { @@ -823,7 +824,7 @@ void MystScriptParser_Stoneship::batteryGaugeUpdate() {  	_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)  	debugC(kDebugScript, "Opcode %d: Battery init", op); @@ -832,7 +833,7 @@ void MystScriptParser_Stoneship::o_battery_init(uint16 op, uint16 var, uint16 ar  	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);  	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;  } -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);  	_batteryLastCharge = batteryRemainingCharge();  	_batteryGaugeRunning = true;  } -void MystScriptParser_Stoneship::batteryGauge_run() { +void Stoneship::batteryGauge_run() {  	uint16 batteryCharge = batteryRemainingCharge();  	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);  		_tunnelImagesCount = argv[0]; @@ -880,7 +881,7 @@ void MystScriptParser_Stoneship::o_tunnel_init(uint16 op, uint16 var, uint16 arg  		debugC(kDebugScript, "\tsoundIdAlarm: %d", _tunnelAlarmSound);  } -void MystScriptParser_Stoneship::tunnel_run() { +void Stoneship::tunnel_run() {  	uint32 time = _vm->_system->getMillis();  	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);  	_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);  	_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);  	// 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;  } -void MystScriptParser_Stoneship::telescope_run() { +void Stoneship::telescope_run() {  	uint32 time = _vm->_system->getMillis();  	if (time > _telescopeNexTime) { @@ -942,7 +943,7 @@ void MystScriptParser_Stoneship::telescope_run() {  	}  } -void MystScriptParser_Stoneship::telescopeLighthouseDraw() { +void Stoneship::telescopeLighthouseDraw() {  	if (_telescopePosition > 1137 && _telescopePosition < 1294) {  		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);  	// 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);  	_cloudOrbMovie = static_cast<MystResourceType6 *>(_invokingResource); @@ -990,4 +991,5 @@ void MystScriptParser_Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 a  	_cloudOrbStopSound = argv[1];  } +} // End of namespace MystStacks  } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/stoneship.h b/engines/mohawk/myst_stacks/stoneship.h index eb58bd6543..091fdcd169 100644 --- a/engines/mohawk/myst_stacks/stoneship.h +++ b/engines/mohawk/myst_stacks/stoneship.h @@ -32,15 +32,16 @@  namespace Mohawk { -#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) - -class MohawkEngine_Myst;  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: -	MystScriptParser_Stoneship(MohawkEngine_Myst *vm); -	~MystScriptParser_Stoneship(); +	Stoneship(MohawkEngine_Myst *vm); +	~Stoneship();  	void disablePersistentScripts();  	void runPersistentScripts(); @@ -142,6 +143,7 @@ private:  	uint16 batteryRemainingCharge();  }; +} // End of namespace MystStacks  }  #undef DECLARE_OPCODE diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 259ad84f69..79993a297a 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -152,9 +152,9 @@ void Palette::fadeTo(const Palette& target, uint step) {  		if (_data[i] == target._data[i]) continue;  		if (_data[i] < target._data[i]) -			_data[i] = CLIP(_data[i] + step, (uint)0, (uint)target._data[i]); +			_data[i] = CLIP(_data[i] + (int)step, (int)0, (int)target._data[i]);  		else -			_data[i] = CLIP(_data[i] - step, (uint)target._data[i], (uint)255); +			_data[i] = CLIP(_data[i] - (int)step, (int)target._data[i], (int)255);  	}  	return; diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h index f042664d8d..c7ef720e1f 100644 --- a/engines/sci/detection_tables.h +++ b/engines/sci/detection_tables.h @@ -2274,7 +2274,7 @@ static const struct ADGameDescription SciGameDescriptions[] = {  		Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, GUIO_NOSPEECH	},  	// Mixed-Up Mother Goose - FM-Towns (supplied by abevi in bug report #3038720) -	{"mothergoose", "", { +	{"mothergoose256", "", {  		{"resource.map", 0, "b11e971ccd2040bebba59dfb409a08ef", 5772},  		{"resource.001", 0, "d49625d9b8005ec01c852f8322a82867", 4330713},  		AD_LISTEND}, diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index d8bbc75c18..ea6fa31d05 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -533,6 +533,7 @@ void Kernel::mapFunctions() {  	switch (g_sci->getPlatform()) {  	case Common::kPlatformPC: +	case Common::kPlatformFMTowns:  		platformMask = SIGFOR_DOS;  		break;  	case Common::kPlatformPC98: diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp index 58de38bd8e..e5a9931605 100644 --- a/engines/sci/engine/kevent.cpp +++ b/engines/sci/engine/kevent.cpp @@ -38,8 +38,6 @@  namespace Sci { -#define SCI_VARIABLE_GAME_SPEED 3 -  reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {  	int mask = argv[0].toUint16();  	reg_t obj = argv[1]; @@ -188,57 +186,42 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {  	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 obj = argv[0];  	SegManager *segMan = s->_segMan;  	if (readSelectorValue(segMan, obj, SELECTOR(type)) == SCI_EVENT_KEYBOARD) { // Keyboard -		int mover = -1; -		switch (readSelectorValue(segMan, obj, SELECTOR(message))) { -		case SCI_KEY_HOME: -			mover = 8; -			break; -		case SCI_KEY_UP: -			mover = 1; -			break; -		case SCI_KEY_PGUP: -			mover = 2; -			break; -		case SCI_KEY_LEFT: -			mover = 7; -			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; +		uint16 message = readSelectorValue(segMan, obj, SELECTOR(message)); +		uint16 eventType = SCI_EVENT_DIRECTION; +		// Check if the game is using cursor views. These games allowed control +		// of the mouse cursor via the keyboard controls (the so called +		// "PseudoMouse" functionality in script 933). +		if (g_sci->_features->detectSetCursorType() == SCI_VERSION_1_1) +			eventType |= SCI_EVENT_KEYBOARD; + +		for (int i = 0; i < 9; i++) { +			if (keyToDirMap[i].key == message) { +				writeSelectorValue(segMan, obj, SELECTOR(type), eventType); +				writeSelectorValue(segMan, obj, SELECTOR(message), keyToDirMap[i].direction); +				return TRUE_REG;	// direction mapped +			}  		} -		if (mover >= 0) { -			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 NULL_REG;	// unknown direction  	} -	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) { diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 6e961f72f3..f95b1dd0f8 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -362,20 +362,29 @@ reg_t kIconBar(EngineState *s, int argc, reg_t *argv) {  		return NULL_REG;  	switch (argv[0].toUint16()) { -	case 0: -		// Add the icons +	case 0: // InitIconBar  		for (int i = 0; i < argv[1].toUint16(); i++)  			g_sci->_gfxMacIconBar->addIcon(argv[i + 2]);  		g_sci->_gfxMacIconBar->drawIcons(); + +		// TODO: Should return icon bar handle +		// Said handle is then used by DisposeIconBar +		break; +	case 1: // DisposeIconBar +		warning("kIconBar(Dispose)"); +		break; +	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 2: -	case 3: -	case 4: -		// TODO: Other calls seem to handle selecting/deselecting them +	case 4: // SetIconBarIcon +		warning("kIconBar(SetIcon, %d, %d)", argv[1].toUint16(), argv[2].toUint16());  		break;  	default: -		warning("Unknown kIconBar subop %d", argv[0].toUint16()); +		error("Unknown kIconBar(%d)", argv[0].toUint16());  	}  	return NULL_REG; @@ -389,23 +398,28 @@ reg_t kMacPlatform(EngineState *s, int argc, reg_t *argv) {  	switch (argv[0].toUint16()) {  	case 0: -		// Set Mac cursor remap -		g_sci->_gfxCursor->setMacCursorRemapList(argc - 1, argv + 1); +		// 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); +		else if (getSciVersion() != SCI_VERSION_1_1) +			warning("Unknown SCI1 kMacPlatform(0) call");  		break; -	case 1: -		// Unknown -		break; -	case 2: -		// Unknown -		break; -	case 3: -		// Unknown -		break; -	case 4: -		// Handle icon bar code +	case 4: // Handle icon bar code  		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: -		warning("Unknown kMacPlatform subop %d", argv[0].toUint16()); +		error("Unknown kMacPlatform(%d)", argv[0].toUint16());  	}  	return s->r_acc; @@ -455,7 +469,8 @@ reg_t kPlatform(EngineState *s, int argc, reg_t *argv) {  		warning("STUB: kPlatform(CDCheck)");  		break;  	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);  		// Otherwise, fall through  	case kPlatformGetPlatform: diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index a59d4c000b..ab355cebb4 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -47,6 +47,10 @@  #include "sci/sound/audio.h"  #include "sci/sound/music.h" +#ifdef ENABLE_SCI32 +#include "sci/graphics/frameout.h" +#endif +  namespace Sci { @@ -130,6 +134,13 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {  		// Reset _scriptSegMap, to be restored below  		_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 @@ -144,17 +155,15 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {  		SegmentType type = (s.isSaving() && mobj) ? mobj->getType() : SEG_TYPE_INVALID;  		s.syncAsUint32LE(type); -		// If we were saving and mobj == 0, or if we are loading and this is an -		// entry marked as empty -> skip to next -		if (type == SEG_TYPE_INVALID) +		if (type == SEG_TYPE_HUNK) { +			// Don't save or load HunkTable segments  			continue; - -		// Don't save or load HunkTable segments -		if (type == SEG_TYPE_HUNK) +		} else if (type == SEG_TYPE_INVALID) { +			// If we were saving and mobj == 0, or if we are loading and this is an +			// entry marked as empty -> skip to next  			continue; - -		// Don't save or load the obsolete system string segments -		if (type == 5) { +		} else if (type == 5) { +			// Don't save or load the obsolete system string segments  			if (s.isSaving()) {  				continue;  			} else { @@ -168,6 +177,14 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {  				_heap[i] = NULL;	// set as freed  				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()) @@ -178,8 +195,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {  		// Let the object sync custom data  		mobj->saveLoadWithSerializer(s); - -		if (type == SEG_TYPE_SCRIPT && s.getVersion() >= 28) { +		if (type == SEG_TYPE_SCRIPT) {  			Script *scr = (Script *)mobj;  			// If we are loading a script, perform some extra steps @@ -196,7 +212,8 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {  			}  			// Sync the script's string heap -			scr->syncStringHeap(s); +			if (s.getVersion() >= 28) +				scr->syncStringHeap(s);  		}  	} diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 6d11a1ad8a..9c7f52d28e 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -131,21 +131,6 @@ static StackPtr validate_stack_addr(EngineState *s, StackPtr sp) {  	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) {  	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;  } -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  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;  	while (framesize > 0) { -		selector = validate_arithmetic(*argp++); -		argc = validate_arithmetic(*argp); +		selector = argp->requireUint16(); +		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"); -		}  #ifdef VM_DEBUG_SEND  		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)  			// Binary not -			int16 value; -			if (validate_signedInteger(s->r_acc, value)) +			int16 value = s->r_acc.toSint16(); +			if (s->r_acc.isNumber())  				s->r_acc = make_reg(0, 0xffff ^ value);  			else  				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)  			r_temp = POP32(); -			int16 value1, value2; -			if (validate_signedInteger(s->r_acc, value1) && validate_signedInteger(r_temp, value2)) +			int16 value1 = s->r_acc.toSint16(); +			int16 value2 = r_temp.toSint16(); +			if (s->r_acc.isNumber() && r_temp.isNumber())  				s->r_acc = make_reg(0, value1 * value2);  			else  				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)  			r_temp = POP32(); -			int16 divisor, dividend; -			if (validate_signedInteger(s->r_acc, divisor) && validate_signedInteger(r_temp, dividend)) +			int16 divisor = s->r_acc.toSint16(); +			int16 dividend = r_temp.toSint16(); +			if (s->r_acc.isNumber() && r_temp.isNumber())  				s->r_acc = make_reg(0, (divisor != 0 ? dividend / divisor : 0));  			else  				s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeDivWorkarounds, s->r_acc, r_temp); @@ -1109,8 +1082,9 @@ void run_vm(EngineState *s) {  			r_temp = POP32();  			if (getSciVersion() <= SCI_VERSION_0_LATE) { -				uint16 modulo, value; -				if (validate_unsignedInteger(s->r_acc, modulo) && validate_unsignedInteger(r_temp, value)) +				uint16 modulo = s->r_acc.toUint16(); +				uint16 value = r_temp.toUint16(); +				if (s->r_acc.isNumber() && r_temp.isNumber())  					s->r_acc = make_reg(0, (modulo != 0 ? value % modulo : 0));  				else  					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  				// games. Fixes the battlecruiser mini game in SQ5 (room 850),  				// bug #3035755 -				int16 modulo, value, result; -				if (validate_signedInteger(s->r_acc, modulo) && validate_signedInteger(r_temp, value)) { +				int16 modulo = s->r_acc.toSint16(); +				int16 value = r_temp.toSint16(); +				int16 result; +				if (s->r_acc.isNumber() && r_temp.isNumber()) {  					modulo = ABS(modulo);  					result = (modulo != 0 ? value % modulo : 0);  					if (result < 0) @@ -1137,8 +1113,9 @@ void run_vm(EngineState *s) {  		case op_shr: { // 0x06 (06)  			// Shift right logical  			r_temp = POP32(); -			uint16 value, shiftCount; -			if (validate_unsignedInteger(r_temp, value) && validate_unsignedInteger(s->r_acc, shiftCount)) +			uint16 value = r_temp.toUint16(); +			uint16 shiftCount = s->r_acc.toUint16(); +			if (r_temp.isNumber() && s->r_acc.isNumber())  				s->r_acc = make_reg(0, value >> shiftCount);  			else  				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)  			// Shift left logical  			r_temp = POP32(); -			uint16 value, shiftCount; -			if (validate_unsignedInteger(r_temp, value) && validate_unsignedInteger(s->r_acc, shiftCount)) +			uint16 value = r_temp.toUint16(); +			uint16 shiftCount = s->r_acc.toUint16(); +			if (r_temp.isNumber() && s->r_acc.isNumber())  				s->r_acc = make_reg(0, value << shiftCount);  			else  				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)  			r_temp = POP32(); -			uint16 value1, value2; -			if (validate_unsignedInteger(r_temp, value1) && validate_unsignedInteger(s->r_acc, value2)) +			uint16 value1 = r_temp.toUint16(); +			uint16 value2 = s->r_acc.toUint16(); +			if (r_temp.isNumber() && s->r_acc.isNumber())  				s->r_acc = make_reg(0, value1 ^ value2);  			else  				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)  			r_temp = POP32(); -			uint16 value1, value2; -			if (validate_unsignedInteger(r_temp, value1) && validate_unsignedInteger(s->r_acc, value2)) +			uint16 value1 = r_temp.toUint16(); +			uint16 value2 = s->r_acc.toUint16(); +			if (r_temp.isNumber() && s->r_acc.isNumber())  				s->r_acc = make_reg(0, value1 & value2);  			else  				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)  			r_temp = POP32(); -			uint16 value1, value2; -			if (validate_unsignedInteger(r_temp, value1) && validate_unsignedInteger(s->r_acc, value2)) +			uint16 value1 = r_temp.toUint16(); +			uint16 value2 = s->r_acc.toUint16(); +			if (r_temp.isNumber() && s->r_acc.isNumber())  				s->r_acc = make_reg(0, value1 | value2);  			else  				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) -			int16 value; -			if (validate_signedInteger(s->r_acc, value)) +			int16 value = s->r_acc.toSint16(); +			if (s->r_acc.isNumber())  				s->r_acc = make_reg(0, -value);  			else  				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  				s->r_acc = make_reg(0, 1);  			} else { -				int16 compare1, compare2; -				if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) +				int16 compare1 = r_temp.toSint16(); +				int16 compare2 = s->r_acc.toSint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 > compare2);  				else  					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));  				s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset >= s->r_acc.offset);  			} else { -				int16 compare1, compare2; -				if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) +				int16 compare1 = r_temp.toSint16(); +				int16 compare2 = s->r_acc.toSint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 >= compare2);  				else  					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  				s->r_acc = make_reg(0, 1);  			} else { -				int16 compare1, compare2; -				if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) +				int16 compare1 = r_temp.toSint16(); +				int16 compare2 = s->r_acc.toSint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 < compare2);  				else  					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));  				s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset <= s->r_acc.offset);  			} else { -				int16 compare1, compare2; -				if (validate_signedInteger(r_temp, compare1) && validate_signedInteger(s->r_acc, compare2)) +				int16 compare1 = r_temp.toSint16(); +				int16 compare2 = s->r_acc.toSint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 <= compare2);  				else  					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)  				s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset > s->r_acc.offset);  			else { -				uint16 compare1, compare2; -				if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) +				uint16 compare1 = r_temp.toUint16(); +				uint16 compare2 = s->r_acc.toUint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 > compare2);  				else  					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)  				s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset >= s->r_acc.offset);  			else { -				uint16 compare1, compare2; -				if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) +				uint16 compare1 = r_temp.toUint16(); +				uint16 compare2 = s->r_acc.toUint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 >= compare2);  				else  					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)  				s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset < s->r_acc.offset);  			else { -				uint16 compare1, compare2; -				if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) +				uint16 compare1 = r_temp.toUint16(); +				uint16 compare2 = s->r_acc.toUint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 < compare2);  				else  					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)  				s->r_acc = make_reg(0, (r_temp.segment == s->r_acc.segment) && r_temp.offset <= s->r_acc.offset);  			else { -				uint16 compare1, compare2; -				if (validate_unsignedInteger(r_temp, compare1) && validate_unsignedInteger(s->r_acc, compare2)) +				uint16 compare1 = r_temp.toUint16(); +				uint16 compare2 = s->r_acc.toUint16(); +				if (r_temp.isNumber() && s->r_acc.isNumber())  					s->r_acc = make_reg(0, compare1 <= compare2);  				else  					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,  											localCallOffset),  											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,  											s->_executionStack.size()-1, s->xs->local_segment);  			s->restAdjust = 0; // Used up the &rest adjustment @@ -1466,7 +1455,7 @@ void run_vm(EngineState *s) {  			if (!oldScriptHeader)  				s->xs->sp -= s->restAdjust; -			int argc = validate_arithmetic(s->xs->sp[0]); +			int argc = s->xs->sp[0].requireUint16();  			if (!oldScriptHeader)  				argc += s->restAdjust; @@ -1663,7 +1652,7 @@ void run_vm(EngineState *s) {  			r_temp.offset = s->variables[var_number] - s->variablesBase[var_number];  			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 *= 2; // variables are 16 bit @@ -1710,8 +1699,8 @@ void run_vm(EngineState *s) {  		case op_ipToa: { // 0x35 (53)  			// Increment Property and copy To Accumulator  			reg_t &opProperty = validate_property(s, obj, opparams[0]); -			uint16 valueProperty; -			if (validate_unsignedInteger(opProperty, valueProperty)) +			uint16 valueProperty = opProperty.toUint16(); +			if (opProperty.isNumber())  				s->r_acc = make_reg(0, valueProperty + 1);  			else  				s->r_acc = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG); @@ -1722,8 +1711,8 @@ void run_vm(EngineState *s) {  		case op_dpToa: { // 0x36 (54)  			// Decrement Property and copy To Accumulator  			reg_t &opProperty = validate_property(s, obj, opparams[0]); -			uint16 valueProperty; -			if (validate_unsignedInteger(opProperty, valueProperty)) +			uint16 valueProperty = opProperty.toUint16(); +			if (opProperty.isNumber())  				s->r_acc = make_reg(0, valueProperty - 1);  			else  				s->r_acc = arithmetic_lookForWorkaround(opcode, opcodeDptoaWorkarounds, opProperty, NULL_REG); @@ -1734,8 +1723,8 @@ void run_vm(EngineState *s) {  		case op_ipTos: { // 0x37 (55)  			// Increment Property and push to Stack  			reg_t &opProperty = validate_property(s, obj, opparams[0]); -			uint16 valueProperty; -			if (validate_unsignedInteger(opProperty, valueProperty)) +			uint16 valueProperty = opProperty.toUint16(); +			if (opProperty.isNumber())  				valueProperty++;  			else  				valueProperty = arithmetic_lookForWorkaround(opcode, NULL, opProperty, NULL_REG).offset; @@ -1747,8 +1736,8 @@ void run_vm(EngineState *s) {  		case op_dpTos: { // 0x38 (56)  			// Decrement Property and push to Stack  			reg_t &opProperty = validate_property(s, obj, opparams[0]); -			uint16 valueProperty; -			if (validate_unsignedInteger(opProperty, valueProperty)) +			uint16 valueProperty = opProperty.toUint16(); +			if (opProperty.isNumber())  				valueProperty--;  			else  				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,  			// using the accumulator as an additional index  			var_type = opcode & 0x3; // Gets the variable type: g, l, t or p -			int16 value; -			if (!validate_signedInteger(s->r_acc, value)) +			int16 value = s->r_acc.toSint16(); +			if (!s->r_acc.isNumber())  				value = arithmetic_lookForWorkaround(opcode, opcodeLaiWorkarounds, s->r_acc, NULL_REG).offset;  			var_number = opparams[0] + value;  			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,  			// using the accumulator as an additional index  			var_type = opcode & 0x3; // Gets the variable type: g, l, t or p -			int16 value; -			if (!validate_signedInteger(s->r_acc, value)) +			int16 value = s->r_acc.toSint16(); +			if (!s->r_acc.isNumber())  				value = arithmetic_lookForWorkaround(opcode, opcodeLsiWorkarounds, s->r_acc, NULL_REG).offset;  			var_number = opparams[0] + value;  			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  			// simultaneously...  			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();  			WRITE_VAR(var_type, var_number, s->r_acc);  			break; @@ -1937,7 +1926,7 @@ void run_vm(EngineState *s) {  			// Save the stack into the global, local, temp or param variable,  			// using the accumulator as an additional index  			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());  			break; @@ -1983,7 +1972,7 @@ void run_vm(EngineState *s) {  			// Increment the global, local, temp or param variable and save it  			// to the accumulator, using the accumulator as an additional index  			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);  			if (r_temp.segment) {  				// Pointer arithmetics! @@ -2000,7 +1989,7 @@ void run_vm(EngineState *s) {  			// Increment the global, local, temp or param variable and save it  			// to the stack, using the accumulator as an additional index  			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);  			if (r_temp.segment) {  				// Pointer arithmetics! @@ -2053,7 +2042,7 @@ void run_vm(EngineState *s) {  			// Decrement the global, local, temp or param variable and save it  			// to the accumulator, using the accumulator as an additional index  			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);  			if (r_temp.segment) {  				// Pointer arithmetics! @@ -2070,7 +2059,7 @@ void run_vm(EngineState *s) {  			// Decrement the global, local, temp or param variable and save it  			// to the stack, using the accumulator as an additional index  			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);  			if (r_temp.segment) {  				// Pointer arithmetics! diff --git a/engines/sci/engine/vm_types.h b/engines/sci/engine/vm_types.h index edf35a122a..cc1f9b2685 100644 --- a/engines/sci/engine/vm_types.h +++ b/engines/sci/engine/vm_types.h @@ -56,6 +56,32 @@ struct reg_t {  	int16 toSint16() const {  		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) { diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp index 7adb0b4e04..faf7662ad6 100644 --- a/engines/sci/engine/workarounds.cpp +++ b/engines/sci/engine/workarounds.cpp @@ -136,6 +136,7 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = {  	// ^^ shouldn't be needed anymore, we got a script patch instead (kq5PatchCdHarpyVolume)  	{ GID_KQ5,            25,    25,  0,              "rm025", "doit",           -1,    0, { WORKAROUND_FAKE,   0 } }, // inside witch forest, when going to the room where the walking rock is  	{ GID_KQ5,            55,    55,  0,         "helpScript", "doit",           -1,    0, { WORKAROUND_FAKE,   0 } }, // when giving the tambourine to the monster in the labyrinth (only happens at one of the locations) - bug #3041262 +	{ GID_KQ5,            -1,   755,  0,              "gcWin", "open",           -1,   -1, { WORKAROUND_FAKE,   0 } }, // when entering control menu in the FM-Towns version  	{ GID_KQ6,            -1,    30,  0,               "rats", "changeState",    -1,   -1, { WORKAROUND_FAKE,   0 } }, // rats in the catacombs (temps 1 - 5) - bugs #3034597, #3035495, #3035824  	{ GID_KQ6,           210,   210,  0,              "rm210", "scriptCheck",    -1,    0, { WORKAROUND_FAKE,   1 } }, // using inventory in that room - bug #3034565  	{ GID_KQ6,           500,   500,  0,              "rm500", "init",           -1,    0, { WORKAROUND_FAKE,   0 } }, // going to island of the beast @@ -357,6 +358,7 @@ const SciWorkaroundEntry kGraphRedrawBox_workarounds[] = {  	{ GID_KQ5,            -1,   981,  0,           "myWindow",     "dispose",    -1,    0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when closing any dialog box, accidental additional parameter specified - bug #3036331  	{ GID_KQ5,            -1,   995,  0,               "invW",        "doit",    -1,    0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when closing the inventory window, accidental additional parameter specified  	{ GID_KQ5,            -1,   995,  0,                   "",    "export 0",    -1,    0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the floppy version, when opening the gem pouch, accidental additional parameter specified - bug #3039395 +	{ GID_KQ5,            -1,   403,  0,          "KQ5Window",     "dispose",    -1,    0, { WORKAROUND_STILLCALL, 0 } }, // Happens in the FM Towns version when closing any dialog box, accidental additional parameter specified  	SCI_WORKAROUNDENTRY_TERMINATOR  }; diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp index 0c17db6028..d607a5314f 100644 --- a/engines/sci/event.cpp +++ b/engines/sci/event.cpp @@ -36,31 +36,11 @@  namespace Sci {  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() {  } -bool EventManager::getUsesNewKeyboardDirectionType() { -	return _usesNewKeyboardDirectionType; -} -  struct ScancodeRow {  	int offset;  	const char *keys; diff --git a/engines/sci/event.h b/engines/sci/event.h index fade7dd337..7c83476294 100644 --- a/engines/sci/event.h +++ b/engines/sci/event.h @@ -116,7 +116,6 @@ public:  	void updateScreen();  	SciEvent getSciEvent(unsigned int mask); -	bool getUsesNewKeyboardDirectionType();  private:  	SciEvent getScummVMEvent(); @@ -124,8 +123,6 @@ private:  	const bool _fontIsExtended;  	int _modifierStates;  	Common::List<SciEvent> _events; - -	bool _usesNewKeyboardDirectionType;  };  } // End of namespace Sci diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 026a2ff405..ab4a2c9c1a 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -58,6 +58,12 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd  GfxFrameout::~GfxFrameout() {  } +void GfxFrameout::clear() { +	_screenItems.clear(); +	_planes.clear(); +	_planePictures.clear(); +} +  void GfxFrameout::kernelAddPlane(reg_t object) {  	PlaneEntry newPlane; diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h index 93d61ba22e..347ecb9424 100644 --- a/engines/sci/graphics/frameout.h +++ b/engines/sci/graphics/frameout.h @@ -28,6 +28,8 @@  namespace Sci { +class GfxPicture; +  struct PlaneEntry {  	reg_t object;  	uint16 priority; @@ -99,6 +101,7 @@ public:  	void addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX);  	void deletePlanePictures(reg_t object); +	void clear();  private:  	SegManager *_segMan; diff --git a/engines/sci/graphics/maciconbar.cpp b/engines/sci/graphics/maciconbar.cpp index 2ce17ab531..77491aa995 100644 --- a/engines/sci/graphics/maciconbar.cpp +++ b/engines/sci/graphics/maciconbar.cpp @@ -29,6 +29,7 @@  #include "sci/engine/state.h"  #include "sci/graphics/maciconbar.h"  #include "sci/graphics/palette.h" +#include "sci/graphics/screen.h"  #include "common/memstream.h"  #include "common/system.h" @@ -58,7 +59,8 @@ void GfxMacIconBar::drawIcons() {  		Graphics::Surface *surf = pict->decodeImage(stream, pal);  		remapColors(surf, pal); -		g_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, lastX, 200, MIN<uint32>(surf->w, 320 - lastX), surf->h); +		g_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, lastX, +				g_sci->_gfxScreen->getHeight() + 2, MIN<uint32>(surf->w, 320 - lastX), surf->h);  		lastX += surf->w;  		surf->free(); @@ -81,11 +83,7 @@ void GfxMacIconBar::remapColors(Graphics::Surface *surf, byte *palette) {  		byte g = palette[color * 4 + 1];  		byte b = palette[color * 4 + 2]; -		// For black, make sure the index is 0 -		if (r == 0 && g == 0 && b == 0) -			*pixels++ = 0; -		else -			*pixels++ = g_sci->_gfxPalette->kernelFindColor(r, g, b); +		*pixels++ = g_sci->_gfxPalette->findMacIconBarColor(r, g, b);  	}  } diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index b27b5f35a7..7a7f79b7af 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -69,6 +69,9 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen, bool useMergi  	_useMerging = useMerging;  	palVaryInit(); + +	_macClut = 0; +	loadMacIconBarPalette();  #ifdef ENABLE_SCI32  	_clutTable = 0; @@ -79,6 +82,8 @@ GfxPalette::~GfxPalette() {  	if (_palVaryResourceId != -1)  		palVaryRemoveTimer(); +	delete[] _macClut; +  #ifdef ENABLE_SCI32  	unloadClut();  #endif @@ -171,39 +176,42 @@ void GfxPalette::createFromData(byte *data, int bytesLeft, Palette *paletteOut)  // Will try to set amiga palette by using "spal" file. If not found, we return false  bool GfxPalette::setAmiga() {  	Common::File file; -	int curColor, byte1, byte2;  	if (file.open("spal")) { -		for (curColor = 0; curColor < 32; curColor++) { -			byte1 = file.readByte(); -			byte2 = file.readByte(); -			if ((byte1 == EOF) || (byte2 == EOF)) +		for (int curColor = 0; curColor < 32; curColor++) { +			byte byte1 = file.readByte(); +			byte byte2 = file.readByte(); + +			if (file.eos())  				error("Amiga palette file ends prematurely"); +  			_sysPalette.colors[curColor].used = 1;  			_sysPalette.colors[curColor].r = (byte1 & 0x0F) * 0x11;  			_sysPalette.colors[curColor].g = ((byte2 & 0xF0) >> 4) * 0x11;  			_sysPalette.colors[curColor].b = (byte2 & 0x0F) * 0x11;  		} -		file.close(); +  		// Directly set the palette, because setOnScreen() wont do a thing for amiga -		_screen->setPalette(&_sysPalette); +		copySysPaletteToScreen();  		return true;  	} +  	return false;  }  // Called from picture class, some amiga sci1 games set half of the palette  void GfxPalette::modifyAmigaPalette(byte *data) { -	int16 curColor, curPos = 0; -	byte byte1, byte2; -	for (curColor = 0; curColor < 16; curColor++) { -		byte1 = data[curPos++]; -		byte2 = data[curPos++]; +	int16 curPos = 0; + +	for (int curColor = 0; curColor < 16; curColor++) { +		byte byte1 = data[curPos++]; +		byte byte2 = data[curPos++];  		_sysPalette.colors[curColor].r = (byte1 & 0x0F) * 0x11;  		_sysPalette.colors[curColor].g = ((byte2 & 0xF0) >> 4) * 0x11;  		_sysPalette.colors[curColor].b = (byte2 & 0x0F) * 0x11;  	} -	_screen->setPalette(&_sysPalette); + +	copySysPaletteToScreen();  }  static byte blendColors(byte c1, byte c2) { @@ -297,19 +305,20 @@ bool GfxPalette::insert(Palette *newPalette, Palette *destPalette) {  			newPalette->mapping[i] = i;  		}  	} +  	// We don't update the timestamp for SCI1.1, it's only updated on kDrawPic calls  	return paletteChanged;  }  bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {  	uint16 res; -	int i,j;  	bool paletteChanged = false; -	// colors 0 (black) and 255 (white) are not affected by merging -	for (i = 1; i < 255; i++) { -		if (!newPalette->colors[i].used)// color is not used - so skip it +	for (int i = 1; i < 255; i++) { +		// skip unused colors +		if (!newPalette->colors[i].used)  			continue; +  		// forced palette merging or dest color is not used yet  		if (force || (!_sysPalette.colors[i].used)) {  			_sysPalette.colors[i].used = newPalette->colors[i].used; @@ -322,6 +331,7 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {  			newPalette->mapping[i] = i;  			continue;  		} +  		// is the same color already at the same position? -> match it directly w/o lookup  		//  this fixes games like lsl1demo/sq5 where the same rgb color exists multiple times and where we would  		//  otherwise match the wrong one (which would result into the pixels affected (or not) by palette changes) @@ -329,14 +339,18 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {  			newPalette->mapping[i] = i;  			continue;  		} +  		// check if exact color could be matched  		res = matchColor(newPalette->colors[i].r, newPalette->colors[i].g, newPalette->colors[i].b);  		if (res & 0x8000) { // exact match was found  			newPalette->mapping[i] = res & 0xFF;  			continue;  		} + +		int j = 1; +  		// no exact match - see if there is an unused color -		for (j = 1; j < 256; j++) +		for (; j < 256; j++) {  			if (!_sysPalette.colors[j].used) {  				_sysPalette.colors[j].used = newPalette->colors[i].used;  				_sysPalette.colors[j].r = newPalette->colors[i].r; @@ -346,6 +360,8 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {  				paletteChanged = true;  				break;  			} +		} +	  		// if still no luck - set an approximate color  		if (j == 256) {  			newPalette->mapping[i] = res & 0xFF; @@ -355,6 +371,7 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) {  	if (!forceRealMerge)  		_sysPalette.timestamp = g_system->getMillis() * 60 / 1000; +  	return paletteChanged;  } @@ -404,11 +421,36 @@ void GfxPalette::setOnScreen() {  	// We dont change palette at all times for amiga  	if (_resMan->isAmiga32color())  		return; -	_screen->setPalette(&_sysPalette); -	// Redraw the Mac SCI1.1 Icon bar every palette change -	if (g_sci->_gfxMacIconBar) -		g_sci->_gfxMacIconBar->drawIcons(); +	copySysPaletteToScreen(); +} + +static byte convertMacGammaToSCIGamma(int comp) { +	return (byte)sqrt(comp * 255); +} + +void GfxPalette::copySysPaletteToScreen() { +	// just copy palette to system +	byte bpal[4 * 256]; + +	// Get current palette, update it and put back +	g_system->getPaletteManager()->grabPalette(bpal, 0, 256); + +	for (int16 i = 0; i < 256; i++) { +		if (colorIsFromMacClut(i)) { +			// If we've got a Mac CLUT, override the SCI palette with its non-black colors +			bpal[i * 4    ] = convertMacGammaToSCIGamma(_macClut[i * 3    ]); +			bpal[i * 4 + 1] = convertMacGammaToSCIGamma(_macClut[i * 3 + 1]); +			bpal[i * 4 + 2] = convertMacGammaToSCIGamma(_macClut[i * 3 + 2]); +		} else if (_sysPalette.colors[i].used != 0) { +			// Otherwise, copy to the screen +			bpal[i * 4    ] = CLIP(_sysPalette.colors[i].r * _sysPalette.intensity[i] / 100, 0, 255); +			bpal[i * 4 + 1] = CLIP(_sysPalette.colors[i].g * _sysPalette.intensity[i] / 100, 0, 255); +			bpal[i * 4 + 2] = CLIP(_sysPalette.colors[i].b * _sysPalette.intensity[i] / 100, 0, 255); +		} +	} + +	g_system->getPaletteManager()->setPalette(bpal, 0, 256);  }  bool GfxPalette::kernelSetFromResource(GuiResourceId resourceId, bool force) { @@ -420,6 +462,7 @@ bool GfxPalette::kernelSetFromResource(GuiResourceId resourceId, bool force) {  		set(&palette, force);  		return true;  	} +  	return false;  } @@ -565,7 +608,16 @@ void GfxPalette::kernelAssertPalette(GuiResourceId resourceId) {  }  void GfxPalette::kernelSyncScreenPalette() { -	_screen->getPalette(&_sysPalette); +	// just copy palette to system +	byte bpal[4 * 256]; + +	// Get current palette, update it and put back +	g_system->getPaletteManager()->grabPalette(bpal, 0, 256); +	for (int16 i = 1; i < 255; i++) { +		_sysPalette.colors[i].r = bpal[i * 4]; +		_sysPalette.colors[i].g = bpal[i * 4 + 1]; +		_sysPalette.colors[i].b = bpal[i * 4 + 2]; +	}  }  // palVary @@ -795,6 +847,64 @@ void GfxPalette::palVaryProcess(int signal, bool setPalette) {  	}  } +byte GfxPalette::findMacIconBarColor(byte r, byte g, byte b) { +	// Find the best color for use with the Mac icon bar + +	// For black, always use 0 +	if (r == 0 && g == 0 && b == 0) +		return 0; + +	byte found = 0xFF; +	uint diff = 0xFFFFFFFF; + +	for (uint16 i = 1; i < 255; i++) { +		int dr = _macClut[i * 3    ] - r; +		int dg = _macClut[i * 3 + 1] - g; +		int db = _macClut[i * 3 + 2] - b; + +		// Use the largest difference. This is what the Mac Palette Manager does. +		uint cdiff = MAX<int>(ABS(dr), ABS(dg)); +		cdiff = MAX<int>(cdiff, ABS(db)); + +		if (cdiff == 0) +			return i; +		else if (cdiff < diff) { +			found = i; +			diff = cdiff; +		} +	} + +	return found; +} + +void GfxPalette::loadMacIconBarPalette() { +	if (!g_sci->hasMacIconBar()) +		return; + +	Common::SeekableReadStream *clutStream = g_sci->getMacExecutable()->getResource(MKID_BE('clut'), 150); + +	if (!clutStream) +		error("Could not find clut 150 for the Mac icon bar"); + +	clutStream->readUint32BE(); // seed +	clutStream->readUint16BE(); // flags +	uint16 colorCount = clutStream->readUint16BE() + 1; +	_macClut = new byte[colorCount * 3]; + +	for (uint16 i = 0; i < colorCount; i++) { +		clutStream->readUint16BE(); +		_macClut[i * 3    ] = clutStream->readUint16BE() >> 8; +		_macClut[i * 3 + 1] = clutStream->readUint16BE() >> 8; +		_macClut[i * 3 + 2] = clutStream->readUint16BE() >> 8; +	} + +	delete clutStream; +} + +bool GfxPalette::colorIsFromMacClut(byte index) { +	return index != 0 && _macClut && (_macClut[index * 3] != 0 || _macClut[index * 3 + 1] != 0 || _macClut[index * 3 + 1] != 0); +} +  #ifdef ENABLE_SCI32  bool GfxPalette::loadClut(uint16 clutId) { diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h index 84334a4a61..317401ac1f 100644 --- a/engines/sci/graphics/palette.h +++ b/engines/sci/graphics/palette.h @@ -56,6 +56,7 @@ public:  	void getSys(Palette *pal);  	void setOnScreen(); +	void copySysPaletteToScreen();  	void drewPicture(GuiResourceId pictureId); @@ -88,6 +89,9 @@ public:  	virtual void saveLoadWithSerializer(Common::Serializer &s);  	void palVarySaveLoadPalette(Common::Serializer &s, Palette *palette); +	byte findMacIconBarColor(byte r, byte g, byte b); +	bool colorIsFromMacClut(byte index); +  #ifdef ENABLE_SCI32  	bool loadClut(uint16 clutId);  	byte matchClutColor(uint16 color); @@ -119,6 +123,9 @@ private:  	uint16 _palVaryTicks;  	int _palVaryPaused;  	int _palVarySignal; + +	void loadMacIconBarPalette(); +	byte *_macClut;  #ifdef ENABLE_SCI32  	byte *_clutTable; diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 896ac0db22..a0f402f833 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -132,10 +132,12 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) {  	if (g_sci->hasMacIconBar()) {  		// For SCI1.1 Mac games with the custom icon bar, we need to expand the screen  		// to accommodate for the icon bar. Of course, both KQ6 and QFG1 VGA differ in size. +		// We add 2 to the height of the icon bar to add a buffer between the screen and the +		// icon bar (as did the original interpreter).  		if (g_sci->getGameId() == GID_KQ6) -			initGraphics(_displayWidth, _displayHeight + 26, _displayWidth > 320); +			initGraphics(_displayWidth, _displayHeight + 26 + 2, _displayWidth > 320);  		else if (g_sci->getGameId() == GID_FREDDYPHARKAS) -			initGraphics(_displayWidth, _displayHeight + 28, _displayWidth > 320); +			initGraphics(_displayWidth, _displayHeight + 28 + 2, _displayWidth > 320);  		else  			error("Unknown SCI1.1 Mac game");  	} else @@ -509,34 +511,6 @@ void GfxScreen::bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr) {  	}  } -void GfxScreen::getPalette(Palette *pal) { -	// just copy palette to system -	byte bpal[4 * 256]; -	// Get current palette, update it and put back -	g_system->getPaletteManager()->grabPalette(bpal, 0, 256); -	for (int16 i = 1; i < 255; i++) { -		pal->colors[i].r = bpal[i * 4]; -		pal->colors[i].g = bpal[i * 4 + 1]; -		pal->colors[i].b = bpal[i * 4 + 2]; -	} -} - -void GfxScreen::setPalette(Palette *pal) { -	// just copy palette to system -	byte bpal[4 * 256]; -	// Get current palette, update it and put back -	g_system->getPaletteManager()->grabPalette(bpal, 0, 256); -	for (int16 i = 0; i < 256; i++) { -		if (!pal->colors[i].used) -			continue; -		bpal[i * 4] = CLIP(pal->colors[i].r * pal->intensity[i] / 100, 0, 255); -		bpal[i * 4 + 1] = CLIP(pal->colors[i].g * pal->intensity[i] / 100, 0, 255); -		bpal[i * 4 + 2] = CLIP(pal->colors[i].b * pal->intensity[i] / 100, 0, 255); -		bpal[i * 4 + 3] = 100; -	} -	g_system->getPaletteManager()->setPalette(bpal, 0, 256); -} -  void GfxScreen::setVerticalShakePos(uint16 shakePos) {  	if (!_upscaledHires)  		g_system->setShakePos(shakePos); diff --git a/engines/sci/graphics/screen.h b/engines/sci/graphics/screen.h index b6898b905a..1d6b127adc 100644 --- a/engines/sci/graphics/screen.h +++ b/engines/sci/graphics/screen.h @@ -106,9 +106,6 @@ public:  	void bitsGetRect(byte *memoryPtr, Common::Rect *destRect);  	void bitsRestore(byte *memoryPtr); -	void getPalette(Palette *pal); -	void setPalette(Palette *pal); -  	void scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel = 1);  	void adjustToUpscaledCoordinates(int16 &y, int16 &x); diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp index b7b2bfb38e..e741f66fde 100644 --- a/engines/sci/graphics/transitions.cpp +++ b/engines/sci/graphics/transitions.cpp @@ -271,9 +271,8 @@ void GfxTransitions::doTransition(int16 number, bool blackoutFlag) {  }  void GfxTransitions::setNewPalette(bool blackoutFlag) { -	if (!blackoutFlag) -		if (_isVGA) -			_palette->setOnScreen(); +	if (!blackoutFlag && _isVGA) +		_palette->setOnScreen();  }  void GfxTransitions::setNewScreen(bool blackoutFlag) { @@ -312,11 +311,18 @@ void GfxTransitions::fadeOut() {  	g_system->getPaletteManager()->grabPalette(oldPalette, 0, 256);  	for (stepNr = 100; stepNr >= 0; stepNr -= 10) { -		for (colorNr = 1; colorNr < tillColorNr; colorNr++){ -			workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4] * stepNr / 100; -			workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100; -			workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100; +		for (colorNr = 1; colorNr < tillColorNr; colorNr++) { +			if (_palette->colorIsFromMacClut(colorNr)) { +				workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4]; +				workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1]; +				workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2]; +			} else { +				workPalette[colorNr * 4 + 0] = oldPalette[colorNr * 4] * stepNr / 100; +				workPalette[colorNr * 4 + 1] = oldPalette[colorNr * 4 + 1] * stepNr / 100; +				workPalette[colorNr * 4 + 2] = oldPalette[colorNr * 4 + 2] * stepNr / 100; +			}  		} +  		g_system->getPaletteManager()->setPalette(workPalette + 4, 1, 254);  		g_sci->getEngineState()->wait(2);  	} diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 8c8bc6d512..22d153a81c 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -38,6 +38,7 @@ namespace Sci {  enum {  	SCI0_RESMAP_ENTRIES_SIZE = 6,  	SCI1_RESMAP_ENTRIES_SIZE = 6, +	KQ5FMT_RESMAP_ENTRIES_SIZE = 7,  	SCI11_RESMAP_ENTRIES_SIZE = 5  }; @@ -1115,6 +1116,8 @@ const char *ResourceManager::versionDescription(ResVersion version) const {  		return "SCI0 / Early SCI1";  	case kResVersionSci1Middle:  		return "Middle SCI1"; +	case kResVersionKQ5FMT: +		return "KQ5 FM Towns";  	case kResVersionSci1Late:  		return "Late SCI1";  	case kResVersionSci11: @@ -1164,6 +1167,14 @@ ResVersion ResourceManager::detectMapVersion() {  	fileStream->seek(-4, SEEK_END);  	uint32 uEnd = fileStream->readUint32LE();  	if (uEnd == 0xFFFFFFFF) { +		// check if the last 7 bytes are all ff, indicating a KQ5 FM-Towns map +		fileStream->seek(-7, SEEK_END); +		fileStream->read(buff, 3); +		if (buff[0] == 0xff && buff[1] == 0xff && buff[2] == 0xff) { +			delete fileStream; +			return kResVersionKQ5FMT; +		} +  		// check if 0 or 01 - try to read resources in SCI0 format and see if exists  		fileStream->seek(0, SEEK_SET);  		while (fileStream->read(buff, 6) == 6 && !(buff[0] == 0xFF && buff[1] == 0xFF && buff[2] == 0xFF)) { @@ -1578,10 +1589,15 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {  	fileStream->seek(0, SEEK_SET); -	byte bMask = (_mapVersion == kResVersionSci1Middle) ? 0xF0 : 0xFC; -	byte bShift = (_mapVersion == kResVersionSci1Middle) ? 28 : 26; +	byte bMask = (_mapVersion >= kResVersionSci1Middle) ? 0xF0 : 0xFC; +	byte bShift = (_mapVersion >= kResVersionSci1Middle) ? 28 : 26;  	do { +		// King's Quest 5 FM-Towns uses a 7 byte version of the SCI1 Middle map, +		// splitting the type from the id. +		if (_mapVersion == kResVersionKQ5FMT) +			type = convertResType(fileStream->readByte()); +  		id = fileStream->readUint16LE();  		offset = fileStream->readUint32LE(); @@ -1590,11 +1606,17 @@ int ResourceManager::readResourceMapSCI0(ResourceSource *map) {  			warning("Error while reading %s", map->getLocationName().c_str());  			return SCI_ERROR_RESMAP_NOT_FOUND;  		} +	  		if (offset == 0xFFFFFFFF)  			break; -		type = convertResType(id >> 11); -		number = id & 0x7FF; +		if (_mapVersion == kResVersionKQ5FMT) { +			number = id; +		} else { +			type = convertResType(id >> 11); +			number = id & 0x7FF; +		} +  		ResourceId resId = ResourceId(type, number);  		// adding a new resource  		if (_resMap.contains(resId) == false) { @@ -2233,6 +2255,7 @@ void ResourceManager::detectSciVersion() {  		s_sciVersion = SCI_VERSION_1_EARLY;  		return;  	case kResVersionSci1Middle: +	case kResVersionKQ5FMT:  		s_sciVersion = SCI_VERSION_1_MIDDLE;  		return;  	case kResVersionSci1Late: diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 92749ba162..76b5a421ee 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -124,6 +124,7 @@ enum ResVersion {  	kResVersionUnknown,  	kResVersionSci0Sci1Early,  	kResVersionSci1Middle, +	kResVersionKQ5FMT,  	kResVersionSci1Late,  	kResVersionSci11,  	kResVersionSci11Mac, diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index c69e35df6d..7147b17b82 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -261,6 +261,9 @@ Common::Error SciEngine::run() {  	syncSoundSettings();  	syncIngameAudioOptions(); +	// Load our Mac executable here for icon bar palettes and high-res fonts +	loadMacExecutable(); +  	// Initialize all graphics related subsystems  	initGraphics(); @@ -857,4 +860,34 @@ void SciEngine::syncIngameAudioOptions() {  	}  } +void SciEngine::loadMacExecutable() { +	if (getPlatform() != Common::kPlatformMacintosh || getSciVersion() < SCI_VERSION_1_EARLY || getSciVersion() > SCI_VERSION_1_1) +		return; + +	Common::String filename; + +	switch (getGameId()) { +	case GID_KQ6: +		filename = "King's Quest VI"; +		break; +	case GID_FREDDYPHARKAS: +		filename = "Freddy Pharkas"; +		break; +	default: +		break; +	} + +	if (filename.empty()) +		return; + +	if (!_macExecutable.open(filename) || !_macExecutable.hasResFork()) { +		// KQ6/Freddy require the executable to load their icon bar palettes +		if (hasMacIconBar()) +			error("Could not load Mac resource fork '%s'", filename.c_str()); +		 +		// TODO: Show some sort of warning dialog saying they can't get any +		// high-res Mac fonts, when we get to that point ;) +	} +} +  } // End of namespace Sci diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 9404425af6..b3e398325f 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -27,6 +27,7 @@  #define SCI_H  #include "engines/engine.h" +#include "common/macresman.h"  #include "common/util.h"  #include "common/random.h"  #include "sci/engine/vm_types.h"	// for Selector @@ -323,6 +324,8 @@ public:  	DebugState _debugState; +	Common::MacResManager *getMacExecutable() { return &_macExecutable; } +  private:  	/**  	 * Initializes a SCI game @@ -349,6 +352,11 @@ private:  	 */  	void exitGame(); +	/** +	 * Loads the Mac executable for SCI1 games +	 */ +	void loadMacExecutable(); +  	void initStackBaseWithSelector(Selector selector);  	bool gameHasFanMadePatch(); @@ -366,6 +374,7 @@ private:  	reg_t _gameSuperClassAddress; // Address of the super class of the game object  	Console *_console;  	Common::RandomSource _rng; +	Common::MacResManager _macExecutable;  }; diff --git a/engines/sky/debug.cpp b/engines/sky/debug.cpp index b43ec917fe..2839665ff8 100644 --- a/engines/sky/debug.cpp +++ b/engines/sky/debug.cpp @@ -1071,11 +1071,11 @@ void Debug::logic(uint32 logic) {  void Debug::script(uint32 command, uint16 *scriptData) {  	debug(6, "SCRIPT: %s", opcodes[command]);  	if (command == 0 || command == 6) -		debug(6, " %s", scriptVars[READ_LE_UINT16(scriptData)/4]); +		debug(6, " %s", scriptVars[(*scriptData)/4]);  	else {  		int i;  		for (i = 0; i < opcode_par[command]; i++) { -			debug(6, " %d", READ_LE_UINT16(scriptData + i)); +			debug(6, " %d", *(scriptData + i));  		}  	}  	debug(6, " ");	// Print an empty line as separator diff --git a/engines/sky/intro.cpp b/engines/sky/intro.cpp index 6455f3b15b..cf1910c5b1 100644 --- a/engines/sky/intro.cpp +++ b/engines/sky/intro.cpp @@ -647,6 +647,7 @@ Intro::~Intro() {  	free(_textBuf);  	free(_saveBuf); +	_mixer->stopID(SOUND_BG);  	free(_bgBuf);  } @@ -917,12 +918,14 @@ bool Intro::escDelay(uint32 msecs) {  		nDelay = _relDelay - _system->getMillis();  		if (nDelay < 0)  			nDelay = 0; -		else if (nDelay > 10) -			nDelay = 10; +		else if (nDelay > 20) +			nDelay = 20; +  		_system->delayMillis(nDelay); +  		_skyScreen->processSequence();  		_system->updateScreen(); -	} while (nDelay == 10); +	} while (nDelay == 20);  	return true;  } diff --git a/engines/sky/screen.cpp b/engines/sky/screen.cpp index ab4ba1eb2a..dae158e41b 100644 --- a/engines/sky/screen.cpp +++ b/engines/sky/screen.cpp @@ -383,14 +383,14 @@ void Screen::waitForTick() {  	Common::Event event;  	while (true) { +		while (eventMan->pollEvent(event)) +			; +  		start = _system->getMillis();  		if (start >= end)  			return; -		while (eventMan->pollEvent(event)) -			; -  		remain = end - start;  		if (remain < 10) {  			_system->delayMillis(remain); @@ -408,7 +408,7 @@ void Screen::waitForSequence() {  	while (_seqInfo.running) {  		processSequence(); -		_system->delayMillis(10); +		_system->delayMillis(20);  		while (eventMan->pollEvent(event))  			;  	} @@ -416,20 +416,18 @@ void Screen::waitForSequence() {  void Screen::startSequence(uint16 fileNum) {  	_seqInfo.seqData = _skyDisk->loadFile(fileNum); -	_seqInfo.nextFrame = _system->getMillis(); +	_seqInfo.nextFrame = _system->getMillis() + 60;  	_seqInfo.framesLeft = _seqInfo.seqData[0];  	_seqInfo.seqDataPos = _seqInfo.seqData + 1; -	_seqInfo.delay = SEQ_DELAY;  	_seqInfo.running = true;  	_seqInfo.runningItem = false;  }  void Screen::startSequenceItem(uint16 itemNum) {  	_seqInfo.seqData = (uint8 *)SkyEngine::fetchItem(itemNum); -	_seqInfo.nextFrame = _system->getMillis(); +	_seqInfo.nextFrame = _system->getMillis() + 60;  	_seqInfo.framesLeft = _seqInfo.seqData[0] - 1;  	_seqInfo.seqDataPos = _seqInfo.seqData + 1; -	_seqInfo.delay = SEQ_DELAY;  	_seqInfo.running = true;  	_seqInfo.runningItem = true;  } @@ -450,75 +448,72 @@ void Screen::processSequence() {  	if (_system->getMillis() < _seqInfo.nextFrame)  		return; -	_seqInfo.delay--; -	if (_seqInfo.delay == 0) { -		_seqInfo.delay = SEQ_DELAY; -		_seqInfo.nextFrame += 20 * SEQ_DELAY; +	_seqInfo.nextFrame += 60; -		memset(_seqGrid, 0, 12 * 20); +	memset(_seqGrid, 0, 12 * 20); -		uint32 screenPos = 0; +	uint32 screenPos = 0; -		uint8 nrToSkip, nrToDo, cnt; +	uint8 nrToSkip, nrToDo, cnt; +	do {  		do { -			do { -				nrToSkip = _seqInfo.seqDataPos[0]; -				_seqInfo.seqDataPos++; -				screenPos += nrToSkip; -			} while (nrToSkip == 0xFF); +			nrToSkip = _seqInfo.seqDataPos[0]; +			_seqInfo.seqDataPos++; +			screenPos += nrToSkip; +		} while (nrToSkip == 0xFF); -			do { -				nrToDo = _seqInfo.seqDataPos[0]; -				_seqInfo.seqDataPos++; - -				uint8 gridSta = (uint8)((screenPos / (GAME_SCREEN_WIDTH * 16))*20 + ((screenPos % GAME_SCREEN_WIDTH) >> 4)); -				uint8 gridEnd = (uint8)(((screenPos+nrToDo) / (GAME_SCREEN_WIDTH * 16))*20 + (((screenPos+nrToDo) % GAME_SCREEN_WIDTH) >> 4)); -				gridSta = MIN(gridSta, (uint8)(12 * 20 - 1)); -				gridEnd = MIN(gridEnd, (uint8)(12 * 20 - 1)); -				if (gridEnd >= gridSta) -					for (cnt = gridSta; cnt <= gridEnd; cnt++) -						_seqGrid[cnt] = 1; -				else { -					for (cnt = gridSta; cnt < (gridSta / 20 + 1) * 20; cnt++) -						_seqGrid[cnt] = 1; -					for (cnt = (gridEnd / 20) * 20; cnt <= gridEnd; cnt++) -						_seqGrid[cnt] = 1; -				} +		do { +			nrToDo = _seqInfo.seqDataPos[0]; +			_seqInfo.seqDataPos++; + +			uint8 gridSta = (uint8)((screenPos / (GAME_SCREEN_WIDTH * 16))*20 + ((screenPos % GAME_SCREEN_WIDTH) >> 4)); +			uint8 gridEnd = (uint8)(((screenPos+nrToDo) / (GAME_SCREEN_WIDTH * 16))*20 + (((screenPos+nrToDo) % GAME_SCREEN_WIDTH) >> 4)); +			gridSta = MIN(gridSta, (uint8)(12 * 20 - 1)); +			gridEnd = MIN(gridEnd, (uint8)(12 * 20 - 1)); +			if (gridEnd >= gridSta) +				for (cnt = gridSta; cnt <= gridEnd; cnt++) +					_seqGrid[cnt] = 1; +			else { +				for (cnt = gridSta; cnt < (gridSta / 20 + 1) * 20; cnt++) +					_seqGrid[cnt] = 1; +				for (cnt = (gridEnd / 20) * 20; cnt <= gridEnd; cnt++) +					_seqGrid[cnt] = 1; +			} -				for (cnt = 0; cnt < nrToDo; cnt++) { -					_currentScreen[screenPos] = _seqInfo.seqDataPos[0]; -					_seqInfo.seqDataPos++; -					screenPos++; -				} -			} while (nrToDo == 0xFF); -		} while (screenPos < (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT)); -		uint8 *gridPtr = _seqGrid; uint8 *scrPtr = _currentScreen; uint8 *rectPtr = NULL; -		uint8 rectWid = 0, rectX = 0, rectY = 0; -		for (uint8 cnty = 0; cnty < 12; cnty++) { -			for (uint8 cntx = 0; cntx < 20; cntx++) { -				if (*gridPtr) { -					if (!rectWid) { -						rectX = cntx; -						rectY = cnty; -						rectPtr = scrPtr; -					} -					rectWid++; -				} else if (rectWid) { -					_system->copyRectToScreen(rectPtr, GAME_SCREEN_WIDTH, rectX << 4, rectY << 4, rectWid << 4, 16); -					rectWid = 0; -				} -				scrPtr += 16; -				gridPtr++; +			for (cnt = 0; cnt < nrToDo; cnt++) { +				_currentScreen[screenPos] = _seqInfo.seqDataPos[0]; +				_seqInfo.seqDataPos++; +				screenPos++;  			} -			if (rectWid) { +		} while (nrToDo == 0xFF); +	} while (screenPos < (GAME_SCREEN_WIDTH * GAME_SCREEN_HEIGHT)); +	uint8 *gridPtr = _seqGrid; uint8 *scrPtr = _currentScreen; uint8 *rectPtr = NULL; +	uint8 rectWid = 0, rectX = 0, rectY = 0; +	for (uint8 cnty = 0; cnty < 12; cnty++) { +		for (uint8 cntx = 0; cntx < 20; cntx++) { +			if (*gridPtr) { +				if (!rectWid) { +					rectX = cntx; +					rectY = cnty; +					rectPtr = scrPtr; +				} +				rectWid++; +			} else if (rectWid) {  				_system->copyRectToScreen(rectPtr, GAME_SCREEN_WIDTH, rectX << 4, rectY << 4, rectWid << 4, 16);  				rectWid = 0;  			} -			scrPtr += 15 * GAME_SCREEN_WIDTH; +			scrPtr += 16; +			gridPtr++;  		} -		_system->updateScreen(); -		_seqInfo.framesLeft--; +		if (rectWid) { +			_system->copyRectToScreen(rectPtr, GAME_SCREEN_WIDTH, rectX << 4, rectY << 4, rectWid << 4, 16); +			rectWid = 0; +		} +		scrPtr += 15 * GAME_SCREEN_WIDTH;  	} +	_system->updateScreen(); +	_seqInfo.framesLeft--; +  	if (_seqInfo.framesLeft == 0) {  		_seqInfo.running = false;  		if (!_seqInfo.runningItem) diff --git a/engines/sky/screen.h b/engines/sky/screen.h index 048f5c1e3e..5310aebeee 100644 --- a/engines/sky/screen.h +++ b/engines/sky/screen.h @@ -46,7 +46,6 @@ struct DataFileHeader;  #define SCROLL_JUMP		16  #define VGA_COLOURS		256  #define GAME_COLOURS		240 -#define SEQ_DELAY 3  #define FORE 1  #define BACK 0 @@ -114,7 +113,6 @@ private:  	struct {  		uint32 nextFrame;  		uint32 framesLeft; -		uint32 delay;  		uint8 *seqData;  		uint8 *seqDataPos;  		volatile bool running; diff --git a/engines/toon/state.cpp b/engines/toon/state.cpp index 71674688d5..f676a65025 100644 --- a/engines/toon/state.cpp +++ b/engines/toon/state.cpp @@ -54,7 +54,7 @@ void Location::load(Common::ReadStream *stream) {  }  State::State(void) { -	for (int32 i = 0; i < 64; i++) { +	for (int32 i = 0; i < 256; i++) {  		_locations[i]._visited = false;  		_locations[i]._numSceneAnimations = 0;  		_locations[i]._numRifBoxes = 0; @@ -80,6 +80,7 @@ State::State(void) {  	_showConversationIcons = false; +	_inMenu = false;  	_inCloseUp = false;  	_inConversation = false; diff --git a/engines/toon/state.h b/engines/toon/state.h index 283e378443..d31ff4f3c2 100644 --- a/engines/toon/state.h +++ b/engines/toon/state.h @@ -62,6 +62,7 @@ public:  	int16 _confiscatedInventory[35];  	int32 _numInventoryItems;  	int32 _numConfiscatedInventoryItems; +	bool _inMenu;  	bool _inCloseUp;  	bool _inCutaway;  	bool _inConversation; diff --git a/engines/toon/text.cpp b/engines/toon/text.cpp index c54ea87d50..f0d17dd34e 100644 --- a/engines/toon/text.cpp +++ b/engines/toon/text.cpp @@ -57,7 +57,7 @@ int32 TextResource::getNext(int32 offset) {  	uint16 *table = (uint16 *)_textData + 1;  	int a = getId(offset); -	return table[a+1]; +	return READ_LE_UINT16(table + a + 1);  }  int32 TextResource::getId(int32 offset) { @@ -66,7 +66,7 @@ int32 TextResource::getId(int32 offset) {  	uint16 *table = (uint16 *)_textData + 1;  	int32 found = -1;  	for (int32 i = 0; i < _numTexts; i++) { -		if (offset == table[i]) { +		if (offset == READ_LE_UINT16(table + i)) {  			found = i;  			break;  		} @@ -80,7 +80,7 @@ char *TextResource::getText(int32 offset) {  	uint16 *table = (uint16 *)_textData + 1;  	int32 found = -1;  	for (int32 i = 0; i < _numTexts; i++) { -		if (offset == table[i]) { +		if (offset == READ_LE_UINT16(table + i)) {  			found = i;  			break;  		} @@ -88,7 +88,7 @@ char *TextResource::getText(int32 offset) {  	if (found < 0)  		return NULL; -	int32 realOffset = ((uint16 *)_textData + 1 + _numTexts)[found]; +	int32 realOffset = READ_LE_UINT16((uint16 *)_textData + 1 + _numTexts + found);  	return (char *)_textData + realOffset;  } diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 79e153a7db..d2b98c2ed0 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -185,7 +185,7 @@ void ToonEngine::parseInput() {  		bool hasModifier = event.kbd.hasFlags(Common::KBD_ALT|Common::KBD_CTRL|Common::KBD_SHIFT);  		switch (event.type) { -		case Common::EVENT_KEYUP: +		case Common::EVENT_KEYDOWN:  			if ((event.kbd.ascii == 27 || event.kbd.ascii == 32) && !hasModifier) {  				_audioManager->stopCurrentVoice();  			} @@ -588,6 +588,8 @@ bool ToonEngine::showMainmenu(bool &loadedGame) {  	AudioStreamInstance *mainmenuMusic = NULL;  	bool musicPlaying = false; +	_gameState->_inMenu = true; +  	while (!doExit) {  		clickingOn = MAINMENUHOTSPOT_NONE;  		clickRelease = false; @@ -700,6 +702,8 @@ bool ToonEngine::showMainmenu(bool &loadedGame) {  		}  	} +	_gameState->_inMenu = false; +  	//delete mainmenuMusic;  	for (int entryNr = 0; entryNr < MAINMENU_ENTRYCOUNT; entryNr++)  		delete entries[entryNr].animation; @@ -2956,11 +2960,11 @@ void ToonEngine::pauseEngineIntern(bool pause) {  }  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() { -	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) { diff --git a/engines/touche/opcodes.cpp b/engines/touche/opcodes.cpp index b2b16eb29d..5df0ca3548 100644 --- a/engines/touche/opcodes.cpp +++ b/engines/touche/opcodes.cpp @@ -41,7 +41,7 @@ void ToucheEngine::setupOpcodes() {  		&ToucheEngine::op_true,  		&ToucheEngine::op_false,  		&ToucheEngine::op_push, -		&ToucheEngine::op_testFalse, +		&ToucheEngine::op_not,  		/* 0x08 */  		&ToucheEngine::op_add,  		&ToucheEngine::op_sub, @@ -51,7 +51,7 @@ void ToucheEngine::setupOpcodes() {  		&ToucheEngine::op_mod,  		&ToucheEngine::op_and,  		&ToucheEngine::op_or, -		&ToucheEngine::op_not, +		&ToucheEngine::op_neg,  		/* 0x10 */  		&ToucheEngine::op_testGreater,  		&ToucheEngine::op_testEquals, @@ -250,8 +250,8 @@ void ToucheEngine::op_push() {  	*_script.stackDataPtr = 0;  } -void ToucheEngine::op_testFalse() { -	debugC(9, kDebugOpcodes, "ToucheEngine::op_testFalse()"); +void ToucheEngine::op_not() { +	debugC(9, kDebugOpcodes, "ToucheEngine::op_not()");  	if (*_script.stackDataPtr == 0) {  		*_script.stackDataPtr = -1;  	} else { @@ -309,8 +309,8 @@ void ToucheEngine::op_or() {  	*_script.stackDataPtr |= val;  } -void ToucheEngine::op_not() { -	debugC(9, kDebugOpcodes, "ToucheEngine::op_not()"); +void ToucheEngine::op_neg() { +	debugC(9, kDebugOpcodes, "ToucheEngine::op_neg()");  	uint16 val = *_script.stackDataPtr;  	*_script.stackDataPtr = ~val;  } diff --git a/engines/touche/touche.h b/engines/touche/touche.h index 50a5c6e439..8b5f14d926 100644 --- a/engines/touche/touche.h +++ b/engines/touche/touche.h @@ -531,7 +531,7 @@ protected:  	void op_true();  	void op_false();  	void op_push(); -	void op_testFalse(); +	void op_not();  	void op_add();  	void op_sub();  	void op_mul(); @@ -539,7 +539,7 @@ protected:  	void op_mod();  	void op_and();  	void op_or(); -	void op_not(); +	void op_neg();  	void op_testGreater();  	void op_testEquals();  	void op_testLower(); diff --git a/engines/tucker/graphics.cpp b/engines/tucker/graphics.cpp index 52018d25e6..163719197d 100644 --- a/engines/tucker/graphics.cpp +++ b/engines/tucker/graphics.cpp @@ -112,7 +112,7 @@ void Graphics::decodeRLE_224(uint8 *dst, const uint8 *src, int w, int h) {  	}  } -void Graphics::decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip) { +void Graphics::decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip, bool color248Only) {  	int code = 0;  	int color = 0;  	for (int y = 0; y < h; ++y) { @@ -125,7 +125,7 @@ void Graphics::decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1,  				}  			}  			if (color != 0) { -				if ((dst[offset] < 0xE0 || y + y1 < y2) && dst[offset] < 0xF8) { +				if ((color248Only || dst[offset] < 0xE0 || y + y1 < y2) && dst[offset] < 0xF8) {  					dst[offset] = color;  				}  			} else { diff --git a/engines/tucker/graphics.h b/engines/tucker/graphics.h index 60c66f519e..c5b723e632 100644 --- a/engines/tucker/graphics.h +++ b/engines/tucker/graphics.h @@ -52,7 +52,7 @@ public:  	static void decodeRLE(uint8 *dst, const uint8 *src, int w, int h);  	static void decodeRLE_224(uint8 *dst, const uint8 *src, int w, int h); -	static void decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip); +	static void decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip, bool color248Only = false);  	static void decodeRLE_320(uint8 *dst, const uint8 *src, int w, int h);  	static void copyRect(uint8 *dst, int dstPitch, uint8 *src, int srcPitch, int w, int h); diff --git a/engines/tucker/locations.cpp b/engines/tucker/locations.cpp index 009695e8aa..416f2ba36e 100644 --- a/engines/tucker/locations.cpp +++ b/engines/tucker/locations.cpp @@ -660,7 +660,7 @@ void TuckerEngine::execData3PostUpdate_locationNum8() {  				_locationBackgroundGfxBuf[offset + 640 * j + i] = colorsTable[(j - 1) * 3  + i + 1];  			}  		} -		addDirtyRect(_updateLocationXPosTable2[0] - 1, _updateLocationYPosTable2[0] + 1, 3, 4); +		addDirtyRect(_updateLocationXPosTable2[0] - 1, _updateLocationYPosTable2[0], 3, 4);  		_updateLocationYPosTable2[0] += 2;  		if (_updateLocationYPosTable2[0] > 120) {  			_updateLocationYPosTable2[0] = 0; @@ -676,7 +676,7 @@ void TuckerEngine::execData3PostUpdate_locationNum8() {  void TuckerEngine::updateSprite_locationNum9_0(int i) {  	if (_charSpeechSoundCounter > 0 && _actionCharacterNum == 0) { -		_spritesTable[0].needUpdate = 1; +		_spritesTable[i].needUpdate = 1;  		_spritesTable[i].state = 3;  	} else if (_updateLocationCounter2 > 0 || getRandomNumber() > 30000) {  		_spritesTable[i].state = 1; @@ -974,7 +974,7 @@ void TuckerEngine::updateSprite_locationNum14(int i) {  }  void TuckerEngine::execData3PreUpdate_locationNum14() { -	if (_yPosCurrent >= 126) +	if (_yPosCurrent >= 127)  		return;  	if (!isSoundPlaying(0)) { @@ -1021,7 +1021,7 @@ void TuckerEngine::execData3PreUpdate_locationNum14() {  }  void TuckerEngine::execData3PreUpdate_locationNum14Helper1(int i) { -	const int y = 1872; // FIXME: bug, 187/182 ? +	const int y = 117 * 16;  	if (_updateLocation14ObjNum[i] == 0) {  		if (getRandomNumber() <= 30000) {  			return; @@ -1031,9 +1031,8 @@ void TuckerEngine::execData3PreUpdate_locationNum14Helper1(int i) {  		_updateLocation14Step[i] = -55 - getRandomNumber() / 512;  		_updateLocation14ObjNum[i] = 231;  		_updateLocation14Delay[i] = 16 + getRandomNumber() / 2048; -		// FIXME: bug, missing return ?  	} -	_updateLocation14Step[i] = 4; +	_updateLocation14Step[i] += 4;  	_updateLocationYPosTable2[i] += _updateLocation14Step[i];  	if (_updateLocationYPosTable2[i] > y) {  		_updateLocationYPosTable2[i] = y; diff --git a/engines/tucker/resource.cpp b/engines/tucker/resource.cpp index 6b6ab1e600..d96b8a35d1 100644 --- a/engines/tucker/resource.cpp +++ b/engines/tucker/resource.cpp @@ -393,16 +393,16 @@ void TuckerEngine::loadBudSpr(int startOffset) {  			switch (_flagsTable[137]) {  			case 0:  				if ((_gameFlags & kGameFlagDemo) != 0) { -					sprintf(filename, "budl00_%d.pcx", frame + 1); +					snprintf(filename, sizeof(filename), "budl00_%d.pcx", frame + 1);  				} else { -					sprintf(filename, "bud_%d.pcx", frame + 1); +					snprintf(filename, sizeof(filename), "bud_%d.pcx", frame + 1);  				}  				break;  			case 1: -				sprintf(filename, "peg_%d.pcx", frame + 1); +				snprintf(filename, sizeof(filename), "peg_%d.pcx", frame + 1);  				break;  			default: -				sprintf(filename, "mac_%d.pcx", frame + 1); +				snprintf(filename, sizeof(filename), "mac_%d.pcx", frame + 1);  				break;  			}  			loadImage(filename, _loadTempBuf, 0); @@ -483,25 +483,25 @@ void TuckerEngine::loadLoc() {  	int i = _locationWidthTable[_locationNum];  	_locationHeight = (_locationNum < 73) ? 140 : 200; -	sprintf(filename, (i == 1) ? "loc%02d.pcx" : "loc%02da.pcx", _locationNum); +	snprintf(filename, sizeof(filename), (i == 1) ? "loc%02d.pcx" : "loc%02da.pcx", _locationNum);  	copyLocBitmap(filename, 0, false);  	Graphics::copyRect(_quadBackgroundGfxBuf, 320, _locationBackgroundGfxBuf, 640, 320, _locationHeight);  	if (_locationHeight == 200) {  		return;  	} -	sprintf(filename, (i != 2) ? "path%02d.pcx" : "path%02da.pcx", _locationNum); +	snprintf(filename, sizeof(filename), (i != 2) ? "path%02d.pcx" : "path%02da.pcx", _locationNum);  	copyLocBitmap(filename, 0, true);  	if (i > 1) { -		sprintf(filename, "loc%02db.pcx", _locationNum); +		snprintf(filename, sizeof(filename), "loc%02db.pcx", _locationNum);  		copyLocBitmap(filename, 320, false);  		Graphics::copyRect(_quadBackgroundGfxBuf + 44800, 320, _locationBackgroundGfxBuf + 320, 640, 320, _locationHeight);  		if (i == 2) { -			sprintf(filename, "path%02db.pcx", _locationNum); +			snprintf(filename, sizeof(filename), "path%02db.pcx", _locationNum);  			copyLocBitmap(filename, 320, true);  		}  	}  	if (i > 2) { -		sprintf(filename, "loc%02dc.pcx", _locationNum); +		snprintf(filename, sizeof(filename), "loc%02dc.pcx", _locationNum);  		copyLocBitmap(filename, 0, false);  		Graphics::copyRect(_quadBackgroundGfxBuf + 89600, 320, _locationBackgroundGfxBuf, 640, 320, 140);  	} @@ -510,7 +510,7 @@ void TuckerEngine::loadLoc() {  		loadImage("rochpath.pcx", _loadLocBufPtr, 0);  	}  	if (i > 3) { -		sprintf(filename, "loc%02dd.pcx", _locationNum); +		snprintf(filename, sizeof(filename), "loc%02dd.pcx", _locationNum);  		copyLocBitmap(filename, 0, false);  		Graphics::copyRect(_quadBackgroundGfxBuf + 134400, 320, _locationBackgroundGfxBuf + 320, 640, 320, 140);  	} @@ -541,10 +541,10 @@ void TuckerEngine::loadObj() {  	_currentPartNum = _partNum;  	char filename[40]; -	sprintf(filename, "objtxt%d.c", _partNum); +	snprintf(filename, sizeof(filename), "objtxt%d.c", _partNum);  	free(_objTxtBuf);  	_objTxtBuf = loadFile(filename, 0); -	sprintf(filename, "pt%dtext.c", _partNum); +	snprintf(filename, sizeof(filename), "pt%dtext.c", _partNum);  	free(_ptTextBuf);  	_ptTextBuf = loadFile(filename, 0);  	_characterSpeechDataPtr = _ptTextBuf; @@ -585,7 +585,7 @@ void TuckerEngine::loadData() {  	int offset = 0;  	for (int i = 0; i < count; ++i) {  		char filename[40]; -		sprintf(filename, "scrobj%d%d.pcx", _partNum, i); +		snprintf(filename, sizeof(filename), "scrobj%d%d.pcx", _partNum, i);  		loadImage(filename, _loadTempBuf, 0);  		offset = loadDataHelper(offset, i);  	} @@ -604,7 +604,7 @@ int TuckerEngine::loadDataHelper(int offset, int index) {  void TuckerEngine::loadPanObj() {  	char filename[40]; -	sprintf(filename, "panobjs%d.pcx", _partNum); +	snprintf(filename, sizeof(filename), "panobjs%d.pcx", _partNum);  	loadImage(filename, _loadTempBuf, 0);  	int offset = 0;  	for (int y = 0; y < 5; ++y) { @@ -813,7 +813,7 @@ void TuckerEngine::loadSprA02_01() {  	const int count = _sprA02LookupTable[_locationNum];  	for (int i = 1; i < count + 1; ++i) {  		char filename[40]; -		sprintf(filename, "sprites/a%02d_%02d.spr", _locationNum, i); +		snprintf(filename, sizeof(filename), "sprites/a%02d_%02d.spr", _locationNum, i);  		_sprA02Table[i] = loadFile(filename, 0);  	}  	_sprA02Table[0] = _sprA02Table[1]; @@ -832,7 +832,7 @@ void TuckerEngine::loadSprC02_01() {  	const int count = _sprC02LookupTable[_locationNum];  	for (int i = 1; i < count + 1; ++i) {  		char filename[40]; -		sprintf(filename, "sprites/c%02d_%02d.spr", _locationNum, i); +		snprintf(filename, sizeof(filename), "sprites/c%02d_%02d.spr", _locationNum, i);  		_sprC02Table[i] = loadFile(filename, 0);  	}  	_sprC02Table[0] = _sprC02Table[1]; diff --git a/engines/tucker/sequences.cpp b/engines/tucker/sequences.cpp index 73018b8c00..a655d5b456 100644 --- a/engines/tucker/sequences.cpp +++ b/engines/tucker/sequences.cpp @@ -119,7 +119,7 @@ void TuckerEngine::handleCreditsSequence() {  			char filename[40];  			if (num == 6) {  				for (int i = 0; i < 16; ++i) { -					sprintf(filename, "cogs%04d.pcx", i + 1); +					snprintf(filename, sizeof(filename), "cogs%04d.pcx", i + 1);  					loadImage(filename, imgBuf + i * 64000, 2);  				}  			} else { diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp index c61a4228c6..766172c87f 100644 --- a/engines/tucker/tucker.cpp +++ b/engines/tucker/tucker.cpp @@ -556,13 +556,7 @@ void TuckerEngine::mainLoop() {  		if (_inputKeys[kInputKeyToggleTextSpeech]) {  			_inputKeys[kInputKeyToggleTextSpeech] = false;  			if ((_gameFlags & kGameFlagNoSubtitles) == 0) { -				if (_displaySpeechText) { -					_displaySpeechText = false; -//					kDefaultCharSpeechSoundCounter = 1; -				} else { -					_displaySpeechText = true; -//					kDefaultCharSpeechSoundCounter = 70; -				} +				_displaySpeechText = !_displaySpeechText;  				ConfMan.setBool("subtitles", _displaySpeechText);  			}  		} @@ -674,8 +668,8 @@ void TuckerEngine::updateCursorPos(int x, int y) {  void TuckerEngine::setCursorNum(int num) {  	_cursorNum = num; -	const int cursorW = 16; -	const int cursorH = 16; +	static const int cursorW = 16; +	static const int cursorH = 16;  	CursorMan.replaceCursor(_cursorGfxBuf + _cursorNum * 256, cursorW, cursorH, 1, 1, 0);  } @@ -952,7 +946,6 @@ void TuckerEngine::fadeOutPalette(int colorsCount) {  	}  	_system->getPaletteManager()->setPalette(pal, 0, colorsCount);  	_system->updateScreen(); -	waitForTimer(1);  }  void TuckerEngine::fadeInPalette(int colorsCount) { @@ -966,7 +959,6 @@ void TuckerEngine::fadeInPalette(int colorsCount) {  	}  	_system->getPaletteManager()->setPalette(pal, 0, colorsCount);  	_system->updateScreen(); -	waitForTimer(1);  }  void TuckerEngine::fadePaletteColor(int color, int step) { @@ -1098,17 +1090,15 @@ void TuckerEngine::stopSounds() {  }  void TuckerEngine::playSounds() { -	for (int i = 0; i < 29; ++i) { -		if (i < _locationSoundsCount) { -			if (_locationSoundsTable[i].type == 1 || _locationSoundsTable[i].type == 2 || _locationSoundsTable[i].type == 5 || -				(_locationSoundsTable[i].type == 7 && _flagsTable[_locationSoundsTable[i].flagNum] == _locationSoundsTable[i].flagValueStartFx)) { -				startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume); -			} +	for (int i = 0; i < _locationSoundsCount; ++i) { +		if (_locationSoundsTable[i].type == 1 || _locationSoundsTable[i].type == 2 || _locationSoundsTable[i].type == 5 || +			(_locationSoundsTable[i].type == 7 && _flagsTable[_locationSoundsTable[i].flagNum] == _locationSoundsTable[i].flagValueStartFx)) { +			startSound(_locationSoundsTable[i].offset, i, _locationSoundsTable[i].volume);  		} -		if (i < _locationMusicsCount) { -			if (_locationMusicsTable[i].flag > 0) { -				startMusic(_locationMusicsTable[i].offset, i, _locationMusicsTable[i].volume); -			} +	} +	for (int i = 0; i < _locationMusicsCount; ++i) { +		if (_locationMusicsTable[i].flag > 0) { +			startMusic(_locationMusicsTable[i].offset, i, _locationMusicsTable[i].volume);  		}  	}  } @@ -1430,7 +1420,6 @@ void TuckerEngine::redrawPanelOverBackground() {  }  void TuckerEngine::drawConversationTexts() { -	int x = 0;  	int y = 141;  	int flag = 0;  	for (int i = 0; i <  _conversationOptionsCount; ++i) { @@ -1438,7 +1427,7 @@ void TuckerEngine::drawConversationTexts() {  		if ((_mousePosY > y && _mousePosY < y + 11) || _nextTableToLoadIndex == i) {  			color = 106;  		} -		drawSpeechText(x, y, _characterSpeechDataPtr, _instructionsActionsTable[i], color); +		drawSpeechText(0, y, _characterSpeechDataPtr, _instructionsActionsTable[i], color);  		if (_mousePosY > y && _mousePosY < _conversationOptionLinesCount * 10 + y + 1) {  			_nextTableToLoadIndex = i;  			flag = 1; @@ -1757,6 +1746,8 @@ void TuckerEngine::drawCurrentSprite() {  	if ((_locationNum == 17 || _locationNum == 18) && _currentSpriteAnimationFrame == 16) {  		return;  	} +	// Workaround original game glitch: location 14 contains some colors from [0xE0-0xF8] in a walkable area (tracker item #3106542) +	const bool color248Only = (_locationNum == 14);  	SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame];  	int yPos = _yPosCurrent + _mainSpritesBaseOffset - 54 + chr->yOffset;  	int xPos = _xPosCurrent; @@ -1766,7 +1757,7 @@ void TuckerEngine::drawCurrentSprite() {  		xPos -= chr->xSize + chr->xOffset - 14;  	}  	Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr->sourceOffset, chr->xSize, chr->ySize, -		chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0); +		chr->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0, color248Only);  	addDirtyRect(xPos, yPos, chr->xSize, chr->ySize);  	if (_currentSpriteAnimationLength > 1) {  		SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2]; @@ -1778,7 +1769,7 @@ void TuckerEngine::drawCurrentSprite() {  			xPos -= chr2->xSize + chr2->xOffset - 14;  		}  		Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr2->sourceOffset, chr2->xSize, chr2->ySize, -			chr2->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0); +			chr2->yOffset, _locationHeightTable[_locationNum], _mirroredDrawing != 0, color248Only);  		addDirtyRect(xPos, yPos, chr2->xSize, chr2->ySize);  	}  } @@ -1929,7 +1920,9 @@ void TuckerEngine::drawSprite(int num) {  			Graphics::decodeRLE_248(dstPtr, srcPtr, srcW, srcH, 0, s->yMaxBackground, s->flipX != 0);  			break;  		} -		addDirtyRect(xPos, srcY, srcW, srcH); +		const int xR = srcX + (s->gfxBackgroundOffset % 640); +		const int yR = srcY + (s->gfxBackgroundOffset / 640); +		addDirtyRect(xR, yR, srcW, srcH);  	}  } @@ -2891,7 +2884,11 @@ void TuckerEngine::updateCharSpeechSound(bool displayText) {  	if (_charSpeechSoundCounter == 0) {  		return;  	} -	--_charSpeechSoundCounter; +	if (_displaySpeechText) { +		_charSpeechSoundCounter = 0; +	} else { +		--_charSpeechSoundCounter; +	}  	if (_charSpeechSoundCounter == 0) {  		_charSpeechSoundCounter = isSpeechSoundPlaying() ? 1 : 0;  		if (_charSpeechSoundCounter == 0) { diff --git a/tools/skycpt/cptcompiler.cpp b/tools/skycpt/cptcompiler.cpp index 956f575d7d..7453b383b6 100644 --- a/tools/skycpt/cptcompiler.cpp +++ b/tools/skycpt/cptcompiler.cpp @@ -362,6 +362,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *  				fwrite(&tmp, 2, 1, resOutf);  			}  		} +		printf("DEBUG lcnt: %lu Output File Position: 0x%08lX\r\n", lcnt, ftell(debOutf));  	}  	cptSize[0] = ftell(debOutf) - cptSize[0];  	cptSize[1] = ftell(resOutf) - cptSize[1]; @@ -390,6 +391,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *  		fwrite(dlinks + cnt * 2 + 1, 2, 1, resOutf);  	}  	printf("Processing diff data...\n"); +	printf("DEBUG Output File Position: 0x%08lX\r\n", ftell(debOutf));  	// 288 diffdata  	FILE *dif = fopen("288diff.txt", "r");  	assert(dif); @@ -448,6 +450,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *  	fwrite(diff, 2, diffDest, resOutf);  	printf("Converting Save data...\n"); +	printf("DEBUG Output File Position: 0x%08lX\r\n", ftell(debOutf));  	// the IDs of the compacts to be saved  	char cptName[1024];  	uint16 saveIds[2048]; @@ -503,6 +506,8 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *  		fwrite(&tmp, 2, 1, debOutf);  		tmp = 0;  		fwrite(&tmp, 2, 1, debOutf); +		 +		printf("DEBUG Output File Position: 0x%08lX\r\n", ftell(debOutf));  		printf("reset destination: %ld\n", ftell(debOutf));  		for (int cnt = 0; cnt < 6; cnt++) {  			printf("Processing diff v0.0%03d\n", gameVers[cnt]); @@ -527,6 +532,7 @@ void doCompile(FILE *inf, FILE *debOutf, FILE *resOutf, TextFile *cptDef, FILE *  			fwrite(&diffPos, 1, 2, debOutf);  			fwrite(diff, 2, 2 * diffPos, debOutf);  			printf("diff v0.0%03d: 2 * 2 * %d\n", gameVers[cnt], diffPos); +			printf("DEBUG Output File Position: 0x%08lX\r\n", ftell(debOutf));  		}  		free(buf288);  	} else { diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 6944fd5a77..a277d6bbde 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -820,19 +820,25 @@ int QuickTimeDecoder::readTKHD(MOVatom atom) {  // edit list atom  int QuickTimeDecoder::readELST(MOVatom atom) { +	MOVStreamContext *st = _streams[_numStreams - 1]; +  	_fd->readByte(); // version  	_fd->readByte(); _fd->readByte(); _fd->readByte(); // flags -	uint32 editCount = _streams[_numStreams - 1]->edit_count = _fd->readUint32BE();	 // entries -	for (uint32 i = 0; i < editCount; i++){ -		_fd->readUint32BE(); // Track duration -		_fd->readUint32BE(); // Media time -		_fd->readUint32BE(); // Media rate -	} +	st->editCount = _fd->readUint32BE(); +	st->editList = new EditListEntry[st->editCount]; -	debug(0, "track[%i].edit_count = %i", _numStreams - 1, _streams[_numStreams - 1]->edit_count); +	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 ="); +	} -	if (editCount != 1) +	if (st->editCount != 1)  		warning("Multiple edit list entries. Things may go awry");  	return 0; @@ -863,7 +869,7 @@ int QuickTimeDecoder::readHDLR(MOVatom atom) {  	else if (type == MKID_BE('soun'))  		st->codec_type = CODEC_TYPE_AUDIO; -	_fd->readUint32BE(); // component  manufacture +	_fd->readUint32BE(); // component manufacture  	_fd->readUint32BE(); // component flags  	_fd->readUint32BE(); // component flags mask @@ -1465,12 +1471,30 @@ QuickTimeDecoder::STSDEntry::~STSDEntry() {  }  QuickTimeDecoder::MOVStreamContext::MOVStreamContext() { -	// FIXME: Setting all members to 0 via memset is a hack -- it works -	// because the only non-POD member of MOVStreamContext is of type -	// Common::Rational, and that luckily has no virtual methods nor -	// does it keep internal pointers or anything like that. But watch -	// out if you ever extend MOVStreamContext! -	memset(this, 0, sizeof(MOVStreamContext)); +	chunk_count = 0; +	chunk_offsets = 0; +	stts_count = 0; +	stts_data = 0; +	sample_to_chunk_sz = 0; +	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() { @@ -1480,6 +1504,7 @@ QuickTimeDecoder::MOVStreamContext::~MOVStreamContext() {  	delete[] sample_sizes;  	delete[] keyframes;  	delete[] stsdEntries; +	delete[] editList;  	delete extradata;  } diff --git a/video/qt_decoder.h b/video/qt_decoder.h index 809c8a718d..e876097dfd 100644 --- a/video/qt_decoder.h +++ b/video/qt_decoder.h @@ -149,6 +149,12 @@ private:  		uint32 id;  	}; +	struct EditListEntry { +		uint32 trackDuration; +		int32 mediaTime; +		Common::Rational mediaRate; +	}; +  	struct STSDEntry {  		STSDEntry();  		~STSDEntry(); @@ -183,7 +189,6 @@ private:  		uint32 *chunk_offsets;  		int stts_count;  		MOVstts *stts_data; -		int edit_count; /* number of 'edit' (elst atom) */  		uint32 sample_to_chunk_sz;  		MOVstsc *sample_to_chunk;  		uint32 sample_size; @@ -201,6 +206,9 @@ private:  		uint32 stsdEntryCount;  		STSDEntry *stsdEntries; +		uint32 editCount; +		EditListEntry *editList; +  		Common::SeekableReadStream *extradata;  		uint32 nb_frames;  | 
