DirectX library loading now done dynamically
This commit is contained in:
@@ -127,6 +127,18 @@ extern "C" {
|
|||||||
DWORD MouseButton;
|
DWORD MouseButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern HMODULE hM_dinput8, hM_ddraw, hM_dsound;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI* lpDirectInput8Create)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);
|
||||||
|
extern lpDirectInput8Create pDirectInput8Create;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI* lpDirectDrawCreateEx)(GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter);
|
||||||
|
extern lpDirectDrawCreateEx pDirectDrawCreateEx;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI* lpDirectSoundCreate8)(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter);
|
||||||
|
extern lpDirectSoundCreate8 pDirectSoundCreate8;
|
||||||
|
}
|
||||||
|
|
||||||
#define UPDATE_TICKS_GAME 1000.855001760297741789468390082/60 // milliseconds per world update
|
#define UPDATE_TICKS_GAME 1000.855001760297741789468390082/60 // milliseconds per world update
|
||||||
#define UPDATE_TICKS_GAMEPAL 1000/50 // milliseconds per world update
|
#define UPDATE_TICKS_GAMEPAL 1000/50 // milliseconds per world update
|
||||||
@@ -506,7 +518,7 @@ InitSound()
|
|||||||
PrevSoundQuality=SoundQuality;
|
PrevSoundQuality=SoundQuality;
|
||||||
PrevStereoSound=StereoSound;
|
PrevStereoSound=StereoSound;
|
||||||
|
|
||||||
if (DS_OK == DirectSoundCreate8(NULL, &lpDirectSound,NULL))
|
if (DS_OK == pDirectSoundCreate8(NULL, &lpDirectSound,NULL))
|
||||||
{
|
{
|
||||||
if (ExclusiveSound == 0)
|
if (ExclusiveSound == 0)
|
||||||
{
|
{
|
||||||
@@ -937,7 +949,7 @@ bool InitInput()
|
|||||||
char message1[256];
|
char message1[256];
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (FAILED(hr=DirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8A,(void **) &DInput,NULL)))
|
if (FAILED(hr=pDirectInput8Create(hInst,DIRECTINPUT_VERSION,IID_IDirectInput8A,(void **) &DInput,NULL)))
|
||||||
{
|
{
|
||||||
sprintf(message1,"Error initializing DirectInput\nYou may need to install DirectX 8.0a or higher located at www.microsoft.com/directx \0");
|
sprintf(message1,"Error initializing DirectInput\nYou may need to install DirectX 8.0a or higher located at www.microsoft.com/directx \0");
|
||||||
MessageBox (NULL, message1, "DirectInput Error" , MB_ICONERROR );
|
MessageBox (NULL, message1, "DirectInput Error" , MB_ICONERROR );
|
||||||
@@ -1122,7 +1134,7 @@ int InitDirectDraw()
|
|||||||
ClientToScreen(hMainWindow, ( LPPOINT )&rcWindow);
|
ClientToScreen(hMainWindow, ( LPPOINT )&rcWindow);
|
||||||
ClientToScreen(hMainWindow, ( LPPOINT )&rcWindow + 1);
|
ClientToScreen(hMainWindow, ( LPPOINT )&rcWindow + 1);
|
||||||
|
|
||||||
if (DirectDrawCreateEx(NULL, (void **)&lpDD, IID_IDirectDraw7, NULL) != DD_OK)
|
if (pDirectDrawCreateEx(NULL, (void **)&lpDD, IID_IDirectDraw7, NULL) != DD_OK)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "DirectDrawCreateEx failed.", "DirectDraw Error", MB_ICONERROR);
|
MessageBox(NULL, "DirectDrawCreateEx failed.", "DirectDraw Error", MB_ICONERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,30 @@
|
|||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include <dinput.h>
|
||||||
|
#include <dsound.h>
|
||||||
|
|
||||||
|
static char dinput8_dll[] = {"dinput8.dll\0"};
|
||||||
|
static char dinput8_imp[] = {"DirectInput8Create\0"};
|
||||||
|
|
||||||
|
static char ddraw_dll[] = {"ddraw.dll\0"};
|
||||||
|
static char ddraw_imp[] = {"DirectDrawCreateEx\0"};
|
||||||
|
|
||||||
|
static char dsound_dll[] = {"dsound.dll\0"};
|
||||||
|
static char dsound_imp[] = {"DirectSoundCreate8\0"};
|
||||||
|
|
||||||
|
HMODULE hM_ddraw = NULL, hM_dsound = NULL,hM_dinput8 = NULL;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI* lpDirectInput8Create)(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);
|
||||||
|
lpDirectInput8Create pDirectInput8Create;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI* lpDirectDrawCreateEx)( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter );
|
||||||
|
lpDirectDrawCreateEx pDirectDrawCreateEx;
|
||||||
|
|
||||||
|
typedef HRESULT (WINAPI* lpDirectSoundCreate8)(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter);
|
||||||
|
lpDirectSoundCreate8 pDirectSoundCreate8;
|
||||||
|
|
||||||
extern void zstart(void);
|
extern void zstart(void);
|
||||||
extern void DosExit(void);
|
extern void DosExit(void);
|
||||||
extern void ConvertJoyMap1(void);
|
extern void ConvertJoyMap1(void);
|
||||||
@@ -81,6 +105,71 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdSh
|
|||||||
|
|
||||||
hInst=hInstance;
|
hInst=hInstance;
|
||||||
|
|
||||||
|
hM_dinput8 = LoadLibrary(dinput8_dll);
|
||||||
|
|
||||||
|
if (hM_dinput8 == NULL)
|
||||||
|
{
|
||||||
|
if (MessageBox(NULL, "Sorry, you need DirectX v8.0 or higher to use\nZSNESW. Would you like to go to the DirectX homepage?", "Error", MB_ICONINFORMATION | MB_YESNO) == IDYES)
|
||||||
|
ShellExecute(NULL, NULL, "http://www.microsoft.com/directx/", NULL, NULL, 0);
|
||||||
|
goto startup_error_exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDirectInput8Create = (lpDirectInput8Create) GetProcAddress(hM_dinput8, dinput8_imp);
|
||||||
|
|
||||||
|
if (pDirectInput8Create == NULL)
|
||||||
|
{
|
||||||
|
char err[256];
|
||||||
|
wsprintf(err,"Failed to import %s:%s", dinput8_dll, dinput8_imp);
|
||||||
|
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
||||||
|
goto startup_dinput8_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
hM_ddraw = LoadLibrary(ddraw_dll);
|
||||||
|
|
||||||
|
if (hM_ddraw == NULL)
|
||||||
|
{
|
||||||
|
char err[256];
|
||||||
|
wsprintf(err,"Failed to import %s",ddraw_dll);
|
||||||
|
MessageBox(NULL, err,"Error",MB_ICONERROR);
|
||||||
|
goto startup_dinput8_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDirectDrawCreateEx = (lpDirectDrawCreateEx) GetProcAddress(hM_ddraw, ddraw_imp);
|
||||||
|
|
||||||
|
if (pDirectDrawCreateEx == NULL)
|
||||||
|
{
|
||||||
|
char err[256];
|
||||||
|
wsprintf(err,"Failed to import %s:%s", ddraw_dll, ddraw_imp);
|
||||||
|
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
||||||
|
goto startup_ddraw_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
hM_dsound = LoadLibrary(dsound_dll);
|
||||||
|
|
||||||
|
if (hM_dsound == NULL)
|
||||||
|
{
|
||||||
|
char err[256];
|
||||||
|
wsprintf(err,"Failed to import %s",dsound_dll);
|
||||||
|
MessageBox(NULL, err,"Error",MB_ICONERROR);
|
||||||
|
goto startup_ddraw_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
pDirectSoundCreate8 = (lpDirectSoundCreate8) GetProcAddress(hM_dsound, dsound_imp);
|
||||||
|
|
||||||
|
if (pDirectSoundCreate8 == NULL)
|
||||||
|
{
|
||||||
|
char err[256];
|
||||||
|
wsprintf(err,"Failed to import %s:%s", dsound_dll, dsound_imp);
|
||||||
|
MessageBox(NULL, err, "Error", MB_ICONERROR);
|
||||||
|
FreeLibrary(hM_dsound);
|
||||||
|
startup_ddraw_error:
|
||||||
|
FreeLibrary(hM_ddraw);
|
||||||
|
startup_dinput8_error:
|
||||||
|
FreeLibrary(hM_dinput8);
|
||||||
|
startup_error_exit:
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Commandline: /ABCDE <nickname> <fname> <IP Addy>
|
// Commandline: /ABCDE <nickname> <fname> <IP Addy>
|
||||||
// nickname = user nickname
|
// nickname = user nickname
|
||||||
// fname = filename w/ full path (if L) or path name (if C)
|
// fname = filename w/ full path (if L) or path name (if C)
|
||||||
|
|||||||
Reference in New Issue
Block a user