Skip to content

Commit

Permalink
WAGE: Implemented cropping in cosole. That fixes crashes in Bug Hunt
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Feb 25, 2016
1 parent 6ac4c9d commit 1415e62
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 0 additions & 1 deletion engines/wage/detection_tables.h
Expand Up @@ -32,7 +32,6 @@ static const ADGameDescription gameDescriptions[] = {
FANGAME("3rd Floor", "3rd Floor", "a107d7a177970b2259e32681bd8b47c9", 285056),
BIGGAME("afm", "v1.8", "Another Fine Mess 1.8", "8e5aa915f3253efb2aab52435647b25e", 1456000),
BIGGAME("amot", "v1.8", "A Mess O' Trouble 1.8", "b3ef53afed282671b704e45df829350c", 1895552),
// Off-screen rendering in second screen
FANGAME("Bug Hunt", "Bug Hunt", "2ebd3515a87941063ad66c3cf93c5e78", 200064),
// Problems with letter rendering
FANGAME("Canal District", "Canal District", "8856bc699a20fc5b7fc67accee12cac7", 658176),
Expand Down
26 changes: 24 additions & 2 deletions engines/wage/gui-console.cpp
Expand Up @@ -257,8 +257,30 @@ void Gui::renderConsole(Graphics::Surface *g, Common::Rect &r) {
y1 += _consoleLineHeight;
}

g->copyRectToSurface(_console, r.left - kConOverscan, r.top - kConOverscan, boundsR);
g_system->copyRectToScreen(g->getBasePtr(r.left, r.top), g->pitch, r.left, r.top, r.width(), r.height());
// Now we need to clip it to the screen
int xcon = r.left - kConOverscan;
int ycon = r.top - kConOverscan;
if (xcon < 0) {
boundsR.left -= xcon;
xcon = 0;
}
if (ycon < 0) {
boundsR.top -= ycon;
ycon = 0;
}
if (xcon + boundsR.width() >= g->w)
boundsR.right -= xcon + boundsR.width() - g->w;
if (ycon + boundsR.height() >= g->h)
boundsR.bottom -= ycon + boundsR.height() - g->h;

Common::Rect rr(r);
if (rr.right > _screen.w - 1)
rr.right = _screen.w - 1;
if (rr.bottom > _screen.h - 1)
rr.bottom = _screen.h - 1;

g->copyRectToSurface(_console, xcon, ycon, boundsR);
g_system->copyRectToScreen(g->getBasePtr(rr.left, rr.top), g->pitch, rr.left, rr.top, rr.width(), rr.height());
}

void Gui::drawInput() {
Expand Down
4 changes: 2 additions & 2 deletions engines/wage/gui.cpp
Expand Up @@ -132,9 +132,9 @@ static void cursorTimerHandler(void *refCon) {
gui->_cursorState = !gui->_cursorState;

gui->_cursorRect.left = x;
gui->_cursorRect.right = x + 1;
gui->_cursorRect.right = MIN<uint16>(x + 1, gui->_screen.w);
gui->_cursorRect.top = y;
gui->_cursorRect.bottom = y + kCursorHeight;
gui->_cursorRect.bottom = MIN<uint16>(y + kCursorHeight, gui->_screen.h);

gui->_cursorDirty = true;
}
Expand Down

0 comments on commit 1415e62

Please sign in to comment.