aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2014-12-01 07:49:26 +0100
committerPaul Gilbert2014-12-12 22:53:43 -0500
commit11e920f427312c496b080c280dca7a9eb8b75676 (patch)
treeedd05f1ec1cc6af91efdf608a06fb06a69ed6817 /engines
parenta3801df5187cb2500e72b74d37c6bccdbff1f8c5 (diff)
downloadscummvm-rg350-11e920f427312c496b080c280dca7a9eb8b75676.tar.gz
scummvm-rg350-11e920f427312c496b080c280dca7a9eb8b75676.tar.bz2
scummvm-rg350-11e920f427312c496b080c280dca7a9eb8b75676.zip
ACCESS: Split SoundManager and MusicManager
Diffstat (limited to 'engines')
-rw-r--r--engines/access/access.cpp2
-rw-r--r--engines/access/access.h1
-rw-r--r--engines/access/amazon/amazon_game.cpp16
-rw-r--r--engines/access/amazon/amazon_logic.cpp24
-rw-r--r--engines/access/amazon/amazon_scripts.cpp2
-rw-r--r--engines/access/room.cpp18
-rw-r--r--engines/access/scripts.cpp2
-rw-r--r--engines/access/sound.cpp51
-rw-r--r--engines/access/sound.h25
9 files changed, 85 insertions, 56 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index bac1308b09..b0b28f64f6 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -100,6 +100,7 @@ AccessEngine::~AccessEngine() {
delete _events;
delete _files;
delete _inventory;
+ delete _midi;
delete _player;
delete _room;
delete _screen;
@@ -150,6 +151,7 @@ void AccessEngine::initialize() {
_player = Player::init(this);
_screen = new Screen(this);
_sound = new SoundManager(this, _mixer);
+ _midi = new MusicManager(this, _mixer);
_video = new VideoPlayer(this);
_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
diff --git a/engines/access/access.h b/engines/access/access.h
index af0d42302b..da10d6326c 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -150,6 +150,7 @@ public:
Screen *_screen;
Scripts *_scripts;
SoundManager *_sound;
+ MusicManager *_midi;
VideoPlayer *_video;
ASurface *_destIn;
diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp
index b665c49806..ba8b156e65 100644
--- a/engines/access/amazon/amazon_game.cpp
+++ b/engines/access/amazon/amazon_game.cpp
@@ -450,7 +450,7 @@ void AmazonEngine::startChapter(int chapter) {
_room->clearRoom();
freeChar();
- _sound->newMusic(32, 0);
+ _midi->newMusic(32, 0);
playVideo(0, Common::Point());
if (shouldQuit())
return;
@@ -508,8 +508,8 @@ void AmazonEngine::startChapter(int chapter) {
if (chapter == 14)
_screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76));
- _sound->newMusic(chapImg[4], 1);
- _sound->newMusic(33, 0);
+ _midi->newMusic(chapImg[4], 1);
+ _midi->newMusic(33, 0);
_screen->forceFadeIn();
_timers[20]._timer = 950;
@@ -534,8 +534,8 @@ void AmazonEngine::startChapter(int chapter) {
_buffer2.copyFrom(*_screen);
_screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7));
- _sound->newMusic(7, 1);
- _sound->newMusic(34, 0);
+ _midi->newMusic(7, 1);
+ _midi->newMusic(34, 0);
_screen->forceFadeIn();
_buffer2.copyFrom(*_screen);
@@ -567,7 +567,7 @@ void AmazonEngine::startChapter(int chapter) {
_screen->clearBuffer();
freeCells();
- _sound->newMusic(_chapter * 2, 1);
+ _midi->newMusic(_chapter * 2, 1);
if (chapter != 1 && chapter != 14) {
_room->init4Quads();
@@ -607,7 +607,7 @@ void AmazonEngine::dead(int deathId) {
_screen->setPanel(3);
if (deathId != 10) {
- _sound->newMusic(62, 0);
+ _midi->newMusic(62, 0);
_files->_setPaletteFlag = false;
_files->loadScreen(94, 0);
_files->_setPaletteFlag = true;
@@ -649,7 +649,7 @@ void AmazonEngine::dead(int deathId) {
printText(_screen, msg);
_screen->forceFadeOut();
- _sound->newMusic(0, 1);
+ _midi->newMusic(0, 1);
_events->showCursor();
_room->clearRoom();
freeChar();
diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp
index c62ca5786e..c330429ee6 100644
--- a/engines/access/amazon/amazon_logic.cpp
+++ b/engines/access/amazon/amazon_logic.cpp
@@ -140,7 +140,7 @@ void CampScene::mWhileDoOpen() {
_vm->_animation->setAnimTimer(anim);
anim = _vm->_animation->setAnimation(1);
_vm->_animation->setAnimTimer(anim);
- _vm->_sound->newMusic(10, 0);
+ _vm->_midi->newMusic(10, 0);
bool startFl = false;
while (!_vm->shouldQuit()) {
@@ -161,7 +161,7 @@ void CampScene::mWhileDoOpen() {
if (events._leftButton || events._rightButton || events._keypresses.size() > 0) {
_skipStart = true;
- _vm->_sound->newMusic(10, 1);
+ _vm->_midi->newMusic(10, 1);
events.debounceLeft();
events.zeroKeys();
@@ -339,7 +339,7 @@ void Opening::doTitle() {
_vm->_buffer2.copyFrom(*_vm->_screen);
_vm->_buffer1.copyFrom(*_vm->_screen);
_vm->_screen->forceFadeIn();
- _vm->_sound->newMusic(1, 0);
+ _vm->_midi->newMusic(1, 0);
_vm->_events->_vbCount = 700;
while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) {
_vm->_events->pollEventsAndWait();
@@ -352,8 +352,8 @@ void Opening::doTitle() {
return;
}
- _vm->_sound->newMusic(1, 1);
- _vm->_sound->_musicRepeat = false;
+ _vm->_midi->newMusic(1, 1);
+ _vm->_midi->_musicRepeat = false;
_vm->_events->zeroKeys();
_vm->_room->loadRoom(0);
_vm->_screen->clearScreen();
@@ -468,8 +468,8 @@ void Opening::doTent() {
}
} else if (_vm->_video->_videoFrame == 18) {
if (step != 1) {
- _vm->_sound->newMusic(73, 1);
- _vm->_sound->newMusic(11, 0);
+ _vm->_midi->newMusic(73, 1);
+ _vm->_midi->newMusic(11, 0);
step = 1;
_vm->_sound->playSound(1);
}
@@ -499,7 +499,7 @@ void Opening::doTent() {
_vm->_events->pollEventsAndWait();
_vm->_events->showCursor();
- _vm->_sound->newMusic(11, 1);
+ _vm->_midi->newMusic(11, 1);
_vm->_sound->_soundTable.clear();
_vm->establishCenter(0, 4);
@@ -1262,7 +1262,7 @@ void Cast::doCast(int param1) {
_vm->_newRects.clear();
_vm->_numAnimTimers = 0;
- _vm->_sound->newMusic(58, 0);
+ _vm->_midi->newMusic(58, 0);
_vm->_screen->forceFadeIn();
while (!_vm->shouldQuit()) {
@@ -1284,14 +1284,14 @@ void Cast::doCast(int param1) {
_vm->_events->pollEventsAndWait();
}
- while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone())
+ while (!_vm->shouldQuit() && !_vm->_midi->checkMidiDone())
_vm->_events->pollEventsAndWait();
break;
}
}
- _vm->_sound->newMusic(58, 1);
+ _vm->_midi->newMusic(58, 1);
_vm->_events->showCursor();
_vm->freeCells();
@@ -1787,7 +1787,7 @@ void River::river() {
// int bx = _vm->_player->_scrollAmount - _screenVertX;
if (_vm->_screen->_scrollX == 0) {
- _vm->_sound->midiRepeat();
+ _vm->_midi->midiRepeat();
if (riverJumpTest()) {
_CHICKENOUTFLG = false;
return;
diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp
index f38c80c915..da43f1bc82 100644
--- a/engines/access/amazon/amazon_scripts.cpp
+++ b/engines/access/amazon/amazon_scripts.cpp
@@ -333,7 +333,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) {
_game->_guard.doGuard();
break;
case 10:
- _vm->_sound->newMusic(param1, param2);
+ _vm->_midi->newMusic(param1, param2);
break;
case 11:
plotInactive();
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index b9ce06959a..7ef3d6937d 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -86,7 +86,7 @@ void Room::doRoom() {
g_system->delayMillis(5);
_vm->_player->walk();
- _vm->_sound->midiRepeat();
+ _vm->_midi->midiRepeat();
_vm->_player->checkScroll();
doCommands();
@@ -150,10 +150,10 @@ void Room::doRoom() {
}
void Room::clearRoom() {
- if (_vm->_sound->_music) {
- _vm->_sound->stopSong();
- delete _vm->_sound->_music;
- _vm->_sound->_music = nullptr;
+ if (_vm->_midi->_music) {
+ _vm->_midi->stopSong();
+ delete _vm->_midi->_music;
+ _vm->_midi->_music = nullptr;
}
_vm->_sound->freeSounds();
@@ -181,11 +181,11 @@ void Room::loadRoomData(const byte *roomData) {
}
}
- _vm->_sound->freeMusic();
+ _vm->_midi->freeMusic();
if (roomInfo._musicFile._fileNum != -1) {
- _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile);
- _vm->_sound->midiPlay();
- _vm->_sound->_musicRepeat = true;
+ _vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile);
+ _vm->_midi->midiPlay();
+ _vm->_midi->_musicRepeat = true;
}
_vm->_scaleH1 = roomInfo._scaleH1;
diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp
index add461eb81..2c32f59ced 100644
--- a/engines/access/scripts.cpp
+++ b/engines/access/scripts.cpp
@@ -679,7 +679,7 @@ void Scripts::cmdWait() {
while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() &&
!_vm->_events->_leftButton && !_vm->_events->_rightButton &&
_vm->_timers[3]._flag) {
- _vm->_sound->midiRepeat();
+ _vm->_midi->midiRepeat();
charLoop();
_vm->_events->pollEvents();
diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp
index fdc606b43e..7d1885955a 100644
--- a/engines/access/sound.cpp
+++ b/engines/access/sound.cpp
@@ -32,17 +32,12 @@ namespace Access {
SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
_vm(vm), _mixer(mixer) {
- _music = nullptr;
- _tempMusic = nullptr;
- _musicRepeat = false;
_playingSound = false;
_isVoice = false;
}
SoundManager::~SoundManager() {
clearSounds();
- delete _music;
- delete _tempMusic;
}
void SoundManager::clearSounds() {
@@ -138,33 +133,51 @@ void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
}
}
-void SoundManager::midiPlay() {
- // TODO
+void SoundManager::stopSound() {
+ // TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG
+ warning("TODO: stopSound");
+}
+
+void SoundManager::freeSounds() {
+ stopSound();
+ clearSounds();
+}
+
+/******************************************************************************************/
+
+MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) {
+ _music = nullptr;
+ _tempMusic = nullptr;
+ _musicRepeat = false;
+}
+
+MusicManager::~MusicManager() {
+ delete _music;
+ delete _tempMusic;
}
-bool SoundManager::checkMidiDone() {
+void MusicManager::midiPlay() {
// TODO
- return true;
}
-void SoundManager::midiRepeat() {
+bool MusicManager::checkMidiDone() {
// TODO
+ return true;
}
-void SoundManager::stopSong() {
+void MusicManager::midiRepeat() {
// TODO
}
-void SoundManager::stopSound() {
- // TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG
+void MusicManager::stopSong() {
+ // TODO
}
-void SoundManager::freeSounds() {
- stopSound();
- clearSounds();
+Resource *MusicManager::loadMusic(int fileNum, int subfile) {
+ return _vm->_files->loadFile(fileNum, subfile);
}
-void SoundManager::newMusic(int musicId, int mode) {
+void MusicManager::newMusic(int musicId, int mode) {
if (mode == 1) {
stopSong();
freeMusic();
@@ -177,11 +190,11 @@ void SoundManager::newMusic(int musicId, int mode) {
_musicRepeat = (mode == 2);
_tempMusic = _music;
stopSong();
- _music = loadSound(97, musicId);
+ _music = loadMusic(97, musicId);
}
}
-void SoundManager::freeMusic() {
+void MusicManager::freeMusic() {
delete _music;
_music = nullptr;
}
diff --git a/engines/access/sound.h b/engines/access/sound.h
index 46e3b23bb1..b14ce7c685 100644
--- a/engines/access/sound.h
+++ b/engines/access/sound.h
@@ -54,9 +54,6 @@ private:
public:
Common::Array<SoundEntry> _soundTable;
- Resource *_music;
- Resource *_tempMusic;
- bool _musicRepeat;
bool _playingSound;
bool _isVoice;
public:
@@ -70,6 +67,25 @@ public:
Resource *loadSound(int fileNum, int subfile);
void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
+ void freeSounds();
+};
+
+class MusicManager {
+private:
+ AccessEngine *_vm;
+ Audio::Mixer *_mixer;
+
+ Resource *loadMusic(int fileNum, int subfile);
+
+public:
+ Resource *_music;
+ Resource *_tempMusic;
+ bool _musicRepeat;
+ bool _playingSound;
+public:
+ MusicManager(AccessEngine *vm, Audio::Mixer *mixer);
+ ~MusicManager();
+
void midiPlay();
bool checkMidiDone();
@@ -78,13 +94,10 @@ public:
void stopSong();
- void freeSounds();
-
void newMusic(int musicId, int mode);
void freeMusic();
};
-
} // End of namespace Access
#endif /* ACCESS_SOUND_H*/