Permalink
Browse files

SLUDGE: Objectify sound manager

  • Loading branch information...
yinsimei committed Jul 20, 2017
1 parent 2b538d4 commit 73a81a5089627599d9adbedf6d2d4dc0122d48c5
View
@@ -1063,7 +1063,7 @@ builtIn(startMusic) {
if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
if (!playMOD(fileNumber, musChan, fromTrack))
if (!g_sludge->_soundMan->playMOD(fileNumber, musChan, fromTrack))
return BR_CONTINUE; //BR_ERROR;
return BR_CONTINUE;
}
@@ -1074,7 +1074,7 @@ builtIn(stopMusic) {
if (!getValueType(v, SVT_INT, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
stopMOD(v);
g_sludge->_soundMan->stopMOD(v);
return BR_CONTINUE;
}
@@ -1087,7 +1087,7 @@ builtIn(setMusicVolume) {
if (!getValueType(musChan, SVT_INT, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
setMusicVolume(musChan, v);
g_sludge->_soundMan->setMusicVolume(musChan, v);
return BR_CONTINUE;
}
@@ -1097,7 +1097,7 @@ builtIn(setDefaultMusicVolume) {
if (!getValueType(v, SVT_INT, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
setDefaultMusicVolume(v);
g_sludge->_soundMan->setDefaultMusicVolume(v);
return BR_CONTINUE;
}
@@ -1107,7 +1107,7 @@ builtIn(playSound) {
if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
if (!startSound(fileNumber, false))
if (!g_sludge->_soundMan->startSound(fileNumber, false))
return BR_CONTINUE; // Was BR_ERROR
return BR_CONTINUE;
}
@@ -1123,7 +1123,7 @@ builtIn(loopSound) {
if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
if (!startSound(fileNumber, true))
if (!g_sludge->_soundMan->startSound(fileNumber, true))
return BR_CONTINUE; // Was BR_ERROR
return BR_CONTINUE;
} else {
@@ -1165,7 +1165,7 @@ builtIn(loopSound) {
s->next = s;
}
old->vol = -1;
playSoundList(old);
g_sludge->_soundMan->playSoundList(old);
return BR_CONTINUE;
}
}
@@ -1176,7 +1176,7 @@ builtIn(stopSound) {
if (!getValueType(v, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
huntKillSound(v);
g_sludge->_soundMan->huntKillSound(v);
return BR_CONTINUE;
}
@@ -1186,7 +1186,7 @@ builtIn(setDefaultSoundVolume) {
if (!getValueType(v, SVT_INT, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
setDefaultSoundVolume(v);
g_sludge->_soundMan->setDefaultSoundVolume(v);
return BR_CONTINUE;
}
@@ -1199,7 +1199,7 @@ builtIn(setSoundVolume) {
if (!getValueType(musChan, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
setSoundVolume(musChan, v);
g_sludge->_soundMan->setSoundVolume(musChan, v);
return BR_CONTINUE;
}
@@ -1215,7 +1215,7 @@ builtIn(setSoundLoopPoints) {
if (!getValueType(musChan, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
setSoundLoop(musChan, theStart, theEnd);
g_sludge->_soundMan->setSoundLoop(musChan, theStart, theEnd);
return BR_CONTINUE;
}
@@ -2153,7 +2153,7 @@ builtIn(cacheSound) {
if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
if (cacheSound(fileNumber) == -1)
if (g_sludge->_soundMan->cacheSound(fileNumber) == -1)
return BR_ERROR;
return BR_CONTINUE;
}
@@ -2245,7 +2245,7 @@ builtIn(getSoundCache) {
fun->reg.varData.theStack->first = NULL;
fun->reg.varData.theStack->last = NULL;
fun->reg.varData.theStack->timesUsed = 1;
if (!getSoundCacheStack(fun->reg.varData.theStack))
if (!g_sludge->_soundMan->getSoundCacheStack(fun->reg.varData.theStack))
return BR_ERROR;
return BR_CONTINUE;
}
@@ -2312,7 +2312,7 @@ builtIn(freeSound) {
if (!getValueType(v, SVT_FILE, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
huntKillFreeSound(v);
g_sludge->_soundMan->huntKillFreeSound(v);
return BR_CONTINUE;
}
@@ -432,7 +432,7 @@ bool saveGame(const Common::String &fname) {
fp->writeByte(fadeMode);
saveSpeech(speech, fp);
saveStatusBars(fp);
saveSounds(fp);
g_sludge->_soundMan->saveSounds(fp);
fp->writeUint16BE(saveEncoding);
@@ -604,7 +604,7 @@ bool loadGame(const Common::String &fname) {
fadeMode = fp->readByte();
loadSpeech(speech, fp);
loadStatusBars(fp);
loadSounds(fp);
g_sludge->_soundMan->loadSounds(fp);
saveEncoding = fp->readUint16BE();
@@ -45,12 +45,6 @@
namespace Sludge {
#ifndef MAX_PATH
#define MAX_PATH 1024 // maximum size of a path name
#endif
HWND hMainWindow = NULL;
extern VariableStack *noStack;
int dialogValue = 0;
@@ -77,7 +71,7 @@ int main_loop(const char *filename) {
resetRandW();
if (!ConfMan.hasKey("mute") || !ConfMan.getBool("mute")) {
initSoundStuff(hMainWindow);
g_sludge->_soundMan->initSoundStuff();
}
startNewFunctionNum(0, 0, NULL, noStack);
@@ -91,11 +85,11 @@ int main_loop(const char *filename) {
runSludge();
}
sludgeDisplay();
handleSoundLists();
g_sludge->_soundMan->handleSoundLists();
g_sludge->_timer.waitFrame();
}
killSoundStuff();
g_sludge->_soundMan->killSoundStuff();
return (0);
}
@@ -58,7 +58,7 @@ void registerWindowForFatal() {
}
int inFatal(const Common::String &str) {
killSoundStuff();
g_sludge->_soundMan->killSoundStuff();
error("%s", str.c_str());
return true;
}
@@ -457,7 +457,7 @@ void drawPeople() {
thisPerson->frameNum = 0;
thisPerson->frameTick = myAnim->frames[0].howMany;
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
startSound(myAnim->frames[thisPerson->frameNum].noise, false);
g_sludge->_soundMan->startSound(myAnim->frames[thisPerson->frameNum].noise, false);
thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
@@ -495,7 +495,7 @@ void drawPeople() {
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
if (thisPerson->show && myAnim && myAnim->frames) {
if (myAnim->frames[thisPerson->frameNum].noise > 0) {
startSound(myAnim->frames[thisPerson->frameNum].noise, false);
g_sludge->_soundMan->startSound(myAnim->frames[thisPerson->frameNum].noise, false);
thisPerson->frameNum++;
thisPerson->frameNum %= thisPerson->myAnim->numFrames;
thisPerson->frameTick = thisPerson->myAnim->frames[thisPerson->frameNum].howMany;
@@ -28,6 +28,7 @@
#include "sludge/event.h"
#include "sludge/graphics.h"
#include "sludge/sludge.h"
#include "sludge/sound.h"
#include "sludge/main_loop.h"
namespace Sludge {
@@ -69,6 +70,7 @@ SludgeEngine::SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc)
_objMan = new ObjectManager(this);
_gfxMan = new GraphicsManager(this);
_evtMan = new EventManager(this);
_soundMan = new SoundManager();
}
SludgeEngine::~SludgeEngine() {
@@ -91,6 +93,8 @@ SludgeEngine::~SludgeEngine() {
_pixelFormat = nullptr;
// Dispose managers
delete _soundMan;
_soundMan = nullptr;
delete _evtMan;
_evtMan = nullptr;
delete _gfxMan;
View
@@ -40,6 +40,8 @@ extern SludgeEngine *g_sludge;
class EventManager;
class GraphicsManager;
class SoundManager;
class SludgeConsole;
struct SludgeGameDescription;
@@ -76,6 +78,7 @@ class SludgeEngine: public Engine {
ObjectManager *_objMan;
GraphicsManager *_gfxMan;
EventManager *_evtMan;
SoundManager *_soundMan;
SludgeEngine(OSystem *syst, const SludgeGameDescription *gameDesc);
virtual ~SludgeEngine();
@@ -882,8 +882,8 @@ bool runSludge() {
if (!thisFunction->freezerLevel) {
if (thisFunction->timeLeft) {
if (thisFunction->timeLeft < 0) {
if (!stillPlayingSound(
findInSoundCache(speech->lastFile))) {
if (!g_sludge->_soundMan->stillPlayingSound(
g_sludge->_soundMan->findInSoundCache(speech->lastFile))) {
thisFunction->timeLeft = 0;
}
} else if (!--(thisFunction->timeLeft)) {
Oops, something went wrong.

0 comments on commit 73a81a5

Please sign in to comment.