aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gob/game.cpp6
-rw-r--r--gob/gob.cpp5
-rw-r--r--gob/gob.h3
-rw-r--r--gob/goblin.cpp5
-rw-r--r--gob/inter.cpp4
-rw-r--r--gob/inter_v1.cpp15
-rw-r--r--gob/music.cpp67
-rw-r--r--gob/music.h4
8 files changed, 94 insertions, 15 deletions
diff --git a/gob/game.cpp b/gob/game.cpp
index 6718c96703..f07fc6c73b 100644
--- a/gob/game.cpp
+++ b/gob/game.cpp
@@ -33,6 +33,7 @@
#include "gob/util.h"
#include "gob/goblin.h"
#include "gob/cdrom.h"
+#include "gob/music.h"
namespace Gob {
@@ -1759,7 +1760,10 @@ void Game::playTot(int16 skipPlay) {
_vm->_draw->_fontToSprite[i].height = -1;
}
- _vm->_cdrom->stopPlaying();
+ if(_vm->_features & GF_MAC)
+ _vm->_music->stopPlay();
+ else
+ _vm->_cdrom->stopPlaying();
_vm->_draw->animateCursor(4);
_vm->_inter->initControlVars();
_vm->_mult->initAll();
diff --git a/gob/gob.cpp b/gob/gob.cpp
index 7344208e56..a5d7f0f06d 100644
--- a/gob/gob.cpp
+++ b/gob/gob.cpp
@@ -70,6 +70,8 @@ static const Gob::GobGameSettings gob_games[] = {
{"gob1", "Gobliiins (Amiga)", Gob::GF_GOB1, "baf88a95928edb3f51067983f2dffa93"},
{"gob1", "Gobliiins (Interactive Demo)", Gob::GF_GOB1, "4f5bf4b9e4c39ebb93579747fc678e97"},
+
+ {"gob1", "Gobliiins (Mac)", Gob::GF_GOB1 | Gob::GF_MAC, "4c0e8ce4a2f66ee8226952ad3c6c1155"},
#if 0
{"gob2", "Gobliins 2 (DOS)", Gob::GF_GOB2, "abb5f762f9979d4253002de20f6e7b56"},
@@ -290,13 +292,14 @@ int GobEngine::init(GameDetector &detector) {
_scenery = new Scenery(this);
_gtimer = new GTimer();
_util = new Util(this);
- _music = new Music(this);
if (_features & Gob::GF_GOB1)
_inter = new Inter_v1(this);
else if (_features & Gob::GF_GOB2)
_inter = new Inter_v2(this);
else
error("GobEngine::init(): Unknown version of game engine");
+ if ((_features & Gob::GF_MAC) || (_features & Gob::GF_GOB1))
+ _music = new Music(this);
_system->beginGFXTransaction();
initCommonGFX(detector);
diff --git a/gob/gob.h b/gob/gob.h
index 099e64bdf6..0a14f2c9d6 100644
--- a/gob/gob.h
+++ b/gob/gob.h
@@ -69,7 +69,8 @@ enum {
GF_GOB2 = 1 << 1,
GF_GOB3 = 1 << 2,
GF_WOODRUFF = 1 << 3,
- GF_CD = 1 << 4
+ GF_CD = 1 << 4,
+ GF_MAC = 1 << 5
};
typedef struct GobGameSettings {
diff --git a/gob/goblin.cpp b/gob/goblin.cpp
index 98158dcaa8..1fafda551f 100644
--- a/gob/goblin.cpp
+++ b/gob/goblin.cpp
@@ -32,6 +32,7 @@
#include "gob/game.h"
#include "gob/dataio.h"
#include "gob/cdrom.h"
+#include "gob/music.h"
namespace Gob {
@@ -3092,7 +3093,9 @@ void Goblin::interFunc(void) {
case 1003:
drawObjects();
- if (_vm->_cdrom->getTrackPos() == -1)
+ if (_vm->_features & GF_MAC)
+ _vm->_music->playBgMusic();
+ else if (_vm->_cdrom->getTrackPos() == -1)
_vm->_cdrom->playBgMusic();
break;
diff --git a/gob/inter.cpp b/gob/inter.cpp
index 31b61697f3..3a5c94d585 100644
--- a/gob/inter.cpp
+++ b/gob/inter.cpp
@@ -154,10 +154,10 @@ void Inter::funcBlock(int16 retFlag) {
// debug(4, "funcBlock(%d, %d)", cmd2, cmd);
- if(cmd2 == 0)
+ if (cmd2 == 0)
cmd >>= 4;
- if(executeFuncOpcode(cmd2, cmd, cmdCount, counter, retFlag))
+ if (executeFuncOpcode(cmd2, cmd, cmdCount, counter, retFlag))
return;
if (_breakFlag) {
diff --git a/gob/inter_v1.cpp b/gob/inter_v1.cpp
index eeb8ef218c..15c28be3bb 100644
--- a/gob/inter_v1.cpp
+++ b/gob/inter_v1.cpp
@@ -30,6 +30,7 @@
#include "gob/mult.h"
#include "gob/goblin.h"
#include "gob/cdrom.h"
+#include "gob/music.h"
namespace Gob {
@@ -1358,9 +1359,12 @@ void Inter_v1::o1_loadCurLayer(void) {
}
void Inter_v1::o1_playCDTrack(void) {
- // Used in gob1 CD
evalExpr(0);
- _vm->_cdrom->startTrack(_vm->_global->_inter_resStr);
+ if (_vm->_features & GF_MAC)
+ _vm->_music->playTrack(_vm->_global->_inter_resStr);
+ else
+ // Used in gob1 CD
+ _vm->_cdrom->startTrack(_vm->_global->_inter_resStr);
}
void Inter_v1::o1_getCDTrackPos(void) {
@@ -1379,8 +1383,11 @@ void Inter_v1::o1_getCDTrackPos(void) {
}
void Inter_v1::o1_stopCD(void) {
- // Used in gob1 CD
- _vm->_cdrom->stopPlaying();
+ if (_vm->_features & GF_MAC)
+ _vm->_music->stopPlay();
+ else
+ // Used in gob1 CD
+ _vm->_cdrom->stopPlaying();
}
void Inter_v1::o1_loadFontToSprite(void) {
diff --git a/gob/music.cpp b/gob/music.cpp
index a77fc0c1b6..187283c16c 100644
--- a/gob/music.cpp
+++ b/gob/music.cpp
@@ -22,9 +22,45 @@
#include "gob/music.h"
#include "gob/gob.h"
+#include "gob/game.h"
namespace Gob {
+const char *Music::_tracks[][2] = {
+ {"avt00.tot", "mine"},
+ {"avt001.tot", "nuit"},
+ {"avt002.tot", "campagne"},
+ {"avt003.tot", "extsor1"},
+ {"avt004.tot", "interieure"},
+ {"avt005.tot", "zombie"},
+ {"avt006.tot", "zombie"},
+ {"avt007.tot", "campagne"},
+ {"avt008.tot", "campagne"},
+ {"avt009.tot", "extsor1"},
+ {"avt010.tot", "extsor1"},
+ {"avt011.tot", "interieure"},
+ {"avt012.tot", "zombie"},
+ {"avt014.tot", "nuit"},
+ {"avt015.tot", "interieure"},
+ {"avt016.tot", "statue"},
+ {"avt017.tot", "zombie"},
+ {"avt018.tot", "statue"},
+ {"avt019.tot", "mine"},
+ {"avt020.tot", "statue"},
+ {"avt021.tot", "mine"},
+ {"avt022.tot", "zombie"}
+};
+
+const char *Music::_tracksToFiles[][2] = {
+ {"campagne", "Musmac2.adl"},
+ {"extsor1", "Musmac3.adl"},
+ {"interieure", "Musmac4.adl"},
+ {"mine", "Musmac5.adl"},
+ {"nuit", "Musmac6.adl"},
+ {"statue", "Musmac2.adl"},
+ {"zombie", "Musmac3.adl"}
+};
+
const unsigned char Music::_operators[] = {0, 1, 2, 8, 9, 10, 16, 17, 18};
const unsigned char Music::_volRegNums[] = {
3, 4, 5,
@@ -32,7 +68,6 @@ const unsigned char Music::_volRegNums[] = {
19, 20, 21
};
-
Music::Music(GobEngine *vm) : _vm(vm) {
_data = 0;
_playPos = 0;
@@ -71,7 +106,7 @@ void Music::premixerCall(int16 *buf, uint len) {
int16 *data = buf;
uint datalen = len;
while (datalen) {
- if(_samplesTillPoll) {
+ if (_samplesTillPoll) {
render = (datalen > _samplesTillPoll) ? (_samplesTillPoll) : (datalen);
datalen -= render;
_samplesTillPoll -= render;
@@ -79,19 +114,19 @@ void Music::premixerCall(int16 *buf, uint len) {
data += render;
} else {
pollMusic();
- if(_ended) {
+ if (_ended) {
memset(data, 0, datalen * sizeof(int16));
datalen = 0;
}
}
}
}
- if(_ended) {
+ if (_ended) {
_first = true;
_ended = false;
_playPos = _data + 3 + (_data[1] + 1) * 0x38;
_samplesTillPoll = 0;
- if(_looping) {
+ if (_looping) {
reset();
setVoices();
}
@@ -349,6 +384,28 @@ void Music::startPlay(void) {
_playing = true;
}
+void Music::playBgMusic(void) {
+ debug(2, "Music::playBgMusic()");
+ for (int i = 0; i < ARRAYSIZE(_tracks); i++)
+ if (!scumm_stricmp(_vm->_game->_curTotFile, _tracks[i][0])) {
+ playTrack(_tracks[i][1]);
+ break;
+ }
+}
+
+void Music::playTrack(const char *trackname) {
+ if (_playing) return;
+
+ debug(2, "Music::playTrack()");
+ unloadMusic();
+ for (int i = 0; i < ARRAYSIZE(_tracksToFiles); i++)
+ if (!scumm_stricmp(trackname, _tracksToFiles[i][0])) {
+ loadMusic(_tracksToFiles[i][1]);
+ startPlay();
+ break;
+ }
+}
+
bool Music::loadMusic(const char *filename) {
Common::File song;
diff --git a/gob/music.h b/gob/music.h
index a8aa06e782..e69306951a 100644
--- a/gob/music.h
+++ b/gob/music.h
@@ -42,6 +42,8 @@ public:
void setLooping(bool looping) { _looping = looping; }
void startPlay(void);
void stopPlay(void) { _playing = false; }
+ void playTrack(const char *trackname);
+ void playBgMusic(void);
bool loadMusic(const char *filename);
void unloadMusic(void);
@@ -55,6 +57,8 @@ public:
int getRate() const { return _rate; }
protected:
+ static const char *_tracks[][2];
+ static const char *_tracksToFiles[][2];
static const unsigned char _operators[];
static const unsigned char _volRegNums [];
FM_OPL *_opl;