diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/startrek/actors.cpp | 2 | ||||
-rw-r--r-- | engines/startrek/awaymission.cpp | 4 | ||||
-rw-r--r-- | engines/startrek/intro.cpp | 2 | ||||
-rw-r--r-- | engines/startrek/menu.cpp | 28 | ||||
-rw-r--r-- | engines/startrek/room.cpp | 4 | ||||
-rw-r--r-- | engines/startrek/sound.cpp | 56 | ||||
-rw-r--r-- | engines/startrek/sound.h | 1 | ||||
-rw-r--r-- | engines/startrek/startrek.cpp | 75 | ||||
-rw-r--r-- | engines/startrek/startrek.h | 6 | ||||
-rw-r--r-- | engines/startrek/textbox.cpp | 4 |
10 files changed, 82 insertions, 100 deletions
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp index a0c6b9c146..24434eb995 100644 --- a/engines/startrek/actors.cpp +++ b/engines/startrek/actors.cpp @@ -1253,7 +1253,7 @@ exitWithoutSelection: removeNextEvent(); } - playSoundEffectIndex(0x10); + _sound->playSoundEffectIndex(0x10); if (lastItemIndex >= 0) drawMenuButtonOutline(itemSprites[lastItemIndex].bitmap, 0); diff --git a/engines/startrek/awaymission.cpp b/engines/startrek/awaymission.cpp index d05cc35a73..0f5f8a8689 100644 --- a/engines/startrek/awaymission.cpp +++ b/engines/startrek/awaymission.cpp @@ -153,7 +153,7 @@ void StarTrekEngine::initAwayCrewPositions(int warpEntryIndex) { _kirkActor->triggerActionWhenAnimFinished = true; _kirkActor->finishedAnimActionParam = 0xff; _awayMission.disableInput = true; - playSoundEffectIndex(0x09); + _sound->playSoundEffectIndex(0x09); _warpHotspotsActive = false; break; case 5: // Crew spawns in directly at a position. @@ -364,7 +364,7 @@ void StarTrekEngine::awayMissionSelectAction(bool openActionMenu) { if (_awayMission.disableInput) return; hideInventoryIcons(); - playSoundEffectIndex(SND_07); + _sound->playSoundEffectIndex(SND_07); _awayMission.activeAction = showActionMenu(); } diff --git a/engines/startrek/intro.cpp b/engines/startrek/intro.cpp index cb0b096be6..02d7642da2 100644 --- a/engines/startrek/intro.cpp +++ b/engines/startrek/intro.cpp @@ -123,7 +123,7 @@ void StarTrekEngine::playIntro() { switch (frame) { case 0: starfieldZoomSpeed = 10; - playMidiMusicTracks(MIDITRACK_0, -1); + _sound->playMidiMusicTracks(MIDITRACK_0, -1); _byte_45b3c = 0; break; diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp index 09528ce3c6..f973f9a95b 100644 --- a/engines/startrek/menu.cpp +++ b/engines/startrek/menu.cpp @@ -469,7 +469,7 @@ lookupNextAction: } } - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); menuSprite.dontDrawNextFrame(); _gfx->drawAllSprites(); @@ -656,12 +656,12 @@ int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool inTe case TREKEVENT_LBUTTONDOWN: lclick: if (_activeMenu->selectedButton != -1) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return _activeMenu->retvals[_activeMenu->selectedButton]; } else { Common::Point mouse = _gfx->getMousePos(); if (getMenuButtonAt(_activeMenu->sprites, _activeMenu->numButtons, mouse.x, mouse.y) == -1) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return MENUEVENT_LCLICK_OFFBUTTON; } } @@ -669,7 +669,7 @@ lclick: case TREKEVENT_RBUTTONDOWN: rclick: - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); if (_activeMenu->selectedButton == -1) return MENUEVENT_RCLICK_OFFBUTTON; else @@ -686,13 +686,13 @@ rclick: case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: case Common::KEYCODE_F1: - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_CONFIRM; case Common::KEYCODE_SPACE: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_NEXTCHOICE)) && _activeMenu->sprites[TEXTBUTTON_NEXTCHOICE].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_NEXTCHOICE; } break; @@ -701,7 +701,7 @@ rclick: case Common::KEYCODE_KP7: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_SCROLLUP)) && _activeMenu->sprites[TEXTBUTTON_SCROLLUP].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_GOTO_TOP; } break; @@ -710,7 +710,7 @@ rclick: case Common::KEYCODE_KP8: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_SCROLLUP)) && _activeMenu->sprites[TEXTBUTTON_SCROLLUP].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_SCROLLUP_ONELINE; } break; @@ -719,7 +719,7 @@ rclick: case Common::KEYCODE_KP9: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_SCROLLUP)) && _activeMenu->sprites[TEXTBUTTON_SCROLLUP].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_SCROLLUP; } break; @@ -728,7 +728,7 @@ rclick: case Common::KEYCODE_KP4: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_PREVCHOICE)) && _activeMenu->sprites[TEXTBUTTON_PREVCHOICE].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_PREVCHOICE; } break; @@ -737,7 +737,7 @@ rclick: case Common::KEYCODE_KP6: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_NEXTCHOICE)) && _activeMenu->sprites[TEXTBUTTON_NEXTCHOICE].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_NEXTCHOICE; } break; @@ -746,7 +746,7 @@ rclick: case Common::KEYCODE_KP1: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_SCROLLDOWN)) && _activeMenu->sprites[TEXTBUTTON_SCROLLDOWN].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_GOTO_BOTTOM; } break; @@ -755,7 +755,7 @@ rclick: case Common::KEYCODE_KP2: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_SCROLLDOWN)) && _activeMenu->sprites[TEXTBUTTON_SCROLLDOWN].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_SCROLLDOWN_ONELINE; } break; @@ -764,7 +764,7 @@ rclick: case Common::KEYCODE_KP3: if (!(_activeMenu->disabledButtons & (1 << TEXTBUTTON_SCROLLDOWN)) && _activeMenu->sprites[TEXTBUTTON_SCROLLDOWN].drawMode == 2) { - playSoundEffectIndex(SND_SELECTION); + _sound->playSoundEffectIndex(SND_SELECTION); return TEXTBUTTON_SCROLLDOWN; } break; diff --git a/engines/startrek/room.cpp b/engines/startrek/room.cpp index 9c308ebeed..a34af48b0b 100644 --- a/engines/startrek/room.cpp +++ b/engines/startrek/room.cpp @@ -630,11 +630,11 @@ int16 Room::getRandomWordInRange(int start, int end) { } void Room::playSoundEffectIndex(int soundEffect) { - _vm->playSoundEffectIndex(soundEffect); + _vm->_sound->playSoundEffectIndex(soundEffect); } void Room::playMidiMusicTracks(int startTrack, int loopTrack) { - _vm->playMidiMusicTracks(startTrack, loopTrack); + _vm->_sound->playMidiMusicTracks(startTrack, loopTrack); } void Room::endMission(int16 score, int16 arg1, int16 arg2) { diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp index c448126e08..7976d05dc8 100644 --- a/engines/startrek/sound.cpp +++ b/engines/startrek/sound.cpp @@ -281,6 +281,62 @@ void Sound::stopPlayingSpeech() { } } +void Sound::playSoundEffectIndex(int index) { + if (!(_vm->getFeatures() & GF_CDROM)) + playMidiTrack(index); + else { + switch (index) { + case 0x04: + playVoc("tricorde"); + break; + case 0x05: + playVoc("STDOOR1"); + break; + case 0x06: + playVoc("PHASSHOT"); + break; + case 0x07: + playMidiTrack(index); + break; + case 0x08: + playVoc("TRANSDEM"); + break; + case 0x09: // Beaming in? + playVoc("TRANSMAT"); + break; + case 0x0a: // Beaming out? + playVoc("TRANSENE"); + break; + case 0x10: // Menu selection sound + playMidiTrack(index); + break; + case 0x22: + playVoc("HAILING"); + break; + case 0x24: + playVoc("PHASSHOT"); + break; + case 0x25: + playVoc("PHOTSHOT"); + break; + case 0x26: + playVoc("HITSHIEL"); + break; + case 0x27: + playMidiTrack(index); + break; + case 0x28: + playVoc("REDALERT"); + break; + case 0x29: + playVoc("WARP"); + break; + default: + debugC(kDebugSound, 6, "Unmapped sound 0x%x", index); + break; + } + } +} void Sound::setMusicEnabled(bool enable) { if (!_vm->_musicWorking || _vm->_musicEnabled == enable) diff --git a/engines/startrek/sound.h b/engines/startrek/sound.h index 5df02bc1d1..732d7819b9 100644 --- a/engines/startrek/sound.h +++ b/engines/startrek/sound.h @@ -69,6 +69,7 @@ public: void playSpeech(const Common::String &basename); void stopAllVocSounds(); void stopPlayingSpeech(); + void playSoundEffectIndex(int index); void setMusicEnabled(bool enable); void setSfxEnabled(bool enable); void checkLoopMusic(); diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index 4266462cff..3c82ea2650 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -300,12 +300,12 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) { _gfx->drawAllSprites(); _gfx->fadeinScreen(); - playSoundEffectIndex(0x0a); + _sound->playSoundEffectIndex(0x0a); if (name.equalsIgnoreCase("teled")) - playSoundEffectIndex(0x08); + _sound->playSoundEffectIndex(0x08); else - playSoundEffectIndex(0x09); + _sound->playSoundEffectIndex(0x09); while (_actorList[0].field62 == 0) { TrekEvent event; @@ -327,75 +327,6 @@ void StarTrekEngine::runTransportSequence(const Common::String &name) { initActors(); } -void StarTrekEngine::playSoundEffectIndex(int index) { - if (!(getFeatures() & GF_CDROM)) - _sound->playMidiTrack(index); - else { - switch (index) { - case 0x04: - _sound->playVoc("tricorde"); - break; - case 0x05: - _sound->playVoc("STDOOR1"); - break; - case 0x06: - _sound->playVoc("PHASSHOT"); - break; - case 0x07: - _sound->playMidiTrack(index); - break; - case 0x08: - _sound->playVoc("TRANSDEM"); - break; - case 0x09: // Beaming in? - _sound->playVoc("TRANSMAT"); - break; - case 0x0a: // Beaming out? - _sound->playVoc("TRANSENE"); - break; - case 0x10: // Menu selection sound - _sound->playMidiTrack(index); - break; - case 0x22: - _sound->playVoc("HAILING"); - break; - case 0x24: - _sound->playVoc("PHASSHOT"); - break; - case 0x25: - _sound->playVoc("PHOTSHOT"); - break; - case 0x26: - _sound->playVoc("HITSHIEL"); - break; - case 0x27: - _sound->playMidiTrack(index); - break; - case 0x28: - _sound->playVoc("REDALERT"); - break; - case 0x29: - _sound->playVoc("WARP"); - break; - default: - debugC(kDebugSound, 6, "Unmapped sound 0x%x", index); - break; - } - } -} - -void StarTrekEngine::playMidiMusicTracks(int startTrack, int loopTrack) { - _sound->playMidiMusicTracks(startTrack, loopTrack); -} - -void StarTrekEngine::playSpeech(const Common::String &filename) { - _sound->playSpeech(filename.c_str()); -} - -void StarTrekEngine::stopPlayingSpeech() { - _sound->stopPlayingSpeech(); -} - /** * TODO: * - Should return nullptr on failure to open a file? diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index a55b59e689..1e4e330ecb 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -243,12 +243,6 @@ public: void initBridge(bool b) {}; // TODO void cleanupBridge() {}; // TODO - // Running the game - void playSoundEffectIndex(int index); - void playMidiMusicTracks(int startTrack, int loopTrack); - void playSpeech(const Common::String &filename); - void stopPlayingSpeech(); - Common::MemoryReadStreamEndian *loadFile(Common::String filename, int fileIndex = 0); /** * TODO: Figure out what the extra parameters are, and if they're important. diff --git a/engines/startrek/textbox.cpp b/engines/startrek/textbox.cpp index 542df25bc7..007ab8f5af 100644 --- a/engines/startrek/textbox.cpp +++ b/engines/startrek/textbox.cpp @@ -240,7 +240,7 @@ String StarTrekEngine::playTextAudio(const String &str) { } soundFile[len] = '\0'; - playSpeech(soundFile); + _sound->playSpeech(soundFile); return String(text + 1); } @@ -462,7 +462,7 @@ readjustScroll: } _textboxVar2 = _frameIndex; - stopPlayingSpeech(); + _sound->stopPlayingSpeech(); return choiceIndex; } |