diff options
-rw-r--r-- | common/file.cpp | 32 | ||||
-rw-r--r-- | common/file.h | 16 | ||||
-rw-r--r-- | scumm/bundle.cpp | 56 | ||||
-rw-r--r-- | scumm/resource.cpp | 186 | ||||
-rw-r--r-- | scumm/resource_v2.cpp | 8 | ||||
-rw-r--r-- | scumm/resource_v3.cpp | 24 | ||||
-rw-r--r-- | scumm/resource_v4.cpp | 2 | ||||
-rw-r--r-- | scumm/scumm.h | 4 | ||||
-rw-r--r-- | scumm/sound.cpp | 10 | ||||
-rw-r--r-- | simon/midi.cpp | 21 | ||||
-rw-r--r-- | simon/res.cpp | 38 | ||||
-rw-r--r-- | simon/simon.cpp | 98 |
12 files changed, 248 insertions, 247 deletions
diff --git a/common/file.cpp b/common/file.cpp index 7812d1f067..c2459abb56 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -221,27 +221,27 @@ byte File::readByte() { return b ^ _encbyte; } -uint16 File::readWordLE() { +uint16 File::readUint16LE() { uint16 a = readByte(); uint16 b = readByte(); return a | (b << 8); } -uint32 File::readDwordLE() { - uint32 a = readWordLE(); - uint32 b = readWordLE(); +uint32 File::readUint32LE() { + uint32 a = readUint16LE(); + uint32 b = readUint16LE(); return (b << 16) | a; } -uint16 File::readWordBE() { +uint16 File::readUint16BE() { uint16 b = readByte(); uint16 a = readByte(); return a | (b << 8); } -uint32 File::readDwordBE() { - uint32 b = readWordBE(); - uint32 a = readWordBE(); +uint32 File::readUint32BE() { + uint32 b = readUint16BE(); + uint32 a = readUint16BE(); return (b << 16) | a; } @@ -280,22 +280,22 @@ void File::writeByte(byte value) { } } -void File::writeWordLE(uint16 value) { +void File::writeUint16LE(uint16 value) { writeByte((byte)(value & 0xff)); writeByte((byte)(value >> 8)); } -void File::writeDwordLE(uint32 value) { - writeWordLE((uint16)(value & 0xffff)); - writeWordLE((uint16)(value >> 16)); +void File::writeUint32LE(uint32 value) { + writeUint16LE((uint16)(value & 0xffff)); + writeUint16LE((uint16)(value >> 16)); } -void File::writeWordBE(uint16 value) { +void File::writeUint16BE(uint16 value) { writeByte((byte)(value >> 8)); writeByte((byte)(value & 0xff)); } -void File::writeDwordBE(uint32 value) { - writeWordBE((uint16)(value >> 16)); - writeWordBE((uint16)(value & 0xffff)); +void File::writeUint32BE(uint32 value) { + writeUint16BE((uint16)(value >> 16)); + writeUint16BE((uint16)(value & 0xffff)); } diff --git a/common/file.h b/common/file.h index e6a7b1505d..efa61f7f66 100644 --- a/common/file.h +++ b/common/file.h @@ -54,16 +54,16 @@ public: void seek(int32 offs, int whence); uint32 read(void *ptr, uint32 size); byte readByte(); - uint16 readWordLE(); - uint32 readDwordLE(); - uint16 readWordBE(); - uint32 readDwordBE(); + uint16 readUint16LE(); + uint32 readUint32LE(); + uint16 readUint16BE(); + uint32 readUint32BE(); uint32 write(void *ptr, uint32 size); void writeByte(byte value); - void writeWordLE(uint16 value); - void writeDwordLE(uint32 value); - void writeWordBE(uint16 value); - void writeDwordBE(uint32 value); + void writeUint16LE(uint16 value); + void writeUint32LE(uint32 value); + void writeUint16BE(uint16 value); + void writeUint32BE(uint32 value); }; #endif diff --git a/scumm/bundle.cpp b/scumm/bundle.cpp index c5ec9344e0..72a5238108 100644 --- a/scumm/bundle.cpp +++ b/scumm/bundle.cpp @@ -42,9 +42,9 @@ bool Bundle::openVoiceFile(const char *filename, const char *directory) { return false; } - tag = _voiceFile.readDwordBE(); - offset = _voiceFile.readDwordBE(); - _numVoiceFiles = _voiceFile.readDwordBE(); + tag = _voiceFile.readUint32BE(); + offset = _voiceFile.readUint32BE(); + _numVoiceFiles = _voiceFile.readUint32BE(); _bundleVoiceTable = (BundleAudioTable *) malloc(_numVoiceFiles * sizeof(BundleAudioTable)); @@ -64,8 +64,8 @@ bool Bundle::openVoiceFile(const char *filename, const char *directory) { name[z++] = c; name[z] = '\0'; strcpy(_bundleVoiceTable[i].filename, name); - _bundleVoiceTable[i].offset = _voiceFile.readDwordBE(); - _bundleVoiceTable[i].size = _voiceFile.readDwordBE(); + _bundleVoiceTable[i].offset = _voiceFile.readUint32BE(); + _bundleVoiceTable[i].size = _voiceFile.readUint32BE(); } return true; @@ -82,9 +82,9 @@ bool Bundle::openMusicFile(const char *filename, const char *directory) { return false; } - tag = _musicFile.readDwordBE(); - offset = _musicFile.readDwordBE(); - _numMusicFiles = _musicFile.readDwordBE(); + tag = _musicFile.readUint32BE(); + offset = _musicFile.readUint32BE(); + _numMusicFiles = _musicFile.readUint32BE(); _bundleMusicTable = (BundleAudioTable *) malloc(_numMusicFiles * sizeof(BundleAudioTable)); @@ -104,8 +104,8 @@ bool Bundle::openMusicFile(const char *filename, const char *directory) { name[z++] = c; name[z] = '\0'; strcpy(_bundleMusicTable[i].filename, name); - _bundleMusicTable[i].offset = _musicFile.readDwordBE(); - _bundleMusicTable[i].size = _musicFile.readDwordBE(); + _bundleMusicTable[i].offset = _musicFile.readUint32BE(); + _bundleMusicTable[i].size = _musicFile.readUint32BE(); } return true; @@ -121,10 +121,10 @@ int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final) { } _voiceFile.seek(_bundleVoiceTable[index].offset, SEEK_SET); - tag = _voiceFile.readDwordBE(); - num = _voiceFile.readDwordBE(); - _voiceFile.readDwordBE(); - _voiceFile.readDwordBE(); + tag = _voiceFile.readUint32BE(); + num = _voiceFile.readUint32BE(); + _voiceFile.readUint32BE(); + _voiceFile.readUint32BE(); if (tag != MKID_BE('COMP')) { warning("Bundle: Compressed sound %d invalid (%c%c%c%c)", index, tag >> 24, tag >> 16, tag >> 8, @@ -133,10 +133,10 @@ int32 Bundle::decompressVoiceSampleByIndex(int32 index, byte *comp_final) { } for (i = 0; i < num; i++) { - _compVoiceTable[i].offset = _voiceFile.readDwordBE(); - _compVoiceTable[i].size = _voiceFile.readDwordBE(); - _compVoiceTable[i].codec = _voiceFile.readDwordBE(); - _voiceFile.readDwordBE(); + _compVoiceTable[i].offset = _voiceFile.readUint32BE(); + _compVoiceTable[i].size = _voiceFile.readUint32BE(); + _compVoiceTable[i].codec = _voiceFile.readUint32BE(); + _voiceFile.readUint32BE(); } final_size = 0; @@ -171,10 +171,10 @@ int32 Bundle::decompressMusicSampleByIndex(int32 index, int32 number, byte *comp if (_lastSong != index) { _musicFile.seek(_bundleMusicTable[index].offset, SEEK_SET); - tag = _musicFile.readDwordBE(); - num = _musicFile.readDwordBE(); - _musicFile.readDwordBE(); - _musicFile.readDwordBE(); + tag = _musicFile.readUint32BE(); + num = _musicFile.readUint32BE(); + _musicFile.readUint32BE(); + _musicFile.readUint32BE(); if (tag != MKID_BE('COMP')) { warning("Bundle: Compressed sound %d invalid (%c%c%c%c)", index, tag >> 24, tag >> 16, tag >> 8, @@ -183,10 +183,10 @@ int32 Bundle::decompressMusicSampleByIndex(int32 index, int32 number, byte *comp } for (i = 0; i < num; i++) { - _compMusicTable[i].offset = _musicFile.readDwordBE(); - _compMusicTable[i].size = _musicFile.readDwordBE(); - _compMusicTable[i].codec = _musicFile.readDwordBE(); - _musicFile.readDwordBE(); + _compMusicTable[i].offset = _musicFile.readUint32BE(); + _compMusicTable[i].size = _musicFile.readUint32BE(); + _compMusicTable[i].codec = _musicFile.readUint32BE(); + _musicFile.readUint32BE(); } } @@ -250,8 +250,8 @@ int32 Bundle::getNumberOfMusicSamplesByIndex(int32 index) { } _musicFile.seek(_bundleMusicTable[index].offset, SEEK_SET); - _musicFile.readDwordBE(); - return _musicFile.readDwordBE(); + _musicFile.readUint32BE(); + return _musicFile.readUint32BE(); } int32 Bundle::getNumberOfMusicSamplesByName(char *name) { diff --git a/scumm/resource.cpp b/scumm/resource.cpp index adfca29156..1edbcd8b05 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -168,9 +168,9 @@ void Scumm::readRoomsOffsets() room = _fileHandle.readByte(); if (_roomFileOffsets[room] != 0xFFFFFFFF) { - _roomFileOffsets[room] = _fileHandle.readDwordLE(); + _roomFileOffsets[room] = _fileHandle.readUint32LE(); } else { - _fileHandle.readDwordLE(); + _fileHandle.readUint32LE(); } } } @@ -211,31 +211,31 @@ void Scumm::readIndexFile() /* Figure out the sizes of various resources */ while (!_fileHandle.eof()) { blocktype = fileReadDword(); - itemsize = _fileHandle.readDwordBE(); + itemsize = _fileHandle.readUint32BE(); if (_fileHandle.ioFailed()) break; switch (blocktype) { case MKID('DOBJ'): - _numGlobalObjects = _fileHandle.readWordLE(); + _numGlobalObjects = _fileHandle.readUint16LE(); itemsize -= 2; break; case MKID('DROO'): - _numRooms = _fileHandle.readWordLE(); + _numRooms = _fileHandle.readUint16LE(); itemsize -= 2; break; case MKID('DSCR'): - _numScripts = _fileHandle.readWordLE(); + _numScripts = _fileHandle.readUint16LE(); itemsize -= 2; break; case MKID('DCOS'): - _numCostumes = _fileHandle.readWordLE(); + _numCostumes = _fileHandle.readUint16LE(); itemsize -= 2; break; case MKID('DSOU'): - _numSounds = _fileHandle.readWordLE(); + _numSounds = _fileHandle.readUint16LE(); itemsize -= 2; break; } @@ -250,7 +250,7 @@ void Scumm::readIndexFile() if (_fileHandle.ioFailed()) break; - itemsize = _fileHandle.readDwordBE(); + itemsize = _fileHandle.readUint32BE(); numblock++; @@ -261,9 +261,9 @@ void Scumm::readIndexFile() case MKID('DOBJ'): if (_features & GF_AFTER_V8) - num = _fileHandle.readDwordLE(); + num = _fileHandle.readUint32LE(); else - num = _fileHandle.readWordLE(); + num = _fileHandle.readUint16LE(); assert(num == _numGlobalObjects); if (_features & GF_AFTER_V8) { /* FIXME: Not sure.. */ @@ -271,7 +271,7 @@ void Scumm::readIndexFile() _fileHandle.seek(40, SEEK_CUR); _objectStateTable[i] = _fileHandle.readByte(); _objectRoomTable[i] = _fileHandle.readByte(); - _classData[i] = _fileHandle.readDwordLE(); + _classData[i] = _fileHandle.readUint32LE(); } memset(_objectOwnerTable, 0xFF, num); } else if (_features & GF_AFTER_V7) { @@ -302,7 +302,7 @@ void Scumm::readIndexFile() break; case MKID('ANAM'): - _numAudioNames = _fileHandle.readWordLE(); + _numAudioNames = _fileHandle.readUint16LE(); _audioNames = (char*)malloc(_numAudioNames * 9); _fileHandle.read(_audioNames, _numAudioNames * 9); break; @@ -353,10 +353,10 @@ void Scumm::readArrayFromIndexFile() int num; int a, b, c; - while ((num = _fileHandle.readWordLE()) != 0) { - a = _fileHandle.readWordLE(); - b = _fileHandle.readWordLE(); - c = _fileHandle.readWordLE(); + while ((num = _fileHandle.readUint16LE()) != 0) { + a = _fileHandle.readUint16LE(); + b = _fileHandle.readUint16LE(); + c = _fileHandle.readUint16LE(); if (c == 1) defineArray(num, 1, a, b); else @@ -372,9 +372,9 @@ void Scumm::readResTypeList(int id, uint32 tag, const char *name) debug(9, "readResTypeList(%s,%x,%s)", resTypeFromId(id), FROM_LE_32(tag), name); if (_features & GF_AFTER_V8) - num = _fileHandle.readDwordLE(); + num = _fileHandle.readUint32LE(); else if (!(_features & GF_OLD_BUNDLE)) - num = _fileHandle.readWordLE(); + num = _fileHandle.readUint16LE(); else num = _fileHandle.readByte(); @@ -399,7 +399,7 @@ void Scumm::readResTypeList(int id, uint32 tag, const char *name) res.roomno[id][i] = _fileHandle.readByte(); } for (i = 0; i < num; i++) - res.roomoffs[id][i] = _fileHandle.readWordLE(); + res.roomoffs[id][i] = _fileHandle.readUint16LE(); } else if (_features & GF_SMALL_HEADER) { for (i = 0; i < num; i++) { res.roomno[id][i] = _fileHandle.readByte(); @@ -526,20 +526,20 @@ int Scumm::loadResource(int type, int idx) _fileHandle.seek(fileOffs + _fileOffset, SEEK_SET); if (_features & GF_OLD_BUNDLE) { - size = _fileHandle.readWordLE(); + size = _fileHandle.readUint16LE(); } else if (_features & GF_SMALL_HEADER) { if (!(_features & GF_SMALL_NAMES)) _fileHandle.seek(8, SEEK_CUR); - size = _fileHandle.readDwordLE(); - tag = _fileHandle.readWordLE(); + size = _fileHandle.readUint32LE(); + tag = _fileHandle.readUint16LE(); _fileHandle.seek(-6, SEEK_CUR); /* FIXME */ if ((type == rtSound) && (_gameId != GID_ZAK256)) return readSoundResourceSmallHeader(type, idx); } else { if (type == rtSound) { - _fileHandle.readDwordLE(); - _fileHandle.readDwordLE(); + _fileHandle.readUint32LE(); + _fileHandle.readUint32LE(); return readSoundResource(type, idx); } @@ -549,7 +549,7 @@ int Scumm::loadResource(int type, int idx) error("%s %d not in room %d at %d+%d", res.name[type], type, roomNr, _fileOffset, fileOffs); } - size = _fileHandle.readDwordBE(); + size = _fileHandle.readUint32BE(); _fileHandle.seek(-8, SEEK_CUR); } _fileHandle.read(createResource(type, idx, size), size); @@ -582,7 +582,7 @@ int Scumm::readSoundResource(int type, int idx) pos = 0; basetag = fileReadDword(); - total_size = _fileHandle.readDwordBE(); + total_size = _fileHandle.readUint32BE(); debug(8, " basetag: %c%c%c%c, total_size=%d", (char)((basetag >> 24) & 0xff), @@ -598,7 +598,7 @@ int Scumm::readSoundResource(int type, int idx) best_pri = -1; while (pos < total_size) { tag = fileReadDword(); - size = _fileHandle.readDwordBE() + 8; + size = _fileHandle.readUint32BE() + 8; pos += size; pri = -1; @@ -650,7 +650,7 @@ int Scumm::readSoundResource(int type, int idx) } } else if (FROM_LE_32(basetag) == 24) { _fileHandle.seek(-12, SEEK_CUR); - total_size = _fileHandle.readDwordBE(); + total_size = _fileHandle.readUint32BE(); _fileHandle.seek(-8, SEEK_CUR); _fileHandle.read(createResource(type, idx, total_size), total_size); return 1; @@ -707,12 +707,12 @@ int Scumm::readSoundResource(int type, int idx) seem to suggest it's 2 byte oriented, or even variable length... */ _fileHandle.seek(-12, SEEK_CUR); - total_size = _fileHandle.readDwordBE(); + total_size = _fileHandle.readUint32BE(); _fileHandle.read(createResource(type, idx, total_size), total_size - 8); return 1; } else if (basetag == MKID('Mac1')) { _fileHandle.seek(-12, SEEK_CUR); - total_size = _fileHandle.readDwordBE(); + total_size = _fileHandle.readUint32BE(); _fileHandle.read(createResource(type, idx, total_size), total_size - 8); return 1; } else if (basetag == MKID('DIGI')) { @@ -721,12 +721,12 @@ int Scumm::readSoundResource(int type, int idx) debug(1, "It was at position %d", _fileHandle.pos()); _fileHandle.seek(-12, SEEK_CUR); - total_size = _fileHandle.readDwordBE(); + total_size = _fileHandle.readUint32BE(); _fileHandle.read(createResource(type, idx, total_size), total_size - 8); return 1; } else if (basetag == MKID('Crea')) { _fileHandle.seek(-12, SEEK_CUR); - total_size = _fileHandle.readDwordBE(); + total_size = _fileHandle.readUint32BE(); _fileHandle.read(createResource(type, idx, total_size), total_size - 8); return 1; } else { @@ -871,16 +871,16 @@ int Scumm::readSoundResourceSmallHeader(int type, int idx) //if (_rescache->readResource(roomNr, type, idx)) // return 1; - total_size = size = _fileHandle.readDwordLE(); - tag = _fileHandle.readWordLE(); + total_size = size = _fileHandle.readUint32LE(); + tag = _fileHandle.readUint16LE(); debug(4, " tag='%c%c', size=%d", (char) (tag & 0xff), (char) ((tag >> 8) & 0xff), size); pos = 6; while (pos < total_size) { - size = _fileHandle.readDwordLE(); - tag = _fileHandle.readWordLE(); + size = _fileHandle.readUint32LE(); + tag = _fileHandle.readUint16LE(); debug(4, " tag='%c%c', size=%d", (char) (tag & 0xff), (char) ((tag >> 8) & 0xff), size); @@ -1498,23 +1498,23 @@ void Scumm::readMAXS() { if (_features & GF_AFTER_V8) { _fileHandle.seek(50 + 50, SEEK_CUR); - _numVariables = _fileHandle.readDwordLE(); /* ? 1500 */ - _numBitVariables = _fileHandle.readDwordLE(); /* ? 2048 */ - _fileHandle.readDwordLE(); /* 40 */ - _numScripts = _fileHandle.readDwordLE(); - _numSounds = _fileHandle.readDwordLE(); - _numCharsets = _fileHandle.readDwordLE(); - _numCostumes = _fileHandle.readDwordLE(); - _numRooms = _fileHandle.readDwordLE(); - _numInventory = _fileHandle.readDwordLE(); - _numGlobalObjects = _fileHandle.readDwordLE(); - _numFlObject = _fileHandle.readDwordLE(); - _numLocalObjects = _fileHandle.readDwordLE(); - _numVerbs = _fileHandle.readDwordLE(); - _numNewNames = _fileHandle.readDwordLE(); - _fileHandle.readDwordLE(); - _fileHandle.readDwordLE(); - _numArray = _fileHandle.readDwordLE(); + _numVariables = _fileHandle.readUint32LE(); /* ? 1500 */ + _numBitVariables = _fileHandle.readUint32LE(); /* ? 2048 */ + _fileHandle.readUint32LE(); /* 40 */ + _numScripts = _fileHandle.readUint32LE(); + _numSounds = _fileHandle.readUint32LE(); + _numCharsets = _fileHandle.readUint32LE(); + _numCostumes = _fileHandle.readUint32LE(); + _numRooms = _fileHandle.readUint32LE(); + _numInventory = _fileHandle.readUint32LE(); + _numGlobalObjects = _fileHandle.readUint32LE(); + _numFlObject = _fileHandle.readUint32LE(); + _numLocalObjects = _fileHandle.readUint32LE(); + _numVerbs = _fileHandle.readUint32LE(); + _numNewNames = _fileHandle.readUint32LE(); + _fileHandle.readUint32LE(); + _fileHandle.readUint32LE(); + _numArray = _fileHandle.readUint32LE(); _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); _numGlobalScripts = 2000; @@ -1522,42 +1522,42 @@ void Scumm::readMAXS() _shadowPaletteSize = NUM_SHADOW_PALETTE * 256; } else if (_features & GF_AFTER_V7) { _fileHandle.seek(50 + 50, SEEK_CUR); - _numVariables = _fileHandle.readWordLE(); - _numBitVariables = _fileHandle.readWordLE(); - _fileHandle.readWordLE(); - _numGlobalObjects = _fileHandle.readWordLE(); - _numLocalObjects = _fileHandle.readWordLE(); - _numNewNames = _fileHandle.readWordLE(); - _numVerbs = _fileHandle.readWordLE(); - _numFlObject = _fileHandle.readWordLE(); - _numInventory = _fileHandle.readWordLE(); - _numArray = _fileHandle.readWordLE(); - _numRooms = _fileHandle.readWordLE(); - _numScripts = _fileHandle.readWordLE(); - _numSounds = _fileHandle.readWordLE(); - _numCharsets = _fileHandle.readWordLE(); - _numCostumes = _fileHandle.readWordLE(); + _numVariables = _fileHandle.readUint16LE(); + _numBitVariables = _fileHandle.readUint16LE(); + _fileHandle.readUint16LE(); + _numGlobalObjects = _fileHandle.readUint16LE(); + _numLocalObjects = _fileHandle.readUint16LE(); + _numNewNames = _fileHandle.readUint16LE(); + _numVerbs = _fileHandle.readUint16LE(); + _numFlObject = _fileHandle.readUint16LE(); + _numInventory = _fileHandle.readUint16LE(); + _numArray = _fileHandle.readUint16LE(); + _numRooms = _fileHandle.readUint16LE(); + _numScripts = _fileHandle.readUint16LE(); + _numSounds = _fileHandle.readUint16LE(); + _numCharsets = _fileHandle.readUint16LE(); + _numCostumes = _fileHandle.readUint16LE(); _objectRoomTable = (byte *)calloc(_numGlobalObjects, 1); _numGlobalScripts = 2000; _shadowPaletteSize = NUM_SHADOW_PALETTE * 256; } else if (_features & GF_AFTER_V6) { - _numVariables = _fileHandle.readWordLE(); - _fileHandle.readWordLE(); - _numBitVariables = _fileHandle.readWordLE(); - _numLocalObjects = _fileHandle.readWordLE(); - _numArray = _fileHandle.readWordLE(); - _fileHandle.readWordLE(); - _numVerbs = _fileHandle.readWordLE(); - _numFlObject = _fileHandle.readWordLE(); - _numInventory = _fileHandle.readWordLE(); - _numRooms = _fileHandle.readWordLE(); - _numScripts = _fileHandle.readWordLE(); - _numSounds = _fileHandle.readWordLE(); - _numCharsets = _fileHandle.readWordLE(); - _numCostumes = _fileHandle.readWordLE(); - _numGlobalObjects = _fileHandle.readWordLE(); + _numVariables = _fileHandle.readUint16LE(); + _fileHandle.readUint16LE(); + _numBitVariables = _fileHandle.readUint16LE(); + _numLocalObjects = _fileHandle.readUint16LE(); + _numArray = _fileHandle.readUint16LE(); + _fileHandle.readUint16LE(); + _numVerbs = _fileHandle.readUint16LE(); + _numFlObject = _fileHandle.readUint16LE(); + _numInventory = _fileHandle.readUint16LE(); + _numRooms = _fileHandle.readUint16LE(); + _numScripts = _fileHandle.readUint16LE(); + _numSounds = _fileHandle.readUint16LE(); + _numCharsets = _fileHandle.readUint16LE(); + _numCostumes = _fileHandle.readUint16LE(); + _numGlobalObjects = _fileHandle.readUint16LE(); _numNewNames = 50; _objectRoomTable = NULL; @@ -1565,20 +1565,20 @@ void Scumm::readMAXS() _shadowPaletteSize = 256; } else { - _numVariables = _fileHandle.readWordLE(); /* 800 */ - _fileHandle.readWordLE(); /* 16 */ - _numBitVariables = _fileHandle.readWordLE(); /* 2048 */ - _numLocalObjects = _fileHandle.readWordLE(); /* 200 */ + _numVariables = _fileHandle.readUint16LE(); /* 800 */ + _fileHandle.readUint16LE(); /* 16 */ + _numBitVariables = _fileHandle.readUint16LE(); /* 2048 */ + _numLocalObjects = _fileHandle.readUint16LE(); /* 200 */ _numArray = 50; _numVerbs = 100; _numNewNames = 0; _objectRoomTable = NULL; - _fileHandle.readWordLE(); /* 50 */ - _numCharsets = _fileHandle.readWordLE(); /* 9 */ - _fileHandle.readWordLE(); /* 100 */ - _fileHandle.readWordLE(); /* 50 */ - _numInventory = _fileHandle.readWordLE(); /* 80 */ + _fileHandle.readUint16LE(); /* 50 */ + _numCharsets = _fileHandle.readUint16LE(); /* 9 */ + _fileHandle.readUint16LE(); /* 100 */ + _fileHandle.readUint16LE(); /* 50 */ + _numInventory = _fileHandle.readUint16LE(); /* 80 */ _numGlobalScripts = 200; _shadowPaletteSize = 256; diff --git a/scumm/resource_v2.cpp b/scumm/resource_v2.cpp index 869cba9a7a..4415afcdcf 100644 --- a/scumm/resource_v2.cpp +++ b/scumm/resource_v2.cpp @@ -31,10 +31,10 @@ void Scumm_v2::readIndexFile() openRoom(-1); openRoom(0); - if (_fileHandle.readWordLE() != 0x0100) + if (_fileHandle.readUint16LE() != 0x0100) warning("The magic id doesn't match\n"); - _numGlobalObjects = _fileHandle.readWordLE(); + _numGlobalObjects = _fileHandle.readUint16LE(); _fileHandle.seek(_numGlobalObjects, SEEK_CUR); // Skip object flags _numRooms = _fileHandle.readByte(); _fileHandle.seek(_numRooms * 3, SEEK_CUR); @@ -71,8 +71,8 @@ void Scumm_v2::readIndexFile() _numFlObject = 50; allocateArrays(); - _fileHandle.readWordLE(); /* version magic number */ - _fileHandle.readWordLE(); /* nb global objects */ + _fileHandle.readUint16LE(); /* version magic number */ + _fileHandle.readUint16LE(); /* nb global objects */ _fileHandle.seek(_numGlobalObjects, SEEK_CUR); // Skip object flags readResTypeList(rtRoom, MKID('ROOM'), "room"); readResTypeList(rtCostume, MKID('COST'), "costume"); diff --git a/scumm/resource_v3.cpp b/scumm/resource_v3.cpp index aee293a552..45b31bf6e5 100644 --- a/scumm/resource_v3.cpp +++ b/scumm/resource_v3.cpp @@ -38,29 +38,29 @@ void Scumm_v3::readIndexFile() openRoom(0); while (!_fileHandle.eof()) { - itemsize = _fileHandle.readDwordLE(); - blocktype = _fileHandle.readWordLE(); + itemsize = _fileHandle.readUint32LE(); + blocktype = _fileHandle.readUint16LE(); if (_fileHandle.ioFailed()) break; switch (blocktype) { case 0x4E52: // 'NR' - _fileHandle.readWordLE(); + _fileHandle.readUint16LE(); break; case 0x5230: // 'R0' - _numRooms = _fileHandle.readWordLE(); + _numRooms = _fileHandle.readUint16LE(); break; case 0x5330: // 'S0' - _numScripts = _fileHandle.readWordLE(); + _numScripts = _fileHandle.readUint16LE(); break; case 0x4E30: // 'N0' - _numSounds = _fileHandle.readWordLE(); + _numSounds = _fileHandle.readUint16LE(); break; case 0x4330: // 'C0' - _numCostumes = _fileHandle.readWordLE(); + _numCostumes = _fileHandle.readUint16LE(); break; case 0x4F30: // 'O0' - _numGlobalObjects = _fileHandle.readWordLE(); + _numGlobalObjects = _fileHandle.readUint16LE(); break; } _fileHandle.seek(itemsize - 8, SEEK_CUR); @@ -94,12 +94,12 @@ void Scumm_v3::readIndexFile() allocateArrays(); while (1) { - itemsize = _fileHandle.readDwordLE(); + itemsize = _fileHandle.readUint32LE(); if (_fileHandle.ioFailed()) break; - blocktype = _fileHandle.readWordLE(); + blocktype = _fileHandle.readUint16LE(); numblock++; @@ -126,7 +126,7 @@ void Scumm_v3::readIndexFile() break; case 0x4F30: // 'O0' - num = _fileHandle.readWordLE(); + num = _fileHandle.readUint16LE(); assert(num == _numGlobalObjects); for (i = 0; i != num; i++) { uint32 bits = _fileHandle.readByte(); @@ -160,7 +160,7 @@ void Scumm_v3::loadCharset(int no) openRoom(98 + no); - size = _fileHandle.readWordLE(); + size = _fileHandle.readUint16LE(); _fileHandle.read(createResource(6, no, size), size); openRoom(-1); diff --git a/scumm/resource_v4.cpp b/scumm/resource_v4.cpp index 21fe321cc5..fc8ea5fb9b 100644 --- a/scumm/resource_v4.cpp +++ b/scumm/resource_v4.cpp @@ -33,7 +33,7 @@ void Scumm_v4::loadCharset(int no) openRoom(900 + no); - size = _fileHandle.readDwordLE() + 11; + size = _fileHandle.readUint32LE() + 11; _fileHandle.read(createResource(6, no, size), size); openRoom(-1); diff --git a/scumm/scumm.h b/scumm/scumm.h index 7464fecf56..255913c860 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -964,9 +964,9 @@ public: bool checkFixedDisk(); #if defined(SCUMM_LITTLE_ENDIAN) - uint32 fileReadDword() { return _fileHandle.readDwordLE(); } + uint32 fileReadDword() { return _fileHandle.readUint32LE(); } #elif defined(SCUMM_BIG_ENDIAN) - uint32 fileReadDword() { return _fileHandle.readDwordBE(); } + uint32 fileReadDword() { return _fileHandle.readUint32BE(); } #endif /* Version 5 script opcodes */ diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 2d8a065d72..2f7e561942 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -823,17 +823,17 @@ File * Sound::openSfxFile() { int size, compressed_offset; MP3OffsetTable *cur; - compressed_offset = file->readDwordBE(); + compressed_offset = file->readUint32BE(); offset_table = (MP3OffsetTable *) malloc(compressed_offset); num_sound_effects = compressed_offset / 16; size = compressed_offset; cur = offset_table; while (size > 0) { - cur[0].org_offset = file->readDwordBE(); - cur[0].new_offset = file->readDwordBE() + compressed_offset + 4; /* The + 4 is to take into accound the 'size' field */ - cur[0].num_tags = file->readDwordBE(); - cur[0].compressed_size = file->readDwordBE(); + cur[0].org_offset = file->readUint32BE(); + cur[0].new_offset = file->readUint32BE() + compressed_offset + 4; /* The + 4 is to take into accound the 'size' field */ + cur[0].num_tags = file->readUint32BE(); + cur[0].compressed_size = file->readUint32BE(); size -= 4 * 4; cur++; } diff --git a/simon/midi.cpp b/simon/midi.cpp index f59d7c42cd..19d573a935 100644 --- a/simon/midi.cpp +++ b/simon/midi.cpp @@ -59,17 +59,17 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old) uint i; if (!old) { - if (in->readDwordBE() != 6) + if (in->readUint32BE() != 6) error("Invalid 'MThd' chunk size"); - s->midi_format = in->readWordBE(); - s->num_tracks = in->readWordBE(); - s->ppqn = in->readWordBE(); + s->midi_format = in->readUint16BE(); + s->num_tracks = in->readUint16BE(); + s->ppqn = in->readUint16BE(); } else { s->midi_format = 0; s->num_tracks = 1; s->ppqn = 0xc0; - in->readWordBE(); + in->readUint16BE(); in->readByte(); } @@ -79,10 +79,11 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old) for (i = 0; i != s->num_tracks; i++, t++) { if (!old) { - if (in->readDwordBE() != 'MTrk') - error("Midi track has no 'MTrk'"); + uint32 foo = in->readUint32BE(); + if (foo != 'MTrk') + error("Midi track has no 'MTrk' (%d, %08x)", i, foo); - t->data_size = in->readDwordLE(); + t->data_size = in->readUint32LE(); } else { uint32 pos = in->pos(); in->seek(0, SEEK_END); @@ -93,7 +94,7 @@ void MidiPlayer::read_mthd(File *in, Song *s, bool old) t->data_ptr = (byte *)calloc(t->data_size, 1); if (t->data_ptr == NULL) - error("Out of memory when allocating MIDI track data"); + error("Out of memory when allocating MIDI track data (%d)", t->data_size); in->read(t->data_ptr, t->data_size); @@ -122,7 +123,7 @@ void MidiPlayer::read_one_song(File *in, Song *s) s->num_tracks = 0; s->tracks = NULL; - uint32 id = in->readDwordBE(); + uint32 id = in->readUint32BE(); switch (id) { case 'MThd': diff --git a/simon/res.cpp b/simon/res.cpp index ad66db8895..6cf2d219c4 100644 --- a/simon/res.cpp +++ b/simon/res.cpp @@ -156,7 +156,7 @@ void SimonState::readGamePcText(File *in) uint text_size; byte *text_mem; - _text_size = text_size = in->readDwordBE(); + _text_size = text_size = in->readUint32BE(); text_mem = (byte *)malloc(text_size); if (text_mem == NULL) error("Out of text memory"); @@ -170,19 +170,19 @@ void SimonState::readItemFromGamePc(File *in, Item *item) { uint32 type; - item->unk2 = in->readWordBE(); - item->unk1 = in->readWordBE(); - item->unk3 = in->readWordBE(); + item->unk2 = in->readUint16BE(); + item->unk1 = in->readUint16BE(); + item->unk3 = in->readUint16BE(); item->sibling = (uint16)fileReadItemID(in); item->child = (uint16)fileReadItemID(in); item->parent = (uint16)fileReadItemID(in); - in->readWordBE(); - item->unk4 = in->readWordBE(); + in->readUint16BE(); + item->unk4 = in->readUint16BE(); item->children = NULL; - type = in->readDwordBE(); + type = in->readUint32BE(); while (type) { - type = in->readWordBE(); + type = in->readUint16BE(); if (type != 0) readItemChildren(in, item, type); } @@ -191,8 +191,8 @@ void SimonState::readItemFromGamePc(File *in, Item *item) void SimonState::readItemChildren(File *in, Item *item, uint type) { if (type == 1) { - uint fr1 = in->readWordBE(); - uint fr2 = in->readWordBE(); + uint fr1 = in->readUint16BE(); + uint fr2 = in->readUint16BE(); uint i, size; uint j, k; Child1 *child; @@ -210,7 +210,7 @@ void SimonState::readItemChildren(File *in, Item *item, uint type) if (j & 3) child->array[k++] = (uint16)fileReadItemID(in); } else if (type == 2) { - uint32 fr = in->readDwordBE(); + uint32 fr = in->readUint32BE(); uint i, k, size; Child2 *child; @@ -224,13 +224,13 @@ void SimonState::readItemChildren(File *in, Item *item, uint type) k = 0; if (fr & 1) { - child->array[k++] = (uint16)in->readDwordBE(); + child->array[k++] = (uint16)in->readUint32BE(); } for (i = 1; i != 16; i++) if (fr & (1 << i)) - child->array[k++] = in->readWordBE(); + child->array[k++] = in->readUint16BE(); - child->string_id = (uint16)in->readDwordBE(); + child->string_id = (uint16)in->readUint32BE(); } else { error("readItemChildren: invalid mode"); } @@ -238,7 +238,7 @@ void SimonState::readItemChildren(File *in, Item *item, uint type) uint fileReadItemID(File *in) { - uint32 val = in->readDwordBE(); + uint32 val = in->readUint32BE(); if (val == 0xFFFFFFFF) return 0; return val + 2; @@ -288,7 +288,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) case 'n': case 'p': case 'v': - val = in->readWordBE(); + val = in->readUint16BE(); *ptr++ = val >> 8; *ptr++ = val & 255; break; @@ -301,7 +301,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) break; case 'I': - val = in->readWordBE(); + val = in->readUint16BE(); switch (val) { case 1: val = 0xFFFF; @@ -326,7 +326,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) break; case 'T': - val = in->readWordBE(); + val = in->readUint16BE(); switch (val) { case 0: val = 0xFFFF; @@ -335,7 +335,7 @@ byte *SimonState::readSingleOpcode(File *in, byte *ptr) val = 0xFFFD; break; default: - val = (uint16)in->readDwordBE(); + val = (uint16)in->readUint32BE(); break; } *ptr++ = val >> 8; diff --git a/simon/simon.cpp b/simon/simon.cpp index cefc4bc0a2..65469215ad 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -190,10 +190,10 @@ int SimonState::allocGamePcVars(File *in) uint32 version; uint i; - item_array_size = in->readDwordBE(); - version = in->readDwordBE(); - item_array_inited = in->readDwordBE(); - stringtable_num = in->readDwordBE(); + item_array_size = in->readUint32BE(); + version = in->readUint32BE(); + item_array_inited = in->readUint32BE(); + stringtable_num = in->readUint32BE(); item_array_inited += 2; /* first two items are predefined */ item_array_size += 2; @@ -297,14 +297,14 @@ void SimonState::readSubroutineLine(File *in, SubroutineLine *sl, Subroutine *su int size; if (sub->id == 0) { - sl->cond_a = in->readWordBE(); - sl->cond_b = in->readWordBE(); - sl->cond_c = in->readWordBE(); + sl->cond_a = in->readUint16BE(); + sl->cond_b = in->readUint16BE(); + sl->cond_c = in->readUint16BE(); } while ((*q = in->readByte()) != 0xFF) { if (*q == 87) { - in->readWordBE(); + in->readUint16BE(); } else { q = readSingleOpcode(in, q); } @@ -351,7 +351,7 @@ SubroutineLine *SimonState::createSubroutineLine(Subroutine *sub, int where) void SimonState::readSubroutine(File *in, Subroutine *sub) { - while (in->readWordBE() == 0) { + while (in->readUint16BE() == 0) { readSubroutineLine(in, createSubroutineLine(sub, 0xFFFF), sub); } } @@ -372,8 +372,8 @@ Subroutine *SimonState::createSubroutine(uint id) void SimonState::readSubroutineBlock(File *in) { - while (in->readWordBE() == 0) { - readSubroutine(in, createSubroutine(in->readWordBE())); + while (in->readUint16BE() == 0) { + readSubroutine(in, createSubroutine(in->readUint16BE())); } } @@ -4436,34 +4436,34 @@ bool SimonState::save_game(uint slot, const char *caption) f.write((char*)caption, 0x12); - f.writeDwordBE(_itemarray_inited - 1); - f.writeDwordBE(0xFFFFFFFF); - f.writeDwordBE(0); - f.writeDwordBE(0); + f.writeUint32BE(_itemarray_inited - 1); + f.writeUint32BE(0xFFFFFFFF); + f.writeUint32BE(0); + f.writeUint32BE(0); i = 0; for (te = _first_time_struct; te; te = te->next) i++; - f.writeDwordBE(i); + f.writeUint32BE(i); for (te = _first_time_struct; te; te = te->next) { - f.writeDwordBE(te->time + _base_time); - f.writeWordBE(te->subroutine_id); + f.writeUint32BE(te->time + _base_time); + f.writeUint16BE(te->subroutine_id); } item_index = 1; for (num_item = _itemarray_inited - 1; num_item; num_item--) { Item *item = _itemarray_ptr[item_index++]; - f.writeWordBE(item->parent); - f.writeWordBE(item->sibling); - f.writeWordBE(item->unk3); - f.writeWordBE(item->unk4); + f.writeUint16BE(item->parent); + f.writeUint16BE(item->sibling); + f.writeUint16BE(item->unk3); + f.writeUint16BE(item->unk4); { Child1 *child1 = findChildOfType1(item); if (child1) { - f.writeWordBE(child1->fr2); + f.writeUint16BE(child1->fr2); } } @@ -4472,12 +4472,12 @@ bool SimonState::save_game(uint slot, const char *caption) uint i, j; if (child2) { - f.writeDwordBE(child2->avail_props); + f.writeUint32BE(child2->avail_props); i = child2->avail_props & 1; for (j = 1; j < 16; j++) { if ((1 << j) & child2->avail_props) { - f.writeWordBE(child2->array[i++]); + f.writeUint16BE(child2->array[i++]); } } } @@ -4488,7 +4488,7 @@ bool SimonState::save_game(uint slot, const char *caption) if (child9) { uint i; for (i = 0; i != 4; i++) { - f.writeWordBE(child9->array[i]); + f.writeUint16BE(child9->array[i]); } } } @@ -4496,17 +4496,17 @@ bool SimonState::save_game(uint slot, const char *caption) /* write the 255 variables */ for (i = 0; i != 255; i++) { - f.writeWordBE(readVariable(i)); + f.writeUint16BE(readVariable(i)); } /* write the items in array 6 */ for (i = 0; i != 10; i++) { - f.writeWordBE(itemPtrToID(_item_array_6[i])); + f.writeUint16BE(itemPtrToID(_item_array_6[i])); } /* Write the bits in array 1 & 2 */ for (i = 0; i != 32; i++) - f.writeWordBE(_bit_array[i]); + f.writeUint16BE(_bit_array[i]); f.close(); @@ -4543,24 +4543,24 @@ bool SimonState::load_game(uint slot) f.read(ident, 18); - num = f.readDwordBE(); + num = f.readUint32BE(); - if (f.readDwordBE() != 0xFFFFFFFF || num != _itemarray_inited - 1) { + if (f.readUint32BE() != 0xFFFFFFFF || num != _itemarray_inited - 1) { f.close(); _lock_word &= ~0x100; return false; } - f.readDwordBE(); - f.readDwordBE(); + f.readUint32BE(); + f.readUint32BE(); _no_parent_notify = true; /* add all timers */ killAllTimers(); - for (num = f.readDwordBE(); num; num--) { - uint32 timeout = f.readDwordBE(); - uint16 func_to_call = f.readWordBE(); + for (num = f.readUint32BE(); num; num--) { + uint32 timeout = f.readUint32BE(); + uint16 func_to_call = f.readUint16BE(); addTimeEvent(timeout, func_to_call); } @@ -4568,8 +4568,8 @@ bool SimonState::load_game(uint slot) for (num = _itemarray_inited - 1; num; num--) { Item *item = _itemarray_ptr[item_index++], *parent_item; - uint parent = f.readWordBE(); - uint sibling = f.readWordBE(); + uint parent = f.readUint16BE(); + uint sibling = f.readUint16BE(); parent_item = derefItem(parent); @@ -4580,13 +4580,13 @@ bool SimonState::load_game(uint slot) item->sibling = sibling; } - item->unk3 = f.readWordBE(); - item->unk4 = f.readWordBE(); + item->unk3 = f.readUint16BE(); + item->unk4 = f.readUint16BE(); { Child1 *child1 = findChildOfType1(item); if (child1 != NULL) { - child1->fr2 = f.readWordBE(); + child1->fr2 = f.readUint16BE(); } } @@ -4594,12 +4594,12 @@ bool SimonState::load_game(uint slot) Child2 *child2 = findChildOfType2(item); uint i, j; if (child2 != NULL) { - child2->avail_props = f.readDwordBE(); + child2->avail_props = f.readUint32BE(); i = child2->avail_props & 1; for (j = 1; j < 16; j++) { if ((1 << j) & child2->avail_props) { - child2->array[i++] = f.readWordBE(); + child2->array[i++] = f.readUint16BE(); } } } @@ -4610,7 +4610,7 @@ bool SimonState::load_game(uint slot) if (child9) { uint i; for (i = 0; i != 4; i++) { - child9->array[i] = f.readWordBE(); + child9->array[i] = f.readUint16BE(); } } } @@ -4619,17 +4619,17 @@ bool SimonState::load_game(uint slot) /* read the 255 variables */ for (i = 0; i != 255; i++) { - writeVariable(i, f.readWordBE()); + writeVariable(i, f.readUint16BE()); } /* write the items in array 6 */ for (i = 0; i != 10; i++) { - _item_array_6[i] = derefItem(f.readWordBE()); + _item_array_6[i] = derefItem(f.readUint16BE()); } /* Write the bits in array 1 & 2 */ for (i = 0; i != 32; i++) - _bit_array[i] = f.readWordBE(); + _bit_array[i] = f.readUint16BE(); f.close(); @@ -4761,8 +4761,8 @@ void SimonState::playVoice(uint voice) _voice_file->seek(READ_LE_UINT32(&wave_hdr.size) - sizeof(wave_hdr) + 20, SEEK_CUR); - data[0] = _voice_file->readDwordLE(); - data[1] = _voice_file->readDwordLE(); + data[0] = _voice_file->readUint32LE(); + data[1] = _voice_file->readUint32LE(); if ( //fread(data, sizeof(data), 1, _voice_file) != 1 || data[0] != 'atad') { warning("playVoice(%d): cannot read data header", voice); |