[Scummvm-cvs-logs] SF.net SVN: scummvm:[46727] scummvm/trunk/engines
sev at users.sourceforge.net
sev at users.sourceforge.net
Wed Dec 30 00:18:25 CET 2009
Revision: 46727
http://scummvm.svn.sourceforge.net/scummvm/?rev=46727&view=rev
Author: sev
Date: 2009-12-29 23:18:24 +0000 (Tue, 29 Dec 2009)
Log Message:
-----------
Add Mohawk engine code. Part 1/3: main code.
Added Paths:
-----------
scummvm/trunk/engines/mohawk/
scummvm/trunk/engines/mohawk/bitmap.cpp
scummvm/trunk/engines/mohawk/bitmap.h
scummvm/trunk/engines/mohawk/console.cpp
scummvm/trunk/engines/mohawk/console.h
scummvm/trunk/engines/mohawk/detection.cpp
scummvm/trunk/engines/mohawk/dialogs.cpp
scummvm/trunk/engines/mohawk/dialogs.h
scummvm/trunk/engines/mohawk/file.cpp
scummvm/trunk/engines/mohawk/file.h
scummvm/trunk/engines/mohawk/graphics.cpp
scummvm/trunk/engines/mohawk/graphics.h
scummvm/trunk/engines/mohawk/livingbooks.cpp
scummvm/trunk/engines/mohawk/livingbooks.h
scummvm/trunk/engines/mohawk/module.mk
scummvm/trunk/engines/mohawk/mohawk.cpp
scummvm/trunk/engines/mohawk/mohawk.h
scummvm/trunk/engines/mohawk/myst.cpp
scummvm/trunk/engines/mohawk/myst.h
scummvm/trunk/engines/mohawk/myst_jpeg.cpp
scummvm/trunk/engines/mohawk/myst_jpeg.h
scummvm/trunk/engines/mohawk/myst_pict.cpp
scummvm/trunk/engines/mohawk/myst_pict.h
scummvm/trunk/engines/mohawk/myst_saveload.cpp
scummvm/trunk/engines/mohawk/myst_saveload.h
scummvm/trunk/engines/mohawk/myst_scripts.cpp
scummvm/trunk/engines/mohawk/myst_scripts.h
scummvm/trunk/engines/mohawk/myst_vars.cpp
scummvm/trunk/engines/mohawk/myst_vars.h
scummvm/trunk/engines/mohawk/riven.cpp
scummvm/trunk/engines/mohawk/riven.h
scummvm/trunk/engines/mohawk/riven_cursors.h
scummvm/trunk/engines/mohawk/riven_external.cpp
scummvm/trunk/engines/mohawk/riven_external.h
scummvm/trunk/engines/mohawk/riven_saveload.cpp
scummvm/trunk/engines/mohawk/riven_saveload.h
scummvm/trunk/engines/mohawk/riven_scripts.cpp
scummvm/trunk/engines/mohawk/riven_scripts.h
scummvm/trunk/engines/mohawk/riven_vars.cpp
scummvm/trunk/engines/mohawk/sound.cpp
scummvm/trunk/engines/mohawk/sound.h
scummvm/trunk/engines/mohawk/video/
scummvm/trunk/engines/mohawk/video/cinepak.cpp
scummvm/trunk/engines/mohawk/video/cinepak.h
scummvm/trunk/engines/mohawk/video/qdm2.cpp
scummvm/trunk/engines/mohawk/video/qdm2.h
scummvm/trunk/engines/mohawk/video/qdm2data.h
scummvm/trunk/engines/mohawk/video/qt_player.cpp
scummvm/trunk/engines/mohawk/video/qt_player.h
scummvm/trunk/engines/mohawk/video/qtrle.cpp
scummvm/trunk/engines/mohawk/video/qtrle.h
scummvm/trunk/engines/mohawk/video/rpza.cpp
scummvm/trunk/engines/mohawk/video/rpza.h
scummvm/trunk/engines/mohawk/video/smc.cpp
scummvm/trunk/engines/mohawk/video/smc.h
scummvm/trunk/engines/mohawk/video/video.cpp
scummvm/trunk/engines/mohawk/video/video.h
Added: scummvm/trunk/engines/mohawk/bitmap.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/bitmap.cpp 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,706 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "mohawk/bitmap.h"
+
+#include "common/debug.h"
+#include "common/util.h"
+#include "common/endian.h"
+#include "common/system.h"
+
+namespace Mohawk {
+
+#define PACK_COMPRESSION (_header.format & kPackMASK)
+#define DRAW_COMPRESSION (_header.format & kDrawMASK)
+
+MohawkBitmap::MohawkBitmap() {
+}
+
+MohawkBitmap::~MohawkBitmap() {
+}
+
+ImageData *MohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
+ _data = stream;
+ _header.colorTable.palette = NULL;
+
+ // NOTE: Only the bottom 12 bits of width/height/bytesPerRow are
+ // considered valid and bytesPerRow has to be an even number.
+ _header.width = _data->readUint16BE() & 0x3FFF;
+ _header.height = _data->readUint16BE() & 0x3FFF;
+ _header.bytesPerRow = _data->readSint16BE() & 0x3FFE;
+ _header.format = _data->readUint16BE();
+
+ debug (2, "Decoding Mohawk Bitmap (%dx%d, %dbpp, %s Packing + %s Drawing)", _header.width, _header.height, getBitsPerPixel(), getPackName(), getDrawName());
+
+ if (getBitsPerPixel() != 8)
+ error ("Unhandled bpp %d", getBitsPerPixel());
+
+ // Read in the palette if it's here.
+ if (_header.format & kBitmapHasCLUT || (PACK_COMPRESSION == kPackRiven && getBitsPerPixel() == 8)) {
+ _header.colorTable.tableSize = _data->readUint16BE();
+ _header.colorTable.rgbBits = _data->readByte();
+ _header.colorTable.colorCount = _data->readByte();
+ _header.colorTable.palette = (byte *)malloc(256 * 4);
+
+ for (uint16 i = 0; i < 256; i++) {
+ _header.colorTable.palette[i * 4 + 2] = _data->readByte();
+ _header.colorTable.palette[i * 4 + 1] = _data->readByte();
+ _header.colorTable.palette[i * 4] = _data->readByte();
+ _header.colorTable.palette[i * 4 + 3] = 0;
+ }
+ }
+
+ _surface = new Graphics::Surface();
+ _surface->create(_header.width, _header.height, getBitsPerPixel() >> 3);
+
+ unpackImage();
+ drawImage();
+ delete _data;
+
+ return new ImageData(_surface, _header.colorTable.palette);
+}
+
+byte MohawkBitmap::getBitsPerPixel() {
+ switch (_header.format & kBitsPerPixelMask) {
+ case kBitsPerPixel1:
+ return 1;
+ case kBitsPerPixel4:
+ return 4;
+ case kBitsPerPixel8:
+ return 8;
+ case kBitsPerPixel16:
+ return 16;
+ case kBitsPerPixel24:
+ return 24;
+ default:
+ error ("Unknown bits per pixel");
+ }
+
+ return 0;
+}
+
+struct CompressionInfo {
+ uint16 flag;
+ const char *name;
+ void (MohawkBitmap::*func)();
+};
+
+static const CompressionInfo packTable[] = {
+ { kPackNone, "Raw", &MohawkBitmap::unpackRaw },
+ { kPackLZ, "LZ", &MohawkBitmap::unpackLZ },
+ { kPackLZ1, "LZ1", &MohawkBitmap::unpackLZ1 },
+ { kPackRiven, "Riven", &MohawkBitmap::unpackRiven }
+};
+
+const char *MohawkBitmap::getPackName() {
+ for (uint32 i = 0; i < ARRAYSIZE(packTable); i++)
+ if (PACK_COMPRESSION == packTable[i].flag)
+ return packTable[i].name;
+
+ return "Unknown";
+}
+
+void MohawkBitmap::unpackImage() {
+ for (uint32 i = 0; i < ARRAYSIZE(packTable); i++)
+ if (PACK_COMPRESSION == packTable[i].flag) {
+ (this->*packTable[i].func)();
+ return;
+ }
+
+ warning("Unknown Pack Compression");
+}
+
+static const CompressionInfo drawTable[] = {
+ { kDrawRaw, "Raw", &MohawkBitmap::drawRaw },
+ { kDrawRLE8, "RLE8", &MohawkBitmap::drawRLE8 },
+ { kDrawRLE, "RLE", &MohawkBitmap::drawRLE }
+};
+
+const char *MohawkBitmap::getDrawName() {
+ for (uint32 i = 0; i < ARRAYSIZE(drawTable); i++)
+ if (DRAW_COMPRESSION == drawTable[i].flag)
+ return drawTable[i].name;
+
+ return "Unknown";
+}
+
+void MohawkBitmap::drawImage() {
+ for (uint32 i = 0; i < ARRAYSIZE(drawTable); i++)
+ if (DRAW_COMPRESSION == drawTable[i].flag) {
+ (this->*drawTable[i].func)();
+ return;
+ }
+
+ warning("Unknown Draw Compression");
+}
+
+//////////////////////////////////////////
+// Raw "Unpacker"
+//////////////////////////////////////////
+
+void MohawkBitmap::unpackRaw() {
+ // Do nothing :D
+}
+
+//////////////////////////////////////////
+// LZ Unpacker
+//////////////////////////////////////////
+
+#define LEN_BITS 6
+#define MIN_STRING 3 // lower limit for string length
+#define POS_BITS (16 - LEN_BITS)
+#define MAX_STRING ((1 << LEN_BITS) + MIN_STRING - 1) // upper limit for string length
+#define CBUFFERSIZE (1 << POS_BITS) // size of the circular buffer
+#define POS_MASK (CBUFFERSIZE - 1)
+
+Common::SeekableReadStream *MohawkBitmap::decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize) {
+ uint16 flags = 0;
+ uint32 bytesOut = 0;
+ uint16 insertPos = 0;
+
+ // Expand the output buffer to at least the ring buffer size
+ uint32 outBufSize = MAX<int>(uncompressedSize, CBUFFERSIZE);
+
+ byte *outputData = (byte *)malloc(outBufSize);
+ byte *dst = outputData;
+ byte *buf = dst;
+
+ // Clear the buffer to all 0's
+ memset(outputData, 0, outBufSize);
+
+ while (stream->pos() < stream->size()) {
+ flags >>= 1;
+
+ if (!(flags & 0x100))
+ flags = stream->readByte() | 0xff00;
+
+ if (flags & 1) {
+ if (++bytesOut > uncompressedSize)
+ break;
+ *dst++ = stream->readByte();
+ if (++insertPos > POS_MASK) {
+ insertPos = 0;
+ buf += CBUFFERSIZE;
+ }
+ } else {
+ uint16 offLen = stream->readUint16BE();
+ uint16 stringLen = (offLen >> POS_BITS) + MIN_STRING;
+ uint16 stringPos = (offLen + MAX_STRING) & POS_MASK;
+
+ bytesOut += stringLen;
+ if (bytesOut > uncompressedSize)
+ stringLen -= bytesOut - uncompressedSize;
+
+ byte *strPtr = buf + stringPos;
+ if (stringPos > insertPos) {
+ if (bytesOut >= CBUFFERSIZE)
+ strPtr -= CBUFFERSIZE;
+ else if (stringPos + stringLen > POS_MASK) {
+ for (uint16 k = 0; k < stringLen; k++) {
+ *dst++ = *strPtr++;
+ if (++stringPos > POS_MASK) {
+ stringPos = 0;
+ strPtr = outputData;
+ }
+ }
+ insertPos = (insertPos + stringLen) & POS_MASK;
+ if (bytesOut >= uncompressedSize)
+ break;
+ continue;
+ }
+ }
+
+ insertPos += stringLen;
+
+ if (insertPos > POS_MASK) {
+ insertPos &= POS_MASK;
+ buf += CBUFFERSIZE;
+ }
+
+ for (uint16 k = 0; k < stringLen; k++)
+ *dst++ = *strPtr++;
+
+ if (bytesOut >= uncompressedSize)
+ break;
+ }
+ }
+
+ return new Common::MemoryReadStream(outputData, uncompressedSize, Common::DisposeAfterUse::YES);
+}
+
+void MohawkBitmap::unpackLZ() {
+ uint32 uncompressedSize = _data->readUint32BE();
+ /* uint32 compressedSize = */ _data->readUint32BE();
+ uint16 dictSize = _data->readUint16BE();
+
+ // We only support the buffer size of 0x400
+ if (dictSize != CBUFFERSIZE)
+ error("Unsupported dictionary size of %04x", dictSize);
+
+ // Now go and decompress the data
+ Common::SeekableReadStream *decompressedData = decompressLZ(_data, uncompressedSize);
+ delete _data;
+ _data = decompressedData;
+}
+
+//////////////////////////////////////////
+// LZ Unpacker
+//////////////////////////////////////////
+
+void MohawkBitmap::unpackLZ1() {
+ error("STUB: unpackLZ1()");
+}
+
+//////////////////////////////////////////
+// Riven Unpacker
+//////////////////////////////////////////
+
+void MohawkBitmap::unpackRiven() {
+ _data->readUint32BE(); // Unknown, the number is close to bytesPerRow * height. Could be bufSize.
+
+ byte *uncompressedData = (byte *)malloc(_header.bytesPerRow * _header.height);
+ byte *dst = uncompressedData;
+
+ while (!_data->eos() && dst < (uncompressedData + _header.bytesPerRow * _header.height)) {
+ byte cmd = _data->readByte();
+ debug (8, "Riven Pack Command %02x", cmd);
+
+ if (cmd == 0x00) { // End of stream
+ break;
+ } else if (cmd >= 0x01 && cmd <= 0x3f) { // Simple Pixel Duplet Output
+ for (byte i = 0; i < cmd; i++) {
+ *dst++ = _data->readByte();
+ *dst++ = _data->readByte();
+ }
+ } else if (cmd >= 0x40 && cmd <= 0x7f) { // Simple Repetition of last 2 pixels (cmd - 0x40) times
+ byte pixel[] = { *(dst - 2), *(dst - 1) };
+
+ for (byte i = 0; i < (cmd - 0x40); i++) {
+ *dst++ = pixel[0];
+ *dst++ = pixel[1];
+ }
+ } else if (cmd >= 0x80 && cmd <= 0xbf) { // Simple Repetition of last 4 pixels (cmd - 0x80) times
+ byte pixel[] = { *(dst - 4), *(dst - 3), *(dst - 2), *(dst - 1) };
+
+ for (byte i = 0; i < (cmd - 0x80); i++) {
+ *dst++ = pixel[0];
+ *dst++ = pixel[1];
+ *dst++ = pixel[2];
+ *dst++ = pixel[3];
+ }
+ } else { // Subcommand Stream of (cmd - 0xc0) subcommands
+ handleRivenSubcommandStream(cmd - 0xc0, dst);
+ }
+ }
+
+ delete _data;
+ _data = new Common::MemoryReadStream(uncompressedData, _header.bytesPerRow * _header.height, Common::DisposeAfterUse::YES);
+}
+
+static byte getLastTwoBits(byte c) {
+ return (c & 0x03);
+}
+
+static byte getLastThreeBits(byte c) {
+ return (c & 0x07);
+}
+
+static byte getLastFourBits(byte c) {
+ return (c & 0x0f);
+}
+
+#define B_BYTE() \
+ *dst = _data->readByte(); \
+ dst++
+
+#define B_LASTDUPLET() \
+ *dst = *(dst - 2); \
+ dst++
+
+#define B_LASTDUPLET_PLUS_M() \
+ *dst = *(dst - 2) + m; \
+ dst++
+
+#define B_LASTDUPLET_MINUS_M() \
+ *dst = *(dst - 2) - m; \
+ dst++
+
+#define B_LASTDUPLET_PLUS(m) \
+ *dst = *(dst - 2) + (m); \
+ dst++
+
+#define B_LASTDUPLET_MINUS(m) \
+ *dst = *(dst - 2) - (m); \
+ dst++
+
+#define B_PIXEL_MINUS(m) \
+ *dst = *(dst - (m)); \
+ dst++
+
+#define B_NDUPLETS(n) \
+ uint16 m1 = ((getLastTwoBits(cmd) << 8) + _data->readByte()); \
+ for (uint16 j = 0; j < (n); j++) { \
+ *dst = *(dst - m1); \
+ dst++; \
+ } \
+ void dummyFuncToAllowTrailingSemicolon()
+
+
+
+void MohawkBitmap::handleRivenSubcommandStream(byte count, byte *&dst) {
+ for (byte i = 0; i < count; i++) {
+ byte cmd = _data->readByte();
+ uint16 m = getLastFourBits(cmd);
+ debug (9, "Riven Pack Subcommand %02x", cmd);
+
+ // Notes: p = value of the next byte, m = last four bits of the command
+
+ // Arithmetic operations
+ if (cmd >= 0x01 && cmd <= 0x0f) {
+ // Repeat duplet at relative position of -m duplets
+ B_PIXEL_MINUS(m * 2);
+ B_PIXEL_MINUS(m * 2);
+ } else if (cmd == 0x10) {
+ // Repeat last duplet, but set the value of the second pixel to p
+ B_LASTDUPLET();
+ B_BYTE();
+ } else if (cmd >= 0x11 && cmd <= 0x1f) {
+ // Repeat last duplet, but set the value of the second pixel to the value of the -m pixel
+ B_LASTDUPLET();
+ B_PIXEL_MINUS(m);
+ } else if (cmd >= 0x20 && cmd <= 0x2f) {
+ // Repeat last duplet, but add x to second pixel
+ B_LASTDUPLET();
+ B_LASTDUPLET_PLUS_M();
+ } else if (cmd >= 0x30 && cmd <= 0x3f) {
+ // Repeat last duplet, but subtract x from second pixel
+ B_LASTDUPLET();
+ B_LASTDUPLET_MINUS_M();
+ } else if (cmd == 0x40) {
+ // Repeat last duplet, but set the value of the first pixel to p
+ B_BYTE();
+ B_LASTDUPLET();
+ } else if (cmd >= 0x41 && cmd <= 0x4f) {
+ // Output pixel at relative position -m, then second pixel of last duplet
+ B_PIXEL_MINUS(m);
+ B_LASTDUPLET();
+ } else if (cmd == 0x50) {
+ // Output two absolute pixel values, p1 and p2
+ B_BYTE();
+ B_BYTE();
+ } else if (cmd >= 0x51 && cmd <= 0x57) {
+ // Output pixel at relative position -m, then absolute pixel value p
+ // m is the last 3 bits of cmd here, not last 4
+ B_PIXEL_MINUS(getLastThreeBits(cmd));
+ B_BYTE();
+ } else if (cmd >= 0x59 && cmd <= 0x5f) {
+ // Output absolute pixel value p, then pixel at relative position -m
+ // m is the last 3 bits of cmd here, not last 4
+ B_BYTE();
+ B_PIXEL_MINUS(getLastThreeBits(cmd));
+ } else if (cmd >= 0x60 && cmd <= 0x6f) {
+ // Output absolute pixel value p, then (second pixel of last duplet) + x
+ B_BYTE();
+ B_LASTDUPLET_PLUS_M();
+ } else if (cmd >= 0x70 && cmd <= 0x7f) {
+ // Output absolute pixel value p, then (second pixel of last duplet) - x
+ B_BYTE();
+ B_LASTDUPLET_MINUS_M();
+ } else if (cmd >= 0x80 && cmd <= 0x8f) {
+ // Repeat last duplet adding x to the first pixel
+ B_LASTDUPLET_PLUS_M();
+ B_LASTDUPLET();
+ } else if (cmd >= 0x90 && cmd <= 0x9f) {
+ // Output (first pixel of last duplet) + x, then absolute pixel value p
+ B_LASTDUPLET_PLUS_M();
+ B_BYTE();
+ } else if (cmd == 0xa0) {
+ // Repeat last duplet, adding first 4 bits of the next byte
+ // to first pixel and last 4 bits to second
+ byte pattern = _data->readByte();
+ B_LASTDUPLET_PLUS(pattern >> 4);
+ B_LASTDUPLET_PLUS(getLastFourBits(pattern));
+ } else if (cmd == 0xb0) {
+ // Repeat last duplet, adding first 4 bits of the next byte
+ // to first pixel and subtracting last 4 bits from second
+ byte pattern = _data->readByte();
+ B_LASTDUPLET_PLUS(pattern >> 4);
+ B_LASTDUPLET_MINUS(getLastFourBits(pattern));
+ } else if (cmd >= 0xc0 && cmd <= 0xcf) {
+ // Repeat last duplet subtracting x from first pixel
+ B_LASTDUPLET_MINUS_M();
+ B_LASTDUPLET();
+ } else if (cmd >= 0xd0 && cmd <= 0xdf) {
+ // Output (first pixel of last duplet) - x, then absolute pixel value p
+ B_LASTDUPLET_MINUS_M();
+ B_BYTE();
+ } else if (cmd == 0xe0) {
+ // Repeat last duplet, subtracting first 4 bits of the next byte
+ // to first pixel and adding last 4 bits to second
+ byte pattern = _data->readByte();
+ B_LASTDUPLET_MINUS(pattern >> 4);
+ B_LASTDUPLET_PLUS(getLastFourBits(pattern));
+ } else if (cmd == 0xf0 || cmd == 0xff) {
+ // Repeat last duplet, subtracting first 4 bits from the next byte
+ // to first pixel and last 4 bits from second
+ byte pattern = _data->readByte();
+ B_LASTDUPLET_MINUS(pattern >> 4);
+ B_LASTDUPLET_MINUS(getLastFourBits(pattern));
+
+ // Repeat operations
+ // Repeat n duplets from relative position -m (given in pixels, not duplets).
+ // If r is 0, another byte follows and the last pixel is set to that value
+ } else if (cmd >= 0xa4 && cmd <= 0xa7) {
+ B_NDUPLETS(3);
+ B_BYTE();
+ } else if (cmd >= 0xa8 && cmd <= 0xab) {
+ B_NDUPLETS(4);
+ } else if (cmd >= 0xac && cmd <= 0xaf) {
+ B_NDUPLETS(5);
+ B_BYTE();
+ } else if (cmd >= 0xb4 && cmd <= 0xb7) {
+ B_NDUPLETS(6);
+ } else if (cmd >= 0xb8 && cmd <= 0xbb) {
+ B_NDUPLETS(7);
+ B_BYTE();
+ } else if (cmd >= 0xbc && cmd <= 0xbf) {
+ B_NDUPLETS(8);
+ } else if (cmd >= 0xe4 && cmd <= 0xe7) {
+ B_NDUPLETS(9);
+ B_BYTE();
+ } else if (cmd >= 0xe8 && cmd <= 0xeb) {
+ B_NDUPLETS(10); // 5 duplets
+ } else if (cmd >= 0xec && cmd <= 0xef) {
+ B_NDUPLETS(11);
+ B_BYTE();
+ } else if (cmd >= 0xf4 && cmd <= 0xf7) {
+ B_NDUPLETS(12);
+ } else if (cmd >= 0xf8 && cmd <= 0xfb) {
+ B_NDUPLETS(13);
+ B_BYTE();
+ } else if (cmd == 0xfc) {
+ byte b1 = _data->readByte();
+ byte b2 = _data->readByte();
+ uint16 m1 = ((getLastTwoBits(b1) << 8) + b2);
+
+ for (uint16 j = 0; j < ((b1 >> 3) + 1); j++) { // one less iteration
+ B_PIXEL_MINUS(m1);
+ B_PIXEL_MINUS(m1);
+ }
+
+ // last iteration
+ B_PIXEL_MINUS(m1);
+
+ if ((b1 & (1 << 2)) == 0) {
+ B_BYTE();
+ } else {
+ B_PIXEL_MINUS(m1);
+ }
+ } else
+ warning("Unknown Riven Pack Subcommand 0x%02x", cmd);
+ }
+}
+
+//////////////////////////////////////////
+// Raw Drawer
+//////////////////////////////////////////
+
+void MohawkBitmap::drawRaw() {
+ for (uint16 y = 0; y < _header.height; y++) {
+ _data->read((byte *)_surface->pixels + y * _header.width, _header.width);
+ _data->skip(_header.bytesPerRow - _header.width);
+ }
+}
+
+//////////////////////////////////////////
+// RLE8 Drawer
+//////////////////////////////////////////
+
+void MohawkBitmap::drawRLE8() {
+ // A very simple RLE8 scheme is used as a secondary compression on
+ // most images in non-Riven tBMP's.
+
+ for (uint16 i = 0; i < _header.height; i++) {
+ uint16 rowByteCount = _data->readUint16BE();
+ int32 startPos = _data->pos();
+ byte *dst = (byte *)_surface->pixels + i * _header.width;
+ int16 remaining = _header.width;
+
+ // HACK: It seems only the bottom 9 bits are valid for images
+ // TODO: Verify if this is still needed after the buffer clearing fix.
+ rowByteCount &= 0x1ff;
+
+ while (remaining > 0) {
+ byte code = _data->readByte();
+ uint16 runLen = (code & 0x7F) + 1;
+
+ if (runLen > remaining)
+ runLen = remaining;
+
+ if (code & 0x80) {
+ byte val = _data->readByte();
+ for (uint16 j = 0; j < runLen; j++)
+ *dst++ = val;
+ } else {
+ for (uint16 j = 0; j < runLen; j++)
+ *dst++ = _data->readByte();
+ }
+
+ remaining -= runLen;
+ }
+
+ _data->seek(startPos + rowByteCount);
+ }
+}
+
+//////////////////////////////////////////
+// RLE Drawer
+//////////////////////////////////////////
+
+void MohawkBitmap::drawRLE() {
+ warning("STUB: drawRLE()");
+}
+
+//////////////////////////////////////////
+// Myst Bitmap Decoder
+//////////////////////////////////////////
+
+ImageData* MystBitmap::decodeImage(Common::SeekableReadStream* stream) {
+ uint32 uncompressedSize = stream->readUint32LE();
+ Common::SeekableReadStream* bmpStream = decompressLZ(stream, uncompressedSize);
+ delete stream;
+
+ _header.type = bmpStream->readUint16BE();
+
+ if (_header.type != 'BM')
+ error("BMP header not detected");
+
+ _header.size = bmpStream->readUint32LE();
+ assert (_header.size > 0);
+ _header.res1 = bmpStream->readUint16LE();
+ _header.res2 = bmpStream->readUint16LE();
+ _header.imageOffset = bmpStream->readUint32LE();
+
+ _info.size = bmpStream->readUint32LE();
+
+ if (_info.size != 40)
+ error("Only Windows v3 BMP's are supported");
+
+ _info.width = bmpStream->readUint32LE();
+ _info.height = bmpStream->readUint32LE();
+ _info.planes = bmpStream->readUint16LE();
+ _info.bitsPerPixel = bmpStream->readUint16LE();
+ _info.compression = bmpStream->readUint32LE();
+ _info.imageSize = bmpStream->readUint32LE();
+ _info.pixelsPerMeterX = bmpStream->readUint32LE();
+ _info.pixelsPerMeterY = bmpStream->readUint32LE();
+ _info.colorsUsed = bmpStream->readUint32LE();
+ _info.colorsImportant = bmpStream->readUint32LE();
+
+ if (_info.compression != 0)
+ error("Unhandled BMP compression %d", _info.compression);
+
+ if (_info.colorsUsed == 0)
+ _info.colorsUsed = 256;
+
+ // TODO: Myst ME's Help.dat contains WDIB's with 24bpp color.
+ if (_info.bitsPerPixel != 8 && _info.bitsPerPixel != 24)
+ error("%dbpp Bitmaps not supported", _info.bitsPerPixel);
+
+ byte *palData = NULL;
+
+ if (_info.bitsPerPixel == 8) {
+ palData = (byte *)malloc(256 * 4);
+ for (uint16 i = 0; i < _info.colorsUsed; i++) {
+ palData[i * 4 + 2] = bmpStream->readByte();
+ palData[i * 4 + 1] = bmpStream->readByte();
+ palData[i * 4] = bmpStream->readByte();
+ palData[i * 4 + 3] = bmpStream->readByte();
+ }
+ }
+
+ bmpStream->seek(_header.imageOffset);
+
+ Graphics::Surface *surface = new Graphics::Surface();
+ int srcPitch = _info.width * (_info.bitsPerPixel >> 3);
+ const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0;
+
+ if (_info.bitsPerPixel == 8) {
+ surface->create(_info.width, _info.height, 1);
+ byte *dst = (byte *)surface->pixels;
+
+ for (uint32 i = 0; i < _info.height; i++) {
+ bmpStream->read(dst + (_info.height - i - 1) * _info.width, _info.width);
+ bmpStream->skip(extraDataLength);
+ }
+ } else {
+ Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
+ surface->create(_info.width, _info.height, pixelFormat.bytesPerPixel);
+
+ byte *dst = (byte *)surface->pixels + (surface->h - 1) * surface->pitch;
+
+ for (uint32 i = 0; i < _info.height; i++) {
+ for (uint32 j = 0; j < _info.width; j++) {
+ byte b = bmpStream->readByte();
+ byte g = bmpStream->readByte();
+ byte r = bmpStream->readByte();
+
+ if (pixelFormat.bytesPerPixel == 2)
+ *((uint16 *)dst) = pixelFormat.RGBToColor(r, g, b);
+ else
+ *((uint32 *)dst) = pixelFormat.RGBToColor(r, g, b);
+
+ dst += pixelFormat.bytesPerPixel;
+ }
+
+ bmpStream->skip(extraDataLength);
+ dst -= surface->pitch * 2;
+ }
+ }
+
+ delete bmpStream;
+
+ return new ImageData(surface, palData);
+}
+
+ImageData *OldMohawkBitmap::decodeImage(Common::SeekableReadStream *stream) {
+ Common::SeekableSubReadStreamEndian *endianStream = (Common::SeekableSubReadStreamEndian *)stream;
+
+ // The format part is just a guess at this point. Note that the width and height roles have been reversed!
+
+ _header.height = endianStream->readUint16() & 0x3FF;
+ _header.width = endianStream->readUint16() & 0x3FF;
+ _header.bytesPerRow = endianStream->readUint16() & 0x3FE;
+ _header.format = endianStream->readUint16();
+
+ debug(2, "Decoding Old Mohawk Bitmap (%dx%d, %04x Format)", _header.width, _header.height, _header.format);
+
+ warning("Unhandled old Mohawk Bitmap decoding");
+
+ delete stream;
+ return new ImageData(NULL, NULL);
+}
+
+} // End of namespace Mohawk
Property changes on: scummvm/trunk/engines/mohawk/bitmap.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/bitmap.h
===================================================================
--- scummvm/trunk/engines/mohawk/bitmap.h (rev 0)
+++ scummvm/trunk/engines/mohawk/bitmap.h 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,159 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MOHAWK_BITMAP_H
+#define MOHAWK_BITMAP_H
+
+#include "mohawk/graphics.h"
+
+#include "common/scummsys.h"
+#include "common/stream.h"
+#include "graphics/surface.h"
+
+namespace Mohawk {
+
+class ImageData;
+
+enum BitmapFormat {
+ kBitsPerPixel1 = 0x0000,
+ kBitsPerPixel4 = 0x0001,
+ kBitsPerPixel8 = 0x0002,
+ kBitsPerPixel16 = 0x0003,
+ kBitsPerPixel24 = 0x0004,
+ kBitsPerPixelMask = 0x0007,
+ kBitmapHasCLUT = 0x0008,
+ kDrawMASK = 0x00f0,
+ kDrawRaw = 0x0000,
+ kDrawRLE8 = 0x0010,
+ kDrawMSRLE8 = 0x0020,
+ kDrawRLE = 0x0030,
+ kPackMASK = 0x0f00,
+ kPackNone = 0x0000,
+ kPackLZ = 0x0100,
+ kPackLZ1 = 0x0200,
+ kPackRiven = 0x0400,
+ kPackXDec = 0x0f00,
+ kFlagMASK = 0xf000,
+ kFlag16_80X86 = 0x1000, // 16 bit pixel data has been converted to 80X86 format
+ kFlag24_MAC = 0x1000 // 24 bit pixel data has been converted to MAC 32 bit format
+};
+
+struct BitmapHeader {
+ uint16 width;
+ uint16 height;
+ int16 bytesPerRow;
+ uint16 format;
+
+ struct ColorTable {
+ uint16 tableSize;
+ byte rgbBits;
+ byte colorCount;
+ byte* palette; // In 8bpp only
+ } colorTable;
+};
+
+class MohawkBitmap {
+public:
+ MohawkBitmap();
+ virtual ~MohawkBitmap();
+
+ virtual ImageData *decodeImage(Common::SeekableReadStream *stream);
+
+ // Unpack Functions
+ void unpackRaw();
+ void unpackLZ();
+ void unpackLZ1();
+ void unpackRiven();
+
+ // Draw Functions
+ void drawRaw();
+ void drawRLE8();
+ void drawRLE();
+
+protected:
+ BitmapHeader _header;
+ byte getBitsPerPixel();
+
+ // The actual LZ decoder
+ static Common::SeekableReadStream *decompressLZ(Common::SeekableReadStream *stream, uint32 uncompressedSize);
+
+private:
+ Common::SeekableReadStream *_data;
+ Graphics::Surface *_surface;
+
+ const char *getPackName();
+ void unpackImage();
+ const char *getDrawName();
+ void drawImage();
+
+ // Riven Decoding
+ void handleRivenSubcommandStream(byte count, byte *&dst);
+};
+
+// Myst uses a different image format than that of other Mohawk games.
+// It essentially uses a Windows bitmap with the LZ encoding from the
+// Mohawk Bitmap format.
+class MystBitmap : public MohawkBitmap {
+public:
+ MystBitmap() : MohawkBitmap() {}
+ ~MystBitmap() {}
+
+ ImageData *decodeImage(Common::SeekableReadStream *stream);
+
+private:
+ struct BitmapHeader {
+ uint16 type;
+ uint32 size;
+ uint16 res1;
+ uint16 res2;
+ uint32 imageOffset;
+ } _header;
+
+ struct InfoHeader {
+ uint32 size;
+ uint32 width;
+ uint32 height;
+ uint16 planes;
+ uint16 bitsPerPixel;
+ uint32 compression;
+ uint32 imageSize;
+ uint32 pixelsPerMeterX;
+ uint32 pixelsPerMeterY;
+ uint32 colorsUsed;
+ uint32 colorsImportant;
+ } _info;
+};
+
+class OldMohawkBitmap : public MohawkBitmap {
+public:
+ OldMohawkBitmap() : MohawkBitmap() {}
+ ~OldMohawkBitmap() {}
+
+ ImageData *decodeImage(Common::SeekableReadStream *stream);
+};
+
+} // End of namespace Mohawk
+
+#endif
Property changes on: scummvm/trunk/engines/mohawk/bitmap.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/console.cpp 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,641 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "mohawk/console.h"
+#include "mohawk/myst.h"
+#include "mohawk/myst_scripts.h"
+#include "mohawk/graphics.h"
+#include "mohawk/riven.h"
+#include "mohawk/livingbooks.h"
+
+namespace Mohawk {
+
+MystConsole::MystConsole(MohawkEngine_Myst *vm) : GUI::Debugger(), _vm(vm) {
+ DCmd_Register("changeCard", WRAP_METHOD(MystConsole, Cmd_ChangeCard));
+ DCmd_Register("curCard", WRAP_METHOD(MystConsole, Cmd_CurCard));
+ DCmd_Register("var", WRAP_METHOD(MystConsole, Cmd_Var));
+ DCmd_Register("curStack", WRAP_METHOD(MystConsole, Cmd_CurStack));
+ DCmd_Register("changeStack", WRAP_METHOD(MystConsole, Cmd_ChangeStack));
+ DCmd_Register("drawImage", WRAP_METHOD(MystConsole, Cmd_DrawImage));
+ DCmd_Register("drawRect", WRAP_METHOD(MystConsole, Cmd_DrawRect));
+ DCmd_Register("setResourceEnable", WRAP_METHOD(MystConsole, Cmd_SetResourceEnable));
+ DCmd_Register("playSound", WRAP_METHOD(MystConsole, Cmd_PlaySound));
+ DCmd_Register("stopSound", WRAP_METHOD(MystConsole, Cmd_StopSound));
+ DCmd_Register("playMovie", WRAP_METHOD(MystConsole, Cmd_PlayMovie));
+ DCmd_Register("disableInitOpcodes", WRAP_METHOD(MystConsole, Cmd_DisableInitOpcodes));
+}
+
+MystConsole::~MystConsole() {
+}
+
+void MystConsole::preEnter() {
+ _vm->_sound->pauseSound();
+}
+
+void MystConsole::postEnter() {
+ _vm->_sound->resumeSound();
+}
+
+bool MystConsole::Cmd_ChangeCard(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: changeCard <card>\n");
+ return true;
+ }
+
+ _vm->_sound->stopSound();
+ _vm->changeToCard((uint16)atoi(argv[1]));
+
+ return false;
+}
+
+bool MystConsole::Cmd_CurCard(int argc, const char **argv) {
+ DebugPrintf("Current Card: %d\n", _vm->getCurCard());
+ return true;
+}
+
+bool MystConsole::Cmd_Var(int argc, const char **argv) {
+ if (argc == 1) {
+ DebugPrintf("Usage: var <var> (<value>)\n");
+ return true;
+ }
+
+ if (argc > 2)
+ _vm->_varStore->setVar((uint16)atoi(argv[1]), (uint32)atoi(argv[2]));
+
+ DebugPrintf("%d = %d\n", (uint16)atoi(argv[1]), _vm->_varStore->getVar((uint16)atoi(argv[1])));
+
+ return true;
+}
+
+static const char *mystStackNames[12] = {
+ "Channelwood",
+ "Credits",
+ "Demo",
+ "D'ni",
+ "Intro",
+ "MakingOf",
+ "Mechanical",
+ "Myst",
+ "Selenitic",
+ "Slideshow",
+ "SneakPreview",
+ "Stoneship"
+};
+
+static const uint16 default_start_card[12] = {
+ 3137,
+ 10000,
+ 2001, // TODO: Should be 2000?
+ 5038,
+ 2, // TODO: Should be 1?
+ 1,
+ 6122,
+ 4134,
+ 1282,
+ 1000,
+ 3000,
+ 2029
+};
+
+bool MystConsole::Cmd_CurStack(int argc, const char **argv) {
+ DebugPrintf("Current Stack: %s\n", mystStackNames[_vm->getCurStack()]);
+ return true;
+}
+
+bool MystConsole::Cmd_ChangeStack(int argc, const char **argv) {
+ if (argc != 2 && argc != 3) {
+ DebugPrintf("Usage: changeStack <stack> [<card>]\n\n");
+ DebugPrintf("Stacks:\n=======\n");
+
+ for (byte i = 0; i < ARRAYSIZE(mystStackNames); i++)
+ DebugPrintf(" %s\n", mystStackNames[i]);
+
+ DebugPrintf("\n");
+
+ return true;
+ }
+
+ byte stackNum = 0;
+
+ for (byte i = 1; i <= ARRAYSIZE(mystStackNames); i++)
+ if (!scumm_stricmp(argv[1], mystStackNames[i - 1])) {
+ stackNum = i;
+ break;
+ }
+
+ if (!stackNum) {
+ DebugPrintf("\'%s\' is not a stack name!\n", argv[1]);
+ return true;
+ }
+
+ // We need to stop any playing sound when we change the stack
+ // as the next card could continue playing it if it.
+ _vm->_sound->stopSound();
+
+ _vm->changeToStack(stackNum - 1);
+
+ if (argc == 3)
+ _vm->changeToCard((uint16)atoi(argv[2]));
+ else
+ _vm->changeToCard(default_start_card[stackNum - 1]);
+
+ return false;
+}
+
+bool MystConsole::Cmd_DrawImage(int argc, const char **argv) {
+ if (argc != 2 && argc != 6) {
+ DebugPrintf("Usage: drawImage <image> [<left> <top> <right> <bottom>]\n");
+ return true;
+ }
+
+ Common::Rect rect;
+
+ if (argc == 2)
+ rect = Common::Rect(0, 0, 544, 333);
+ else
+ 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);
+ return false;
+}
+
+bool MystConsole::Cmd_DrawRect(int argc, const char **argv) {
+ if (argc < 5) {
+ DebugPrintf("Usage: drawRect <left> <top> <right> <bottom>\n");
+ return true;
+ }
+
+ _vm->_gfx->drawRect(Common::Rect((uint16)atoi(argv[1]), (uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4])), true);
+ return false;
+}
+
+bool MystConsole::Cmd_SetResourceEnable(int argc, const char **argv) {
+ if (argc < 3) {
+ DebugPrintf("Usage: setResourceEnable <resource id> <bool>\n");
+ return true;
+ }
+
+ _vm->setResourceEnabled((uint16)atoi(argv[1]), atoi(argv[2]) == 1);
+ return true;
+}
+
+bool MystConsole::Cmd_PlaySound(int argc, const char **argv) {
+ if (argc == 1) {
+ DebugPrintf("Usage: playSound <value>\n");
+
+ return true;
+ }
+
+ _vm->_sound->stopSound();
+ _vm->_sound->playSound((uint16)atoi(argv[1]));
+
+ return false;
+}
+
+bool MystConsole::Cmd_StopSound(int argc, const char **argv) {
+ DebugPrintf("Stopping Sound\n");
+
+ _vm->_sound->stopSound();
+
+ return true;
+}
+
+bool MystConsole::Cmd_PlayMovie(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: playMovie <name> [<stack>] [<left> <top>]\n");
+ DebugPrintf("NOTE: The movie will play *once* in the background.\n");
+ return true;
+ }
+
+ int8 stackNum = 0;
+
+ if (argc == 3 || argc > 4) {
+ for (byte i = 1; i <= ARRAYSIZE(mystStackNames); i++)
+ if (!scumm_stricmp(argv[2], mystStackNames[i - 1])) {
+ stackNum = i;
+ break;
+ }
+
+ if (!stackNum) {
+ DebugPrintf("\'%s\' is not a stack name!\n", argv[2]);
+ return true;
+ }
+ }
+
+ if (argc == 2)
+ _vm->_video->playBackgroundMovie(argv[1], 0, 0);
+ else if (argc == 3)
+ _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename(argv[1], stackNum - 1), 0, 0);
+ else if (argc == 4)
+ _vm->_video->playBackgroundMovie(argv[1], atoi(argv[2]), atoi(argv[3]));
+ else
+ _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename(argv[1], stackNum - 1), atoi(argv[3]), atoi(argv[4]));
+
+ return false;
+}
+
+bool MystConsole::Cmd_DisableInitOpcodes(int argc, const char **argv) {
+ if (argc != 1) {
+ DebugPrintf("Usage: disableInitOpcodes\n");
+
+ return true;
+ }
+
+ _vm->_scriptParser->disableInitOpcodes();
+
+ return true;
+}
+
+RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) {
+ DCmd_Register("changeCard", WRAP_METHOD(RivenConsole, Cmd_ChangeCard));
+ DCmd_Register("curCard", WRAP_METHOD(RivenConsole, Cmd_CurCard));
+ DCmd_Register("var", WRAP_METHOD(RivenConsole, Cmd_Var));
+ DCmd_Register("playSound", WRAP_METHOD(RivenConsole, Cmd_PlaySound));
+ DCmd_Register("playSLST", WRAP_METHOD(RivenConsole, Cmd_PlaySLST));
+ DCmd_Register("stopSound", WRAP_METHOD(RivenConsole, Cmd_StopSound));
+ DCmd_Register("curStack", WRAP_METHOD(RivenConsole, Cmd_CurStack));
+ DCmd_Register("changeStack", WRAP_METHOD(RivenConsole, Cmd_ChangeStack));
+ DCmd_Register("restart", WRAP_METHOD(RivenConsole, Cmd_Restart));
+ DCmd_Register("hotspots", WRAP_METHOD(RivenConsole, Cmd_Hotspots));
+ DCmd_Register("zipMode", WRAP_METHOD(RivenConsole, Cmd_ZipMode));
+ DCmd_Register("dumpScript", WRAP_METHOD(RivenConsole, Cmd_DumpScript));
+ DCmd_Register("listZipCards", WRAP_METHOD(RivenConsole, Cmd_ListZipCards));
+ DCmd_Register("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP));
+}
+
+RivenConsole::~RivenConsole() {
+}
+
+void RivenConsole::preEnter() {
+ _vm->_sound->pauseSound();
+ _vm->_sound->pauseSLST();
+}
+
+void RivenConsole::postEnter() {
+ _vm->_sound->resumeSound();
+ _vm->_sound->resumeSLST();
+}
+
+bool RivenConsole::Cmd_ChangeCard(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: changeCard <card>\n");
+ return true;
+ }
+
+ _vm->_sound->stopSound();
+ _vm->_sound->stopAllSLST();
+ _vm->changeToCard((uint16)atoi(argv[1]));
+
+ return false;
+}
+
+bool RivenConsole::Cmd_CurCard(int argc, const char **argv) {
+ DebugPrintf("Current Card: %d\n", _vm->getCurCard());
+
+ return true;
+}
+
+bool RivenConsole::Cmd_Var(int argc, const char **argv) {
+ if (argc == 1) {
+ DebugPrintf("Usage: var <var name> (<value>)\n");
+ return true;
+ }
+
+ uint32 *globalVar = _vm->matchVarToString(argv[1]);
+
+ if (!globalVar) {
+ DebugPrintf("Unknown variable \'%s\'\n", argv[1]);
+ return true;
+ }
+
+ if (argc > 2)
+ *globalVar = (uint32)atoi(argv[2]);
+
+ DebugPrintf("%s = %d\n", argv[1], *globalVar);
+
+ return true;
+}
+
+bool RivenConsole::Cmd_PlaySound(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: playSound <value> (<use main sound file, default = true>)\n");
+ DebugPrintf("The main sound file is default, but you can use the word \'false\' to make it use the current stack file.\n");
+
+ return true;
+ }
+
+ _vm->_sound->stopSound();
+ _vm->_sound->stopAllSLST();
+
+ bool mainSoundFile = (argc < 3) || (scumm_stricmp(argv[2], "false") != 0);
+
+ _vm->_sound->playSound((uint16)atoi(argv[1]), mainSoundFile);
+
+ return false;
+}
+
+bool RivenConsole::Cmd_PlaySLST(int argc, const char **argv) {
+ if (argc < 2) {
+ DebugPrintf("Usage: playSLST <slst index> <card, default = current>\n");
+
+ return true;
+ }
+
+ _vm->_sound->stopSound();
+ _vm->_sound->stopAllSLST();
+
+ uint16 card = _vm->getCurCard();
+
+ if (argc == 3)
+ card = (uint16)atoi(argv[2]);
+
+ _vm->_sound->playSLST((uint16)atoi(argv[1]), card);
+
+ return false;
+}
+
+bool RivenConsole::Cmd_StopSound(int argc, const char **argv) {
+ DebugPrintf("Stopping Sound\n");
+
+ _vm->_sound->stopSound();
+ _vm->_sound->stopAllSLST();
+
+ return true;
+}
+
+bool RivenConsole::Cmd_CurStack(int argc, const char **argv) {
+ DebugPrintf("Current Stack: %s\n", _vm->getStackName(_vm->getCurStack()).c_str());
+
+ return true;
+}
+
+bool RivenConsole::Cmd_ChangeStack(int argc, const char **argv) {
+ byte i;
+
+ if (argc < 3) {
+ DebugPrintf("Usage: changeStack <stack> <card>\n\n");
+ DebugPrintf("Stacks:\n=======\n");
+
+ for (i = 0; i <= tspit; i++)
+ DebugPrintf(" %s\n", _vm->getStackName(i).c_str());
+
+ DebugPrintf("\n");
+
+ return true;
+ }
+
+ byte stackNum = 0;
+
+ for (i = 1; i <= tspit + 1; i++)
+ if (!scumm_stricmp(argv[1], _vm->getStackName(i - 1).c_str())) {
+ stackNum = i;
+ break;
+ }
+
+ if (!stackNum) {
+ DebugPrintf("\'%s\' is not a stack name!\n", argv[1]);
+ return true;
+ }
+
+ _vm->changeToStack(stackNum - 1);
+ _vm->changeToCard((uint16)atoi(argv[2]));
+
+ return false;
+}
+
+bool RivenConsole::Cmd_Restart(int argc, const char **argv) {
+ _vm->initVars();
+ _vm->changeToStack(aspit);
+ _vm->changeToCard(1);
+
+ return false;
+}
+
+bool RivenConsole::Cmd_Hotspots(int argc, const char **argv) {
+ DebugPrintf("Current card (%d) has %d hotspots:\n", _vm->getCurCard(), _vm->getHotspotCount());
+
+ for (uint16 i = 0; i < _vm->getHotspotCount(); i++) {
+ DebugPrintf("Hotspot %d, index %d, BLST ID %d (", i, _vm->_hotspots[i].index, _vm->_hotspots[i].blstID);
+
+ if (_vm->_hotspots[i].enabled)
+ DebugPrintf("enabled)\n");
+ else
+ DebugPrintf("disabled)\n");
+
+ DebugPrintf(" Name = %s\n", _vm->getHotspotName(i).c_str());
+ }
+
+ return true;
+}
+
+bool RivenConsole::Cmd_ZipMode(int argc, const char **argv) {
+ uint32 *zipModeActive = _vm->matchVarToString("azip");
+ *zipModeActive = !(*zipModeActive);
+
+ DebugPrintf("Zip Mode is ");
+ DebugPrintf((*zipModeActive) ? "Enabled" : "Disabled");
+ DebugPrintf("\n");
+ return true;
+}
+
+bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) {
+ if (argc < 4) {
+ DebugPrintf("Usage: dumpScript <stack> <CARD or HSPT> <card>\n");
+ return true;
+ }
+
+ uint16 oldStack = _vm->getCurStack();
+
+ byte newStack = 0;
+
+ for (byte i = 1; i <= tspit + 1; i++)
+ if (!scumm_stricmp(argv[1], _vm->getStackName(i - 1).c_str())) {
+ newStack = i;
+ break;
+ }
+
+ if (!newStack) {
+ DebugPrintf("\'%s\' is not a stack name!\n", argv[1]);
+ return true;
+ }
+
+ newStack--;
+ _vm->changeToStack(newStack);
+
+ // Load in Variable Names
+ Common::SeekableReadStream *nameStream = _vm->getRawData(ID_NAME, VariableNames);
+ Common::StringList varNames;
+
+ uint16 namesCount = nameStream->readUint16BE();
+ uint16 *stringOffsets = new uint16[namesCount];
+ for (uint16 i = 0; i < namesCount; i++)
+ stringOffsets[i] = nameStream->readUint16BE();
+ nameStream->seek(namesCount * 2, SEEK_CUR);
+ int32 curNamesPos = nameStream->pos();
+
+ for (uint32 i = 0; i < namesCount; i++) {
+ nameStream->seek(curNamesPos + stringOffsets[i]);
+
+ Common::String name = Common::String::emptyString;
+ for (char c = nameStream->readByte(); c; c = nameStream->readByte())
+ name += c;
+ varNames.push_back(name);
+ }
+ delete nameStream;
+
+ // Load in External Command Names
+ nameStream = _vm->getRawData(ID_NAME, ExternalCommandNames);
+ Common::StringList xNames;
+
+ namesCount = nameStream->readUint16BE();
+ stringOffsets = new uint16[namesCount];
+ for (uint16 i = 0; i < namesCount; i++)
+ stringOffsets[i] = nameStream->readUint16BE();
+ nameStream->seek(namesCount * 2, SEEK_CUR);
+ curNamesPos = nameStream->pos();
+
+ for (uint32 i = 0; i < namesCount; i++) {
+ nameStream->seek(curNamesPos + stringOffsets[i]);
+
+ Common::String name = Common::String::emptyString;
+ for (char c = nameStream->readByte(); c; c = nameStream->readByte())
+ name += c;
+ xNames.push_back(name);
+ }
+ delete nameStream;
+
+ // Get CARD/HSPT data and dump their scripts
+ if (!scumm_stricmp(argv[2], "CARD")) {
+ printf ("\n\nDumping scripts for %s\'s card %d!\n", argv[1], (uint16)atoi(argv[3]));
+ printf ("==================================\n\n");
+ Common::SeekableReadStream *cardStream = _vm->getRawData(MKID_BE('CARD'), (uint16)atoi(argv[3]));
+ cardStream->seek(4);
+ RivenScriptList scriptList = RivenScript::readScripts(_vm, cardStream);
+ for (uint32 i = 0; i < scriptList.size(); i++)
+ scriptList[i]->dumpScript(varNames, xNames, 0);
+ delete cardStream;
+ } else if (!scumm_stricmp(argv[2], "HSPT")) {
+ printf ("\n\nDumping scripts for %s\'s card %d hotspots!\n", argv[1], (uint16)atoi(argv[3]));
+ printf ("===========================================\n\n");
+
+ Common::SeekableReadStream *hsptStream = _vm->getRawData(MKID_BE('HSPT'), (uint16)atoi(argv[3]));
+
+ uint16 hotspotCount = hsptStream->readUint16BE();
+
+ for (uint16 i = 0; i < hotspotCount; i++) {
+ printf ("Hotspot %d:\n", i);
+ hsptStream->seek(22, SEEK_CUR); // Skip non-script related stuff
+ RivenScriptList scriptList = RivenScript::readScripts(_vm, hsptStream);
+ for (uint32 j = 0; j < scriptList.size(); j++)
+ scriptList[j]->dumpScript(varNames, xNames, 1);
+ }
+
+ delete hsptStream;
+ } else {
+ DebugPrintf("%s doesn't have any scripts!\n", argv[2]);
+ }
+
+ printf("\n\n");
+
+ _vm->changeToStack(oldStack);
+
+ DebugPrintf("Script dump complete.\n");
+
+ return true;
+}
+
+bool RivenConsole::Cmd_ListZipCards(int argc, const char **argv) {
+ if (_vm->_zipModeData.size() == 0) {
+ DebugPrintf("No zip card data.\n");
+ } else {
+ DebugPrintf("Listing zip cards:\n");
+ for (uint32 i = 0; i < _vm->_zipModeData.size(); i++)
+ DebugPrintf("ID = %d, Name = %s\n", _vm->_zipModeData[i].id, _vm->_zipModeData[i].name.c_str());
+ }
+
+ return true;
+}
+
+bool RivenConsole::Cmd_GetRMAP(int argc, const char **argv) {
+ Common::SeekableReadStream *rmapStream = _vm->getRawData(ID_RMAP, 1);
+ rmapStream->seek(_vm->getCurCard() * 4);
+ DebugPrintf("RMAP for %s %d = %08x\n", _vm->getStackName(_vm->getCurStack()).c_str(), _vm->getCurCard(), rmapStream->readUint32BE());
+ delete rmapStream;
+
+ return true;
+}
+
+LivingBooksConsole::LivingBooksConsole(MohawkEngine_LivingBooks *vm) : GUI::Debugger(), _vm(vm) {
+ DCmd_Register("playSound", WRAP_METHOD(LivingBooksConsole, Cmd_PlaySound));
+ DCmd_Register("stopSound", WRAP_METHOD(LivingBooksConsole, Cmd_StopSound));
+ DCmd_Register("drawImage", WRAP_METHOD(LivingBooksConsole, Cmd_DrawImage));
+}
+
+LivingBooksConsole::~LivingBooksConsole() {
+}
+
+void LivingBooksConsole::preEnter() {
+ _vm->_sound->pauseSound();
+}
+
+void LivingBooksConsole::postEnter() {
+ _vm->_sound->resumeSound();
+}
+
+bool LivingBooksConsole::Cmd_PlaySound(int argc, const char **argv) {
+ if (argc == 1) {
+ DebugPrintf("Usage: playSound <value>\n");
+
+ return true;
+ }
+
+ _vm->_sound->stopSound();
+ _vm->_sound->playSound((uint16)atoi(argv[1]));
+
+ return false;
+}
+
+bool LivingBooksConsole::Cmd_StopSound(int argc, const char **argv) {
+ DebugPrintf("Stopping Sound\n");
+
+ _vm->_sound->stopSound();
+
+ return true;
+}
+
+bool LivingBooksConsole::Cmd_DrawImage(int argc, const char **argv) {
+ if (argc == 1) {
+ DebugPrintf("Usage: drawImage <value>\n");
+ return true;
+ }
+
+ if (_vm->getGameType() == GType_OLDLIVINGBOOKS)
+ DebugPrintf("This isn't supported in the old Living Books games (yet)!\n");
+
+ _vm->_gfx->copyImageToScreen((uint16)atoi(argv[1]));
+ return _vm->getGameType() != GType_OLDLIVINGBOOKS;
+}
+
+} // End of namespace Mohawk
Property changes on: scummvm/trunk/engines/mohawk/console.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/console.h
===================================================================
--- scummvm/trunk/engines/mohawk/console.h (rev 0)
+++ scummvm/trunk/engines/mohawk/console.h 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MOHAWK_CONSOLE_H
+#define MOHAWK_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Mohawk {
+
+class MohawkEngine_Myst;
+class MohawkEngine_Riven;
+class MohawkEngine_LivingBooks;
+
+class MystConsole : public GUI::Debugger {
+public:
+ MystConsole(MohawkEngine_Myst *vm);
+ virtual ~MystConsole(void);
+
+protected:
+ virtual void preEnter();
+ virtual void postEnter();
+
+private:
+ MohawkEngine_Myst *_vm;
+
+ bool Cmd_ChangeCard(int argc, const char **argv);
+ bool Cmd_CurCard(int argc, const char **argv);
+ bool Cmd_Var(int argc, const char **argv);
+ bool Cmd_DrawImage(int argc, const char **argv);
+ bool Cmd_DrawRect(int argc, const char **argv);
+ bool Cmd_SetResourceEnable(int argc, const char **argv);
+ bool Cmd_CurStack(int argc, const char **argv);
+ bool Cmd_ChangeStack(int argc, const char **argv);
+ bool Cmd_PlaySound(int argc, const char **argv);
+ bool Cmd_StopSound(int argc, const char **argv);
+ bool Cmd_PlayMovie(int argc, const char **argv);
+ bool Cmd_DisableInitOpcodes(int argc, const char **argv);
+};
+
+class RivenConsole : public GUI::Debugger {
+public:
+ RivenConsole(MohawkEngine_Riven *vm);
+ virtual ~RivenConsole(void);
+
+protected:
+ virtual void preEnter();
+ virtual void postEnter();
+
+private:
+ MohawkEngine_Riven *_vm;
+
+ bool Cmd_ChangeCard(int argc, const char **argv);
+ bool Cmd_CurCard(int argc, const char **argv);
+ bool Cmd_Var(int argc, const char **argv);
+ bool Cmd_PlaySound(int argc, const char **argv);
+ bool Cmd_PlaySLST(int argc, const char **argv);
+ bool Cmd_StopSound(int argc, const char **argv);
+ bool Cmd_CurStack(int argc, const char **argv);
+ bool Cmd_ChangeStack(int argc, const char **argv);
+ bool Cmd_Restart(int argc, const char **argv);
+ bool Cmd_Hotspots(int argc, const char **argv);
+ bool Cmd_ZipMode(int argc, const char **argv);
+ bool Cmd_RunAllBlocks(int argc, const char **argv);
+ bool Cmd_DumpScript(int argc, const char **argv);
+ bool Cmd_ListZipCards(int argc, const char **argv);
+ bool Cmd_GetRMAP(int argc, const char **argv);
+};
+
+class LivingBooksConsole : public GUI::Debugger {
+public:
+ LivingBooksConsole(MohawkEngine_LivingBooks *vm);
+ virtual ~LivingBooksConsole(void);
+
+protected:
+ virtual void preEnter();
+ virtual void postEnter();
+
+private:
+ MohawkEngine_LivingBooks *_vm;
+
+ bool Cmd_PlaySound(int argc, const char **argv);
+ bool Cmd_StopSound(int argc, const char **argv);
+ bool Cmd_DrawImage(int argc, const char **argv);
+};
+
+} // End of namespace Mohawk
+
+#endif
Property changes on: scummvm/trunk/engines/mohawk/console.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/detection.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/detection.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/detection.cpp 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,1042 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+#include "common/config-manager.h"
+#include "common/file.h"
+#include "common/savefile.h"
+
+#include "mohawk/myst.h"
+#include "mohawk/riven.h"
+#include "mohawk/livingbooks.h"
+
+// Define this to enable detection of other Broderbund titles which use Mohawk (besides Myst/Riven)
+#define DETECT_BRODERBUND_TITLES
+
+namespace Mohawk {
+
+struct MohawkGameDescription {
+ ADGameDescription desc;
+
+ uint8 gameType;
+ uint32 features;
+ uint16 version;
+};
+
+const char* MohawkEngine::getGameId() const {
+ return _gameDescription->desc.gameid;
+}
+
+uint32 MohawkEngine::getFeatures() const {
+ return _gameDescription->features;
+}
+
+Common::Platform MohawkEngine::getPlatform() const {
+ return _gameDescription->desc.platform;
+}
+
+uint16 MohawkEngine::getVersion() const {
+ return _gameDescription->version;
+}
+
+uint8 MohawkEngine::getGameType() {
+ return _gameDescription->gameType;
+}
+
+Common::String MohawkEngine_LivingBooks::getBookInfoFileName() {
+ return _gameDescription->desc.filesDescriptions[0].fileName;
+}
+
+Common::Language MohawkEngine::getLanguage() {
+ return _gameDescription->desc.language;
+}
+
+bool MohawkEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsRTL);
+}
+
+bool MohawkEngine_Myst::hasFeature(EngineFeature f) const {
+ return
+ MohawkEngine::hasFeature(f)
+ || (f == kSupportsLoadingDuringRuntime)
+ || (f == kSupportsSavingDuringRuntime);
+}
+
+bool MohawkEngine_Riven::hasFeature(EngineFeature f) const {
+ return
+ MohawkEngine::hasFeature(f)
+ || (f == kSupportsLoadingDuringRuntime)
+ || (f == kSupportsSavingDuringRuntime);
+}
+
+} // End of Namespace Mohawk
+
+static const PlainGameDescriptor mohawkGames[] = {
+ {"mohawk", "Mohawk Game"},
+ {"myst", "Myst"},
+ {"MakingOfMyst", "The Making of Myst"},
+ {"riven", "Riven: The Sequel to Myst"},
+#ifdef DETECT_BRODERBUND_TITLES
+ {"zoombini", "Logical Journey of the Zoombinis Deluxe"},
+ {"csworld", "Where in the World is Carmen Sandiego?"},
+ {"csamtrak", "Where in America is Carmen Sandiego? (The Great Amtrak Train Adventure)"},
+ {"maggiess", "Maggie's Farmyard Adventure"},
+ {"jamesmath", "James Discovers/Explores Math"},
+ {"treehouse", "The Treehouse"},
+ {"greeneggs", "Green Eggs and Ham"},
+ {"1stdegree", "In the 1st Degree"},
+ {"csusa", "Where in the USA is Carmen Sandiego?"},
+ {"tortoise", "Aesop's Fables: The Tortoise and the Hare"},
+ {"arthur", "Arthur's Teacher Troubles"},
+ {"grandma", "Just Grandma and Me"},
+ {"ruff", "Ruff's Bone"},
+ {"newkid", "The New Kid on the Block"},
+ {"arthurrace", "Arthur's Reading Race"},
+#endif
+ {0, 0}
+};
+
+
+namespace Mohawk {
+
+static const MohawkGameDescription gameDescriptions[] = {
+ // Myst
+ // English Windows 3.11
+ // From clone2727
+ {
+ {
+ "myst",
+ "",
+ AD_ENTRY1("MYST.DAT", "ae3258c9c90128d274aa6a790b3ad181"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ 0,
+ 0,
+ },
+
+ // Myst Demo
+ // English Windows 3.11
+ // From CD-ROM Today July, 1994
+ {
+ {
+ "myst",
+ "Demo",
+ AD_ENTRY1("DEMO.DAT", "c39303dd53fb5c4e7f3c23231c606cd0"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ GF_DEMO,
+ 0,
+ },
+
+ // Myst
+ // German Windows 3.11
+ // From clone2727
+ {
+ {
+ "myst",
+ "",
+ AD_ENTRY1("MYST.DAT", "4beb3366ed3f3b9bfb6e81a14a43bdcc"),
+ Common::DE_DEU,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ 0,
+ 0,
+ },
+
+ // Myst
+ // German Windows 3.11
+ // From LordHoto
+ {
+ {
+ "myst",
+ "",
+ AD_ENTRY1("MYST.DAT", "e0937cca1ab125e48e30dc3cd5046ddf"),
+ Common::DE_DEU,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ 0,
+ 0,
+ },
+
+ // Myst
+ // Spanish Windows ?
+ // From jvprat
+ {
+ {
+ "myst",
+ "",
+ AD_ENTRY1("MYST.DAT", "f7e7d7ca69934f1351b5acd4fe4d44c2"),
+ Common::ES_ESP,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ 0,
+ 0,
+ },
+
+ // Myst
+ // Japanese Windows 3.11
+ // From clone2727
+ {
+ {
+ "myst",
+ "",
+ AD_ENTRY1("MYST.DAT", "032c88e3b7e8db4ca475e7b7db9a66bb"),
+ Common::JA_JPN,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ 0,
+ 0,
+ },
+
+ // Making of Myst
+ // English Windows 3.11
+ // From clone2727
+ {
+ {
+ "MakingOfMyst",
+ "",
+ AD_ENTRY1("MAKING.DAT", "f6387e8f0f7b8a3e42c95294315d6a0e"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MAKINGOF,
+ 0,
+ 0,
+ },
+
+ // Making of Myst
+ // Japanese Windows 3.11
+ // From clone2727
+ {
+ {
+ "MakingOfMyst",
+ "",
+ AD_ENTRY1("MAKING.DAT", "03ff62607e64419ab2b6ebf7b7bcdf63"),
+ Common::JA_JPN,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MAKINGOF,
+ 0,
+ 0,
+ },
+
+ // Myst Masterpiece Edition
+ // English Windows
+ // From clone2727
+ {
+ {
+ "myst",
+ "Masterpiece Edition",
+ AD_ENTRY1("MYST.DAT", "c4cae9f143b5947262e6cb2397e1617e"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ GF_ME|GF_10TH,
+ 0,
+ },
+
+ // Myst Masterpiece Edition
+ // English Windows
+ // From clone2727
+ {
+ {
+ "myst",
+ "Masterpiece Edition",
+ AD_ENTRY1("MYST.DAT", "c4cae9f143b5947262e6cb2397e1617e"),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ GF_ME|GF_10TH,
+ 0,
+ },
+
+ // Myst Masterpiece Edition
+ // German Windows
+ // From DrMcCoy (Included in "Myst: Die Trilogie")
+ {
+ {
+ "myst",
+ "Masterpiece Edition",
+ AD_ENTRY1("MYST.DAT", "f88e0ace66dbca78eebdaaa1d3314ceb"),
+ Common::DE_DEU,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ GF_ME,
+ 0,
+ },
+
+ // Riven: The Sequel to Myst
+ // Version 1.0 (5CD)
+ // From clone2727
+ {
+ {
+ "riven",
+ "",
+ AD_ENTRY1("a_Data.MHK", "71145fdecbd68a0cfc292c2fbddf8e08"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ 0,
+ 0,
+ },
+
+ // Riven: The Sequel to Myst
+ // Version 1.03 (5CD)
+ // From ST
+ {
+ {
+ "riven",
+ "",
+ AD_ENTRY1("a_Data.MHK", "d8ccae34a0e3c709135a73f449b783be"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ 0,
+ 0,
+ },
+
+ // Riven: The Sequel to Myst
+ // Version 1.? (5CD)
+ // From jvprat
+ {
+ {
+ "riven",
+ "",
+ AD_ENTRY1("a_Data.MHK", "249e8c995d191b03ee94c892c0eac775"),
+ Common::ES_ESP,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ 0,
+ 0,
+ },
+
+ // Riven: The Sequel to Myst
+ // Version 1.? (DVD, From "Myst 10th Anniversary Edition")
+ // From Clone2727
+ {
+ {
+ "riven",
+ "DVD",
+ AD_ENTRY1("a_Data.MHK", "08fcaa5d5a2a01d7a5a6960f497212fe"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ GF_DVD|GF_10TH,
+ 0,
+ },
+
+ // Riven: The Sequel to Myst
+ // Version 1.0 (DVD, From "Myst: Die Trilogie")
+ // From DrMcCoy
+ {
+ {
+ "riven",
+ "",
+ AD_ENTRY1("a_Data.MHK", "a5fe1c91a6033eb6ee54b287578b74b9"),
+ Common::DE_DEU,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ GF_DVD,
+ 0,
+ },
+
+ // Riven: The Sequel to Myst
+ // Version ? (Demo, From "Prince of Persia Collector's Edition")
+ // From Clone2727
+ {
+ {
+ "riven",
+ "Demo",
+ AD_ENTRY1("a_Data.MHK", "bae6b03bd8d6eb350d35fd13f0e3139f"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ GF_DEMO,
+ 0,
+ },
+
+#ifdef DETECT_BRODERBUND_TITLES
+ {
+ {
+ "zoombini",
+ "",
+ AD_ENTRY1("ZOOMBINI.MHK", "98b758fec55104c096cfd129048be9a6"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_ZOOMBINI,
+ GF_HASMIDI,
+ 0
+ },
+
+ {
+ {
+ "csworld",
+ "v3.0",
+ AD_ENTRY1("C2K.MHK", "605fe88380848031bbd0ff84ade6fe40"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_CSWORLD,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "csworld",
+ "v3.5",
+ AD_ENTRY1("C2K.MHK", "d4857aeb0f5e2e0c4ac556aa74f38c23"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_CSWORLD,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "csamtrak",
+ "",
+ AD_ENTRY1("AMTRAK.MHK", "2f95301f0bb950d555bb7b0e3b1b7eb1"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_CSAMTRAK,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "maggiess",
+ "",
+ AD_ENTRY1("MAGGIESS.MHK", "08f75fc8c0390e68fdada5ddb35d0355"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MAGGIESS,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "jamesmath",
+ "",
+ AD_ENTRY1("BRODER.MHK", "007299da8b2c6e8ec1cde9598c243024"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_JAMESMATH,
+ GF_HASMIDI,
+ 0
+ },
+
+ // This is in the NEWDATA folder, so I assume it's a newer version ;)
+ {
+ {
+ "jamesmath",
+ "",
+ AD_ENTRY1("BRODER.MHK", "53c000938a50dca92860fd9b546dd276"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_JAMESMATH,
+ GF_HASMIDI,
+ 1
+ },
+
+ {
+ {
+ "treehouse",
+ "",
+ AD_ENTRY1("MAINROOM.MHK", "12f51894d7f838af639ea9bf1bc8f45b"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_TREEHOUSE,
+ GF_HASMIDI,
+ 0
+ },
+
+ {
+ {
+ "greeneggs",
+ "",
+ AD_ENTRY1("GREEN.LB", "5df8438138186f89e71299d7b4f88d06"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_NEWLIVINGBOOKS,
+ 0,
+ 0
+ },
+
+ // 32-bit version of the previous entry
+ {
+ {
+ "greeneggs",
+ "",
+ AD_ENTRY1("GREEN32.LB", "5df8438138186f89e71299d7b4f88d06"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_NEWLIVINGBOOKS,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "1stdegree",
+ "",
+ AD_ENTRY1("AL236_1.MHK", "3ba145492a7b8b4dee0ef4222c5639c3"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_1STDEGREE,
+ GF_HASMIDI,
+ 0
+ },
+
+ {
+ {
+ "csusa",
+ "",
+ AD_ENTRY1("USAC2K.MHK", "b8c9d3a2586f62bce3a48b50d7a700e9"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_CSUSA,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "tortoise",
+ "Demo v1.0",
+ AD_ENTRY1("TORTOISE.512", "75d9a2f8339e423604a0c6e8177600a6"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "tortoise",
+ "Demo v1.1",
+ AD_ENTRY1("TORTOISE.512", "a38c99360e2bea3bfdec418469aef022"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "arthur",
+ "",
+ AD_ENTRY1("PAGES.512", "1550a361454ec452fe7d2328aac2003c"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "arthur",
+ "Demo",
+ AD_ENTRY1("PAGES.512", "a4d68cef197af1416921ca5b2e0c1e31"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "arthur",
+ "Demo",
+ AD_ENTRY1("Bookoutline", "7e2691611ff4c7b89c05221736628059"),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "grandma",
+ "Demo v1.0",
+ AD_ENTRY1("PAGES.512", "95d9f4b035bf5d15c57a9189f231b0f8"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "grandma",
+ "Demo v1.1",
+ AD_ENTRY1("GRANDMA.512", "72a4d5fb1b3f06b5f75425635d42ce2e"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "grandma",
+ "Demo",
+ AD_ENTRY1("Bookoutline", "553c93891b9631d1e1d269599e1efa6c"),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "ruff",
+ "Demo",
+ AD_ENTRY1("RUFF.512", "2ba1aa65177c816e156db648c398d362"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "ruff",
+ "Demo",
+ AD_ENTRY1("Ruff's Bone Demo", "22553ac2ceb2a166bdf1def6ad348532"),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "newkid",
+ "Demo v1.0",
+ AD_ENTRY1("NEWKID.512", "2b9d94763a50d514c04a3af488934f73"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "newkid",
+ "Demo v1.1",
+ AD_ENTRY1("NEWKID.512", "41e975b7390c626f8d1058a34f9d9b2e"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_DEMO,
+ Common::GUIO_NONE
+ },
+ GType_OLDLIVINGBOOKS,
+ GF_DEMO,
+ 0
+ },
+
+ {
+ {
+ "arthurrace",
+ "",
+ AD_ENTRY1("RACE.LB", "1645f36bcb36e440d928e920aa48c373"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_NEWLIVINGBOOKS,
+ 0,
+ 0
+ },
+
+ // 32-bit version of the previous entry
+ {
+ {
+ "arthurrace",
+ "",
+ AD_ENTRY1("RACE32.LB", "292a05bc48c1dd9583821a4181a02ef2"),
+ Common::EN_ANY,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_NEWLIVINGBOOKS,
+ 0,
+ 0
+ },
+#endif
+
+ { AD_TABLE_END_MARKER, 0, 0, 0 }
+};
+
+//////////////////////////////
+//Fallback detection
+//////////////////////////////
+
+static const MohawkGameDescription fallbackDescs[] = {
+ {
+ {
+ "myst",
+ "unknown",
+ AD_ENTRY1(0, 0),
+ Common::UNK_LANG,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "MakingOfMyst",
+ "unknown",
+ AD_ENTRY1(0, 0),
+ Common::UNK_LANG,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MAKINGOF,
+ 0,
+ 0
+ },
+
+ // The Masterpiece Edition of Myst has 24bit color, and thus is not supported by ScummVM
+ // Currently, its graphics are just bypassed.
+ {
+ {
+ "myst",
+ "unknown (Masterpiece Edition)",
+ AD_ENTRY1(0, 0),
+ Common::UNK_LANG,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_MYST,
+ GF_ME,
+ 0
+ },
+
+ {
+ {
+ "riven",
+ "unknown",
+ AD_ENTRY1(0, 0),
+ Common::UNK_LANG,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ 0,
+ 0
+ },
+
+ {
+ {
+ "riven",
+ "unknown (DVD)",
+ AD_ENTRY1(0, 0),
+ Common::UNK_LANG,
+ Common::kPlatformWindows,
+ ADGF_NO_FLAGS,
+ Common::GUIO_NONE
+ },
+ GType_RIVEN,
+ GF_DVD,
+ 0
+ }
+};
+
+static const ADFileBasedFallback fileBased[] = {
+ { &fallbackDescs[0], { "MYST.DAT", 0 } },
+ { &fallbackDescs[1], { "MAKING.DAT", 0 } },
+ { &fallbackDescs[2], { "MYST.DAT", "Help.dat", 0 } }, // Help system doesn't exist in original
+ { &fallbackDescs[3], { "a_Data.MHK", 0 } },
+ { &fallbackDescs[4], { "a_Data.MHK", "t_Data1.MHK" , 0 } },
+ { 0, { 0 } }
+};
+
+} // End of namespace Mohawk
+
+static const ADParams detectionParams = {
+ // Pointer to ADGameDescription or its superset structure
+ (const byte *)Mohawk::gameDescriptions,
+ // Size of that superset structure
+ sizeof(Mohawk::MohawkGameDescription),
+ // Number of bytes to compute MD5 sum for
+ 5000,
+ // List of all engine targets
+ mohawkGames,
+ // Structure for autoupgrading obsolete targets
+ 0,
+ // Name of single gameid (optional)
+ "mohawk",
+ // List of files for file-based fallback detection (optional)
+ Mohawk::fileBased,
+ // Flags
+ 0,
+ // Additional GUI options (for every game)
+ Common::GUIO_NONE
+};
+
+class MohawkMetaEngine : public AdvancedMetaEngine {
+public:
+ MohawkMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+
+ virtual const char *getName() const {
+ return "Mohawk Engine";
+ }
+
+ virtual const char *getOriginalCopyright() const {
+ return "Myst and Riven (C) Cyan Worlds\nMohawk OS (C) Ubisoft";
+ }
+
+ virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual int getMaximumSaveSlot() const { return 999; }
+ virtual void removeSaveState(const char *target, int slot) const;
+};
+
+bool MohawkMetaEngine::hasFeature(MetaEngineFeature f) const {
+ return
+ (f == kSupportsListSaves)
+ || (f == kSupportsLoadingDuringStartup)
+ || (f == kSupportsDeleteSave);
+}
+
+SaveStateList MohawkMetaEngine::listSaves(const char *target) const {
+ Common::StringList filenames;
+ SaveStateList saveList;
+
+ // Loading games is only supported in Myst/Riven currently.
+ if (strstr(target, "myst")) {
+ filenames = g_system->getSavefileManager()->listSavefiles("*.mys");
+
+ for (uint32 i = 0; i < filenames.size(); i++)
+ saveList.push_back(SaveStateDescriptor(i, filenames[i]));
+ } else if (strstr(target, "riven")) {
+ filenames = g_system->getSavefileManager()->listSavefiles("*.rvn");
+
+ for (uint32 i = 0; i < filenames.size(); i++)
+ saveList.push_back(SaveStateDescriptor(i, filenames[i]));
+ }
+
+ return saveList;
+}
+
+void MohawkMetaEngine::removeSaveState(const char *target, int slot) const {
+ // Removing saved games is only supported in Myst/Riven currently.
+ if (strstr(target, "myst")) {
+ Common::StringList filenames = g_system->getSavefileManager()->listSavefiles("*.mys");
+ g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str());
+ } else if (strstr(target, "riven")) {
+ Common::StringList filenames = g_system->getSavefileManager()->listSavefiles("*.rvn");
+ g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str());
+ }
+}
+
+bool MohawkMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ const Mohawk::MohawkGameDescription *gd = (const Mohawk::MohawkGameDescription *)desc;
+
+ if (gd) {
+ switch (gd->gameType) {
+ case Mohawk::GType_MYST:
+ case Mohawk::GType_MAKINGOF:
+ *engine = new Mohawk::MohawkEngine_Myst(syst, gd);
+ break;
+ case Mohawk::GType_RIVEN:
+ *engine = new Mohawk::MohawkEngine_Riven(syst, gd);
+ break;
+ case Mohawk::GType_OLDLIVINGBOOKS:
+ case Mohawk::GType_NEWLIVINGBOOKS:
+ *engine = new Mohawk::MohawkEngine_LivingBooks(syst, gd);
+ break;
+ case Mohawk::GType_ZOOMBINI:
+ case Mohawk::GType_CSWORLD:
+ case Mohawk::GType_CSAMTRAK:
+ case Mohawk::GType_MAGGIESS:
+ case Mohawk::GType_JAMESMATH:
+ case Mohawk::GType_TREEHOUSE:
+ case Mohawk::GType_1STDEGREE:
+ case Mohawk::GType_CSUSA:
+ error ("Unsupported Mohawk Engine");
+ break;
+ default:
+ error ("Unknown Mohawk Engine");
+ }
+ }
+
+ return (gd != 0);
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(MOHAWK)
+ REGISTER_PLUGIN_DYNAMIC(MOHAWK, PLUGIN_TYPE_ENGINE, MohawkMetaEngine);
+#else
+ REGISTER_PLUGIN_STATIC(MOHAWK, PLUGIN_TYPE_ENGINE, MohawkMetaEngine);
+#endif
Property changes on: scummvm/trunk/engines/mohawk/detection.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/dialogs.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/dialogs.cpp 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,148 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "mohawk/mohawk.h"
+#include "mohawk/myst.h"
+#include "mohawk/riven.h"
+#include "mohawk/dialogs.h"
+
+#include "gui/GuiManager.h"
+#include "common/savefile.h"
+
+namespace Mohawk {
+
+// This used to have GUI::Dialog("MohawkDummyDialog"), but that doesn't work with the gui branch merge :P (Sorry, Tanoku!)
+InfoDialog::InfoDialog(MohawkEngine *vm, Common::String message) : _vm(vm), GUI::Dialog(0, 0, 1, 1), _message(message) {
+ _backgroundType = GUI::ThemeEngine::kDialogBackgroundSpecial;
+
+ _text = new GUI::StaticTextWidget(this, 4, 4, 10, 10, _message, Graphics::kTextAlignCenter);
+}
+
+void InfoDialog::setInfoText(Common::String message) {
+ _message = message;
+ _text->setLabel(_message);
+}
+
+void InfoDialog::reflowLayout() {
+ const int screenW = g_system->getOverlayWidth();
+ const int screenH = g_system->getOverlayHeight();
+
+ int width = g_gui.getStringWidth(_message) + 16;
+ int height = g_gui.getFontHeight() + 8;
+
+ _w = width;
+ _h = height;
+ _x = (screenW - width) / 2;
+ _y = (screenH - height) / 2;
+
+ _text->setSize(_w - 8, _h);
+}
+
+PauseDialog::PauseDialog(MohawkEngine *vm, Common::String message) : InfoDialog(vm, message) {
+}
+
+void PauseDialog::handleKeyDown(Common::KeyState state) {
+ if (state.ascii == ' ')
+ close();
+ else
+ InfoDialog::handleKeyDown(state);
+}
+
+enum {
+ kCloseCmd = 'CLOS',
+ kZipCmd = 'ZIPM',
+ kTransCmd = 'TRAN',
+ kWaterCmd = 'WATR'
+};
+
+MystOptionsDialog::MystOptionsDialog(MohawkEngine_Myst* vm) : GUI::OptionsDialog("", 120, 120, 360, 200), _vm(vm) {
+ _zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 300, 15, "Zip Mode Activated", kZipCmd, 'Z');
+ _transistionsCheckbox = new GUI::CheckboxWidget(this, 15, 30, 300, 15, "Transistions Enabled", kTransCmd, 'T');
+
+ new GUI::ButtonWidget(this, 95, 160, 120, 25, "OK", GUI::OptionsDialog::kOKCmd, 'O');
+ new GUI::ButtonWidget(this, 225, 160, 120, 25, "Cancel", kCloseCmd, 'C');
+}
+
+MystOptionsDialog::~MystOptionsDialog() {
+}
+
+void MystOptionsDialog::open() {
+ Dialog::open();
+
+ _zipModeCheckbox->setState(_vm->_zipMode);
+ _transistionsCheckbox->setState(_vm->_transitionsEnabled);
+}
+
+void MystOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kZipCmd:
+ _vm->_zipMode = _zipModeCheckbox->getState();
+ break;
+ case kTransCmd:
+ _vm->_transitionsEnabled = _transistionsCheckbox->getState();
+ break;
+ case kCloseCmd:
+ close();
+ break;
+ default:
+ GUI::OptionsDialog::handleCommand(sender, cmd, data);
+ }
+}
+
+RivenOptionsDialog::RivenOptionsDialog(MohawkEngine_Riven* vm) : GUI::OptionsDialog("", 120, 120, 360, 200), _vm(vm) {
+ _zipModeCheckbox = new GUI::CheckboxWidget(this, 15, 10, 300, 15, "Zip Mode Activated", kZipCmd, 'Z');
+ _waterEffectCheckbox = new GUI::CheckboxWidget(this, 15, 30, 300, 15, "Water Effect Enabled", kWaterCmd, 'W');
+
+ new GUI::ButtonWidget(this, 95, 160, 120, 25, "OK", GUI::OptionsDialog::kOKCmd, 'O');
+ new GUI::ButtonWidget(this, 225, 160, 120, 25, "Cancel", kCloseCmd, 'C');
+}
+
+RivenOptionsDialog::~RivenOptionsDialog() {
+}
+
+void RivenOptionsDialog::open() {
+ Dialog::open();
+
+ _zipModeCheckbox->setState(*_vm->matchVarToString("azip") != 0);
+ _waterEffectCheckbox->setState(*_vm->matchVarToString("waterenabled") != 0);
+}
+
+void RivenOptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
+ switch (cmd) {
+ case kZipCmd:
+ *_vm->matchVarToString("azip") = _zipModeCheckbox->getState() ? 1 : 0;
+ break;
+ case kWaterCmd:
+ *_vm->matchVarToString("waterenabled") = _waterEffectCheckbox->getState() ? 1 : 0;
+ break;
+ case kCloseCmd:
+ close();
+ break;
+ default:
+ GUI::OptionsDialog::handleCommand(sender, cmd, data);
+ }
+}
+
+} // End of namespace Mohawk
Property changes on: scummvm/trunk/engines/mohawk/dialogs.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/dialogs.h
===================================================================
--- scummvm/trunk/engines/mohawk/dialogs.h (rev 0)
+++ scummvm/trunk/engines/mohawk/dialogs.h 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,100 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef MOHAWK_DIALOGS_H
+#define MOHAWK_DIALOGS_H
+
+#include "mohawk/mohawk.h"
+
+#include "common/events.h"
+#include "common/str.h"
+#include "gui/dialog.h"
+#include "gui/options.h"
+#include "gui/widget.h"
+#include "gui/ListWidget.h"
+
+namespace Mohawk {
+
+class MohawkEngine;
+
+class InfoDialog : public GUI::Dialog {
+protected:
+ MohawkEngine *_vm;
+ Common::String _message;
+ GUI::StaticTextWidget *_text;
+
+public:
+ InfoDialog(MohawkEngine *vm, Common::String message);
+
+ void setInfoText(Common::String message);
+
+ virtual void handleMouseDown(int x, int y, int button, int clickCount) {
+ setResult(0);
+ close();
+ }
+
+ virtual void handleKeyDown(Common::KeyState state) {
+ setResult(state.ascii);
+ close();
+ }
+
+ virtual void reflowLayout();
+};
+
+class PauseDialog : public InfoDialog {
+public:
+ PauseDialog(MohawkEngine* vm, Common::String message);
+ virtual void handleKeyDown(Common::KeyState state);
+};
+
+class MystOptionsDialog : public GUI::OptionsDialog {
+public:
+ MystOptionsDialog(MohawkEngine_Myst *vm);
+ ~MystOptionsDialog();
+ void open();
+
+ virtual void handleCommand(GUI::CommandSender*, uint32, uint32);
+private:
+ MohawkEngine_Myst *_vm;
+ GUI::CheckboxWidget *_zipModeCheckbox;
+ GUI::CheckboxWidget *_transistionsCheckbox;
+};
+
+class RivenOptionsDialog : public GUI::OptionsDialog {
+public:
+ RivenOptionsDialog(MohawkEngine_Riven *vm);
+ ~RivenOptionsDialog();
+ void open();
+
+ virtual void handleCommand(GUI::CommandSender*, uint32, uint32);
+private:
+ MohawkEngine_Riven *_vm;
+ GUI::CheckboxWidget *_zipModeCheckbox;
+ GUI::CheckboxWidget *_waterEffectCheckbox;
+};
+
+} // End of namespace Mohawk
+
+#endif
Property changes on: scummvm/trunk/engines/mohawk/dialogs.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/file.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/file.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/file.cpp 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,317 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "mohawk/file.h"
+
+#include "common/util.h"
+
+namespace Mohawk {
+
+MohawkFile::MohawkFile() {
+ _mhk = NULL;
+ _curFile = Common::String::emptyString;
+ _types = NULL;
+ _fileTable = NULL;
+}
+
+void MohawkFile::open(Common::String filename) {
+ Common::File *file = new Common::File();
+ if (!file->open(filename.c_str()))
+ error ("Could not open file \'%s\'", filename.c_str());
+
+ _curFile = filename;
+
+ open(file);
+}
+
+void MohawkFile::close() {
+ delete _mhk; _mhk = NULL;
+ delete[] _types; _types = NULL;
+ delete[] _fileTable; _fileTable = NULL;
+
+ _curFile = Common::String::emptyString;
+}
+
+void MohawkFile::open(Common::SeekableReadStream *stream) {
+ // Make sure no other file is open...
+ close();
+ _mhk = stream;
+
+ if (_mhk->readUint32BE() != ID_MHWK)
+ error ("Could not find tag \'MHWK\'");
+
+ _fileSize = _mhk->readUint32BE();
+
+ if (_mhk->readUint32BE() != ID_RSRC)
+ error ("Could not find tag \'RSRC\'");
+
+ _rsrc.size = _mhk->readUint32BE();
+ _rsrc.filesize = _mhk->readUint32BE();
+ _rsrc.abs_offset = _mhk->readUint32BE();
+ _rsrc.file_table_offset = _mhk->readUint16BE();
+ _rsrc.file_table_size = _mhk->readUint16BE();
+
+ debug (3, "Absolute Offset = %08x", _rsrc.abs_offset);
+
+ /////////////////////////////////
+ //Resource Dir
+ /////////////////////////////////
+
+ // Type Table
+ _mhk->seek(_rsrc.abs_offset);
+ _typeTable.name_offset = _mhk->readUint16BE();
+ _typeTable.resource_types = _mhk->readUint16BE();
+
+ debug (0, "Name List Offset = %04x Number of Resource Types = %04x", _typeTable.name_offset, _typeTable.resource_types);
+
+ _types = new Type[_typeTable.resource_types];
+
+ for (uint16 i = 0; i < _typeTable.resource_types; i++) {
+ _types[i].tag = _mhk->readUint32BE();
+ _types[i].resource_table_offset = _mhk->readUint16BE();
+ _types[i].name_table_offset = _mhk->readUint16BE();
+
+ // HACK: Zoombini's SND resource starts will a NULL.
+ if (_types[i].tag == ID_SND)
+ debug (3, "Type[%02d]: Tag = \'SND\' ResTable Offset = %04x NameTable Offset = %04x", i, _types[i].resource_table_offset, _types[i].name_table_offset);
+ else
+ debug (3, "Type[%02d]: Tag = \'%s\' ResTable Offset = %04x NameTable Offset = %04x", i, tag2str(_types[i].tag), _types[i].resource_table_offset, _types[i].name_table_offset);
+
+ //Resource Table
+ _mhk->seek(_rsrc.abs_offset + _types[i].resource_table_offset);
+ _types[i].resTable.resources = _mhk->readUint16BE();
+
+ debug (3, "Resources = %04x", _types[i].resTable.resources);
+
+ _types[i].resTable.entries = new Type::ResourceTable::Entries[_types[i].resTable.resources];
+
+ for (uint16 j = 0; j < _types[i].resTable.resources; j++) {
+ _types[i].resTable.entries[j].id = _mhk->readUint16BE();
+ _types[i].resTable.entries[j].index = _mhk->readUint16BE();
+
+ debug (4, "Entry[%02x]: ID = %04x (%d) Index = %04x", j, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].index);
+ }
+
+ // Name Table
+ _mhk->seek(_rsrc.abs_offset + _types[i].name_table_offset);
+ _types[i].nameTable.num = _mhk->readUint16BE();
+
+ debug (3, "Names = %04x", _types[i].nameTable.num);
+
+ _types[i].nameTable.entries = new Type::NameTable::Entries[_types[i].nameTable.num];
+
+ for (uint16 j = 0; j < _types[i].nameTable.num; j++) {
+ _types[i].nameTable.entries[j].offset = _mhk->readUint16BE();
+ _types[i].nameTable.entries[j].index = _mhk->readUint16BE();
+
+ debug (4, "Entry[%02x]: Name List Offset = %04x Index = %04x", j, _types[i].nameTable.entries[j].offset, _types[i].nameTable.entries[j].index);
+
+ // Name List
+ uint32 pos = _mhk->pos();
+ _mhk->seek(_rsrc.abs_offset + _typeTable.name_offset + _types[i].nameTable.entries[j].offset);
+ char c = (char)_mhk->readByte();
+ while (c != 0) {
+ _types[i].nameTable.entries[j].name += c;
+ c = (char)_mhk->readByte();
+ }
+
+ debug (3, "Name = \'%s\'", _types[i].nameTable.entries[j].name.c_str());
+
+ // Get back to next entry
+ _mhk->seek(pos);
+ }
+
+ // Return to next TypeTable entry
+ _mhk->seek(_rsrc.abs_offset + (i + 1) * 8 + 4);
+
+ debug (3, "\n");
+ }
+
+ _mhk->seek(_rsrc.abs_offset + _rsrc.file_table_offset);
+ _fileTableAmount = _mhk->readUint32BE();
+ _fileTable = new FileTable[_fileTableAmount];
+
+ for (uint32 i = 0; i < _fileTableAmount; i++) {
+ _fileTable[i].offset = _mhk->readUint32BE();
+ _fileTable[i].dataSize = _mhk->readUint16BE();
+ _fileTable[i].dataSize += _mhk->readByte() << 16; // Get bits 15-24 of dataSize too
+ _fileTable[i].flags = _mhk->readByte();
+ _fileTable[i].unk = _mhk->readUint16BE();
+
+ // Add in another 3 bits for file size from the flags.
+ // The flags are useless to us except for doing this ;)
+ _fileTable[i].dataSize += (_fileTable[i].flags & 7) << 24;
+
+ debug (4, "File[%02x]: Offset = %08x DataSize = %07x Flags = %02x Unk = %04x", i, _fileTable[i].offset, _fileTable[i].dataSize, _fileTable[i].flags, _fileTable[i].unk);
+ }
+}
+
+bool MohawkFile::hasResource(uint32 tag, uint16 id) {
+ if (!_mhk)
+ return false;
+
+ int16 typeIndex = getTypeIndex(tag);
+
+ if (typeIndex < 0)
+ return false;
+
+ return (getIdIndex(typeIndex, id) >= 0);
+}
+
+Common::SeekableReadStream *MohawkFile::getRawData(uint32 tag, uint16 id) {
+ if (!_mhk)
+ error ("MohawkFile::getRawData - No File in Use");
+
+ int16 typeIndex = getTypeIndex(tag);
+
+ if (typeIndex < 0)
+ error ("Could not find a tag of \'%s\' in file \'%s\'", tag2str(tag), _curFile.c_str());
+
+ int16 idIndex = getIdIndex(typeIndex, id);
+
+ if (idIndex < 0)
+ error ("Could not find \'%s\' %04x in file \'%s\'", tag2str(tag), id, _curFile.c_str());
+
+ // Note: the fileTableIndex is based off 1, not 0. So, subtract 1
+ uint16 fileTableIndex = _types[typeIndex].resTable.entries[idIndex].index - 1;
+
+ // WORKAROUND: tMOV resources pretty much ignore the size part of the file table,
+ // as the original just passed the full Mohawk file to QuickTime and the offset.
+ // We need to do this because of the way Mohawk is set up (this is much more "proper"
+ // than passing _mhk at the right offset). We may want to do that in the future, though.
+ if (_types[typeIndex].tag == ID_TMOV) {
+ if (fileTableIndex == _fileTableAmount)
+ return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _mhk->size());
+ else
+ return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex + 1].offset);
+ }
+
+ return new Common::SeekableSubReadStream(_mhk, _fileTable[fileTableIndex].offset, _fileTable[fileTableIndex].offset + _fileTable[fileTableIndex].dataSize);
+}
+
+void OldMohawkFile::open(Common::SeekableReadStream *stream) {
+ close();
+ _mhk = stream;
+
+ // This is for the "old" Mohawk resource format used in some older
+ // Living Books. It is very similar, just missing the MHWK tag and
+ // some other minor differences, especially with the file table
+ // being merged into the resource table.
+
+ uint32 headerSize = _mhk->readUint32BE();
+
+ // NOTE: There are differences besides endianness! (Subtle changes,
+ // but different).
+
+ if (headerSize == 6) { // We're in Big Endian mode (Macintosh)
+ _mhk->readUint16BE(); // Resource Table Size
+ _typeTable.resource_types = _mhk->readUint16BE();
+ _types = new OldType[_typeTable.resource_types];
+
+ debug (0, "Old Mohawk File (Macintosh): Number of Resource Types = %04x", _typeTable.resource_types);
+
+ for (uint16 i = 0; i < _typeTable.resource_types; i++) {
+ _types[i].tag = _mhk->readUint32BE();
+ _types[i].resource_table_offset = (uint16)_mhk->readUint32BE() + 6;
+ _mhk->readUint32BE(); // Unknown (always 0?)
+
+ debug (3, "Type[%02d]: Tag = \'%s\' ResTable Offset = %04x", i, tag2str(_types[i].tag), _types[i].resource_table_offset);
+
+ uint32 oldPos = _mhk->pos();
+
+ // Resource Table/File Table
+ _mhk->seek(_types[i].resource_table_offset);
+ _types[i].resTable.resources = _mhk->readUint16BE();
+ _types[i].resTable.entries = new OldType::ResourceTable::Entries[_types[i].resTable.resources];
+
+ for (uint16 j = 0; j < _types[i].resTable.resources; j++) {
+ _types[i].resTable.entries[j].id = _mhk->readUint16BE();
+ _types[i].resTable.entries[j].offset = _mhk->readUint32BE();
+ _types[i].resTable.entries[j].size = _mhk->readByte() << 16;
+ _types[i].resTable.entries[j].size += _mhk->readUint16BE();
+ _mhk->skip(5); // Unknown (always 0?)
+
+ debug (4, "Entry[%02x]: ID = %04x (%d)\tOffset = %08x, Size = %08x", j, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].offset, _types[i].resTable.entries[j].size);
+ }
+
+ _mhk->seek(oldPos);
+ debug (3, "\n");
+ }
+ } else if (SWAP_BYTES_32(headerSize) == 6) { // We're in Little Endian mode (Windows)
+ _mhk->readUint16LE(); // Resource Table Size
+ _typeTable.resource_types = _mhk->readUint16LE();
+ _types = new OldType[_typeTable.resource_types];
+
+ debug (0, "Old Mohawk File (Windows): Number of Resource Types = %04x", _typeTable.resource_types);
+
+ for (uint16 i = 0; i < _typeTable.resource_types; i++) {
+ _types[i].tag = _mhk->readUint32LE();
+ _types[i].resource_table_offset = _mhk->readUint16LE() + 6;
+ _mhk->readUint16LE(); // Unknown (always 0?)
+
+ debug (3, "Type[%02d]: Tag = \'%s\' ResTable Offset = %04x", i, tag2str(_types[i].tag), _types[i].resource_table_offset);
+
+ uint32 oldPos = _mhk->pos();
+
+ // Resource Table/File Table
+ _mhk->seek(_types[i].resource_table_offset);
+ _types[i].resTable.resources = _mhk->readUint16LE();
+ _types[i].resTable.entries = new OldType::ResourceTable::Entries[_types[i].resTable.resources];
+
+ for (uint16 j = 0; j < _types[i].resTable.resources; j++) {
+ _types[i].resTable.entries[j].id = _mhk->readUint16LE();
+ _types[i].resTable.entries[j].offset = _mhk->readUint32LE();
+ _types[i].resTable.entries[j].size = _mhk->readUint16LE();
+ _mhk->readUint32LE(); // Unknown (always 0?)
+
+ debug (4, "Entry[%02x]: ID = %04x (%d)\tOffset = %08x, Size = %08x", j, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].id, _types[i].resTable.entries[j].offset, _types[i].resTable.entries[j].size);
+ }
+
+ _mhk->seek(oldPos);
+ debug (3, "\n");
+ }
+ } else
+ error("Could not determine type of Old Mohawk resource");
+
+}
+
+Common::SeekableReadStream *OldMohawkFile::getRawData(uint32 tag, uint16 id) {
+ if (!_mhk)
+ error ("OldMohawkFile::getRawData - No File in Use");
+
+ int16 typeIndex = getTypeIndex(tag);
+
+ if (typeIndex < 0)
+ error ("Could not find a tag of \'%s\' in file \'%s\'", tag2str(tag), _curFile.c_str());
+
+ int16 idIndex = getIdIndex(typeIndex, id);
+
+ if (idIndex < 0)
+ error ("Could not find \'%s\' %04x in file \'%s\'", tag2str(tag), id, _curFile.c_str());
+
+ return new Common::SeekableSubReadStream(_mhk, _types[typeIndex].resTable.entries[idIndex].offset, _types[typeIndex].resTable.entries[idIndex].offset + _types[typeIndex].resTable.entries[idIndex].size);
+}
+
+} // End of namespace Mohawk
Property changes on: scummvm/trunk/engines/mohawk/file.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/file.h
===================================================================
--- scummvm/trunk/engines/mohawk/file.h (rev 0)
+++ scummvm/trunk/engines/mohawk/file.h 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,257 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/file.h"
+#include "common/str.h"
+
+#include "mohawk/sound.h"
+
+#ifndef MOHAWK_FILE_H
+#define MOHAWK_FILE_H
+
+namespace Mohawk {
+
+// Main FourCC's
+#define ID_MHWK MKID_BE('MHWK') // Main FourCC
+#define ID_RSRC MKID_BE('RSRC') // Resource Directory Tag
+
+// Myst Resource FourCC's
+#define ID_CLRC MKID_BE('CLRC') // Cursor Hotspots
+#define ID_EXIT MKID_BE('EXIT') // Card Exit Scripts
+#define ID_HINT MKID_BE('HINT') // Specifies Cursors in What Area
+#define ID_INIT MKID_BE('INIT') // Card Entrance Scripts
+#define ID_MSND MKID_BE('MSND') // Standard Mohawk Sound
+#define ID_RLST MKID_BE('RLST') // Resource List, Specifies HotSpots
+#define ID_RSFL MKID_BE('RSFL') // ??? (system.dat only)
+#define ID_VIEW MKID_BE('VIEW') // Card Details
+#define ID_WDIB MKID_BE('WDIB') // LZ-Compressed Windows Bitmap
+
+// Myst Masterpiece Edition Resource FourCC's (In addition to Myst FourCC's)
+#define ID_HELP MKID_BE('HELP') // Help Chunk
+#define ID_MJMP MKID_BE('MJMP') // MSND Jumps (To reduce MSND duplication)
+#define ID_PICT MKID_BE('PICT') // JPEG/PICT Image
+
+// Riven Resource FourCC's
+#define ID_BLST MKID_BE('BLST') // Card Hotspot Enabling Lists
+#define ID_CARD MKID_BE('CARD') // Card Scripts
+#define ID_FLST MKID_BE('FLST') // Card SFXE Lists
+#define ID_HSPT MKID_BE('HSPT') // Card Hotspots
+#define ID_MLST MKID_BE('MLST') // Card Movie Lists
+#define ID_NAME MKID_BE('NAME') // Object Names
+#define ID_PLST MKID_BE('PLST') // Card Picture Lists
+#define ID_RMAP MKID_BE('RMAP') // Card Code
+#define ID_SFXE MKID_BE('SFXE') // Water Effect Animations
+#define ID_SLST MKID_BE('SLST') // Card Ambient Sound Lists
+#define ID_TMOV MKID_BE('tMOV') // Game Movie
+
+// Riven Saved Game FourCC's
+#define ID_VARS MKID_BE('VARS') // Saved Game Variable Values
+#define ID_VERS MKID_BE('VERS') // Version Info
+#define ID_ZIPS MKID_BE('ZIPS') // Zip Mode Status
+
+// Zoombini Resource FourCC's
+#define ID_SND MKID_BE('\0SND') // Standard Mohawk Sound
+#define ID_CURS MKID_BE('CURS') // Cursor?
+#define ID_SCRB MKID_BE('SCRB') // ???
+#define ID_SCRS MKID_BE('SCRS') // ???
+#define ID_NODE MKID_BE('NODE') // ???
+#define ID_PATH MKID_BE('PATH') // ???
+#define ID_SHPL MKID_BE('SHPL') // ???
+
+// Living Books Resource FourCC's
+#define ID_TCUR MKID_BE('tCUR') // Cursor
+#define ID_BITL MKID_BE('BITL') // ???
+#define ID_CTBL MKID_BE('CTBL') // Color Table?
+#define ID_SCRP MKID_BE('SCRP') // Script?
+#define ID_SPR MKID_BE('SPR#') // Sprites?
+#define ID_VRSN MKID_BE('VRSN') // Version
+#define ID_ANI MKID_BE('ANI ') // Animation?
+#define ID_SHP MKID_BE('SHP#') // ???
+
+// JamesMath Resource FourCC's
+#define ID_TANM MKID_BE('tANM') // Animation?
+#define ID_TMFO MKID_BE('tMFO') // ???
+
+// Mohawk Wave Tags
+#define ID_WAVE MKID_BE('WAVE') // Game Sound (Third Tag)
+#define ID_ADPC MKID_BE('ADPC') // Game Sound Chunk
+#define ID_DATA MKID_BE('Data') // Game Sound Chunk
+#define ID_CUE MKID_BE('Cue#') // Game Sound Chunk
+
+// Mohawk MIDI Tags
+#define ID_MIDI MKID_BE('MIDI') // Game Sound (Third Tag), instead of WAVE
+#define ID_PRG MKID_BE('Prg#') // Midi Program?
+
+// Old Mohawk Resource FourCC's
+#define ID_WAV MKID_BE('WAV ') // Old Sound Resource
+#define ID_BMAP MKID_BE('BMAP') // Standard Mohawk Bitmap
+
+// Common Resource FourCC's
+#define ID_TBMP MKID_BE('tBMP') // Standard Mohawk Bitmap
+#define ID_TWAV MKID_BE('tWAV') // Standard Mohawk Sound
+#define ID_TPAL MKID_BE('tPAL') // Standard Mohawk Palette
+#define ID_TCNT MKID_BE('tCNT') // ??? (CSWorld, CSAmtrak, JamesMath)
+#define ID_TSCR MKID_BE('tSCR') // Script? Screen? (CSWorld, CSAmtrak, Treehouse)
+#define ID_STRL MKID_BE('STRL') // String List (Zoombini, CSWorld, CSAmtrak)
+#define ID_TBMH MKID_BE('tBMH') // Standard Mohawk Bitmap
+#define ID_TMID MKID_BE('tMID') // Standard Mohawk MIDI
+#define ID_REGS MKID_BE('REGS') // ??? (Zoombini, Treehouse)
+#define ID_BYTS MKID_BE('BYTS') // Database Entry (CSWorld, CSAmtrak)
+#define ID_INTS MKID_BE('INTS') // ??? (CSWorld, CSAmtrak)
+#define ID_BBOX MKID_BE('BBOX') // Boxes? (CSWorld, CSAmtrak)
+#define ID_SYSX MKID_BE('SYSX') // MIDI Sysex
+
+struct FileTable {
+ uint32 offset;
+ uint32 dataSize; // Really 27 bits
+ byte flags; // Mostly useless except for the bottom 3 bits which are part of the size
+ uint16 unk; // Always 0
+};
+
+struct Type {
+ Type() { resTable.entries = NULL; nameTable.entries = NULL; }
+ ~Type() { delete[] resTable.entries; delete[] nameTable.entries; }
+
+ //Type Table
+ uint32 tag;
+ uint16 resource_table_offset;
+ uint16 name_table_offset;
+
+ struct ResourceTable {
+ uint16 resources;
+ struct Entries {
+ uint16 id;
+ uint16 index;
+ } *entries;
+ } resTable;
+
+ struct NameTable {
+ uint16 num;
+ struct Entries {
+ uint16 offset;
+ uint16 index;
+ // Name List
+ Common::String name;
+ } *entries;
+ } nameTable;
+};
+
+struct TypeTable {
+ uint16 name_offset;
+ uint16 resource_types;
+};
+
+struct RSRC_Header {
+ uint32 size;
+ uint32 filesize;
+ uint32 abs_offset;
+ uint16 file_table_offset;
+ uint16 file_table_size;
+};
+
+class MohawkFile {
+public:
+ MohawkFile();
+ virtual ~MohawkFile() { close(); }
+
+ void open(Common::String filename);
+ virtual void open(Common::SeekableReadStream *stream);
+ void close();
+
+ bool hasResource(uint32 tag, uint16 id);
+ virtual Common::SeekableReadStream *getRawData(uint32 tag, uint16 id);
+
+protected:
+ Common::SeekableReadStream *_mhk;
+ TypeTable _typeTable;
+ Common::String _curFile;
+
+private:
+ bool _hasData;
+ uint32 _fileSize;
+ RSRC_Header _rsrc;
+ Type *_types;
+ FileTable *_fileTable;
+ uint16 _nameTableAmount;
+ uint16 _resourceTableAmount;
+ uint16 _fileTableAmount;
+
+ virtual int16 getTypeIndex(uint32 tag) {
+ for (uint16 i = 0; i < _typeTable.resource_types; i++)
+ if (_types[i].tag == tag)
+ return i;
+ return -1; // not found
+ }
+
+ virtual int16 getIdIndex(int16 typeIndex, uint16 id) {
+ for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++)
+ if (_types[typeIndex].resTable.entries[i].id == id)
+ return i;
+ return -1; // not found
+ }
+};
+
+class OldMohawkFile : public MohawkFile {
+public:
+ OldMohawkFile() : MohawkFile() {}
+ ~OldMohawkFile() {}
+
+ void open(Common::SeekableReadStream *stream);
+ Common::SeekableReadStream *getRawData(uint32 tag, uint16 id);
+
+private:
+ struct OldType {
+ uint32 tag;
+ uint16 resource_table_offset;
+ struct ResourceTable {
+ uint16 resources;
+ struct Entries {
+ uint16 id;
+ uint32 offset;
+ uint32 size;
+ } *entries;
+ } resTable;
+ } *_types;
+
+ int16 getTypeIndex(uint32 tag) {
+ for (uint16 i = 0; i < _typeTable.resource_types; i++)
+ if (_types[i].tag == tag)
+ return i;
+ return -1; // not found
+ }
+
+ int16 getIdIndex(int16 typeIndex, uint16 id) {
+ for (uint16 i = 0; i < _types[typeIndex].resTable.resources; i++)
+ if (_types[typeIndex].resTable.entries[i].id == id)
+ return i;
+ return -1; // not found
+ }
+};
+
+} // End of namespace Mohawk
+
+#endif
Property changes on: scummvm/trunk/engines/mohawk/file.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:eol-style
+ native
Added: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/graphics.cpp 2009-12-29 23:18:24 UTC (rev 46727)
@@ -0,0 +1,739 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "mohawk/file.h"
+#include "mohawk/graphics.h"
+#include "mohawk/myst.h"
+#include "mohawk/riven.h"
+#include "mohawk/riven_cursors.h"
+
+#include "graphics/cursorman.h"
+#include "graphics/primitives.h"
+#include "gui/message.h"
+
+namespace Mohawk {
+
+Graphics::Surface *ImageData::getSurface() {
+ Graphics::PixelFormat pixelFormat = g_system->getScreenFormat();
+ Graphics::Surface *surface = new Graphics::Surface();
+ surface->create(_surface->w, _surface->h, pixelFormat.bytesPerPixel);
+
+ if (_surface->bytesPerPixel == 1) {
+ assert(_palette);
+
+ for (uint16 i = 0; i < _surface->h; i++) {
+ for (uint16 j = 0; j < _surface->w; j++) {
+ byte palIndex = *((byte *)_surface->pixels + i * _surface->pitch + j);
+ byte r = _palette[palIndex * 4];
+ byte g = _palette[palIndex * 4 + 1];
+ byte b = _palette[palIndex * 4 + 2];
+ if (pixelFormat.bytesPerPixel == 2)
+ *((uint16 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
+ else
+ *((uint32 *)surface->getBasePtr(j, i)) = pixelFormat.RGBToColor(r, g, b);
+ }
+ }
+ } else
+ memcpy(surface->pixels, _surface->pixels, _surface->w * _surface->h * _surface->bytesPerPixel);
+
+ return surface;
+}
+
+MystGraphics::MystGraphics(MohawkEngine_Myst* vm) : _vm(vm) {
+ _bmpDecoder = new MystBitmap();
+
+ // The original version of Myst could run in 8bpp color too.
+ // However, it dithered videos to 8bpp and they looked considerably
+ // worse (than they already did :P). So we're not even going to
@@ Diff output truncated at 100000 characters. @@
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