experimental support for the V2 resource format (patch #601560)

svn-id: r4864
This commit is contained in:
Max Horn 2002-08-29 16:57:43 +00:00
parent 0cf920e040
commit bbcae3efbe
7 changed files with 117 additions and 8 deletions

View file

@ -17,7 +17,7 @@ GUI_OBJS = gui/gui.o gui/newgui.o gui/widget.o gui/dialog.o gui/ListWidget.o \
SCUMM_OBJS = scumm/actor.o scumm/akos.o scumm/boxes.o scumm/bundle.o \
scumm/costume.o scumm/debug.o scumm/debugrl.o scumm/gfx.o scumm/imuse.o \
scumm/object.o scumm/resource.o scumm/resource_v3.o \
scumm/object.o scumm/resource.o scumm/resource_v2.o scumm/resource_v3.o \
scumm/resource_v4.o scumm/saveload.o scumm/script.o \
scumm/script_v1.o scumm/script_v2.o scumm/scummvm.o scumm/string.o \
scumm/sys.o scumm/vars.o scumm/verbs.o \

View file

@ -85,7 +85,9 @@ Engine *Engine::createFromDetector(GameDetector *detector, OSystem *syst)
engine = new SimonState(detector, syst);
} else {
// Some kind of Scumm game
if (detector->_features & GF_OLD256)
if (detector->_features & GF_OLD_BUNDLE)
engine = new Scumm_v2(detector, syst);
else if (detector->_features & GF_OLD256)
engine = new Scumm_v3(detector, syst);
else if (detector->_features & GF_SMALL_HEADER) // this force loomCD as v4
engine = new Scumm_v4(detector, syst);

View file

@ -350,8 +350,12 @@ static const VersionSettings version_settings[] = {
// {"zak", "Zak McKracken and the Alien Mindbenders (C64)", GID_ZAK64, 1, 0, 0,},
/* Scumm Version 2 */
// {"maniac", "Maniac Mansion", GID_MANIAC, 2, 0, 0,},
// {"zak", "Zak McKracken and the Alien Mindbenders", GID_ZAK, 2, 0, 0,},
// {"maniac", "Maniac Mansion", GID_MANIAC, 2, 0, 0,
// GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_16COLOR | GF_OLD_BUNDLE |
// GF_NO_SCALLING},
// {"zak", "Zak McKracken and the Alien Mindbenders", GID_ZAK, 2, 0, 0,
// GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_16COLOR | GF_OLD_BUNDLE |
// GF_NO_SCALLING},
// {"indy3", "Indiana Jones and the Last Crusade", GID_INDY3, 2, 0, 0,},
/* Scumm Version 3 */

View file

@ -388,8 +388,10 @@ void Scumm::readResTypeList(int id, uint32 tag, const char *name)
if (_features & GF_AFTER_V8)
num = fileReadDwordLE();
else
else if (!(_features & GF_OLD_BUNDLE))
num = fileReadWordLE();
else
num = fileReadByte();
if (1 || _features & GF_AFTER_V6) {
if (num != res.num[id]) {
@ -402,7 +404,18 @@ void Scumm::readResTypeList(int id, uint32 tag, const char *name)
allocResTypeData(id, tag, num, name, 1);
}
if (_features & GF_SMALL_HEADER) {
if (_features & GF_OLD_BUNDLE) {
if (id == rtRoom){
for (i = 0; i < num; i++)
res.roomno[id][i] = i;
fileSeek(_fileHandle, num, SEEK_CUR);
} else {
for (i = 0; i < num; i++)
res.roomno[id][i] = fileReadByte();
}
for (i = 0; i < num; i++)
res.roomoffs[id][i] = fileReadWordLE();
} else if (_features & GF_SMALL_HEADER) {
for (i = 0; i < num; i++) {
res.roomno[id][i] = fileReadByte();
res.roomoffs[id][i] = fileReadDword();
@ -530,7 +543,9 @@ int Scumm::loadResource(int type, int idx)
fileSeek(_fileHandle, fileOffs + _fileOffset, SEEK_SET);
if (_features & GF_SMALL_HEADER) {
if (_features & GF_OLD_BUNDLE) {
size = fileReadWordLE();
} else if (_features & GF_SMALL_HEADER) {
if (!(_features & GF_SMALL_NAMES))
fileSeek(_fileHandle, 8, SEEK_CUR);
size = fileReadDwordLE();

76
scumm/resource_v2.cpp Normal file
View file

@ -0,0 +1,76 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001/2002 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "stdafx.h"
#include "scumm.h"
#include "resource.h"
void Scumm_v2::readIndexFile()
{
debug(9, "readIndexFile()");
openRoom(-1);
openRoom(0);
if (fileReadWordLE() != 0x0100)
warning("The magic id doesn't match\n");
_numGlobalObjects = fileReadWordLE();
fileSeek(_fileHandle, _numGlobalObjects, SEEK_CUR); // Skip object flags
_numRooms = fileReadByte();
fileSeek(_fileHandle, _numRooms * 3, SEEK_CUR);
_numCostumes = fileReadByte();
fileSeek(_fileHandle, _numCostumes * 3, SEEK_CUR);
_numScripts = fileReadByte();
fileSeek(_fileHandle, _numScripts * 3, SEEK_CUR);
_numSounds = fileReadByte();
clearFileReadFailed(_fileHandle);
fileSeek(_fileHandle, 0, SEEK_SET);
// FIXME - I'm not sure for those values yet, they will have to be rechecked
_numVariables = 800; /* 800 */
_numBitVariables = 4096; /* 2048 */
_numLocalObjects = 200; /* 200 */
_numArray = 50;
_numVerbs = 100;
_numNewNames = 0;
_objectRoomTable = NULL;
_numCharsets = 9; /* 9 */
_numInventory = 80; /* 80 */
_numGlobalScripts = 200;
_shadowPaletteSize = 256;
_shadowPalette = (byte *) calloc(_shadowPaletteSize, 1); // FIXME - needs to be removed later
_numFlObject = 50;
allocateArrays();
fileReadWordLE(); /* version magic number */
fileReadWordLE(); /* nb global objects */
fileSeek(_fileHandle, _numGlobalObjects, SEEK_CUR); // Skip object flags
readResTypeList(rtRoom, MKID('ROOM'), "room");
readResTypeList(rtCostume, MKID('COST'), "costume");
readResTypeList(rtScript, MKID('SCRP'), "script");
readResTypeList(rtSound, MKID('SOUN'), "sound");
openRoom(-1);
}

View file

@ -273,6 +273,8 @@ enum GameId {
GID_DIG = 12,
GID_MONKEY_VGA = 13,
GID_CMI = 14,
//GID_MANIAC = 15;
//GID_ZAK = 16;
/* Simon the Sorcerer */
GID_SIMON_FIRST = 20,
@ -1352,6 +1354,14 @@ public:
void updatePalette();
};
class Scumm_v2 : public Scumm
{
public:
Scumm_v2(GameDetector *detector, OSystem *syst) : Scumm(detector, syst) {}
virtual void readIndexFile();
};
class Scumm_v3 : public Scumm
{
public:

View file

@ -165,7 +165,9 @@ void Scumm::scummInit()
tempMusic = 0;
debug(9, "scummInit");
if (_features & GF_SMALL_HEADER)
if (_features & GF_OLD_BUNDLE)
_resourceHeaderSize = 2; // FIXME - to be rechecked
else if (_features & GF_SMALL_HEADER)
_resourceHeaderSize = 6;
else
_resourceHeaderSize = 8;