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;
|
||||
WidthHeight bgDimensions = _vm->_backgroundInstances->getMasterBgDimensions();
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -784,7 +781,7 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
|||
static const int16 kAngleTbl[] = {60, 0, 120, 0, 60, 0, 120, 0};
|
||||
bool fastWalked = false;
|
||||
|
||||
while (1) {
|
||||
do {
|
||||
|
||||
if (!fastWalked && _vm->testMainActorFastWalk(this)) {
|
||||
fastWalked = true;
|
||||
|
@ -817,7 +814,7 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
|||
if (!_actor->_pathFlag50) {
|
||||
|
||||
// TODO Move to own function
|
||||
FP16 angle;
|
||||
FixedPoint16 angle;
|
||||
if (currPt.x == prevPt.x) {
|
||||
if (prevPt.y >= currPt.y)
|
||||
angle = fixedMul(-0x5A0000, 0x478);
|
||||
|
@ -829,7 +826,7 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
|||
_actor->_pathAngle = angle;
|
||||
|
||||
// TODO Move to own function
|
||||
int16 v13 = (fixedTrunc(fixedMul(angle, 0x394BB8)) + 360) % 360;
|
||||
int16 v13 = (fixedTrunc(fixedMul(angle, 0x394BB8)) + 360) % 360; // 0x394BB8 is 180 / pi
|
||||
if (deltaX >= 0)
|
||||
v13 += 180;
|
||||
v13 = (v13 + 90) % 360;
|
||||
|
@ -851,18 +848,18 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
|||
|
||||
}
|
||||
|
||||
FP16 deltaX24, deltaY24;
|
||||
FixedPoint16 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);
|
||||
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) {
|
||||
FP16 prevDistance = fixedDistance(prevPt.x << 16, prevPt.y << 16, _actor->_posXShl, _actor->_posYShl);
|
||||
FP16 distance = prevDistance + 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);
|
||||
|
@ -880,8 +877,8 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
|||
|
||||
if (ABS(deltaX24) < ABS(deltaX << 16) ||
|
||||
ABS(deltaY24) < ABS(deltaY << 16)) {
|
||||
FP16 newX = (prevPt.x << 16) + deltaX24;
|
||||
FP16 newY = (prevPt.y << 16) + deltaY24;
|
||||
FixedPoint16 newX = (prevPt.x << 16) + deltaX24;
|
||||
FixedPoint16 newY = (prevPt.y << 16) + deltaY24;
|
||||
if (newX == _actor->_posXShl && newY == _actor->_posYShl) {
|
||||
_actor->_pathCtrX += deltaTime;
|
||||
} else {
|
||||
|
@ -917,10 +914,7 @@ void Control::updateActorMovement(uint32 deltaTime) {
|
|||
_actor->_pathFlag50 = false;
|
||||
}
|
||||
|
||||
if (!fastWalked)
|
||||
break;
|
||||
|
||||
}
|
||||
} while (fastWalked);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -488,11 +488,11 @@ void Camera::recalcPan(uint32 currTime) {
|
|||
if (_activeState._panSpeed == 0) {
|
||||
_activeState._time2E = 0;
|
||||
} else {
|
||||
FP16 x1 = _activeState._currPan2.x << 16;
|
||||
FP16 y1 = _activeState._currPan2.y << 16;
|
||||
FP16 x2 = _activeState._panTargetPoint.x << 16;
|
||||
FP16 y2 = _activeState._panTargetPoint.y << 16;
|
||||
FP16 distance = fixedDistance(x1, y1, x2, y2);
|
||||
FixedPoint16 x1 = _activeState._currPan2.x << 16;
|
||||
FixedPoint16 y1 = _activeState._currPan2.y << 16;
|
||||
FixedPoint16 x2 = _activeState._panTargetPoint.x << 16;
|
||||
FixedPoint16 y2 = _activeState._panTargetPoint.y << 16;
|
||||
FixedPoint16 distance = fixedDistance(x1, y1, x2, y2);
|
||||
_activeState._time2E = 60 * fixedTrunc(distance) / _activeState._panSpeed;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,23 +25,23 @@
|
|||
|
||||
namespace Illusions {
|
||||
|
||||
FP16 floatToFixed(float value) {
|
||||
FixedPoint16 floatToFixed(float value) {
|
||||
return value * 65536.0;
|
||||
}
|
||||
|
||||
float fixedToFloat(FP16 value) {
|
||||
float fixedToFloat(FixedPoint16 value) {
|
||||
return value / 65536.0;
|
||||
}
|
||||
|
||||
FP16 fixedMul(FP16 a, FP16 b) {
|
||||
FixedPoint16 fixedMul(FixedPoint16 a, FixedPoint16 b) {
|
||||
return ((float)a * b) / 65536.0;
|
||||
}
|
||||
|
||||
FP16 fixedDiv(FP16 a, FP16 b) {
|
||||
FixedPoint16 fixedDiv(FixedPoint16 a, FixedPoint16 b) {
|
||||
return ((float)a / b) * 65536.0;
|
||||
}
|
||||
|
||||
int16 fixedTrunc(FP16 value) {
|
||||
int16 fixedTrunc(FixedPoint16 value) {
|
||||
// CHECKME Not sure if this correct
|
||||
int16 result = (value >> 16) & 0xFFFF;
|
||||
if ((value & 0xFFFF) >= 0x8000)
|
||||
|
@ -49,7 +49,7 @@ int16 fixedTrunc(FP16 value) {
|
|||
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 yd = fixedToFloat(y1) - fixedToFloat(y2);
|
||||
if (xd != 0.0 || yd != 0.0)
|
||||
|
@ -57,16 +57,16 @@ FP16 fixedDistance(FP16 x1, FP16 y1, FP16 x2, FP16 y2) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
FP16 fixedAtan(FP16 value) {
|
||||
FixedPoint16 fixedAtan(FixedPoint16 value) {
|
||||
//return floatToFixed(atan2(1.0, fixedToFloat(value)));
|
||||
return floatToFixed(atan(fixedToFloat(value)));
|
||||
}
|
||||
|
||||
FP16 fixedCos(FP16 value) {
|
||||
FixedPoint16 fixedCos(FixedPoint16 value) {
|
||||
return floatToFixed(cos(fixedToFloat(value)));
|
||||
}
|
||||
|
||||
FP16 fixedSin(FP16 value) {
|
||||
FixedPoint16 fixedSin(FixedPoint16 value) {
|
||||
return floatToFixed(sin(fixedToFloat(value)));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,17 +27,17 @@
|
|||
|
||||
namespace Illusions {
|
||||
|
||||
typedef int32 FP16;
|
||||
typedef int32 FixedPoint16;
|
||||
|
||||
FP16 floatToFixed(float value);
|
||||
float fixedToFloat(FP16 value);
|
||||
FP16 fixedMul(FP16 a, FP16 b);
|
||||
FP16 fixedDiv(FP16 a, FP16 b);
|
||||
int16 fixedTrunc(FP16 value);
|
||||
FP16 fixedDistance(FP16 x1, FP16 y1, FP16 x2, FP16 y2);
|
||||
FP16 fixedAtan(FP16 value);
|
||||
FP16 fixedCos(FP16 value);
|
||||
FP16 fixedSin(FP16 value);
|
||||
FixedPoint16 floatToFixed(float value);
|
||||
float fixedToFloat(FixedPoint16 value);
|
||||
FixedPoint16 fixedMul(FixedPoint16 a, FixedPoint16 b);
|
||||
FixedPoint16 fixedDiv(FixedPoint16 a, FixedPoint16 b);
|
||||
int16 fixedTrunc(FixedPoint16 value);
|
||||
FixedPoint16 fixedDistance(FixedPoint16 x1, FixedPoint16 y1, FixedPoint16 x2, FixedPoint16 y2);
|
||||
FixedPoint16 fixedAtan(FixedPoint16 value);
|
||||
FixedPoint16 fixedCos(FixedPoint16 value);
|
||||
FixedPoint16 fixedSin(FixedPoint16 value);
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
||||
|
|
|
@ -672,11 +672,11 @@ void MenuActionLoadGame::execute() {
|
|||
|
||||
// MenuActionSaveGame
|
||||
|
||||
MenuActionSaveGame::MenuActionSaveGame(BaseMenuSystem *menuSystem, uint choiceIndex)
|
||||
MenuActionSaveGame::MenuActionSaveGame(BaseMenuSystem *menuSystem, uint choiceIndex)
|
||||
: BaseMenuAction(menuSystem), _choiceIndex(choiceIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
void MenuActionSaveGame::execute() {
|
||||
void MenuActionSaveGame::execute() {
|
||||
const Plugin *plugin = NULL;
|
||||
EngineMan.findGame(ConfMan.get("gameid"), &plugin);
|
||||
GUI::SaveLoadChooser *dialog;
|
||||
|
@ -694,5 +694,6 @@ void MenuActionLoadGame::execute() {
|
|||
_menuSystem->setSavegameDescription(desc);
|
||||
_menuSystem->selectMenuChoiceIndex(_choiceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Illusions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue