diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/startrek/common.h | 5 | ||||
-rw-r--r-- | engines/startrek/menu.cpp | 2 | ||||
-rw-r--r-- | engines/startrek/object.h | 10 | ||||
-rw-r--r-- | engines/startrek/startrek.cpp | 16 | ||||
-rw-r--r-- | engines/startrek/startrek.h | 8 | ||||
-rw-r--r-- | engines/startrek/text.cpp | 2 |
6 files changed, 23 insertions, 20 deletions
diff --git a/engines/startrek/common.h b/engines/startrek/common.h index c84b9c4e43..c5e3efea04 100644 --- a/engines/startrek/common.h +++ b/engines/startrek/common.h @@ -36,7 +36,10 @@ Common::Rect getRectEncompassing(Common::Rect r1, Common::Rect r2); // Fixed-point (16.16) number -typedef int32 FixedInt; +typedef int32 Fixed32; + +// Fixed-point (8.8) number +typedef int16 Fixed16; } diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp index 50661be8ed..37ab57bc6d 100644 --- a/engines/startrek/menu.cpp +++ b/engines/startrek/menu.cpp @@ -540,7 +540,7 @@ void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) { _activeMenu->numButtons = _activeMenu->menuFile->size() / 16; for (int i = 0; i < _activeMenu->numButtons; i++) { - memset(&_activeMenu->sprites[i], 0, sizeof(Sprite)); + _activeMenu->sprites[i] = Sprite(); _gfx->addSprite(&_activeMenu->sprites[i]); _activeMenu->sprites[i].drawMode = 2; diff --git a/engines/startrek/object.h b/engines/startrek/object.h index cdcae7403f..8885390f60 100644 --- a/engines/startrek/object.h +++ b/engines/startrek/object.h @@ -40,7 +40,7 @@ struct Object { uint16 animType; Sprite sprite; char animationString4[10]; - uint16 scale; + Fixed16 scale; SharedPtr<FileStream> animFile; uint16 numAnimFrames; uint16 animFrame; @@ -59,12 +59,12 @@ struct Object { int16 iwDestPosition; // Fixed-point position values (16.16) used while walking. - FixedInt granularPosX; - FixedInt granularPosY; + Fixed32 granularPosX; + Fixed32 granularPosY; // Fixed-point speed values (16.16). - FixedInt speedX; - FixedInt speedY; + Fixed32 speedX; + Fixed32 speedY; Common::Point dest; // Position object is walking toward uint16 field90; diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 02c80efee1..efde236580 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -344,7 +344,7 @@ void StarTrekEngine::initObjects() { /** * Set an object's animation, position, and scale. */ -int StarTrekEngine::loadObjectAnim(int objectIndex, const Common::String &animName, int16 x, int16 y, uint16 scale) { +int StarTrekEngine::loadObjectAnim(int objectIndex, const Common::String &animName, int16 x, int16 y, Fixed16 scale) { debugC(6, kDebugGraphics, "Load animation '%s' on object %d", animName.c_str(), objectIndex); Object *object; @@ -576,7 +576,7 @@ void StarTrekEngine::objectFunc1() { } } -void StarTrekEngine::drawObjectToScreen(Object *object, const Common::String &_animName, int16 x, int16 y, uint16 scale, bool addSprite) { +void StarTrekEngine::drawObjectToScreen(Object *object, const Common::String &_animName, int16 x, int16 y, Fixed16 scale, bool addSprite) { Common::String animFilename = _animName; if (_animName.hasPrefixIgnoreCase("stnd") /* && word_45d20 == -1 */) // TODO animFilename += 'j'; @@ -762,7 +762,7 @@ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16 int32 absDistY = abs(distY); int32 distCounter; - FixedInt speedX, speedY; + Fixed32 speedX, speedY; if (absDistX > absDistY) { distCounter = absDistX; @@ -791,8 +791,8 @@ bool StarTrekEngine::directPathExists(int16 srcX, int16 srcY, int16 destX, int16 speedY = -1 << 16; } - FixedInt fixedX = srcX << 16; - FixedInt fixedY = srcY << 16; + Fixed32 fixedX = srcX << 16; + Fixed32 fixedY = srcY << 16; if (isPositionSolid((fixedX + 0x8000) >> 16, (fixedY + 0x8000) >> 16)) return false; @@ -837,7 +837,7 @@ int StarTrekEngine::findObjectAt(int x, int y) { int objectIndex = _room->readRdfWord(offset + 6); // word_4b418 = 1; // word_4a792 = _room->readRdfWord(offset + 2); - // word_4a796 = _room->readRdfWord(offset + 4); + // word_4a796 = _room->readRdfWord(offset + 4); // TODO return objectIndex; } @@ -861,7 +861,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, uint16 scale) { +SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed16 scale) { SharedPtr<Bitmap> bitmapToReturn; char basename[5]; @@ -1239,7 +1239,7 @@ exitWithoutSelection: /** * A scale of 256 is the baseline. */ -SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, uint16 scale) { +SharedPtr<Bitmap> StarTrekEngine::scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed16 scale) { int scaledWidth = (bitmap->width * scale) >> 8; int scaledHeight = (bitmap->height * scale) >> 8; int origWidth = bitmap->width; diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index 1e1dbc7598..f1a5176c94 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -246,12 +246,12 @@ public: // Objects void initObjects(); - int loadObjectAnim(int objectIndex, const Common::String &animName, int16 x, int16 y, uint16 arg8); + int loadObjectAnim(int objectIndex, const Common::String &animName, int16 x, int16 y, Fixed16 scale); bool objectWalkToPosition(int objectIndex, const Common::String &animFile, int16 srcX, int16 srcY, int16 destX, int16 destY); void updateObjectAnimations(); void removeObjectFromScreen(int objectIndex); void objectFunc1(); - void drawObjectToScreen(Object *object, const Common::String &animName, int16 x, int16 y, uint16 scale, bool addSprite); + void drawObjectToScreen(Object *object, const Common::String &animName, int16 x, int16 y, Fixed16 scale, bool addSprite); void releaseAnim(Object *object); void initStandAnim(int objectIndex); void updateObjectPositionWhileWalking(Object *object, int16 x, int16 y); @@ -260,13 +260,13 @@ 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, uint16 arg2); + SharedPtr<Bitmap> loadAnimationFrame(const Common::String &filename, Fixed16 scale); Common::String getCrewmanAnimFilename(int objectIndex, const Common::String &basename); void updateMouseBitmap(); void showInventoryIcons(bool showItem); void hideInventoryIcons(); int showInventoryMenu(int x, int y, bool restoreMouse); - SharedPtr<Bitmap> scaleBitmap(SharedPtr<Bitmap> bitmap, uint16 scale); + SharedPtr<Bitmap> scaleBitmap(SharedPtr<Bitmap> bitmap, Fixed16 scale); void scaleBitmapRow(byte *src, byte *dest, uint16 origWidth, uint16 scaledWidth); // Events diff --git a/engines/startrek/text.cpp b/engines/startrek/text.cpp index 239e4f5206..04b40bfee2 100644 --- a/engines/startrek/text.cpp +++ b/engines/startrek/text.cpp @@ -469,7 +469,7 @@ SharedPtr<TextBitmap> StarTrekEngine::initTextSprite(int *xoffsetPtr, int *yoffs SharedPtr<TextBitmap> bitmap(new TextBitmap(TEXTBOX_WIDTH*8, textHeight*8)); - memset(sprite, 0, sizeof(Sprite)); + *sprite = Sprite(); sprite->drawPriority = 15; sprite->drawPriority2 = 8; sprite->bitmap = bitmap; |