aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruruk2014-06-06 22:07:32 +0200
committeruruk2014-06-06 22:07:32 +0200
commit152d795b456e4e71e85322cdfcfa402241bf9365 (patch)
tree45239f293f9d31d01ae7d94ee5c32b13c4946f5a
parent9efb2ef1a9e57ee1bf01a0111a1bdbd387486938 (diff)
downloadscummvm-rg350-152d795b456e4e71e85322cdfcfa402241bf9365.tar.gz
scummvm-rg350-152d795b456e4e71e85322cdfcfa402241bf9365.tar.bz2
scummvm-rg350-152d795b456e4e71e85322cdfcfa402241bf9365.zip
CGE2: Implement InfoLine.
Move initialization of _font, so it precedes _infoLine's and doesn't cause more problems.
-rw-r--r--engines/cge2/cge2.cpp6
-rw-r--r--engines/cge2/cge2.h2
-rw-r--r--engines/cge2/cge2_main.cpp3
-rw-r--r--engines/cge2/talk.cpp69
-rw-r--r--engines/cge2/talk.h9
5 files changed, 70 insertions, 19 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp
index c80bf502d8..231e72b6f3 100644
--- a/engines/cge2/cge2.cpp
+++ b/engines/cge2/cge2.cpp
@@ -58,6 +58,7 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_spare = nullptr;
_commandHandler = nullptr;
_commandHandlerTurbo = nullptr;
+ _font = nullptr;
_infoLine = nullptr;
_mouse = nullptr;
_keyboard = nullptr;
@@ -70,7 +71,6 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription)
_vol[i] = nullptr;
_eventManager = nullptr;
_blinkSprite = nullptr;
- _font = nullptr;
_quitFlag = false;
_bitmapPalette = nullptr;
@@ -109,6 +109,7 @@ void CGE2Engine::init() {
_spare = new Spare(this);
_commandHandler = new CommandHandler(this, false);
_commandHandlerTurbo = new CommandHandler(this, true);
+ _font = new Font(this);
_infoLine = new InfoLine(this, kInfoW);
_mouse = new Mouse(this);
_keyboard = new Keyboard(this);
@@ -116,7 +117,6 @@ void CGE2Engine::init() {
_point[i] = new V3D();
_sys = new System(this);
_eventManager = new EventManager(this);
- _font = new Font(this);
}
void CGE2Engine::deinit() {
@@ -136,6 +136,7 @@ void CGE2Engine::deinit() {
delete _sprite;
delete _commandHandler;
delete _commandHandlerTurbo;
+ delete _font;
delete _infoLine;
delete _mouse;
delete _keyboard;
@@ -148,7 +149,6 @@ void CGE2Engine::deinit() {
delete _eventManager;
if (_blinkSprite != nullptr)
delete _blinkSprite;
- delete _font;
}
bool CGE2Engine::hasFeature(EngineFeature f) const {
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index ec206af1db..d049339dee 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -219,6 +219,7 @@ public:
Spare *_spare;
CommandHandler *_commandHandler;
CommandHandler *_commandHandlerTurbo;
+ Font *_font;
InfoLine *_infoLine;
Mouse *_mouse;
Keyboard *_keyboard;
@@ -229,7 +230,6 @@ public:
Sprite *_vol[2];
EventManager *_eventManager;
Sprite *_blinkSprite;
- Font *_font;
private:
void init();
void deinit();
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index 99447efad2..a37abbceed 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -516,8 +516,7 @@ void CGE2Engine::runGame() {
_infoLine->gotoxyz(V3D(kInfoX, kInfoY, 0));
_infoLine->setText(nullptr);
- //_vga->_showQ->insert(_infoLine);
- warning("STUB: CGE2Engine::runGame() - Info Line is missing!");
+ _vga->_showQ->insert(_infoLine);
caveUp(_now);
_startupMode = 0;
diff --git a/engines/cge2/talk.cpp b/engines/cge2/talk.cpp
index df88f72774..ee4a675fc3 100644
--- a/engines/cge2/talk.cpp
+++ b/engines/cge2/talk.cpp
@@ -244,20 +244,71 @@ void Talk::update(const char *text) {
setShapeList(b, 1);
}
-InfoLine::InfoLine(CGE2Engine *vm, uint16 w) : Talk(vm), _oldText(NULL), _vm(vm) {
- warning("STUB: InfoLine::InfoLine()");
+InfoLine::InfoLine(CGE2Engine *vm, uint16 w, ColorBank color)
+: Talk(vm), _oldText(nullptr), _newText(nullptr), _realTime(false), _vm(vm) {
+ BitmapPtr b = new Bitmap[1];
+ if (color == kCBRel)
+ _vm->setAutoColors();
+ _color = _vm->_font->_colorSet[color];
+ V2D siz = V2D(_vm, w, kFontHigh);
+ b[0] = Bitmap(_vm, siz.x, siz.y, _color[2]);
+ setShapeList(b, 1);
}
void InfoLine::update(const char *text) {
- warning("STUB: InfoLine::update()");
-}
+ if (!_realTime && text == _oldText)
+ return;
+
+ _oldText = text;
+
+ uint16 w = _ext->_shpList->_w;
+ uint16 h = _ext->_shpList->_h;
+ uint8 *v = _ext->_shpList->_v;
+ uint16 dsiz = w >> 2; // data size (1 plane line size)
+ uint16 lsiz = 2 + dsiz + 2; // uint16 for line header, uint16 for gap
+ uint16 psiz = h * lsiz; // - last gape, but + plane trailer
+ uint16 size = 4 * psiz; // whole map size
+ uint8 fg = _color[0];
+ uint8 bg = _color[2];
-void InfoLine::update() {
- warning("STUB: InfoLine::update()");
-}
+ // clear whole rectangle
+ memset(v + 2, bg, dsiz); // data bytes
+ for (byte *pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz) {
+ Common::copy(v, v + lsiz, pDest);
+ }
+ *(uint16 *)(v + psiz - 2) = TO_LE_16(kBmpEOI); // plane trailer uint16
+ for (byte *pDest = v + psiz; pDest < (v + 4 * psiz); pDest += psiz) {
+ Common::copy(v, v + psiz, pDest);
+ }
-void InfoLine::setText(const char *txt) {
- warning("STUB: InfoLine::setText()");
+ // paint text line
+ if (_newText) {
+ uint8 *p = v + 2, *q = p + size;
+
+ while (*text) {
+ uint16 cw = _vm->_font->_widthArr[(unsigned char)*text];
+ uint8 *fp = _vm->_font->_map + _vm->_font->_pos[(unsigned char)*text];
+
+ // Handle properly space size, after it was enlarged to display properly
+ // 'F1' text.
+ int8 fontStart = 0;
+ if ((*text == 0x20) && (cw > 4) && (!_wideSpace))
+ fontStart = 2;
+
+ for (int i = fontStart; i < cw; i++) {
+ uint16 b = fp[i];
+ for (uint16 n = 0; n < kFontHigh; n++) {
+ if (b & 1)
+ *p = fg;
+ b >>= 1;
+ p += lsiz;
+ }
+ if (p >= q)
+ p = p - size + 1;
+ }
+ text++;
+ }
+ }
}
} // End of namespace CGE2
diff --git a/engines/cge2/talk.h b/engines/cge2/talk.h
index 771478c5d1..84ba7281f9 100644
--- a/engines/cge2/talk.h
+++ b/engines/cge2/talk.h
@@ -82,12 +82,13 @@ private:
};
class InfoLine : public Talk {
- const char *_oldText;
+ const char *_oldText, *_newText;
public:
- InfoLine(CGE2Engine *vm, uint16 wid);
+ bool _realTime;
+ InfoLine(CGE2Engine *vm, uint16 wid, ColorBank color = kCBStd);
void update(const char *text);
- void update();
- void setText(const char *txt);
+ void update() { update(_newText); }
+ void setText(const char *txt) { _newText = txt; }
private:
CGE2Engine *_vm;
};