aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2007-02-16 16:57:59 +0000
committerJohannes Schickel2007-02-16 16:57:59 +0000
commit940e89d00e26bec98b6a61f0913c0491ec931472 (patch)
tree368893ae0841a59bb25390f2f185ff854335e0f4 /engines/kyra
parentd849f4762ce09dc6d83b6ef31179c2a587d2ded7 (diff)
downloadscummvm-rg350-940e89d00e26bec98b6a61f0913c0491ec931472.tar.gz
scummvm-rg350-940e89d00e26bec98b6a61f0913c0491ec931472.tar.bz2
scummvm-rg350-940e89d00e26bec98b6a61f0913c0491ec931472.zip
Added support for Kyrandia 2 ADL files.
svn-id: r25634
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/kyra.cpp2
-rw-r--r--engines/kyra/kyra2.cpp11
-rw-r--r--engines/kyra/sound.h3
-rw-r--r--engines/kyra/sound_adlib.cpp39
4 files changed, 41 insertions, 14 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index ab6dad32cb..a4c3b4d262 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -152,7 +152,7 @@ int KyraEngine::init() {
// no sfx enabled for CD audio music atm
// later on here should be a usage of MixedSoundDriver
_sound = new SoundTowns(this, _mixer);
- } else if (midiDriver == MD_ADLIB && _flags.gameID == GI_KYRA1) {
+ } else if (midiDriver == MD_ADLIB) {
_sound = new SoundAdlibPC(this, _mixer);
assert(_sound);
} else {
diff --git a/engines/kyra/kyra2.cpp b/engines/kyra/kyra2.cpp
index d0c1a5c38e..f0009c0011 100644
--- a/engines/kyra/kyra2.cpp
+++ b/engines/kyra/kyra2.cpp
@@ -32,7 +32,6 @@
namespace Kyra {
KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngine(system, flags) {
-
memset(_gameShapes, 0, sizeof(_gameShapes));
_mouseSHPBuf = 0;
}
@@ -43,6 +42,7 @@ KyraEngine_v2::~KyraEngine_v2() {
int KyraEngine_v2::init() {
KyraEngine::init();
+
_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
_screen->loadFont(Screen::FID_GOLDFONT_FNT, "GOLDFONT.FNT");
@@ -67,7 +67,14 @@ int KyraEngine_v2::init() {
}
int KyraEngine_v2::go() {
- //_sound->loadMusicFile("K2INTRO");
+ // TODO: move this to proper place
+ static const char *soundfileList[] = {
+ "K2INTRO"
+ };
+
+ _sound->setSoundFileList(soundfileList, 1);
+ _sound->loadSoundFile(0);
+
// Temporary measure to work around the fact that there's
// several WSA files with identical names in different PAK files.
_res->unloadPakFile("OUTFARM.PAK");
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 2c09716c2f..741d3a8d9a 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -148,7 +148,8 @@ private:
AdlibDriver *_driver;
- uint8 _trackEntries[120];
+ bool _v2;
+ uint8 _trackEntries[500];
uint8 *_soundDataPtr;
int _sfxPlayingSound;
uint _soundFileLoaded;
diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp
index c308d1ba54..dc092a5a2e 100644
--- a/engines/kyra/sound_adlib.cpp
+++ b/engines/kyra/sound_adlib.cpp
@@ -60,7 +60,7 @@ namespace Kyra {
class AdlibDriver : public Audio::AudioStream {
public:
- AdlibDriver(Audio::Mixer *mixer);
+ AdlibDriver(Audio::Mixer *mixer, bool v2);
~AdlibDriver();
int callback(int opcode, ...);
@@ -241,7 +241,7 @@ private:
}
uint8 *getInstrument(int instrumentId) {
- return _soundData + READ_LE_UINT16(_soundData + 500 + 2 * instrumentId);
+ return _soundData + READ_LE_UINT16(_soundData + (_v2 ? 1000 : 500) + 2 * instrumentId);
}
void setupPrograms();
@@ -407,14 +407,18 @@ private:
Common::Mutex _mutex;
Audio::Mixer *_mixer;
+ bool _v2;
+
void lock() { _mutex.lock(); }
void unlock() { _mutex.unlock(); }
};
-AdlibDriver::AdlibDriver(Audio::Mixer *mixer) {
+AdlibDriver::AdlibDriver(Audio::Mixer *mixer, bool v2) {
setupOpcodeList();
setupParserOpcodeTable();
+ _v2 = v2;
+
_mixer = mixer;
_flags = 0;
@@ -2209,7 +2213,8 @@ const int SoundAdlibPC::_kyra1NumSoundTriggers = ARRAYSIZE(SoundAdlibPC::_kyra1S
SoundAdlibPC::SoundAdlibPC(KyraEngine *engine, Audio::Mixer *mixer)
: Sound(engine, mixer), _driver(0), _trackEntries(), _soundDataPtr(0) {
memset(_trackEntries, 0, sizeof(_trackEntries));
- _driver = new AdlibDriver(mixer);
+ _v2 = (_engine->gameFlags().gameID == GI_KYRA2);
+ _driver = new AdlibDriver(mixer, _v2);
assert(_driver);
_sfxPlayingSound = -1;
@@ -2279,14 +2284,21 @@ void SoundAdlibPC::playSoundEffect(uint8 track) {
}
void SoundAdlibPC::play(uint8 track) {
- uint8 soundId = _trackEntries[track];
- if ((int8)soundId == -1 || !_soundDataPtr)
+ uint16 soundId = 0;
+
+ if (_v2)
+ soundId = READ_LE_UINT16(&_trackEntries[track<<1]);
+ else
+ soundId = _trackEntries[track];
+
+ if ((soundId == 0xFFFF && _v2) || (soundId == 0xFF && !_v2) || !_soundDataPtr)
return;
- soundId &= 0xFF;
+
while ((_driver->callback(16, 0) & 8)) {
// We call the system delay and not the game delay to avoid concurrency issues.
_engine->_system->delayMillis(10);
}
+
if (_sfxPlayingSound != -1) {
// Restore the sounds's normal values.
_driver->callback(10, _sfxPlayingSound, int(1), int(_sfxPriority));
@@ -2350,11 +2362,18 @@ void SoundAdlibPC::loadSoundFile(uint file) {
_driver->callback(8, int(-1));
_soundDataPtr = 0;
+ int soundDataSize = file_size;
uint8 *p = file_data;
- memcpy(_trackEntries, p, 120*sizeof(uint8));
- p += 120;
- int soundDataSize = file_size - 120;
+ if (_v2) {
+ memcpy(_trackEntries, p, 500);
+ p += 500;
+ soundDataSize -= 500;
+ } else {
+ memcpy(_trackEntries, p, 120);
+ p += 120;
+ soundDataSize -= 120;
+ }
_soundDataPtr = new uint8[soundDataSize];
assert(_soundDataPtr);