ILLUSIONS: Replace 0x40004 with CURSOR_OBJECT_ID constant

Fix pan bug in starship enterprise scene
Add sequence opcode name to debug log
Hack to fix endless loop bug outside the starship enterprise
This commit is contained in:
Eric Fry 2018-05-29 22:30:54 +10:00 committed by Eugene Sandulenko
parent bdc477bef9
commit 423a8ec433
11 changed files with 46 additions and 29 deletions

View File

@ -222,7 +222,7 @@ void Control::pause() {
_vm->_dict->setObjectControl(_objectId, 0);
if (_objectId == 0x40004)
if (_objectId == Illusions::CURSOR_OBJECT_ID)
_vm->setCursorControl(0);
if (_actor && !(_actor->_flags & Illusions::ACTOR_FLAG_200))
@ -234,7 +234,7 @@ void Control::unpause() {
_vm->_dict->setObjectControl(_objectId, this);
if (_objectId == 0x40004)
if (_objectId == Illusions::CURSOR_OBJECT_ID)
_vm->setCursorControl(this);
if (_actor && !(_actor->_flags & Illusions::ACTOR_FLAG_200)) {
@ -253,7 +253,7 @@ void Control::appearActor() {
if (_vm->getGameId() == kGameIdDuckman) {
_flags |= 1;
_actor->_flags |= Illusions::ACTOR_FLAG_IS_VISIBLE;
if (_objectId == 0x40004) {
if (_objectId == Illusions::CURSOR_OBJECT_ID) {
if (_actor->_frameIndex) {
_actor->_flags |= Illusions::ACTOR_FLAG_2000;
_actor->_flags |= Illusions::ACTOR_FLAG_4000;
@ -261,7 +261,7 @@ void Control::appearActor() {
_vm->_input->discardAllEvents();
}
} else {
if (_objectId == 0x40004) {
if (_objectId == Illusions::CURSOR_OBJECT_ID) {
_vm->showCursor();
} else {
if (_actor->_frameIndex || _actorTypeId == 0x50004)
@ -282,7 +282,7 @@ void Control::disappearActor() {
_flags &= ~1;
_actor->_flags &= ~Illusions::ACTOR_FLAG_IS_VISIBLE;
} else {
if (_objectId == 0x40004) {
if (_objectId == Illusions::CURSOR_OBJECT_ID) {
_vm->hideCursor();
} else {
_actor->_flags &= ~Illusions::ACTOR_FLAG_IS_VISIBLE;
@ -646,7 +646,7 @@ void Control::sequenceActor() {
//debug(1, "New frame %d", _actor->_newFrameIndex);
setActorFrameIndex(_actor->_newFrameIndex);
if (_vm->getGameId() == kGameIdBBDOU &&
!(_actor->_flags & Illusions::ACTOR_FLAG_IS_VISIBLE) && (_actor->_flags & Illusions::ACTOR_FLAG_1000) && (_objectId != 0x40004)) {
!(_actor->_flags & Illusions::ACTOR_FLAG_IS_VISIBLE) && (_actor->_flags & Illusions::ACTOR_FLAG_1000) && (_objectId != Illusions::CURSOR_OBJECT_ID)) {
appearActor();
_actor->_flags &= ~Illusions::ACTOR_FLAG_1000;
}
@ -1105,6 +1105,9 @@ void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequ
if (_vm->isCursorObject(actorTypeId, objectId))
_vm->placeCursorControl(control, sequenceId);
// TODO HACK at least we should restrict this to the sequenceId
control->setActorIndex(1);
control->startSequenceActor(sequenceId, 2, notifyThreadId);
}
@ -1205,7 +1208,7 @@ void Controls::destroyActiveControls() {
destroyControlInternal(*it);
it = _controls.erase(it);
} else
++it;
++it;
}
}
@ -1216,7 +1219,7 @@ void Controls::destroyControlsBySceneId(uint32 sceneId) {
destroyControlInternal(*it);
it = _controls.erase(it);
} else
++it;
++it;
}
}
@ -1481,7 +1484,7 @@ void Controls::destroyControlInternal(Control *control) {
if (!(control->_flags & 4) && control->_pauseCtr <= 0)
_vm->_dict->setObjectControl(control->_objectId, 0);
if (!(control->_flags & 4) && control->_objectId == 0x40004 && control->_pauseCtr <= 0)
if (!(control->_flags & 4) && control->_objectId == Illusions::CURSOR_OBJECT_ID && control->_pauseCtr <= 0)
_vm->setCursorControl(0);
if (control->_actor) {

View File

@ -58,6 +58,10 @@ enum ActorFlags {
ACTOR_FLAG_8000 = 0x8000
};
enum ControlObjectID {
CURSOR_OBJECT_ID = 0x40004
};
const uint kSubObjectsCount = 15;
struct DefaultSequence {

View File

@ -384,7 +384,7 @@ uint32 IllusionsEngine_BBDOU::getPrevScene() {
}
bool IllusionsEngine_BBDOU::isCursorObject(uint32 actorTypeId, uint32 objectId) {
return actorTypeId == 0x50001 && objectId == 0x40004;
return actorTypeId == 0x50001 && objectId == Illusions::CURSOR_OBJECT_ID;
}
void IllusionsEngine_BBDOU::setCursorControlRoutine(Control *control) {

View File

@ -25,6 +25,7 @@
#include "illusions/fixedpoint.h"
#include "illusions/resources/backgroundresource.h"
#include "illusions/time.h"
#include "illusions/actor.h"
namespace Illusions {
@ -85,10 +86,16 @@ void Camera::set(Common::Point &panPoint, WidthHeight &dimensions) {
void Camera::panCenterObject(uint32 objectId, int16 panSpeed) {
Common::Point *actorPosition = _vm->getObjectActorPositionPtr(objectId);
if (_vm->getGameId() == kGameIdDuckman && objectId == 0x40004) {
_activeState._cameraMode = 2;
_activeState._trackingLimits.x = 156;
_activeState._trackingLimits.y = 96;
if (_vm->getGameId() == kGameIdDuckman) {
if(objectId == Illusions::CURSOR_OBJECT_ID) {
_activeState._cameraMode = 2;
_activeState._trackingLimits.x = 156;
_activeState._trackingLimits.y = 96;
} else {
_activeState._cameraMode = 1;
_activeState._trackingLimits.x = 4;
_activeState._trackingLimits.y = 4;
}
} else if (_vm->getGameId() == kGameIdBBDOU) {
_activeState._cameraMode = 1;
_activeState._trackingLimits = _centerObjectTrackingLimits;

View File

@ -85,8 +85,8 @@ void DuckmanDialogSystem::startDialog(int16 *choiceOfsPtr, uint32 actorTypeId, u
} else {
if (!_vm->_cursor._control) {
Common::Point pos = _vm->getNamedPointPosition(0x70001);
_vm->_controls->placeActor(0x50001, pos, 0x60001, 0x40004, 0);
_vm->_cursor._control = _vm->_dict->getObjectControl(0x40004);
_vm->_controls->placeActor(0x50001, pos, 0x60001, Illusions::CURSOR_OBJECT_ID, 0);
_vm->_cursor._control = _vm->_dict->getObjectControl(Illusions::CURSOR_OBJECT_ID);
}
_vm->_cursor._control->appearActor();
_vm->setCursorActorIndex(6, 1, 0);

View File

@ -944,13 +944,13 @@ void IllusionsEngine_Duckman::pause(uint32 callerThreadId) {
_threads->pauseThreads(callerThreadId);
_camera->pause();
pauseFader();
// TODO largeObj_pauseControlActor(0x40004);
// TODO largeObj_pauseControlActor(Illusions::CURSOR_OBJECT_ID);
}
}
void IllusionsEngine_Duckman::unpause(uint32 callerThreadId) {
if (--_pauseCtr == 0) {
// TODO largeObj_unpauseControlActor(0x40004);
// TODO largeObj_unpauseControlActor(Illusions::CURSOR_OBJECT_ID);
unpauseFader();
_camera->unpause();
_threads->unpauseThreads(callerThreadId);

View File

@ -171,15 +171,15 @@ int DuckmanMenuSystem::convertRootMenuId(uint32 menuId) {
bool DuckmanMenuSystem::initMenuCursor() {
bool cursorInitialVisibleFlag = false;
Control *cursorControl = _vm->getObjectControl(0x40004);
Control *cursorControl = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
if (cursorControl) {
if (cursorControl->_flags & 1)
cursorInitialVisibleFlag = false;
cursorControl->appearActor();
} else {
Common::Point pos = _vm->getNamedPointPosition(0x70001);
_vm->_controls->placeActor(0x50001, pos, 0x60001, 0x40004, 0);
cursorControl = _vm->getObjectControl(0x40004);
_vm->_controls->placeActor(0x50001, pos, 0x60001, Illusions::CURSOR_OBJECT_ID, 0);
cursorControl = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
}
return cursorInitialVisibleFlag;
}
@ -189,7 +189,7 @@ int DuckmanMenuSystem::getGameState() {
}
void DuckmanMenuSystem::setMenuCursorNum(int cursorNum) {
Control *mouseCursor = _vm->getObjectControl(0x40004);
Control *mouseCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
_vm->setCursorActorIndex(5, cursorNum, 0);
mouseCursor->startSequenceActor(0x60001, 2, 0);
}

View File

@ -215,7 +215,7 @@ bool BaseMenuSystem::calcMenuItemIndexAtPoint(Common::Point pt, uint &menuItemIn
void BaseMenuSystem::setMousePos(Common::Point &mousePos) {
_vm->_input->setCursorPosition(mousePos);
Control *mouseCursor = _vm->getObjectControl(0x40004);
Control *mouseCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
mouseCursor->_actor->_position = mousePos;
}
@ -332,7 +332,7 @@ void BaseMenuSystem::openMenu(BaseMenu *menu) {
_cursorInitialVisibleFlag = initMenuCursor();
_savedCursorPos = _vm->_input->getCursorPosition();
_savedGameState = getGameState();
Control *cursorControl = _vm->getObjectControl(0x40004);
Control *cursorControl = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
_savedCursorActorIndex = cursorControl->_actor->_actorIndex;
_savedCursorSequenceId = cursorControl->_actor->_sequenceId;
@ -358,7 +358,7 @@ void BaseMenuSystem::closeMenu() {
_vm->_screenText->removeText();
hideActorHoverBackground();
hideActorTextColorRect();
Control *mouseCursor = _vm->getObjectControl(0x40004);
Control *mouseCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
setGameState(_savedGameState);
mouseCursor->_actor->_actorIndex = _savedCursorActorIndex;
mouseCursor->_actor->_position = _savedCursorPos;

View File

@ -45,12 +45,14 @@ SequenceOpcodes::~SequenceOpcodes() {
void SequenceOpcodes::execOpcode(Control *control, OpCall &opCall) {
if (!_opcodes[opCall._op])
error("SequenceOpcodes::execOpcode() Unimplemented opcode %d", opCall._op);
debug(3, "execOpcode(%d)", opCall._op);
debug(3, "execSequenceOpcode(%d) %s objectID: %08X", opCall._op, _opcodeNames[opCall._op].c_str(), control->_objectId);
(*_opcodes[opCall._op])(control, opCall);
}
typedef Common::Functor2Mem<Control*, OpCall&, void, SequenceOpcodes> SequenceOpcodeI;
#define OPCODE(op, func) _opcodes[op] = new SequenceOpcodeI(this, &SequenceOpcodes::func);
#define OPCODE(op, func) \
_opcodes[op] = new SequenceOpcodeI(this, &SequenceOpcodes::func); \
_opcodeNames[op] = #func;
void SequenceOpcodes::initOpcodes() {
// First clear everything

View File

@ -41,6 +41,7 @@ public:
protected:
IllusionsEngine *_vm;
SequenceOpcode *_opcodes[256];
Common::String _opcodeNames[256];
void initOpcodes();
void freeOpcodes();

View File

@ -39,14 +39,14 @@ CauseThread_Duckman::CauseThread_Duckman(IllusionsEngine_Duckman *vm, uint32 thr
int CauseThread_Duckman::onUpdate() {
if (_flag) {
if (_vm->getCurrentScene() == _sceneId) {
Control *cursorCursor = _vm->getObjectControl(0x40004);
Control *cursorCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
cursorCursor->appearActor();
_vm->_input->discardEvent(kEventLeftClick);
}
return kTSTerminate;
} else {
_sceneId = _vm->getCurrentScene();
Control *cursorCursor = _vm->getObjectControl(0x40004);
Control *cursorCursor = _vm->getObjectControl(Illusions::CURSOR_OBJECT_ID);
cursorCursor->disappearActor();
_vm->_input->discardEvent(kEventLeftClick);
_vm->startScriptThread(_triggerThreadId, _threadId);