diff options
author | James Brown | 2002-05-05 17:44:39 +0000 |
---|---|---|
committer | James Brown | 2002-05-05 17:44:39 +0000 |
commit | 46f7c4d543fb335a85041747cf489621e451a58d (patch) | |
tree | b62fccc7a75910349d4c504737fab496dccff55e | |
parent | 59374705586d137fe6b847f4af4e972b02c35fbe (diff) | |
download | scummvm-rg350-46f7c4d543fb335a85041747cf489621e451a58d.tar.gz scummvm-rg350-46f7c4d543fb335a85041747cf489621e451a58d.tar.bz2 scummvm-rg350-46f7c4d543fb335a85041747cf489621e451a58d.zip |
Add more Dig compatability, fix Dig sounds due to Endian.
svn-id: r4201
-rw-r--r-- | saveload.cpp | 124 | ||||
-rw-r--r-- | scumm.h | 4 | ||||
-rw-r--r-- | scummsys.h | 2 | ||||
-rw-r--r-- | sound.cpp | 16 |
4 files changed, 34 insertions, 112 deletions
diff --git a/saveload.cpp b/saveload.cpp index 9d0db96f18..33ec427329 100644 --- a/saveload.cpp +++ b/saveload.cpp @@ -25,10 +25,6 @@ #include "sound/mididrv.h" #include "sound/imuse.h" -#ifdef _WIN32_WCE -#define _MANAGE_OLD_SAVE -#endif - struct SaveGameHeader { uint32 type; uint32 size; @@ -36,24 +32,17 @@ struct SaveGameHeader { char name[32]; }; -#ifdef _MANAGE_OLD_SAVE - // Support for "old" savegames (made with 2501 CVS build) // Can be useful for other ports too :) +#define VER_V9 9 #define VER_V8 8 #define VER_V7 7 -#define CURRENT_VER VER_V8 +#define CURRENT_VER VER_V9 static uint32 _current_version = CURRENT_VER; -#else - -#define CURRENT_VER 7 - -#endif - bool Scumm::saveState(int slot, bool compat) { char filename[256]; @@ -70,17 +59,8 @@ bool Scumm::saveState(int slot, bool compat) hdr.type = MKID('SCVM'); hdr.size = 0; - -#ifdef _MANAGE_OLD_SAVE - hdr.ver = _current_version; -#else - - hdr.ver = CURRENT_VER; - -#endif - out.fwrite(&hdr, sizeof(hdr), 1); ser._saveLoadStream = out; @@ -111,26 +91,14 @@ bool Scumm::loadState(int slot, bool compat) out.fclose(); return false; } -#ifdef _MANAGE_OLD_SAVE - - if (hdr.ver != VER_V8 && hdr.ver != VER_V7) { - -#else - - if (hdr.ver != CURRENT_VER) { - -#endif + if (hdr.ver < VER_V7 || hdr.ver > _current_version) { warning("Invalid version of '%s'", filename); out.fclose(); return false; } -#ifdef _MANAGE_OLD_SAVE _current_version = hdr.ver; - -#endif - memcpy(_saveLoadName, hdr.name, sizeof(hdr.name)); pauseSounds(true); @@ -228,16 +196,8 @@ bool Scumm::getSavegameName(int slot, char *desc) strcpy(desc, "Invalid savegame"); return false; } -#ifdef _MANAGE_OLD_SAVE - - if (hdr.ver != VER_V8 && hdr.ver != VER_V7) { - -#else - - if (hdr.ver != CURRENT_VER) { - -#endif + if (hdr.ver < VER_V8 || hdr.ver > _current_version) { strcpy(desc, "Invalid version"); return false; } @@ -371,9 +331,7 @@ void Scumm::saveOrLoad(Serializer * s) MKEND() }; -#ifdef _MANAGE_OLD_SAVE - - const SaveLoadEntry mainEntries1[] = { + const SaveLoadEntry mainEntriesV9[] = { MKLINE(Scumm, _scrWidth, sleUint16), MKLINE(Scumm, _scrHeight, sleUint16), MKLINE(Scumm, _ENCD_offs, sleUint32), @@ -393,10 +351,6 @@ void Scumm::saveOrLoad(Serializer * s) MKARRAY(Scumm, charset._colorMap[0], sleByte, 16), MKARRAY(Scumm, _charsetData[0][0], sleByte, 10 * 16), MKLINE(Scumm, _curExecScript, sleUint16), - MKEND() - }; - - const SaveLoadEntry mainEntries2V8[] = { MKLINE(Scumm, camera._dest.x, sleInt16), MKLINE(Scumm, camera._dest.y, sleInt16), @@ -413,24 +367,6 @@ void Scumm::saveOrLoad(Serializer * s) MKLINE(Scumm, camera._leftTrigger, sleInt16), MKLINE(Scumm, camera._rightTrigger, sleInt16), MKLINE(Scumm, camera._movingToActor, sleUint16), - MKEND() - }; - - const SaveLoadEntry mainEntries2V7[] = { - MKLINE(Scumm, camera._dest.x, sleInt16), - MKLINE(Scumm, camera._cur.x, sleInt16), - MKLINE(Scumm, camera._last.x, sleInt16), - MKLINE(Scumm, _screenStartStrip, sleInt16), - MKLINE(Scumm, _screenEndStrip, sleInt16), - MKLINE(Scumm, camera._mode, sleByte), - MKLINE(Scumm, camera._follows, sleByte), - MKLINE(Scumm, camera._leftTrigger, sleInt16), - MKLINE(Scumm, camera._rightTrigger, sleInt16), - MKLINE(Scumm, camera._movingToActor, sleUint16), - MKEND() - }; - - const SaveLoadEntry mainEntries3[] = { MKLINE(Scumm, _actorToPrintStrFor, sleByte), MKLINE(Scumm, _charsetColor, sleByte), @@ -467,7 +403,7 @@ void Scumm::saveOrLoad(Serializer * s) MKLINE(Scumm, gdi._transparency, sleByte), MKARRAY(Scumm, _currentPalette[0], sleByte, 768), - + MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256), /* virtscr */ MKARRAY(Scumm, charset._buffer[0], sleByte, 256), @@ -491,12 +427,15 @@ void Scumm::saveOrLoad(Serializer * s) MKLINE(Scumm, _screenB, sleUint16), MKLINE(Scumm, _screenH, sleUint16), + MKLINE(Scumm, _cd_track, sleInt16), + MKLINE(Scumm, _cd_loops, sleInt16), + MKLINE(Scumm, _cd_frame, sleInt16), + MKLINE(Scumm, _cd_end, sleInt16), + MKEND() }; -#else - - const SaveLoadEntry mainEntries[] = { + const SaveLoadEntry mainEntriesV8[] = { MKLINE(Scumm, _scrWidth, sleUint16), MKLINE(Scumm, _scrHeight, sleUint16), MKLINE(Scumm, _ENCD_offs, sleUint32), @@ -511,7 +450,7 @@ void Scumm::saveOrLoad(Serializer * s) MKLINE(Scumm, _numObjectsInRoom, sleByte), MKLINE(Scumm, _currentScript, sleByte), MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT), - MKARRAY(Scumm, vm.localvar[0][0], sleUint16, NUM_SCRIPT_SLOT * 17), + MKARRAY(Scumm, vm.localvar[0][0], sleUint16, 25 * 17), MKARRAY(Scumm, _resourceMapper[0], sleByte, 128), MKARRAY(Scumm, charset._colorMap[0], sleByte, 16), MKARRAY(Scumm, _charsetData[0][0], sleByte, 10 * 16), @@ -595,8 +534,6 @@ void Scumm::saveOrLoad(Serializer * s) MKEND() }; -#endif - const SaveLoadEntry scriptSlotEntries[] = { MKLINE(ScriptSlot, offs, sleUint32), MKLINE(ScriptSlot, delay, sleInt32), @@ -662,35 +599,18 @@ void Scumm::saveOrLoad(Serializer * s) int var120Backup; int var98Backup; -#ifdef _MANAGE_OLD_SAVE - - s->saveLoadEntries(this, mainEntries1); - s->saveLoadEntries(this, - (_current_version == - VER_V8 ? mainEntries2V8 : mainEntries2V7)); - s->saveLoadEntries(this, mainEntries3); - -#else - - s->saveLoadEntries(this, mainEntries); - -#endif - -#ifdef _MANAGE_OLD_SAVE - - // Probably not necessary anymore with latest NUM_ACTORS values - - s->saveLoadArrayOf(actor, (_current_version == VER_V8 ? NUM_ACTORS : 13), - sizeof(actor[0]), actorEntries); - -#else + if (_current_version == VER_V9) + s->saveLoadEntries(this, mainEntriesV9); + else + s->saveLoadEntries(this, mainEntriesV8); s->saveLoadArrayOf(actor, NUM_ACTORS, sizeof(actor[0]), actorEntries); -#endif - - s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), - scriptSlotEntries); + if (_current_version < VER_V9) { + printf("Loading pre-v9\n"); + s->saveLoadArrayOf(vm.slot, 25, sizeof(vm.slot[0]), scriptSlotEntries); + } else + s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries); s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries); s->saveLoadArrayOf(_verbs, _numVerbs, sizeof(_verbs[0]), verbEntries); @@ -52,7 +52,7 @@ enum { #endif BITS_PER_SAMPLE = 16, NUM_MIXER = 4, - NUM_SCRIPT_SLOT = 25, + NUM_SCRIPT_SLOT = 40, NUM_LOCALSCRIPT = 60, NUM_SHADOW_PALETTE = 8, MAX_ACTORS = 30, @@ -966,7 +966,7 @@ public: bool _endOfMouthSync; uint16 _mouthSyncTimes[52]; uint _curSoundPos; - int current_cd_sound; + int current_cd_sound, _cd_loops, _cd_frame, _cd_track, _cd_end; int tempMusic; diff --git a/scummsys.h b/scummsys.h index 6da86834c2..d82fb309c6 100644 --- a/scummsys.h +++ b/scummsys.h @@ -258,6 +258,7 @@ typedef signed long int32; //#endif #define MKID(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000)) +#define MKID_BE(a) (a) #if defined(SCUMM_NEED_ALIGNMENT) FORCEINLINE uint READ_LE_UINT16(void *ptr) { @@ -307,6 +308,7 @@ uint16 FORCEINLINE TO_BE_16(uint16 a) { return (a>>8) | (a<<8); } #elif defined(SCUMM_BIG_ENDIAN) #define MKID(a) (a) +#define MKID_BE(a) ((((a)>>24)&0xFF) | (((a)>>8)&0xFF00) | (((a)<<8)&0xFF0000) | (((a)<<24)&0xFF000000)) uint32 FORCEINLINE FROM_LE_32(uint32 a) { return ((a>>24)&0xFF) + ((a>>8)&0xFF00) + ((a<<8)&0xFF0000) + ((a<<24)&0xFF000000); @@ -693,7 +693,7 @@ void Scumm::decompressBundleSound(int index) { int num = fileReadDwordBE(_sfxFile); fileReadDwordBE(_sfxFile); fileReadDwordBE(_sfxFile); - if (tag != MKID('COMP')) { + if (tag != MKID_BE('COMP')) { warning("Compressed sound %d invalid (%c%c%c%c)", index, tag>>24, tag>>16, tag>>8, tag); return; } @@ -763,24 +763,24 @@ void Scumm::decompressBundleSound(int index) { byte *ptr = CompFinal; int tag, size; tag = READ_BE_UINT32(ptr); ptr+=4; - if (tag != MKID('iMUS')) { + if (tag != MKID_BE('iMUS')) { warning("Decompression of bundle sound failed"); free(CompFinal); return; } ptr+=12; /* Skip header */ - while(tag != MKID('DATA')) { + while(tag != MKID_BE('DATA')) { tag = READ_BE_UINT32(ptr); ptr+=4; switch(tag) { - case MKID('FRMT'): - case MKID('TEXT'): - case MKID('REGN'): - case MKID('STOP'): + case MKID_BE('FRMT'): + case MKID_BE('TEXT'): + case MKID_BE('REGN'): + case MKID_BE('STOP'): size = READ_BE_UINT32(ptr); ptr+=size+4; break; - case MKID('DATA'): + case MKID_BE('DATA'): size = READ_BE_UINT32(ptr); ptr+=4; break; |