diff options
author | Filippos Karapetis | 2009-10-31 10:54:19 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-31 10:54:19 +0000 |
commit | 71db8b851bf27bb4c76e5122161b3a0fe38c3ed3 (patch) | |
tree | 12533bd8ca37d8c0c0a1972de7009a05ea6d8bc3 /engines/sci | |
parent | d76c1c65522a852562d213ca1c5410251b065774 (diff) | |
download | scummvm-rg350-71db8b851bf27bb4c76e5122161b3a0fe38c3ed3.tar.gz scummvm-rg350-71db8b851bf27bb4c76e5122161b3a0fe38c3ed3.tar.bz2 scummvm-rg350-71db8b851bf27bb4c76e5122161b3a0fe38c3ed3.zip |
Some more work on KQ6 hi res version - screen scaling should be done now, but other methods haven't been updated yet
svn-id: r45555
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/gui/gui_screen.cpp | 33 | ||||
-rw-r--r-- | engines/sci/gui/gui_screen.h | 2 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 22 |
3 files changed, 43 insertions, 14 deletions
diff --git a/engines/sci/gui/gui_screen.cpp b/engines/sci/gui/gui_screen.cpp index 627708cf43..eeced790e7 100644 --- a/engines/sci/gui/gui_screen.cpp +++ b/engines/sci/gui/gui_screen.cpp @@ -34,11 +34,13 @@ namespace Sci { SciGuiScreen::SciGuiScreen(ResourceManager *resMan, int16 width, int16 height, int16 scaleFactor) : - _resMan(resMan), _width(width), _height(height) { + _resMan(resMan), _width(width), _height(height), _scaleFactor(scaleFactor) { _pixels = _width * _height; - // if you want to do scaling, adjust putPixel() accordingly + if (scaleFactor != 1 && scaleFactor != 2) + error("Only scaling factors of 1 or 2 are supported"); + _displayWidth = _width * scaleFactor; _displayHeight = _height * scaleFactor; _displayPixels = _displayWidth * _displayHeight; @@ -64,6 +66,9 @@ SciGuiScreen::SciGuiScreen(ResourceManager *resMan, int16 width, int16 height, i _colorWhite = 15; _colorDefaultVectorData = 0; } + + // Initialize the actual screen + initGraphics(_displayWidth, _displayHeight, _displayWidth > 320); } SciGuiScreen::~SciGuiScreen() { @@ -103,12 +108,26 @@ byte SciGuiScreen::getDrawingMask(byte color, byte prio, byte control) { return flag; } +Common::Rect SciGuiScreen::getScaledRect(Common::Rect rect) { + return Common::Rect( + rect.left * _scaleFactor, rect.top * _scaleFactor, + rect.left * _scaleFactor + rect.width() * _scaleFactor, + rect.top * _scaleFactor + rect.height() * _scaleFactor); +} + void SciGuiScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) { int offset = y * _width + x; + int displayOffset = y * _displayWidth * _scaleFactor + x * _scaleFactor; if (drawMask & SCI_SCREEN_MASK_VISUAL) { _visualScreen[offset] = color; - _displayScreen[offset] = color; + _displayScreen[displayOffset] = color; + + // If we need to scale, update the display screen appropriately + if (_scaleFactor != 1) + _displayScreen[(y + 1) * _displayWidth + x] = color; // one pixel down + _displayScreen[y * _displayWidth + x + 1] = color; // one pixel right + _displayScreen[(y + 1) * _displayWidth + x + 1] = color; // one pixel down and right } if (drawMask & SCI_SCREEN_MASK_PRIORITY) _priorityScreen[offset] = priority; @@ -208,9 +227,11 @@ byte SciGuiScreen::isFillMatch(int16 x, int16 y, byte screenMask, byte t_color, int SciGuiScreen::bitsGetDataSize(Common::Rect rect, byte mask) { int byteCount = sizeof(rect) + sizeof(mask); int pixels = rect.width() * rect.height(); + Common::Rect scaledRect = getScaledRect(rect); + int scaledPixels = scaledRect.width() * scaledRect.height(); if (mask & SCI_SCREEN_MASK_VISUAL) { byteCount += pixels; // _visualScreen - byteCount += pixels; // _displayScreen + byteCount += scaledPixels; // _displayScreen } if (mask & SCI_SCREEN_MASK_PRIORITY) { byteCount += pixels; // _priorityScreen @@ -228,7 +249,7 @@ void SciGuiScreen::bitsSave(Common::Rect rect, byte mask, byte *memoryPtr) { if (mask & SCI_SCREEN_MASK_VISUAL) { bitsSaveScreen(rect, _visualScreen, memoryPtr); - bitsSaveScreen(rect, _displayScreen, memoryPtr); + bitsSaveScreen(getScaledRect(rect), _displayScreen, memoryPtr); } if (mask & SCI_SCREEN_MASK_PRIORITY) { bitsSaveScreen(rect, _priorityScreen, memoryPtr); @@ -263,7 +284,7 @@ void SciGuiScreen::bitsRestore(byte *memoryPtr) { if (mask & SCI_SCREEN_MASK_VISUAL) { bitsRestoreScreen(rect, memoryPtr, _visualScreen); - bitsRestoreScreen(rect, memoryPtr, _displayScreen); + bitsRestoreScreen(getScaledRect(rect), memoryPtr, _displayScreen); } if (mask & SCI_SCREEN_MASK_PRIORITY) { bitsRestoreScreen(rect, memoryPtr, _priorityScreen); diff --git a/engines/sci/gui/gui_screen.h b/engines/sci/gui/gui_screen.h index a30ddc48da..4cac837f3a 100644 --- a/engines/sci/gui/gui_screen.h +++ b/engines/sci/gui/gui_screen.h @@ -106,11 +106,13 @@ public: // HACK. TODO: make private // SCI0 games may be undithered in here. Only read from this buffer for Save/ShowBits usage. byte *_displayScreen; private: + Common::Rect getScaledRect(Common::Rect rect); ResourceManager *_resMan; // this is a pointer to the currently active screen (changing it only required for debug purposes) byte *_activeScreen; + int _scaleFactor; }; } // End of namespace Sci diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index a45abcc90e..4c0441e0f1 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -96,11 +96,6 @@ SciEngine::~SciEngine() { } Common::Error SciEngine::run() { - initGraphics(320, 200, false); - - // Create debugger console. It requires GFX to be initialized - _console = new Console(this); - // FIXME/TODO: Move some of the stuff below to init() _resMan = new ResourceManager(); @@ -110,12 +105,23 @@ Common::Error SciEngine::run() { return Common::kNoGameDataFoundError; } - _kernel = new Kernel(_resMan); - _vocabulary = new Vocabulary(_resMan); - SciGuiScreen *screen = new SciGuiScreen(_resMan); + int scaleFactor = 1; + + // Scale the screen, if needed + if (!strcmp(getGameID(), "kq6") && getPlatform() == Common::kPlatformWindows) + scaleFactor = 2; + + // Initialize graphics-related parts + SciGuiScreen *screen = new SciGuiScreen(_resMan, 320, 200, scaleFactor); // invokes initGraphics() SciGuiPalette *palette = new SciGuiPalette(_resMan, screen); SciGuiCursor *cursor = new SciGuiCursor(_resMan, palette, screen); + // Create debugger console. It requires GFX to be initialized + _console = new Console(this); + + _kernel = new Kernel(_resMan); + _vocabulary = new Vocabulary(_resMan); + // We'll set the GUI below _gamestate = new EngineState(_resMan, _kernel, _vocabulary, NULL, cursor); |