diff options
| -rw-r--r-- | engines/kyra/chargen.cpp | 39 | ||||
| -rw-r--r-- | engines/kyra/debugger.cpp | 6 | ||||
| -rw-r--r-- | engines/kyra/debugger.h | 12 | ||||
| -rw-r--r-- | engines/kyra/eob1.h | 2 | ||||
| -rw-r--r-- | engines/kyra/eob2.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/eobcommon.cpp | 19 | ||||
| -rw-r--r-- | engines/kyra/eobcommon.h | 1 | ||||
| -rw-r--r-- | engines/kyra/items_eob.cpp | 2 | ||||
| -rw-r--r-- | engines/kyra/saveload_eob.cpp | 6 | ||||
| -rw-r--r-- | engines/kyra/scene_eob.cpp | 8 | ||||
| -rw-r--r-- | engines/kyra/script_eob.cpp | 83 | ||||
| -rw-r--r-- | engines/kyra/script_eob.h | 4 | ||||
| -rw-r--r-- | engines/kyra/sequences_eob1.cpp | 36 | ||||
| -rw-r--r-- | engines/kyra/sequences_eob2.cpp | 10 | ||||
| -rw-r--r-- | engines/kyra/sound_lol.cpp | 6 | ||||
| -rw-r--r-- | engines/kyra/sprites_eob.cpp | 4 | ||||
| -rw-r--r-- | engines/kyra/timer_eob.cpp | 9 | 
17 files changed, 179 insertions, 70 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp index 7516916f67..0e38ffec3d 100644 --- a/engines/kyra/chargen.cpp +++ b/engines/kyra/chargen.cpp @@ -47,6 +47,7 @@ private:  	int raceSexMenu();  	int classMenu(int raceSex);  	int alignmentMenu(int cClass); +	int getInput(Button *buttonList);  	void updateMagicShapes();  	void generateStats(int index);  	void modifyMenu(); @@ -153,8 +154,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) {  	_characters = characters;  	_faceShapes = *faceShapes; -	_vm->sound()->playTrack(0); - +	_vm->snd_stopSound();  	_vm->delay(_vm->_tickLength);  	init(); @@ -169,8 +169,7 @@ bool CharacterGenerator::start(EobCharacter *characters, uint8 ***faceShapes) {  	for (bool loop = true; loop && (!_vm->shouldQuit()); ) {  		_vm->_gui->updateBoxFrameHighLight(_activeBox + 6); -		_vm->sound()->process(); -		int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); +		int inputFlag = getInput(_vm->_activeButtons);		  		_vm->removeInputTop();  		if (inputFlag) { @@ -381,9 +380,7 @@ int CharacterGenerator::viewDeleteCharacter() {  	int res = 0;  	for (bool loop = true; loop && _characters[_activeBox].name[0] && !_vm->shouldQuit(); ) {  		_vm->_gui->updateBoxFrameHighLight(_activeBox + 6); -		_vm->sound()->process(); - -		int inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); +		int inputFlag =getInput(_vm->_activeButtons);  		int cbx = _activeBox;  		_vm->removeInputTop(); @@ -520,8 +517,7 @@ int CharacterGenerator::classMenu(int raceSex) {  	while (res == -1 && !_vm->shouldQuit()) {  		updateMagicShapes(); - -		int in = _vm->checkInput(0, false, 0) & 0xff; +		int in = getInput(_vm->_activeButtons) & 0xff;  		Common::Point mp = _vm->getMousePos();  		if (in == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_b]) { @@ -569,8 +565,7 @@ int CharacterGenerator::alignmentMenu(int cClass) {  	while (res == -1 && !_vm->shouldQuit()) {  		updateMagicShapes(); - -		int in = _vm->checkInput(0, false, 0) & 0xff; +		int in = getInput(_vm->_activeButtons) & 0xff;  		Common::Point mp = _vm->getMousePos();  		if (in == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_ESCAPE] || _vm->_gui->_menuLastInFlags == _vm->_keyMap[Common::KEYCODE_b]) { @@ -593,9 +588,21 @@ int CharacterGenerator::alignmentMenu(int cClass) {  	return res;  } -void CharacterGenerator::updateMagicShapes() { -	_vm->sound()->process(); +int CharacterGenerator::getInput(Button *buttonList) { +	if (_vm->game() == GI_EOB1 && _vm->sound()->checkTrigger()) { +		_vm->sound()->resetTrigger(); +		_vm->sound()->playTrack(20); +	// WORKAROUND for EOB II: The original implements the same sound trigger check as in EOB I. +	// However, Westwood seems to have forgotten to set the trigger at the end of the AdLib song, +	// so that the music will not loop. We simply check whether the sound driver is still playing. +	} else if (_vm->game() == GI_EOB2 && !_vm->sound()->isPlaying()) { +		_vm->delay(3 * _vm->_tickLength); +		_vm->sound()->playTrack(13); +	} +	return _vm->checkInput(buttonList, false, 0); +} +void CharacterGenerator::updateMagicShapes() {  	if (_magicShapesBox != _activeBox) {  		_chargenMagicShapeTimer = 0;  		_magicShapesBox = _activeBox; @@ -719,7 +726,7 @@ void CharacterGenerator::statsAndFacesMenu() {  	while (!in && !_vm->shouldQuit()) {  		updateMagicShapes(); -		in = _vm->checkInput(_vm->_activeButtons, false, 0); +		in = getInput(_vm->_activeButtons);  		_vm->removeInputTop();  		if (in == 0x8001) { @@ -786,7 +793,7 @@ void CharacterGenerator::faceSelectMenu() {  		while (!in && !_vm->shouldQuit()) {  			updateMagicShapes(); -			in = _vm->checkInput(_vm->_activeButtons, false, 0); +			in = getInput(_vm->_activeButtons);  			_vm->removeInputTop();  			_vm->_gui->updateBoxFrameHighLight(box + 10); @@ -978,7 +985,7 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {  	for (bool loop = true; loop && !_vm->shouldQuit(); ) {  		uint8 v1 = *s1;  		updateMagicShapes(); -		int	inputFlag = _vm->checkInput(_vm->_activeButtons, false, 0); +		int	inputFlag = getInput(_vm->_activeButtons);  		_vm->removeInputTop();  		if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_MINUS] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP_MINUS] || inputFlag == 0x8009) { diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp index 35b4d8ba7f..6a4b88c77a 100644 --- a/engines/kyra/debugger.cpp +++ b/engines/kyra/debugger.cpp @@ -26,6 +26,7 @@  #include "kyra/timer.h"  #include "kyra/resource.h"  #include "kyra/lol.h" +#include "kyra/eobcommon.h"  #include "common/system.h" @@ -470,4 +471,9 @@ Debugger_LoL::Debugger_LoL(LoLEngine *vm) : Debugger(vm), _vm(vm) {  }  #endif // ENABLE_LOL +#ifdef ENABLE_EOB +Debugger_Eob::Debugger_Eob(EobCoreEngine *vm) : Debugger(vm), _vm(vm) { +} +#endif // ENABLE_EOB +  } // End of namespace Kyra diff --git a/engines/kyra/debugger.h b/engines/kyra/debugger.h index e9c0a6a98a..1bd8363612 100644 --- a/engines/kyra/debugger.h +++ b/engines/kyra/debugger.h @@ -108,6 +108,18 @@ protected:  };  #endif // ENABLE_LOL +#ifdef ENABLE_EOB +class EobCoreEngine; + +class Debugger_Eob : public Debugger { +public: +	Debugger_Eob(EobCoreEngine *vm); + +protected: +	EobCoreEngine *_vm; +}; +#endif // ENABLE_EOB +  } // End of namespace Kyra  #endif diff --git a/engines/kyra/eob1.h b/engines/kyra/eob1.h index 227db4f916..8811d7d92a 100644 --- a/engines/kyra/eob1.h +++ b/engines/kyra/eob1.h @@ -65,8 +65,8 @@ private:  	void seq_xdeath(); +	void loadSetIntroPalette(const char *filename);  	void copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step); -  	void boxMorphTransition(int targetDestX, int targetDestY, int targetFinalX, int targetFinalY, int targetSrcX, int targetSrcY, int targetFinalW, int targetFinalH, int originX1, int originY1, int originW, int originH);  	void whirlTransition(); diff --git a/engines/kyra/eob2.cpp b/engines/kyra/eob2.cpp index d9aad0ce3d..f309fae2aa 100644 --- a/engines/kyra/eob2.cpp +++ b/engines/kyra/eob2.cpp @@ -115,7 +115,7 @@ void DarkMoonEngine::runNpcDialogue(int npcIndex) {  		int r = runDialogue(-1, 0, _npc1Strings[0], _npc1Strings[1], 0) - 1;  		if (r == 0) { -			_sound->playTrack(0); +			snd_stopSound();  			delay(3 * _tickLength);  			snd_playSoundEffect(91);  			npcJoinDialogue(1, 5, 6, 7); diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index fbd8ef62e1..802907eba5 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -27,6 +27,7 @@  #include "kyra/sound_intern.h"  #include "kyra/script_eob.h"  #include "kyra/timer.h" +#include "kyra/debugger.h"  #include "common/config-manager.h" @@ -40,6 +41,7 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa  	_teleporterWallId(flags.gameID == GI_EOB1 ? 52 : 44) {  	_screen = 0;  	_gui = 0; +	_debugger = 0;  	_playFinale = false;  	_runFlag = true; @@ -220,8 +222,11 @@ EobCoreEngine::~EobCoreEngine() {  	_menuDefs = 0;  	delete _inf; +	_inf = 0;  	delete _timer;  	_timer = 0; +	delete _debugger; +	_debugger = 0;  }  Common::Error EobCoreEngine::init() { @@ -241,6 +246,7 @@ Common::Error EobCoreEngine::init() {  	//MidiDriverType midiDriver = MidiDriver::detectDevice(MDT_PCSPK | MDT_ADLIB);  	_sound = new SoundAdLibPC(this, _mixer); +	_sound->init();  	assert(_sound);  	if (_sound) @@ -266,8 +272,13 @@ Common::Error EobCoreEngine::init() {  	setupKeyMap();  	_gui = new GUI_Eob(this); +	assert(_gui);  	_txt = new TextDisplayer_Eob(this, _screen); +	assert(_txt);  	_inf = new EobInfProcessor(this, _screen); +	assert(_inf); +	_debugger = new Debugger_Eob(this); +	assert(_debugger);  	_screen->loadFont(Screen::FID_6_FNT, "FONT6.FNT");  	_screen->loadFont(Screen::FID_8_FNT, "FONT8.FNT"); @@ -682,7 +693,7 @@ void EobCoreEngine::setHandItem(Item itemIndex) {  	int icon = _items[_itemInHand].icon;  	const uint8 *shp = _itemIconShapes[icon]; -	if (icon && (_items[_itemInHand].flags & 0x80) && ((_flags.gameID == GI_EOB2 && (_partyEffectFlags & 2)) || (_flags.gameID == GI_EOB1 && (_partyEffectFlags & 0x10000)))) { +	if (icon && (_items[_itemInHand].flags & 0x80) && (_partyEffectFlags & 2)) {  		memcpy(_tempIconShape, shp, 300);  		if (_flags.gameID == GI_EOB1)  			_screen->replaceShapePalette(_tempIconShape, &_itemsOverlay[icon << 4]); @@ -1246,7 +1257,7 @@ void EobCoreEngine::initDialogueSequence() {  	gui_updateControls();  	//_allowSkip = true; -	_sound->playTrack(0); +	snd_stopSound();  	Common::SeekableReadStream *s = _res->createReadStream("TEXT.DAT");  	_screen->loadFileDataToPage(s, 5, 32000);  	_txt->setupField(9, 0); @@ -2246,6 +2257,10 @@ void EobCoreEngine::snd_playSoundEffect(int id, int volume) {  	_sound->playSoundEffect(id, volume);  } +void EobCoreEngine::snd_stopSound() { +	_sound->playSoundEffect(0); +} +  }	// End of namespace Kyra  #endif // ENABLE_EOB diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index 7ab933390e..fcfc29f766 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -1139,6 +1139,7 @@ protected:  	// sound  	void snd_playSoundEffect(int id, int volume=0xFF); +	void snd_stopSound();  };  }	// End of namespace Kyra diff --git a/engines/kyra/items_eob.cpp b/engines/kyra/items_eob.cpp index e3309f830d..96b19a9f93 100644 --- a/engines/kyra/items_eob.cpp +++ b/engines/kyra/items_eob.cpp @@ -303,7 +303,7 @@ int EobCoreEngine::countQueuedItems(Item itemQueue, int16 id, int16 type, int co  		EobItem *itm = &_items[o1];  		forceLoop = false;  		if (id != -1 || type != -1) { -			if (((id != -1 ) || (id == -1 && type != itm->type)) && ((type != -1) || (type == -1 && id != o1))) +			if (((id != -1) || (id == -1 && type != itm->type)) && ((type != -1) || (type == -1 && id != o1)))  				continue;			  		} diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp index 49c6668abf..07841be1e4 100644 --- a/engines/kyra/saveload_eob.cpp +++ b/engines/kyra/saveload_eob.cpp @@ -411,9 +411,13 @@ Common::Error EobCoreEngine::saveGameStateIntern(int slot, const char *saveName,  	completeDoorOperations();  	generateTempData(); +	advanceTimers(_restPartyElapsedTime); +	_restPartyElapsedTime = 0; -	for (int i = 0; i < 6; i++) { +	for (int i = 0; i < 6; i++)  		timerSpecialCharacterUpdate(0x30 + i); + +	for (int i = 0; i < 6; i++) {  		EobCharacter *c = &_characters[i];  		out->writeByte(c->id); diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp index 5f06139f3f..cf20429e2c 100644 --- a/engines/kyra/scene_eob.cpp +++ b/engines/kyra/scene_eob.cpp @@ -708,8 +708,6 @@ Common::String EobCoreEngine::initLevelData(int sub){  	int slen = (_flags.gameID == GI_EOB1) ? 12 : 13; -	_sound->playTrack(0); -  	for (int i = 0; i < sub; i++)  		pos = data + READ_LE_UINT16(pos); @@ -762,7 +760,7 @@ Common::String EobCoreEngine::initLevelData(int sub){  	}  	if (_flags.gameID == GI_EOB2) { -		delay(_tickLength); +		delay(3 * _tickLength);  		_sound->loadSoundFile((const char*) pos);  		pos += 13;  	} @@ -1029,10 +1027,8 @@ void EobCoreEngine::drawScene(int refresh) {  		}  	} -	if (_sceneDefaultUpdate) { +	if (_sceneDefaultUpdate)  		delayUntil(_drawSceneTimer); -		removeInputTop(); -	}  	if (refresh && !_partyResting)  		_screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK); diff --git a/engines/kyra/script_eob.cpp b/engines/kyra/script_eob.cpp index 6522731751..e85b1dc11a 100644 --- a/engines/kyra/script_eob.cpp +++ b/engines/kyra/script_eob.cpp @@ -133,7 +133,7 @@ EobInfProcessor::EobInfProcessor(EobCoreEngine *engine, Screen_Eob *screen) : _v  	_preventRest = 0;  	_lastScriptFunc = 0; -	_lastScriptSub = 0; +	_lastScriptFlags = 0;  	_subroutineStack = new int8*[10];  	memset(_subroutineStack, 0, 10 * sizeof(int8*)); @@ -171,7 +171,7 @@ void EobInfProcessor::loadData(const uint8 *data, uint32 dataSize) {  	memcpy(_scriptData, data, _scriptSize);  } -void EobInfProcessor::run(int func, int sub) { +void EobInfProcessor::run(int func, int flags) {  	int o = _vm->_levelBlockProperties[func].assignedObjects;  	if (!o)  		return; @@ -179,7 +179,7 @@ void EobInfProcessor::run(int func, int sub) {  	uint16 f = _vm->_levelBlockProperties[func].flags;  	uint16 subFlags = ((f & 0xfff8) >> 3) | 0xe0; -	if (!(sub & subFlags)) +	if (!(flags & subFlags))  		return;  	_abortScript = 0; @@ -188,9 +188,7 @@ void EobInfProcessor::run(int func, int sub) {  	_activeCharacter = -1;  	_lastScriptFunc = func; -	_lastScriptSub = sub; - -	_vm->resetSkipFlag(true); +	_lastScriptFlags = flags;  	int8 *pos = (int8*)(_scriptData + o); @@ -198,7 +196,7 @@ void EobInfProcessor::run(int func, int sub) {  		int8 cmd = *pos++;  		if (cmd <= _commandMin || cmd >= 0)  			continue; -		debugC(5, kDebugLevelScript, "[0x%.08X] EobInfProcessor::%s()", (uint32)(pos - _scriptData), _opcodes[-(cmd + 1)]->desc.c_str()); +		debugC(3, kDebugLevelScript, "[0x%.04X] EobInfProcessor::%s()", (uint32)(pos - _scriptData), _opcodes[-(cmd + 1)]->desc.c_str());  		pos += (*_opcodes[-(cmd + 1)]->proc)(pos);  	} while (!_abortScript && !_abortAfterSubroutine);  } @@ -379,21 +377,23 @@ int EobInfProcessor::oeob_movePartyOrObject(int8 *data) {  				continue;  			_vm->placeMonster(&_vm->_monsters[i], d, _vm->_monsters[i].pos);  		} +		debugC(5, kDebugLevelScript, "         - move monsters on block '0x%.04X' to block '0x%.04X'", c, d);  	} else if (a == -24) {  		// move party to block d  		int ba = _dlgResult;  		int bb = _lastScriptFunc; -		int bc = _lastScriptSub; +		int bc = _lastScriptFlags;  		int bd = _abortScript;  		int be = _activeCharacter;  		int bf = _subroutineStackPos;  		_vm->moveParty(d); +		debugC(5, kDebugLevelScript, "         - move party to block '0x%.04X'", d);  		_dlgResult = ba;  		_lastScriptFunc = bb; -		_lastScriptSub = bc; +		_lastScriptFlags = bc;  		_abortScript = bd;  		_activeCharacter = be;  		if (!_abortAfterSubroutine) @@ -447,6 +447,7 @@ int EobInfProcessor::oeob_movePartyOrObject(int8 *data) {  				_vm->_items[i].block = d;  			}  		} +		debugC(5, kDebugLevelScript, "         - move items from level '%d', block '0x%.04X' to level '%d', block '0x%.04X'", c, e, d, f);  	}  	_vm->_sceneUpdateRequired = true; @@ -550,24 +551,29 @@ int EobInfProcessor::oeob_setFlags(int8 *data) {  	switch (*pos++) {  	case -47:  		_preventRest = 0; +		debugC(5, kDebugLevelScript, "         - set preventRest to 0");  		break;  	case -28:  		_dlgResult = 1; +		debugC(5, kDebugLevelScript, "         - set dlgResult to 1");  		break;  	case -17:  		_flagTable[_vm->_currentLevel] |= (1 << (*pos++)); +		debugC(5, kDebugLevelScript, "         - set level flag '%d' for current level (current level = '%d')", *(pos - 1), _vm->_currentLevel);  		break;  	case -16:  		_flagTable[17] |= (1 << (*pos++)); +		debugC(5, kDebugLevelScript, "         - set global flag '%d'", *(pos - 1));  		break;  	case -13:  		b = *pos++;  		_vm->_monsters[b].flags |= (1 << (*pos++));  		_vm->_monsters[b].mode = 0; +		debugC(5, kDebugLevelScript, "         - set monster flag '%d' for monster '%d'", *(pos - 1), b);  		break;  	default: @@ -598,18 +604,22 @@ int EobInfProcessor::oeob_removeFlags(int8 *data) {  	switch (a) {  	case -47:  		_preventRest = 1; +		debugC(5, kDebugLevelScript, "         - set preventRest to 1");  		break;  	case -28:  		_dlgResult = 0; +		debugC(5, kDebugLevelScript, "         - set dlgResult to 0");  		break;  	case -17:  		_flagTable[_vm->_currentLevel] &= ~(1 << (*pos++)); +		debugC(5, kDebugLevelScript, "         - clear level flag '%d' for current level (current level = '%d')", *(pos - 1), _vm->_currentLevel);  		break;  	case -16:  		_flagTable[17] &= ~(1 << (*pos++)); +		debugC(5, kDebugLevelScript, "         - clear global flag '%d'", *(pos - 1));  		break;  	default: @@ -724,10 +734,12 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  				break;  			}  			_stack[_stackIndex++] = a; +			debugC(5, kDebugLevelScript, "         - check if whole party is invisible - PUSH result: '%d'", a);  			break; -		case 1: +		case 1:			  			_stack[_stackIndex++] = _vm->rollDice(pos[0], pos[1], pos[2]); +			debugC(9, kDebugLevelScript, "         - throw dice(s): num = '%d', pips = '%d', offset = '%d' - PUSH result: '%d'", pos[0], pos[1], pos[2], _stack[_stackIndex - 1]);  			pos += 3;  			break; @@ -743,6 +755,7 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  				}  			}  			_stack[_stackIndex++] = b; +			debugC(5, kDebugLevelScript, "         - check if character with class flags '0x%.02X' is present - PUSH result: '%d'", cmd, b);  			break;  		case 3: @@ -757,10 +770,12 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  				}  			}  			_stack[_stackIndex++] = b; +			debugC(5, kDebugLevelScript, "         - check if character with race '%d' is present - PUSH result: '%d'", cmd, b);  			break;  		case 6: -			_stack[_stackIndex++] = _lastScriptSub; +			_stack[_stackIndex++] = _lastScriptFlags; +			debugC(5, kDebugLevelScript, "         - get script execution flags - PUSH result: '%d'", _lastScriptFlags);  			break;  		case 13: @@ -768,37 +783,45 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  			switch (*pos++) {  			case -31:  				_stack[_stackIndex++] = itm->type; +				debugC(5, kDebugLevelScript, "         - get hand item type (hand item number = '%d') - PUSH result: '%d'", _vm->_itemInHand, itm->type);  				break;  			case -11:  				_stack[_stackIndex++] = _vm->_itemInHand; +				debugC(5, kDebugLevelScript, "         - get hand item number - PUSH result: '%d'", _vm->_itemInHand);  				break;  			default:  				_stack[_stackIndex++] = itm->value; +				debugC(5, kDebugLevelScript, "         - get hand item value (hand item number = '%d') - PUSH result: '%d'", _vm->_itemInHand, itm->value);  				break;  			}  			break;  		case 15:  			_stack[_stackIndex++] = _vm->_levelBlockProperties[READ_LE_UINT16(pos + 1)].walls[pos[0]]; +			debugC(5, kDebugLevelScript, "         - get wall index for block '0x%.04X', direction '%d' - PUSH result: '%d'", READ_LE_UINT16(pos + 1), pos[0], _stack[_stackIndex - 1]);  			pos += 3;  			break;  		case 19:  			_stack[_stackIndex++] = _vm->_currentDirection; +			debugC(5, kDebugLevelScript, "         - get current direction - PUSH result: '%d'", _vm->_currentDirection);  			break;  		case 21:  			_stack[_stackIndex++] = (_flagTable[_vm->_currentLevel] & (1 << (*pos++))) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - test level flag '%d' (current level = '%d') - PUSH result: '%d'", *(pos - 1), _vm->_currentLevel, _stack[_stackIndex - 1]);  			break;  		case 22:  			_stack[_stackIndex++] = (_flagTable[17] & (1 << (*pos++))) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - test global flag '%d' - PUSH result: '%d'", *(pos - 1), _stack[_stackIndex - 1]);  			break;  		case 23:  			_stack[_stackIndex++] = (_vm->_currentBlock == READ_LE_UINT16(pos)) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - compare current block with block '0x%.04X' (current block = '0x%.04X') - PUSH result: '%d'", _vm->_currentBlock, READ_LE_UINT16(pos), _stack[_stackIndex - 1]);  			pos += 2;  			break; @@ -808,10 +831,12 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  			b = READ_LE_UINT16(pos);  			pos += 2;  			_stack[_stackIndex++] = _vm->countQueuedItems(_vm->_levelBlockProperties[b].drawObjects, a, -1, 0, 1); +			debugC(5, kDebugLevelScript, "         - find item number '%d' on block '0x%.04X' - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 25:  			_stack[_stackIndex++] = (_vm->_levelBlockProperties[READ_LE_UINT16(pos)].flags & 1) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - test block flag '1' for block '0x%.04X' - PUSH result: '%d'", READ_LE_UINT16(pos), _stack[_stackIndex - 1]);  			pos += 2;  			break; @@ -820,10 +845,12 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  			i = READ_LE_UINT16(pos);  			pos += 2;  			_stack[_stackIndex++] = _vm->countQueuedItems(_vm->_levelBlockProperties[i].drawObjects, -1, b, 1, 1); +			debugC(5, kDebugLevelScript, "         - count items of type '%d' on block '0x%.04X' - PUSH result: '%d'", b, i, _stack[_stackIndex - 1]);  			break;  		case 29:  			_stack[_stackIndex++] = _vm->_levelBlockProperties[READ_LE_UINT16(pos)].walls[0]; +			debugC(5, kDebugLevelScript, "         - get wall index 0 for block '0x%.04X' - PUSH result: '%d'", READ_LE_UINT16(pos), _stack[_stackIndex - 1]);  			pos += 2;  			break; @@ -831,54 +858,63 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a || b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') || POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 31:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a && b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') && POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 32:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a <= b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') <= POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 33:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a < b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') < POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 34:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a >= b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') >= POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 35:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a > b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') > POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 36:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a != b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') != POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		case 37:  			a = _stack[--_stackIndex];  			b = _stack[--_stackIndex];  			_stack[_stackIndex++] = (a == b) ? 1 : 0; +			debugC(5, kDebugLevelScript, "         - evaluate: POP('%d') == POP('%d') - PUSH result: '%d'", a, b, _stack[_stackIndex - 1]);  			break;  		default:  			a = cmd;  			if (a >= 0 && a < 128)  				_stack[_stackIndex++] = a; +			debugC(5, kDebugLevelScript, "         - PUSH value: '%d'", a);  			break;  		}  		cmd = *pos++; @@ -889,6 +925,7 @@ int EobInfProcessor::oeob_eval_v1(int8 *data) {  		pos += 2;  	else  		pos = _scriptData + READ_LE_UINT16(pos); +	debugC(5, kDebugLevelScript, "         - conditional jump depending on POP('%d')", cmd);  	return pos - data;  } @@ -1005,7 +1042,7 @@ int EobInfProcessor::oeob_eval_v2(int8 *data) {  			break;  		case 18: -			_stack[_stackIndex++] = _lastScriptSub; +			_stack[_stackIndex++] = _lastScriptFlags;  			break;  		case 22: @@ -1193,10 +1230,13 @@ int EobInfProcessor::oeob_eval_v2(int8 *data) {  int EobInfProcessor::oeob_deleteItem(int8 *data) {  	int8 *pos = data;  	int8 c = *pos++; +  	if (c == -1) {  		_vm->deleteInventoryItem(0, -1); +		debugC(5, kDebugLevelScript, "         - delete hand item");  	} else {  		_vm->deleteBlockItem(READ_LE_UINT16(pos), (c == -2) ? -1 : c); +		debugC(5, kDebugLevelScript, "         - delete item(s) of type '%d' on block '0x%.04X'", (c == -2) ? -1 : c, READ_LE_UINT16(pos));  		pos += 2;  	} @@ -1239,6 +1279,7 @@ int EobInfProcessor::oeob_loadNewLevelOrMonsters(int8 *data) {  		_screen->setScreenDim(7);  		_vm->loadLevel(index, cmd); +		debugC(5, kDebugLevelScript, "         - entering level '%d', sub level '%d', start block '0x%.04X', start direction '%d'", index, cmd, _vm->_currentBlock, _vm->_currentDirection);  		if (_vm->_dialogueField)  			_vm->restoreAfterDialogueSequence(); @@ -1256,6 +1297,7 @@ int EobInfProcessor::oeob_loadNewLevelOrMonsters(int8 *data) {  		cmd = *pos++;  		_vm->releaseMonsterShapes(cmd * 18, 18);  		_vm->loadMonsterShapes((const char*)pos, cmd * 18, true, index * 18); +		debugC(5, kDebugLevelScript, "         - loading monster shapes '%s', monster number '%d', encode type '%d'", (const char*)pos, cmd, index);  		pos += 13;  		_vm->gui_restorePlayField();  		res = pos - data; @@ -1268,6 +1310,7 @@ int EobInfProcessor::oeob_increasePartyExperience(int8 *data) {  	int8 *pos = data;  	if (*pos++ == -30) {  		_vm->increasePartyExperience((int16)READ_LE_UINT16(pos)); +		debugC(5, kDebugLevelScript, "         - award '%d' experience points", READ_LE_UINT16(pos));  		pos += 2;  	}  	return pos - data; @@ -1282,10 +1325,13 @@ int EobInfProcessor::oeob_createItem_v1(int8 *data) {  	uint8 itmPos = *pos++;  	if (itm) { -		if (block == 0xffff && !_vm->_itemInHand) +		if (block == 0xffff && !_vm->_itemInHand) {  			_vm->setHandItem(itm); -		else if (block != 0xffff ) +			debugC(5, kDebugLevelScript, "         - create hand item '%d'", itm); +		} else if (block != 0xffff) {  			_vm->setItemPosition((Item*)&_vm->_levelBlockProperties[block & 0x3ff].drawObjects, block, itm, itmPos); +			debugC(5, kDebugLevelScript, "         - create item '%d' on block '0x%.04X', position '%d'", itm, block, itmPos); +		}  	}  	return pos - data; @@ -1315,14 +1361,19 @@ int EobInfProcessor::oeob_createItem_v2(int8 *data) {  		return pos - data;  	if (block == 0xffff) { -		if (!_vm->_itemInHand) +		if (!_vm->_itemInHand) {  			_vm->setHandItem(itm); -		else +			debugC(5, kDebugLevelScript, "         - create hand item '%d' (value '%d', flags '0x%X', icon number '%d')", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon); +		} else {  			_vm->setItemPosition((Item*)&_vm->_levelBlockProperties[_vm->_currentBlock & 0x3ff].drawObjects, _vm->_currentBlock, itm, _itemPos[_vm->rollDice(1, 2, -1)]); +			debugC(5, kDebugLevelScript, "         - create item '%d' (value '%d', flags '0x%X', icon number '%d') on current block", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon); +		}  	} else if (block == 0xfffe) {  		_vm->setItemPosition((Item*)&_vm->_levelBlockProperties[_vm->_currentBlock & 0x3ff].drawObjects, _vm->_currentBlock, itm, _itemPos[(_vm->_currentDirection << 2) + _vm->rollDice(1, 2, -1)]); +		debugC(5, kDebugLevelScript, "         - create item '%d' (value '%d', flags '0x%X', icon number '%d') on current block", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon);  	} else {  		_vm->setItemPosition((Item*)&_vm->_levelBlockProperties[block & 0x3ff].drawObjects, block, itm, itmPos); +		debugC(5, kDebugLevelScript, "         - create item '%d' (value '%d', flags '0x%X', icon number '%d') on block '0x%.04X', position '%d'", itm, _vm->_items[itm].value, _vm->_items[itm].flags, _vm->_items[itm].icon, block, itmPos);  	}  	return pos - data; diff --git a/engines/kyra/script_eob.h b/engines/kyra/script_eob.h index f7e5f09379..8f883fd712 100644 --- a/engines/kyra/script_eob.h +++ b/engines/kyra/script_eob.h @@ -40,7 +40,7 @@ public:  	~EobInfProcessor();  	void loadData(const uint8 *data, uint32 dataSize); -	void run(int func, int sub); +	void run(int func, int flags);  	void setFlags(uint32 flags);  	void clearFlags(uint32 flags); @@ -107,7 +107,7 @@ private:  	uint8 _preventRest;  	uint16 _lastScriptFunc; -	uint16 _lastScriptSub; +	uint16 _lastScriptFlags;  	int8 **_subroutineStack;  	int _subroutineStackPos; diff --git a/engines/kyra/sequences_eob1.cpp b/engines/kyra/sequences_eob1.cpp index 4c5bd17f02..2ff4a3aa9f 100644 --- a/engines/kyra/sequences_eob1.cpp +++ b/engines/kyra/sequences_eob1.cpp @@ -105,9 +105,8 @@ int EobEngine::mainMenuLoop() {  void EobEngine::seq_playOpeningCredits() {  	_allowSkip = true; -	_screen->loadPalette(_introFilesOpening[5], _screen->getPalette(0)); -	_screen->setScreenPalette(_screen->getPalette(0)); +	loadSetIntroPalette(_introFilesOpening[5]);  	_screen->loadBitmap(_introFilesOpening[4], 5, 3, 0);  	_screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK);  	_screen->updateScreen(); @@ -135,7 +134,14 @@ void EobEngine::seq_playIntro() {  		delay(120 * _tickLength);  	} -	_screen->loadBitmap("TEXT.CMP", 3, 6, 0); +	Common::SeekableReadStream *s = _res->createReadStream("TEXT.RAW"); +	if (s) { +		s->seek(768); +		_screen->loadFileDataToPage(s, 6, s->size() - 768); +		delete s; +	} else { +		_screen->loadBitmap("TEXT.CMP", 3, 6, 0); +	}  	seq_tower();  	seq_orb(); @@ -194,8 +200,7 @@ void EobEngine::seq_playFinale() {  void EobEngine::seq_tower() {  	if (shouldQuit() || skipFlag())  		return; - -	_screen->loadPalette(_introFilesTower[0], _screen->getPalette(0)); +	  	_screen->loadBitmap(_introFilesTower[1], 5, 3, 0);  	_screen->setCurPage(2);  	uint8 *shp = _screen->encodeShape(0, 0, 16, 56, true); @@ -208,7 +213,8 @@ void EobEngine::seq_tower() {  	_screen->fillRect(0, 184, 319, 199, 12);  	int cp = _screen->setCurPage(0);  	whirlTransition(); -	_screen->setScreenPalette(_screen->getPalette(0)); +	loadSetIntroPalette(_introFilesTower[0]); +  	_screen->setCurPage(cp);  	_screen->clearCurPage(); @@ -331,8 +337,7 @@ void EobEngine::seq_waterdeepEntry() {  	uint8 *shp2[31];  	uint8 *shp3[3]; -	_screen->loadPalette(_introFilesWdEntry[0], _screen->getPalette(0)); -	_screen->setScreenPalette(_screen->getPalette(0)); +	loadSetIntroPalette(_introFilesWdEntry[0]);  	_screen->loadBitmap(_introFilesWdEntry[1], 5, 3, 0);  	_screen->setCurPage(2);  	shp[3] = _screen->encodeShape(0, 0, 20, 136, true); @@ -712,8 +717,7 @@ void EobEngine::seq_waterdeepExit() {  	_screen->fillRect(0, 168, 319, 199, 12, 0);  	_screen->copyRegion(0, 136, 0, 0, 48, 36, 0, 4, Screen::CR_NO_P_CHECK); -	_screen->loadPalette(_introFilesWdExit[1], _screen->getPalette(0)); -	_screen->setScreenPalette(_screen->getPalette(0)); +	loadSetIntroPalette(_introFilesWdExit[1]);  	_screen->loadBitmap(_introFilesWdExit[2], 3, 5, 0);  	_screen->copyPage(5, 2);  	whirlTransition(); @@ -762,8 +766,7 @@ void EobEngine::seq_waterdeepExit() {  	_screen->fillRect(0, 16, 319, 31, 12);  	_screen->fillRect(0, 136, 319, 199, 12);  	_screen->copyRegion(0, 0, 80, 32, 160, 120, 2, 0, Screen::CR_NO_P_CHECK); -	_screen->loadPalette(_introFilesWdExit[4], _screen->getPalette(0)); -	_screen->setScreenPalette(_screen->getPalette(0)); +	loadSetIntroPalette(_introFilesWdExit[4]);  	_screen->updateScreen();  	delay(50 * _tickLength);  } @@ -916,6 +919,15 @@ void EobEngine::seq_xdeath() {  	for (int i = 0; i < 4; i++)  		delete[] shapes1[i];  	delete[] shapes2; + +	gui_drawPlayField(false); +	gui_drawAllCharPortraitsWithStats(); +} + +void EobEngine::loadSetIntroPalette(const char *filename) { +	_screen->loadPalette(filename, _screen->getPalette(0)); +	_screen->getPalette(0).fill(0, 1, 0); +	_screen->setScreenPalette(_screen->getPalette(0));  }  void EobEngine::copyBlurRegion(int x1, int y1, int x2, int y2, int w, int h, int step) { diff --git a/engines/kyra/sequences_eob2.cpp b/engines/kyra/sequences_eob2.cpp index 37aca45237..58540fdc85 100644 --- a/engines/kyra/sequences_eob2.cpp +++ b/engines/kyra/sequences_eob2.cpp @@ -169,11 +169,10 @@ void DarkMoonEngine::seq_playIntro() {  	_screen->setCurPage(0);  	_screen->clearCurPage(); -	_sound->playTrack(0); +	snd_stopSound();  	sq.loadScene(4, 2);  	sq.loadScene(0, 2); -  	sq.delay(1);  	if (!skipFlag() && !shouldQuit()) @@ -469,8 +468,7 @@ void DarkMoonEngine::seq_playFinale() {  	_screen->setFont(Screen::FID_8_FNT);  	_sound->loadSoundFile("FINALE1"); -	_sound->playTrack(0); - +	snd_stopSound();  	sq.delay(3);  	_screen->clearCurPage(); @@ -741,7 +739,7 @@ void DarkMoonEngine::seq_playFinale() {  	sq.loadScene(10, 2);  	sq.loadScene(9, 2); -	_sound->playTrack(0); +	snd_stopSound();  	sq.delay(3);  	_sound->loadSoundFile("FINALE2"); @@ -780,7 +778,7 @@ void DarkMoonEngine::seq_playFinale() {  	while (!skipFlag() && !shouldQuit())  		delay(_tickLength); -	_sound->playTrack(0); +	snd_stopSound();  	sq.fadePalette(9, 10);  } diff --git a/engines/kyra/sound_lol.cpp b/engines/kyra/sound_lol.cpp index 6bf047fe35..a37ec9f674 100644 --- a/engines/kyra/sound_lol.cpp +++ b/engines/kyra/sound_lol.cpp @@ -167,8 +167,8 @@ void LoLEngine::snd_playSoundEffect(int track, int volume) {  	volume &= 0xff;  	int16 volIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2 + 1]); -	volume = (volIndex > 0) ? (volIndex * volume) >> 8 : -volIndex; -	volume = CLIP(volume >> 4, 2, 13) * 7 + 164; +	uint16 vocLevel = (volIndex > 0) ? (volIndex * volume) >> 8 : -volIndex; +	vocLevel = CLIP(volume >> 4, 2, 13) * 7 + 164;  	int16 vocIndex = (int16)READ_LE_UINT16(&_ingameSoundIndex[track * 2]); @@ -180,7 +180,7 @@ void LoLEngine::snd_playSoundEffect(int track, int volume) {  	if (hasVocFile) {  		if (_sound->isVoicePresent(_ingameSoundList[vocIndex])) -			_sound->voicePlay(_ingameSoundList[vocIndex], 0, volume & 0xff, true); +			_sound->voicePlay(_ingameSoundList[vocIndex], 0, vocLevel & 0xff, true);  	} else if (_flags.platform == Common::kPlatformPC) {  		if (_sound->getSfxType() == Sound::kMidiMT32)  			track = (track < _ingameMT32SoundIndexSize) ? (_ingameMT32SoundIndex[track] - 1) : -1; diff --git a/engines/kyra/sprites_eob.cpp b/engines/kyra/sprites_eob.cpp index eca053017c..2dc9405f72 100644 --- a/engines/kyra/sprites_eob.cpp +++ b/engines/kyra/sprites_eob.cpp @@ -438,7 +438,7 @@ void EobCoreEngine::drawBlockItems(int index) {  			}  			int8 scaleSteps = (int8)_dscItemScaleIndex[(_dscDimMap[index] << 2) + ps]; -			if (flg & 8 && ps < 2 && scaleSteps) { +			if ((flg & 8) && ps < 2 && scaleSteps) {  				tile2 = _dscItemTileIndex[index];  				if (tile2 != -1)  					setLevelShapesDim(tile2, _shpDmX1, _shpDmX2, 5); @@ -447,7 +447,7 @@ void EobCoreEngine::drawBlockItems(int index) {  			if (scaleSteps >= 0) {  				const uint8 *shp = _screen->scaleShape(_dscItemShapeMap[itm->icon] < _numLargeItemShapes ? _largeItemShapes[_dscItemShapeMap[itm->icon]] : (_dscItemShapeMap[itm->icon] < 15 ? 0 : _smallItemShapes[_dscItemShapeMap[itm->icon] - 15]), scaleSteps); -				x = x + itemPosFin[o & 7] - (shp[2] << 2); +				x = x + (itemPosFin[o & 7] << 1) - ((shp[2] << 3) >> 1);  				y -= shp[1];  				if (itm->pos != 8) diff --git a/engines/kyra/timer_eob.cpp b/engines/kyra/timer_eob.cpp index 277e04e769..3b56b793d5 100644 --- a/engines/kyra/timer_eob.cpp +++ b/engines/kyra/timer_eob.cpp @@ -304,6 +304,10 @@ void EobCoreEngine::timerSpecialCharacterUpdate(int timerNum) {  			continue;  		} +		int od = _screen->curDimIndex(); +		Screen::FontId of = _screen->setFont(Screen::FID_6_FNT); +		_screen->setScreenDim(7); +  		switch (evt) {  		case 2:  		case 3: @@ -363,7 +367,10 @@ void EobCoreEngine::timerSpecialCharacterUpdate(int timerNum) {  		default:  			break;  		} -	} + +		_screen->setScreenDim(od); +		_screen->setFont(of); +	}	  	uint32 nextTimer = 0xffffffff;  	for (int i = 0; i < 10; i++) {  | 
