Merge pull request #1961 from zsilencer/develop

remove directsound and get sound working for linux native
This commit is contained in:
Ted John 2015-09-23 18:22:51 +01:00
commit ec25b2f121
17 changed files with 129 additions and 2114 deletions

View File

@ -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)

View File

@ -363,7 +363,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<StructMemberAlignment>1Byte</StructMemberAlignment>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ObjectFileName>$(IntDir)fake\%(RelativeDir)</ObjectFileName>
@ -372,7 +372,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>winmm.lib;sdl2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\"

File diff suppressed because it is too large Load Diff

View File

@ -21,10 +21,6 @@
#ifndef _AUDIO_H_
#define _AUDIO_H_
#ifdef _WIN32
#include <guiddef.h>
#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();

View File

@ -18,10 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifdef _WIN32
#include <dsound.h>
#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;
}

View File

@ -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

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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)

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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();

View File

@ -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;

View File

@ -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;
}