mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 22:58:09 +00:00
STARTREK: Don't memset sprites, add Fixed16 type
This commit is contained in:
parent
6117a89194
commit
ec2306f8b0
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user