From 9c04b0c2290caa67fc4b22b7a37e2abbff97c3de Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 6 Dec 2008 14:24:40 +0000 Subject: All the screen drawing functions draw to the back buffer, so there is no point in passing it everywhere svn-id: r35260 --- engines/saga/actor.cpp | 10 +-- engines/saga/font.cpp | 48 +++++------ engines/saga/font.h | 16 ++-- engines/saga/interface.cpp | 196 +++++++++++++++++++++++---------------------- engines/saga/interface.h | 18 ++--- engines/saga/isomap.cpp | 45 +++++------ engines/saga/isomap.h | 14 ++-- engines/saga/objectmap.cpp | 8 +- engines/saga/objectmap.h | 2 +- engines/saga/puzzle.cpp | 5 +- engines/saga/render.cpp | 6 +- engines/saga/scene.cpp | 13 ++- engines/saga/scene.h | 2 +- engines/saga/sprite.cpp | 30 +++---- engines/saga/sprite.h | 8 +- 15 files changed, 212 insertions(+), 209 deletions(-) (limited to 'engines/saga') diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index 5f099f88da..0365412aae 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -1046,7 +1046,6 @@ void Actor::drawActors() { CommonObjectDataPointer drawObject; int frameNumber = 0; SpriteList *spriteList = NULL; - Surface *backBuffer = _vm->_gfx->getBackBuffer(); createDrawOrderList(); @@ -1058,9 +1057,9 @@ void Actor::drawActors() { } if (_vm->_scene->getFlags() & kSceneFlagISO) { - _vm->_isoMap->drawSprite(backBuffer, *spriteList, frameNumber, drawObject->_location, drawObject->_screenPosition, drawObject->_screenScale); + _vm->_isoMap->drawSprite(*spriteList, frameNumber, drawObject->_location, drawObject->_screenPosition, drawObject->_screenScale); } else { - _vm->_sprite->drawOccluded(backBuffer, _vm->_scene->getSceneClip(),*spriteList, frameNumber, drawObject->_screenPosition, drawObject->_screenScale, drawObject->_screenDepth); + _vm->_sprite->drawOccluded(_vm->_scene->getSceneClip(),*spriteList, frameNumber, drawObject->_screenPosition, drawObject->_screenScale, drawObject->_screenDepth); } } @@ -1076,7 +1075,6 @@ void Actor::drawSpeech(void) { Point textPoint; ActorData *actor; int width, height; - Surface *backBuffer = _vm->_gfx->getBackBuffer(); int stringLength = strlen(_activeSpeech.strings[0]); char *outputString = (char*)calloc(stringLength + 1, 1); @@ -1100,11 +1098,11 @@ void Actor::drawSpeech(void) { else if (_vm->getGameType() == GType_IHNM) textPoint.y = 10; // CLIP(actor->_screenPosition.y - 160, 10, _vm->_scene->getHeight(true) - 10 - height); - _vm->_font->textDraw(kKnownFontScript, backBuffer, outputString, textPoint, + _vm->_font->textDraw(kKnownFontScript, outputString, textPoint, _activeSpeech.speechColor[i], _activeSpeech.outlineColor[i], _activeSpeech.getFontFlags(i)); } } else { - _vm->_font->textDrawRect(kKnownFontScript, backBuffer, outputString, _activeSpeech.drawRect, _activeSpeech.speechColor[0], + _vm->_font->textDrawRect(kKnownFontScript, outputString, _activeSpeech.drawRect, _activeSpeech.speechColor[0], _activeSpeech.outlineColor[0], _activeSpeech.getFontFlags(0)); } diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp index 42ae28fdf6..1361e310d6 100644 --- a/engines/saga/font.cpp +++ b/engines/saga/font.cpp @@ -278,7 +278,7 @@ int Font::getStringWidth(FontId fontId, const char *text, size_t count, FontEffe } -void Font::draw(FontId fontId, Surface *ds, const char *text, size_t count, const Common::Point &point, +void Font::draw(FontId fontId, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags) { FontData *font; Point offsetPoint(point); @@ -288,19 +288,19 @@ void Font::draw(FontId fontId, Surface *ds, const char *text, size_t count, cons if (flags & kFontOutline) { offsetPoint.x--; offsetPoint.y--; - outFont(font->outline, ds, text, count, offsetPoint, effectColor, flags); - outFont(font->normal, ds, text, count, point, color, flags); + outFont(font->outline, text, count, offsetPoint, effectColor, flags); + outFont(font->normal, text, count, point, color, flags); } else if (flags & kFontShadow) { offsetPoint.x--; offsetPoint.y++; - outFont(font->normal, ds, text, count, offsetPoint, effectColor, flags); - outFont(font->normal, ds, text, count, point, color, flags); + outFont(font->normal, text, count, offsetPoint, effectColor, flags); + outFont(font->normal, text, count, point, color, flags); } else { // FONT_NORMAL - outFont(font->normal, ds, text, count, point, color, flags); + outFont(font->normal, text, count, point, color, flags); } } -void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, FontEffectFlags flags) { +void Font::outFont(const FontStyle &drawFont, const char *text, size_t count, const Common::Point &point, int color, FontEffectFlags flags) { const byte *textPointer; byte *c_dataPointer; int c_code; @@ -310,6 +310,7 @@ void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, siz byte *outputPointer; byte *outputPointer_min; byte *outputPointer_max; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); int row; int rowLimit; @@ -319,7 +320,7 @@ void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, siz int c_bit; int ct; - if ((point.x > ds->w) || (point.y > ds->h)) { + if ((point.x > backBuffer->w) || (point.y > backBuffer->h)) { // Output string can't be visible return; } @@ -372,7 +373,7 @@ void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, siz // Get length of character in bytes c_byte_len = ((drawFont.fontCharEntry[c_code].width - 1) / 8) + 1; - rowLimit = (ds->h < (textPoint.y + drawFont.header.charHeight)) ? ds->h : textPoint.y + drawFont.header.charHeight; + rowLimit = (backBuffer->h < (textPoint.y + drawFont.header.charHeight)) ? backBuffer->h : textPoint.y + drawFont.header.charHeight; charRow = 0; for (row = textPoint.y; row < rowLimit; row++, charRow++) { @@ -381,9 +382,9 @@ void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, siz continue; } - outputPointer = (byte *)ds->pixels + (ds->pitch * row) + textPoint.x; - outputPointer_min = (byte *)ds->pixels + (ds->pitch * row) + (textPoint.x > 0 ? textPoint.x : 0); - outputPointer_max = outputPointer + (ds->pitch - textPoint.x); + outputPointer = (byte *)backBuffer->pixels + (backBuffer->pitch * row) + textPoint.x; + outputPointer_min = (byte *)backBuffer->pixels + (backBuffer->pitch * row) + (textPoint.x > 0 ? textPoint.x : 0); + outputPointer_max = outputPointer + (backBuffer->pitch - textPoint.x); // If character starts off the screen, jump to next character if (outputPointer < outputPointer_min) { @@ -409,17 +410,18 @@ void Font::outFont(const FontStyle &drawFont, Surface *ds, const char *text, siz } -void Font::textDraw(FontId fontId, Surface *ds, const char *text, const Common::Point &point, int color, int effectColor, FontEffectFlags flags) { +void Font::textDraw(FontId fontId, const char *text, const Common::Point &point, int color, int effectColor, FontEffectFlags flags) { int textWidth; int textLength; int fitWidth; Common::Point textPoint(point); + Surface *backBuffer = _vm->_gfx->getBackBuffer(); textLength = strlen(text); if (!(flags & kFontCentered)) { // Text is not centered; No formatting required - draw(fontId, ds, text, textLength, point, color, effectColor, flags); + draw(fontId, text, textLength, point, color, effectColor, flags); return; } @@ -429,8 +431,8 @@ void Font::textDraw(FontId fontId, Surface *ds, const char *text, const Common:: textPoint.x = TEXT_CENTERLIMIT; } - if (textPoint.x > ds->w - TEXT_CENTERLIMIT) { - textPoint.x = ds->w - TEXT_CENTERLIMIT; + if (textPoint.x > backBuffer->w - TEXT_CENTERLIMIT) { + textPoint.x = backBuffer->w - TEXT_CENTERLIMIT; } if (textPoint.x < (TEXT_MARGIN * 2)) { @@ -440,12 +442,12 @@ void Font::textDraw(FontId fontId, Surface *ds, const char *text, const Common:: textWidth = getStringWidth(fontId, text, textLength, flags); - if (textPoint.x < (ds->w / 2)) { + if (textPoint.x < (backBuffer->w / 2)) { // Fit to right side fitWidth = (textPoint.x - TEXT_MARGIN) * 2; } else { // Fit to left side - fitWidth = ((ds->w - TEXT_MARGIN) - textPoint.x) * 2; + fitWidth = ((backBuffer->w - TEXT_MARGIN) - textPoint.x) * 2; } if (fitWidth < textWidth) { @@ -454,7 +456,7 @@ void Font::textDraw(FontId fontId, Surface *ds, const char *text, const Common:: } // Entire string fits, draw it textPoint.x = textPoint.x - (textWidth / 2); - draw(fontId, ds, text, textLength, textPoint, color, effectColor, flags); + draw(fontId, text, textLength, textPoint, color, effectColor, flags); } int Font::getHeight(FontId fontId, const char *text, int width, FontEffectFlags flags) { @@ -541,7 +543,7 @@ int Font::getHeight(FontId fontId, const char *text, int width, FontEffectFlags } } -void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags) { +void Font::textDrawRect(FontId fontId, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags) { int textWidth; int textLength; int fitWidth; @@ -570,7 +572,7 @@ void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Comm if (fitWidth >= textWidth) { // Entire string fits, draw it textPoint.x -= (textWidth / 2); - draw(fontId, ds, text, textLength, textPoint, color, effectColor, flags); + draw(fontId, text, textLength, textPoint, color, effectColor, flags); return; } @@ -607,7 +609,7 @@ void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Comm // Wrap what we've got and restart textPoint2.x = textPoint.x - (w_total / 2); textPoint2.y = textPoint.y; - draw(fontId, ds, startPointer, len_total, textPoint2, color, effectColor, flags); + draw(fontId, startPointer, len_total, textPoint2, color, effectColor, flags); textPoint.y += h + TEXT_LINESPACING; if (textPoint.y >= rect.bottom) { return; @@ -642,7 +644,7 @@ void Font::textDrawRect(FontId fontId, Surface *ds, const char *text, const Comm // Since word hit NULL but fit, we are done textPoint2.x = textPoint.x - (w_total / 2); textPoint2.y = textPoint.y; - draw(fontId, ds, startPointer, len_total, textPoint2, color, + draw(fontId, startPointer, len_total, textPoint2, color, effectColor, flags); return; } diff --git a/engines/saga/font.h b/engines/saga/font.h index 20a34d2aef..c14d7a8b75 100644 --- a/engines/saga/font.h +++ b/engines/saga/font.h @@ -136,11 +136,11 @@ class Font { int getHeight(KnownFont font, const char *text, int width, FontEffectFlags flags) { return getHeight(knownFont2FontIdx(font), text, width, flags); } - void textDraw(KnownFont font, Surface *ds, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags) { - textDraw(knownFont2FontIdx(font), ds, string, point, color, effectColor, flags); + void textDraw(KnownFont font, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags) { + textDraw(knownFont2FontIdx(font), string, point, color, effectColor, flags); } - void textDrawRect(KnownFont font, Surface *ds, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags) { - textDrawRect(knownFont2FontIdx(font), ds, text, rect, color, effectColor, flags); + void textDrawRect(KnownFont font, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags) { + textDrawRect(knownFont2FontIdx(font), text, rect, color, effectColor, flags); } void setFontMapping(int mapping) { _fontMapping = mapping; @@ -162,13 +162,13 @@ class Font { int getStringWidth(FontId fontId, const char *text, size_t count, FontEffectFlags flags); int getHeight(FontId fontId, const char *text, int width, FontEffectFlags flags); - void textDrawRect(FontId fontId, Surface *ds, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags); - void textDraw(FontId fontId, Surface *ds, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags); + void textDrawRect(FontId fontId, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags); + void textDraw(FontId fontId, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags); void loadFont(uint32 fontResourceId); void createOutline(FontData *font); - void draw(FontId fontId, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags); - void outFont(const FontStyle &drawFont, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, FontEffectFlags flags); + void draw(FontId fontId, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags); + void outFont(const FontStyle &drawFont, const char *text, size_t count, const Common::Point &point, int color, FontEffectFlags flags); FontData *getFont(FontId fontId) { validate(fontId); diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index ffa2be758d..d336cb3135 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -755,7 +755,7 @@ void Interface::loadScenePortraits(int resourceId) { _vm->_sprite->loadList(resourceId, _scenePortraits); } -void Interface::drawVerbPanel(Surface *backBuffer, PanelButton* panelButton) { +void Interface::drawVerbPanel(PanelButton* panelButton) { PanelButton * rightButtonVerbPanelButton; PanelButton * currentVerbPanelButton; KnownColor textColor; @@ -781,13 +781,12 @@ void Interface::drawVerbPanel(Surface *backBuffer, PanelButton* panelButton) { point.x = _mainPanel.x + panelButton->xOffset; point.y = _mainPanel.y + panelButton->yOffset; - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _mainPanel.sprites, spriteNumber, point, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _mainPanel.sprites, spriteNumber, point, 256); - drawVerbPanelText(backBuffer, panelButton, textColor, kKnownColorVerbTextShadow); + drawVerbPanelText(panelButton, textColor, kKnownColorVerbTextShadow); } void Interface::draw() { - Surface *backBuffer = _vm->_gfx->getBackBuffer(); Point leftPortraitPoint; Point rightPortraitPoint; Rect rect; @@ -800,17 +799,17 @@ void Interface::draw() { if (_panelMode == kPanelMain || _panelMode == kPanelMap || (_panelMode == kPanelNull && _vm->getGameId() == GID_IHNM_DEMO)) { _mainPanel.getRect(rect); - backBuffer->blit(rect, _mainPanel.image); + _vm->_gfx->getBackBuffer()->blit(rect, _mainPanel.image); for (int i = 0; i < kVerbTypeIdsMax; i++) { if (_verbTypeToPanelButton[i] != NULL) { - drawVerbPanel(backBuffer, _verbTypeToPanelButton[i]); + drawVerbPanel(_verbTypeToPanelButton[i]); } } } else if (_panelMode == kPanelConverse) { _conversePanel.getRect(rect); - backBuffer->blit(rect, _conversePanel.image); - converseDisplayTextLines(backBuffer); + _vm->_gfx->getBackBuffer()->blit(rect, _conversePanel.image); + converseDisplayTextLines(); } if (_panelMode == kPanelMain || _panelMode == kPanelConverse || @@ -818,7 +817,7 @@ void Interface::draw() { (_panelMode == kPanelNull && _vm->getGameId() == GID_IHNM_DEMO)) { leftPortraitPoint.x = _mainPanel.x + _vm->getDisplayInfo().leftPortraitXOffset; leftPortraitPoint.y = _mainPanel.y + _vm->getDisplayInfo().leftPortraitYOffset; - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _defPortraits, _leftPortrait, leftPortraitPoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _defPortraits, _leftPortrait, leftPortraitPoint, 256); } if (!_inMainMode && _vm->getDisplayInfo().rightPortraitXOffset >= 0) { //FIXME: should we change !_inMainMode to _panelMode == kPanelConverse ? @@ -833,10 +832,10 @@ void Interface::draw() { if (_rightPortrait >= _scenePortraits.spriteCount) _rightPortrait = 0; - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _scenePortraits, _rightPortrait, rightPortraitPoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _scenePortraits, _rightPortrait, rightPortraitPoint, 256); } - drawInventory(backBuffer); + drawInventory(); } void Interface::calcOptionSaveSlider() { @@ -879,7 +878,7 @@ void Interface::calcOptionSaveSlider() { _optionSaveRectBottom.right--; } -void Interface::drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) { +void Interface::drawPanelText(InterfacePanel *panel, PanelButton *panelButton) { const char *text; int textWidth; Rect rect; @@ -925,7 +924,8 @@ void Interface::drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *p textPoint.x = rect.left; textPoint.y = rect.top + 1; - _vm->_font->textDraw(textFont, ds, text, textPoint, _vm->KnownColor2ColorId(kKnownColorVerbText), _vm->KnownColor2ColorId(textShadowKnownColor), kFontShadow); + _vm->_font->textDraw(textFont, text, textPoint, + _vm->KnownColor2ColorId(kKnownColorVerbText), _vm->KnownColor2ColorId(textShadowKnownColor), kFontShadow); } void Interface::drawOption() { @@ -951,14 +951,14 @@ void Interface::drawOption() { if (panelButton->type == kPanelButtonOption) { if (_vm->getGameType() == GType_ITE) { - drawPanelButtonText(backBuffer, &_optionPanel, panelButton); + drawPanelButtonText(&_optionPanel, panelButton); } else { - drawPanelButtonText(backBuffer, &_optionPanel, panelButton, spritenum); + drawPanelButtonText(&_optionPanel, panelButton, spritenum); spritenum += 2; // 2 sprites per button (lit and unlit) } } if (panelButton->type == kPanelButtonOptionText) { - drawPanelText(backBuffer, &_optionPanel, panelButton); + drawPanelText(&_optionPanel, panelButton); } } @@ -968,12 +968,12 @@ void Interface::drawOption() { } if (_vm->getGameType() == GType_ITE) { - drawButtonBox(backBuffer, _optionSaveRectSlider, kSlider, _optionSaveFileSlider->state > 0); + drawButtonBox(_optionSaveRectSlider, kSlider, _optionSaveFileSlider->state > 0); } else { panelButton = &_optionPanel.buttons[0]; sliderPoint.x = _optionPanel.x + panelButton->xOffset; sliderPoint.y = _optionSaveRectSlider.top; - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _optionPanel.sprites, 0 + _optionSaveFileSlider->state, sliderPoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _optionPanel.sprites, 0 + _optionSaveFileSlider->state, sliderPoint, 256); } @@ -1004,9 +1004,9 @@ void Interface::drawOption() { textPoint.x = rect.left + 1; textPoint.y = rect2.top; if (_vm->getGameType() == GType_ITE) - _vm->_font->textDraw(kKnownFontSmall, backBuffer, text, textPoint, fgColor, 0, kFontNormal); + _vm->_font->textDraw(kKnownFontSmall, text, textPoint, fgColor, 0, kFontNormal); else - _vm->_font->textDraw(kKnownFontVerb, backBuffer, text, textPoint, fgColor, 0, kFontNormal); + _vm->_font->textDraw(kKnownFontVerb, text, textPoint, fgColor, 0, kFontNormal); } } @@ -1020,17 +1020,17 @@ void Interface::drawQuit() { _quitPanel.getRect(rect); if (_vm->getGameType() == GType_ITE) - drawButtonBox(backBuffer, rect, kButton, false); + drawButtonBox(rect, kButton, false); else backBuffer->blit(rect, _quitPanel.image); for (i = 0; i < _quitPanel.buttonsCount; i++) { panelButton = &_quitPanel.buttons[i]; if (panelButton->type == kPanelButtonQuit) { - drawPanelButtonText(backBuffer, &_quitPanel, panelButton); + drawPanelButtonText(&_quitPanel, panelButton); } if (panelButton->type == kPanelButtonQuitText) { - drawPanelText(backBuffer, &_quitPanel, panelButton); + drawPanelText(&_quitPanel, panelButton); } } } @@ -1085,17 +1085,17 @@ void Interface::drawLoad() { _loadPanel.getRect(rect); if (_vm->getGameType() == GType_ITE) - drawButtonBox(backBuffer, rect, kButton, false); + drawButtonBox(rect, kButton, false); else backBuffer->blit(rect, _loadPanel.image); for (i = 0; i < _loadPanel.buttonsCount; i++) { panelButton = &_loadPanel.buttons[i]; if (panelButton->type == kPanelButtonLoad) { - drawPanelButtonText(backBuffer, &_loadPanel, panelButton); + drawPanelButtonText(&_loadPanel, panelButton); } if (panelButton->type == kPanelButtonLoadText) { - drawPanelText(backBuffer, &_loadPanel, panelButton); + drawPanelText(&_loadPanel, panelButton); } } } @@ -1262,16 +1262,17 @@ bool Interface::processTextInput(Common::KeyState keystate) { return true; } -void Interface::drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) { +void Interface::drawTextInput(InterfacePanel *panel, PanelButton *panelButton) { Point textPoint; Rect rect; char ch[2]; int fgColor; uint i; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); ch[1] = 0; panel->calcPanelButtonRect(panelButton, rect); - drawButtonBox(ds, rect, kEdit, _textInput); + drawButtonBox(rect, kEdit, _textInput); rect.left += 4; rect.top += 4; rect.setHeight(_vm->_font->getHeight(kKnownFontSmall)); @@ -1281,20 +1282,20 @@ void Interface::drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *p rect.setWidth(_vm->_font->getStringWidth(kKnownFontSmall, ch, 0, kFontNormal)); if ((i == _textInputPos) && _textInput) { fgColor = _vm->KnownColor2ColorId(kKnownColorBlack); - ds->fillRect(rect, _vm->KnownColor2ColorId(kKnownColorWhite)); + backBuffer->fillRect(rect, _vm->KnownColor2ColorId(kKnownColorWhite)); } else { fgColor = _vm->KnownColor2ColorId(kKnownColorWhite); } textPoint.x = rect.left; textPoint.y = rect.top + 1; - _vm->_font->textDraw(kKnownFontSmall, ds, ch, textPoint, fgColor, 0, kFontNormal); + _vm->_font->textDraw(kKnownFontSmall, ch, textPoint, fgColor, 0, kFontNormal); rect.left += rect.width(); } if (_textInput && (_textInputPos >= i)) { ch[0] = ' '; rect.setWidth(_vm->_font->getStringWidth(kKnownFontSmall, ch, 0, kFontNormal)); - ds->fillRect(rect, _vm->KnownColor2ColorId(kKnownColorWhite)); + backBuffer->fillRect(rect, _vm->KnownColor2ColorId(kKnownColorWhite)); } } @@ -1306,21 +1307,21 @@ void Interface::drawSave() { _savePanel.getRect(rect); if (_vm->getGameType() == GType_ITE) - drawButtonBox(backBuffer, rect, kButton, false); + drawButtonBox(rect, kButton, false); else backBuffer->blit(rect, _savePanel.image); for (i = 0; i < _savePanel.buttonsCount; i++) { panelButton = &_savePanel.buttons[i]; if (panelButton->type == kPanelButtonSave) { - drawPanelButtonText(backBuffer, &_savePanel, panelButton); + drawPanelButtonText(&_savePanel, panelButton); } if (panelButton->type == kPanelButtonSaveText) { - drawPanelText(backBuffer, &_savePanel, panelButton); + drawPanelText(&_savePanel, panelButton); } } - drawTextInput(backBuffer, &_savePanel, _saveEdit); + drawTextInput(&_savePanel, _saveEdit); } void Interface::drawProtect() { @@ -1330,15 +1331,15 @@ void Interface::drawProtect() { PanelButton *panelButton; _protectPanel.getRect(rect); - drawButtonBox(backBuffer, rect, kButton, false); + drawButtonBox(rect, kButton, false); for (i = 0; i < _protectPanel.buttonsCount; i++) { panelButton = &_protectPanel.buttons[i]; if (panelButton->type == kPanelButtonProtectText) { - drawPanelText(backBuffer, &_protectPanel, panelButton); + drawPanelText(&_protectPanel, panelButton); } } - drawTextInput(backBuffer, &_protectPanel, _protectEdit); + drawTextInput(&_protectPanel, _protectEdit); } void Interface::handleSaveUpdate(const Point& mousePoint) { @@ -1863,7 +1864,6 @@ void Interface::update(const Point& mousePoint, int updateFlag) { } void Interface::drawStatusBar() { - Surface *backBuffer = _vm->_gfx->getBackBuffer(); Rect rect; Point textPoint; int stringWidth; @@ -1886,7 +1886,7 @@ void Interface::drawStatusBar() { rect.right = rect.left + _vm->getDisplayWidth(); rect.bottom = rect.top + _vm->getDisplayInfo().statusHeight; - backBuffer->drawRect(rect, _vm->getDisplayInfo().statusBGColor - offset); + _vm->_gfx->getBackBuffer()->drawRect(rect, _vm->getDisplayInfo().statusBGColor - offset); stringWidth = _vm->_font->getStringWidth(kKnownFontSmall, _statusText, 0, kFontNormal); @@ -1898,9 +1898,9 @@ void Interface::drawStatusBar() { textPoint.x = _vm->getDisplayInfo().statusXOffset + (_vm->getDisplayInfo().statusWidth - stringWidth) / 2; textPoint.y = _vm->getDisplayInfo().statusYOffset + _vm->getDisplayInfo().statusTextY; if (_vm->getGameType() == GType_ITE) - _vm->_font->textDraw(kKnownFontSmall, backBuffer, _statusText, textPoint, color, 0, kFontNormal); + _vm->_font->textDraw(kKnownFontSmall, _statusText, textPoint, color, 0, kFontNormal); else - _vm->_font->textDraw(kKnownFontVerb, backBuffer, _statusText, textPoint, color, 0, kFontNormal); + _vm->_font->textDraw(kKnownFontVerb, _statusText, textPoint, color, 0, kFontNormal); if (_saveReminderState > 0) { rect.left = _vm->getDisplayInfo().saveReminderXOffset; @@ -1908,7 +1908,7 @@ void Interface::drawStatusBar() { rect.right = rect.left + _vm->getDisplayInfo().saveReminderWidth; rect.bottom = rect.top + _vm->getDisplayInfo().saveReminderHeight; - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _vm->_sprite->_saveReminderSprites, + _vm->_sprite->draw(_vm->getDisplayClip(), _vm->_sprite->_saveReminderSprites, _vm->getDisplayInfo().saveReminderFirstSpriteNumber + _saveReminderState - 1, rect, 256); @@ -2094,23 +2094,23 @@ int Interface::inventoryItemPosition(int objectId) { return -1; } -void Interface::drawInventory(Surface *backBuffer) { +void Interface::drawInventory() { if (!isInMainMode()) return; - int i; Rect rect; - int ci; + int ci = _inventoryStart; ObjectData *obj; - ci = _inventoryStart; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); + if (_inventoryStart != 0) { - drawPanelButtonArrow(backBuffer, &_mainPanel, _inventoryUpButton); + drawPanelButtonArrow(&_mainPanel, _inventoryUpButton); } if (_inventoryStart != _inventoryEnd) { - drawPanelButtonArrow(backBuffer, &_mainPanel, _inventoryDownButton); + drawPanelButtonArrow(&_mainPanel, _inventoryDownButton); } - for (i = 0; i < _mainPanel.buttonsCount; i++) { + for (int i = 0; i < _mainPanel.buttonsCount; i++) { if (_mainPanel.buttons[i].type != kPanelButtonInventory) { continue; } @@ -2123,7 +2123,7 @@ void Interface::drawInventory(Surface *backBuffer) { if (ci < _inventoryCount) { obj = _vm->_actor->getObj(_inventory[ci]); - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), _vm->_sprite->_inventorySprites, obj->_spriteListResourceId, rect, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _vm->_sprite->_inventorySprites, obj->_spriteListResourceId, rect, 256); } ci++; @@ -2140,12 +2140,13 @@ void Interface::setVerbState(int verb, int state) { draw(); } -void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bool down) { +void Interface::drawButtonBox(const Rect& rect, ButtonKind kind, bool down) { byte cornerColor; byte frameColor; byte fillColor; byte solidColor; byte odl, our, idl, iur; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); switch (kind ) { case kSlider: @@ -2193,14 +2194,14 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo int xe = rect.right - 1; int ye = rect.bottom - 1; - ((byte *)ds->getBasePtr(x, y))[0] = cornerColor; - ((byte *)ds->getBasePtr(x, ye))[0] = cornerColor; - ((byte *)ds->getBasePtr(xe, y))[0] = cornerColor; - ((byte *)ds->getBasePtr(xe, ye))[0] = cornerColor; - ds->hLine(x + 1, y, x + w - 2, frameColor); - ds->hLine(x + 1, ye, x + w - 2, frameColor); - ds->vLine(x, y + 1, y + h - 2, frameColor); - ds->vLine(xe, y + 1, y + h - 2, frameColor); + ((byte *)backBuffer->getBasePtr(x, y))[0] = cornerColor; + ((byte *)backBuffer->getBasePtr(x, ye))[0] = cornerColor; + ((byte *)backBuffer->getBasePtr(xe, y))[0] = cornerColor; + ((byte *)backBuffer->getBasePtr(xe, ye))[0] = cornerColor; + backBuffer->hLine(x + 1, y, x + w - 2, frameColor); + backBuffer->hLine(x + 1, ye, x + w - 2, frameColor); + backBuffer->vLine(x, y + 1, y + h - 2, frameColor); + backBuffer->vLine(xe, y + 1, y + h - 2, frameColor); x++; y++; @@ -2208,10 +2209,10 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo ye--; w -= 2; h -= 2; - ds->vLine(x, y, y + h - 1, odl); - ds->hLine(x, ye, x + w - 1, odl); - ds->vLine(xe, y, y + h - 2, our); - ds->hLine(x + 1, y, x + 1 + w - 2, our); + backBuffer->vLine(x, y, y + h - 1, odl); + backBuffer->hLine(x, ye, x + w - 1, odl); + backBuffer->vLine(xe, y, y + h - 2, our); + backBuffer->hLine(x + 1, y, x + 1 + w - 2, our); x++; y++; @@ -2219,23 +2220,23 @@ void Interface::drawButtonBox(Surface *ds, const Rect& rect, ButtonKind kind, bo ye--; w -= 2; h -= 2; - ((byte *)ds->getBasePtr(x, y))[0] = fillColor; - ((byte *)ds->getBasePtr(xe, ye))[0] = fillColor; - ds->vLine(x, y + 1, y + 1 + h - 2, idl); - ds->hLine(x + 1, ye, x + 1 + w - 2, idl); - ds->vLine(xe, y, y + h - 2, iur); - ds->hLine(x + 1, y, x + 1 + w - 2, iur); + ((byte *)backBuffer->getBasePtr(x, y))[0] = fillColor; + ((byte *)backBuffer->getBasePtr(xe, ye))[0] = fillColor; + backBuffer->vLine(x, y + 1, y + 1 + h - 2, idl); + backBuffer->hLine(x + 1, ye, x + 1 + w - 2, idl); + backBuffer->vLine(xe, y, y + h - 2, iur); + backBuffer->hLine(x + 1, y, x + 1 + w - 2, iur); x++; y++; w -= 2; h -= 2; Common::Rect fill(x, y, x + w, y + h); - ds->fillRect(fill, solidColor); + backBuffer->fillRect(fill, solidColor); } static const int readingSpeeds[] = { kTextClick, kTextSlow, kTextMid, kTextFast }; -void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton, int spritenum) { +void Interface::drawPanelButtonText(InterfacePanel *panel, PanelButton *panelButton, int spritenum) { const char *text; int textId; int textWidth; @@ -2314,41 +2315,41 @@ void Interface::drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelBut panel->calcPanelButtonRect(panelButton, rect); if (_vm->getGameType() == GType_ITE) { - drawButtonBox(ds, rect, kButton, panelButton->state > 0); + drawButtonBox(rect, kButton, panelButton->state > 0); } else { litButton = panelButton->state > 0; if (panel == &_optionPanel) { texturePoint.x = _optionPanel.x + panelButton->xOffset - 1; texturePoint.y = _optionPanel.y + panelButton->yOffset - 1; - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _optionPanel.sprites, spritenum + 2 + litButton, texturePoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _optionPanel.sprites, spritenum + 2 + litButton, texturePoint, 256); } else if (panel == &_quitPanel) { texturePoint.x = _quitPanel.x + panelButton->xOffset - 3; texturePoint.y = _quitPanel.y + panelButton->yOffset - 3; - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _quitPanel.sprites, litButton, texturePoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _quitPanel.sprites, litButton, texturePoint, 256); } else if (panel == &_savePanel) { texturePoint.x = _savePanel.x + panelButton->xOffset - 3; texturePoint.y = _savePanel.y + panelButton->yOffset - 3; - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _savePanel.sprites, litButton, texturePoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _savePanel.sprites, litButton, texturePoint, 256); // Input text box sprite texturePoint.x = _savePanel.x + _saveEdit->xOffset - 2; texturePoint.y = _savePanel.y + _saveEdit->yOffset - 2; - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _savePanel.sprites, 2, texturePoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _savePanel.sprites, 2, texturePoint, 256); } else if (panel == &_loadPanel) { texturePoint.x = _loadPanel.x + panelButton->xOffset - 3; texturePoint.y = _loadPanel.y + panelButton->yOffset - 3; - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _loadPanel.sprites, litButton, texturePoint, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _loadPanel.sprites, litButton, texturePoint, 256); } else { // revert to default behavior - drawButtonBox(ds, rect, kButton, panelButton->state > 0); + drawButtonBox(rect, kButton, panelButton->state > 0); } } - _vm->_font->textDraw(textFont, ds, text, point, + _vm->_font->textDraw(textFont, text, point, _vm->KnownColor2ColorId(textColor), _vm->KnownColor2ColorId(textShadowKnownColor), kFontShadow); } -void Interface::drawPanelButtonArrow(Surface *ds, InterfacePanel *panel, PanelButton *panelButton) { +void Interface::drawPanelButtonArrow(InterfacePanel *panel, PanelButton *panelButton) { Point point; int spriteNumber; @@ -2366,12 +2367,12 @@ void Interface::drawPanelButtonArrow(Surface *ds, InterfacePanel *panel, PanelBu point.y = panel->y + panelButton->yOffset; if (_vm->getGameType() == GType_ITE) - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _vm->_sprite->_mainSprites, spriteNumber, point, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _vm->_sprite->_mainSprites, spriteNumber, point, 256); else - _vm->_sprite->draw(ds, _vm->getDisplayClip(), _vm->_sprite->_arrowSprites, spriteNumber, point, 256); + _vm->_sprite->draw(_vm->getDisplayClip(), _vm->_sprite->_arrowSprites, spriteNumber, point, 256); } -void Interface::drawVerbPanelText(Surface *ds, PanelButton *panelButton, KnownColor textKnownColor, KnownColor textShadowKnownColor) { +void Interface::drawVerbPanelText(PanelButton *panelButton, KnownColor textKnownColor, KnownColor textShadowKnownColor) { const char *text; int textWidth; Point point; @@ -2396,7 +2397,9 @@ void Interface::drawVerbPanelText(Surface *ds, PanelButton *panelButton, KnownCo point.y = _mainPanel.y + panelButton->yOffset + 12; } - _vm->_font->textDraw(kKnownFontVerb, ds, text, point, _vm->KnownColor2ColorId(textKnownColor),_vm->KnownColor2ColorId(textShadowKnownColor), (textShadowKnownColor != kKnownColorTransparent) ? kFontShadow : kFontNormal); + _vm->_font->textDraw(kKnownFontVerb, text, point, + _vm->KnownColor2ColorId(textKnownColor), _vm->KnownColor2ColorId(textShadowKnownColor), + (textShadowKnownColor != kKnownColorTransparent) ? kFontShadow : kFontNormal); } @@ -2508,7 +2511,7 @@ void Interface::converseSetTextLines(int row) { } } -void Interface::converseDisplayTextLines(Surface *ds) { +void Interface::converseDisplayTextLines() { int relPos; byte foregnd; byte backgnd; @@ -2520,6 +2523,7 @@ void Interface::converseDisplayTextLines(Surface *ds) { }; Rect rect(8, _vm->getDisplayInfo().converseTextLines * _vm->getDisplayInfo().converseTextHeight); Point textPoint; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); assert(_conversePanel.buttonsCount >= 6); @@ -2536,9 +2540,9 @@ void Interface::converseDisplayTextLines(Surface *ds) { _conversePanel.y + _conversePanel.buttons[0].yOffset); if (_vm->getGameType() == GType_ITE) - ds->drawRect(rect, kITEColorDarkGrey); //fill bullet place + backBuffer->drawRect(rect, kITEColorDarkGrey); //fill bullet place else - ds->drawRect(rect, _vm->KnownColor2ColorId(kKnownColorBlack)); //fill bullet place + backBuffer->drawRect(rect, _vm->KnownColor2ColorId(kKnownColorBlack)); //fill bullet place for (int i = 0; i < _vm->getDisplayInfo().converseTextLines; i++) { relPos = _converseStartPos + i; @@ -2567,7 +2571,7 @@ void Interface::converseDisplayTextLines(Surface *ds) { _conversePanel.calcPanelButtonRect(&_conversePanel.buttons[i], rect); rect.left += 8; - ds->drawRect(rect, backgnd); + backBuffer->drawRect(rect, backgnd); str = _converseText[relPos].text; @@ -2576,24 +2580,24 @@ void Interface::converseDisplayTextLines(Surface *ds) { textPoint.y = rect.top; if (_vm->getGameType() == GType_ITE) - _vm->_font->textDraw(kKnownFontSmall, ds, bullet, textPoint, bulletForegnd, bulletBackgnd, (FontEffectFlags)(kFontShadow | kFontDontmap)); + _vm->_font->textDraw(kKnownFontSmall, bullet, textPoint, bulletForegnd, bulletBackgnd, (FontEffectFlags)(kFontShadow | kFontDontmap)); else - _vm->_font->textDraw(kKnownFontVerb, ds, bullet, textPoint, bulletForegnd, bulletBackgnd, (FontEffectFlags)(kFontShadow | kFontDontmap)); + _vm->_font->textDraw(kKnownFontVerb, bullet, textPoint, bulletForegnd, bulletBackgnd, (FontEffectFlags)(kFontShadow | kFontDontmap)); } textPoint.x = rect.left + 1; textPoint.y = rect.top; if (_vm->getGameType() == GType_ITE) - _vm->_font->textDraw(kKnownFontSmall, ds, str, textPoint, foregnd, kITEColorBlack, kFontShadow); + _vm->_font->textDraw(kKnownFontSmall, str, textPoint, foregnd, kITEColorBlack, kFontShadow); else - _vm->_font->textDraw(kKnownFontVerb, ds, str, textPoint, foregnd, _vm->KnownColor2ColorId(kKnownColorBlack), kFontShadow); + _vm->_font->textDraw(kKnownFontVerb, str, textPoint, foregnd, _vm->KnownColor2ColorId(kKnownColorBlack), kFontShadow); } if (_converseStartPos != 0) { - drawPanelButtonArrow(ds, &_conversePanel, _converseUpButton); + drawPanelButtonArrow(&_conversePanel, _converseUpButton); } if (_converseStartPos != _converseEndPos) { - drawPanelButtonArrow(ds, &_conversePanel, _converseDownButton); + drawPanelButtonArrow(&_conversePanel, _converseDownButton); } } @@ -2792,7 +2796,7 @@ void Interface::mapPanelDrawCrossHair() { Rect screen(_vm->getDisplayWidth(), _vm->_scene->getHeight()); if (screen.contains(mapPosition)) { - _vm->_sprite->draw(_vm->_gfx->getBackBuffer(), _vm->getDisplayClip(), _vm->_sprite->_mainSprites, + _vm->_sprite->draw(_vm->getDisplayClip(), _vm->_sprite->_mainSprites, _mapPanelCrossHairState? RID_ITE_SPR_CROSSHAIR : RID_ITE_SPR_CROSSHAIR + 1, mapPosition, 256); } diff --git a/engines/saga/interface.h b/engines/saga/interface.h index 46df12ed51..b58fed6676 100644 --- a/engines/saga/interface.h +++ b/engines/saga/interface.h @@ -256,7 +256,7 @@ public: } private: - void drawInventory(Surface *backBuffer); + void drawInventory(); void updateInventory(int pos); void inventoryChangePos(int chg); void inventorySetPos(int key); @@ -339,18 +339,18 @@ private: void setLoad(PanelButton *panelButton); void setSave(PanelButton *panelButton); - void drawTextInput(Surface *ds, InterfacePanel *panel, PanelButton *panelButton); - void drawPanelText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton); - void drawPanelButtonText(Surface *ds, InterfacePanel *panel, PanelButton *panelButton, int spritenum = 0); + void drawTextInput(InterfacePanel *panel, PanelButton *panelButton); + void drawPanelText(InterfacePanel *panel, PanelButton *panelButton); + void drawPanelButtonText(InterfacePanel *panel, PanelButton *panelButton, int spritenum = 0); enum ButtonKind { kButton, kSlider, kEdit }; - void drawButtonBox(Surface *ds, const Rect &rect, ButtonKind kind, bool down); - void drawPanelButtonArrow(Surface *ds, InterfacePanel *panel, PanelButton *panelButton); - void drawVerbPanelText(Surface *ds, PanelButton *panelButton, KnownColor textKnownColor, KnownColor textShadowKnownColor); - void drawVerbPanel(Surface *backBuffer, PanelButton* panelButton); + void drawButtonBox(const Rect &rect, ButtonKind kind, bool down); + void drawPanelButtonArrow(InterfacePanel *panel, PanelButton *panelButton); + void drawVerbPanelText(PanelButton *panelButton, KnownColor textKnownColor, KnownColor textShadowKnownColor); + void drawVerbPanel(PanelButton* panelButton); void calcOptionSaveSlider(); bool processTextInput(Common::KeyState keystate); void processStatusTextInput(Common::KeyState keystate); @@ -365,7 +365,7 @@ public: void converseSetPos(int key); private: - void converseDisplayTextLines(Surface *ds); + void converseDisplayTextLines(); PanelButton *getPanelButtonByVerbType(int verb) { if ((verb < 0) || (verb >= kVerbTypeIdsMax)) { error("Interface::getPanelButtonByVerbType wrong verb"); diff --git a/engines/saga/isomap.cpp b/engines/saga/isomap.cpp index e607adb4cb..1df3c2aa26 100644 --- a/engines/saga/isomap.cpp +++ b/engines/saga/isomap.cpp @@ -377,10 +377,9 @@ int16 IsoMap::findMulti(int16 tileIndex, int16 absU, int16 absV, int16 absH) { } void IsoMap::draw(Surface *ds) { - _tileClip = _vm->_scene->getSceneClip(); ds->drawRect(_tileClip, 0); - drawTiles(ds, NULL); + drawTiles(NULL); } void IsoMap::setMapPosition(int x, int y) { @@ -388,7 +387,7 @@ void IsoMap::setMapPosition(int x, int y) { _mapPosition.y = y; } -void IsoMap::drawSprite(Surface *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale) { +void IsoMap::drawSprite(SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale) { int width; int height; int xAlign; @@ -407,12 +406,12 @@ void IsoMap::drawSprite(Surface *ds, SpriteList &spriteList, int spriteNumber, c _tileClip.top = CLIP(spritePointer.y, 0, _vm->_scene->getHeight()); _tileClip.bottom = CLIP(spritePointer.y + height, 0, _vm->_scene->getHeight()); - _vm->_sprite->drawClip(ds, clip, spritePointer, width, height, spriteBuffer); - drawTiles(ds, &location); + _vm->_sprite->drawClip(clip, spritePointer, width, height, spriteBuffer); + drawTiles(&location); } -void IsoMap::drawTiles(Surface *ds, const Location *location) { +void IsoMap::drawTiles(const Location *location) { Point view1; Point fineScroll; Point tileScroll; @@ -480,9 +479,9 @@ void IsoMap::drawTiles(Surface *ds, const Location *location) { rLocation.u() = location->u() - (u2 << 7); rLocation.v() = location->v() - (v2 << 7); rLocation.z = location->z; - drawSpriteMetaTile(ds, metaTileIndex, metaTileX, rLocation, u2 << 3, v2 << 3); + drawSpriteMetaTile(metaTileIndex, metaTileX, rLocation, u2 << 3, v2 << 3); } else { - drawMetaTile(ds, metaTileIndex, metaTileX, u2 << 3, v2 << 3); + drawMetaTile(metaTileIndex, metaTileX, u2 << 3, v2 << 3); } } @@ -524,9 +523,9 @@ void IsoMap::drawTiles(Surface *ds, const Location *location) { rLocation.u() = location->u() - (u2 << 7); rLocation.v() = location->v() - (v2 << 7); rLocation.z = location->z; - drawSpriteMetaTile(ds, metaTileIndex, metaTileX, rLocation, u2 << 3, v2 << 3); + drawSpriteMetaTile(metaTileIndex, metaTileX, rLocation, u2 << 3, v2 << 3); } else { - drawMetaTile(ds, metaTileIndex, metaTileX, u2 << 3, v2 << 3); + drawMetaTile(metaTileIndex, metaTileX, u2 << 3, v2 << 3); } } metaTileY.y += 64; @@ -534,7 +533,7 @@ void IsoMap::drawTiles(Surface *ds, const Location *location) { } -void IsoMap::drawSpriteMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV) { +void IsoMap::drawSpriteMetaTile(uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV) { MetaTileData * metaTile; uint16 high; int16 platformIndex; @@ -556,12 +555,12 @@ void IsoMap::drawSpriteMetaTile(Surface *ds, uint16 metaTileIndex, const Point & platformIndex = metaTile->stack[high]; if (platformIndex >= 0) { - drawSpritePlatform( ds, platformIndex, platformPoint, location, absU, absV, high ); + drawSpritePlatform(platformIndex, platformPoint, location, absU, absV, high); } } } -void IsoMap::drawMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, int16 absU, int16 absV) { +void IsoMap::drawMetaTile(uint16 metaTileIndex, const Point &point, int16 absU, int16 absV) { MetaTileData * metaTile; uint16 high; int16 platformIndex; @@ -583,12 +582,12 @@ void IsoMap::drawMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, platformIndex = metaTile->stack[high]; if (platformIndex >= 0) { - drawPlatform( ds, platformIndex, platformPoint, absU, absV, high ); + drawPlatform(platformIndex, platformPoint, absU, absV, high); } } } -void IsoMap::drawSpritePlatform(Surface *ds, uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH) { +void IsoMap::drawSpritePlatform(uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH) { TilePlatformData *tilePlatform; int16 u, v; Point s; @@ -636,14 +635,14 @@ void IsoMap::drawSpritePlatform(Surface *ds, uint16 platformIndex, const Point & tileIndex = findMulti(tileIndex, absU + u, absV + v, absH); } - drawTile(ds, tileIndex, s, ©Location); + drawTile(tileIndex, s, ©Location); } } } } } -void IsoMap::drawPlatform(Surface *ds, uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH) { +void IsoMap::drawPlatform(uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH) { TilePlatformData *tilePlatform; int16 u, v; Point s; @@ -688,7 +687,7 @@ void IsoMap::drawPlatform(Surface *ds, uint16 platformIndex, const Point &point, tileIndex = findMulti(tileIndex, absU + u, absV + v, absH); } - drawTile(ds, tileIndex, s, NULL); + drawTile(tileIndex, s, NULL); } } } @@ -699,7 +698,7 @@ void IsoMap::drawPlatform(Surface *ds, uint16 platformIndex, const Point &point, #define THRESH8 8 #define THRESH16 16 -void IsoMap::drawTile(Surface *ds, uint16 tileIndex, const Point &point, const Location *location) { +void IsoMap::drawTile(uint16 tileIndex, const Point &point, const Location *location) { const byte *tilePointer; const byte *readPointer; byte *drawPointer; @@ -709,7 +708,7 @@ void IsoMap::drawTile(Surface *ds, uint16 tileIndex, const Point &point, const L int row, col, count, lowBound; int bgRunCount; int fgRunCount; - + Surface *backBuffer = _vm->_gfx->getBackBuffer(); if (tileIndex >= _tilesCount) { error("IsoMap::drawTile wrong tileIndex"); @@ -833,7 +832,7 @@ void IsoMap::drawTile(Surface *ds, uint16 tileIndex, const Point &point, const L for (row = drawPoint.y; row < lowBound; row++) { widthCount = 0; if (row >= _tileClip.top) { - drawPointer = (byte *)ds->pixels + drawPoint.x + (row * ds->pitch); + drawPointer = (byte *)backBuffer->pixels + drawPoint.x + (row * backBuffer->pitch); col = drawPoint.x; for (;;) { bgRunCount = *readPointer++; @@ -853,8 +852,8 @@ void IsoMap::drawTile(Surface *ds, uint16 tileIndex, const Point &point, const L col++; } while ((col < _tileClip.right) && (count < fgRunCount)) { - assert((byte *)ds->pixels <= (byte *)(drawPointer + count)); - assert((byte *)((byte *)ds->pixels + (_vm->getDisplayWidth() * + assert((byte *)backBuffer->pixels <= (byte *)(drawPointer + count)); + assert((byte *)((byte *)backBuffer->pixels + (_vm->getDisplayWidth() * _vm->getDisplayHeight())) > (byte *)(drawPointer + count)); drawPointer[count] = readPointer[count]; count++; diff --git a/engines/saga/isomap.h b/engines/saga/isomap.h index eb548ce5dc..fd84ce1518 100644 --- a/engines/saga/isomap.h +++ b/engines/saga/isomap.h @@ -163,7 +163,7 @@ public: void loadMulti(const byte * resourcePointer, size_t resourceLength); void freeMem(); void draw(Surface *ds); - void drawSprite(Surface *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale); + void drawSprite(SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale); void adjustScroll(bool jump); void tileCoordsToScreenPoint(const Location &location, Point &position) { position.x = location.u() - location.v() + (128 * SAGA_TILEMAP_W) - _viewScroll.x + 16; @@ -181,12 +181,12 @@ public: int16 getTileIndex(int16 u, int16 v, int16 z); private: - void drawTiles(Surface *ds, const Location *location); - void drawMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, int16 absU, int16 absV); - void drawSpriteMetaTile(Surface *ds, uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV); - void drawPlatform(Surface *ds, uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH); - void drawSpritePlatform(Surface *ds, uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH); - void drawTile(Surface *ds, uint16 tileIndex, const Point &point, const Location *location); + void drawTiles(const Location *location); + void drawMetaTile(uint16 metaTileIndex, const Point &point, int16 absU, int16 absV); + void drawSpriteMetaTile(uint16 metaTileIndex, const Point &point, Location &location, int16 absU, int16 absV); + void drawPlatform(uint16 platformIndex, const Point &point, int16 absU, int16 absV, int16 absH); + void drawSpritePlatform(uint16 platformIndex, const Point &point, const Location &location, int16 absU, int16 absV, int16 absH); + void drawTile(uint16 tileIndex, const Point &point, const Location *location); int16 smoothSlide(int16 value, int16 min, int16 max) { if (value < min) { if (value < min - 100 || value > min - 4) { diff --git a/engines/saga/objectmap.cpp b/engines/saga/objectmap.cpp index 6ad3d38cfb..91d265fa05 100644 --- a/engines/saga/objectmap.cpp +++ b/engines/saga/objectmap.cpp @@ -142,7 +142,7 @@ bool HitZone::hitTest(const Point &testPoint) { } #ifdef SAGA_DEBUG -void HitZone::draw(SagaEngine *vm, Surface *ds, int color) { +void HitZone::draw(SagaEngine *vm, int color) { int i, pointsCount, j; Location location; HitZone::ClickArea *clickArea; @@ -237,7 +237,7 @@ void ObjectMap::freeMem() { #ifdef SAGA_DEBUG -void ObjectMap::draw(Surface *ds, const Point& testPoint, int color, int color2) { +void ObjectMap::draw(const Point& testPoint, int color, int color2) { int i; int hitZoneIndex; char txtBuf[32]; @@ -255,14 +255,14 @@ void ObjectMap::draw(Surface *ds, const Point& testPoint, int color, int color2) hitZoneIndex = hitTest(pickPoint); for (i = 0; i < _hitZoneListCount; i++) { - _hitZoneList[i]->draw(_vm, ds, (hitZoneIndex == i) ? color2 : color); + _hitZoneList[i]->draw(_vm, (hitZoneIndex == i) ? color2 : color); } if (hitZoneIndex != -1) { snprintf(txtBuf, sizeof(txtBuf), "hitZone %d", hitZoneIndex); textPoint.x = 2; textPoint.y = 2; - _vm->_font->textDraw(kKnownFontSmall, ds, txtBuf, textPoint, kITEColorBrightWhite, kITEColorBlack, kFontOutline); + _vm->_font->textDraw(kKnownFontSmall, txtBuf, textPoint, kITEColorBrightWhite, kITEColorBlack, kFontOutline); } } #endif diff --git a/engines/saga/objectmap.h b/engines/saga/objectmap.h index 05207007db..8076180eaf 100644 --- a/engines/saga/objectmap.h +++ b/engines/saga/objectmap.h @@ -77,7 +77,7 @@ public: } bool getSpecialPoint(Point &specialPoint) const; #ifdef SAGA_DEBUG - void draw(SagaEngine *vm, Surface *ds, int color); + void draw(SagaEngine *vm, int color); #endif bool hitTest(const Point &testPoint); diff --git a/engines/saga/puzzle.cpp b/engines/saga/puzzle.cpp index e37892693c..ccc395f322 100644 --- a/engines/saga/puzzle.cpp +++ b/engines/saga/puzzle.cpp @@ -189,14 +189,13 @@ void Puzzle::showPieces(void) { ActorData *puzzle = _vm->_actor->getActor(_vm->_actor->actorIndexToId(ITE_ACTOR_PUZZLE)); int frameNumber; SpriteList *spriteList; - Surface *backBuffer = _vm->_gfx->getBackBuffer(); _vm->_actor->getSpriteParams(puzzle, frameNumber, spriteList); for (int j = PUZZLE_PIECES - 1 ; j >= 0; j--) { int num = _piecePriority[j]; if (_puzzlePiece != num) { - _vm->_sprite->draw(backBuffer, _vm->getDisplayClip(), *spriteList, num, Point(_pieceInfo[num].curX, _pieceInfo[num].curY), 256); + _vm->_sprite->draw(_vm->getDisplayClip(), *spriteList, num, Point(_pieceInfo[num].curX, _pieceInfo[num].curY), 256); } } } @@ -207,7 +206,7 @@ void Puzzle::drawCurrentPiece() { SpriteList *spriteList; _vm->_actor->getSpriteParams(puzzle, frameNumber, spriteList); - _vm->_sprite->draw(_vm->_gfx->getBackBuffer(), _vm->_scene->getSceneClip(), *spriteList, _puzzlePiece, + _vm->_sprite->draw(_vm->_scene->getSceneClip(), *spriteList, _puzzlePiece, Point(_pieceInfo[_puzzlePiece].curX, _pieceInfo[_puzzlePiece].curY), 256); } diff --git a/engines/saga/render.cpp b/engines/saga/render.cpp index 623a425f75..f0867eb3eb 100644 --- a/engines/saga/render.cpp +++ b/engines/saga/render.cpp @@ -155,7 +155,7 @@ void Render::drawScene() { } // Draw queued text strings - _vm->_scene->drawTextList(backBufferSurface); + _vm->_scene->drawTextList(); // Handle user input _vm->processInput(); @@ -178,7 +178,7 @@ void Render::drawScene() { textPoint.x = (backBufferSurface->w - _vm->_font->getStringWidth(kKnownFontPause, pauseString, 0, kFontOutline)) / 2; textPoint.y = 90; - _vm->_font->textDraw(kKnownFontPause, backBufferSurface, pauseString, textPoint, + _vm->_font->textDraw(kKnownFontPause, pauseString, textPoint, _vm->KnownColor2ColorId(kKnownColorBrightWhite), _vm->KnownColor2ColorId(kKnownColorBlack), kFontOutline); } @@ -189,7 +189,7 @@ void Render::drawScene() { // Display text formatting test, if applicable if (_flags & RF_TEXT_TEST) { Rect rect(mousePoint.x, mousePoint.y, mousePoint.x + 100, mousePoint.y + 50); - _vm->_font->textDrawRect(kKnownFontMedium, backBufferSurface, test_txt, rect, + _vm->_font->textDrawRect(kKnownFontMedium, test_txt, rect, kITEColorBrightWhite, kITEColorBlack, (FontEffectFlags)(kFontOutline | kFontCentered)); } diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 06c2bbe87d..dafacc5588 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -233,7 +233,7 @@ void Scene::getResourceTypes(SAGAResourceTypes *&types, int &typesCount) { } } -void Scene::drawTextList(Surface *ds) { +void Scene::drawTextList() { TextListEntry *entry; for (TextList::iterator textIterator = _textList.begin(); textIterator != _textList.end(); ++textIterator) { @@ -241,9 +241,9 @@ void Scene::drawTextList(Surface *ds) { if (entry->display) { if (entry->useRect) { - _vm->_font->textDrawRect(entry->font, ds, entry->text, entry->rect, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags); + _vm->_font->textDrawRect(entry->font, entry->text, entry->rect, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags); } else { - _vm->_font->textDraw(entry->font, ds, entry->text, entry->point, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags); + _vm->_font->textDraw(entry->font, entry->text, entry->point, _vm->KnownColor2ColorId(entry->knownColor), _vm->KnownColor2ColorId(entry->effectKnownColor), entry->flags); } } } @@ -455,7 +455,6 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy if (_vm->getFeatures() & GF_SCENE_SUBSTITUTES) { for (int i = 0; i < ARRAYSIZE(sceneSubstitutes); i++) { if (sceneSubstitutes[i].sceneId == sceneNumber) { - Surface *backBuffer = _vm->_gfx->getBackBuffer(); Surface bbmBuffer; byte *pal, *colors; Common::File file; @@ -469,7 +468,7 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy colors = pal; rect.setWidth(bbmBuffer.w); rect.setHeight(bbmBuffer.h); - backBuffer->blit(rect, (const byte*)bbmBuffer.pixels); + _vm->_gfx->getBackBuffer()->blit(rect, (const byte*)bbmBuffer.pixels); for (int j = 0; j < PAL_ENTRIES; j++) { cPal[j].red = *pal++; cPal[j].green = *pal++; @@ -481,9 +480,9 @@ void Scene::changeScene(int16 sceneNumber, int actorsEntrance, SceneTransitionTy } _vm->_interface->setStatusText("Click or Press Return to continue. Press Q to quit.", 96); - _vm->_font->textDrawRect(kKnownFontMedium, backBuffer, sceneSubstitutes[i].title, + _vm->_font->textDrawRect(kKnownFontMedium, sceneSubstitutes[i].title, Common::Rect(0, 7, _vm->getDisplayWidth(), 27), _vm->KnownColor2ColorId(kKnownColorBrightWhite), _vm->KnownColor2ColorId(kKnownColorBlack), kFontOutline); - _vm->_font->textDrawRect(kKnownFontMedium, backBuffer, sceneSubstitutes[i].message, + _vm->_font->textDrawRect(kKnownFontMedium, sceneSubstitutes[i].message, Common::Rect(24, getHeight() - 33, _vm->getDisplayWidth() - 11, getHeight()), _vm->KnownColor2ColorId(kKnownColorBrightWhite), _vm->KnownColor2ColorId(kKnownColorBlack), kFontOutline); return; diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 723792f050..a97b5d203a 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -345,7 +345,7 @@ class Scene { _vm->_framesEsc = 1; } - void drawTextList(Surface *ds); + void drawTextList(); int getHeight(bool speech = false) const { if (_vm->getGameType() == GType_IHNM && _vm->_scene->currentChapterNumber() == 8 && !speech) diff --git a/engines/saga/sprite.cpp b/engines/saga/sprite.cpp index 2a4443916e..2723ce7d7f 100644 --- a/engines/saga/sprite.cpp +++ b/engines/saga/sprite.cpp @@ -211,15 +211,16 @@ void Sprite::getScaledSpriteBuffer(SpriteList &spriteList, int spriteNumber, int } } -void Sprite::drawClip(Surface *ds, const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer) { +void Sprite::drawClip(const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer) { int clipWidth; int clipHeight; int i, j, jo, io; byte *bufRowPointer; const byte *srcRowPointer; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); - bufRowPointer = (byte *)ds->pixels + ds->pitch * spritePointer.y; + bufRowPointer = (byte *)backBuffer->pixels + backBuffer->pitch * spritePointer.y; srcRowPointer = spriteBuffer; clipWidth = CLIP(width, 0, clipRect.right - spritePointer.x); @@ -232,14 +233,14 @@ void Sprite::drawClip(Surface *ds, const Rect &clipRect, const Point &spritePoin } if (spritePointer.y < clipRect.top) { io = clipRect.top - spritePointer.y; - bufRowPointer += ds->pitch * io; + bufRowPointer += backBuffer->pitch * io; srcRowPointer += width * io; } for (i = io; i < clipHeight; i++) { for (j = jo; j < clipWidth; j++) { - assert((byte *)ds->pixels <= (byte *)(bufRowPointer + j + spritePointer.x)); - assert(((byte *)ds->pixels + (_vm->getDisplayWidth() * + assert((byte *)backBuffer->pixels <= (byte *)(bufRowPointer + j + spritePointer.x)); + assert(((byte *)backBuffer->pixels + (_vm->getDisplayWidth() * _vm->getDisplayHeight())) > (byte *)(bufRowPointer + j + spritePointer.x)); assert((const byte *)spriteBuffer <= (const byte *)(srcRowPointer + j)); assert(((const byte *)spriteBuffer + (width * height)) > (const byte *)(srcRowPointer + j)); @@ -248,12 +249,12 @@ void Sprite::drawClip(Surface *ds, const Rect &clipRect, const Point &spritePoin *(bufRowPointer + j + spritePointer.x) = *(srcRowPointer + j); } } - bufRowPointer += ds->pitch; + bufRowPointer += backBuffer->pitch; srcRowPointer += width; } } -void Sprite::draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale) { +void Sprite::draw(const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale) { const byte *spriteBuffer = NULL; int width = 0; int height = 0; @@ -266,10 +267,10 @@ void Sprite::draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int spritePointer.x = screenCoord.x + xAlign; spritePointer.y = screenCoord.y + yAlign; - drawClip(ds, clipRect, spritePointer, width, height, spriteBuffer); + drawClip(clipRect, spritePointer, width, height, spriteBuffer); } -void Sprite::draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale) { +void Sprite::draw(const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale) { const byte *spriteBuffer = NULL; int width = 0; int height = 0; @@ -290,7 +291,7 @@ void Sprite::draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int } spritePointer.x = screenRect.left + xAlign + spw; spritePointer.y = screenRect.top + yAlign + sph; - drawClip(ds, clipRect, spritePointer, width, height, spriteBuffer); + drawClip(clipRect, spritePointer, width, height, spriteBuffer); } bool Sprite::hitTest(SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, const Point &testPoint) { @@ -320,7 +321,7 @@ bool Sprite::hitTest(SpriteList &spriteList, int spriteNumber, const Point &scre return *srcRowPointer != 0; } -void Sprite::drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth) { +void Sprite::drawOccluded(const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth) { const byte *spriteBuffer = NULL; int x, y; byte *destRowPointer; @@ -332,6 +333,7 @@ void Sprite::drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteL int height = 0; int xAlign = 0; int yAlign = 0; + Surface *backBuffer = _vm->_gfx->getBackBuffer(); ClipData clipData; @@ -344,7 +346,7 @@ void Sprite::drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteL int maskZ; if (!_vm->_scene->isBGMaskPresent()) { - draw(ds, clipRect, spriteList, spriteNumber, screenCoord, scale); + draw(clipRect, spriteList, spriteNumber, screenCoord, scale); return; } @@ -369,7 +371,7 @@ void Sprite::drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteL // Finally, draw the occluded sprite sourceRowPointer = spriteBuffer + clipData.drawSource.x + (clipData.drawSource.y * width); - destRowPointer = (byte *)ds->pixels + clipData.drawDest.x + (clipData.drawDest.y * ds->pitch); + destRowPointer = (byte *)backBuffer->pixels + clipData.drawDest.x + (clipData.drawDest.y * backBuffer->pitch); maskRowPointer = maskBuffer + clipData.drawDest.x + (clipData.drawDest.y * maskWidth); for (y = 0; y < clipData.drawHeight; y++) { @@ -387,7 +389,7 @@ void Sprite::drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteL destPointer++; maskPointer++; } - destRowPointer += ds->pitch; + destRowPointer += backBuffer->pitch; maskRowPointer += maskWidth; sourceRowPointer += width; } diff --git a/engines/saga/sprite.h b/engines/saga/sprite.h index 112a4b0307..0c31044be2 100644 --- a/engines/saga/sprite.h +++ b/engines/saga/sprite.h @@ -74,15 +74,15 @@ public: ~Sprite(void); // draw scaled sprite using background scene mask - void drawOccluded(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth); + void drawOccluded(const Rect &clipRect, SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, int depth); // draw scaled sprite using background scene mask - void draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale); + void draw(const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Point &screenCoord, int scale); // main function - void drawClip(Surface *ds, const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer); + void drawClip(const Rect &clipRect, const Point &spritePointer, int width, int height, const byte *spriteBuffer); - void draw(Surface *ds, const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale); + void draw(const Rect &clipRect, SpriteList &spriteList, int32 spriteNumber, const Rect &screenRect, int scale); void loadList(int resourceId, SpriteList &spriteList); // load or append spriteList bool hitTest(SpriteList &spriteList, int spriteNumber, const Point &screenCoord, int scale, const Point &testPoint); -- cgit v1.2.3