diff options
author | Robert Göffringmann | 2003-06-01 03:44:07 +0000 |
---|---|---|
committer | Robert Göffringmann | 2003-06-01 03:44:07 +0000 |
commit | d67c53d756a1706a9796acf258ab2d29ddf54939 (patch) | |
tree | 0b17cba30a0f9ab5e0bce473044b56b85ae77fc2 /sky | |
parent | 738497ef1413e8148d445389ab65144997652934 (diff) | |
download | scummvm-rg350-d67c53d756a1706a9796acf258ab2d29ddf54939.tar.gz scummvm-rg350-d67c53d756a1706a9796acf258ab2d29ddf54939.tar.bz2 scummvm-rg350-d67c53d756a1706a9796acf258ab2d29ddf54939.zip |
basic ingame speech support
svn-id: r8220
Diffstat (limited to 'sky')
-rw-r--r-- | sky/disk.cpp | 22 | ||||
-rw-r--r-- | sky/disk.h | 2 | ||||
-rw-r--r-- | sky/intro.cpp | 4 | ||||
-rw-r--r-- | sky/logic.cpp | 3 | ||||
-rw-r--r-- | sky/sky.cpp | 4 | ||||
-rw-r--r-- | sky/sound.cpp | 35 | ||||
-rw-r--r-- | sky/sound.h | 5 |
7 files changed, 65 insertions, 10 deletions
diff --git a/sky/disk.cpp b/sky/disk.cpp index a74160b0a5..76140c5d35 100644 --- a/sky/disk.cpp +++ b/sky/disk.cpp @@ -64,11 +64,11 @@ SkyDisk::SkyDisk(char *gameDataPath) { SkyDisk::~SkyDisk(void) { - PrefFile **fEntry = &_prefRoot; - while (*fEntry) { - free((*fEntry)->data); - PrefFile *fTemp = *fEntry; - fEntry = &((*fEntry)->next); + PrefFile *fEntry = _prefRoot; + while (fEntry) { + free(fEntry->data); + PrefFile *fTemp = fEntry; + fEntry = fEntry->next; delete fTemp; } if (_dnrHandle->isOpen()) _dnrHandle->close(); @@ -77,6 +77,18 @@ SkyDisk::~SkyDisk(void) { delete _dataDiskHandle; } +void SkyDisk::flushPrefetched(void) { + + PrefFile *fEntry = _prefRoot; + while (fEntry) { + free(fEntry->data); + PrefFile *fTemp = fEntry; + fEntry = fEntry->next; + delete fTemp; + } + _prefRoot = NULL; +} + //load in file file_nr to address dest //if dest == NULL, then allocate memory for this file uint8 *SkyDisk::loadFile(uint16 fileNr, uint8 *dest) { diff --git a/sky/disk.h b/sky/disk.h index dcde7697ff..d38e816020 100644 --- a/sky/disk.h +++ b/sky/disk.h @@ -40,6 +40,7 @@ public: uint8 *loadFile(uint16 fileNr, uint8 *dest); void prefetchFile(uint16 fileNr); + void flushPrefetched(void); uint32 determineGameVersion(); @@ -52,7 +53,6 @@ public: protected: - PrefFile *_prefRoot; uint8 *givePrefetched(uint16 fileNr, uint32 *fSize); diff --git a/sky/intro.cpp b/sky/intro.cpp index d136ddf299..344ca58ee1 100644 --- a/sky/intro.cpp +++ b/sky/intro.cpp @@ -477,12 +477,16 @@ void SkyState::removeText(uint32 *&cmdPtr) { void SkyState::introFx(uint32 *&cmdPtr) { + _mixer->stopAll(); _skySound->playSound((uint16)cmdPtr[2], (uint16)cmdPtr[3]); cmdPtr += 4; } void SkyState::introVol(uint32 *&cmdPtr) { + // 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)); cmdPtr += 3; } diff --git a/sky/logic.cpp b/sky/logic.cpp index b5ad755f2e..4464bf0615 100644 --- a/sky/logic.cpp +++ b/sky/logic.cpp @@ -2073,7 +2073,8 @@ void SkyLogic::stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32 target->grafixProg = animPtr; if (SkyState::isCDVersion(_gameVersion)) - warning("stdSpeak: speech not implemented yet"); + _skySound->fnStartSpeech((uint16)textNum); +// warning("stdSpeak: speech not implemented yet"); //now form the text sprite struct lowTextManager_t textInfo; diff --git a/sky/sky.cpp b/sky/sky.cpp index 341727b9be..746dfbd0df 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -140,10 +140,12 @@ void SkyState::go() { if (!isDemo(_gameVersion) || isCDVersion(_gameVersion)) intro(); + _skyDisk->flushPrefetched(); + loadBase0(); while (1) { - delay(100); + delay(50); _skyLogic->engine(); _skyScreen->recreate(); _skyScreen->spriteEngine(); diff --git a/sky/sound.cpp b/sky/sound.cpp index ef58ee0a2c..45e30670cd 100644 --- a/sky/sound.cpp +++ b/sky/sound.cpp @@ -49,6 +49,17 @@ struct Sfx { #pragma END_PACK_STRUCTS #endif +uint16 SkySound::_speechConvertTable[8] = { + 0, //;Text numbers to file numbers + 600, //; 553 lines in section 0 + 600+500, //; 488 lines in section 1 + 600+500+1330, //;1303 lines in section 2 + 600+500+1330+950, //; 922 lines in section 3 + 600+500+1330+950+1150, //;1140 lines in section 4 + 600+500+1330+950+1150+550, //; 531 lines in section 5 + 600+500+1330+950+1150+550+150, //; 150 lines in section 6 +}; + static Sfx fx_null = { 0, @@ -1076,7 +1087,8 @@ void SkySound::playSound(uint16 sound, uint16 volume) { if (dataSize == dataLoop) flags |= SoundMixer::FLAG_LOOP; - _mixer->stopAll(); + //_mixer->stopAll(); + if (_ingameSound > 0) _mixer->stop(_ingameSound - 1); _mixer->setVolume(volume); _mixer->playRaw(&_ingameSound, _soundData + dataOfs, dataSize, sampleRate, flags); } @@ -1123,3 +1135,24 @@ bool SkySound::fnStartFx(uint32 sound) { return true; } +void SkySound::fnStartSpeech(uint16 textNum) { + + uint16 speechFileNum = _speechConvertTable[textNum >> 12] + (textNum & 0xFFF); + + uint8 *speechData = _skyDisk->loadFile(speechFileNum + 50000, NULL); + if (!speechData) { + error("File %d (speechFile %d from section %d) wasn't found!\n", speechFileNum + 50000, textNum & 0xFFF, textNum >> 12); + } + + uint32 speechSize = ((dataFileHeader*)speechData)->s_tot_size; + uint8 *playBuffer = (uint8*)malloc(speechSize); + memcpy(playBuffer, speechData + sizeof(dataFileHeader), speechSize); + + free(speechData); + _skyDisk->flushPrefetched(); + + // 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); + +}
\ No newline at end of file diff --git a/sky/sound.h b/sky/sound.h index c141568e8d..348cfc4c99 100644 --- a/sky/sound.h +++ b/sky/sound.h @@ -35,7 +35,7 @@ public: PlayingSoundHandle _voiceHandle; PlayingSoundHandle _effectHandle; PlayingSoundHandle _bgSoundHandle; - PlayingSoundHandle _ingameSound; + PlayingSoundHandle _ingameSound, _ingameSpeech; protected: @@ -50,6 +50,7 @@ public: void loadSection(uint8 pSection); void playSound(uint16 sound, uint16 volume); bool fnStartFx(uint32 sound); + void fnStartSpeech(uint16 textNum); private: SkyDisk *_skyDisk; @@ -57,6 +58,8 @@ private: uint16 _sfxBaseOfs; uint8 *_soundData; uint8 *_sampleRates, *_sfxInfo; + + static uint16 _speechConvertTable[8]; }; #endif |