diff options
| -rw-r--r-- | engines/illusions/actor.cpp | 21 | ||||
| -rw-r--r-- | engines/illusions/actor.h | 1 | ||||
| -rw-r--r-- | engines/illusions/fontresource.cpp | 49 | ||||
| -rw-r--r-- | engines/illusions/fontresource.h | 47 | ||||
| -rw-r--r-- | engines/illusions/illusions.cpp | 22 | ||||
| -rw-r--r-- | engines/illusions/module.mk | 3 | ||||
| -rw-r--r-- | engines/illusions/screen.cpp | 2 | ||||
| -rw-r--r-- | engines/illusions/scriptman.h | 2 | ||||
| -rw-r--r-- | engines/illusions/scriptopcodes.cpp | 158 | ||||
| -rw-r--r-- | engines/illusions/scriptopcodes.h | 20 | ||||
| -rw-r--r-- | engines/illusions/scriptthread.cpp | 1 | ||||
| -rw-r--r-- | engines/illusions/sequenceopcodes.cpp | 13 | ||||
| -rw-r--r-- | engines/illusions/sequenceopcodes.h | 3 | ||||
| -rw-r--r-- | engines/illusions/soundresource.cpp | 49 | ||||
| -rw-r--r-- | engines/illusions/soundresource.h | 47 | ||||
| -rw-r--r-- | engines/illusions/spritedrawqueue.cpp | 3 | ||||
| -rw-r--r-- | engines/illusions/talkresource.cpp | 49 | ||||
| -rw-r--r-- | engines/illusions/talkresource.h | 47 | ||||
| -rw-r--r-- | engines/illusions/thread.cpp | 11 | ||||
| -rw-r--r-- | engines/illusions/thread.h | 2 | 
20 files changed, 525 insertions, 25 deletions
| diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp index e1aa5f772f..ad91b0200f 100644 --- a/engines/illusions/actor.cpp +++ b/engines/illusions/actor.cpp @@ -73,6 +73,7 @@ Actor::Actor(IllusionsEngine *vm)  	_position2.y = 0;  	_facing = 64;  	_fontId = 0; +	_actorIndex = 0;  	_parentObjectId = 0;  	_linkIndex = 0;  	_linkIndex2 = 0; @@ -104,7 +105,6 @@ Actor::Actor(IllusionsEngine *vm)  	_pathInitialPosFlag = 1;  	_pathInitialPos.x = 0;  	_pathInitialPos.y = 0; -	_actorIndex = 0;  	_namedPointsCount = 0;  	_namedPoints = 0;  	_field164 = 0; @@ -267,8 +267,8 @@ void Control::disappearActor() {  			_actor->_flags &= ~1;  		}  	} else { -		_actor->_flags |= ~1; -		_actor->_flags |= ~0x1000; +		_actor->_flags &= ~1; +		_actor->_flags &= ~0x1000;  		for (uint i = 0; i < kSubObjectsCount; ++i)  			if (_actor->_subobjects[i]) {  				Control *subControl = _vm->_dict->getObjectControl(_actor->_subobjects[i]); @@ -302,20 +302,20 @@ void Control::deactivateObject() {  void Control::readPointsConfig(byte *pointsConfig) {  	_unkPt.x = READ_LE_UINT16(pointsConfig + 0);  	_unkPt.y = READ_LE_UINT16(pointsConfig + 2); -	pointsConfig += 2; +	pointsConfig += 4;  	_pt.x = READ_LE_UINT16(pointsConfig + 0);  	_pt.y = READ_LE_UINT16(pointsConfig + 2); -	pointsConfig += 2; +	pointsConfig += 4;  	_feetPt.x = READ_LE_UINT16(pointsConfig + 0);  	_feetPt.y = READ_LE_UINT16(pointsConfig + 2); -	pointsConfig += 2; +	pointsConfig += 4;  	_position.x = READ_LE_UINT16(pointsConfig + 0);  	_position.y = READ_LE_UINT16(pointsConfig + 2); -	pointsConfig += 2; +	pointsConfig += 4;  	for (uint i = 0; i < kSubObjectsCount; ++i) {  		_subobjectsPos[i].x = READ_LE_UINT16(pointsConfig + 0);  		_subobjectsPos[i].y = READ_LE_UINT16(pointsConfig + 2); -		pointsConfig += 2; +		pointsConfig += 4;  	}  } @@ -553,7 +553,7 @@ void Control::sequenceActor() {  	while (_actor->_seqCodeValue3 <= 0 && !sequenceFinished) {  		bool breakInner = false;  		while (!breakInner) { -			debug("op: %08X", _actor->_seqCodeIp[0]); +			debug("SEQ op: %08X", _actor->_seqCodeIp[0]);  			opCall._op = _actor->_seqCodeIp[0] & 0x7F;  			opCall._opSize = _actor->_seqCodeIp[1];  			opCall._code = _actor->_seqCodeIp + 2; @@ -608,8 +608,6 @@ void Control::startSequenceActorIntern(uint32 sequenceId, int value, int value2,  	_actor->_seqCodeIp = sequence->_sequenceCode;  	_actor->_frames = _vm->_actorItems->findSequenceFrames(sequence); -	debug("Control::startSequenceActorIntern() _actor->_seqCodeIp = %p", (void*)_actor->_seqCodeIp); -	debug("Control::startSequenceActorIntern() _actor->_frames = %p", (void*)_actor->_frames);  	_actor->_seqCodeValue3 = 0;  	_actor->_seqCodeValue1 = 0; @@ -801,7 +799,6 @@ void Controls::destroyControl(Control *control) {  }  void Controls::actorControlRouine(Control *control, uint32 deltaTime) { -	//debug("Controls::actorControlRouine()");  	Actor *actor = control->_actor; diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h index 6a682c6a9e..b37e1317eb 100644 --- a/engines/illusions/actor.h +++ b/engines/illusions/actor.h @@ -106,6 +106,7 @@ public:  	uint _facing;  	uint32 _fontId; +	int16 _actorIndex;  	DefaultSequences _defaultSequences; diff --git a/engines/illusions/fontresource.cpp b/engines/illusions/fontresource.cpp new file mode 100644 index 0000000000..e0f48d051c --- /dev/null +++ b/engines/illusions/fontresource.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "illusions/illusions.h" +#include "illusions/fontresource.h" + +namespace Illusions { + +// FontResourceLoader + +void FontResourceLoader::load(Resource *resource) { +	debug("FontResourceLoader::load() Loading font %08X from %s...", resource->_resId, resource->_filename.c_str()); + +    // TODO +	 +} + +void FontResourceLoader::unload(Resource *resource) { +} + +void FontResourceLoader::buildFilename(Resource *resource) { +	resource->_filename = Common::String::format("%08X.fnt", resource->_resId); +} + +bool FontResourceLoader::isFlag(int flag) { +	return +		flag == kRlfLoadFile; +} + +} // End of namespace Illusions diff --git a/engines/illusions/fontresource.h b/engines/illusions/fontresource.h new file mode 100644 index 0000000000..66860bb14b --- /dev/null +++ b/engines/illusions/fontresource.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ILLUSIONS_FONTRESOURCE_H +#define ILLUSIONS_FONTRESOURCE_H + +#include "illusions/graphics.h" +#include "illusions/resourcesystem.h" + +namespace Illusions { + +class IllusionsEngine; + +class FontResourceLoader : public BaseResourceLoader { +public: +	FontResourceLoader(IllusionsEngine *vm) : _vm(vm) {} +	virtual ~FontResourceLoader() {} +	virtual void load(Resource *resource); +	virtual void unload(Resource *resource); +	virtual void buildFilename(Resource *resource); +	virtual bool isFlag(int flag); +protected: +	IllusionsEngine *_vm; +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_FONTRESOURCE_H diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp index 50e1bfa78b..1d591c76f6 100644 --- a/engines/illusions/illusions.cpp +++ b/engines/illusions/illusions.cpp @@ -21,20 +21,23 @@   */  #include "illusions/illusions.h" -#include "illusions/resourcesystem.h" +#include "illusions/actor.h" +#include "illusions/actorresource.h"  #include "illusions/backgroundresource.h"  #include "illusions/camera.h" +#include "illusions/dictionary.h" +#include "illusions/fontresource.h"  #include "illusions/graphics.h"  #include "illusions/input.h" -#include "illusions/updatefunctions.h" -#include "illusions/actor.h" -#include "illusions/actorresource.h" -#include "illusions/thread.h" +#include "illusions/resourcesystem.h"  #include "illusions/screen.h"  #include "illusions/scriptresource.h"  #include "illusions/scriptman.h" +#include "illusions/soundresource.h" +#include "illusions/talkresource.h" +#include "illusions/thread.h"  #include "illusions/time.h" -#include "illusions/dictionary.h" +#include "illusions/updatefunctions.h"  #include "audio/audiostream.h"  #include "common/config-manager.h" @@ -85,9 +88,12 @@ Common::Error IllusionsEngine::run() {  	_resSys = new ResourceSystem();  	_resSys->addResourceLoader(0x00060000, new ActorResourceLoader(this)); +	_resSys->addResourceLoader(0x00080000, new SoundGroupResourceLoader(this));  	_resSys->addResourceLoader(0x000D0000, new ScriptResourceLoader(this)); +	_resSys->addResourceLoader(0x000F0000, new TalkResourceLoader(this));  	_resSys->addResourceLoader(0x00100000, new ActorResourceLoader(this));  	_resSys->addResourceLoader(0x00110000, new BackgroundResourceLoader(this)); +	_resSys->addResourceLoader(0x00120000, new FontResourceLoader(this));  	_screen = new Screen(this);  	_input = new Input();	 @@ -180,6 +186,8 @@ Common::Error IllusionsEngine::run() {  	delete _resSys;  	delete _dict; +	debug("Ok"); +	  	return Common::kNoError;  } @@ -369,7 +377,7 @@ int IllusionsEngine::convertPanXCoord(int16 x) {  Common::Point IllusionsEngine::getNamedPointPosition(uint32 namedPointId) {  	// TODO -	return Common::Point(320, 240); +	return Common::Point(0, 0);  }  void IllusionsEngine::playVideo(uint32 videoId, uint32 objectId, uint32 priority, uint32 threadId) { diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk index de801b3abe..9121343b3b 100644 --- a/engines/illusions/module.mk +++ b/engines/illusions/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \  	detection.o \  	dictionary.o \  	fixedpoint.o \ +	fontresource.o \  	graphics.o \  	illusions.o \  	input.o \ @@ -18,8 +19,10 @@ MODULE_OBJS := \  	scriptresource.o \  	scriptthread.o \  	sequenceopcodes.o \ +	soundresource.o \  	spritedecompressqueue.o \  	spritedrawqueue.o \ +	talkresource.o \  	thread.o \  	time.o \  	timerthread.o \ diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp index 6cb55ec5c2..1a80a33905 100644 --- a/engines/illusions/screen.cpp +++ b/engines/illusions/screen.cpp @@ -87,7 +87,7 @@ void Screen::drawSurface10(int16 destX, int16 destY, Graphics::Surface *surface,  void Screen::drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect) {  	// Unscaled, non-transparent -	debug(1, "Screen::drawSurface11() destX: %d; destY: %d; srcRect: (%d, %d, %d, %d)", destX, destY, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom); +	debug("Screen::drawSurface11() destX: %d; destY: %d; srcRect: (%d, %d, %d, %d)", destX, destY, srcRect.left, srcRect.top, srcRect.right, srcRect.bottom);  	const int16 w = srcRect.width();  	const int16 h = srcRect.height();  	for (int16 yc = 0; yc < h; ++yc) { diff --git a/engines/illusions/scriptman.h b/engines/illusions/scriptman.h index f80101fe10..da0f6b6e04 100644 --- a/engines/illusions/scriptman.h +++ b/engines/illusions/scriptman.h @@ -101,6 +101,8 @@ public:  	ThreadList *_threads;  	ScriptOpcodes *_scriptOpcodes; +	uint32 _callerThreadId; +	  	void newScriptThread(uint32 threadId, uint32 callingThreadId, uint notifyFlags,  		byte *scriptCodeIp, uint32 value8, uint32 valueC, uint32 value10);  	uint32 newTimerThread(uint32 duration, uint32 callingThreadId, bool isAbortable); diff --git a/engines/illusions/scriptopcodes.cpp b/engines/illusions/scriptopcodes.cpp index 13cb8aa557..72c455ad08 100644 --- a/engines/illusions/scriptopcodes.cpp +++ b/engines/illusions/scriptopcodes.cpp @@ -23,6 +23,7 @@  #include "illusions/illusions.h"  #include "illusions/scriptopcodes.h"  #include "illusions/actor.h" +#include "illusions/dictionary.h"  #include "illusions/input.h"  #include "illusions/screen.h"  #include "illusions/scriptman.h" @@ -67,7 +68,7 @@ ScriptOpcodes::~ScriptOpcodes() {  void ScriptOpcodes::execOpcode(ScriptThread *scriptThread, OpCall &opCall) {  	if (!_opcodes[opCall._op])  		error("ScriptOpcodes::execOpcode() Unimplemented opcode %d", opCall._op); -	debug("execOpcode(%d)", opCall._op); +	debug("\nexecOpcode(%d)", opCall._op);  	(*_opcodes[opCall._op])(scriptThread, opCall);  } @@ -81,19 +82,38 @@ void ScriptOpcodes::initOpcodes() {  	// Register opcodes  	OPCODE(2, opSuspend);  	OPCODE(3, opYield); +	OPCODE(4, opTerminate); +	OPCODE(5, opJump);  	OPCODE(6, opStartScriptThread); +	OPCODE(8, opStartTempScriptThread);  	OPCODE(9, opStartTimerThread); +	OPCODE(14, opSetThreadSceneId);  	OPCODE(16, opLoadResource);  	OPCODE(20, opEnterScene);  	OPCODE(39, opSetDisplay);  	OPCODE(42, opIncBlockCounter); -	OPCODE(46, opPlaceActor); +	OPCODE(45, opSetProperty); +	OPCODE(46, opPlaceActor);	 +	OPCODE(49, opStartSequenceActor); +	OPCODE(57, opAppearActor); +	OPCODE(58, opDisappearActor); +	OPCODE(63, opSetSelectSfx); +	OPCODE(64, opSetMoveSfx); +	OPCODE(65, opSetDenySfx); +	OPCODE(66, opSetAdjustUpSfx); +	OPCODE(67, opSetAdjustDnSfx); +	OPCODE(75, opStartMusic);  	OPCODE(87, opDeactivateButton);  	OPCODE(88, opActivateButton); +	OPCODE(103, opJumpIf);  	OPCODE(126, opDebug126);  	OPCODE(144, opPlayVideo); +	OPCODE(148, opLoadSpecialCodeModule); +	OPCODE(150, opRunSpecialCode);  	OPCODE(175, opSetSceneIdThreadId); +	OPCODE(176, opStackPush0);  	OPCODE(177, opSetFontId); +	OPCODE(178, opAddMenuKey);  }  #undef OPCODE @@ -118,6 +138,15 @@ void ScriptOpcodes::opYield(ScriptThread *scriptThread, OpCall &opCall) {  	opCall._result = kTSYield;  } +void ScriptOpcodes::opTerminate(ScriptThread *scriptThread, OpCall &opCall) { +	opCall._result = kTSTerminate; +} + +void ScriptOpcodes::opJump(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_INT16(jumpOffs); +	opCall._deltaOfs += jumpOffs; +} +  void ScriptOpcodes::opStartScriptThread(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_SKIP(2);  	ARG_UINT32(threadId); @@ -125,18 +154,33 @@ void ScriptOpcodes::opStartScriptThread(ScriptThread *scriptThread, OpCall &opCa  		scriptThread->_value8, scriptThread->_valueC, scriptThread->_value10);  } +void ScriptOpcodes::opStartTempScriptThread(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_INT16(codeOffs); +	_vm->_scriptMan->startTempScriptThread(opCall._code + codeOffs, +		opCall._threadId, scriptThread->_value8, scriptThread->_valueC, scriptThread->_value10); +} +  void ScriptOpcodes::opStartTimerThread(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_INT16(isAbortable);  	ARG_INT16(duration);  	ARG_INT16(maxDuration);  	if (maxDuration)  		duration += _vm->getRandom(maxDuration); +		 +duration = 5;//DEBUG Speeds up things		 +		  	if (isAbortable)  		_vm->_scriptMan->startAbortableTimerThread(duration, opCall._threadId);  	else  		_vm->_scriptMan->startTimerThread(duration, opCall._threadId);  } +void ScriptOpcodes::opSetThreadSceneId(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(sceneId); +	_vm->_scriptMan->_threads->setThreadSceneId(opCall._callerThreadId, sceneId); +} +  void ScriptOpcodes::opLoadResource(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_SKIP(2);  	ARG_UINT32(resourceId); @@ -170,6 +214,12 @@ void ScriptOpcodes::opIncBlockCounter(ScriptThread *scriptThread, OpCall &opCall  		_vm->_scriptMan->_scriptResource->_blockCounters.set(index + 1, value);  } +void ScriptOpcodes::opSetProperty(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_INT16(value)	 +	ARG_INT16(propertyId)	 +	// TODO _vm->_scriptMan->_scriptResource->_properties.set(propertyId, value); +} +  void ScriptOpcodes::opPlaceActor(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_SKIP(2);  	ARG_UINT32(objectId); @@ -180,6 +230,73 @@ void ScriptOpcodes::opPlaceActor(ScriptThread *scriptThread, OpCall &opCall) {  	_vm->_controls->placeActor(actorTypeId, pos, sequenceId, objectId, opCall._threadId);  } +void ScriptOpcodes::opStartSequenceActor(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(objectId); +	ARG_UINT32(sequenceId); +	// NOTE Skipped checking for stalled sequence, not sure if needed +	Control *control = _vm->_dict->getObjectControl(objectId); +	control->startSequenceActor(sequenceId, 2, opCall._threadId); +} + +void ScriptOpcodes::opAppearActor(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(objectId); +	Control *control = _vm->_dict->getObjectControl(objectId); +	if (!control) { +		Common::Point pos = _vm->getNamedPointPosition(0x70023); +        _vm->_controls->placeActor(0x50001, pos, 0x60001, objectId, 0); +        control = _vm->_dict->getObjectControl(objectId); +        control->startSequenceActor(0x60001, 2, 0); +	} +	control->appearActor(); +} + +void ScriptOpcodes::opDisappearActor(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(objectId); +	Control *control = _vm->_dict->getObjectControl(objectId); +	control->disappearActor(); +} + +void ScriptOpcodes::opSetSelectSfx(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(soundEffectId); +	// TODO _vm->setSelectSfx(soundEffectId); +} + +void ScriptOpcodes::opSetMoveSfx(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(soundEffectId); +	// TODO _vm->setMoveSfx(soundEffectId); +} + +void ScriptOpcodes::opSetDenySfx(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(soundEffectId); +	// TODO _vm->setDenySfx(soundEffectId); +} + +void ScriptOpcodes::opSetAdjustUpSfx(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(soundEffectId); +	// TODO _vm->setAdjustUpSfx(soundEffectId); +} + +void ScriptOpcodes::opSetAdjustDnSfx(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(soundEffectId); +	// TODO _vm->setAdjustDnSfx(soundEffectId); +} +void ScriptOpcodes::opStartMusic(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_INT16(volume) +	ARG_INT16(pan) +	ARG_UINT32(musicId); +	ARG_UINT32(type); +	// TODO _vm->playMusic(musicId, type, volume, pan); +} +  void ScriptOpcodes::opDeactivateButton(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_INT16(button)  	_vm->_input->deactivateButton(button); @@ -190,8 +307,16 @@ void ScriptOpcodes::opActivateButton(ScriptThread *scriptThread, OpCall &opCall)  	_vm->_input->activateButton(button);  } +void ScriptOpcodes::opJumpIf(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_INT16(jumpOffs) +	int16 value = _vm->_scriptMan->_stack.pop(); +	if (!value) +		opCall._deltaOfs += jumpOffs; +} +  void ScriptOpcodes::opDebug126(ScriptThread *scriptThread, OpCall &opCall) {  	// NOTE Prints some debug text +	debug("[DBG] %s", (char*)opCall._code);  }  void ScriptOpcodes::opPlayVideo(ScriptThread *scriptThread, OpCall &opCall) { @@ -206,6 +331,24 @@ void ScriptOpcodes::opPlayVideo(ScriptThread *scriptThread, OpCall &opCall) {  } +void ScriptOpcodes::opLoadSpecialCodeModule(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(specialCodeModuleId); +	// TODO _vm->loadSpecialCodeModule(specialCodeModuleId); +} + +void ScriptOpcodes::opRunSpecialCode(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(specialCodeId); +	_vm->_scriptMan->_callerThreadId = opCall._callerThreadId; +	// TODO _vm->runSpecialCode(specialCodeId, opCall._code + 8, opCall._threadId); +	_vm->_scriptMan->_callerThreadId = 0; + +	//DEBUG Resume calling thread, later done by the special code +	_vm->notifyThreadId(opCall._threadId); + +} +  void ScriptOpcodes::opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_SKIP(2);  	ARG_UINT32(sceneId); @@ -213,10 +356,21 @@ void ScriptOpcodes::opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opC  	_vm->_scriptMan->setSceneIdThreadId(sceneId, threadId);  } +void ScriptOpcodes::opStackPush0(ScriptThread *scriptThread, OpCall &opCall) { +	_vm->_scriptMan->_stack.push(0); +} +  void ScriptOpcodes::opSetFontId(ScriptThread *scriptThread, OpCall &opCall) {  	ARG_SKIP(2);  	ARG_UINT32(fontId);  	_vm->_scriptMan->setCurrFontId(fontId);  } +void ScriptOpcodes::opAddMenuKey(ScriptThread *scriptThread, OpCall &opCall) { +	ARG_SKIP(2); +	ARG_UINT32(key); +	ARG_UINT32(threadId); +	// TODO _vm->addMenuKey(key, threadId); +} +  } // End of namespace Illusions diff --git a/engines/illusions/scriptopcodes.h b/engines/illusions/scriptopcodes.h index d812d58c26..4d14010f2f 100644 --- a/engines/illusions/scriptopcodes.h +++ b/engines/illusions/scriptopcodes.h @@ -34,6 +34,7 @@ struct OpCall {  	byte _op;  	byte _opSize;  	uint32 _threadId; +	uint32 _callerThreadId;  	int16 _deltaOfs;  	byte *_code;  	int _result; @@ -59,19 +60,38 @@ protected:  	// Opcodes  	void opSuspend(ScriptThread *scriptThread, OpCall &opCall);  	void opYield(ScriptThread *scriptThread, OpCall &opCall); +	void opTerminate(ScriptThread *scriptThread, OpCall &opCall); +	void opJump(ScriptThread *scriptThread, OpCall &opCall);  	void opStartScriptThread(ScriptThread *scriptThread, OpCall &opCall); +	void opStartTempScriptThread(ScriptThread *scriptThread, OpCall &opCall);  	void opStartTimerThread(ScriptThread *scriptThread, OpCall &opCall); +	void opSetThreadSceneId(ScriptThread *scriptThread, OpCall &opCall);  	void opLoadResource(ScriptThread *scriptThread, OpCall &opCall);  	void opEnterScene(ScriptThread *scriptThread, OpCall &opCall);  	void opSetDisplay(ScriptThread *scriptThread, OpCall &opCall);	  	void opIncBlockCounter(ScriptThread *scriptThread, OpCall &opCall); +	void opSetProperty(ScriptThread *scriptThread, OpCall &opCall);  	void opPlaceActor(ScriptThread *scriptThread, OpCall &opCall); +	void opStartSequenceActor(ScriptThread *scriptThread, OpCall &opCall); +	void opAppearActor(ScriptThread *scriptThread, OpCall &opCall); +	void opDisappearActor(ScriptThread *scriptThread, OpCall &opCall); +	void opSetSelectSfx(ScriptThread *scriptThread, OpCall &opCall); +	void opSetMoveSfx(ScriptThread *scriptThread, OpCall &opCall); +	void opSetDenySfx(ScriptThread *scriptThread, OpCall &opCall); +	void opSetAdjustUpSfx(ScriptThread *scriptThread, OpCall &opCall); +	void opSetAdjustDnSfx(ScriptThread *scriptThread, OpCall &opCall); +	void opStartMusic(ScriptThread *scriptThread, OpCall &opCall);  	void opDeactivateButton(ScriptThread *scriptThread, OpCall &opCall);  	void opActivateButton(ScriptThread *scriptThread, OpCall &opCall); +	void opJumpIf(ScriptThread *scriptThread, OpCall &opCall);  	void opDebug126(ScriptThread *scriptThread, OpCall &opCall);  	void opPlayVideo(ScriptThread *scriptThread, OpCall &opCall); +	void opLoadSpecialCodeModule(ScriptThread *scriptThread, OpCall &opCall); +	void opRunSpecialCode(ScriptThread *scriptThread, OpCall &opCall);  	void opSetSceneIdThreadId(ScriptThread *scriptThread, OpCall &opCall); +	void opStackPush0(ScriptThread *scriptThread, OpCall &opCall);  	void opSetFontId(ScriptThread *scriptThread, OpCall &opCall); +	void opAddMenuKey(ScriptThread *scriptThread, OpCall &opCall);  }; diff --git a/engines/illusions/scriptthread.cpp b/engines/illusions/scriptthread.cpp index 0f32a6ffb9..b21b003c21 100644 --- a/engines/illusions/scriptthread.cpp +++ b/engines/illusions/scriptthread.cpp @@ -40,6 +40,7 @@ ScriptThread::ScriptThread(IllusionsEngine *vm, uint32 threadId, uint32 callingT  int ScriptThread::onUpdate() {  	OpCall opCall;  	opCall._result = kTSRun; +	opCall._callerThreadId = _threadId;  	while (!_terminated && opCall._result == kTSRun) {  		opCall._op = _scriptCodeIp[0];  		opCall._opSize = _scriptCodeIp[1] >> 1; diff --git a/engines/illusions/sequenceopcodes.cpp b/engines/illusions/sequenceopcodes.cpp index e19d8cdf7d..4eaa7a9c38 100644 --- a/engines/illusions/sequenceopcodes.cpp +++ b/engines/illusions/sequenceopcodes.cpp @@ -62,7 +62,8 @@ void SequenceOpcodes::initOpcodes() {  	OPCODE(9, opGotoSequence);  	OPCODE(11, opBeginLoop);  	OPCODE(12, opNextLoop); -	OPCODE(15, opJumpIfNotFacing); +	OPCODE(14, opSwitchActorIndex); +	OPCODE(15, opSwitchFacing);  	OPCODE(28, opNotifyThreadId1);  	OPCODE(29, opSetPathCtrY);  	OPCODE(33, opSetPathWalkPoints); @@ -176,7 +177,15 @@ void SequenceOpcodes::opNextLoop(Control *control, OpCall &opCall) {  	}  } -void SequenceOpcodes::opJumpIfNotFacing(Control *control, OpCall &opCall) { +void SequenceOpcodes::opSwitchActorIndex(Control *control, OpCall &opCall) { +	ARG_INT16(actorIndex); +	ARG_INT16(jumpOffs); +	debug("control->_objectId = %08X", control->_objectId); +	if (control->_actor->_actorIndex != actorIndex) +		opCall._deltaOfs += jumpOffs; +} + +void SequenceOpcodes::opSwitchFacing(Control *control, OpCall &opCall) {  	ARG_INT16(facing);  	ARG_INT16(jumpOffs);  	if (!(control->_actor->_facing & facing)) diff --git a/engines/illusions/sequenceopcodes.h b/engines/illusions/sequenceopcodes.h index 366fbba6b7..31827aaf7e 100644 --- a/engines/illusions/sequenceopcodes.h +++ b/engines/illusions/sequenceopcodes.h @@ -53,7 +53,8 @@ protected:  	void opGotoSequence(Control *control, OpCall &opCall);  	void opBeginLoop(Control *control, OpCall &opCall);  	void opNextLoop(Control *control, OpCall &opCall); -	void opJumpIfNotFacing(Control *control, OpCall &opCall); +	void opSwitchActorIndex(Control *control, OpCall &opCall); +	void opSwitchFacing(Control *control, OpCall &opCall);  	void opNotifyThreadId1(Control *control, OpCall &opCall);  	void opSetPathCtrY(Control *control, OpCall &opCall);  	void opSetPathWalkPoints(Control *control, OpCall &opCall); diff --git a/engines/illusions/soundresource.cpp b/engines/illusions/soundresource.cpp new file mode 100644 index 0000000000..e5cc5dde50 --- /dev/null +++ b/engines/illusions/soundresource.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "illusions/illusions.h" +#include "illusions/soundresource.h" + +namespace Illusions { + +// SoundGroupResourceLoader + +void SoundGroupResourceLoader::load(Resource *resource) { +	debug("SoundGroupResourceLoader::load() Loading sound group %08X...", resource->_resId); + +    // TODO +    // Load all sounds in sfx/{SoundGroupId}/ +	 +} + +void SoundGroupResourceLoader::unload(Resource *resource) { +} + +void SoundGroupResourceLoader::buildFilename(Resource *resource) { +	resource->_filename = Common::String::format("%08X.fnt", resource->_resId); +} + +bool SoundGroupResourceLoader::isFlag(int flag) { +	return false; +} + +} // End of namespace Illusions diff --git a/engines/illusions/soundresource.h b/engines/illusions/soundresource.h new file mode 100644 index 0000000000..d278a30f52 --- /dev/null +++ b/engines/illusions/soundresource.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ILLUSIONS_SOUNDRESOURCE_H +#define ILLUSIONS_SOUNDRESOURCE_H + +#include "illusions/graphics.h" +#include "illusions/resourcesystem.h" + +namespace Illusions { + +class IllusionsEngine; + +class SoundGroupResourceLoader : public BaseResourceLoader { +public: +	SoundGroupResourceLoader(IllusionsEngine *vm) : _vm(vm) {} +	virtual ~SoundGroupResourceLoader() {} +	virtual void load(Resource *resource); +	virtual void unload(Resource *resource); +	virtual void buildFilename(Resource *resource); +	virtual bool isFlag(int flag); +protected: +	IllusionsEngine *_vm; +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_SOUNDRESOURCE_H diff --git a/engines/illusions/spritedrawqueue.cpp b/engines/illusions/spritedrawqueue.cpp index 2cffb0c28b..1e42d18e3e 100644 --- a/engines/illusions/spritedrawqueue.cpp +++ b/engines/illusions/spritedrawqueue.cpp @@ -142,6 +142,9 @@ bool SpriteDrawQueue::calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcR  	srcRect.top = 0;  	srcRect.right = item->_dimensions._width;  	srcRect.bottom = item->_dimensions._height; +	 +	debug("item->_drawPosition.x: %d; item->_drawPosition.y: %d", item->_drawPosition.x, item->_drawPosition.y); +	debug("item->_controlPosition.x: %d; item->_controlPosition.y: %d", item->_controlPosition.x, item->_controlPosition.y);  	dstRect.left = item->_drawPosition.x - item->_scale * item->_controlPosition.x / 100;  	dstRect.top = item->_drawPosition.y - item->_scale * item->_controlPosition.y / 100; diff --git a/engines/illusions/talkresource.cpp b/engines/illusions/talkresource.cpp new file mode 100644 index 0000000000..d0fa607518 --- /dev/null +++ b/engines/illusions/talkresource.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "illusions/illusions.h" +#include "illusions/talkresource.h" + +namespace Illusions { + +// TalkResourceLoader + +void TalkResourceLoader::load(Resource *resource) { +	debug("TalkResourceLoader::load() Loading font %08X from %s...", resource->_resId, resource->_filename.c_str()); + +    // TODO +	 +} + +void TalkResourceLoader::unload(Resource *resource) { +} + +void TalkResourceLoader::buildFilename(Resource *resource) { +	resource->_filename = Common::String::format("%08X.tlk", resource->_resId); +} + +bool TalkResourceLoader::isFlag(int flag) { +	return +		flag == kRlfLoadFile; +} + +} // End of namespace Illusions diff --git a/engines/illusions/talkresource.h b/engines/illusions/talkresource.h new file mode 100644 index 0000000000..982d5fdf75 --- /dev/null +++ b/engines/illusions/talkresource.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ILLUSIONS_TALKRESOURCE_H +#define ILLUSIONS_TALKRESOURCE_H + +#include "illusions/graphics.h" +#include "illusions/resourcesystem.h" + +namespace Illusions { + +class IllusionsEngine; + +class TalkResourceLoader : public BaseResourceLoader { +public: +	TalkResourceLoader(IllusionsEngine *vm) : _vm(vm) {} +	virtual ~TalkResourceLoader() {} +	virtual void load(Resource *resource); +	virtual void unload(Resource *resource); +	virtual void buildFilename(Resource *resource); +	virtual bool isFlag(int flag); +protected: +	IllusionsEngine *_vm; +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_TALKRESOURCE_H diff --git a/engines/illusions/thread.cpp b/engines/illusions/thread.cpp index e398c33ba5..c16ecd4584 100644 --- a/engines/illusions/thread.cpp +++ b/engines/illusions/thread.cpp @@ -256,4 +256,15 @@ void ThreadList::killThread(uint32 threadId) {  } +void ThreadList::setThreadSceneId(uint32 threadId, uint32 sceneId) { +	Thread *thread = findThread(threadId); +	if (thread) +		thread->_tag = sceneId; +} + +uint32 ThreadList::getThreadSceneId(uint32 threadId) { +	Thread *thread = findThread(threadId); +	return thread ? thread->_tag : 0; +} +  } // End of namespace Illusions diff --git a/engines/illusions/thread.h b/engines/illusions/thread.h index eab92aeaad..977262a671 100644 --- a/engines/illusions/thread.h +++ b/engines/illusions/thread.h @@ -89,6 +89,8 @@ public:  	void pauseThreads(uint32 threadId);  	void resumeThreads(uint32 threadId);  	void killThread(uint32 threadId); +	void setThreadSceneId(uint32 threadId, uint32 sceneId); +	uint32 getThreadSceneId(uint32 threadId);  protected:  	typedef Common::List<Thread*> List;  	typedef List::iterator Iterator; | 
