aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2017-06-21 07:45:25 +0200
committerThierry Crozat2018-01-22 23:34:49 +0000
commit534bd3837069f45c94e07a6ef593550b29abe51e (patch)
tree6ce1b8edee3356d9e5707cace5cd670a656d0253
parent8f5e712df0bbfe54fd43179a3e9af60ae2d1da78 (diff)
downloadscummvm-rg350-534bd3837069f45c94e07a6ef593550b29abe51e.tar.gz
scummvm-rg350-534bd3837069f45c94e07a6ef593550b29abe51e.tar.bz2
scummvm-rg350-534bd3837069f45c94e07a6ef593550b29abe51e.zip
SUPERNOVA: Extends renderText()
Restructures the renderText() function for providing a renderText(text) overload that starts rendering the string where the last call stopped.
-rw-r--r--engines/supernova/supernova.cpp12
-rw-r--r--engines/supernova/supernova.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 52bc379582..2e2957f0c4 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -355,6 +355,8 @@ void SupernovaEngine::removeMessage() {
void SupernovaEngine::renderText(const char *text, int x, int y, byte color) {
Graphics::Surface *screen = _system->lockScreen();
byte *cursor = static_cast<byte *>(screen->getBasePtr(x, y));
+ const byte *basePtr = cursor;
+
byte c;
while ((c = *text++) != '\0') {
if (c < 32) {
@@ -380,6 +382,16 @@ void SupernovaEngine::renderText(const char *text, int x, int y, byte color) {
}
}
_system->unlockScreen();
+
+ size_t numChars = cursor - basePtr;
+ size_t absPosition = y * kScreenWidth + x + numChars;
+ _textCursorX = absPosition % kScreenWidth;
+ _textCursorY = absPosition / kScreenWidth;
+ _textColor = color;
+}
+
+void SupernovaEngine::renderText(const char *text) {
+ renderText(text, _textCursorX, _textCursorY, _textColor);
}
void SupernovaEngine::renderBox(int x, int y, int width, int height, byte color) {
diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h
index d46da280fb..c1dc3013a7 100644
--- a/engines/supernova/supernova.h
+++ b/engines/supernova/supernova.h
@@ -91,6 +91,9 @@ public:
byte _brightness;
uint _delay;
bool _messageDisplayed;
+ int _textCursorX;
+ int _textCursorY;
+ int _textColor;
uint getDOSTicks();
void initData();
@@ -109,6 +112,7 @@ public:
void renderMessage(const char *text, MessagePosition position = kMessageNormal);
void removeMessage();
void renderText(const char *text, int x, int y, byte color);
+ void renderText(const char *text);
void renderBox(int x, int y, int width, int height, byte color);
void setColor63(byte value);
};