aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorjohndoe1232014-12-12 13:12:12 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit9d98f92298c7e0c494b0ae6455a5f0183080db70 (patch)
treeef54e0d117025bfe315fc858e65b9460a1d31bec /engines
parent36ec0fafdb186ad55a0d6c08e38b96ef84fa60a8 (diff)
downloadscummvm-rg350-9d98f92298c7e0c494b0ae6455a5f0183080db70.tar.gz
scummvm-rg350-9d98f92298c7e0c494b0ae6455a5f0183080db70.tar.bz2
scummvm-rg350-9d98f92298c7e0c494b0ae6455a5f0183080db70.zip
ILLUSIONS: Add text drawing to BBDOU
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.cpp9
-rw-r--r--engines/illusions/bbdou/bbdou_specialcode.h4
-rw-r--r--engines/illusions/bbdou/illusions_bbdou.cpp3
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp2
-rw-r--r--engines/illusions/resources/fontresource.cpp6
-rw-r--r--engines/illusions/resources/fontresource.h2
-rw-r--r--engines/illusions/screen.cpp62
-rw-r--r--engines/illusions/screen.h13
-rw-r--r--engines/illusions/screentext.cpp32
-rw-r--r--engines/illusions/threads/talkthread.cpp25
-rw-r--r--engines/illusions/threads/talkthread_duckman.cpp2
11 files changed, 124 insertions, 36 deletions
diff --git a/engines/illusions/bbdou/bbdou_specialcode.cpp b/engines/illusions/bbdou/bbdou_specialcode.cpp
index a7054841ac..a7dadc487c 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.cpp
+++ b/engines/illusions/bbdou/bbdou_specialcode.cpp
@@ -50,7 +50,7 @@ static const Struct10 kStruct10s[] = {
{0x1B000C, 0, 0, 0},
};
-CauseThread::CauseThread(IllusionsEngine_BBDOU *vm, uint32 threadId, uint32 callingThreadId,
+CauseThread_BBDOU::CauseThread_BBDOU(IllusionsEngine_BBDOU *vm, uint32 threadId, uint32 callingThreadId,
BbdouSpecialCode *bbdou, uint32 cursorObjectId, uint32 sceneId, uint32 verbId,
uint32 objectId2, uint32 objectId)
: Thread(vm, threadId, callingThreadId, 0), _bbdou(bbdou), _cursorObjectId(cursorObjectId),
@@ -58,12 +58,12 @@ CauseThread::CauseThread(IllusionsEngine_BBDOU *vm, uint32 threadId, uint32 call
_type = kTTSpecialThread;
}
-void CauseThread::onNotify() {
+void CauseThread_BBDOU::onNotify() {
_bbdou->_cursor->_data._causeThreadId1 = 0;
terminate();
}
-void CauseThread::onTerminated() {
+void CauseThread_BBDOU::onTerminated() {
_bbdou->_cursor->_data._causeThreadId1 = 0;
_bbdou->_cursor->enable(_cursorObjectId);
}
@@ -260,7 +260,6 @@ void BbdouSpecialCode::spcRemoveInventoryItem(OpCall &opCall) {
void BbdouSpecialCode::spcHasInventoryItem(OpCall &opCall) {
ARG_UINT32(objectId);
_vm->_stack->push(_inventory->hasInventoryItem(objectId) ? 1 : 0);
-debug("_inventory->hasInventoryItem(%08X) = %d", objectId, _inventory->hasInventoryItem(objectId));
}
void BbdouSpecialCode::spcCloseInventory(OpCall &opCall) {
@@ -683,7 +682,7 @@ bool BbdouSpecialCode::runCause(Control *cursorControl, CursorData &cursorData,
uint32 BbdouSpecialCode::startCauseThread(uint32 cursorObjectId, uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) {
uint32 tempThreadId = _vm->newTempThreadId();
debug(3, "Starting cause thread %08X...", tempThreadId);
- CauseThread *causeThread = new CauseThread(_vm, tempThreadId, 0, this,
+ CauseThread_BBDOU *causeThread = new CauseThread_BBDOU(_vm, tempThreadId, 0, this,
cursorObjectId, sceneId, verbId, objectId2, objectId);
_vm->_threads->startThread(causeThread);
causeThread->suspend();
diff --git a/engines/illusions/bbdou/bbdou_specialcode.h b/engines/illusions/bbdou/bbdou_specialcode.h
index 037d4750ce..2462c2b172 100644
--- a/engines/illusions/bbdou/bbdou_specialcode.h
+++ b/engines/illusions/bbdou/bbdou_specialcode.h
@@ -47,9 +47,9 @@ struct Struct10 {
uint32 _sequenceId3;
};
-class CauseThread : public Thread {
+class CauseThread_BBDOU : public Thread {
public:
- CauseThread(IllusionsEngine_BBDOU *vm, uint32 threadId, uint32 callingThreadId,
+ CauseThread_BBDOU(IllusionsEngine_BBDOU *vm, uint32 threadId, uint32 callingThreadId,
BbdouSpecialCode *bbdou, uint32 cursorObjectId, uint32 sceneId,
uint32 verbId, uint32 objectId2, uint32 objectId);
virtual void onNotify();
diff --git a/engines/illusions/bbdou/illusions_bbdou.cpp b/engines/illusions/bbdou/illusions_bbdou.cpp
index 112aa3f1d0..9aeb0808cf 100644
--- a/engines/illusions/bbdou/illusions_bbdou.cpp
+++ b/engines/illusions/bbdou/illusions_bbdou.cpp
@@ -216,6 +216,8 @@ Common::Error IllusionsEngine_BBDOU::run() {
_updateFunctions = new UpdateFunctions();
_soundMan = new SoundMan(this);
+ _screen->setColorKey1(0xF81F);
+
initInput();
initUpdateFunctions();
@@ -286,6 +288,7 @@ bool IllusionsEngine_BBDOU::hasFeature(EngineFeature f) const {
}
void IllusionsEngine_BBDOU::initInput() {
+ // TODO Check if these are correct...
_input->setInputEvent(kEventLeftClick, 0x01)
.addMouseButton(MOUSE_LEFT_BUTTON)
.addKey(Common::KEYCODE_RETURN);
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index b861d7328e..d30f17bd69 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -113,6 +113,8 @@ Common::Error IllusionsEngine_Duckman::run() {
_dialogSys = new DuckmanDialogSystem(this);
+ _screen->setColorKey1(0);
+
initInput();
initUpdateFunctions();
diff --git a/engines/illusions/resources/fontresource.cpp b/engines/illusions/resources/fontresource.cpp
index becc6cf58b..678e555686 100644
--- a/engines/illusions/resources/fontresource.cpp
+++ b/engines/illusions/resources/fontresource.cpp
@@ -92,7 +92,7 @@ void FontResource::load(Resource *resource) {
Common::MemoryReadStream stream(data, dataSize, DisposeAfterUse::NO);
_totalSize = stream.readUint32LE();
_charHeight = stream.readUint16LE();
- _field_6 = stream.readUint16LE();
+ _defaultChar = stream.readUint16LE();
_colorIndex = stream.readUint16LE();
_lineIncr = stream.readUint16LE();
_widthC = stream.readUint16LE();
@@ -103,8 +103,8 @@ void FontResource::load(Resource *resource) {
stream.seek(charRangesOffs + i * 8);
_charRanges[i].load(data, stream);
}
- debug(2, "FontResource::load() _charHeight: %d; _field_6: %d; _colorIndex: %d; _lineIncr: %d; _widthC: %d; _charRangesCount: %d",
- _charHeight, _field_6, _colorIndex, _lineIncr, _widthC, _charRangesCount);
+ debug(2, "FontResource::load() _charHeight: %d; _defaultChar: %d; _colorIndex: %d; _lineIncr: %d; _widthC: %d; _charRangesCount: %d",
+ _charHeight, _defaultChar, _colorIndex, _lineIncr, _widthC, _charRangesCount);
}
CharInfo *FontResource::getCharInfo(uint16 c) {
diff --git a/engines/illusions/resources/fontresource.h b/engines/illusions/resources/fontresource.h
index 8ea059fa37..579277c5f9 100644
--- a/engines/illusions/resources/fontresource.h
+++ b/engines/illusions/resources/fontresource.h
@@ -69,7 +69,7 @@ public:
public:
uint32 _totalSize;
int16 _charHeight;
- int16 _field_6;
+ int16 _defaultChar;
int16 _colorIndex;
int16 _lineIncr;
int16 _widthC;
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp
index 955317bcc0..b9506f63d4 100644
--- a/engines/illusions/screen.cpp
+++ b/engines/illusions/screen.cpp
@@ -217,11 +217,10 @@ bool SpriteDrawQueue::calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcR
// Screen
Screen::Screen(IllusionsEngine *vm, int16 width, int16 height, int bpp)
- : _vm(vm), _colorKey2(0) {
+ : _vm(vm), _colorKey1(0), _colorKey2(0) {
_displayOn = true;
_decompressQueue = new SpriteDecompressQueue(this);
_drawQueue = new SpriteDrawQueue(this);
- _colorKey1 = 0xF800 | 0x1F;
if (bpp == 8) {
initGraphics(width, height, false);
} else {
@@ -274,10 +273,6 @@ void Screen::setScreenOffset(Common::Point offsPt) {
}
}
-uint16 Screen::getColorKey2() {
- return _colorKey2;
-}
-
void Screen::updateSprites() {
_decompressQueue->decompressAll();
// NOTE Skipped doShiftBrightness and related as it seems to be unused
@@ -475,11 +470,24 @@ void Screen::buildColorTransTbl() {
}
void Screen::drawText(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count) {
+ switch (_backSurface->format.bytesPerPixel) {
+ case 1:
+ drawText8(font, surface, x, y, text, count);
+ break;
+ case 2:
+ drawText16(font, surface, x, y, text, count);
+ break;
+ default:
+ break;
+ }
+}
+
+void Screen::drawText8(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count) {
for (uint i = 0; i < count; ++i)
- x += font->_widthC + drawChar(font, surface, x, y, *text++);
+ x += font->_widthC + drawChar8(font, surface, x, y, *text++);
}
-int16 Screen::drawChar(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c) {
+int16 Screen::drawChar8(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c) {
const CharInfo *charInfo = font->getCharInfo(c);
const int16 charWidth = charInfo->_width;
byte *dst = (byte*)surface->getBasePtr(x, y);
@@ -494,6 +502,27 @@ int16 Screen::drawChar(FontResource *font, Graphics::Surface *surface, int16 x,
return charWidth;
}
+void Screen::drawText16(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count) {
+ for (uint i = 0; i < count; ++i)
+ x += font->_widthC + drawChar16(font, surface, x, y, *text++);
+}
+
+int16 Screen::drawChar16(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c) {
+ const CharInfo *charInfo = font->getCharInfo(c);
+ const int16 charWidth = charInfo->_width;
+ byte *pixels = charInfo->_pixels;
+ for (int16 yc = 0; yc < font->_charHeight; ++yc) {
+ byte *dst = (byte*)surface->getBasePtr(x, y + yc);
+ for (int16 xc = 0; xc < charWidth; ++xc) {
+ if (pixels[xc])
+ WRITE_LE_UINT16(dst, convertFontColor(pixels[xc]));
+ dst += 2;
+ }
+ pixels += charWidth;
+ }
+ return charWidth;
+}
+
void Screen::setSystemPalette(byte *palette) {
g_system->getPaletteManager()->setPalette(palette, 0, 256);
}
@@ -843,4 +872,21 @@ void Screen::drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Co
}
+uint16 Screen::convertFontColor(byte color) {
+ if (color) {
+ byte r, g, b;
+ if (color == 204) {
+ r = 50;
+ g = 50;
+ b = 180;
+ } else {
+ r = 256 - color;
+ g = 256 - color;
+ b = 256 - color;
+ }
+ return g_system->getScreenFormat().RGBToColor(r, g, b);
+ }
+ return _colorKey1;
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/screen.h b/engines/illusions/screen.h
index 1eef207513..bdb7ea0258 100644
--- a/engines/illusions/screen.h
+++ b/engines/illusions/screen.h
@@ -122,7 +122,6 @@ public:
bool isDisplayOn();
void setDisplayOn(bool isOn);
void setScreenOffset(Common::Point offsPt);
- uint16 getColorKey2();
void updateSprites();
void clearScreenOffsetAreas();
void decompressSprite(SpriteDecompressQueueItem *item);
@@ -135,7 +134,9 @@ public:
void updateFaderPalette();
void setFader(int newValue, int firstIndex, int lastIndex);
void drawText(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count);
- int16 drawChar(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c);
+ uint16 getColorKey1() const { return _colorKey1; }
+ void setColorKey1(uint16 colorKey) { _colorKey1 = colorKey; }
+ uint16 getColorKey2() const { return _colorKey2; }
int16 getScreenWidth() const { return _backSurface->w; }
int16 getScreenHeight() const { return _backSurface->h; }
public:
@@ -161,6 +162,12 @@ public:
void setSystemPalette(byte *palette);
void buildColorTransTbl();
+ void drawText8(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count);
+ int16 drawChar8(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c);
+
+ void drawText16(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 *text, uint count);
+ int16 drawChar16(FontResource *font, Graphics::Surface *surface, int16 x, int16 y, uint16 c);
+
void decompressSprite8(SpriteDecompressQueueItem *item);
void drawSurface8(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, int16 scale, uint32 flags);
void drawSurface81(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect);
@@ -172,6 +179,8 @@ public:
void drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface, Common::Rect &srcRect);
void drawSurface20(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect, uint16 colorKey);
void drawSurface21(Common::Rect &dstRect, Graphics::Surface *surface, Common::Rect &srcRect);
+
+ uint16 convertFontColor(byte color);
};
} // End of namespace Illusions
diff --git a/engines/illusions/screentext.cpp b/engines/illusions/screentext.cpp
index 018decba36..8c31705300 100644
--- a/engines/illusions/screentext.cpp
+++ b/engines/illusions/screentext.cpp
@@ -56,15 +56,28 @@ void ScreenText::updateTextInfoPosition(Common::Point position) {
}
void ScreenText::clipTextInfoPosition(Common::Point &position) {
- // TODO Set min/max for BBDOU
- if (position.x < 2)
- position.x = 2;
- else if (position.x + _dimensions._width > 318)
- position.x = 318 - _dimensions._width;
- if (position.y < 2)
- position.y = 2;
- else if (position.y + _dimensions._height > 198)
- position.y = 198 - _dimensions._height;
+ // TODO Move values outside
+ if (_vm->getGameId() == kGameIdBBDOU) {
+ // BBDOU
+ if (position.x < 2)
+ position.x = 2;
+ else if (position.x + _dimensions._width > 638)
+ position.x = 638 - _dimensions._width;
+ if (position.y < 2)
+ position.y = 2;
+ else if (position.y + _dimensions._height > 478)
+ position.y = 478 - _dimensions._height;
+ } else {
+ // Duckman
+ if (position.x < 2)
+ position.x = 2;
+ else if (position.x + _dimensions._width > 318)
+ position.x = 318 - _dimensions._width;
+ if (position.y < 2)
+ position.y = 2;
+ else if (position.y + _dimensions._height > 198)
+ position.y = 198 - _dimensions._height;
+ }
}
bool ScreenText::refreshScreenText(FontResource *font, WidthHeight dimensions, Common::Point offsPt,
@@ -72,6 +85,7 @@ bool ScreenText::refreshScreenText(FontResource *font, WidthHeight dimensions, C
TextDrawer textDrawer;
bool done = textDrawer.wrapText(font, text, &dimensions, offsPt, textFlags, outTextPtr);
_surface = _vm->_screen->allocSurface(dimensions._width, dimensions._height);
+ _surface->fillRect(Common::Rect(0, 0, _surface->w, _surface->h), _vm->_screen->getColorKey1());
_dimensions = dimensions;
textDrawer.drawText(_vm->_screen, _surface, color2, color1);
return done;
diff --git a/engines/illusions/threads/talkthread.cpp b/engines/illusions/threads/talkthread.cpp
index 4fbb5a2393..7adf9e56bd 100644
--- a/engines/illusions/threads/talkthread.cpp
+++ b/engines/illusions/threads/talkthread.cpp
@@ -26,6 +26,7 @@
#include "illusions/dictionary.h"
#include "illusions/input.h"
#include "illusions/resources/talkresource.h"
+#include "illusions/screentext.h"
#include "illusions/sound.h"
#include "illusions/time.h"
@@ -159,7 +160,7 @@ int TalkThread::onUpdate() {
if (!(_flags & 4) && !_vm->_soundMan->isVoicePlaying())
_flags |= 4;
if (!(_flags & 8) && isTimerExpired(_textStartTime, _textEndTime)) {
- // TODO _vm->removeText();
+ _vm->_screenText->removeText();
if (_entryText && *_entryText) {
refreshText();
_vm->_input->discardEvent(kEventSkip);
@@ -180,7 +181,7 @@ int TalkThread::onUpdate() {
}
if (_objectId && _vm->_input->pollEvent(kEventSkip)) {
if (!(_flags & 8)) {
- // TODO _vm->removeText();
+ _vm->_screenText->removeText();
if (_entryText && *_entryText)
refreshText();
else
@@ -224,7 +225,7 @@ int TalkThread::onUpdate() {
_flags |= 2;
}
if (!(_flags & 8)) {
- // TODO _vm->removeText();
+ _vm->_screenText->removeText();
_flags |= 8;
}
if (!(_flags & 4)) {
@@ -307,11 +308,10 @@ static char *debugW2I(byte *wstr) {
}
int TalkThread::insertText() {
+/*
int charCount = 100;
-
debug("%08X %08X [%s]", _threadId, _talkId, debugW2I(_currEntryText));
_entryText = 0;
-
// TODO _vm->getDimensions1(&dimensions);
// TODO _vm->insertText(_currEntryText, _vm->_currFontId, dimensions, 0, 2, 0, 0, 0, 0, 0, 0, &outTextPtr);
// TODO _vm->charCount = (char *)outTextPtr - (char *)text;
@@ -319,6 +319,21 @@ int TalkThread::insertText() {
// TODO _vm->getPoint1(&pt);
// TODO _vm->updateTextInfoPosition(pt);
return charCount >> 1;
+*/
+ debug("%08X %08X [%s]", _threadId, _talkId, debugW2I(_currEntryText));
+ WidthHeight dimensions;
+ _vm->getDefaultTextDimensions(dimensions);
+ uint16 *outTextPtr;
+ _vm->_screenText->insertText((uint16*)_currEntryText, 0x120001, dimensions,
+ //Common::Point(0, 0), 2, 0, 0, _color.r, _color.g, _color.b, outTextPtr);
+ Common::Point(0, 0), 2, 0, 0, 0, 0, 0, outTextPtr);
+ _entryText = (byte*)outTextPtr;
+ Common::Point pt;
+ _vm->getDefaultTextPosition(pt);
+ _vm->_screenText->updateTextInfoPosition(pt);
+ //_vm->_screenText->updateTextInfoPosition(Common::Point(320, 200));
+ int charCount = (_entryText - _currEntryText) / 2;
+ return charCount;
}
TalkEntry *TalkThread::getTalkResourceEntry(uint32 talkId) {
diff --git a/engines/illusions/threads/talkthread_duckman.cpp b/engines/illusions/threads/talkthread_duckman.cpp
index f47dd7d903..6d8224e990 100644
--- a/engines/illusions/threads/talkthread_duckman.cpp
+++ b/engines/illusions/threads/talkthread_duckman.cpp
@@ -289,7 +289,7 @@ int TalkThread_Duckman::insertText() {
_vm->getDefaultTextDimensions(dimensions);
uint16 *outTextPtr;
_vm->_screenText->insertText((uint16*)_currEntryText, 0x120001, dimensions,
- Common::Point(0, 0), 2, 0, 0, _color.r, _color.r, _color.r, outTextPtr);
+ Common::Point(0, 0), 2, 0, 0, _color.r, _color.g, _color.b, outTextPtr);
_entryText = (byte*)outTextPtr;
Common::Point pt;
_vm->getDefaultTextPosition(pt);