From c05a09d33717d1b2c41b258013be589fa63a7097 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 Mar 2016 21:53:14 -0500 Subject: VOYEUR: Changed engine to use Graphics::ManagedSurface --- engines/voyeur/animation.cpp | 7 +- engines/voyeur/data.cpp | 16 +- engines/voyeur/debugger.cpp | 2 +- engines/voyeur/events.cpp | 58 +- engines/voyeur/files.cpp | 115 ++-- engines/voyeur/files.h | 6 +- engines/voyeur/files_threads.cpp | 74 +-- engines/voyeur/graphics.cpp | 1051 ------------------------------------- engines/voyeur/graphics.h | 120 ----- engines/voyeur/module.mk | 2 +- engines/voyeur/screen.cpp | 1074 ++++++++++++++++++++++++++++++++++++++ engines/voyeur/screen.h | 116 ++++ engines/voyeur/voyeur.cpp | 165 +++--- engines/voyeur/voyeur.h | 4 +- engines/voyeur/voyeur_game.cpp | 306 +++++------ 15 files changed, 1563 insertions(+), 1553 deletions(-) delete mode 100644 engines/voyeur/graphics.cpp delete mode 100644 engines/voyeur/graphics.h create mode 100644 engines/voyeur/screen.cpp create mode 100644 engines/voyeur/screen.h (limited to 'engines') diff --git a/engines/voyeur/animation.cpp b/engines/voyeur/animation.cpp index 62b37346da..d5d58a2fd3 100644 --- a/engines/voyeur/animation.cpp +++ b/engines/voyeur/animation.cpp @@ -470,7 +470,7 @@ void RL2Decoder::play(VoyeurEngine *vm, int resourceOffset, if (hasDirtyPalette()) { const byte *palette = getPalette(); - vm->_graphicsManager->setPalette128(palette, paletteStart, paletteCount); + vm->_screen->setPalette128(palette, paletteStart, paletteCount); } if (needsUpdate()) { @@ -482,15 +482,14 @@ void RL2Decoder::play(VoyeurEngine *vm, int resourceOffset, Common::Point pt(READ_LE_UINT16(imgPos + 4 * picCtr) - 32, READ_LE_UINT16(imgPos + 4 * picCtr + 2) - 20); - vm->_graphicsManager->sDrawPic(newPic, &videoFrame, pt); + vm->_screen->sDrawPic(newPic, &videoFrame, pt); ++picCtr; } } // Decode the next frame and display const Graphics::Surface *frame = decodeNextFrame(); - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)vm->_graphicsManager->_screenSurface.getPixels()); + vm->_screen->blitFrom(*frame); } vm->_eventsManager->getMouseInfo(); diff --git a/engines/voyeur/data.cpp b/engines/voyeur/data.cpp index b8c987f18b..4d6e32436d 100644 --- a/engines/voyeur/data.cpp +++ b/engines/voyeur/data.cpp @@ -240,10 +240,10 @@ void SVoy::reviewAnEvidEvent(int eventIndex) { int frameOff = e._computerOff; if (_vm->_bVoy->getBoltGroup(_vm->_playStampGroupId)) { - _vm->_graphicsManager->_backColors = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + 1)._cMapResource; - _vm->_graphicsManager->_backgroundPage = _vm->_bVoy->boltEntry(_vm->_playStampGroupId)._picResource; - _vm->_graphicsManager->_vPort->setupViewPort(_vm->_graphicsManager->_backgroundPage); - _vm->_graphicsManager->_backColors->startFade(); + _vm->_screen->_backColors = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + 1)._cMapResource; + _vm->_screen->_backgroundPage = _vm->_bVoy->boltEntry(_vm->_playStampGroupId)._picResource; + _vm->_screen->_vPort->setupViewPort(_vm->_screen->_backgroundPage); + _vm->_screen->_backColors->startFade(); _vm->doEvidDisplay(frameOff, e._dead); _vm->_bVoy->freeBoltGroup(_vm->_playStampGroupId); @@ -262,10 +262,10 @@ void SVoy::reviewComputerEvent(int eventIndex) { _computerTextId = e._computerOn; if (_vm->_bVoy->getBoltGroup(_vm->_playStampGroupId)) { - _vm->_graphicsManager->_backColors = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + 1)._cMapResource; - _vm->_graphicsManager->_backgroundPage = _vm->_bVoy->boltEntry(_vm->_playStampGroupId)._picResource; - _vm->_graphicsManager->_vPort->setupViewPort(_vm->_graphicsManager->_backgroundPage); - _vm->_graphicsManager->_backColors->startFade(); + _vm->_screen->_backColors = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + 1)._cMapResource; + _vm->_screen->_backgroundPage = _vm->_bVoy->boltEntry(_vm->_playStampGroupId)._picResource; + _vm->_screen->_vPort->setupViewPort(_vm->_screen->_backgroundPage); + _vm->_screen->_backColors->startFade(); _vm->flipPageAndWaitForFade(); _vm->getComputerBrush(); diff --git a/engines/voyeur/debugger.cpp b/engines/voyeur/debugger.cpp index e9a12180da..ebfa123eb6 100644 --- a/engines/voyeur/debugger.cpp +++ b/engines/voyeur/debugger.cpp @@ -21,7 +21,7 @@ */ #include "voyeur/debugger.h" -#include "voyeur/graphics.h" +#include "voyeur/screen.h" #include "voyeur/voyeur.h" #include "voyeur/staticres.h" diff --git a/engines/voyeur/events.cpp b/engines/voyeur/events.cpp index 34ef507ad3..020fe4b692 100644 --- a/engines/voyeur/events.cpp +++ b/engines/voyeur/events.cpp @@ -111,18 +111,18 @@ void EventsManager::mainVoyeurIntFunc() { } void EventsManager::sWaitFlip() { - Common::Array &viewPorts = _vm->_graphicsManager->_viewPortListPtr->_entries; + Common::Array &viewPorts = _vm->_screen->_viewPortListPtr->_entries; for (uint idx = 0; idx < viewPorts.size(); ++idx) { ViewPortResource &viewPort = *viewPorts[idx]; - if (_vm->_graphicsManager->_saveBack && (viewPort._flags & DISPFLAG_40)) { - Common::Rect *clipPtr = _vm->_graphicsManager->_clipPtr; - _vm->_graphicsManager->_clipPtr = &viewPort._clipRect; + if (_vm->_screen->_saveBack && (viewPort._flags & DISPFLAG_40)) { + Common::Rect *clipPtr = _vm->_screen->_clipPtr; + _vm->_screen->_clipPtr = &viewPort._clipRect; if (viewPort._restoreFn) - (_vm->_graphicsManager->*viewPort._restoreFn)(&viewPort); + (_vm->_screen->*viewPort._restoreFn)(&viewPort); - _vm->_graphicsManager->_clipPtr = clipPtr; + _vm->_screen->_clipPtr = clipPtr; viewPort._rectListCount[viewPort._pageIndex] = 0; viewPort._rectListPtr[viewPort._pageIndex]->clear(); viewPort._flags &= ~DISPFLAG_40; @@ -158,9 +158,7 @@ void EventsManager::checkForNextFrameCounter() { showMousePosition(); // Display the frame - g_system->copyRectToScreen((byte *)_vm->_graphicsManager->_screenSurface.getPixels(), - SCREEN_WIDTH, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - g_system->updateScreen(); + _vm->_screen->update(); // Signal the ScummVM debugger _vm->_debugger->onFrame(); @@ -178,10 +176,8 @@ void EventsManager::showMousePosition() { mousePos += Common::String::format(" - (%d,%d)", pt.x, pt.y); } - _vm->_graphicsManager->_screenSurface.fillRect( - Common::Rect(0, 0, 110, font.getFontHeight()), 0); - font.drawString(&_vm->_graphicsManager->_screenSurface, mousePos, - 0, 0, 110, 63); + _vm->_screen->fillRect(Common::Rect(0, 0, 110, font.getFontHeight()), 0); + font.drawString(_vm->_screen, mousePos, 0, 0, 110, 63); } void EventsManager::voyeurTimer() { @@ -299,11 +295,11 @@ void EventsManager::startFade(CMapResource *cMap) { if (cMap->_steps > 0) { _fadeStatus = cMap->_fadeStatus | 1; - byte *vgaP = &_vm->_graphicsManager->_VGAColors[_fadeFirstCol * 3]; + byte *vgaP = &_vm->_screen->_VGAColors[_fadeFirstCol * 3]; int mapIndex = 0; for (int idx = _fadeFirstCol; idx <= _fadeLastCol; ++idx, vgaP += 3) { - ViewPortPalEntry &palEntry = _vm->_graphicsManager->_viewPortListPtr->_palette[idx]; + ViewPortPalEntry &palEntry = _vm->_screen->_viewPortListPtr->_palette[idx]; palEntry._rEntry = vgaP[0] << 8; int rDiff = (cMap->_entries[mapIndex * 3] << 8) - palEntry._rEntry; palEntry._rChange = rDiff / cMap->_steps; @@ -325,7 +321,7 @@ void EventsManager::startFade(CMapResource *cMap) { _intPtr._skipFading = true; _fadeIntNode._flags &= ~1; } else { - byte *vgaP = &_vm->_graphicsManager->_VGAColors[_fadeFirstCol * 3]; + byte *vgaP = &_vm->_screen->_VGAColors[_fadeFirstCol * 3]; int mapIndex = 0; for (int idx = _fadeFirstCol; idx <= _fadeLastCol; ++idx, vgaP += 3) { @@ -371,8 +367,8 @@ void EventsManager::vDoFadeInt() { } for (int i = _fadeFirstCol; i <= _fadeLastCol; ++i) { - ViewPortPalEntry &palEntry = _vm->_graphicsManager->_viewPortListPtr->_palette[i]; - byte *vgaP = &_vm->_graphicsManager->_VGAColors[palEntry._palIndex * 3]; + ViewPortPalEntry &palEntry = _vm->_screen->_viewPortListPtr->_palette[i]; + byte *vgaP = &_vm->_screen->_VGAColors[palEntry._palIndex * 3]; palEntry._rEntry += palEntry._rChange; palEntry._gEntry += palEntry._gChange; @@ -395,7 +391,7 @@ void EventsManager::vDoCycleInt() { for (int idx = 3; idx >= 0; --idx) { if (_cyclePtr->_type[idx] && --_cycleTime[idx] <= 0) { byte *pSrc = _cycleNext[idx]; - byte *pPal = _vm->_graphicsManager->_VGAColors; + byte *pPal = _vm->_screen->_VGAColors; if (_cyclePtr->_type[idx] != 1) { // New palette data being specified - loop to set entries @@ -521,7 +517,7 @@ void EventsManager::setCursor(PictureResource *pic) { cursor._bounds = pic->_bounds; cursor._flags = DISPFLAG_CURSOR; - _vm->_graphicsManager->sDrawPic(pic, &cursor, Common::Point()); + _vm->_screen->sDrawPic(pic, &cursor, Common::Point()); } void EventsManager::setCursor(byte *cursorData, int width, int height, int keyColor) { @@ -531,16 +527,16 @@ void EventsManager::setCursor(byte *cursorData, int width, int height, int keyCo void EventsManager::setCursorColor(int idx, int mode) { switch (mode) { case 0: - _vm->_graphicsManager->setColor(idx, 90, 90, 232); + _vm->_screen->setColor(idx, 90, 90, 232); break; case 1: - _vm->_graphicsManager->setColor(idx, 232, 90, 90); + _vm->_screen->setColor(idx, 232, 90, 90); break; case 2: - _vm->_graphicsManager->setColor(idx, 90, 232, 90); + _vm->_screen->setColor(idx, 90, 232, 90); break; case 3: - _vm->_graphicsManager->setColor(idx, 90, 232, 232); + _vm->_screen->setColor(idx, 90, 232, 232); break; default: break; @@ -564,12 +560,12 @@ void EventsManager::getMouseInfo() { if (_cursorBlinked) { _cursorBlinked = false; - _vm->_graphicsManager->setOneColor(128, 220, 20, 20); - _vm->_graphicsManager->setColor(128, 220, 20, 20); + _vm->_screen->setOneColor(128, 220, 20, 20); + _vm->_screen->setColor(128, 220, 20, 20); } else { _cursorBlinked = true; - _vm->_graphicsManager->setOneColor(128, 220, 220, 220); - _vm->_graphicsManager->setColor(128, 220, 220, 220); + _vm->_screen->setOneColor(128, 220, 220, 220); + _vm->_screen->setColor(128, 220, 220, 220); } } } @@ -585,11 +581,11 @@ void EventsManager::getMouseInfo() { void EventsManager::startCursorBlink() { if (_vm->_voy->_eventFlags & EVTFLAG_RECORDING) { - _vm->_graphicsManager->setOneColor(128, 55, 5, 5); - _vm->_graphicsManager->setColor(128, 220, 20, 20); + _vm->_screen->setOneColor(128, 55, 5, 5); + _vm->_screen->setColor(128, 220, 20, 20); _intPtr._hasPalette = true; - _vm->_graphicsManager->drawDot(); + _vm->_screen->drawDot(); //copySection(); } } diff --git a/engines/voyeur/files.cpp b/engines/voyeur/files.cpp index 300e086f75..46b195ecaf 100644 --- a/engines/voyeur/files.cpp +++ b/engines/voyeur/files.cpp @@ -21,7 +21,7 @@ */ #include "voyeur/files.h" -#include "voyeur/graphics.h" +#include "voyeur/screen.h" #include "voyeur/voyeur.h" #include "voyeur/staticres.h" @@ -359,7 +359,7 @@ void BoltFile::resolveIt(uint32 id, byte **p) { } } -void BoltFile::resolveFunction(uint32 id, GraphicMethodPtr *fn) { +void BoltFile::resolveFunction(uint32 id, ScreenMethodPtr *fn) { if ((int32)id == -1) *fn = NULL; else @@ -485,8 +485,8 @@ void BVoyBoltFile::initViewPortList() { _state._curMemberPtr->_viewPortListResource = res = new ViewPortListResource( _state, _state._curMemberPtr->_data); - _state._vm->_graphicsManager->_viewPortListPtr = res; - _state._vm->_graphicsManager->_vPort = res->_entries[0]; + _state._vm->_screen->_viewPortListPtr = res; + _state._vm->_screen->_vPort = res->_entries[0]; } void BVoyBoltFile::initFontInfo() { @@ -752,24 +752,24 @@ DisplayResource::DisplayResource(VoyeurEngine *vm) { void DisplayResource::sFillBox(int width, int height) { assert(_vm); - bool saveBack = _vm->_graphicsManager->_saveBack; - _vm->_graphicsManager->_saveBack = false; + bool saveBack = _vm->_screen->_saveBack; + _vm->_screen->_saveBack = false; PictureResource pr; pr._flags = DISPFLAG_1; pr._select = 0xff; pr._pick = 0; - pr._onOff = _vm->_graphicsManager->_drawPtr->_penColor; + pr._onOff = _vm->_screen->_drawPtr->_penColor; pr._bounds = Common::Rect(0, 0, width, height); - _vm->_graphicsManager->sDrawPic(&pr, this, _vm->_graphicsManager->_drawPtr->_pos); - _vm->_graphicsManager->_saveBack = saveBack; + _vm->_screen->sDrawPic(&pr, this, _vm->_screen->_drawPtr->_pos); + _vm->_screen->_saveBack = saveBack; } bool DisplayResource::clipRect(Common::Rect &rect) { Common::Rect clippingRect; - if (_vm->_graphicsManager->_clipPtr) { - clippingRect = *_vm->_graphicsManager->_clipPtr; + if (_vm->_screen->_clipPtr) { + clippingRect = *_vm->_screen->_clipPtr; } else if (_flags & DISPFLAG_VIEWPORT) { clippingRect = ((ViewPortResource *)this)->_clipRect; } else { @@ -804,18 +804,18 @@ bool DisplayResource::clipRect(Common::Rect &rect) { } int DisplayResource::drawText(const Common::String &msg) { - GraphicsManager &gfxManager = *_vm->_graphicsManager; - assert(gfxManager._fontPtr); - assert(gfxManager._fontPtr->_curFont); - FontInfoResource &fontInfo = *gfxManager._fontPtr; - PictureResource &fontChar = *_vm->_graphicsManager->_fontChar; + Screen &screen = *_vm->_screen; + assert(screen._fontPtr); + assert(screen._fontPtr->_curFont); + FontInfoResource &fontInfo = *screen._fontPtr; + PictureResource &fontChar = *_vm->_screen->_fontChar; FontResource &fontData = *fontInfo._curFont; int xShadows[9] = { 0, 1, 1, 1, 0, -1, -1, -1, 0 }; int yShadows[9] = { 0, 1, 0, -1, -1, -1, 0, 1, 1 }; - Common::Rect *clipPtr = gfxManager._clipPtr; + Common::Rect *clipPtr = screen._clipPtr; if (!(fontInfo._picFlags & DISPFLAG_1)) - gfxManager._clipPtr = NULL; + screen._clipPtr = NULL; int minChar = fontData._minChar; int padding = fontData._padding; @@ -834,7 +834,7 @@ int DisplayResource::drawText(const Common::String &msg) { (ViewPortResource *)this; if ((fontInfo._fontFlags & DISPFLAG_1) || fontInfo._justify || - (gfxManager._saveBack && fontInfo._fontSaveBack && (_flags & DISPFLAG_VIEWPORT))) { + (screen._saveBack && fontInfo._fontSaveBack && (_flags & DISPFLAG_VIEWPORT))) { msgWidth = viewPort->textWidth(msg); yp = pos.y; xp = pos.x; @@ -898,18 +898,18 @@ int DisplayResource::drawText(const Common::String &msg) { } } - if (gfxManager._saveBack && fontInfo._fontSaveBack && (_flags & DISPFLAG_VIEWPORT)) { + if (screen._saveBack && fontInfo._fontSaveBack && (_flags & DISPFLAG_VIEWPORT)) { viewPort->addSaveRect(viewPort->_pageIndex, viewPort->_fontRect); } if (fontInfo._fontFlags & DISPFLAG_1) { - gfxManager._drawPtr->_pos = Common::Point(viewPort->_fontRect.left, viewPort->_fontRect.top); - gfxManager._drawPtr->_penColor = fontInfo._backColor; + screen._drawPtr->_pos = Common::Point(viewPort->_fontRect.left, viewPort->_fontRect.top); + screen._drawPtr->_penColor = fontInfo._backColor; sFillBox(viewPort->_fontRect.width(), viewPort->_fontRect.height()); } - bool saveBack = gfxManager._saveBack; - gfxManager._saveBack = false; + bool saveBack = screen._saveBack; + screen._saveBack = false; int count = 0; if (fontInfo._fontFlags & DISPFLAG_4) @@ -970,7 +970,7 @@ int DisplayResource::drawText(const Common::String &msg) { uint16 offset = READ_LE_UINT16(fontData._charOffsets + charValue * 2); fontChar._imgData = fontData._charImages + offset * 2; - gfxManager.sDrawPic(&fontChar, this, Common::Point(xp, yp)); + screen.sDrawPic(&fontChar, this, Common::Point(xp, yp)); fontChar._imgData = NULL; xp += charWidth + padding; @@ -982,8 +982,8 @@ int DisplayResource::drawText(const Common::String &msg) { if (fontInfo._justify == ALIGN_LEFT) fontInfo._pos.x = xp; - gfxManager._saveBack = saveBack; - gfxManager._clipPtr = clipPtr; + screen._saveBack = saveBack; + screen._clipPtr = clipPtr; return msgWidth; } @@ -993,7 +993,7 @@ int DisplayResource::textWidth(const Common::String &msg) { return 0; const char *msgP = msg.c_str(); - FontResource &fontData = *_vm->_graphicsManager->_fontPtr->_curFont; + FontResource &fontData = *_vm->_screen->_fontPtr->_curFont; int minChar = fontData._minChar; int maxChar = fontData._maxChar; int padding = fontData._padding; @@ -1085,9 +1085,9 @@ PictureResource::PictureResource(BoltFilesState &state, const byte *src): mode = 226; } - if (mode != state._vm->_graphicsManager->_SVGAMode) { - state._vm->_graphicsManager->_SVGAMode = mode; - state._vm->_graphicsManager->clearPalette(); + if (mode != state._vm->_screen->_SVGAMode) { + state._vm->_screen->_SVGAMode = mode; + state._vm->_screen->clearPalette(); } int screenOffset = READ_LE_UINT32(&src[18]) & 0xffff; @@ -1096,13 +1096,14 @@ PictureResource::PictureResource(BoltFilesState &state, const byte *src): if (_flags & PICFLAG_CLEAR_SCREEN) { // Clear screen picture. That's right. This game actually has a picture // resource flag to clear the screen! Bizarre. - Graphics::Surface &s = state._vm->_graphicsManager->_screenSurface; - s.fillRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); + state._vm->_screen->clear(); } else { // Direct screen loading picture. In this case, the raw data of the resource // is directly decompressed into the screen surface. Again, bizarre. - byte *pDest = (byte *)state._vm->_graphicsManager->_screenSurface.getPixels(); + Screen &screen = *state._vm->_screen; + byte *pDest = (byte *)screen.getPixels(); state.decompress(pDest, SCREEN_WIDTH * SCREEN_HEIGHT, state._curMemberPtr->_mode); + screen.markAllDirty(); } } else { if (_flags & PICFLAG_CLEAR_SCREEN00) { @@ -1249,13 +1250,13 @@ ViewPortResource::ViewPortResource(BoltFilesState &state, const byte *src): ys + READ_LE_UINT16(src + 0x4C)); state._curLibPtr->resolveIt(READ_LE_UINT32(src + 0x7A), &dummy); - state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x7E), (GraphicMethodPtr *)&_fn1); - state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x82), (GraphicMethodPtr *)&_setupFn); - state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x86), (GraphicMethodPtr *)&_addFn); - state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x8A), (GraphicMethodPtr *)&_restoreFn); + state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x7E), (ScreenMethodPtr *)&_fn1); + state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x82), (ScreenMethodPtr *)&_setupFn); + state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x86), (ScreenMethodPtr *)&_addFn); + state._curLibPtr->resolveFunction(READ_LE_UINT32(src + 0x8A), (ScreenMethodPtr *)&_restoreFn); if (!_restoreFn && _addFn) - _addFn = &GraphicsManager::addRectNoSaveBack; + _addFn = &Screen::addRectNoSaveBack; } ViewPortResource::~ViewPortResource() { @@ -1327,19 +1328,19 @@ void ViewPortResource::setupViewPort(PictureResource *page, Common::Rect *clippi _restoreFn = restoreFn; if (setupFn) - (_state._vm->_graphicsManager->*setupFn)(this); + (_state._vm->_screen->*setupFn)(this); } void ViewPortResource::setupViewPort() { - setupViewPort(_state._vm->_graphicsManager->_backgroundPage, NULL, - &GraphicsManager::setupMCGASaveRect, &GraphicsManager::addRectOptSaveRect, - &GraphicsManager::restoreMCGASaveRect); + setupViewPort(_state._vm->_screen->_backgroundPage, NULL, + &Screen::setupMCGASaveRect, &Screen::addRectOptSaveRect, + &Screen::restoreMCGASaveRect); } void ViewPortResource::setupViewPort(PictureResource *pic, Common::Rect *clippingRect) { setupViewPort(pic, clippingRect, - &GraphicsManager::setupMCGASaveRect, &GraphicsManager::addRectOptSaveRect, - &GraphicsManager::restoreMCGASaveRect); + &Screen::setupMCGASaveRect, &Screen::addRectOptSaveRect, + &Screen::restoreMCGASaveRect); } void ViewPortResource::addSaveRect(int pageIndex, const Common::Rect &r) { @@ -1347,7 +1348,7 @@ void ViewPortResource::addSaveRect(int pageIndex, const Common::Rect &r) { if (clipRect(rect)) { if (_addFn) { - (_state._vm->_graphicsManager->*_addFn)(this, pageIndex, rect); + (_state._vm->_screen->*_addFn)(this, pageIndex, rect); } else if (_rectListCount[pageIndex] != -1) { _rectListPtr[pageIndex]->push_back(rect); } @@ -1355,26 +1356,26 @@ void ViewPortResource::addSaveRect(int pageIndex, const Common::Rect &r) { } void ViewPortResource::fillPic(byte onOff) { - _state._vm->_graphicsManager->fillPic(this, onOff); + _state._vm->_screen->fillPic(this, onOff); } void ViewPortResource::drawIfaceTime() { // Hour display - _state._vm->_graphicsManager->drawANumber(_state._vm->_graphicsManager->_vPort, + _state._vm->_screen->drawANumber(_state._vm->_screen->_vPort, (_state._vm->_gameHour / 10) == 0 ? 10 : _state._vm->_gameHour / 10, Common::Point(161, 25)); - _state._vm->_graphicsManager->drawANumber(_state._vm->_graphicsManager->_vPort, + _state._vm->_screen->drawANumber(_state._vm->_screen->_vPort, _state._vm->_gameHour % 10, Common::Point(172, 25)); // Minute display - _state._vm->_graphicsManager->drawANumber(_state._vm->_graphicsManager->_vPort, + _state._vm->_screen->drawANumber(_state._vm->_screen->_vPort, _state._vm->_gameMinute / 10, Common::Point(190, 25)); - _state._vm->_graphicsManager->drawANumber(_state._vm->_graphicsManager->_vPort, + _state._vm->_screen->drawANumber(_state._vm->_screen->_vPort, _state._vm->_gameMinute % 10, Common::Point(201, 25)); // AM/PM indicator PictureResource *pic = _state._vm->_bVoy->boltEntry(_state._vm->_voy->_isAM ? 272 : 273)._picResource; - _state._vm->_graphicsManager->sDrawPic(pic, _state._vm->_graphicsManager->_vPort, + _state._vm->_screen->sDrawPic(pic, _state._vm->_screen->_vPort, Common::Point(215, 27)); } @@ -1382,9 +1383,9 @@ void ViewPortResource::drawPicPerm(PictureResource *pic, const Common::Point &pt Common::Rect bounds = pic->_bounds; bounds.translate(pt.x, pt.y); - bool saveBack = _state._vm->_graphicsManager->_saveBack; - _state._vm->_graphicsManager->_saveBack = false; - _state._vm->_graphicsManager->sDrawPic(pic, this, pt); + bool saveBack = _state._vm->_screen->_saveBack; + _state._vm->_screen->_saveBack = false; + _state._vm->_screen->sDrawPic(pic, this, pt); clipRect(bounds); for (int pageIndex = 0; pageIndex < _pageCount; ++pageIndex) { @@ -1393,7 +1394,7 @@ void ViewPortResource::drawPicPerm(PictureResource *pic, const Common::Point &pt } } - _state._vm->_graphicsManager->_saveBack = saveBack; + _state._vm->_screen->_saveBack = saveBack; } /*------------------------------------------------------------------------*/ @@ -1526,7 +1527,7 @@ CMapResource::CMapResource(BoltFilesState &state, const byte *src): _vm(state._v _entries = new byte[count * 3]; Common::copy(src + 6, src + 6 + 3 * count, _entries); - int palIndex = state._vm->_graphicsManager->_viewPortListPtr->_palIndex; + int palIndex = state._vm->_screen->_viewPortListPtr->_palIndex; if (_end > palIndex) _end = palIndex; if (_start > palIndex) diff --git a/engines/voyeur/files.h b/engines/voyeur/files.h index eef5df497c..8726b38ddf 100644 --- a/engines/voyeur/files.h +++ b/engines/voyeur/files.h @@ -27,7 +27,7 @@ #include "common/file.h" #include "common/rect.h" #include "common/str.h" -#include "voyeur/graphics.h" +#include "voyeur/screen.h" namespace Voyeur { @@ -112,7 +112,7 @@ public: byte *memberAddr(uint32 id); byte *memberAddrOffset(uint32 id); void resolveIt(uint32 id, byte **p); - void resolveFunction(uint32 id, GraphicMethodPtr *fn); + void resolveFunction(uint32 id, ScreenMethodPtr *fn); BoltEntry &boltEntry(uint16 id); BoltEntry &getBoltEntryFromLong(uint32 id); @@ -340,7 +340,7 @@ public: int _rectListCount[3]; Common::Rect _clipRect; - GraphicMethodPtr _fn1; + ScreenMethodPtr _fn1; ViewPortSetupPtr _setupFn; ViewPortAddPtr _addFn; ViewPortRestorePtr _restoreFn; diff --git a/engines/voyeur/files_threads.cpp b/engines/voyeur/files_threads.cpp index 9908324043..bbd3dfe4e9 100644 --- a/engines/voyeur/files_threads.cpp +++ b/engines/voyeur/files_threads.cpp @@ -21,7 +21,7 @@ */ #include "voyeur/files.h" -#include "voyeur/graphics.h" +#include "voyeur/screen.h" #include "voyeur/voyeur.h" #include "voyeur/staticres.h" @@ -461,7 +461,7 @@ void ThreadResource::parsePlayCommands() { pic = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + i * 2)._picResource; pal = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + i * 2 + 1)._cMapResource; - _vm->_graphicsManager->_vPort->setupViewPort(pic); + _vm->_screen->_vPort->setupViewPort(pic); pal->startFade(); _vm->flipPageAndWaitForFade(); @@ -980,10 +980,10 @@ int ThreadResource::doApt() { _vm->_soundManager->startVOCPlay(_vm->_soundManager->getVOCFileName(_vm->_currentVocId)); _vm->_currentVocId = 151; - _vm->_graphicsManager->setColor(129, 82, 82, 82); - _vm->_graphicsManager->setColor(130, 112, 112, 112); - _vm->_graphicsManager->setColor(131, 215, 215, 215); - _vm->_graphicsManager->setColor(132, 235, 235, 235); + _vm->_screen->setColor(129, 82, 82, 82); + _vm->_screen->setColor(130, 112, 112, 112); + _vm->_screen->setColor(131, 215, 215, 215); + _vm->_screen->setColor(132, 235, 235, 235); _vm->_eventsManager->_intPtr._hasPalette = true; @@ -1044,7 +1044,7 @@ int ThreadResource::doApt() { // Draw the text description for the highlighted hotspot pic = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + hotspotId + 6)._picResource; - _vm->_graphicsManager->sDrawPic(pic, _vm->_graphicsManager->_vPort, + _vm->_screen->sDrawPic(pic, _vm->_screen->_vPort, Common::Point(106, 200)); } @@ -1112,10 +1112,10 @@ void ThreadResource::doRoom() { if (!vm._bVoy->getBoltGroup(vm._playStampGroupId)) return; - vm._graphicsManager->_backColors = vm._bVoy->boltEntry(vm._playStampGroupId + 1)._cMapResource; - vm._graphicsManager->_backgroundPage = vm._bVoy->boltEntry(vm._playStampGroupId)._picResource; - vm._graphicsManager->_vPort->setupViewPort(vm._graphicsManager->_backgroundPage); - vm._graphicsManager->_backColors->startFade(); + vm._screen->_backColors = vm._bVoy->boltEntry(vm._playStampGroupId + 1)._cMapResource; + vm._screen->_backgroundPage = vm._bVoy->boltEntry(vm._playStampGroupId)._picResource; + vm._screen->_vPort->setupViewPort(vm._screen->_backgroundPage); + vm._screen->_backColors->startFade(); voy._fadingStep1 = 2; voy._fadingStep2 = 0; @@ -1144,7 +1144,7 @@ void ThreadResource::doRoom() { bool breakFlag = false; while (!vm.shouldQuit() && !breakFlag) { _vm->_voyeurArea = AREA_ROOM; - vm._graphicsManager->setColor(128, 0, 255, 0); + vm._screen->setColor(128, 0, 255, 0); vm._eventsManager->_intPtr._hasPalette = true; do { @@ -1186,7 +1186,7 @@ void ThreadResource::doRoom() { } vm._eventsManager->_intPtr._hasPalette = true; - vm._graphicsManager->flipPage(); + vm._screen->flipPage(); vm._eventsManager->sWaitFlip(); } while (!vm.shouldQuit() && !vm._eventsManager->_mouseClicked); @@ -1234,13 +1234,13 @@ void ThreadResource::doRoom() { // WORKAROUND: Skipped code from the original, that freed the group, // reloaded it, and reloaded the cursors - vm._graphicsManager->_backColors = vm._bVoy->boltEntry( + vm._screen->_backColors = vm._bVoy->boltEntry( vm._playStampGroupId + 1)._cMapResource; - vm._graphicsManager->_backgroundPage = vm._bVoy->boltEntry( + vm._screen->_backgroundPage = vm._bVoy->boltEntry( vm._playStampGroupId)._picResource; - vm._graphicsManager->_vPort->setupViewPort(); - vm._graphicsManager->_backColors->startFade(); + vm._screen->_vPort->setupViewPort(); + vm._screen->_backColors->startFade(); _vm->flipPageAndWait(); while (!vm.shouldQuit() && (vm._eventsManager->_fadeStatus & 1)) @@ -1265,7 +1265,7 @@ void ThreadResource::doRoom() { _vm->flipPageAndWait(); - vm._graphicsManager->fadeUpICF1(); + vm._screen->fadeUpICF1(); voy._eventFlags &= EVTFLAG_RECORDING; vm._eventsManager->showCursor(); } @@ -1350,7 +1350,7 @@ int ThreadResource::doInterface() { _vm->_soundManager->startVOCPlay(fname); _vm->_eventsManager->getMouseInfo(); - _vm->_graphicsManager->setColor(240, 220, 220, 220); + _vm->_screen->setColor(240, 220, 220, 220); _vm->_eventsManager->_intPtr._hasPalette = true; _vm->_voy->_eventFlags &= ~EVTFLAG_TIME_DISABLED; @@ -1424,20 +1424,20 @@ int ThreadResource::doInterface() { // Regularly update the time display if (_vm->_voy->_RTANum & 2) { - _vm->_graphicsManager->drawANumber(_vm->_graphicsManager->_vPort, + _vm->_screen->drawANumber(_vm->_screen->_vPort, _vm->_gameMinute / 10, Common::Point(190, 25)); - _vm->_graphicsManager->drawANumber(_vm->_graphicsManager->_vPort, + _vm->_screen->drawANumber(_vm->_screen->_vPort, _vm->_gameMinute % 10, Common::Point(201, 25)); if (_vm->_voy->_RTANum & 4) { int v = _vm->_gameHour / 10; - _vm->_graphicsManager->drawANumber(_vm->_graphicsManager->_vPort, + _vm->_screen->drawANumber(_vm->_screen->_vPort, v == 0 ? 10 : v, Common::Point(161, 25)); - _vm->_graphicsManager->drawANumber(_vm->_graphicsManager->_vPort, + _vm->_screen->drawANumber(_vm->_screen->_vPort, _vm->_gameHour % 10, Common::Point(172, 25)); pic = _vm->_bVoy->boltEntry(_vm->_voy->_isAM ? 272 : 273)._picResource; - _vm->_graphicsManager->sDrawPic(pic, _vm->_graphicsManager->_vPort, + _vm->_screen->sDrawPic(pic, _vm->_screen->_vPort, Common::Point(215, 27)); } } @@ -1605,16 +1605,16 @@ void ThreadResource::loadTheApt() { _vm->_bVoy->getBoltGroup(_vm->_playStampGroupId); _vm->_voy->_aptLoadMode = -1; - _vm->_graphicsManager->_backgroundPage = _vm->_bVoy->boltEntry( + _vm->_screen->_backgroundPage = _vm->_bVoy->boltEntry( _vm->_playStampGroupId + 5)._picResource; - _vm->_graphicsManager->_vPort->setupViewPort( - _vm->_graphicsManager->_backgroundPage); + _vm->_screen->_vPort->setupViewPort( + _vm->_screen->_backgroundPage); } else { _vm->_bVoy->getBoltGroup(_vm->_playStampGroupId); - _vm->_graphicsManager->_backgroundPage = _vm->_bVoy->boltEntry( + _vm->_screen->_backgroundPage = _vm->_bVoy->boltEntry( _vm->_playStampGroupId + 5)._picResource; - _vm->_graphicsManager->_vPort->setupViewPort( - _vm->_graphicsManager->_backgroundPage); + _vm->_screen->_vPort->setupViewPort( + _vm->_screen->_backgroundPage); } CMapResource *pal = _vm->_bVoy->boltEntry(_vm->_playStampGroupId + 4)._cMapResource; @@ -1624,10 +1624,10 @@ void ThreadResource::loadTheApt() { } void ThreadResource::freeTheApt() { - _vm->_graphicsManager->fadeDownICF1(5); + _vm->_screen->fadeDownICF1(5); _vm->flipPageAndWaitForFade(); - _vm->_graphicsManager->fadeUpICF1(); + _vm->_screen->fadeUpICF1(); if (_vm->_currentVocId != -1) { _vm->_soundManager->stopVOCPlay(); @@ -1635,17 +1635,17 @@ void ThreadResource::freeTheApt() { } if (_vm->_voy->_aptLoadMode == -1) { - _vm->_graphicsManager->fadeDownICF(6); + _vm->_screen->fadeDownICF(6); } else { doAptAnim(2); } if (_vm->_voy->_aptLoadMode == 140) { - _vm->_graphicsManager->screenReset(); - _vm->_graphicsManager->resetPalette(); + _vm->_screen->screenReset(); + _vm->_screen->resetPalette(); } - _vm->_graphicsManager->_vPort->setupViewPort(nullptr); + _vm->_screen->_vPort->setupViewPort(nullptr); _vm->_bVoy->freeBoltGroup(_vm->_playStampGroupId); _vm->_playStampGroupId = -1; _vm->_voy->_viewBounds = nullptr; @@ -1705,7 +1705,7 @@ void ThreadResource::doAptAnim(int mode) { for (int idx = 0; (idx < 6) && !_vm->shouldQuit(); ++idx) { PictureResource *pic = _vm->_bVoy->boltEntry(id + idx + 1)._picResource; - _vm->_graphicsManager->_vPort->setupViewPort(pic); + _vm->_screen->_vPort->setupViewPort(pic); pal->startFade(); _vm->flipPageAndWait(); diff --git a/engines/voyeur/graphics.cpp b/engines/voyeur/graphics.cpp deleted file mode 100644 index a20e9f6006..0000000000 --- a/engines/voyeur/graphics.cpp +++ /dev/null @@ -1,1051 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "voyeur/graphics.h" -#include "voyeur/voyeur.h" -#include "voyeur/staticres.h" -#include "engines/util.h" -#include "graphics/palette.h" -#include "graphics/surface.h" - -namespace Voyeur { - -/*------------------------------------------------------------------------*/ - -DrawInfo::DrawInfo(int penColor, const Common::Point &pos) { - _penColor = penColor; - _pos = pos; -} - -/*------------------------------------------------------------------------*/ - -GraphicsManager::GraphicsManager(VoyeurEngine *vm) : _defaultDrawInfo(1, Common::Point()), _drawPtr(&_defaultDrawInfo), _vm(vm) { - _SVGAMode = 0; - _planeSelect = 0; - _saveBack = true; - _clipPtr = NULL; - _viewPortListPtr = NULL; - _backgroundPage = NULL; - _vPort = NULL; - _fontPtr = NULL; - Common::fill(&_VGAColors[0], &_VGAColors[PALETTE_SIZE], 0); - _fontChar = new PictureResource(DISPFLAG_NONE, 0xff, 0xff, 0, Common::Rect(), 0, NULL, 0); - _backColors = nullptr; -} - -void GraphicsManager::sInitGraphics() { - initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, false); - _screenSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT, Graphics::PixelFormat::createFormatCLUT8()); - clearPalette(); -} - -GraphicsManager::~GraphicsManager() { - _screenSurface.free(); - delete _fontChar; -} - -void GraphicsManager::setupMCGASaveRect(ViewPortResource *viewPort) { - if (viewPort->_activePage) { - viewPort->_activePage->_flags |= DISPFLAG_1; - Common::Rect *clipRect = _clipPtr; - _clipPtr = &viewPort->_clipRect; - - sDrawPic(viewPort->_activePage, viewPort->_currentPic, Common::Point()); - - _clipPtr = clipRect; - } - - viewPort->_rectListCount[1] = -1; -} - -void GraphicsManager::addRectOptSaveRect(ViewPortResource *viewPort, int idx, const Common::Rect &bounds) { - if (viewPort->_rectListCount[idx] == -1) - return; - - // TODO: Lots of code in original, which I suspect may be overlapping rect merging - viewPort->_rectListPtr[idx]->push_back(bounds); - ++viewPort->_rectListCount[idx]; -} - -void GraphicsManager::restoreMCGASaveRect(ViewPortResource *viewPort) { - if (viewPort->_rectListCount[0] != -1) { - for (int i = 0; i < viewPort->_rectListCount[0]; ++i) { - addRectOptSaveRect(viewPort, 1, (*viewPort->_rectListPtr[0])[i]); - } - } else { - viewPort->_rectListCount[1] = -1; - } - - restoreBack(*viewPort->_rectListPtr[1], viewPort->_rectListCount[1], viewPort->_pages[0], - viewPort->_pages[1]); - - int count = viewPort->_rectListCount[0]; - restoreBack(*viewPort->_rectListPtr[0], viewPort->_rectListCount[0], - viewPort->_activePage, viewPort->_currentPic); - - SWAP(viewPort->_rectListPtr[0], viewPort->_rectListPtr[1]); - viewPort->_rectListCount[1] = count; -} - -void GraphicsManager::addRectNoSaveBack(ViewPortResource *viewPort, int idx, const Common::Rect &bounds) { - // Stubbed/dummy method in the original. -} - -void GraphicsManager::sDrawPic(DisplayResource *srcDisplay, DisplayResource *destDisplay, - const Common::Point &initialOffset) { - int width1, width2; - int widthDiff, widthDiff2; - int height1; - int srcOffset; - int screenOffset; - int srcFlags, destFlags; - ViewPortResource *destViewPort = NULL; - Common::Rect newBounds; - Common::Rect backBounds; - int tmpWidth = 0; - int tmpHeight = 0; - bool isClipped = false; - byte pixel = 0; - int runLength; - - byte *srcImgData, *destImgData; - byte *srcP, *destP; - byte byteVal, byteVal2; - - PictureResource *srcPic; - PictureResource *destPic; - - // Get the picture parameters, or deference viewport pointers to get their pictures - if (srcDisplay->_flags & DISPFLAG_VIEWPORT) { - // A viewport was passed, not a picture - srcPic = ((ViewPortResource *)srcDisplay)->_currentPic; - } else { - srcPic = (PictureResource *)srcDisplay; - } - - if (destDisplay->_flags & DISPFLAG_VIEWPORT) { - // A viewport was passed, not a picture - destViewPort = (ViewPortResource *)destDisplay; - destPic = destViewPort->_currentPic; - } else { - destPic = (PictureResource *)destDisplay; - } - - Common::Point offset = Common::Point(initialOffset.x + srcPic->_bounds.left - destPic->_bounds.left, - initialOffset.y + srcPic->_bounds.top - destPic->_bounds.top); - width1 = width2 = srcPic->_bounds.width(); - height1 = srcPic->_bounds.height(); - srcOffset = 0; - srcFlags = srcPic->_flags; - destFlags = destPic->_flags; - byte *cursorData = NULL; - - if (srcFlags & DISPFLAG_1) { - if (_clipPtr) { - int xs = _clipPtr->left - destPic->_bounds.left; - int ys = _clipPtr->top - destPic->_bounds.top; - newBounds = Common::Rect(xs, ys, xs + _clipPtr->width(), ys + _clipPtr->height()); - } else if (destViewPort) { - int xs = destViewPort->_clipRect.left - destPic->_bounds.left; - int ys = destViewPort->_clipRect.top - destPic->_bounds.top; - newBounds = Common::Rect(xs, ys, xs + destViewPort->_clipRect.width(), - ys + destViewPort->_clipRect.height()); - } else { - newBounds = Common::Rect(0, 0, destPic->_bounds.width(), destPic->_bounds.height()); - } - - tmpHeight = offset.y - newBounds.top; - if (tmpHeight < 0) { - srcOffset -= tmpHeight * width2; - height1 += tmpHeight; - offset.y = newBounds.top; - - if (height1 <= 0) - return; - - isClipped = true; - } - - int yMin = newBounds.bottom - (offset.y + height1); - if (yMin < 0) { - height1 += yMin; - if (height1 <= 0) - return; - } - - tmpWidth = offset.x - newBounds.left; - if (tmpWidth < 0) { - srcOffset -= tmpWidth; - width2 += tmpWidth; - offset.x = newBounds.left; - - if (width2 <= 0) - return; - - isClipped = true; - } - - int xMin = newBounds.right - (offset.x + width2); - if (xMin < 0) { - width2 += xMin; - if (width2 <= 0) - return; - - isClipped = true; - } - } - - screenOffset = offset.y * destPic->_bounds.width() + offset.x; - widthDiff = width1 - width2; - widthDiff2 = destPic->_bounds.width() - width2; - - if (destViewPort) { - if (!_saveBack || (srcPic->_flags & DISPFLAG_800)) { - backBounds.left = destPic->_bounds.left + offset.x; - backBounds.top = destPic->_bounds.top + offset.y; - backBounds.setWidth(width2); - backBounds.setHeight(height1); - addRectOptSaveRect(destViewPort, 1, backBounds); - - } else if (!destViewPort->_addFn) { - if (destViewPort->_rectListCount[destViewPort->_pageIndex] < -1) { - Common::Rect r; - r.left = destPic->_bounds.left + offset.x; - r.top = destPic->_bounds.top + offset.y; - r.setWidth(width2); - r.setHeight(height1); - - (*destViewPort->_rectListPtr[destViewPort->_pageIndex]).push_back(r); - ++destViewPort->_rectListCount[destViewPort->_pageIndex]; - } - } else { - int xs = offset.x + destPic->_bounds.left; - int ys = offset.y + destPic->_bounds.top; - backBounds = Common::Rect(xs, ys, xs + width2, ys + height1); - - (this->*destViewPort->_addFn)(destViewPort, destViewPort->_bounds.top, backBounds); - } - } - - if (srcFlags & DISPFLAG_1000) { - int imageDataShift = 0; - srcImgData = srcPic->_imgData + (imageDataShift << 14); - for (uint idx = 0; idx < srcPic->_maskData; ++idx) { - if (imageDataShift < 4) - ++imageDataShift; - } - - destImgData = destPic->_imgData + (imageDataShift << 14); - for (uint idx = 0; idx < srcPic->_maskData; ++idx) { - if (imageDataShift < 4) - ++imageDataShift; - } - } else { - srcImgData = srcPic->_imgData; - destImgData = destPic->_imgData; - } - - if (srcPic->_select != 0xff) - return; - - if (destFlags & DISPFLAG_CURSOR) { - cursorData = new byte[width2 * height1]; - Common::fill(cursorData, cursorData + width2 * height1, 0); - destImgData = cursorData; - } - - if (srcPic->_pick == 0xff) { - if (srcFlags & DISPFLAG_8) { - error("TODO: sDrawPic variation"); - } else { - // loc_258B8 - srcP = srcImgData + srcOffset; - - if (destFlags & DISPFLAG_8) { - // loc_258D8 - destP = destImgData + screenOffset; - - if (srcFlags & DISPFLAG_2) { - // loc_25652 - srcP = srcImgData + srcOffset; - - if (destFlags & DISPFLAG_8) { - // loc_2566F - if (srcFlags & DISPFLAG_2) { - // loc_256FA - srcP = (byte *)_screenSurface.getPixels() + srcOffset; - - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { - pixel = *srcP; - if (pixel) - *destP = pixel; - } - - srcP += widthDiff; - destP += widthDiff2; - } - } else { - // loc_25706 - for (int yp = 0; yp < height1; ++yp) { - Common::copy(srcP, srcP + width2, destP); - srcP += width2 + widthDiff; - destP += width2 + widthDiff2; - } - } - } else { - // loc_25773 - destP = destImgData + screenOffset; - - if (srcFlags & DISPFLAG_2) { - // loc_25793 - for (int yp = 0; yp < height1; ++yp) { - Common::copy(srcP, srcP + width2, destP); - srcP += width2 + widthDiff; - destP += width2 + widthDiff2; - } - } else { - // loc_25829 - destP = (byte *)_screenSurface.getPixels() + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - Common::copy(srcP, srcP + width2, destP); - srcP += width2 + widthDiff; - destP += width2 + widthDiff2; - } - } - } - } else { - // loc_25D40 - if (srcFlags & DISPFLAG_100) { - // loc_25D4A - error("TODO: sDrawPic variation"); - } else { - // loc_2606D - destP = (byte *)_screenSurface.getPixels() + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - Common::copy(srcP, srcP + width2, destP); - destP += width2 + widthDiff2; - srcP += width2 + widthDiff; - } - } - } - } else { - // loc_2615E - destP = destImgData + screenOffset; - - if (srcFlags & DISPFLAG_2) { - // loc_2617e - if (srcFlags & DISPFLAG_100) { - // loc_26188 - srcP = srcImgData; - if (isClipped) { - // loc_26199 - tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; - int xMax = tmpWidth + width2; - tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; - - width2 = srcPic->_bounds.width(); - height1 = tmpHeight + height1; - - for (int yp = 0; yp < height1; ++yp) { - runLength = 0; - - for (int xp = 0; xp < width2; ++xp, --runLength) { - if (runLength <= 0) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7f; - runLength = *srcP++; - if (!runLength) - runLength = width2; - } - } - - if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { - if (pixel > 0) - *destP = pixel; - ++destP; - } - } - - if (yp >= tmpHeight) - destP += widthDiff2; - } - } else { - // loc_262BE - byteVal = 0; - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp) { - byteVal2 = 0; - if (!byteVal2) { - byteVal = *++srcP; - if (byteVal & 0x80) { - byteVal &= 0x7f; - byteVal2 = *srcP++; - - if (!byteVal2) - byteVal2 = width2; - } - } - - if (byteVal > 0) - *destP = byteVal; - - ++destP; - --byteVal2; - } - - destP += widthDiff2; - } - } - } else { - // loc_2637F - // Copy with transparency - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { - if (*srcP != 0) - *destP = *srcP; - } - - destP += widthDiff2; - srcP += widthDiff; - } - } - } else { - if (srcFlags & DISPFLAG_100) { - // Simple run-length encoded image - srcP = srcImgData; - - if (isClipped) { - // loc_26424 - tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; - int xMax = tmpWidth + width2; - tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; - width2 = srcPic->_bounds.width(); - height1 = tmpHeight + height1; - - for (int yp = 0; yp < height1; ++yp) { - runLength = 0; - for (int xp = 0; xp < width2; ++xp, --runLength) { - if (runLength <= 0) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - runLength = *srcP++; - - if (!runLength) - runLength = width2; - } - } - - if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { - *destP++ = pixel; - } - } - - if (yp >= tmpHeight) - destP += widthDiff2; - } - } else { - // loc_26543 - for (int yp = 0; yp < height1; ++yp) { - int runLen = 0; - for (int xp = 0; xp < width2; ++xp, --runLen) { - if (runLen <= 0) { - // Start of run length, so get pixel and repeat length - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7f; - runLen = *srcP++; - if (runLen == 0) - runLen = width2; - } - } - - // Copy pixel to output - *destP++ = pixel; - } - - destP += widthDiff2; - } - } - } else { - for (int yp = 0; yp < height1; ++yp) { - Common::copy(srcP, srcP + width2, destP); - destP += width2 + widthDiff2; - srcP += width2 + widthDiff; - } - } - } - } - } - } else { - // loc_26666 - if (srcPic->_pick == 0) { - // loc_2727A - byte onOff = srcPic->_onOff; - - if (srcFlags & DISPFLAG_2) { - if (!(srcFlags & DISPFLAG_8)) { - srcP = srcImgData + srcOffset; - - if (destFlags & DISPFLAG_8) { - // loc_272C3 - error("TODO: sDrawPic variation"); - } else { - destP = destImgData + screenOffset; - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++destP) { - if ((int8)*srcP++ < 0) - *destP = onOff; - } - - destP += widthDiff2; - srcP += widthDiff; - } - } - } - } else { - // loc_27477 - if (destFlags & DISPFLAG_8) { - // loc_27481 - destP = (byte *)_screenSurface.getPixels() + screenOffset; - for (int yp = 0; yp < height1; ++yp) { - Common::fill(destP, destP + width2, onOff); - destP += width2 + widthDiff2; - } - } else { - // loc_2753C - destP = destImgData + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - Common::fill(destP, destP + width2, onOff); - destP += width2 + widthDiff2; - } - } - } - - } else { - // loc_26673 - byte pick = srcPic->_pick; - byte onOff = srcPic->_onOff; - - if (!(srcFlags & PICFLAG_PIC_OFFSET)) { - srcP = srcImgData += srcOffset; - pixel = 0; - - if (destFlags & PICFLAG_PIC_OFFSET) { - destP = destImgData + screenOffset; - if (srcFlags & PICFLAG_2) { - if (srcFlags & PICFLAG_100) { - if (isClipped) { - // loc_266E3 - destP = (byte *)_screenSurface.getPixels() + screenOffset; - tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; - int xMax = tmpWidth + width2; - tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; - pick = 0x7F; - width2 = srcPic->_bounds.width(); - height1 = tmpHeight + height1; - - for (int yp = 0; yp < height1; ++yp) { - int runLen = 0; - for (int xp = 0; xp < width2; ++xp, --runLen) { - if (runLen <= 0) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - runLen = *srcP++; - if (!runLen) - runLen = width2; - } - } - - if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { - if (pixel) { - *destP = (pixel & pick) ^ onOff; - } - ++destP; - } - } - if (yp >= tmpHeight) - destP += widthDiff2; - } - } else { - // loc_26815 - destP = (byte *)_screenSurface.getPixels() + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - for (int xi = 0; xi < width2; ++xi, ++destP) { - byteVal2 = 0; - for (int xp = 0; xp < width2; ++xp, ++destP, --byteVal2) { - if (!byteVal2) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - byteVal2 = *srcP++; - if (!byteVal2) { - byteVal2 = width2; - } - } - } - - if (pixel) - *destP = (pixel & pick) ^ onOff; - } - } - - destP += widthDiff2; - } - } - } else { - // Direct screen write - destP = (byte *)_screenSurface.getPixels() + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { - if (*srcP) - *destP = (*srcP & pick) ^ onOff; - } - destP += widthDiff2; - srcP += widthDiff; - } - } - } else if (srcFlags & PICFLAG_100) { - srcP = srcImgData; - if (isClipped) { - // loc_269FD - tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; - int xMax = tmpWidth + width2; - tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; - width2 = srcPic->_bounds.width(); - height1 = tmpHeight + height1; - - for (int yp = 0; yp < height1; ++yp) { - runLength = 0; - for (int xp = 0; xp < width2; ++xp, --runLength) { - if (runLength <= 0) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - runLength = *srcP++; - - if (!runLength) - runLength = width2; - } - } - - if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { - *destP++ = (pixel & 0x80) ^ onOff; - } - } - } - } else { - // loc_26BD5 - destP = (byte *)_screenSurface.getPixels() + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - byteVal2 = 0; - - for (int xp = 0; xp < width2; ++xp, ++destP) { - if (!byteVal2) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - byteVal2 = *srcP++; - if (!byteVal2) - byteVal2 = width2; - } - } - - *destP = (pixel & pick) ^ onOff; - } - - destP += widthDiff2; - } - } - } else { - // loc_26C9A - destP = (byte *)_screenSurface.getPixels() + screenOffset; - - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { - *destP = (*srcP & pick) ^ onOff; - } - destP += widthDiff2; - srcP += widthDiff; - } - } - } else { - // loc_26D2F - destP = destImgData + screenOffset; - - if (srcFlags & PICFLAG_2) { - // loc_26D4F - if (srcFlags & PICFLAG_100) { - srcP = srcImgData; - - if (isClipped) { - // loc_26D6A - tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; - int xMax = tmpWidth + width2; - tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; - width2 = srcPic->_bounds.width(); - height1 = tmpHeight + height1; - - for (int yp = 0; yp < height1; ++yp) { - runLength = 0; - - for (int xp = 0; xp < width2; ++xp, --runLength) { - if (runLength <= 0) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - runLength = *srcP++; - if (!runLength) - runLength = width2; - } - } - - if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { - if (pixel) - *destP = (pixel & pick) ^ onOff; - - ++destP; - } - } - - if (yp >= tmpHeight) - destP += widthDiff2; - } - } else { - // loc_26E95 - for (int yp = 0; yp < height1; ++yp) { - byteVal2 = 0; - for (int xp = 0; xp < width2; ++xp, ++destP, --byteVal2) { - if (!byteVal2) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - byteVal2 = *srcP++; - if (!byteVal2) - byteVal2 = width2; - } - } - - if (pixel) - *destP = (pixel & pick) ^ onOff; - } - - destP += widthDiff2; - } - } - } else { - // loc_26F5D - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { - if (*srcP) - *destP = (*srcP & pick) ^ onOff; - } - destP += widthDiff2; - srcP += widthDiff; - } - } - } else { - // loc_26FEF - if (srcFlags & PICFLAG_100) { - // loc_26FF9 - for (int yp = 0; yp < height1; ++yp) { - for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { - *destP = (*srcP & pick) ^ onOff; - } - destP += widthDiff2; - srcP += widthDiff; - } - } else { - // loc_271F0 - srcP = srcImgData; - - if (isClipped) { - // loc_2700A - tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; - int xMax = tmpWidth + width2; - tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; - width2 = srcPic->_bounds.width(); - height1 = tmpHeight + height1; - - for (int yp = 0; yp < height1; ++yp) { - runLength = 0; - - for (int xp = 0; xp < width2; ++xp, --runLength) { - if (runLength <= 0) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - runLength = *srcP++; - if (!runLength) - runLength = width2; - } - } - - if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { - *destP++ = (pixel & pick) ^ onOff; - } - } - - if (yp >= tmpHeight) - destP += widthDiff2; - } - } else { - // loc_2712F - for (int yp = 0; yp < height1; ++yp) { - byteVal2 = 0; - for (int xp = 0; xp < width2; ++xp, ++destP, --byteVal2) { - if (!byteVal2) { - pixel = *srcP++; - if (pixel & 0x80) { - pixel &= 0x7F; - byteVal2 = *srcP++; - if (!byteVal2) - byteVal2 = width2; - } - } - - *destP = (*srcP & pick) ^ onOff; - } - destP += widthDiff2; - } - } - } - } - } - } - } - } - - if (cursorData) { - _vm->_eventsManager->setCursor(cursorData, width2, height1, srcPic->_keyColor); - delete[] cursorData; - } -} - -void GraphicsManager::drawANumber(DisplayResource *display, int num, const Common::Point &pt) { - PictureResource *pic = _vm->_bVoy->boltEntry(num + 261)._picResource; - sDrawPic(pic, display, pt); -} - -void GraphicsManager::fillPic(DisplayResource *display, byte onOff) { - PictureResource *pic; - if (display->_flags & DISPFLAG_VIEWPORT) { - pic = ((ViewPortResource *)display)->_currentPic; - } else { - pic = (PictureResource *)display; - } - - PictureResource picResource; - picResource._flags = DISPFLAG_NONE; - picResource._select = 0xff; - picResource._pick = 0; - picResource._onOff = onOff; - picResource._bounds = pic->_bounds; - - sDrawPic(&picResource, display, Common::Point()); -} - -/** - * Queues the given picture for display - */ -void GraphicsManager::sDisplayPic(PictureResource *pic) { - _vm->_eventsManager->_intPtr._flipWait = true; -} - -void GraphicsManager::flipPage() { - Common::Array &viewPorts = _viewPortListPtr->_entries; - bool flipFlag = false; - - for (uint idx = 0; idx < viewPorts.size(); ++idx) { - if ((viewPorts[idx]->_flags & (DISPFLAG_20 | DISPFLAG_8 | DISPFLAG_1)) == (DISPFLAG_20 | DISPFLAG_8 | DISPFLAG_1)) { - if (_planeSelect == idx) - sDisplayPic(viewPorts[idx]->_currentPic); - flipFlag = true; - } - - if (flipFlag) { - ViewPortResource &viewPort = *viewPorts[idx]; - - viewPort._lastPage = viewPort._pageIndex; - ++viewPort._pageIndex; - - if (viewPort._pageIndex >= viewPort._pageCount) - viewPort._pageIndex = 0; - - assert(viewPort._pageIndex < 2); - viewPort._currentPic = viewPort._pages[viewPort._pageIndex]; - viewPort._flags = (viewPort._flags & ~DISPFLAG_8) | DISPFLAG_40; - } - } -} - -void GraphicsManager::restoreBack(Common::Array &rectList, int rectListCount, - PictureResource *srcPic, PictureResource *destPic) { - // WORKAROUND: Since _backgroundPage can point to a resource freed at the end of display methods, - // I'm now explicitly resetting it to null in screenReset(), so at this point it can be null - if (!srcPic) - return; - - bool saveBack = _saveBack; - _saveBack = false; - - if (rectListCount == -1) { - sDrawPic(srcPic, destPic, Common::Point()); - } else { - for (int i = rectListCount - 1; i >= 0; --i) { - _clipPtr = &rectList[i]; - sDrawPic(srcPic, destPic, Common::Point()); - } - } - - _saveBack = saveBack; -} - -void GraphicsManager::clearPalette() { - byte palette[768]; - Common::fill(&palette[0], &palette[768], 0); - g_system->getPaletteManager()->setPalette(&palette[0], 0, 256); -} - -void GraphicsManager::setPalette(const byte *palette, int start, int count) { - g_system->getPaletteManager()->setPalette(palette, start, count); - _vm->_eventsManager->_gameData._hasPalette = false; -} - -void GraphicsManager::setPalette128(const byte *palette, int start, int count) { - byte rgb[3]; - g_system->getPaletteManager()->grabPalette(&rgb[0], 128, 1); - g_system->getPaletteManager()->setPalette(palette, start, count); - g_system->getPaletteManager()->setPalette(&rgb[0], 128, 1); -} - - -void GraphicsManager::resetPalette() { - for (int i = 0; i < 256; ++i) - setColor(i, 0, 0, 0); - - _vm->_eventsManager->_intPtr._hasPalette = true; -} - -void GraphicsManager::setColor(int idx, byte r, byte g, byte b) { - byte *vgaP = &_VGAColors[idx * 3]; - vgaP[0] = r; - vgaP[1] = g; - vgaP[2] = b; - - _vm->_eventsManager->_intPtr._palStartIndex = MIN(_vm->_eventsManager->_intPtr._palStartIndex, idx); - _vm->_eventsManager->_intPtr._palEndIndex = MAX(_vm->_eventsManager->_intPtr._palEndIndex, idx); -} - -void GraphicsManager::setOneColor(int idx, byte r, byte g, byte b) { - byte palEntry[3]; - palEntry[0] = r; - palEntry[1] = g; - palEntry[2] = b; - g_system->getPaletteManager()->setPalette(&palEntry[0], idx, 1); -} - -void GraphicsManager::setColors(int start, int count, const byte *pal) { - for (int i = 0; i < count; ++i) { - if ((i + start) != 128) { - const byte *rgb = pal + i * 3; - setColor(i + start, rgb[0], rgb[1], rgb[2]); - } - } - - _vm->_eventsManager->_intPtr._hasPalette = true; -} - -void GraphicsManager::screenReset() { - resetPalette(); - - _backgroundPage = NULL; - _vPort->setupViewPort(NULL); - fillPic(_vPort, 0); - - _vm->flipPageAndWait(); -} - -void GraphicsManager::fadeDownICF1(int steps) { - if (steps > 0) { - int stepAmount = _vm->_voy->_fadingAmount2 / steps; - - for (int idx = 0; idx < steps; ++idx) { - _vm->_voy->_fadingAmount2 -= stepAmount; - _vm->_eventsManager->delay(1); - } - } - - _vm->_voy->_fadingAmount2 = 0; -} - -void GraphicsManager::fadeUpICF1(int steps) { - if (steps > 0) { - int stepAmount = (63 - _vm->_voy->_fadingAmount2) / steps; - - for (int idx = 0; idx < steps; ++idx) { - _vm->_voy->_fadingAmount2 += stepAmount; - _vm->_eventsManager->delay(1); - } - } - - _vm->_voy->_fadingAmount2 = 63; -} - -void GraphicsManager::fadeDownICF(int steps) { - if (steps > 0) { - _vm->_eventsManager->hideCursor(); - int stepAmount1 = _vm->_voy->_fadingAmount1 / steps; - int stepAmount2 = _vm->_voy->_fadingAmount2 / steps; - - for (int idx = 0; idx < steps; ++idx) { - _vm->_voy->_fadingAmount1 -= stepAmount1; - _vm->_voy->_fadingAmount2 -= stepAmount2; - _vm->_eventsManager->delay(1); - } - } - - _vm->_voy->_fadingAmount1 = 0; - _vm->_voy->_fadingAmount2 = 0; -} - -void GraphicsManager::drawDot() { - for (int y = 0; y < 9; ++y) { - byte *pDest = (byte *)_screenSurface.getPixels() + DOT_LINE_START[y] + DOT_LINE_OFFSET[y]; - Common::fill(pDest, pDest + DOT_LINE_LENGTH[y], 0x80); - } -} - -void GraphicsManager::synchronize(Common::Serializer &s) { - s.syncBytes(&_VGAColors[0], PALETTE_SIZE); -} - -} // End of namespace Voyeur diff --git a/engines/voyeur/graphics.h b/engines/voyeur/graphics.h deleted file mode 100644 index e4d0b38650..0000000000 --- a/engines/voyeur/graphics.h +++ /dev/null @@ -1,120 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef VOYEUR_GRAPHICS_H -#define VOYEUR_GRAPHICS_H - -#include "common/scummsys.h" -#include "common/array.h" -#include "common/rect.h" -#include "common/serializer.h" -#include "graphics/surface.h" - -namespace Voyeur { - -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 200 -#define PALETTE_COUNT 256 -#define PALETTE_SIZE (256 * 3) - -class VoyeurEngine; -class GraphicsManager; -class DisplayResource; -class PictureResource; -class ViewPortResource; -class ViewPortListResource; -class FontResource; -class FontInfoResource; -class CMapResource; - -class DrawInfo { -public: - int _penColor; - Common::Point _pos; -public: - DrawInfo(int penColor, const Common::Point &pos); -}; - -typedef void (GraphicsManager::*GraphicMethodPtr)(); -typedef void (GraphicsManager::*ViewPortSetupPtr)(ViewPortResource *); -typedef void (GraphicsManager::*ViewPortAddPtr)(ViewPortResource *, int idx, const Common::Rect &bounds); -typedef void (GraphicsManager::*ViewPortRestorePtr)(ViewPortResource *); - -class GraphicsManager { -public: - byte _VGAColors[PALETTE_SIZE]; - PictureResource *_backgroundPage; - int _SVGAMode; - ViewPortListResource *_viewPortListPtr; - ViewPortResource *_vPort; - bool _saveBack; - Common::Rect *_clipPtr; - uint _planeSelect; - Graphics::Surface _screenSurface; - CMapResource *_backColors; - FontInfoResource *_fontPtr; - PictureResource *_fontChar; - DrawInfo *_drawPtr; - DrawInfo _defaultDrawInfo; -private: - VoyeurEngine *_vm; - - void restoreBack(Common::Array &rectList, int rectListCount, - PictureResource *srcPic, PictureResource *destPic); -public: - GraphicsManager(VoyeurEngine *vm); - ~GraphicsManager(); - - void sInitGraphics(); - - void setupMCGASaveRect(ViewPortResource *viewPort); - void addRectOptSaveRect(ViewPortResource *viewPort, int idx, const Common::Rect &bounds); - void restoreMCGASaveRect(ViewPortResource *viewPort); - void addRectNoSaveBack(ViewPortResource *viewPort, int idx, const Common::Rect &bounds); - - void sDrawPic(DisplayResource *srcDisplay, DisplayResource *destDisplay, const Common::Point &initialOffset); - void fillPic(DisplayResource *display, byte onOff); - void sDisplayPic(PictureResource *pic); - void drawANumber(DisplayResource *display, int num, const Common::Point &pt); - void flipPage(); - void clearPalette(); - void setPalette(const byte *palette, int start, int count); - void setPalette128(const byte *palette, int start, int count); - void resetPalette(); - void setColor(int idx, byte r, byte g, byte b); - void setOneColor(int idx, byte r, byte g, byte b); - void setColors(int start, int count, const byte *pal); - void screenReset(); - void fadeDownICF1(int steps); - void fadeUpICF1(int steps = 0); - void fadeDownICF(int steps); - void drawDot(); - - /** - * Synchronizes the game data - */ - void synchronize(Common::Serializer &s); -}; - -} // End of namespace Voyeur - -#endif /* VOYEUR_GRAPHICS_H */ diff --git a/engines/voyeur/module.mk b/engines/voyeur/module.mk index aab254cf36..a38bdd9ab2 100644 --- a/engines/voyeur/module.mk +++ b/engines/voyeur/module.mk @@ -8,7 +8,7 @@ MODULE_OBJS := \ events.o \ files.o \ files_threads.o \ - graphics.o \ + screen.o \ sound.o \ staticres.o \ voyeur.o \ diff --git a/engines/voyeur/screen.cpp b/engines/voyeur/screen.cpp new file mode 100644 index 0000000000..62f609c5c7 --- /dev/null +++ b/engines/voyeur/screen.cpp @@ -0,0 +1,1074 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "voyeur/screen.h" +#include "voyeur/voyeur.h" +#include "voyeur/staticres.h" +#include "engines/util.h" +#include "graphics/palette.h" +#include "graphics/surface.h" + +namespace Voyeur { + +/*------------------------------------------------------------------------*/ + +DrawInfo::DrawInfo(int penColor, const Common::Point &pos) { + _penColor = penColor; + _pos = pos; +} + +/*------------------------------------------------------------------------*/ + +Screen::Screen(VoyeurEngine *vm) : Graphics::Screen(), _vm(vm), _drawPtr(&_defaultDrawInfo), + _defaultDrawInfo(1, Common::Point()) { + _SVGAMode = 0; + _planeSelect = 0; + _saveBack = true; + _clipPtr = NULL; + _viewPortListPtr = NULL; + _backgroundPage = NULL; + _vPort = NULL; + _fontPtr = NULL; + Common::fill(&_VGAColors[0], &_VGAColors[PALETTE_SIZE], 0); + _fontChar = new PictureResource(DISPFLAG_NONE, 0xff, 0xff, 0, Common::Rect(), 0, NULL, 0); + _backColors = nullptr; +} + +void Screen::sInitGraphics() { + initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, false); + create(SCREEN_WIDTH, SCREEN_HEIGHT); + clearPalette(); +} + +Screen::~Screen() { + delete _fontChar; +} + +void Screen::setupMCGASaveRect(ViewPortResource *viewPort) { + if (viewPort->_activePage) { + viewPort->_activePage->_flags |= DISPFLAG_1; + Common::Rect *clipRect = _clipPtr; + _clipPtr = &viewPort->_clipRect; + + sDrawPic(viewPort->_activePage, viewPort->_currentPic, Common::Point()); + + _clipPtr = clipRect; + } + + viewPort->_rectListCount[1] = -1; +} + +void Screen::addRectOptSaveRect(ViewPortResource *viewPort, int idx, const Common::Rect &bounds) { + if (viewPort->_rectListCount[idx] == -1) + return; + + // TODO: Lots of code in original, which I suspect may be overlapping rect merging + viewPort->_rectListPtr[idx]->push_back(bounds); + ++viewPort->_rectListCount[idx]; +} + +void Screen::restoreMCGASaveRect(ViewPortResource *viewPort) { + if (viewPort->_rectListCount[0] != -1) { + for (int i = 0; i < viewPort->_rectListCount[0]; ++i) { + addRectOptSaveRect(viewPort, 1, (*viewPort->_rectListPtr[0])[i]); + } + } else { + viewPort->_rectListCount[1] = -1; + } + + restoreBack(*viewPort->_rectListPtr[1], viewPort->_rectListCount[1], viewPort->_pages[0], + viewPort->_pages[1]); + + int count = viewPort->_rectListCount[0]; + restoreBack(*viewPort->_rectListPtr[0], viewPort->_rectListCount[0], + viewPort->_activePage, viewPort->_currentPic); + + SWAP(viewPort->_rectListPtr[0], viewPort->_rectListPtr[1]); + viewPort->_rectListCount[1] = count; +} + +void Screen::addRectNoSaveBack(ViewPortResource *viewPort, int idx, const Common::Rect &bounds) { + // Stubbed/dummy method in the original. +} + +void Screen::sDrawPic(DisplayResource *srcDisplay, DisplayResource *destDisplay, + const Common::Point &initialOffset) { + int width1, width2; + int widthDiff, widthDiff2; + int height1; + int srcOffset; + int screenOffset; + int srcFlags, destFlags; + ViewPortResource *destViewPort = NULL; + Common::Rect newBounds; + Common::Rect backBounds; + int tmpWidth = 0; + int tmpHeight = 0; + bool isClipped = false; + byte pixel = 0; + int runLength; + + byte *srcImgData, *destImgData; + const byte *srcP; + byte *destP; + byte byteVal, byteVal2; + + PictureResource *srcPic; + PictureResource *destPic; + + // Get the picture parameters, or deference viewport pointers to get their pictures + if (srcDisplay->_flags & DISPFLAG_VIEWPORT) { + // A viewport was passed, not a picture + srcPic = ((ViewPortResource *)srcDisplay)->_currentPic; + } else { + srcPic = (PictureResource *)srcDisplay; + } + + if (destDisplay->_flags & DISPFLAG_VIEWPORT) { + // A viewport was passed, not a picture + destViewPort = (ViewPortResource *)destDisplay; + destPic = destViewPort->_currentPic; + } else { + destPic = (PictureResource *)destDisplay; + } + + Common::Point offset = Common::Point(initialOffset.x + srcPic->_bounds.left - destPic->_bounds.left, + initialOffset.y + srcPic->_bounds.top - destPic->_bounds.top); + width1 = width2 = srcPic->_bounds.width(); + height1 = srcPic->_bounds.height(); + srcOffset = 0; + srcFlags = srcPic->_flags; + destFlags = destPic->_flags; + byte *cursorData = NULL; + + if (srcFlags & DISPFLAG_1) { + if (_clipPtr) { + int xs = _clipPtr->left - destPic->_bounds.left; + int ys = _clipPtr->top - destPic->_bounds.top; + newBounds = Common::Rect(xs, ys, xs + _clipPtr->width(), ys + _clipPtr->height()); + } else if (destViewPort) { + int xs = destViewPort->_clipRect.left - destPic->_bounds.left; + int ys = destViewPort->_clipRect.top - destPic->_bounds.top; + newBounds = Common::Rect(xs, ys, xs + destViewPort->_clipRect.width(), + ys + destViewPort->_clipRect.height()); + } else { + newBounds = Common::Rect(0, 0, destPic->_bounds.width(), destPic->_bounds.height()); + } + + tmpHeight = offset.y - newBounds.top; + if (tmpHeight < 0) { + srcOffset -= tmpHeight * width2; + height1 += tmpHeight; + offset.y = newBounds.top; + + if (height1 <= 0) + return; + + isClipped = true; + } + + int yMin = newBounds.bottom - (offset.y + height1); + if (yMin < 0) { + height1 += yMin; + if (height1 <= 0) + return; + } + + tmpWidth = offset.x - newBounds.left; + if (tmpWidth < 0) { + srcOffset -= tmpWidth; + width2 += tmpWidth; + offset.x = newBounds.left; + + if (width2 <= 0) + return; + + isClipped = true; + } + + int xMin = newBounds.right - (offset.x + width2); + if (xMin < 0) { + width2 += xMin; + if (width2 <= 0) + return; + + isClipped = true; + } + } + + screenOffset = offset.y * destPic->_bounds.width() + offset.x; + widthDiff = width1 - width2; + widthDiff2 = destPic->_bounds.width() - width2; + + if (destViewPort) { + if (!_saveBack || (srcPic->_flags & DISPFLAG_800)) { + backBounds.left = destPic->_bounds.left + offset.x; + backBounds.top = destPic->_bounds.top + offset.y; + backBounds.setWidth(width2); + backBounds.setHeight(height1); + addRectOptSaveRect(destViewPort, 1, backBounds); + + } else if (!destViewPort->_addFn) { + if (destViewPort->_rectListCount[destViewPort->_pageIndex] < -1) { + Common::Rect r; + r.left = destPic->_bounds.left + offset.x; + r.top = destPic->_bounds.top + offset.y; + r.setWidth(width2); + r.setHeight(height1); + + (*destViewPort->_rectListPtr[destViewPort->_pageIndex]).push_back(r); + ++destViewPort->_rectListCount[destViewPort->_pageIndex]; + } + } else { + int xs = offset.x + destPic->_bounds.left; + int ys = offset.y + destPic->_bounds.top; + backBounds = Common::Rect(xs, ys, xs + width2, ys + height1); + + (this->*destViewPort->_addFn)(destViewPort, destViewPort->_bounds.top, backBounds); + } + } + + if (srcFlags & DISPFLAG_1000) { + int imageDataShift = 0; + srcImgData = srcPic->_imgData + (imageDataShift << 14); + for (uint idx = 0; idx < srcPic->_maskData; ++idx) { + if (imageDataShift < 4) + ++imageDataShift; + } + + destImgData = destPic->_imgData + (imageDataShift << 14); + for (uint idx = 0; idx < srcPic->_maskData; ++idx) { + if (imageDataShift < 4) + ++imageDataShift; + } + } else { + srcImgData = srcPic->_imgData; + destImgData = destPic->_imgData; + } + + if (srcPic->_select != 0xff) + return; + + if (destFlags & DISPFLAG_CURSOR) { + cursorData = new byte[width2 * height1]; + Common::fill(cursorData, cursorData + width2 * height1, 0); + destImgData = cursorData; + } + + if (srcPic->_pick == 0xff) { + if (srcFlags & DISPFLAG_8) { + error("TODO: sDrawPic variation"); + } else { + // loc_258B8 + srcP = srcImgData + srcOffset; + + if (destFlags & DISPFLAG_8) { + // loc_258D8 + destP = destImgData + screenOffset; + + if (srcFlags & DISPFLAG_2) { + // loc_25652 + srcP = srcImgData + srcOffset; + + if (destFlags & DISPFLAG_8) { + // loc_2566F + if (srcFlags & DISPFLAG_2) { + // loc_256FA + srcP = (const byte *)getPixels() + srcOffset; + + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { + pixel = *srcP; + if (pixel) + *destP = pixel; + } + + srcP += widthDiff; + destP += widthDiff2; + } + } else { + // loc_25706 + for (int yp = 0; yp < height1; ++yp) { + Common::copy(srcP, srcP + width2, destP); + srcP += width2 + widthDiff; + destP += width2 + widthDiff2; + } + } + } else { + // loc_25773 + destP = destImgData + screenOffset; + + if (srcFlags & DISPFLAG_2) { + // loc_25793 + for (int yp = 0; yp < height1; ++yp) { + Common::copy(srcP, srcP + width2, destP); + srcP += width2 + widthDiff; + destP += width2 + widthDiff2; + } + } else { + // loc_25829 + destP = (byte *)getPixels() + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + Common::copy(srcP, srcP + width2, destP); + srcP += width2 + widthDiff; + destP += width2 + widthDiff2; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } + } + } else { + // loc_25D40 + if (srcFlags & DISPFLAG_100) { + // loc_25D4A + error("TODO: sDrawPic variation"); + } else { + // loc_2606D + destP = (byte *)getPixels() + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + Common::copy(srcP, srcP + width2, destP); + destP += width2 + widthDiff2; + srcP += width2 + widthDiff; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } + } + } else { + // loc_2615E + destP = destImgData + screenOffset; + + if (srcFlags & DISPFLAG_2) { + // loc_2617e + if (srcFlags & DISPFLAG_100) { + // loc_26188 + srcP = srcImgData; + if (isClipped) { + // loc_26199 + tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; + int xMax = tmpWidth + width2; + tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; + + width2 = srcPic->_bounds.width(); + height1 = tmpHeight + height1; + + for (int yp = 0; yp < height1; ++yp) { + runLength = 0; + + for (int xp = 0; xp < width2; ++xp, --runLength) { + if (runLength <= 0) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7f; + runLength = *srcP++; + if (!runLength) + runLength = width2; + } + } + + if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { + if (pixel > 0) + *destP = pixel; + ++destP; + } + } + + if (yp >= tmpHeight) + destP += widthDiff2; + } + } else { + // loc_262BE + byteVal = 0; + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp) { + byteVal2 = 0; + if (!byteVal2) { + byteVal = *++srcP; + if (byteVal & 0x80) { + byteVal &= 0x7f; + byteVal2 = *srcP++; + + if (!byteVal2) + byteVal2 = width2; + } + } + + if (byteVal > 0) + *destP = byteVal; + + ++destP; + --byteVal2; + } + + destP += widthDiff2; + } + } + } else { + // loc_2637F + // Copy with transparency + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { + if (*srcP != 0) + *destP = *srcP; + } + + destP += widthDiff2; + srcP += widthDiff; + } + } + } else { + if (srcFlags & DISPFLAG_100) { + // Simple run-length encoded image + srcP = srcImgData; + + if (isClipped) { + // loc_26424 + tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; + int xMax = tmpWidth + width2; + tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; + width2 = srcPic->_bounds.width(); + height1 = tmpHeight + height1; + + for (int yp = 0; yp < height1; ++yp) { + runLength = 0; + for (int xp = 0; xp < width2; ++xp, --runLength) { + if (runLength <= 0) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + runLength = *srcP++; + + if (!runLength) + runLength = width2; + } + } + + if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { + *destP++ = pixel; + } + } + + if (yp >= tmpHeight) + destP += widthDiff2; + } + } else { + // loc_26543 + for (int yp = 0; yp < height1; ++yp) { + int runLen = 0; + for (int xp = 0; xp < width2; ++xp, --runLen) { + if (runLen <= 0) { + // Start of run length, so get pixel and repeat length + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7f; + runLen = *srcP++; + if (runLen == 0) + runLen = width2; + } + } + + // Copy pixel to output + *destP++ = pixel; + } + + destP += widthDiff2; + } + } + } else { + for (int yp = 0; yp < height1; ++yp) { + Common::copy(srcP, srcP + width2, destP); + destP += width2 + widthDiff2; + srcP += width2 + widthDiff; + } + } + } + } + } + } else { + // loc_26666 + if (srcPic->_pick == 0) { + // loc_2727A + byte onOff = srcPic->_onOff; + + if (srcFlags & DISPFLAG_2) { + if (!(srcFlags & DISPFLAG_8)) { + srcP = srcImgData + srcOffset; + + if (destFlags & DISPFLAG_8) { + // loc_272C3 + error("TODO: sDrawPic variation"); + } else { + destP = destImgData + screenOffset; + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++destP) { + if ((int8)*srcP++ < 0) + *destP = onOff; + } + + destP += widthDiff2; + srcP += widthDiff; + } + } + } + } else { + // loc_27477 + if (destFlags & DISPFLAG_8) { + // loc_27481 + destP = (byte *)getPixels() + screenOffset; + for (int yp = 0; yp < height1; ++yp) { + Common::fill(destP, destP + width2, onOff); + destP += width2 + widthDiff2; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } else { + // loc_2753C + destP = destImgData + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + Common::fill(destP, destP + width2, onOff); + destP += width2 + widthDiff2; + } + } + } + + } else { + // loc_26673 + byte pick = srcPic->_pick; + byte onOff = srcPic->_onOff; + + if (!(srcFlags & PICFLAG_PIC_OFFSET)) { + srcP = srcImgData += srcOffset; + pixel = 0; + + if (destFlags & PICFLAG_PIC_OFFSET) { + destP = destImgData + screenOffset; + if (srcFlags & PICFLAG_2) { + if (srcFlags & PICFLAG_100) { + if (isClipped) { + // loc_266E3 + destP = (byte *)getPixels() + screenOffset; + tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; + int xMax = tmpWidth + width2; + tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; + pick = 0x7F; + width2 = srcPic->_bounds.width(); + height1 = tmpHeight + height1; + + for (int yp = 0; yp < height1; ++yp) { + int runLen = 0; + for (int xp = 0; xp < width2; ++xp, --runLen) { + if (runLen <= 0) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + runLen = *srcP++; + if (!runLen) + runLen = width2; + } + } + + if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { + if (pixel) { + *destP = (pixel & pick) ^ onOff; + } + ++destP; + } + } + if (yp >= tmpHeight) + destP += widthDiff2; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } else { + // loc_26815 + destP = (byte *)getPixels() + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + for (int xi = 0; xi < width2; ++xi, ++destP) { + byteVal2 = 0; + for (int xp = 0; xp < width2; ++xp, ++destP, --byteVal2) { + if (!byteVal2) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + byteVal2 = *srcP++; + if (!byteVal2) { + byteVal2 = width2; + } + } + } + + if (pixel) + *destP = (pixel & pick) ^ onOff; + } + } + + destP += widthDiff2; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } + } else { + // Direct screen write + destP = (byte *)getPixels() + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { + if (*srcP) + *destP = (*srcP & pick) ^ onOff; + } + destP += widthDiff2; + srcP += widthDiff; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } + } else if (srcFlags & PICFLAG_100) { + srcP = srcImgData; + if (isClipped) { + // loc_269FD + tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; + int xMax = tmpWidth + width2; + tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; + width2 = srcPic->_bounds.width(); + height1 = tmpHeight + height1; + + for (int yp = 0; yp < height1; ++yp) { + runLength = 0; + for (int xp = 0; xp < width2; ++xp, --runLength) { + if (runLength <= 0) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + runLength = *srcP++; + + if (!runLength) + runLength = width2; + } + } + + if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { + *destP++ = (pixel & 0x80) ^ onOff; + } + } + } + } else { + // loc_26BD5 + destP = (byte *)getPixels() + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + byteVal2 = 0; + + for (int xp = 0; xp < width2; ++xp, ++destP) { + if (!byteVal2) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + byteVal2 = *srcP++; + if (!byteVal2) + byteVal2 = width2; + } + } + + *destP = (pixel & pick) ^ onOff; + } + + destP += widthDiff2; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } + } else { + // loc_26C9A + destP = (byte *)getPixels() + screenOffset; + + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { + *destP = (*srcP & pick) ^ onOff; + } + destP += widthDiff2; + srcP += widthDiff; + } + + addDirtyRect(Common::Rect(offset.x, offset.y, offset.x + width2, + offset.y + height1)); + } + } else { + // loc_26D2F + destP = destImgData + screenOffset; + + if (srcFlags & PICFLAG_2) { + // loc_26D4F + if (srcFlags & PICFLAG_100) { + srcP = srcImgData; + + if (isClipped) { + // loc_26D6A + tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; + int xMax = tmpWidth + width2; + tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; + width2 = srcPic->_bounds.width(); + height1 = tmpHeight + height1; + + for (int yp = 0; yp < height1; ++yp) { + runLength = 0; + + for (int xp = 0; xp < width2; ++xp, --runLength) { + if (runLength <= 0) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + runLength = *srcP++; + if (!runLength) + runLength = width2; + } + } + + if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { + if (pixel) + *destP = (pixel & pick) ^ onOff; + + ++destP; + } + } + + if (yp >= tmpHeight) + destP += widthDiff2; + } + } else { + // loc_26E95 + for (int yp = 0; yp < height1; ++yp) { + byteVal2 = 0; + for (int xp = 0; xp < width2; ++xp, ++destP, --byteVal2) { + if (!byteVal2) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + byteVal2 = *srcP++; + if (!byteVal2) + byteVal2 = width2; + } + } + + if (pixel) + *destP = (pixel & pick) ^ onOff; + } + + destP += widthDiff2; + } + } + } else { + // loc_26F5D + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { + if (*srcP) + *destP = (*srcP & pick) ^ onOff; + } + destP += widthDiff2; + srcP += widthDiff; + } + } + } else { + // loc_26FEF + if (srcFlags & PICFLAG_100) { + // loc_26FF9 + for (int yp = 0; yp < height1; ++yp) { + for (int xp = 0; xp < width2; ++xp, ++srcP, ++destP) { + *destP = (*srcP & pick) ^ onOff; + } + destP += widthDiff2; + srcP += widthDiff; + } + } else { + // loc_271F0 + srcP = srcImgData; + + if (isClipped) { + // loc_2700A + tmpWidth = (tmpWidth < 0) ? -tmpWidth : 0; + int xMax = tmpWidth + width2; + tmpHeight = (tmpHeight < 0) ? -tmpHeight : 0; + width2 = srcPic->_bounds.width(); + height1 = tmpHeight + height1; + + for (int yp = 0; yp < height1; ++yp) { + runLength = 0; + + for (int xp = 0; xp < width2; ++xp, --runLength) { + if (runLength <= 0) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + runLength = *srcP++; + if (!runLength) + runLength = width2; + } + } + + if (yp >= tmpHeight && xp >= tmpWidth && xp < xMax) { + *destP++ = (pixel & pick) ^ onOff; + } + } + + if (yp >= tmpHeight) + destP += widthDiff2; + } + } else { + // loc_2712F + for (int yp = 0; yp < height1; ++yp) { + byteVal2 = 0; + for (int xp = 0; xp < width2; ++xp, ++destP, --byteVal2) { + if (!byteVal2) { + pixel = *srcP++; + if (pixel & 0x80) { + pixel &= 0x7F; + byteVal2 = *srcP++; + if (!byteVal2) + byteVal2 = width2; + } + } + + *destP = (*srcP & pick) ^ onOff; + } + destP += widthDiff2; + } + } + } + } + } + } + } + } + + if (cursorData) { + _vm->_eventsManager->setCursor(cursorData, width2, height1, srcPic->_keyColor); + delete[] cursorData; + } +} + +void Screen::drawANumber(DisplayResource *display, int num, const Common::Point &pt) { + PictureResource *pic = _vm->_bVoy->boltEntry(num + 261)._picResource; + sDrawPic(pic, display, pt); +} + +void Screen::fillPic(DisplayResource *display, byte onOff) { + PictureResource *pic; + if (display->_flags & DISPFLAG_VIEWPORT) { + pic = ((ViewPortResource *)display)->_currentPic; + } else { + pic = (PictureResource *)display; + } + + PictureResource picResource; + picResource._flags = DISPFLAG_NONE; + picResource._select = 0xff; + picResource._pick = 0; + picResource._onOff = onOff; + picResource._bounds = pic->_bounds; + + sDrawPic(&picResource, display, Common::Point()); +} + +/** + * Queues the given picture for display + */ +void Screen::sDisplayPic(PictureResource *pic) { + _vm->_eventsManager->_intPtr._flipWait = true; +} + +void Screen::flipPage() { + Common::Array &viewPorts = _viewPortListPtr->_entries; + bool flipFlag = false; + + for (uint idx = 0; idx < viewPorts.size(); ++idx) { + if ((viewPorts[idx]->_flags & (DISPFLAG_20 | DISPFLAG_8 | DISPFLAG_1)) == (DISPFLAG_20 | DISPFLAG_8 | DISPFLAG_1)) { + if (_planeSelect == idx) + sDisplayPic(viewPorts[idx]->_currentPic); + flipFlag = true; + } + + if (flipFlag) { + ViewPortResource &viewPort = *viewPorts[idx]; + + viewPort._lastPage = viewPort._pageIndex; + ++viewPort._pageIndex; + + if (viewPort._pageIndex >= viewPort._pageCount) + viewPort._pageIndex = 0; + + assert(viewPort._pageIndex < 2); + viewPort._currentPic = viewPort._pages[viewPort._pageIndex]; + viewPort._flags = (viewPort._flags & ~DISPFLAG_8) | DISPFLAG_40; + } + } +} + +void Screen::restoreBack(Common::Array &rectList, int rectListCount, + PictureResource *srcPic, PictureResource *destPic) { + // WORKAROUND: Since _backgroundPage can point to a resource freed at the end of display methods, + // I'm now explicitly resetting it to null in screenReset(), so at this point it can be null + if (!srcPic) + return; + + bool saveBack = _saveBack; + _saveBack = false; + + if (rectListCount == -1) { + sDrawPic(srcPic, destPic, Common::Point()); + } else { + for (int i = rectListCount - 1; i >= 0; --i) { + _clipPtr = &rectList[i]; + sDrawPic(srcPic, destPic, Common::Point()); + } + } + + _saveBack = saveBack; +} + +void Screen::setPalette(const byte *palette, int start, int count) { + Graphics::Screen::setPalette(palette, start, count); + _vm->_eventsManager->_gameData._hasPalette = false; +} + +void Screen::setPalette128(const byte *palette, int start, int count) { + byte rgb[3]; + getPalette(&rgb[0], 128, 1); + Graphics::Screen::setPalette(palette, start, count); + Graphics::Screen::setPalette(&rgb[0], 128, 1); +} + +void Screen::resetPalette() { + for (int i = 0; i < 256; ++i) + setColor(i, 0, 0, 0); + + _vm->_eventsManager->_intPtr._hasPalette = true; +} + +void Screen::setColor(int idx, byte r, byte g, byte b) { + byte *vgaP = &_VGAColors[idx * 3]; + vgaP[0] = r; + vgaP[1] = g; + vgaP[2] = b; + + _vm->_eventsManager->_intPtr._palStartIndex = MIN(_vm->_eventsManager->_intPtr._palStartIndex, idx); + _vm->_eventsManager->_intPtr._palEndIndex = MAX(_vm->_eventsManager->_intPtr._palEndIndex, idx); +} + +void Screen::setOneColor(int idx, byte r, byte g, byte b) { + byte palEntry[3]; + palEntry[0] = r; + palEntry[1] = g; + palEntry[2] = b; + g_system->getPaletteManager()->setPalette(&palEntry[0], idx, 1); +} + +void Screen::setColors(int start, int count, const byte *pal) { + for (int i = 0; i < count; ++i) { + if ((i + start) != 128) { + const byte *rgb = pal + i * 3; + setColor(i + start, rgb[0], rgb[1], rgb[2]); + } + } + + _vm->_eventsManager->_intPtr._hasPalette = true; +} + +void Screen::screenReset() { + resetPalette(); + + _backgroundPage = NULL; + _vPort->setupViewPort(NULL); + fillPic(_vPort, 0); + + _vm->flipPageAndWait(); +} + +void Screen::fadeDownICF1(int steps) { + if (steps > 0) { + int stepAmount = _vm->_voy->_fadingAmount2 / steps; + + for (int idx = 0; idx < steps; ++idx) { + _vm->_voy->_fadingAmount2 -= stepAmount; + _vm->_eventsManager->delay(1); + } + } + + _vm->_voy->_fadingAmount2 = 0; +} + +void Screen::fadeUpICF1(int steps) { + if (steps > 0) { + int stepAmount = (63 - _vm->_voy->_fadingAmount2) / steps; + + for (int idx = 0; idx < steps; ++idx) { + _vm->_voy->_fadingAmount2 += stepAmount; + _vm->_eventsManager->delay(1); + } + } + + _vm->_voy->_fadingAmount2 = 63; +} + +void Screen::fadeDownICF(int steps) { + if (steps > 0) { + _vm->_eventsManager->hideCursor(); + int stepAmount1 = _vm->_voy->_fadingAmount1 / steps; + int stepAmount2 = _vm->_voy->_fadingAmount2 / steps; + + for (int idx = 0; idx < steps; ++idx) { + _vm->_voy->_fadingAmount1 -= stepAmount1; + _vm->_voy->_fadingAmount2 -= stepAmount2; + _vm->_eventsManager->delay(1); + } + } + + _vm->_voy->_fadingAmount1 = 0; + _vm->_voy->_fadingAmount2 = 0; +} + +void Screen::drawDot() { + for (int idx = 0; idx < 9; ++idx) { + uint offset = DOT_LINE_START[idx] + DOT_LINE_OFFSET[idx]; + int xp = offset % SCREEN_WIDTH; + int yp = offset / SCREEN_WIDTH; + + byte *pDest = (byte *)getPixels() + offset; + Common::fill(pDest, pDest + DOT_LINE_LENGTH[idx], 0x80); + addDirtyRect(Common::Rect(xp, yp, xp + DOT_LINE_LENGTH[idx], yp + 1)); + } +} + +void Screen::synchronize(Common::Serializer &s) { + s.syncBytes(&_VGAColors[0], PALETTE_SIZE); +} + +} // End of namespace Voyeur diff --git a/engines/voyeur/screen.h b/engines/voyeur/screen.h new file mode 100644 index 0000000000..aaf61747a4 --- /dev/null +++ b/engines/voyeur/screen.h @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef VOYEUR_GRAPHICS_H +#define VOYEUR_GRAPHICS_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/rect.h" +#include "common/serializer.h" +#include "graphics/screen.h" + +namespace Voyeur { + +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 200 + +class VoyeurEngine; +class Screen; +class DisplayResource; +class PictureResource; +class ViewPortResource; +class ViewPortListResource; +class FontResource; +class FontInfoResource; +class CMapResource; + +class DrawInfo { +public: + int _penColor; + Common::Point _pos; +public: + DrawInfo(int penColor, const Common::Point &pos); +}; + +typedef void (Screen::*ScreenMethodPtr)(); +typedef void (Screen::*ViewPortSetupPtr)(ViewPortResource *); +typedef void (Screen::*ViewPortAddPtr)(ViewPortResource *, int idx, const Common::Rect &bounds); +typedef void (Screen::*ViewPortRestorePtr)(ViewPortResource *); + +class Screen: public Graphics::Screen { +public: + byte _VGAColors[PALETTE_SIZE]; + PictureResource *_backgroundPage; + int _SVGAMode; + ViewPortListResource *_viewPortListPtr; + ViewPortResource *_vPort; + bool _saveBack; + Common::Rect *_clipPtr; + uint _planeSelect; + CMapResource *_backColors; + FontInfoResource *_fontPtr; + PictureResource *_fontChar; + DrawInfo *_drawPtr; + DrawInfo _defaultDrawInfo; +private: + VoyeurEngine *_vm; + + void restoreBack(Common::Array &rectList, int rectListCount, + PictureResource *srcPic, PictureResource *destPic); +public: + Screen(VoyeurEngine *vm); + virtual ~Screen(); + + void sInitGraphics(); + + void setupMCGASaveRect(ViewPortResource *viewPort); + void addRectOptSaveRect(ViewPortResource *viewPort, int idx, const Common::Rect &bounds); + void restoreMCGASaveRect(ViewPortResource *viewPort); + void addRectNoSaveBack(ViewPortResource *viewPort, int idx, const Common::Rect &bounds); + + void sDrawPic(DisplayResource *srcDisplay, DisplayResource *destDisplay, const Common::Point &initialOffset); + void fillPic(DisplayResource *display, byte onOff); + void sDisplayPic(PictureResource *pic); + void drawANumber(DisplayResource *display, int num, const Common::Point &pt); + void flipPage(); + void setPalette(const byte *palette, int start, int count); + void setPalette128(const byte *palette, int start, int count); + void resetPalette(); + void setColor(int idx, byte r, byte g, byte b); + void setOneColor(int idx, byte r, byte g, byte b); + void setColors(int start, int count, const byte *pal); + void screenReset(); + void fadeDownICF1(int steps); + void fadeUpICF1(int steps = 0); + void fadeDownICF(int steps); + void drawDot(); + + /** + * Synchronizes the game data + */ + void synchronize(Common::Serializer &s); +}; + +} // End of namespace Voyeur + +#endif /* VOYEUR_GRAPHICS_H */ diff --git a/engines/voyeur/voyeur.cpp b/engines/voyeur/voyeur.cpp index cbb6846340..01b76a72d1 100644 --- a/engines/voyeur/voyeur.cpp +++ b/engines/voyeur/voyeur.cpp @@ -22,7 +22,7 @@ #include "voyeur/voyeur.h" #include "voyeur/animation.h" -#include "voyeur/graphics.h" +#include "voyeur/screen.h" #include "voyeur/staticres.h" #include "common/scummsys.h" #include "common/config-manager.h" @@ -40,7 +40,7 @@ VoyeurEngine::VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc) _debugger = nullptr; _eventsManager = nullptr; _filesManager = nullptr; - _graphicsManager = nullptr; + _screen = nullptr; _soundManager = nullptr; _voy = nullptr; _bVoy = NULL; @@ -65,13 +65,6 @@ VoyeurEngine::VoyeurEngine(OSystem *syst, const VoyeurGameDescription *gameDesc) DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts"); - _debugger = new Debugger(this); - _eventsManager = new EventsManager(this); - _filesManager = new FilesManager(this); - _graphicsManager = new GraphicsManager(this); - _soundManager = new SoundManager(_mixer); - _voy = new SVoy(this); - _stampLibPtr = nullptr; _controlGroupPtr = nullptr; _stampData = nullptr; @@ -88,7 +81,7 @@ VoyeurEngine::~VoyeurEngine() { delete _bVoy; delete _voy; delete _soundManager; - delete _graphicsManager; + delete _screen; delete _filesManager; delete _eventsManager; delete _debugger; @@ -126,15 +119,22 @@ void VoyeurEngine::ESP_Init() { } void VoyeurEngine::globalInitBolt() { + _debugger = new Debugger(this); + _eventsManager = new EventsManager(this); + _filesManager = new FilesManager(this); + _screen = new Screen(this); + _soundManager = new SoundManager(_mixer); + _voy = new SVoy(this); + initBolt(); _filesManager->openBoltLib("bvoy.blt", _bVoy); _bVoy->getBoltGroup(0x000); _bVoy->getBoltGroup(0x100); - _graphicsManager->_fontPtr = &_defaultFontInfo; - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; - assert(_graphicsManager->_fontPtr->_curFont); + _screen->_fontPtr = &_defaultFontInfo; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; + assert(_screen->_fontPtr->_curFont); // Setup default flags _voy->_viewBounds = nullptr; @@ -144,13 +144,13 @@ void VoyeurEngine::globalInitBolt() { void VoyeurEngine::initBolt() { vInitInterrupts(); - _graphicsManager->sInitGraphics(); + _screen->sInitGraphics(); _eventsManager->vInitColor(); initInput(); } void VoyeurEngine::vInitInterrupts() { - _eventsManager->_intPtr._palette = &_graphicsManager->_VGAColors[0]; + _eventsManager->_intPtr._palette = &_screen->_VGAColors[0]; } void VoyeurEngine::initInput() { @@ -213,8 +213,8 @@ bool VoyeurEngine::doHeadTitle() { } void VoyeurEngine::showConversionScreen() { - _graphicsManager->_backgroundPage = _bVoy->boltEntry(0x502)._picResource; - _graphicsManager->_vPort->setupViewPort(); + _screen->_backgroundPage = _bVoy->boltEntry(0x502)._picResource; + _screen->_vPort->setupViewPort(); flipPageAndWait(); // Immediate palette load to show the initial screen @@ -237,7 +237,7 @@ void VoyeurEngine::showConversionScreen() { flipPageAndWaitForFade(); - _graphicsManager->screenReset(); + _screen->screenReset(); } bool VoyeurEngine::doLock() { @@ -249,28 +249,28 @@ bool VoyeurEngine::doLock() { if (_bVoy->getBoltGroup(0x700)) { Common::String password = "3333"; - _graphicsManager->_backgroundPage = _bVoy->getPictureResource(0x700); - _graphicsManager->_backColors = _bVoy->getCMapResource(0x701); + _screen->_backgroundPage = _bVoy->getPictureResource(0x700); + _screen->_backColors = _bVoy->getCMapResource(0x701); PictureResource *cursorPic = _bVoy->getPictureResource(0x702); _voy->_viewBounds = _bVoy->boltEntry(0x704)._rectResource; Common::Array &hotspots = _bVoy->boltEntry(0x705)._rectResource->_entries; assert(cursorPic); - _graphicsManager->_vPort->setupViewPort(); + _screen->_vPort->setupViewPort(); - _graphicsManager->_backColors->startFade(); - _graphicsManager->_vPort->_parent->_flags |= DISPFLAG_8; - _graphicsManager->flipPage(); + _screen->_backColors->startFade(); + _screen->_vPort->_parent->_flags |= DISPFLAG_8; + _screen->flipPage(); _eventsManager->sWaitFlip(); while (!shouldQuit() && (_eventsManager->_fadeStatus & 1)) _eventsManager->delay(1); _eventsManager->setCursorColor(127, 0); - _graphicsManager->setColor(1, 64, 64, 64); - _graphicsManager->setColor(2, 96, 96, 96); - _graphicsManager->setColor(3, 160, 160, 160); - _graphicsManager->setColor(4, 224, 224, 224); + _screen->setColor(1, 64, 64, 64); + _screen->setColor(2, 96, 96, 96); + _screen->setColor(3, 160, 160, 160); + _screen->setColor(4, 224, 224, 224); // Set up the cursor _eventsManager->setCursor(cursorPic); @@ -278,9 +278,9 @@ bool VoyeurEngine::doLock() { _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x708)._fontResource; - _graphicsManager->_fontPtr->_fontSaveBack = 0; - _graphicsManager->_fontPtr->_fontFlags = DISPFLAG_NONE; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x708)._fontResource; + _screen->_fontPtr->_fontSaveBack = 0; + _screen->_fontPtr->_fontFlags = DISPFLAG_NONE; Common::String dateString = "ScummVM"; Common::String displayString = Common::String::format("Last Play %s", dateString.c_str()); @@ -288,16 +288,16 @@ bool VoyeurEngine::doLock() { bool firstLoop = true; bool breakFlag = false; while (!breakFlag && !shouldQuit()) { - _graphicsManager->_vPort->setupViewPort(); + _screen->_vPort->setupViewPort(); flipPageAndWait(); // Display the last play time - _graphicsManager->_fontPtr->_pos = Common::Point(0, 97); - _graphicsManager->_fontPtr->_justify = ALIGN_CENTER; - _graphicsManager->_fontPtr->_justifyWidth = 384; - _graphicsManager->_fontPtr->_justifyHeight = 97; + _screen->_fontPtr->_pos = Common::Point(0, 97); + _screen->_fontPtr->_justify = ALIGN_CENTER; + _screen->_fontPtr->_justifyWidth = 384; + _screen->_fontPtr->_justifyHeight = 97; - _graphicsManager->_vPort->drawText(displayString); + _screen->_vPort->drawText(displayString); flipPageAndWait(); if (firstLoop) { @@ -356,7 +356,7 @@ bool VoyeurEngine::doLock() { } else if (key == 11) { // New code if ((password.empty() && displayString.empty()) || (password != displayString)) { - _graphicsManager->_vPort->setupViewPort(); + _screen->_vPort->setupViewPort(); password = displayString; displayString = ""; continue; @@ -373,9 +373,9 @@ bool VoyeurEngine::doLock() { _soundManager->playVOCMap(wrongVoc, wrongVocSize); } - _graphicsManager->fillPic(_graphicsManager->_vPort, 0); + _screen->fillPic(_screen->_vPort, 0); flipPageAndWait(); - _graphicsManager->resetPalette(); + _screen->resetPalette(); _voy->_viewBounds = nullptr; _bVoy->freeBoltGroup(0x700); @@ -393,9 +393,9 @@ void VoyeurEngine::showTitleScreen() { if (!_bVoy->getBoltGroup(0x500)) return; - _graphicsManager->_backgroundPage = _bVoy->getPictureResource(0x500); + _screen->_backgroundPage = _bVoy->getPictureResource(0x500); - _graphicsManager->_vPort->setupViewPort(); + _screen->_vPort->setupViewPort(); flipPageAndWait(); // Immediate palette load to show the initial screen @@ -422,18 +422,18 @@ void VoyeurEngine::showTitleScreen() { return; } - _graphicsManager->screenReset(); + _screen->screenReset(); _eventsManager->delayClick(200); // Voyeur title playRL2Video("a1100100.rl2"); - _graphicsManager->screenReset(); + _screen->screenReset(); _bVoy->freeBoltGroup(0x500); } void VoyeurEngine::doOpening() { - _graphicsManager->screenReset(); + _screen->screenReset(); if (!_bVoy->getBoltGroup(0x200)) return; @@ -459,10 +459,10 @@ void VoyeurEngine::doOpening() { _voy->_eventFlags &= ~EVTFLAG_TIME_DISABLED; for (int i = 0; i < 256; ++i) - _graphicsManager->setColor(i, 8, 8, 8); + _screen->setColor(i, 8, 8, 8); _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_vPort->setupViewPort(); + _screen->_vPort->setupViewPort(); flipPageAndWait(); RL2Decoder decoder; @@ -472,14 +472,12 @@ void VoyeurEngine::doOpening() { while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager->_mouseClicked) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); - _graphicsManager->setPalette(palette, 0, 256); + _screen->setPalette(palette, 0, 256); } if (decoder.needsUpdate()) { const Graphics::Surface *frame = decoder.decodeNextFrame(); - - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)_graphicsManager->_screenSurface.getPixels()); + _screen->blitFrom(*frame); if (decoder.getCurFrame() >= (int32)READ_LE_UINT32(frameTable + frameIndex * 4)) { if (creditShow) { @@ -499,7 +497,7 @@ void VoyeurEngine::doOpening() { } if (textPic) { - _graphicsManager->sDrawPic(textPic, _graphicsManager->_vPort, textPos); + _screen->sDrawPic(textPic, _screen->_vPort, textPos); } flipPageAndWait(); @@ -527,14 +525,12 @@ void VoyeurEngine::playRL2Video(const Common::String &filename) { while (!shouldQuit() && !decoder.endOfVideo() && !_eventsManager->_mouseClicked) { if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); - _graphicsManager->setPalette(palette, 0, 256); + _screen->setPalette(palette, 0, 256); } if (decoder.needsUpdate()) { const Graphics::Surface *frame = decoder.decodeNextFrame(); - - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)_graphicsManager->_screenSurface.getPixels()); + _screen->blitFrom(*frame); } _eventsManager->getMouseInfo(); @@ -573,17 +569,16 @@ void VoyeurEngine::playAVideoDuration(int videoId, int duration) { (decoder.getCurFrame() < endFrame)) { if (decoder.needsUpdate()) { const Graphics::Surface *frame = decoder.decodeNextFrame(); + _screen->blitFrom(*frame); - Common::copy((const byte *)frame->getPixels(), (const byte *)frame->getPixels() + 320 * 200, - (byte *)_graphicsManager->_screenSurface.getPixels()); if (_voy->_eventFlags & EVTFLAG_RECORDING) - _graphicsManager->drawDot(); + _screen->drawDot(); } if (decoder.hasDirtyPalette()) { const byte *palette = decoder.getPalette(); - _graphicsManager->setPalette(palette, 0, decoder.getPaletteCount()); - _graphicsManager->setOneColor(128, 220, 20, 20); + _screen->setPalette(palette, 0, decoder.getPaletteCount()); + _screen->setOneColor(128, 220, 20, 20); } _eventsManager->getMouseInfo(); @@ -591,13 +586,13 @@ void VoyeurEngine::playAVideoDuration(int videoId, int duration) { } // RL2 finished - _graphicsManager->screenReset(); + _screen->screenReset(); _voy->_eventFlags &= ~EVTFLAG_RECORDING; if (_voy->_eventFlags & EVTFLAG_8) { assert(pic); - byte *imgData = _graphicsManager->_vPort->_currentPic->_imgData; - _graphicsManager->_vPort->_currentPic->_imgData = pic->_imgData; + byte *imgData = _screen->_vPort->_currentPic->_imgData; + _screen->_vPort->_currentPic->_imgData = pic->_imgData; pic->_imgData = imgData; _voy->_eventFlags &= ~EVTFLAG_8; } @@ -608,13 +603,13 @@ void VoyeurEngine::playAVideoDuration(int videoId, int duration) { void VoyeurEngine::playAudio(int audioId) { _bVoy->getBoltGroup(0x7F00); - _graphicsManager->_backgroundPage = _bVoy->boltEntry(0x7F00 + + _screen->_backgroundPage = _bVoy->boltEntry(0x7F00 + BLIND_TABLE[audioId] * 2)._picResource; - _graphicsManager->_backColors = _bVoy->boltEntry(0x7F01 + + _screen->_backColors = _bVoy->boltEntry(0x7F01 + BLIND_TABLE[audioId] * 2)._cMapResource; - _graphicsManager->_vPort->setupViewPort(); - _graphicsManager->_backColors->startFade(); + _screen->_vPort->setupViewPort(); + _screen->_backColors->startFade(); flipPageAndWaitForFade(); _voy->_eventFlags &= ~EVTFLAG_TIME_DISABLED; @@ -633,26 +628,26 @@ void VoyeurEngine::playAudio(int audioId) { _soundManager->stopVOCPlay(); _bVoy->freeBoltGroup(0x7F00); - _graphicsManager->_vPort->setupViewPort(NULL); + _screen->_vPort->setupViewPort(NULL); _voy->_eventFlags &= ~EVTFLAG_RECORDING; _voy->_playStampMode = 129; } void VoyeurEngine::doTransitionCard(const Common::String &time, const Common::String &location) { - _graphicsManager->setColor(128, 16, 16, 16); - _graphicsManager->setColor(224, 220, 220, 220); + _screen->setColor(128, 16, 16, 16); + _screen->setColor(224, 220, 220, 220); _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_vPort->setupViewPort(NULL); - _graphicsManager->_vPort->fillPic(0x80); - _graphicsManager->flipPage(); + _screen->_vPort->setupViewPort(NULL); + _screen->_vPort->fillPic(0x80); + _screen->flipPage(); _eventsManager->sWaitFlip(); flipPageAndWait(); - _graphicsManager->_vPort->fillPic(0x80); + _screen->_vPort->fillPic(0x80); - FontInfoResource &fi = *_graphicsManager->_fontPtr; + FontInfoResource &fi = *_screen->_fontPtr; fi._curFont = _bVoy->boltEntry(257)._fontResource; fi._foreColor = 224; fi._fontSaveBack = 0; @@ -661,7 +656,7 @@ void VoyeurEngine::doTransitionCard(const Common::String &time, const Common::St fi._justifyWidth = 384; fi._justifyHeight = 120; - _graphicsManager->_vPort->drawText(time); + _screen->_vPort->drawText(time); if (!location.empty()) { fi._pos = Common::Point(0, 138); @@ -669,7 +664,7 @@ void VoyeurEngine::doTransitionCard(const Common::String &time, const Common::St fi._justifyWidth = 384; fi._justifyHeight = 140; - _graphicsManager->_vPort->drawText(location); + _screen->_vPort->drawText(location); } flipPageAndWait(); @@ -680,8 +675,8 @@ void VoyeurEngine::saveLastInplay() { } void VoyeurEngine::flipPageAndWait() { - _graphicsManager->_vPort->_flags |= DISPFLAG_8; - _graphicsManager->flipPage(); + _screen->_vPort->_flags |= DISPFLAG_8; + _screen->flipPage(); _eventsManager->sWaitFlip(); } @@ -702,7 +697,7 @@ void VoyeurEngine::showEndingNews() { PictureResource *pic = _bVoy->boltEntry(_playStampGroupId)._picResource; CMapResource *pal = _bVoy->boltEntry(_playStampGroupId + 1)._cMapResource; - _graphicsManager->_vPort->setupViewPort(pic); + _screen->_vPort->setupViewPort(pic); pal->startFade(); flipPageAndWaitForFade(); @@ -717,7 +712,7 @@ void VoyeurEngine::showEndingNews() { pal = _bVoy->boltEntry(_playStampGroupId + idx * 2 + 1)._cMapResource; } - _graphicsManager->_vPort->setupViewPort(pic); + _screen->_vPort->setupViewPort(pic); pal->startFade(); flipPageAndWaitForFade(); @@ -852,7 +847,7 @@ void VoyeurEngine::synchronize(Common::Serializer &s) { // Sub-systems _voy->synchronize(s); - _graphicsManager->synchronize(s); + _screen->synchronize(s); _mainThread->synchronize(s); _controlPtr->_state->synchronize(s); } @@ -906,8 +901,8 @@ void VoyeurSavegameHeader::write(Common::OutSaveFile *f, VoyeurEngine *vm, const // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); - ::createThumbnail(thumb, (byte *)vm->_graphicsManager->_screenSurface.getPixels(), - SCREEN_WIDTH, SCREEN_HEIGHT, vm->_graphicsManager->_VGAColors); + ::createThumbnail(thumb, (const byte *)vm->_screen->getPixels(), + SCREEN_WIDTH, SCREEN_HEIGHT, vm->_screen->_VGAColors); Graphics::saveThumbnail(*f, *thumb); thumb->free(); delete thumb; diff --git a/engines/voyeur/voyeur.h b/engines/voyeur/voyeur.h index e0bb734fa8..9cda85fd51 100644 --- a/engines/voyeur/voyeur.h +++ b/engines/voyeur/voyeur.h @@ -27,7 +27,7 @@ #include "voyeur/data.h" #include "voyeur/events.h" #include "voyeur/files.h" -#include "voyeur/graphics.h" +#include "voyeur/screen.h" #include "voyeur/sound.h" #include "common/scummsys.h" #include "common/system.h" @@ -164,7 +164,7 @@ public: Debugger *_debugger; EventsManager *_eventsManager; FilesManager *_filesManager; - GraphicsManager *_graphicsManager; + Screen *_screen; SoundManager *_soundManager; SVoy *_voy; diff --git a/engines/voyeur/voyeur_game.cpp b/engines/voyeur/voyeur_game.cpp index 13ef31839a..e9591955fc 100644 --- a/engines/voyeur/voyeur_game.cpp +++ b/engines/voyeur/voyeur_game.cpp @@ -149,8 +149,8 @@ void VoyeurEngine::playStamp() { case 130: { // user selected to send the tape if (_bVoy->getBoltGroup(_playStampGroupId)) { - _graphicsManager->_backgroundPage = _bVoy->boltEntry(_playStampGroupId)._picResource; - _graphicsManager->_backColors = _bVoy->boltEntry(_playStampGroupId + 1)._cMapResource; + _screen->_backgroundPage = _bVoy->boltEntry(_playStampGroupId)._picResource; + _screen->_backColors = _bVoy->boltEntry(_playStampGroupId + 1)._cMapResource; buttonId = getChooseButton(); if (_eventsManager->_rightClick) @@ -158,7 +158,7 @@ void VoyeurEngine::playStamp() { buttonId = 4; _bVoy->freeBoltGroup(_playStampGroupId); - _graphicsManager->screenReset(); + _screen->screenReset(); _playStampGroupId = -1; flag = true; @@ -232,8 +232,8 @@ void VoyeurEngine::closeStamp() { } void VoyeurEngine::doTailTitle() { - _graphicsManager->_vPort->setupViewPort(NULL); - _graphicsManager->screenReset(); + _screen->_vPort->setupViewPort(NULL); + _screen->screenReset(); if (_bVoy->getBoltGroup(0x600)) { RL2Decoder decoder; @@ -245,12 +245,12 @@ void VoyeurEngine::doTailTitle() { doClosingCredits(); if (!shouldQuit() && !_eventsManager->_mouseClicked) { - _graphicsManager->screenReset(); + _screen->screenReset(); PictureResource *pic = _bVoy->boltEntry(0x602)._picResource; CMapResource *pal = _bVoy->boltEntry(0x603)._cMapResource; - _graphicsManager->_vPort->setupViewPort(pic); + _screen->_vPort->setupViewPort(pic); pal->startFade(); flipPageAndWaitForFade(); _eventsManager->delayClick(300); @@ -258,7 +258,7 @@ void VoyeurEngine::doTailTitle() { pic = _bVoy->boltEntry(0x604)._picResource; pal = _bVoy->boltEntry(0x605)._cMapResource; - _graphicsManager->_vPort->setupViewPort(pic); + _screen->_vPort->setupViewPort(pic); pal->startFade(); flipPageAndWaitForFade(); _eventsManager->delayClick(120); @@ -283,26 +283,26 @@ void VoyeurEngine::doClosingCredits() { const char *msg = (const char *)_bVoy->memberAddr(0x404); const byte *creditList = (const byte *)_bVoy->memberAddr(0x405); - _graphicsManager->_vPort->setupViewPort(NULL); - _graphicsManager->setColor(1, 180, 180, 180); - _graphicsManager->setColor(2, 200, 200, 200); + _screen->_vPort->setupViewPort(NULL); + _screen->setColor(1, 180, 180, 180); + _screen->setColor(2, 200, 200, 200); _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x402)._fontResource; - _graphicsManager->_fontPtr->_foreColor = 2; - _graphicsManager->_fontPtr->_backColor = 2; - _graphicsManager->_fontPtr->_fontSaveBack = false; - _graphicsManager->_fontPtr->_fontFlags = DISPFLAG_NONE; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x402)._fontResource; + _screen->_fontPtr->_foreColor = 2; + _screen->_fontPtr->_backColor = 2; + _screen->_fontPtr->_fontSaveBack = false; + _screen->_fontPtr->_fontFlags = DISPFLAG_NONE; _soundManager->startVOCPlay(152); - FontInfoResource &fi = *_graphicsManager->_fontPtr; + FontInfoResource &fi = *_screen->_fontPtr; for (int idx = 0; idx < 78; ++idx) { const byte *entry = creditList + idx * 6; int flags = READ_LE_UINT16(entry + 4); if (flags & 0x10) - _graphicsManager->_vPort->fillPic(0); + _screen->_vPort->fillPic(0); if (flags & 1) { fi._foreColor = 1; @@ -312,7 +312,7 @@ void VoyeurEngine::doClosingCredits() { fi._justifyHeight = 240; fi._pos = Common::Point(0, READ_LE_UINT16(entry)); - _graphicsManager->_vPort->drawText(msg); + _screen->_vPort->drawText(msg); msg += strlen(msg) + 1; } @@ -324,7 +324,7 @@ void VoyeurEngine::doClosingCredits() { fi._justifyHeight = 240; fi._pos = Common::Point(0, READ_LE_UINT16(entry)); - _graphicsManager->_vPort->drawText(msg); + _screen->_vPort->drawText(msg); msg += strlen(msg) + 1; } @@ -336,7 +336,7 @@ void VoyeurEngine::doClosingCredits() { fi._justifyHeight = 240; fi._pos = Common::Point(38, READ_LE_UINT16(entry)); - _graphicsManager->_vPort->drawText(msg); + _screen->_vPort->drawText(msg); msg += strlen(msg) + 1; fi._foreColor = 2; @@ -345,7 +345,7 @@ void VoyeurEngine::doClosingCredits() { fi._justifyHeight = 240; fi._pos = Common::Point(198, READ_LE_UINT16(entry)); - _graphicsManager->_vPort->drawText(msg); + _screen->_vPort->drawText(msg); msg += strlen(msg) + 1; } @@ -357,7 +357,7 @@ void VoyeurEngine::doClosingCredits() { fi._justifyHeight = 240; fi._pos = Common::Point(0, READ_LE_UINT16(entry)); - _graphicsManager->_vPort->drawText(msg); + _screen->_vPort->drawText(msg); msg += strlen(msg) + 1; fi._foreColor = 2; @@ -367,7 +367,7 @@ void VoyeurEngine::doClosingCredits() { fi._justifyHeight = 240; fi._pos = Common::Point(0, READ_LE_UINT16(entry) + 13); - _graphicsManager->_vPort->drawText(msg); + _screen->_vPort->drawText(msg); msg += strlen(msg) + 1; } @@ -381,19 +381,19 @@ void VoyeurEngine::doClosingCredits() { } _soundManager->stopVOCPlay(); - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; _bVoy->freeBoltGroup(0x400); } void VoyeurEngine::doPiracy() { - _graphicsManager->screenReset(); - _graphicsManager->setColor(1, 0, 0, 0); - _graphicsManager->setColor(2, 255, 255, 255); + _screen->screenReset(); + _screen->setColor(1, 0, 0, 0); + _screen->setColor(2, 255, 255, 255); _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_vPort->setupViewPort(NULL); - _graphicsManager->_vPort->fillPic(1); + _screen->_vPort->setupViewPort(NULL); + _screen->_vPort->fillPic(1); - FontInfoResource &fi = *_graphicsManager->_fontPtr; + FontInfoResource &fi = *_screen->_fontPtr; fi._curFont = _bVoy->boltEntry(0x101)._fontResource; fi._foreColor = 2; fi._backColor = 2; @@ -406,7 +406,7 @@ void VoyeurEngine::doPiracy() { // Loop through the piracy message array to draw each line for (int idx = 0, yp = 33; idx < 10; ++idx) { fi._pos = Common::Point(0, yp); - _graphicsManager->_vPort->drawText(PIRACY_MESSAGE[idx]); + _screen->_vPort->drawText(PIRACY_MESSAGE[idx]); yp += fi._curFont->_fontHeight + 4; } @@ -439,27 +439,27 @@ void VoyeurEngine::reviewTape() { _voy->_viewBounds = _bVoy->boltEntry(0x907)._rectResource; Common::Array &hotspots = _bVoy->boltEntry(0x906)._rectResource->_entries; - _graphicsManager->_backColors = _bVoy->boltEntry(0x902)._cMapResource; - _graphicsManager->_backgroundPage = _bVoy->boltEntry(0x901)._picResource; - _graphicsManager->_vPort->setupViewPort(_graphicsManager->_backgroundPage); - _graphicsManager->_backColors->startFade(); + _screen->_backColors = _bVoy->boltEntry(0x902)._cMapResource; + _screen->_backgroundPage = _bVoy->boltEntry(0x901)._picResource; + _screen->_vPort->setupViewPort(_screen->_backgroundPage); + _screen->_backColors->startFade(); flipPageAndWaitForFade(); - _graphicsManager->setColor(1, 32, 32, 32); - _graphicsManager->setColor(2, 96, 96, 96); - _graphicsManager->setColor(3, 160, 160, 160); - _graphicsManager->setColor(4, 224, 224, 224); - _graphicsManager->setColor(9, 24, 64, 24); - _graphicsManager->setColor(10, 64, 132, 64); - _graphicsManager->setColor(11, 100, 192, 100); - _graphicsManager->setColor(12, 120, 248, 120); + _screen->setColor(1, 32, 32, 32); + _screen->setColor(2, 96, 96, 96); + _screen->setColor(3, 160, 160, 160); + _screen->setColor(4, 224, 224, 224); + _screen->setColor(9, 24, 64, 24); + _screen->setColor(10, 64, 132, 64); + _screen->setColor(11, 100, 192, 100); + _screen->setColor(12, 120, 248, 120); _eventsManager->setCursorColor(128, 1); _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x909)._fontResource; - _graphicsManager->_fontPtr->_fontSaveBack = false; - _graphicsManager->_fontPtr->_fontFlags = DISPFLAG_NONE; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x909)._fontResource; + _screen->_fontPtr->_fontSaveBack = false; + _screen->_fontPtr->_fontFlags = DISPFLAG_NONE; _eventsManager->getMouseInfo(); if (newX == -1) { @@ -481,37 +481,37 @@ void VoyeurEngine::reviewTape() { needRedraw = false; flipPageAndWait(); - _graphicsManager->_drawPtr->_penColor = 0; - _graphicsManager->_drawPtr->_pos = Common::Point(tempRect.left, tempRect.top); - _graphicsManager->_backgroundPage->sFillBox(tempRect.width(), tempRect.height()); + _screen->_drawPtr->_penColor = 0; + _screen->_drawPtr->_pos = Common::Point(tempRect.left, tempRect.top); + _screen->_backgroundPage->sFillBox(tempRect.width(), tempRect.height()); int yp = 45; int eventNum = eventStart; for (int lineNum = 0; lineNum < 8 && eventNum < _voy->_eventCount; ++lineNum, ++eventNum) { - _graphicsManager->_fontPtr->_picFlags = DISPFLAG_NONE; - _graphicsManager->_fontPtr->_picSelect = 0xff; - _graphicsManager->_fontPtr->_picPick = 7; - _graphicsManager->_fontPtr->_picOnOff = (lineNum == eventLine) ? 8 : 0; - _graphicsManager->_fontPtr->_pos = Common::Point(68, yp); - _graphicsManager->_fontPtr->_justify = ALIGN_LEFT; - _graphicsManager->_fontPtr->_justifyWidth = 0; - _graphicsManager->_fontPtr->_justifyHeight = 0; + _screen->_fontPtr->_picFlags = DISPFLAG_NONE; + _screen->_fontPtr->_picSelect = 0xff; + _screen->_fontPtr->_picPick = 7; + _screen->_fontPtr->_picOnOff = (lineNum == eventLine) ? 8 : 0; + _screen->_fontPtr->_pos = Common::Point(68, yp); + _screen->_fontPtr->_justify = ALIGN_LEFT; + _screen->_fontPtr->_justifyWidth = 0; + _screen->_fontPtr->_justifyHeight = 0; Common::String msg = _eventsManager->getEvidString(eventNum); - _graphicsManager->_backgroundPage->drawText(msg); + _screen->_backgroundPage->drawText(msg); yp += 15; } - _graphicsManager->_vPort->addSaveRect( - _graphicsManager->_vPort->_lastPage, tempRect); + _screen->_vPort->addSaveRect( + _screen->_vPort->_lastPage, tempRect); flipPageAndWait(); - _graphicsManager->_vPort->addSaveRect( - _graphicsManager->_vPort->_lastPage, tempRect); + _screen->_vPort->addSaveRect( + _screen->_vPort->_lastPage, tempRect); } - _graphicsManager->sDrawPic(cursor, _graphicsManager->_vPort, + _screen->sDrawPic(cursor, _screen->_vPort, _eventsManager->getMousePos()); flipPageAndWait(); @@ -543,34 +543,34 @@ void VoyeurEngine::reviewTape() { flipPageAndWait(); - _graphicsManager->_drawPtr->_penColor = 0; - _graphicsManager->_drawPtr->_pos = Common::Point(tempRect.left, tempRect.top); - _graphicsManager->_backgroundPage->sFillBox(tempRect.width(), tempRect.height()); + _screen->_drawPtr->_penColor = 0; + _screen->_drawPtr->_pos = Common::Point(tempRect.left, tempRect.top); + _screen->_backgroundPage->sFillBox(tempRect.width(), tempRect.height()); int yp = 45; int eventNum = eventStart; for (int idx = 0; idx < 8 && eventNum < _voy->_eventCount; ++idx, ++eventNum) { - _graphicsManager->_fontPtr->_picFlags = DISPFLAG_NONE; - _graphicsManager->_fontPtr->_picSelect = 0xff; - _graphicsManager->_fontPtr->_picPick = 7; - _graphicsManager->_fontPtr->_picOnOff = (idx == eventLine) ? 8 : 0; - _graphicsManager->_fontPtr->_pos = Common::Point(68, yp); - _graphicsManager->_fontPtr->_justify = ALIGN_LEFT; - _graphicsManager->_fontPtr->_justifyWidth = 0; - _graphicsManager->_fontPtr->_justifyHeight = 0; + _screen->_fontPtr->_picFlags = DISPFLAG_NONE; + _screen->_fontPtr->_picSelect = 0xff; + _screen->_fontPtr->_picPick = 7; + _screen->_fontPtr->_picOnOff = (idx == eventLine) ? 8 : 0; + _screen->_fontPtr->_pos = Common::Point(68, yp); + _screen->_fontPtr->_justify = ALIGN_LEFT; + _screen->_fontPtr->_justifyWidth = 0; + _screen->_fontPtr->_justifyHeight = 0; Common::String msg = _eventsManager->getEvidString(eventNum); - _graphicsManager->_backgroundPage->drawText(msg); + _screen->_backgroundPage->drawText(msg); yp += 15; } - _graphicsManager->_vPort->addSaveRect( - _graphicsManager->_vPort->_lastPage, tempRect); + _screen->_vPort->addSaveRect( + _screen->_vPort->_lastPage, tempRect); flipPageAndWait(); - _graphicsManager->_vPort->addSaveRect( - _graphicsManager->_vPort->_lastPage, tempRect); + _screen->_vPort->addSaveRect( + _screen->_vPort->_lastPage, tempRect); flipPageAndWait(); _eventsManager->getMouseInfo(); @@ -650,7 +650,7 @@ void VoyeurEngine::reviewTape() { newY = _eventsManager->getMousePos().y; _voy->_fadingType = 0; _voy->_viewBounds = nullptr; - _graphicsManager->_vPort->setupViewPort(NULL); + _screen->_vPort->setupViewPort(NULL); if (_currentVocId != -1) { _voy->_vocSecondsOffset = _voy->_RTVNum - _voy->_musicStartTime; @@ -673,13 +673,13 @@ void VoyeurEngine::reviewTape() { _voy->_vocSecondsOffset = e._computerOn; _bVoy->getBoltGroup(0x7F00); - _graphicsManager->_backgroundPage = _bVoy->boltEntry(0x7F00 + + _screen->_backgroundPage = _bVoy->boltEntry(0x7F00 + BLIND_TABLE[_audioVideoId])._picResource; - _graphicsManager->_backColors = _bVoy->boltEntry(0x7F01 + + _screen->_backColors = _bVoy->boltEntry(0x7F01 + BLIND_TABLE[_audioVideoId])._cMapResource; - _graphicsManager->_vPort->setupViewPort(_graphicsManager->_backgroundPage); - _graphicsManager->_backColors->startFade(); + _screen->_vPort->setupViewPort(_screen->_backgroundPage); + _screen->_backColors->startFade(); flipPageAndWaitForFade(); _eventsManager->_intPtr._flashStep = 1; @@ -725,16 +725,16 @@ void VoyeurEngine::reviewTape() { } } - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; - _graphicsManager->_vPort->fillPic(0); + _screen->_vPort->fillPic(0); flipPageAndWait(); _bVoy->freeBoltGroup(0x900); } void VoyeurEngine::doGossip() { - _graphicsManager->resetPalette(); - _graphicsManager->screenReset(); + _screen->resetPalette(); + _screen->screenReset(); if (!_bVoy->getBoltGroup(0x300)) return; @@ -752,7 +752,7 @@ void VoyeurEngine::doGossip() { // Transfer initial background to video decoder PictureResource videoFrame(decoder.getRL2VideoTrack()->getBackSurface()); bgPic->_bounds.moveTo(0, 0); - _graphicsManager->sDrawPic(bgPic, &videoFrame, Common::Point(0, 0)); + _screen->sDrawPic(bgPic, &videoFrame, Common::Point(0, 0)); byte *frameNumsP = _bVoy->memberAddr(0x309); byte *posP = _bVoy->boltEntry(0x30A)._data; @@ -762,8 +762,8 @@ void VoyeurEngine::doGossip() { decoder.close(); // Reset the palette and clear the screen - _graphicsManager->resetPalette(); - _graphicsManager->screenReset(); + _screen->resetPalette(); + _screen->screenReset(); // Play interview video RL2Decoder decoder2; @@ -775,7 +775,7 @@ void VoyeurEngine::doGossip() { decoder2.close(); _bVoy->freeBoltGroup(0x300); - _graphicsManager->screenReset(); + _screen->screenReset(); } void VoyeurEngine::doTapePlaying() { @@ -783,14 +783,14 @@ void VoyeurEngine::doTapePlaying() { return; _eventsManager->getMouseInfo(); - _graphicsManager->_backColors = _bVoy->boltEntry(0xA01)._cMapResource; - _graphicsManager->_backgroundPage = _bVoy->boltEntry(0xA00)._picResource; + _screen->_backColors = _bVoy->boltEntry(0xA01)._cMapResource; + _screen->_backgroundPage = _bVoy->boltEntry(0xA00)._picResource; PictureResource *pic = _bVoy->boltEntry(0xA02)._picResource; VInitCycleResource *cycle = _bVoy->boltEntry(0xA05)._vInitCycleResource; - _graphicsManager->_vPort->setupViewPort(_graphicsManager->_backgroundPage); - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point(57, 30)); - _graphicsManager->_backColors->startFade(); + _screen->_vPort->setupViewPort(_screen->_backgroundPage); + _screen->sDrawPic(pic, _screen->_vPort, Common::Point(57, 30)); + _screen->_backColors->startFade(); flipPageAndWaitForFade(); cycle->vStartCycle(); @@ -932,9 +932,9 @@ int VoyeurEngine::getChooseButton() { + 6)._rectResource->_entries; int selectedIndex = -1; - _graphicsManager->_vPort->setupViewPort(_graphicsManager->_backgroundPage); - _graphicsManager->_backColors->_steps = 0; - _graphicsManager->_backColors->startFade(); + _screen->_vPort->setupViewPort(_screen->_backgroundPage); + _screen->_backColors->_steps = 0; + _screen->_backColors->startFade(); flipPageAndWait(); _voy->_viewBounds = _bVoy->boltEntry(_playStampGroupId + 7)._rectResource; @@ -955,7 +955,7 @@ int VoyeurEngine::getChooseButton() { selectedIndex = idx; if (selectedIndex != prevIndex) { PictureResource *btnPic = _bVoy->boltEntry(_playStampGroupId + 8 + idx)._picResource; - _graphicsManager->sDrawPic(btnPic, _graphicsManager->_vPort, + _screen->sDrawPic(btnPic, _screen->_vPort, Common::Point(106, 200)); cursorPic = _bVoy->boltEntry(_playStampGroupId + 4)._picResource; @@ -967,11 +967,11 @@ int VoyeurEngine::getChooseButton() { if (selectedIndex == -1) { cursorPic = _bVoy->boltEntry(_playStampGroupId + 2)._picResource; PictureResource *btnPic = _bVoy->boltEntry(_playStampGroupId + 12)._picResource; - _graphicsManager->sDrawPic(btnPic, _graphicsManager->_vPort, + _screen->sDrawPic(btnPic, _screen->_vPort, Common::Point(106, 200)); } - _graphicsManager->sDrawPic(cursorPic, _graphicsManager->_vPort, + _screen->sDrawPic(cursorPic, _screen->_vPort, Common::Point(pt.x + 13, pt.y - 12)); flipPageAndWait(); @@ -982,9 +982,9 @@ int VoyeurEngine::getChooseButton() { } void VoyeurEngine::makeViewFinder() { - _graphicsManager->_backgroundPage = _bVoy->boltEntry(0x103)._picResource; - _graphicsManager->sDrawPic(_graphicsManager->_backgroundPage, - _graphicsManager->_vPort, Common::Point(0, 0)); + _screen->_backgroundPage = _bVoy->boltEntry(0x103)._picResource; + _screen->sDrawPic(_screen->_backgroundPage, + _screen->_vPort, Common::Point(0, 0)); CMapResource *pal = _bVoy->boltEntry(0x104)._cMapResource; int palOffset = 0; @@ -1016,22 +1016,22 @@ void VoyeurEngine::makeViewFinder() { break; } - _graphicsManager->_vPort->drawIfaceTime(); + _screen->_vPort->drawIfaceTime(); doTimeBar(); pal->startFade(); flipPageAndWaitForFade(); - _graphicsManager->setColor(241, 105, 105, 105); - _graphicsManager->setColor(242, 105, 105, 105); - _graphicsManager->setColor(243, 105, 105, 105); - _graphicsManager->setColor(palOffset + 241, 219, 235, 235); + _screen->setColor(241, 105, 105, 105); + _screen->setColor(242, 105, 105, 105); + _screen->setColor(243, 105, 105, 105); + _screen->setColor(palOffset + 241, 219, 235, 235); _eventsManager->_intPtr._hasPalette = true; } void VoyeurEngine::makeViewFinderP() { - _graphicsManager->screenReset(); + _screen->screenReset(); } void VoyeurEngine::initIFace() { @@ -1077,7 +1077,7 @@ void VoyeurEngine::initIFace() { void VoyeurEngine::doScroll(const Common::Point &pt) { Common::Rect clipRect(72, 47, 72 + 240, 47 + 148); - _graphicsManager->_vPort->setupViewPort(NULL, &clipRect); + _screen->_vPort->setupViewPort(NULL, &clipRect); int base = 0; switch (_voy->_transitionId) { @@ -1101,18 +1101,18 @@ void VoyeurEngine::doScroll(const Common::Point &pt) { if (base) { PictureResource *pic = _bVoy->boltEntry(base + 3)._picResource; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y - 104)); + _screen->sDrawPic(pic, _screen->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y - 104)); pic = _bVoy->boltEntry(base + 4)._picResource; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y - 44)); + _screen->sDrawPic(pic, _screen->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y - 44)); pic = _bVoy->boltEntry(base + 5)._picResource; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y + 16)); + _screen->sDrawPic(pic, _screen->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y + 16)); pic = _bVoy->boltEntry(base + 6)._picResource; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y + 76)); + _screen->sDrawPic(pic, _screen->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y + 76)); pic = _bVoy->boltEntry(base + 7)._picResource; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y + 136)); + _screen->sDrawPic(pic, _screen->_vPort, Common::Point(784 - pt.x - 712, 150 - pt.y + 136)); } - _graphicsManager->_vPort->setupViewPort(NULL); + _screen->_vPort->setupViewPort(NULL); } void VoyeurEngine::checkTransition() { @@ -1124,7 +1124,7 @@ void VoyeurEngine::checkTransition() { // Only proceed if a valid day string was returned if (!day.empty()) { - _graphicsManager->fadeDownICF(6); + _screen->fadeDownICF(6); // Get the time of day string time = getTimeOfDay(); @@ -1163,7 +1163,7 @@ Common::String VoyeurEngine::getTimeOfDay() { } int VoyeurEngine::doComputerText(int maxLen) { - FontInfoResource &font = *_graphicsManager->_fontPtr; + FontInfoResource &font = *_screen->_fontPtr; int totalChars = 0; font._curFont = _bVoy->boltEntry(0x4910)._fontResource; @@ -1180,7 +1180,7 @@ int VoyeurEngine::doComputerText(int maxLen) { font._justifyWidth = 384; font._justifyHeight = 100; font._pos = Common::Point(128, 100); - _graphicsManager->_vPort->drawText(END_OF_MESSAGE); + _screen->_vPort->drawText(END_OF_MESSAGE); } else if (_voy->_RTVNum < _voy->_computerTimeMin && maxLen == 9999) { if (_currentVocId != -1) _soundManager->startVOCPlay(_currentVocId); @@ -1188,7 +1188,7 @@ int VoyeurEngine::doComputerText(int maxLen) { font._justifyWidth = 384; font._justifyHeight = 100; font._pos = Common::Point(120, 100); - _graphicsManager->_vPort->drawText(START_OF_MESSAGE); + _screen->_vPort->drawText(START_OF_MESSAGE); } else { char *msg = (char *)_bVoy->memberAddr(0x4900 + _voy->_computerTextId); font._pos = Common::Point(96, 60); @@ -1206,14 +1206,14 @@ int VoyeurEngine::doComputerText(int maxLen) { if (c == '\0') { if (showEnd) { _eventsManager->delay(90); - _graphicsManager->_drawPtr->_pos = Common::Point(96, 54); - _graphicsManager->_drawPtr->_penColor = 254; - _graphicsManager->_vPort->sFillBox(196, 124); - _graphicsManager->_fontPtr->_justify = ALIGN_LEFT; - _graphicsManager->_fontPtr->_justifyWidth = 384; - _graphicsManager->_fontPtr->_justifyHeight = 100; - _graphicsManager->_fontPtr->_pos = Common::Point(128, 100); - _graphicsManager->_vPort->drawText(END_OF_MESSAGE); + _screen->_drawPtr->_pos = Common::Point(96, 54); + _screen->_drawPtr->_penColor = 254; + _screen->_vPort->sFillBox(196, 124); + _screen->_fontPtr->_justify = ALIGN_LEFT; + _screen->_fontPtr->_justifyWidth = 384; + _screen->_fontPtr->_justifyHeight = 100; + _screen->_fontPtr->_pos = Common::Point(128, 100); + _screen->_vPort->drawText(END_OF_MESSAGE); } break; } @@ -1223,20 +1223,20 @@ int VoyeurEngine::doComputerText(int maxLen) { yp += 10; } else { _eventsManager->delay(90); - _graphicsManager->_drawPtr->_pos = Common::Point(96, 54); - _graphicsManager->_drawPtr->_penColor = 255; - _graphicsManager->_vPort->sFillBox(196, 124); + _screen->_drawPtr->_pos = Common::Point(96, 54); + _screen->_drawPtr->_penColor = 255; + _screen->_vPort->sFillBox(196, 124); yp = 60; } - _graphicsManager->_fontPtr->_pos = Common::Point(96, yp); + _screen->_fontPtr->_pos = Common::Point(96, yp); } else if (c == '_') { showEnd = false; } else { - _graphicsManager->_fontPtr->_justify = ALIGN_LEFT; - _graphicsManager->_fontPtr->_justifyWidth = 0; - _graphicsManager->_fontPtr->_justifyHeight = 0; - _graphicsManager->_vPort->drawText(Common::String(c)); + _screen->_fontPtr->_justify = ALIGN_LEFT; + _screen->_fontPtr->_justifyWidth = 0; + _screen->_fontPtr->_justifyHeight = 0; + _screen->_vPort->drawText(Common::String(c)); _eventsManager->delay(4); } @@ -1251,7 +1251,7 @@ int VoyeurEngine::doComputerText(int maxLen) { flipPageAndWait(); - _graphicsManager->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; + _screen->_fontPtr->_curFont = _bVoy->boltEntry(0x101)._fontResource; return totalChars; } @@ -1263,7 +1263,7 @@ void VoyeurEngine::getComputerBrush() { int xp = (384 - pic->_bounds.width()) / 2; int yp = (240 - pic->_bounds.height()) / 2 - 4; - _graphicsManager->_vPort->drawPicPerm(pic, Common::Point(xp, yp)); + _screen->_vPort->drawPicPerm(pic, Common::Point(xp, yp)); CMapResource *pal = _bVoy->boltEntry(0x490F)._cMapResource; pal->startFade(); @@ -1280,17 +1280,17 @@ void VoyeurEngine::doTimeBar() { int height = ((_voy->_RTVLimit - _voy->_RTVNum) * 59) / _voy->_RTVLimit; int fullHeight = MAX(151 - height, 93); - _graphicsManager->_drawPtr->_penColor = 134; - _graphicsManager->_drawPtr->_pos = Common::Point(39, 92); + _screen->_drawPtr->_penColor = 134; + _screen->_drawPtr->_pos = Common::Point(39, 92); - _graphicsManager->_vPort->sFillBox(6, fullHeight - 92); + _screen->_vPort->sFillBox(6, fullHeight - 92); if (height > 0) { - _graphicsManager->setColor(215, 238, 238, 238); + _screen->setColor(215, 238, 238, 238); _eventsManager->_intPtr._hasPalette = true; - _graphicsManager->_drawPtr->_penColor = 215; - _graphicsManager->_drawPtr->_pos = Common::Point(39, fullHeight); - _graphicsManager->_vPort->sFillBox(6, height); + _screen->_drawPtr->_penColor = 215; + _screen->_drawPtr->_pos = Common::Point(39, fullHeight); + _screen->_vPort->sFillBox(6, height); } } } @@ -1303,9 +1303,9 @@ void VoyeurEngine::flashTimeBar() { _flashTimeVal = _eventsManager->_intPtr._flashTimer; if (_flashTimeFlag) - _graphicsManager->setColor(240, 220, 20, 20); + _screen->setColor(240, 220, 20, 20); else - _graphicsManager->setColor(240, 220, 220, 220); + _screen->setColor(240, 220, 220, 220); _eventsManager->_intPtr._hasPalette = true; _flashTimeFlag = !_flashTimeFlag; @@ -1343,7 +1343,7 @@ void VoyeurEngine::doEvidDisplay(int evidId, int eventId) { _bVoy->getBoltGroup(_voy->_boltGroupId2); PictureResource *pic = _bVoy->boltEntry(_voy->_boltGroupId2 + evidId * 2)._picResource; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, Common::Point( + _screen->sDrawPic(pic, _screen->_vPort, Common::Point( (384 - pic->_bounds.width()) / 2, (240 - pic->_bounds.height()) / 2)); _bVoy->freeBoltMember(_voy->_boltGroupId2 + evidId * 2); @@ -1394,7 +1394,7 @@ void VoyeurEngine::doEvidDisplay(int evidId, int eventId) { continue; pic = _voy->_evPicPtrs[arrIndex]; - _graphicsManager->sDrawPic(pic, _graphicsManager->_vPort, + _screen->sDrawPic(pic, _screen->_vPort, Common::Point((384 - pic->_bounds.width()) / 2, (240 - pic->_bounds.height()) / 2)); _voy->_evCmPtrs[arrIndex]->startFade(); -- cgit v1.2.3