aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-08-11 14:26:12 +0000
committerNicola Mettifogo2007-08-11 14:26:12 +0000
commit81b864e9e8199b0102b122626badba059eb618d4 (patch)
treebeeeb91cbb85be2cac56c17507cee895bdb67b2b /engines
parent74b16c7e90e9b1dd011a85b447fc91073896a056 (diff)
downloadscummvm-rg350-81b864e9e8199b0102b122626badba059eb618d4.tar.gz
scummvm-rg350-81b864e9e8199b0102b122626badba059eb618d4.tar.bz2
scummvm-rg350-81b864e9e8199b0102b122626badba059eb618d4.zip
Added preliminary font support for Big Red Adventure.
svn-id: r28529
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/disk.h1
-rw-r--r--engines/parallaction/disk_br.cpp10
-rw-r--r--engines/parallaction/font.cpp169
3 files changed, 170 insertions, 10 deletions
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index a52e9e1981..a0b20b8378 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -203,6 +203,7 @@ protected:
protected:
void errorFileNotFound(const char *s);
+ Font *createFont(const char *name, Common::ReadStream &stream);
public:
DosDisk_br(Parallaction *vm);
diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp
index 3d8ee015d7..babe6043a6 100644
--- a/engines/parallaction/disk_br.cpp
+++ b/engines/parallaction/disk_br.cpp
@@ -83,7 +83,15 @@ Graphics::Surface* DosDisk_br::loadPointer() {
Font* DosDisk_br::loadFont(const char* name) {
debugC(5, kDebugDisk, "DosDisk_br::loadFont");
- return 0;
+
+ char path[PATH_LEN];
+ sprintf(path, "%s.fnt", name);
+
+ Common::File stream;
+ if (!stream.open(path))
+ errorFileNotFound(path);
+
+ return createFont(name, stream);
}
diff --git a/engines/parallaction/font.cpp b/engines/parallaction/font.cpp
index ee624b083c..99ec28ec60 100644
--- a/engines/parallaction/font.cpp
+++ b/engines/parallaction/font.cpp
@@ -34,6 +34,146 @@ namespace Parallaction {
extern byte _amigaTopazFont[];
+class BraFont : public Font {
+
+ byte *_cp;
+ uint _bufPitch;
+
+ uint32 _height;
+ byte _numGlyphs;
+
+ byte *_widths;
+ uint *_offsets;
+
+ byte *_data;
+
+ static byte _charMap[];
+
+ byte mapChar(byte c) {
+ return _charMap[c];
+ }
+
+public:
+ BraFont(Common::ReadStream &stream) {
+
+ _numGlyphs = stream.readByte();
+ _height = stream.readUint32BE();
+
+ _widths = (byte*)malloc(_numGlyphs);
+ stream.read(_widths, _numGlyphs);
+
+ _offsets = (uint*)malloc(_numGlyphs * sizeof(uint));
+ _offsets[0] = 0;
+ for (uint i = 1; i < _numGlyphs; i++)
+ _offsets[i] = _offsets[i-1] + _widths[i-1] * _height;
+
+ uint size = _offsets[_numGlyphs-1] + _widths[_numGlyphs-1] * _height;
+
+ _data = (byte*)malloc(size);
+ stream.read(_data, size);
+
+ }
+
+ ~BraFont() {
+ free(_widths);
+ free(_offsets);
+ free(_data);
+ }
+
+
+ uint32 getStringWidth(const char *s) {
+ uint32 len = 0;
+
+ while (*s) {
+ byte c = mapChar(*s);
+ len += (_widths[c] + 2);
+ s++;
+ }
+
+ return len;
+ }
+
+ uint16 height() {
+ return (uint16)_height;
+ }
+
+ uint16 drawChar(char c) {
+ assert(c < _numGlyphs);
+
+ byte *src = _data + _offsets[c];
+ byte *dst = _cp;
+ uint16 w = _widths[c];
+
+ for (uint16 j = 0; j < height(); j++) {
+ for (uint16 k = 0; k < w; k++) {
+
+ if (*src) {
+ *dst = (_color) ? _color : *src;
+ }
+
+ dst++;
+ src++;
+ }
+
+ dst += (_bufPitch - w);
+ }
+
+ return w + 2;
+
+ }
+
+ void drawString(byte* buffer, uint32 pitch, const char *s) {
+ if (s == NULL)
+ return;
+
+ _bufPitch = pitch;
+
+ _cp = buffer;
+ while (*s) {
+ byte c = mapChar(*s);
+ _cp += drawChar(c);
+ s++;
+ }
+ }
+
+};
+
+byte BraFont::_charMap[] = {
+// 0
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// 1
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// 2
+ 0x34, 0x49, 0x48, 0x34, 0x34, 0x34, 0x34, 0x47, 0x34, 0x34, 0x34, 0x34, 0x40, 0x34, 0x3F, 0x34,
+// 3
+ 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x46, 0x45, 0x34, 0x34, 0x34, 0x42,
+// 4
+ 0x34, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
+// 5
+ 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x34, 0x34, 0x34, 0x34, 0x34,
+// 6
+ 0x34, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
+// 7
+ 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x34, 0x34, 0x34, 0x34,
+// 8
+ 0x5E, 0x5D, 0x4E, 0x4B, 0x4D, 0x4C, 0x34, 0x5E, 0x4F, 0x51, 0x50, 0x34, 0x34, 0x34, 0x34, 0x34,
+// 9
+ 0x34, 0x34, 0x34, 0x57, 0x59, 0x58, 0x5B, 0x5C, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// A
+ 0x4A, 0x52, 0x34, 0x5A, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// B
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// C
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// D
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// E
+ 0x34, 0x5F, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
+// F
+ 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34
+};
+
+
class DosFont : public Font {
protected:
@@ -430,19 +570,30 @@ Font *AmigaDisk_ns::createFont(const char *name, Common::SeekableReadStream &str
return new AmigaFont(stream);
}
+Font *DosDisk_br::createFont(const char *name, Common::ReadStream &stream) {
+ printf("DosDisk_br::createFont(%s)\n", name);
+ return new BraFont(stream);
+}
+
+
void Gfx::initFonts() {
- if (_vm->getPlatform() == Common::kPlatformPC) {
- _fonts[kFontDialogue] = _vm->_disk->loadFont("comic");
- _fonts[kFontLabel] = _vm->_disk->loadFont("topaz");
- _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
- } else {
- _fonts[kFontDialogue] = _vm->_disk->loadFont("comic");
+ if (_vm->getGameType() == GType_Nippon) {
+ if (_vm->getPlatform() == Common::kPlatformPC) {
+ _fonts[kFontDialogue] = _vm->_disk->loadFont("comic");
+ _fonts[kFontLabel] = _vm->_disk->loadFont("topaz");
+ _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
+ } else {
+ _fonts[kFontDialogue] = _vm->_disk->loadFont("comic");
- Common::MemoryReadStream stream(_amigaTopazFont, 2600, false);
- _fonts[kFontLabel] = new AmigaFont(stream);
+ Common::MemoryReadStream stream(_amigaTopazFont, 2600, false);
+ _fonts[kFontLabel] = new AmigaFont(stream);
- _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
+ _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
+ }
+ } else
+ if (_vm->getGameType() == GType_BRA) {
+ _fonts[kFontMenu] = _vm->_disk->loadFont("russia");
}
}