diff --git a/CMakeLists.txt b/CMakeLists.txt
index c392ed1def..51d08c54c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -81,5 +81,5 @@ set_target_properties(${PROJECT} PROPERTIES PREFIX "")
TARGET_LINK_LIBRARIES(${PROJECT} ${SDL2_LIBRARIES} ${ORCTLIBS_LIB})
if (WIN32)
- target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion -ldsound ws2_32)
+ target_link_libraries(${PROJECT} winmm.lib -limm32 -lversion ws2_32)
endif (WIN32)
diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj
index 491574e929..68fe45712f 100644
--- a/projects/openrct2.vcxproj
+++ b/projects/openrct2.vcxproj
@@ -363,7 +363,7 @@
Disabled
true
1Byte
- _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)
MultiThreaded
true
$(IntDir)fake\%(RelativeDir)
@@ -372,7 +372,7 @@
true
- winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)
+ winmm.lib;sdl2.lib;%(AdditionalDependencies)
"$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\"
diff --git a/src/audio/audio.c b/src/audio/audio.c
index a919d9b241..dfc3b0e598 100644
--- a/src/audio/audio.c
+++ b/src/audio/audio.c
@@ -18,10 +18,6 @@
* along with this program. If not, see .
*****************************************************************************/
-#ifdef _WIN32
-#include
-#endif // _WIN32
-
#include "../addresses.h"
#include "../config.h"
#include "../interface/viewport.h"
@@ -35,38 +31,6 @@
#include "mixer.h"
#include "../openrct2.h"
-typedef struct {
- uint32 playing; // 0x000
- uint32 var_4;
- char filename[MAX_PATH]; // 0x008
- uint32 var_10C;
- uint32 var_110;
- uint32 var_114;
- uint32 var_118;
-#ifdef _WIN32
- HGLOBAL hmem; // 0x11C
- HMMIO hmmio; // 0x120
- MMCKINFO mmckinfo1; // 0x124
- MMCKINFO mmckinfo2; // 0x138
- LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C
-#endif // _WIN32
- uint32 bufsize; // 0x150
- uint32 playpos; // 0x154
- uint32 var_158;
- uint32 var_15C;
- uint32 stopped; // 0x160
- uint32 var_164;
- uint32 var_168;
-} rct_sound_channel;
-
-struct rct_sound_effect {
- uint32 size;
-#ifdef _WIN32
- WAVEFORMATEX format;
-#endif // _WIN32
- uint8* data;
-};
-
int gAudioDeviceCount;
audio_device *gAudioDevices = NULL;
rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS];
@@ -79,22 +43,6 @@ void *gCrowdSoundChannel = 0;
void *gTitleMusicChannel = 0;
bool gGameSoundsOff = false;
-#ifdef _WIN32
-void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel);
-int sound_effect_loadvars(struct rct_sound_effect* sound_effect, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize);
-MMRESULT mmio_open(const char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO mmckinfo);
-MMRESULT mmio_read(HMMIO hmmio, uint32 size, char* buffer, LPMMCKINFO mmckinfo, int* read);
-MMRESULT mmio_seek(HMMIO* hmmio, LPMMCKINFO mmckinfo1, LPMMCKINFO mmckinfo2, int offset);
-int mmio_open_channel(int channel, char* filename, LONG offset);
-BOOL CALLBACK dsound_enum_callback_count(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext);
-BOOL CALLBACK dsound_enum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext);
-int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
-int sound_fill_buffer(LPDIRECTSOUNDBUFFER dsbuffer, char* src, DWORD size);
-void sound_channel_free(HMMIO* hmmio, HGLOBAL* hmem);
-LPVOID map_file(LPCWSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap);
-int unmap_file(LPCVOID base);
-#endif // _WIN32
-
void audio_init(int i)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
@@ -134,1452 +82,6 @@ void audio_get_devices()
}
}
-#ifdef _WIN32
-/**
-*
-* rct2: 0x00401000
-*/
-void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel)
-{
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
- DWORD status;
- DWORD dwCurrentPlayCursor;
- DWORD dwCurrentWriteCursor;
- uint32 var1;
- int var2;
- int bufferlost = 0;
- char* buf1;
- int buf1size;
- char* buf2;
- int buf2size;
- sound_channel->dsbuffer->lpVtbl->GetStatus(sound_channel->dsbuffer, &status);
- if (status & DSBSTATUS_BUFFERLOST) {
- if (FAILED(sound_channel->dsbuffer->lpVtbl->Restore(sound_channel->dsbuffer))) {
- return;
- }
- sound_channel->playpos = 0;
- bufferlost = 1;
- }
- sound_channel->dsbuffer->lpVtbl->GetCurrentPosition(sound_channel->dsbuffer, &dwCurrentPlayCursor, &dwCurrentWriteCursor);
- if (dwCurrentPlayCursor != sound_channel->playpos || bufferlost) {
- if (sound_channel->var_168 && !sound_channel->var_15C) {
- if (!sound_channel->stopped) {
- sound_channel->stopped = 1;
- if (!sound_channel->var_4) {
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- sound_channel->playing = 0;
- if (dsbuffer) {
- dsbuffer->lpVtbl->Stop(dsbuffer);
- dsbuffer->lpVtbl->Release(dsbuffer);
- RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel] = 0;
- }
- if (sound_channel->hmmio) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- }
- }
- }
- return;
- }
- if (dwCurrentPlayCursor >= sound_channel->playpos) {
- var1 = dwCurrentPlayCursor - sound_channel->playpos;
- } else {
- var1 = dwCurrentPlayCursor + sound_channel->bufsize - sound_channel->playpos;
- }
- if (bufferlost) {
- var2 = 2 * sound_channel->bufsize / 6;
- } else {
- var2 = var1;
- }
- sound_channel->var_158 += var1;
- if (sound_channel->var_168) {
- uint32 var3 = sound_channel->var_15C;
- uint32* var4 = &sound_channel->var_15C;
- if (var3) {
- if (var1 <= var3) {
- *var4 = var3 - var1;
- } else {
- *var4 = 0;
- }
- if (SUCCEEDED(sound_channel->dsbuffer->lpVtbl->Lock(sound_channel->dsbuffer, sound_channel->playpos, var2, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0))) {
- uint16 var5 = -(sound_channel->mmckinfo1.cksize != 8);
- var5 &= 0x80;
- memset(buf1, var5 + 128, buf1size);
- if (buf2 && buf2size) {
- uint16 var5 = -(sound_channel->mmckinfo1.cksize != 8);
- var5 &= 0x80;
- memset(buf2, var5 + 128, buf2size);
- }
- sound_channel->dsbuffer->lpVtbl->Unlock(sound_channel->dsbuffer, buf1, buf1size, buf2, buf2size);
- sound_channel->playpos += var2;
- if (sound_channel->playpos >= sound_channel->bufsize) {
- sound_channel->playpos = sound_channel->playpos - sound_channel->bufsize;
- }
- return;
- }
- // TimeFunc() could not lock DirectSoundBuffer
- return;
- }
- }
- if (FAILED(sound_channel->dsbuffer->lpVtbl->Lock(sound_channel->dsbuffer, sound_channel->playpos, var2, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0))) {
- // TimeFunc() could not lock DirectSoundBuffer
- return;
- }
- if (buf1size) {
- if (sound_channel->stopped) {
- uint16 var5 = -(sound_channel->mmckinfo1.cksize != 8);
- var5 &= 0x80;
- memset(buf1, var5 + 128, buf1size);
- goto label49;
- }
- }
- int var7;
- mmio_read(sound_channel->hmmio, buf1size, buf1, &sound_channel->mmckinfo1, &var7);
- if (var7 < buf1size) {
- if (!sound_channel->var_164) {
- int s = sound_channel->mmckinfo1.cksize;
- int t = buf1size - var7;
- int v;
- if (s == 8) {
- v = 128;
- } else {
- if (s != 16) {
- goto label42;
- }
- v = 0;
- }
- memset(&buf1[var7], v, t);
- label42:
- sound_channel->var_168 = 1;
- if (dwCurrentPlayCursor <= sound_channel->playpos) {
- sound_channel->var_15C = sound_channel->playpos - dwCurrentPlayCursor;
- } else {
- sound_channel->var_15C = sound_channel->playpos + sound_channel->bufsize - dwCurrentPlayCursor;
- }
- goto label49;
- }
- char* v21 = buf1;
- int v38 = buf1size;
- do {
- v38 -= var7;
- v21 += var7;
- sub_40153B(channel);
- mmio_read(sound_channel->hmmio, v38, v21, &sound_channel->mmckinfo1, &var7);
- } while(var7 < v38);
- }
- label49:
- if (buf2size == 0 || sound_channel->stopped != 0) {
- if(buf2 != 0 && buf2size != 0 && sound_channel->stopped != 0) {
- int var5 = -(sound_channel->mmckinfo1.cksize != 8);
- var5 &= 0x80;
- memset(buf2, var5 + 128, buf2size);
- }
- goto label68;
- }
- mmio_read(sound_channel->hmmio, buf2size, buf2, &sound_channel->mmckinfo1, &var7);
- if (var7 >= buf2size) {
- label68:
- sound_channel->dsbuffer->lpVtbl->Unlock(sound_channel->dsbuffer, buf1, buf1size, buf2, buf2size);
- sound_channel->playpos += var2;
- if (sound_channel->playpos >= sound_channel->bufsize) {
- sound_channel->playpos -= sound_channel->bufsize;
- }
- if (bufferlost != 0) {
- sound_channel->dsbuffer->lpVtbl->Play(sound_channel->dsbuffer, 0, 0, DSBPLAY_LOOPING);
- }
- return;
- }
- if (sound_channel->var_164 != 0) {
- char* v26 = buf2;
- int v27 = buf2size;
- do {
- v26 += var7;
- v27 -= var7;
- sub_40153B(channel);
- mmio_read(sound_channel->hmmio, v27, v26, &sound_channel->mmckinfo1, &var7);
- } while(var7 < v27);
- goto label68;
- }
- int s = buf2size - var7;
- int v;
- if (sound_channel->hmem == (HGLOBAL)8) {
- v = 128;
- } else {
- if (sound_channel->hmem != (HGLOBAL)16) {
- goto label58;
- }
- v = 0;
- }
- memset(&buf2[var7], v, s);
- label58:
- sound_channel->var_168 = 1;
- if (dwCurrentPlayCursor <= sound_channel->playpos) {
- sound_channel->var_15C = sound_channel->playpos - dwCurrentPlayCursor;
- } else {
- sound_channel->var_15C = sound_channel->playpos + sound_channel->bufsize - dwCurrentPlayCursor;
- }
- goto label68;
- }
-}
-
-/**
-*
-* rct2: 0x004014DF
-*/
-int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
-{
- if (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) == 0) {
- for (int i = 0; i < 4; i++) {
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[i];
- if(sound_channel->playing){
- audio_timefunc(uTimerID, uMsg, dwUser, dw1, dw2, i);
- }
- }
- return _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0);
- }
- return 0;
-}
-#endif // _WIN32
-
-/**
-*
-* rct2: 0x0040153B
-*/
-int sub_40153B(int channel)
-{
-#ifdef _WIN32
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
- if (sound_channel->var_4) {
- if (sound_channel->hmmio) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- }
- if (mmio_open_channel(channel, sound_channel->filename, sound_channel->var_110)) {
- return 0;
- }
- sound_channel->var_164 = sound_channel->var_114;
- sound_channel->var_118 = sound_channel->var_110;
- sound_channel->var_4 = 0;
- } else {
- int result = mmio_seek(&sound_channel->hmmio, &sound_channel->mmckinfo1, &sound_channel->mmckinfo2, sound_channel->var_118);
- sound_channel->var_158 = sound_channel->var_118;
- if (result) {
- return 0;
- }
- }
-#else
- STUB();
-#endif // _WIN32
- return 1;
-}
-
-/**
-*
-* rct2: 0x004015E7
-*/
-int sub_4015E7(int channel)
-{
- char* buf1;
- int buf1size;
- char* buf2;
- int buf2size;
- int read;
- int zero = 0;
-#ifdef _WIN32
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- int result = dsbuffer->lpVtbl->Lock(dsbuffer, 0, sound_channel->bufsize, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0);
- if (SUCCEEDED(result)) {
- if (buf1size) {
- mmio_read(sound_channel->hmmio, buf1size, buf1, &sound_channel->mmckinfo1, &read);
- int r = read;
- if (read < buf1size) {
- if (sound_channel->var_164) {
- char* b = buf1;
- int d = buf1size;
- do {
- d -= r;
- b += r;
- sub_40153B(channel);
- mmio_read(sound_channel->hmmio, d, b, &sound_channel->mmckinfo1, &read);
- r = read;
- } while(read < d);
- } else {
- sound_channel->var_168 = 1;
- sound_channel->var_15C = read;
- LPWAVEFORMATEX waveformat = sound_channel->hmem;
- uint16 v = ((waveformat->nBlockAlign != 8) - 1) & 0x80;
- memset(&buf1[read], v, buf1size - r);
- }
- }
- }
- result = dsbuffer->lpVtbl->Unlock(dsbuffer, buf1, buf1size, buf2, zero);
- sound_channel->var_158 = 0;
- sound_channel->playpos = 0;
- }
- return result;
-#else
- STUB();
- return 0;
-#endif // _WIN32
-}
-
-/**
-*
-* rct2: 0x004016FF
-*/
-int sound_channel_load_file(int channel, const char* filename, int offset)
-{
-#ifdef _WIN32
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
- sound_channel->hmem;
- sound_channel->hmmio;
- if (mmio_open(filename, &sound_channel->hmmio, &sound_channel->hmem, &sound_channel->mmckinfo2)) {
- return -100;
- }
- if (*(uint16*)sound_channel->hmem != 1) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- return -101;
- }
- if (mmio_seek(&sound_channel->hmmio, &sound_channel->mmckinfo1, &sound_channel->mmckinfo2, offset)) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- return -103;
- }
- sound_channel->bufsize = 120 * *((uint32*)sound_channel->hmem + 2) / 100;
- DSBUFFERDESC bufferdesc;
- memset(&bufferdesc, 0, sizeof(bufferdesc));
- bufferdesc.dwFlags = RCT2_GLOBAL(0x009E1AA8, uint32) | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
- bufferdesc.dwBufferBytes = sound_channel->bufsize;
- bufferdesc.lpwfxFormat = sound_channel->hmem;
- bufferdesc.dwSize = sizeof(bufferdesc);
- int ret = RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel], 0);
- if (FAILED(ret)) {
- return -102;
- }
- sound_channel->dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- sound_channel->var_168 = 0;
- sound_channel->var_15C = 0;
- sound_channel->var_164 = 1;
- sub_4015E7(channel);
- sound_channel->var_158 = offset;
- sound_channel->stopped = 0;
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-#ifdef _WIN32
-/**
-*
-* rct2: 0x00401822
-*/
-int mmio_open_channel(int channel, char* filename, LONG offset)
-{
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
- LPMMCKINFO v4 = &sound_channel->mmckinfo2;
- HMMIO* v5 = &sound_channel->hmmio;
- if (mmio_open(filename, &sound_channel->hmmio, &sound_channel->hmem, &sound_channel->mmckinfo2)) {
- return -100;
- }
- if (*(uint16*)sound_channel->hmem != 1) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- return -101;
- }
- if (mmio_seek(&sound_channel->hmmio, &sound_channel->mmckinfo1, &sound_channel->mmckinfo2, offset)) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- return -103;
- }
- sound_channel->var_158 = offset;
- return 0;
-}
-#endif // _WIN32
-
-/**
-*
-* rct2: 0x004018A6
-*/
-int audio_create_timer()
-{
-#ifdef _WIN32
- if (RCT2_GLOBAL(0x009E1AA4, int)) {
- return 0;
- }
- for (int i = 0; i < 4; i++) {
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[i];
- sound_channel->playing = 0;
- }
- RCT2_GLOBAL(0x009E1AA0, MMRESULT) = timeSetEvent(50, 10, (LPTIMECALLBACK)audio_timer_callback, 0, TIME_PERIODIC);
- if (!RCT2_GLOBAL(0x009E1AA0, MMRESULT)) {
- return 0;
- }
-#else
- STUB();
-#endif // _WIN32
- RCT2_GLOBAL(0x009E1AA4, int) = 1;
- return 1;
-}
-
-/**
-*
-* rct2: 0x004018F0
-*/
-int audio_remove_timer()
-{
- for (int i = 0; i < 4; i++) {
- sound_channel_stop(i);
- }
-#ifdef _WIN32
- if (RCT2_GLOBAL(0x009E1AA4, int)) {
- timeKillEvent(RCT2_GLOBAL(0x009E1AA0, MMRESULT));
- timeEndPeriod(50);
- while (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) != 1) {
- Sleep(100);
- }
- int result = _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0);
- RCT2_GLOBAL(0x009E1AA4, int) = 0;
- return result;
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x0040194E
-*/
-int sound_channel_load_file2(int channel, const char* filename, int offset)
-{
- if (!RCT2_GLOBAL(0x009E1AA4, int)) {
- return 0;
- }
- if (sound_channel_is_playing(channel)) {
- sound_channel_stop(channel);
- }
- int load_result = sound_channel_load_file(channel, filename, offset);
- if (load_result >= 0) {
- RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel].var_4 = 0;
- return 1;
- }
- return 0;
-}
-
-/**
-*
-* rct2: 0x00401999
-*/
-int sound_channel_play(int channel, int a2, int volume, int pan, int frequency)
-{
-#ifdef _WIN32
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel];
- sound_channel->var_164 = a2;
- sound_channel_set_frequency(channel, frequency);
- sound_channel_set_pan(channel, pan);
- sound_channel_set_volume(channel, volume);
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- dsbuffer->lpVtbl->SetCurrentPosition(dsbuffer, 0);
- dsbuffer->lpVtbl->Play(dsbuffer, 0, 0, DSBPLAY_LOOPING);
- sound_channel->playing = 1;
-#else
- STUB();
-#endif // _WIN32
- return 1;
-}
-
-/**
-*
-* rct2: 0x00401A05
-*/
-int sound_channel_stop(int channel)
-{
-#ifdef _WIN32
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel];
- sound_channel->playing = 0;
- sound_channel->stopped = 1;
- while (_InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 1) != 1) {
- Sleep(10);
- }
- if (sound_channel->hmmio) {
- sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
- }
-
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- if (dsbuffer) {
- dsbuffer->lpVtbl->Stop(dsbuffer);
- dsbuffer->lpVtbl->Release(dsbuffer);
- RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel] = 0;
- }
- _InterlockedExchange(&RCT2_GLOBAL(0x009E1AAC, LONG), 0);
-#else
- STUB();
-#endif // _WIN32
- return 1;
-}
-
-/**
-*
-* rct2: 0x00401A93
-*/
-int sound_channel_set_frequency(int channel, int frequency)
-{
-#ifdef _WIN32
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- if (dsbuffer) {
- if (SUCCEEDED(dsbuffer->lpVtbl->SetFrequency(dsbuffer, frequency)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00401AB3
-*/
-int sound_channel_set_pan(int channel, int pan)
-{
-#ifdef _WIN32
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- if (dsbuffer) {
- if (SUCCEEDED(dsbuffer->lpVtbl->SetPan(dsbuffer, pan)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00401AD3
-*/
-int sound_channel_set_volume(int channel, int volume)
-{
-#ifdef _WIN32
- LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
- if (dsbuffer) {
- if (SUCCEEDED(dsbuffer->lpVtbl->SetVolume(dsbuffer, volume)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00401AF3
-*/
-void sub_401AF3(int channel, const char* filename, int a3, int a4)
-{
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel];
- sound_channel->var_4 = 1;
- memcpy(sound_channel->filename, filename, sizeof(sound_channel->filename));
- sound_channel->var_10C = 0;
- sound_channel->var_110 = a4;
- sound_channel->var_114 = a3;
- sound_channel->var_164 = 1;
-}
-
-/**
-*
-* rct2: 0x00401B46
-*/
-int sub_401B46(int channel)
-{
- rct_sound_channel* sound_channel = &RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel];
- if (sound_channel->stopped) {
- return 0;
- } else {
- return sound_channel->var_158;
- }
-}
-
-/**
-*
-* rct2: 0x00401B63
-*/
-int sound_channel_is_playing(int channel)
-{
- if (RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel].playing) {
- return RCT2_ADDRESS(RCT2_ADDRESS_SOUND_CHANNEL_LIST, rct_sound_channel)[channel].stopped == 0;
- } else {
- return 0;
- }
-}
-
-/**
-*
-* rct2: 0x00404BD2
-*/
-int audio_release()
-{
- sound_stop_all();
-#ifdef _WIN32
- if (RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)) {
- RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER));
- RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER) = 0;
- }
- if (RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)) {
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
- }
- int result = 0;
- if (RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)) {
- result = RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
- }
- return result;
-#else
- STUB();
- return 0;
-#endif // _WIN32
-}
-
-/**
-*
-* rct2: 0x00404C1A
-*/
-int map_sound_effects(const char* filename)
-{
-#ifdef _WIN32
- if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID)) {
- return 0;
- } else {
- wchar_t *wcFilename = utf8_to_widechar(filename);
- RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) = map_file(wcFilename, 0, 0);
- free(wcFilename);
- return RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) != 0;
- }
-#else
- STUB();
- return 0;
-#endif // _WIN32
-}
-
-/**
-*
-* rct2: 0x00404C45
-*/
-int unmap_sound_effects()
-{
-#ifdef _WIN32
- if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID)) {
- sound_stop_all();
- unmap_file(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID));
- RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) = 0;
- return 1;
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404C6D
-*/
-int sound_prepare(int sound_id, rct_sound *sound, int channels, int software)
-{
-#ifdef _WIN32
- DSBUFFERDESC bufferdesc;
- char* buffer = 0;
- memset(&bufferdesc, 0, sizeof(bufferdesc));
- bufferdesc.dwSize = sizeof(bufferdesc);
- rct_sound* tempsound = sound_begin();
- if (tempsound) {
- int wasduplicated = 0;
- while (!tempsound->dsbuffer || tempsound->id != sound_id || !sound_duplicate(sound, tempsound)) {
- tempsound = sound_next(tempsound);
- if (!tempsound) {
- wasduplicated = 1;
- break;
- }
- }
- if (!wasduplicated) {
- return 1;
- }
- }
- struct rct_sound_effect* sound_effect = sound_get_effect(sound_id);
- if (sound_effect) {
- if (sound_effect_loadvars(sound_effect, &bufferdesc.lpwfxFormat, &buffer, &bufferdesc.dwBufferBytes)) {
- if (channels == 0){
- bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC;
- }
- else if (channels == 2) {
- bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D | DSBCAPS_STATIC;
- } else {
- bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | DSBCAPS_STATIC;
- }
- if (RCT2_GLOBAL(0x009E2B90, uint32)) {
- bufferdesc.dwFlags |= DSBCAPS_CTRLPAN;
- }
- if (software) {
- bufferdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
- }
- if (SUCCEEDED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &sound->dsbuffer, 0))) {
- if (sound_fill_buffer(sound->dsbuffer, buffer, bufferdesc.dwBufferBytes)) {
- sound->id = sound_id;
- DSBCAPS caps;
- caps.dwSize = sizeof(caps);
- sound->dsbuffer->lpVtbl->GetCaps(sound->dsbuffer, &caps);
- sound->has_caps = caps.dwFlags;
- sound_add(sound);
- return 1;
- }
- sound->dsbuffer->lpVtbl->Release(sound->dsbuffer);
- sound->dsbuffer = 0;
- }
- sound->dsbuffer = 0;
- }
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404D99
-*/
-int sound_duplicate(rct_sound* newsound, rct_sound* sound)
-{
-#ifdef _WIN32
- if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->DuplicateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), sound->dsbuffer, &newsound->dsbuffer))) {
- return 0;
- } else {
- newsound->id = sound->id;
- newsound->has_caps = sound->has_caps;
- newsound->var_0C = sound->var_0C;
- sound_add(newsound);
- return 1;
- }
-#else
- STUB();
- return 1;
-#endif // _WIN32
-}
-
-/**
-*
-* rct2: 0x00404DD8
-*/
-int sound_stop(rct_sound* sound)
-{
-#ifdef _WIN32
- if (sound->dsbuffer) {
- sound->dsbuffer->lpVtbl->Release(sound->dsbuffer);
- sound->dsbuffer = 0;
- return sound_remove(sound) ? 1 : 0;
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404DF5
-*/
-int sound_stop_all()
-{
- int result = 0;
- while (RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)) {
- result = sound_stop(RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*));
- }
- return result;
-}
-
-/**
-*
-* rct2: 0x00404E0D
-*/
-void sound_bufferlost_check()
-{
-#ifdef _WIN32
- rct_sound* sound = RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*);
- while (sound && sound != RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)) {
- DWORD status;
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->GetStatus(sound->dsbuffer, &status))) {
- if (status & DSBSTATUS_BUFFERLOST) {
- sound_bufferlost_restore(sound);
- }
- }
- sound = sound->next;
- }
-#else
- STUB();
-#endif // _WIN32
-}
-
-/**
-*
-* rct2: 0x00404E53
-*/
-int sound_is_playing(rct_sound* sound){
-#ifdef _WIN32
- if (sound->dsbuffer) {
- DWORD status;
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->GetStatus(sound->dsbuffer, &status))) {
- if (status & DSBSTATUS_PLAYING || status & DSBSTATUS_LOOPING)
- return 1;
-
- }
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404E7F
-*/
-int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency)
-{
-#ifdef _WIN32
- if (sound->dsbuffer) {
- sound_set_frequency(sound, frequency);
- sound_set_pan(sound, pan);
- sound_set_volume(sound, volume);
- DWORD playflags;
- if (looping) {
- if (looping != 1)
- return 1;
-
- playflags = DSBPLAY_LOOPING;
- } else {
- playflags = 0;
- }
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->Play(sound->dsbuffer, 0, 0, playflags)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404ED7
-*/
-int sound_set_frequency(rct_sound* sound, int frequency)
-{
-#ifdef _WIN32
- if (sound->dsbuffer) {
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetFrequency(sound->dsbuffer, frequency)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404EF2
-*/
-int sound_set_pan(rct_sound* sound, int pan)
-{
-#ifdef _WIN32
- if (sound->dsbuffer) {
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetPan(sound->dsbuffer, pan)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404F0D
-*/
-int sound_set_volume(rct_sound* sound, int volume)
-{
-#ifdef _WIN32
- if (sound->dsbuffer) {
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->SetVolume(sound->dsbuffer, volume)))
- return 1;
-
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x000404F28
-*/
-int sound_load3dparameters()
-{
-#ifdef _WIN32
- if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->GetAllParameters(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), &RCT2_GLOBAL(0x009A6084, DS3DBUFFER)))) {
- return 1;
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404F3F
-*/
-int sound_load3dposition()
-{
- /*if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->GetPosition(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), &RCT2_GLOBAL(0x009A6084, D3DVECTOR), 1))) {
- return 1;
- }*/
- return 0;
-}
-
-#ifdef _WIN32
-/**
-*
-* rct2: 0x00404F85
-*/
-BOOL CALLBACK dsound_enum_callback_count(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
-{
- RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES_COUNTER, int)++;
- return 1;
-}
-
-/**
-*
-* rct2: 0x00404F91
-*/
-int dsound_count_devices()
-{
- RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES_COUNTER, int) = 0;
- if (SUCCEEDED(DirectSoundEnumerate(dsound_enum_callback_count, 0))) {
- return RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES_COUNTER, int);
- }
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404FB1
-*/
-BOOL CALLBACK dsound_enum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
-{
- if (lpGuid) {
- memcpy(&RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].guid, lpGuid, sizeof(GUID));
- } else {
- memset(&RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].guid, 0, sizeof(GUID));
- }
- strcpy(RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].desc, lpcstrDescription);
- strcpy(RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[RCT2_GLOBAL(0x01425B54, int)].drvname, lpcstrModule);
- RCT2_GLOBAL(0x01425B54, int)++;
- return 1;
-}
-
-/**
-*
-* rct2: 0x00405054
-*/
-int sound_effect_loadvars(struct rct_sound_effect* sound_effect, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize)
-{
- *buffersize = sound_effect->size;
- *waveformat = &sound_effect->format;
- *data = (char*)&sound_effect->data;
- return 1;
-}
-
-/**
-*
-* rct2: 0x00405076
-*/
-int sound_fill_buffer(LPDIRECTSOUNDBUFFER dsbuffer, char* src, DWORD size)
-{
- LPVOID buf;
- LPVOID buf2;
- DWORD buf2size;
- if (SUCCEEDED(dsbuffer->lpVtbl->Lock(dsbuffer, 0, size, &buf, &size, &buf2, &buf2size, 0))) {
- memset(buf, 0, size);
- memcpy(buf, src, size);
- if (buf2size) {
- memcpy(buf2, &src[size], buf2size);
- }
- dsbuffer->lpVtbl->Unlock(dsbuffer, buf, size, buf2, buf2size);
- return 1;
- }
- return 0;
-}
-#endif // _WIN32
-
-/**
-*
-* rct2: 0x00405103
-*/
-rct_sound* sound_begin()
-{
- return RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*);
-}
-
-/**
-*
-* rct2: 0x00405109
-*/
-rct_sound* sound_next(rct_sound* sound)
-{
- if (RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) == sound) {
- return 0;
- } else {
- return sound->next;
- }
-}
-
-/**
-*
-* rct2: 0x0040511C
-*/
-rct_sound* sound_add(rct_sound* sound)
-{
- if (RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)) {
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)->next = sound;
- } else {
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = sound;
- }
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = sound;
- sound->next = 0;
- return sound;
-}
-
-/**
-*
-* rct2: 0x00405143
-*/
-rct_sound* sound_remove(rct_sound* sound)
-{
- rct_sound* result = RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*);
- if (sound == result) {
- if (sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)) {
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = 0;
- }
- result = sound->next;
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = result;
- } else {
- while (result->next != sound)
- result = result->next;
-
- if (sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)) {
- RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = result;
- result->next = 0;
- } else
- result->next = sound->next;
-
- }
- sound->next = 0;
- return result;
-}
-
-/**
-*
-* rct2: 0x00405199
-*/
-int sound_bufferlost_restore(rct_sound* sound)
-{
-#ifdef _WIN32
- DWORD buffersize = 0;
- LPWAVEFORMATEX waveformat = 0;
- char* data = 0;
- if (sound) {
- if (SUCCEEDED(sound->dsbuffer->lpVtbl->Restore(sound->dsbuffer))) {
- struct rct_sound_effect* sound_effect = sound_get_effect(sound->id);
- if (sound_effect != 0) {
- return sound_effect_loadvars(sound_effect, &waveformat, &data, &buffersize) && sound_fill_buffer(sound->dsbuffer, data, buffersize);
- }
- }
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-/**
-*
-* rct2: 0x00405206
-*/
-struct rct_sound_effect* sound_get_effect(uint16 sound_id)
-{
-#ifdef _WIN32
- if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) && sound_id < RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[0]) {
- return (struct rct_sound_effect*)(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, int) + RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[sound_id + 1]);
- }
-#else
- STUB();
-#endif // _WIN32
- return 0;
-}
-
-#ifdef _WIN32
-/**
-*
-* rct2: 0x00405222
-*/
-MMRESULT mmio_open(const char* filename, HMMIO* hmmio, HGLOBAL* hmem, LPMMCKINFO mmckinfo)
-{
- HGLOBAL* hmemold;
- HGLOBAL hmemold2;
- HMMIO hmmio1;
- MMRESULT result;
- MMCKINFO mmckinfo1;
- WAVEFORMATEX waveformat;
-
- hmemold = hmem;
- *hmem = 0;
- hmmio1 = mmioOpenA((char*)filename, 0, MMIO_ALLOCBUF);
- if (hmmio1) {
- result = mmioDescend(hmmio1, mmckinfo, 0, 0);
- if (result != MMSYSERR_NOERROR) {
- goto label20;
- }
- if (mmckinfo->ckid != 1179011410/*RIFF*/ || mmckinfo->fccType != 1163280727/*WAVE*/) {
- result = 57601;
- goto label20;
- }
- mmckinfo1.ckid = 544501094/*fmt*/;
- result = mmioDescend(hmmio1, &mmckinfo1, mmckinfo, MMIO_FINDCHUNK);
- if (result != MMSYSERR_NOERROR) {
- goto label20;
- }
- if (mmckinfo1.cksize < 16) {
- label19:
- result = 57601;
- goto label20;
- }
- if (mmioRead(hmmio1, (HPSTR)&waveformat, 16) == 16) {
- if (waveformat.wFormatTag == 1) {
- //strcpy(audio_info.var_0, "\x01");
- hmem = 0;
- label11:
- hmemold2 = GlobalAlloc(0, (SIZE_T)(hmem + 18));
- *hmemold = hmemold2;
- if (!hmemold2) {
- result = 57344;
- goto label20;
- }
- memcpy(hmemold2, &waveformat, 16);
- *((uint16*)*hmemold + 8) = *(uint16*)*hmem;
- if (!hmem || mmioRead(hmmio1, (char*)*hmemold + 18, (LONG)hmem) == (LONG)hmem) {
- result = mmioAscend(hmmio1, &mmckinfo1, 0);
- if (!result) {
- goto label24;
- }
- goto label20;
- }
- goto label19;
- }
- if (mmioRead(hmmio1, (HPSTR)&hmem, 2) == 2) {
- goto label11;
- }
- }
- result = 57602;
- goto label20;
- }
- result = 57600;
- label20:
- if (*hmemold) {
- GlobalFree(*hmemold);
- *hmemold = 0;
- }
- if (hmmio1) {
- mmioClose(hmmio1, 0);
- hmmio1 = 0;
- }
- label24:
- *hmmio = hmmio1;
- return result;
-}
-
-/**
-*
-* rct2: 0x00405383
-*/
-MMRESULT mmio_read(HMMIO hmmio, uint32 size, char* buffer, LPMMCKINFO mmckinfo, int* read)
-{
- MMIOINFO mmioinfo;
- MMRESULT result;
- result = mmioGetInfo(hmmio, &mmioinfo, 0);
- if (result != 0) {
- *read = 0;
- return 1;
- }
- int size2 = size;
- if (size > mmckinfo->cksize) {
- size2 = mmckinfo->cksize;
- }
- int v8 = 0;
- mmckinfo->cksize -= size2;
- if (size2) {
- while (1) {
- HPSTR p = mmioinfo.pchEndRead;
- if (mmioinfo.pchNext == mmioinfo.pchEndRead) {
- result = mmioAdvance(hmmio, &mmioinfo, 0);
- if (result != 0) {
- *read = 0;
- return result;
- }
- p = mmioinfo.pchEndRead;
- if (mmioinfo.pchNext == mmioinfo.pchEndRead) {
- break;
- }
- }
- int q = p - mmioinfo.pchNext;
- if (size2 - v8 < p - mmioinfo.pchNext) {
- q = size2 - v8;
- }
- memcpy(&buffer[v8], mmioinfo.pchNext, q);
- mmioinfo.pchNext += q;
- v8 += q;
- if (v8 >= size2) {
- result = mmioSetInfo(hmmio, &mmioinfo, 0);
- if (result != 0) {
- *read = 0;
- return result;
- } else {
- *read = size2;
- return result;
- }
- }
- }
- *read = 0;
- return 57603;
- }
- result = mmioSetInfo(hmmio, &mmioinfo, 0);
- if (result != 0) {
- *read = 0;
- return result;
- } else {
- *read = size2;
- return result;
- }
-}
-
-/**
-*
-* rct2: 0x00405436
-*/
-void sound_channel_free(HMMIO* hmmio, HGLOBAL* hmem)
-{
- if(*hmem)
- {
- GlobalFree(*hmem);
- *hmem = 0;
- }
- if(*hmmio)
- {
- mmioClose(*hmmio, 0);
- *hmmio = 0;
- }
-}
-
-/**
-*
-* rct2: 0x00405465
-*/
-MMRESULT mmio_seek(HMMIO* hmmio, LPMMCKINFO mmckinfo1, LPMMCKINFO mmckinfo2, int offset)
-{
- mmioSeek(*hmmio, mmckinfo2->dwDataOffset + 4, SEEK_SET);
- mmckinfo1->ckid = 1635017060/*DATA*/;
- MMRESULT result = mmioDescend(*hmmio, mmckinfo1, mmckinfo2, MMIO_FINDCHUNK);
- if (!result) {
- mmioSeek(*hmmio, offset, SEEK_CUR);
- return 0;
- }
- return result;
-}
-
-/**
-*
-* rct2: 0x004067F9
-*/
-LPVOID map_file(LPCWSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap)
-{
- DWORD dwDesiredAccess;
- DWORD dwDesiredAccessmap;
- DWORD flProtect;
- HANDLE filehandle;
- HANDLE filemaphandle;
- LPVOID address = 0;
- if (dwCreationDisposition) {
- if (dwCreationDisposition == CREATE_NEW) {
- dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
- dwDesiredAccessmap = FILE_MAP_WRITE;
- flProtect = PAGE_READWRITE;
- dwCreationDisposition = OPEN_ALWAYS;
- }
- } else {
- dwDesiredAccess = GENERIC_READ;
- flProtect = PAGE_READONLY;
- dwDesiredAccessmap = FILE_MAP_READ;
- dwCreationDisposition = OPEN_EXISTING;
- }
- filehandle = CreateFileW(lpFileName, dwDesiredAccess, 0, 0, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, 0);
- if (filehandle != INVALID_HANDLE_VALUE) {
- filemaphandle = CreateFileMappingW(filehandle, 0, flProtect, 0, dwNumberOfBytesToMap, 0);
- CloseHandle(filehandle);
- if (filemaphandle) {
- address = MapViewOfFile(filemaphandle, dwDesiredAccessmap, 0, 0, dwNumberOfBytesToMap);
- CloseHandle(filemaphandle);
- }
- }
- return address;
-}
-
-/**
-*
-* rct2: 0x004068A0
-*/
-int unmap_file(LPCVOID base)
-{
- if (base) {
- return UnmapViewOfFile(base);
- }
- return 0;
-}
-
-/**
-*
-* rct2: 0x00404932
-*/
-int dsound_create_primary_buffer(int a, int device, int channels, int samples, int bits)
-{
- rct_dsdevice* dsdevice = 0;
- if (device) {
- if (device > RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, int)) {
- return 0;
- }
- dsdevice = &RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[device];
- }
- memset(&RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX), 0, sizeof(WAVEFORMATEX));
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).wFormatTag = 1;
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).nChannels = channels;
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).nSamplesPerSec = samples;
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).nAvgBytesPerSec = samples * RCT2_GLOBAL(0x01425B4C, uint16);
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).nBlockAlign = bits * channels / 8;
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).wBitsPerSample = bits;
- RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX).cbSize = 0;
- DSBUFFERDESC bufferdesc;
- memset(&bufferdesc, 0, sizeof(bufferdesc));
- bufferdesc.dwSize = sizeof(bufferdesc);
- if (a) {
- if (a != 1) {
- return 0;
- }
- bufferdesc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
- if (RCT2_GLOBAL(0x009E2B90, uint32)) {
- bufferdesc.dwFlags = DSBCAPS_STICKYFOCUS | DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
- }
- if (FAILED(DirectSoundCreate(&dsdevice->guid, &RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), 0))) {
- return 0;
- }
- if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->SetCooperativeLevel(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), windows_get_window_handle(), DSSCL_NORMAL)) ||
- FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), 0))) {
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
- return 0;
- }
- if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->QueryInterface(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &RCT2_GLOBAL(0x009A4444, IID) /* IID_IDirectSound3DBuffer */, (void**)&RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)))) {
- // doesn't seem to ever make it here, below doesn't make sense and is probably remnants of unused 3d sound tests
- memset(&RCT2_GLOBAL(0x009A6084, DS3DBUFFER), 0, sizeof(RCT2_GLOBAL(0x009A6084, DS3DBUFFER)));
- RCT2_GLOBAL(0x009A6084, DS3DBUFFER).dwSize = sizeof(RCT2_GLOBAL(0x009A6084, DS3DBUFFER));
-
- if (sound_load3dparameters()) {
- RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.x = 0.0f;
- }
- RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.y = 0.0f;
- RCT2_GLOBAL(0x009A6084, DS3DBUFFER).vPosition.x = -1.0f;
- RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMaxDistance = 9.8999996f;
- RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMinDistance = 0.25f;
- if (sound_load3dposition()) {
- if (SUCCEEDED(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->SetMinDistance(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER), RCT2_GLOBAL(0x009A6084, DS3DBUFFER).flMinDistance, 1))) {
- if (sound_load3dparameters()) {
- return 1;
- }
- }
- }
- RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER));
- RCT2_GLOBAL(0x009E2BA4, LPDIRECTSOUND3DBUFFER) = 0;
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
- } else {
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
- }
- }
- bufferdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
- if (RCT2_GLOBAL(0x009E2B90, uint32)) {
- bufferdesc.dwFlags = DSBCAPS_STICKYFOCUS | DSBCAPS_PRIMARYBUFFER;
- }
- if (FAILED(DirectSoundCreate(&dsdevice->guid, &RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), 0))) {
- return 0;
- }
- if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->SetCooperativeLevel(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), windows_get_window_handle(), DSSCL_PRIORITY))) {
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
- return 0;
- }
- RCT2_GLOBAL(0x01425B60, DSCAPS).dwSize = sizeof(DSCAPS);
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->GetCaps(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &RCT2_GLOBAL(0x01425B60, DSCAPS));
- if (FAILED(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), 0))) {
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->Release(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER));
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->Release(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND));
- RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND) = 0;
- }
- WAVEFORMATEX waveformat1, waveformat2;
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->GetFormat(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &waveformat1, sizeof(WAVEFORMATEX), 0);
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->SetFormat(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &RCT2_GLOBAL(RCT2_ADDRESS_AUDIO_INFO, WAVEFORMATEX));
- RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER)->lpVtbl->GetFormat(RCT2_GLOBAL(0x009E2BA8, LPDIRECTSOUNDBUFFER), &waveformat2, sizeof(WAVEFORMATEX), 0);
- return 1;
-}
-
-/**
-*
-* rct2: 0x0040502E
-*/
-int get_dsound_devices()
-{
- RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32) = dsound_count_devices();
- RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*) = malloc(RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, uint32) * sizeof(rct_dsdevice));
- if (RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)) {
- RCT2_GLOBAL(0x01425B54, int) = 0;
- DirectSoundEnumerate(dsound_enum_callback, 0);
- return RCT2_GLOBAL(0x01425B54, int);
- }
- return 0;
-}
-#endif // _WIN32
-
/**
*
* rct2: 0x006BB76E
@@ -1641,16 +143,6 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z)
}
}
}
- int i = 0;
- rct_other_sound* other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
- while (other_sound->id != 0xFFFF) {
- i++;
- other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
- if (i > RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MAX_NO_SOUNDS, uint8)) { // too many sounds playing
- return sound_id;
- }
- }
- other_sound->id = sound_id;
int pan;
if (ebx == (sint16)0x8000) {
pan = 0;
@@ -1665,44 +157,11 @@ int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z)
if (!RCT2_GLOBAL(0x009AAC6D, uint8)) {
pan = 0;
}
-#ifdef USE_MIXER
Mixer_Play_Effect(sound_id, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), 1, 1);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_prepare(sound_id, &other_sound->sound, 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32));
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- result = sound_play(&other_sound->sound, 0, volume, pan, 0);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
return result;
}
-/**
-*
-* rct2: 0x006BB991
-*/
-void stop_completed_sounds()
-{
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1) {
- for (int i = 0; i < 7; i++) {
- rct_other_sound* other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
- if (other_sound->id != (uint16)-1) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int isplaying = sound_is_playing(&other_sound->sound);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (!isplaying) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&other_sound->sound);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- other_sound->id = (uint16)-1;
- }
- }
- }
- }
-}
-
/**
*
* rct2: 0x006BD0F8
@@ -1730,18 +189,7 @@ void start_title_music()
if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && !gGameSoundsOff
&& RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) {
if (!RCT2_GLOBAL(0x009AF600, uint8)) {
-#ifdef USE_MIXER
gTitleMusicChannel = Mixer_Play_Music(musicPathId, MIXER_LOOP_INFINITE, true);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int result = sound_channel_load_file2(3, (char*)get_file_path(musicPathId), 0);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (result) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_play(3, 1, 0, 0, 0);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- }
-#endif
RCT2_GLOBAL(0x009AF600, uint8) = 1;
}
} else {
@@ -1751,34 +199,6 @@ void start_title_music()
}
}
-/**
-*
-* rct2: 0x006BCAE5
-*/
-void stop_other_sounds()
-{
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1) {
- if (RCT2_GLOBAL(0x009AF5A8, uint32) != 1) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(RCT2_GLOBAL(0x009AF5AC, rct_sound*));
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- RCT2_GLOBAL(0x009AF5A8, uint32) = 1;
- }
- if (RCT2_GLOBAL(0x009AF5C0, uint32) != 8) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(RCT2_GLOBAL(0x009AF5C4, rct_sound*));
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- RCT2_GLOBAL(0x009AF5C0, uint32) = 8;
- }
- if (RCT2_GLOBAL(0x009AF5D8, uint32) != 8) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(RCT2_GLOBAL(0x009AF5DC, rct_sound*));
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- RCT2_GLOBAL(0x009AF5D8, uint32) = 8;
- }
- }
-}
-
/**
*
* rct2: 0x006BCA9F
@@ -1787,15 +207,9 @@ void stop_ride_music()
{
if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) {
for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) {
- rct_ride_music* ride_music = &gRideMusicList[i];//&RCT2_ADDRESS(0x009AF46C, rct_ride_music)[i];
+ rct_ride_music* ride_music = &gRideMusicList[i];
if (ride_music->rideid != (uint8)-1) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(ride_music->sound_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_stop(i);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
ride_music->rideid = -1;
}
}
@@ -1810,16 +224,10 @@ void stop_crowd_sound()
{
if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) {
if (RCT2_GLOBAL(0x009AF5FC, uint32) != 1) {
-#ifdef USE_MIXER
if (gCrowdSoundChannel) {
Mixer_Stop_Channel(gCrowdSoundChannel);
gCrowdSoundChannel = 0;
}
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_stop(2);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
RCT2_GLOBAL(0x009AF5FC, uint32) = 1;
}
}
@@ -1833,16 +241,10 @@ void stop_title_music()
{
if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) {
if (RCT2_GLOBAL(0x009AF600, uint8) != 0) {
-#ifdef USE_MIXER
if (gTitleMusicChannel) {
Mixer_Stop_Channel(gTitleMusicChannel);
gTitleMusicChannel = 0;
}
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_stop(3);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
RCT2_GLOBAL(0x009AF600, uint8) = 0;
@@ -1855,21 +257,6 @@ void stop_title_music()
void audio_init1()
{
int devicenum = 0;
-#ifdef _WIN32
- if (RCT2_GLOBAL(0x009AAC5C, uint8)) {
- rct_dsdevice* dsdevice = &RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[0];
- while (dsdevice->guid.Data1 != RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID).Data1 ||
- dsdevice->guid.Data2 != RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID).Data2 ||
- dsdevice->guid.Data3 != RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID).Data3 ||
- memcmp(dsdevice->guid.Data4, RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID).Data4, sizeof(dsdevice->guid.Data4)) != 0) {
- dsdevice++;
- devicenum++;
- if (devicenum >= RCT2_GLOBAL(RCT2_ADDRESS_NUM_DSOUND_DEVICES, int)) {
- devicenum = 0;
- break;
- }
- }
- }
audio_init2(devicenum);
for(int m = 0; m < countof(ride_music_info_list); m++) {
@@ -1885,9 +272,6 @@ void audio_init1()
}
}
}
-#else
- STUB();
-#endif // _WIN32
}
/**
@@ -1897,59 +281,17 @@ void audio_init1()
void audio_init2(int device)
{
audio_close();
- for (int i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS/*7*/; i++) {
+ for (int i = 0; i < AUDIO_MAX_VEHICLE_SOUNDS; i++) {
rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[i];
- //rct_vehicle_sound* vehicle_sound = &RCT2_ADDRESS(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound)[i];
vehicle_sound->id = 0xFFFF;
}
- for (int i = 0; i < 7; i++) {
- rct_other_sound* other_sound = &RCT2_ADDRESS(0x009AF484, rct_other_sound)[i];
- other_sound->id = 0xFFFF;
- }
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
-#ifdef _WIN32
- int successdsound = dsound_create_primary_buffer(0, device, 2, 22050, 16);
-#else
- int successdsound = 0;
- STUB();
-#endif // _WIN32
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (!successdsound) {
- return;
- }
- const char * filepath = get_file_path(2);
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int successmap = map_sound_effects(filepath);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (!successmap) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- audio_release();
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- return;
- }
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = device;
- rct_dsdevice dsdevice = RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_DEVICES, rct_dsdevice*)[device];
-#ifdef _WIN32
- RCT2_GLOBAL(RCT2_ADDRESS_DSOUND_GUID, GUID) = dsdevice.guid;
-#else
- STUB();
-#endif // _WIN32
RCT2_GLOBAL(0x009AAC5C, uint8) = 1;
config_save_default();
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int successtimer = audio_create_timer();
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (successtimer) {
- RCT2_GLOBAL(0x009AF284, uint32) |= (1 << 0);
- for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) {
- rct_ride_music* ride_music = &gRideMusicList[i];//&RCT2_ADDRESS(0x009AF46C, rct_ride_music)[i];
- ride_music->rideid = -1;
- }
- }
-
- // Used by original code for directsound
- if (!(RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & 1 << 4)) {
- RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) |= 1 << 4;
+ RCT2_GLOBAL(0x009AF284, uint32) |= (1 << 0);
+ for (int i = 0; i < AUDIO_MAX_RIDE_MUSIC; i++) {
+ rct_ride_music* ride_music = &gRideMusicList[i];
+ ride_music->rideid = -1;
}
}
@@ -1959,22 +301,12 @@ void audio_init2(int device)
*/
void audio_close()
{
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1) {
- stop_other_sounds();
- stop_crowd_sound();
- stop_title_music();
- if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) {
- stop_ride_music();
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- audio_remove_timer();
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- }
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- unmap_sound_effects();
- audio_release();
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1;
+ stop_crowd_sound();
+ stop_title_music();
+ if (RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) {
+ stop_ride_music();
}
+ RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = -1;
}
/* rct2: 0x006BAB8A */
@@ -1995,7 +327,6 @@ void toggle_all_sounds(){
void pause_sounds()
{
gGameSoundsOff = 1;
- stop_other_sounds();
stop_vehicle_sounds();
stop_ride_music();
stop_crowd_sound();
@@ -2017,27 +348,14 @@ void unpause_sounds()
void stop_vehicle_sounds()
{
if (!gOpenRCT2Headless && RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
- for (int i = 0; i < countof(gVehicleSoundList)/*7*/; i++) {
+ for (int i = 0; i < countof(gVehicleSoundList); i++) {
rct_vehicle_sound* vehicle_sound = &gVehicleSoundList[i];
- //rct_vehicle_sound* vehicle_sound = &RCT2_ADDRESS(RCT2_ADDRESS_VEHICLE_SOUND_LIST, rct_vehicle_sound)[i];
if (vehicle_sound->id != 0xFFFF) {
if (vehicle_sound->sound1_id != 0xFFFF) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound1_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound1);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
if (vehicle_sound->sound2_id != 0xFFFF) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound2_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound2);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
vehicle_sound->id = 0xFFFF;
diff --git a/src/audio/audio.h b/src/audio/audio.h
index 7c6ca1431d..82a475ad38 100644
--- a/src/audio/audio.h
+++ b/src/audio/audio.h
@@ -21,10 +21,6 @@
#ifndef _AUDIO_H_
#define _AUDIO_H_
-#ifdef _WIN32
-#include
-#endif // _WIN32
-
#include "../common.h"
#include "../world/sprite.h"
@@ -42,95 +38,55 @@ void audio_init();
void audio_quit();
void audio_get_devices();
-/**
- * Represents a single directsound device.
- */
-typedef struct {
-#ifdef _WIN32
- GUID guid;
- char desc[256];
- char drvname[256];
-#else
- uint8 padding[16+256+256];
-#endif // _WIN32
-} rct_dsdevice;
-
-/**
- * Represents a prepared sound.
- */
-typedef struct rct_sound {
-#ifdef _WIN32
- struct IDirectSoundBuffer *dsbuffer;
-#else
- void *padding;
-#endif // _WIN32
- uint16 id;
- uint16 var_8;
- int has_caps;
- int var_0C;
- struct rct_sound* next;
-} rct_sound;
-
typedef struct {
uint16 id;
- sint16 volume; // 0x02
- rct_sound sound1; // 0x04
- uint16 sound1_id; // 0x18
- sint16 sound1_volume; // 0x1A
- sint16 sound1_pan; // 0x1C
+ sint16 volume;
+ uint16 sound1_id;
+ sint16 sound1_volume;
+ sint16 sound1_pan;
uint16 sound1_freq;
- rct_sound sound2; // 0x20
- uint16 sound2_id; // 0x34
- sint16 sound2_volume; // 0x36
- sint16 sound2_pan; // 0x38
- uint16 sound2_freq; // 0x3A
- // added to openrct2:
+ uint16 sound2_id;
+ sint16 sound2_volume;
+ sint16 sound2_pan;
+ uint16 sound2_freq;
void* sound1_channel;
void* sound2_channel;
} rct_vehicle_sound;
typedef struct {
uint16 id;
- sint16 panx; // 0x2
- sint16 pany; // 0x4
- uint16 frequency; // 0x6
- sint16 volume; // 0x8
- uint16 var_A; // 0xA
+ sint16 panx;
+ sint16 pany;
+ uint16 frequency;
+ sint16 volume;
+ uint16 var_A;
} rct_vehicle_sound_params;
-typedef struct {
- uint16 id;
- rct_sound sound;
-} rct_other_sound;
-
typedef struct {
uint8 rideid;
uint8 tuneid;
- sint32 offset; //0x2
- sint16 volume; //0x6
- sint16 pan; //0x8
- uint16 freq; //0xA
+ sint32 offset;
+ sint16 volume;
+ sint16 pan;
+ uint16 freq;
} rct_ride_music_params;
typedef struct {
uint8 rideid;
uint8 tuneid;
- sint16 volume; //0x2
- sint16 pan; //0x4
- uint16 freq; //0x6
- // added to openrct2:
+ sint16 volume;
+ sint16 pan;
+ uint16 freq;
void* sound_channel;
} rct_ride_music;
typedef struct {
uint32 length;
uint32 offset;
- uint8 pathid; //0x8
+ uint8 pathid;
uint8 var_9;
} rct_ride_music_info;
-struct rct_sound_effect;
-
#define NUM_DEFAULT_MUSIC_TRACKS 46
extern rct_ride_music_info* ride_music_info_list[NUM_DEFAULT_MUSIC_TRACKS];
extern rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS];
@@ -143,52 +99,8 @@ extern void *gCrowdSoundChannel;
extern void *gTitleMusicChannel;
extern bool gGameSoundsOff;
-int sub_40153B(int channel);
-int sub_4015E7(int channel);
-int sound_channel_load_file(int channel, const char* filename, int offset);
-int audio_create_timer();
-int audio_remove_timer();
-int sound_channel_load_file2(int channel, const char* filename, int offset);
-int sound_channel_play(int channel, int a2, int volume, int pan, int frequency);
-int sound_channel_stop(int channel);
-int sound_channel_set_frequency(int channel, int frequency);
-int sound_channel_set_pan(int channel, int pan);
-int sound_channel_set_volume(int channel, int volume);
-void sub_401AF3(int channel, const char* filename, int a3, int a4);
-int sub_401B46(int channel);
-int sound_channel_is_playing(int channel);
-int audio_release();
-int map_sound_effects(const char* filename);
-int unmap_sound_effects();
-int sound_prepare(int sound_id, rct_sound *sound, int channels, int software);
-int sound_duplicate(rct_sound* newsound, rct_sound* sound);
-int sound_stop(rct_sound *sound);
-int sound_stop_all();
-void sound_bufferlost_check();
-int sound_is_playing(rct_sound* sound);
-int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency);
-int sound_set_frequency(rct_sound* sound, int frequency);
-int sound_set_pan(rct_sound* sound, int pan);
-int sound_set_volume(rct_sound* sound, int volume);
-int sound_load3dparameters();
-int sound_load3dposition();
-#ifdef _WIN32
-int dsound_count_devices();
-#endif // _WIN32
-rct_sound* sound_begin();
-rct_sound* sound_next(rct_sound* sound);
-rct_sound* sound_add(rct_sound* sound);
-rct_sound* sound_remove(rct_sound* sound);
-int sound_bufferlost_restore(rct_sound* sound);
-struct rct_sound_effect* sound_get_effect(uint16 sound_id);
-#ifdef _WIN32
-int dsound_create_primary_buffer(int a, int device, int channels, int samples, int bits);
-int get_dsound_devices();
-#endif // _WIN32
int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z);
-void stop_completed_sounds();
void start_title_music();
-void stop_other_sounds();
void stop_ride_music();
void stop_crowd_sound();
void stop_title_music();
diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp
index 4faad9c126..210d90407d 100644
--- a/src/audio/mixer.cpp
+++ b/src/audio/mixer.cpp
@@ -18,10 +18,6 @@
* along with this program. If not, see .
*****************************************************************************/
-#ifdef _WIN32
-#include
-#endif // _WIN32
-
extern "C" {
#include "../config.h"
#include "../platform/platform.h"
@@ -105,11 +101,7 @@ bool Source_Sample::LoadWAV(const char* filename)
if (spec != NULL) {
format.freq = spec->freq;
-#ifdef _WIN32
format.format = spec->format;
-#else
- STUB();
-#endif // _WIN32
format.channels = spec->channels;
issdlwav = true;
} else {
@@ -144,15 +136,20 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset)
Uint32 soundsize;
SDL_RWread(rw, &soundsize, sizeof(soundsize), 1);
length = soundsize;
-#ifdef _WIN32
- WAVEFORMATEX waveformat;
+ struct WaveFormatEx
+ {
+ Uint16 encoding;
+ Uint16 channels;
+ Uint32 frequency;
+ Uint32 byterate;
+ Uint16 blockalign;
+ Uint16 bitspersample;
+ Uint16 extrasize;
+ } waveformat;
SDL_RWread(rw, &waveformat, sizeof(waveformat), 1);
- format.freq = waveformat.nSamplesPerSec;
+ format.freq = waveformat.frequency;
format.format = AUDIO_S16LSB;
- format.channels = waveformat.nChannels;
-#else
- STUB();
-#endif // _WIN32
+ format.channels = waveformat.channels;
data = new (std::nothrow) uint8[length];
if (!data) {
log_verbose("Unable to allocate data");
@@ -180,7 +177,6 @@ void Source_Sample::Unload()
bool Source_Sample::Convert(AudioFormat format)
{
-#ifdef _WIN32
if(Source_Sample::format.format != format.format || Source_Sample::format.channels != format.channels || Source_Sample::format.freq != format.freq){
SDL_AudioCVT cvt;
if (SDL_BuildAudioCVT(&cvt, Source_Sample::format.format, Source_Sample::format.channels, Source_Sample::format.freq, format.format, format.channels, format.freq) < 0) {
@@ -199,9 +195,6 @@ bool Source_Sample::Convert(AudioFormat format)
Source_Sample::format = format;
return true;
}
-#else
- STUB();
-#endif // _WIN32
return false;
}
@@ -276,16 +269,24 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw)
return false;
}
Uint64 chunkstart = SDL_RWtell(rw);
-#ifdef _WIN32
- PCMWAVEFORMAT waveformat;
+ struct WaveFormat
+ {
+ Uint16 encoding;
+ Uint16 channels;
+ Uint32 frequency;
+ Uint32 byterate;
+ Uint16 blockalign;
+ Uint16 bitspersample;
+ } waveformat;
SDL_RWread(rw, &waveformat, sizeof(waveformat), 1);
SDL_RWseek(rw, chunkstart + fmtchunk_size, RW_SEEK_SET);
- if (waveformat.wf.wFormatTag != WAVE_FORMAT_PCM) {
+ const Uint16 pcmformat = 0x0001;
+ if (waveformat.encoding != pcmformat) {
log_verbose("Not in proper format");
return false;
}
- format.freq = waveformat.wf.nSamplesPerSec;
- switch (waveformat.wBitsPerSample) {
+ format.freq = waveformat.frequency;
+ switch (waveformat.bitspersample) {
case 8:
format.format = AUDIO_U8;
break;
@@ -297,10 +298,7 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw)
return false;
break;
}
- format.channels = waveformat.wf.nChannels;
-#else
- STUB();
-#endif // _WIN32
+ format.channels = waveformat.channels;
const Uint32 DATA = 0x61746164;
Uint32 datachunk_size = FindChunk(rw, DATA);
if (!datachunk_size) {
@@ -462,7 +460,6 @@ void Mixer::Init(const char* device)
{
Close();
SDL_AudioSpec want, have;
-#ifdef _WIN32
SDL_zero(want);
want.freq = 44100;
want.format = AUDIO_S16SYS;
@@ -474,9 +471,6 @@ void Mixer::Init(const char* device)
format.format = have.format;
format.channels = have.channels;
format.freq = have.freq;
-#else
- STUB();
-#endif // _WIN32
const char* filename = get_file_path(PATH_ID_CSS1);
for (int i = 0; i < countof(css1sources); i++) {
Source_Sample* source_sample = new Source_Sample;
@@ -545,13 +539,9 @@ Channel* Mixer::Play(Source& source, int loop, bool deleteondone, bool deletesou
void Mixer::Stop(Channel& channel)
{
-#ifdef _WIN32
Lock();
channel.stopping = true;
Unlock();
-#else
-#warning unimplemented
-#endif // _WIN32
}
bool Mixer::LoadMusic(int pathid)
@@ -593,7 +583,6 @@ void SDLCALL Mixer::Callback(void* arg, uint8* stream, int length)
void Mixer::MixChannel(Channel& channel, uint8* data, int length)
{
-#ifdef _WIN32
if (channel.source && channel.source->Length() > 0 && !channel.done && gConfigSound.sound) {
AudioFormat streamformat = channel.source->Format();
int loaded = 0;
@@ -737,9 +726,6 @@ void Mixer::MixChannel(Channel& channel, uint8* data, int length)
channel.done = true;
}
}
-#else
- STUB();
-#endif // _WIN32
}
void Mixer::EffectPanS16(Channel& channel, sint16* data, int length)
@@ -782,14 +768,10 @@ void Mixer::EffectFadeU8(uint8* data, int length, int startvolume, int endvolume
bool Mixer::MustConvert(Source& source)
{
-#ifdef _WIN32
const AudioFormat sourceformat = source.Format();
if (sourceformat.format != format.format || sourceformat.channels != format.channels || sourceformat.freq != format.freq) {
return true;
}
-#else
- STUB();
-#endif // _WIN32
return false;
}
diff --git a/src/audio/mixer.h b/src/audio/mixer.h
index fde3658d73..6f68e1177d 100644
--- a/src/audio/mixer.h
+++ b/src/audio/mixer.h
@@ -31,8 +31,6 @@ extern "C" {
}
#endif // __cplusplus
-#define USE_MIXER
-
#define MIXER_LOOP_NONE 0
#define MIXER_LOOP_INFINITE -1
@@ -213,11 +211,7 @@ void Mixer_Channel_SetGroup(void* channel, int group);
void* Mixer_Play_Music(int pathid, int loop, int streaming);
static int DStoMixerVolume(int volume) { return (int)(SDL_MIX_MAXVOLUME * (SDL_pow(10, (float)volume / 2000))); };
-#ifdef _WIN32
static float DStoMixerPan(int pan) { return (((float)pan + -DSBPAN_LEFT) / DSBPAN_RIGHT) / 2; };
-#else
-static float DStoMixerPan(int pan) { STUB(); return ((float)pan) / 2; };
-#endif // _WIN32
static double DStoMixerRate(int frequency) { return (double)frequency / 22050; };
#ifdef __cplusplus
diff --git a/src/game.c b/src/game.c
index 265b34d0eb..50ee37673d 100644
--- a/src/game.c
+++ b/src/game.c
@@ -1071,7 +1071,7 @@ void rct2_exit_reason(rct_string_id title, rct_string_id body){
*/
void rct2_exit()
{
- audio_close();
+ //audio_close();
//Post quit message does not work in 0x6e3879 as its windows only.
openrct2_finish();
}
diff --git a/src/intro.c b/src/intro.c
index 0757c467ff..f067568a85 100644
--- a/src/intro.c
+++ b/src/intro.c
@@ -31,7 +31,6 @@ static void screen_intro_process_keyboard_input();
static void screen_intro_skip_part();
static int _sound_playing_flag = 0; ///< Used to test if a sound is currently playing.
-static rct_sound _prepared_sound; ///< A prepared sound for playing.
static int _tick_counter; ///< Used mainly for timing but also for Y coordinate and fading.
// rct2: 0x0068E966
@@ -60,12 +59,12 @@ void intro_update()
// Chain lift sound
_sound_playing_flag = 0;
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
+ /*if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
// Prepare and play the sound
if (sound_prepare(SOUND_LIFT_7, &_prepared_sound, 0, 1))
if (sound_play(&_prepared_sound, 1, 0, 0, 0))
_sound_playing_flag = 1;
- }
+ }*/
// Move to next part
(*part)++;
@@ -132,17 +131,17 @@ void intro_update()
if (_tick_counter == 259) {
// Stop the chain lift sound
if (_sound_playing_flag == 1) {
- sound_stop(&_prepared_sound);
+ //sound_stop(&_prepared_sound);
_sound_playing_flag = 0;
}
// Play the track friction sound
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
+ /*if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1) {
// Prepare and play the sound
if (sound_prepare(SOUND_TRACK_FRICTION_3, &_prepared_sound, 1, 1))
if (sound_play(&_prepared_sound, 1, -800, 0, 0x3A98))
_sound_playing_flag = 1;
- }
+ }*/
}
// Check if logo is off the screen .ish
@@ -163,15 +162,15 @@ void intro_update()
// Stop the track friction sound
if (_sound_playing_flag == 1) {
- sound_stop(&_prepared_sound);
+ //sound_stop(&_prepared_sound);
_sound_playing_flag = 0;
}
// Play long peep scream sound
- if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1)
+ /*if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, sint32) != -1)
if (sound_prepare(SOUND_SCREAM_1, &_prepared_sound, 0, 1))
if (sound_play(&_prepared_sound, 0, 0, 0, 0))
- _sound_playing_flag = 1;
+ _sound_playing_flag = 1;*/
// Move to the next part
(*part)++;
@@ -230,7 +229,7 @@ void intro_update()
// Stop any playing sound
if (_sound_playing_flag == 1) {
- sound_stop(&_prepared_sound);
+ //sound_stop(&_prepared_sound);
_sound_playing_flag = 0;
}
diff --git a/src/openrct2.c b/src/openrct2.c
index 7eede9d930..69d5b9a46d 100644
--- a/src/openrct2.c
+++ b/src/openrct2.c
@@ -290,11 +290,7 @@ bool openrct2_initialise()
if (!gOpenRCT2Headless) {
audio_init();
audio_get_devices();
-#ifdef _WIN32
- get_dsound_devices();
-#else
- STUB();
-#endif // _WIN32
+ //get_dsound_devices();
}
language_open(gConfigGeneral.language);
http_init();
diff --git a/src/peep/peep.c b/src/peep/peep.c
index 3b42080bdc..61d0f78203 100644
--- a/src/peep/peep.c
+++ b/src/peep/peep.c
@@ -5184,12 +5184,8 @@ void peep_update_crowd_noise()
if (visiblePeeps < 0) {
// Mute crowd noise
if (RCT2_GLOBAL(0x009AF5FC, uint32) != 1) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(gCrowdSoundChannel);
gCrowdSoundChannel = 0;
-#else
- sound_channel_stop(2); //RCT2_CALLPROC_1(0x00401A05, int, 2);
-#endif
RCT2_GLOBAL(0x009AF5FC, uint32) = 1;
}
} else {
@@ -5204,7 +5200,6 @@ void peep_update_crowd_noise()
// Check if crowd noise is already playing
if (RCT2_GLOBAL(0x009AF5FC, uint32) == 1) {
// Load and play crowd noise
-#ifdef USE_MIXER
if (!gCrowdSoundChannel) {
gCrowdSoundChannel = Mixer_Play_Music(PATH_ID_CSS2, MIXER_LOOP_INFINITE, false);
if (gCrowdSoundChannel) {
@@ -5215,20 +5210,10 @@ void peep_update_crowd_noise()
Mixer_Channel_Volume(gCrowdSoundChannel, DStoMixerVolume(volume));
RCT2_GLOBAL(0x009AF5FC, uint32) = volume;
}
-#else
- if (sound_channel_load_file2(2, (char*)get_file_path(PATH_ID_CSS2), 0)) {
- sound_channel_play(2, 1, volume, 0, 0);
- RCT2_GLOBAL(0x009AF5FC, uint32) = volume;
- }
-#endif
} else {
// Alter crowd noise volume
if (RCT2_GLOBAL(0x009AF5FC, uint32) != volume) {
-#ifdef USE_MIXER
Mixer_Channel_Volume(gCrowdSoundChannel, DStoMixerVolume(volume));
-#else
- sound_channel_set_volume(2, volume);//RCT2_CALLPROC_2(0x00401AD3, int, int, 2, volume);
-#endif
RCT2_GLOBAL(0x009AF5FC, uint32) = volume;
}
}
diff --git a/src/rct2.c b/src/rct2.c
index 025f329a52..8c071ea771 100644
--- a/src/rct2.c
+++ b/src/rct2.c
@@ -403,7 +403,7 @@ void rct2_update_2()
else
game_update();
- stop_completed_sounds(); // removes other sounds that are no longer playing in directsound
+ //stop_completed_sounds(); // removes other sounds that are no longer playing in directsound
twitch_update();
chat_update();
diff --git a/src/rct2.h b/src/rct2.h
index 74cf311b7e..669a2ec026 100644
--- a/src/rct2.h
+++ b/src/rct2.h
@@ -208,9 +208,6 @@ static const char * const file_paths[] =
{
#ifdef _WIN32
"data\\g1.dat",
-#else
- "data/g1.dat",
-#endif // _WIN32
"Data\\PLUGIN.DAT",
"Data\\CSS1.DAT",
"Data\\CSS2.DAT",
@@ -261,6 +258,59 @@ static const char * const file_paths[] =
"Data\\CSS45.DAT",
"Data\\CSS46.DAT",
"Data\\CSS50.DAT"
+#else
+ "data/g1.dat",
+ "data/plugin.dat",
+ "data/css1.dat",
+ "data/css2.dat",
+ "data/css4.dat",
+ "data/css5.dat",
+ "data/css6.dat",
+ "data/css7.dat",
+ "data/css8.dat",
+ "data/css9.dat",
+ "data/css11.dat",
+ "data/css12.dat",
+ "data/css13.dat",
+ "data/css14.dat",
+ "data/css15.dat",
+ "data/css3.dat",
+ "data/css17.dat",
+ "data/css18.dat",
+ "data/css19.dat",
+ "data/css20.dat",
+ "data/css21.dat",
+ "data/css22.dat",
+ "Saved Games/scores.dat",
+ "data/css23.dat",
+ "data/css24.dat",
+ "data/css25.dat",
+ "data/css26.dat",
+ "data/css27.dat",
+ "data/css28.dat",
+ "data/css29.dat",
+ "data/css30.dat",
+ "data/css31.dat",
+ "data/css32.dat",
+ "data/css33.dat",
+ "data/css34.dat",
+ "data/css35.dat",
+ "data/css36.dat",
+ "data/css37.dat",
+ "data/css38.dat",
+ "data/CUSTOM1.WAV",
+ "data/CUSTOM2.WAV",
+ "data/css39.dat",
+ "data/css40.dat",
+ "data/css41.dat",
+ "Scenarios/Six Flags Magic Mountain.SC6",
+ "data/css42.dat",
+ "data/css43.dat",
+ "data/css44.dat",
+ "data/css45.dat",
+ "data/css46.dat",
+ "data/css50.dat"
+#endif // _WIN32
};
// Files to check (rct2 @ 0x0097FB5A)
diff --git a/src/ride/ride.c b/src/ride/ride.c
index e07840e230..e9feb8dce6 100644
--- a/src/ride/ride.c
+++ b/src/ride/ride.c
@@ -3322,24 +3322,12 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint
goto label51;
}
}
-#ifdef USE_MIXER
int playing = Mixer_Channel_IsPlaying(gRideMusicList[channel].sound_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int playing = sound_channel_is_playing(channel);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
if (!playing) {
*tuneId = 0xFF;
return 0;
}
-#ifdef USE_MIXER
a1 = Mixer_Channel_GetOffset(gRideMusicList[channel].sound_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- a1 = sub_401B46(channel);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
label51:
if (a1 < ride_music_info_list[*tuneId]->length) {
position = a1;
@@ -3487,13 +3475,7 @@ void ride_music_update_final()
rct_ride_music_params* ride_music_params = &gRideMusicParamsList[0];//&RCT2_GLOBAL(0x009AF430, rct_ride_music_params);
while (ride_music_params < gRideMusicParamsListEnd/*RCT2_GLOBAL(0x009AF42C, rct_ride_music_params*)*/) {
if (ride_music_params->rideid == ride_music->rideid && ride_music_params->tuneid == ride_music->tuneid) {
-#ifdef USE_MIXER
int isplaying = Mixer_Channel_IsPlaying(gRideMusicList[channel].sound_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int isplaying = sound_channel_is_playing(channel);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
if (isplaying) {
goto label32;
}
@@ -3501,13 +3483,7 @@ void ride_music_update_final()
}
ride_music_params++;
}
-#ifdef USE_MIXER
Mixer_Stop_Channel(gRideMusicList[channel].sound_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_stop(channel);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
ride_music->rideid = -1;
}
label32:
@@ -3527,7 +3503,6 @@ void ride_music_update_final()
channel++;
if (channel >= AUDIO_MAX_RIDE_MUSIC) {
rct_ride_music_info* ride_music_info = ride_music_info_list[ride_music_params->tuneid];
-#ifdef USE_MIXER
rct_ride_music* ride_music = &gRideMusicList[ebx];
ride_music->sound_channel = Mixer_Play_Music(ride_music_info->pathid, MIXER_LOOP_NONE, true);
if (ride_music->sound_channel) {
@@ -3547,82 +3522,21 @@ void ride_music_update_final()
} else {
//RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) = 0;
}
-#else
- const char* filename = get_file_path(ride_music_info->pathid);
- RCT2_GLOBAL(0x014241BC, uint32) = 3;
- HANDLE hfile = osinterface_file_open(filename);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (hfile != INVALID_HANDLE_VALUE) {
- RCT2_GLOBAL(0x014241BC, uint32) = 3;
- osinterface_file_read(hfile, &RCT2_GLOBAL(0x009AF47E, uint32), 4);
- RCT2_GLOBAL(0x014241BC, uint32) = 3;
- osinterface_file_close(hfile);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- }
- if (hfile == INVALID_HANDLE_VALUE || RCT2_GLOBAL(0x009AF47E, uint32) != 0x78787878) {
- int offset = ride_music_params->offset - 10000;
- if (offset < 0) {
- offset = 0;
- }
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int musicloaded = sound_channel_load_file2(ebx, filename, offset & 0xFFFFFFF0);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (musicloaded) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- int musicplayed = sound_channel_play(ebx, 0, ride_music_params->volume, ride_music_params->pan, ride_music_params->freq);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- if (musicplayed) {
- rct_ride_music_info* ride_music_info = &RCT2_GLOBAL(0x009AF1C8, rct_ride_music_info*)[ride_music_params->tuneid];
- if (ride_music_info->var_9) {
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sub_401AF3(ebx, get_file_path(ride_music_info->pathid), 1, 0);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
- }
- rct_ride_music* ride_music = &gRideMusicList[ebx];//&RCT2_ADDRESS(0x009AF46C, rct_ride_music)[ebx];
- ride_music->volume = ride_music_params->volume;
- ride_music->pan = ride_music_params->pan;
- ride_music->freq = ride_music_params->freq;
- ride_music->rideid = ride_music_params->rideid;
- ride_music->tuneid = ride_music_params->tuneid;
- }
- } else {
- RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) = 0;
- }
- }
-#endif
return;
}
}
if (ride_music_params->volume != ride_music->volume) {
ride_music->volume = ride_music_params->volume;
-#ifdef USE_MIXER
Mixer_Channel_Volume(ride_music->sound_channel, DStoMixerVolume(ride_music->volume));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_set_volume(channel, ride_music_params->volume);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
if (ride_music_params->pan != ride_music->pan) {
ride_music->pan = ride_music_params->pan;
-#ifdef USE_MIXER
Mixer_Channel_Pan(ride_music->sound_channel, DStoMixerPan(ride_music->pan));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_set_pan(channel, ride_music_params->pan);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
if (ride_music_params->freq != ride_music->freq) {
ride_music->freq = ride_music_params->freq;
-#ifdef USE_MIXER
Mixer_Channel_Rate(ride_music->sound_channel, DStoMixerRate(ride_music->freq));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_channel_set_frequency(channel, ride_music_params->freq);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c
index 6fcb060c28..a51b2aa365 100644
--- a/src/ride/vehicle.c
+++ b/src/ride/vehicle.c
@@ -212,22 +212,10 @@ void vehicle_sounds_update()
}
}
if (vehicle_sound->sound1_id != (uint16)-1) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound1_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound1);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
if (vehicle_sound->sound2_id != (uint16)-1) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound2_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound2);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
vehicle_sound->id = (uint16)-1;
}
@@ -347,33 +335,16 @@ void vehicle_sounds_update()
if (sprite->vehicle.sound1_id == (uint8)-1) {
if (vehicle_sound->sound1_id != (uint16)-1) {
vehicle_sound->sound1_id = -1;
-#ifdef USE_MIXER
- Mixer_Stop_Channel(vehicle_sound->sound1_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound1);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
+ Mixer_Stop_Channel(vehicle_sound->sound1_channel);
}
} else {
if (vehicle_sound->sound1_id == (uint16)-1) {
goto label69;
}
if (sprite->vehicle.sound1_id != vehicle_sound->sound1_id) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound1_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound1);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
label69:
vehicle_sound->sound1_id = sprite->vehicle.sound1_id;
-#ifndef USE_MIXER
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_prepare(sprite->vehicle.sound1_id, &vehicle_sound->sound1, 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32));
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
vehicle_sound->sound1_pan = vehicle_sound_params->panx;
vehicle_sound->sound1_volume = volume;
vehicle_sound->sound1_freq = vehicle_sound_params->frequency;
@@ -386,35 +357,17 @@ void vehicle_sounds_update()
if (!RCT2_GLOBAL(0x009AAC6D, uint8)) {
pan = 0;
}
-#ifdef USE_MIXER
vehicle_sound->sound1_channel = Mixer_Play_Effect(sprite->vehicle.sound1_id, looping ? MIXER_LOOP_INFINITE : MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), DStoMixerRate(frequency), 0);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_play(&vehicle_sound->sound1, looping, volume, pan, frequency);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
goto label87;
}
if (volume != vehicle_sound->sound1_volume) {
vehicle_sound->sound1_volume = volume;
-#ifdef USE_MIXER
Mixer_Channel_Volume(vehicle_sound->sound1_channel, DStoMixerVolume(volume));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_set_volume(&vehicle_sound->sound1, volume);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
if (vehicle_sound_params->panx != vehicle_sound->sound1_pan) {
vehicle_sound->sound1_pan = vehicle_sound_params->panx;
if (RCT2_GLOBAL(0x009AAC6D, uint8)) {
-#ifdef USE_MIXER
Mixer_Channel_Pan(vehicle_sound->sound1_channel, DStoMixerPan(vehicle_sound_params->panx));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_set_pan(&vehicle_sound->sound1, vehicle_sound_params->panx);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 3) && vehicle_sound_params->frequency != vehicle_sound->sound1_freq) {
@@ -423,13 +376,7 @@ void vehicle_sounds_update()
if (RCT2_GLOBAL(0x009AF51F, uint8*)[2 * sprite->vehicle.sound1_id] & 2) {
frequency = (frequency / 2) + 4000;
}
-#ifdef USE_MIXER
Mixer_Channel_Rate(vehicle_sound->sound1_channel, DStoMixerRate(frequency));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_set_frequency(&vehicle_sound->sound1, frequency);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
label87: // do sound2 stuff, screams
@@ -444,33 +391,16 @@ void vehicle_sounds_update()
if (sprite->vehicle.sound2_id == (uint8)-1) {
if (vehicle_sound->sound2_id != (uint16)-1) {
vehicle_sound->sound2_id = -1;
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound2_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound2);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
} else {
if (vehicle_sound->sound2_id == (uint16)-1) {
goto label93;
}
if (sprite->vehicle.sound2_id != vehicle_sound->sound2_id) {
-#ifdef USE_MIXER
Mixer_Stop_Channel(vehicle_sound->sound2_channel);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_stop(&vehicle_sound->sound2);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
label93:
vehicle_sound->sound2_id = sprite->vehicle.sound2_id;
-#ifndef USE_MIXER
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_prepare(sprite->vehicle.sound2_id, &vehicle_sound->sound2, 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32));
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
vehicle_sound->sound2_pan = vehicle_sound_params->panx;
vehicle_sound->sound2_volume = volume;
vehicle_sound->sound2_freq = vehicle_sound_params->frequency;
@@ -487,35 +417,17 @@ void vehicle_sounds_update()
if (!RCT2_GLOBAL(0x009AAC6D, uint8)) {
pan = 0;
}
-#ifdef USE_MIXER
vehicle_sound->sound2_channel = Mixer_Play_Effect(sprite->vehicle.sound2_id, looping ? MIXER_LOOP_INFINITE : MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), DStoMixerRate(frequency), 0);
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_play(&vehicle_sound->sound2, looping, volume, pan, frequency);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
goto label114;
}
if (volume != vehicle_sound->sound2_volume) {
-#ifdef USE_MIXER
Mixer_Channel_Volume(vehicle_sound->sound2_channel, DStoMixerVolume(volume));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_set_volume(&vehicle_sound->sound2, volume);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
vehicle_sound->sound2_volume = volume;
}
if (vehicle_sound_params->panx != vehicle_sound->sound2_pan) {
vehicle_sound->sound2_pan = vehicle_sound_params->panx;
if (RCT2_GLOBAL(0x009AAC6D, uint8)) {
-#ifdef USE_MIXER
Mixer_Channel_Pan(vehicle_sound->sound2_channel, DStoMixerPan(vehicle_sound_params->panx));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_set_pan(&vehicle_sound->sound2, vehicle_sound_params->panx);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
if (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 3) && vehicle_sound_params->frequency != vehicle_sound->sound2_freq) {
@@ -525,13 +437,7 @@ void vehicle_sounds_update()
if (frequency > 25700) {
frequency = 25700;
}
-#ifdef USE_MIXER
Mixer_Channel_Rate(vehicle_sound->sound2_channel, DStoMixerRate(frequency));
-#else
- RCT2_GLOBAL(0x014241BC, uint32) = 1;
- sound_set_frequency(&vehicle_sound->sound2, frequency);
- RCT2_GLOBAL(0x014241BC, uint32) = 0;
-#endif
}
}
diff --git a/src/title.c b/src/title.c
index f4d0d6de75..dda66712a4 100644
--- a/src/title.c
+++ b/src/title.c
@@ -124,7 +124,7 @@ void title_load()
reset_0x69EBE4();
stop_ride_music();
stop_crowd_sound();
- stop_other_sounds();
+ //stop_other_sounds();
viewport_init_all();
news_item_init_queue();
title_create_windows();
diff --git a/src/windows/options.c b/src/windows/options.c
index abdccf5799..03e1282fff 100644
--- a/src/windows/options.c
+++ b/src/windows/options.c
@@ -1003,7 +1003,6 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown
case WIDX_SOUND_DROPDOWN:
audio_init2(dropdownIndex);
if (dropdownIndex < gAudioDeviceCount) {
-#ifdef USE_MIXER
if (dropdownIndex == 0) {
Mixer_Init(NULL);
gConfigSound.device = NULL;
@@ -1016,7 +1015,6 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown
strcpy(gConfigSound.device, devicename);
}
config_save_default();
-#endif
}
window_invalidate(w);
break;
diff --git a/src/world/climate.c b/src/world/climate.c
index f72319fd3b..470a1d2fbd 100644
--- a/src/world/climate.c
+++ b/src/world/climate.c
@@ -62,10 +62,8 @@ static const rct_weather_transition* climate_transitions[4];
// Sound data
static int _rainVolume = 1;
-static rct_sound _rainSoundInstance;
static void* _rainSoundChannel = 0;
static unsigned int _lightningTimer, _thunderTimer;
-static rct_sound _thunderSoundInstance[MAX_THUNDER_INSTANCES];
static void* _thunderSoundChannels[MAX_THUNDER_INSTANCES];
static int _thunderStatus[MAX_THUNDER_INSTANCES] = { THUNDER_STATUS_NULL, THUNDER_STATUS_NULL };
static unsigned int _thunderSoundId;
@@ -110,14 +108,10 @@ void climate_reset(int climate)
_lightningTimer = 0;
_thunderTimer = 0;
if (_rainVolume != 1){
-#ifdef USE_MIXER
if (_rainSoundChannel) {
Mixer_Stop_Channel(_rainSoundChannel);
_rainSoundChannel = 0;
}
-#else
- sound_stop(&_rainSoundInstance);
-#endif
_rainVolume = 1;
}
@@ -259,46 +253,29 @@ static void climate_update_rain_sound()
if (_climateCurrentWeatherEffect == 1 || _climateCurrentWeatherEffect == 2) {
if (_rainVolume == 1) {
// Start playing the rain sound
-#ifdef USE_MIXER
if (!_rainSoundChannel) {
_rainSoundChannel = Mixer_Play_Effect(SOUND_RAIN_1, MIXER_LOOP_INFINITE, DStoMixerVolume(-4000), 0.5f, 1, 0);
}
-#else
- if (sound_prepare(SOUND_RAIN_1, &_rainSoundInstance, 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32)))
- sound_play(&_rainSoundInstance, 1, -4000, 0, 0);
-#endif
_rainVolume = -4000;
} else {
// Increase rain sound
_rainVolume = min(-1400, _rainVolume + 80);
-#ifdef USE_MIXER
if (_rainSoundChannel) {
Mixer_Channel_Volume(_rainSoundChannel, DStoMixerVolume(_rainVolume));
}
-#else
- sound_set_volume(&_rainSoundInstance, _rainVolume);
-#endif
}
} else if (_rainVolume != 1) {
// Decrease rain sound
_rainVolume -= 80;
if (_rainVolume > -4000) {
-#ifdef USE_MIXER
if (_rainSoundChannel) {
Mixer_Channel_Volume(_rainSoundChannel, DStoMixerVolume(_rainVolume));
}
-#else
- sound_set_volume(&_rainSoundInstance, _rainVolume);
-#endif
} else {
-#ifdef USE_MIXER
if (_rainSoundChannel) {
Mixer_Stop_Channel(_rainSoundChannel);
_rainSoundChannel = 0;
}
-#else
- sound_stop(&_rainSoundInstance);
-#endif
_rainVolume = 1;
}
}
@@ -328,17 +305,10 @@ static void climate_update_thunder_sound()
if (_thunderStatus[i] == THUNDER_STATUS_NULL)
continue;
-#ifdef USE_MIXER
if (!Mixer_Channel_IsPlaying(_thunderSoundChannels[i])) {
Mixer_Stop_Channel(_thunderSoundChannels[i]);
_thunderStatus[i] = THUNDER_STATUS_NULL;
}
-#else
- if (!sound_is_playing(&_thunderSoundInstance[i])) {
- sound_stop(&_thunderSoundInstance[i]);
- _thunderStatus[i] = THUNDER_STATUS_NULL;
- }
-#endif
}
}
@@ -381,20 +351,11 @@ static void climate_update_thunder()
static int climate_play_thunder(int instanceIndex, int soundId, int volume, int pan)
{
-#ifdef USE_MIXER
_thunderSoundChannels[instanceIndex] = Mixer_Play_Effect(soundId, MIXER_LOOP_NONE, DStoMixerVolume(volume), DStoMixerPan(pan), 1, 0);
if (_thunderSoundChannels[instanceIndex]) {
_thunderStatus[instanceIndex] = THUNDER_STATUS_PLAYING;
return 1;
}
-#else
- if (sound_prepare(soundId, &_thunderSoundInstance[instanceIndex], 1, RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_SOUND_SW_BUFFER, uint32))) {
- sound_play(&_thunderSoundInstance[instanceIndex], 0, volume, pan, 0);
-
- _thunderStatus[instanceIndex] = THUNDER_STATUS_PLAYING;
- return 1;
- }
-#endif
return 0;
}