diff options
author | Strangerke | 2013-08-04 10:39:34 +0200 |
---|---|---|
committer | Strangerke | 2013-08-04 10:39:34 +0200 |
commit | 134532090bac167979b3114b8caccb25f3a8dc86 (patch) | |
tree | 07ccaaeb443a5224819c37d265fcad5945892d5e /engines | |
parent | 870a583c8b93eb560dca37add3cf9d98f21d594a (diff) | |
download | scummvm-rg350-134532090bac167979b3114b8caccb25f3a8dc86.tar.gz scummvm-rg350-134532090bac167979b3114b8caccb25f3a8dc86.tar.bz2 scummvm-rg350-134532090bac167979b3114b8caccb25f3a8dc86.zip |
MORTEVIELLE: Implement music in intro screen
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 5 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.h | 19 | ||||
-rw-r--r-- | engines/mortevielle/sound.cpp | 54 | ||||
-rw-r--r-- | engines/mortevielle/sound.h | 5 | ||||
-rw-r--r-- | engines/mortevielle/speech.cpp | 2 | ||||
-rw-r--r-- | engines/mortevielle/utils.cpp | 14 |
6 files changed, 34 insertions, 65 deletions
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index c481b7371b..7126df933f 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -105,7 +105,6 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g _curAnim = nullptr; _rightFramePict = nullptr; _compMusicBuf1 = nullptr; - _compMusicBuf2 = nullptr; } MortevielleEngine::~MortevielleEngine() { @@ -113,7 +112,6 @@ MortevielleEngine::~MortevielleEngine() { free(_curAnim); free(_rightFramePict); free(_compMusicBuf1); - free(_compMusicBuf2); } /** @@ -388,10 +386,9 @@ void MortevielleEngine::showIntroduction() { if (shouldQuit()) return; - // TODO: Once music (Amiga/Atari ports) is implemented, only use the below delay if music is turned off showTitleScreen(); - delay(3000); music(); + _mixer->stopAll(); } /** diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index eb5c8dfe52..8c7da8cc97 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -49,22 +49,6 @@ namespace Mortevielle { -/*---------------------------------------------------------------------------*/ -/*------------------- MEMORY MAP ------------------------*/ -/*---------------------------------------------------------------------------*/ -/* The following is a list of physical addresses in memory currently used - * by the game. - * - * Address - * ------- - * 5000:0 - Music data - * 6000:0 - Decompressed current image - * 7000:0+ - Compressed images - * 7000:2 - 16 words representing palette map - * 7000:4138 - width, height, x/y offset of decoded image - */ -const int kAdrMusic = 0x5000; - // Debug channels enum { kMortevielleCore = 1 << 0, @@ -197,7 +181,6 @@ private: Pattern _patternArr[15]; int _menuOpcode; - bool _mouseClick; bool _inMainGameLoop; // Flag when the main game loop is active bool _quitGame; // Quit game flag. Originally called 'arret' bool _endGame; // End game flag. Originally called 'solu' @@ -441,6 +424,7 @@ public: int _savedBitIndex; int _numpal; int _key; + bool _mouseClick; SaveStruct _coreVar, _saveStruct; int _maff; @@ -456,7 +440,6 @@ public: byte *_curAnim; byte *_rightFramePict; byte *_compMusicBuf1; - byte *_compMusicBuf2; Debugger _debugger; ScreenSurface _screenSurface; diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp index f9b53ffed7..76495c6658 100644 --- a/engines/mortevielle/sound.cpp +++ b/engines/mortevielle/sound.cpp @@ -28,6 +28,7 @@ #include "mortevielle/mortevielle.h" #include "mortevielle/sound.h" +#include "audio/decoders/raw.h" #include "common/scummsys.h" namespace Mortevielle { @@ -128,8 +129,6 @@ int8 PCSpeaker::generateSquare(uint32 x, uint32 oscLength) { /*-------------------------------------------------------------------------*/ -const int tab[16] = { -96, -72, -48, -32, -20, -12, -8, -4, 0, 4, 8, 12, 20, 32, 48, 72 }; - // The PC timer chip works at a frequency of 1.19318Mhz #define TIMER_FREQUENCY 1193180 @@ -149,21 +148,21 @@ SoundManager::~SoundManager() { /** * Decode music data */ -void SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int NbreSeg) { - int seed = 128; +void SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int size) { + static const int tab[16] = { -96, -72, -48, -32, -20, -12, -8, -4, 0, 4, 8, 12, 20, 32, 48, 72 }; + + uint seed = 128; int v; - for (int idx1 = 0; idx1 < (NbreSeg * 2); ++idx1) { - for (int idx2 = 0; idx2 < 64; ++idx2) { - byte srcByte = *PSrc++; - v = tab[srcByte >> 4]; - seed += v; - *PDest++ = seed & 0xff; - - v = tab[srcByte & 0xf]; - seed += v; - *PDest++ = seed & 0xff; - } + for (int idx1 = 0; idx1 < size; ++idx1) { + byte srcByte = *PSrc++; + v = tab[srcByte >> 4]; + seed += v; + *PDest++ = seed & 0xff; + + v = tab[srcByte & 0xf]; + seed += v; + *PDest++ = seed & 0xff; } } @@ -176,27 +175,12 @@ void SoundManager::playNote(int frequency, int32 length) { } -void SoundManager::musyc(tablint &tb, int nbseg, int att) { -#ifdef DEBUG - const byte *pSrc = &_vm->_mem[kAdrMusic * 16]; - - // Convert the countdown amount to a tempo rate, and then to note length in microseconds - int tempo = TIMER_FREQUENCY / att; - int length = 1000000 / tempo; +void SoundManager::playSong(const byte* buf, int size) { + Audio::AudioStream *stream = Audio::makeRawStream(buf, size, 11025 / 2, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS); + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); - for (int noteIndex = 0; noteIndex < (nbseg * 16); ++noteIndex) { - int lookupValue = *pSrc++; - int noteCountdown = tb[lookupValue]; - int noteFrequency = TIMER_FREQUENCY / noteCountdown; - - playNote(noteFrequency, length); - } - - // Keep waiting until the song has been finished - while (_speakerStream->isPlaying() && !_vm->shouldQuit()) { - _vm->delay(10); - } -#endif + while (_mixer->isSoundHandleActive(_speakerHandle) && !_vm->keyPressed() && !_vm->_mouseClick) + ; } void SoundManager::setParent(MortevielleEngine *vm) { diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h index a47e8db32e..c1df98e937 100644 --- a/engines/mortevielle/sound.h +++ b/engines/mortevielle/sound.h @@ -105,9 +105,10 @@ public: void setParent(MortevielleEngine *vm); void playNote(int frequency, int32 length); - void decodeMusic(const byte *PSrc, byte *PDest, int NbreSeg); + void decodeMusic(const byte *PSrc, byte *PDest, int size); + void playSong(const byte *buf, int size); + void litph(tablint &t, int typ, int tempo); - void musyc(tablint &tb, int nbseg, int att); }; } // End of namespace Mortevielle diff --git a/engines/mortevielle/speech.cpp b/engines/mortevielle/speech.cpp index 68ae3dac3e..35eefc898f 100644 --- a/engines/mortevielle/speech.cpp +++ b/engines/mortevielle/speech.cpp @@ -170,7 +170,7 @@ void SpeechManager::loadMusicSound() { _vm->_compMusicBuf1 = (byte *)malloc(sizeof(byte) * size); f.read(_vm->_compMusicBuf1, size); - _vm->_soundManager.decodeMusic(_vm->_compMusicBuf1, &_vm->_mem[kAdrNoise * 16], size / 128); + _vm->_soundManager.decodeMusic(_vm->_compMusicBuf1, &_vm->_mem[kAdrNoise * 16], size); f.close(); } diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp index af2c4868de..b729d5951e 100644 --- a/engines/mortevielle/utils.cpp +++ b/engines/mortevielle/utils.cpp @@ -2201,13 +2201,15 @@ void MortevielleEngine::music() { if (!f.open("mort.img")) error("Missing file - mort.img"); - free(_compMusicBuf2); int size = f.size(); - _compMusicBuf2 = (byte *)malloc(sizeof(byte) * size); - f.read(_compMusicBuf2, size); + byte *compMusicBuf = (byte *)malloc(sizeof(byte) * size); + byte *musicBuf = (byte *)malloc(sizeof(byte) * size * 2); + f.read(compMusicBuf, size); f.close(); - _soundManager.decodeMusic(_compMusicBuf2, &_mem[kAdrMusic * 16], size / 128); + _soundManager.decodeMusic(compMusicBuf, musicBuf, size); + free(compMusicBuf); + _addFix = (float)((kTempoMusic - 8)) / 256; _speechManager.cctable(_speechManager._tbi); @@ -2215,12 +2217,14 @@ void MortevielleEngine::music() { int k = 0; do { fin = keyPressed(); - _soundManager.musyc(_speechManager._tbi, 9958, kTempoMusic); + _soundManager.playSong(musicBuf, size * 2); ++k; fin = fin | keyPressed() | (k >= 5); } while (!fin); while (keyPressed()) getChar(); + + free(musicBuf); } /** |