[Scummvm-cvs-logs] CVS: scummvm/sky control.cpp,1.15,1.16 control.h,1.9,1.10 intro.cpp,1.27,1.28 logic.cpp,1.111,1.112 sky.cpp,1.73,1.74 sound.cpp,1.19,1.20 sound.h,1.9,1.10
Robert G?ffringmann
lavosspawn at users.sourceforge.net
Fri Jul 4 13:15:06 CEST 2003
Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1:/tmp/cvs-serv25608/sky
Modified Files:
control.cpp control.h intro.cpp logic.cpp sky.cpp sound.cpp
sound.h
Log Message:
SFX is working correctly now. also implemented queued fx and fx saving.
The bass version is now included in the savegames, too.
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/control.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- control.cpp 3 Jul 2003 22:36:45 -0000 1.15
+++ control.cpp 4 Jul 2003 20:14:11 -0000 1.16
@@ -115,7 +115,7 @@
_system->copy_rect(_screen + _y * GAME_SCREEN_WIDTH + _x, GAME_SCREEN_WIDTH, _x, _y, cpWidth, PAN_CHAR_HEIGHT);
}
-SkyControl::SkyControl(SkyScreen *screen, SkyDisk *disk, SkyMouse *mouse, SkyText *text, SkyMusicBase *music, SkyLogic *logic, OSystem *system, const char *savePath) {
+SkyControl::SkyControl(SkyScreen *screen, SkyDisk *disk, SkyMouse *mouse, SkyText *text, SkyMusicBase *music, SkyLogic *logic, SkySound *sound, OSystem *system, const char *savePath) {
_skyScreen = screen;
_skyDisk = disk;
@@ -123,6 +123,7 @@
_skyText = text;
_skyMusic = music;
_skyLogic = logic;
+ _skySound = sound;
_system = system;
_savePath = savePath;
_memListRoot = NULL;
@@ -993,9 +994,11 @@
uint8 *destPos = destBuf + 4;
STOSD(destPos, SAVE_FILE_REVISION);
- STOSD(destPos, _skyMusic->giveCurrentMusic());
+ STOSD(destPos, SkyState::_systemVars.gameVersion);
+ STOSW(destPos, _skySound->_saveSounds[0]);
+ STOSW(destPos, _skySound->_saveSounds[1]);
- //TODO: save queued sfx
+ STOSD(destPos, _skyMusic->giveCurrentMusic());
STOSD(destPos, _skyText->giveCurrentCharSet());
STOSD(destPos, _savedMouse);
STOSD(destPos, SkyState::_systemVars.currentPalette);
@@ -1174,7 +1177,19 @@
freeMemList(); // memory from last restore isn't needed anymore
- uint32 music, charSet, mouseType, palette;
+ uint32 music, charSet, mouseType, palette, gameVersion;
+
+ if (saveRev >= 3) {
+ LODSD(srcPos, gameVersion);
+ if (gameVersion != SkyState::_systemVars.gameVersion) {
+ printf("This savegame was created by Beneath a Steel Sky V.0.0%03d\n",gameVersion);
+ printf("It cannot be loaded by this version (%0.0%3d)\n",SkyState::_systemVars.gameVersion);
+ return RESTORE_FAILED;
+ }
+ LODSW(srcPos, _skySound->_saveSounds[0]);
+ LODSW(srcPos, _skySound->_saveSounds[1]);
+ _skySound->restoreSfx();
+ }
LODSD(srcPos, music);
LODSD(srcPos, charSet);
LODSD(srcPos, mouseType);
@@ -1315,9 +1330,12 @@
uint8 *textBuf2 = (uint8*)malloc(GAME_SCREEN_WIDTH * 14 + sizeof(dataFileHeader));
uint8 textNum;
uint8 *screenData;
- if (useScreen)
+ if (useScreen) {
+ if (_skyScreen->sequenceRunning())
+ _skyScreen->stopSequence();
+
screenData = _skyScreen->giveCurrent();
- else
+ } else
screenData = _screenBuf;
switch (SkyState::_systemVars.language) {
case DE_DEU: textNum = 1; break;
Index: control.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/control.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- control.h 3 Jul 2003 22:32:18 -0000 1.9
+++ control.h 4 Jul 2003 20:14:11 -0000 1.10
@@ -106,7 +106,7 @@
#define SAVE_GRAFX 32
#define SAVE_TURNP 64
-#define SAVE_FILE_REVISION 2
+#define SAVE_FILE_REVISION 3
struct AllocedMem {
uint16 *mem;
@@ -145,7 +145,7 @@
class SkyControl {
public:
- SkyControl(SkyScreen *screen, SkyDisk *disk, SkyMouse *mouse, SkyText *text, SkyMusicBase *music, SkyLogic *logic, OSystem *system, const char *savePath);
+ SkyControl(SkyScreen *screen, SkyDisk *disk, SkyMouse *mouse, SkyText *text, SkyMusicBase *music, SkyLogic *logic, SkySound *sound, OSystem *system, const char *savePath);
void doControlPanel(void);
void doLoadSavePanel(void);
void restartGame(void);
@@ -205,6 +205,7 @@
SkyText *_skyText;
SkyMusicBase *_skyMusic;
SkyLogic *_skyLogic;
+ SkySound *_skySound;
OSystem *_system;
int _mouseX, _mouseY;
bool _mouseClicked;
Index: intro.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/intro.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- intro.cpp 2 Jul 2003 01:46:24 -0000 1.27
+++ intro.cpp 4 Jul 2003 20:14:11 -0000 1.28
@@ -492,7 +492,7 @@
void SkyState::introFx(uint32 *&cmdPtr) {
_mixer->stopAll();
- _skySound->playSound((uint16)cmdPtr[2], (uint16)cmdPtr[3]);
+ _skySound->playSound((uint16)cmdPtr[2], (uint16)cmdPtr[3], 0);
cmdPtr += 4;
}
@@ -501,6 +501,6 @@
// HACK: for some reason, the mixer will only stop playing
// looping sounds if you do it using SoundMixer::stopAll();
_mixer->stopAll();
- _skySound->playSound(1, (uint16)(cmdPtr[2] & 0x7F));
+ _skySound->playSound(1, (uint16)(cmdPtr[2] & 0x7F), 0);
cmdPtr += 3;
}
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- logic.cpp 3 Jul 2003 17:17:32 -0000 1.111
+++ logic.cpp 4 Jul 2003 20:14:11 -0000 1.112
@@ -2373,7 +2373,8 @@
}
bool SkyLogic::fnStartFx(uint32 sound, uint32 b, uint32 c) {
- return _skySound->fnStartFx(sound);
+ _skySound->fnStartFx(sound, (uint8)(b & 1));
+ return true;
}
bool SkyLogic::fnStopFx(uint32 a, uint32 b, uint32 c) {
Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- sky.cpp 4 Jul 2003 15:14:47 -0000 1.73
+++ sky.cpp 4 Jul 2003 20:14:11 -0000 1.74
@@ -149,6 +149,7 @@
/*if ((_key_pressed == 27) && (!_systemVars.pastIntro))
_skyControl->restartGame();*/
+ _skySound->checkFxQueue();
_skyMouse->mouseEngine((uint16)_sdl_mouse_x, (uint16)_sdl_mouse_y);
_skyLogic->engine();
if (!_skyLogic->checkProtection()) { // don't let copy prot. screen flash up
@@ -202,7 +203,7 @@
_timer = Engine::_timer; // initialize timer *after* _skyScreen has been initialized.
_timer->installProcedure(&timerHandler, 1000000 / 50); //call 50 times per second
- _skyControl = new SkyControl(_skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _system, getSavePath());
+ _skyControl = new SkyControl(_skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system, getSavePath());
_skyLogic->useControlInstance(_skyControl);
if (_systemVars.gameVersion == 288)
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- sound.cpp 3 Jul 2003 22:52:17 -0000 1.19
+++ sound.cpp 4 Jul 2003 20:14:11 -0000 1.20
@@ -1005,6 +1005,13 @@
&fx_25_weld // 394 my anchor weld bodge
};
+SfxQueue SkySound::_sfxQueue[MAX_QUEUED_FX] = {
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0}
+};
+
SkySound::SkySound(SoundMixer *mixer, SkyDisk *pDisk) {
_skyDisk = pDisk;
_soundData = NULL;
@@ -1012,9 +1019,10 @@
_voiceHandle = 0;
_effectHandle = 0;
_bgSoundHandle = 0;
- _ingameSound = 0;
_ingameSpeech = 0;
- _sfxPaused = false;
+ _ingameSound0 = _ingameSound1 = 0;
+ _slot0 = _slot1 = -1;
+ _saveSounds[0] = _saveSounds[1] = 0xFFFF;
}
SkySound::~SkySound(void) {
@@ -1048,8 +1056,8 @@
void SkySound::loadSection(uint8 pSection) {
- if (_ingameSound) _mixer->stop(_ingameSound - 1);
- _ingameSound = 0;
+ fnStopFx();
+
if (_soundData) free(_soundData);
_soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE, NULL);
if ((_soundData[0x7E] != 0x3C) || (_soundData[0xA5] != 0x8D) || (_soundData[0xA6] != 0x1E) ||
@@ -1060,9 +1068,23 @@
_sfxBaseOfs = (_soundData[0xB0] << 8) | _soundData[0xAF];
_sampleRates = _soundData + sRateTabOfs;
_sfxInfo = _soundData + _sfxBaseOfs;
+ for (uint8 cnt = 0; cnt < 4; cnt++)
+ _sfxQueue[cnt].count = 0;
}
-void SkySound::playSound(uint16 sound, uint16 volume) {
+void SkySound::playSound(uint16 sound, uint16 volume, uint8 channel) {
+
+ if (channel == 0) {
+ if (_slot0 >= 0) {
+ _mixer->stop(_slot0);
+ _slot0 = -1;
+ }
+ } else {
+ if (_slot1 >= 0) {
+ _mixer->stop(_slot1);
+ _slot1 = -1;
+ }
+ }
if (!_soundData) {
warning("SkySound::playSound(%04X, %04X) called with a section having been loaded.\n", sound, volume);
@@ -1070,8 +1092,7 @@
}
if (sound > _soundsTotal) {
- if (sound & 0x80) warning("SkySound::playSound(%04X, %04X) not implemented.\n", sound, volume);
- else warning("SkySound::playSound(%04X, %04X) ignored.\n", sound, volume);
+ debug(5, "SkySound::playSound %d ignored, only %d sfx in file.\n", sound, _soundsTotal);
return ;
}
@@ -1080,30 +1101,28 @@
// 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;
+ uint32 dataOfs = ((_sfxInfo[sound << 3] << 8) | _sfxInfo[(sound << 3) | 1]) << 4;
dataOfs += _sfxBaseOfs;
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 (dataSize == dataLoop)
+ flags |= SoundMixer::FLAG_LOOP;
- if (_ingameSound > 0) _mixer->stop(_ingameSound - 1);
_mixer->setVolume(volume);
- _mixer->playRaw(&_ingameSound, _soundData + dataOfs, dataSize, sampleRate, flags);
+ if (channel == 0)
+ _slot0 = _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags);
+ else
+ _slot1 = _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags);
}
-void SkySound::fnPauseFx(void) {
-
- if (_ingameSound) _mixer->stop(_ingameSound - 1);
- _sfxPaused = true;
-}
+void SkySound::fnStartFx(uint32 sound, uint8 channel) {
-bool SkySound::fnStartFx(uint32 sound) {
- if (sound < 256 || sound > MAX_FX_NUMBER || _sfxPaused || (SkyState::_systemVars.systemFlags & SF_FX_OFF))
- return true;
+ _saveSounds[channel] = 0xFFFF;
+ if (sound < 256 || sound > MAX_FX_NUMBER || (SkyState::_systemVars.systemFlags & SF_FX_OFF))
+ return;
uint8 screen = (uint8)(SkyLogic::_scriptVariables[SCREEN] & 0xff);
if (sound == 278 && screen == 25) // is this weld in room 25
@@ -1119,7 +1138,7 @@
while (roomList[i].room != screen) { // check rooms
i++;
if (roomList[i].room == 0xff)
- return true;
+ return;
}
// get fx volume
@@ -1137,14 +1156,59 @@
// Check the flags, the sound may come on after a delay.
if (sfx->flags & SFXF_START_DELAY) {
- // queue sound
+ for (uint8 cnt = 0; cnt < MAX_QUEUED_FX; cnt++) {
+ if (_sfxQueue[cnt].count == 0) {
+ _sfxQueue[cnt].chan = channel;
+ _sfxQueue[cnt].fxNo = sfx->soundNo;
+ _sfxQueue[cnt].vol = volume;
+ _sfxQueue[cnt].count = sfx->flags & 0x7F;
+ return;
+ }
+ }
+ return; // ignore sound if it can't be queued
}
- //if (sfx->flags & SFXF_SAVE)
- // save_fx_0[stfx_cur_chn] = sound;
+ if (sfx->flags & SFXF_SAVE)
+ _saveSounds[channel] = sfx->soundNo | (volume << 8);
- playSound(sfx->soundNo, volume);
- return true;
+ playSound(sfx->soundNo, volume, channel);
+}
+
+void SkySound::checkFxQueue(void) {
+ for (uint8 cnt = 0; cnt < MAX_QUEUED_FX; cnt++) {
+ if (_sfxQueue[cnt].count) {
+ _sfxQueue[cnt].count--;
+ if (_sfxQueue[cnt].count == 0)
+ playSound(_sfxQueue[cnt].fxNo, _sfxQueue[cnt].vol, _sfxQueue[cnt].chan);
+ }
+ }
+}
+
+void SkySound::restoreSfx(void) {
+
+ // queue sfx, so they will be started when the player exits the control panel
+ memset(_sfxQueue, 0, sizeof(_sfxQueue));
+ uint8 queueSlot = 0;
+ if (_saveSounds[0] != 0xFFFF) {
+ _sfxQueue[queueSlot].fxNo = (uint8)_saveSounds[0];
+ _sfxQueue[queueSlot].vol = (uint8)(_saveSounds[0] >> 8);
+ _sfxQueue[queueSlot].chan = 0;
+ _sfxQueue[queueSlot].count = 1;
+ queueSlot++;
+ }
+ if (_saveSounds[1] != 0xFFFF) {
+ _sfxQueue[queueSlot].fxNo = (uint8)_saveSounds[1];
+ _sfxQueue[queueSlot].vol = (uint8)(_saveSounds[1] >> 8);
+ _sfxQueue[queueSlot].chan = 1;
+ _sfxQueue[queueSlot].count = 1;
+ }
+}
+
+void SkySound::fnStopFx(void) {
+ if (_slot0 >= 0) _mixer->stop(_slot0);
+ if (_slot1 >= 0) _mixer->stop(_slot1);
+ _slot0 = _slot1 = -1;
+ _saveSounds[0] = _saveSounds[1] = 0xFFFF;
}
bool SkySound::startSpeech(uint16 textNum) {
@@ -1168,6 +1232,6 @@
// TODO: implement pre_after_table_area to find and prefetch file for next speech
- _mixer->playRaw(&_ingameSpeech, playBuffer, speechSize - 64, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
+ int slt = _mixer->playRaw(&_ingameSpeech, playBuffer, speechSize - 64, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
return true;
}
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sound.h 9 Jun 2003 23:37:51 -0000 1.9
+++ sound.h 4 Jul 2003 20:14:11 -0000 1.10
@@ -26,6 +26,12 @@
#include "sky/disk.h"
#include "common/engine.h"
+struct SfxQueue {
+ uint8 count, fxNo, chan, vol;
+};
+
+#define MAX_QUEUED_FX 4
+
class SkySound {
protected:
@@ -35,7 +41,9 @@
PlayingSoundHandle _voiceHandle;
PlayingSoundHandle _effectHandle;
PlayingSoundHandle _bgSoundHandle;
- PlayingSoundHandle _ingameSound, _ingameSpeech;
+ PlayingSoundHandle _ingameSound0, _ingameSound1, _ingameSpeech;
+
+ uint16 _saveSounds[2];
protected:
@@ -48,23 +56,26 @@
int playBgSound(byte *sound, uint32 size);
void loadSection(uint8 pSection);
- void playSound(uint16 sound, uint16 volume);
- bool fnStartFx(uint32 sound);
+ void playSound(uint16 sound, uint16 volume, uint8 channel);
+ void fnStartFx(uint32 sound, uint8 channel);
bool startSpeech(uint16 textNum);
bool speechFinished(void) { return _ingameSpeech == 0; };
- void fnPauseFx(void);
- void fnUnPauseFx(void) { _sfxPaused = false; };
- void fnStopFx(void) { if (_ingameSound) _mixer->stop(_ingameSound - 1); };
+ void fnPauseFx(void) { _mixer->pause(true); };
+ void fnUnPauseFx(void) { _mixer->pause(false); };
+ void fnStopFx(void);
+ void checkFxQueue(void);
+ void restoreSfx(void);
+ uint8 _soundsTotal;
private:
SkyDisk *_skyDisk;
- uint8 _soundsTotal;
uint16 _sfxBaseOfs;
uint8 *_soundData;
uint8 *_sampleRates, *_sfxInfo;
- bool _sfxPaused;
+ int _slot0, _slot1;
static uint16 _speechConvertTable[8];
+ static SfxQueue _sfxQueue[MAX_QUEUED_FX];
};
#endif
More information about the Scummvm-git-logs
mailing list