aboutsummaryrefslogtreecommitdiff
path: root/engines/startrek
diff options
context:
space:
mode:
authorFilippos Karapetis2019-06-10 01:16:48 +0300
committerFilippos Karapetis2019-06-11 00:48:15 +0300
commit3f7f1a24108b1333908e82fd01455ea4f863afd3 (patch)
treee8bc7506632e942dacb29b18afbaa1a9705bdb60 /engines/startrek
parent9ba6b79e1a0bd48fe69879a145c63296e631cf5f (diff)
downloadscummvm-rg350-3f7f1a24108b1333908e82fd01455ea4f863afd3.tar.gz
scummvm-rg350-3f7f1a24108b1333908e82fd01455ea4f863afd3.tar.bz2
scummvm-rg350-3f7f1a24108b1333908e82fd01455ea4f863afd3.zip
STARTREK: Remove the FileStream wrapper class
Diffstat (limited to 'engines/startrek')
-rw-r--r--engines/startrek/actors.cpp7
-rw-r--r--engines/startrek/bitmap.cpp5
-rw-r--r--engines/startrek/bitmap.h8
-rw-r--r--engines/startrek/filestream.cpp35
-rw-r--r--engines/startrek/filestream.h40
-rw-r--r--engines/startrek/font.cpp5
-rw-r--r--engines/startrek/graphics.cpp10
-rw-r--r--engines/startrek/graphics.h1
-rw-r--r--engines/startrek/iwfile.cpp2
-rw-r--r--engines/startrek/menu.cpp2
-rw-r--r--engines/startrek/module.mk1
-rw-r--r--engines/startrek/object.h8
-rw-r--r--engines/startrek/room.cpp3
-rw-r--r--engines/startrek/sound.cpp2
-rw-r--r--engines/startrek/space.cpp2
-rw-r--r--engines/startrek/space.h4
-rw-r--r--engines/startrek/startrek.cpp22
-rw-r--r--engines/startrek/startrek.h16
18 files changed, 56 insertions, 117 deletions
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp
index b2912497d2..1e0d8b6d2a 100644
--- a/engines/startrek/actors.cpp
+++ b/engines/startrek/actors.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "common/stream.h"
+#include "common/memstream.h"
+
#include "startrek/iwfile.h"
#include "startrek/room.h"
#include "startrek/startrek.h"
@@ -278,7 +281,7 @@ void StarTrekEngine::renderBanBelowSprites() {
_gfx->unlockScreenPixels();
}
-void StarTrekEngine::renderBan(byte *destPixels, SharedPtr<FileStream> banFile) {
+void StarTrekEngine::renderBan(byte *destPixels, FileStream banFile) {
uint16 offset = banFile->readUint16();
int32 size = banFile->readUint16();
@@ -761,7 +764,7 @@ SharedPtr<Bitmap> StarTrekEngine::loadAnimationFrame(const Common::String &filen
}
// Redraw face with xor file
- SharedPtr<FileStream> xorFile = loadFile(filename + ".xor");
+ FileStream xorFile = loadFile(filename + ".xor");
xorFile->seek(0, SEEK_SET);
uint16 xoffset = bitmap->xoffset - xorFile->readUint16();
uint16 yoffset = bitmap->yoffset - xorFile->readUint16();
diff --git a/engines/startrek/bitmap.cpp b/engines/startrek/bitmap.cpp
index c444a07b18..2d2a223c80 100644
--- a/engines/startrek/bitmap.cpp
+++ b/engines/startrek/bitmap.cpp
@@ -19,12 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "common/stream.h"
+#include "common/memstream.h"
+
#include "startrek/bitmap.h"
#include "startrek/startrek.h"
namespace StarTrek {
-Bitmap::Bitmap(SharedPtr<FileStream> stream) {
+Bitmap::Bitmap(FileStream stream) {
xoffset = stream->readUint16();
yoffset = stream->readUint16();
width = stream->readUint16();
diff --git a/engines/startrek/bitmap.h b/engines/startrek/bitmap.h
index 746562df49..8178f54e1a 100644
--- a/engines/startrek/bitmap.h
+++ b/engines/startrek/bitmap.h
@@ -23,13 +23,15 @@
#ifndef STARTREK_BITMAP_H
#define STARTREK_BITMAP_H
-#include "startrek/filestream.h"
-
#include "common/ptr.h"
#include "common/stream.h"
+#include "common/memstream.h"
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;
@@ -37,7 +39,7 @@ struct Bitmap {
int16 height;
byte *pixels;
- Bitmap(Common::SharedPtr<FileStream> stream);
+ Bitmap(FileStream stream);
Bitmap(const Bitmap &bitmap);
Bitmap(int w, int h);
~Bitmap();
diff --git a/engines/startrek/filestream.cpp b/engines/startrek/filestream.cpp
deleted file mode 100644
index b4b864416a..0000000000
--- a/engines/startrek/filestream.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "startrek/filestream.h"
-
-namespace StarTrek {
-
-FileStream::FileStream(byte *data, uint32 len, bool bigEndian) : Common::MemoryReadStreamEndian(data, len, bigEndian) {
- _data = data;
-}
-
-FileStream::~FileStream() {
- free(_data);
-}
-
-} // End of namespace StarTrek
diff --git a/engines/startrek/filestream.h b/engines/startrek/filestream.h
deleted file mode 100644
index 9f69d62686..0000000000
--- a/engines/startrek/filestream.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef STARTREK_FILESTREAM_H
-#define STARTREK_FILESTREAM_H
-
-#include "common/stream.h"
-#include "common/memstream.h"
-
-namespace StarTrek {
-
-class FileStream : public Common::MemoryReadStreamEndian {
-public:
- FileStream(byte *data, uint32 len, bool bigEndian);
- ~FileStream();
-
- byte *_data;
-};
-
-} // End of namespace StarTrek
-
-#endif
diff --git a/engines/startrek/font.cpp b/engines/startrek/font.cpp
index f9802348ed..a5f12a5b27 100644
--- a/engines/startrek/font.cpp
+++ b/engines/startrek/font.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "common/stream.h"
+#include "common/memstream.h"
+
#include "startrek/font.h"
namespace StarTrek {
@@ -28,7 +31,7 @@ static const byte CHARACTER_COUNT = 0x80;
static const byte CHARACTER_SIZE = 0x40;
Font::Font(StarTrekEngine *vm) : _vm(vm) {
- SharedPtr<FileStream> fontStream = _vm->loadFile("FONT.FNT");
+ FileStream fontStream = _vm->loadFile("FONT.FNT");
_characters = new Character[CHARACTER_COUNT];
diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index 5c6a1441b6..bc82100bc1 100644
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -139,11 +139,11 @@ void Graphics::loadPalette(const Common::String &paletteName) {
Common::String palFile = paletteName + ".PAL";
Common::String lutFile = paletteName + ".LUT";
- SharedPtr<FileStream> palStream = _vm->loadFile(palFile.c_str());
+ FileStream palStream = _vm->loadFile(palFile.c_str());
palStream->read(_palData, 256 * 3);
// Load LUT file
- SharedPtr<FileStream> lutStream = _vm->loadFile(lutFile.c_str());
+ FileStream lutStream = _vm->loadFile(lutFile.c_str());
lutStream->read(_lutData, 256);
}
@@ -220,7 +220,7 @@ void Graphics::decPaletteFadeLevel() {
void Graphics::loadPri(const Common::String &priFile) {
- SharedPtr<FileStream> priStream = _vm->loadFile(priFile + ".pri");
+ FileStream priStream = _vm->loadFile(priFile + ".pri");
priStream->read(_priData, SCREEN_WIDTH * SCREEN_HEIGHT / 2);
}
@@ -737,14 +737,14 @@ void Graphics::loadEGAData(const char *filename) {
if (!_egaData)
_egaData = new byte[256];
- SharedPtr<FileStream> egaStream = _vm->loadFile(filename);
+ FileStream egaStream = _vm->loadFile(filename);
egaStream->read(_egaData, 256);
}
void Graphics::drawBackgroundImage(const char *filename) {
// Draw an stjr BGD image (palette built-in)
- SharedPtr<FileStream> imageStream = _vm->loadFile(filename);
+ FileStream imageStream = _vm->loadFile(filename);
byte *palette = new byte[256 * 3];
imageStream->read(palette, 256 * 3);
diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h
index c0d7d272cf..deca9e550d 100644
--- a/engines/startrek/graphics.h
+++ b/engines/startrek/graphics.h
@@ -104,7 +104,6 @@ public:
SharedPtr<Bitmap> getMouseBitmap();
void warpMouse(int16 x, int16 y);
- void drawTextChar(::Graphics::Surface *surface, const Sprite &sprite, int x, int y, const Common::Rect &rect);
void drawSprite(const Sprite &sprite, ::Graphics::Surface *surface);
/**
* @param sprite The sprite to draw
diff --git a/engines/startrek/iwfile.cpp b/engines/startrek/iwfile.cpp
index d1e7355517..9f6eb44ebf 100644
--- a/engines/startrek/iwfile.cpp
+++ b/engines/startrek/iwfile.cpp
@@ -29,7 +29,7 @@ IWFile::IWFile(StarTrekEngine *vm, const Common::String &filename) {
_vm = vm;
- SharedPtr<FileStream> file = _vm->loadFile(filename);
+ FileStream file = _vm->loadFile(filename);
_numEntries = file->readUint16();
assert(_numEntries < MAX_KEY_POSITIONS);
diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp
index d284809268..9aec7ccf93 100644
--- a/engines/startrek/menu.cpp
+++ b/engines/startrek/menu.cpp
@@ -504,7 +504,7 @@ void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) {
_activeMenu = new Menu();
_activeMenu->nextMenu = oldMenu;
- SharedPtr<FileStream> stream = loadFile(mnuFilename + ".MNU");
+ FileStream stream = loadFile(mnuFilename + ".MNU");
_activeMenu->menuFile = stream;
_activeMenu->numButtons = _activeMenu->menuFile->size() / 16;
diff --git a/engines/startrek/module.mk b/engines/startrek/module.mk
index 0f82c852fc..e8012b572d 100644
--- a/engines/startrek/module.mk
+++ b/engines/startrek/module.mk
@@ -7,7 +7,6 @@ MODULE_OBJS = \
common.o \
detection.o \
events.o \
- filestream.o \
font.o \
graphics.o \
intro.o \
diff --git a/engines/startrek/object.h b/engines/startrek/object.h
index 6a32983ff1..1b945ffee6 100644
--- a/engines/startrek/object.h
+++ b/engines/startrek/object.h
@@ -28,14 +28,18 @@
#include "startrek/items.h"
#include "startrek/sprite.h"
+#include "common/ptr.h"
+#include "common/stream.h"
+#include "common/memstream.h"
#include "common/scummsys.h"
namespace StarTrek {
class StarTrekEngine;
-class FileStream;
class Room;
+// FIXME: Eventually get rid of Common::SharedPtr and dispose of file streams properly
+typedef Common::SharedPtr<Common::MemoryReadStreamEndian> FileStream;
// Objects 0-31 are "actors" that are drawn to the screen, are animated, etc.
// Objects 32-63 are "hotspots" corresponding to specific regions in the screen.
@@ -82,7 +86,7 @@ struct Actor {
Sprite sprite;
Common::String bitmapFilename;
Fixed8 scale;
- SharedPtr<FileStream> animFile;
+ FileStream animFile;
uint16 numAnimFrames;
uint16 animFrame;
uint32 frameToStartNextAnim;
diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp
index faf27eb4ce..d4f84d2b67 100644
--- a/engines/startrek/room.cpp
+++ b/engines/startrek/room.cpp
@@ -20,7 +20,6 @@
*
*/
-#include "startrek/filestream.h"
#include "startrek/iwfile.h"
#include "startrek/room.h"
#include "startrek/startrek.h"
@@ -46,7 +45,7 @@
namespace StarTrek {
Room::Room(StarTrekEngine *vm, const Common::String &name) : _vm(vm), _awayMission(&vm->_awayMission) {
- SharedPtr<FileStream> rdfFile = _vm->loadFile(name + ".RDF");
+ FileStream rdfFile = _vm->loadFile(name + ".RDF");
int size = rdfFile->size();
_rdfData = new byte[size];
diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp
index ae31727479..3b77228324 100644
--- a/engines/startrek/sound.cpp
+++ b/engines/startrek/sound.cpp
@@ -346,7 +346,7 @@ void Sound::loadPCMusicFile(const Common::String &baseSoundName) {
}
debugC(5, kDebugSound, "Loading midi \'%s\'\n", soundName.c_str());
- SharedPtr<FileStream> soundStream = _vm->loadFile(soundName.c_str());
+ FileStream soundStream = _vm->loadFile(soundName.c_str());
if (loadedSoundData != nullptr)
delete[] loadedSoundData;
diff --git a/engines/startrek/space.cpp b/engines/startrek/space.cpp
index 781993fb67..96a40da2ab 100644
--- a/engines/startrek/space.cpp
+++ b/engines/startrek/space.cpp
@@ -81,7 +81,7 @@ void StarTrekEngine::drawStarfield() {
int16 yvar = var2a / 2;
int16 var8 = _starfieldPointDivisor << 3;
- SharedPtr<FileStream> file = loadFile("stars.shp");
+ FileStream file = loadFile("stars.shp");
for (int i = 0; i < NUM_STARS; i++) {
Star *star = &_starList[i];
diff --git a/engines/startrek/space.h b/engines/startrek/space.h
index 075ea0951d..06e08b05ea 100644
--- a/engines/startrek/space.h
+++ b/engines/startrek/space.h
@@ -27,8 +27,6 @@
namespace StarTrek {
-class FileStream;
-
template<typename T>
struct TPoint {
T x;
@@ -172,7 +170,7 @@ struct R3 {
int32 field54; // 0x54 (used for sorting by draw priority?)
int16 field58; // 0x58
int16 field5a; // 0x5a
- SharedPtr<FileStream> shpFile; // 0x68
+ FileStream shpFile; // 0x68
int16 bitmapOffset; // 0x6a
double field80; // 0x80
double field88; // 0x88
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 6160f9caf3..6e197de15d 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -37,7 +37,6 @@
#include "engines/util.h"
#include "video/qt_decoder.h"
-#include "startrek/filestream.h"
#include "startrek/iwfile.h"
#include "startrek/lzss.h"
#include "startrek/room.h"
@@ -395,7 +394,7 @@ void StarTrekEngine::stopPlayingSpeech() {
* - This is supposed to read from a "patches" folder which overrides files in the
* packed blob.
*/
-SharedPtr<FileStream> StarTrekEngine::loadFile(Common::String filename, int fileIndex) {
+FileStream StarTrekEngine::loadFile(Common::String filename, int fileIndex) {
filename.toUppercase();
Common::String basename, extension;
@@ -430,7 +429,7 @@ SharedPtr<FileStream> StarTrekEngine::loadFile(Common::String filename, int file
byte *data = (byte *)malloc(size);
file->read(data, size);
delete file;
- return SharedPtr<FileStream>(new FileStream(data, size, bigEndian));
+ return Common::SharedPtr<Common::MemoryReadStreamEndian>(new Common::MemoryReadStreamEndian(data, size, bigEndian));
}
Common::SeekableReadStream *indexFile = 0;
@@ -560,10 +559,10 @@ SharedPtr<FileStream> StarTrekEngine::loadFile(Common::String filename, int file
stream->read(data, size);
delete stream;
- return SharedPtr<FileStream>(new FileStream(data, size, bigEndian));
+ return Common::SharedPtr<Common::MemoryReadStreamEndian>(new Common::MemoryReadStreamEndian(data, size, bigEndian));
}
-SharedPtr<FileStream> StarTrekEngine::loadFileWithParams(Common::String filename, bool unk1, bool unk2, bool unk3) {
+FileStream StarTrekEngine::loadFileWithParams(Common::String filename, bool unk1, bool unk2, bool unk3) {
return loadFile(filename);
}
@@ -619,15 +618,20 @@ uint16 StarTrekEngine::getRandomWord() {
}
Common::String StarTrekEngine::getLoadedText(int textIndex) {
- SharedPtr<FileStream> txtFile = loadFile(_txtFilename + ".txt");
+ FileStream txtFile = loadFile(_txtFilename + ".txt");
- byte *data = txtFile->_data;
+ Common::String str;
+ byte cur;
while (textIndex != 0) {
- while (*(data++) != '\0');
+ do {
+ cur = txtFile->readByte();
+ if (cur != '\0')
+ str += cur;
+ } while (cur != '\0');
textIndex--;
}
- return (char *)data;
+ return str;
}
} // End of namespace StarTrek
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index bfc8266e45..a47e0219b4 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -42,7 +42,6 @@
#include "startrek/action.h"
#include "startrek/awaymission.h"
-#include "startrek/filestream.h"
#include "startrek/graphics.h"
#include "startrek/items.h"
#include "startrek/object.h"
@@ -63,7 +62,8 @@ class StarTrekEngine;
class Room;
typedef String(StarTrekEngine::*TextGetterFunc)(int, uintptr, String *);
-
+// FIXME: Eventually get rid of Common::SharedPtr and dispose of file streams properly
+typedef Common::SharedPtr<Common::MemoryReadStreamEndian> FileStream;
const int SAVEGAME_DESCRIPTION_LEN = 30;
@@ -159,7 +159,7 @@ struct Menu {
Sprite sprites[MAX_MENUBUTTONS];
uint16 retvals[MAX_MENUBUTTONS];
uint32 disabledButtons;
- SharedPtr<FileStream> menuFile;
+ FileStream menuFile;
uint16 numButtons;
int16 selectedButton;
Menu *nextMenu;
@@ -247,11 +247,11 @@ public:
void playSpeech(const Common::String &filename);
void stopPlayingSpeech();
- SharedPtr<FileStream> loadFile(Common::String filename, int fileIndex = 0);
+ FileStream loadFile(Common::String filename, int fileIndex = 0);
/**
* TODO: Figure out what the extra parameters are, and if they're important.
*/
- SharedPtr<FileStream> loadFileWithParams(Common::String filename, bool unk1, bool unk2, bool unk3);
+ FileStream loadFileWithParams(Common::String filename, bool unk1, bool unk2, bool unk3);
void playMovie(Common::String filename);
void playMovieMac(Common::String filename);
@@ -379,7 +379,7 @@ public:
* "renderBanAboveSprites()" redraws sprites above them if necessary.
*/
void renderBanBelowSprites();
- void renderBan(byte *pixelDest, SharedPtr<FileStream> file);
+ void renderBan(byte *pixelDest, FileStream file);
void renderBanAboveSprites();
void removeActorFromScreen(int actorIndex);
void actorFunc1();
@@ -692,7 +692,7 @@ public:
int _roomIndex;
Common::String _screenName; // _screenName = _missionName + _roomIndex
Common::String _mapFilename; // Similar to _screenName, but used for .map files?
- SharedPtr<FileStream> _mapFile;
+ FileStream _mapFile;
Fixed16 _playerActorScale;
Common::String _txtFilename;
@@ -717,7 +717,7 @@ public:
// ".BAN" files provide extra miscellaneous animations in the room, ie. flashing
// pixels on computer consoles, or fireflies in front of the screen.
- SharedPtr<FileStream> _banFiles[MAX_BAN_FILES];
+ FileStream _banFiles[MAX_BAN_FILES];
uint16 _banFileOffsets[MAX_BAN_FILES];
Sprite _inventoryIconSprite;