aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/startrek/actors.cpp20
-rw-r--r--engines/startrek/bitmap.cpp16
-rw-r--r--engines/startrek/bitmap.h6
-rw-r--r--engines/startrek/graphics.cpp15
-rw-r--r--engines/startrek/graphics.h6
-rw-r--r--engines/startrek/intro.cpp12
-rw-r--r--engines/startrek/menu.cpp24
-rw-r--r--engines/startrek/room.cpp2
-rw-r--r--engines/startrek/rooms/demon4.cpp24
-rw-r--r--engines/startrek/rooms/demon6.cpp7
-rw-r--r--engines/startrek/space.cpp28
-rw-r--r--engines/startrek/space.h4
-rw-r--r--engines/startrek/sprite.cpp5
-rw-r--r--engines/startrek/sprite.h1
-rw-r--r--engines/startrek/startrek.cpp6
-rw-r--r--engines/startrek/startrek.h4
-rw-r--r--engines/startrek/textbox.cpp2
17 files changed, 93 insertions, 89 deletions
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp
index fa35468cd3..80704d7ac3 100644
--- a/engines/startrek/actors.cpp
+++ b/engines/startrek/actors.cpp
@@ -717,19 +717,19 @@ Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed
&& (c == 'm' || c == 's' || c == 'k' || c == 'r')) {
if (c == 'm') {
// Mccoy has the "base" animations for all crewmen
- bitmapToReturn = _gfx->loadBitmap(filename);
+ bitmapToReturn = new Bitmap(loadBitmapFile(filename));
} else {
// All crewman other than mccoy copy the animation frames from mccoy, change
// the colors of the uniforms, and load an "xor" file to redraw the face.
// TODO: The ".$bm" extension is a "virtual file"? Caches the changes to the
// file made here?
- // bitmapToReturn = _gfx->loadBitmap(filename + ".$bm");
+ // bitmapToReturn = new Bitmap(loadBitmapFile(filename + ".$bm"));
if (bitmapToReturn == nullptr) {
Common::String mccoyFilename = filename;
mccoyFilename.setChar('m', 0);
- Bitmap *bitmap = _gfx->loadBitmap(mccoyFilename);
+ Bitmap *bitmap = new Bitmap(loadBitmapFile(mccoyFilename));
uint16 width = bitmap->width;
uint16 height = bitmap->height;
@@ -796,7 +796,7 @@ Bitmap *StarTrekEngine::loadAnimationFrame(const Common::String &filename, Fixed
} else {
// TODO: when loading a bitmap, it passes a different argument than is standard to
// the "file loading with cache" function...
- bitmapToReturn = _gfx->loadBitmap(filename);
+ bitmapToReturn = new Bitmap(loadBitmapFile(filename));
}
if (scale != 1.0) {
@@ -1035,7 +1035,7 @@ void StarTrekEngine::showInventoryIcons(bool showItem) {
_itemIconSprite.pos.y = 10;
_itemIconSprite.drawPriority = 15;
_itemIconSprite.drawPriority2 = 8;
- _itemIconSprite.setBitmap(_gfx->loadBitmap(itemFilename));
+ _itemIconSprite.setBitmap(loadBitmapFile(itemFilename));
_inventoryIconSprite.pos.x = 46;
}
@@ -1046,7 +1046,7 @@ void StarTrekEngine::showInventoryIcons(bool showItem) {
_inventoryIconSprite.drawMode = 2;
_inventoryIconSprite.drawPriority = 15;
_inventoryIconSprite.drawPriority2 = 8;
- _inventoryIconSprite.setBitmap(_gfx->loadBitmap("inv00"));
+ _inventoryIconSprite.setBitmap(loadBitmapFile("inv00"));
}
bool StarTrekEngine::isObjectUnusable(int object, int action) {
@@ -1163,7 +1163,7 @@ int StarTrekEngine::showInventoryMenu(int x, int y, bool restoreMouse) {
itemSprites[i].pos.y = itemPositions[i].y;
itemSprites[i].drawPriority = 15;
itemSprites[i].drawPriority2 = 8;
- itemSprites[i].setBitmap(_gfx->loadBitmap(itemNames[i]));
+ itemSprites[i].setBitmap(loadBitmapFile(itemNames[i]));
}
chooseMousePositionFromSprites(itemSprites, numItems, -1, 4);
@@ -1183,11 +1183,11 @@ int StarTrekEngine::showInventoryMenu(int x, int y, bool restoreMouse) {
itemIndex = getMenuButtonAt(itemSprites, numItems, mousePos.x, mousePos.y);
if (itemIndex != lastItemIndex) {
if (lastItemIndex != -1) {
- drawMenuButtonOutline(itemSprites[lastItemIndex].bitmap, 0);
+ drawMenuButtonOutline(itemSprites[lastItemIndex].bitmap.get(), 0);
itemSprites[lastItemIndex].bitmapChanged = true;
}
if (itemIndex != -1) {
- drawMenuButtonOutline(itemSprites[itemIndex].bitmap, 15);
+ drawMenuButtonOutline(itemSprites[itemIndex].bitmap.get(), 15);
itemSprites[itemIndex].bitmapChanged = true;
}
lastItemIndex = itemIndex;
@@ -1266,7 +1266,7 @@ exitWithoutSelection:
_sound->playSoundEffectIndex(0x10);
if (lastItemIndex >= 0)
- drawMenuButtonOutline(itemSprites[lastItemIndex].bitmap, 0);
+ drawMenuButtonOutline(itemSprites[lastItemIndex].bitmap.get(), 0);
for (int i = 0; i < numItems; i++)
itemSprites[i].dontDrawNextFrame();
diff --git a/engines/startrek/bitmap.cpp b/engines/startrek/bitmap.cpp
index 9fa1d36f40..dee8f67154 100644
--- a/engines/startrek/bitmap.cpp
+++ b/engines/startrek/bitmap.cpp
@@ -27,7 +27,7 @@
namespace StarTrek {
-Bitmap::Bitmap(FileStream stream) {
+Bitmap::Bitmap(Common::MemoryReadStreamEndian *stream, bool closeStream) {
xoffset = stream->readUint16();
yoffset = stream->readUint16();
width = stream->readUint16();
@@ -36,17 +36,11 @@ Bitmap::Bitmap(FileStream stream) {
pixelsArraySize = width * height;
pixels = new byte[pixelsArraySize];
stream->read(pixels, width * height);
-}
-Bitmap::Bitmap(Common::MemoryReadStreamEndian *stream) {
- xoffset = stream->readUint16();
- yoffset = stream->readUint16();
- width = stream->readUint16();
- height = stream->readUint16();
-
- pixelsArraySize = width * height;
- pixels = new byte[pixelsArraySize];
- stream->read(pixels, width * height);
+ if (closeStream) {
+ delete stream;
+ stream = nullptr;
+ }
}
Bitmap::Bitmap(const Bitmap &bitmap) {
diff --git a/engines/startrek/bitmap.h b/engines/startrek/bitmap.h
index 6385d191fa..6eef47622b 100644
--- a/engines/startrek/bitmap.h
+++ b/engines/startrek/bitmap.h
@@ -29,9 +29,6 @@
namespace StarTrek {
-// FIXME: Eventually get rid of Common::SharedPtr and dispose of file streams properly
-typedef Common::SharedPtr<Common::MemoryReadStreamEndian> FileStream;
-
struct Bitmap {
int16 xoffset;
int16 yoffset;
@@ -39,8 +36,7 @@ struct Bitmap {
int16 height;
byte *pixels;
- Bitmap(FileStream stream);
- Bitmap(Common::MemoryReadStreamEndian *stream);
+ Bitmap(Common::MemoryReadStreamEndian *stream, bool closeStream = true);
Bitmap(const Bitmap &bitmap);
Bitmap(int w, int h);
~Bitmap();
diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index c782bc5ed6..1bef521b9e 100644
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -62,18 +62,21 @@ Graphics::Graphics(StarTrekEngine *vm) : _vm(vm), _egaMode(false) {
_paletteFadeLevel = 0;
_lockedMousePos = Common::Point(-1, -1);
+ _backgroundImage = nullptr;
}
Graphics::~Graphics() {
delete[] _egaData;
delete[] _palData;
delete[] _lutData;
+ delete _backgroundImage;
delete _font;
}
void Graphics::setBackgroundImage(Common::String imageName) {
- _backgroundImage = SharedPtr<Bitmap>(loadBitmap(imageName));
+ delete _backgroundImage;
+ _backgroundImage = new Bitmap(_vm->loadBitmapFile(imageName));
}
void Graphics::drawBitmapToBackground(const Common::Rect &origRect, const Common::Rect &drawRect, Bitmap *bitmap) {
@@ -238,15 +241,13 @@ byte Graphics::getPriValue(int x, int y) {
return b >> 4;
}
-Bitmap *Graphics::loadBitmap(Common::String basename) {
- return new Bitmap(SharedPtr<Common::MemoryReadStreamEndian>(_vm->loadFile(basename + ".BMP")));
-}
-
Common::Point Graphics::getMousePos() {
return _vm->_system->getEventManager()->getMousePos();
}
-void Graphics::setMouseBitmap(Bitmap *bitmap) {
+void Graphics::setMouseBitmap(Common::String bitmapName) {
+ Bitmap *bitmap = new Bitmap(_vm->loadBitmapFile(bitmapName));
+
CursorMan.pushCursor(
bitmap->pixels,
bitmap->width,
@@ -255,6 +256,8 @@ void Graphics::setMouseBitmap(Bitmap *bitmap) {
bitmap->yoffset,
0
);
+
+ delete bitmap;
}
void Graphics::popMouseBitmap() {
diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h
index 7b4bb06882..8f8656ded3 100644
--- a/engines/startrek/graphics.h
+++ b/engines/startrek/graphics.h
@@ -84,14 +84,12 @@ public:
void setPri(byte val);
byte getPriValue(int x, int y);
- Bitmap *loadBitmap(String basename);
-
Common::Point getMousePos();
/**
* Changes the mouse bitmap. The change won't take effect until drawAllSprites is
* called again.
*/
- void setMouseBitmap(Bitmap *bitmap);
+ void setMouseBitmap(Common::String bitmapName);
void popMouseBitmap();
void toggleMouse(bool visible);
@@ -166,7 +164,7 @@ private:
int16 _paletteFadeLevel;
Common::Rect _screenRect;
- SharedPtr<Bitmap> _backgroundImage;
+ Bitmap *_backgroundImage;
Sprite *_sprites[MAX_SPRITES];
int _numSprites;
diff --git a/engines/startrek/intro.cpp b/engines/startrek/intro.cpp
index dd791cb747..26f23557f9 100644
--- a/engines/startrek/intro.cpp
+++ b/engines/startrek/intro.cpp
@@ -40,7 +40,6 @@ void StarTrekEngine::playIntro() {
planetR3.field1e = 3;
planetR3.funcPtr1 = 0;
planetR3.funcPtr2 = 0;
- planetR3.bitmapOffset = 0;
_gfx->clearScreenAndPriBuffer();
_gfx->fadeoutScreen();
@@ -57,7 +56,7 @@ void StarTrekEngine::playIntro() {
Sprite subtitleSprite;
_gfx->addSprite(&subtitleSprite);
subtitleSprite.setXYAndPriority(0, 0, 12);
- subtitleSprite.setBitmap(_gfx->loadBitmap("blank"));
+ subtitleSprite.setBitmap(loadBitmapFile("blank"));
subtitleSprite.drawPriority2 = 16;
int index = 12;
@@ -151,7 +150,7 @@ void StarTrekEngine::playIntro() {
loadSubtitleSprite(2, &subtitleSprite);
planetR3.field22 = 2000;
planetR3.field24 = 10000 / _starfieldPointDivisor;
- planetR3.shpFile = SharedPtr<Common::MemoryReadStreamEndian>(loadFile("planet.shp"));
+ planetR3.bitmap = new Bitmap(loadFile("planet.shp"));
initIntroR3ObjectToMove(&planetR3, 6, 10000, 6, 10000, 0);
addR3(&planetR3);
initIntroR3ObjectToMove(&_enterpriseR3, -15, 250, 15, 500, 18);
@@ -164,7 +163,8 @@ void StarTrekEngine::playIntro() {
break;
case 366:
- planetR3.shpFile.reset();
+ delete planetR3.bitmap;
+ planetR3.bitmap = nullptr;
delR3(&planetR3);
break;
@@ -232,10 +232,10 @@ void StarTrekEngine::initIntroR3ObjectToMove(R3 *r3, int16 srcAngle, int16 srcDe
void StarTrekEngine::loadSubtitleSprite(int index, Sprite *sprite) {
if (_showSubtitles) {
if (index == -1)
- sprite->setBitmap(_gfx->loadBitmap("blank"));
+ sprite->setBitmap(loadBitmapFile("blank"));
else {
Common::String file = Common::String::format("tittxt%02d", index);
- sprite->setBitmap(_gfx->loadBitmap(file));
+ sprite->setBitmap(loadBitmapFile(file));
}
}
}
diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp
index 72531c8554..cb1c290cc8 100644
--- a/engines/startrek/menu.cpp
+++ b/engines/startrek/menu.cpp
@@ -159,7 +159,7 @@ void StarTrekEngine::chooseMousePositionFromSprites(Sprite *sprites, int numSpri
}
-void StarTrekEngine::drawMenuButtonOutline(SharedPtr<Bitmap> bitmap, byte color) {
+void StarTrekEngine::drawMenuButtonOutline(Bitmap *bitmap, byte color) {
int lineWidth = bitmap->width - 2;
int offsetToBottom = (bitmap->height - 3) * bitmap->width;
@@ -188,7 +188,7 @@ void StarTrekEngine::showOptionsMenu(int x, int y) {
_mouseControllingShip = false;
Common::Point oldMousePos = _gfx->getMousePos();
- _gfx->setMouseBitmap(_gfx->loadBitmap("options"));
+ _gfx->setMouseBitmap("options");
loadMenuButtons("options", x, y);
uint32 disabledButtons = 0;
@@ -307,7 +307,7 @@ int StarTrekEngine::showActionMenu() {
bool addEventBack = false;
int action = ACTION_WALK;
- menuSprite.setBitmap(_gfx->loadBitmap("action"));
+ menuSprite.setBitmap(loadBitmapFile("action"));
int menuWidth = menuSprite.bitmap->width;
int menuHeight = menuSprite.bitmap->height;
@@ -376,7 +376,7 @@ mousePosChanged: {
bitmapName = "walk";
}
- _gfx->setMouseBitmap(_gfx->loadBitmap(bitmapName));
+ _gfx->setMouseBitmap(bitmapName);
if (lockMousePoint.x != -1)
_gfx->lockMousePosition(lockMousePoint.x, lockMousePoint.y);
@@ -523,7 +523,7 @@ void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) {
}
bitmapBasename[10] = '\0';
- _activeMenu->sprites[i].setBitmap(_gfx->loadBitmap(bitmapBasename));
+ _activeMenu->sprites[i].setBitmap(loadBitmapFile(bitmapBasename));
_activeMenu->sprites[i].pos.x = stream->readUint16() + xpos;
_activeMenu->sprites[i].pos.y = stream->readUint16() + ypos;
_activeMenu->retvals[i] = stream->readUint16();
@@ -555,7 +555,7 @@ void StarTrekEngine::setVisibleMenuButtons(uint32 bits) {
if ((bits & spriteBitmask) == 0 || sprite->drawMode != 0) {
if ((bits & spriteBitmask) == 0 && sprite->drawMode == 2) {
if (i == _activeMenu->selectedButton) {
- drawMenuButtonOutline(sprite->bitmap, 0x00);
+ drawMenuButtonOutline(sprite->bitmap.get(), 0x00);
_activeMenu->selectedButton = -1;
}
@@ -592,7 +592,7 @@ void StarTrekEngine::disableMenuButtons(uint32 bits) {
if (_activeMenu->selectedButton != -1
&& (_activeMenu->disabledButtons & (1 << _activeMenu->selectedButton))) {
Sprite *sprite = &_activeMenu->sprites[_activeMenu->selectedButton];
- drawMenuButtonOutline(sprite->bitmap, 0x00);
+ drawMenuButtonOutline(sprite->bitmap.get(), 0x00);
sprite->bitmapChanged = true;
_activeMenu->selectedButton = -1;
@@ -622,12 +622,12 @@ int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool inTe
if (buttonIndex != _activeMenu->selectedButton) {
if (_activeMenu->selectedButton != -1) {
Sprite &spr = _activeMenu->sprites[_activeMenu->selectedButton];
- drawMenuButtonOutline(spr.bitmap, 0x00);
+ drawMenuButtonOutline(spr.bitmap.get(), 0x00);
spr.bitmapChanged = true;
}
if (buttonIndex != -1) {
Sprite &spr = _activeMenu->sprites[buttonIndex];
- drawMenuButtonOutline(spr.bitmap, 0xda);
+ drawMenuButtonOutline(spr.bitmap.get(), 0xda);
spr.bitmapChanged = true;
}
_activeMenu->selectedButton = buttonIndex;
@@ -835,7 +835,7 @@ rclick:
void StarTrekEngine::unloadMenuButtons() {
if (_activeMenu->selectedButton != -1)
- drawMenuButtonOutline(_activeMenu->sprites[_activeMenu->selectedButton].bitmap, 0x00);
+ drawMenuButtonOutline(_activeMenu->sprites[_activeMenu->selectedButton].bitmap.get(), 0x00);
for (int i = 0; i < _activeMenu->numButtons; i++) {
Sprite *sprite = &_activeMenu->sprites[i];
@@ -921,7 +921,7 @@ void StarTrekEngine::chooseMouseBitmapForAction(int action, bool withRedOutline)
break;
}
- _gfx->setMouseBitmap(_gfx->loadBitmap(bitmapName));
+ _gfx->setMouseBitmap(bitmapName);
}
void StarTrekEngine::showQuitGamePrompt(int x, int y) {
@@ -1134,7 +1134,7 @@ lclick:
if (!spriteLoaded) {
_gfx->addSprite(&someSprite);
someSprite.setXYAndPriority(3, 168, 15);
- someSprite.setBitmap(_gfx->loadBitmap(Common::String::format("turbo%d", clickedArea)));
+ someSprite.setBitmap(loadBitmapFile(Common::String::format("turbo%d", clickedArea)));
spriteLoaded = true;
}
} else {
diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp
index 84688acddc..45fd2b2d84 100644
--- a/engines/startrek/room.cpp
+++ b/engines/startrek/room.cpp
@@ -601,7 +601,7 @@ void Room::showBitmapFor5Ticks(const Common::String &bmpName, int priority) {
Sprite sprite;
_vm->_gfx->addSprite(&sprite);
sprite.setXYAndPriority(0, 0, priority);
- sprite.setBitmap(_vm->_gfx->loadBitmap(bmpName));
+ sprite.setBitmap(_vm->loadBitmapFile(bmpName));
_vm->_gfx->drawAllSprites();
diff --git a/engines/startrek/rooms/demon4.cpp b/engines/startrek/rooms/demon4.cpp
index 46ae5c8f4c..0028ad7a18 100644
--- a/engines/startrek/rooms/demon4.cpp
+++ b/engines/startrek/rooms/demon4.cpp
@@ -393,25 +393,25 @@ bool Room::demon4ShowSunPuzzle() {
_vm->_gfx->addSprite(&sprites[i]);
}
- sprites[0].setBitmap(_vm->_gfx->loadBitmap("levery"));
- sprites[1].setBitmap(_vm->_gfx->loadBitmap("leverr"));
- sprites[2].setBitmap(_vm->_gfx->loadBitmap("leverb"));
+ sprites[0].setBitmap(_vm->loadBitmapFile("levery"));
+ sprites[1].setBitmap(_vm->loadBitmapFile("leverr"));
+ sprites[2].setBitmap(_vm->loadBitmapFile("leverb"));
- SharedPtr<Bitmap> lightyBitmap = SharedPtr<Bitmap>(_vm->_gfx->loadBitmap("lighty"));
- SharedPtr<Bitmap> lightrBitmap = SharedPtr<Bitmap>(_vm->_gfx->loadBitmap("lightr"));
- SharedPtr<Bitmap> lightbBitmap = SharedPtr<Bitmap>(_vm->_gfx->loadBitmap("lightb"));
+ Bitmap *lightyBitmap = new Bitmap(_vm->loadBitmapFile("lighty"));
+ Bitmap *lightrBitmap = new Bitmap(_vm->loadBitmapFile("lightr"));
+ Bitmap *lightbBitmap = new Bitmap(_vm->loadBitmapFile("lightb"));
for (int i = 3; i < 9; i++)
- sprites[i].bitmap = lightyBitmap;
+ sprites[i].setBitmap(lightyBitmap);
for (int i = 9; i < 15; i++)
- sprites[i].bitmap = lightrBitmap;
+ sprites[i].setBitmap(lightrBitmap);
for (int i = 15; i < 21; i++)
- sprites[i].bitmap = lightbBitmap;
+ sprites[i].setBitmap(lightbBitmap);
Sprite doneButtonSprite;
_vm->_gfx->addSprite(&doneButtonSprite);
doneButtonSprite.setXYAndPriority(0x104, 0x64, 2);
- doneButtonSprite.setBitmap(_vm->_gfx->loadBitmap("donebutt"));
+ doneButtonSprite.setBitmap(_vm->loadBitmapFile("donebutt"));
// BUGFIX: use draw mode 2 so the entire button is clickable (not just non-transparent
// pixels)
doneButtonSprite.drawMode = 2;
@@ -532,6 +532,10 @@ done:
_vm->_gfx->copyBackgroundScreen();
_vm->_gfx->forceDrawAllSprites();
+ delete lightbBitmap;
+ delete lightrBitmap;
+ delete lightyBitmap;
+
return solved;
}
diff --git a/engines/startrek/rooms/demon6.cpp b/engines/startrek/rooms/demon6.cpp
index 38e274ef41..038f66dea8 100644
--- a/engines/startrek/rooms/demon6.cpp
+++ b/engines/startrek/rooms/demon6.cpp
@@ -466,7 +466,7 @@ int Room::demon6ShowCase(int visible) {
sprites[i].pos.y = spritePositions[i].y;
sprites[i].drawPriority = 2;
sprites[i].bitmapChanged = true;
- sprites[i].setBitmap(_vm->_gfx->loadBitmap(Common::String::format("stlitem%d", i)));
+ sprites[i].setBitmap(_vm->loadBitmapFile(Common::String::format("stlitem%d", i)));
}
Sprite buttonSprite;
@@ -478,7 +478,7 @@ int Room::demon6ShowCase(int visible) {
buttonSprite.pos.y = 0x19;
buttonSprite.drawPriority = 2;
buttonSprite.bitmapChanged = true;
- buttonSprite.setBitmap(_vm->_gfx->loadBitmap("donebutt"));
+ buttonSprite.setBitmap(_vm->loadBitmapFile("donebutt"));
_vm->_gfx->addSprite(&buttonSprite);
_vm->_gfx->forceDrawAllSprites();
@@ -579,8 +579,7 @@ int Room::demon6ShowCaseProcessSelection(Sprite *sprites, Sprite *clickedSprite,
_vm->_gfx->drawAllSprites();
_vm->_gfx->delSprite(clickedSprite);
clickedSprite->bitmap.reset();
- int i = clickedSprite - sprites;
- visible ^= (0x10 >> i);
+ visible ^= (0x10 >> (clickedSprite - sprites));
return visible;
}
diff --git a/engines/startrek/space.cpp b/engines/startrek/space.cpp
index 65f11f30ff..6da45f7170 100644
--- a/engines/startrek/space.cpp
+++ b/engines/startrek/space.cpp
@@ -116,7 +116,7 @@ void StarTrekEngine::drawStarfield() {
file->seek(fileOffset, SEEK_SET);
- Bitmap *bitmap = new Bitmap(file);
+ Bitmap *bitmap = new Bitmap(file, false);
if (!drawRect.isEmpty())
_gfx->drawBitmapToBackground(starRect, drawRect, bitmap);
delete bitmap;
@@ -238,9 +238,7 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
// TODO: call it
}
- if (r3->shpFile != nullptr) {
- r3->shpFile->seek(r3->bitmapOffset, SEEK_SET);
- SharedPtr<Bitmap> bitmap(new Bitmap(r3->shpFile));
+ if (r3->bitmap != nullptr) {
double dbl68 = ((double)r3->field24 * _starfieldPointDivisor) / r3->field36.z;
double dbl70 = 1.0 / dbl68;
@@ -278,24 +276,24 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
r3->field98 = dbl48;
// dbl30, (bitmap->xoffset + 2), r3->field58,
- double tmp = r3->field58 - (double)(bitmap->xoffset + 2) * dbl30;
+ double tmp = r3->field58 - (double)(r3->bitmap->xoffset + 2) * dbl30;
// dbl20, (bitmap->yoffset + 2), tmp
- double dbl10 = tmp - (double)(bitmap->yoffset + 2) * dbl20;
+ double dbl10 = tmp - (double)(r3->bitmap->yoffset + 2) * dbl20;
// dbl28, (bitmap->xoffset + 2), r3->field5a
- tmp = r3->field5a - (double)(bitmap->xoffset + 2) * dbl28;
+ tmp = r3->field5a - (double)(r3->bitmap->xoffset + 2) * dbl28;
// dbl18, (bitmap->yoffset + 2), tmp
- double dbl8 = tmp - (double)(bitmap->yoffset + 2) * dbl18;
+ double dbl8 = tmp - (double)(r3->bitmap->yoffset + 2) * dbl18;
// dbl60, r3->field58, bitmap->xoffset + 2
- tmp = (bitmap->xoffset + 2) - dbl60 * r3->field58;
+ tmp = (r3->bitmap->xoffset + 2) - dbl60 * r3->field58;
double dbl40 = tmp - dbl50 * r3->field5a;
- tmp = (bitmap->yoffset + 2) - dbl58 * r3->field58;
+ tmp = (r3->bitmap->yoffset + 2) - dbl58 * r3->field58;
double dbl38 = tmp - dbl48 * r3->field5a;
- double dbl3e4 = bitmap->width + 2;
- double dbl3ec = bitmap->height + 2;
+ double dbl3e4 = r3->bitmap->width + 2;
+ double dbl3ec = r3->bitmap->height + 2;
double thing[8];
tmp = 1.0 * dbl30;
@@ -424,8 +422,8 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
Bitmap tmpBitmap(256, 249);
byte *otherBuffer = new byte[256 * 256];
- int16 bitmapWidth = bitmap->width;
- int16 bitmapHeight = bitmap->height;
+ int16 bitmapWidth = r3->bitmap->width;
+ int16 bitmapHeight = r3->bitmap->height;
if (bitmapHeight > 245)
error("Shape height too big in drawR3Shape!");
@@ -447,7 +445,7 @@ void StarTrekEngine::drawR3Shape(R3 *r3) {
if (r3->field1e == 2) {
// TODO
} else
- _gfx->copyRectBetweenBitmaps(&tmpBitmap, 2, 2, bitmap.get(), 0, 0, bitmapWidth, bitmapHeight);
+ _gfx->copyRectBetweenBitmaps(&tmpBitmap, 2, 2, r3->bitmap, 0, 0, bitmapWidth, bitmapHeight);
byte *bgPixels = _gfx->getBackgroundPixels() + shpImageTop * SCREEN_WIDTH;
diff --git a/engines/startrek/space.h b/engines/startrek/space.h
index 06e08b05ea..d8fe6798dd 100644
--- a/engines/startrek/space.h
+++ b/engines/startrek/space.h
@@ -170,8 +170,8 @@ struct R3 {
int32 field54; // 0x54 (used for sorting by draw priority?)
int16 field58; // 0x58
int16 field5a; // 0x5a
- FileStream shpFile; // 0x68
- int16 bitmapOffset; // 0x6a
+ Bitmap *bitmap; // 0x68 (was: shpFile)
+ // 0x6a (was: bitmapOffset)
double field80; // 0x80
double field88; // 0x88
double field90; // 0x90
diff --git a/engines/startrek/sprite.cpp b/engines/startrek/sprite.cpp
index 8b042f2525..51a97ee89f 100644
--- a/engines/startrek/sprite.cpp
+++ b/engines/startrek/sprite.cpp
@@ -37,6 +37,11 @@ void Sprite::setBitmap(Bitmap *b) {
bitmapChanged = true;
}
+void Sprite::setBitmap(Common::MemoryReadStreamEndian *stream) {
+ bitmap = SharedPtr<Bitmap>(new Bitmap(stream));
+ bitmapChanged = true;
+}
+
void Sprite::setXYAndPriority(int16 x, int16 y, int16 priority) {
pos.x = x;
pos.y = y;
diff --git a/engines/startrek/sprite.h b/engines/startrek/sprite.h
index 5c9792be6a..73ba1c4541 100644
--- a/engines/startrek/sprite.h
+++ b/engines/startrek/sprite.h
@@ -62,6 +62,7 @@ struct Sprite : Common::Serializable {
Sprite();
void setBitmap(Bitmap *b);
+ void setBitmap(Common::MemoryReadStreamEndian *stream);
void setXYAndPriority(int16 x, int16 y, int16 priority);
void dontDrawNextFrame();
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index cd9ec63a34..6a312f3dd0 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -135,7 +135,7 @@ Common::Error StarTrekEngine::run() {
initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT);
initializeEventsAndMouse();
- _gfx->setMouseBitmap(_gfx->loadBitmap("pushbtn"));
+ _gfx->setMouseBitmap("pushbtn");
_gfx->toggleMouse(true);
bool shouldPlayIntro = true;
@@ -511,6 +511,10 @@ Common::MemoryReadStreamEndian *StarTrekEngine::loadFile(Common::String filename
return new Common::MemoryReadStreamEndian(data, size, bigEndian);
}
+Common::MemoryReadStreamEndian *StarTrekEngine::loadBitmapFile(Common::String baseName) {
+ return loadFile(baseName + ".BMP");
+}
+
Common::MemoryReadStreamEndian *StarTrekEngine::loadFileWithParams(Common::String filename, bool unk1, bool unk2, bool unk3) {
return loadFile(filename);
}
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 1c21201661..34feebe4ea 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -242,6 +242,8 @@ public:
void cleanupBridge() {}; // TODO
Common::MemoryReadStreamEndian *loadFile(Common::String filename, int fileIndex = 0);
+ Common::MemoryReadStreamEndian *loadBitmapFile(Common::String baseName);
+
/**
* TODO: Figure out what the extra parameters are, and if they're important.
*/
@@ -570,7 +572,7 @@ public:
* Draws or removes the outline on menu buttons when the cursor hovers on them, or leaves
* them.
*/
- void drawMenuButtonOutline(SharedPtr<Bitmap> bitmap, byte color);
+ void drawMenuButtonOutline(Bitmap *bitmap, byte color);
void showOptionsMenu(int x, int y);
/**
* Show the "action selection" menu, ie. look, talk, etc.
diff --git a/engines/startrek/textbox.cpp b/engines/startrek/textbox.cpp
index 4e5acfe6fa..2e213a7c39 100644
--- a/engines/startrek/textbox.cpp
+++ b/engines/startrek/textbox.cpp
@@ -310,7 +310,7 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
Common::Point oldMousePos = _gfx->getMousePos();
_gfx->warpMouse(xoffset + 0xde, yoffset - 0x08);
- _gfx->setMouseBitmap(_gfx->loadBitmap("pushbtn"));
+ _gfx->setMouseBitmap("pushbtn");
bool tmpMouseControllingShip = _mouseControllingShip;
_mouseControllingShip = false;