[Scummvm-cvs-logs] SF.net SVN: scummvm: [25634] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Fri Feb 16 17:58:00 CET 2007


Revision: 25634
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25634&view=rev
Author:   lordhoto
Date:     2007-02-16 08:57:59 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
Added support for Kyrandia 2 ADL files.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.cpp
    scummvm/trunk/engines/kyra/kyra2.cpp
    scummvm/trunk/engines/kyra/sound.h
    scummvm/trunk/engines/kyra/sound_adlib.cpp

Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp	2007-02-16 16:34:02 UTC (rev 25633)
+++ scummvm/trunk/engines/kyra/kyra.cpp	2007-02-16 16:57:59 UTC (rev 25634)
@@ -152,7 +152,7 @@
 		// 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 {

Modified: scummvm/trunk/engines/kyra/kyra2.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra2.cpp	2007-02-16 16:34:02 UTC (rev 25633)
+++ scummvm/trunk/engines/kyra/kyra2.cpp	2007-02-16 16:57:59 UTC (rev 25634)
@@ -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 @@
 
 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::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");

Modified: scummvm/trunk/engines/kyra/sound.h
===================================================================
--- scummvm/trunk/engines/kyra/sound.h	2007-02-16 16:34:02 UTC (rev 25633)
+++ scummvm/trunk/engines/kyra/sound.h	2007-02-16 16:57:59 UTC (rev 25634)
@@ -148,7 +148,8 @@
 
 	AdlibDriver *_driver;
 
-	uint8 _trackEntries[120];
+	bool _v2;
+	uint8 _trackEntries[500];
 	uint8 *_soundDataPtr;
 	int _sfxPlayingSound;
 	uint _soundFileLoaded;

Modified: scummvm/trunk/engines/kyra/sound_adlib.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_adlib.cpp	2007-02-16 16:34:02 UTC (rev 25633)
+++ scummvm/trunk/engines/kyra/sound_adlib.cpp	2007-02-16 16:57:59 UTC (rev 25634)
@@ -60,7 +60,7 @@
 
 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 @@
 	}
 
 	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 @@
 	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 @@
 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::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 @@
 	_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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list