diff options
author | Martin Kiewitz | 2010-01-06 13:05:14 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-01-06 13:05:14 +0000 |
commit | 7d7d23ce2b8d7d2a4725303d893f273f366be18c (patch) | |
tree | 3f2a2f7cea3e9c839c56140cf4fefd4aefe5303c /engines/sci | |
parent | 86c1171b11edcfe28dab7a3ba282e8e75060b01c (diff) | |
download | scummvm-rg350-7d7d23ce2b8d7d2a4725303d893f273f366be18c.tar.gz scummvm-rg350-7d7d23ce2b8d7d2a4725303d893f273f366be18c.tar.bz2 scummvm-rg350-7d7d23ce2b8d7d2a4725303d893f273f366be18c.zip |
SCI: making most of the variables in screen class private (some of it was needed for old gui)
svn-id: r47075
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 24 | ||||
-rw-r--r-- | engines/sci/graphics/cursor.cpp | 6 | ||||
-rw-r--r-- | engines/sci/graphics/font.cpp | 4 | ||||
-rw-r--r-- | engines/sci/graphics/gfx.cpp | 8 | ||||
-rw-r--r-- | engines/sci/graphics/gui.cpp | 16 | ||||
-rw-r--r-- | engines/sci/graphics/gui.h | 3 | ||||
-rw-r--r-- | engines/sci/graphics/menu.cpp | 6 | ||||
-rw-r--r-- | engines/sci/graphics/picture.cpp | 12 | ||||
-rw-r--r-- | engines/sci/graphics/screen.h | 18 | ||||
-rw-r--r-- | engines/sci/graphics/transitions.cpp | 12 | ||||
-rw-r--r-- | engines/sci/graphics/windowmgr.cpp | 6 |
11 files changed, 43 insertions, 72 deletions
diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index 44d67cb5df..1db605af1e 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -646,30 +646,6 @@ reg_t kAddScreenItem(EngineState *s, int argc, reg_t *argv) { reg_t kUpdateScreenItem(EngineState *s, int argc, reg_t *argv) { reg_t viewObj = argv[0]; - uint16 viewId = GET_SEL32V(s->_segMan, viewObj, view); - uint16 loopNo = GET_SEL32V(s->_segMan, viewObj, loop); - uint16 celNo = GET_SEL32V(s->_segMan, viewObj, cel); - uint16 leftPos = GET_SEL32V(s->_segMan, viewObj, x); - uint16 topPos = GET_SEL32V(s->_segMan, viewObj, y); - int16 priority = GET_SEL32V(s->_segMan, viewObj, priority); - //int16 control = 0; - - // Theoretically, leftPos and topPos should be sane - // Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that - // the hack underneath does not try and draw cels outside the screen coordinates - if (leftPos >= s->_gui->getScreenWidth()) { - warning("kUpdateScreenItem: invalid left position (%d), resetting to 0", leftPos); - leftPos = 0; - } - - if (topPos >= s->_gui->getScreenHeight()) { - warning("kUpdateScreenItem: invalid top position (%d), resetting to 0", topPos); - topPos = 0; - } - - // HACK: just draw the view on screen - if (viewId != 0xffff) - s->_gui->drawCel(viewId, loopNo, celNo, leftPos, topPos, priority, 0); //warning("kUpdateScreenItem, object %04x:%04x, view %d, loop %d, cel %d, pri %d", PRINT_REG(viewObj), viewId, loopNo, celNo, priority); return NULL_REG; diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index 4682fd42a6..fda017341e 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -41,8 +41,8 @@ Cursor::Cursor(ResourceManager *resMan, SciPalette *palette, Screen *screen) _upscaledHires = _screen->getUpscaledHires(); // center mouse cursor - setPosition(Common::Point(_screen->_displayWidth / 2, _screen->_displayHeight / 2)); - setMoveZone(Common::Rect(0, 0, _screen->_displayWidth, _screen->_displayHeight)); + setPosition(Common::Point(_screen->getDisplayWidth() / 2, _screen->getDisplayHeight() / 2)); + setMoveZone(Common::Rect(0, 0, _screen->getDisplayWidth(), _screen->getDisplayHeight())); _isVisible = true; } @@ -109,7 +109,7 @@ void Cursor::setShape(GuiResourceId resourceId) { // Now find out what colors we are supposed to use colorMapping[0] = 0; // Black is hardcoded - colorMapping[1] = _screen->_colorWhite; // White is also hardcoded + colorMapping[1] = _screen->getColorWhite(); // White is also hardcoded colorMapping[2] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR; colorMapping[3] = _palette->matchColor(&_palette->_sysPalette, 170, 170, 170); // Grey diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp index 6b20899c26..b7ffec522b 100644 --- a/engines/sci/graphics/font.cpp +++ b/engines/sci/graphics/font.cpp @@ -79,8 +79,8 @@ byte *Font::getCharData(byte chr) { } void Font::draw(Screen *screen, int16 chr, int16 top, int16 left, byte color, bool greyedOutput) { - int charWidth = MIN<int>(getCharWidth(chr), screen->_width - left); - int charHeight = MIN<int>(getCharHeight(chr), 200 - top); + int charWidth = MIN<int>(getCharWidth(chr), screen->getWidth() - left); + int charHeight = MIN<int>(getCharHeight(chr), screen->getHeight() - top); byte b = 0, mask = 0xFF; int y = top; diff --git a/engines/sci/graphics/gfx.cpp b/engines/sci/graphics/gfx.cpp index f8f6146990..089ac3f08e 100644 --- a/engines/sci/graphics/gfx.cpp +++ b/engines/sci/graphics/gfx.cpp @@ -64,8 +64,8 @@ void Gfx::init(Text *text) { _menuPort = new Port(0xFFFF); OpenPort(_menuPort); _text->SetFont(0); - _menuPort->rect = Common::Rect(0, 0, _screen->_width, _screen->_height); - _menuBarRect = Common::Rect(0, 0, _screen->_width, 9); + _menuPort->rect = Common::Rect(0, 0, _screen->getWidth(), _screen->getHeight()); + _menuBarRect = Common::Rect(0, 0, _screen->getWidth(), 9); } void Gfx::purgeCache() { @@ -322,7 +322,7 @@ void Gfx::drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredF // do we add to a picture? if not -> clear screen with white if (!addToFlag) - ClearScreen(_screen->_colorWhite); + ClearScreen(_screen->getColorWhite()); picture->draw(animationNr, mirroredFlag, addToFlag, paletteId); delete picture; @@ -426,7 +426,7 @@ void Gfx::PriorityBandsInit(int16 bandCount, int16 top, int16 bottom) { _priorityBands[y]--; } // We fill space that is left over with the highest band - for (y = _priorityBottom; y < _screen->_height; y++) + for (y = _priorityBottom; y < _screen->getHeight(); y++) _priorityBands[y] = _priorityBandCount; } diff --git a/engines/sci/graphics/gui.cpp b/engines/sci/graphics/gui.cpp index c07211b8a4..c4a974f18a 100644 --- a/engines/sci/graphics/gui.cpp +++ b/engines/sci/graphics/gui.cpp @@ -254,7 +254,7 @@ void SciGui::display(const char *text, int argc, reg_t *argv) { _text->Size(rect, text, -1, width); rect.moveTo(_gfx->GetPort()->curLeft, _gfx->GetPort()->curTop); if (getSciVersion() >= SCI_VERSION_1_LATE) { - _gfx->Move(rect.right <= _screen->_width ? 0 : _screen->_width - rect.right, rect.bottom <= _screen->_height ? 0 : _screen->_width - rect.bottom); + _gfx->Move(rect.right <= _screen->getWidth() ? 0 : _screen->getWidth() - rect.right, rect.bottom <= _screen->getHeight() ? 0 : _screen->getWidth() - rect.bottom); rect.moveTo(_gfx->GetPort()->curLeft, _gfx->GetPort()->curTop); } @@ -775,7 +775,7 @@ void SciGui::moveCursor(Common::Point pos) { pos.y = CLIP<int16>(pos.y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1); pos.x = CLIP<int16>(pos.x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1); - if (pos.x > _screen->_width || pos.y > _screen->_height) { + if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) { warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x); return; } @@ -817,14 +817,6 @@ void SciGui::portraitShow(Common::String resourceName, Common::Point position, u void SciGui::portraitUnload(uint16 portraitId) { } -uint16 SciGui::getScreenWidth() { - return _screen->_displayWidth; -} - -uint16 SciGui::getScreenHeight() { - return _screen->_displayHeight; -} - #ifdef ENABLE_SCI32 void SciGui::addScreenItem(reg_t object) { _screenItems.push_back(object); @@ -895,12 +887,12 @@ void SciGui::frameOut() { // Theoretically, leftPos and topPos should be sane // Apparently, sometimes they're not, therefore I'm adding some sanity checks here so that // the hack underneath does not try and draw cels outside the screen coordinates - if (leftPos >= getScreenWidth()) { + if (leftPos >= _screen->getWidth()) { warning("kAddScreenItem: invalid left position (%d), resetting to 0", leftPos); leftPos = 0; } - if (topPos >= getScreenHeight()) { + if (topPos >= _screen->getHeight()) { warning("kAddScreenItem: invalid top position (%d), resetting to 0", topPos); topPos = 0; } diff --git a/engines/sci/graphics/gui.h b/engines/sci/graphics/gui.h index 06aeab5521..f5b888ecfb 100644 --- a/engines/sci/graphics/gui.h +++ b/engines/sci/graphics/gui.h @@ -149,9 +149,6 @@ public: virtual void portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq); virtual void portraitUnload(uint16 portraitId); - virtual uint16 getScreenWidth(); - virtual uint16 getScreenHeight(); - #ifdef ENABLE_SCI32 // SCI32 virtual void addScreenItem(reg_t object); diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 9583189512..219e5018f5 100644 --- a/engines/sci/graphics/menu.cpp +++ b/engines/sci/graphics/menu.cpp @@ -285,7 +285,7 @@ void Menu::drawBar() { GuiMenuList::iterator listEnd = _list.end(); // Hardcoded black on white - _gfx->FillRect(_gfx->_menuBarRect, 1, _screen->_colorWhite); + _gfx->FillRect(_gfx->_menuBarRect, 1, _screen->getColorWhite()); _gfx->PenColor(0); _gfx->MoveTo(8, 1); @@ -503,7 +503,7 @@ void Menu::drawMenu(uint16 oldMenuId, uint16 newMenuId) { // Do the drawing _gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, 0); _menuRect.left++; _menuRect.right--; _menuRect.bottom--; - _gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, _screen->_colorWhite); + _gfx->FillRect(_menuRect, SCI_SCREEN_MASK_VISUAL, _screen->getColorWhite()); _menuRect.left += 8; topPos = _menuRect.top + 1; @@ -564,7 +564,7 @@ GuiMenuItemEntry *Menu::interactiveWithKeyboard() { _barSaveHandle = _gfx->BitsSave(_gfx->_menuBarRect, SCI_SCREEN_MASK_VISUAL); _gfx->PenColor(0); - _gfx->BackColor(_screen->_colorWhite); + _gfx->BackColor(_screen->getColorWhite()); drawBar(); drawMenu(0, curItemEntry->menuId); diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp index 545616e062..d7d7fa63d6 100644 --- a/engines/sci/graphics/picture.cpp +++ b/engines/sci/graphics/picture.cpp @@ -81,8 +81,8 @@ void SciGuiPicture::draw(int16 animationNr, bool mirroredFlag, bool addToFlag, i void SciGuiPicture::reset() { int16 x, y; - for (y = _gfx->GetPort()->top; y < _screen->_height; y++) { - for (x = 0; x < _screen->_width; x++) { + for (y = _gfx->GetPort()->top; y < _screen->getHeight(); y++) { + for (x = 0; x < _screen->getWidth(); x++) { _screen->putPixel(x, y, SCI_SCREEN_MASK_ALL, 255, 0, 0); } } @@ -273,7 +273,7 @@ void SciGuiPicture::drawCelData(byte *inbuffer, int size, int headerPos, int rle // SCI1.1 games use color 0 as transparency and SCI1 games use color 255 as transparency. Sierra SCI seems to paint // the whole data to screen and wont skip over transparent pixels. So this will actually make it work like Sierra if (!_addToFlag) - clearColor = _screen->_colorWhite; + clearColor = _screen->getColorWhite(); ptr = celBitmap; if (!_mirroredFlag) { @@ -367,7 +367,7 @@ static const byte vector_defaultEGApriority[PIC_EGAPRIORITY_SIZE] = { void SciGuiPicture::drawVectorData(byte *data, int dataSize) { byte pic_op; - byte pic_color = _screen->_colorDefaultVectorData; + byte pic_color = _screen->getColorDefaultVectorData(); byte pic_priority = 255, pic_control = 255; int16 x = 0, y = 0, oldx, oldy; byte EGApalettes[PIC_EGAPALETTE_TOTALSIZE] = {0}; @@ -671,7 +671,7 @@ void SciGuiPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, // This logic was taken directly from sierra sci, floodfill will get aborted on various occations if (screenMask & SCI_SCREEN_MASK_VISUAL) { - if ((color == _screen->_colorWhite) || (searchColor != _screen->_colorWhite)) + if ((color == _screen->getColorWhite()) || (searchColor != _screen->getColorWhite())) return; } else if (screenMask & SCI_SCREEN_MASK_PRIORITY) { if ((priority == 0) || (searchPriority != 0)) @@ -957,7 +957,7 @@ void SciGuiPicture::vectorPattern(int16 x, int16 y, byte color, byte priority, b rect.top = y; rect.left = x; rect.setHeight((size*2)+1); rect.setWidth((size*2)+2); _gfx->OffsetRect(rect); - rect.clip(_screen->_width, _screen->_height); + rect.clip(_screen->getWidth(), _screen->getHeight()); if (code & SCI_PATTERN_CODE_RECTANGLE) { // Rectangle diff --git a/engines/sci/graphics/screen.h b/engines/sci/graphics/screen.h index efcfa17e03..447eb31d38 100644 --- a/engines/sci/graphics/screen.h +++ b/engines/sci/graphics/screen.h @@ -46,6 +46,13 @@ public: Screen(ResourceManager *resMan, int16 width = 320, int16 height = 200, bool upscaledHires = false); ~Screen(); + uint16 getWidth() { return _width; }; + uint16 getHeight() { return _height; }; + uint16 getDisplayWidth() { return _displayWidth; }; + uint16 getDisplayHeight() { return _displayHeight; }; + byte getColorWhite() { return _colorWhite; }; + byte getColorDefaultVectorData() { return _colorDefaultVectorData; }; + void copyToScreen(); void copyFromScreen(byte *buffer); void copyRectToScreen(const Common::Rect &rect); @@ -83,6 +90,10 @@ public: void debugShowMap(int mapNo); + int _picNotValid; // possible values 0, 1 and 2 + int _picNotValidSci11; // another variable that is used by kPicNotValid in sci1.1 + +private: uint16 _width; uint16 _height; uint _pixels; @@ -90,13 +101,9 @@ public: uint16 _displayHeight; uint _displayPixels; - int _picNotValid; // possible values 0, 1 and 2 - int _picNotValidSci11; // another variable that is used by kPicNotValid in sci1.1 - byte _colorWhite; byte _colorDefaultVectorData; -private: void bitsRestoreScreen(Common::Rect rect, byte *&memoryPtr, byte *screen); void bitsRestoreDisplayScreen(Common::Rect rect, byte *&memoryPtr); void bitsSaveScreen(Common::Rect rect, byte *screen, byte *&memoryPtr); @@ -105,7 +112,6 @@ private: bool _unditherState; int16 _unditherMemorial[SCI_SCREEN_UNDITHERMEMORIAL_SIZE]; -public: // HACK. TODO: make private // these screens have the real resolution of the game engine (320x200 for SCI0/SCI1/SCI11 games, 640x480 for SCI2 games) // SCI0 games will be dithered in here at any time byte *_visualScreen; @@ -115,7 +121,7 @@ public: // HACK. TODO: make private // this screen is the one that is actually displayed to the user. It may be 640x480 for japanese SCI1 games // SCI0 games may be undithered in here. Only read from this buffer for Save/ShowBits usage. byte *_displayScreen; -private: + Common::Rect getScaledRect(Common::Rect rect); ResourceManager *_resMan; diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp index c5cac0be89..77843d626f 100644 --- a/engines/sci/graphics/transitions.cpp +++ b/engines/sci/graphics/transitions.cpp @@ -102,7 +102,7 @@ static const GuiTransitionTranslateEntry blackoutTransitionIDs[] = { }; void Transitions::init() { - _oldScreen = new byte[_screen->_displayHeight * _screen->_displayWidth]; + _oldScreen = new byte[_screen->getDisplayHeight() * _screen->getDisplayWidth()]; if (getSciVersion() >= SCI_VERSION_1_LATE) _translationTable = NULL; @@ -170,7 +170,7 @@ void Transitions::doit(Common::Rect picRect) { // Now we do the actual transition to the new screen doTransition(_number, false); - if (picRect.bottom != _screen->_height) { + if (picRect.bottom != _screen->getHeight()) { // TODO: this is a workaround for lsl6 not showing menubar when playing // There is some new code in the sierra sci in ShowPic that seems to do something similar to this _screen->copyToScreen(); @@ -305,10 +305,10 @@ void Transitions::pixelation (bool blackoutFlag) { do { mask = (mask & 1) ? (mask >> 1) ^ 0xB400 : mask >> 1; - if (mask >= _screen->_width * _screen->_height) + if (mask >= _screen->getWidth() * _screen->getHeight()) continue; - pixelRect.left = mask % _screen->_width; pixelRect.right = pixelRect.left + 1; - pixelRect.top = mask / _screen->_width; pixelRect.bottom = pixelRect.top + 1; + pixelRect.left = mask % _screen->getWidth(); pixelRect.right = pixelRect.left + 1; + pixelRect.top = mask / _screen->getWidth(); pixelRect.bottom = pixelRect.top + 1; pixelRect.clip(_picRect); if (!pixelRect.isEmpty()) copyRectToScreen(pixelRect, blackoutFlag); @@ -403,7 +403,7 @@ void Transitions::scroll(int16 number) { Common::Rect newScreenRect = _picRect; _screen->copyFromScreen(_oldScreen); - screenWidth = _screen->_displayWidth; screenHeight = _screen->_displayHeight; + screenWidth = _screen->getDisplayWidth(); screenHeight = _screen->getDisplayHeight(); oldScreenPtr = _oldScreen + _picRect.left + _picRect.top * screenWidth; diff --git a/engines/sci/graphics/windowmgr.cpp b/engines/sci/graphics/windowmgr.cpp index 198649cf64..92c014d7e1 100644 --- a/engines/sci/graphics/windowmgr.cpp +++ b/engines/sci/graphics/windowmgr.cpp @@ -71,14 +71,14 @@ void WindowMgr::init(Common::String gameId) { _gfx->OpenPort(_wmgrPort); _gfx->SetPort(_wmgrPort); _gfx->SetOrigin(0, offTop); - _wmgrPort->rect.bottom = _screen->_height - offTop; - _wmgrPort->rect.right = _screen->_width; + _wmgrPort->rect.bottom = _screen->getHeight() - offTop; + _wmgrPort->rect.right = _screen->getWidth(); _wmgrPort->rect.moveTo(0, 0); _wmgrPort->curTop = 0; _wmgrPort->curLeft = 0; _windowList.push_front(_wmgrPort); - _picWind = NewWindow(Common::Rect(0, offTop, _screen->_width, _screen->_height), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true); + _picWind = NewWindow(Common::Rect(0, offTop, _screen->getWidth(), _screen->getHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true); } int16 WindowMgr::isFrontWindow(Window *pWnd) { |