mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-29 14:42:26 +00:00
SCUMM: Move _heV7RoomIntOffsets from ScummEngine to ScummEngine_v70he
This commit is contained in:
parent
827561911a
commit
7ce3719587
@ -115,6 +115,7 @@ protected:
|
||||
|
||||
byte *_heV7DiskOffsets;
|
||||
byte *_heV7RoomOffsets;
|
||||
uint32 *_heV7RoomIntOffsets;
|
||||
|
||||
int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags, _heSndSoundFreq;
|
||||
|
||||
@ -130,6 +131,9 @@ public:
|
||||
void restoreBackgroundHE(Common::Rect rect, int dirtybit = 0);
|
||||
|
||||
protected:
|
||||
virtual void allocateArrays();
|
||||
virtual int readResTypeList(int id);
|
||||
virtual uint32 getResourceRoomOffset(int type, int idx);
|
||||
virtual void setupOpcodes();
|
||||
|
||||
virtual void setupScummVars();
|
||||
|
@ -46,7 +46,7 @@ Sprite::~Sprite() {
|
||||
}
|
||||
|
||||
void ScummEngine_v90he::allocateArrays() {
|
||||
ScummEngine::allocateArrays();
|
||||
ScummEngine_v70he::allocateArrays();
|
||||
_sprite->allocTables(_numSprites, MAX(64, _numSprites / 4), 64);
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,6 @@ void ScummEngine::deleteRoomOffsets() {
|
||||
|
||||
/** Read room offsets */
|
||||
void ScummEngine::readRoomsOffsets() {
|
||||
int num, room;
|
||||
|
||||
debug(9, "readRoomOffsets()");
|
||||
|
||||
if (_game.features & GF_SMALL_HEADER) {
|
||||
@ -177,13 +175,12 @@ void ScummEngine::readRoomsOffsets() {
|
||||
_fileHandle->seek(16, SEEK_SET);
|
||||
}
|
||||
|
||||
num = _fileHandle->readByte();
|
||||
int num = _fileHandle->readByte();
|
||||
while (num--) {
|
||||
room = _fileHandle->readByte();
|
||||
int room = _fileHandle->readByte();
|
||||
int offset = _fileHandle->readUint32LE();
|
||||
if (_res->roomoffs[rtRoom][room] != RES_INVALID_OFFSET) {
|
||||
_res->roomoffs[rtRoom][room] = _fileHandle->readUint32LE();
|
||||
} else {
|
||||
_fileHandle->readUint32LE();
|
||||
_res->roomoffs[rtRoom][room] = offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -491,7 +488,7 @@ void ScummEngine::readArrayFromIndexFile() {
|
||||
error("readArrayFromIndexFile() not supported in pre-V6 games");
|
||||
}
|
||||
|
||||
void ScummEngine::readResTypeList(int id) {
|
||||
int ScummEngine::readResTypeList(int id) {
|
||||
int num;
|
||||
int i;
|
||||
|
||||
@ -511,16 +508,27 @@ void ScummEngine::readResTypeList(int id) {
|
||||
}
|
||||
for (i = 0; i < num; i++) {
|
||||
_res->roomoffs[id][i] = _fileHandle->readUint32LE();
|
||||
|
||||
if (id == rtRoom && _game.heversion >= 70)
|
||||
_heV7RoomIntOffsets[i] = _res->roomoffs[id][i];
|
||||
}
|
||||
|
||||
if (_game.heversion >= 70) {
|
||||
return num;
|
||||
}
|
||||
|
||||
int ScummEngine_v70he::readResTypeList(int id) {
|
||||
int num;
|
||||
int i;
|
||||
|
||||
num = ScummEngine::readResTypeList(id);
|
||||
|
||||
if (id == rtRoom)
|
||||
for (i = 0; i < num; i++) {
|
||||
_res->globsize[id][i] = _fileHandle->readUint32LE();
|
||||
_heV7RoomIntOffsets[i] = _res->roomoffs[rtRoom][i];
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
_res->globsize[id][i] = _fileHandle->readUint32LE();
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
void ResourceManager::allocResTypeData(int id, uint32 tag, int num_, const char *name_, int mode_) {
|
||||
@ -635,18 +643,9 @@ int ScummEngine::loadResource(int type, int idx) {
|
||||
if (roomNr == 0)
|
||||
roomNr = _roomResource;
|
||||
|
||||
if (type == rtRoom) {
|
||||
if (_game.version == 8)
|
||||
fileOffs = 8;
|
||||
else if (_game.heversion >= 70)
|
||||
fileOffs = _heV7RoomIntOffsets[idx];
|
||||
else
|
||||
fileOffs = 0;
|
||||
} else {
|
||||
fileOffs = _res->roomoffs[type][idx];
|
||||
if (fileOffs == RES_INVALID_OFFSET)
|
||||
return 0;
|
||||
}
|
||||
fileOffs = getResourceRoomOffset(type, idx);
|
||||
if (fileOffs == RES_INVALID_OFFSET)
|
||||
return 0;
|
||||
|
||||
openRoom(roomNr);
|
||||
|
||||
@ -691,13 +690,11 @@ int ScummEngine::loadResource(int type, int idx) {
|
||||
dumpResource("script-", idx, getResourceAddress(rtScript, idx));
|
||||
}
|
||||
|
||||
if (!_fileHandle->err() && !_fileHandle->eos()) {
|
||||
return 1;
|
||||
if (_fileHandle->err() || _fileHandle->eos()) {
|
||||
error("Cannot read resource");
|
||||
}
|
||||
|
||||
_res->nukeResource(type, idx);
|
||||
|
||||
error("Cannot read resource");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ScummEngine::getResourceRoomNr(int type, int idx) {
|
||||
@ -706,6 +703,20 @@ int ScummEngine::getResourceRoomNr(int type, int idx) {
|
||||
return _res->roomno[type][idx];
|
||||
}
|
||||
|
||||
uint32 ScummEngine::getResourceRoomOffset(int type, int idx) {
|
||||
if (type == rtRoom) {
|
||||
return (_game.version == 8) ? 8 : 0;
|
||||
}
|
||||
return _res->roomoffs[type][idx];
|
||||
}
|
||||
|
||||
uint32 ScummEngine_v70he::getResourceRoomOffset(int type, int idx) {
|
||||
if (type == rtRoom) {
|
||||
return _heV7RoomIntOffsets[idx];
|
||||
}
|
||||
return _res->roomoffs[type][idx];
|
||||
}
|
||||
|
||||
int ScummEngine::getResourceSize(int type, int idx) {
|
||||
byte *ptr = getResourceAddress(type, idx);
|
||||
assert(ptr);
|
||||
@ -1295,13 +1306,16 @@ void ScummEngine::allocateArrays() {
|
||||
_res->allocResTypeData(rtMatrix, 0, 10, "boxes", 0);
|
||||
_res->allocResTypeData(rtImage, MKID_BE('AWIZ'), _numImages, "images", 1);
|
||||
_res->allocResTypeData(rtTalkie, MKID_BE('TLKE'), _numTalkies, "talkie", 1);
|
||||
|
||||
if (_game.heversion >= 70) {
|
||||
_res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
|
||||
_heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
|
||||
}
|
||||
}
|
||||
|
||||
void ScummEngine_v70he::allocateArrays() {
|
||||
ScummEngine::allocateArrays();
|
||||
|
||||
_res->allocResTypeData(rtSpoolBuffer, 0, 9, "spool buffer", 1);
|
||||
_heV7RoomIntOffsets = (uint32 *)calloc(_numRooms, sizeof(uint32));
|
||||
}
|
||||
|
||||
|
||||
void ScummEngine::dumpResource(const char *tag, int idx, const byte *ptr, int length) {
|
||||
char buf[256];
|
||||
Common::DumpFile out;
|
||||
|
@ -32,7 +32,7 @@ namespace Scumm {
|
||||
|
||||
extern const char *resTypeFromId(int id);
|
||||
|
||||
void ScummEngine_v3old::readResTypeList(int id) {
|
||||
int ScummEngine_v3old::readResTypeList(int id) {
|
||||
int num;
|
||||
int i;
|
||||
|
||||
@ -57,6 +57,8 @@ void ScummEngine_v3old::readResTypeList(int id) {
|
||||
if (_res->roomoffs[id][i] == 0xFFFF)
|
||||
_res->roomoffs[id][i] = (uint32)RES_INVALID_OFFSET;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
void ScummEngine_v3old::readIndexFile() {
|
||||
|
@ -33,7 +33,7 @@ namespace Scumm {
|
||||
|
||||
extern const char *resTypeFromId(int id);
|
||||
|
||||
void ScummEngine_v4::readResTypeList(int id) {
|
||||
int ScummEngine_v4::readResTypeList(int id) {
|
||||
int num;
|
||||
int i;
|
||||
|
||||
@ -49,6 +49,8 @@ void ScummEngine_v4::readResTypeList(int id) {
|
||||
_res->roomno[id][i] = _fileHandle->readByte();
|
||||
_res->roomoffs[id][i] = _fileHandle->readUint32LE();
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
void ScummEngine_v4::readIndexFile() {
|
||||
|
@ -201,7 +201,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
|
||||
_bootParam = 0;
|
||||
_dumpScripts = false;
|
||||
_debugMode = 0;
|
||||
_heV7RoomIntOffsets = NULL;
|
||||
_objectOwnerTable = NULL;
|
||||
_objectRoomTable = NULL;
|
||||
_objectStateTable = NULL;
|
||||
@ -789,6 +788,7 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
|
||||
|
||||
_heV7DiskOffsets = NULL;
|
||||
_heV7RoomOffsets = NULL;
|
||||
_heV7RoomIntOffsets = NULL;
|
||||
|
||||
_heSndSoundId = 0;
|
||||
_heSndOffset = 0;
|
||||
@ -805,8 +805,8 @@ ScummEngine_v70he::ScummEngine_v70he(OSystem *syst, const DetectorResult &dr)
|
||||
ScummEngine_v70he::~ScummEngine_v70he() {
|
||||
delete _resExtractor;
|
||||
free(_heV7DiskOffsets);
|
||||
free(_heV7RoomIntOffsets);
|
||||
free(_heV7RoomOffsets);
|
||||
free(_heV7RoomIntOffsets);
|
||||
free(_storedFlObjects);
|
||||
}
|
||||
|
||||
|
@ -773,7 +773,6 @@ public:
|
||||
protected:
|
||||
int _resourceHeaderSize;
|
||||
byte _resourceMapper[128];
|
||||
uint32 *_heV7RoomIntOffsets;
|
||||
const byte *_resourceLastSearchBuf; // FIXME: need to put it to savefile?
|
||||
uint32 _resourceLastSearchSize; // FIXME: need to put it to savefile?
|
||||
|
||||
@ -786,11 +785,13 @@ protected:
|
||||
bool openResourceFile(const Common::String &filename, byte encByte); // TODO: Use Common::String
|
||||
|
||||
void loadPtrToResource(int type, int i, const byte *ptr);
|
||||
virtual void readResTypeList(int id);
|
||||
virtual int readResTypeList(int id);
|
||||
// void allocResTypeData(int id, uint32 tag, int num, const char *name, int mode);
|
||||
// byte *createResource(int type, int index, uint32 size);
|
||||
int loadResource(int type, int i);
|
||||
// void nukeResource(int type, int i);
|
||||
int getResourceRoomNr(int type, int idx);
|
||||
virtual uint32 getResourceRoomOffset(int type, int idx);
|
||||
int getResourceSize(int type, int idx);
|
||||
|
||||
public:
|
||||
@ -798,7 +799,6 @@ public:
|
||||
virtual byte *getStringAddress(int i);
|
||||
byte *getStringAddressVar(int i);
|
||||
void ensureResourceLoaded(int type, int i);
|
||||
int getResourceRoomNr(int type, int index);
|
||||
|
||||
protected:
|
||||
int readSoundResource(int index);
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
ScummEngine_v3old(OSystem *syst, const DetectorResult &dr);
|
||||
|
||||
protected:
|
||||
virtual void readResTypeList(int id);
|
||||
virtual int readResTypeList(int id);
|
||||
virtual void readIndexFile();
|
||||
virtual void setupRoomSubBlocks();
|
||||
virtual void resetRoomSubBlocks();
|
||||
|
@ -59,7 +59,7 @@ protected:
|
||||
|
||||
virtual void scummLoop_handleSaveLoad();
|
||||
|
||||
virtual void readResTypeList(int id);
|
||||
virtual int readResTypeList(int id);
|
||||
virtual void readIndexFile();
|
||||
virtual void loadCharset(int no);
|
||||
virtual void resetRoomObjects();
|
||||
|
Loading…
x
Reference in New Issue
Block a user