Skip to content

Commit

Permalink
MOHAWK: Allow the games to have a different sound manager
Browse files Browse the repository at this point in the history
  • Loading branch information
bgK committed Aug 11, 2016
1 parent e55758f commit aeee488
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 34 deletions.
3 changes: 3 additions & 0 deletions engines/mohawk/cstime.cpp
Expand Up @@ -54,6 +54,7 @@ MohawkEngine_CSTime::MohawkEngine_CSTime(OSystem *syst, const MohawkGameDescript

_console = 0;
_gfx = 0;
_sound = 0;
_cursor = 0;
_interface = 0;
_view = 0;
Expand All @@ -66,6 +67,7 @@ MohawkEngine_CSTime::~MohawkEngine_CSTime() {
delete _interface;
delete _view;
delete _console;
delete _sound;
delete _gfx;
delete _rnd;
}
Expand All @@ -75,6 +77,7 @@ Common::Error MohawkEngine_CSTime::run() {

_console = new CSTimeConsole(this);
_gfx = new CSTimeGraphics(this);
_sound = new Sound(this);
_cursor = new DefaultCursorManager(this, ID_CURS);

_interface = new CSTimeInterface(this);
Expand Down
1 change: 1 addition & 0 deletions engines/mohawk/cstime.h
Expand Up @@ -136,6 +136,7 @@ class MohawkEngine_CSTime : public MohawkEngine {

Common::RandomSource *_rnd;

Sound *_sound;
CSTimeGraphics *_gfx;
bool _needsUpdate;

Expand Down
3 changes: 3 additions & 0 deletions engines/mohawk/livingbooks.cpp
Expand Up @@ -144,6 +144,7 @@ MohawkEngine_LivingBooks::MohawkEngine_LivingBooks(OSystem *syst, const MohawkGa

_rnd = new Common::RandomSource("livingbooks");

_sound = NULL;
_page = NULL;

const Common::FSNode gameDataDir(ConfMan.get("path"));
Expand All @@ -158,6 +159,7 @@ MohawkEngine_LivingBooks::~MohawkEngine_LivingBooks() {
destroyPage();

delete _console;
delete _sound;
delete _gfx;
delete _rnd;
_bookInfoFile.clear();
Expand All @@ -182,6 +184,7 @@ Common::Error MohawkEngine_LivingBooks::run() {
error("Could not find xRes/yRes variables");

_gfx = new LBGraphics(this, _screenWidth, _screenHeight);
_sound = new Sound(this);

if (getGameType() != GType_LIVINGBOOKSV1)
_cursor = new LivingBooksCursorManager_v2();
Expand Down
1 change: 1 addition & 0 deletions engines/mohawk/livingbooks.h
Expand Up @@ -714,6 +714,7 @@ class MohawkEngine_LivingBooks : public MohawkEngine {

Common::RandomSource *_rnd;

Sound *_sound;
LBGraphics *_gfx;
bool _needsRedraw, _needsUpdate;

Expand Down
9 changes: 2 additions & 7 deletions engines/mohawk/mohawk.cpp
Expand Up @@ -40,14 +40,12 @@ MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc)
// Setup mixer
syncSoundSettings();

_sound = 0;
_video = 0;
_pauseDialog = 0;
_cursor = 0;
}

MohawkEngine::~MohawkEngine() {
delete _sound;
delete _video;
delete _pauseDialog;
delete _cursor;
Expand All @@ -58,22 +56,19 @@ MohawkEngine::~MohawkEngine() {
}

Common::Error MohawkEngine::run() {
_sound = new Sound(this);
_video = new VideoManager(this);
_pauseDialog = new PauseDialog(this, "The game is paused. Press any key to continue.");

return Common::kNoError;
}

void MohawkEngine::pauseEngineIntern(bool pause) {
Engine::pauseEngineIntern(pause);

if (pause) {
_video->pauseVideos();
_sound->pauseSound();
_sound->pauseSLST();
} else {
_video->resumeVideos();
_sound->resumeSound();
_sound->resumeSLST();
_system->updateScreen();
}
}
Expand Down
1 change: 0 additions & 1 deletion engines/mohawk/mohawk.h
Expand Up @@ -100,7 +100,6 @@ class MohawkEngine : public ::Engine {

bool hasFeature(EngineFeature f) const;

Sound *_sound;
VideoManager *_video;
CursorManager *_cursor;

Expand Down
3 changes: 3 additions & 0 deletions engines/mohawk/myst.cpp
Expand Up @@ -75,6 +75,7 @@ MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription
_curResource = -1;
_hoverResource = nullptr;

_sound = nullptr;
_gfx = nullptr;
_console = nullptr;
_scriptParser = nullptr;
Expand All @@ -88,6 +89,7 @@ MohawkEngine_Myst::~MohawkEngine_Myst() {
DebugMan.clearAllDebugChannels();

delete _gfx;
delete _sound;
delete _console;
delete _scriptParser;
delete _gameState;
Expand Down Expand Up @@ -220,6 +222,7 @@ Common::Error MohawkEngine_Myst::run() {
MohawkEngine::run();

_gfx = new MystGraphics(this);
_sound = new Sound(this);
_console = new MystConsole(this);
_gameState = new MystGameState(this, _saveFileMan);
_optionsDialog = new MystOptionsDialog(this);
Expand Down
1 change: 1 addition & 0 deletions engines/mohawk/myst.h
Expand Up @@ -200,6 +200,7 @@ class MohawkEngine_Myst : public MohawkEngine {

bool _showResourceRects;

Sound *_sound;
MystGraphics *_gfx;
MystGameState *_gameState;
MystScriptParser *_scriptParser;
Expand Down
3 changes: 3 additions & 0 deletions engines/mohawk/riven.cpp
Expand Up @@ -59,6 +59,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
_curStack = kStackUnknown;
_hotspots = nullptr;
_gfx = nullptr;
_sound = nullptr;
_externalScriptHandler = nullptr;
_rnd = nullptr;
_scriptMan = nullptr;
Expand Down Expand Up @@ -92,6 +93,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
}

MohawkEngine_Riven::~MohawkEngine_Riven() {
delete _sound;
delete _gfx;
delete _console;
delete _externalScriptHandler;
Expand Down Expand Up @@ -123,6 +125,7 @@ Common::Error MohawkEngine_Riven::run() {
SearchMan.add("arcriven.z", &_installerArchive, 0, false);

_gfx = new RivenGraphics(this);
_sound = new Sound(this);
_console = new RivenConsole(this);
_saveLoad = new RivenSaveLoad(this, _saveFileMan);
_externalScriptHandler = new RivenExternal(this);
Expand Down
1 change: 1 addition & 0 deletions engines/mohawk/riven.h
Expand Up @@ -121,6 +121,7 @@ class MohawkEngine_Riven : public MohawkEngine {
MohawkEngine_Riven(OSystem *syst, const MohawkGameDescription *gamedesc);
virtual ~MohawkEngine_Riven();

Sound *_sound;
RivenGraphics *_gfx;
RivenExternal *_externalScriptHandler;
Common::RandomSource *_rnd;
Expand Down
22 changes: 0 additions & 22 deletions engines/mohawk/sound.cpp
Expand Up @@ -518,16 +518,6 @@ void Sound::stopSLSTSound(uint16 index, bool fade) {
_currentSLSTSounds.remove_at(index);
}

void Sound::pauseSLST() {
for (uint16 i = 0; i < _currentSLSTSounds.size(); i++)
_vm->_mixer->pauseHandle(*_currentSLSTSounds[i].handle, true);
}

void Sound::resumeSLST() {
for (uint16 i = 0; i < _currentSLSTSounds.size(); i++)
_vm->_mixer->pauseHandle(*_currentSLSTSounds[i].handle, false);
}

Audio::RewindableAudioStream *Sound::makeLivingBooksWaveStream_v1(Common::SeekableReadStream *stream) {
uint16 header = stream->readUint16BE();
uint16 rate = 0;
Expand Down Expand Up @@ -591,18 +581,6 @@ void Sound::stopSound(uint16 id) {
}
}

void Sound::pauseSound() {
for (uint32 i = 0; i < _handles.size(); i++)
if (_handles[i].type == kUsedHandle)
_vm->_mixer->pauseHandle(_handles[i].handle, true);
}

void Sound::resumeSound() {
for (uint32 i = 0; i < _handles.size(); i++)
if (_handles[i].type == kUsedHandle)
_vm->_mixer->pauseHandle(_handles[i].handle, false);
}

bool Sound::isPlaying(uint16 id) {
for (uint32 i = 0; i < _handles.size(); i++)
if (_handles[i].type == kUsedHandle && _handles[i].id == id)
Expand Down
4 changes: 0 additions & 4 deletions engines/mohawk/sound.h
Expand Up @@ -132,8 +132,6 @@ class Sound {
void stopMidi();
void stopSound();
void stopSound(uint16 id);
void pauseSound();
void resumeSound();
bool isPlaying(uint16 id);
bool isPlaying();
uint getNumSamplesPlayed(uint16 id);
Expand All @@ -149,8 +147,6 @@ class Sound {
// Riven-specific sound functions
void playSLST(uint16 index, uint16 card);
void playSLST(SLSTRecord slstRecord);
void pauseSLST();
void resumeSLST();
void stopAllSLST(bool fade = false);
static byte convertRivenVolume(uint16 volume);

Expand Down

0 comments on commit aeee488

Please sign in to comment.