Skip to content

Commit 92c5b67

Browse files
committed
FF8: Make Creative EAX Unified as an optional dependency
1 parent 8b047aa commit 92c5b67

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
- SFX: Add missing support for audio effects to be stopped in time
3434
- Speedhack: Fix support in field which were not getting the real speed up despite FFNx prompting it on screen.
3535

36+
# FF8 2000
37+
38+
- Audio: Creative EAX Unified is now optional to launch the game ( https://github.com/julianxhokaxhiu/FFNx/pull/718 )
39+
3640
# FF8 Steam
3741

3842
- Files: Fix `app_path` option support ( https://github.com/julianxhokaxhiu/FFNx/pull/714 )

src/common.cpp

+25-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <mmsystem.h>
3636
#include <malloc.h>
3737
#include <ddraw.h>
38+
#include <filesystem>
3839

3940
#include "renderer.h"
4041
#include "hext.h"
@@ -3419,15 +3420,33 @@ __declspec(dllexport) BOOL __stdcall dotemuDeleteFileA(LPCSTR lpFileName)
34193420
__declspec(dllexport) HRESULT __stdcall EAXDirectSoundCreate(LPGUID guid, LPLPDIRECTSOUND directsound, IUnknown FAR* unk)
34203421
{
34213422
typedef HRESULT(FAR PASCAL* LPEAXDIRECTSOUNDCREATE)(LPGUID, LPLPDIRECTSOUND, IUnknown FAR*);
3423+
char eax_dll[MAX_PATH] = {};
34223424

3423-
char eax_dll[MAX_PATH];
3424-
GetSystemDirectoryA(eax_dll, sizeof(eax_dll));
3425-
strcat(eax_dll, R"(\eax.dll)");
3425+
if (std::filesystem::exists("creative_eax.dll")) {
3426+
// For portable installation, this name can be used to load the official Creative EAX 2.0+ DLL along with FFNx
3427+
snprintf(eax_dll, sizeof(eax_dll), R"(%s\creative_eax.dll)", basedir);
3428+
} else {
3429+
GetSystemDirectoryA(eax_dll, sizeof(eax_dll));
3430+
strcat(eax_dll, R"(\eax.dll)");
3431+
}
3432+
3433+
FARPROC procDSoundCreate = NULL;
3434+
HMODULE hDll = LoadLibraryA(eax_dll);
3435+
if (hDll != NULL) {
3436+
procDSoundCreate = GetProcAddress(hDll, "EAXDirectSoundCreate");
3437+
}
34263438

3427-
HMODULE hEaxDll = LoadLibraryA(eax_dll);
3428-
FARPROC procEaxDSoundCreate = GetProcAddress((HMODULE)hEaxDll, "EAXDirectSoundCreate");
3439+
if (procDSoundCreate == NULL) {
3440+
ffnx_warning("%s: Cannot load EAX Library, please install Creative EAX Unified redistribuable version 2.0+\n", __func__);
3441+
3442+
hDll = LoadLibraryA("dsound.dll");
3443+
if (hDll != NULL) {
3444+
// EAXDirectSoundCreate is basically DirectSoundCreate with more features
3445+
procDSoundCreate = GetProcAddress(hDll, "DirectSoundCreate");
3446+
}
3447+
}
34293448

3430-
return ((LPEAXDIRECTSOUNDCREATE)procEaxDSoundCreate)(guid, directsound, unk);
3449+
return LPEAXDIRECTSOUNDCREATE(procDSoundCreate)(guid, directsound, unk);
34313450
}
34323451

34333452
void ffnx_inject_driver(struct game_obj* game_object)

0 commit comments

Comments
 (0)