aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet2010-12-14 19:11:16 +0000
committerBastien Bouclet2010-12-14 19:11:16 +0000
commitd4ce60336166f2a18632e4bb3fe54d5bdff59651 (patch)
treea2f75bc39cc74313767af3222ec646a79513fe76
parentc2e48f5c085b9ae4ddeb2e6be21071fe4d1cc8bb (diff)
downloadscummvm-rg350-d4ce60336166f2a18632e4bb3fe54d5bdff59651.tar.gz
scummvm-rg350-d4ce60336166f2a18632e4bb3fe54d5bdff59651.tar.bz2
scummvm-rg350-d4ce60336166f2a18632e4bb3fe54d5bdff59651.zip
MOHAWK: Rework Myst GFX updates
- Initial card state is drawn to the back buffer - Script driven updates are drawn to the front buffer Allows opcode 28 (copy back buffer to screen) and opcodes 29/33 (copy image to screen / back buffer) to work properly. Fixes among others the generator room lights, and the matchbox. svn-id: r54907
-rw-r--r--engines/mohawk/console.cpp2
-rw-r--r--engines/mohawk/graphics.cpp104
-rw-r--r--engines/mohawk/graphics.h7
-rw-r--r--engines/mohawk/myst.cpp5
-rw-r--r--engines/mohawk/myst_areas.cpp74
-rw-r--r--engines/mohawk/myst_areas.h3
-rw-r--r--engines/mohawk/myst_scripts.cpp146
-rw-r--r--engines/mohawk/myst_scripts.h5
-rw-r--r--engines/mohawk/myst_stacks/credits.cpp2
-rw-r--r--engines/mohawk/myst_stacks/intro.cpp9
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp20
-rw-r--r--engines/mohawk/myst_stacks/preview.cpp4
-rw-r--r--engines/mohawk/myst_stacks/selenitic.cpp6
13 files changed, 189 insertions, 198 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp
index 8594b1c4f6..edf7247e22 100644
--- a/engines/mohawk/console.cpp
+++ b/engines/mohawk/console.cpp
@@ -174,7 +174,7 @@ bool MystConsole::Cmd_DrawImage(int argc, const char **argv) {
rect = Common::Rect((uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4]), (uint16)atoi(argv[5]));
_vm->_gfx->copyImageToScreen((uint16)atoi(argv[1]), rect);
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
return false;
}
diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp
index 64968723bd..46f2d3c0d7 100644
--- a/engines/mohawk/graphics.cpp
+++ b/engines/mohawk/graphics.cpp
@@ -235,8 +235,8 @@ MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : GraphicsManager(), _vm(vm) {
_pictureFile.entries = NULL;
// Initialize our buffer
- _mainScreen = new Graphics::Surface();
- _mainScreen->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
+ _backBuffer = new Graphics::Surface();
+ _backBuffer->create(_vm->_system->getWidth(), _vm->_system->getHeight(), _pixelFormat.bytesPerPixel);
}
MystGraphics::~MystGraphics() {
@@ -245,8 +245,8 @@ MystGraphics::~MystGraphics() {
delete _pictDecoder;
delete[] _pictureFile.entries;
- _mainScreen->free();
- delete _mainScreen;
+ _backBuffer->free();
+ delete _backBuffer;
}
static const char* picFileNames[] = {
@@ -371,36 +371,50 @@ void MystGraphics::copyImageSectionToScreen(uint16 image, Common::Rect src, Comm
// Convert from bitmap coordinates to surface coordinates
uint16 top = surface->h - src.top - height;
- for (uint16 i = 0; i < height; i++)
- memcpy(_mainScreen->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
+ _vm->_system->copyRectToScreen((byte *)surface->getBasePtr(src.left, top), surface->pitch, dest.left, dest.top, width, height);
+}
+
+void MystGraphics::copyImageSectionToBackBuffer(uint16 image, Common::Rect src, Common::Rect dest) {
+ // Clip the destination rect to the screen
+ if (dest.right > _vm->_system->getWidth() || dest.bottom > _vm->_system->getHeight())
+ dest.debugPrint(4, "Clipping destination rect to the screen:");
+
+ dest.right = CLIP<int>(dest.right, 0, _vm->_system->getWidth());
+ dest.bottom = CLIP<int>(dest.bottom, 0, _vm->_system->getHeight());
+
+ Graphics::Surface *surface = findImage(image)->getSurface();
+
+ debug(3, "Image Blit:");
+ debug(3, "src.x: %d", src.left);
+ debug(3, "src.y: %d", src.top);
+ debug(3, "dest.x: %d", dest.left);
+ debug(3, "dest.y: %d", dest.top);
+ debug(3, "width: %d", src.width());
+ debug(3, "height: %d", src.height());
+
+ uint16 width = MIN<int>(surface->w, dest.width());
+ uint16 height = MIN<int>(surface->h, dest.height());
+
+ // Convert from bitmap coordinates to surface coordinates
+ uint16 top = surface->h - src.top - height;
- // Add to the list of dirty rects
- _dirtyRects.push_back(dest);
+ for (uint16 i = 0; i < height; i++)
+ memcpy(_backBuffer->getBasePtr(dest.left, i + dest.top), surface->getBasePtr(src.left, top + i), width * surface->bytesPerPixel);
}
void MystGraphics::copyImageToScreen(uint16 image, Common::Rect dest) {
copyImageSectionToScreen(image, Common::Rect(0, 0, 544, 333), dest);
}
-void MystGraphics::updateScreen() {
- // Only update the screen if there have been changes since last frame
- if (!_dirtyRects.empty()) {
-
- // Copy any modified area
- for (uint i = 0; i < _dirtyRects.size(); i++) {
- Common::Rect &r = _dirtyRects[i];
- _vm->_system->copyRectToScreen((byte *)_mainScreen->getBasePtr(r.left, r.top), _mainScreen->pitch, r.left, r.top, r.width(), r.height());
- }
+void MystGraphics::copyImageToBackBuffer(uint16 image, Common::Rect dest) {
+ copyImageSectionToBackBuffer(image, Common::Rect(0, 0, 544, 333), dest);
+}
- _vm->_system->updateScreen();
- _dirtyRects.clear();
- }
+void MystGraphics::copyBackBufferToScreen(const Common::Rect &r) {
+ _vm->_system->copyRectToScreen((byte *)_backBuffer->getBasePtr(r.left, r.top), _backBuffer->pitch, r.left, r.top, r.width(), r.height());
}
void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay) {
- // Bypass dirty rects for animated updates
- _dirtyRects.clear();
-
switch (type) {
case 0: {
debugC(kDebugScript, "Left to Right");
@@ -413,15 +427,15 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
_vm->_system->delayMillis(delay);
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
if (area.right < rect.right) {
area.left = area.right;
area.right = rect.right;
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
}
break;
@@ -436,15 +450,15 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
_vm->_system->delayMillis(delay);
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
if (area.left > rect.left) {
area.right = area.left;
area.left = rect.left;
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
}
break;
@@ -459,15 +473,15 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
_vm->_system->delayMillis(delay);
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
if (area.bottom < rect.bottom) {
area.top = area.bottom;
area.bottom = rect.bottom;
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
}
break;
@@ -482,15 +496,15 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
_vm->_system->delayMillis(delay);
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
if (area.top > rect.top) {
area.bottom = area.top;
area.top = rect.top;
- _dirtyRects.push_back(area);
- updateScreen();
+ copyBackBufferToScreen(area);
+ _vm->_system->updateScreen();
}
}
break;
@@ -498,8 +512,8 @@ void MystGraphics::runTransition(uint16 type, Common::Rect rect, uint16 steps, u
warning("Unknown Update Direction");
//TODO: Replace minimal implementation
- _dirtyRects.push_back(rect);
- updateScreen();
+ copyBackBufferToScreen(rect);
+ _vm->_system->updateScreen();
break;
}
}
@@ -510,15 +524,15 @@ void MystGraphics::drawRect(Common::Rect rect, RectState state) {
return;
if (state == kRectEnabled)
- _mainScreen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
+ _backBuffer->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
else if (state == kRectUnreachable)
- _mainScreen->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
+ _backBuffer->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
else
- _mainScreen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
+ _backBuffer->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
}
void MystGraphics::drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color) {
- _mainScreen->drawLine(p1.x, p1.y, p2.x, p2.y, color);
+ _backBuffer->drawLine(p1.x, p1.y, p2.x, p2.y, color);
}
RivenGraphics::RivenGraphics(MohawkEngine_Riven* vm) : GraphicsManager(), _vm(vm) {
diff --git a/engines/mohawk/graphics.h b/engines/mohawk/graphics.h
index f027f98d9f..873873ccda 100644
--- a/engines/mohawk/graphics.h
+++ b/engines/mohawk/graphics.h
@@ -111,8 +111,10 @@ public:
void loadExternalPictureFile(uint16 stack);
void copyImageSectionToScreen(uint16 image, Common::Rect src, Common::Rect dest);
+ void copyImageSectionToBackBuffer(uint16 image, Common::Rect src, Common::Rect dest);
void copyImageToScreen(uint16 image, Common::Rect dest);
- void updateScreen();
+ void copyImageToBackBuffer(uint16 image, Common::Rect dest);
+ void copyBackBufferToScreen(const Common::Rect &r);
void runTransition(uint16 type, Common::Rect rect, uint16 steps, uint16 delay);
void drawRect(Common::Rect rect, RectState state);
void drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color);
@@ -141,8 +143,7 @@ private:
Common::File picFile;
} _pictureFile;
- Graphics::Surface *_mainScreen;
- Common::Array<Common::Rect> _dirtyRects;
+ Graphics::Surface *_backBuffer;
Graphics::PixelFormat _pixelFormat;
};
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 0e791aadc6..7cafaf69a3 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -472,7 +472,7 @@ uint16 MohawkEngine_Myst::getCardBackgroundId() {
}
void MohawkEngine_Myst::drawCardBackground() {
- _gfx->copyImageToScreen(getCardBackgroundId(), Common::Rect(0, 0, 544, 333));
+ _gfx->copyImageToBackBuffer(getCardBackgroundId(), Common::Rect(0, 0, 544, 333));
}
void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {
@@ -568,7 +568,8 @@ void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {
// Make sure the screen is updated
if (updateScreen) {
- _gfx->updateScreen();
+ _gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+ _system->updateScreen();
}
}
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index afb3bc7b14..030b5954bf 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -386,35 +386,18 @@ void MystResourceType8::drawDataToScreen() {
}
if (drawSubImage) {
- uint16 imageToDraw = 0;
-
- if (_subImages[subImageId].wdib == 0xFFFF) {
- // TODO: Think the reason for problematic screen updates in some rects is that they
- // are these -1 cases.
- // They need to be redrawn i.e. if the Myst marker switches are changed, but I don't think
- // the rects are valid. This does not matter in the original engine as the screen update redraws
- // the VIEW images, followed by the RLST resource images, and -1 for the WDIB is interpreted as
- // "Do Not Draw Image" i.e so the VIEW image is shown through.. We need to fix screen update
- // to do this same behaviour.
- if (_vm->_view.conditionalImageCount == 0)
- imageToDraw = _vm->_view.mainImage;
- else {
- for (uint16 i = 0; i < _vm->_view.conditionalImageCount; i++)
- if (_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var) < _vm->_view.conditionalImages[i].numStates)
- imageToDraw = _vm->_view.conditionalImages[i].values[_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var)];
- }
- } else
- imageToDraw = _subImages[subImageId].wdib;
+ uint16 imageToDraw = _subImages[subImageId].wdib;
- _vm->_gfx->copyImageSectionToScreen(imageToDraw, _subImages[subImageId].rect, _rect);
+ // This special case means redraw background
+ if (imageToDraw == 0xFFFF) {
+ imageToDraw = _vm->getCardBackgroundId();
+ }
+
+ _vm->_gfx->copyImageSectionToBackBuffer(imageToDraw, _subImages[subImageId].rect, _rect);
}
}
void MystResourceType8::drawConditionalDataToScreen(uint16 state, bool update) {
- // Need to call overidden Type 7 function to ensure
- // switch section is processed correctly.
- MystResourceType7::drawDataToScreen();
-
bool drawSubImage = false;
int16 subImageId = 0;
@@ -432,31 +415,20 @@ void MystResourceType8::drawConditionalDataToScreen(uint16 state, bool update) {
if (drawSubImage) {
- uint16 imageToDraw = 0;
-
- if (_subImages[subImageId].wdib == 0xFFFF) {
- // TODO: Think the reason for problematic screen updates in some rects is that they
- // are these -1 cases.
- // They need to be redrawn i.e. if the Myst marker switches are changed, but I don't think
- // the rects are valid. This does not matter in the original engine as the screen update redraws
- // the VIEW images, followed by the RLST resource images, and -1 for the WDIB is interpreted as
- // "Do Not Draw Image" i.e so the VIEW image is shown through.. We need to fix screen update
- // to do this same behaviour.
- if (_vm->_view.conditionalImageCount == 0)
- imageToDraw = _vm->_view.mainImage;
- else {
- for (uint16 i = 0; i < _vm->_view.conditionalImageCount; i++)
- if (_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var) < _vm->_view.conditionalImages[i].numStates)
- imageToDraw = _vm->_view.conditionalImages[i].values[_vm->_scriptParser->getVar(_vm->_view.conditionalImages[i].var)];
- }
- } else
- imageToDraw = _subImages[subImageId].wdib;
+ uint16 imageToDraw = _subImages[subImageId].wdib;
- _vm->_gfx->copyImageSectionToScreen(imageToDraw, _subImages[subImageId].rect, _rect);
+ // This special case means redraw background
+ if (imageToDraw == 0xFFFF) {
+ imageToDraw = _vm->getCardBackgroundId();
+ }
// Draw to screen
- if (update)
- _vm->_gfx->updateScreen();
+ if (update) {
+ _vm->_gfx->copyImageSectionToScreen(imageToDraw, _subImages[subImageId].rect, _rect);
+ _vm->_system->updateScreen();
+ } else {
+ _vm->_gfx->copyImageSectionToBackBuffer(imageToDraw, _subImages[subImageId].rect, _rect);
+ }
}
}
@@ -521,14 +493,6 @@ void MystResourceType10::restoreBackground() {
_vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, dest);
}
-void MystResourceType10::drawDataToScreen()
-{
- // Restore background
- restoreBackground();
-
- MystResourceType8::drawDataToScreen();
-}
-
void MystResourceType10::handleMouseDown(const Common::Point &mouse) {
// Tell the engine we are dragging a resource
_vm->_dragResource = this;
@@ -775,7 +739,7 @@ MystResourceType12::~MystResourceType12() {
void MystResourceType12::drawFrame(uint16 frame) {
_currentFrame = _firstFrame + frame;
_vm->_gfx->copyImageToScreen(_currentFrame, _frameRect);
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
}
MystResourceType13::MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 81fbb0e216..c65c91ba55 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -203,17 +203,16 @@ public:
MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
virtual ~MystResourceType10();
- void drawDataToScreen();
void handleMouseDown(const Common::Point &mousee);
void handleMouseUp(const Common::Point &mouse);
void handleMouseDrag(const Common::Point &mouse);
void setStep(uint16 step);
void setPosition(uint16 pos);
+ void restoreBackground();
protected:
Common::Rect boundingBox();
void updatePosition(const Common::Point &mouse);
- void restoreBackground();
uint16 _dragSound;
uint16 _sliderWidth;
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 5f27b3704c..de9d67e8ff 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -126,12 +126,12 @@ void MystScriptParser::setupCommonOpcodes() {
// Opcode 25 is unused; original calls replaceSound
OPCODE(26, o_stopSoundBackground);
OPCODE(27, o_playSoundBlocking);
- OPCODE(28, o_restoreDefaultRect);
- OPCODE(29, o_blitRect);
+ OPCODE(28, o_copyBackBufferToScreen);
+ OPCODE(29, o_copyImageToBackBuffer);
OPCODE(30, o_changeSound);
OPCODE(31, o_soundPlaySwitch);
OPCODE(32, o_soundResumeBackground);
- OPCODE(33, o_blitRect);
+ OPCODE(33, o_copyImageToScreen);
OPCODE(34, o_changeCard);
OPCODE(35, o_drawImageChangeCard);
OPCODE(36, o_changeMainCursor);
@@ -360,10 +360,10 @@ void MystScriptParser::o_takePage(uint16 op, uint16 var, uint16 argc, uint16 *ar
void MystScriptParser::o_redrawCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Redraw card", op);
- // TODO: Is redrawing the background correct ?
_vm->drawCardBackground();
_vm->drawResourceImages();
- _vm->_gfx->updateScreen();
+ _vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+ _vm->_system->updateScreen();
}
void MystScriptParser::o_goToDest(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -406,7 +406,7 @@ void MystScriptParser::o_drawAreaState(uint16 op, uint16 var, uint16 argc, uint1
}
void MystScriptParser::o_redrawAreaForVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- debugC(kDebugScript, "Opcode %d: dropPage", op);
+ debugC(kDebugScript, "Opcode %d: redraw area", op);
debugC(kDebugScript, "\tvar: %d", var);
_vm->redrawArea(var);
@@ -577,81 +577,56 @@ void MystScriptParser::o_playSoundBlocking(uint16 op, uint16 var, uint16 argc, u
_vm->_sound->playSoundBlocking(soundId);
}
-void MystScriptParser::o_restoreDefaultRect(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser::o_copyBackBufferToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Copy back buffer to screen", op);
Common::Rect rect;
+ if (argv[0] == 0xFFFF) {
+ // Used in Stoneship Card 2111 (Compass Rose)
+ // Used in Mechanical Card 6267 (Code Lock)
+ rect = _invokingResource->getRect();
+ } else {
+ // Used in ... TODO: Fill in.
+ rect = Common::Rect(argv[0], argv[1], argv[2], argv[3]);
+ }
- if (argc == 1 || argc == 4) {
- debugC(kDebugScript, "Opcode %d: Restore VIEW Default Image in Region", op);
-
- if (argc == 1) {
- // Used in Stoneship Card 2111 (Compass Rose)
- // Used in Mechanical Card 6267 (Code Lock)
- if (argv[0] == 0xFFFF) {
- rect = _invokingResource->getRect();
- } else
- unknown(op, var, argc, argv);
- } else if (argc == 4) {
- // Used in ... TODO: Fill in.
- rect = Common::Rect(argv[0], argv[1], argv[2], argv[3]);
- } else
- warning("Opcode %d: argc Error", op);
-
- debugC(kDebugScript, "\trect.left: %d", rect.left);
- debugC(kDebugScript, "\trect.top: %d", rect.top);
- debugC(kDebugScript, "\trect.right: %d", rect.right);
- debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
-
- Common::Rect src;
- src.left = rect.left;
- src.top = 333 - rect.bottom;
- src.right = rect.right;
- src.bottom = 333 - rect.top;
+ debugC(kDebugScript, "\trect.left: %d", rect.left);
+ debugC(kDebugScript, "\trect.top: %d", rect.top);
+ debugC(kDebugScript, "\trect.right: %d", rect.right);
+ debugC(kDebugScript, "\trect.bottom: %d", rect.bottom);
- _vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, rect);
- } else
- unknown(op, var, argc, argv);
+ _vm->_gfx->copyBackBufferToScreen(rect);
+ _vm->_system->updateScreen();
}
-void MystScriptParser::o_blitRect(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
-
- // TODO: Opcode 29 called on Mechanical Card 6178 causes a engine
- // abort this is because imageId is 7158 (not valid), but the
- // script resource gives this as 7178 (valid)...
- // FIXME: opcode 33 also hides the cursor when drawing if it is in the way
+void MystScriptParser::o_copyImageToBackBuffer(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ uint16 imageId = argv[0];
- if (argc == 7) {
- uint16 imageId = argv[0];
+ Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
- Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
+ Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
- Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
+ if (dstRect.left == -1 || dstRect.top == -1) {
+ // Interpreted as full screen
+ dstRect.left = 0;
+ dstRect.top = 0;
+ }
- if (dstRect.left == -1 || dstRect.top == -1) {
- // Interpreted as full screen
- dstRect.left = 0;
- dstRect.top = 0;
- }
+ dstRect.right = dstRect.left + srcRect.width();
+ dstRect.bottom = dstRect.top + srcRect.height();
- dstRect.right = dstRect.left + srcRect.width();
- dstRect.bottom = dstRect.top + srcRect.height();
+ debugC(kDebugScript, "Opcode %d: Copy image to back buffer", op);
+ debugC(kDebugScript, "\timageId: %d", imageId);
+ debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
+ debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
+ debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
+ debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
+ debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
+ debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
+ debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
+ debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
- debugC(kDebugScript, "Opcode %d: Blit Image", op);
- debugC(kDebugScript, "\timageId: %d", imageId);
- debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
- debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
- debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
- debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
- debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
- debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
- debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
- debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
-
- _vm->_gfx->copyImageSectionToScreen(imageId, srcRect, dstRect);
- } else
- unknown(op, var, argc, argv);
+ _vm->_gfx->copyImageSectionToBackBuffer(imageId, srcRect, dstRect);
}
// TODO: Implement common engine function for read and processing of sound blocks
@@ -760,6 +735,37 @@ void MystScriptParser::o_soundResumeBackground(uint16 op, uint16 var, uint16 arg
//_vm->_sound->resumeBackground();
}
+void MystScriptParser::o_copyImageToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ uint16 imageId = argv[0];
+
+ Common::Rect srcRect = Common::Rect(argv[1], argv[2], argv[3], argv[4]);
+
+ Common::Rect dstRect = Common::Rect(argv[5], argv[6], 544, 333);
+
+ if (dstRect.left == -1 || dstRect.top == -1) {
+ // Interpreted as full screen
+ dstRect.left = 0;
+ dstRect.top = 0;
+ }
+
+ dstRect.right = dstRect.left + srcRect.width();
+ dstRect.bottom = dstRect.top + srcRect.height();
+
+ debugC(kDebugScript, "Opcode %d: Copy image to screen", op);
+ debugC(kDebugScript, "\timageId: %d", imageId);
+ debugC(kDebugScript, "\tsrcRect.left: %d", srcRect.left);
+ debugC(kDebugScript, "\tsrcRect.top: %d", srcRect.top);
+ debugC(kDebugScript, "\tsrcRect.right: %d", srcRect.right);
+ debugC(kDebugScript, "\tsrcRect.bottom: %d", srcRect.bottom);
+ debugC(kDebugScript, "\tdstRect.left: %d", dstRect.left);
+ debugC(kDebugScript, "\tdstRect.top: %d", dstRect.top);
+ debugC(kDebugScript, "\tdstRect.right: %d", dstRect.right);
+ debugC(kDebugScript, "\tdstRect.bottom: %d", dstRect.bottom);
+
+ _vm->_gfx->copyImageSectionToScreen(imageId, srcRect, dstRect);
+ _vm->_system->updateScreen();
+}
+
void MystScriptParser::o_changeCard(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Change Card", op);
@@ -789,7 +795,7 @@ void MystScriptParser::o_drawImageChangeCard(uint16 op, uint16 var, uint16 argc,
debugC(kDebugScript, "\tdelay: %d", delay);
_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
_vm->_system->delayMillis(delay * 100);
_vm->changeToCard(cardId, true);
} else
diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h
index 92f4a765f0..ecf82ea6ce 100644
--- a/engines/mohawk/myst_scripts.h
+++ b/engines/mohawk/myst_scripts.h
@@ -101,10 +101,11 @@ public:
DECLARE_OPCODE(o_playSound);
DECLARE_OPCODE(o_stopSoundBackground);
DECLARE_OPCODE(o_playSoundBlocking);
- DECLARE_OPCODE(o_restoreDefaultRect);
- DECLARE_OPCODE(o_blitRect);
+ DECLARE_OPCODE(o_copyBackBufferToScreen);
+ DECLARE_OPCODE(o_copyImageToBackBuffer);
DECLARE_OPCODE(o_changeSound);
DECLARE_OPCODE(o_soundPlaySwitch);
+ DECLARE_OPCODE(o_copyImageToScreen);
DECLARE_OPCODE(o_soundResumeBackground);
DECLARE_OPCODE(o_changeCard);
DECLARE_OPCODE(o_drawImageChangeCard);
diff --git a/engines/mohawk/myst_stacks/credits.cpp b/engines/mohawk/myst_stacks/credits.cpp
index 152740139a..7bd652079b 100644
--- a/engines/mohawk/myst_stacks/credits.cpp
+++ b/engines/mohawk/myst_stacks/credits.cpp
@@ -75,7 +75,7 @@ void MystScriptParser_Credits::runPersistentScripts() {
// Note: The modulus by 6 is because the 6th image is the one at imageBaseId
_vm->_gfx->copyImageToScreen(_baseImageId + curImageIndex % 6, Common::Rect(0, 0, 544, 333));
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
_vm->_varStore->setVar(_creditsVar, curImageIndex + 1);
_lastCardTime = _vm->_system->getMillis();
diff --git a/engines/mohawk/myst_stacks/intro.cpp b/engines/mohawk/myst_stacks/intro.cpp
index 0741c22e1f..b2f5d927cb 100644
--- a/engines/mohawk/myst_stacks/intro.cpp
+++ b/engines/mohawk/myst_stacks/intro.cpp
@@ -173,13 +173,16 @@ void MystScriptParser_Intro::o_playIntroMovies(uint16 op, uint16 var, uint16 arg
void MystScriptParser_Intro::opcode_201(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
varUnusedCheck(op, var);
- _vm->_gfx->updateScreen();
+ _vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+ _vm->_system->updateScreen();
_vm->_system->delayMillis(4 * 1000);
- _vm->_gfx->copyImageToScreen(4, Common::Rect(0, 0, 544, 333));
+ _vm->_gfx->copyImageToBackBuffer(4, Common::Rect(544, 333));
+ _vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+ _vm->_system->updateScreen();
MystResourceType6 *resource = static_cast<MystResourceType6 *>(_invokingResource);
resource->playMovie();
- // TODO: Complete
+ // TODO: Complete / Fix
}
void MystScriptParser_Intro::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 89793c7bdf..2fc763ade9 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -579,7 +579,7 @@ void MystScriptParser_Myst::o_libraryBookPageTurnLeft(uint16 op, uint16 var, uin
else
_vm->_sound->playSound(_libraryBookSound2);
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
}
}
@@ -597,7 +597,7 @@ void MystScriptParser_Myst::o_libraryBookPageTurnRight(uint16 op, uint16 var, ui
else
_vm->_sound->playSound(_libraryBookSound2);
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
}
}
@@ -615,7 +615,7 @@ void MystScriptParser_Myst::o_fireplaceToggleButton(uint16 op, uint16 var, uint1
// Unset button
for (uint i = 4795; i >= 4779; i--) {
_vm->_gfx->copyImageToScreen(i, _invokingResource->getRect());
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
_vm->_system->delayMillis(1);
}
_fireplaceLines[var - 17] &= ~bitmask;
@@ -623,7 +623,7 @@ void MystScriptParser_Myst::o_fireplaceToggleButton(uint16 op, uint16 var, uint1
// Set button
for (uint i = 4779; i <= 4795; i++) {
_vm->_gfx->copyImageToScreen(i, _invokingResource->getRect());
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
_vm->_system->delayMillis(1);
}
_fireplaceLines[var - 17] |= bitmask;
@@ -1698,7 +1698,7 @@ void MystScriptParser_Myst::libraryCombinationBookTurnLeft() {
else
_vm->_sound->playSound(_libraryBookSound2);
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
}
}
@@ -1724,7 +1724,7 @@ void MystScriptParser_Myst::libraryCombinationBookTurnRight() {
else
_vm->_sound->playSound(_libraryBookSound2);
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
}
}
@@ -1879,7 +1879,8 @@ void MystScriptParser_Myst::towerRotationMap_run() {
towerRotationDrawBuildings();
// Draw to screen
- _vm->_gfx->updateScreen();
+ _vm->_gfx->copyBackBufferToScreen(Common::Rect(106, 42, 459, 273));
+ _vm->_system->updateScreen();
}
uint32 time = _vm->_system->getMillis();
@@ -1998,7 +1999,7 @@ void MystScriptParser_Myst::towerRotationMapDrawLine(const Common::Point &center
src.bottom = 333 - rect.top;
// Redraw background
- _vm->_gfx->copyImageSectionToScreen(_vm->getCardBackgroundId(), src, rect);
+ _vm->_gfx->copyImageSectionToBackBuffer(_vm->getCardBackgroundId(), src, rect);
// Draw buildings
towerRotationDrawBuildings();
@@ -2011,7 +2012,8 @@ void MystScriptParser_Myst::towerRotationMapDrawLine(const Common::Point &center
// Draw line
_vm->_gfx->drawLine(center, end, color);
- _vm->_gfx->updateScreen();
+ _vm->_gfx->copyBackBufferToScreen(rect);
+ _vm->_system->updateScreen();
}
void MystScriptParser_Myst::towerRotationMapRotate() {
diff --git a/engines/mohawk/myst_stacks/preview.cpp b/engines/mohawk/myst_stacks/preview.cpp
index 169411cc00..64d0898000 100644
--- a/engines/mohawk/myst_stacks/preview.cpp
+++ b/engines/mohawk/myst_stacks/preview.cpp
@@ -115,12 +115,12 @@ void MystScriptParser_Preview::opcode_298(uint16 op, uint16 var, uint16 argc, ui
// TODO: Flash Library Red
// TODO: Move to run process based delay to prevent
// blocking...
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
_vm->_system->delayMillis(20 * 1000);
for (uint16 imageId = 3001; imageId <= 3012; imageId++) {
_vm->_gfx->copyImageToScreen(imageId, Common::Rect(0, 0, 544, 333));
- _vm->_gfx->updateScreen();
+ _vm->_system->updateScreen();
_vm->_system->delayMillis(5 * 1000);
}
}
diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp
index 183c92745d..161c90b6f5 100644
--- a/engines/mohawk/myst_stacks/selenitic.cpp
+++ b/engines/mohawk/myst_stacks/selenitic.cpp
@@ -872,12 +872,12 @@ void MystScriptParser_Selenitic::o_soundLockEndMove(uint16 op, uint16 var, uint1
*value = stepped;
slider->setStep(stepped);
- slider->drawDataToScreen();
- _vm->_gfx->updateScreen();
+ slider->restoreBackground();
+ slider->drawConditionalDataToScreen(1);
uint16 soundId = slider->getList3(0);
if (soundId)
- _vm->_sound->playSoundBlocking(soundId);
+ _vm->_sound->playSound(soundId);
_vm->_sound->stopSound();
_vm->_sound->resumeBackground();