diff --git a/src_rebuild/PsyX/include/PSYX_PUBLIC.H b/src_rebuild/PsyX/include/PSYX_PUBLIC.H index 8c8fab12..d3cf1cf0 100644 --- a/src_rebuild/PsyX/include/PSYX_PUBLIC.H +++ b/src_rebuild/PsyX/include/PSYX_PUBLIC.H @@ -91,9 +91,6 @@ extern void PsyX_EndScene(); /* Explicitly updates emulator input loop */ extern void PsyX_UpdateInput(); -/* Usually called at the end if main function */ -extern void PsyX_ShutDown(); - /* Screen size of emulated PSX viewport with widescreen offsets */ extern void PsyX_GetPSXWidescreenMappedViewport(struct _RECT16* rect); diff --git a/src_rebuild/PsyX/src/PSX/LIBSPU.C b/src_rebuild/PsyX/src/PSX/LIBSPU.C index 4508d00d..253b06c7 100644 --- a/src_rebuild/PsyX/src/PSX/LIBSPU.C +++ b/src_rebuild/PsyX/src/PSX/LIBSPU.C @@ -97,11 +97,14 @@ int g_enableSPUReverb = 0; int g_ALEffectsSupported = 0; LPALGENEFFECTS alGenEffects = NULL; +LPALDELETEEFFECTS alDeleteEffects = NULL; LPALEFFECTI alEffecti = NULL; LPALEFFECTF alEffectf = NULL; LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots = NULL; +LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots = NULL; LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti = NULL; + void InitOpenAlEffects() { g_ALEffectsSupported = 0; @@ -113,9 +116,11 @@ void InitOpenAlEffects() } alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects"); + alDeleteEffects = (LPALDELETEEFFECTS)alGetProcAddress("alDeleteEffects"); alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti"); alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf"); alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots"); + alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots"); alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti"); int max_sends = 0; @@ -234,10 +239,18 @@ void PsyX_ShutdownSound() for (int i = 0; i < SPU_VOICES; i++) { SPUVoice& voice = g_SpuVoices[i]; - alGenSources(1, &voice.alSource); - alGenBuffers(1, &voice.alBuffer); + alDeleteSources(1, &voice.alSource); + alDeleteBuffers(1, &voice.alBuffer); } + if (g_ALEffectsSupported) + { + alDeleteEffects(1, &g_nAlReverbEffect); + g_ALEffectsSupported = AL_NONE; + } + + alDeleteAuxiliaryEffectSlots(1, g_ALEffectSlots); + alcDestroyContext(g_ALCcontext); alcCloseDevice(g_ALCdevice); diff --git a/src_rebuild/PsyX/src/PSYX.C b/src_rebuild/PsyX/src/PSYX.C index 3fd5fc3c..beeae467 100644 --- a/src_rebuild/PsyX/src/PSYX.C +++ b/src_rebuild/PsyX/src/PSYX.C @@ -419,35 +419,35 @@ void PsyX_Initialise(char* appName, int width, int height, int fullscreen) if (SDL_Init(SDL_INIT_VIDEO) != 0) { eprinterr("Failed to initialise SDL\n"); - PsyX_ShutDown(); + PsyX_Shutdown(); return; } if (!GR_InitialiseRender(windowNameStr, width, height, fullscreen)) { eprinterr("Failed to Intialise Window\n"); - PsyX_ShutDown(); + PsyX_Shutdown(); return; } if (!PsyX_Sys_InitialiseCore()) { eprinterr("Failed to Intialise Psy-X Core.\n"); - PsyX_ShutDown(); + PsyX_Shutdown(); return; } if (!GR_InitialisePSX()) { eprinterr("Failed to Intialise PSX.\n"); - PsyX_ShutDown(); + PsyX_Shutdown(); return; } PsyX_Sys_InitialiseInput(); // set shutdown function (PSX apps usualy don't exit) - atexit(PsyX_ShutDown); + atexit(PsyX_Shutdown); } void PsyX_GetScreenSize(int& screenWidth, int& screenHeight) @@ -722,7 +722,7 @@ void PsyX_Exit() exit(0); } -void PsyX_ShutDown() +void PsyX_Shutdown() { if (!g_window) return; diff --git a/src_rebuild/PsyX/src/RENDER/PsyX_RENDER.C b/src_rebuild/PsyX/src/RENDER/PsyX_RENDER.C index e53cc108..7cabda76 100644 --- a/src_rebuild/PsyX/src/RENDER/PsyX_RENDER.C +++ b/src_rebuild/PsyX/src/RENDER/PsyX_RENDER.C @@ -430,7 +430,7 @@ int GR_InitialiseRender(char* windowName, int width, int height, int fullscreen) if (!GR_InitialiseGLExt()) { eprinterr("Failed to Intialise GL extensions\n"); - PsyX_ShutDown(); + return 0; } #endif diff --git a/src_rebuild/redriver2_psxpc.cpp b/src_rebuild/redriver2_psxpc.cpp index 12e25f92..e032f340 100644 --- a/src_rebuild/redriver2_psxpc.cpp +++ b/src_rebuild/redriver2_psxpc.cpp @@ -681,5 +681,7 @@ int main(int argc, char** argv) DeinitStringMng(); + PsyX_Shutdown(); + return 0; }