diff --git a/src/audio/audio.c b/src/audio/audio.c
index 4418a6e017..d94dea542a 100644
--- a/src/audio/audio.c
+++ b/src/audio/audio.c
@@ -18,6 +18,8 @@
* along with this program. If not, see .
*****************************************************************************/
+#include
+
#include "../addresses.h"
#include "../config.h"
#include "../interface/viewport.h"
@@ -31,6 +33,34 @@
#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;
+ HGLOBAL hmem; // 0x11C
+ HMMIO hmmio; // 0x120
+ MMCKINFO mmckinfo1; // 0x124
+ MMCKINFO mmckinfo2; // 0x138
+ LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C
+ 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;
+ WAVEFORMATEX format;
+ uint8* data;
+};
+
int gAudioDeviceCount;
audio_device *gAudioDevices = NULL;
rct_vehicle_sound gVehicleSoundList[AUDIO_MAX_VEHICLE_SOUNDS];
@@ -43,6 +73,20 @@ void *gCrowdSoundChannel = 0;
void *gTitleMusicChannel = 0;
bool gGameSoundsOff = false;
+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(LPCSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap);
+int unmap_file(LPCVOID base);
+
void audio_init(int i)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
@@ -693,7 +737,7 @@ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software)
return 1;
}
}
- rct_sound_effect* sound_effect = sound_get_effect(sound_id);
+ 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){
@@ -943,7 +987,7 @@ BOOL CALLBACK dsound_enum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCS
*
* rct2: 0x00405054
*/
-int sound_effect_loadvars(rct_sound_effect* sound_effect, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize)
+int sound_effect_loadvars(struct rct_sound_effect* sound_effect, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize)
{
*buffersize = sound_effect->size;
*waveformat = &sound_effect->format;
@@ -1050,7 +1094,7 @@ int sound_bufferlost_restore(rct_sound* sound)
char* data = 0;
if (sound) {
if (SUCCEEDED(sound->dsbuffer->lpVtbl->Restore(sound->dsbuffer))) {
- rct_sound_effect* sound_effect = sound_get_effect(sound->id);
+ 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);
}
@@ -1063,10 +1107,10 @@ int sound_bufferlost_restore(rct_sound* sound)
*
* rct2: 0x00405206
*/
-rct_sound_effect* sound_get_effect(uint16 sound_id)
+struct rct_sound_effect* sound_get_effect(uint16 sound_id)
{
if (RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, LPVOID) && sound_id < RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[0]) {
- return (rct_sound_effect*)(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, int) + RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[sound_id + 1]);
+ return (struct rct_sound_effect*)(RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, int) + RCT2_GLOBAL(RCT2_ADDRESS_SOUND_EFFECTS_MAPPING, uint32*)[sound_id + 1]);
}
return 0;
}
diff --git a/src/audio/audio.h b/src/audio/audio.h
index aee7f80f00..648d937ac7 100644
--- a/src/audio/audio.h
+++ b/src/audio/audio.h
@@ -21,6 +21,8 @@
#ifndef _AUDIO_H_
#define _AUDIO_H_
+#include
+
#include "../common.h"
#include "../world/sprite.h"
@@ -38,22 +40,20 @@ void audio_init();
void audio_quit();
void audio_get_devices();
-#include
-
/**
* Represents a single directsound device.
*/
typedef struct {
GUID guid;
- CHAR desc[256];
- CHAR drvname[256];
+ char desc[256];
+ char drvname[256];
} rct_dsdevice;
/**
* Represents a prepared sound.
*/
typedef struct rct_sound {
- LPDIRECTSOUNDBUFFER dsbuffer;
+ struct IDirectSoundBuffer *dsbuffer;
uint16 id;
uint16 var_8;
int has_caps;
@@ -61,34 +61,6 @@ typedef struct rct_sound {
struct rct_sound* next;
} rct_sound;
-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;
- HGLOBAL hmem; // 0x11C
- HMMIO hmmio; // 0x120
- MMCKINFO mmckinfo1; // 0x124
- MMCKINFO mmckinfo2; // 0x138
- LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C
- uint32 bufsize; // 0x150
- uint32 playpos; // 0x154
- uint32 var_158;
- uint32 var_15C;
- uint32 stopped; // 0x160
- uint32 var_164;
- uint32 var_168;
-} rct_sound_channel;
-
-typedef struct {
- uint32 size;
- WAVEFORMATEX format;
- uint8* data;
-} rct_sound_effect;
-
typedef struct {
uint16 id;
sint16 volume; // 0x02
@@ -147,6 +119,8 @@ typedef struct {
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];
@@ -159,12 +133,9 @@ extern void *gCrowdSoundChannel;
extern void *gTitleMusicChannel;
extern bool gGameSoundsOff;
-void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel);
-int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
int sub_40153B(int channel);
int sub_4015E7(int channel);
int sound_channel_load_file(int channel, const char* filename, int offset);
-int mmio_open_channel(int channel, char* filename, LONG offset);
int audio_create_timer();
int audio_remove_timer();
int sound_channel_load_file2(int channel, const char* filename, int offset);
@@ -191,23 +162,13 @@ int sound_set_pan(rct_sound* sound, int pan);
int sound_set_volume(rct_sound* sound, int volume);
int sound_load3dparameters();
int sound_load3dposition();
-BOOL CALLBACK dsound_enum_callback_count(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext);
int dsound_count_devices();
-BOOL CALLBACK dsound_enum_callback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext);
-int sound_effect_loadvars(rct_sound_effect* sound_effect, LPWAVEFORMATEX* waveformat, char** data, DWORD* buffersize);
-int sound_fill_buffer(LPDIRECTSOUNDBUFFER dsbuffer, char* src, DWORD size);
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);
-rct_sound_effect* sound_get_effect(uint16 sound_id);
-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);
-void sound_channel_free(HMMIO* hmmio, HGLOBAL* hmem);
-MMRESULT mmio_seek(HMMIO* hmmio, LPMMCKINFO mmckinfo1, LPMMCKINFO mmckinfo2, int offset);
-LPVOID map_file(LPCSTR lpFileName, DWORD dwCreationDisposition, DWORD dwNumberOfBytesToMap);
-int unmap_file(LPCVOID base);
+struct rct_sound_effect* sound_get_effect(uint16 sound_id);
int dsound_create_primary_buffer(int a, int device, int channels, int samples, int bits);
int get_dsound_devices();
int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z);
diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp
index 0ba7743bee..9a3d2c6da5 100644
--- a/src/audio/mixer.cpp
+++ b/src/audio/mixer.cpp
@@ -18,6 +18,8 @@
* along with this program. If not, see .
*****************************************************************************/
+#include
+
extern "C" {
#include "../config.h"
#include "../platform/platform.h"
diff --git a/src/audio/mixer.h b/src/audio/mixer.h
index 679f7ef0af..3f592fa6f3 100644
--- a/src/audio/mixer.h
+++ b/src/audio/mixer.h
@@ -186,6 +186,13 @@ extern "C"
{
#endif
+#ifndef DSBPAN_LEFT
+#define DSBPAN_LEFT -10000
+#endif
+#ifndef DSBPAN_RIGHT
+#define DSBPAN_RIGHT 10000
+#endif
+
void Mixer_Init(const char* device);
void* Mixer_Play_Effect(int id, int loop, int volume, float pan, double rate, int deleteondone);
void Mixer_Stop_Channel(void* channel);
diff --git a/src/network/network.cpp b/src/network/network.cpp
index dd5797c34c..988a2d53b5 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -18,6 +18,8 @@
* along with this program. If not, see .
*****************************************************************************/
+#include
+
#include "network.h"
extern "C" {
diff --git a/src/platform/platform.h b/src/platform/platform.h
index 7b51a15f72..5d62464e63 100644
--- a/src/platform/platform.h
+++ b/src/platform/platform.h
@@ -130,9 +130,9 @@ uint8 platform_get_locale_temperature_format();
// Windows specific definitions
#ifdef _WIN32
// Defining WIN32_LEAN_AND_MEAN breaks dsound.h in audio.h (uncomment when dsound is finally removed)
- // #ifndef WIN32_LEAN_AND_MEAN
- // #define WIN32_LEAN_AND_MEAN
- // #endif
+ #ifndef WIN32_LEAN_AND_MEAN
+ #define WIN32_LEAN_AND_MEAN
+ #endif
#include
int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset);
diff --git a/src/rct2.c b/src/rct2.c
index 8fdf68811a..534ec5c337 100644
--- a/src/rct2.c
+++ b/src/rct2.c
@@ -358,7 +358,7 @@ void rct2_update_2()
{
int tick, tick2;
- tick = timeGetTime();
+ tick = SDL_GetTicks();
tick2 = tick - RCT2_GLOBAL(0x009DE580, sint32);
RCT2_GLOBAL(0x009DE588, sint16) = tick2 = min(tick2, 500);