mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-13 07:14:59 +00:00
CHEWY: Refactor room music code
This commit is contained in:
parent
e4d1dc98d5
commit
ff23832042
@ -261,7 +261,6 @@ enter:
|
||||
const int16 slotNum = text_off + active_slot;
|
||||
for (uint j = 0; j < saveList.size(); ++j) {
|
||||
if (saveList[j].getSaveSlot() == slotNum) {
|
||||
_G(currentSong) = -1;
|
||||
_G(cur)->hide_cur();
|
||||
g_engine->loadGameState(slotNum);
|
||||
key = Common::KEYCODE_ESCAPE;
|
||||
|
@ -68,8 +68,7 @@ void MainMenu::execute() {
|
||||
_G(gameState)._personRoomNr[P_CHEWY] = 98;
|
||||
_G(room)->loadRoom(&_G(room_blk), 98, &_G(gameState));
|
||||
|
||||
_G(currentSong) = -1;
|
||||
load_room_music(98);
|
||||
g_engine->_sound->playRoomMusic(98);
|
||||
_G(fx)->border(_G(workpage), 100, 0, 0);
|
||||
|
||||
_G(out)->setPalette(_G(pal));
|
||||
|
@ -174,8 +174,7 @@ void Options::execute(TafInfo *ti) {
|
||||
g_engine->_sound->stopMusic();
|
||||
} else {
|
||||
g_engine->_sound->toggleMusic(true);
|
||||
_G(currentSong) = -1;
|
||||
load_room_music(_G(gameState)._personRoomNr[P_CHEWY]);
|
||||
g_engine->_sound->playRoomMusic(_G(gameState)._personRoomNr[P_CHEWY]);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
|
@ -153,7 +153,6 @@ public:
|
||||
|
||||
int16 _talk_start_ani = -1;
|
||||
int16 _talk_hide_static = -1;
|
||||
int16 _currentSong = -1;
|
||||
bool _savegameFlag = false;
|
||||
int _timer_action_ctr = 0;
|
||||
|
||||
@ -531,8 +530,6 @@ void load_person_ani(int16 ani_id, int16 p_nr);
|
||||
|
||||
void calc_person_ani();
|
||||
|
||||
void load_room_music(int16 room_nr);
|
||||
|
||||
} // namespace Chewy
|
||||
|
||||
#endif
|
||||
|
@ -137,7 +137,6 @@ void var_init() {
|
||||
_G(gpkt).Vorschub = _G(spieler_mi)[P_CHEWY].Vorschub;
|
||||
init_room();
|
||||
_G(gameState).FramesPerSecond = 7;
|
||||
_G(currentSong) = -1;
|
||||
_G(SetUpScreenFunc) = nullptr;
|
||||
_G(pfeil_delay) = 0;
|
||||
_G(pfeil_ani) = 0;
|
||||
|
@ -1,256 +0,0 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "chewy/defines.h"
|
||||
#include "chewy/globals.h"
|
||||
#include "chewy/sound.h"
|
||||
|
||||
namespace Chewy {
|
||||
|
||||
#define NORMAL_PLAY 0
|
||||
#define SEQUENCE_PLAY 1
|
||||
#define PATTERN_PLAY 2
|
||||
|
||||
void load_room_music(int16 room_nr) {
|
||||
int16 musicIndex = -1;
|
||||
if (!g_engine->_sound->musicEnabled())
|
||||
return;
|
||||
|
||||
switch (room_nr) {
|
||||
case 0:
|
||||
musicIndex = 13;
|
||||
break;
|
||||
case 1:
|
||||
case 18:
|
||||
case 90:
|
||||
musicIndex = 17;
|
||||
break;
|
||||
case 2:
|
||||
case 88:
|
||||
musicIndex = 43;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
musicIndex = 0;
|
||||
break;
|
||||
case 5:
|
||||
case 8:
|
||||
case 12:
|
||||
case 86:
|
||||
musicIndex = 14;
|
||||
break;
|
||||
case 6:
|
||||
musicIndex = 1;
|
||||
break;
|
||||
case 7:
|
||||
case 97:
|
||||
musicIndex = 18;
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
case 47:
|
||||
case 87:
|
||||
musicIndex = 20;
|
||||
break;
|
||||
case 11:
|
||||
musicIndex = 19;
|
||||
break;
|
||||
case 13:
|
||||
musicIndex = -1;
|
||||
break;
|
||||
case 14:
|
||||
musicIndex = 19;
|
||||
break;
|
||||
case 15:
|
||||
case 16:
|
||||
case 19:
|
||||
case 96:
|
||||
musicIndex = 16;
|
||||
break;
|
||||
case 21:
|
||||
musicIndex = 2;
|
||||
break;
|
||||
case 22:
|
||||
musicIndex = 48;
|
||||
break;
|
||||
case 25:
|
||||
case 26:
|
||||
musicIndex = 11;
|
||||
break;
|
||||
case 27:
|
||||
case 30:
|
||||
case 54:
|
||||
case 63:
|
||||
musicIndex = 33;
|
||||
break;
|
||||
case 28:
|
||||
case 29:
|
||||
musicIndex = 47;
|
||||
break;
|
||||
case 31:
|
||||
case 35:
|
||||
musicIndex = 9;
|
||||
break;
|
||||
case 32:
|
||||
case 40:
|
||||
case 71:
|
||||
case 89:
|
||||
case 92:
|
||||
musicIndex = 38;
|
||||
break;
|
||||
case 33:
|
||||
musicIndex = 35;
|
||||
break;
|
||||
case 37:
|
||||
musicIndex = 8;
|
||||
break;
|
||||
case 39:
|
||||
musicIndex = 9;
|
||||
break;
|
||||
case 41:
|
||||
case 77:
|
||||
case 78:
|
||||
case 83:
|
||||
case 93:
|
||||
musicIndex = -1;
|
||||
break;
|
||||
case 42:
|
||||
musicIndex = 41;
|
||||
break;
|
||||
case 45:
|
||||
musicIndex = 44;
|
||||
break;
|
||||
case 46:
|
||||
case 50:
|
||||
case 73:
|
||||
case 74:
|
||||
musicIndex = 21;
|
||||
break;
|
||||
case 48:
|
||||
musicIndex = 22;
|
||||
break;
|
||||
case 49:
|
||||
musicIndex = 3;
|
||||
break;
|
||||
case 51:
|
||||
case 52:
|
||||
musicIndex = 27;
|
||||
break;
|
||||
case 53:
|
||||
musicIndex = 26;
|
||||
break;
|
||||
case 55:
|
||||
case 57:
|
||||
musicIndex = 23;
|
||||
break;
|
||||
case 56:
|
||||
// TODO: Extra checks for two flags
|
||||
//if ( (spieler.flags32 & SpielerFlags32_10) != 0 && spieler.flags33 >= 0 ) {
|
||||
musicIndex = 52;
|
||||
//} else {
|
||||
// musicIndex = 7;
|
||||
//}
|
||||
break;
|
||||
case 62:
|
||||
musicIndex = 25;
|
||||
break;
|
||||
case 64:
|
||||
musicIndex = 51;
|
||||
break;
|
||||
case 66:
|
||||
case 68:
|
||||
musicIndex = 34;
|
||||
break;
|
||||
case 67:
|
||||
case 69:
|
||||
case 70:
|
||||
case 75:
|
||||
musicIndex = 28;
|
||||
break;
|
||||
case 72:
|
||||
musicIndex = 31;
|
||||
break;
|
||||
case 76:
|
||||
musicIndex = 46;
|
||||
break;
|
||||
case 79:
|
||||
musicIndex = 6;
|
||||
break;
|
||||
case 80:
|
||||
musicIndex = 29;
|
||||
break;
|
||||
case 81:
|
||||
musicIndex = 45;
|
||||
break;
|
||||
case 82:
|
||||
musicIndex = 50;
|
||||
break;
|
||||
case 84:
|
||||
musicIndex = 24;
|
||||
break;
|
||||
case 85:
|
||||
musicIndex = 32;
|
||||
break;
|
||||
case 91:
|
||||
musicIndex = 36;
|
||||
break;
|
||||
case 94:
|
||||
case 95:
|
||||
musicIndex = 40;
|
||||
break;
|
||||
case 98:
|
||||
musicIndex = 4;
|
||||
break;
|
||||
case 255:
|
||||
musicIndex = 5;
|
||||
break;
|
||||
case 256:
|
||||
musicIndex = 10;
|
||||
break;
|
||||
case 257:
|
||||
musicIndex = 52;
|
||||
break;
|
||||
case 258:
|
||||
musicIndex = 53;
|
||||
break;
|
||||
case 259:
|
||||
musicIndex = 54;
|
||||
break;
|
||||
case 260:
|
||||
musicIndex = 24;
|
||||
break;
|
||||
default:
|
||||
musicIndex = -1;
|
||||
_G(currentSong) = -1;
|
||||
g_engine->_sound->stopMusic();
|
||||
break;
|
||||
}
|
||||
|
||||
// The original changed the volume here,
|
||||
// but we try to maintain a stable volume
|
||||
if (musicIndex != _G(currentSong)) {
|
||||
g_engine->_sound->stopMusic();
|
||||
_G(currentSong) = musicIndex;
|
||||
g_engine->_sound->playMusic(musicIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Chewy
|
@ -1830,7 +1830,6 @@ void calc_auto_go() {
|
||||
|
||||
void hide_person() {
|
||||
for (int16 i = 0; i < MAX_PERSON; i++) {
|
||||
|
||||
if (!_G(gameState)._personHide[i]) {
|
||||
_G(gameState)._personHide[i] = true;
|
||||
_G(person_tmp_hide)[i] = true;
|
||||
|
@ -11,7 +11,6 @@ MODULE_OBJS = \
|
||||
events.o \
|
||||
globals.o \
|
||||
inits.o \
|
||||
m_event.o \
|
||||
main.o \
|
||||
mouse.o \
|
||||
mcga_graphics.o \
|
||||
|
@ -173,7 +173,7 @@ void check_ged_action(int16 index) {
|
||||
}
|
||||
|
||||
void enter_room(int16 eib_nr) {
|
||||
load_room_music(_G(gameState)._personRoomNr[P_CHEWY]);
|
||||
g_engine->_sound->playRoomMusic(_G(gameState)._personRoomNr[P_CHEWY]);
|
||||
load_chewy_taf(_G(gameState).ChewyAni);
|
||||
_G(atds)->stopAad();
|
||||
_G(atds)->stop_ats();
|
||||
@ -667,11 +667,11 @@ static void playIntroSequence() {
|
||||
|
||||
for (int i = 0; i < 29 && ret != -1; ++i) {
|
||||
if (introVideo[i] == FCUT_135)
|
||||
load_room_music(258);
|
||||
g_engine->_sound->playRoomMusic(258);
|
||||
else if (introVideo[i] == FCUT_148)
|
||||
load_room_music(259);
|
||||
g_engine->_sound->playRoomMusic(259);
|
||||
else if (introVideo[i] == FCUT_143)
|
||||
load_room_music(260);
|
||||
g_engine->_sound->playRoomMusic(260);
|
||||
|
||||
if (introDialog[i] != -1)
|
||||
start_aad(introDialog[i], -1);
|
||||
@ -729,7 +729,7 @@ void flic_cut(int16 nr) {
|
||||
break;
|
||||
|
||||
case FCUT_058:
|
||||
load_room_music(255);
|
||||
g_engine->_sound->playRoomMusic(255);
|
||||
g_engine->_video->playVideo(FCUT_058);
|
||||
g_engine->_video->playVideo(FCUT_059);
|
||||
|
||||
@ -750,10 +750,8 @@ void flic_cut(int16 nr) {
|
||||
|
||||
case FCUT_065:
|
||||
g_engine->_sound->stopMusic();
|
||||
_G(currentSong) = -1;
|
||||
load_room_music(256);
|
||||
g_engine->_sound->playRoomMusic(256);
|
||||
Room46::kloppe();
|
||||
_G(currentSong) = -1;
|
||||
break;
|
||||
|
||||
case FCUT_112:
|
||||
@ -794,7 +792,7 @@ void flic_cut(int16 nr) {
|
||||
g_engine->_sound->setMusicVolume(_G(gameState).MusicVol * Audio::Mixer::kMaxChannelVolume / 120);
|
||||
|
||||
if (nr != FCUT_135) {
|
||||
load_room_music(_G(gameState)._personRoomNr[0]);
|
||||
g_engine->_sound->playRoomMusic(_G(gameState)._personRoomNr[0]);
|
||||
|
||||
if (g_engine->_sound->speechEnabled())
|
||||
_G(det)->enable_room_sound();
|
||||
|
@ -268,7 +268,7 @@ void Room37::use_hahn() {
|
||||
_G(gameState).R37Kloppe = true;
|
||||
hideCur();
|
||||
autoMove(6, P_CHEWY);
|
||||
load_room_music(256);
|
||||
g_engine->_sound->playRoomMusic(256);
|
||||
_G(room)->set_timer_status(7, TIMER_STOP);
|
||||
_G(det)->stop_detail(7);
|
||||
_G(det)->del_static_ani(7);
|
||||
|
@ -418,8 +418,7 @@ void Room68::kostuem_aad(int16 aad_nr) {
|
||||
setPersonPos(150, -13, P_NICHELLE, P_RIGHT);
|
||||
|
||||
if (g_engine->_sound->subtitlesEnabled()) {
|
||||
_G(currentSong) = -1;
|
||||
load_room_music(_G(gameState)._personRoomNr[0]);
|
||||
g_engine->_sound->playRoomMusic(_G(gameState)._personRoomNr[0]);
|
||||
}
|
||||
}
|
||||
showCur();
|
||||
|
@ -122,18 +122,20 @@ void Sound::setSoundChannelBalance(uint channel, int8 balance) {
|
||||
_mixer->setChannelBalance(_soundHandle[channel], balance);
|
||||
}
|
||||
|
||||
void Sound::playMusic(int num, bool loop) {
|
||||
void Sound::playMusic(int16 num, bool loop) {
|
||||
uint32 musicNum = _soundRes->getChunkCount() - 1 - num;
|
||||
Chunk *chunk = _soundRes->getChunk(musicNum);
|
||||
uint8 *data = _soundRes->getChunkData(musicNum);
|
||||
_curMusic = num;
|
||||
|
||||
playMusic(data, chunk->size, loop);
|
||||
playMusic(data, chunk->size);
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void Sound::playMusic(uint8 *data, uint32 size, bool loop, DisposeAfterUse::Flag dispose) {
|
||||
void Sound::playMusic(uint8 *data, uint32 size) {
|
||||
TMFStream *stream = new TMFStream(new Common::MemoryReadStream(data, size), 0);
|
||||
_curMusic = -1;
|
||||
|
||||
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, stream);
|
||||
}
|
||||
@ -147,6 +149,7 @@ void Sound::resumeMusic() {
|
||||
}
|
||||
|
||||
void Sound::stopMusic() {
|
||||
_curMusic = -1;
|
||||
_mixer->stopHandle(_musicHandle);
|
||||
}
|
||||
|
||||
@ -251,4 +254,55 @@ void Sound::toggleSubtitles(bool enable) {
|
||||
return ConfMan.setBool("subtitles", enable);
|
||||
}
|
||||
|
||||
struct RoomMusic {
|
||||
int16 room;
|
||||
int16 music;
|
||||
};
|
||||
|
||||
const RoomMusic roomMusic[] = {
|
||||
{ 0, 13 }, { 1, 17 }, { 18, 17 }, { 90, 17 }, { 2, 43 },
|
||||
{ 88, 43 }, { 3, 0 }, { 4, 0 }, { 5, 14 }, { 8, 14 },
|
||||
{ 12, 14 }, { 86, 14 }, { 6, 1 }, { 7, 18 }, { 97, 18 },
|
||||
{ 9, 20 }, { 10, 20 }, { 47, 20 }, { 87, 20 }, { 11, 19 },
|
||||
{ 14, 19 }, { 15, 16 }, { 16, 16 }, { 19, 16 }, { 96, 16 },
|
||||
{ 21, 2 }, { 22, 48 }, { 25, 11 }, { 26, 11 }, { 27, 33 },
|
||||
{ 30, 33 }, { 54, 33 }, { 63, 33 }, { 28, 47 }, { 29, 47 },
|
||||
{ 31, 9 }, { 35, 9 }, { 32, 38 }, { 40, 38 }, { 71, 38 },
|
||||
{ 89, 38 }, { 92, 38 }, { 33, 35 }, { 37, 8 }, { 39, 9 },
|
||||
{ 42, 41 }, { 45, 44 }, { 46, 21 }, { 50, 21 }, { 73, 21 },
|
||||
{ 74, 21 }, { 48, 22 }, { 49, 3 }, { 51, 27 }, { 52, 27 },
|
||||
{ 53, 26 }, { 55, 23 }, { 57, 23 }, { 56, 52 }, { 62, 25 },
|
||||
{ 64, 51 }, { 66, 34 }, { 68, 34 }, { 67, 28 }, { 69, 28 },
|
||||
{ 70, 28 }, { 75, 28 }, { 72, 31 }, { 76, 46 }, { 79, 6 },
|
||||
{ 80, 29 }, { 81, 45 }, { 82, 50 }, { 84, 24 }, { 85, 32 },
|
||||
{ 91, 36 }, { 94, 40 }, { 95, 40 }, { 98, 4 }, { 255, 5 },
|
||||
{ 256, 10 }, { 257, 52 }, { 258, 53 }, { 259, 54 }, { 260, 24 },
|
||||
{ -1, -1 }
|
||||
};
|
||||
|
||||
void Sound::playRoomMusic(int16 roomNum) {
|
||||
int16 musicIndex = -1;
|
||||
if (!musicEnabled())
|
||||
return;
|
||||
|
||||
for (const RoomMusic *cur = roomMusic; cur->room >= 0; ++cur) {
|
||||
if (cur->room == roomNum) {
|
||||
musicIndex = cur->music;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Extra checks for two flags in room 56
|
||||
//if ((spieler.flags32 & SpielerFlags32_10) != 0 && spieler.flags33 >= 0)
|
||||
// musicIndex = 52;
|
||||
//else
|
||||
// musicIndex = 7;
|
||||
|
||||
if (musicIndex != _curMusic) {
|
||||
stopMusic();
|
||||
if (musicIndex >= 0)
|
||||
playMusic(musicIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Chewy
|
||||
|
@ -54,13 +54,14 @@ public:
|
||||
void setSoundChannelVolume(uint channel, uint volume);
|
||||
void setSoundChannelBalance(uint channel, int8 balance);
|
||||
|
||||
void playMusic(int num, bool loop = false);
|
||||
void playMusic(uint8 *data, uint32 size, bool loop = false, DisposeAfterUse::Flag dispose = DisposeAfterUse::YES);
|
||||
void playMusic(int16 num, bool loop = false);
|
||||
void playMusic(uint8 *data, uint32 size);
|
||||
void pauseMusic();
|
||||
void resumeMusic();
|
||||
void stopMusic();
|
||||
bool isMusicActive();
|
||||
void setMusicVolume(uint volume);
|
||||
void playRoomMusic(int16 roomNum);
|
||||
|
||||
void playSpeech(int num, bool waitForFinish);
|
||||
void pauseSpeech();
|
||||
@ -93,6 +94,7 @@ private:
|
||||
Audio::SoundHandle _soundHandle[MAX_SOUND_EFFECTS];
|
||||
Audio::SoundHandle _musicHandle;
|
||||
Audio::SoundHandle _speechHandle;
|
||||
int16 _curMusic = -1;
|
||||
|
||||
SoundResource *_speechRes;
|
||||
SoundResource *_soundRes;
|
||||
|
@ -213,7 +213,7 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() {
|
||||
break;
|
||||
case kChunkPlayMusic:
|
||||
// Used in videos 0, 18, 34, 71
|
||||
_sound->playMusic(_musicData, _musicSize, false, DisposeAfterUse::NO);
|
||||
_sound->playMusic(_musicData, _musicSize);
|
||||
break;
|
||||
case kChunkPlaySeq:
|
||||
error("Unused chunk kChunkPlaySeq found");
|
||||
|
@ -40,7 +40,6 @@ bool VideoPlayer::playVideo(uint num, bool stopMusic) {
|
||||
|
||||
if (stopMusic) {
|
||||
g_engine->_sound->stopMusic();
|
||||
_G(currentSong) = -1;
|
||||
}
|
||||
|
||||
if (!cfoDecoder->loadStream(videoStream)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user