[Scummvm-cvs-logs] CVS: scummvm/sky intro.cpp,1.19,1.20 logic.cpp,1.23,1.24 logic.h,1.11,1.12 musicbase.cpp,1.2,1.3 musicbase.h,1.3,1.4 sky.cpp,1.34,1.35 sound.cpp,1.3,1.4 sound.h,1.2,1.3
Robert G?ffringmann
lavosspawn at users.sourceforge.net
Fri May 16 08:34:06 CEST 2003
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv20125/sky
Modified Files:
intro.cpp logic.cpp logic.h musicbase.cpp musicbase.h sky.cpp
sound.cpp sound.h
Log Message:
added SFX support
Index: intro.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/intro.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- intro.cpp 15 May 2003 19:14:39 -0000 1.19
+++ intro.cpp 16 May 2003 15:33:17 -0000 1.20
@@ -197,7 +197,8 @@
_skyDisk->prefetchFile(60112); // revolution screen
_skyDisk->prefetchFile(60113); // revolution palette
- _skyMusic->loadSectionMusic(0);
+ _skyMusic->loadSection(0);
+ _skySound->loadSection(0);
delay(3000); //keep virgin screen up for 3 seconds
CHECK_ESC
@@ -475,12 +476,12 @@
void SkyState::introFx(uint32 *&cmdPtr) {
- warning("introFx() not implemented yet");
+ _skySound->playSound((uint16)cmdPtr[2], (uint16)cmdPtr[3]);
cmdPtr += 4;
}
void SkyState::introVol(uint32 *&cmdPtr) {
- warning("introVol() not implemented yet");
+ _mixer->setVolume(((cmdPtr[2] & 0x7F) + 1) << 1);
cmdPtr += 3;
}
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- logic.cpp 6 May 2003 06:27:30 -0000 1.23
+++ logic.cpp 16 May 2003 15:33:17 -0000 1.24
@@ -48,11 +48,12 @@
&SkyLogic::simpleAnim, // 16 Module anim without x,y's
};
-SkyLogic::SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, uint32 gameVersion) {
+SkyLogic::SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound, uint32 gameVersion) {
_skyDisk = skyDisk;
_skyGrid = skyGrid;
_skyText = skyText;
_skyMusic = skyMusic;
+ _skySound = skySound;
_skyMouse = skyMouse;
_gameVersion = gameVersion;
_skyAutoRoute = new SkyAutoRoute(_skyGrid);
@@ -1552,7 +1553,8 @@
_saveCurrentSection = sectionNo;
sectionNo++;
- _skyMusic->loadSectionMusic((byte)sectionNo);
+ _skyMusic->loadSection((byte)sectionNo);
+ _skySound->loadSection((byte)sectionNo);
_skyGrid->loadGrids();
}
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- logic.h 5 May 2003 13:19:59 -0000 1.11
+++ logic.h 16 May 2003 15:33:18 -0000 1.12
@@ -31,7 +31,7 @@
class SkyLogic {
public:
- SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, uint32 gameVersion);
+ SkyLogic(SkyDisk *skyDisk, SkyGrid *skyGrid, SkyText *skyText, SkyMusicBase *skyMusic, SkyMouse *skyMouse, SkySound *skySound, uint32 gameVersion);
void engine();
void lreturn();
@@ -196,6 +196,7 @@
SkyGrid *_skyGrid;
SkyText *_skyText;
SkyMusicBase *_skyMusic;
+ SkySound *_skySound;
SkyAutoRoute *_skyAutoRoute;
SkyMouse *_skyMouse;
};
Index: musicbase.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/musicbase.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- musicbase.cpp 12 May 2003 23:25:54 -0000 1.2
+++ musicbase.cpp 16 May 2003 15:33:18 -0000 1.3
@@ -34,7 +34,7 @@
if (_musicData) free(_musicData);
}
-void SkyMusicBase::loadSectionMusic(uint8 pSection)
+void SkyMusicBase::loadSection(uint8 pSection)
{
if (_currentMusic) stopMusic();
if (_musicData) free(_musicData);
Index: musicbase.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/musicbase.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- musicbase.h 12 May 2003 23:25:54 -0000 1.3
+++ musicbase.h 16 May 2003 15:33:18 -0000 1.4
@@ -45,7 +45,7 @@
public:
SkyMusicBase(SkyDisk *pSkyDisk);
virtual ~SkyMusicBase(void);
- void loadSectionMusic(uint8 pSection);
+ void loadSection(uint8 pSection);
void musicCommand(uint16 command);
void startMusic(uint16 param) { _onNextPoll.musicToProcess = param & 0xF; }; // 4
Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sky.cpp 15 May 2003 18:56:15 -0000 1.34
+++ sky.cpp 16 May 2003 15:33:18 -0000 1.35
@@ -106,8 +106,8 @@
//initialise_memory();
- _skySound = new SkySound(_mixer);
_skyDisk = new SkyDisk(_gameDataPath);
+ _skySound = new SkySound(_mixer, _skyDisk);
if (_detector->getMidiDriverType() == MD_ADLIB) {
_skyMusic = new SkyAdlibMusic(_mixer, _skyDisk);
@@ -127,7 +127,7 @@
//initialiseRouter();
loadFixedItems();
_skyGrid = new SkyGrid(_skyDisk);
- _skyLogic = new SkyLogic(_skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _gameVersion);
+ _skyLogic = new SkyLogic(_skyDisk, _skyGrid, _skyText, _skyMusic, _skyMouse, _skySound, _gameVersion);
_timer = Engine::_timer; // initialize timer *after* _skyScreen has been initialized.
_timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sound.cpp 12 Mar 2003 16:54:30 -0000 1.3
+++ sound.cpp 16 May 2003 15:33:18 -0000 1.4
@@ -23,11 +23,23 @@
#include "sky/sound.h"
#include "sky/struc.h"
-SkySound::SkySound(SoundMixer *mixer) {
+#define SOUND_FILE_BASE 60203
+#define SFX_BASE 0xA60
+
+SkySound::SkySound(SoundMixer *mixer, SkyDisk *pDisk) {
+ _skyDisk = pDisk;
+ _soundData = NULL;
_mixer = mixer;
_voiceHandle = 0;
_effectHandle = 0;
_bgSoundHandle = 0;
+ _ingameSound = 0;
+}
+
+SkySound::~SkySound(void) {
+
+ if (_ingameSound) _mixer->stop(_ingameSound - 1);
+ if (_soundData) free(_soundData);
}
int SkySound::playVoice(byte *sound, uint32 size) {
@@ -52,3 +64,45 @@
return _mixer->playRaw(handle, buffer, size, 11025, flags);
}
+
+void SkySound::loadSection(uint8 pSection) {
+
+ if (_ingameSound) _mixer->stop(_ingameSound - 1);
+ _ingameSound = 0;
+ if (_soundData) free(_soundData);
+ _soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE, NULL);
+ _sampleRates = _soundData + 0xA4E;
+ _sfxInfo = _soundData + 0xA60;
+}
+
+void SkySound::playSound(uint16 sound, uint16 volume) {
+
+ if (!_soundData) {
+ warning("SkySound::playSound(%04X, %04X) called with a section having been loaded.\n", sound, volume);
+ return;
+ }
+
+ if (sound > 2) {
+ if (sound & 0x80) warning("SkySound::playSound(%04X, %04X) not implemented.\n", sound, volume);
+ else warning("SkySound::playSound(%04X, %04X) ignored.\n", sound, volume);
+ return ;
+ }
+
+ volume = ((volume & 0x7F) + 1) << 1;
+ sound &= 0xFF;
+
+ // note: all those tables are big endian. Don't ask me why. *sigh*
+ uint16 sampleRate = (_sampleRates[sound << 2] << 8) | _sampleRates[(sound << 2) | 1];
+ uint16 dataOfs = ((_sfxInfo[sound << 3] << 8) | _sfxInfo[(sound << 3) | 1]) << 4;
+ dataOfs += SFX_BASE;
+ uint16 dataSize = (_sfxInfo[(sound << 3) | 2] << 8) | _sfxInfo[(sound << 3) | 3];
+ uint16 dataLoop = (_sfxInfo[(sound << 3) | 6] << 8) | _sfxInfo[(sound << 3) | 7];
+
+ byte flags = SoundMixer::FLAG_UNSIGNED;
+ if (dataSize == dataLoop)
+ flags |= SoundMixer::FLAG_LOOP;
+
+ if (_ingameSound) _mixer->stop(_ingameSound - 1);
+ _mixer->setVolume(volume);
+ _mixer->playRaw(&_ingameSound, _soundData + dataOfs, dataSize, sampleRate, flags);
+}
\ No newline at end of file
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sound.h 11 Mar 2003 18:32:57 -0000 1.2
+++ sound.h 16 May 2003 15:33:18 -0000 1.3
@@ -19,8 +19,9 @@
*
*/
-
#include "sound/mixer.h"
+#include "sky/disk.h"
+#include "common/engine.h"
class SkySound {
protected:
@@ -31,15 +32,24 @@
PlayingSoundHandle _voiceHandle;
PlayingSoundHandle _effectHandle;
PlayingSoundHandle _bgSoundHandle;
+ PlayingSoundHandle _ingameSound;
protected:
int playSound(byte *sound, uint32 size, PlayingSoundHandle *handle);
public:
- SkySound(SoundMixer *mixer);
+ SkySound(SoundMixer *mixer, SkyDisk *pDisk);
+ ~SkySound(void);
int playVoice(byte *sound, uint32 size);
int playBgSound(byte *sound, uint32 size);
+ void loadSection(uint8 pSection);
+ void playSound(uint16 sound, uint16 volume);
+
+private:
+ SkyDisk *_skyDisk;
+ uint8 *_soundData;
+ uint8 *_sampleRates, *_sfxInfo;
};
More information about the Scummvm-git-logs
mailing list