diff options
-rw-r--r-- | engines/supernova/console.cpp | 10 | ||||
-rw-r--r-- | engines/supernova/msn_def.h | 29 | ||||
-rw-r--r-- | engines/supernova/rooms.cpp | 26 | ||||
-rw-r--r-- | engines/supernova/supernova.cpp | 65 | ||||
-rw-r--r-- | engines/supernova/supernova.h | 6 |
5 files changed, 104 insertions, 32 deletions
diff --git a/engines/supernova/console.cpp b/engines/supernova/console.cpp index 98875ecba6..96f97b71ce 100644 --- a/engines/supernova/console.cpp +++ b/engines/supernova/console.cpp @@ -53,15 +53,13 @@ bool Console::cmdRenderImage(int argc, const char **argv) { } bool Console::cmdPlaySound(int argc, const char **argv) { - if (argc != 3) { - debugPrintf("Usage: play [filenumber] [offset]\n"); + if (argc != 2) { + debugPrintf("Usage: play [0-%d]\n", kAudioNumSamples - 1); return true; } - int filenumber = atoi(argv[1]); - int offset = atoi(argv[2]); - - _vm->playSound(filenumber, offset); + int sample = Common::String(argv[1]).asUint64(); + _vm->playSound(static_cast<AudioIndex>(sample)); return true; } diff --git a/engines/supernova/msn_def.h b/engines/supernova/msn_def.h index 81138f1d92..23516a72b7 100644 --- a/engines/supernova/msn_def.h +++ b/engines/supernova/msn_def.h @@ -49,6 +49,35 @@ enum MessagePosition { kMessageTop }; +enum AudioIndex { + kAudioGreat, // 44|0 + kAudioCrash, // 45|0 + kAudioVoiceHalt, // 46|0 + kAudioUndef1, // 46|2510 + kAudioUndef2, // 46|4020 + kAudioVoiceSupernova, // 47|0 + kAudioVoiceYeah, // 47|24010 + kAudioUndef3, // 48|0 + kAudioUndef4, // 48|2510 + kAudioShock, // 48|10520 + kAudioTurntable, // 48|13530 + kAudioUndef5, // 50|0 + kAudioUndef6, // 50|12786 + kAudioDeath, // 53|0 + kAudioAlarm, // 54|0 + kAudioUndef7, // 54|8010 + kAudioDoorSound, // 54|24020 + kAudioDoorOpen, // 54|30030 + kAudioDoorClose, // 54|31040 + kAudioNumSamples +}; + +struct AudioInfo { + int _filenumber; + int _offsetStart; + int _offsetEnd; +}; + // Colors const int kColorBlack = 0; const int kColorWhite25 = 1; diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp index 66013a1db4..cd7a88bd9f 100644 --- a/engines/supernova/rooms.cpp +++ b/engines/supernova/rooms.cpp @@ -29,7 +29,7 @@ namespace Supernova { bool ShipCorridor::interact(Action verb, Object &obj1, Object &obj2) { if ((verb == ACTION_PRESS) && (obj1._id == BUTTON)) { if (_objectState[6].hasProperty(OPENED)) { - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); _objectState[6].disableProperty(OPENED); _vm->renderImage(_gm->_currentRoom->getFileNumber(), 8); _shown[9] = false; @@ -39,7 +39,7 @@ bool ShipCorridor::interact(Action verb, Object &obj1, Object &obj2) { _gm->wait2(2); _vm->renderImage(_gm->_currentRoom->getFileNumber(), _gm->invertSection(7)); } else { - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); _objectState[6].setProperty(OPENED); _vm->renderImage(_gm->_currentRoom->getFileNumber(), 7); _gm->wait2(2); @@ -239,7 +239,7 @@ bool ShipSleepCabin::interact(Action verb, Object &obj1, Object &obj2) { _gm->wait2(18); _vm->paletteFadeIn(); if (_gm->_state.time == 0) { - _vm->playSound(45); + _vm->playSound(kAudioCrash); _gm->screenShake(); _gm->wait2(18); _vm->renderMessage("Was war das?"); @@ -447,7 +447,7 @@ bool ShipCabinL3::interact(Action verb, Object &obj1, Object &obj2) { _vm->renderImage(this->getFileNumber(), 14); this->setSectionVisible(15, false); for (int i = 3; i; i--) { - _vm->playSound(48, 13530); + _vm->playSound(kAudioTurntable); if (_gm->_soundDevice) { do { if (this->isSectionVisible(13)) { @@ -580,7 +580,7 @@ bool ShipAirlock::interact(Action verb, Object &obj1, Object &obj2) { if ((verb == ACTION_PRESS) && (obj1._id == BUTTON1)) { if (!this->getObject(1)->hasProperty(OPENED)) { _vm->renderImage(this->getFileNumber(), 10); - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); if (this->getObject(0)->hasProperty(OPENED)) { this->getObject(0)->disableProperty(OPENED); _vm->renderImage(this->getFileNumber(), 1); @@ -606,7 +606,7 @@ bool ShipAirlock::interact(Action verb, Object &obj1, Object &obj2) { if (!this->getObject(0)->hasProperty(OPENED)) { _vm->renderImage(this->getFileNumber(), 11); if (this->getObject(1)->hasProperty(OPENED)) { - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); this->getObject(1)->disableProperty(OPENED); _vm->renderImage(this->getFileNumber(), 4); _gm->wait2(2); @@ -649,7 +649,7 @@ bool ShipAirlock::interact(Action verb, Object &obj1, Object &obj2) { _gm->wait2(3); _vm->renderImage(this->getFileNumber(), 17); this->setSectionVisible(16, false); - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); _vm->renderImage(this->getFileNumber(), 5); this->setSectionVisible(6, false); _gm->wait2(2); @@ -860,7 +860,7 @@ bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { if ((verb == ACTION_OPEN) && (obj1._id == OUTERHATCH)) { if (obj1.hasProperty(OPENED)) return false; - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); _vm->renderImage(this->getFileNumber(), 1); if (this->isSectionVisible(7)) _vm->renderImage(this->getFileNumber(), 10); @@ -869,14 +869,14 @@ bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { _gm->_rooms[HOLD].setSectionVisible(3, true); obj1.setProperty(OPENED); obj1._click = 2; - _vm->playSound(54, 30030); + _vm->playSound(kAudioDoorOpen); } else if ((verb == ACTION_CLOSE) && (obj1._id == OUTERHATCH)) { if (!obj1.hasProperty(OPENED)) return false; if (this->isSectionVisible(11) || this->isSectionVisible(12)) { _vm->renderMessage("Das Seil ist im Weg."); } else { - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); _vm->renderImage(this->getFileNumber(), _gm->invertSection(1)); this->setSectionVisible(10, false); if (this->isSectionVisible(13)) @@ -884,7 +884,7 @@ bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { _gm->_rooms[HOLD].setSectionVisible(3, false); obj1.disableProperty(OPENED); obj1._click = 1; - _vm->playSound(54, 31040); + _vm->playSound(kAudioDoorClose); } } else if ((verb == ACTION_WALK) && (obj1._id == OUTERHATCH) && this->isSectionVisible(7)) { @@ -918,7 +918,7 @@ bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { else _vm->renderImage(this->getFileNumber(), 4); } else if ((verb == ACTION_OPEN) && (obj1._id == TRAP)) { - _vm->playSound(54, 24020); + _vm->playSound(kAudioDoorSound); _vm->renderImage(this->getFileNumber(), 2); if (this->getObject(11)->_click == 11) _vm->renderImage(this->getFileNumber(), 3); @@ -928,7 +928,7 @@ bool ShipGenerator::interact(Action verb, Object &obj1, Object &obj2) { obj1._click = 6; obj1._click2 = 5; - _vm->playSound(54, 30030); + _vm->playSound(kAudioDoorOpen); } else if ((verb == ACTION_CLOSE) && (obj1._id == TRAP)) { if (this->isSectionVisible(9)) _vm->renderMessage("Das Kabel ist im Weg."); diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index f8fce4cb69..99cc867682 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -37,9 +37,30 @@ #include "supernova/supernova.h" - namespace Supernova { +const AudioInfo audioInfo[kAudioNumSamples] = { + {44, 0, -1}, + {45, 0, -1}, + {46, 0, 2510}, + {46, 2510, 4020}, + {46, 4020, -1}, + {47, 0, 24010}, + {47, 24010, -1}, + {48, 0, 2510}, + {48, 2510, 10520}, + {48, 10520, 13530}, + {48, 13530, -1}, + {50, 0, 12786}, + {50, 12786, -1}, + {53, 0, -1}, + {54, 0, 8010}, + {54, 8010, 24020}, + {54, 24020, 30030}, + {54, 30030, 31040}, + {54, 31040, -1} +}; + const char *const Object::defaultDescription = "Es ist nichts Besonderes daran."; const char *const Object::takeMessage = "Das mußt du erst nehmen."; @@ -92,6 +113,9 @@ SupernovaEngine::~SupernovaEngine() { delete _rnd; delete _console; + for (int i = 0; i < kAudioNumSamples; ++i) { + delete[] _soundSamples[i]._buffer; + } } Common::Error SupernovaEngine::run() { @@ -167,20 +191,37 @@ void SupernovaEngine::initData() { _images[i].init(i); // Sound + Common::File file; + + for (int i = 0; i < kAudioNumSamples; ++i) { + if (!file.open(Common::String::format("msn_data.%03d", audioInfo[i]._filenumber))) { + error("File %s could not be read!", file.getName()); + } + + if (audioInfo[i]._offsetEnd == -1) { + file.seek(0, SEEK_END); + _soundSamples[i]._length = file.pos() - audioInfo[i]._offsetStart; + } else { + _soundSamples[i]._length = audioInfo[i]._offsetEnd - audioInfo[i]._offsetStart; + } + _soundSamples[i]._buffer = new byte[_soundSamples[i]._length]; + file.seek(audioInfo[i]._offsetStart); + file.read(_soundSamples[i]._buffer, _soundSamples[i]._length); + file.close(); + } } void SupernovaEngine::initPalette() { _system->getPaletteManager()->setPalette(initVGAPalette, 0, 256); } -void SupernovaEngine::playSound(int filenumber, int offset) { - Common::File *file = new Common::File; - if (!file->open(Common::String::format("msn_data.0%2d", filenumber))) { - error("File %s could not be read!", file->getName()); - } +void SupernovaEngine::playSound(AudioIndex sample) { + if (sample > kAudioNumSamples - 1) + return; - file->seek(offset); - Audio::SeekableAudioStream *audioStream = Audio::makeRawStream(file, 11931, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN); + Audio::SeekableAudioStream *audioStream = Audio::makeRawStream( + _soundSamples[sample]._buffer, _soundSamples[sample]._length, + 11931, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN, DisposeAfterUse::NO); stopSound(); _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream); } @@ -622,7 +663,7 @@ void GameManager::great(uint number) { if (number && (_state.greatF & (1 << number))) return; - _vm->playSound(54, 8010); + _vm->playSound(kAudioUndef7); _state.greatF |= 1 << number; } @@ -714,7 +755,7 @@ void GameManager::palette() { void GameManager::shock() { // STUB - _vm->playSound(48, 10520); + _vm->playSound(kAudioShock); // die } @@ -1087,7 +1128,7 @@ void GameManager::executeRoom() { byte i = _inputObject[0]._click; _inputObject[0]._click = _inputObject[0]._click2; _inputObject[0]._click2 = i; - _vm->playSound(54, 30030); + _vm->playSound(kAudioDoorOpen); } break; @@ -1106,7 +1147,7 @@ void GameManager::executeRoom() { byte i = _inputObject[0]._click; _inputObject[0]._click = _inputObject[0]._click2; _inputObject[0]._click2 = i; - _vm->playSound(54, 31040); + _vm->playSound(kAudioDoorClose); } break; diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h index 7f181b5be5..16b9b4e130 100644 --- a/engines/supernova/supernova.h +++ b/engines/supernova/supernova.h @@ -82,6 +82,10 @@ public: ScreenBufferStack _screenBuffer; MSNImageDecoder _images[44]; MSNImageDecoder *_currentImage; + struct SoundSample { + byte *_buffer; + int _length; + } _soundSamples[kAudioNumSamples]; Common::Event _event; bool _gameRunning; @@ -102,7 +106,7 @@ public: void paletteFadeOut(); void paletteBrightness(); void updateEvents(); - void playSound(int filenumber, int offset = 0); + void playSound(AudioIndex sample); void playSoundMod(int filenumber); void stopSound(); void renderImage(MSNImageDecoder &image, int section, bool fullscreen = false); |