diff options
author | Nicola Mettifogo | 2007-11-21 20:04:14 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-11-21 20:04:14 +0000 |
commit | 6af9577e84341630c00a29faa23d65a0d671aa81 (patch) | |
tree | 76d620fbdb2ae361f8fd3e23c1f6efdd0e589fd4 /engines | |
parent | 634595e0738cfb55d922ab91cdea7460156306a9 (diff) | |
download | scummvm-rg350-6af9577e84341630c00a29faa23d65a0d671aa81.tar.gz scummvm-rg350-6af9577e84341630c00a29faa23d65a0d671aa81.tar.bz2 scummvm-rg350-6af9577e84341630c00a29faa23d65a0d671aa81.zip |
* moved label drawing into Gfx, to be drawn directly in the framebuffer
* changed low level blitting function to accept Graphics::Surface to ease development
* temporarily disabled labels/subtitles in BRA
svn-id: r29593
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/exec_br.cpp | 8 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 63 | ||||
-rw-r--r-- | engines/parallaction/graphics.cpp | 126 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 13 | ||||
-rw-r--r-- | engines/parallaction/objects.cpp | 11 | ||||
-rw-r--r-- | engines/parallaction/objects.h | 3 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 30 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 15 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 4 |
9 files changed, 111 insertions, 162 deletions
diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 0806d6f9b6..b21c67ab0e 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -106,8 +106,6 @@ void Parallaction_br::setupSubtitles(char *s, char *s2, int y) { _subtitle1._pos.x = (_gfx->_screenX << 2) + ((640 - _subtitle1._cnv.w) >> 1); if (_jDisplaySubtitle == 0) { - _subtitle0._old.x = -1000; - _subtitle0._old.y = -1000; _jDisplaySubtitle = addJob(kJobDisplaySubtitle, 0, 1); _jEraseSubtitle = addJob(kJobEraseSubtitle, 0, 20); } @@ -427,11 +425,12 @@ DECLARE_INSTRUCTION_OPCODE(print) { void Parallaction_br::jobDisplaySubtitle(void *parm, Job *job) { - _gfx->drawLabel(_subtitle0); - _gfx->drawLabel(_subtitle1); +// _gfx->drawLabel(_subtitle0); +// _gfx->drawLabel(_subtitle1); } void Parallaction_br::jobEraseSubtitle(void *parm, Job *job) { +#if 0 Common::Rect r; if (_subtitle0._old.x != -1000) { @@ -451,6 +450,7 @@ void Parallaction_br::jobEraseSubtitle(void *parm, Job *job) { _gfx->restoreBackground(r); } _subtitle1._old = _subtitle1._pos; +#endif } DECLARE_INSTRUCTION_OPCODE(text) { diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 071810ad16..52e132a56e 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -844,67 +844,4 @@ void Parallaction_ns::initOpcodes() { } - -void Parallaction_ns::drawLabel() { - - if (!_label) - return; - - if (_deletingLabel) - return; - - debugC(9, kDebugExec, "jobDisplayLabel (%p)", (void *) _label); - - _gfx->drawLabel(*_label); - - return; -} - -void Parallaction_ns::eraseLabel() { - - static uint16 count = 0; - - if (!_label) - return; - - debugC(9, kDebugExec, "jobEraseLabel (%p)", (void *) _label); - - int16 _si, _di; - - if (_activeItem._id != 0) { - _si = _mousePos.x + 16 - _label->_cnv.w/2; - _di = _mousePos.y + 34; - } else { - _si = _mousePos.x + 8 - _label->_cnv.w/2; - _di = _mousePos.y + 21; - } - - if (_si < 0) _si = 0; - if (_di > 190) _di = 190; - - if (_label->_cnv.w + _si > _screenWidth) - _si = _screenWidth - _label->_cnv.w; - - Common::Rect r; - _label->getRect(r, true); - _gfx->restoreBackground(r); - - _label->_old = _label->_pos; - _label->_pos.x = _si; - _label->_pos.y = _di; - - if (_deletingLabel) { - count++; - if (count == 2) { - count = 0; - _engineFlags &= ~kEngineBlockInput; - _deletingLabel = false; - _label = 0; - } - } - - return; -} - - } // namespace Parallaction diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 615366a643..f8c792e148 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -214,7 +214,7 @@ void Gfx::drawBalloon(const Common::Rect& r, uint16 winding) { winding = (winding == 0 ? 1 : 0); Common::Rect s(BALLOON_TAIL_WIDTH, BALLOON_TAIL_HEIGHT); s.moveTo(r.left + (r.width()+5)/2 - 5, r.bottom - 1); - flatBlit(s, _resBalloonTail[winding], kBitFront, 2); + flatBlit(s, _resBalloonTail[winding], _buffers[kBitFront], 2); return; } @@ -285,16 +285,24 @@ void Gfx::setHalfbriteMode(bool enable) { #endif } +void Gfx::drawInventory() { + + if ((_engineFlags & kEngineInventory) == 0) { + return; + } + + Common::Rect r; + _vm->_inventoryRenderer->getRect(r); + byte *data = _vm->_inventoryRenderer->getData(); + + g_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height()); +} + void Gfx::updateScreen() { g_system->copyRectToScreen((const byte*)_buffers[kBitFront]->pixels, _buffers[kBitFront]->pitch, _screenX, _screenY, _vm->_screenWidth, _vm->_screenHeight); - if (_engineFlags & kEngineInventory) { - Common::Rect r; - _vm->_inventoryRenderer->getRect(r); - byte *data = _vm->_inventoryRenderer->getData(); - - g_system->copyRectToScreen(data, r.width(), r.left, r.top, r.width(), r.height()); - } + drawInventory(); + drawLabel(); g_system->updateScreen(); return; @@ -358,36 +366,26 @@ void Gfx::invertRect(Gfx::Buffers buffer, const Common::Rect& r) { } -void Gfx::screenClip(Common::Rect& r, Common::Point& p) { +void Gfx::flatBlit(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor) { - int32 x = r.left; - int32 y = r.top; - - Common::Rect screen(0, 0, _vm->_screenWidth, _vm->_screenHeight); - - r.clip(screen); - - if (!r.isValidRect()) return; - - p.x = r.left; - p.y = r.top; - - r.translate(screen.left - x, screen.top - y); + Common::Point dp; + Common::Rect q(r); -} + Common::Rect clipper(surf->w, surf->h); -void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor) { + q.clip(clipper); + if (!q.isValidRect()) return; - Common::Point dp; - Common::Rect q(r); + dp.x = q.left; + dp.y = q.top; - screenClip(q, dp); + q.translate(-r.left, -r.top); byte *s = data + q.left + q.top * r.width(); - byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y); + byte *d = (byte*)surf->getBasePtr(dp.x, dp.y); uint sPitch = r.width() - q.width(); - uint dPitch = _backgroundWidth - q.width(); + uint dPitch = surf->w - q.width(); for (uint16 i = q.top; i < q.bottom; i++) { for (uint16 j = q.left; j < q.right; j++) { @@ -404,20 +402,30 @@ void Gfx::flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte return; + } -void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer) { +void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *surf) { Common::Point dp; Common::Rect q(r); - screenClip(q, dp); + Common::Rect clipper(surf->w, surf->h); + + q.clip(clipper); + if (!q.isValidRect()) return; + + dp.x = q.left; + dp.y = q.top; + + q.translate(-r.left, -r.top); + byte *s = data + q.left + q.top * r.width(); - byte *d = (byte*)_buffers[buffer]->getBasePtr(dp.x, dp.y); + byte *d = (byte*)surf->getBasePtr(dp.x, dp.y); uint sPitch = r.width() - q.width(); - uint dPitch = _backgroundWidth - q.width(); + uint dPitch = surf->w - q.width(); for (uint16 i = 0; i < q.height(); i++) { @@ -439,11 +447,47 @@ void Gfx::blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer) } -void Gfx::drawLabel(Label &label) { - if (label._text == 0) +void Gfx::setLabel(Label *label) { + _label = label; + + if (_label) { + _label->resetPosition(); + } +} + +void Gfx::drawLabel() { + if (!_label || !_label->_text) { return; + } - flatBlitCnv(&label._cnv, label._pos.x, label._pos.y, Gfx::kBitBack); + int16 _si, _di; + + Common::Point cursor; + _vm->getCursorPos(cursor); + + if (_vm->_activeItem._id != 0) { + _si = cursor.x + 16 - _label->_cnv.w/2; + _di = cursor.y + 34; + } else { + _si = cursor.x + 8 - _label->_cnv.w/2; + _di = cursor.y + 21; + } + + if (_si < 0) _si = 0; + if (_di > 190) _di = 190; + + if (_label->_cnv.w + _si > _vm->_screenWidth) + _si = _vm->_screenWidth - _label->_cnv.w; + + _label->_pos.x = _si; + _label->_pos.y = _di; + + Common::Rect r(_label->_cnv.w, _label->_cnv.h); + r.moveTo(_label->_pos); + + Graphics::Surface* surf = g_system->lockScreen(); + flatBlit(r, (byte*)_label->_cnv.getBasePtr(0, 0), surf, 0); + g_system->unlockScreen(); } @@ -468,7 +512,7 @@ void Gfx::flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buf Common::Rect r(cnv->w, cnv->h); r.moveTo(x, y); - flatBlit(r, (byte*)cnv->pixels, buffer, 0); + flatBlit(r, (byte*)cnv->pixels, _buffers[buffer], 0); return; } @@ -477,7 +521,7 @@ void Gfx::blitCnv(Graphics::Surface *cnv, int16 x, int16 y, uint16 z, Gfx::Buffe Common::Rect r(cnv->w, cnv->h); r.moveTo(x, y); - blit(r, z, (byte*)cnv->pixels, buffer); + blit(r, z, (byte*)cnv->pixels, _buffers[buffer]); return; } @@ -551,8 +595,8 @@ void Gfx::restoreDoorBackground(const Common::Rect& r, byte *data, byte* backgro // void Gfx::restoreGetBackground(const Common::Rect& r, byte *data) { - flatBlit(r, data, kBitBack, 0); - flatBlit(r, data, kBit2, 0); + flatBlit(r, data, _buffers[kBitBack], 0); + flatBlit(r, data, _buffers[kBit2], 0); return; } @@ -765,6 +809,8 @@ Gfx::Gfx(Parallaction* vm) : setPalette(_palette); + _label = 0; + _screenX = 0; _screenY = 0; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index a0aa19254f..9476edb517 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -217,7 +217,9 @@ public: uint16 getStringWidth(const char *text); void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height); - void drawLabel(Label &label); + // labels + Label *_label; + void setLabel(Label *label); // cut/paste void flatBlitCnv(Graphics::Surface *cnv, int16 x, int16 y, Gfx::Buffers buffer); @@ -278,13 +280,16 @@ protected: bool _halfbrite; protected: + void drawInventory(); + void drawLabel(); + void initBuffers(int w, int h); void freeBuffers(); void copyRect(uint width, uint height, byte *dst, uint dstPitch, byte *src, uint srcPitch); - void flatBlit(const Common::Rect& r, byte *data, Gfx::Buffers buffer, byte transparentColor); - void blit(const Common::Rect& r, uint16 z, byte *data, Gfx::Buffers buffer); - void screenClip(Common::Rect& r, Common::Point& p); + + void blit(const Common::Rect& r, uint16 z, byte *data, Graphics::Surface *surf); + void flatBlit(const Common::Rect& r, byte *data, Graphics::Surface *surf, byte transparentColor); }; diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp index c3e0a2dacc..0d46568106 100644 --- a/engines/parallaction/objects.cpp +++ b/engines/parallaction/objects.cpp @@ -210,19 +210,12 @@ void Label::free() { void Label::resetPosition() { _pos.x = -1000; _pos.y = -1000; - _old.x = -1000; - _old.y = -1000; } -void Label::getRect(Common::Rect &r, bool old) { +void Label::getRect(Common::Rect &r) { r.setWidth(_cnv.w); r.setHeight(_cnv.h); - - if (old) { - r.moveTo(_old); - } else { - r.moveTo(_pos); - } + r.moveTo(_pos); } Answer::Answer() { diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h index f4246cf2ae..fdbe062e8b 100644 --- a/engines/parallaction/objects.h +++ b/engines/parallaction/objects.h @@ -262,14 +262,13 @@ struct Label { Graphics::Surface _cnv; Common::Point _pos; - Common::Point _old; Label(); ~Label(); void free(); void resetPosition(); - void getRect(Common::Rect &r, bool old = false); + void getRect(Common::Rect &r); }; struct Zone { diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 43091286af..1dd377b9a3 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -159,8 +159,6 @@ int Parallaction::init() { _location._startFrame = 0; _location._comment = NULL; _location._endComment = NULL; - _label = 0; - _deletingLabel = false; _backgroundInfo = 0; _pathBuffer = 0; @@ -285,7 +283,6 @@ void Parallaction::runGame() { changeLocation(_location._name); } - eraseLabel(); eraseAnimations(); runScripts(); @@ -294,7 +291,6 @@ void Parallaction::runGame() { runJobs(); drawAnimations(); - drawLabel(); updateView(); @@ -313,38 +309,18 @@ void Parallaction::updateView() { g_system->delayMillis(30); } -void Parallaction::showLabel(Label &label) { - label.resetPosition(); - _label = &label; -} - -void Parallaction::hideLabel(uint priority) { - - if (!_label) - return; - - if (priority == kPriority99) { - _label = 0; - } else { - // schedule job for deletion - _deletingLabel = true; - _engineFlags |= kEngineBlockInput; - } - -} - void Parallaction::processInput(InputData *data) { switch (data->_event) { case kEvEnterZone: debugC(2, kDebugInput, "processInput: kEvEnterZone"); - showLabel(*data->_label); + _gfx->setLabel(data->_label); break; case kEvExitZone: debugC(2, kDebugInput, "processInput: kEvExitZone"); - hideLabel(kPriority15); + _gfx->setLabel(0); break; case kEvAction: @@ -359,7 +335,7 @@ void Parallaction::processInput(InputData *data) { case kEvOpenInventory: _procCurrentHoverItem = -1; _hoverZone = NULL; - hideLabel(kPriority2); + _gfx->setLabel(0); if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) == 0) { setArrowCursor(); } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 23506de61d..874c5cb1b6 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -91,8 +91,7 @@ enum { kPriority18 = 18, kPriority19 = 19, kPriority20 = 20, - kPriority21 = 21, - kPriority99 = 99 // fictitious priority value used as a flag to handle quick label deletion + kPriority21 = 21 }; enum { @@ -439,11 +438,6 @@ public: Table *_callableNames; Table *_localFlagNames; - bool _deletingLabel; - Label *_label; - void showLabel(Label &label); - void hideLabel(uint priority); - public: int getGameType() const; uint32 getFeatures() const; @@ -477,6 +471,9 @@ public: InventoryItem _activeItem; Common::Point _mousePos; + void getCursorPos(Common::Point& p) { + p = _mousePos; + } Zone *_activeZone; @@ -577,8 +574,6 @@ public: virtual void walk() = 0; virtual void drawAnimations() = 0; virtual void eraseAnimations() = 0; - virtual void drawLabel() = 0; - virtual void eraseLabel() = 0; void beep(); @@ -749,8 +744,6 @@ protected: void walk(); void drawAnimations(); void eraseAnimations(); - void drawLabel(); - void eraseLabel(); // location parser diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 5ec2f3812c..b810ff7da7 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -204,7 +204,7 @@ void Parallaction_ns::setArrowCursor() { debugC(1, kDebugInput, "setting mouse cursor to arrow"); // this stuff is needed to avoid artifacts with labels and selected items when switching cursors - hideLabel(kPriority15); + _gfx->setLabel(0); _activeItem._id = 0; _system->setMouseCursor(_mouseArrow, MOUSEARROW_WIDTH, MOUSEARROW_HEIGHT, 0, 0, 0); @@ -317,7 +317,7 @@ void Parallaction_ns::changeLocation(char *location) { // WORKAROUND: this hideLabel has been added to avoid crashes caused by // execution of label jobs after a location switch. The other workaround in // Parallaction::runGame should have been rendered useless by this one. - hideLabel(kPriority99); + _gfx->setLabel(0); _hoverZone = NULL; if (_engineFlags & kEngineBlockInput) { |