[Scummvm-cvs-logs] SF.net SVN: scummvm: [25968] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Mar 4 11:57:31 CET 2007
Revision: 25968
http://scummvm.svn.sourceforge.net/scummvm/?rev=25968&view=rev
Author: peres001
Date: 2007-03-04 02:57:30 -0800 (Sun, 04 Mar 2007)
Log Message:
-----------
moved background loading into disk.cpp
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/disk.cpp
scummvm/trunk/engines/parallaction/disk.h
scummvm/trunk/engines/parallaction/graphics.cpp
scummvm/trunk/engines/parallaction/graphics.h
scummvm/trunk/engines/parallaction/location.cpp
scummvm/trunk/engines/parallaction/menu.cpp
Modified: scummvm/trunk/engines/parallaction/disk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/disk.cpp 2007-03-04 09:58:04 UTC (rev 25967)
+++ scummvm/trunk/engines/parallaction/disk.cpp 2007-03-04 10:57:30 UTC (rev 25968)
@@ -329,5 +329,89 @@
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
Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h 2007-03-04 09:58:04 UTC (rev 25967)
+++ scummvm/trunk/engines/parallaction/disk.h 2007-03-04 10:57:30 UTC (rev 25968)
@@ -81,6 +81,8 @@
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
Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp 2007-03-04 09:58:04 UTC (rev 25967)
+++ scummvm/trunk/engines/parallaction/graphics.cpp 2007-03-04 10:57:30 UTC (rev 25968)
@@ -856,41 +856,7 @@
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 @@
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::loadBackground(const char *filename, Graphics::Buffers buffer) {
-// printf("Graphics::loadBackground(%s)\n", filename);
+void Graphics::setBackground(byte *background) {
+ memcpy(_buffers[kBitBack], background, SCREEN_WIDTH*SCREEN_HEIGHT);
+}
- 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::setMask(byte *mask) {
+ memcpy(_buffers[kMask0], mask, SCREENMASK_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];
-
- _vm->_archive.closeArchivedFile();
- return;
+void Graphics::setPath(byte *path) {
+ memcpy(_buffers[kPath0], path, SCREENPATH_WIDTH*SCREEN_HEIGHT);
}
Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h 2007-03-04 09:58:04 UTC (rev 25967)
+++ scummvm/trunk/engines/parallaction/graphics.h 2007-03-04 10:57:30 UTC (rev 25968)
@@ -95,7 +95,10 @@
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:
- //
- // 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
Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp 2007-03-04 09:58:04 UTC (rev 25967)
+++ scummvm/trunk/engines/parallaction/location.cpp 2007-03-04 10:57:30 UTC (rev 25968)
@@ -281,13 +281,12 @@
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 @@
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);
Modified: scummvm/trunk/engines/parallaction/menu.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/menu.cpp 2007-03-04 09:58:04 UTC (rev 25967)
+++ scummvm/trunk/engines/parallaction/menu.cpp 2007-03-04 10:57:30 UTC (rev 25968)
@@ -106,19 +106,19 @@
_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 @@
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 @@
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 @@
_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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list