aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--engines/cine/cine.cpp3
-rw-r--r--engines/cine/main_loop.cpp4
-rw-r--r--engines/cine/saveload.cpp9
-rw-r--r--engines/cine/script_fw.cpp6
-rw-r--r--engines/cine/sound.cpp88
-rw-r--r--engines/cine/sound.h5
7 files changed, 116 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index f9aac42b6e..bee4a0409a 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,9 @@ For a more comprehensive changelog of the latest experimental code, see:
head scene (bug #6728). It may have been happening in other scenes as
well.
+ CinE:
+ - Added support for music in CD version of Future Wars.
+
MADE:
- Improved AdLib music support in Return to Zork.
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index a4af8f2201..5fed92051c 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -92,6 +92,9 @@ Common::Error CineEngine::run() {
// Initialize backend
initGraphics(320, 200, false);
+ if (g_cine->getGameType() == GType_FW && (g_cine->getFeatures() & GF_CD))
+ checkCD();
+
if (getPlatform() == Common::kPlatformDOS) {
g_sound = new PCSound(_mixer, this);
} else {
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index 9ce683445f..e52fc464d5 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -31,6 +31,8 @@
#include "cine/bg_list.h"
#include "cine/sound.h"
+#include "backends/audiocd/audiocd.h"
+
namespace Cine {
struct MouseStatusStruct {
@@ -219,6 +221,8 @@ void manageEvents() {
mouseData.left = mouseLeft;
mouseData.right = mouseRight;
+
+ g_system->getAudioCDManager()->updateCD();
}
void getMouseData(uint16 param, uint16 *pButton, uint16 *pX, uint16 *pY) {
diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp
index c707c60695..907086a9a1 100644
--- a/engines/cine/saveload.cpp
+++ b/engines/cine/saveload.cpp
@@ -543,6 +543,15 @@ bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) {
loadRel(currentRelName);
}
+ // Reset background music in CD version of Future Wars
+ if (getGameType() == GType_FW && (getFeatures() & GF_CD)) {
+ if (strlen(bgNames[0])) {
+ char buffer[20];
+ removeExtention(buffer, bgNames[0]);
+ g_sound->setBgMusic(atoi(buffer + 1));
+ }
+ }
+
// Load first background (Uses loadBg)
if (strlen(bgNames[0])) {
loadBg(bgNames[0]);
diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp
index c0b0c1f5da..6ad38f4433 100644
--- a/engines/cine/script_fw.cpp
+++ b/engines/cine/script_fw.cpp
@@ -1380,6 +1380,12 @@ int FWScript::o1_loadBg() {
debugC(5, kCineDebugScript, "Line: %d: loadBg(\"%s\")", _line, param);
+ if (g_cine->getGameType() == GType_FW && (g_cine->getFeatures() & GF_CD)) {
+ char buffer[20];
+ removeExtention(buffer, param);
+ g_sound->setBgMusic(atoi(buffer + 1));
+ }
+
loadBg(param);
g_cine->_bgIncrustList.clear();
bgVar0 = 0;
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 0c788b816c..18aff7e71a 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -32,6 +32,8 @@
#include "cine/cine.h"
#include "cine/sound.h"
+#include "backends/audiocd/audiocd.h"
+
#include "audio/audiostream.h"
#include "audio/fmopl.h"
#include "audio/mididrv.h"
@@ -907,6 +909,10 @@ void PCSoundFxPlayer::unload() {
PCSound::PCSound(Audio::Mixer *mixer, CineEngine *vm)
: Sound(mixer, vm), _soundDriver(0) {
+ _currentMusic = 0;
+ _currentMusicStatus = 0;
+ _currentBgSlot = 0;
+
const MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB);
const MusicType musicType = MidiDriver::getMusicType(dev);
if (musicType == MT_MT32 || musicType == MT_GM) {
@@ -940,23 +946,98 @@ PCSound::~PCSound() {
delete _soundDriver;
}
+static const char *const musicFileNames[12] = {
+ "DUGGER.DAT",
+ "SUITE21.DAT",
+ "FWARS.DAT",
+ "SUITE23.DAT",
+ "SUITE22.DAT",
+ "ESCAL",
+ "MOINES.DAT",
+ "MEDIAVAL.DAT",
+ "SFUTUR",
+ "ALIENS",
+ "TELESONG.DAT",
+};
+
+static uint8 musicCDTracks[12] = {
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 22,
+};
+
void PCSound::loadMusic(const char *name) {
debugC(5, kCineDebugSound, "PCSound::loadMusic('%s')", name);
- _player->load(name);
+ if (_vm->getGameType() == GType_FW && (_vm->getFeatures() & GF_CD)) {
+ _currentMusic = 0;
+ _currentMusicStatus = 0;
+ for (int i = 0; i < 11; i++) {
+ if (!strcmp((const char *)name, musicFileNames[i])) {
+ _currentMusic = musicCDTracks[i];
+ _currentMusicStatus = musicCDTracks[i];
+ }
+ }
+ } else {
+ _player->load(name);
+ }
}
void PCSound::playMusic() {
debugC(5, kCineDebugSound, "PCSound::playMusic()");
- _player->play();
+ if (_vm->getGameType() == GType_FW && (_vm->getFeatures() & GF_CD)) {
+ g_system->getAudioCDManager()->stop();
+ g_system->getAudioCDManager()->play(_currentMusic - 1, -1, 0, 0);
+ } else {
+ _player->play();
+ }
+}
+
+static uint8 bgCDTracks[49] = {
+ 0, 21, 21, 23, 0, 29, 0, 0, 0, 0,
+ 0, 27, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 22, 22, 23, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+void PCSound::setBgMusic(int num) {
+ debugC(5, kCineDebugSound, "PCSound::setBgMusic(%d)", num);
+ _currentBgSlot = num;
+ if (!bgCDTracks[_currentBgSlot])
+ return;
+
+ if ((_currentBgSlot == 1) || (_currentMusicStatus == 0 && _currentMusic != bgCDTracks[_currentBgSlot])) {
+ _currentMusic = bgCDTracks[_currentBgSlot];
+ g_system->getAudioCDManager()->stop();
+ g_system->getAudioCDManager()->play(bgCDTracks[_currentBgSlot] - 1, -1, 0, 0);
+ }
}
void PCSound::stopMusic() {
debugC(5, kCineDebugSound, "PCSound::stopMusic()");
+
+ if (_vm->getGameType() == GType_FW && (_vm->getFeatures() & GF_CD)) {
+ if (_currentBgSlot != 1)
+ g_system->getAudioCDManager()->stop();
+ }
_player->stop();
}
void PCSound::fadeOutMusic() {
debugC(5, kCineDebugSound, "PCSound::fadeOutMusic()");
+
+ if (_vm->getGameType() == GType_FW && (_vm->getFeatures() & GF_CD)) {
+ if (_currentMusicStatus) {
+ if (_currentBgSlot == 1) {
+ _currentMusicStatus = 0;
+ } else {
+ _currentMusic = 0;
+ _currentMusicStatus = 0;
+ g_system->getAudioCDManager()->stop();
+ if (bgCDTracks[_currentBgSlot]) {
+ g_system->getAudioCDManager()->play(_currentBgSlot - 1, -1, 0, 0);
+ }
+ }
+ }
+ }
_player->fadeOut();
}
@@ -1056,6 +1137,9 @@ void PaulaSound::stopMusic() {
_mixer->stopHandle(_moduleHandle);
}
+void PaulaSound::setBgMusic(int num) {
+}
+
void PaulaSound::fadeOutMusic() {
debugC(5, kCineDebugSound, "PaulaSound::fadeOutMusic()");
Common::StackLock lock(_musicMutex);
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index efb3811f9a..0149071ed7 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -48,6 +48,7 @@ public:
virtual void playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat) = 0;
virtual void stopSound(int channel) = 0;
+ virtual void setBgMusic(int num) = 0;
protected:
@@ -71,11 +72,14 @@ public:
virtual void playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat);
virtual void stopSound(int channel);
+ virtual void setBgMusic(int num);
protected:
PCSoundDriver *_soundDriver;
PCSoundFxPlayer *_player;
+
+ uint8 _currentMusic, _currentMusicStatus, _currentBgSlot;
};
class PaulaSound : public Sound {
@@ -91,6 +95,7 @@ public:
virtual void playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat);
virtual void stopSound(int channel);
+ virtual void setBgMusic(int num);
enum {
PAULA_FREQ = 3579545,