Ticket #8142: saveload.patch

File saveload.patch, 51.2 KB (added by fingolfin, 21 years ago)
  • scumm/actor.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
    retrieving revision 1.5
    diff -u -r1.5 actor.h
     
    101101        byte frame;
    102102
    103103        byte walkbox;
    104         byte mask;      // FIXME: This field is *NOT* used - remove next time save game format changes
    105104        byte animProgress, animSpeed;
    106105        int16 new_1, new_2;
    107106        uint16 talk_script, walk_script;
  • scumm/imuse.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
    retrieving revision 1.92
    diff -u -r1.92 imuse.cpp
     
    455455        void fix_parts_after_load();
    456456        void fix_players_after_load(Scumm *scumm);
    457457
    458         static int saveReference(IMuseInternal *me, byte type, void *ref);
    459         static void *loadReference(IMuseInternal *me, byte type, int ref);
     458        static int saveReference(void *me_ref, byte type, void *ref);
     459        static void *loadReference(void *me_ref, byte type, int ref);
    460460
    461461        void lock();
    462462        void unlock();
     
    31433143        TYPE_PLAYER = 2,
    31443144};
    31453145
    3146 int IMuseInternal::saveReference(IMuseInternal *me, byte type, void *ref)
     3146int IMuseInternal::saveReference(void *me_ref, byte type, void *ref)
    31473147{
     3148        IMuseInternal *me = (IMuseInternal *)me_ref;
    31483149        switch (type) {
    31493150        case TYPE_PART:
    31503151                return (Part *)ref - me->_parts;
     
    31553156        }
    31563157}
    31573158
    3158 void *IMuseInternal::loadReference(IMuseInternal *me, byte type, int ref)
     3159void *IMuseInternal::loadReference(void *me_ref, byte type, int ref)
    31593160{
     3161        IMuseInternal *me = (IMuseInternal *)me_ref;
    31603162        switch (type) {
    31613163        case TYPE_PART:
    31623164                return &me->_parts[ref];
     
    31703172int IMuseInternal::save_or_load(Serializer *ser, Scumm *scumm)
    31713173{
    31723174        const SaveLoadEntry mainEntries[] = {
    3173                 MKLINE(IMuseInternal, _queue_end, sleUint8),
    3174                 MKLINE(IMuseInternal, _queue_pos, sleUint8),
    3175                 MKLINE(IMuseInternal, _queue_sound, sleUint16),
    3176                 MKLINE(IMuseInternal, _queue_adding, sleByte),
    3177                 MKLINE(IMuseInternal, _queue_marker, sleByte),
    3178                 MKLINE(IMuseInternal, _queue_cleared, sleByte),
    3179                 MKLINE(IMuseInternal, _master_volume, sleByte),
    3180                 MKLINE(IMuseInternal, _trigger_count, sleUint16),
    3181                 MKARRAY(IMuseInternal, _channel_volume[0], sleUint16, 8),
    3182                 MKARRAY(IMuseInternal, _volchan_table[0], sleUint16, 8),
     3175                MKLINE(IMuseInternal, _queue_end, sleUint8, VER_V8),
     3176                MKLINE(IMuseInternal, _queue_pos, sleUint8, VER_V8),
     3177                MKLINE(IMuseInternal, _queue_sound, sleUint16, VER_V8),
     3178                MKLINE(IMuseInternal, _queue_adding, sleByte, VER_V8),
     3179                MKLINE(IMuseInternal, _queue_marker, sleByte, VER_V8),
     3180                MKLINE(IMuseInternal, _queue_cleared, sleByte, VER_V8),
     3181                MKLINE(IMuseInternal, _master_volume, sleByte, VER_V8),
     3182                MKLINE(IMuseInternal, _trigger_count, sleUint16, VER_V8),
     3183                MKARRAY(IMuseInternal, _channel_volume[0], sleUint16, 8, VER_V8),
     3184                MKARRAY(IMuseInternal, _volchan_table[0], sleUint16, 8, VER_V8),
    31833185                MKEND()
    31843186        };
    31853187
    31863188        const SaveLoadEntry playerEntries[] = {
    3187                 MKREF(Player, _parts, TYPE_PART),
    3188                 MKLINE(Player, _active, sleByte),
    3189                 MKLINE(Player, _id, sleUint16),
    3190                 MKLINE(Player, _priority, sleByte),
    3191                 MKLINE(Player, _volume, sleByte),
    3192                 MKLINE(Player, _pan, sleInt8),
    3193                 MKLINE(Player, _transpose, sleByte),
    3194                 MKLINE(Player, _detune, sleInt8),
    3195                 MKLINE(Player, _vol_chan, sleUint16),
    3196                 MKLINE(Player, _vol_eff, sleByte),
    3197                 MKLINE(Player, _speed, sleByte),
    3198                 MKLINE(Player, _song_index, sleUint16),
    3199                 MKLINE(Player, _track_index, sleUint16),
    3200                 MKLINE(Player, _timer_counter, sleUint16),
    3201                 MKLINE(Player, _loop_to_beat, sleUint16),
    3202                 MKLINE(Player, _loop_from_beat, sleUint16),
    3203                 MKLINE(Player, _loop_counter, sleUint16),
    3204                 MKLINE(Player, _loop_to_tick, sleUint16),
    3205                 MKLINE(Player, _loop_from_tick, sleUint16),
    3206                 MKLINE(Player, _tempo, sleUint32),
    3207                 MKLINE(Player, _cur_pos, sleUint32),
    3208                 MKLINE(Player, _next_pos, sleUint32),
    3209                 MKLINE(Player, _song_offset, sleUint32),
    3210                 MKLINE(Player, _tick_index, sleUint16),
    3211                 MKLINE(Player, _beat_index, sleUint16),
    3212                 MKLINE(Player, _ticks_per_beat, sleUint16),
    3213                 MKLINE(Player, _hook._jump, sleByte),
    3214                 MKLINE(Player, _hook._transpose, sleByte),
    3215                 MKARRAY(Player, _hook._part_onoff[0], sleByte, 16),
    3216                 MKARRAY(Player, _hook._part_volume[0], sleByte, 16),
    3217                 MKARRAY(Player, _hook._part_program[0], sleByte, 16),
    3218                 MKARRAY(Player, _hook._part_transpose[0], sleByte, 16),
     3189                MKREF(Player, _parts, TYPE_PART, VER_V8),
     3190                MKLINE(Player, _active, sleByte, VER_V8),
     3191                MKLINE(Player, _id, sleUint16, VER_V8),
     3192                MKLINE(Player, _priority, sleByte, VER_V8),
     3193                MKLINE(Player, _volume, sleByte, VER_V8),
     3194                MKLINE(Player, _pan, sleInt8, VER_V8),
     3195                MKLINE(Player, _transpose, sleByte, VER_V8),
     3196                MKLINE(Player, _detune, sleInt8, VER_V8),
     3197                MKLINE(Player, _vol_chan, sleUint16, VER_V8),
     3198                MKLINE(Player, _vol_eff, sleByte, VER_V8),
     3199                MKLINE(Player, _speed, sleByte, VER_V8),
     3200                MKLINE(Player, _song_index, sleUint16, VER_V8),
     3201                MKLINE(Player, _track_index, sleUint16, VER_V8),
     3202                MKLINE(Player, _timer_counter, sleUint16, VER_V8),
     3203                MKLINE(Player, _loop_to_beat, sleUint16, VER_V8),
     3204                MKLINE(Player, _loop_from_beat, sleUint16, VER_V8),
     3205                MKLINE(Player, _loop_counter, sleUint16, VER_V8),
     3206                MKLINE(Player, _loop_to_tick, sleUint16, VER_V8),
     3207                MKLINE(Player, _loop_from_tick, sleUint16, VER_V8),
     3208                MKLINE(Player, _tempo, sleUint32, VER_V8),
     3209                MKLINE(Player, _cur_pos, sleUint32, VER_V8),
     3210                MKLINE(Player, _next_pos, sleUint32, VER_V8),
     3211                MKLINE(Player, _song_offset, sleUint32, VER_V8),
     3212                MKLINE(Player, _tick_index, sleUint16, VER_V8),
     3213                MKLINE(Player, _beat_index, sleUint16, VER_V8),
     3214                MKLINE(Player, _ticks_per_beat, sleUint16, VER_V8),
     3215                MKLINE(Player, _hook._jump, sleByte, VER_V8),
     3216                MKLINE(Player, _hook._transpose, sleByte, VER_V8),
     3217                MKARRAY(Player, _hook._part_onoff[0], sleByte, 16, VER_V8),
     3218                MKARRAY(Player, _hook._part_volume[0], sleByte, 16, VER_V8),
     3219                MKARRAY(Player, _hook._part_program[0], sleByte, 16, VER_V8),
     3220                MKARRAY(Player, _hook._part_transpose[0], sleByte, 16, VER_V8),
    32193221                MKEND()
    32203222        };
    32213223
    32223224        const SaveLoadEntry volumeFaderEntries[] = {
    3223                 MKREF(VolumeFader, player, TYPE_PLAYER),
    3224                 MKLINE(VolumeFader, active, sleUint8),
    3225                 MKLINE(VolumeFader, curvol, sleUint8),
    3226                 MKLINE(VolumeFader, speed_lo_max, sleUint16),
    3227                 MKLINE(VolumeFader, num_steps, sleUint16),
    3228                 MKLINE(VolumeFader, speed_hi, sleInt8),
    3229                 MKLINE(VolumeFader, direction, sleInt8),
    3230                 MKLINE(VolumeFader, speed_lo, sleInt8),
    3231                 MKLINE(VolumeFader, speed_lo_counter, sleUint16),
     3225                MKREF(VolumeFader, player, TYPE_PLAYER, VER_V8),
     3226                MKLINE(VolumeFader, active, sleUint8, VER_V8),
     3227                MKLINE(VolumeFader, curvol, sleUint8, VER_V8),
     3228                MKLINE(VolumeFader, speed_lo_max, sleUint16, VER_V8),
     3229                MKLINE(VolumeFader, num_steps, sleUint16, VER_V8),
     3230                MKLINE(VolumeFader, speed_hi, sleInt8, VER_V8),
     3231                MKLINE(VolumeFader, direction, sleInt8, VER_V8),
     3232                MKLINE(VolumeFader, speed_lo, sleInt8, VER_V8),
     3233                MKLINE(VolumeFader, speed_lo_counter, sleUint16, VER_V8),
    32323234                MKEND()
    32333235        };
    32343236
    32353237        const SaveLoadEntry partEntries[] = {
    3236                 MKREF(Part, _next, TYPE_PART),
    3237                 MKREF(Part, _prev, TYPE_PART),
    3238                 MKREF(Part, _player, TYPE_PLAYER),
    3239                 MKLINE(Part, _pitchbend, sleInt16),
    3240                 MKLINE(Part, _pitchbend_factor, sleUint8),
    3241                 MKLINE(Part, _transpose, sleInt8),
    3242                 MKLINE(Part, _vol, sleUint8),
    3243                 MKLINE(Part, _detune, sleInt8),
    3244                 MKLINE(Part, _pan, sleInt8),
    3245                 MKLINE(Part, _on, sleUint8),
    3246                 MKLINE(Part, _modwheel, sleUint8),
    3247                 MKLINE(Part, _pedal, sleUint8),
    3248                 MKLINE(Part, _program, sleUint8),
    3249                 MKLINE(Part, _pri, sleUint8),
    3250                 MKLINE(Part, _chan, sleUint8),
    3251                 MKLINE(Part, _effect_level, sleUint8),
    3252                 MKLINE(Part, _chorus, sleUint8),
    3253                 MKLINE(Part, _percussion, sleUint8),
    3254                 MKLINE(Part, _bank, sleUint8),
     3238                MKREF(Part, _next, TYPE_PART, VER_V8),
     3239                MKREF(Part, _prev, TYPE_PART, VER_V8),
     3240                MKREF(Part, _player, TYPE_PLAYER, VER_V8),
     3241                MKLINE(Part, _pitchbend, sleInt16, VER_V8),
     3242                MKLINE(Part, _pitchbend_factor, sleUint8, VER_V8),
     3243                MKLINE(Part, _transpose, sleInt8, VER_V8),
     3244                MKLINE(Part, _vol, sleUint8, VER_V8),
     3245                MKLINE(Part, _detune, sleInt8, VER_V8),
     3246                MKLINE(Part, _pan, sleInt8, VER_V8),
     3247                MKLINE(Part, _on, sleUint8, VER_V8),
     3248                MKLINE(Part, _modwheel, sleUint8, VER_V8),
     3249                MKLINE(Part, _pedal, sleUint8, VER_V8),
     3250                MKLINE(Part, _program, sleUint8, VER_V8),
     3251                MKLINE(Part, _pri, sleUint8, VER_V8),
     3252                MKLINE(Part, _chan, sleUint8, VER_V8),
     3253                MKLINE(Part, _effect_level, sleUint8, VER_V8),
     3254                MKLINE(Part, _chorus, sleUint8, VER_V8),
     3255                MKLINE(Part, _percussion, sleUint8, VER_V8),
     3256                MKLINE(Part, _bank, sleUint8, VER_V8),
    32553257                MKEND()
    32563258        };
    32573259
     
    32643266#endif
    32653267
    32663268        ser->_ref_me = this;
    3267         ser->_saveload_ref = ser->isSaving()? ((void *)&saveReference) : ((void *)&loadReference);
     3269        ser->_save_ref = saveReference;
     3270        ser->_load_ref = loadReference;
    32683271
    32693272        ser->saveLoadEntries(this, mainEntries);
    32703273        ser->saveLoadArrayOf(_players, ARRAYSIZE(_players), sizeof(_players[0]), playerEntries);
  • scumm/saveload.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
    retrieving revision 1.25
    diff -u -r1.25 saveload.cpp
     
    3838        char name[32];
    3939};
    4040
    41 // Support for "old" savegames (made with 2501 CVS build)
    42 // Can be useful for other ports too :)
    43 
    44 #define VER_V9 9
    45 #define VER_V8 8
    46 #define VER_V7 7
    47 
    48 #define CURRENT_VER VER_V9
    49 
    50 static uint32 _current_version = CURRENT_VER;
    5141
    5242bool Scumm::saveState(int slot, bool compat)
    5343{
    5444        char filename[256];
    5545        SerializerStream out;
    5646        SaveGameHeader hdr;
    57         Serializer ser;
    5847
    5948        makeSavegameName(filename, slot, compat);
    6049
     
    6554
    6655        hdr.type = MKID('SCVM');
    6756        hdr.size = 0;
    68         hdr.ver = TO_LE_32(_current_version);
     57        hdr.ver = TO_LE_32(CURRENT_VER);
    6958
    7059        out.fwrite(&hdr, sizeof(hdr), 1);
    7160
    72         ser._saveLoadStream = out;
    73         ser._saveOrLoad = true;
     61        Serializer ser(out, true, CURRENT_VER);
     62
     63        _savegameVersion = CURRENT_VER;
    7464        saveOrLoad(&ser);
    7565
    7666        out.fclose();
     
    8474        SerializerStream out;
    8575        int i, j;
    8676        SaveGameHeader hdr;
    87         Serializer ser;
    8877        int sb, sh;
    8978
    9079        makeSavegameName(filename, slot, compat);
     
    10089
    10190        // In older versions of ScummVM, the header version was not endian safe.
    10291        // We account for that by retrying once with swapped byte order.
    103         if (hdr.ver < VER_V7 || hdr.ver > _current_version)
     92        if (hdr.ver > CURRENT_VER)
    10493                hdr.ver = SWAP_BYTES(hdr.ver);
    105         if (hdr.ver < VER_V7 || hdr.ver > _current_version)
     94        if (hdr.ver < VER_V7 || hdr.ver > CURRENT_VER)
    10695        {
    10796                warning("Invalid version of '%s'", filename);
    10897                out.fclose();
    10998                return false;
    11099        }
    111 
    112         _current_version = hdr.ver;
     100       
     101        // Due to a bug in scummvm up to and including 0.3.0, save games could be saved
     102        // in the V8/V9 format but were tagged with a V7 mark. Ouch. So we just pretend V7 == V8 here
     103        if (hdr.ver == VER_V7)
     104                hdr.ver = VER_V8;
     105
     106        // _savegameVersion is set so that the load code can know which data format to expect
     107        _savegameVersion = hdr.ver;
     108       
    113109        memcpy(_saveLoadName, hdr.name, sizeof(hdr.name));
    114110
    115111        if (_imuseDigital) {
     
    133129
    134130        initScummVars();
    135131
    136         ser._saveLoadStream = out;
    137         ser._saveOrLoad = false;
     132        Serializer ser(out, false, _savegameVersion);
    138133        saveOrLoad(&ser);
    139134        out.fclose();
    140135
     
    181176{
    182177        const char *dir = getSavePath();
    183178
    184         // snprintf should be used here, but it's not portable enough
    185179        sprintf(out, "%s%s.%c%.2d", dir, _game_name, compatible ? 'c' : 's', slot);
    186180}
    187181
     
    205199                return false;
    206200        }
    207201
    208         if (hdr.ver < VER_V7 || hdr.ver > _current_version)
     202        if (hdr.ver > CURRENT_VER)
    209203                hdr.ver = TO_LE_32(hdr.ver);
    210         if (hdr.ver < VER_V7 || hdr.ver > _current_version) {
     204        if (hdr.ver < VER_V7 || hdr.ver > CURRENT_VER) {
    211205                strcpy(desc, "Invalid version");
    212206                return false;
    213207        }
     
    220214void Scumm::saveOrLoad(Serializer *s)
    221215{
    222216        const SaveLoadEntry objectEntries[] = {
    223                 MKLINE(ObjectData, offs_obim_to_room, sleUint32),
    224                 MKLINE(ObjectData, offs_obcd_to_room, sleUint32),
    225                 MKLINE(ObjectData, walk_x, sleUint16),
    226                 MKLINE(ObjectData, walk_y, sleUint16),
    227                 MKLINE(ObjectData, obj_nr, sleUint16),
    228                 MKLINE(ObjectData, x_pos, sleInt16),
    229                 MKLINE(ObjectData, y_pos, sleInt16),
    230                 MKLINE(ObjectData, width, sleUint16),
    231                 MKLINE(ObjectData, height, sleUint16),
    232                 MKLINE(ObjectData, actordir, sleByte),
    233                 MKLINE(ObjectData, parentstate, sleByte),
    234                 MKLINE(ObjectData, parent, sleByte),
    235                 MKLINE(ObjectData, state, sleByte),
    236                 MKLINE(ObjectData, fl_object_index, sleByte),
     217                MKLINE(ObjectData, offs_obim_to_room, sleUint32, VER_V8),
     218                MKLINE(ObjectData, offs_obcd_to_room, sleUint32, VER_V8),
     219                MKLINE(ObjectData, walk_x, sleUint16, VER_V8),
     220                MKLINE(ObjectData, walk_y, sleUint16, VER_V8),
     221                MKLINE(ObjectData, obj_nr, sleUint16, VER_V8),
     222                MKLINE(ObjectData, x_pos, sleInt16, VER_V8),
     223                MKLINE(ObjectData, y_pos, sleInt16, VER_V8),
     224                MKLINE(ObjectData, width, sleUint16, VER_V8),
     225                MKLINE(ObjectData, height, sleUint16, VER_V8),
     226                MKLINE(ObjectData, actordir, sleByte, VER_V8),
     227                MKLINE(ObjectData, parentstate, sleByte, VER_V8),
     228                MKLINE(ObjectData, parent, sleByte, VER_V8),
     229                MKLINE(ObjectData, state, sleByte, VER_V8),
     230                MKLINE(ObjectData, fl_object_index, sleByte, VER_V8),
    237231                MKEND()
    238232        };
    239233
    240234        const SaveLoadEntry actorEntries[] = {
    241                 MKLINE(Actor, x, sleInt16),
    242                 MKLINE(Actor, y, sleInt16),
    243                 MKLINE(Actor, top, sleInt16),
    244                 MKLINE(Actor, bottom, sleInt16),
    245                 MKLINE(Actor, elevation, sleInt16),
    246                 MKLINE(Actor, width, sleUint16),
    247                 MKLINE(Actor, facing, sleUint16),
    248                 MKLINE(Actor, costume, sleUint16),
    249                 MKLINE(Actor, room, sleByte),
    250                 MKLINE(Actor, talkColor, sleByte),
    251                 MKLINE(Actor, scalex, sleByte),
    252                 MKLINE(Actor, scaley, sleByte),
    253                 MKLINE(Actor, charset, sleByte),
    254                 MKARRAY(Actor, sound[0], sleByte, 8),
    255                 MKARRAY(Actor, animVariable[0], sleUint16, 8),
    256                 MKLINE(Actor, newDirection, sleUint16),
    257                 MKLINE(Actor, moving, sleByte),
    258                 MKLINE(Actor, ignoreBoxes, sleByte),
    259                 MKLINE(Actor, forceClip, sleByte),
    260                 MKLINE(Actor, initFrame, sleByte),
    261                 MKLINE(Actor, walkFrame, sleByte),
    262                 MKLINE(Actor, standFrame, sleByte),
    263                 MKLINE(Actor, talkFrame1, sleByte),
    264                 MKLINE(Actor, talkFrame2, sleByte),
    265                 MKLINE(Actor, speedx, sleUint16),
    266                 MKLINE(Actor, speedy, sleUint16),
    267                 MKLINE(Actor, cost.animCounter1, sleUint16),
    268                 MKLINE(Actor, cost.animCounter2, sleByte),
    269                 // TODO: increase actor palette to 256
    270                 MKARRAY(Actor, palette[0], sleByte, 64),
    271                 MKLINE(Actor, mask, sleByte), // FIXME: see actor.h comment
    272                 MKLINE(Actor, shadow_mode, sleByte),
    273                 MKLINE(Actor, visible, sleByte),
     235                MKLINE(Actor, x, sleInt16, VER_V8),
     236                MKLINE(Actor, y, sleInt16, VER_V8),
     237                MKLINE(Actor, top, sleInt16, VER_V8),
     238                MKLINE(Actor, bottom, sleInt16, VER_V8),
     239                MKLINE(Actor, elevation, sleInt16, VER_V8),
     240                MKLINE(Actor, width, sleUint16, VER_V8),
     241                MKLINE(Actor, facing, sleUint16, VER_V8),
     242                MKLINE(Actor, costume, sleUint16, VER_V8),
     243                MKLINE(Actor, room, sleByte, VER_V8),
     244                MKLINE(Actor, talkColor, sleByte, VER_V8),
     245                MKLINE(Actor, scalex, sleByte, VER_V8),
     246                MKLINE(Actor, scaley, sleByte, VER_V8),
     247                MKLINE(Actor, charset, sleByte, VER_V8),
     248                MKARRAY(Actor, sound[0], sleByte, 8, VER_V8),
     249                MKARRAY(Actor, animVariable[0], sleUint16, 8, VER_V8),
     250                MKLINE(Actor, newDirection, sleUint16, VER_V8),
     251                MKLINE(Actor, moving, sleByte, VER_V8),
     252                MKLINE(Actor, ignoreBoxes, sleByte, VER_V8),
     253                MKLINE(Actor, forceClip, sleByte, VER_V8),
     254                MKLINE(Actor, initFrame, sleByte, VER_V8),
     255                MKLINE(Actor, walkFrame, sleByte, VER_V8),
     256                MKLINE(Actor, standFrame, sleByte, VER_V8),
     257                MKLINE(Actor, talkFrame1, sleByte, VER_V8),
     258                MKLINE(Actor, talkFrame2, sleByte, VER_V8),
     259                MKLINE(Actor, speedx, sleUint16, VER_V8),
     260                MKLINE(Actor, speedy, sleUint16, VER_V8),
     261                MKLINE(Actor, cost.animCounter1, sleUint16, VER_V8),
     262                MKLINE(Actor, cost.animCounter2, sleByte, VER_V8),
     263
     264                // Actor palette grew from 64 to 256 bytes
     265                MKARRAY_OLD(Actor, palette[0], sleByte, 64, VER_V8, VER_V9),
     266                MKARRAY(Actor, palette[0], sleByte, 256, VER_V10),
     267
     268                MK_OBSOLETE(Actor, mask, sleByte, VER_V8, VER_V9),
     269                MKLINE(Actor, shadow_mode, sleByte, VER_V8),
     270                MKLINE(Actor, visible, sleByte, VER_V8),
    274271                // FIXME - frame is never set and thus always 0! See actor.h comment
    275                 MKLINE(Actor, frame, sleByte),
    276                 MKLINE(Actor, animSpeed, sleByte),
    277                 MKLINE(Actor, animProgress, sleByte),
    278                 MKLINE(Actor, walkbox, sleByte),
    279                 MKLINE(Actor, needRedraw, sleByte),
    280                 MKLINE(Actor, needBgReset, sleByte),
    281                 MKLINE(Actor, costumeNeedsInit, sleByte),
    282 
    283                 MKLINE(Actor, new_1, sleInt16),
    284                 MKLINE(Actor, new_2, sleInt16),
    285                 MKLINE(Actor, new_3, sleByte),
    286 
    287                 MKLINE(Actor, layer, sleByte),
    288 
    289                 MKLINE(Actor, talk_script, sleUint16),
    290                 MKLINE(Actor, walk_script, sleUint16),
    291 
    292                 MKLINE(Actor, walkdata.destx, sleInt16),
    293                 MKLINE(Actor, walkdata.desty, sleInt16),
    294                 MKLINE(Actor, walkdata.destbox, sleByte),
    295                 MKLINE(Actor, walkdata.destdir, sleUint16),
    296                 MKLINE(Actor, walkdata.curbox, sleByte),
    297                 MKLINE(Actor, walkdata.x, sleInt16),
    298                 MKLINE(Actor, walkdata.y, sleInt16),
    299                 MKLINE(Actor, walkdata.newx, sleInt16),
    300                 MKLINE(Actor, walkdata.newy, sleInt16),
    301                 MKLINE(Actor, walkdata.XYFactor, sleInt32),
    302                 MKLINE(Actor, walkdata.YXFactor, sleInt32),
    303                 MKLINE(Actor, walkdata.xfrac, sleUint16),
    304                 MKLINE(Actor, walkdata.yfrac, sleUint16),
    305 
    306                 MKARRAY(Actor, cost.active[0], sleByte, 16),
    307                 MKLINE(Actor, cost.stopped, sleUint16),
    308                 MKARRAY(Actor, cost.curpos[0], sleUint16, 16),
    309                 MKARRAY(Actor, cost.start[0], sleUint16, 16),
    310                 MKARRAY(Actor, cost.end[0], sleUint16, 16),
    311                 MKARRAY(Actor, cost.frame[0], sleUint16, 16),
     272                MKLINE(Actor, frame, sleByte, VER_V8),
     273                MKLINE(Actor, animSpeed, sleByte, VER_V8),
     274                MKLINE(Actor, animProgress, sleByte, VER_V8),
     275                MKLINE(Actor, walkbox, sleByte, VER_V8),
     276                MKLINE(Actor, needRedraw, sleByte, VER_V8),
     277                MKLINE(Actor, needBgReset, sleByte, VER_V8),
     278                MKLINE(Actor, costumeNeedsInit, sleByte, VER_V8),
     279
     280                MKLINE(Actor, new_1, sleInt16, VER_V8),
     281                MKLINE(Actor, new_2, sleInt16, VER_V8),
     282                MKLINE(Actor, new_3, sleByte, VER_V8),
     283
     284                MKLINE(Actor, layer, sleByte, VER_V8),
     285
     286                MKLINE(Actor, talk_script, sleUint16, VER_V8),
     287                MKLINE(Actor, walk_script, sleUint16, VER_V8),
     288
     289                MKLINE(Actor, walkdata.destx, sleInt16, VER_V8),
     290                MKLINE(Actor, walkdata.desty, sleInt16, VER_V8),
     291                MKLINE(Actor, walkdata.destbox, sleByte, VER_V8),
     292                MKLINE(Actor, walkdata.destdir, sleUint16, VER_V8),
     293                MKLINE(Actor, walkdata.curbox, sleByte, VER_V8),
     294                MKLINE(Actor, walkdata.x, sleInt16, VER_V8),
     295                MKLINE(Actor, walkdata.y, sleInt16, VER_V8),
     296                MKLINE(Actor, walkdata.newx, sleInt16, VER_V8),
     297                MKLINE(Actor, walkdata.newy, sleInt16, VER_V8),
     298                MKLINE(Actor, walkdata.XYFactor, sleInt32, VER_V8),
     299                MKLINE(Actor, walkdata.YXFactor, sleInt32, VER_V8),
     300                MKLINE(Actor, walkdata.xfrac, sleUint16, VER_V8),
     301                MKLINE(Actor, walkdata.yfrac, sleUint16, VER_V8),
     302
     303                MKARRAY(Actor, cost.active[0], sleByte, 16, VER_V8),
     304                MKLINE(Actor, cost.stopped, sleUint16, VER_V8),
     305                MKARRAY(Actor, cost.curpos[0], sleUint16, 16, VER_V8),
     306                MKARRAY(Actor, cost.start[0], sleUint16, 16, VER_V8),
     307                MKARRAY(Actor, cost.end[0], sleUint16, 16, VER_V8),
     308                MKARRAY(Actor, cost.frame[0], sleUint16, 16, VER_V8),
    312309                MKEND()
    313310        };
    314311
    315312        const SaveLoadEntry verbEntries[] = {
    316                 MKLINE(VerbSlot, x, sleInt16),
    317                 MKLINE(VerbSlot, y, sleInt16),
    318                 MKLINE(VerbSlot, right, sleInt16),
    319                 MKLINE(VerbSlot, bottom, sleInt16),
    320                 MKLINE(VerbSlot, oldleft, sleInt16),
    321                 MKLINE(VerbSlot, oldtop, sleInt16),
    322                 MKLINE(VerbSlot, oldright, sleInt16),
    323                 MKLINE(VerbSlot, oldbottom, sleInt16),
    324                 MKLINE(VerbSlot, verbid, sleByte),
    325                 MKLINE(VerbSlot, color, sleByte),
    326                 MKLINE(VerbSlot, hicolor, sleByte),
    327                 MKLINE(VerbSlot, dimcolor, sleByte),
    328                 MKLINE(VerbSlot, bkcolor, sleByte),
    329                 MKLINE(VerbSlot, type, sleByte),
    330                 MKLINE(VerbSlot, charset_nr, sleByte),
    331                 MKLINE(VerbSlot, curmode, sleByte),
    332                 MKLINE(VerbSlot, saveid, sleByte),
    333                 MKLINE(VerbSlot, key, sleByte),
    334                 MKLINE(VerbSlot, center, sleByte),
    335                 MKLINE(VerbSlot, field_1B, sleByte),
    336                 MKLINE(VerbSlot, imgindex, sleUint16),
    337                 MKEND()
    338         };
    339 
    340         const SaveLoadEntry mainEntriesV9[] = {
    341                 MKLINE(Scumm, _scrWidth, sleUint16),
    342                 MKLINE(Scumm, _scrHeight, sleUint16),
    343                 MKLINE(Scumm, _ENCD_offs, sleUint32),
    344                 MKLINE(Scumm, _EXCD_offs, sleUint32),
    345                 MKLINE(Scumm, _IM00_offs, sleUint32),
    346                 MKLINE(Scumm, _CLUT_offs, sleUint32),
    347                 /* XXX Remove _EPAL_offs next time format changes */
    348                 MKLINE(Scumm, _EPAL_offs, sleUint32),
    349                 MKLINE(Scumm, _PALS_offs, sleUint32),
    350                 MKLINE(Scumm, _curPalIndex, sleByte),
    351                 MKLINE(Scumm, _currentRoom, sleByte),
    352                 MKLINE(Scumm, _roomResource, sleByte),
    353                 MKLINE(Scumm, _numObjectsInRoom, sleByte),
    354                 MKLINE(Scumm, _currentScript, sleByte),
    355                 MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT),
    356                 MKARRAY(Scumm, vm.localvar[0][0], sleUint16, NUM_SCRIPT_SLOT * 17),
    357                 MKARRAY(Scumm, _resourceMapper[0], sleByte, 128),
    358                 MKARRAY(Scumm, charset._colorMap[0], sleByte, 16),
    359                 MKARRAY(Scumm, _charsetData[0][0], sleByte, 10 * 16),   // FIXME - _charsetData is 15*16 these days
    360                 MKLINE(Scumm, _curExecScript, sleUint16),
    361 
    362                 MKLINE(Scumm, camera._dest.x, sleInt16),
    363                 MKLINE(Scumm, camera._dest.y, sleInt16),
    364                 MKLINE(Scumm, camera._cur.x, sleInt16),
    365                 MKLINE(Scumm, camera._cur.y, sleInt16),
    366                 MKLINE(Scumm, camera._last.x, sleInt16),
    367                 MKLINE(Scumm, camera._last.y, sleInt16),
    368                 MKLINE(Scumm, camera._accel.x, sleInt16),
    369                 MKLINE(Scumm, camera._accel.y, sleInt16),
    370                 MKLINE(Scumm, _screenStartStrip, sleInt16),
    371                 MKLINE(Scumm, _screenEndStrip, sleInt16),
    372                 MKLINE(Scumm, camera._mode, sleByte),
    373                 MKLINE(Scumm, camera._follows, sleByte),
    374                 MKLINE(Scumm, camera._leftTrigger, sleInt16),
    375                 MKLINE(Scumm, camera._rightTrigger, sleInt16),
    376                 MKLINE(Scumm, camera._movingToActor, sleUint16),
    377 
    378                 MKLINE(Scumm, _actorToPrintStrFor, sleByte),
    379                 MKLINE(Scumm, _charsetColor, sleByte),
    380                 /* XXX Convert into word next time format changes */
    381                 MKLINE(Scumm, charset._bufPos, sleByte),
    382                 MKLINE(Scumm, _haveMsg, sleByte),
    383                 MKLINE(Scumm, _useTalkAnims, sleByte),
    384 
    385                 MKLINE(Scumm, _talkDelay, sleInt16),
    386                 MKLINE(Scumm, _defaultTalkDelay, sleInt16),
    387                 MKLINE(Scumm, _numInMsgStack, sleInt16),
    388                 MKLINE(Scumm, _sentenceNum, sleByte),
    389 
    390                 MKLINE(Scumm, vm.cutSceneStackPointer, sleByte),
    391                 MKARRAY(Scumm, vm.cutScenePtr[0], sleUint32, 5),
    392                 MKARRAY(Scumm, vm.cutSceneScript[0], sleByte, 5),
    393                 MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5),
    394                 MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16),
    395 
    396                 /* nest */
    397                 MKLINE(Scumm, _numNestedScripts, sleByte),
    398                 MKLINE(Scumm, _userPut, sleByte),
    399                 MKLINE(Scumm, _cursor.state, sleByte),
    400                 MKLINE(Scumm, gdi._cursorActive, sleByte),
    401                 MKLINE(Scumm, _currentCursor, sleByte),
    402 
    403                 MKLINE(Scumm, _doEffect, sleByte),
    404                 MKLINE(Scumm, _switchRoomEffect, sleByte),
    405                 MKLINE(Scumm, _newEffect, sleByte),
    406                 MKLINE(Scumm, _switchRoomEffect2, sleByte),
    407                 MKLINE(Scumm, _BgNeedsRedraw, sleByte),
    408 
    409                 // Jamieson630: variables for palManipulate
    410                 // TODO: Add these next time save game format changes.
    411                 // MKLINE(Scumm, _palManipStart, sleByte),
    412                 // MKLINE(Scumm, _palManipEnd, sleByte),
    413                 // MKLINE(Scumm, _palManipCounter, sleUint16),
    414 
    415                 // MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 410),
    416                 // replace below:
    417                 MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
    418                 MKLINE(Scumm, gdi._transparency, sleByte),
    419                 MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
    420 
    421                 MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256),
    422                 /* virtscr */
    423 
    424                 MKARRAY(Scumm, charset._buffer[0], sleByte, 256),
    425 
    426                 MKLINE(Scumm, _egoPositioned, sleByte),
    427 
    428                 // FIXME: Should be 5, not 4 :
    429                 MKARRAY(Scumm, gdi._imgBufOffs[0], sleUint16, 4),
    430                 MKLINE(Scumm, gdi._numZBuffer, sleByte),
    431 
    432                 MKLINE(Scumm, _screenEffectFlag, sleByte),
    433 
    434                 // FIXME: remove when new savegame system is implemented
    435                 MKLINE(Scumm, _randSeed1, sleUint32),
    436                 MKLINE(Scumm, _randSeed2, sleUint32),
    437 
    438                 /* XXX: next time the save game format changes,
    439                  * convert _shakeEnabled to boolean and add a _shakeFrame field */
    440                 MKLINE(Scumm, _shakeEnabled, sleInt16),
    441 
    442                 MKLINE(Scumm, _keepText, sleByte),
    443 
    444                 MKLINE(Scumm, _screenB, sleUint16),
    445                 MKLINE(Scumm, _screenH, sleUint16),
    446 
    447                 MKLINE(Scumm, _cd_track, sleInt16),     // FIXME - remove next time save format changes
    448                 MKLINE(Scumm, _cd_loops, sleInt16),     // FIXME - remove next time save format changes
    449                 MKLINE(Scumm, _cd_frame, sleInt16),     // FIXME - remove next time save format changes
    450                 MKLINE(Scumm, _cd_end, sleInt16),       // FIXME - remove next time save format changes
    451 
     313                MKLINE(VerbSlot, x, sleInt16, VER_V8),
     314                MKLINE(VerbSlot, y, sleInt16, VER_V8),
     315                MKLINE(VerbSlot, right, sleInt16, VER_V8),
     316                MKLINE(VerbSlot, bottom, sleInt16, VER_V8),
     317                MKLINE(VerbSlot, oldleft, sleInt16, VER_V8),
     318                MKLINE(VerbSlot, oldtop, sleInt16, VER_V8),
     319                MKLINE(VerbSlot, oldright, sleInt16, VER_V8),
     320                MKLINE(VerbSlot, oldbottom, sleInt16, VER_V8),
     321                MKLINE(VerbSlot, verbid, sleByte, VER_V8),
     322                MKLINE(VerbSlot, color, sleByte, VER_V8),
     323                MKLINE(VerbSlot, hicolor, sleByte, VER_V8),
     324                MKLINE(VerbSlot, dimcolor, sleByte, VER_V8),
     325                MKLINE(VerbSlot, bkcolor, sleByte, VER_V8),
     326                MKLINE(VerbSlot, type, sleByte, VER_V8),
     327                MKLINE(VerbSlot, charset_nr, sleByte, VER_V8),
     328                MKLINE(VerbSlot, curmode, sleByte, VER_V8),
     329                MKLINE(VerbSlot, saveid, sleByte, VER_V8),
     330                MKLINE(VerbSlot, key, sleByte, VER_V8),
     331                MKLINE(VerbSlot, center, sleByte, VER_V8),
     332                MKLINE(VerbSlot, field_1B, sleByte, VER_V8),
     333                MKLINE(VerbSlot, imgindex, sleUint16, VER_V8),
    452334                MKEND()
    453335        };
    454336
    455         const SaveLoadEntry mainEntriesV8[] = {
    456                 MKLINE(Scumm, _scrWidth, sleUint16),
    457                 MKLINE(Scumm, _scrHeight, sleUint16),
    458                 MKLINE(Scumm, _ENCD_offs, sleUint32),
    459                 MKLINE(Scumm, _EXCD_offs, sleUint32),
    460                 MKLINE(Scumm, _IM00_offs, sleUint32),
    461                 MKLINE(Scumm, _CLUT_offs, sleUint32),
    462                 /* XXX Remove _EPAL_offs next time format changes */
    463                 MKLINE(Scumm, _EPAL_offs, sleUint32),
    464                 MKLINE(Scumm, _PALS_offs, sleUint32),
    465                 MKLINE(Scumm, _curPalIndex, sleByte),
    466                 MKLINE(Scumm, _currentRoom, sleByte),
    467                 MKLINE(Scumm, _roomResource, sleByte),
    468                 MKLINE(Scumm, _numObjectsInRoom, sleByte),
    469                 MKLINE(Scumm, _currentScript, sleByte),
    470                 MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT),
    471                 MKARRAY(Scumm, vm.localvar[0][0], sleUint16, 25 * 17),
    472                 MKARRAY(Scumm, _resourceMapper[0], sleByte, 128),
    473                 MKARRAY(Scumm, charset._colorMap[0], sleByte, 16),
    474                 MKARRAY(Scumm, _charsetData[0][0], sleByte, 10 * 16),   // FIXME - _charsetData is 15*16 these days
    475                 MKLINE(Scumm, _curExecScript, sleUint16),
    476 
    477                 MKLINE(Scumm, camera._dest.x, sleInt16),
    478                 MKLINE(Scumm, camera._dest.y, sleInt16),
    479                 MKLINE(Scumm, camera._cur.x, sleInt16),
    480                 MKLINE(Scumm, camera._cur.y, sleInt16),
    481                 MKLINE(Scumm, camera._last.x, sleInt16),
    482                 MKLINE(Scumm, camera._last.y, sleInt16),
    483                 MKLINE(Scumm, camera._accel.x, sleInt16),
    484                 MKLINE(Scumm, camera._accel.y, sleInt16),
    485                 MKLINE(Scumm, _screenStartStrip, sleInt16),
    486                 MKLINE(Scumm, _screenEndStrip, sleInt16),
    487                 MKLINE(Scumm, camera._mode, sleByte),
    488                 MKLINE(Scumm, camera._follows, sleByte),
    489                 MKLINE(Scumm, camera._leftTrigger, sleInt16),
    490                 MKLINE(Scumm, camera._rightTrigger, sleInt16),
    491                 MKLINE(Scumm, camera._movingToActor, sleUint16),
    492 
    493                 MKLINE(Scumm, _actorToPrintStrFor, sleByte),
    494                 MKLINE(Scumm, _charsetColor, sleByte),
    495                 /* XXX Convert into word next time format changes */
    496                 MKLINE(Scumm, charset._bufPos, sleByte),
    497                 MKLINE(Scumm, _haveMsg, sleByte),
    498                 MKLINE(Scumm, _useTalkAnims, sleByte),
    499 
    500                 MKLINE(Scumm, _talkDelay, sleInt16),
    501                 MKLINE(Scumm, _defaultTalkDelay, sleInt16),
    502                 MKLINE(Scumm, _numInMsgStack, sleInt16),
    503                 MKLINE(Scumm, _sentenceNum, sleByte),
    504 
    505                 MKLINE(Scumm, vm.cutSceneStackPointer, sleByte),
    506                 MKARRAY(Scumm, vm.cutScenePtr[0], sleUint32, 5),
    507                 MKARRAY(Scumm, vm.cutSceneScript[0], sleByte, 5),
    508                 MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5),
    509                 MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16),
    510 
    511                 /* nest */
    512                 MKLINE(Scumm, _numNestedScripts, sleByte),
    513                 MKLINE(Scumm, _userPut, sleByte),
    514                 MKLINE(Scumm, _cursor.state, sleByte),
    515                 MKLINE(Scumm, gdi._cursorActive, sleByte),
    516                 MKLINE(Scumm, _currentCursor, sleByte),
    517 
    518                 MKLINE(Scumm, _doEffect, sleByte),
    519                 MKLINE(Scumm, _switchRoomEffect, sleByte),
    520                 MKLINE(Scumm, _newEffect, sleByte),
    521                 MKLINE(Scumm, _switchRoomEffect2, sleByte),
    522                 MKLINE(Scumm, _BgNeedsRedraw, sleByte),
    523 
    524                 // Jamieson630: variables for palManipulate
    525                 // TODO: Add these next time save game format changes.
    526                 // MKLINE(Scumm, _palManipStart, sleByte),
    527                 // MKLINE(Scumm, _palManipEnd, sleByte),
    528                 // MKLINE(Scumm, _palManipCounter, sleUint16),
    529 
    530                 // MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 410),
    531                 // replace below:
    532                 MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
    533                 MKLINE(Scumm, gdi._transparency, sleByte),
    534                 MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
    535 
    536                 MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256),
    537                 /* virtscr */
    538 
    539                 MKARRAY(Scumm, charset._buffer[0], sleByte, 256),
    540 
    541                 MKLINE(Scumm, _egoPositioned, sleByte),
    542 
    543                 // FIXME: Should be 5, not 4 :
    544                 MKARRAY(Scumm, gdi._imgBufOffs[0], sleUint16, 4),
    545                 MKLINE(Scumm, gdi._numZBuffer, sleByte),
    546 
    547                 MKLINE(Scumm, _screenEffectFlag, sleByte),
    548 
    549                 // FIXME: remove when new savegame system is implemented
    550                 MKLINE(Scumm, _randSeed1, sleUint32),
    551                 MKLINE(Scumm, _randSeed2, sleUint32),
    552 
    553                 /* XXX: next time the save game format changes,
    554                  * convert _shakeEnabled to boolean and add a _shakeFrame field */
    555                 MKLINE(Scumm, _shakeEnabled, sleInt16),
    556 
    557                 MKLINE(Scumm, _keepText, sleByte),
    558 
    559                 MKLINE(Scumm, _screenB, sleUint16),
    560                 MKLINE(Scumm, _screenH, sleUint16),
    561 
     337        const SaveLoadEntry mainEntries[] = {
     338                MKLINE(Scumm, _scrWidth, sleUint16, VER_V8),
     339                MKLINE(Scumm, _scrHeight, sleUint16, VER_V8),
     340                MKLINE(Scumm, _ENCD_offs, sleUint32, VER_V8),
     341                MKLINE(Scumm, _EXCD_offs, sleUint32, VER_V8),
     342                MKLINE(Scumm, _IM00_offs, sleUint32, VER_V8),
     343                MKLINE(Scumm, _CLUT_offs, sleUint32, VER_V8),
     344                MK_OBSOLETE(Scumm, _EPAL_offs, sleUint32, VER_V8, VER_V9),
     345                MKLINE(Scumm, _PALS_offs, sleUint32, VER_V8),
     346                MKLINE(Scumm, _curPalIndex, sleByte, VER_V8),
     347                MKLINE(Scumm, _currentRoom, sleByte, VER_V8),
     348                MKLINE(Scumm, _roomResource, sleByte, VER_V8),
     349                MKLINE(Scumm, _numObjectsInRoom, sleByte, VER_V8),
     350                MKLINE(Scumm, _currentScript, sleByte, VER_V8),
     351                MKARRAY(Scumm, _localScriptList[0], sleUint32, NUM_LOCALSCRIPT, VER_V8),
     352
     353                // vm.localvar grew from 25 to 40 entries
     354                MKARRAY_OLD(Scumm, vm.localvar[0][0], sleUint16, 25 * 17, VER_V8, VER_V8),
     355                MKARRAY(Scumm, vm.localvar[0][0], sleUint16, NUM_SCRIPT_SLOT * 17, VER_V9),
     356
     357                MKARRAY(Scumm, _resourceMapper[0], sleByte, 128, VER_V8),
     358                MKARRAY(Scumm, charset._colorMap[0], sleByte, 16, VER_V8),
     359               
     360                // _charsetData grew from 10*16 to 15*16 bytes
     361                MKARRAY_OLD(Scumm, _charsetData[0][0], sleByte, 10 * 16, VER_V8, VER_V9),
     362                MKARRAY(Scumm, _charsetData[0][0], sleByte, 15 * 16, VER_V10),
     363
     364                MKLINE(Scumm, _curExecScript, sleUint16, VER_V8),
     365
     366                MKLINE(Scumm, camera._dest.x, sleInt16, VER_V8),
     367                MKLINE(Scumm, camera._dest.y, sleInt16, VER_V8),
     368                MKLINE(Scumm, camera._cur.x, sleInt16, VER_V8),
     369                MKLINE(Scumm, camera._cur.y, sleInt16, VER_V8),
     370                MKLINE(Scumm, camera._last.x, sleInt16, VER_V8),
     371                MKLINE(Scumm, camera._last.y, sleInt16, VER_V8),
     372                MKLINE(Scumm, camera._accel.x, sleInt16, VER_V8),
     373                MKLINE(Scumm, camera._accel.y, sleInt16, VER_V8),
     374                MKLINE(Scumm, _screenStartStrip, sleInt16, VER_V8),
     375                MKLINE(Scumm, _screenEndStrip, sleInt16, VER_V8),
     376                MKLINE(Scumm, camera._mode, sleByte, VER_V8),
     377                MKLINE(Scumm, camera._follows, sleByte, VER_V8),
     378                MKLINE(Scumm, camera._leftTrigger, sleInt16, VER_V8),
     379                MKLINE(Scumm, camera._rightTrigger, sleInt16, VER_V8),
     380                MKLINE(Scumm, camera._movingToActor, sleUint16, VER_V8),
     381
     382                MKLINE(Scumm, _actorToPrintStrFor, sleByte, VER_V8),
     383                MKLINE(Scumm, _charsetColor, sleByte, VER_V8),
     384
     385                // charset._bufPos was changed from byte to int
     386                MKLINE_OLD(Scumm, charset._bufPos, sleByte, VER_V8, VER_V9),
     387                MKLINE(Scumm, charset._bufPos, sleInt16, VER_V10),
     388
     389                MKLINE(Scumm, _haveMsg, sleByte, VER_V8),
     390                MKLINE(Scumm, _useTalkAnims, sleByte, VER_V8),
     391
     392                MKLINE(Scumm, _talkDelay, sleInt16, VER_V8),
     393                MKLINE(Scumm, _defaultTalkDelay, sleInt16, VER_V8),
     394                MKLINE(Scumm, _numInMsgStack, sleInt16, VER_V8),
     395                MKLINE(Scumm, _sentenceNum, sleByte, VER_V8),
     396
     397                MKLINE(Scumm, vm.cutSceneStackPointer, sleByte, VER_V8),
     398                MKARRAY(Scumm, vm.cutScenePtr[0], sleUint32, 5, VER_V8),
     399                MKARRAY(Scumm, vm.cutSceneScript[0], sleByte, 5, VER_V8),
     400                MKARRAY(Scumm, vm.cutSceneData[0], sleInt16, 5, VER_V8),
     401                MKLINE(Scumm, vm.cutSceneScriptIndex, sleInt16, VER_V8),
     402
     403                MKLINE(Scumm, _numNestedScripts, sleByte, VER_V8),
     404                MKLINE(Scumm, _userPut, sleByte, VER_V8),
     405                MKLINE(Scumm, _cursor.state, sleByte, VER_V8),
     406                MKLINE(Scumm, gdi._cursorActive, sleByte, VER_V8),
     407                MKLINE(Scumm, _currentCursor, sleByte, VER_V8),
     408
     409                MKLINE(Scumm, _doEffect, sleByte, VER_V8),
     410                MKLINE(Scumm, _switchRoomEffect, sleByte, VER_V8),
     411                MKLINE(Scumm, _newEffect, sleByte, VER_V8),
     412                MKLINE(Scumm, _switchRoomEffect2, sleByte, VER_V8),
     413                MKLINE(Scumm, _BgNeedsRedraw, sleByte, VER_V8),
     414
     415                // The state of palManipulate is stored only since V10
     416                MKLINE(Scumm, _palManipStart, sleByte, VER_V10),
     417                MKLINE(Scumm, _palManipEnd, sleByte, VER_V10),
     418                MKLINE(Scumm, _palManipCounter, sleUint16, VER_V10),
     419
     420                // gfxUsageBits grew from 200 to 410 entries:
     421                MKARRAY_OLD(Scumm, gfxUsageBits[0], sleUint32, 200, VER_V8, VER_V9),
     422                MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 410, VER_V10),
     423
     424                MKLINE(Scumm, gdi._transparency, sleByte, VER_V8),
     425                MKARRAY(Scumm, _currentPalette[0], sleByte, 768, VER_V8),
     426
     427                MKARRAY(Scumm, _proc_special_palette[0], sleByte, 256, VER_V8),
     428
     429                MKARRAY(Scumm, charset._buffer[0], sleByte, 256, VER_V8),
     430
     431                MKLINE(Scumm, _egoPositioned, sleByte, VER_V8),
     432
     433                // gdi._imgBufOffs grew from 4 to 5 entries :
     434                MKARRAY_OLD(Scumm, gdi._imgBufOffs[0], sleUint16, 4, VER_V8, VER_V9),
     435                MKARRAY(Scumm, gdi._imgBufOffs[0], sleUint16, 5, VER_V10),
     436
     437                MKLINE(Scumm, gdi._numZBuffer, sleByte, VER_V8),
     438
     439                MKLINE(Scumm, _screenEffectFlag, sleByte, VER_V8),
     440
     441                MK_OBSOLETE(Scumm, _randSeed1, sleUint32, VER_V8, VER_V9),
     442                MK_OBSOLETE(Scumm, _randSeed2, sleUint32, VER_V8, VER_V9),
     443
     444                // Converted _shakeEnabled to boolean and added a _shakeFrame field.
     445                MKLINE_OLD(Scumm, _shakeEnabled, sleInt16, VER_V8, VER_V9),
     446                MKLINE(Scumm, _shakeEnabled, sleByte, VER_V10),
     447                MKLINE(Scumm, _shakeFrame, sleUint32, VER_V10),
     448
     449                MKLINE(Scumm, _keepText, sleByte, VER_V8),
     450
     451                MKLINE(Scumm, _screenB, sleUint16, VER_V8),
     452                MKLINE(Scumm, _screenH, sleUint16, VER_V8),
     453
     454                MK_OBSOLETE(Scumm, _cd_track, sleInt16, VER_V9, VER_V9),
     455                MK_OBSOLETE(Scumm, _cd_loops, sleInt16, VER_V9, VER_V9),
     456                MK_OBSOLETE(Scumm, _cd_frame, sleInt16, VER_V9, VER_V9),
     457                MK_OBSOLETE(Scumm, _cd_end, sleInt16, VER_V9, VER_V9),
     458               
    562459                MKEND()
    563460        };
    564461
    565462        const SaveLoadEntry scriptSlotEntries[] = {
    566                 MKLINE(ScriptSlot, offs, sleUint32),
    567                 MKLINE(ScriptSlot, delay, sleInt32),
    568                 MKLINE(ScriptSlot, number, sleUint16),
    569                 MKLINE(ScriptSlot, delayFrameCount, sleUint16),
    570                 MKLINE(ScriptSlot, status, sleByte),
    571                 MKLINE(ScriptSlot, where, sleByte),
    572                 MKLINE(ScriptSlot, unk1, sleByte),
    573                 MKLINE(ScriptSlot, unk2, sleByte),
    574                 MKLINE(ScriptSlot, freezeCount, sleByte),
    575                 MKLINE(ScriptSlot, didexec, sleByte),
    576                 MKLINE(ScriptSlot, cutsceneOverride, sleByte),
    577                 MKLINE(ScriptSlot, unk5, sleByte),
     463                MKLINE(ScriptSlot, offs, sleUint32, VER_V8),
     464                MKLINE(ScriptSlot, delay, sleInt32, VER_V8),
     465                MKLINE(ScriptSlot, number, sleUint16, VER_V8),
     466                MKLINE(ScriptSlot, delayFrameCount, sleUint16, VER_V8),
     467                MKLINE(ScriptSlot, status, sleByte, VER_V8),
     468                MKLINE(ScriptSlot, where, sleByte, VER_V8),
     469                MKLINE(ScriptSlot, unk1, sleByte, VER_V8),
     470                MKLINE(ScriptSlot, unk2, sleByte, VER_V8),
     471                MKLINE(ScriptSlot, freezeCount, sleByte, VER_V8),
     472                MKLINE(ScriptSlot, didexec, sleByte, VER_V8),
     473                MKLINE(ScriptSlot, cutsceneOverride, sleByte, VER_V8),
     474                MKLINE(ScriptSlot, unk5, sleByte, VER_V8),
    578475                MKEND()
    579476        };
    580477
    581478        const SaveLoadEntry nestedScriptEntries[] = {
    582                 MKLINE(NestedScript, number, sleUint16),
    583                 MKLINE(NestedScript, where, sleByte),
    584                 MKLINE(NestedScript, slot, sleByte),
     479                MKLINE(NestedScript, number, sleUint16, VER_V8),
     480                MKLINE(NestedScript, where, sleByte, VER_V8),
     481                MKLINE(NestedScript, slot, sleByte, VER_V8),
    585482                MKEND()
    586483        };
    587484
    588485        const SaveLoadEntry sentenceTabEntries[] = {
    589                 MKLINE(SentenceTab, unk5, sleUint8),
    590                 MKLINE(SentenceTab, unk2, sleUint8),
    591                 MKLINE(SentenceTab, unk4, sleUint16),
    592                 MKLINE(SentenceTab, unk3, sleUint16),
    593                 MKLINE(SentenceTab, unk, sleUint8),
     486                MKLINE(SentenceTab, unk5, sleUint8, VER_V8),
     487                MKLINE(SentenceTab, unk2, sleUint8, VER_V8),
     488                MKLINE(SentenceTab, unk4, sleUint16, VER_V8),
     489                MKLINE(SentenceTab, unk3, sleUint16, VER_V8),
     490                MKLINE(SentenceTab, unk, sleUint8, VER_V8),
    594491                MKEND()
    595492        };
    596493
    597494        const SaveLoadEntry stringTabEntries[] = {
    598495                // TODO - It makes no sense to have all these t_* fields in StringTab
    599496                // Rather let's dump them all when the save game format changes, and
    600                 // keep two StringTab objects: one normal, and a "t_" one.
    601                 // Then copying them can be done in one line etc.
    602                 MKLINE(StringTab, xpos, sleInt16),
    603                 MKLINE(StringTab, t_xpos, sleInt16),
    604                 MKLINE(StringTab, ypos, sleInt16),
    605                 MKLINE(StringTab, t_ypos, sleInt16),
    606                 MKLINE(StringTab, right, sleInt16),
    607                 MKLINE(StringTab, t_right, sleInt16),
    608                 MKLINE(StringTab, color, sleInt8),
    609                 MKLINE(StringTab, t_color, sleInt8),
    610                 MKLINE(StringTab, charset, sleInt8),
    611                 MKLINE(StringTab, t_charset, sleInt8),
    612                 MKLINE(StringTab, center, sleByte),
    613                 MKLINE(StringTab, t_center, sleByte),
    614                 MKLINE(StringTab, overhead, sleByte),
    615                 MKLINE(StringTab, t_overhead, sleByte),
    616                 MKLINE(StringTab, no_talk_anim, sleByte),
    617                 MKLINE(StringTab, t_no_talk_anim, sleByte),
     497                // keep two StringTab objects where we have one now: a "normal" one,
     498                // and a temporar y"t_" one.
     499                // Then backup/restore of a StringTab entry becomes a one liner.
     500                MKLINE(StringTab, xpos, sleInt16, VER_V8),
     501                MKLINE(StringTab, t_xpos, sleInt16, VER_V8),
     502                MKLINE(StringTab, ypos, sleInt16, VER_V8),
     503                MKLINE(StringTab, t_ypos, sleInt16, VER_V8),
     504                MKLINE(StringTab, right, sleInt16, VER_V8),
     505                MKLINE(StringTab, t_right, sleInt16, VER_V8),
     506                MKLINE(StringTab, color, sleInt8, VER_V8),
     507                MKLINE(StringTab, t_color, sleInt8, VER_V8),
     508                MKLINE(StringTab, charset, sleInt8, VER_V8),
     509                MKLINE(StringTab, t_charset, sleInt8, VER_V8),
     510                MKLINE(StringTab, center, sleByte, VER_V8),
     511                MKLINE(StringTab, t_center, sleByte, VER_V8),
     512                MKLINE(StringTab, overhead, sleByte, VER_V8),
     513                MKLINE(StringTab, t_overhead, sleByte, VER_V8),
     514                MKLINE(StringTab, no_talk_anim, sleByte, VER_V8),
     515                MKLINE(StringTab, t_no_talk_anim, sleByte, VER_V8),
    618516                MKEND()
    619517        };
    620518
    621519        const SaveLoadEntry colorCycleEntries[] = {
    622                 MKLINE(ColorCycle, delay, sleUint16),
    623                 MKLINE(ColorCycle, counter, sleUint16),
    624                 MKLINE(ColorCycle, flags, sleUint16),
    625                 MKLINE(ColorCycle, start, sleByte),
    626                 MKLINE(ColorCycle, end, sleByte),
     520                MKLINE(ColorCycle, delay, sleUint16, VER_V8),
     521                MKLINE(ColorCycle, counter, sleUint16, VER_V8),
     522                MKLINE(ColorCycle, flags, sleUint16, VER_V8),
     523                MKLINE(ColorCycle, start, sleByte, VER_V8),
     524                MKLINE(ColorCycle, end, sleByte, VER_V8),
    627525                MKEND()
    628526        };
    629527
     
    639537                }
    640538        }
    641539
    642         if (_current_version == VER_V9)
    643                 s->saveLoadEntries(this, mainEntriesV9);
    644         else
    645                 s->saveLoadEntries(this, mainEntriesV8);
     540        s->saveLoadEntries(this, mainEntries);
    646541
    647542        s->saveLoadArrayOf(_actors, NUM_ACTORS, sizeof(_actors[0]), actorEntries);
    648543
    649         if (_current_version < VER_V9)
     544        if (_savegameVersion < VER_V9)
    650545                s->saveLoadArrayOf(vm.slot, 25, sizeof(vm.slot[0]), scriptSlotEntries);
    651546        else
    652547                s->saveLoadArrayOf(vm.slot, NUM_SCRIPT_SLOT, sizeof(vm.slot[0]), scriptSlotEntries);
     548
    653549        s->saveLoadArrayOf(_objs, _numLocalObjects, sizeof(_objs[0]), objectEntries);
    654550        s->saveLoadArrayOf(_verbs, _numVerbs, sizeof(_verbs[0]), verbEntries);
    655551        s->saveLoadArrayOf(vm.nest, 16, sizeof(vm.nest[0]), nestedScriptEntries);
     
    671567        if (_shadowPaletteSize)
    672568                s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte);
    673569
    674         _palManipCounter = 0; // TODO: Remove this once it's being loaded from disk
     570        // PalManip data was not saved before V10 save games
     571        if (_savegameVersion < VER_V10)
     572                _palManipCounter = 0;
    675573        if (_palManipCounter) {
    676574                if (!_palManipPalette)
    677575                        _palManipPalette = (byte *)calloc(0x300, 1);
     
    817715        return e;
    818716}
    819717
    820 void Serializer::saveLoadArrayOf(void *b, int len, int datasize, byte filetype)
     718void Serializer::saveArrayOf(void *b, int len, int datasize, byte filetype)
    821719{
    822720        byte *at = (byte *)b;
    823721        uint32 data;
    824722
    825         /* speed up byte arrays */
     723        // speed up byte arrays
    826724        if (datasize == 1 && filetype == sleByte) {
    827                 if (isSaving())
    828                         saveBytes(b, len);
    829                 else
    830                         loadBytes(b, len);
     725                saveBytes(b, len);
    831726                return;
    832727        }
    833728
    834729        while (--len >= 0) {
    835                 if (isSaving()) {
    836                         /* saving */
    837                         if (datasize == 1) {
    838                                 data = *(byte *)at;
    839                                 at += 1;
    840                         } else if (datasize == 2) {
    841                                 data = *(uint16 *)at;
    842                                 at += 2;
    843                         } else if (datasize == 4) {
    844                                 data = *(uint32 *)at;
    845                                 at += 4;
    846                         } else {
    847                                 error("saveLoadArrayOf: invalid size %d", datasize);
    848                         }
    849                         switch (filetype) {
    850                         case sleByte:
    851                                 saveByte((byte)data);
    852                                 break;
    853                         case sleUint16:
    854                         case sleInt16:
    855                                 saveWord((int16)data);
    856                                 break;
    857                         case sleInt32:
    858                         case sleUint32:
    859                                 saveUint32(data);
    860                                 break;
    861                         default:
    862                                 error("saveLoadArrayOf: invalid filetype %d", filetype);
    863                         }
     730                if (datasize == 1) {
     731                        data = *(byte *)at;
     732                        at += 1;
     733                } else if (datasize == 2) {
     734                        data = *(uint16 *)at;
     735                        at += 2;
     736                } else if (datasize == 4) {
     737                        data = *(uint32 *)at;
     738                        at += 4;
    864739                } else {
    865                         /* loading */
    866                         switch (filetype) {
    867                         case sleByte:
    868                                 data = loadByte();
    869                                 break;
    870                         case sleUint16:
    871                                 data = loadWord();
    872                                 break;
    873                         case sleInt16:
    874                                 data = (int16)loadWord();
    875                                 break;
    876                         case sleUint32:
    877                                 data = loadUint32();
    878                                 break;
    879                         case sleInt32:
    880                                 data = (int32)loadUint32();
    881                                 break;
    882                         default:
    883                                 error("saveLoadArrayOf: invalid filetype %d", filetype);
    884                         }
    885                         if (datasize == 1) {
    886                                 *(byte *)at = (byte)data;
    887                                 at += 1;
    888                         } else if (datasize == 2) {
    889                                 *(uint16 *)at = (uint16)data;
    890                                 at += 2;
    891                         } else if (datasize == 4) {
    892                                 *(uint32 *)at = data;
    893                                 at += 4;
    894                         } else {
    895                                 error("saveLoadArrayOf: invalid size %d", datasize);
    896                         }
     740                        error("saveLoadArrayOf: invalid size %d", datasize);
     741                }
     742                switch (filetype) {
     743                case sleByte:
     744                        saveByte((byte)data);
     745                        break;
     746                case sleUint16:
     747                case sleInt16:
     748                        saveWord((int16)data);
     749                        break;
     750                case sleInt32:
     751                case sleUint32:
     752                        saveUint32(data);
     753                        break;
     754                default:
     755                        error("saveLoadArrayOf: invalid filetype %d", filetype);
     756                }
     757        }
     758}
     759
     760void Serializer::loadArrayOf(void *b, int len, int datasize, byte filetype)
     761{
     762        byte *at = (byte *)b;
     763        uint32 data;
     764
     765        // speed up byte arrays
     766        if (datasize == 1 && filetype == sleByte) {
     767                loadBytes(b, len);
     768                return;
     769        }
     770
     771        while (--len >= 0) {
     772                switch (filetype) {
     773                case sleByte:
     774                        data = loadByte();
     775                        break;
     776                case sleUint16:
     777                        data = loadWord();
     778                        break;
     779                case sleInt16:
     780                        data = (int16)loadWord();
     781                        break;
     782                case sleUint32:
     783                        data = loadUint32();
     784                        break;
     785                case sleInt32:
     786                        data = (int32)loadUint32();
     787                        break;
     788                default:
     789                        error("saveLoadArrayOf: invalid filetype %d", filetype);
     790                }
     791                if (datasize == 0) {
     792                        // Do nothing for obsolete data
     793                } else if (datasize == 1) {
     794                        *(byte *)at = (byte)data;
     795                        at += 1;
     796                } else if (datasize == 2) {
     797                        *(uint16 *)at = (uint16)data;
     798                        at += 2;
     799                } else if (datasize == 4) {
     800                        *(uint32 *)at = data;
     801                        at += 4;
     802                } else {
     803                        error("saveLoadArrayOf: invalid size %d", datasize);
    897804                }
    898805        }
    899806}
     
    902809{
    903810        byte *data = (byte *)b;
    904811
    905         while (--num >= 0) {
    906                 saveLoadEntries(data, sle);
    907                 data += datasize;
     812        if (isSaving()) {
     813                while (--num >= 0) {
     814                        saveEntries(data, sle);
     815                        data += datasize;
     816                }
     817        } else {
     818                while (--num >= 0) {
     819                        loadEntries(data, sle);
     820                        data += datasize;
     821                }
    908822        }
    909823}
    910824
     825void Serializer::saveLoadArrayOf(void *b, int len, int datasize, byte filetype)
     826{
     827        if (isSaving())
     828                saveArrayOf(b, len, datasize, filetype);
     829        else
     830                loadArrayOf(b, len, datasize, filetype);
     831}
    911832
    912833void Serializer::saveLoadEntries(void *d, const SaveLoadEntry *sle)
    913834{
    914         int replen;
     835        if (isSaving())
     836                saveEntries(d, sle);
     837        else
     838                loadEntries(d, sle);
     839}
     840
     841void Serializer::saveEntries(void *d, const SaveLoadEntry *sle)
     842{
    915843        byte type;
    916844        byte *at;
    917845        int size;
    918         int num;
    919         void *ptr;
    920846
    921847        while (sle->offs != 0xFFFF) {
    922848                at = (byte *)d + sle->offs;
    923849                size = sle->size;
    924850                type = sle->type;
    925851
    926                 if (size == 0xFF) {
    927                         if (isSaving()) {
    928                                 /* save reference */
    929                                 ptr = *((void **)at);
    930                                 saveWord(ptr ? ((*_save_ref) (_ref_me, type, ptr) + 1) : 0);
    931                         } else {
    932                                 /* load reference */
    933                                 num = loadWord();
    934                                 *((void **)at) = num ? (*_load_ref) (_ref_me, type, num - 1) : NULL;
     852                if (sle->maxVersion != CURRENT_VER) {
     853                        // Skip obsolete entries
     854                        if (type & 128)
     855                                sle++;
     856                } else if (size == 0xFF) {
     857                        // save reference
     858                        void *ptr = *((void **)at);
     859                        saveWord(ptr ? ((*_save_ref) (_ref_me, type, ptr) + 1) : 0);
     860                } else {
     861                        // save entry
     862                        int replen = 1;
     863                        if (type & 128) {
     864                                sle++;
     865                                replen = sle->offs;
     866                                type &= ~128;
    935867                        }
     868                        saveArrayOf(at, replen, size, type);
     869                }
     870                sle++;
     871        }
     872}
     873
     874void Serializer::loadEntries(void *d, const SaveLoadEntry *sle)
     875{
     876        byte type;
     877        byte *at;
     878        int size;
     879
     880        while (sle->offs != 0xFFFF) {
     881                at = (byte *)d + sle->offs;
     882                size = sle->size;
     883                type = sle->type;
     884
     885                if (_savegameVersion < sle->minVersion || _savegameVersion > sle->maxVersion) {
     886                        // Skip entries which are not present in this save game version
     887                        if (type & 128)
     888                                sle++;
     889                } else if (size == 0xFF) {
     890                        // load reference...
     891                        int num = loadWord();
     892                        // ...but only use it if it's still there in CURRENT_VER
     893                        if (sle->maxVersion == CURRENT_VER)
     894                                *((void **)at) = num ? (*_load_ref) (_ref_me, type, num - 1) : NULL;
    936895                } else {
    937                         replen = 1;
     896                        // load entry
     897                        int replen = 1;
     898
    938899                        if (type & 128) {
    939900                                sle++;
    940901                                replen = sle->offs;
    941902                                type &= ~128;
    942903                        }
    943                         saveLoadArrayOf(at, replen, size, type);
     904                        loadArrayOf(at, replen, size, type);
    944905                }
    945906                sle++;
    946907        }
  • scumm/saveload.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
    retrieving revision 1.4
    diff -u -r1.4 saveload.h
     
    2222#ifndef SAVELOAD_H
    2323#define SAVELOAD_H
    2424
     25// Support for "old" savegames (made with 2501 CVS build)
     26// Can be useful for other ports too :)
     27
     28#define VER_V10 10
     29#define VER_V9 9
     30#define VER_V8 8
     31#define VER_V7 7
     32
     33#define CURRENT_VER VER_V10
     34
     35
    2536// To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types,
    2637// we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC
    2738// versions hae a heuristic built in to detect "offset-of" patterns - which is exactly
     
    3243
    3344#define OFFS(type,item) (((int)(&((type*)42)->type::item))-42)
    3445#define SIZE(type,item) sizeof(((type*)42)->type::item)
    35 #define MKLINE(type,item,saveas) {OFFS(type,item),saveas,SIZE(type,item)}
    36 #define MKARRAY(type,item,saveas,num) {OFFS(type,item),128|saveas,SIZE(type,item)}, {num,0,0}
    37 #define MKEND() {0xFFFF,0xFF,0xFF}
    3846
    39 #define MKREF(type,item,refid) {OFFS(type,item),refid,0xFF}
     47// Any item that is still in use automatically gets a maxVersion equal to CURRENT_VER
     48#define MKLINE(type,item,saveas,minVer) {OFFS(type,item),saveas,SIZE(type,item),minVer,CURRENT_VER}
     49#define MKARRAY(type,item,saveas,num,minVer) {OFFS(type,item),128|saveas,SIZE(type,item),minVer,CURRENT_VER}, {num,0,0,0,0}
     50
     51// Use this if you have an entry that used to be smaller:
     52#define MKLINE_OLD(type,item,saveas,minVer,maxVer) {OFFS(type,item),saveas,SIZE(type,item),minVer,maxVer}
     53#define MKARRAY_OLD(type,item,saveas,num,minVer,maxVer) {OFFS(type,item),128|saveas,SIZE(type,item),minVer,maxVer}, {num,0,0,0,0}
     54
     55// An obsolete item/array, to be ignored upon load. We retain the type/item params to make it easier to debug.
     56// Obsolete items have size == 0.
     57#define MK_OBSOLETE(type,item,saveas,minVer,maxVer) {0,saveas,0,minVer,maxVer}
     58#define MK_OBSOLETE_ARRAY(type,item,saveas,num,minVer,maxVer) {0,128|saveas,0,minVer,maxVer}, {num,0,0,0,0}
     59
     60// End marker
     61#define MKEND() {0xFFFF,0xFF,0xFF,0,0}
     62
     63// A reference
     64#define MKREF(type,item,refid,minVer) {OFFS(type,item),refid,0xFF,minVer,CURRENT_VER}
     65
     66// An obsolete reference.
     67#define MK_OBSOLETE_REF(type,item,refid,minVer,maxVer) {0,sleUint16,0,minVer,maxVer}
     68
    4069
    4170enum {
    4271        sleByte = 1,
     
    5281        uint32 offs;
    5382        uint8 type;
    5483        uint8 size;
     84        uint8 minVersion;
     85        uint8 maxVersion;
    5586};
    5687
    5788struct SerializerStream {
     
    83114typedef int SerializerSaveReference(void *me, byte type, void *ref);
    84115typedef void *SerializerLoadReference(void *me, byte type, int ref);
    85116
    86 struct Serializer {
    87         SerializerStream _saveLoadStream;
     117class Serializer {
     118public:
     119        Serializer(SerializerStream stream, bool saveOrLoad, uint32 savegameVersion)
     120                : _save_ref(0), _load_ref(0), _ref_me(0),
     121                  _saveLoadStream(stream), _saveOrLoad(saveOrLoad),
     122                  _savegameVersion(savegameVersion)
     123        { }
    88124
    89         union {
    90                 SerializerSaveReference *_save_ref;
    91                 SerializerLoadReference *_load_ref;
    92                 void *_saveload_ref;
    93         };
     125        SerializerSaveReference *_save_ref;
     126        SerializerLoadReference *_load_ref;
    94127        void *_ref_me;
    95128
    96         bool _saveOrLoad;
    97 
    98         void saveBytes(void *b, int len);
    99         void loadBytes(void *b, int len);
    100        
    101129        void saveLoadArrayOf(void *b, int len, int datasize, byte filetype);
    102         void saveLoadEntries(void *d, const SaveLoadEntry *sle);
    103130        void saveLoadArrayOf(void *b, int num, int datasize, const SaveLoadEntry *sle);
     131        void saveLoadEntries(void *d, const SaveLoadEntry *sle);
     132
     133        bool isSaving() { return _saveOrLoad; }
     134
     135        bool checkEOFLoadStream();
    104136
    105137        void saveUint32(uint32 d);
    106138        void saveWord(uint16 d);
     
    110142        uint16 loadWord();
    111143        uint32 loadUint32();
    112144
    113         bool isSaving() { return _saveOrLoad; }
     145        void saveBytes(void *b, int len);
     146        void loadBytes(void *b, int len);
     147       
     148protected:
     149        SerializerStream _saveLoadStream;
     150        bool _saveOrLoad;
     151        uint32 _savegameVersion;
    114152
    115         bool checkEOFLoadStream();
     153        void saveArrayOf(void *b, int len, int datasize, byte filetype);
     154        void loadArrayOf(void *b, int len, int datasize, byte filetype);
    116155
     156        void saveEntries(void *d, const SaveLoadEntry *sle);
     157        void loadEntries(void *d, const SaveLoadEntry *sle);
    117158};
    118159
    119160#endif
  • scumm/scumm.h

    RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
    retrieving revision 1.72
    diff -u -r1.72 scumm.h
     
    359359        void convertKeysToClicks();
    360360
    361361        /* Random number generation */
    362         uint32 _randSeed1, _randSeed2; // FIXME: can be removed when new savegame system is implemented
    363362        RandomSource _rnd;
    364363
    365364        /* Core variable definitions */
     
    427426        bool _saveLoadCompatible;
    428427        char _saveLoadName[32];
    429428
     429        uint32 _savegameVersion;
     430
    430431        bool saveState(int slot, bool compat);
    431432        bool loadState(int slot, bool compat);
    432433        void saveOrLoad(Serializer *s);
     
    692693        ColorCycle _colorCycle[16];     // Palette cycles
    693694
    694695        uint32 _ENCD_offs, _EXCD_offs;
    695         uint32 _CLUT_offs, _EPAL_offs;
     696        uint32 _CLUT_offs;
    696697        uint32 _IM00_offs, _PALS_offs;
    697698
    698699        //ender: fullscreen
     
    856857        bool _silentDigitalImuse;
    857858        int _saveSound;
    858859        int current_cd_sound;
    859         int _cd_loops, _cd_frame, _cd_track, _cd_end;   // FIXME - these are not used anymore
    860860
    861861        /* Walkbox / Navigation class */
    862862        int _maxBoxVertexHeap, _boxPathVertexHeapIndex, _boxMatrixItem;