Skip to content

Commit

Permalink
GROOVIE: Add initial full screen functionality for V2 games
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Nov 3, 2014
1 parent f733498 commit 9d6437c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
25 changes: 22 additions & 3 deletions engines/groovie/graphics.cpp
Expand Up @@ -63,7 +63,7 @@ void GraphicsMan::update() {

// Clear the buffer when ending the fade out
if (_fading == 2)
_foreground.fillRect(Common::Rect(640, 320), 0);
_foreground.fillRect(Common::Rect(640, _foreground.h), 0);
}
}

Expand All @@ -74,6 +74,22 @@ void GraphicsMan::update() {
}
}

void GraphicsMan::switchToFullScreen(bool fullScreen) {
_foreground.free();
_background.free();

if (fullScreen) {
_foreground.create(640, 480, _vm->_pixelFormat);
_background.create(640, 480, _vm->_pixelFormat);
} else {
_vm->_system->fillScreen(0);
_foreground.create(640, 320, _vm->_pixelFormat);
_background.create(640, 320, _vm->_pixelFormat);
}

_changed = true;
}

void GraphicsMan::change() {
_changed = true;
}
Expand All @@ -84,7 +100,7 @@ void GraphicsMan::mergeFgAndBg() {

countf = (byte *)_foreground.getPixels();
countb = (byte *)_background.getPixels();
for (i = 640 * 320; i; i--) {
for (i = 640 * _foreground.h; i; i--) {
if (255 == *(countf)) {
*(countf) = *(countb);
}
Expand All @@ -94,7 +110,10 @@ void GraphicsMan::mergeFgAndBg() {
}

void GraphicsMan::updateScreen(Graphics::Surface *source) {
_vm->_system->copyRectToScreen(source->getPixels(), 640, 0, 80, 640, 320);
if (!isFullScreen())
_vm->_system->copyRectToScreen(source->getPixels(), source->pitch, 0, 80, 640, 320);
else
_vm->_system->copyRectToScreen(source->getPixels(), source->pitch, 0, 0, 640, 480);
change();
}

Expand Down
2 changes: 2 additions & 0 deletions engines/groovie/graphics.h
Expand Up @@ -38,6 +38,8 @@ class GraphicsMan {
void update();
void change();
void mergeFgAndBg();
void switchToFullScreen(bool fullScreen);
bool isFullScreen() { return (_foreground.h == 480); }
void updateScreen(Graphics::Surface *source);
Graphics::Surface _foreground; // The main surface that most things are drawn to
Graphics::Surface _background; // Used occasionally, mostly (only?) in puzzles
Expand Down
6 changes: 6 additions & 0 deletions engines/groovie/roq.cpp
Expand Up @@ -277,6 +277,12 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) {
_prevBuf->create(width, height, _vm->_pixelFormat);
}

// Switch from/to fullscreen, if needed
if (_bg->h != 480 && height == 480)
_vm->_graphicsMan->switchToFullScreen(true);
else if (_bg->h == 480 && height != 480)
_vm->_graphicsMan->switchToFullScreen(false);

// Clear the buffers with black
_currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0));
_prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0));
Expand Down
20 changes: 11 additions & 9 deletions engines/groovie/script.cpp
Expand Up @@ -350,9 +350,10 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {

// Show hotspots when debugging
if (DebugMan.isDebugChannelEnabled(kDebugHotspots)) {
rect.translate(0, -80);
if (!_vm->_graphicsMan->isFullScreen())
rect.translate(0, -80);
_vm->_graphicsMan->_foreground.frameRect(rect, 250);
_vm->_system->copyRectToScreen(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_foreground.pitch, 0, 80, 640, 320);
_vm->_graphicsMan->updateScreen(&_vm->_graphicsMan->_foreground);
_vm->_system->updateScreen();
}

Expand Down Expand Up @@ -962,7 +963,7 @@ void Script::o_strcmpnejmp_var() { // 0x21

void Script::o_copybgtofg() { // 0x22
debugC(1, kDebugScript, "COPY_BG_TO_FG");
memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * 320);
memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * _vm->_graphicsMan->_foreground.h);
}

void Script::o_strcmpeqjmp() { // 0x23
Expand Down Expand Up @@ -1198,6 +1199,7 @@ void Script::o_copyrecttobg() { // 0x37
uint16 top = readScript16bits();
uint16 right = readScript16bits();
uint16 bottom = readScript16bits();
uint16 baseTop = (!_vm->_graphicsMan->isFullScreen()) ? 80 : 0;

// Sanity checks to prevent bad pointer access crashes
if (left > right) {
Expand All @@ -1216,9 +1218,9 @@ void Script::o_copyrecttobg() { // 0x37
bottom = top;
top = j;
}
if (top < 80) {
warning("COPYRECT top < 80... clamping");
top = 80;
if (top < baseTop) {
warning("COPYRECT top < baseTop... clamping");
top = baseTop;
}
if (top >= 480) {
warning("COPYRECT top >= 480... clamping");
Expand All @@ -1243,13 +1245,13 @@ void Script::o_copyrecttobg() { // 0x37

debugC(1, kDebugScript, "COPYRECT((%d,%d)->(%d,%d))", left, top, right, bottom);

fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - 80);
bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - 80);
fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - baseTop);
bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - baseTop);
for (i = 0; i < height; i++) {
memcpy(bg + offset, fg + offset, width);
offset += 640;
}
_vm->_system->copyRectToScreen(_vm->_graphicsMan->_background.getBasePtr(left, top - 80), 640, left, top, width, height);
_vm->_system->copyRectToScreen(_vm->_graphicsMan->_background.getBasePtr(left, top - baseTop), 640, left, top, width, height);
_vm->_graphicsMan->change();
}

Expand Down

0 comments on commit 9d6437c

Please sign in to comment.