aboutsummaryrefslogtreecommitdiff
path: root/engines/startrek
diff options
context:
space:
mode:
authorMatthew Stewart2018-07-18 23:58:28 -0400
committerEugene Sandulenko2018-08-09 08:37:30 +0200
commit710b9db0fd2e724dde746aa9b2319933fe21cbe0 (patch)
tree332bf6fb80e9336fdd71cb5bcaa4a7a7561bed6b /engines/startrek
parentac9cd1f00a28b09dd0202c90a2fe023bc8cba525 (diff)
downloadscummvm-rg350-710b9db0fd2e724dde746aa9b2319933fe21cbe0.tar.gz
scummvm-rg350-710b9db0fd2e724dde746aa9b2319933fe21cbe0.tar.bz2
scummvm-rg350-710b9db0fd2e724dde746aa9b2319933fe21cbe0.zip
STARTREK: Rename fixed-point types
Diffstat (limited to 'engines/startrek')
-rw-r--r--engines/startrek/awaymission.cpp12
-rw-r--r--engines/startrek/fixedint.h4
-rw-r--r--engines/startrek/object.h10
-rw-r--r--engines/startrek/room.h4
-rw-r--r--engines/startrek/startrek.cpp30
-rw-r--r--engines/startrek/startrek.h12
6 files changed, 36 insertions, 36 deletions
diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp
index 94ee86993c..911c760265 100644
--- a/engines/startrek/awaymission.cpp
+++ b/engines/startrek/awaymission.cpp
@@ -105,9 +105,9 @@ void StarTrekEngine::loadRoom(const Common::String &missionName, int roomIndex)
actorFunc1();
initActors();
- Fixed16 num = _room->getMaxScale() - _room->getMinScale();
+ Fixed8 num = _room->getMaxScale() - _room->getMinScale();
int16 den = _room->getMaxY() - _room->getMinY() + 1;
- _playerActorScale = Fixed32(num) / den;
+ _playerActorScale = Fixed16(num) / den;
// TODO: RDF vars 1e/1f and 20/21; relates to BAN files?
@@ -446,21 +446,21 @@ void StarTrekEngine::unloadRoom() {
* further up (away) the object is, the smaller it is.
*/
int StarTrekEngine::loadActorAnimWithRoomScaling(int actorIndex, const Common::String &animName, int16 x, int16 y) {
- Fixed16 scale = getActorScaleAtPosition(y);
+ Fixed8 scale = getActorScaleAtPosition(y);
return loadActorAnim(actorIndex, animName, x, y, scale);
}
-Fixed16 StarTrekEngine::getActorScaleAtPosition(int16 y) {
+Fixed8 StarTrekEngine::getActorScaleAtPosition(int16 y) {
int16 maxY = _room->getMaxY();
int16 minY = _room->getMinY();
- Fixed16 minScale = _room->getMinScale();
+ Fixed8 minScale = _room->getMinScale();
if (y > maxY)
y = maxY;
if (y < minY)
y = minY;
- return Fixed16(_playerActorScale * (y - minY)) + minScale;
+ return Fixed8(_playerActorScale * (y - minY)) + minScale;
}
SharedPtr<Room> StarTrekEngine::getRoom() {
diff --git a/engines/startrek/fixedint.h b/engines/startrek/fixedint.h
index a91e6b33d9..88e9c311e4 100644
--- a/engines/startrek/fixedint.h
+++ b/engines/startrek/fixedint.h
@@ -142,10 +142,10 @@ int32 operator*(const int16 lhs, const TFixedInt<T, totalBits, decimalBits> &rhs
typedef TFixedInt<int16, 16, 14> Fixed14;
// Fixed-point (8.8) number
-typedef TFixedInt<int16, 16, 8> Fixed16;
+typedef TFixedInt<int16, 16, 8> Fixed8;
// Fixed-point (16.16) number
-typedef TFixedInt<int32, 32, 16> Fixed32;
+typedef TFixedInt<int32, 32, 16> Fixed16;
}
diff --git a/engines/startrek/object.h b/engines/startrek/object.h
index e10a0f637f..4d3b270a02 100644
--- a/engines/startrek/object.h
+++ b/engines/startrek/object.h
@@ -81,7 +81,7 @@ struct Actor {
uint16 animType;
Sprite sprite;
char bitmapFilename[10];
- Fixed16 scale;
+ Fixed8 scale;
SharedPtr<FileStream> animFile;
uint16 numAnimFrames;
uint16 animFrame;
@@ -106,12 +106,12 @@ struct Actor {
int16 iwDestPosition;
// Fixed-point position values (16.16) used while walking.
- Fixed32 granularPosX;
- Fixed32 granularPosY;
+ Fixed16 granularPosX;
+ Fixed16 granularPosY;
// Fixed-point speed values (16.16).
- Fixed32 speedX;
- Fixed32 speedY;
+ Fixed16 speedX;
+ Fixed16 speedY;
Common::Point dest; // Position object is walking toward
uint16 field90;
diff --git a/engines/startrek/room.h b/engines/startrek/room.h
index 434ff76eb2..937d0ff213 100644
--- a/engines/startrek/room.h
+++ b/engines/startrek/room.h
@@ -66,8 +66,8 @@ public:
// the "max Y" value.
uint16 getMaxY() { return readRdfWord(0x06); }
uint16 getMinY() { return readRdfWord(0x08); }
- Fixed16 getMinScale() { return Fixed16::fromRaw(readRdfWord(0x0a)); }
- Fixed16 getMaxScale() { return Fixed16::fromRaw(readRdfWord(0x0c)); }
+ Fixed8 getMinScale() { return Fixed8::fromRaw(readRdfWord(0x0a)); }
+ Fixed8 getMaxScale() { return Fixed8::fromRaw(readRdfWord(0x0c)); }
// words 0x0e and 0x10 in RDF file are pointers to start and end of event code.
// That code is instead rewritten on a per-room basis.
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 9adba5fd85..e836e3bd68 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -538,7 +538,7 @@ void StarTrekEngine::initActors() {
/**
* Set an actor's animation, position, and scale.
*/
-int StarTrekEngine::loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed16 scale) {
+int StarTrekEngine::loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed8 scale) {
debugC(6, kDebugGraphics, "Load animation '%s' on actor %d", animName.c_str(), actorIndex);
Actor *actor;
@@ -695,8 +695,8 @@ void StarTrekEngine::updateActorAnimations() {
if (actor->field90 == 0)
break;
actor->field90--;
- Fixed32 newX = actor->granularPosX + actor->speedX;
- Fixed32 newY = actor->granularPosY + actor->speedY;
+ Fixed16 newX = actor->granularPosX + actor->speedX;
+ Fixed16 newY = actor->granularPosY + actor->speedY;
if ((actor->field90 & 3) == 0) {
sprite->bitmap.reset();
updateActorPositionWhileWalking(actor, (newX + 0.5).toInt(), (newY + 0.5).toInt());
@@ -771,7 +771,7 @@ void StarTrekEngine::actorFunc1() {
}
}
-void StarTrekEngine::drawActorToScreen(Actor *actor, const Common::String &_animName, int16 x, int16 y, Fixed16 scale, bool addSprite) {
+void StarTrekEngine::drawActorToScreen(Actor *actor, const Common::String &_animName, int16 x, int16 y, Fixed8 scale, bool addSprite) {
Common::String animFilename = _animName;
if (_animName.hasPrefixIgnoreCase("stnd") /* && word_45d20 == -1 */) // TODO
animFilename += 'j';
@@ -861,7 +861,7 @@ void StarTrekEngine::initStandAnim(int actorIndex) {
else // Default to facing south
animName = Common::String(actor->animationString) + 's';
- Fixed16 scale = getActorScaleAtPosition(actor->pos.y);
+ Fixed8 scale = getActorScaleAtPosition(actor->pos.y);
loadActorAnim(actorIndex, animName, actor->pos.x, actor->pos.y, scale);
actor->animType = 0;
}
@@ -918,7 +918,7 @@ void StarTrekEngine::chooseActorDirectionForWalking(Actor *actor, int16 srcX, in
else
actor->speedX = -1.0;
- actor->speedY = Fixed32(distY) / absDistX;
+ actor->speedY = Fixed16(distY) / absDistX;
}
}
else {
@@ -941,7 +941,7 @@ void StarTrekEngine::chooseActorDirectionForWalking(Actor *actor, int16 srcX, in
else
actor->speedY = -1.0;
- actor->speedX = Fixed32(distX) / absDistY;
+ actor->speedX = Fixed16(distX) / absDistY;
}
}
}
@@ -958,7 +958,7 @@ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16
int32 absDistY = abs(distY);
int32 distCounter;
- Fixed32 speedX, speedY;
+ Fixed16 speedX, speedY;
if (absDistX > absDistY) {
distCounter = absDistX;
@@ -966,7 +966,7 @@ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16
if (distCounter == 0)
return true;
- speedY = Fixed32(distY) / absDistX;
+ speedY = Fixed16(distY) / absDistX;
if (distX > 0)
speedX = 1.0;
@@ -979,7 +979,7 @@ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16
if (distCounter == 0)
return true;
- speedX = Fixed32(distX) / absDistY;
+ speedX = Fixed16(distX) / absDistY;
if (distY > 0)
speedY = 1.0;
@@ -987,8 +987,8 @@ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16
speedY = -1.0;
}
- Fixed32 fixedX = srcX;
- Fixed32 fixedY = srcY;
+ Fixed16 fixedX = srcX;
+ Fixed16 fixedY = srcY;
if (isPositionSolid((fixedX + 0.5).toInt(), (fixedY + 0.5).toInt()))
return false;
@@ -1057,7 +1057,7 @@ int StarTrekEngine::findObjectAt(int x, int y) {
/**
* Loads a bitmap for the animation frame with the given scale.
*/
-SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed16 scale) {
+SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed8 scale) {
SharedPtr<Bitmap> bitmapToReturn;
char basename[5];
@@ -1481,7 +1481,7 @@ void StarTrekEngine::updateCrewmanGetupTimers() {
}
else {
const char *dirs = "nsew";
- Fixed16 scale = getActorScaleAtPosition(actor->sprite.pos.y);
+ Fixed8 scale = getActorScaleAtPosition(actor->sprite.pos.y);
d = dirs[dir];
int16 xOffset = 0, yOffset = 0;
@@ -1679,7 +1679,7 @@ void StarTrekEngine::initStarfieldSprite(Sprite *sprite, SharedPtr<Bitmap> bitma
sprite->drawMode = 1;
}
-SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed16 scale) {
+SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 scale) {
int scaledWidth = scale.multToInt(bitmap->width);
int scaledHeight = scale.multToInt(bitmap->height);
int origWidth = bitmap->width;
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 1ec54f1ac3..aab4f3abb4 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -222,7 +222,7 @@ public:
void handleAwayMissionEvents();
void unloadRoom();
int loadActorAnimWithRoomScaling(int actorIndex, const Common::String &animName, int16 x, int16 y);
- Fixed16 getActorScaleAtPosition(int16 y);
+ Fixed8 getActorScaleAtPosition(int16 y);
void addAction(const Action &action);
void addAction(byte type, byte b1, byte b2, byte b3);
bool checkItemInteractionExists(int action, int activeItem, int passiveItem, int16 arg6);
@@ -284,12 +284,12 @@ public:
// Actors
void initActors();
- int loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed16 scale);
+ int loadActorAnim(int actorIndex, const Common::String &animName, int16 x, int16 y, Fixed8 scale);
bool actorWalkToPosition(int actorIndex, const Common::String &animFile, int16 srcX, int16 srcY, int16 destX, int16 destY);
void updateActorAnimations();
void removeActorFromScreen(int actorIndex);
void actorFunc1();
- void drawActorToScreen(Actor *actor, const Common::String &animName, int16 x, int16 y, Fixed16 scale, bool addSprite);
+ void drawActorToScreen(Actor *actor, const Common::String &animName, int16 x, int16 y, Fixed8 scale, bool addSprite);
void releaseAnim(Actor *actor);
void initStandAnim(int actorIndex);
void updateActorPositionWhileWalking(Actor *actor, int16 x, int16 y);
@@ -298,7 +298,7 @@ public:
int findObjectAt(int x, int y);
int findObjectAt(Common::Point p) { return findObjectAt(p.x, p.y); }
- SharedPtr<Bitmap> loadAnimationFrame(const Common::String &filename, Fixed16 scale);
+ SharedPtr<Bitmap> loadAnimationFrame(const Common::String &filename, Fixed8 scale);
int selectObjectForUseAction();
Common::String getCrewmanAnimFilename(int actorIndex, const Common::String &basename);
@@ -310,7 +310,7 @@ public:
void hideInventoryIcons();
int showInventoryMenu(int x, int y, bool restoreMouse);
void initStarfieldSprite(Sprite *sprite, SharedPtr<Bitmap> bitmap, const Common::Rect &rect);
- SharedPtr<Bitmap> scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed16 scale);
+ SharedPtr<Bitmap> scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed8 scale);
void scaleBitmapRow(byte *src, byte *dest, uint16 origWidth, uint16 scaledWidth);
// Events
@@ -459,7 +459,7 @@ public:
Common::String _screenName; // _screenName = _missionName + _roomIndex
Common::String _mapFilename; // Similar to _screenName, but used for .map files?
SharedPtr<FileStream> _mapFile;
- Fixed32 _playerActorScale;
+ Fixed16 _playerActorScale;
Common::String _txtFilename;
Common::String _loadedText; // TODO: might be OK to delete this