aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-03-04 10:57:30 +0000
committerNicola Mettifogo2007-03-04 10:57:30 +0000
commitc5e848fb3282da26c2f7be59d244a0cc65d267bc (patch)
treefbfe0c8bc2f55ae6aa00e13549b9718048c38f21 /engines
parent43cd4283559f556cfd1268d7b95bbf2a35a64c21 (diff)
downloadscummvm-rg350-c5e848fb3282da26c2f7be59d244a0cc65d267bc.tar.gz
scummvm-rg350-c5e848fb3282da26c2f7be59d244a0cc65d267bc.tar.bz2
scummvm-rg350-c5e848fb3282da26c2f7be59d244a0cc65d267bc.zip
moved background loading into disk.cpp
svn-id: r25968
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/disk.cpp84
-rw-r--r--engines/parallaction/disk.h2
-rw-r--r--engines/parallaction/graphics.cpp119
-rw-r--r--engines/parallaction/graphics.h11
-rw-r--r--engines/parallaction/location.cpp7
-rw-r--r--engines/parallaction/menu.cpp12
6 files changed, 114 insertions, 121 deletions
diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp
index bfed880b98..fe51ea125e 100644
--- a/engines/parallaction/disk.cpp
+++ b/engines/parallaction/disk.cpp
@@ -329,5 +329,89 @@ void loadFrames(const char* name, Cnv* cnv) {
return;
}
+//
+// slides (background images) are stored compressed by scanline in a rle fashion
+//
+// the uncompressed data must then be unpacked to get:
+// * color data [bits 0-5]
+// * mask data [bits 6-7] (z buffer)
+// * path data [bit 8] (walkable areas)
+//
+
+
+void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) {
+
+ // update mask, path and screen
+ for (uint16 i = 0; i < SCREEN_WIDTH; i++) {
+ path[i/8] |= ((src[i] & 0x80) >> 7) << (i & 7);
+ mask[i/4] |= ((src[i] & 0x60) >> 5) << ((i & 3) << 1);
+ screen[i] = src[i] & 0x1F;
+ }
+
+ return;
+}
+
+void loadBackground(const char *filename) {
+// printf("Graphics::loadBackground(%s)\n", filename);
+
+ if (!_vm->_archive.openArchivedFile(filename))
+ errorFileNotFound(filename);
+
+ _vm->_graphics->parseBackground(_vm->_archive);
+
+ byte *bg = (byte*)calloc(1, SCREEN_WIDTH*SCREEN_HEIGHT);
+ byte *mask = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+ byte *path = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+
+ byte *v4 = (byte*)malloc(SCREEN_SIZE);
+ _vm->_archive.read(v4, SCREEN_SIZE);
+
+ byte v144[SCREEN_WIDTH];
+
+ byte *s = v4;
+ for (uint16 i = 0; i < SCREEN_HEIGHT; i++) {
+ s += decompressChunk(s, v144, SCREEN_WIDTH);
+ unpackBackgroundScanline(v144, bg+SCREEN_WIDTH*i, mask+SCREENMASK_WIDTH*i, path+SCREENPATH_WIDTH*i);
+ }
+
+ _vm->_graphics->setBackground(bg);
+ _vm->_graphics->setMask(mask);
+ _vm->_graphics->setPath(path);
+
+ free(v4);
+
+ free(bg);
+ free(mask);
+ free(path);
+
+ return;
+}
+
+//
+// read background path and mask from a file
+//
+// mask and path are normally combined (via OR) into the background picture itself
+// read the comment on the top of this file for more
+//
+void loadMaskAndPath(const char *name) {
+ char path[PATH_LEN];
+ sprintf(path, "%s.msk", name);
+
+ if (!_vm->_archive.openArchivedFile(path))
+ errorFileNotFound(name);
+
+ byte *maskBuf = (byte*)calloc(1, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+ byte *pathBuf = (byte*)calloc(1, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+
+ _vm->_graphics->parseDepths(_vm->_archive);
+
+ _vm->_archive.read(pathBuf, SCREENPATH_WIDTH*SCREEN_HEIGHT);
+ _vm->_archive.read(maskBuf, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+
+ _vm->_graphics->setMask(maskBuf);
+ _vm->_graphics->setPath(pathBuf);
+
+ return;
+}
} // namespace Parallaction
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index 8ffdc9c658..5e37744e87 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -81,6 +81,8 @@ void loadHead(const char* name, StaticCnv* cnv);
void loadFont(const char* name, Cnv* cnv);
void loadStatic(const char* name, StaticCnv* cnv);
void loadFrames(const char* name, Cnv* cnv);
+void loadBackground(const char *filename);
+void loadMaskAndPath(const char *name);
} // namespace Parallaction
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index c83cf6c119..901b4d2d8e 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -856,40 +856,6 @@ void Graphics::restoreBackgroundPath(Graphics::Buffers path) {
return;
}
-//
-// decompress a graphics block
-//
-uint16 Graphics::decompressChunk(byte *src, byte *dst, uint16 size) {
-
- uint16 written = 0;
- uint16 read = 0;
- uint16 len = 0;
-
- for (; written != size; written += len) {
-
- len = src[read];
- read++;
-
- if (len <= 127) {
- // copy run
-
- len++;
- memcpy(dst+written, src+read, len);
- read += len;
-
- } else {
- // expand run
-
- len = 257 - len;
- memset(dst+written, src[read], len);
- read++;
-
- }
-
- }
-
- return read;
-}
void Graphics::restoreBackground(int16 left, int16 top, uint16 width, uint16 height) {
// printf("restoreBackground(%i, %i, %i, %i)\n", left, top, width, height);
@@ -980,38 +946,21 @@ void Graphics::freeStaticCnv(StaticCnv *cnv) {
return;
}
-
-//
-// slides (background images) are stored compressed by scanline in a rle fashion
-//
-// the uncompressed data must then be unpacked to get:
-// * color data [bits 0-5]
-// * mask data [bits 6-7] (z buffer)
-// * path data [bit 8] (walkable areas)
-//
-
-
-void unpackBackgroundScanline(byte *src, byte *screen, byte *mask, byte *path) {
-
- // update mask, path and screen
- for (uint16 i = 0; i < SCREEN_WIDTH; i++) {
- path[i/8] |= ((src[i] & 0x80) >> 7) << (i & 7);
- mask[i/4] |= ((src[i] & 0x60) >> 5) << ((i & 3) << 1);
- screen[i] = src[i] & 0x1F;
- }
-
- return;
+void Graphics::parseDepths(Common::SeekableReadStream &stream) {
+ _bgLayers[0] = stream.readByte();
+ _bgLayers[1] = stream.readByte();
+ _bgLayers[2] = stream.readByte();
+ _bgLayers[3] = stream.readByte();
}
+
void Graphics::parseBackground(Common::SeekableReadStream &stream) {
stream.read(_palette, PALETTE_SIZE);
- uint16 _si;
- for (_si = 0; _si < 4; _si++)
- _bgLayers[_si] = stream.readByte();
+ parseDepths(stream);
- for (_si = 0; _si < 6; _si++) {
+ for (uint32 _si = 0; _si < 6; _si++) {
_palettefx[_si]._timer = stream.readUint16BE();
_palettefx[_si]._step = stream.readUint16BE();
_palettefx[_si]._flags = stream.readUint16BE();
@@ -1029,54 +978,16 @@ void Graphics::parseBackground(Common::SeekableReadStream &stream) {
}
-void Graphics::loadBackground(const char *filename, Graphics::Buffers buffer) {
-// printf("Graphics::loadBackground(%s)\n", filename);
-
- if (!_vm->_archive.openArchivedFile(filename))
- errorFileNotFound(filename);
-
- parseBackground(_vm->_archive);
-
- memset(_buffers[kPath0], 0, SCREENPATH_WIDTH*SCREEN_HEIGHT);
- memset(_buffers[kMask0], 0, SCREENMASK_WIDTH*SCREEN_HEIGHT);
-
- byte *v4 = (byte*)malloc(SCREEN_SIZE);
- _vm->_archive.read(v4, SCREEN_SIZE);
-
- byte v144[SCREEN_WIDTH];
-
- byte *s = v4;
- for (uint16 i = 0; i < SCREEN_HEIGHT; i++) {
- s += decompressChunk(s, v144, SCREEN_WIDTH);
- unpackBackgroundScanline(v144, _buffers[buffer]+SCREEN_WIDTH*i, _buffers[kMask0]+SCREENMASK_WIDTH*i, _buffers[kPath0]+SCREENPATH_WIDTH*i);
- }
-
- free(v4);
- _vm->_archive.closeArchivedFile();
-
- return;
+void Graphics::setBackground(byte *background) {
+ memcpy(_buffers[kBitBack], background, SCREEN_WIDTH*SCREEN_HEIGHT);
}
-//
-// read background path and mask from a file
-//
-// mask and path are normally combined (via OR) into the background picture itself
-// read the comment on the top of this file for more
-//
-void Graphics::loadMaskAndPath(const char *filename) {
-
- if (!_vm->_archive.openArchivedFile(filename))
- errorFileNotFound(filename);
-
- byte v4[4];
- _vm->_archive.read(v4, 4);
- _vm->_archive.read(_buffers[kPath0], SCREENPATH_WIDTH*SCREEN_HEIGHT);
- _vm->_archive.read(_buffers[kMask0], SCREENMASK_WIDTH*SCREEN_HEIGHT);
-
- for (uint16 _si = 0; _si < 4; _si++) _bgLayers[_si] = v4[_si];
+void Graphics::setMask(byte *mask) {
+ memcpy(_buffers[kMask0], mask, SCREENMASK_WIDTH*SCREEN_HEIGHT);
+}
- _vm->_archive.closeArchivedFile();
- return;
+void Graphics::setPath(byte *path) {
+ memcpy(_buffers[kPath0], path, SCREENPATH_WIDTH*SCREEN_HEIGHT);
}
diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h
index 2202237132..5aef2138ea 100644
--- a/engines/parallaction/graphics.h
+++ b/engines/parallaction/graphics.h
@@ -95,7 +95,10 @@ public:
void restoreCnvBackground(StaticCnv *cnv, int16 x, int16 y);
// location
- void loadBackground(const char *filename, Graphics::Buffers buffer);
+ void setBackground(byte *background);
+ void setMask(byte *mask);
+ void setPath(byte *path);
+ void parseDepths(Common::SeekableReadStream &stream);
void parseBackground(Common::SeekableReadStream &stream);
void loadMaskAndPath(const char *filename);
uint16 queryPath(uint16 x, uint16 y);
@@ -157,12 +160,6 @@ protected:
protected:
- //
- // decompress a graphics block (size is *target* size)
- //
- // returns amount of byte read
- //
- uint16 decompressChunk(byte *src, byte *dst, uint16 size);
//
// maps a character for representation
diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp
index 4994b4424f..ed5f85f058 100644
--- a/engines/parallaction/location.cpp
+++ b/engines/parallaction/location.cpp
@@ -281,13 +281,12 @@ void switchBackground(const char* background, const char* mask) {
char path[PATH_LEN];
sprintf(path, "%s.dyn", background);
- _vm->_graphics->loadBackground(path, Graphics::kBitBack);
+ loadBackground(path);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
if (scumm_stricmp(background, mask)) {
// load external masks and paths only for certain locations
- sprintf(path, "%s.msk", mask);
- _vm->_graphics->loadMaskAndPath(path);
+ loadMaskAndPath(mask);
}
return;
@@ -369,7 +368,7 @@ void Parallaction::changeLocation(char *location) {
char filename[200];
sprintf(filename, "%s.slide", _newLocation);
- _vm->_graphics->loadBackground(filename, Graphics::kBitBack);
+ loadBackground(filename);
_vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
diff --git a/engines/parallaction/menu.cpp b/engines/parallaction/menu.cpp
index e3b72f915d..a342722743 100644
--- a/engines/parallaction/menu.cpp
+++ b/engines/parallaction/menu.cpp
@@ -106,19 +106,19 @@ void Menu::start() {
_vm->_graphics->setFont("slide");
- _vm->_graphics->Graphics::loadBackground("intro.slide", Graphics::kBitBack);
+ loadBackground("intro.slide");
_vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
g_system->delayMillis(2000);
- _vm->_graphics->loadBackground("minintro.slide", Graphics::kBitBack);
+ loadBackground("minintro.slide");
_vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
g_system->delayMillis(2000);
- _vm->_graphics->loadBackground("lingua.slide", Graphics::kBitBack);
+ loadBackground("lingua.slide");
_vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
@@ -146,7 +146,7 @@ void Menu::start() {
break;
}
- _vm->_graphics->loadBackground("restore.slide", Graphics::kBitBack);
+ loadBackground("restore.slide");
_vm->_graphics->palUnk0(_palette);
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
@@ -167,7 +167,7 @@ void Menu::newGame() {
const char **v14 = introMsg3;
- _vm->_graphics->loadBackground("test.dyn", Graphics::kBitBack);
+ loadBackground("test.dyn");
_vm->_graphics->palUnk0(_palette);
_vm->_graphics->swapBuffers();
@@ -317,7 +317,7 @@ void Menu::selectCharacter() {
_vm->_graphics->setFont("slide");
_vm->_archive.open("disk1");
- _vm->_graphics->loadBackground("password.slide", Graphics::kBitBack);
+ loadBackground("password.slide");
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
_vm->_graphics->palUnk0(_palette);