aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2014-01-18 03:18:40 +0100
committerJohannes Schickel2014-01-18 03:18:40 +0100
commit238aa2be2aeefda17cb5c2023f89e3934bed8424 (patch)
tree475fdf913d207ed16cebd168da2f7762e3ecc0d2
parent19cb3499f587630f2429c3e99b4fcadf491836cb (diff)
downloadscummvm-rg350-238aa2be2aeefda17cb5c2023f89e3934bed8424.tar.gz
scummvm-rg350-238aa2be2aeefda17cb5c2023f89e3934bed8424.tar.bz2
scummvm-rg350-238aa2be2aeefda17cb5c2023f89e3934bed8424.zip
KYRA: Let the VQA decoder draw directly to the backend
As an alternative to using the Screen class's functions, we can let the VQA decoder draw directly to the backend. This won't work if the game uses "hi-res mode", but I don't think that's ever the case for Malcolm's Revenge. I believe the KyraEngine_MR::playVQA() function ensures that the screen is properly updated after the movie has finished. This almost limits the VQA rewrite to vqa.cpp and vqa.h. Whether it's better this way than changing the Screen functions to take a 'pitch' parameter...? I don't know. But it's an alternative.
-rw-r--r--engines/kyra/kyra_mr.cpp1
-rw-r--r--engines/kyra/screen.cpp6
-rw-r--r--engines/kyra/screen.h1
-rw-r--r--engines/kyra/vqa.cpp18
-rw-r--r--engines/kyra/vqa.h4
5 files changed, 10 insertions, 20 deletions
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index 48ba96ec8b..a485ae47e4 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -378,7 +378,6 @@ void KyraEngine_MR::playVQA(const char *name) {
_screen->fadeToBlack(60);
_screen->clearPage(0);
- vqa.setDrawPage(0);
vqa.play();
vqa.close();
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index d172045302..8c97e46a8f 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -977,10 +977,6 @@ void Screen::copyPage(uint8 srcPage, uint8 dstPage) {
}
void Screen::copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src) {
- copyBlockToPage(pageNum, w, x, y, w, h, src);
-}
-
-void Screen::copyBlockToPage(int pageNum, int pitch, int x, int y, int w, int h, const uint8 *src) {
if (y < 0) {
src += (-y) * w;
h += y;
@@ -1010,7 +1006,7 @@ void Screen::copyBlockToPage(int pageNum, int pitch, int x, int y, int w, int h,
while (h--) {
memcpy(dst, src, w);
dst += SCREEN_W;
- src += pitch;
+ src += w;
}
}
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index 33bff4dd4f..156b5b9a7c 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -428,7 +428,6 @@ public:
void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest);
void copyBlockToPage(int pageNum, int x, int y, int w, int h, const uint8 *src);
- void copyBlockToPage(int pageNum, int pitch, int x, int y, int w, int h, const uint8 *src);
void shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPage, int ticks, bool transparent);
void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1, bool xored = false);
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index 76e5c7285a..975a763715 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -38,6 +38,7 @@
#include "common/system.h"
#include "common/events.h"
+#include "graphics/palette.h"
#include "graphics/surface.h"
namespace Kyra {
@@ -594,7 +595,6 @@ VQAMovie::VQAMovie(KyraEngine_v1 *vm, OSystem *system) {
_vm = vm;
_screen = _vm->screen();
_decoder = new VQADecoder();
- _drawPage = -1;
}
VQAMovie::~VQAMovie() {
@@ -602,10 +602,6 @@ VQAMovie::~VQAMovie() {
delete _decoder;
}
-void VQAMovie::setDrawPage(int page) {
- _drawPage = page;
-}
-
bool VQAMovie::open(const char *filename) {
if (_file.open(filename)) {
return true;
@@ -652,14 +648,18 @@ void VQAMovie::play() {
if (_decoder->needsUpdate()) {
const Graphics::Surface *surface = _decoder->decodeNextFrame();
if (_decoder->hasDirtyPalette()) {
- memcpy(_screen->getPalette(0).getData(), _decoder->getPalette(), 3 * 256);
- _screen->setScreenPalette(_screen->getPalette(0));
+ const byte *decoderPalette = _decoder->getPalette();
+ byte systemPalette[256 * 3];
+ for (int i = 0; i < ARRAYSIZE(systemPalette); i++) {
+ systemPalette[i] = (decoderPalette[i] * 0xFF) / 0x3F;
+ }
+ _system->getPaletteManager()->setPalette(systemPalette, 0, 256);
}
- _screen->copyBlockToPage(_drawPage, surface->pitch, x, y, width, height, (const byte *)surface->getBasePtr(0, 0));
+ _system->copyRectToScreen((const byte *)surface->getBasePtr(0, 0), surface->pitch, x, y, width, height);
}
- _screen->updateScreen();
+ _system->updateScreen();
_system->delayMillis(10);
}
}
diff --git a/engines/kyra/vqa.h b/engines/kyra/vqa.h
index 26dbc8d062..44d1354f3d 100644
--- a/engines/kyra/vqa.h
+++ b/engines/kyra/vqa.h
@@ -139,8 +139,6 @@ public:
VQAMovie(KyraEngine_v1 *vm, OSystem *system);
~VQAMovie();
- void setDrawPage(int page);
-
bool open(const char *filename);
void close();
void play();
@@ -150,8 +148,6 @@ private:
Screen *_screen;
VQADecoder *_decoder;
Common::File _file;
-
- int _drawPage;
};
} // End of namespace Kyra