From bb840c9ec205d4c6a94d73c107f520d557983791 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 12 Feb 2017 21:00:31 -0500 Subject: TITANIC: More renamings in music classes --- engines/titanic/module.mk | 4 +- engines/titanic/sound/music_object.cpp | 192 ------------------------ engines/titanic/sound/music_object.h | 81 ---------- engines/titanic/sound/music_room_handler.cpp | 56 +++---- engines/titanic/sound/music_room_handler.h | 13 +- engines/titanic/sound/music_room_instrument.cpp | 12 +- engines/titanic/sound/music_room_instrument.h | 2 +- engines/titanic/sound/music_song.cpp | 192 ++++++++++++++++++++++++ engines/titanic/sound/music_song.h | 81 ++++++++++ 9 files changed, 319 insertions(+), 314 deletions(-) delete mode 100644 engines/titanic/sound/music_object.cpp delete mode 100644 engines/titanic/sound/music_object.h create mode 100644 engines/titanic/sound/music_song.cpp create mode 100644 engines/titanic/sound/music_song.h (limited to 'engines/titanic') diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 6aadf5dc5b..35233763d3 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -409,11 +409,11 @@ MODULE_OBJS := \ sound/dome_from_top_of_well.o \ sound/enter_view_toggles_other_music.o \ sound/gondolier_song.o \ - sound/music_object.o \ + sound/music_player.o \ sound/music_room.o \ sound/music_room_handler.o \ sound/music_room_instrument.o \ - sound/music_player.o \ + sound/music_song.o \ sound/node_auto_sound_player.o \ sound/proximity.o \ sound/qmixer.o \ diff --git a/engines/titanic/sound/music_object.cpp b/engines/titanic/sound/music_object.cpp deleted file mode 100644 index d12b6eb403..0000000000 --- a/engines/titanic/sound/music_object.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "titanic/sound/music_object.h" -#include "titanic/titanic.h" -#include "common/util.h" - -namespace Titanic { - -CMusicObject::CMusicObject(int index) { - // Read in the list of parser strings - Common::SeekableReadStream *res = g_vm->_filesManager->getResource("MUSIC/PARSER"); - Common::StringArray parserStrings; - while (res->pos() < res->size()) - parserStrings.push_back(readStringFromStream(res)); - delete res; - - // Set up a new parser with the desired string - CMusicParser parser(parserStrings[index].c_str()); - - // Count how many encoded values there are - CValuePair r; - int count = 0; - while (parser.parse(r)) - ++count; - assert(count > 0); - - // Read in the values to the array - _data.resize(count); - parser.reset(); - for (int idx = 0; idx < count; ++idx) - parser.parse(_data[idx]); - - // Figure out the range of values in the array - _minVal = 0x7FFFFFFF; - int maxVal = -0x7FFFFFFF; - - for (int idx = 0; idx < count; ++idx) { - CValuePair &vp = _data[idx]; - if (vp._field0 != 0x7FFFFFFF) { - if (vp._field0 < _minVal) - _minVal = vp._field0; - if (vp._field0 > maxVal) - maxVal = vp._field0; - } - } - - _range = maxVal - _minVal; -} - -CMusicObject::~CMusicObject() { - _data.clear(); -} - -/*------------------------------------------------------------------------*/ - -#define FETCH_CHAR _currentChar = _str[_strIndex++] - -CMusicParser::CMusicParser(const char *str) : _str(str), _strIndex(0), - _field8(0), _priorChar('A'), _field10(32), _field14(0), _flag(false), - _field1C(0), _currentChar(' '), _numValue(1) { -} - -void CMusicParser::reset() { - _strIndex = 0; - _field8 = 0; - _field10 = 0; - _field14 = 0; - _currentChar = ' '; - _priorChar = 'A'; - _numValue = 1; - _field1C = 0; -} - -bool CMusicParser::parse(CValuePair &r) { - const int INDEXES[8] = { 0, 2, 3, 5, 7, 8, 10, 0 }; - - while (_currentChar) { - skipSpaces(); - - if (Common::isDigit(_currentChar)) { - // Parse the number - Common::String numStr; - do { - numStr += _currentChar; - FETCH_CHAR; - } while (_currentChar && Common::isDigit(_currentChar)); - - _numValue = atoi(numStr.c_str()); - } else if (_currentChar == ',') { - _field10 = _numValue; - FETCH_CHAR; - } else if (_currentChar == ':') { - _priorChar = 'A'; - _field8 = _numValue * 12; - FETCH_CHAR; - } else if (_currentChar == '/') { - r._field4 += _field10; - _field1C += _field10; - FETCH_CHAR; - } else if (_currentChar == '+') { - ++_field14; - FETCH_CHAR; - } else if (_currentChar == '-') { - --_field14; - FETCH_CHAR; - } else if (_currentChar == '^') { - if (_flag) - break; - - _flag = true; - r._field0 = 0x7FFFFFFF; - r._field4 = _field10; - _field14 = 0; - _field1C += _field10; - FETCH_CHAR; - } else if (_currentChar == '|') { - _field1C = 0; - FETCH_CHAR; - } else if (Common::isAlpha(_currentChar)) { - if (_flag) - break; - - int val1 = INDEXES[tolower(_currentChar) - 'a']; - int val2 = INDEXES[tolower(_priorChar) - 'a']; - bool flag = true; - - if (_currentChar == _priorChar) { - r._field0 = _field8; - } else if (_currentChar >= 'a' && _currentChar <= 'g') { - val1 -= val2; - if (val1 >= 0) - val1 -= 12; - r._field0 = _field8 + val1; - } else if (_currentChar >= 'A' && _currentChar <= 'G') { - val1 -= val2; - if (val1 <= 0) - val1 += 12; - r._field0 = _field8 + val1; - } else { - flag = false; - } - - if (flag) { - r._field4 = _field10; - _field1C += _field10; - _field8 = r._field0; - _priorChar = _currentChar; - r._field0 += _field14; - _field14 = 0; - _flag = true; - } - - FETCH_CHAR; - } else { - FETCH_CHAR; - } - } - - if (!_flag) - return false; - - _flag = false; - return true; -} - -void CMusicParser::skipSpaces() { - while (_currentChar && Common::isSpace(_currentChar)) { - FETCH_CHAR; - } -} - -} // End of namespace Titanic diff --git a/engines/titanic/sound/music_object.h b/engines/titanic/sound/music_object.h deleted file mode 100644 index 6159a034d8..0000000000 --- a/engines/titanic/sound/music_object.h +++ /dev/null @@ -1,81 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef TITANIC_MUSIC_OBJECT_H -#define TITANIC_MUSIC_OBJECT_H - -#include "common/scummsys.h" -#include "common/array.h" - -namespace Titanic { - -struct CValuePair { - int _field0; - int _field4; - CValuePair() : _field0(0), _field4(0) {} -}; - -class CMusicObject { -public: - Common::Array _data; - int _minVal; - int _range; -public: - CMusicObject(int index); - ~CMusicObject(); - - int size() const { return _data.size(); } - - const CValuePair &operator[](int index) const { return _data[index]; } -}; - -class CMusicParser { -private: - const char *_str; - uint _strIndex; - int _field8; - char _priorChar; - int _field10; - int _field14; - bool _flag; - int _field1C; - char _currentChar; - int _numValue; -private: - void skipSpaces(); -public: - CMusicParser(const char *str); - - /** - * Resets the parser - */ - void reset(); - - /** - * Parses a value from the string - */ - bool parse(CValuePair &r); -}; - -} // End of namespace Titanic - -#endif /* TITANIC_MUSIC_OBJECT_H */ diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp index df2bc54dec..1373f200e7 100644 --- a/engines/titanic/sound/music_room_handler.cpp +++ b/engines/titanic/sound/music_room_handler.cpp @@ -35,9 +35,9 @@ CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *sound _startTicks = _soundStartTicks = 0; Common::fill(&_instruments[0], &_instruments[4], (CMusicRoomInstrument *)nullptr); for (int idx = 0; idx < 4; ++idx) - _musicObjs[idx] = new CMusicObject(idx); + _songs[idx] = new CMusicSong(idx); Common::fill(&_startPos[0], &_startPos[4], 0); - Common::fill(&_array5[0], &_array5[4], 0.0); + Common::fill(&_animTime[0], &_animTime[4], 0.0); Common::fill(&_position[0], &_position[4], 0); _audioBuffer = new CAudioBuffer(88200); @@ -46,7 +46,7 @@ CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *sound CMusicRoomHandler::~CMusicRoomHandler() { stop(); for (int idx = 0; idx < 4; ++idx) - delete _musicObjs[idx]; + delete _songs[idx]; delete _audioBuffer; } @@ -84,11 +84,11 @@ void CMusicRoomHandler::setup(int volume) { if (ins1._directionControl == ins2._directionControl) { _startPos[idx] = 0; } else { - _startPos[idx] = _musicObjs[idx]->size() - 1; + _startPos[idx] = _songs[idx]->size() - 1; } _position[idx] = _startPos[idx]; - _array5[idx] = 0.0; + _animTime[idx] = 0.0; } _field108 = 4; @@ -246,18 +246,18 @@ void CMusicRoomHandler::updateInstruments() { CMusicRoomInstrument *ins = _instruments[instrument]; // Is this about checking playback position? - if (_position[instrument] < 0 || ins1._muteControl || _position[instrument] >= _musicObjs[instrument]->size()) { + if (_position[instrument] < 0 || ins1._muteControl || _position[instrument] >= _songs[instrument]->size()) { _position[instrument] = -1; continue; } uint ticks = g_vm->_events->getTicksCount() - _soundStartTicks; - double val = (double)ticks * 0.001 - 0.6; + double time = (double)ticks * 0.001 - 0.6; - if (val >= (ins->_floatVal - _array5[instrument])) { - _array5[instrument] += fn3(instrument, _position[instrument]); + if (time >= (ins->_animTime - _animTime[instrument])) { + _animTime[instrument] += getAnimDuration(instrument, _position[instrument]); - const CValuePair &vp = (*_musicObjs[instrument])[_position[instrument]]; + const CValuePair &vp = (*_songs[instrument])[_position[instrument]]; if (vp._field0 != 0x7FFFFFFF) { int amount = getPitch(instrument, _position[instrument]); _instruments[instrument]->update(amount); @@ -280,20 +280,20 @@ bool CMusicRoomHandler::pollInstrument(MusicInstrument instrument) { return false; } - const CMusicObject &mObj = *_musicObjs[instrument]; - if (arrIndex >= mObj.size()) { + const CMusicSong &song = *_songs[instrument]; + if (arrIndex >= song.size()) { arrIndex = -1; _instruments[instrument]->clear(); return false; } - const CValuePair &vp = mObj[arrIndex]; - int size = static_cast(fn3(instrument, arrIndex) * 44100.0) & ~1; + const CValuePair &vp = song[arrIndex]; + uint duration = static_cast(getAnimDuration(instrument, arrIndex) * 44100.0) & ~1; if (vp._field0 == 0x7FFFFFFF || _array1[instrument]._muteControl) - _instruments[instrument]->reset(size); + _instruments[instrument]->reset(duration); else - _instruments[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), size); + _instruments[instrument]->chooseWaveFile(getPitch(instrument, arrIndex), duration); if (_array1[instrument]._directionControl == _array2[instrument]._directionControl) { ++arrIndex; @@ -304,36 +304,36 @@ bool CMusicRoomHandler::pollInstrument(MusicInstrument instrument) { return true; } -double CMusicRoomHandler::fn3(MusicInstrument instrument, int arrIndex) { - const CValuePair &vp = (*_musicObjs[instrument])[arrIndex]; +double CMusicRoomHandler::getAnimDuration(MusicInstrument instrument, int arrIndex) { + const CValuePair &vp = (*_songs[instrument])[arrIndex]; switch (_array1[instrument]._speedControl + _array2[instrument]._speedControl + 3) { case 0: - return (double)vp._field4 * 1.5 * 0.0625 * 0.46875; + return (double)vp._length * 1.5 * 0.0625 * 0.46875; case 1: - return (double)vp._field4 * 1.33 * 0.0625 * 0.46875; + return (double)vp._length * 1.33 * 0.0625 * 0.46875; case 2: - return (double)vp._field4 * 1.25 * 0.0625 * 0.46875; + return (double)vp._length * 1.25 * 0.0625 * 0.46875; case 4: - return (double)vp._field4 * 0.75 * 0.0625 * 0.46875; + return (double)vp._length * 0.75 * 0.0625 * 0.46875; case 5: - return (double)vp._field4 * 0.67 * 0.0625 * 0.46875; + return (double)vp._length * 0.67 * 0.0625 * 0.46875; case 6: - return (double)vp._field4 * 0.5 * 0.0625 * 0.46875; + return (double)vp._length * 0.5 * 0.0625 * 0.46875; default: - return (double)vp._field4 * 1.0 * 0.0625 * 0.46875; + return (double)vp._length * 1.0 * 0.0625 * 0.46875; } } int CMusicRoomHandler::getPitch(MusicInstrument instrument, int arrIndex) { - const CMusicObject &mObj = *_musicObjs[instrument]; - const CValuePair &vp = mObj[arrIndex]; + const CMusicSong &song = *_songs[instrument]; + const CValuePair &vp = song[arrIndex]; int val = vp._field0; const MusicRoomInstrument &ins1 = _array1[instrument]; const MusicRoomInstrument &ins2 = _array2[instrument]; if (ins1._inversionControl != ins2._inversionControl) { - val = mObj._minVal * 2 + mObj._range - val; + val = song._minVal * 2 + song._range - val; } val += ins1._pitchControl + ins2._pitchControl; diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h index 34d2b95740..9222a9248d 100644 --- a/engines/titanic/sound/music_room_handler.h +++ b/engines/titanic/sound/music_room_handler.h @@ -24,8 +24,8 @@ #define TITANIC_MUSIC_ROOM_HANDLER_H #include "titanic/sound/audio_buffer.h" -#include "titanic/sound/music_object.h" #include "titanic/sound/music_room_instrument.h" +#include "titanic/sound/music_song.h" #include "titanic/sound/wave_file.h" namespace Titanic { @@ -52,10 +52,10 @@ private: CMusicRoomInstrument *_instruments[4]; MusicRoomInstrument _array1[4]; MusicRoomInstrument _array2[4]; - CMusicObject *_musicObjs[4]; + CMusicSong *_songs[4]; int _startPos[4]; int _position[4]; - double _array5[4]; + double _animTime[4]; bool _active; CWaveFile *_waveFile; @@ -89,7 +89,12 @@ private: */ bool pollInstrument(MusicInstrument instrument); - double fn3(MusicInstrument instrument, int arrIndex); + /** + * Gets the duration for a given fragment of an instrument to play + * out, so that animations of the instruments can be synchronized + * to the actual music + */ + double getAnimDuration(MusicInstrument instrument, int arrIndex); /** * Figures out a pitch value (of some sort) for use in determining diff --git a/engines/titanic/sound/music_room_instrument.cpp b/engines/titanic/sound/music_room_instrument.cpp index 144f9d190b..5e7bd9bb8c 100644 --- a/engines/titanic/sound/music_room_instrument.cpp +++ b/engines/titanic/sound/music_room_instrument.cpp @@ -52,7 +52,7 @@ void CMusicRoomInstrument::deinit() { CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager *soundManager, MusicWaveInstrument instrument) : _project(project), _soundManager(soundManager), _instrument(instrument) { Common::fill(&_gameObjects[0], &_gameObjects[4], (CGameObject *)nullptr); - _floatVal = 0.0; + _animTime = 0.0; _waveIndex = -1; _readPos = 0; _readIncrement = 0; @@ -66,7 +66,7 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager _gameObjects[1] = static_cast(_project->findByName("Piano Mouth")); _gameObjects[2] = static_cast(_project->findByName("Piano Left Arm")); _gameObjects[3] = static_cast(_project->findByName("Piano Right Arm")); - _floatVal = 0.45; + _animTime = 0.45; break; case MV_BASS: @@ -75,14 +75,14 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager case MV_BELLS: _gameObjects[0] = static_cast(_project->findByName("Tubular Bells")); - _floatVal = 0.4; + _animTime = 0.4; break; case MV_SNAKE: _gameObjects[0] = static_cast(_project->findByName("Snake_Hammer")); _gameObjects[1] = static_cast(_project->findByName("Snake_Glass")); _gameObjects[2] = static_cast(_project->findByName("Snake_Head")); - _floatVal = 0.17; + _animTime = 0.17; break; } } @@ -212,12 +212,12 @@ void CMusicRoomInstrument::update(int val) { case 60: _gameObjects[0]->movieSetAudioTiming(true); _gameObjects[0]->playMovie(0, 512, MOVIE_STOP_PREVIOUS); - _floatVal = 0.6; + _animTime = 0.6; break; case 62: _gameObjects[0]->playMovie(828, 1023, MOVIE_STOP_PREVIOUS); - _floatVal = 0.3; + _animTime = 0.3; break; case 63: diff --git a/engines/titanic/sound/music_room_instrument.h b/engines/titanic/sound/music_room_instrument.h index d63fe93f20..d859fe2a0e 100644 --- a/engines/titanic/sound/music_room_instrument.h +++ b/engines/titanic/sound/music_room_instrument.h @@ -73,7 +73,7 @@ private: */ void setupArray(int minVal, int maxVal); public: - double _floatVal; + double _animTime; public: /** * Handles initialization of static fields diff --git a/engines/titanic/sound/music_song.cpp b/engines/titanic/sound/music_song.cpp new file mode 100644 index 0000000000..5894f344af --- /dev/null +++ b/engines/titanic/sound/music_song.cpp @@ -0,0 +1,192 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/music_song.h" +#include "titanic/titanic.h" +#include "common/util.h" + +namespace Titanic { + +CMusicSong::CMusicSong(int index) { + // Read in the list of song strings + Common::SeekableReadStream *res = g_vm->_filesManager->getResource("MUSIC/PARSER"); + Common::StringArray parserStrings; + while (res->pos() < res->size()) + parserStrings.push_back(readStringFromStream(res)); + delete res; + + // Set up a new song parser with the desired string + CSongParser parser(parserStrings[index].c_str()); + + // Count how many encoded values there are + CValuePair r; + int count = 0; + while (parser.parse(r)) + ++count; + assert(count > 0); + + // Read in the values to the array + _data.resize(count); + parser.reset(); + for (int idx = 0; idx < count; ++idx) + parser.parse(_data[idx]); + + // Figure out the range of values in the array + _minVal = 0x7FFFFFFF; + int maxVal = -0x7FFFFFFF; + + for (int idx = 0; idx < count; ++idx) { + CValuePair &vp = _data[idx]; + if (vp._field0 != 0x7FFFFFFF) { + if (vp._field0 < _minVal) + _minVal = vp._field0; + if (vp._field0 > maxVal) + maxVal = vp._field0; + } + } + + _range = maxVal - _minVal; +} + +CMusicSong::~CMusicSong() { + _data.clear(); +} + +/*------------------------------------------------------------------------*/ + +#define FETCH_CHAR _currentChar = _str[_strIndex++] + +CSongParser::CSongParser(const char *str) : _str(str), _strIndex(0), + _field8(0), _priorChar('A'), _field10(32), _field14(0), _flag(false), + _field1C(0), _currentChar(' '), _numValue(1) { +} + +void CSongParser::reset() { + _strIndex = 0; + _field8 = 0; + _field10 = 0; + _field14 = 0; + _currentChar = ' '; + _priorChar = 'A'; + _numValue = 1; + _field1C = 0; +} + +bool CSongParser::parse(CValuePair &r) { + const int INDEXES[8] = { 0, 2, 3, 5, 7, 8, 10, 0 }; + + while (_currentChar) { + skipSpaces(); + + if (Common::isDigit(_currentChar)) { + // Parse the number + Common::String numStr; + do { + numStr += _currentChar; + FETCH_CHAR; + } while (_currentChar && Common::isDigit(_currentChar)); + + _numValue = atoi(numStr.c_str()); + } else if (_currentChar == ',') { + _field10 = _numValue; + FETCH_CHAR; + } else if (_currentChar == ':') { + _priorChar = 'A'; + _field8 = _numValue * 12; + FETCH_CHAR; + } else if (_currentChar == '/') { + r._length += _field10; + _field1C += _field10; + FETCH_CHAR; + } else if (_currentChar == '+') { + ++_field14; + FETCH_CHAR; + } else if (_currentChar == '-') { + --_field14; + FETCH_CHAR; + } else if (_currentChar == '^') { + if (_flag) + break; + + _flag = true; + r._field0 = 0x7FFFFFFF; + r._length = _field10; + _field14 = 0; + _field1C += _field10; + FETCH_CHAR; + } else if (_currentChar == '|') { + _field1C = 0; + FETCH_CHAR; + } else if (Common::isAlpha(_currentChar)) { + if (_flag) + break; + + int val1 = INDEXES[tolower(_currentChar) - 'a']; + int val2 = INDEXES[tolower(_priorChar) - 'a']; + bool flag = true; + + if (_currentChar == _priorChar) { + r._field0 = _field8; + } else if (_currentChar >= 'a' && _currentChar <= 'g') { + val1 -= val2; + if (val1 >= 0) + val1 -= 12; + r._field0 = _field8 + val1; + } else if (_currentChar >= 'A' && _currentChar <= 'G') { + val1 -= val2; + if (val1 <= 0) + val1 += 12; + r._field0 = _field8 + val1; + } else { + flag = false; + } + + if (flag) { + r._length = _field10; + _field1C += _field10; + _field8 = r._field0; + _priorChar = _currentChar; + r._field0 += _field14; + _field14 = 0; + _flag = true; + } + + FETCH_CHAR; + } else { + FETCH_CHAR; + } + } + + if (!_flag) + return false; + + _flag = false; + return true; +} + +void CSongParser::skipSpaces() { + while (_currentChar && Common::isSpace(_currentChar)) { + FETCH_CHAR; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/music_song.h b/engines/titanic/sound/music_song.h new file mode 100644 index 0000000000..33ad95882c --- /dev/null +++ b/engines/titanic/sound/music_song.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_SONG_H +#define TITANIC_MUSIC_SONG_H + +#include "common/scummsys.h" +#include "common/array.h" + +namespace Titanic { + +struct CValuePair { + int _field0; + int _length; + CValuePair() : _field0(0), _length(0) {} +}; + +class CMusicSong { +public: + Common::Array _data; + int _minVal; + int _range; +public: + CMusicSong(int index); + ~CMusicSong(); + + int size() const { return _data.size(); } + + const CValuePair &operator[](int index) const { return _data[index]; } +}; + +class CSongParser { +private: + const char *_str; + uint _strIndex; + int _field8; + char _priorChar; + int _field10; + int _field14; + bool _flag; + int _field1C; + char _currentChar; + int _numValue; +private: + void skipSpaces(); +public: + CSongParser(const char *str); + + /** + * Resets the parser + */ + void reset(); + + /** + * Parses a value from the string + */ + bool parse(CValuePair &r); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SONG_H */ -- cgit v1.2.3