aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-04-16 20:16:18 +0000
committerNicola Mettifogo2007-04-16 20:16:18 +0000
commit987638a71361129748ef0bfac51850d7c8dc3ecc (patch)
treed0e24f20e358992c817479f7bdb790258cda721c /engines/parallaction
parentbf7123548ab5dc5f3eef105ea4d58a30f4844c29 (diff)
downloadscummvm-rg350-987638a71361129748ef0bfac51850d7c8dc3ecc.tar.gz
scummvm-rg350-987638a71361129748ef0bfac51850d7c8dc3ecc.tar.bz2
scummvm-rg350-987638a71361129748ef0bfac51850d7c8dc3ecc.zip
Now handling fonts with brand-new Font hierarchy. Amiga font have been implemented for dialogues/descriptions, but not for labels yet.
svn-id: r26530
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/dialogue.cpp5
-rw-r--r--engines/parallaction/disk.cpp14
-rw-r--r--engines/parallaction/disk.h9
-rw-r--r--engines/parallaction/font.cpp452
-rw-r--r--engines/parallaction/graphics.cpp147
-rw-r--r--engines/parallaction/graphics.h25
-rw-r--r--engines/parallaction/location.cpp1
-rw-r--r--engines/parallaction/menu.cpp7
-rw-r--r--engines/parallaction/zone.cpp4
9 files changed, 518 insertions, 146 deletions
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index 008278a0c5..f84bf48982 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -225,6 +225,7 @@ uint16 Parallaction::askDialoguePassword(Dialogue *q, StaticCnv *face) {
password[passwordLen] = '\0';
_gfx->displayBalloonString(_answerBalloonX[0] + 5, _answerBalloonY[0] + _answerBalloonH[0] - 15, password, 0);
+ _gfx->updateScreen();
g_system->delayMillis(20);
}
@@ -286,6 +287,7 @@ bool Parallaction::displayAnswers(Dialogue *q) {
}
i++;
}
+ _gfx->updateScreen();
return displayed;
}
@@ -310,6 +312,7 @@ void Parallaction::displayQuestion(Dialogue *q, Cnv *cnv) {
_gfx->drawBalloon(r, q->_mood & 0x10);
_gfx->displayWrappedString(q->_text, QUESTION_BALLOON_X, QUESTION_BALLOON_Y, MAX_BALLOON_WIDTH, 0);
+ _gfx->updateScreen();
waitUntilLeftClick();
@@ -412,6 +415,7 @@ int16 Parallaction::selectAnswer(Question *q, StaticCnv *cnv) {
cnv->_data0 = _char._talk->getFramePtr(q->_answers[_di]->_mood & 0xF);
// cnv->_data1 = _char._talk->field_8[q->_answers[_di]->_mood & 0xF];
_gfx->flatBlitCnv(cnv, ANSWER_CHARACTER_X, ANSWER_CHARACTER_Y, Gfx::kBitFront);
+ _gfx->updateScreen();
waitUntilLeftClick();
return _di;
}
@@ -434,6 +438,7 @@ int16 Parallaction::selectAnswer(Question *q, StaticCnv *cnv) {
_gfx->flatBlitCnv(cnv, ANSWER_CHARACTER_X, ANSWER_CHARACTER_Y, Gfx::kBitFront);
}
+ _gfx->updateScreen();
g_system->delayMillis(30);
v2 = _si;
}
diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp
index 1ed4624429..7a6caf9fb6 100644
--- a/engines/parallaction/disk.cpp
+++ b/engines/parallaction/disk.cpp
@@ -377,10 +377,10 @@ StaticCnv* DosDisk::loadPointer() {
}
-Cnv* DosDisk::loadFont(const char* name) {
+Font* DosDisk::loadFont(const char* name) {
char path[PATH_LEN];
sprintf(path, "%scnv", name);
- return loadExternalCnv(path);
+ return createFont(name, loadExternalCnv(path));
}
@@ -916,7 +916,7 @@ StaticCnv* AmigaDisk::loadHead(const char* name) {
return cnv;
}
-Cnv* AmigaDisk::loadFont(const char* name) {
+Font* AmigaDisk::loadFont(const char* name) {
debugC(1, kDebugDisk, "AmigaDisk::loadFont '%s'", name);
char path[PATH_LEN];
@@ -925,11 +925,7 @@ Cnv* AmigaDisk::loadFont(const char* name) {
if (!_resArchive.openArchivedFile(path))
errorFileNotFound(path);
- // FIXME: actually read data from font file and create
- // real font instead of this dummy one
- byte *data = (byte*)malloc(256*8*8);
- memset(data, 0, 256*8*8);
- return new Cnv(256, 8, 8, data);
+ return createFont(name, _resArchive);
}
StaticCnv* AmigaDisk::loadStatic(const char* name) {
@@ -992,7 +988,7 @@ void AmigaDisk::loadSlide(const char *name) {
Graphics::ILBMDecoder decoder(*s);
decoder.decode(surf, pal);
- for (uint32 i = 0; i < PALETTE_SIZE; i++)
+ for (uint32 i = 0; i < BASE_PALETTE_COLORS * 3; i++)
_vm->_gfx->_palette[i] = pal[i] >> 2;
free(pal);
_vm->_gfx->setPalette(_vm->_gfx->_palette);
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index 5e6233f3af..52565a29e7 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -39,6 +39,7 @@ class Table;
class Parallaction;
class Gfx;
class Script;
+class Font;
struct Cnv;
struct StaticCnv;
@@ -104,7 +105,7 @@ public:
virtual Cnv* loadObjects(const char *name) = 0;
virtual StaticCnv* loadPointer() = 0;
virtual StaticCnv* loadHead(const char* name) = 0;
- virtual Cnv* loadFont(const char* name) = 0;
+ virtual Font* loadFont(const char* name) = 0;
virtual StaticCnv* loadStatic(const char* name) = 0;
virtual Cnv* loadFrames(const char* name) = 0;
virtual void loadSlide(const char *filename) = 0;
@@ -124,6 +125,7 @@ private:
void loadMaskAndPath(const char *name);
void parseDepths(Common::SeekableReadStream &stream);
void parseBackground(Common::SeekableReadStream &stream);
+ Font *createFont(const char *name, Cnv* cnv);
protected:
Gfx *_gfx;
@@ -138,7 +140,7 @@ public:
Cnv* loadObjects(const char *name);
StaticCnv* loadPointer();
StaticCnv* loadHead(const char* name);
- Cnv* loadFont(const char* name);
+ Font* loadFont(const char* name);
StaticCnv* loadStatic(const char* name);
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
@@ -153,6 +155,7 @@ protected:
StaticCnv* makeStaticCnv(Common::SeekableReadStream &stream);
void unpackBitmap(byte *dst, byte *src, uint16 numFrames, uint16 planeSize);
Common::SeekableReadStream *openArchivedFile(const char* name, bool errorOnFileNotFound = false);
+ Font *createFont(const char *name, Common::SeekableReadStream &stream);
public:
AmigaDisk(Parallaction *vm);
@@ -164,7 +167,7 @@ public:
Cnv* loadObjects(const char *name);
StaticCnv* loadPointer();
StaticCnv* loadHead(const char* name);
- Cnv* loadFont(const char* name);
+ Font* loadFont(const char* name);
StaticCnv* loadStatic(const char* name);
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
diff --git a/engines/parallaction/font.cpp b/engines/parallaction/font.cpp
new file mode 100644
index 0000000000..a2d1fcaf62
--- /dev/null
+++ b/engines/parallaction/font.cpp
@@ -0,0 +1,452 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2006 The ScummVM project
+ *
+ * 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$
+ * $Id$
+ *
+ */
+
+#include "common/stdafx.h"
+#include "common/endian.h"
+#include "common/stream.h"
+
+#include "parallaction/defs.h"
+#include "parallaction/graphics.h"
+#include "parallaction/parallaction.h"
+
+namespace Parallaction {
+
+
+class DosFont : public Font {
+
+protected:
+ // drawing properties
+ byte *_cp;
+ byte _color;
+
+ Cnv *_data;
+ byte _pitch;
+ uint32 _bufPitch;
+
+protected:
+ virtual uint16 drawChar(char c) = 0;
+ virtual uint16 width(byte c) = 0;
+ virtual uint16 height() = 0;
+
+ byte mapChar(byte c) {
+ if (c == 0xA5) return 0x5F;
+ if (c == 0xDF) return 0x60;
+
+ if (c > 0x7F) return c - 0x7F;
+
+ return c - 0x20;
+ }
+
+public:
+ DosFont(Cnv *cnv) : _data(cnv), _pitch(cnv->_width) {
+ }
+
+ ~DosFont() {
+ if (_data)
+ delete _data;
+ }
+
+ void setData() {
+
+ }
+
+ void setColor(byte color) {
+ _color = color;
+ }
+
+ uint32 getStringWidth(const char *s) {
+ uint32 len = 0;
+
+ while (*s) {
+ byte c = mapChar(*s);
+ len += width(c);
+ s++;
+ }
+
+ return len;
+ }
+
+ 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++;
+ }
+ }
+};
+
+class DosDialogueFont : public DosFont {
+
+private:
+ static const byte _glyphWidths[126];
+
+protected:
+ uint16 width(byte c) {
+ return _glyphWidths[c];
+ }
+
+ uint16 height() {
+ return _data->_height;
+ }
+
+public:
+ DosDialogueFont(Cnv *cnv) : DosFont(cnv) {
+ }
+
+protected:
+ uint16 drawChar(char c) {
+
+ byte *src = _data->getFramePtr(c);
+ byte *dst = _cp;
+ uint16 w = width(c);
+
+ for (uint16 j = 0; j < height(); j++) {
+ for (uint16 k = 0; k < w; k++) {
+ *dst = (*src) ? 1 : _color;
+ dst++;
+ src++;
+ }
+
+ src += (_pitch - w);
+ dst += (_bufPitch - w);
+ }
+
+ return w;
+
+ }
+
+};
+
+const byte DosDialogueFont::_glyphWidths[126] = {
+ 0x04, 0x03, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04, 0x04, 0x06, 0x06, 0x03, 0x05, 0x03, 0x05,
+ 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x05, 0x04, 0x05, 0x05,
+ 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x05, 0x06, 0x05, 0x08, 0x07,
+ 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x03, 0x04, 0x05, 0x05, 0x06, 0x06, 0x05,
+ 0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x05, 0x05, 0x05, 0x05, 0x02, 0x05, 0x05, 0x07,
+ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04,
+ 0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06, 0x05, 0x05, 0x05, 0x05
+};
+
+
+class DosMonospacedFont : public DosFont {
+
+protected:
+ uint16 _width;
+
+protected:
+ uint16 width(byte c) {
+ return _width;
+ }
+
+ uint16 height() {
+ return _data->_height;
+ }
+
+
+public:
+ DosMonospacedFont(Cnv *cnv) : DosFont(cnv) {
+ _width = 8;
+ }
+
+};
+
+class DosMenuFont : public DosMonospacedFont {
+
+public:
+ DosMenuFont(Cnv *cnv) : DosMonospacedFont(cnv) {
+ }
+
+protected:
+ uint16 drawChar(char c) {
+
+ byte *src = _data->getFramePtr(c);
+ byte *dst = _cp;
+
+ for (uint16 i = 0; i < height(); i++) {
+ for (uint16 j = 0; j < _width; j++) {
+ if (*src)
+ *dst = *src;
+ src++;
+ dst++;
+ }
+
+ dst += (_bufPitch - _width);
+ src += (_pitch - _width);
+ }
+
+ return _width;
+ }
+
+};
+
+
+class DosLabelFont : public DosMonospacedFont {
+
+public:
+ DosLabelFont(Cnv *cnv) : DosMonospacedFont(cnv) {
+ }
+
+protected:
+ uint16 drawChar(char c) {
+
+ byte *src = _data->getFramePtr(c);
+ byte *dst = _cp;
+
+ for (uint16 i = 0; i < height(); i++) {
+ memcpy(dst, src, _width);
+ dst += _bufPitch;
+ src += _pitch;
+ }
+
+ return _width;
+ }
+
+};
+
+// this flags comes from Aros Projects
+#define FPB_PROPORTIONAL 5
+#define FPF_PROPORTIONAL (1<<5)
+
+class AmigaFont : public Font {
+
+#include "common/pack-start.h"
+ struct CharLoc {
+ uint16 _offset;
+ uint16 _length;
+ };
+
+ struct AmigaDiskFont {
+ uint16 _ySize;
+ byte _style;
+ byte _flags;
+ uint16 _xSize;
+ uint16 _baseline;
+ uint16 _boldSmear;
+ uint16 _accessors; // unused
+ byte _loChar;
+ byte _hiChar;
+ byte *_charData;
+ uint16 _modulo;
+ CharLoc *_charLoc;
+ uint16 *_charSpace;
+ uint16 *_charKern;
+ };
+#include "common/pack-end.h"
+
+ AmigaDiskFont *_font;
+ uint32 _dataSize;
+ byte *_data;
+ bool _proportional;
+
+ byte *_cp;
+ uint32 _pitch;
+ byte _color;
+
+protected:
+ uint16 getSpacing(char c);
+ void blitData(char c);
+ uint16 getKerning(char c);
+ uint16 getPixels(char c);
+ uint16 getOffset(char c);
+ uint16 width(char c);
+ uint16 height();
+
+ void drawChar(char c);
+
+ char mapChar(byte c);
+
+public:
+ AmigaFont(Common::SeekableReadStream &stream);
+ ~AmigaFont();
+
+ uint32 getStringWidth(const char *s);
+ void drawString(byte *buf, uint32 pitch, const char *s);
+
+
+
+};
+
+AmigaFont::AmigaFont(Common::SeekableReadStream &stream) {
+ stream.seek(32); // skips dummy header
+
+ _dataSize = stream.size() - stream.pos();
+ _data = (byte*)malloc(_dataSize);
+ stream.read(_data, _dataSize);
+
+ _font = (AmigaDiskFont*)(_data + 78);
+ _font->_ySize = FROM_BE_16(_font->_ySize);
+ _font->_xSize = FROM_BE_16(_font->_xSize);
+ _font->_baseline = FROM_BE_16(_font->_baseline);
+ _font->_modulo = FROM_BE_16(_font->_modulo);
+
+ _font->_charLoc = (CharLoc*)(_data + FROM_BE_32((uint32)_font->_charLoc));
+ _font->_charData = _data + FROM_BE_32((uint32)_font->_charData);
+ _font->_charSpace = (uint16*)(_data + FROM_BE_32((uint32)_font->_charSpace));
+ _font->_charKern = (uint16*)(_data + FROM_BE_32((uint32)_font->_charKern));
+/*
+ printf("H = %i, W = %i\n", _font->_ySize, _font->_xSize);
+ printf("_data = %p\n", _data);
+ printf("_charLoc = %p (%x)\n", _font->_charLoc, _font->_charLoc[0]._offset);
+ printf("_charData = %p\n", _font->_charData);
+ printf("_charSpace = %p\n", _font->_charSpace);
+ printf("_charKern = %p\n", _font->_charKern);
+*/
+
+ _proportional = (_font->_flags & FPF_PROPORTIONAL) == FPF_PROPORTIONAL;
+}
+
+AmigaFont::~AmigaFont() {
+ if (_data)
+ free(_data);
+}
+
+uint16 AmigaFont::getSpacing(char c) {
+ return FROM_BE_16(_proportional ? _font->_charSpace[c] : _font->_xSize);
+}
+
+uint16 AmigaFont::getKerning(char c) {
+ return FROM_BE_16(_font->_charKern[c]);
+}
+
+uint16 AmigaFont::getPixels(char c) {
+ return FROM_BE_16(_font->_charLoc[c]._length);
+}
+
+uint16 AmigaFont::getOffset(char c) {
+ return FROM_BE_16(_font->_charLoc[c]._offset);
+}
+
+void AmigaFont::blitData(char c) {
+
+ int num = getPixels(c);
+ int bitOffset = getOffset(c);
+
+ byte *d = _cp;
+ byte *s = _font->_charData;
+
+ for (int i = 0; i < _font->_ySize; i++) {
+
+ for (int j = bitOffset; j < bitOffset + num; j++) {
+ byte *b = s + (j >> 3);
+ byte bit = *b & (0x80 >> (j & 7));
+
+ if (bit)
+ *d = _color;
+
+ d++;
+ }
+
+ s += _font->_modulo;
+ d += _pitch - num;
+ }
+
+}
+
+uint16 AmigaFont::width(char c) {
+ return getKerning(c) + getSpacing(c);
+}
+
+uint16 AmigaFont::height() {
+ return _font->_ySize;
+}
+
+char AmigaFont::mapChar(byte c) {
+
+ if (c < _font->_loChar || c > _font->_hiChar)
+ error("character '%c (%x)' not supported by font", c, c);
+
+ return c - _font->_loChar;
+}
+
+uint32 AmigaFont::getStringWidth(const char *s) {
+ uint32 len = 0;
+
+ while (*s) {
+ byte c = mapChar(*s);
+ len += width(c);
+ s++;
+ }
+
+ return len;
+}
+
+void AmigaFont::drawString(byte *buffer, uint32 pitch, const char *s) {
+
+ _cp = buffer;
+ _pitch = pitch;
+
+ char c;
+
+ while (*s) {
+ c = mapChar(*s);
+ _cp += getKerning(c);
+ blitData(c);
+ _cp += getSpacing(c);
+ s++;
+ }
+
+}
+
+Font *DosDisk::createFont(const char *name, Cnv* cnv) {
+ Font *f = 0;
+
+ if (!scumm_stricmp(name, "comic"))
+ f = new DosDialogueFont(cnv);
+ else
+ if (!scumm_stricmp(name, "topaz"))
+ f = new DosLabelFont(cnv);
+ else
+ if (!scumm_stricmp(name, "slide"))
+ f = new DosMenuFont(cnv);
+ else
+ error("unknown dos font '%s'", name);
+
+ return f;
+}
+
+Font *AmigaDisk::createFont(const char *name, Common::SeekableReadStream &stream) {
+ // TODO: implement AmigaLabelFont for labels
+ return new AmigaFont(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");
+ _fonts[kFontLabel] = _vm->_disk->loadFont("intro");
+ _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
+ }
+
+}
+
+}
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index e37175e67b..818befaa95 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -34,7 +34,7 @@
extern OSystem *g_system;
namespace Parallaction {
-
+/*
//
// proportional font glyphs width
//
@@ -48,7 +48,7 @@ const byte _glyphWidths[126] = {
0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04,
0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06, 0x05, 0x05, 0x05, 0x05
};
-
+*/
bool Gfx::_proportionalFont = false;
byte * Gfx::_buffers[];
@@ -537,69 +537,32 @@ void Gfx::restoreZoneBackground(const Common::Rect& r, byte *data) {
return;
}
+void Gfx::makeCnvFromString(StaticCnv *cnv, char *text) {
+ assert(_font == _fonts[kFontLabel]);
+ cnv->_width = _font->getStringWidth(text);
+ cnv->_height = _font->height();
+ cnv->_data0 = (byte*)malloc(cnv->_width * cnv->_height);
-//
-// strings
-//
-void Gfx::displayString(uint16 x, uint16 y, const char *text) {
- if (text == NULL)
- return;
-
- uint16 len = strlen(text);
- StaticCnv tmp;
-
- for (uint16 i = 0; i < len; i++) {
- byte c = mapChar(text[i]);
-
- tmp._width = _font->_width;
- tmp._height = _font->_height;
- tmp._data0 = _font->getFramePtr(c);
-
- flatBlitCnv(&tmp, x, y, kBitFront);
-
- x += (_proportionalFont ? _glyphWidths[(int)c] : 8);
+ _font->drawString(cnv->_data0, cnv->_width, text);
+}
- }
+void Gfx::displayString(uint16 x, uint16 y, const char *text) {
+ assert(_font == _fonts[kFontMenu]);
- return;
+ byte *dst = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
+ _font->drawString(dst, SCREEN_WIDTH, text);
}
-
void Gfx::displayBalloonString(uint16 x, uint16 y, const char *text, byte color) {
+ assert(_font == _fonts[kFontDialogue]);
- uint16 len = strlen(text);
+ byte *dst = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
- for (uint16 i = 0; i < len; i++) {
-
- byte c = mapChar(text[i]);
- uint16 w = _proportionalFont ? _glyphWidths[(int)c] : 8;
- byte *s = _font->getFramePtr(c);
- byte *d = _buffers[kBitFront] + x + y*SCREEN_WIDTH;
-
-// printf("%i\n", text[i]);
-
- for (uint16 j = 0; j < _font->_height; j++) {
- for (uint16 k = 0; k < w; k++) {
- *d = (*s) ? 1 : color;
- d++;
- s++;
- }
-
- s += (8 - w);
- d += (SCREEN_WIDTH - w);
- }
-
- x += w;
- }
-
- updateScreen();
-
- return;
+ _font->setColor(color);
+ _font->drawString(dst, SCREEN_WIDTH, text);
}
-
-
bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, uint16 maxwidth, byte color) {
// printf("Gfx::displayWrappedString(%s, %i, %i, %i, %i)...", text, x, y, maxwidth, color);
@@ -646,29 +609,10 @@ bool Gfx::displayWrappedString(char *text, uint16 x, uint16 y, uint16 maxwidth,
}
-
-
uint16 Gfx::getStringWidth(const char *text) {
- if (text == NULL) return 0;
-
- uint16 len = strlen(text);
-
- if (_proportionalFont == 0) {
- // fixed font
- return len*8;
- }
-
- // proportional font
- uint16 w = 0;
- for (uint16 i = 0; i < len; i++) {
- byte c = mapChar(text[i]);
- w += _glyphWidths[(int)c];
- }
-
- return w;
+ return _font->getStringWidth(text);
}
-
void Gfx::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height) {
uint16 lines = 0;
@@ -741,50 +685,6 @@ void Gfx::restoreBackground(const Common::Rect& r) {
return;
}
-
-void Gfx::makeCnvFromString(StaticCnv *cnv, char *text) {
-// printf("makeCnvFromString('%s')\n", text);
-
- uint16 len = strlen(text);
-
- cnv->_width = _font->_width * len;
- cnv->_height = _font->_height;
-
-// printf("%i x %i\n", cnv->_width, cnv->_height);
-
- cnv->_data0 = (byte*)malloc(cnv->_width * cnv->_height);
-
- for (uint16 i = 0; i < len; i++) {
- byte c = mapChar(text[i]);
-
- byte *s = _font->getFramePtr(c);
- byte *d = cnv->_data0 + _font->_width * i;
-
- for (uint16 j = 0; j < _font->_height; j++) {
- memcpy(d, s, 8);
-
- s += 8;
- d += cnv->_width;
- }
- }
-
- return;
-}
-
-//
-// internal character mapping
-//
-byte Gfx::mapChar(byte c) {
-
- if (c == 0xA5) return 0x5F;
- if (c == 0xDF) return 0x60;
-
- if (c > 0x7F) return c - 0x7F;
-
- return c - 0x20;
-}
-
-
void Gfx::freeStaticCnv(StaticCnv *cnv) {
// printf("free_static_cnv()\n");
@@ -902,16 +802,7 @@ Gfx::Gfx(Parallaction* vm) :
memset(_palettefx, 0, sizeof(_palettefx));
initMouse( 0 );
-
- 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");
- _fonts[kFontLabel] = _vm->_disk->loadFont("intro");
- _fonts[kFontMenu] = _vm->_disk->loadFont("slide");
- }
+ initFonts();
_font = NULL;
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 0126532a2f..67226000e1 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -68,6 +68,26 @@ struct PaletteFxRange {
#include "common/pack-end.h" // END STRUCT PACKING
+class Font {
+
+ byte _color;
+
+
+public:
+ Font() {}
+ virtual ~Font() {}
+
+ virtual void setColor(byte color) {
+ _color = color;
+ }
+ virtual uint32 getStringWidth(const char *s) = 0;
+ virtual uint16 height() = 0;
+
+ virtual void drawString(byte* buffer, uint32 pitch, const char *s) = 0;
+
+
+};
+
struct StaticCnv {
uint16 _width; //
uint16 _height; //
@@ -195,6 +215,7 @@ public:
void setMousePointer(int16 index);
+ void initFonts();
void setFont(Fonts name);
public:
@@ -209,8 +230,8 @@ protected:
static byte * _buffers[NUM_BUFFERS];
static byte _mouseArrow[256];
StaticCnv *_mouseComposedArrow;
- Cnv *_font;
- Cnv *_fonts[3];
+ Font *_font;
+ Font *_fonts[3];
protected:
byte mapChar(byte c);
diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp
index 7d8bd59480..c07ea94297 100644
--- a/engines/parallaction/location.cpp
+++ b/engines/parallaction/location.cpp
@@ -459,6 +459,7 @@ void Parallaction::doLocationEnterTransition() {
} while (_mouseButtons != kMouseLeftUp);
#endif
+ _gfx->updateScreen();
waitUntilLeftClick();
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront );
diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp
index f8ea0a0d7d..0214779d90 100644
--- a/engines/parallaction/menu.cpp
+++ b/engines/parallaction/menu.cpp
@@ -106,21 +106,19 @@ void Menu::start() {
_vm->_disk->selectArchive((_vm->getPlatform() == Common::kPlatformPC) ? "disk1" : "disk0");
_vm->_gfx->_proportionalFont = false;
- _vm->_gfx->setFont(kFontMenu);
_vm->_disk->loadSlide("intro");
_vm->_gfx->extendPalette(_vm->_gfx->_palette);
_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
-
g_system->delayMillis(2000);
_vm->_disk->loadSlide("minintro");
_vm->_gfx->extendPalette(_vm->_gfx->_palette);
_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
-
g_system->delayMillis(2000);
if (_vm->getPlatform() == Common::kPlatformPC) {
+ _vm->_gfx->setFont(kFontMenu);
_vm->_disk->loadSlide("lingua");
_vm->_gfx->extendPalette(_vm->_gfx->_palette);
@@ -164,6 +162,7 @@ void Menu::newGame() {
_ax = (SCREEN_WIDTH - _vm->_gfx->getStringWidth(v14[3])) / 2;
_vm->_gfx->displayString(_ax, 120, v14[3]);
+ _vm->_gfx->updateScreen();
_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
@@ -255,6 +254,7 @@ uint16 Menu::selectGame() {
_vm->_gfx->displayString(60, 30, newGameMsg[_language]);
}
+ _vm->_gfx->updateScreen();
_vm->_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
}
@@ -359,6 +359,7 @@ void Menu::selectCharacter() {
_vm->_gfx->copyScreen(Gfx::kBit2, Gfx::kBitFront);
_vm->_gfx->displayString(60, 30, introMsg2[_language]);
+ _vm->_gfx->updateScreen();
g_system->delayMillis(2000);
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index ef140fb61f..08ba5d20d2 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -314,6 +314,8 @@ void Parallaction::displayCharacterComment(ExamineData *data) {
_gfx->drawBalloon(r, 0);
_gfx->displayWrappedString(data->_description, 140, 10, 130, 0);
+ _gfx->updateScreen();
+
waitUntilLeftClick();
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
@@ -352,9 +354,9 @@ void Parallaction::displayItemComment(ExamineData *data) {
_gfx->displayWrappedString(data->_description, 0, 90, 130, 0);
jobEraseAnimations((void*)1, NULL);
+ _gfx->updateScreen();
waitUntilLeftClick();
-
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
return;