aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xengines/startrek/font.cpp4
-rwxr-xr-xengines/startrek/graphics.cpp21
-rwxr-xr-xengines/startrek/graphics.h55
-rwxr-xr-xengines/startrek/module.mk4
-rwxr-xr-xengines/startrek/sound.cpp8
-rw-r--r--engines/startrek/sprite.cpp35
-rw-r--r--engines/startrek/sprite.h63
-rwxr-xr-xengines/startrek/startrek.cpp59
-rwxr-xr-xengines/startrek/startrek.h18
-rw-r--r--engines/startrek/text.cpp271
10 files changed, 469 insertions, 69 deletions
diff --git a/engines/startrek/font.cpp b/engines/startrek/font.cpp
index a6f583a312..db310425a0 100755
--- a/engines/startrek/font.cpp
+++ b/engines/startrek/font.cpp
@@ -31,15 +31,13 @@ static const byte CHARACTER_COUNT = 0x80;
static const byte CHARACTER_SIZE = 0x40;
Font::Font(StarTrekEngine *vm) : _vm(vm) {
- Common::SeekableReadStream *fontStream = _vm->openFile("FONT.FNT");
+ SharedPtr<Common::SeekableReadStream> fontStream = _vm->openFile("FONT.FNT");
_characters = new Character[CHARACTER_COUNT];
for (byte i = 0; i < CHARACTER_COUNT; i++)
fontStream->read(_characters[i].data, CHARACTER_SIZE);
- delete fontStream;
-
#if 0
// Code to dump the font
printf ("DUMPING FONT");
diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index 039f62ac4b..307efcb1b5 100755
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -42,7 +42,7 @@ Graphics::Graphics(StarTrekEngine *vm) : _vm(vm), _egaMode(false) {
if (_vm->getGameType() == GType_ST25 && _vm->getPlatform() == Common::kPlatformDOS)
_font = new Font(_vm);
- _backgroundImage = new Bitmap(_vm->openFile("DEMON0.BMP"));
+ _backgroundImage = new Bitmap(_vm->openFile("DEMON0.BMP").get());
_canvas = new Bitmap(SCREEN_WIDTH, SCREEN_HEIGHT);
_numSprites = 0;
@@ -67,15 +67,14 @@ void Graphics::loadEGAData(const char *filename) {
if (!_egaData)
_egaData = new byte[256];
- Common::SeekableReadStream *egaStream = _vm->openFile(filename);
+ SharedPtr<Common::SeekableReadStream> egaStream = _vm->openFile(filename);
egaStream->read(_egaData, 256);
- delete egaStream;
}
void Graphics::drawBackgroundImage(const char *filename) {
// Draw an stjr BGD image (palette built-in)
- Common::SeekableReadStream *imageStream = _vm->openFile(filename);
+ SharedPtr<Common::SeekableReadStream> imageStream = _vm->openFile(filename);
byte *palette = new byte[256 * 3];
imageStream->read(palette, 256 * 3);
@@ -96,7 +95,6 @@ void Graphics::drawBackgroundImage(const char *filename) {
_vm->_system->updateScreen();
delete[] palette;
- delete imageStream;
}
@@ -105,7 +103,7 @@ void Graphics::loadPalette(const Common::String &paletteName) {
Common::String palFile = paletteName + ".PAL";
Common::String lutFile = paletteName + ".LUT";
- Common::SeekableReadStream *palStream = _vm->openFile(palFile.c_str());
+ SharedPtr<Common::SeekableReadStream> palStream = _vm->openFile(palFile.c_str());
byte *palette = new byte[256 * 3];
palStream->read(palette, 256 * 3);
@@ -117,26 +115,27 @@ void Graphics::loadPalette(const Common::String &paletteName) {
_vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
delete[] palette;
- delete palStream;
// Load LUT file
- Common::SeekableReadStream *lutStream = _vm->openFile(lutFile.c_str());
+ SharedPtr<Common::SeekableReadStream> lutStream = _vm->openFile(lutFile.c_str());
delete[] _lutData;
_lutData = new byte[256];
lutStream->read(_lutData, 256);
-
- delete lutStream;
}
void Graphics::loadPri(const char *priFile) {
- Common::SeekableReadStream *priStream = _vm->openFile(priFile);
+ SharedPtr<Common::SeekableReadStream> priStream = _vm->openFile(priFile);
delete[] _priData;
_priData = new byte[SCREEN_WIDTH*SCREEN_HEIGHT/2];
priStream->read(_priData, SCREEN_WIDTH*SCREEN_HEIGHT/2);
}
+SharedPtr<Bitmap> Graphics::loadBitmap(Common::String basename) {
+ return SharedPtr<Bitmap>(new Bitmap(_vm->openFile(basename+".BMP").get()));
+}
+
void Graphics::redrawScreen() {
// TODO: get rid of _canvas for efficiency
memcpy(_canvas->pixels, _backgroundImage->pixels, SCREEN_WIDTH*SCREEN_HEIGHT);
diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h
index cefbf70e5f..ef146a2d7a 100755
--- a/engines/startrek/graphics.h
+++ b/engines/startrek/graphics.h
@@ -27,12 +27,16 @@
#define STARTREK_GRAPHICS_H
#include "startrek/bitmap.h"
-#include "startrek/startrek.h"
#include "startrek/font.h"
+#include "startrek/startrek.h"
+#include "startrek/sprite.h"
+#include "common/ptr.h"
#include "common/rect.h"
#include "common/stream.h"
+using Common::SharedPtr;
+
namespace StarTrek {
class Font;
@@ -44,24 +48,11 @@ const int SCREEN_HEIGHT = 200;
const int MAX_SPRITES = 32;
+const int TEXTBOX_WIDTH = 26;
-struct Sprite {
- uint16 x,y;
- uint16 drawPriority;
- uint16 field6;
- uint16 field8;
- Bitmap *bitmap;
- uint16 drawMode;
- uint16 textColor;
- uint16 bitmapChanged;
- uint16 redrawCondition2;
- uint16 redrawCondition3;
- uint16 field16;
- Common::Rect rectangle1;
- Common::Rect clickRectangle;
- Common::Rect rectangle2;
- uint16 drawX,drawY;
-};
+
+class Graphics;
+typedef Common::String (Graphics::*TextGetterFunc)(int, int, Common::String *);
class Graphics {
@@ -75,6 +66,8 @@ public:
void loadPalette(const Common::String &paletteFile);
void loadPri(const char *priFile);
+ SharedPtr<Bitmap> loadBitmap(Common::String basename);
+
void redrawScreen();
void drawSprite(const Sprite &sprite);
void drawSprite(const Sprite &sprite, const Common::Rect &rect);
@@ -102,6 +95,32 @@ private:
Sprite *_sprites[MAX_SPRITES];
int _numSprites;
+
+ Common::Point _mousePos;
+ Sprite _mouseSprite;
+
+
+ // text.cpp (TODO: separate class)
+public:
+ int showText(TextGetterFunc textGetter, int var, int xoffset, int yoffset, int textColor, int argC, int maxTextLines, int arg10);
+ Common::String tmpFunction(int choiceIndex, int var, Common::String *speakerTextOutput);
+ SharedPtr<TextBitmap> initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite);
+
+private:
+ Common::String skipOverAudioPrompt(const Common::String &str);
+ int getNumLines(const Common::String &str);
+ Common::String readLineFormattedText(TextGetterFunc textGetter, int var, int choiceIndex, SharedPtr<TextBitmap> textBitmap, int numTextboxLines, int *numLines);
+ void loadTextButtons(Common::String mnuFilename, int xpos, int ypos);
+ void warpMousePosition(int x, int y);
+
+ uint16 _textboxVar1;
+ uint32 _textboxVar2;
+ uint32 _textboxVar3;
+ uint16 _textboxVar4;
+ uint16 _textboxVar5;
+ uint16 _textboxVar6;
+ uint16 _textboxVar7;
+ bool _textboxHasMultipleChoices;
};
}
diff --git a/engines/startrek/module.mk b/engines/startrek/module.mk
index c47c19a3b0..e2670b443a 100755
--- a/engines/startrek/module.mk
+++ b/engines/startrek/module.mk
@@ -8,7 +8,9 @@ MODULE_OBJS = \
lzss.o \
graphics.o \
sound.o \
- startrek.o
+ sprite.o \
+ startrek.o \
+ text.o
diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp
index 114ec8acec..5191fc404c 100755
--- a/engines/startrek/sound.cpp
+++ b/engines/startrek/sound.cpp
@@ -107,12 +107,11 @@ void Sound::playSMFSound(const char *baseSoundName) {
}
debug(0, "Playing sound \'%s\'\n", soundName.c_str());
- Common::SeekableReadStream *soundStream = _vm->openFile(soundName.c_str());
+ SharedPtr<Common::SeekableReadStream> soundStream = _vm->openFile(soundName.c_str());
byte *soundData = (byte *)malloc(soundStream->size());
soundStream->read(soundData, soundStream->size());
_midiParser->loadMusic(soundData, soundStream->size());
- delete soundStream;
_midiDriver->setTimerCallback(_midiParser, MidiParser::timerCallback);
}
@@ -135,12 +134,11 @@ void Sound::playXMIDISound(const char *baseSoundName) {
}
debug(0, "Playing sound \'%s\'\n", soundName.c_str());
- Common::SeekableReadStream *soundStream = _vm->openFile(soundName.c_str());
+ SharedPtr<Common::SeekableReadStream> soundStream = _vm->openFile(soundName.c_str());
byte *soundData = (byte *)malloc(soundStream->size());
soundStream->read(soundData, soundStream->size());
_midiParser->loadMusic(soundData, soundStream->size());
- delete soundStream;
_midiDriver->setTimerCallback(_midiParser, MidiParser::timerCallback);
}
@@ -165,7 +163,7 @@ void Sound::playAmigaSoundEffect(const char *baseSoundName) {
if (_vm->_mixer->isSoundHandleActive(*_soundHandle))
_vm->_mixer->stopHandle(*_soundHandle);
- Audio::AudioStream *audStream = (Audio::AudioStream *)Audio::makeRawStream(_vm->openFile(soundName.c_str()), 11025, 0);
+ Audio::AudioStream *audStream = (Audio::AudioStream *)Audio::makeRawStream(_vm->openFile(soundName.c_str()).get(), 11025, 0);
_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, _soundHandle, audStream);
}
diff --git a/engines/startrek/sprite.cpp b/engines/startrek/sprite.cpp
new file mode 100644
index 0000000000..d58cd3077e
--- /dev/null
+++ b/engines/startrek/sprite.cpp
@@ -0,0 +1,35 @@
+/* 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.
+ *
+ * $URL: https://scummvm-startrek.googlecode.com/svn/trunk/graphics.h $
+ * $Id: graphics.h 2 2009-09-12 20:13:40Z clone2727 $
+ *
+ */
+
+#include "startrek/sprite.h"
+
+namespace StarTrek {
+
+void Sprite::setBitmap(SharedPtr<Bitmap> b) {
+ bitmap = b;
+ bitmapChanged = 1;
+}
+
+}
diff --git a/engines/startrek/sprite.h b/engines/startrek/sprite.h
new file mode 100644
index 0000000000..280a0d2755
--- /dev/null
+++ b/engines/startrek/sprite.h
@@ -0,0 +1,63 @@
+/* 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.
+ *
+ * $URL: https://scummvm-startrek.googlecode.com/svn/trunk/graphics.h $
+ * $Id: graphics.h 2 2009-09-12 20:13:40Z clone2727 $
+ *
+ */
+
+#ifndef STARTREK_SPRITE_H
+#define STARTREK_SPRITE_H
+
+#include "startrek/bitmap.h"
+
+#include "common/ptr.h"
+#include "common/rect.h"
+#include "common/stream.h"
+
+using Common::SharedPtr;
+
+namespace StarTrek {
+
+
+struct Sprite {
+ Common::Point pos;
+ uint16 drawPriority;
+ uint16 field6;
+ uint16 field8;
+ SharedPtr<Bitmap> bitmap;
+ uint16 drawMode;
+ uint16 textColor;
+ uint16 bitmapChanged;
+ uint16 redrawCondition2;
+ uint16 redrawCondition3;
+ uint16 field16;
+ Common::Rect rectangle1;
+ Common::Rect clickRectangle;
+ Common::Rect rectangle2;
+ uint16 drawX,drawY;
+
+
+ void setBitmap(SharedPtr<Bitmap> b);
+};
+
+}
+
+#endif
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index ff3bf5e575..10ec35fcc1 100755
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -18,9 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm-startrek.googlecode.com/svn/trunk/startrek.cpp $
- * $Id: startrek.cpp 17 2010-12-16 02:29:35Z clone2727 $
- *
*/
#include "base/plugins.h"
@@ -110,7 +107,7 @@ Common::Error StarTrekEngine::run() {
// Draw mode 0
Sprite *spr = new Sprite;
_gfx->addSprite(spr);
- spr->bitmap = new Bitmap(openFile("MWALKE00.BMP"));
+ spr->bitmap = _gfx->loadBitmap("MWALKE00");
spr->drawPriority = 1;
spr->drawX = 150;
spr->drawY = 30;
@@ -119,7 +116,7 @@ Common::Error StarTrekEngine::run() {
// Draw mode 2 (translucent background)
spr = new Sprite;
_gfx->addSprite(spr);
- spr->bitmap = new Bitmap(openFile("KWALKS00.BMP"));
+ spr->bitmap = _gfx->loadBitmap("KWALKS00");
spr->drawPriority = 1;
spr->drawX = 200;
spr->drawY = 40;
@@ -128,7 +125,7 @@ Common::Error StarTrekEngine::run() {
// Draw mode 3 (text)
spr = new Sprite;
_gfx->addSprite(spr);
- spr->bitmap = new TextBitmap(8*8,8*8);
+ spr->bitmap = SharedPtr<Bitmap>(new TextBitmap(8*8,8*8));
for (int i=0;i<8*8;i++)
spr->bitmap->pixels[i] = 0x40+i;
spr->drawX = 8*10;
@@ -136,29 +133,41 @@ Common::Error StarTrekEngine::run() {
spr->textColor = 0xb3;
spr->drawMode = 3;
-
- Common::Event event;
+ // initTextSprite function
+ spr = new Sprite;
+ int x=0,y=0;
+ _gfx->initTextSprite(&x, &y, 0xb3, 3, false, spr);
+ spr->drawY = 150;
+
+
+ _gfx->showText(&Graphics::tmpFunction, 0, 0, 0, 0xb3, 0, 10, 0);
while (!shouldQuit()) {
- while (_eventMan->pollEvent(event)) {
- switch (event.type) {
- case Common::EVENT_QUIT:
- _system->quit();
- break;
- default:
- break;
- }
- }
- _gfx->redrawScreen();
-
- _system->delayMillis(1000/60);
+ pollEvents();
}
#endif
return Common::kNoError;
}
-Common::SeekableReadStreamEndian *StarTrekEngine::openFile(Common::String filename, int fileIndex) {
+void StarTrekEngine::pollEvents() {
+ Common::Event event;
+
+ while (_eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ _system->quit();
+ break;
+ default:
+ break;
+ }
+ }
+ _gfx->redrawScreen();
+
+ _system->delayMillis(1000/60);
+}
+
+SharedPtr<FileStream> StarTrekEngine::openFile(Common::String filename, int fileIndex) {
filename.toUppercase();
Common::String basename, extension;
@@ -179,7 +188,7 @@ Common::SeekableReadStreamEndian *StarTrekEngine::openFile(Common::String filena
Common::File *file = new Common::File();
if (!file->open(filename.c_str()))
error ("Could not find file \'%s\'", filename.c_str());
- return new FileStream(file, bigEndian);
+ return SharedPtr<FileStream>(new FileStream(file, bigEndian));
}
Common::SeekableReadStream *indexFile = 0;
@@ -282,7 +291,7 @@ Common::SeekableReadStreamEndian *StarTrekEngine::openFile(Common::String filena
Common::SeekableReadStream *stream = dataFile->readStream(uncompressedSize);
delete dataFile;
delete dataRunFile;
- return new FileStream(stream, bigEndian);
+ return SharedPtr<FileStream>(new FileStream(stream, bigEndian));
} else {
if (fileCount != 1) {
dataRunFile->seek(indexOffset);
@@ -304,13 +313,13 @@ Common::SeekableReadStreamEndian *StarTrekEngine::openFile(Common::String filena
delete dataFile;
delete dataRunFile;
- return new FileStream(stream, bigEndian);
+ return SharedPtr<FileStream>(new FileStream(stream, bigEndian));
}
// We should not get to this point...
error("Could not find data for \'%s\'", filename.c_str());
- return NULL;
+ return SharedPtr<FileStream>();
}
void StarTrekEngine::playMovie(Common::String filename) {
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 22dec315b5..9bf1065655 100755
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -26,18 +26,23 @@
#ifndef STARTREK_H
#define STARTREK_H
-#include "common/scummsys.h"
-#include "common/util.h"
-#include "common/system.h"
+#include "common/ptr.h"
#include "common/rect.h"
+#include "common/scummsys.h"
#include "common/str.h"
#include "common/stream.h"
+#include "common/system.h"
+#include "common/util.h"
#include "engines/engine.h"
+#include "startrek/filestream.h"
#include "startrek/graphics.h"
#include "startrek/sound.h"
+
+using Common::SharedPtr;
+
namespace Common {
class MacResManager;
}
@@ -65,6 +70,9 @@ public:
StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gamedesc);
virtual ~StarTrekEngine();
+ // Running the game
+ void pollEvents();
+
// Detection related functions
const StarTrekGameDescription *_gameDescription;
uint32 getFeatures() const;
@@ -74,7 +82,7 @@ public:
Common::Language getLanguage();
// Resource related functions
- Common::SeekableReadStreamEndian *openFile(Common::String filename, int fileIndex=0);
+ SharedPtr<FileStream> openFile(Common::String filename, int fileIndex=0);
// Movie related functions
void playMovie(Common::String filename);
@@ -84,8 +92,6 @@ private:
Graphics *_gfx;
Sound *_sound;
Common::MacResManager *_macResFork;
-
- byte getStartingIndex(Common::String filename);
};
} // End of namespace StarTrek
diff --git a/engines/startrek/text.cpp b/engines/startrek/text.cpp
new file mode 100644
index 0000000000..5af9bc0c9e
--- /dev/null
+++ b/engines/startrek/text.cpp
@@ -0,0 +1,271 @@
+/* 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 "common/stream.h"
+
+#include "startrek/graphics.h"
+
+namespace StarTrek {
+
+int Graphics::showText(TextGetterFunc textGetter, int var, int xoffset, int yoffset, int textColor, int argC, int maxTextLines, int arg10) {
+ uint16 tmpTextboxVar1 = _textboxVar1;
+
+ uint32 var7c = 8;
+ if (_textboxVar3 > _textboxVar2+1) {
+ var7c = 0x10;
+ }
+
+ int numChoicesWithNames = 0;
+ int numTextboxLines = 0;
+ int numChoices = 0;
+ Common::String speakerText;
+
+ while(true) {
+ Common::String choiceText = (this->*textGetter)(numChoices, var, &speakerText);
+ if (choiceText.empty())
+ break;
+
+ int lines = getNumLines(choiceText);
+ if (lines > numTextboxLines)
+ numTextboxLines = lines;
+
+ if (!speakerText.empty()) // Technically should check for nullptr
+ numChoicesWithNames++;
+
+ numChoices++;
+ }
+
+ if (maxTextLines == 0 || maxTextLines > 12)
+ maxTextLines = 12;
+ if (numTextboxLines > maxTextLines)
+ numTextboxLines = maxTextLines;
+
+ if (numChoicesWithNames != 0 && numChoices != numChoicesWithNames)
+ error("showText: Not all choices have titles.");
+
+ Sprite textboxSprite;
+ SharedPtr<TextBitmap> textBitmap = initTextSprite(&xoffset, &yoffset, textColor, numTextboxLines, numChoicesWithNames, &textboxSprite);
+
+ int choiceIndex = 0;
+ int var28 = 0;
+ if (tmpTextboxVar1 != 0 && tmpTextboxVar1 != 1 && numChoices == 1
+ && _textboxVar5 != 0 && _textboxVar4 == 0)
+ _textboxHasMultipleChoices = false;
+ else
+ _textboxHasMultipleChoices = true;
+
+ if (tmpTextboxVar1 >= 0 && tmpTextboxVar1 <= 2 && _textboxVar5 == 1 && _textboxVar4 == 0)
+ _textboxVar6 = true;
+ else
+ _textboxVar6 = false;
+
+ int numPrintedLines;
+ Common::String lineFormattedText = readLineFormattedText(textGetter, var, choiceIndex, textBitmap, numTextboxLines, &numPrintedLines);
+
+ if (lineFormattedText.empty()) { // Technically should check for nullptr
+ // TODO
+ }
+ else {
+ loadTextButtons("textbtns", xoffset+0x96, yoffset-0x11);
+
+ Common::Point oldMousePos = _mousePos;
+ SharedPtr<Bitmap> oldMouseBitmap = _mouseSprite.bitmap;
+
+ _mousePos.x = xoffset + 0xde;
+ _mousePos.y = yoffset - 0x08;
+ _mouseSprite.pos = _mousePos;
+ _mouseSprite.drawPriority = 15;
+
+ _mouseSprite.setBitmap(loadBitmap("pushbtn"));
+ warpMousePosition(_mousePos.x, _mousePos.y);
+
+ uint16 tmpTextboxVar7 = _textboxVar7;
+ _textboxVar7 = 0;
+
+ int var80 = (numChoices > 1 ? 0x18 : 0);
+
+ // TODO: sub_288FB function call
+ // TODO: sub_28ACA(0x0002);
+
+ if (var7c == 0) {
+ // sub_28ACA(0x0001);
+ }
+ if (argC == 0) {
+ // sub_28ACA(0x0008);
+ }
+
+ bool doneShowingText = false;
+
+ while (!doneShowingText) {
+ // TODO
+ _vm->pollEvents();
+ }
+
+ _mousePos = oldMousePos;
+ _mouseSprite.pos = _mousePos;
+ _mouseSprite.drawPriority = 15;
+ _mouseSprite.setBitmap(oldMouseBitmap);
+ warpMousePosition(_mousePos.x, _mousePos.y);
+
+ _textboxVar7 = tmpTextboxVar7;
+ // sub_29326();
+ textboxSprite.field16 = 1;
+ textboxSprite.bitmapChanged = 1;
+
+ drawAllSprites();
+ delSprite(&textboxSprite);
+ // sub_272B4
+ }
+
+ _textboxVar2 = _textboxVar3;
+ // sub_29EE3();
+ return choiceIndex;
+}
+
+const char* text = "Text test";
+
+Common::String Graphics::tmpFunction(int choiceIndex, int var, Common::String *speakerTextOutput) {
+ if (speakerTextOutput != nullptr)
+ *speakerTextOutput = "Speaker";
+
+ if (choiceIndex >= 1)
+ return NULL;
+ return text;
+}
+
+/**
+ * Creates a blank textbox in a TextBitmap, and initializes a sprite to use it.
+ */
+SharedPtr<TextBitmap> Graphics::initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite) {
+ int linesBeforeTextStart = 2;
+ if (withHeader != 0)
+ linesBeforeTextStart = 4;
+
+ int xoffset = *xoffsetPtr;
+ int yoffset = *yoffsetPtr;
+
+ int textHeight = numTextLines + linesBeforeTextStart;
+
+ SharedPtr<TextBitmap> bitmap(new TextBitmap(TEXTBOX_WIDTH*8, textHeight*8));
+
+ memset(sprite, 0, sizeof(Sprite));
+ sprite->drawPriority = 15;
+ sprite->field6 = 8;
+ sprite->bitmap = bitmap;
+ sprite->textColor = textColor;
+
+ memset(bitmap->pixels, ' ', textHeight*TEXTBOX_WIDTH);
+
+ int varC = SCREEN_WIDTH-1 - xoffset - (bitmap->width+0x1d)/2;
+ if (varC < 0)
+ xoffset += varC;
+
+ varC = xoffset - (bitmap->width+0x1d)/2;
+ if (varC < 1)
+ xoffset += varC-1;
+
+ varC = yoffset - (bitmap->height+0x11) - 20;
+ if (varC < 0)
+ yoffset -= varC;
+
+ xoffset -= (bitmap->width+0x1d)/2;
+ yoffset -= bitmap->height;
+
+ bitmap->pixels[0] = 0x10;
+ memset(&bitmap->pixels[1], 0x11, TEXTBOX_WIDTH-2);
+ bitmap->pixels[TEXTBOX_WIDTH-1] = 0x12;
+
+ byte *textAddr = bitmap->pixels+TEXTBOX_WIDTH;
+
+ if (withHeader) {
+ textAddr[0] = 0x13;
+ textAddr[TEXTBOX_WIDTH-1] = 0x14;
+ textAddr += TEXTBOX_WIDTH;
+
+ textAddr[0] = 0x13;
+ memset(&textAddr[1], 0x19, TEXTBOX_WIDTH-2);
+ textAddr[TEXTBOX_WIDTH-1] = 0x14;
+ textAddr += TEXTBOX_WIDTH;
+ }
+
+ for (int line=0; line<numTextLines; line++) {
+ textAddr[0] = 0x13;
+ textAddr[TEXTBOX_WIDTH-1] = 0x14;
+ textAddr += TEXTBOX_WIDTH;
+ }
+
+ textAddr[0] = 0x15;
+ memset(&textAddr[1], 0x16, TEXTBOX_WIDTH-2);
+ textAddr[TEXTBOX_WIDTH-1] = 0x17;
+
+ addSprite(sprite);
+ sprite->drawMode = 3;
+ sprite->pos.x = xoffset;
+ sprite->pos.y = yoffset;
+ sprite->drawPriority = 15;
+
+ *xoffsetPtr = xoffset;
+ *yoffsetPtr = yoffset;
+
+ return bitmap;
+}
+
+Common::String Graphics::skipOverAudioPrompt(const Common::String &str) {
+ // TODO
+ return str;
+}
+
+int Graphics::getNumLines(const Common::String &str) {
+ // TODO
+ return 1;
+}
+
+Common::String Graphics::readLineFormattedText(TextGetterFunc textGetter, int var, int choiceIndex, SharedPtr<TextBitmap> textBitmap, int numTextboxLines, int *numPrintedLines) {
+ // TODO
+ *numPrintedLines = 1;
+
+ int numChars = textBitmap->width*textBitmap->height;
+
+ Common::String text = (this->*textGetter)(choiceIndex, var, nullptr);
+ while (text.size() < numChars) text += ' ';
+
+ byte *dest = textBitmap->pixels + TEXTBOX_WIDTH + 1;
+
+ for (int y=0; y<*numPrintedLines; y++) {
+ memcpy(dest, text.c_str(), TEXTBOX_WIDTH-2);
+ dest += TEXTBOX_WIDTH;
+ }
+
+ return text;
+}
+
+void Graphics::loadTextButtons(Common::String mnuFilename, int xpos, int ypos) {
+ // TODO: start of function
+
+ SharedPtr<Common::SeekableReadStream> mnuFile = _vm->openFile(mnuFilename + ".MNU");
+ int numEntries = mnuFile->size()/16;
+}
+
+void Graphics::warpMousePosition(int x, int y) {
+ // TODO
+}
+
+}