Skip to content

Commit

Permalink
GOB: Play the music on the title screen of Gob1 EGA
Browse files Browse the repository at this point in the history
The EGA version of Gobliiins comes with an MDY track.
While the original doesn't play it, we thought it might
be a nice idea to play it nevertheless.
  • Loading branch information
DrMcCoy committed Jun 11, 2012
1 parent 385bd7c commit fe44939
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 22 deletions.
4 changes: 2 additions & 2 deletions engines/gob/detection_tables.h
Expand Up @@ -34,7 +34,7 @@ static const GOBGameDescription gameDescriptions[] = {
GUIO2(GUIO_NOSUBTITLES, GUIO_NOSPEECH)
},
kGameTypeGob1,
kFeaturesEGA,
kFeaturesEGA | kFeaturesAdLib,
0, 0, 0
},
{
Expand All @@ -48,7 +48,7 @@ static const GOBGameDescription gameDescriptions[] = {
GUIO2(GUIO_NOSUBTITLES, GUIO_NOSPEECH)
},
kGameTypeGob1,
kFeaturesEGA,
kFeaturesEGA | kFeaturesAdLib,
0, 0, 0
},
{ // Supplied by Theruler76 in bug report #1201233
Expand Down
34 changes: 32 additions & 2 deletions engines/gob/inter_v1.cpp
Expand Up @@ -286,10 +286,40 @@ void Inter_v1::o1_loadMult() {
}

void Inter_v1::o1_playMult() {
int16 checkEscape;
// NOTE: The EGA version of Gobliiins has an MDY tune.
// While the original doesn't play it, we do.
bool isGob1EGAIntro = _vm->getGameType() == kGameTypeGob1 &&
_vm->isEGA() &&
_vm->_game->_script->pos() == 1010 &&
_vm->isCurrentTot("intro.tot") &&
VAR(57) != 0xFFFFFFFF &&
_vm->_dataIO->hasFile("goblins.mdy") &&
_vm->_dataIO->hasFile("goblins.tbr");

int16 checkEscape = _vm->_game->_script->readInt16();

if (isGob1EGAIntro) {
_vm->_sound->adlibLoadTBR("goblins.tbr");
_vm->_sound->adlibLoadMDY("goblins.mdy");
_vm->_sound->adlibSetRepeating(-1);

_vm->_sound->adlibPlay();
}

checkEscape = _vm->_game->_script->readInt16();
_vm->_mult->playMult(VAR(57), -1, checkEscape, 0);

if (isGob1EGAIntro) {

// User didn't escape the intro mult, wait for an escape here
if (VAR(57) != 0xFFFFFFFF) {
while (_vm->_util->getKey() != kKeyEscape) {
_vm->_util->processInput();
_vm->_util->longDelay(1);
}
}

_vm->_sound->adlibUnload();
}
}

void Inter_v1::o1_freeMultKeys() {
Expand Down
6 changes: 3 additions & 3 deletions engines/gob/sound/adlib.h
Expand Up @@ -20,8 +20,8 @@
*
*/

#ifndef GOB_SOUND_NEWADLIB_H
#define GOB_SOUND_NEWADLIB_H
#ifndef GOB_SOUND_ADLIB_H
#define GOB_SOUND_ADLIB_H

#include "common/mutex.h"

Expand Down Expand Up @@ -303,4 +303,4 @@ class AdLib : public Audio::AudioStream {

} // End of namespace Gob

#endif // GOB_SOUND_NEWADLIB_H
#endif // GOB_SOUND_ADLIB_H
53 changes: 38 additions & 15 deletions engines/gob/sound/sound.cpp
Expand Up @@ -51,6 +51,8 @@ Sound::Sound(GobEngine *vm) : _vm(vm) {

_hasAdLib = (!_vm->_noMusic && _vm->hasAdLib());

_hasAdLibBg = _hasAdLib;

if (!_vm->_noMusic && (_vm->getPlatform() == Common::kPlatformAmiga)) {
_infogrames = new Infogrames(*_vm->_mixer);
_protracker = new Protracker(*_vm->_mixer);
Expand Down Expand Up @@ -274,8 +276,7 @@ bool Sound::adlibLoadMDY(const char *fileName) {
if (!_hasAdLib)
return false;

if (!_mdyPlayer)
_mdyPlayer = new MUSPlayer(*_vm->_mixer);
createMDYPlayer();

debugC(1, kDebugSound, "AdLib: Loading MDY data (\"%s\")", fileName);

Expand All @@ -296,8 +297,7 @@ bool Sound::adlibLoadTBR(const char *fileName) {
if (!_hasAdLib)
return false;

if (!_mdyPlayer)
_mdyPlayer = new MUSPlayer(*_vm->_mixer);
createMDYPlayer();

Common::SeekableReadStream *stream = _vm->_dataIO->getFile(fileName);
if (!stream) {
Expand All @@ -318,8 +318,7 @@ void Sound::adlibPlayTrack(const char *trackname) {
if (!_hasAdLib)
return;

if (!_adlPlayer)
_adlPlayer = new ADLPlayer(*_vm->_mixer);
createADLPlayer();

if (_adlPlayer->isPlaying())
return;
Expand All @@ -329,11 +328,10 @@ void Sound::adlibPlayTrack(const char *trackname) {
}

void Sound::adlibPlayBgMusic() {
if (!_hasAdLib)
if (!_hasAdLib || _hasAdLibBg)
return;

if (!_adlPlayer)
_adlPlayer = new ADLPlayer(*_vm->_mixer);
createADLPlayer();

static const char *const tracksMac[] = {
// "musmac1.adl", // This track seems to be missing instruments...
Expand All @@ -352,13 +350,18 @@ void Sound::adlibPlayBgMusic() {
"musmac5.mid"
};

if (_vm->getPlatform() == Common::kPlatformWindows) {
int track = _vm->_util->getRandom(ARRAYSIZE(tracksWin));
adlibPlayTrack(tracksWin[track]);
} else {
int track = _vm->_util->getRandom(ARRAYSIZE(tracksMac));
adlibPlayTrack(tracksMac[track]);
const char *track = 0;
if (_vm->getPlatform() == Common::kPlatformWindows)
track = tracksWin[ARRAYSIZE(tracksWin)];
else
track = tracksMac[_vm->_util->getRandom(ARRAYSIZE(tracksMac))];

if (!track || !_vm->_dataIO->hasFile(track)) {
_hasAdLibBg = false;
return;
}

adlibPlayTrack(track);
}

void Sound::adlibPlay() {
Expand Down Expand Up @@ -722,4 +725,24 @@ void Sound::bgUnshade() {
_bgatmos->unshade();
}

void Sound::createMDYPlayer() {
if (_mdyPlayer)
return;

delete _adlPlayer;
_adlPlayer = 0;

_mdyPlayer = new MUSPlayer(*_vm->_mixer);
}

void Sound::createADLPlayer() {
if (_adlPlayer)
return;

delete _mdyPlayer;
_mdyPlayer= 0;

_adlPlayer = new ADLPlayer(*_vm->_mixer);
}

} // End of namespace Gob
4 changes: 4 additions & 0 deletions engines/gob/sound/sound.h
Expand Up @@ -142,6 +142,7 @@ class Sound {
GobEngine *_vm;

bool _hasAdLib;
bool _hasAdLibBg;

SoundDesc _sounds[kSoundsCount];

Expand All @@ -162,6 +163,9 @@ class Sound {

// Audio CD
CDROM *_cdrom;

void createMDYPlayer();
void createADLPlayer();
};

} // End of namespace Gob
Expand Down

0 comments on commit fe44939

Please sign in to comment.