mirror of https://github.com/OpenRCT2/OpenRCT2.git
Decompiled audio functions
This commit is contained in:
parent
5c01091043
commit
31e2e4919a
|
@ -154,8 +154,11 @@
|
|||
|
||||
#define RCT2_ADDRESS_WINDOW_DPI 0x009DEA74
|
||||
|
||||
#define RCT2_ADDRESS_DSOUND_BUFFERS 0x009E1AB0
|
||||
#define RCT2_ADDRESS_NUM_DSOUND_DEVICES 0x009E2B88
|
||||
#define RCT2_ADDRESS_DSOUND_DEVICES 0x009E2B8C
|
||||
#define RCT2_ADDRESS_SOUNDLIST_END 0x009E2B98
|
||||
#define RCT2_ADDRESS_SOUNDLIST_BEGIN 0x009E2B9C
|
||||
|
||||
#define RCT2_ADDRESS_CMDLINE 0x009E2D98
|
||||
|
||||
|
|
173
src/audio.c
173
src/audio.c
|
@ -65,6 +65,10 @@ void audio_get_devices()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0040502E
|
||||
*/
|
||||
void get_dsound_devices()
|
||||
{
|
||||
RCT2_CALLPROC(0x0040502E);
|
||||
|
@ -80,14 +84,177 @@ void sound_play_panned(int sound_id, int x)
|
|||
RCT2_CALLPROC_X(0x006BB76E, sound_id, x, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency)
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00401999
|
||||
*/
|
||||
int sound_channel_play(int channel, int a2, int volume, int pan, int frequency)
|
||||
{
|
||||
return RCT2_CALLFUNC_5(0x00404E7F, int, rct_sound*, int, int, int, int, sound, looping, volume, pan, frequency);
|
||||
RCT2_GLOBAL(0x1426444 + (91 * channel * 4), uint32) = 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);
|
||||
RCT2_GLOBAL(0x14262E0 + (91 * channel * 4), uint32) = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00401A93
|
||||
*/
|
||||
int sound_channel_set_frequency(int channel, int frequency)
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
|
||||
if(dsbuffer){
|
||||
if(SUCCEEDED(dsbuffer->lpVtbl->SetFrequency(dsbuffer, frequency))){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00401AB3
|
||||
*/
|
||||
int sound_channel_set_pan(int channel, int pan)
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
|
||||
if(dsbuffer){
|
||||
if(SUCCEEDED(dsbuffer->lpVtbl->SetPan(dsbuffer, pan))){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00401AD3
|
||||
*/
|
||||
int sound_channel_set_volume(int channel, int volume)
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
|
||||
if(dsbuffer){
|
||||
if(SUCCEEDED(dsbuffer->lpVtbl->SetVolume(dsbuffer, volume))){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00404E7F
|
||||
*/
|
||||
int sound_play(rct_sound* sound, int looping, int volume, int pan, int frequency)
|
||||
{
|
||||
if(sound){
|
||||
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;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00404ED7
|
||||
*/
|
||||
int sound_set_frequency(rct_sound* sound, int frequency)
|
||||
{
|
||||
if(sound){
|
||||
if(SUCCEEDED(sound->dsbuffer->lpVtbl->SetFrequency(sound->dsbuffer, frequency))){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00404EF2
|
||||
*/
|
||||
int sound_set_pan(rct_sound* sound, int pan)
|
||||
{
|
||||
if(sound){
|
||||
if(SUCCEEDED(sound->dsbuffer->lpVtbl->SetPan(sound->dsbuffer, pan))){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00404F0D
|
||||
*/
|
||||
int sound_set_volume(rct_sound* sound, int volume)
|
||||
{
|
||||
if(sound){
|
||||
if(SUCCEEDED(sound->dsbuffer->lpVtbl->SetVolume(sound->dsbuffer, volume))){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00404DD8
|
||||
*/
|
||||
void sound_stop(rct_sound* sound)
|
||||
{
|
||||
RCT2_CALLPROC_1(0x00404DD8, rct_sound*, sound);
|
||||
if(sound->dsbuffer){
|
||||
sound->dsbuffer->lpVtbl->Release(sound);
|
||||
sound->dsbuffer = 0;
|
||||
sound_remove(sound);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00405143
|
||||
*/
|
||||
rct_sound* sound_remove(rct_sound* sound)
|
||||
{
|
||||
rct_sound* result = RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*);
|
||||
if(sound == result){
|
||||
if(sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = 0;
|
||||
}
|
||||
result = sound->prev;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = result;
|
||||
}
|
||||
else{
|
||||
while(result->prev != sound){
|
||||
result = result->prev;
|
||||
}
|
||||
if(sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = result;
|
||||
result->prev = 0;
|
||||
}
|
||||
else{
|
||||
result->prev = sound->prev;
|
||||
}
|
||||
}
|
||||
sound->prev = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
10
src/audio.h
10
src/audio.h
|
@ -52,14 +52,22 @@ typedef struct {
|
|||
int id;
|
||||
int has_caps;
|
||||
int var_0C;
|
||||
int var_10;
|
||||
struct rct_sound* prev;
|
||||
} rct_sound;
|
||||
|
||||
void get_dsound_devices();
|
||||
int sound_prepare(int sound_id, rct_sound *sound, int var_8, int var_c);
|
||||
void sound_play_panned(int sound_id, int x);
|
||||
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_channel_play(int channel, int a2, int volume, int pan, int frequency);
|
||||
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 sound_stop(rct_sound *sound);
|
||||
rct_sound* sound_remove(rct_sound* sound);
|
||||
void pause_sounds();
|
||||
void unpause_sounds();
|
||||
|
||||
|
|
|
@ -109,7 +109,9 @@ typedef struct {
|
|||
uint16 build_date;
|
||||
sint16 upkeep_cost; // 0x182
|
||||
uint16 race_winner; // 0x184
|
||||
uint8 pad_186[0x10];
|
||||
uint8 pad_186[0x06];
|
||||
uint8 var_18C;
|
||||
uint8 pad_18D[0x09];
|
||||
uint16 var_196;
|
||||
// used in computing excitement, nausea, etc
|
||||
uint8 var_198;
|
||||
|
|
|
@ -35,8 +35,27 @@ typedef struct {
|
|||
sint16 x; // 0x0E
|
||||
sint16 y; // 0x10
|
||||
sint16 z; // 0x12
|
||||
uint8 pad_14[0x2A];
|
||||
uint8 pad_14[0x0B];
|
||||
uint8 var_1F;
|
||||
uint8 pad_20[0x08];
|
||||
uint32 var_28;
|
||||
uint8 pad_2C[0x04];
|
||||
uint8 ride; // 0x30
|
||||
uint8 var_31;
|
||||
uint8 pad_32[0x0C];
|
||||
uint16 next_vehicle_on_train; // 0x3E
|
||||
uint8 pad_40[0x08];
|
||||
uint16 var_48;
|
||||
uint8 pad_4A[0x06];
|
||||
uint8 var_50;
|
||||
uint8 var_51;
|
||||
uint8 pad_52[0x69];
|
||||
uint16 var_BB;
|
||||
uint16 var_BD;
|
||||
uint8 pad_BF[0x0D];
|
||||
uint8 var_CC;
|
||||
uint8 pad_CD[0x09];
|
||||
uint8 var_D6;
|
||||
} rct_vehicle;
|
||||
|
||||
void vehicle_update_all();
|
||||
|
|
Loading…
Reference in New Issue