aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/inter_v2.cpp
diff options
context:
space:
mode:
authorSven Hesse2008-05-08 00:47:23 +0000
committerSven Hesse2008-05-08 00:47:23 +0000
commit220d6ce82f478966db6a4760b2288750212880b9 (patch)
treeef41df7127d8e1b9ec8ca523174431193f521f68 /engines/gob/inter_v2.cpp
parent627d30d389299ee64f0105f08e8910206a1e9edb (diff)
downloadscummvm-rg350-220d6ce82f478966db6a4760b2288750212880b9.tar.gz
scummvm-rg350-220d6ce82f478966db6a4760b2288750212880b9.tar.bz2
scummvm-rg350-220d6ce82f478966db6a4760b2288750212880b9.zip
Restructured sound code
svn-id: r31937
Diffstat (limited to 'engines/gob/inter_v2.cpp')
-rw-r--r--engines/gob/inter_v2.cpp108
1 files changed, 27 insertions, 81 deletions
diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp
index 2442e4dcf2..36f33e6553 100644
--- a/engines/gob/inter_v2.cpp
+++ b/engines/gob/inter_v2.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "common/endian.h"
#include "sound/mixer.h"
#include "sound/mods/infogrames.h"
@@ -33,8 +32,6 @@
#include "gob/global.h"
#include "gob/util.h"
#include "gob/dataio.h"
-#include "gob/music.h"
-#include "gob/cdrom.h"
#include "gob/draw.h"
#include "gob/game.h"
#include "gob/goblin.h"
@@ -42,10 +39,10 @@
#include "gob/mult.h"
#include "gob/parse.h"
#include "gob/scenery.h"
-#include "gob/sound.h"
#include "gob/video.h"
#include "gob/saveload.h"
#include "gob/videoplayer.h"
+#include "gob/sound/sound.h"
namespace Gob {
@@ -1086,16 +1083,16 @@ void Inter_v2::o2_playCDTrack() {
_vm->_draw->blitInvalidated();
evalExpr(0);
- _vm->_cdrom->startTrack(_vm->_global->_inter_resStr);
+ _vm->_sound->cdPlay(_vm->_global->_inter_resStr);
}
void Inter_v2::o2_waitCDTrackEnd() {
- while (_vm->_cdrom->getTrackPos() >= 0)
+ while (_vm->_sound->cdGetTrackPos() >= 0)
_vm->_util->longDelay(1);
}
void Inter_v2::o2_stopCD() {
- _vm->_cdrom->stopPlaying();
+ _vm->_sound->cdStop();
}
void Inter_v2::o2_readLIC() {
@@ -1105,11 +1102,11 @@ void Inter_v2::o2_readLIC() {
strncpy0(path, _vm->_global->_inter_resStr, 35);
strcat(path, ".LIC");
- _vm->_cdrom->readLIC(path);
+ _vm->_sound->cdLoadLIC(path);
}
void Inter_v2::o2_freeLIC() {
- _vm->_cdrom->freeLICbuffer();
+ _vm->_sound->cdUnloadLIC();
}
void Inter_v2::o2_getCDTrackPos() {
@@ -1121,8 +1118,8 @@ void Inter_v2::o2_getCDTrackPos() {
varPos = _vm->_parse->parseVarIndex();
varName = _vm->_parse->parseVarIndex();
- WRITE_VAR_OFFSET(varPos, _vm->_cdrom->getTrackPos(GET_VARO_STR(varName)));
- WRITE_VARO_STR(varName, _vm->_cdrom->getCurTrack());
+ WRITE_VAR_OFFSET(varPos, _vm->_sound->cdGetTrackPos(GET_VARO_STR(varName)));
+ WRITE_VARO_STR(varName, _vm->_sound->cdGetCurrentTrack());
}
void Inter_v2::o2_loadFontToSprite() {
@@ -1883,10 +1880,9 @@ bool Inter_v2::o2_stopSound(OpFuncParams &params) {
expr = _vm->_parse->parseValExpr();
if (expr < 0) {
- if (_vm->_adlib)
- _vm->_adlib->stopPlay();
+ _vm->_sound->adlibStop();
} else
- _vm->_snd->stopSound(expr);
+ _vm->_sound->blasterStop(expr);
_soundEndTimeKey = 0;
return false;
@@ -2009,7 +2005,7 @@ bool Inter_v2::o2_readData(OpFuncParams &params) {
WRITE_VAR(59, stream->readUint32LE());
// The scripts in some versions divide through 256^3 then,
// effectively doing a LE->BE conversion
- if ((_vm->_platform != Common::kPlatformPC) && (VAR(59) < 256))
+ if ((_vm->getPlatform() != Common::kPlatformPC) && (VAR(59) < 256))
WRITE_VAR(59, SWAP_BYTES_32(VAR(59)));
} else
retSize = stream->read(buf, size);
@@ -2054,29 +2050,11 @@ void Inter_v2::o2_loadInfogramesIns(OpGobParams &params) {
varName = load16();
- if (_vm->_noMusic)
- return;
-
strncpy0(fileName, GET_VAR_STR(varName), 15);
strcat(fileName, ".INS");
- debugC(1, kDebugMusic, "Loading Infogrames instrument file \"%s\"",
- fileName);
-
- if (_vm->_game->_infogrames) {
- _vm->_mixer->stopHandle(_vm->_game->_infHandle);
- delete _vm->_game->_infogrames;
- _vm->_game->_infogrames = 0;
- }
+ debugC(1, kDebugMusic, "Loading Infogrames instrument file \"%s\"", fileName);
- if (_vm->_game->_infIns)
- delete _vm->_game->_infIns;
-
- _vm->_game->_infIns = new Audio::Infogrames::Instruments;
- if (!_vm->_game->_infIns->load(fileName)) {
- warning("Couldn't load instruments file");
- delete _vm->_game->_infIns;
- _vm->_game->_infIns = 0;
- }
+ _vm->_sound->infogramesLoadInstruments(fileName);
}
void Inter_v2::o2_playInfogrames(OpGobParams &params) {
@@ -2085,58 +2063,24 @@ void Inter_v2::o2_playInfogrames(OpGobParams &params) {
varName = load16();
- if (_vm->_noMusic)
- return;
-
strncpy0(fileName, GET_VAR_STR(varName), 15);
strcat(fileName, ".DUM");
debugC(1, kDebugMusic, "Playing Infogrames music file \"%s\"", fileName);
- if (!_vm->_game->_infIns) {
- _vm->_game->_infIns = new Audio::Infogrames::Instruments;
-
- if (!_vm->_game->_infIns->load("i1.ins")) {
- warning("Couldn't load instruments file");
- delete _vm->_game->_infIns;
- _vm->_game->_infIns = 0;
- }
- }
-
- if (_vm->_game->_infIns) {
- _vm->_mixer->stopHandle(_vm->_game->_infHandle);
- delete _vm->_game->_infogrames;
- _vm->_game->_infogrames =
- new Audio::Infogrames(*_vm->_game->_infIns, true,
- _vm->_mixer->getOutputRate(),
- _vm->_mixer->getOutputRate() / 75);
-
- if (!_vm->_game->_infogrames->load(fileName)) {
- warning("Couldn't load infogrames music");
- delete _vm->_game->_infogrames;
- _vm->_game->_infogrames = 0;
- } else
- _vm->_mixer->playInputStream(Audio::Mixer::kMusicSoundType,
- &_vm->_game->_infHandle, _vm->_game->_infogrames,
- -1, 255, 0, false);
- }
+ _vm->_sound->infogramesLoadSong(fileName);
+ _vm->_sound->infogramesPlay();
}
void Inter_v2::o2_startInfogrames(OpGobParams &params) {
load16();
- if (_vm->_game->_infogrames &&
- !_vm->_mixer->isSoundHandleActive(_vm->_game->_infHandle)) {
- _vm->_game->_infogrames->restart();
- _vm->_mixer->playInputStream(Audio::Mixer::kMusicSoundType,
- &_vm->_game->_infHandle, _vm->_game->_infogrames,
- -1, 255, 0, false);
- }
+ _vm->_sound->infogramesPlay();
}
void Inter_v2::o2_stopInfogrames(OpGobParams &params) {
load16();
- _vm->_mixer->stopHandle(_vm->_game->_infHandle);
+ _vm->_sound->infogramesStop();
}
void Inter_v2::o2_handleGoblins(OpGobParams &params) {
@@ -2172,15 +2116,15 @@ int16 Inter_v2::loadSound(int16 search) {
} else {
id = load16();
- for (slot = 0; slot < 60; slot++)
- if (_vm->_game->_soundSamples[slot].isId(id)) {
+ for (slot = 0; slot < Sound::kSoundsCount; slot++)
+ if (_vm->_sound->sampleGetBySlot(slot)->isId(id)) {
slotIdMask = 0x8000;
break;
}
- if (slot == 60) {
- for (slot = 59; slot >= 0; slot--) {
- if (_vm->_game->_soundSamples[slot].empty())
+ if (slot == Sound::kSoundsCount) {
+ for (slot = (Sound::kSoundsCount - 1); slot >= 0; slot--) {
+ if (_vm->_sound->sampleGetBySlot(slot)->empty())
break;
}
@@ -2192,7 +2136,9 @@ int16 Inter_v2::loadSound(int16 search) {
}
}
- _vm->_game->freeSoundSlot(slot);
+ SoundDesc *sample = _vm->_sound->sampleGetBySlot(slot);
+
+ _vm->_sound->sampleFree(sample, true, slot);
if (id == -1) {
char sndfile[14];
@@ -2224,8 +2170,8 @@ int16 Inter_v2::loadSound(int16 search) {
}
if (dataPtr) {
- _vm->_game->_soundSamples[slot].load(type, source, dataPtr, dataSize);
- _vm->_game->_soundSamples[slot]._id = id;
+ sample->load(type, source, dataPtr, dataSize);
+ sample->_id = id;
}
return slot | slotIdMask;