diff options
Diffstat (limited to 'engines/scumm/players/player_mac.cpp')
-rw-r--r-- | engines/scumm/players/player_mac.cpp | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/engines/scumm/players/player_mac.cpp b/engines/scumm/players/player_mac.cpp index 87406f4e34..cc65adceab 100644 --- a/engines/scumm/players/player_mac.cpp +++ b/engines/scumm/players/player_mac.cpp @@ -97,53 +97,46 @@ Player_Mac::~Player_Mac() { delete[] _channel; } -void Player_Mac::saveLoadWithSerializer(Serializer *ser) { +void syncWithSerializer(Common::Serializer &s, Player_Mac::Channel &c) { + s.syncAsUint16LE(c._pos, VER(94)); + s.syncAsSint32LE(c._pitchModifier, VER(94)); + s.syncAsByte(c._velocity, VER(94)); + s.syncAsUint32LE(c._remaining, VER(94)); + s.syncAsByte(c._notesLeft, VER(94)); +} + +void syncWithSerializer(Common::Serializer &s, Player_Mac::Instrument &i) { + s.syncAsUint32LE(i._pos, VER(94)); + s.syncAsUint32LE(i._subPos, VER(94)); +} + +void Player_Mac::saveLoadWithSerializer(Common::Serializer &s) { Common::StackLock lock(_mutex); - if (ser->getVersion() < VER(94)) { - if (_vm->_game.id == GID_MONKEY && ser->isLoading()) { + if (s.getVersion() < VER(94)) { + if (_vm->_game.id == GID_MONKEY && s.isLoading()) { IMuse *dummyImuse = IMuse::create(_vm->_system, NULL, NULL); - dummyImuse->save_or_load(ser, _vm, false); + dummyImuse->saveLoadWithSerializer(s, _vm, false); delete dummyImuse; } } else { - static const SaveLoadEntry musicEntries[] = { - MKLINE(Player_Mac, _sampleRate, sleUint32, VER(94)), - MKLINE(Player_Mac, _soundPlaying, sleInt16, VER(94)), - MKEND() - }; - - static const SaveLoadEntry channelEntries[] = { - MKLINE(Channel, _pos, sleUint16, VER(94)), - MKLINE(Channel, _pitchModifier, sleInt32, VER(94)), - MKLINE(Channel, _velocity, sleUint8, VER(94)), - MKLINE(Channel, _remaining, sleUint32, VER(94)), - MKLINE(Channel, _notesLeft, sleUint8, VER(94)), - MKEND() - }; - - static const SaveLoadEntry instrumentEntries[] = { - MKLINE(Instrument, _pos, sleUint32, VER(94)), - MKLINE(Instrument, _subPos, sleUint32, VER(94)), - MKEND() - }; - uint32 mixerSampleRate = _sampleRate; int i; - ser->saveLoadEntries(this, musicEntries); + s.syncAsUint32LE(_sampleRate, VER(94)); + s.syncAsSint16LE(_soundPlaying, VER(94)); - if (ser->isLoading() && _soundPlaying != -1) { + if (s.isLoading() && _soundPlaying != -1) { const byte *ptr = _vm->getResourceAddress(rtSound, _soundPlaying); assert(ptr); loadMusic(ptr); } - ser->saveLoadArrayOf(_channel, _numberOfChannels, sizeof(Channel), channelEntries); + s.syncArray(_channel, _numberOfChannels, syncWithSerializer); for (i = 0; i < _numberOfChannels; i++) { - ser->saveLoadEntries(&_channel[i], instrumentEntries); + syncWithSerializer(s, _channel[i]); } - if (ser->isLoading()) { + if (s.isLoading()) { // If necessary, adjust the channel data to fit the // current sample rate. if (_soundPlaying != -1 && _sampleRate != mixerSampleRate) { |