diff -ur ScummVM+orig/scummvm/sky/sound.cpp ScummVM+hack/scummvm/sky/sound.cpp
old
|
new
|
|
33 | 33 | #pragma START_PACK_STRUCTS |
34 | 34 | #endif |
35 | 35 | |
| 36 | enum { |
| 37 | SOUND_CH0 = 0, |
| 38 | SOUND_CH1 = 1, |
| 39 | SOUND_BG = 2, |
| 40 | SOUND_VOICE = 3, |
| 41 | SOUND_SPEECH = 4 |
| 42 | }; |
| 43 | |
36 | 44 | struct RoomList { |
37 | 45 | uint8 room; |
38 | 46 | uint8 adlibVolume; |
… |
… |
|
1021 | 1029 | _bgSoundHandle = 0; |
1022 | 1030 | _ingameSpeech = 0; |
1023 | 1031 | _ingameSound0 = _ingameSound1 = 0; |
1024 | | _spSlot = _slot0 = _slot1 = -1; |
1025 | 1032 | _saveSounds[0] = _saveSounds[1] = 0xFFFF; |
1026 | 1033 | } |
1027 | 1034 | |
… |
… |
|
1033 | 1040 | |
1034 | 1041 | int SkySound::playVoice(byte *sound, uint32 size) { |
1035 | 1042 | |
1036 | | return playSound(sound, size, &_voiceHandle); |
| 1043 | _mixer->stopID(SOUND_VOICE); |
| 1044 | return playSound(SOUND_VOICE, sound, size, &_voiceHandle); |
1037 | 1045 | } |
1038 | 1046 | |
1039 | 1047 | |
1040 | 1048 | int SkySound::playBgSound(byte *sound, uint32 size) { |
1041 | 1049 | |
1042 | 1050 | size -= 512; //Hack to get rid of the annoying pop at the end of some bg sounds |
1043 | | return playSound(sound, size, &_bgSoundHandle); |
| 1051 | _mixer->stopID(SOUND_BG); |
| 1052 | return playSound(SOUND_BG, sound, size, &_bgSoundHandle); |
1044 | 1053 | } |
1045 | 1054 | |
1046 | | int SkySound::playSound(byte *sound, uint32 size, PlayingSoundHandle *handle) { |
| 1055 | int SkySound::playSound(uint32 id, byte *sound, uint32 size, PlayingSoundHandle *handle) { |
1047 | 1056 | |
1048 | 1057 | byte flags = 0; |
1049 | 1058 | flags |= SoundMixer::FLAG_UNSIGNED|SoundMixer::FLAG_AUTOFREE; |
1050 | 1059 | size -= sizeof(struct dataFileHeader); |
1051 | 1060 | byte *buffer = (byte *)malloc(size); |
1052 | 1061 | memcpy(buffer, sound+sizeof(struct dataFileHeader), size); |
1053 | | |
1054 | | return _mixer->playRaw(handle, buffer, size, 11025, flags); |
| 1062 | |
| 1063 | _mixer->stopID(id); |
| 1064 | return _mixer->playRaw(handle, buffer, size, 11025, flags, id); |
1055 | 1065 | } |
1056 | 1066 | |
1057 | 1067 | void SkySound::loadSection(uint8 pSection) { |
… |
… |
|
1074 | 1084 | |
1075 | 1085 | void SkySound::playSound(uint16 sound, uint16 volume, uint8 channel) { |
1076 | 1086 | |
1077 | | if (channel == 0) { |
1078 | | if ((_slot0 >= 0) && ((_slot0 != _spSlot) || (!_ingameSpeech))) { |
1079 | | _mixer->stop(_slot0); |
1080 | | _slot0 = -1; |
1081 | | } |
1082 | | } else { |
1083 | | if ((_slot1 >= 0) && ((_slot1 != _spSlot) || (!_ingameSpeech))){ |
1084 | | _mixer->stop(_slot1); |
1085 | | _slot1 = -1; |
1086 | | } |
1087 | | } |
| 1087 | if (channel == 0) |
| 1088 | _mixer->stopID(SOUND_CH0); |
| 1089 | else |
| 1090 | _mixer->stopID(SOUND_CH1); |
1088 | 1091 | |
1089 | 1092 | if (!_soundData) { |
1090 | 1093 | warning("SkySound::playSound(%04X, %04X) called with a section having been loaded.\n", sound, volume); |
… |
… |
|
1113 | 1116 | |
1114 | 1117 | _mixer->setVolume(volume); |
1115 | 1118 | if (channel == 0) |
1116 | | _slot0 = _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags); |
| 1119 | _mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH0); |
1117 | 1120 | else |
1118 | | _slot1 = _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags); |
| 1121 | _mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH1); |
1119 | 1122 | } |
1120 | 1123 | |
1121 | 1124 | void SkySound::fnStartFx(uint32 sound, uint8 channel) { |
… |
… |
|
1205 | 1208 | } |
1206 | 1209 | |
1207 | 1210 | void SkySound::fnStopFx(void) { |
1208 | | if (_slot0 >= 0) _mixer->stop(_slot0); |
1209 | | if (_slot1 >= 0) _mixer->stop(_slot1); |
1210 | | _slot0 = _slot1 = -1; |
| 1211 | _mixer->stopID(SOUND_CH0); |
| 1212 | _mixer->stopID(SOUND_CH1); |
1211 | 1213 | _saveSounds[0] = _saveSounds[1] = 0xFFFF; |
1212 | 1214 | } |
1213 | 1215 | |
… |
… |
|
1229 | 1231 | |
1230 | 1232 | free(speechData); |
1231 | 1233 | |
1232 | | _spSlot = _mixer->playRaw(&_ingameSpeech, playBuffer, speechSize, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); |
| 1234 | _mixer->stopID(SOUND_SPEECH); |
| 1235 | _mixer->playRaw(&_ingameSpeech, playBuffer, speechSize, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); |
1233 | 1236 | return true; |
1234 | 1237 | } |
diff -ur ScummVM+orig/scummvm/sky/sound.h ScummVM+hack/scummvm/sky/sound.h
old
|
new
|
|
47 | 47 | |
48 | 48 | protected: |
49 | 49 | |
50 | | int playSound(byte *sound, uint32 size, PlayingSoundHandle *handle); |
| 50 | int playSound(uint32 id, byte *sound, uint32 size, PlayingSoundHandle *handle); |
51 | 51 | |
52 | 52 | public: |
53 | 53 | SkySound(SoundMixer *mixer, SkyDisk *pDisk); |
… |
… |
|
72 | 72 | uint16 _sfxBaseOfs; |
73 | 73 | uint8 *_soundData; |
74 | 74 | uint8 *_sampleRates, *_sfxInfo; |
75 | | int _slot0, _slot1, _spSlot; |
76 | 75 | |
77 | 76 | static uint16 _speechConvertTable[8]; |
78 | 77 | static SfxQueue _sfxQueue[MAX_QUEUED_FX]; |