[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.414,2.415 object.cpp,1.216,1.217 resource_v3.cpp,1.30,1.31 resource_v4.cpp,1.11,1.12 scumm.cpp,1.397,1.398 scumm.h,1.557,1.558
Max Horn
fingolfin at users.sourceforge.net
Sun Apr 3 08:06:38 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v100he.cpp,2.109,2.110
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga isomap.cpp,1.42,1.43 isomap.h,1.18,1.19 music.cpp,1.49,1.50 objectmap.cpp,1.39,1.40 render.cpp,1.52,1.53 saga.cpp,1.102,1.103 script.cpp,1.62,1.63 sfuncs.cpp,1.95,1.96 sthread.cpp,1.75,1.76
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17432
Modified Files:
intern.h object.cpp resource_v3.cpp resource_v4.cpp scumm.cpp
scumm.h
Log Message:
ScummEngine_v4 used to be a subclass of ScummEngine_v3, now it is the other way around; added a new class ScummEngine_v3old, for GF_OLD_BUNDLE games; took advantage of the new inheritance structure and turned various methods into virtual methods which then are overriden in subclasses
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.414
retrieving revision 2.415
diff -u -d -r2.414 -r2.415
--- intern.h 3 Apr 2005 02:24:27 -0000 2.414
+++ intern.h 3 Apr 2005 15:06:07 -0000 2.415
@@ -187,13 +187,14 @@
void o5_walkActorToObject();
};
-class ScummEngine_v3 : public ScummEngine_v5 {
+class ScummEngine_v4 : public ScummEngine_v5 {
public:
- ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v5(detector, syst, gs, md5sum) {}
+ ScummEngine_v4(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
protected:
void readIndexFile();
void loadCharset(int no);
+ void loadRoomObjects();
void readMAXS();
void readGlobalObjects();
@@ -201,15 +202,25 @@
void setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL);
};
-class ScummEngine_v4 : public ScummEngine_v3 {
+class ScummEngine_v3 : public ScummEngine_v4 {
public:
- ScummEngine_v4(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v3(detector, syst, gs, md5sum) {}
+ ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
protected:
void loadCharset(int no);
};
-class ScummEngine_v2 : public ScummEngine_v3 {
+class ScummEngine_v3old : public ScummEngine_v3 {
+public:
+ ScummEngine_v3old(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
+
+protected:
+ void readIndexFile();
+ void initRoomSubBlocks();
+ void loadRoomObjects();
+};
+
+class ScummEngine_v2 : public ScummEngine_v3old {
protected:
void readIndexFile();
void readClassicIndexFile(); // V1
@@ -226,7 +237,7 @@
const OpcodeEntryV2 *_opcodesV2;
public:
- ScummEngine_v2(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v3(detector, syst, gs, md5sum) {}
+ ScummEngine_v2(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]);
virtual void scummInit();
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.216
retrieving revision 1.217
diff -u -d -r1.216 -r1.217
--- object.cpp 1 Apr 2005 13:05:39 -0000 1.216
+++ object.cpp 3 Apr 2005 15:06:07 -0000 1.217
@@ -625,7 +625,7 @@
CHECK_HEAP
}
-void ScummEngine::loadRoomObjectsOldBundle() {
+void ScummEngine_v3old::loadRoomObjects() {
int i;
ObjectData *od;
const byte *room, *ptr;
@@ -665,7 +665,7 @@
CHECK_HEAP
}
-void ScummEngine::loadRoomObjectsSmall() {
+void ScummEngine_v4::loadRoomObjects() {
int i, j;
ObjectData *od;
const byte *ptr;
@@ -725,7 +725,7 @@
CHECK_HEAP
}
-void ScummEngine_v3::setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
+void ScummEngine_v4::setupRoomObject(ObjectData *od, const byte *room, const byte *searchptr) {
assert(room);
const byte *ptr = room + od->OBCDoffset;
Index: resource_v3.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v3.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- resource_v3.cpp 30 Mar 2005 21:58:05 -0000 1.30
+++ resource_v3.cpp 3 Apr 2005 15:06:08 -0000 1.31
@@ -23,145 +23,48 @@
#include "stdafx.h"
#include "scumm/scumm.h"
#include "scumm/intern.h"
-#include "scumm/resource.h"
namespace Scumm {
-void ScummEngine_v3::readIndexFile() {
- if (_features & GF_OLD_BUNDLE) {
- int magic = 0;
- debug(9, "readIndexFile()");
-
- closeRoom();
- openRoom(0);
-
- magic = _fileHandle->readUint16LE();
- if (magic != 0x0100)
- warning("The magic id doesn't match (0x%X)", magic);
-
- _numGlobalObjects = _fileHandle->readUint16LE();
- _fileHandle->seek(_numGlobalObjects * 4, SEEK_CUR);
- _numRooms = _fileHandle->readByte();
- _fileHandle->seek(_numRooms * 3, SEEK_CUR);
- _numCostumes = _fileHandle->readByte();
- _fileHandle->seek(_numCostumes * 3, SEEK_CUR);
- _numScripts = _fileHandle->readByte();
- _fileHandle->seek(_numScripts * 3, SEEK_CUR);
- _numSounds = _fileHandle->readByte();
-
- _fileHandle->clearIOFailed();
- _fileHandle->seek(0, SEEK_SET);
-
- readMAXS();
-
- // Jamieson630: palManipulate variable initialization
- _palManipCounter = 0;
- _palManipPalette = 0; // Will allocate when needed
- _palManipIntermediatePal = 0; // Will allocate when needed
-
- _fileHandle->readUint16LE(); /* version magic number */
- readGlobalObjects();
- readResTypeList(rtRoom, MKID('ROOM'), "room");
- readResTypeList(rtCostume, MKID('COST'), "costume");
- readResTypeList(rtScript, MKID('SCRP'), "script");
- readResTypeList(rtSound, MKID('SOUN'), "sound");
-
- closeRoom();
- } else {
- uint16 blocktype;
- uint32 itemsize;
- int numblock = 0;
-
- debug(9, "readIndexFile()");
-
- closeRoom();
- openRoom(0);
-
- while (!_fileHandle->eof()) {
- itemsize = _fileHandle->readUint32LE();
- blocktype = _fileHandle->readUint16LE();
- if (_fileHandle->ioFailed())
- break;
-
- switch (blocktype) {
- case 0x4E52: // 'NR'
- _fileHandle->readUint16LE();
- break;
- case 0x5230: // 'R0'
- _numRooms = _fileHandle->readUint16LE();
- break;
- case 0x5330: // 'S0'
- _numScripts = _fileHandle->readUint16LE();
- break;
- case 0x4E30: // 'N0'
- _numSounds = _fileHandle->readUint16LE();
- break;
- case 0x4330: // 'C0'
- _numCostumes = _fileHandle->readUint16LE();
- break;
- case 0x4F30: // 'O0'
- _numGlobalObjects = _fileHandle->readUint16LE();
- break;
- }
- _fileHandle->seek(itemsize - 8, SEEK_CUR);
- }
-
- _fileHandle->clearIOFailed();
- _fileHandle->seek(0, SEEK_SET);
-
- readMAXS();
-
- // Jamieson630: palManipulate variable initialization
- _palManipCounter = 0;
- _palManipPalette = 0; // Will allocate when needed
- _palManipIntermediatePal = 0; // Will allocate when needed
-
- while (1) {
- itemsize = _fileHandle->readUint32LE();
-
- if (_fileHandle->ioFailed())
- break;
-
- blocktype = _fileHandle->readUint16LE();
-
- numblock++;
+void ScummEngine_v3old::readIndexFile() {
+ int magic = 0;
+ debug(9, "readIndexFile()");
- switch (blocktype) {
+ closeRoom();
+ openRoom(0);
- case 0x4E52: // 'NR'
- _fileHandle->seek(itemsize - 6, SEEK_CUR);
- break;
+ magic = _fileHandle->readUint16LE();
+ if (magic != 0x0100)
+ warning("The magic id doesn't match (0x%X)", magic);
- case 0x5230: // 'R0'
- readResTypeList(rtRoom, MKID('ROOM'), "room");
- break;
+ _numGlobalObjects = _fileHandle->readUint16LE();
+ _fileHandle->seek(_numGlobalObjects * 4, SEEK_CUR);
+ _numRooms = _fileHandle->readByte();
+ _fileHandle->seek(_numRooms * 3, SEEK_CUR);
+ _numCostumes = _fileHandle->readByte();
+ _fileHandle->seek(_numCostumes * 3, SEEK_CUR);
+ _numScripts = _fileHandle->readByte();
+ _fileHandle->seek(_numScripts * 3, SEEK_CUR);
+ _numSounds = _fileHandle->readByte();
- case 0x5330: // 'S0'
- readResTypeList(rtScript, MKID('SCRP'), "script");
- break;
+ _fileHandle->clearIOFailed();
+ _fileHandle->seek(0, SEEK_SET);
- case 0x4E30: // 'N0'
- readResTypeList(rtSound, MKID('SOUN'), "sound");
- break;
+ readMAXS();
- case 0x4330: // 'C0'
- readResTypeList(rtCostume, MKID('COST'), "costume");
- break;
+ // Jamieson630: palManipulate variable initialization
+ _palManipCounter = 0;
+ _palManipPalette = 0; // Will allocate when needed
+ _palManipIntermediatePal = 0; // Will allocate when needed
- case 0x4F30: // 'O0'
- readGlobalObjects();
- break;
+ _fileHandle->readUint16LE(); /* version magic number */
+ readGlobalObjects();
+ readResTypeList(rtRoom, MKID('ROOM'), "room");
+ readResTypeList(rtCostume, MKID('COST'), "costume");
+ readResTypeList(rtScript, MKID('SCRP'), "script");
+ readResTypeList(rtSound, MKID('SOUN'), "sound");
- default:
- // FIXME: this is a little hack because Indy3 FM-TOWNS has
- // 32 extra bytes of unknown meaning appended to 00.LFL
- if (!(_gameId == GID_INDY3 && _features & GF_FMTOWNS))
- error("Bad ID %c%c found in directory!", blocktype & 0xFF, blocktype >> 8);
- return;
- }
- }
- closeRoom();
- }
+ closeRoom();
}
void ScummEngine_v3::loadCharset(int no) {
@@ -191,40 +94,4 @@
file.close();
}
-void ScummEngine_v3::readMAXS() {
- // 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 = 50;
- _objectRoomTable = NULL;
- _numCharsets = 9; // 9
- _numInventory = 80; // 80
- _numGlobalScripts = 200;
- _numFlObject = 50;
-
- _shadowPaletteSize = 256;
-
- _shadowPalette = (byte *) calloc(_shadowPaletteSize, 1); // FIXME - needs to be removed later
- allocateArrays();
-}
-
-void ScummEngine_v3::readGlobalObjects() {
- int num = _fileHandle->readUint16LE();
- assert(num == _numGlobalObjects);
- for (int i = 0; i != num; i++) {
- uint32 bits = _fileHandle->readByte();
- byte tmp;
- bits |= _fileHandle->readByte() << 8;
- bits |= _fileHandle->readByte() << 16;
- _classData[i] = bits;
- tmp = _fileHandle->readByte();
- _objectOwnerTable[i] = tmp & OF_OWNER_MASK;
- _objectStateTable[i] = tmp >> OF_STATE_SHL;
- }
-}
-
} // End of namespace Scumm
Index: resource_v4.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource_v4.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- resource_v4.cpp 30 Mar 2005 21:58:06 -0000 1.11
+++ resource_v4.cpp 3 Apr 2005 15:06:08 -0000 1.12
@@ -23,9 +23,106 @@
#include "stdafx.h"
#include "scumm/scumm.h"
#include "scumm/intern.h"
+#include "scumm/resource.h"
namespace Scumm {
+void ScummEngine_v4::readIndexFile() {
+ uint16 blocktype;
+ uint32 itemsize;
+ int numblock = 0;
+
+ debug(9, "readIndexFile()");
+
+ closeRoom();
+ openRoom(0);
+
+ while (!_fileHandle->eof()) {
+ itemsize = _fileHandle->readUint32LE();
+ blocktype = _fileHandle->readUint16LE();
+ if (_fileHandle->ioFailed())
+ break;
+
+ switch (blocktype) {
+ case 0x4E52: // 'NR'
+ _fileHandle->readUint16LE();
+ break;
+ case 0x5230: // 'R0'
+ _numRooms = _fileHandle->readUint16LE();
+ break;
+ case 0x5330: // 'S0'
+ _numScripts = _fileHandle->readUint16LE();
+ break;
+ case 0x4E30: // 'N0'
+ _numSounds = _fileHandle->readUint16LE();
+ break;
+ case 0x4330: // 'C0'
+ _numCostumes = _fileHandle->readUint16LE();
+ break;
+ case 0x4F30: // 'O0'
+ _numGlobalObjects = _fileHandle->readUint16LE();
+ break;
+ }
+ _fileHandle->seek(itemsize - 8, SEEK_CUR);
+ }
+
+ _fileHandle->clearIOFailed();
+ _fileHandle->seek(0, SEEK_SET);
+
+ readMAXS();
+
+ // Jamieson630: palManipulate variable initialization
+ _palManipCounter = 0;
+ _palManipPalette = 0; // Will allocate when needed
+ _palManipIntermediatePal = 0; // Will allocate when needed
+
+ while (1) {
+ itemsize = _fileHandle->readUint32LE();
+
+ if (_fileHandle->ioFailed())
+ break;
+
+ blocktype = _fileHandle->readUint16LE();
+
+ numblock++;
+
+ switch (blocktype) {
+
+ case 0x4E52: // 'NR'
+ _fileHandle->seek(itemsize - 6, SEEK_CUR);
+ break;
+
+ case 0x5230: // 'R0'
+ readResTypeList(rtRoom, MKID('ROOM'), "room");
+ break;
+
+ case 0x5330: // 'S0'
+ readResTypeList(rtScript, MKID('SCRP'), "script");
+ break;
+
+ case 0x4E30: // 'N0'
+ readResTypeList(rtSound, MKID('SOUN'), "sound");
+ break;
+
+ case 0x4330: // 'C0'
+ readResTypeList(rtCostume, MKID('COST'), "costume");
+ break;
+
+ case 0x4F30: // 'O0'
+ readGlobalObjects();
+ break;
+
+ default:
+ // FIXME: this is a little hack because Indy3 FM-TOWNS has
+ // 32 extra bytes of unknown meaning appended to 00.LFL
+ if (!(_gameId == GID_INDY3 && _features & GF_FMTOWNS))
+ error("Bad ID %c%c found in directory!", blocktype & 0xFF, blocktype >> 8);
+ return;
+ }
+ }
+ closeRoom();
+}
+
void ScummEngine_v4::loadCharset(int no) {
uint32 size;
memset(_charsetData, 0, sizeof(_charsetData));
@@ -41,4 +138,40 @@
closeRoom();
}
+void ScummEngine_v4::readMAXS() {
+ // 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 = 50;
+ _objectRoomTable = NULL;
+ _numCharsets = 9; // 9
+ _numInventory = 80; // 80
+ _numGlobalScripts = 200;
+ _numFlObject = 50;
+
+ _shadowPaletteSize = 256;
+
+ _shadowPalette = (byte *) calloc(_shadowPaletteSize, 1); // FIXME - needs to be removed later
+ allocateArrays();
+}
+
+void ScummEngine_v4::readGlobalObjects() {
+ int num = _fileHandle->readUint16LE();
+ assert(num == _numGlobalObjects);
+ for (int i = 0; i != num; i++) {
+ uint32 bits = _fileHandle->readByte();
+ byte tmp;
+ bits |= _fileHandle->readByte() << 8;
+ bits |= _fileHandle->readByte() << 16;
+ _classData[i] = bits;
+ tmp = _fileHandle->readByte();
+ _objectOwnerTable[i] = tmp & OF_OWNER_MASK;
+ _objectStateTable[i] = tmp >> OF_STATE_SHL;
+ }
+}
+
} // End of namespace Scumm
Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.397
retrieving revision 1.398
diff -u -d -r1.397 -r1.398
--- scumm.cpp 2 Apr 2005 14:24:41 -0000 1.397
+++ scumm.cpp 3 Apr 2005 15:06:08 -0000 1.398
@@ -754,7 +754,7 @@
_numObjectsInRoom = 0;
_userPut = 0;
_userState = 0;
- _resourceHeaderSize = 0;
+ _resourceHeaderSize = 8;
_saveLoadFlag = 0;
_saveLoadSlot = 0;
_lastSaveTime = 0;
@@ -1198,6 +1198,24 @@
delete _debugger;
}
+ScummEngine_v4::ScummEngine_v4(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine_v5(detector, syst, gs, md5sum) {
+ _resourceHeaderSize = 6;
+}
+
+ScummEngine_v3::ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine_v4(detector, syst, gs, md5sum) {
+}
+
+ScummEngine_v3old::ScummEngine_v3old(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine_v3(detector, syst, gs, md5sum) {
+ _resourceHeaderSize = 4;
+}
+
+ScummEngine_v2::ScummEngine_v2(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
+ : ScummEngine_v3old(detector, syst, gs, md5sum) {
+}
+
ScummEngine_v6::ScummEngine_v6(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16])
: ScummEngine(detector, syst, gs, md5sum) {
VAR_VIDEONAME = 0xFF;
@@ -1346,13 +1364,6 @@
_bootParam = -1;
}
- if (_features & GF_OLD_BUNDLE)
- _resourceHeaderSize = 4;
- else if (_features & GF_SMALL_HEADER)
- _resourceHeaderSize = 6;
- else
- _resourceHeaderSize = 8;
-
readIndexFile();
scummInit();
@@ -2207,12 +2218,7 @@
initRoomSubBlocks();
- if (_features & GF_OLD_BUNDLE)
- loadRoomObjectsOldBundle();
- else if (_features & GF_SMALL_HEADER)
- loadRoomObjectsSmall();
- else
- loadRoomObjects();
+ loadRoomObjects();
if (VAR_ROOM_WIDTH != 0xFF && VAR_ROOM_HEIGHT != 0xFF) {
@@ -2297,33 +2303,12 @@
if (!roomptr || !roomResPtr)
error("Room %d: data not found (" __FILE__ ":%d)", _roomResource, __LINE__);
- // Reset room color for V1 zak
- if (_version == 1)
- _roomPalette[0] = 0;
-
//
// Determine the room dimensions (width/height)
//
- if (_features & GF_OLD_BUNDLE)
- rmhd = (const RoomHeader *)(roomptr + 4);
- else
- rmhd = (const RoomHeader *)findResourceData(MKID('RMHD'), roomptr);
+ rmhd = (const RoomHeader *)findResourceData(MKID('RMHD'), roomptr);
- if (_version == 1) {
- if (_features & GF_NES) {
- _roomWidth = READ_LE_UINT16(roomptr + 4) * 8;
-
- // HACK: To let our code work normal with narrow rooms we
- // adjust width. It will render garbage on right edge but we do
- // not render it anyway
- if (_roomWidth < 32 * 8)
- _roomWidth = 32 * 8;
- _roomHeight = READ_LE_UINT16(roomptr + 6) * 8;
- } else {
- _roomWidth = roomptr[4] * 8;
- _roomHeight = roomptr[5] * 8;
- }
- } else if (_version == 8) {
+ if (_version == 8) {
_roomWidth = READ_LE_UINT32(&(rmhd->v8.width));
_roomHeight = READ_LE_UINT32(&(rmhd->v8.height));
} else if (_version == 7) {
@@ -2337,11 +2322,7 @@
//
// Find the room image data
//
- if (_version == 1) {
- _IM00_offs = 0;
- } else if (_features & GF_OLD_BUNDLE) {
- _IM00_offs = READ_LE_UINT16(roomptr + 0x0A);
- } else if (_version == 8) {
+ if (_version == 8) {
_IM00_offs = getObjectImage(roomptr, 1) - roomptr;
} else if (_features & GF_SMALL_HEADER) {
_IM00_offs = findResourceData(MKID('IM00'), roomptr) - roomptr;
@@ -2356,44 +2337,20 @@
//
// Look for an exit script
//
- int EXCD_len = -1;
- if (_version <= 2) {
- _EXCD_offs = READ_LE_UINT16(roomptr + 0x18);
- EXCD_len = READ_LE_UINT16(roomptr + 0x1A) - _EXCD_offs + _resourceHeaderSize; // HACK
- } else if (_features & GF_OLD_BUNDLE) {
- _EXCD_offs = READ_LE_UINT16(roomptr + 0x19);
- EXCD_len = READ_LE_UINT16(roomptr + 0x1B) - _EXCD_offs + _resourceHeaderSize; // HACK
- } else {
- ptr = findResourceData(MKID('EXCD'), roomResPtr);
- if (ptr)
- _EXCD_offs = ptr - roomResPtr;
- }
+ ptr = findResourceData(MKID('EXCD'), roomResPtr);
+ if (ptr)
+ _EXCD_offs = ptr - roomResPtr;
if (_dumpScripts && _EXCD_offs)
- dumpResource("exit-", _roomResource, roomResPtr + _EXCD_offs - _resourceHeaderSize, EXCD_len);
+ dumpResource("exit-", _roomResource, roomResPtr + _EXCD_offs - _resourceHeaderSize, -1);
//
// Look for an entry script
//
- int ENCD_len = -1;
- if (_version <= 2) {
- _ENCD_offs = READ_LE_UINT16(roomptr + 0x1A);
- ENCD_len = READ_LE_UINT16(roomptr) - _ENCD_offs + _resourceHeaderSize; // HACK
- } else if (_features & GF_OLD_BUNDLE) {
- _ENCD_offs = READ_LE_UINT16(roomptr + 0x1B);
- // FIXME - the following is a hack which assumes that immediately after
- // the entry script the first local script follows.
- int num_objects = *(roomResPtr + 20);
- int num_sounds = *(roomResPtr + 23);
- int num_scripts = *(roomResPtr + 24);
- ptr = roomptr + 29 + num_objects * 4 + num_sounds + num_scripts;
- ENCD_len = READ_LE_UINT16(ptr + 1) - _ENCD_offs + _resourceHeaderSize; // HACK
- } else {
- ptr = findResourceData(MKID('ENCD'), roomResPtr);
- if (ptr)
- _ENCD_offs = ptr - roomResPtr;
- }
+ ptr = findResourceData(MKID('ENCD'), roomResPtr);
+ if (ptr)
+ _ENCD_offs = ptr - roomResPtr;
if (_dumpScripts && _ENCD_offs)
- dumpResource("entry-", _roomResource, roomResPtr + _ENCD_offs - _resourceHeaderSize, ENCD_len);
+ dumpResource("entry-", _roomResource, roomResPtr + _ENCD_offs - _resourceHeaderSize, -1);
//
// Load box data
@@ -2401,18 +2358,11 @@
res.nukeResource(rtMatrix, 1);
res.nukeResource(rtMatrix, 2);
if (_features & GF_SMALL_HEADER) {
- if (_version <= 2)
- ptr = roomptr + *(roomptr + 0x15);
- else if (_features & GF_OLD_BUNDLE)
- ptr = roomptr + READ_LE_UINT16(roomptr + 0x15);
- else
- ptr = findResourceData(MKID('BOXD'), roomptr);
+ ptr = findResourceData(MKID('BOXD'), roomptr);
if (ptr) {
byte numOfBoxes = *ptr;
int size;
- if (_version <= 2)
- size = numOfBoxes * SIZEOF_BOX_V2 + 1;
- else if (_version == 3)
+ if (_version == 3)
size = numOfBoxes * SIZEOF_BOX_V3 + 1;
else
size = numOfBoxes * SIZEOF_BOX + 1;
@@ -2420,14 +2370,8 @@
createResource(rtMatrix, 2, size);
memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
ptr += size;
- if (_version <= 2) {
- size = numOfBoxes * (numOfBoxes + 1);
- } else if (_features & GF_OLD_BUNDLE)
- // FIXME. This is an evil HACK!!!
- size = (READ_LE_UINT16(roomptr + 0x0A) - READ_LE_UINT16(roomptr + 0x15)) - size;
- else
- size = getResourceDataSize(ptr - size - _resourceHeaderSize) - size;
+ size = getResourceDataSize(ptr - size - _resourceHeaderSize) - size;
if (size > 0) { // do this :)
createResource(rtMatrix, 1, size);
memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
@@ -2460,10 +2404,7 @@
for (i = 1; i < res.num[rtScaleTable]; i++)
res.nukeResource(rtScaleTable, i);
- if (_features & GF_OLD_BUNDLE)
- ptr = 0;
- else
- ptr = findResourceData(MKID('SCAL'), roomptr);
+ ptr = findResourceData(MKID('SCAL'), roomptr);
if (ptr) {
int s1, s2, y1, y2;
if (_version == 8) {
@@ -2499,46 +2440,7 @@
memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
- if (_features & GF_OLD_BUNDLE) {
- int num_objects = *(roomResPtr + 20);
- int num_sounds;
- int num_scripts;
-
- if (_version <= 2) {
- num_sounds = *(roomResPtr + 22);
- num_scripts = *(roomResPtr + 23);
- ptr = roomptr + 28 + num_objects * 4;
- while (num_sounds--)
- loadResource(rtSound, *ptr++);
- while (num_scripts--)
- loadResource(rtScript, *ptr++);
- } else if (_version == 3) {
- num_sounds = *(roomResPtr + 23);
- num_scripts = *(roomResPtr + 24);
- ptr = roomptr + 29 + num_objects * 4 + num_sounds + num_scripts;
- while (*ptr) {
- int id = *ptr;
-
- _localScriptOffsets[id - _numGlobalScripts] = READ_LE_UINT16(ptr + 1);
- ptr += 3;
-
- if (_dumpScripts) {
- char buf[32];
- sprintf(buf, "room-%d-", _roomResource);
-
- // HACK: to determine the sizes of the local scripts, we assume that
- // a) their order in the data file is the same as in the index
- // b) the last script at the same time is the last item in the room "header"
- int len = - (int)_localScriptOffsets[id - _numGlobalScripts] + _resourceHeaderSize;
- if (*ptr)
- len += READ_LE_UINT16(ptr + 1);
- else
- len += READ_LE_UINT16(roomResPtr);
- dumpResource(buf, id, roomResPtr + _localScriptOffsets[id - _numGlobalScripts] - _resourceHeaderSize, len);
- }
- }
- }
- } else if (_features & GF_SMALL_HEADER) {
+ if (_features & GF_SMALL_HEADER) {
ResourceIterator localScriptIterator(searchptr, true);
while ((ptr = localScriptIterator.findNext(MKID('LSCR'))) != NULL) {
int id = 0;
@@ -2617,14 +2519,9 @@
}
// Locate the EGA palette (currently unused).
- if (_features & GF_OLD_BUNDLE)
- ptr = 0;
- else
- ptr = findResourceData(MKID('EPAL'), roomptr);
-
- if (ptr) {
+ ptr = findResourceData(MKID('EPAL'), roomptr);
+ if (ptr)
_EPAL_offs = ptr - roomptr;
- }
// Locate the standard room palette (for V3-V5 games).
// TODO: We used to use findResourceSmall instead of findResourceData;
@@ -2637,10 +2534,7 @@
//
// Of course this would break savegame compatibility unless extra code
// were added to the save/load system to cope with this.
- if (_features & GF_OLD_BUNDLE)
- ptr = 0;
- else
- ptr = findResourceData(MKID('CLUT'), roomptr);
+ ptr = findResourceData(MKID('CLUT'), roomptr);
if (ptr) {
if ((_features & GF_SMALL_HEADER) && ptr)
@@ -2668,8 +2562,6 @@
// Transparent color
if (_version == 8)
gdi._transparentColor = (byte)READ_LE_UINT32(&(rmhd->v8.transparency));
- else if (_features & GF_OLD_BUNDLE)
- gdi._transparentColor = 255;
else {
ptr = findResourceData(MKID('TRNS'), roomptr);
if (ptr)
@@ -2704,6 +2596,193 @@
initBGBuffers(_roomHeight);
}
+void ScummEngine_v3old::initRoomSubBlocks() {
+ int i;
+ const byte *ptr;
+ byte *roomptr, *searchptr = 0;
+ const RoomHeader *rmhd;
+
+ _ENCD_offs = 0;
+ _EXCD_offs = 0;
+ _EPAL_offs = 0;
+ _CLUT_offs = 0;
+ _PALS_offs = 0;
+
+ memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags));
+
+ // Determine the room and room script base address
+ roomptr = getResourceAddress(rtRoom, _roomResource);
+ if (!roomptr)
+ error("Room %d: data not found (" __FILE__ ":%d)", _roomResource, __LINE__);
+
+ // Reset room color for V1 zak
+ if (_version == 1)
+ _roomPalette[0] = 0;
+
+ //
+ // Determine the room dimensions (width/height)
+ //
+ rmhd = (const RoomHeader *)(roomptr + 4);
+
+ if (_version == 1) {
+ if (_features & GF_NES) {
+ _roomWidth = READ_LE_UINT16(roomptr + 4) * 8;
+
+ // HACK: To let our code work normal with narrow rooms we
+ // adjust width. It will render garbage on right edge but we do
+ // not render it anyway
+ if (_roomWidth < 32 * 8)
+ _roomWidth = 32 * 8;
+ _roomHeight = READ_LE_UINT16(roomptr + 6) * 8;
+ } else {
+ _roomWidth = roomptr[4] * 8;
+ _roomHeight = roomptr[5] * 8;
+ }
+ } else {
+ _roomWidth = READ_LE_UINT16(&(rmhd->old.width));
+ _roomHeight = READ_LE_UINT16(&(rmhd->old.height));
+ }
+
+ //
+ // Find the room image data
+ //
+ if (_version == 1) {
+ _IM00_offs = 0;
+ } else {
+ _IM00_offs = READ_LE_UINT16(roomptr + 0x0A);
+ }
+ gdi.roomChanged(roomptr, _IM00_offs);
+
+ //
+ // Look for an exit script
+ //
+ int EXCD_len = -1;
+ if (_version <= 2) {
+ _EXCD_offs = READ_LE_UINT16(roomptr + 0x18);
+ EXCD_len = READ_LE_UINT16(roomptr + 0x1A) - _EXCD_offs + _resourceHeaderSize; // HACK
+ } else {
+ _EXCD_offs = READ_LE_UINT16(roomptr + 0x19);
+ EXCD_len = READ_LE_UINT16(roomptr + 0x1B) - _EXCD_offs + _resourceHeaderSize; // HACK
+ }
+ if (_dumpScripts && _EXCD_offs)
+ dumpResource("exit-", _roomResource, roomptr + _EXCD_offs - _resourceHeaderSize, EXCD_len);
+
+ //
+ // Look for an entry script
+ //
+ int ENCD_len = -1;
+ if (_version <= 2) {
+ _ENCD_offs = READ_LE_UINT16(roomptr + 0x1A);
+ ENCD_len = READ_LE_UINT16(roomptr) - _ENCD_offs + _resourceHeaderSize; // HACK
+ } else {
+ _ENCD_offs = READ_LE_UINT16(roomptr + 0x1B);
+ // FIXME - the following is a hack which assumes that immediately after
+ // the entry script the first local script follows.
+ int num_objects = *(roomptr + 20);
+ int num_sounds = *(roomptr + 23);
+ int num_scripts = *(roomptr + 24);
+ ptr = roomptr + 29 + num_objects * 4 + num_sounds + num_scripts;
+ ENCD_len = READ_LE_UINT16(ptr + 1) - _ENCD_offs + _resourceHeaderSize; // HACK
+ }
+ if (_dumpScripts && _ENCD_offs)
+ dumpResource("entry-", _roomResource, roomptr + _ENCD_offs - _resourceHeaderSize, ENCD_len);
+
+ //
+ // Load box data
+ //
+ res.nukeResource(rtMatrix, 1);
+ res.nukeResource(rtMatrix, 2);
+
+ if (_version <= 2)
+ ptr = roomptr + *(roomptr + 0x15);
+ else
+ ptr = roomptr + READ_LE_UINT16(roomptr + 0x15);
+ if (ptr) {
+ byte numOfBoxes = *ptr;
+ int size;
+ if (_version <= 2)
+ size = numOfBoxes * SIZEOF_BOX_V2 + 1;
+ else
+ size = numOfBoxes * SIZEOF_BOX_V3 + 1;
+
+ createResource(rtMatrix, 2, size);
+ memcpy(getResourceAddress(rtMatrix, 2), ptr, size);
+ ptr += size;
+ if (_version <= 2) {
+ size = numOfBoxes * (numOfBoxes + 1);
+ } else {
+ // FIXME. This is an evil HACK!!!
+ size = (READ_LE_UINT16(roomptr + 0x0A) - READ_LE_UINT16(roomptr + 0x15)) - size;
+ }
+
+ if (size > 0) { // do this :)
+ createResource(rtMatrix, 1, size);
+ memcpy(getResourceAddress(rtMatrix, 1), ptr, size);
+ }
+
+ }
+
+ //
+ // No scale data in old bundle games
+ //
+ for (i = 1; i < res.num[rtScaleTable]; i++)
+ res.nukeResource(rtScaleTable, i);
+
+ //
+ // Setup local scripts
+ //
+
+ // Determine the room script base address
+ roomptr = getResourceAddress(rtRoom, _roomResource);
+ searchptr = roomptr;
+
+ memset(_localScriptOffsets, 0, sizeof(_localScriptOffsets));
+
+ int num_objects = *(roomptr + 20);
+ int num_sounds;
+ int num_scripts;
+
+ if (_version <= 2) {
+ num_sounds = *(roomptr + 22);
+ num_scripts = *(roomptr + 23);
+ ptr = roomptr + 28 + num_objects * 4;
+ while (num_sounds--)
+ loadResource(rtSound, *ptr++);
+ while (num_scripts--)
+ loadResource(rtScript, *ptr++);
+ } else /* if (_version == 3) */ {
+ num_sounds = *(roomptr + 23);
+ num_scripts = *(roomptr + 24);
+ ptr = roomptr + 29 + num_objects * 4 + num_sounds + num_scripts;
+ while (*ptr) {
+ int id = *ptr;
+
+ _localScriptOffsets[id - _numGlobalScripts] = READ_LE_UINT16(ptr + 1);
+ ptr += 3;
+
+ if (_dumpScripts) {
+ char buf[32];
+ sprintf(buf, "room-%d-", _roomResource);
+
+ // HACK: to determine the sizes of the local scripts, we assume that
+ // a) their order in the data file is the same as in the index
+ // b) the last script at the same time is the last item in the room "header"
+ int len = - (int)_localScriptOffsets[id - _numGlobalScripts] + _resourceHeaderSize;
+ if (*ptr)
+ len += READ_LE_UINT16(ptr + 1);
+ else
+ len += READ_LE_UINT16(roomptr);
+ dumpResource(buf, id, roomptr + _localScriptOffsets[id - _numGlobalScripts] - _resourceHeaderSize, len);
+ }
+ }
+ }
+
+ // Transparent color
+ gdi._transparentColor = 255;
+
+ initBGBuffers(_roomHeight);
+}
+
void ScummEngine::pauseGame() {
pauseDialog();
}
@@ -3193,7 +3272,10 @@
engine = new ScummEngine_v2(detector, syst, game, md5sum);
break;
case 3:
- engine = new ScummEngine_v3(detector, syst, game, md5sum);
+ if (game.features & GF_OLD_BUNDLE)
+ engine = new ScummEngine_v3old(detector, syst, game, md5sum);
+ else
+ engine = new ScummEngine_v3(detector, syst, game, md5sum);
break;
case 4:
engine = new ScummEngine_v4(detector, syst, game, md5sum);
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.557
retrieving revision 1.558
diff -u -d -r1.557 -r1.558
--- scumm.h 2 Apr 2005 14:24:41 -0000 1.557
+++ scumm.h 3 Apr 2005 15:06:08 -0000 1.558
@@ -689,11 +689,9 @@
void convertADResource(int type, int index, byte *ptr, int size);
int readSoundResourceSmallHeader(int type, int index);
bool isResourceInUse(int type, int i) const;
- void initRoomSubBlocks();
+ virtual void initRoomSubBlocks();
void clearRoomObjects();
- void loadRoomObjects();
- void loadRoomObjectsSmall();
- void loadRoomObjectsOldBundle();
+ virtual void loadRoomObjects();
virtual void readArrayFromIndexFile();
virtual void readMAXS(int blockSize);
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v100he.cpp,2.109,2.110
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga isomap.cpp,1.42,1.43 isomap.h,1.18,1.19 music.cpp,1.49,1.50 objectmap.cpp,1.39,1.40 render.cpp,1.52,1.53 saga.cpp,1.102,1.103 script.cpp,1.62,1.63 sfuncs.cpp,1.95,1.96 sthread.cpp,1.75,1.76
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list