Change initialization of DirectSound and XAudio2 to load DLLs at runtime instead of linking statically to them.
Replace timeGetTime() with GetTickCount() in order to eliminate the need of additionally linking against winmm.lib.
This commit is contained in:
parent
a2b6f46db8
commit
107d1670a7
|
@ -85,7 +85,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="nafxcwd.lib LIBCMTD.lib Vfw32.Lib OpenGL32.Lib dinput8.lib dxguid.lib ddraw.lib winmm.lib Dsound.lib HtmlHelp.lib zlib1.lib libpng13.lib"
|
||||
AdditionalDependencies="nafxcwd.lib LIBCMTD.lib zlib1.lib libpng13.lib"
|
||||
OutputFile="$(OutDir)\VisualBoyAdvance.exe"
|
||||
Version=""
|
||||
LinkIncremental="2"
|
||||
|
@ -193,7 +193,7 @@
|
|||
Name="VCLinkerTool"
|
||||
RegisterOutput="false"
|
||||
IgnoreImportLibrary="false"
|
||||
AdditionalDependencies="nafxcw.lib LIBCMT.lib Vfw32.Lib OpenGL32.Lib dinput8.lib winmm.lib dxguid.lib ddraw.lib Dsound.lib htmlhelp.lib zlib1.lib libpng13.lib"
|
||||
AdditionalDependencies="nafxcw.lib LIBCMT.lib zlib1.lib libpng13.lib"
|
||||
ShowProgress="0"
|
||||
OutputFile="$(OutDir)\VisualBoyAdvance.exe"
|
||||
Version=""
|
||||
|
|
|
@ -5255,18 +5255,18 @@ void gbEmulate(int ticksToStop)
|
|||
while(synchronizeTicks < 0) {
|
||||
synchronizeTicks += SYNCHRONIZE_CLOCK_TICKS;
|
||||
|
||||
DWORD now = timeGetTime();
|
||||
DWORD now = GetTickCount();
|
||||
gbElapsedTime += (now - timeNow);
|
||||
|
||||
if(gbElapsedTime < 50) {
|
||||
DWORD diff = 50 - gbElapsedTime;
|
||||
Sleep(diff);
|
||||
timeNow = timeGetTime();
|
||||
timeNow = GetTickCount();
|
||||
elapsedTime = timeNow - now - diff;
|
||||
if((int)elapsedTime < 0)
|
||||
elapsedTime = 0;
|
||||
} else {
|
||||
timeNow = timeGetTime();
|
||||
timeNow = GetTickCount();
|
||||
elapsedTime = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
|
||||
#include "AVIWrite.h"
|
||||
#pragma comment( lib, "vfw32.lib" )
|
||||
#pragma comment( lib, "Vfw32" )
|
||||
|
||||
|
||||
AVIWrite::AVIWrite()
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
#ifndef NO_D3D
|
||||
|
||||
#pragma comment( lib, "d3d9.lib" )
|
||||
#pragma comment( lib, "d3dx9.lib" )
|
||||
#pragma comment( lib, "dxerr9.lib" )
|
||||
#pragma comment( lib, "d3d9" )
|
||||
#pragma comment( lib, "d3dx9" )
|
||||
#pragma comment( lib, "DxErr9" )
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
|
|
@ -28,8 +28,9 @@
|
|||
#include "WinResUtil.h"
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <Dinput.h>
|
||||
#pragma comment(lib, "Dinput8")
|
||||
#include <dinput.h>
|
||||
#pragma comment( lib, "dinput8" )
|
||||
#pragma comment( lib, "dxguid" )
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
@ -608,7 +609,8 @@ BOOL checkKey(KeyList &k)
|
|||
}
|
||||
|
||||
DirectInput::DirectInput()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
DirectInput::~DirectInput()
|
||||
{
|
||||
|
@ -631,27 +633,21 @@ DirectInput::~DirectInput()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool DirectInput::initialize()
|
||||
{
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
hr = DirectInput8Create(
|
||||
AfxGetInstanceHandle(),
|
||||
DIRECTINPUT_VERSION,
|
||||
IID_IDirectInput8,
|
||||
(LPVOID*)&pDirectInput,
|
||||
NULL );
|
||||
|
||||
if ( hr != DI_OK ) {
|
||||
return false;
|
||||
}
|
||||
HRESULT hr;
|
||||
|
||||
hr = DirectInput8Create(
|
||||
GetModuleHandle( NULL ),
|
||||
DIRECTINPUT_VERSION,
|
||||
IID_IDirectInput8,
|
||||
(LPVOID *)&pDirectInput,
|
||||
NULL );
|
||||
ASSERT( hr == DI_OK );
|
||||
if( hr != DI_OK ) return false;
|
||||
|
||||
|
||||
|
||||
|
||||
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||
hr = pDirectInput->EnumDevices(DI8DEVCLASS_GAMECTRL,
|
||||
DIEnumDevicesCallback2,
|
||||
NULL,
|
||||
DIEDFL_ATTACHEDONLY);
|
||||
|
|
|
@ -32,9 +32,7 @@
|
|||
#include "../Sound.h"
|
||||
|
||||
// DirectSound8
|
||||
#include <Dsound.h>
|
||||
#pragma comment( lib, "Dsound" )
|
||||
#pragma comment( lib, "Dxguid" )
|
||||
#include <dsound.h>
|
||||
|
||||
extern bool soundBufferLow;
|
||||
extern void setsystemSoundOn(bool value);
|
||||
|
@ -64,7 +62,10 @@ public:
|
|||
|
||||
DirectSound::DirectSound()
|
||||
{
|
||||
CoInitialize( NULL );
|
||||
if( S_OK != CoInitializeEx( NULL, COINIT_MULTITHREADED ) ) {
|
||||
systemMessage( IDS_COM_FAILURE, NULL );
|
||||
return;
|
||||
}
|
||||
|
||||
pDirectSound = NULL;
|
||||
dsbPrimary = NULL;
|
||||
|
@ -114,14 +115,17 @@ bool DirectSound::init()
|
|||
DSBUFFERDESC dsbdesc;
|
||||
int i;
|
||||
|
||||
|
||||
// Initialize DirectSound
|
||||
if( FAILED( hr = DirectSoundCreate8( &DSDEVID_DefaultPlayback, &pDirectSound, NULL ) ) ) {
|
||||
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, _T("Cannot create DirectSound %08x"), hr );
|
||||
pDirectSound = NULL;
|
||||
hr = CoCreateInstance( CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID *)&pDirectSound );
|
||||
if( hr != S_OK ) {
|
||||
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
|
||||
return false;
|
||||
}
|
||||
|
||||
pDirectSound->Initialize( &DSDEVID_DefaultPlayback );
|
||||
if( hr != DS_OK ) {
|
||||
systemMessage( IDS_CANNOT_CREATE_DIRECTSOUND, NULL, hr );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( FAILED( hr = pDirectSound->SetCooperativeLevel( theApp.m_pMainWnd->GetSafeHwnd(), DSSCL_EXCLUSIVE ) ) ) {
|
||||
systemMessage( IDS_CANNOT_SETCOOPERATIVELEVEL, _T("Cannot SetCooperativeLevel %08x"), hr );
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
#ifndef NO_D3D
|
||||
#pragma comment( lib, "d3d9.lib" )
|
||||
#pragma comment( lib, "d3d9" )
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef NO_OGL
|
||||
|
||||
//OpenGL library
|
||||
#pragma comment( lib, "opengl32.lib" )
|
||||
#pragma comment( lib, "OpenGL32" )
|
||||
|
||||
// MFC
|
||||
#include "stdafx.h"
|
||||
|
|
|
@ -2624,7 +2624,7 @@ bool Sm60FPS_CanSkipFrame()
|
|||
if( Sm60FPS::nFrameCnt == 0 ) {
|
||||
Sm60FPS::nFrameCnt = 0;
|
||||
Sm60FPS::dwTimeElapse = 0;
|
||||
Sm60FPS::dwTime0 = timeGetTime();
|
||||
Sm60FPS::dwTime0 = GetTickCount();
|
||||
} else {
|
||||
if( Sm60FPS::nFrameCnt >= 10 ) {
|
||||
Sm60FPS::nFrameCnt = 0;
|
||||
|
@ -2644,7 +2644,7 @@ bool Sm60FPS_CanSkipFrame()
|
|||
}
|
||||
}
|
||||
} else { // between frame 1-10
|
||||
Sm60FPS::dwTime1 = timeGetTime();
|
||||
Sm60FPS::dwTime1 = GetTickCount();
|
||||
Sm60FPS::dwTimeElapse += (Sm60FPS::dwTime1 - Sm60FPS::dwTime0);
|
||||
Sm60FPS::dwTime0 = Sm60FPS::dwTime1;
|
||||
if( !Sm60FPS::bLastSkip &&
|
||||
|
@ -2668,7 +2668,7 @@ bool Sm60FPS_CanSkipFrame()
|
|||
void Sm60FPS_Sleep()
|
||||
{
|
||||
if( theApp.autoFrameSkip ) {
|
||||
u32 dwTimePass = Sm60FPS::dwTimeElapse + (timeGetTime() - Sm60FPS::dwTime0);
|
||||
u32 dwTimePass = Sm60FPS::dwTimeElapse + (GetTickCount() - Sm60FPS::dwTime0);
|
||||
u32 dwTimeShould = (u32)(Sm60FPS::nFrameCnt * Sm60FPS::K_fDT);
|
||||
if( dwTimeShould > dwTimePass ) {
|
||||
Sleep(dwTimeShould - dwTimePass);
|
||||
|
|
|
@ -155,16 +155,35 @@ bool XAudio2_Output::init()
|
|||
{
|
||||
if( failed || initialized ) return false;
|
||||
|
||||
// Initialize XAudio2 using COM
|
||||
HRESULT hr;
|
||||
UINT32 flags = 0;
|
||||
|
||||
hr = CoCreateInstance(
|
||||
#ifdef _DEBUG
|
||||
flags |= XAUDIO2_DEBUG_ENGINE;
|
||||
__uuidof( XAudio2_Debug ),
|
||||
#else
|
||||
__uuidof( XAudio2 ),
|
||||
#endif
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
__uuidof( IXAudio2 ),
|
||||
(LPVOID *)&xaud
|
||||
);
|
||||
if( hr != S_OK ) {
|
||||
systemMessage( IDS_XAUDIO2_FAILURE, NULL );
|
||||
failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = XAudio2Create( &xaud, flags );
|
||||
|
||||
if( FAILED( hr ) ) {
|
||||
hr = xaud->Initialize(
|
||||
#ifdef _DEBUG
|
||||
XAUDIO2_DEBUG_ENGINE,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
XAUDIO2_DEFAULT_PROCESSOR
|
||||
);
|
||||
if( hr != S_OK ) {
|
||||
systemMessage( IDS_XAUDIO2_FAILURE, NULL );
|
||||
failed = true;
|
||||
return false;
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
// Enable STRICT type checking
|
||||
#define STRICT
|
||||
|
||||
|
||||
#include <afxwin.h>
|
||||
#include <afxcmn.h>
|
||||
#include <afxdlgs.h>
|
||||
|
|
Loading…
Reference in New Issue