ILLUSIONS: Replace spaces with tabs
Replace while(1) with do..while loop Removed dead code Renamed FP16 to FixedPoint16 to improve readability
This commit is contained in:
parent
d77dd6c14a
commit
3d9f5ed20f
18 changed files with 218 additions and 223 deletions
|
@ -771,9 +771,6 @@ PointArray *Control::createPath(Common::Point destPt) {
|
||||||
PathFinder pathFinder;
|
PathFinder pathFinder;
|
||||||
WidthHeight bgDimensions = _vm->_backgroundInstances->getMasterBgDimensions();
|
WidthHeight bgDimensions = _vm->_backgroundInstances->getMasterBgDimensions();
|
||||||
PointArray *path = pathFinder.findPath(_vm->_camera, _actor->_position, destPt, walkPoints, walkRects, bgDimensions);
|
PointArray *path = pathFinder.findPath(_vm->_camera, _actor->_position, destPt, walkPoints, walkRects, bgDimensions);
|
||||||
for (uint i = 0; i < path->size(); ++i) {
|
|
||||||
//debug(0, "Path(%d) (%d, %d)", i, (*path)[i].x, (*path)[i].y);
|
|
||||||
}
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,143 +781,140 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
||||||
static const int16 kAngleTbl[] = {60, 0, 120, 0, 60, 0, 120, 0};
|
static const int16 kAngleTbl[] = {60, 0, 120, 0, 60, 0, 120, 0};
|
||||||
bool fastWalked = false;
|
bool fastWalked = false;
|
||||||
|
|
||||||
while (1) {
|
do {
|
||||||
|
|
||||||
if (!fastWalked && _vm->testMainActorFastWalk(this)) {
|
if (!fastWalked && _vm->testMainActorFastWalk(this)) {
|
||||||
fastWalked = true;
|
fastWalked = true;
|
||||||
disappearActor();
|
disappearActor();
|
||||||
_actor->_flags |= Illusions::ACTOR_FLAG_8000;
|
_actor->_flags |= Illusions::ACTOR_FLAG_8000;
|
||||||
_actor->_seqCodeIp = 0;
|
_actor->_seqCodeIp = 0;
|
||||||
deltaTime = 2;
|
deltaTime = 2;
|
||||||
}
|
|
||||||
|
|
||||||
if (_vm->testMainActorCollision(this))
|
|
||||||
break;
|
|
||||||
|
|
||||||
Common::Point prevPt;
|
|
||||||
if (_actor->_pathPointIndex == 0) {
|
|
||||||
if (_actor->_pathInitialPosFlag) {
|
|
||||||
_actor->_pathCtrX = 0;
|
|
||||||
_actor->_pathInitialPos = _actor->_position;
|
|
||||||
_actor->_pathInitialPosFlag = false;
|
|
||||||
}
|
|
||||||
prevPt = _actor->_pathInitialPos;
|
|
||||||
} else {
|
|
||||||
prevPt = (*_actor->_pathNode)[_actor->_pathPointIndex - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::Point currPt = (*_actor->_pathNode)[_actor->_pathPointIndex];
|
|
||||||
|
|
||||||
int16 deltaX = currPt.x - prevPt.x;
|
|
||||||
int16 deltaY = currPt.y - prevPt.y;
|
|
||||||
|
|
||||||
if (!_actor->_pathFlag50) {
|
|
||||||
|
|
||||||
// TODO Move to own function
|
|
||||||
FP16 angle;
|
|
||||||
if (currPt.x == prevPt.x) {
|
|
||||||
if (prevPt.y >= currPt.y)
|
|
||||||
angle = fixedMul(-0x5A0000, 0x478);
|
|
||||||
else
|
|
||||||
angle = fixedMul(0x5A0000, 0x478);
|
|
||||||
} else {
|
|
||||||
angle = fixedAtan(fixedDiv(deltaY << 16, deltaX << 16));
|
|
||||||
}
|
|
||||||
_actor->_pathAngle = angle;
|
|
||||||
|
|
||||||
// TODO Move to own function
|
|
||||||
int16 v13 = (fixedTrunc(fixedMul(angle, 0x394BB8)) + 360) % 360;
|
|
||||||
if (deltaX >= 0)
|
|
||||||
v13 += 180;
|
|
||||||
v13 = (v13 + 90) % 360;
|
|
||||||
int16 v15 = kAngleTbl[0] / -2;
|
|
||||||
uint newFacing = 1;
|
|
||||||
for (uint i = 0; i < 8; ++i) {
|
|
||||||
v15 += kAngleTbl[i];
|
|
||||||
if (v13 < v15) {
|
|
||||||
newFacing = 1 << i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newFacing != _actor->_facing) {
|
|
||||||
refreshSequenceCode();
|
|
||||||
faceActor(newFacing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_actor->_pathFlag50 = true;
|
if (_vm->testMainActorCollision(this))
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FP16 deltaX24, deltaY24;
|
|
||||||
|
|
||||||
if (_actor->_flags & Illusions::ACTOR_FLAG_400) {
|
|
||||||
|
|
||||||
FP16 v20 = fixedMul((deltaTime + _actor->_pathCtrX) << 16, _actor->_pathCtrY << 16);
|
|
||||||
FP16 v21 = fixedDiv(v20, 100 << 16);
|
|
||||||
FP16 v22 = fixedMul(v21, _actor->_scale << 16);
|
|
||||||
FP16 v23 = fixedDiv(v22, 100 << 16);
|
|
||||||
_actor->_seqCodeValue1 = 100 * _actor->_pathCtrY * deltaTime / 100;
|
|
||||||
if (v23) {
|
|
||||||
FP16 prevDistance = fixedDistance(prevPt.x << 16, prevPt.y << 16, _actor->_posXShl, _actor->_posYShl);
|
|
||||||
FP16 distance = prevDistance + v23;
|
|
||||||
if (prevPt.x > currPt.x)
|
|
||||||
distance = -distance;
|
|
||||||
deltaX24 = fixedMul(fixedCos(_actor->_pathAngle), distance);
|
|
||||||
deltaY24 = fixedMul(fixedSin(_actor->_pathAngle), distance);
|
|
||||||
} else {
|
|
||||||
deltaX24 = _actor->_posXShl - (prevPt.x << 16);
|
|
||||||
deltaY24 = _actor->_posYShl - (prevPt.y << 16);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (100 * (int)deltaTime <= _actor->_seqCodeValue2)
|
|
||||||
break;
|
break;
|
||||||
deltaX24 = deltaX << 16;
|
|
||||||
deltaY24 = deltaY << 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ABS(deltaX24) < ABS(deltaX << 16) ||
|
Common::Point prevPt;
|
||||||
ABS(deltaY24) < ABS(deltaY << 16)) {
|
if (_actor->_pathPointIndex == 0) {
|
||||||
FP16 newX = (prevPt.x << 16) + deltaX24;
|
if (_actor->_pathInitialPosFlag) {
|
||||||
FP16 newY = (prevPt.y << 16) + deltaY24;
|
_actor->_pathCtrX = 0;
|
||||||
if (newX == _actor->_posXShl && newY == _actor->_posYShl) {
|
_actor->_pathInitialPos = _actor->_position;
|
||||||
_actor->_pathCtrX += deltaTime;
|
_actor->_pathInitialPosFlag = false;
|
||||||
|
}
|
||||||
|
prevPt = _actor->_pathInitialPos;
|
||||||
} else {
|
} else {
|
||||||
_actor->_pathCtrX = 0;
|
prevPt = (*_actor->_pathNode)[_actor->_pathPointIndex - 1];
|
||||||
_actor->_posXShl = newX;
|
|
||||||
_actor->_posYShl = newY;
|
|
||||||
_actor->_position.x = fixedTrunc(_actor->_posXShl);
|
|
||||||
_actor->_position.y = fixedTrunc(_actor->_posYShl);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_actor->_position = currPt;
|
Common::Point currPt = (*_actor->_pathNode)[_actor->_pathPointIndex];
|
||||||
_actor->_posXShl = _actor->_position.x << 16;
|
|
||||||
_actor->_posYShl = _actor->_position.y << 16;
|
int16 deltaX = currPt.x - prevPt.x;
|
||||||
--_actor->_pathPointsCount;
|
int16 deltaY = currPt.y - prevPt.y;
|
||||||
++_actor->_pathPointIndex;
|
|
||||||
++_actor->_pathPoints;
|
if (!_actor->_pathFlag50) {
|
||||||
_actor->_pathInitialPosFlag = true;
|
|
||||||
if (_actor->_pathPointsCount == 0) {
|
// TODO Move to own function
|
||||||
if (_actor->_flags & Illusions::ACTOR_FLAG_400) {
|
FixedPoint16 angle;
|
||||||
delete _actor->_pathNode;
|
if (currPt.x == prevPt.x) {
|
||||||
_actor->_flags &= ~Illusions::ACTOR_FLAG_400;
|
if (prevPt.y >= currPt.y)
|
||||||
|
angle = fixedMul(-0x5A0000, 0x478);
|
||||||
|
else
|
||||||
|
angle = fixedMul(0x5A0000, 0x478);
|
||||||
|
} else {
|
||||||
|
angle = fixedAtan(fixedDiv(deltaY << 16, deltaX << 16));
|
||||||
}
|
}
|
||||||
_actor->_pathNode = 0;
|
_actor->_pathAngle = angle;
|
||||||
_actor->_pathPoints = 0;
|
|
||||||
_actor->_pathPointsCount = 0;
|
// TODO Move to own function
|
||||||
_actor->_pathPointIndex = 0;
|
int16 v13 = (fixedTrunc(fixedMul(angle, 0x394BB8)) + 360) % 360; // 0x394BB8 is 180 / pi
|
||||||
if (_actor->_notifyId3C) {
|
if (deltaX >= 0)
|
||||||
_vm->notifyThreadId(_actor->_notifyId3C);
|
v13 += 180;
|
||||||
_actor->_walkCallerThreadId1 = 0;
|
v13 = (v13 + 90) % 360;
|
||||||
|
int16 v15 = kAngleTbl[0] / -2;
|
||||||
|
uint newFacing = 1;
|
||||||
|
for (uint i = 0; i < 8; ++i) {
|
||||||
|
v15 += kAngleTbl[i];
|
||||||
|
if (v13 < v15) {
|
||||||
|
newFacing = 1 << i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fastWalked = false;
|
if (newFacing != _actor->_facing) {
|
||||||
|
refreshSequenceCode();
|
||||||
|
faceActor(newFacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
_actor->_pathFlag50 = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
_actor->_pathFlag50 = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fastWalked)
|
FixedPoint16 deltaX24, deltaY24;
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
if (_actor->_flags & Illusions::ACTOR_FLAG_400) {
|
||||||
|
|
||||||
|
FixedPoint16 v20 = fixedMul((deltaTime + _actor->_pathCtrX) << 16, _actor->_pathCtrY << 16);
|
||||||
|
FixedPoint16 v21 = fixedDiv(v20, 100 << 16);
|
||||||
|
FixedPoint16 v22 = fixedMul(v21, _actor->_scale << 16);
|
||||||
|
FixedPoint16 v23 = fixedDiv(v22, 100 << 16);
|
||||||
|
_actor->_seqCodeValue1 = 100 * _actor->_pathCtrY * deltaTime / 100;
|
||||||
|
if (v23) {
|
||||||
|
FixedPoint16 prevDistance = fixedDistance(prevPt.x << 16, prevPt.y << 16, _actor->_posXShl, _actor->_posYShl);
|
||||||
|
FixedPoint16 distance = prevDistance + v23;
|
||||||
|
if (prevPt.x > currPt.x)
|
||||||
|
distance = -distance;
|
||||||
|
deltaX24 = fixedMul(fixedCos(_actor->_pathAngle), distance);
|
||||||
|
deltaY24 = fixedMul(fixedSin(_actor->_pathAngle), distance);
|
||||||
|
} else {
|
||||||
|
deltaX24 = _actor->_posXShl - (prevPt.x << 16);
|
||||||
|
deltaY24 = _actor->_posYShl - (prevPt.y << 16);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (100 * (int)deltaTime <= _actor->_seqCodeValue2)
|
||||||
|
break;
|
||||||
|
deltaX24 = deltaX << 16;
|
||||||
|
deltaY24 = deltaY << 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ABS(deltaX24) < ABS(deltaX << 16) ||
|
||||||
|
ABS(deltaY24) < ABS(deltaY << 16)) {
|
||||||
|
FixedPoint16 newX = (prevPt.x << 16) + deltaX24;
|
||||||
|
FixedPoint16 newY = (prevPt.y << 16) + deltaY24;
|
||||||
|
if (newX == _actor->_posXShl && newY == _actor->_posYShl) {
|
||||||
|
_actor->_pathCtrX += deltaTime;
|
||||||
|
} else {
|
||||||
|
_actor->_pathCtrX = 0;
|
||||||
|
_actor->_posXShl = newX;
|
||||||
|
_actor->_posYShl = newY;
|
||||||
|
_actor->_position.x = fixedTrunc(_actor->_posXShl);
|
||||||
|
_actor->_position.y = fixedTrunc(_actor->_posYShl);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_actor->_position = currPt;
|
||||||
|
_actor->_posXShl = _actor->_position.x << 16;
|
||||||
|
_actor->_posYShl = _actor->_position.y << 16;
|
||||||
|
--_actor->_pathPointsCount;
|
||||||
|
++_actor->_pathPointIndex;
|
||||||
|
++_actor->_pathPoints;
|
||||||
|
_actor->_pathInitialPosFlag = true;
|
||||||
|
if (_actor->_pathPointsCount == 0) {
|
||||||
|
if (_actor->_flags & Illusions::ACTOR_FLAG_400) {
|
||||||
|
delete _actor->_pathNode;
|
||||||
|
_actor->_flags &= ~Illusions::ACTOR_FLAG_400;
|
||||||
|
}
|
||||||
|
_actor->_pathNode = 0;
|
||||||
|
_actor->_pathPoints = 0;
|
||||||
|
_actor->_pathPointsCount = 0;
|
||||||
|
_actor->_pathPointIndex = 0;
|
||||||
|
if (_actor->_notifyId3C) {
|
||||||
|
_vm->notifyThreadId(_actor->_notifyId3C);
|
||||||
|
_actor->_walkCallerThreadId1 = 0;
|
||||||
|
}
|
||||||
|
fastWalked = false;
|
||||||
|
}
|
||||||
|
_actor->_pathFlag50 = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (fastWalked);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ void BbdouCredits::drawTextToControl(uint32 objectId, const char *text, uint ali
|
||||||
charToWChar(text, wtext, ARRAYSIZE(wtext));
|
charToWChar(text, wtext, ARRAYSIZE(wtext));
|
||||||
|
|
||||||
// TODO Extract to Actor class
|
// TODO Extract to Actor class
|
||||||
Control *control = _vm->getObjectControl(objectId);
|
Control *control = _vm->getObjectControl(objectId);
|
||||||
FontResource *font = _vm->_dict->findFont(_currFontId);
|
FontResource *font = _vm->_dict->findFont(_currFontId);
|
||||||
TextDrawer textDrawer;
|
TextDrawer textDrawer;
|
||||||
WidthHeight dimensions;
|
WidthHeight dimensions;
|
||||||
|
|
|
@ -60,7 +60,7 @@ CauseThread_BBDOU::CauseThread_BBDOU(IllusionsEngine_BBDOU *vm, uint32 threadId,
|
||||||
_sceneId(sceneId), _verbId(verbId), _objectId2(objectId2), _objectId(objectId) {
|
_sceneId(sceneId), _verbId(verbId), _objectId2(objectId2), _objectId(objectId) {
|
||||||
_type = kTTSpecialThread;
|
_type = kTTSpecialThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CauseThread_BBDOU::onNotify() {
|
void CauseThread_BBDOU::onNotify() {
|
||||||
_bbdou->_cursor->_data._causeThreadId1 = 0;
|
_bbdou->_cursor->_data._causeThreadId1 = 0;
|
||||||
terminate();
|
terminate();
|
||||||
|
|
|
@ -168,7 +168,7 @@ Common::Error IllusionsEngine_BBDOU::run() {
|
||||||
|
|
||||||
_screen->setColorKey1(0xF81F);
|
_screen->setColorKey1(0xF81F);
|
||||||
|
|
||||||
initInput();
|
initInput();
|
||||||
|
|
||||||
initUpdateFunctions();
|
initUpdateFunctions();
|
||||||
|
|
||||||
|
@ -188,10 +188,10 @@ Common::Error IllusionsEngine_BBDOU::run() {
|
||||||
ConfMan.registerDefault("talkspeed", 240);
|
ConfMan.registerDefault("talkspeed", 240);
|
||||||
_subtitleDuration = (uint16)ConfMan.getInt("talkspeed");
|
_subtitleDuration = (uint16)ConfMan.getInt("talkspeed");
|
||||||
|
|
||||||
_globalSceneId = 0x00010003;
|
_globalSceneId = 0x00010003;
|
||||||
|
|
||||||
setDefaultTextCoords();
|
setDefaultTextCoords();
|
||||||
|
|
||||||
_resSys->loadResource(0x000D0001, 0, 0);
|
_resSys->loadResource(0x000D0001, 0, 0);
|
||||||
|
|
||||||
_doScriptThreadInit = false;
|
_doScriptThreadInit = false;
|
||||||
|
@ -214,7 +214,7 @@ Common::Error IllusionsEngine_BBDOU::run() {
|
||||||
delete _stack;
|
delete _stack;
|
||||||
delete _scriptOpcodes;
|
delete _scriptOpcodes;
|
||||||
|
|
||||||
delete _soundMan;
|
delete _soundMan;
|
||||||
delete _updateFunctions;
|
delete _updateFunctions;
|
||||||
delete _threads;
|
delete _threads;
|
||||||
delete _triggerFunctions;
|
delete _triggerFunctions;
|
||||||
|
@ -230,9 +230,9 @@ Common::Error IllusionsEngine_BBDOU::run() {
|
||||||
delete _resSys;
|
delete _resSys;
|
||||||
delete _resReader;
|
delete _resReader;
|
||||||
delete _dict;
|
delete _dict;
|
||||||
|
|
||||||
debug("Ok");
|
debug("Ok");
|
||||||
|
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void causeDeclare(uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback);
|
void causeDeclare(uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback);
|
||||||
uint32 causeTrigger(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, uint32 callingThreadId);
|
uint32 causeTrigger(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, uint32 callingThreadId);
|
||||||
|
|
||||||
void setDefaultTextCoords();
|
void setDefaultTextCoords();
|
||||||
|
|
||||||
void loadSpecialCode(uint32 resId);
|
void loadSpecialCode(uint32 resId);
|
||||||
void unloadSpecialCode(uint32 resId);
|
void unloadSpecialCode(uint32 resId);
|
||||||
|
|
|
@ -488,11 +488,11 @@ void Camera::recalcPan(uint32 currTime) {
|
||||||
if (_activeState._panSpeed == 0) {
|
if (_activeState._panSpeed == 0) {
|
||||||
_activeState._time2E = 0;
|
_activeState._time2E = 0;
|
||||||
} else {
|
} else {
|
||||||
FP16 x1 = _activeState._currPan2.x << 16;
|
FixedPoint16 x1 = _activeState._currPan2.x << 16;
|
||||||
FP16 y1 = _activeState._currPan2.y << 16;
|
FixedPoint16 y1 = _activeState._currPan2.y << 16;
|
||||||
FP16 x2 = _activeState._panTargetPoint.x << 16;
|
FixedPoint16 x2 = _activeState._panTargetPoint.x << 16;
|
||||||
FP16 y2 = _activeState._panTargetPoint.y << 16;
|
FixedPoint16 y2 = _activeState._panTargetPoint.y << 16;
|
||||||
FP16 distance = fixedDistance(x1, y1, x2, y2);
|
FixedPoint16 distance = fixedDistance(x1, y1, x2, y2);
|
||||||
_activeState._time2E = 60 * fixedTrunc(distance) / _activeState._panSpeed;
|
_activeState._time2E = 60 * fixedTrunc(distance) / _activeState._panSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,20 +87,20 @@ public:
|
||||||
void removeActorType(uint32 id);
|
void removeActorType(uint32 id);
|
||||||
ActorType *findActorType(uint32 id);
|
ActorType *findActorType(uint32 id);
|
||||||
|
|
||||||
void addFont(uint32 id, FontResource *fontResource);
|
void addFont(uint32 id, FontResource *fontResource);
|
||||||
void removeFont(uint32 id);
|
void removeFont(uint32 id);
|
||||||
FontResource *findFont(uint32 id);
|
FontResource *findFont(uint32 id);
|
||||||
|
|
||||||
void addSequence(uint32 id, Sequence *sequence);
|
void addSequence(uint32 id, Sequence *sequence);
|
||||||
void removeSequence(uint32 id);
|
void removeSequence(uint32 id);
|
||||||
Sequence *findSequence(uint32 id);
|
Sequence *findSequence(uint32 id);
|
||||||
|
|
||||||
void addTalkEntry(uint32 id, TalkEntry *talkEntry);
|
void addTalkEntry(uint32 id, TalkEntry *talkEntry);
|
||||||
void removeTalkEntry(uint32 id);
|
void removeTalkEntry(uint32 id);
|
||||||
TalkEntry *findTalkEntry(uint32 id);
|
TalkEntry *findTalkEntry(uint32 id);
|
||||||
|
|
||||||
void setObjectControl(uint32 objectId, Control *control);
|
void setObjectControl(uint32 objectId, Control *control);
|
||||||
Control *getObjectControl(uint32 objectId);
|
Control *getObjectControl(uint32 objectId);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DictionaryHashMap<ActorType> _actorTypes;
|
DictionaryHashMap<ActorType> _actorTypes;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* ScummVM is the legal property of its developers, whose names
|
* ScummVM is the legal property of its developers, whose names
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
* file distributed with this source distribution.
|
* file distributed with this source distribution.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* ScummVM is the legal property of its developers, whose names
|
* ScummVM is the legal property of its developers, whose names
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
* file distributed with this source distribution.
|
* file distributed with this source distribution.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
|
|
@ -213,7 +213,7 @@ Common::Error IllusionsEngine_Duckman::run() {
|
||||||
|
|
||||||
delete _fader;
|
delete _fader;
|
||||||
|
|
||||||
delete _gameState;
|
delete _gameState;
|
||||||
delete _menuSystem;
|
delete _menuSystem;
|
||||||
delete _soundMan;
|
delete _soundMan;
|
||||||
delete _updateFunctions;
|
delete _updateFunctions;
|
||||||
|
|
|
@ -25,23 +25,23 @@
|
||||||
|
|
||||||
namespace Illusions {
|
namespace Illusions {
|
||||||
|
|
||||||
FP16 floatToFixed(float value) {
|
FixedPoint16 floatToFixed(float value) {
|
||||||
return value * 65536.0;
|
return value * 65536.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float fixedToFloat(FP16 value) {
|
float fixedToFloat(FixedPoint16 value) {
|
||||||
return value / 65536.0;
|
return value / 65536.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FP16 fixedMul(FP16 a, FP16 b) {
|
FixedPoint16 fixedMul(FixedPoint16 a, FixedPoint16 b) {
|
||||||
return ((float)a * b) / 65536.0;
|
return ((float)a * b) / 65536.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FP16 fixedDiv(FP16 a, FP16 b) {
|
FixedPoint16 fixedDiv(FixedPoint16 a, FixedPoint16 b) {
|
||||||
return ((float)a / b) * 65536.0;
|
return ((float)a / b) * 65536.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16 fixedTrunc(FP16 value) {
|
int16 fixedTrunc(FixedPoint16 value) {
|
||||||
// CHECKME Not sure if this correct
|
// CHECKME Not sure if this correct
|
||||||
int16 result = (value >> 16) & 0xFFFF;
|
int16 result = (value >> 16) & 0xFFFF;
|
||||||
if ((value & 0xFFFF) >= 0x8000)
|
if ((value & 0xFFFF) >= 0x8000)
|
||||||
|
@ -49,7 +49,7 @@ int16 fixedTrunc(FP16 value) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FP16 fixedDistance(FP16 x1, FP16 y1, FP16 x2, FP16 y2) {
|
FixedPoint16 fixedDistance(FixedPoint16 x1, FixedPoint16 y1, FixedPoint16 x2, FixedPoint16 y2) {
|
||||||
float xd = fixedToFloat(x1) - fixedToFloat(x2);
|
float xd = fixedToFloat(x1) - fixedToFloat(x2);
|
||||||
float yd = fixedToFloat(y1) - fixedToFloat(y2);
|
float yd = fixedToFloat(y1) - fixedToFloat(y2);
|
||||||
if (xd != 0.0 || yd != 0.0)
|
if (xd != 0.0 || yd != 0.0)
|
||||||
|
@ -57,16 +57,16 @@ FP16 fixedDistance(FP16 x1, FP16 y1, FP16 x2, FP16 y2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FP16 fixedAtan(FP16 value) {
|
FixedPoint16 fixedAtan(FixedPoint16 value) {
|
||||||
//return floatToFixed(atan2(1.0, fixedToFloat(value)));
|
//return floatToFixed(atan2(1.0, fixedToFloat(value)));
|
||||||
return floatToFixed(atan(fixedToFloat(value)));
|
return floatToFixed(atan(fixedToFloat(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
FP16 fixedCos(FP16 value) {
|
FixedPoint16 fixedCos(FixedPoint16 value) {
|
||||||
return floatToFixed(cos(fixedToFloat(value)));
|
return floatToFixed(cos(fixedToFloat(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
FP16 fixedSin(FP16 value) {
|
FixedPoint16 fixedSin(FixedPoint16 value) {
|
||||||
return floatToFixed(sin(fixedToFloat(value)));
|
return floatToFixed(sin(fixedToFloat(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,17 +27,17 @@
|
||||||
|
|
||||||
namespace Illusions {
|
namespace Illusions {
|
||||||
|
|
||||||
typedef int32 FP16;
|
typedef int32 FixedPoint16;
|
||||||
|
|
||||||
FP16 floatToFixed(float value);
|
FixedPoint16 floatToFixed(float value);
|
||||||
float fixedToFloat(FP16 value);
|
float fixedToFloat(FixedPoint16 value);
|
||||||
FP16 fixedMul(FP16 a, FP16 b);
|
FixedPoint16 fixedMul(FixedPoint16 a, FixedPoint16 b);
|
||||||
FP16 fixedDiv(FP16 a, FP16 b);
|
FixedPoint16 fixedDiv(FixedPoint16 a, FixedPoint16 b);
|
||||||
int16 fixedTrunc(FP16 value);
|
int16 fixedTrunc(FixedPoint16 value);
|
||||||
FP16 fixedDistance(FP16 x1, FP16 y1, FP16 x2, FP16 y2);
|
FixedPoint16 fixedDistance(FixedPoint16 x1, FixedPoint16 y1, FixedPoint16 x2, FixedPoint16 y2);
|
||||||
FP16 fixedAtan(FP16 value);
|
FixedPoint16 fixedAtan(FixedPoint16 value);
|
||||||
FP16 fixedCos(FP16 value);
|
FixedPoint16 fixedCos(FixedPoint16 value);
|
||||||
FP16 fixedSin(FP16 value);
|
FixedPoint16 fixedSin(FixedPoint16 value);
|
||||||
|
|
||||||
} // End of namespace Illusions
|
} // End of namespace Illusions
|
||||||
|
|
||||||
|
|
|
@ -262,12 +262,12 @@ void BaseMenuSystem::placeActorHoverBackground() {
|
||||||
|
|
||||||
WidthHeight frameDimensions;
|
WidthHeight frameDimensions;
|
||||||
v0->getActorFrameDimensions(frameDimensions);
|
v0->getActorFrameDimensions(frameDimensions);
|
||||||
|
|
||||||
FontResource *font = _vm->_dict->findFont(_activeMenu->_fontId);
|
FontResource *font = _vm->_dict->findFont(_activeMenu->_fontId);
|
||||||
int charHeight = font->getCharHeight() + font->getLineIncr();
|
int charHeight = font->getCharHeight() + font->getLineIncr();
|
||||||
if (frameDimensions._height < charHeight)
|
if (frameDimensions._height < charHeight)
|
||||||
charHeight = frameDimensions._height;
|
charHeight = frameDimensions._height;
|
||||||
|
|
||||||
v0->drawActorRect(Common::Rect(textInfoDimensions._width - 1, charHeight), _activeMenu->_fieldE);
|
v0->drawActorRect(Common::Rect(textInfoDimensions._width - 1, charHeight), _activeMenu->_fieldE);
|
||||||
|
|
||||||
updateActorHoverBackground();
|
updateActorHoverBackground();
|
||||||
|
@ -375,8 +375,8 @@ void BaseMenuSystem::handleClick(uint menuItemIndex, const Common::Point &mouseP
|
||||||
debug(0, "BaseMenuSystem::handleClick() menuItemIndex: %d click point: (%d, %d)", menuItemIndex, mousePos.x, mousePos.y);
|
debug(0, "BaseMenuSystem::handleClick() menuItemIndex: %d click point: (%d, %d)", menuItemIndex, mousePos.x, mousePos.y);
|
||||||
|
|
||||||
if (menuItemIndex == 0) {
|
if (menuItemIndex == 0) {
|
||||||
playSoundEffect14();
|
playSoundEffect14();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem *menuItem = _activeMenu->getMenuItem(menuItemIndex - 1);
|
MenuItem *menuItem = _activeMenu->getMenuItem(menuItemIndex - 1);
|
||||||
|
@ -434,7 +434,7 @@ uint BaseMenuSystem::drawMenuText(BaseMenu *menu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseMenuSystem::update(Control *cursorControl) {
|
void BaseMenuSystem::update(Control *cursorControl) {
|
||||||
Common::Point mousePos = _vm->_input->getCursorPosition();
|
Common::Point mousePos = _vm->_input->getCursorPosition();
|
||||||
setMousePos(mousePos);
|
setMousePos(mousePos);
|
||||||
|
|
||||||
uint newHoveredMenuItemIndex;
|
uint newHoveredMenuItemIndex;
|
||||||
|
@ -518,7 +518,7 @@ void BaseMenuSystem::setSavegameSlotNum(int slotNum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseMenuSystem::setSavegameDescription(Common::String desc) {
|
void BaseMenuSystem::setSavegameDescription(Common::String desc) {
|
||||||
_vm->_savegameDescription = desc;
|
_vm->_savegameDescription = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseMenuSystem::updateTimeOut(bool resetTimeOut) {
|
void BaseMenuSystem::updateTimeOut(bool resetTimeOut) {
|
||||||
|
@ -672,27 +672,28 @@ void MenuActionLoadGame::execute() {
|
||||||
|
|
||||||
// MenuActionSaveGame
|
// MenuActionSaveGame
|
||||||
|
|
||||||
MenuActionSaveGame::MenuActionSaveGame(BaseMenuSystem *menuSystem, uint choiceIndex)
|
MenuActionSaveGame::MenuActionSaveGame(BaseMenuSystem *menuSystem, uint choiceIndex)
|
||||||
: BaseMenuAction(menuSystem), _choiceIndex(choiceIndex) {
|
: BaseMenuAction(menuSystem), _choiceIndex(choiceIndex) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuActionSaveGame::execute() {
|
||||||
|
const Plugin *plugin = NULL;
|
||||||
|
EngineMan.findGame(ConfMan.get("gameid"), &plugin);
|
||||||
|
GUI::SaveLoadChooser *dialog;
|
||||||
|
Common::String desc;
|
||||||
|
int slot;
|
||||||
|
|
||||||
|
dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
|
||||||
|
slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
|
||||||
|
desc = dialog->getResultString().c_str();
|
||||||
|
|
||||||
|
delete dialog;
|
||||||
|
|
||||||
|
if (slot >= 0) {
|
||||||
|
_menuSystem->setSavegameSlotNum(slot);
|
||||||
|
_menuSystem->setSavegameDescription(desc);
|
||||||
|
_menuSystem->selectMenuChoiceIndex(_choiceIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuActionSaveGame::execute() {
|
|
||||||
const Plugin *plugin = NULL;
|
|
||||||
EngineMan.findGame(ConfMan.get("gameid"), &plugin);
|
|
||||||
GUI::SaveLoadChooser *dialog;
|
|
||||||
Common::String desc;
|
|
||||||
int slot;
|
|
||||||
|
|
||||||
dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
|
|
||||||
slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
|
|
||||||
desc = dialog->getResultString().c_str();
|
|
||||||
|
|
||||||
delete dialog;
|
|
||||||
|
|
||||||
if (slot >= 0) {
|
|
||||||
_menuSystem->setSavegameSlotNum(slot);
|
|
||||||
_menuSystem->setSavegameDescription(desc);
|
|
||||||
_menuSystem->selectMenuChoiceIndex(_choiceIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // End of namespace Illusions
|
} // End of namespace Illusions
|
||||||
|
|
|
@ -116,57 +116,57 @@ public:
|
||||||
protected:
|
protected:
|
||||||
IllusionsEngine *_vm;
|
IllusionsEngine *_vm;
|
||||||
MenuStack _menuStack;
|
MenuStack _menuStack;
|
||||||
|
|
||||||
uint32 _menuCallerThreadId;
|
uint32 _menuCallerThreadId;
|
||||||
bool _isTimeOutEnabled;
|
bool _isTimeOutEnabled;
|
||||||
bool _isTimeOutReached;
|
bool _isTimeOutReached;
|
||||||
uint32 _timeOutDuration;
|
uint32 _timeOutDuration;
|
||||||
uint _timeOutMenuChoiceIndex;
|
uint _timeOutMenuChoiceIndex;
|
||||||
uint32 _timeOutStartTime;
|
uint32 _timeOutStartTime;
|
||||||
uint32 _timeOutEndTime;
|
uint32 _timeOutEndTime;
|
||||||
|
|
||||||
Common::Point _savedCursorPos;
|
Common::Point _savedCursorPos;
|
||||||
bool _cursorInitialVisibleFlag;
|
bool _cursorInitialVisibleFlag;
|
||||||
int _savedGameState;
|
int _savedGameState;
|
||||||
int _savedCursorActorIndex;
|
int _savedCursorActorIndex;
|
||||||
int _savedCursorSequenceId;
|
int _savedCursorSequenceId;
|
||||||
|
|
||||||
bool _isActive;
|
bool _isActive;
|
||||||
|
|
||||||
MenuChoiceOffsets _menuChoiceOffsets;
|
MenuChoiceOffsets _menuChoiceOffsets;
|
||||||
int16 *_menuChoiceOffset;
|
int16 *_menuChoiceOffset;
|
||||||
|
|
||||||
uint _queryConfirmationChoiceIndex;
|
uint _queryConfirmationChoiceIndex;
|
||||||
|
|
||||||
uint _field54;
|
uint _field54;
|
||||||
uint _menuLinesCount;
|
uint _menuLinesCount;
|
||||||
uint _menuItemCount;
|
uint _menuItemCount;
|
||||||
|
|
||||||
uint _hoveredMenuItemIndex;
|
uint _hoveredMenuItemIndex;
|
||||||
uint _hoveredMenuItemIndex2;
|
uint _hoveredMenuItemIndex2;
|
||||||
uint _hoveredMenuItemIndex3;
|
uint _hoveredMenuItemIndex3;
|
||||||
|
|
||||||
BaseMenu *_activeMenu;
|
BaseMenu *_activeMenu;
|
||||||
void setMouseCursorToMenuItem(int menuItemIndex);
|
void setMouseCursorToMenuItem(int menuItemIndex);
|
||||||
|
|
||||||
void calcMenuItemRect(uint menuItemIndex, WRect &rect);
|
void calcMenuItemRect(uint menuItemIndex, WRect &rect);
|
||||||
bool calcMenuItemMousePos(uint menuItemIndex, Common::Point &pt);
|
bool calcMenuItemMousePos(uint menuItemIndex, Common::Point &pt);
|
||||||
bool calcMenuItemIndexAtPoint(Common::Point pt, uint &menuItemIndex);
|
bool calcMenuItemIndexAtPoint(Common::Point pt, uint &menuItemIndex);
|
||||||
void setMousePos(Common::Point &mousePos);
|
void setMousePos(Common::Point &mousePos);
|
||||||
|
|
||||||
void activateMenu(BaseMenu *menu);
|
void activateMenu(BaseMenu *menu);
|
||||||
|
|
||||||
void updateTimeOut(bool resetTimeOut);
|
void updateTimeOut(bool resetTimeOut);
|
||||||
|
|
||||||
void initActorHoverBackground();
|
void initActorHoverBackground();
|
||||||
void placeActorHoverBackground();
|
void placeActorHoverBackground();
|
||||||
void updateActorHoverBackground();
|
void updateActorHoverBackground();
|
||||||
void hideActorHoverBackground();
|
void hideActorHoverBackground();
|
||||||
|
|
||||||
void initActorTextColorRect();
|
void initActorTextColorRect();
|
||||||
void placeActorTextColorRect();
|
void placeActorTextColorRect();
|
||||||
void hideActorTextColorRect();
|
void hideActorTextColorRect();
|
||||||
|
|
||||||
virtual BaseMenu *getMenuById(int menuId) = 0;
|
virtual BaseMenu *getMenuById(int menuId) = 0;
|
||||||
virtual void playSoundEffect(int sfxId) = 0;
|
virtual void playSoundEffect(int sfxId) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
|
|
||||||
class ActorInstance : public ResourceInstance {
|
class ActorInstance : public ResourceInstance {
|
||||||
public:
|
public:
|
||||||
ActorInstance(IllusionsEngine *vm);
|
ActorInstance(IllusionsEngine *vm);
|
||||||
virtual void load(Resource *resource);
|
virtual void load(Resource *resource);
|
||||||
virtual void unload();
|
virtual void unload();
|
||||||
virtual void pause();
|
virtual void pause();
|
||||||
|
|
|
@ -30,8 +30,8 @@ namespace Illusions {
|
||||||
void MidiGroupResourceLoader::load(Resource *resource) {
|
void MidiGroupResourceLoader::load(Resource *resource) {
|
||||||
debug(1, "MidiGroupResourceLoader::load() Loading midi group %08X...", resource->_resId);
|
debug(1, "MidiGroupResourceLoader::load() Loading midi group %08X...", resource->_resId);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MidiGroupResourceLoader::isFlag(int flag) {
|
bool MidiGroupResourceLoader::isFlag(int flag) {
|
||||||
|
|
|
@ -141,11 +141,11 @@ public:
|
||||||
|
|
||||||
class ScriptInstance : public ResourceInstance {
|
class ScriptInstance : public ResourceInstance {
|
||||||
public:
|
public:
|
||||||
ScriptInstance(IllusionsEngine *vm);
|
ScriptInstance(IllusionsEngine *vm);
|
||||||
virtual void load(Resource *resource);
|
virtual void load(Resource *resource);
|
||||||
virtual void unload();
|
virtual void unload();
|
||||||
public:
|
public:
|
||||||
IllusionsEngine *_vm;
|
IllusionsEngine *_vm;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Illusions
|
} // End of namespace Illusions
|
||||||
|
|
|
@ -61,11 +61,11 @@ public:
|
||||||
|
|
||||||
class SoundGroupInstance : public ResourceInstance {
|
class SoundGroupInstance : public ResourceInstance {
|
||||||
public:
|
public:
|
||||||
SoundGroupInstance(IllusionsEngine *vm);
|
SoundGroupInstance(IllusionsEngine *vm);
|
||||||
virtual void load(Resource *resource);
|
virtual void load(Resource *resource);
|
||||||
virtual void unload();
|
virtual void unload();
|
||||||
public:
|
public:
|
||||||
IllusionsEngine *_vm;
|
IllusionsEngine *_vm;
|
||||||
SoundGroupResource *_soundGroupResource;
|
SoundGroupResource *_soundGroupResource;
|
||||||
uint32 _resId;
|
uint32 _resId;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue