Skip to content

Commit

Permalink
FF8: Make Creative EAX Unified as an optional dependency (julianxhoka…
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re authored Aug 23, 2024
1 parent 8b047aa commit 1ab9391
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
- SFX: Add missing support for audio effects to be stopped in time
- Speedhack: Fix support in field which were not getting the real speed up despite FFNx prompting it on screen.

# FF8 2000

- Audio: Creative EAX Unified is now optional to launch the game ( https://github.com/julianxhokaxhiu/FFNx/pull/718 )

# FF8 Steam

- Files: Fix `app_path` option support ( https://github.com/julianxhokaxhiu/FFNx/pull/714 )
Expand Down
31 changes: 25 additions & 6 deletions src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <mmsystem.h>
#include <malloc.h>
#include <ddraw.h>
#include <filesystem>

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

char eax_dll[MAX_PATH];
GetSystemDirectoryA(eax_dll, sizeof(eax_dll));
strcat(eax_dll, R"(\eax.dll)");
if (std::filesystem::exists("creative_eax.dll")) {
// For portable installation, this name can be used to load the official Creative EAX 2.0+ DLL along with FFNx
snprintf(eax_dll, sizeof(eax_dll), R"(%s\creative_eax.dll)", basedir);
} else {
GetSystemDirectoryA(eax_dll, sizeof(eax_dll));
strcat(eax_dll, R"(\eax.dll)");
}

FARPROC procDSoundCreate = NULL;
HMODULE hDll = LoadLibraryA(eax_dll);
if (hDll != NULL) {
procDSoundCreate = GetProcAddress(hDll, "EAXDirectSoundCreate");
}

HMODULE hEaxDll = LoadLibraryA(eax_dll);
FARPROC procEaxDSoundCreate = GetProcAddress((HMODULE)hEaxDll, "EAXDirectSoundCreate");
if (procDSoundCreate == NULL) {
ffnx_warning("%s: Cannot load EAX Library, please install Creative EAX Unified redistribuable version 2.0+\n", __func__);

hDll = LoadLibraryA("dsound.dll");
if (hDll != NULL) {
// EAXDirectSoundCreate is basically DirectSoundCreate with more features
procDSoundCreate = GetProcAddress(hDll, "DirectSoundCreate");
}
}

return ((LPEAXDIRECTSOUNDCREATE)procEaxDSoundCreate)(guid, directsound, unk);
return LPEAXDIRECTSOUNDCREATE(procDSoundCreate)(guid, directsound, unk);
}

void ffnx_inject_driver(struct game_obj* game_object)
Expand Down

0 comments on commit 1ab9391

Please sign in to comment.