mirror of
https://github.com/alexbatalov/fallout2-ce.git
synced 2024-09-03 21:39:07 +00:00
parent
6dd55e4ee9
commit
ca68373e74
@ -233,6 +233,7 @@ add_executable(${EXECUTABLE_NAME} WIN32
|
||||
)
|
||||
|
||||
target_sources(${EXECUTABLE_NAME} PUBLIC
|
||||
"src/dsound_compat.h"
|
||||
"src/fps_limiter.cc"
|
||||
"src/fps_limiter.h"
|
||||
"src/platform_compat.cc"
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "tile.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// 0x51805C
|
||||
@ -1399,7 +1400,6 @@ Object* _ai_danger_source(Object* a1)
|
||||
attackWho = -1;
|
||||
}
|
||||
|
||||
|
||||
Object* whoHitMe = a1->data.critter.combat.whoHitMe;
|
||||
if (whoHitMe == NULL || a1 == whoHitMe) {
|
||||
targets[0] = NULL;
|
||||
|
17
src/dsound_compat.h
Normal file
17
src/dsound_compat.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef DSOUND_COMPAT_H
|
||||
#define DSOUND_COMPAT_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#define HAVE_DSOUND 1
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
#include <mmreg.h>
|
||||
|
||||
#define DIRECTSOUND_VERSION 0x0300
|
||||
#include <dsound.h>
|
||||
#endif
|
||||
|
||||
#endif /* DSOUND_COMPAT_H */
|
@ -330,8 +330,12 @@ int _noop()
|
||||
void movieInit()
|
||||
{
|
||||
movieLibSetMemoryProcs(movieMallocImpl, movieFreeImpl);
|
||||
#ifdef HAVE_DSOUND
|
||||
movieLibSetDirectSound(gDirectSound);
|
||||
gMovieDirectSoundInitialized = (gDirectSound != NULL);
|
||||
#else
|
||||
gMovieDirectSoundInitialized = false;
|
||||
#endif
|
||||
movieLibSetPaletteEntriesProc(movieSetPaletteEntriesImpl);
|
||||
_MVE_sfSVGA(640, 480, 480, 0, 0, 0, 0, 0, 0);
|
||||
movieLibSetReadProc(movieReadImpl);
|
||||
|
@ -63,11 +63,15 @@ int _sync_late = 0;
|
||||
// 0x51EDEC
|
||||
int _sync_FrameDropped = 0;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x51EDF0
|
||||
LPDIRECTSOUND gMovieLibDirectSound = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x51EDF4
|
||||
LPDIRECTSOUNDBUFFER gMovieLibDirectSoundBuffer = NULL;
|
||||
#endif
|
||||
|
||||
// 0x51EDF8
|
||||
int gMovieLibVolume = 0;
|
||||
@ -261,8 +265,10 @@ unsigned int _$$R0063[256] = {
|
||||
// 0x6B3660
|
||||
int dword_6B3660;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x6B3668
|
||||
DSBCAPS stru_6B3668;
|
||||
#endif
|
||||
|
||||
// 0x6B367C
|
||||
int _sf_ScreenWidth;
|
||||
@ -469,20 +475,24 @@ void _MVE_MemFree(STRUCT_6B3690* a1)
|
||||
a1->field_4 = 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x4F48F0
|
||||
void movieLibSetDirectSound(LPDIRECTSOUND ds)
|
||||
{
|
||||
gMovieLibDirectSound = ds;
|
||||
}
|
||||
#endif
|
||||
|
||||
// 0x4F4900
|
||||
void movieLibSetVolume(int volume)
|
||||
{
|
||||
gMovieLibVolume = volume;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
if (gMovieLibDirectSoundBuffer != NULL) {
|
||||
IDirectSoundBuffer_SetVolume(gMovieLibDirectSoundBuffer, volume);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F4920
|
||||
@ -490,9 +500,11 @@ void movieLibSetPan(int pan)
|
||||
{
|
||||
gMovieLibPan = pan;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
if (gMovieLibDirectSoundBuffer != NULL) {
|
||||
IDirectSoundBuffer_SetPan(gMovieLibDirectSoundBuffer, pan);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F4940
|
||||
@ -733,9 +745,11 @@ int _syncWait()
|
||||
// 0x4F4EA0
|
||||
void _MVE_sndPause()
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (gMovieLibDirectSoundBuffer != NULL) {
|
||||
IDirectSoundBuffer_Stop(gMovieLibDirectSoundBuffer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F4EC0
|
||||
@ -1051,6 +1065,7 @@ void _syncReset(int a1)
|
||||
// 0x4F5570
|
||||
int _MVE_sndConfigure(int a1, int a2, int a3, int a4, int a5, int a6)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
DSBUFFERDESC dsbd;
|
||||
WAVEFORMATEX wfxFormat;
|
||||
|
||||
@ -1096,6 +1111,9 @@ int _MVE_sndConfigure(int a1, int a2, int a3, int a4, int a5, int a6)
|
||||
}
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F56C0
|
||||
@ -1110,16 +1128,19 @@ void _MVE_syncSync()
|
||||
// 0x4F56F0
|
||||
void _MVE_sndReset()
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (gMovieLibDirectSoundBuffer != NULL) {
|
||||
IDirectSoundBuffer_Stop(gMovieLibDirectSoundBuffer);
|
||||
IDirectSoundBuffer_Release(gMovieLibDirectSoundBuffer);
|
||||
gMovieLibDirectSoundBuffer = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F5720
|
||||
void _MVE_sndSync()
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
DWORD dwCurrentPlayCursor;
|
||||
DWORD dwCurrentWriteCursor;
|
||||
bool v10;
|
||||
@ -1257,6 +1278,10 @@ void _MVE_sndSync()
|
||||
++dword_6B3660;
|
||||
}
|
||||
}
|
||||
#else
|
||||
_sync_late = _syncWaitLevel(_sync_wait_quanta >> 2) > -_sync_wait_quanta >> 1 && !_sync_FrameDropped;
|
||||
_sync_FrameDropped = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F59B0
|
||||
@ -1282,6 +1307,7 @@ int _syncWaitLevel(int a1)
|
||||
// 0x4F5A00
|
||||
void _CallsSndBuff_Loc(unsigned char* a1, int a2)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
int v2;
|
||||
int v3;
|
||||
int v5;
|
||||
@ -1343,6 +1369,7 @@ void _CallsSndBuff_Loc(unsigned char* a1, int a2)
|
||||
} else {
|
||||
++dword_6B3AE4;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4F5B70
|
||||
|
@ -1,13 +1,11 @@
|
||||
#ifndef MOVIE_LIB_H
|
||||
#define MOVIE_LIB_H
|
||||
|
||||
#include "dsound_compat.h"
|
||||
#include "memory_defs.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#define DIRECTSOUND_VERSION 0x0300
|
||||
#include <dsound.h>
|
||||
|
||||
typedef struct STRUCT_6B3690 {
|
||||
void* field_0;
|
||||
int field_4;
|
||||
@ -56,8 +54,10 @@ extern unsigned short word_51EBE0[256];
|
||||
extern int _sync_active;
|
||||
extern int _sync_late;
|
||||
extern int _sync_FrameDropped;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern LPDIRECTSOUND gMovieLibDirectSound;
|
||||
extern LPDIRECTSOUNDBUFFER gMovieLibDirectSoundBuffer;
|
||||
#endif
|
||||
extern int gMovieLibVolume;
|
||||
extern int gMovieLibPan;
|
||||
extern MovieShowFrameProc* _sf_ShowFrame;
|
||||
@ -74,7 +74,9 @@ extern unsigned int _$$R0004[256];
|
||||
extern unsigned int _$$R0063[256];
|
||||
|
||||
extern int dword_6B3660;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern DSBCAPS stru_6B3668;
|
||||
#endif
|
||||
extern int _sf_ScreenWidth;
|
||||
extern int dword_6B3680;
|
||||
extern int _rm_FrameDropCount;
|
||||
@ -138,7 +140,9 @@ void movieLibSetMemoryProcs(MallocProc* mallocProc, FreeProc* freeProc);
|
||||
void movieLibSetReadProc(MovieReadProc* readProc);
|
||||
void _MVE_MemInit(STRUCT_6B3690* a1, int a2, void* a3);
|
||||
void _MVE_MemFree(STRUCT_6B3690* a1);
|
||||
#ifdef HAVE_DSOUND
|
||||
void movieLibSetDirectSound(LPDIRECTSOUND ds);
|
||||
#endif
|
||||
void movieLibSetVolume(int volume);
|
||||
void movieLibSetPan(int pan);
|
||||
void _MVE_sfSVGA(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "window_manager_private.h"
|
||||
#include "world_map.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
116
src/sound.cc
116
src/sound.cc
@ -80,6 +80,7 @@ const char* gSoundErrorDescriptions[SOUND_ERR_COUNT] = {
|
||||
"sound.c: invalid handle",
|
||||
"sound.c: no memory available",
|
||||
"sound.c: unknown error",
|
||||
"sound.c: not implemented",
|
||||
};
|
||||
|
||||
// 0x668150
|
||||
@ -88,8 +89,10 @@ int gSoundLastError;
|
||||
// 0x668154
|
||||
int _masterVol;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x668158
|
||||
LPDIRECTSOUNDBUFFER gDirectSoundPrimaryBuffer;
|
||||
#endif
|
||||
|
||||
// 0x66815C
|
||||
int _sampleRate;
|
||||
@ -114,8 +117,10 @@ bool gSoundInitialized;
|
||||
// 0x668174
|
||||
Sound* gSoundListHead;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x668178
|
||||
LPDIRECTSOUND gDirectSound;
|
||||
#endif
|
||||
|
||||
// 0x4AC6F0
|
||||
void* soundMallocProcDefaultImpl(size_t size)
|
||||
@ -166,6 +171,7 @@ const char* soundGetErrorDescription(int err)
|
||||
// 0x4AC7B0
|
||||
void _refreshSoundBuffers(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (sound->field_3C & 0x80) {
|
||||
return;
|
||||
}
|
||||
@ -340,11 +346,13 @@ void _refreshSoundBuffers(Sound* sound)
|
||||
sound->field_70 = v6;
|
||||
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ACC58
|
||||
int soundInit(int a1, int a2, int a3, int a4, int rate)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
DWORD v24;
|
||||
|
||||
@ -475,11 +483,16 @@ out:
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD04C
|
||||
void soundExit()
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
while (gSoundListHead != NULL) {
|
||||
Sound* next = gSoundListHead->next;
|
||||
soundDelete(gSoundListHead);
|
||||
@ -508,11 +521,13 @@ void soundExit()
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
gSoundInitialized = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD0FC
|
||||
Sound* soundAllocate(int a1, int a2)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return NULL;
|
||||
@ -588,6 +603,10 @@ Sound* soundAllocate(int a1, int a2)
|
||||
gSoundListHead = sound;
|
||||
|
||||
return sound;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD308
|
||||
@ -680,6 +699,7 @@ int soundLoad(Sound* sound, char* filePath)
|
||||
// 0x4AD504
|
||||
int _soundRewind(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
|
||||
if (!gSoundInitialized) {
|
||||
@ -713,11 +733,16 @@ int _soundRewind(Sound* sound)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD5C8
|
||||
int _addSoundData(Sound* sound, unsigned char* buf, int size)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
void* audio_ptr_1;
|
||||
DWORD audio_bytes_1;
|
||||
@ -749,11 +774,16 @@ int _addSoundData(Sound* sound, unsigned char* buf, int size)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD6C0
|
||||
int _soundSetData(Sound* sound, unsigned char* buf, int size)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return gSoundLastError;
|
||||
@ -774,11 +804,16 @@ int _soundSetData(Sound* sound, unsigned char* buf, int size)
|
||||
}
|
||||
|
||||
return _addSoundData(sound, buf, size);
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD73C
|
||||
int soundPlay(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
DWORD readPos;
|
||||
DWORD writePos;
|
||||
@ -816,11 +851,16 @@ int soundPlay(Sound* sound)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD828
|
||||
int soundStop(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
|
||||
if (!gSoundInitialized) {
|
||||
@ -849,6 +889,10 @@ int soundStop(Sound* sound)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AD8DC
|
||||
@ -878,6 +922,7 @@ int soundDelete(Sound* sample)
|
||||
// 0x4AD948
|
||||
int soundContinue(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
DWORD status;
|
||||
|
||||
@ -942,11 +987,16 @@ int soundContinue(Sound* sound)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADA84
|
||||
bool soundIsPlaying(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return false;
|
||||
@ -958,11 +1008,16 @@ bool soundIsPlaying(Sound* sound)
|
||||
}
|
||||
|
||||
return (sound->field_40 & SOUND_FLAG_SOUND_IS_PLAYING) != 0;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADAC4
|
||||
bool _soundDone(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return false;
|
||||
@ -974,11 +1029,16 @@ bool _soundDone(Sound* sound)
|
||||
}
|
||||
|
||||
return sound->field_40 & 1;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADB44
|
||||
bool soundIsPaused(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return false;
|
||||
@ -990,11 +1050,16 @@ bool soundIsPaused(Sound* sound)
|
||||
}
|
||||
|
||||
return (sound->field_40 & SOUND_FLAG_SOUND_IS_PAUSED) != 0;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADBC4
|
||||
int _soundType(Sound* sound, int a2)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return 0;
|
||||
@ -1006,11 +1071,16 @@ int _soundType(Sound* sound, int a2)
|
||||
}
|
||||
|
||||
return sound->field_44 & a2;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADC04
|
||||
int soundGetDuration(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return gSoundLastError;
|
||||
@ -1030,6 +1100,10 @@ int soundGetDuration(Sound* sound)
|
||||
}
|
||||
|
||||
return result;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADD00
|
||||
@ -1083,6 +1157,7 @@ int _soundVolumeHMItoDirectSound(int volume)
|
||||
// 0x4ADE0C
|
||||
int soundSetVolume(Sound* sound, int volume)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
int normalizedVolume;
|
||||
HRESULT hr;
|
||||
|
||||
@ -1113,11 +1188,16 @@ int soundSetVolume(Sound* sound, int volume)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADE80
|
||||
int _soundGetVolume(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
long volume;
|
||||
int v13;
|
||||
int v8;
|
||||
@ -1150,6 +1230,10 @@ int _soundGetVolume(Sound* sound)
|
||||
}
|
||||
|
||||
return sound->volume;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4ADFF0
|
||||
@ -1175,6 +1259,7 @@ int soundSetCallback(Sound* sound, SoundCallback* callback, void* userData)
|
||||
// 0x4AE02C
|
||||
int soundSetChannels(Sound* sound, int channels)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
LPWAVEFORMATEX format;
|
||||
|
||||
if (!gSoundInitialized) {
|
||||
@ -1197,6 +1282,10 @@ int soundSetChannels(Sound* sound, int channels)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AE0B0
|
||||
@ -1223,6 +1312,7 @@ int soundSetReadLimit(Sound* sound, int readLimit)
|
||||
// 0x4AE0E4
|
||||
int soundPause(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
DWORD readPos;
|
||||
DWORD writePos;
|
||||
@ -1262,6 +1352,10 @@ int soundPause(Sound* sound)
|
||||
sound->field_40 |= SOUND_FLAG_SOUND_IS_PAUSED;
|
||||
|
||||
return soundStop(sound);
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: Check, looks like it uses couple of inlined functions.
|
||||
@ -1269,6 +1363,7 @@ int soundPause(Sound* sound)
|
||||
// 0x4AE1F0
|
||||
int soundResume(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
HRESULT hr;
|
||||
|
||||
if (!gSoundInitialized) {
|
||||
@ -1301,6 +1396,10 @@ int soundResume(Sound* sound)
|
||||
sound->field_48 = 0;
|
||||
|
||||
return soundPlay(sound);
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AE2FC
|
||||
@ -1351,6 +1450,7 @@ int soundSetFileIO(Sound* sound, SoundOpenProc* openProc, SoundCloseProc* closeP
|
||||
// 0x4AE378
|
||||
void soundDeleteInternal(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
STRUCT_51D478* curr;
|
||||
Sound* v10;
|
||||
Sound* v11;
|
||||
@ -1409,6 +1509,7 @@ void soundDeleteInternal(Sound* sound)
|
||||
}
|
||||
|
||||
gSoundFreeProc(sound);
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AE578
|
||||
@ -1454,6 +1555,7 @@ void _removeTimedEvent(unsigned int* timerId)
|
||||
// 0x4AE634
|
||||
int _soundGetPosition(Sound* sound)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return gSoundLastError;
|
||||
@ -1477,11 +1579,16 @@ int _soundGetPosition(Sound* sound)
|
||||
}
|
||||
|
||||
return playPos;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AE6CC
|
||||
int _soundSetPosition(Sound* sound, int a2)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (!gSoundInitialized) {
|
||||
gSoundLastError = SOUND_NOT_INITIALIZED;
|
||||
return gSoundLastError;
|
||||
@ -1529,6 +1636,10 @@ int _soundSetPosition(Sound* sound, int a2)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AE830
|
||||
@ -1613,6 +1724,7 @@ void _fadeSounds()
|
||||
// 0x4AE988
|
||||
int _internalSoundFade(Sound* sound, int a2, int a3, int a4)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
STRUCT_51D478* ptr;
|
||||
|
||||
if (!_deviceInit) {
|
||||
@ -1701,6 +1813,10 @@ int _internalSoundFade(Sound* sound, int a2, int a3, int a4)
|
||||
|
||||
gSoundLastError = SOUND_NO_ERROR;
|
||||
return gSoundLastError;
|
||||
#else
|
||||
gSoundLastError = SOUND_NOT_IMPLEMENTED;
|
||||
return gSoundLastError;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4AEB0C
|
||||
|
@ -44,6 +44,8 @@ typedef enum SoundError {
|
||||
SOUND_INVALID_HANDLE = 30,
|
||||
SOUND_NO_MEMORY_AVAILABLE = 31,
|
||||
SOUND_UNKNOWN_ERROR = 32,
|
||||
// TODO: Remove once DirectX -> SDL transition is completed.
|
||||
SOUND_NOT_IMPLEMENTED = 33,
|
||||
SOUND_ERR_COUNT,
|
||||
} SoundError;
|
||||
|
||||
@ -72,8 +74,10 @@ typedef void SoundCallback(void* userData, int a2);
|
||||
typedef struct Sound {
|
||||
SoundFileIO io;
|
||||
unsigned char* field_20;
|
||||
#ifdef HAVE_DSOUND
|
||||
LPDIRECTSOUNDBUFFER directSoundBuffer;
|
||||
DSBUFFERDESC directSoundBufferDescription;
|
||||
#endif
|
||||
int field_3C;
|
||||
// flags
|
||||
int field_40;
|
||||
@ -128,7 +132,9 @@ extern const char* gSoundErrorDescriptions[SOUND_ERR_COUNT];
|
||||
|
||||
extern int gSoundLastError;
|
||||
extern int _masterVol;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern LPDIRECTSOUNDBUFFER gDirectSoundPrimaryBuffer;
|
||||
#endif
|
||||
extern int _sampleRate;
|
||||
extern int _numSounds;
|
||||
extern int _deviceInit;
|
||||
@ -136,7 +142,9 @@ extern int _dataSize;
|
||||
extern int _numBuffers;
|
||||
extern bool gSoundInitialized;
|
||||
extern Sound* gSoundListHead;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern LPDIRECTSOUND gDirectSound;
|
||||
#endif
|
||||
|
||||
void* soundMallocProcDefaultImpl(size_t size);
|
||||
void* soundReallocProcDefaultImpl(void* ptr, size_t size);
|
||||
|
11
src/win32.cc
11
src/win32.cc
@ -5,9 +5,12 @@
|
||||
#include "window_manager.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x51E430
|
||||
DirectSoundCreateProc* gDirectSoundCreateProc = NULL;
|
||||
#endif
|
||||
|
||||
// 0x51E434
|
||||
HWND gProgramWindow = NULL;
|
||||
@ -18,8 +21,10 @@ bool gProgramIsActive = false;
|
||||
// GNW95MUTEX
|
||||
HANDLE _GNW95_mutex = NULL;
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
// 0x51E454
|
||||
HMODULE gDSoundDLL = NULL;
|
||||
#endif
|
||||
|
||||
// 0x4DE700
|
||||
int main(int argc, char* argv[])
|
||||
@ -39,6 +44,7 @@ int main(int argc, char* argv[])
|
||||
// 0x4DE8D0
|
||||
bool _LoadDirectX()
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
gDSoundDLL = LoadLibraryA("DSOUND.DLL");
|
||||
if (gDSoundDLL == NULL) {
|
||||
goto err;
|
||||
@ -48,6 +54,7 @@ bool _LoadDirectX()
|
||||
if (gDirectSoundCreateProc == NULL) {
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
atexit(_UnloadDirectX);
|
||||
|
||||
@ -55,7 +62,7 @@ bool _LoadDirectX()
|
||||
|
||||
err:
|
||||
_UnloadDirectX();
|
||||
|
||||
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Could not load DirectX", "This program requires DirectX 3.0a or later.", NULL);
|
||||
|
||||
return false;
|
||||
@ -64,8 +71,10 @@ err:
|
||||
// 0x4DE988
|
||||
void _UnloadDirectX(void)
|
||||
{
|
||||
#ifdef HAVE_DSOUND
|
||||
if (gDSoundDLL != NULL) {
|
||||
FreeLibrary(gDSoundDLL);
|
||||
gDSoundDLL = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
14
src/win32.h
14
src/win32.h
@ -1,23 +1,25 @@
|
||||
#ifndef WIN32_H
|
||||
#define WIN32_H
|
||||
|
||||
#include "dsound_compat.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
#include <mmreg.h>
|
||||
|
||||
#define DIRECTSOUND_VERSION 0x0300
|
||||
#include <dsound.h>
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
typedef HRESULT(__stdcall DirectSoundCreateProc)(GUID*, LPDIRECTSOUND*, IUnknown*);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DSOUND
|
||||
extern DirectSoundCreateProc* gDirectSoundCreateProc;
|
||||
#endif
|
||||
extern HWND gProgramWindow;
|
||||
extern bool gProgramIsActive;
|
||||
extern HANDLE _GNW95_mutex;
|
||||
#ifdef HAVE_DSOUND
|
||||
extern HMODULE gDSoundDLL;
|
||||
|
||||
#endif
|
||||
bool _LoadDirectX();
|
||||
void _UnloadDirectX(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user