aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2017-06-08 12:15:24 +0200
committerThierry Crozat2018-01-22 19:31:42 +0000
commite7252018e8ea645af733b2201a69e6427e0ef091 (patch)
tree19bcf40b751eae628182ae9b1b8477358a81cc9c
parent332763e8253f11e769f44bbaf17b4ddb3e80c097 (diff)
downloadscummvm-rg350-e7252018e8ea645af733b2201a69e6427e0ef091.tar.gz
scummvm-rg350-e7252018e8ea645af733b2201a69e6427e0ef091.tar.bz2
scummvm-rg350-e7252018e8ea645af733b2201a69e6427e0ef091.zip
SUPERNOVA: add characterWidth() function
Also did some cleanup on the font definition
-rw-r--r--engines/supernova/msn_def.h75
-rw-r--r--engines/supernova/supernova.cpp23
-rw-r--r--engines/supernova/supernova.h1
3 files changed, 69 insertions, 30 deletions
diff --git a/engines/supernova/msn_def.h b/engines/supernova/msn_def.h
index c17b7bdc3c..10b4e3214e 100644
--- a/engines/supernova/msn_def.h
+++ b/engines/supernova/msn_def.h
@@ -387,27 +387,27 @@ const byte mouseWait[64] = {
0x34,0x2c,0x14,0x28,0xfe,0x7f,0x00,0x00
};
-char font[][5] =
+const byte font[][5] =
{
- {0x00,0x00,0x00,0xff},
- {0x5f,0xff},
- {0x03,0x00,0x03,0xff},
+ {0x00,0x00,0x00,0xff,0x00},
+ {0x5f,0xff,0x00,0x00,0x00},
+ {0x03,0x00,0x03,0xff,0x00},
{0x14,0x7f,0x14,0x7f,0x14},
{0x24,0x2a,0x7f,0x2a,0x12},
{0x61,0x10,0x08,0x04,0x43},
{0x38,0x4e,0x59,0x26,0x50},
- {0x03,0xff},
- {0x3e,0x41,0xff},
- {0x41,0x3e,0xff},
+ {0x03,0xff,0x00,0x00,0x00},
+ {0x3e,0x41,0xff,0x00,0x00},
+ {0x41,0x3e,0xff,0x00,0x00},
{0x10,0x54,0x38,0x54,0x10},
{0x10,0x10,0x7c,0x10,0x10},
- {0x80,0x40,0xff},
+ {0x80,0x40,0xff,0x00,0x00},
{0x10,0x10,0x10,0x10,0x10},
- {0x40,0xff},
+ {0x40,0xff,0x00,0x00,0x00},
{0x60,0x10,0x08,0x04,0x03},
{0x3e,0x41,0x41,0x41,0x3e}, /* digits */
- {0x04,0x02,0x7f,0xff},
+ {0x04,0x02,0x7f,0xff,0x00},
{0x42,0x61,0x51,0x49,0x46},
{0x22,0x41,0x49,0x49,0x36},
{0x18,0x14,0x12,0x7f,0x10},
@@ -417,11 +417,11 @@ char font[][5] =
{0x36,0x49,0x49,0x49,0x36},
{0x26,0x49,0x49,0x49,0x3e},
- {0x44,0xff},
- {0x80,0x44,0xff},
- {0x10,0x28,0x44,0xff},
+ {0x44,0xff,0x00,0x00,0x00},
+ {0x80,0x44,0xff,0x00,0x00},
+ {0x10,0x28,0x44,0xff,0x00},
{0x28,0x28,0x28,0x28,0x28},
- {0x44,0x28,0x10,0xff},
+ {0x44,0x28,0x10,0xff,0x00},
{0x02,0x01,0x51,0x09,0x06},
{0x3e,0x41,0x5d,0x5d,0x1e},
@@ -433,7 +433,7 @@ char font[][5] =
{0x7f,0x09,0x09,0x09,0xff},
{0x3e,0x41,0x41,0x49,0x3a},
{0x7f,0x08,0x08,0x08,0x7f},
- {0x41,0x7f,0x41,0xff},
+ {0x41,0x7f,0x41,0xff,0x00},
{0x20,0x40,0x40,0x3f,0xff},
{0x7f,0x08,0x14,0x22,0x41},
{0x7f,0x40,0x40,0x40,0xff},
@@ -452,12 +452,12 @@ char font[][5] =
{0x03,0x04,0x78,0x04,0x03},
{0x61,0x51,0x49,0x45,0x43},
- {0x7f,0x41,0x41,0xff},
+ {0x7f,0x41,0x41,0xff,0x00},
{0x03,0x04,0x08,0x10,0x60},
- {0x41,0x41,0x7f,0xff},
- {0x02,0x01,0x02,0xff},
+ {0x41,0x41,0x7f,0xff,0x00},
+ {0x02,0x01,0x02,0xff,0x00},
{0x80,0x80,0x80,0x80,0x80},
- {0x01,0x02,0xff},
+ {0x01,0x02,0xff,0x00,0x00},
{0x38,0x44,0x44,0x44,0x7c}, /* lowercase letters */
{0x7f,0x44,0x44,0x44,0x38},
@@ -467,10 +467,10 @@ char font[][5] =
{0x04,0x7e,0x05,0x01,0xff},
{0x98,0xa4,0xa4,0xa4,0x7c},
{0x7f,0x04,0x04,0x04,0x78},
- {0x7d,0xff},
- {0x80,0x80,0x7d,0xff},
+ {0x7d,0xff,0x00,0x00,0x00},
+ {0x80,0x80,0x7d,0xff,0x00},
{0x7f,0x10,0x28,0x44,0xff},
- {0x7f,0xff},
+ {0x7f,0xff,0x00,0x00,0x00},
{0x7c,0x04,0x7c,0x04,0x78},
{0x7c,0x04,0x04,0x04,0x78},
{0x38,0x44,0x44,0x44,0x38},
@@ -486,13 +486,13 @@ char font[][5] =
{0x9c,0xa0,0xa0,0xa0,0x7c},
{0x44,0x64,0x54,0x4c,0x44},
- {0x08,0x36,0x41,0xff},
- {0x77,0xff},
- {0x41,0x36,0x08,0xff},
+ {0x08,0x36,0x41,0xff,0x00},
+ {0x77,0xff,0x00,0x00,0x00},
+ {0x41,0x36,0x08,0xff,0x00},
{0x02,0x01,0x02,0x01,0xff},
- {0xff},
+ {0xff,0x00,0x00,0x00,0x00},
- {0xfe,0x49,0x49,0x4e,0x30}, /* รก */
+ {0xfe,0x49,0x49,0x4e,0x30}, /* sharp S */
{0x7c,0x41,0x40,0x41,0x3c}, /* umlauts */
@@ -500,11 +500,26 @@ char font[][5] =
{0x20,0x60,0xfe,0x60,0x20},
{0x38,0x45,0x44,0x45,0x7c}, /* umlauts */
- {0xff},{0xff},{0xff},{0xff},{0xff},{0xff},{0xff},{0xff},{0xff},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
{0x79,0x14,0x12,0x14,0x79},
- {0xff},{0xff},{0xff},{0xff},{0xff},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
{0x38,0x45,0x44,0x45,0x38},
- {0xff},{0xff},{0xff},{0xff},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
+ {0xff,0x00,0x00,0x00,0x00},
{0x3d,0x42,0x42,0x42,0x3d},
{0x3d,0x40,0x40,0x40,0x3d},
};
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index f05aa1b72a..db97ad7954 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -38,6 +38,7 @@
//#include "graphics/fontman.h"
#include "supernova/supernova.h"
+#include "supernova/msn_def.h"
namespace Supernova {
@@ -74,6 +75,7 @@ Common::Error SupernovaEngine::run() {
_gameRunning = true;
while (_gameRunning) {
updateEvents();
+ renderImage(31, 0);
_system->updateScreen();
_system->delayMillis(10);
@@ -216,6 +218,26 @@ void SupernovaEngine::renderImage(int filenumber, int section) {
_system->copyRectToScreen(_image.getSurface()->getPixels(), 320, 0, 0, 320, 200);
}
+static int characterWidth(const char *text) {
+ int charWidth = 0;
+ while (*text != '\0') {
+ byte c = *text++;
+ if (c < 32) {
+ continue;
+ } else if (c == 225) {
+ c = 35;
+ }
+
+ for (size_t i = 0; i < 5; ++i) {
+ ++charWidth;
+ if (font[c - 32][i] == 0xff) {
+ break;
+ }
+ }
+ }
+
+ return charWidth;
+}
void SupernovaEngine::renderBox(int x, int y, int width, int height, byte color) {
Graphics::Surface *screen = _system->lockScreen();
@@ -227,3 +249,4 @@ 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 823184ae4d..2167df0e90 100644
--- a/engines/supernova/supernova.h
+++ b/engines/supernova/supernova.h
@@ -62,6 +62,7 @@ private:
void playSoundMod(int filenumber);
void stopSound();
void renderImage(int filenumber, int section);
+ void renderText(const char *text, int x, int y);
void renderBox(int x, int y, int width, int height, byte color);
};