From f55ff7ba2184168bcbb3131a7ae978bc75032ff0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 May 2015 17:21:21 -0400 Subject: SHERLOCK: Fix display of beveled background when entering Journal search --- engines/sherlock/screen.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index cbf18f146f..c1c53fbe65 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -467,7 +467,7 @@ void Screen::buttonPrint(const Common::Point &pt, byte color, bool slamIt, } /** - * Draw a panel in th eback buffer with a raised area effect around the edges + * Draw a panel in the back buffer with a raised area effect around the edges */ void Screen::makePanel(const Common::Rect &r) { _backBuffer->fillRect(r, BUTTON_MIDDLE); @@ -482,6 +482,18 @@ void Screen::makePanel(const Common::Rect &r) { _backBuffer->hLine(r.left + 1, r.bottom - 2, r.right - 1, BUTTON_BOTTOM); } +/** + * Draw a field in the back buffer with a raised area effect around the edges, + * suitable for text input. + */ +void Screen::makeField(const Common::Rect &r) { + _backBuffer->fillRect(r, BUTTON_MIDDLE); + _backBuffer->hLine(r.left, r.top, r.right - 1, BUTTON_BOTTOM); + _backBuffer->hLine(r.left + 1, r.bottom - 1, r.right - 1, BUTTON_TOP); + _backBuffer->vLine(r.left, r.top + 1, r.bottom - 1, BUTTON_BOTTOM); + _backBuffer->vLine(r.right - 1, r.top + 1, r.bottom - 2, BUTTON_TOP); +} + /** * Sets the active back buffer pointer to a restricted sub-area of the first back buffer */ -- cgit v1.2.3 From d82d476b277f80b69514fcb360ec47e9482e4a28 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 May 2015 20:57:27 +0200 Subject: SHERLOCK: Add code to make non-interactive demo completable --- engines/sherlock/screen.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index c1c53fbe65..e98d9a51a9 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -53,6 +53,10 @@ Screen::~Screen() { * Set the font to use for writing text on the screen */ void Screen::setFont(int fontNumb) { + // Interactive demo doesn't use fonts + if (!_vm->_interactiveFl) + return; + _fontNumber = fontNumb; Common::String fname = Common::String::format("FONT%d.VGS", fontNumb + 1); -- cgit v1.2.3 From 0aebac9174f935e535b8e133efde43bd94be5b27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 18 May 2015 23:23:37 +0200 Subject: SHERLOCK: Fix some issues pointed by LordHoto --- engines/sherlock/screen.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index e98d9a51a9..d9ec1d745d 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -116,8 +116,7 @@ int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) { // For any palette component that doesn't already match the given destination // palette, change by 1 towards the reference palette component for (int idx = 0; idx < PALETTE_SIZE; ++idx) { - if (tempPalette[idx] > palette[idx]) - { + if (tempPalette[idx] > palette[idx]) { tempPalette[idx] = MAX((int)palette[idx], (int)tempPalette[idx] - 4); ++total; } else if (tempPalette[idx] < palette[idx]) { @@ -216,7 +215,7 @@ void Screen::randomTransition() { for (int idx = 0; idx <= 65535 && !_vm->shouldQuit(); ++idx) { _transitionSeed = _transitionSeed * TRANSITION_MULTIPLIER + 1; - int offset = _transitionSeed & 65535; + int offset = _transitionSeed & 0xFFFF; if (offset < (SHERLOCK_SCREEN_WIDTH * SHERLOCK_SCREEN_HEIGHT)) *((byte *)getPixels() + offset) = *((const byte *)_backBuffer->getPixels() + offset); -- cgit v1.2.3 From a09937121c3844071ab992115f32b47d57a5d337 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 20:57:58 -0400 Subject: SHERLOCK: Syntactic fixes --- engines/sherlock/screen.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index d9ec1d745d..4c70bf21c5 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -328,13 +328,10 @@ void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, */ void Screen::print(const Common::Point &pt, byte color, const char *formatStr, ...) { // Create the string to display - char buffer[100]; va_list args; - va_start(args, formatStr); - vsprintf(buffer, formatStr, args); + Common::String str = Common::String::vformat(formatStr, args); va_end(args); - Common::String str(buffer); // Figure out area to draw text in Common::Point pos = pt; @@ -362,13 +359,10 @@ void Screen::print(const Common::Point &pt, byte color, const char *formatStr, . */ void Screen::gPrint(const Common::Point &pt, byte color, const char *formatStr, ...) { // Create the string to display - char buffer[100]; va_list args; - va_start(args, formatStr); - vsprintf(buffer, formatStr, args); + Common::String str = Common::String::vformat(formatStr, args); va_end(args); - Common::String str(buffer); // Print the text writeString(str, pt, color); -- cgit v1.2.3 From 7c3ac25ac153a2934ee94c8aa83b72843bd56351 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 May 2015 23:44:59 -0400 Subject: SHERLOCK: Further syntactic fixes --- engines/sherlock/screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index 4c70bf21c5..f43bf17288 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -387,7 +387,7 @@ int Screen::stringWidth(const Common::String &str) { int Screen::charWidth(char c) { if (c == ' ') return 5; - else if (c > ' ' && c <= '~') + else if (Common::isPrint(c)) return (*_font)[c - 33]._frame.w + 1; else return 0; @@ -403,7 +403,7 @@ void Screen::writeString(const Common::String &str, const Common::Point &pt, byt if (*c == ' ') charPos.x += 5; else { - assert(*c > ' ' && *c <= '~'); + assert(Common::isPrint(*c)); ImageFrame &frame = (*_font)[*c - 33]; _backBuffer->transBlitFrom(frame, charPos, false, color); charPos.x += frame._frame.w + 1; -- cgit v1.2.3 From 1df183ffcb08a69ed414afd69284a0596fee4e82 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 07:37:55 -0400 Subject: SHERLOCK: Move method comments from cpp to headers --- engines/sherlock/screen.cpp | 96 --------------------------------------------- 1 file changed, 96 deletions(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index f43bf17288..583ac5b485 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -49,9 +49,6 @@ Screen::~Screen() { delete _font; } -/** - * Set the font to use for writing text on the screen - */ void Screen::setFont(int fontNumb) { // Interactive demo doesn't use fonts if (!_vm->_interactiveFl) @@ -70,9 +67,6 @@ void Screen::setFont(int fontNumb) { _fontHeight = MAX((uint16)_fontHeight, (*_font)[idx]._frame.h); } -/** - * Handles updating any dirty areas of the screen Surface object to the physical screen - */ void Screen::update() { // Merge the dirty rects mergeDirtyRects(); @@ -91,23 +85,14 @@ void Screen::update() { _dirtyRects.clear(); } -/** - * Return the currently active palette - */ void Screen::getPalette(byte palette[PALETTE_SIZE]) { g_system->getPaletteManager()->grabPalette(palette, 0, PALETTE_COUNT); } -/** - * Set the palette - */ void Screen::setPalette(const byte palette[PALETTE_SIZE]) { g_system->getPaletteManager()->setPalette(palette, 0, PALETTE_COUNT); } -/** - * Fades from the currently active palette to the passed palette - */ int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) { int total = 0; byte tempPalette[PALETTE_SIZE]; @@ -132,9 +117,6 @@ int Screen::equalizePalette(const byte palette[PALETTE_SIZE]) { return total; } -/** - * Fade out the palette to black - */ void Screen::fadeToBlack(int speed) { byte tempPalette[PALETTE_SIZE]; Common::fill(&tempPalette[0], &tempPalette[PALETTE_SIZE], 0); @@ -147,9 +129,6 @@ void Screen::fadeToBlack(int speed) { fillRect(Common::Rect(0, 0, this->w, this->h), 0); } -/** - * Fade in a given palette - */ void Screen::fadeIn(const byte palette[PALETTE_SIZE], int speed) { int count = 50; while (equalizePalette(palette) && --count) { @@ -159,18 +138,11 @@ void Screen::fadeIn(const byte palette[PALETTE_SIZE], int speed) { setPalette(palette); } -/** - * Adds a rectangle to the list of modified areas of the screen during the - * current frame - */ void Screen::addDirtyRect(const Common::Rect &r) { _dirtyRects.push_back(r); assert(r.width() > 0 && r.height() > 0); } -/** - * Merges together overlapping dirty areas of the screen - */ void Screen::mergeDirtyRects() { Common::List::iterator rOuter, rInner; @@ -195,9 +167,6 @@ void Screen::mergeDirtyRects() { } } -/** - * Returns the union of two dirty area rectangles - */ bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2) { destRect = src1; destRect.extend(src2); @@ -205,9 +174,6 @@ bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, co return !destRect.isEmpty(); } -/** - * Do a random pixel transition in from _backBuffer surface to the screen - */ void Screen::randomTransition() { Events &events = *_vm->_events; const int TRANSITION_MULTIPLIER = 0x15a4e35; @@ -234,9 +200,6 @@ void Screen::randomTransition() { blitFrom(*_backBuffer); } -/** - * Transition to the surface from _backBuffer using a vertical transition - */ void Screen::verticalTransition() { Events &events = *_vm->_events; @@ -259,9 +222,6 @@ void Screen::verticalTransition() { } } -/** - * Copies a section of the second back buffer into the main back buffer - */ void Screen::restoreBackground(const Common::Rect &r) { if (r.width() > 0 && r.height() > 0) { Common::Rect tempRect = r; @@ -272,16 +232,10 @@ void Screen::restoreBackground(const Common::Rect &r) { } } -/** - * Copies a given area to the screen - */ void Screen::slamArea(int16 xp, int16 yp, int16 width, int16 height) { slamRect(Common::Rect(xp, yp, xp + width, yp + height)); } -/** - * Copies a given area to the screen - */ void Screen::slamRect(const Common::Rect &r) { if (r.width() && r.height() > 0) { Common::Rect tempRect = r; @@ -292,10 +246,6 @@ void Screen::slamRect(const Common::Rect &r) { } } -/** - * Copy an image from the back buffer to the screen, taking care of both the - * new area covered by the shape as well as the old area, which must be restored - */ void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, int16 *xp, int16 *yp, int16 *width, int16 *height) { Common::Point imgPos = pt + frame->_offset; @@ -322,10 +272,6 @@ void Screen::flushImage(ImageFrame *frame, const Common::Point &pt, *height = newBounds.height(); } -/** - * Prints the text passed onto the back buffer at the given position and color. - * The string is then blitted to the screen - */ void Screen::print(const Common::Point &pt, byte color, const char *formatStr, ...) { // Create the string to display va_list args; @@ -354,9 +300,6 @@ void Screen::print(const Common::Point &pt, byte color, const char *formatStr, . slamRect(textBounds); } -/** - * Print a strings onto the back buffer without blitting it to the screen - */ void Screen::gPrint(const Common::Point &pt, byte color, const char *formatStr, ...) { // Create the string to display va_list args; @@ -368,10 +311,6 @@ void Screen::gPrint(const Common::Point &pt, byte color, const char *formatStr, writeString(str, pt, color); } - -/** - * Returns the width of a string in pixels - */ int Screen::stringWidth(const Common::String &str) { int width = 0; @@ -381,9 +320,6 @@ int Screen::stringWidth(const Common::String &str) { return width; } -/** - * Returns the width of a character in pixels - */ int Screen::charWidth(char c) { if (c == ' ') return 5; @@ -393,9 +329,6 @@ int Screen::charWidth(char c) { return 0; } -/** - * Draws the given string into the back buffer using the images stored in _font - */ void Screen::writeString(const Common::String &str, const Common::Point &pt, byte color) { Common::Point charPos = pt; @@ -411,17 +344,11 @@ void Screen::writeString(const Common::String &str, const Common::Point &pt, byt } } -/** - * Fills an area on the back buffer, and then copies it to the screen - */ void Screen::vgaBar(const Common::Rect &r, int color) { _backBuffer->fillRect(r, color); slamRect(r); } -/** - * Draws a button for use in the inventory, talk, and examine dialogs. - */ void Screen::makeButton(const Common::Rect &bounds, int textX, const Common::String &str) { @@ -437,10 +364,6 @@ void Screen::makeButton(const Common::Rect &bounds, int textX, COMMAND_FOREGROUND, "%s", str.c_str() + 1); } -/** - * Prints an interface command with the first letter highlighted to indicate - * what keyboard shortcut is associated with it - */ void Screen::buttonPrint(const Common::Point &pt, byte color, bool slamIt, const Common::String &str) { int xStart = pt.x - stringWidth(str) / 2; @@ -463,9 +386,6 @@ void Screen::buttonPrint(const Common::Point &pt, byte color, bool slamIt, } } -/** - * Draw a panel in the back buffer with a raised area effect around the edges - */ void Screen::makePanel(const Common::Rect &r) { _backBuffer->fillRect(r, BUTTON_MIDDLE); _backBuffer->hLine(r.left, r.top, r.right - 2, BUTTON_TOP); @@ -479,10 +399,6 @@ void Screen::makePanel(const Common::Rect &r) { _backBuffer->hLine(r.left + 1, r.bottom - 2, r.right - 1, BUTTON_BOTTOM); } -/** - * Draw a field in the back buffer with a raised area effect around the edges, - * suitable for text input. - */ void Screen::makeField(const Common::Rect &r) { _backBuffer->fillRect(r, BUTTON_MIDDLE); _backBuffer->hLine(r.left, r.top, r.right - 1, BUTTON_BOTTOM); @@ -491,9 +407,6 @@ void Screen::makeField(const Common::Rect &r) { _backBuffer->vLine(r.right - 1, r.top + 1, r.bottom - 2, BUTTON_TOP); } -/** - * Sets the active back buffer pointer to a restricted sub-area of the first back buffer - */ void Screen::setDisplayBounds(const Common::Rect &r) { assert(r.left == 0 && r.top == 0); _sceneSurface.setPixels(_backBuffer1.getPixels()); @@ -503,24 +416,15 @@ void Screen::setDisplayBounds(const Common::Rect &r) { _backBuffer = &_sceneSurface; } -/** - * Resets the active buffer pointer to point back to the full first back buffer - */ void Screen::resetDisplayBounds() { _backBuffer = &_backBuffer1; } -/** - * Return the size of the current display window - */ Common::Rect Screen::getDisplayBounds() { return (_backBuffer == &_sceneSurface) ? Common::Rect(0, 0, _sceneSurface.w, _sceneSurface.h) : Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); } -/** - * Synchronize the data for a savegame - */ void Screen::synchronize(Common::Serializer &s) { int fontNumb = _fontNumber; s.syncAsByte(fontNumb); -- cgit v1.2.3 From 8ae0014bc25e42e519d5a6a31279ee22580aaba9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 May 2015 09:10:35 -0400 Subject: SHERLOCK: Refactor Surface not to descend directly from Graphics::Surface --- engines/sherlock/screen.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index 583ac5b485..1d3c0e0dbf 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -39,10 +39,6 @@ Screen::Screen(SherlockEngine *vm) : Surface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCR Common::fill(&_cMap[0], &_cMap[PALETTE_SIZE], 0); Common::fill(&_sMap[0], &_sMap[PALETTE_SIZE], 0); setFont(1); - - // Set dummy surface used for restricted scene drawing - _sceneSurface.format = Graphics::PixelFormat::createFormatCLUT8(); - _sceneSurface.pitch = SHERLOCK_SCREEN_WIDTH; } Screen::~Screen() { @@ -76,7 +72,7 @@ void Screen::update() { for (i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) { const Common::Rect &r = *i; const byte *srcP = (const byte *)getBasePtr(r.left, r.top); - g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top, + g_system->copyRectToScreen(srcP, _surface.pitch, r.left, r.top, r.width(), r.height()); } @@ -126,7 +122,7 @@ void Screen::fadeToBlack(int speed) { } setPalette(tempPalette); - fillRect(Common::Rect(0, 0, this->w, this->h), 0); + fillRect(Common::Rect(0, 0, _surface.w, _surface.h), 0); } void Screen::fadeIn(const byte palette[PALETTE_SIZE], int speed) { @@ -189,7 +185,7 @@ void Screen::randomTransition() { if (idx != 0 && (idx % 300) == 0) { // Ensure there's a full screen dirty rect for the next frame update if (_dirtyRects.empty()) - addDirtyRect(Common::Rect(0, 0, this->w, this->h)); + addDirtyRect(Common::Rect(0, 0, _surface.w, _surface.h)); events.pollEvents(); events.delay(1); @@ -409,9 +405,7 @@ void Screen::makeField(const Common::Rect &r) { void Screen::setDisplayBounds(const Common::Rect &r) { assert(r.left == 0 && r.top == 0); - _sceneSurface.setPixels(_backBuffer1.getPixels()); - _sceneSurface.w = r.width(); - _sceneSurface.h = r.height(); + _sceneSurface.setPixels(_backBuffer1.getPixels(), r.width(), r.height()); _backBuffer = &_sceneSurface; } @@ -421,7 +415,7 @@ void Screen::resetDisplayBounds() { } Common::Rect Screen::getDisplayBounds() { - return (_backBuffer == &_sceneSurface) ? Common::Rect(0, 0, _sceneSurface.w, _sceneSurface.h) : + return (_backBuffer == &_sceneSurface) ? Common::Rect(0, 0, _sceneSurface.w(), _sceneSurface.h()) : Common::Rect(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT); } -- cgit v1.2.3 From 30133cef0e2a840325c1b46b106628c3cccd7d04 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 May 2015 08:28:12 -0400 Subject: SHERLOCK: Re-add GCC_PRINTF and fix resulting GCC warnings --- engines/sherlock/screen.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sherlock/screen.cpp') diff --git a/engines/sherlock/screen.cpp b/engines/sherlock/screen.cpp index 1d3c0e0dbf..e70d0614d1 100644 --- a/engines/sherlock/screen.cpp +++ b/engines/sherlock/screen.cpp @@ -369,16 +369,16 @@ void Screen::buttonPrint(const Common::Point &pt, byte color, bool slamIt, if (slamIt) { print(Common::Point(xStart, pt.y + 1), COMMAND_HIGHLIGHTED, "%c", str[0]); print(Common::Point(xStart + charWidth(str[0]), pt.y + 1), - COMMAND_FOREGROUND, str.c_str() + 1); + COMMAND_FOREGROUND, "%s", str.c_str() + 1); } else { gPrint(Common::Point(xStart, pt.y), COMMAND_HIGHLIGHTED, "%c", str[0]); gPrint(Common::Point(xStart + charWidth(str[0]), pt.y), - COMMAND_FOREGROUND, str.c_str() + 1); + COMMAND_FOREGROUND, "%s", str.c_str() + 1); } } else if (slamIt) { - print(Common::Point(xStart, pt.y + 1), color, str.c_str()); + print(Common::Point(xStart, pt.y + 1), color, "%s", str.c_str()); } else { - gPrint(Common::Point(xStart, pt.y), color, str.c_str()); + gPrint(Common::Point(xStart, pt.y), color, "%s", str.c_str()); } } -- cgit v1.2.3