[Scummvm-cvs-logs] SF.net SVN: scummvm:[47429] scummvm/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Fri Jan 22 04:43:57 CET 2010
Revision: 47429
http://scummvm.svn.sourceforge.net/scummvm/?rev=47429&view=rev
Author: mthreepwood
Date: 2010-01-22 03:43:57 +0000 (Fri, 22 Jan 2010)
Log Message:
-----------
Rename MohawkFile to MohawkArchive and OldMohawkFile to LivingBooksArchive_v1 (the latter originally having an ambiguous meaning) and move them to resource.* Also, renaming the Living Books game types to remove the ambiguous old/new.
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/console.cpp
scummvm/trunk/engines/mohawk/detection.cpp
scummvm/trunk/engines/mohawk/graphics.cpp
scummvm/trunk/engines/mohawk/livingbooks.cpp
scummvm/trunk/engines/mohawk/livingbooks.h
scummvm/trunk/engines/mohawk/module.mk
scummvm/trunk/engines/mohawk/mohawk.h
scummvm/trunk/engines/mohawk/myst.cpp
scummvm/trunk/engines/mohawk/riven.cpp
scummvm/trunk/engines/mohawk/riven.h
scummvm/trunk/engines/mohawk/riven_saveload.cpp
scummvm/trunk/engines/mohawk/riven_saveload.h
scummvm/trunk/engines/mohawk/sound.cpp
scummvm/trunk/engines/mohawk/sound.h
scummvm/trunk/engines/mohawk/video/video.cpp
Added Paths:
-----------
scummvm/trunk/engines/mohawk/resource.cpp
scummvm/trunk/engines/mohawk/resource.h
Removed Paths:
-------------
scummvm/trunk/engines/mohawk/file.cpp
scummvm/trunk/engines/mohawk/file.h
Modified: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/console.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -630,11 +630,11 @@
return true;
}
- if (_vm->getGameType() == GType_OLDLIVINGBOOKS)
+ if (_vm->getGameType() == GType_LIVINGBOOKSV1)
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;
+ return _vm->getGameType() != GType_LIVINGBOOKSV1;
}
} // End of namespace Mohawk
Modified: scummvm/trunk/engines/mohawk/detection.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/detection.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/detection.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -581,7 +581,7 @@
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
- GType_NEWLIVINGBOOKS,
+ GType_LIVINGBOOKSV3,
0,
0
},
@@ -597,7 +597,7 @@
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
- GType_NEWLIVINGBOOKS,
+ GType_LIVINGBOOKSV3,
0,
0
},
@@ -660,7 +660,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -675,7 +675,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -690,7 +690,7 @@
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
0,
0
},
@@ -705,7 +705,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -720,7 +720,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -735,7 +735,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -750,7 +750,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -765,7 +765,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -780,7 +780,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -795,7 +795,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -810,7 +810,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -825,7 +825,7 @@
ADGF_DEMO,
Common::GUIO_NONE
},
- GType_OLDLIVINGBOOKS,
+ GType_LIVINGBOOKSV1,
GF_DEMO,
0
},
@@ -840,7 +840,7 @@
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
- GType_NEWLIVINGBOOKS,
+ GType_LIVINGBOOKSV3,
0,
0
},
@@ -856,7 +856,7 @@
ADGF_NO_FLAGS,
Common::GUIO_NONE
},
- GType_NEWLIVINGBOOKS,
+ GType_LIVINGBOOKSV3,
0,
0
},
@@ -1047,8 +1047,8 @@
case Mohawk::GType_RIVEN:
*engine = new Mohawk::MohawkEngine_Riven(syst, gd);
break;
- case Mohawk::GType_OLDLIVINGBOOKS:
- case Mohawk::GType_NEWLIVINGBOOKS:
+ case Mohawk::GType_LIVINGBOOKSV1:
+ case Mohawk::GType_LIVINGBOOKSV3:
*engine = new Mohawk::MohawkEngine_LivingBooks(syst, gd);
break;
case Mohawk::GType_ZOOMBINI:
Deleted: scummvm/trunk/engines/mohawk/file.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/file.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/file.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -1,340 +0,0 @@
-/* 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;
- _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.clear();
-}
-
-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);
-}
-
-uint32 MohawkFile::getOffset(uint32 tag, uint16 id) {
- assert(_mhk);
-
- int16 typeIndex = getTypeIndex(tag);
- assert(typeIndex >= 0);
-
- int16 idIndex = getIdIndex(typeIndex, id);
- assert(idIndex >= 0);
-
- return _fileTable[_types[typeIndex].resTable.entries[idIndex].index - 1].offset;
-}
-
-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");
-
-}
-
-uint32 OldMohawkFile::getOffset(uint32 tag, uint16 id) {
- assert(_mhk);
-
- int16 typeIndex = getTypeIndex(tag);
- assert(typeIndex >= 0);
-
- int16 idIndex = getIdIndex(typeIndex, id);
- assert(idIndex >= 0);
-
- return _types[typeIndex].resTable.entries[idIndex].offset;
-}
-
-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
Deleted: scummvm/trunk/engines/mohawk/file.h
===================================================================
--- scummvm/trunk/engines/mohawk/file.h 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/file.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -1,259 +0,0 @@
-/* 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);
- virtual uint32 getOffset(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);
- uint32 getOffset(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
Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/graphics.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -23,7 +23,7 @@
*
*/
-#include "mohawk/file.h"
+#include "mohawk/resource.h"
#include "mohawk/graphics.h"
#include "mohawk/myst.h"
#include "mohawk/riven.h"
@@ -671,7 +671,7 @@
}
LBGraphics::LBGraphics(MohawkEngine_LivingBooks *vm) : _vm(vm) {
- _bmpDecoder = (_vm->getGameType() == GType_OLDLIVINGBOOKS) ? new OldMohawkBitmap() : new MohawkBitmap();
+ _bmpDecoder = (_vm->getGameType() == GType_LIVINGBOOKSV1) ? new OldMohawkBitmap() : new MohawkBitmap();
_palette = new byte[256 * 4];
memset(_palette, 0, 256 * 4);
}
@@ -682,7 +682,7 @@
}
void LBGraphics::copyImageToScreen(uint16 image, uint16 left, uint16 right) {
- if (_vm->getGameType() == GType_OLDLIVINGBOOKS) {
+ if (_vm->getGameType() == GType_LIVINGBOOKSV1) {
// Drawing images in the old format isn't supported (yet)
ImageData *imageData = _bmpDecoder->decodeImage(_vm->wrapStreamEndian(ID_BMAP, image));
delete imageData;
@@ -708,7 +708,7 @@
// Old Living Books gamnes use the old CTBL-style palette format while newer
// games use the better tPAL format which can store partial palettes.
- if (_vm->getGameType() == GType_OLDLIVINGBOOKS) {
+ if (_vm->getGameType() == GType_LIVINGBOOKSV1) {
Common::SeekableSubReadStreamEndian *ctblStream = _vm->wrapStreamEndian(ID_CTBL, id);
uint16 colorCount = ctblStream->readUint16();
Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -24,7 +24,7 @@
*/
#include "mohawk/livingbooks.h"
-#include "mohawk/file.h"
+#include "mohawk/resource.h"
#include "common/events.h"
@@ -148,9 +148,9 @@
filename = getFileNameFromConfig("Intro", "Page1.r");
if (!filename.empty() && Common::File::exists(filename)) {
- MohawkFile *introFile = createMohawkFile();
- introFile->open(filename);
- _mhk.push_back(introFile);
+ MohawkArchive *introArchive = createMohawkArchive();
+ introArchive->open(filename);
+ _mhk.push_back(introArchive);
}
filename = getFileNameFromConfig("Intro", "Page2");
@@ -159,9 +159,9 @@
filename = getFileNameFromConfig("Intro", "Page2.r");
if (!filename.empty() && Common::File::exists(filename)) {
- MohawkFile *coverFile = createMohawkFile();
- coverFile->open(filename);
- _mhk.push_back(coverFile);
+ MohawkArchive *coverArchive = createMohawkArchive();
+ coverArchive->open(filename);
+ _mhk.push_back(coverArchive);
}
}
@@ -323,8 +323,8 @@
return filename;
}
-MohawkFile *MohawkEngine_LivingBooks::createMohawkFile() const {
- return (getGameType() == GType_NEWLIVINGBOOKS) ? new MohawkFile() : new OldMohawkFile();
+MohawkArchive *MohawkEngine_LivingBooks::createMohawkArchive() const {
+ return (getGameType() == GType_LIVINGBOOKSV1) ? new LivingBooksArchive_v1() : new MohawkArchive();
}
} // End of namespace Mohawk
Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/livingbooks.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -85,8 +85,8 @@
Common::String getFileNameFromConfig(Common::String section, Common::String key);
// Platform/Version functions
- bool isBigEndian() const { return getGameType() == GType_NEWLIVINGBOOKS || getPlatform() == Common::kPlatformMacintosh; }
- MohawkFile *createMohawkFile() const;
+ bool isBigEndian() const { return getGameType() == GType_LIVINGBOOKSV3 || getPlatform() == Common::kPlatformMacintosh; }
+ MohawkArchive *createMohawkArchive() const;
};
} // End of namespace Mohawk
Modified: scummvm/trunk/engines/mohawk/module.mk
===================================================================
--- scummvm/trunk/engines/mohawk/module.mk 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/module.mk 2010-01-22 03:43:57 UTC (rev 47429)
@@ -5,7 +5,6 @@
console.o \
detection.o \
dialogs.o \
- file.o \
graphics.o \
livingbooks.o \
mohawk.o \
@@ -15,6 +14,7 @@
myst_vars.o \
myst_saveload.o \
myst_scripts.o \
+ resource.o \
riven.o \
riven_external.o \
riven_saveload.o \
Modified: scummvm/trunk/engines/mohawk/mohawk.h
===================================================================
--- scummvm/trunk/engines/mohawk/mohawk.h 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/mohawk.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -47,8 +47,8 @@
GType_TREEHOUSE,
GType_1STDEGREE,
GType_CSUSA,
- GType_OLDLIVINGBOOKS,
- GType_NEWLIVINGBOOKS
+ GType_LIVINGBOOKSV1,
+ GType_LIVINGBOOKSV3
};
enum MohawkGameFeatures {
@@ -61,7 +61,7 @@
struct MohawkGameDescription;
class Sound;
class PauseDialog;
-class MohawkFile;
+class MohawkArchive;
class VideoManager;
class MohawkEngine : public ::Engine {
@@ -98,7 +98,7 @@
protected:
// An array holding the main Mohawk archives require by the games
- Common::Array<MohawkFile *> _mhk;
+ Common::Array<MohawkArchive *> _mhk;
};
} // End of namespace Mohawk
Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/myst.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -30,7 +30,7 @@
#include "mohawk/myst_scripts.h"
#include "mohawk/myst_saveload.h"
#include "mohawk/dialogs.h"
-#include "mohawk/file.h"
+#include "mohawk/resource.h"
#include "mohawk/video/video.h"
namespace Mohawk {
@@ -223,7 +223,7 @@
// Load Help System (Masterpiece Edition Only)
if (getFeatures() & GF_ME) {
- MohawkFile *mhk = new MohawkFile();
+ MohawkArchive *mhk = new MohawkArchive();
mhk->open("help.dat");
_mhk.push_back(mhk);
}
@@ -316,10 +316,10 @@
// If the array is empty, add a new one. Otherwise, delete the first
// entry which is the stack file (the second, if there, is the help file).
if (_mhk.empty())
- _mhk.push_back(new MohawkFile());
+ _mhk.push_back(new MohawkArchive());
else {
delete _mhk[0];
- _mhk[0] = new MohawkFile();
+ _mhk[0] = new MohawkArchive();
}
_mhk[0]->open(mystFiles[_curStack]);
Copied: scummvm/trunk/engines/mohawk/resource.cpp (from rev 47420, scummvm/trunk/engines/mohawk/file.cpp)
===================================================================
--- scummvm/trunk/engines/mohawk/resource.cpp (rev 0)
+++ scummvm/trunk/engines/mohawk/resource.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -0,0 +1,340 @@
+/* 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/resource.h"
+
+#include "common/util.h"
+
+namespace Mohawk {
+
+MohawkArchive::MohawkArchive() {
+ _mhk = NULL;
+ _types = NULL;
+ _fileTable = NULL;
+}
+
+void MohawkArchive::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 MohawkArchive::close() {
+ delete _mhk; _mhk = NULL;
+ delete[] _types; _types = NULL;
+ delete[] _fileTable; _fileTable = NULL;
+
+ _curFile.clear();
+}
+
+void MohawkArchive::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 MohawkArchive::hasResource(uint32 tag, uint16 id) {
+ if (!_mhk)
+ return false;
+
+ int16 typeIndex = getTypeIndex(tag);
+
+ if (typeIndex < 0)
+ return false;
+
+ return (getIdIndex(typeIndex, id) >= 0);
+}
+
+uint32 MohawkArchive::getOffset(uint32 tag, uint16 id) {
+ assert(_mhk);
+
+ int16 typeIndex = getTypeIndex(tag);
+ assert(typeIndex >= 0);
+
+ int16 idIndex = getIdIndex(typeIndex, id);
+ assert(idIndex >= 0);
+
+ return _fileTable[_types[typeIndex].resTable.entries[idIndex].index - 1].offset;
+}
+
+Common::SeekableReadStream *MohawkArchive::getRawData(uint32 tag, uint16 id) {
+ if (!_mhk)
+ error ("MohawkArchive::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 LivingBooksArchive_v1::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");
+
+}
+
+uint32 LivingBooksArchive_v1::getOffset(uint32 tag, uint16 id) {
+ assert(_mhk);
+
+ int16 typeIndex = getTypeIndex(tag);
+ assert(typeIndex >= 0);
+
+ int16 idIndex = getIdIndex(typeIndex, id);
+ assert(idIndex >= 0);
+
+ return _types[typeIndex].resTable.entries[idIndex].offset;
+}
+
+Common::SeekableReadStream *LivingBooksArchive_v1::getRawData(uint32 tag, uint16 id) {
+ if (!_mhk)
+ error ("LivingBooksArchive_v1::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
Copied: scummvm/trunk/engines/mohawk/resource.h (from rev 47420, scummvm/trunk/engines/mohawk/file.h)
===================================================================
--- scummvm/trunk/engines/mohawk/resource.h (rev 0)
+++ scummvm/trunk/engines/mohawk/resource.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -0,0 +1,259 @@
+/* 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_RESOURCE_H
+#define MOHAWK_RESOURCE_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 MohawkArchive {
+public:
+ MohawkArchive();
+ virtual ~MohawkArchive() { 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);
+ virtual uint32 getOffset(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 LivingBooksArchive_v1 : public MohawkArchive {
+public:
+ LivingBooksArchive_v1() : MohawkArchive() {}
+ ~LivingBooksArchive_v1() {}
+
+ void open(Common::SeekableReadStream *stream);
+ Common::SeekableReadStream *getRawData(uint32 tag, uint16 id);
+ uint32 getOffset(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
Modified: scummvm/trunk/engines/mohawk/riven.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/riven.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -83,7 +83,7 @@
// Open extras.mhk for common images (non-existant in the demo)
if (!(getFeatures() & GF_DEMO)) {
- _extrasFile = new MohawkFile();
+ _extrasFile = new MohawkArchive();
_extrasFile->open("extras.mhk");
}
@@ -230,7 +230,7 @@
for (int i = 0; i < ARRAYSIZE(endings); i++) {
Common::String filename = Common::String(prefix) + endings[i];
if (Common::File::exists(filename)) {
- MohawkFile *mhk = new MohawkFile();
+ MohawkArchive *mhk = new MohawkArchive();
mhk->open(filename);
_mhk.push_back(mhk);
}
Modified: scummvm/trunk/engines/mohawk/riven.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven.h 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/riven.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -34,7 +34,7 @@
namespace Mohawk {
struct MohawkGameDescription;
-class MohawkFile;
+class MohawkArchive;
class RivenGraphics;
class RivenExternal;
class RivenConsole;
@@ -120,7 +120,7 @@
bool hasFeature(EngineFeature f) const;
private:
- MohawkFile *_extrasFile; // We need a separate handle for the extra data
+ MohawkArchive *_extrasFile; // We need a separate handle for the extra data
RivenConsole *_console;
RivenSaveLoad *_saveLoad;
GUI::SaveLoadChooser *_loadDialog;
Modified: scummvm/trunk/engines/mohawk/riven_saveload.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_saveload.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/riven_saveload.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -31,7 +31,7 @@
namespace Mohawk {
RivenSaveLoad::RivenSaveLoad(MohawkEngine_Riven *vm, Common::SaveFileManager *saveFileMan) : _vm(vm), _saveFileMan(saveFileMan) {
- _loadFile = new MohawkFile();
+ _loadFile = new MohawkArchive();
}
RivenSaveLoad::~RivenSaveLoad() {
Modified: scummvm/trunk/engines/mohawk/riven_saveload.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven_saveload.h 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/riven_saveload.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -29,7 +29,7 @@
#include "common/savefile.h"
#include "common/str.h"
-#include "mohawk/file.h"
+#include "mohawk/resource.h"
namespace Mohawk {
@@ -53,7 +53,7 @@
private:
MohawkEngine_Riven *_vm;
Common::SaveFileManager *_saveFileMan;
- MohawkFile *_loadFile;
+ MohawkArchive *_loadFile;
Common::MemoryWriteStreamDynamic *genVERSSection();
Common::MemoryWriteStreamDynamic *genNAMESection();
Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/sound.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -68,7 +68,7 @@
static const char prefixes[] = { 'a', 'b', 'g', 'j', 'o', 'p', 'r', 't' };
if (!_rivenSoundFile)
- _rivenSoundFile = new MohawkFile();
+ _rivenSoundFile = new MohawkArchive();
_rivenSoundFile->open(Common::String(prefixes[stack]) + "_Sounds.mhk");
}
@@ -128,7 +128,7 @@
else
audStream = getCSAmtrakMusic(id);
break;
- case GType_OLDLIVINGBOOKS:
+ case GType_LIVINGBOOKSV1:
audStream = makeOldMohawkWaveStream(_vm->getRawData(ID_WAV, id));
break;
default:
@@ -322,7 +322,7 @@
Audio::AudioStream *Sound::getCSAmtrakMusic(uint16 id) {
char filename[18];
sprintf(filename, "MUSIC/MUSIC%02d.MHK", id);
- MohawkFile *file = new MohawkFile();
+ MohawkArchive *file = new MohawkArchive();
file->open(filename);
Audio::AudioStream *audStream = makeMohawkWaveStream(file->getRawData(ID_TWAV, 2000 + id));
delete file;
Modified: scummvm/trunk/engines/mohawk/sound.h
===================================================================
--- scummvm/trunk/engines/mohawk/sound.h 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/sound.h 2010-01-22 03:43:57 UTC (rev 47429)
@@ -36,7 +36,7 @@
#include "sound/mixer.h"
#include "mohawk/mohawk.h"
-#include "mohawk/file.h"
+#include "mohawk/resource.h"
namespace Mohawk {
@@ -134,7 +134,7 @@
private:
MohawkEngine *_vm;
- MohawkFile *_rivenSoundFile;
+ MohawkArchive *_rivenSoundFile;
MidiDriver *_midiDriver;
MidiParser *_midiParser;
Modified: scummvm/trunk/engines/mohawk/video/video.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video/video.cpp 2010-01-22 01:01:08 UTC (rev 47428)
+++ scummvm/trunk/engines/mohawk/video/video.cpp 2010-01-22 03:43:57 UTC (rev 47429)
@@ -23,7 +23,7 @@
*
*/
-#include "mohawk/file.h"
+#include "mohawk/resource.h"
#include "mohawk/video/video.h"
#include "mohawk/video/qt_player.h"
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