Renamed DbgFuncArgs to DbgFuncFmtArgs, added DbgFuncHexArgs

DbgFuncHexArgs doesn't need a format string anymore, because of creative
use of macro defines.

Note : This is not tested yet!
This commit is contained in:
PatrickvL 2016-11-07 14:56:46 +01:00
parent 89b2a5cf5f
commit 966745cfe6
6 changed files with 347 additions and 1196 deletions

View File

@ -103,11 +103,95 @@ extern volatile bool g_bPrintfOn;
#endif
/*! DbgPrintf enabled if _DEBUG_TRACE is set */
#define DbgPrintf(fmt, ...) do { if (_DEBUG_TRACE) if(g_bPrintfOn) printf(fmt, __VA_ARGS__); } while (0)
#define DbgPrintf(fmt, ...) do { if (_DEBUG_TRACE) if(g_bPrintfOn) printf(fmt, ## __VA_ARGS__); } while (0)
// From https://codecraft.co/2014/11/25/variadic-macros-tricks/
// And https://groups.google.com/d/msg/comp.std.c/d-6Mj5Lko_s/jqonQLK20HcJ
// Accept any number of args >= N, but expand to just the Nth one. In this case,
// we have settled on 10 as N. We could pick a different number by adjusting
// the count of throwaway args before N. Note that this macro is preceded by
// an underscore--it's an implementation detail, not something we expect people
// to call directly.
#define _GET_NTH_ARG(\
_01,_02,_03,_04,_05,_06,_07,_08,_09,_10, \
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
_41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
_51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
_61,_62,_63,N,...) N
#define __RSEQ_N() \
62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
// COUNT_VARARGS returns the number of arguments that have been passed to it.
// Count how many args are in a variadic macro. We now use GCC/Clang's extension to
// handle the case where ... expands to nothing. We must add a placeholder arg before
// ##__VA_ARGS__ (its value is totally irrelevant, but it's necessary to preserve
// the shifting offset we want). In addition, we must add 0 as a valid value to be in
// the N position.
#define COUNT_VARARGS(...) (_GET_NTH_ARG(_00, ##__VA_ARGS__, __RSEQ_N()))
// Define some macros to help us create overrides based on the
// arity of a for-each-style macro.
#define _fe_0(_call, ...)
#define _fe_1(_call, x) _call(x)
#define _fe_2(_call, x, ...) _call(x) _fe_1(_call, __VA_ARGS__)
#define _fe_3(_call, x, ...) _call(x) _fe_2(_call, __VA_ARGS__)
#define _fe_4(_call, x, ...) _call(x) _fe_3(_call, __VA_ARGS__)
#define _fe_5(_call, x, ...) _call(x) _fe_4(_call, __VA_ARGS__)
#define _fe_6(_call, x, ...) _call(x) _fe_5(_call, __VA_ARGS__)
#define _fe_7(_call, x, ...) _call(x) _fe_6(_call, __VA_ARGS__)
#define _fe_8(_call, x, ...) _call(x) _fe_7(_call, __VA_ARGS__)
#define _fe_9(_call, x, ...) _call(x) _fe_8(_call, __VA_ARGS__)
#define _fe_10(_call, x, ...) _call(x) _fe_9(_call, __VA_ARGS__)
#define _fe_11(_call, x, ...) _call(x) _fe_10(_call, __VA_ARGS__)
#define _fe_12(_call, x, ...) _call(x) _fe_11(_call, __VA_ARGS__)
/**
* Provide a for-each construct for variadic macros. Supports up
* to 10 args.
*
* Example usage1:
* #define FWD_DECLARE_CLASS(cls) class cls;
* CALL_MACRO_X_FOR_EACH(FWD_DECLARE_CLASS, Foo, Bar)
*
* Example usage 2:
* #define START_NS(ns) namespace ns {
* #define END_NS(ns) }
* #define MY_NAMESPACES System, Net, Http
* CALL_MACRO_X_FOR_EACH(START_NS, MY_NAMESPACES)
* typedef foo int;
* CALL_MACRO_X_FOR_EACH(END_NS, MY_NAMESPACES)
*/
#define CALL_MACRO_X_FOR_EACH(x, ...) \
_GET_NTH_ARG("ignored", ##__VA_ARGS__, \
_fe_10, _fe_9, _fe_8, _fe_7, _fe_6, _fe_5, \
_fe_4, _fe_3, _fe_2, _fe_1, _fe_0)(x, ##__VA_ARGS__)
#define DBG_ARG_WIDTH 18
#define DbgPrintHexArg(arg) printf("\n %*s : 0x%.08X", DBG_ARG_WIDTH, #arg, arg);
// See https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html
#define DbgFuncHexArgs(...) do { if (_DEBUG_TRACE) if(g_bPrintfOn) \
printf(__FILE__ " (0x%X): " __func__ "(", GetCurrentThreadID()); \
if (COUNT_VARARGS(##__VA_ARGS__) > 0) { \
CALL_MACRO_X_FOR_EACH(DbgPrintHexArg, ##__VA_ARGS__); \
printf("\n"); \
} \
printf(");\n"); \
} while (0)
// See http://stackoverflow.com/questions/1644868/c-define-macro-for-debug-printing
// TODO : print each argument indented on a separate line
#define DbgFuncArgs(fmt, ...) \
#define DbgFuncFmtArgs(fmt, ...) \
do { if (_DEBUG_TRACE) if(g_bPrintfOn) \
printf(__FILE__ " (0x%X): " __func__ "(" fmt ");\n", GetCurrentThreadID(), __VA_ARGS__); \
} while (0)

File diff suppressed because it is too large Load Diff

View File

@ -58,9 +58,7 @@ PVOID WINAPI XTL::EmuXGIsSwizzledFormat
XTL::D3DFORMAT Format
)
{
DbgFuncArgs(
" Format : 0x%.08X\n",
Format);
DbgFuncHexArgs(Format);
return FALSE;
}
@ -80,18 +78,7 @@ VOID WINAPI XTL::EmuXGSwizzleRect
DWORD BytesPerPixel
)
{
DbgFuncArgs(
" pSource : 0x%.08X\n"
" Pitch : 0x%.08X\n"
" pRect : 0x%.08X\n"
" pDest : 0x%.08X\n"
" Width : 0x%.08X\n"
" Height : 0x%.08X\n"
" pPoint : 0x%.08X\n"
" BytesPerPixel : 0x%.08X\n",
pSource, Pitch, pRect, pDest, Width, Height,
DbgFuncHexArgs(pSource, Pitch, pRect, pDest, Width, Height,
pPoint, BytesPerPixel);
if(pRect == NULL && pPoint == NULL && Pitch == 0)
@ -148,20 +135,7 @@ VOID WINAPI XTL::EmuXGSwizzleBox
DWORD BytesPerPixel
)
{
DbgFuncArgs(
" pSource : 0x%.08X\n"
" RowPitch : 0x%.08X\n"
" SlicePitch : 0x%.08X\n"
" pBox : 0x%.08X\n"
" pDest : 0x%.08X\n"
" Width : 0x%.08X\n"
" Height : 0x%.08X\n"
" Depth : 0x%.08X\n"
" pPoint : 0x%.08X\n"
" BytesPerPixel : 0x%.08X\n",
pSource, RowPitch, SlicePitch, pBox, pDest, Width, Height,
DbgFuncHexArgs(pSource, RowPitch, SlicePitch, pBox, pDest, Width, Height,
Depth, pPoint, BytesPerPixel);
if(pDest != (LPVOID) 0x80000000)
@ -322,13 +296,7 @@ HRESULT WINAPI XTL::EmuXGWriteSurfaceOrTextureToXPR
BOOL bWriteSurfaceAsTexture
)
{
DbgFuncArgs(
" pResource : 0x%.08X\n"
" cPath : 0x%.08X\n"
" bWriteSurfaceAsTexture : 0x%.08X\n",
pResource, cPath, bWriteSurfaceAsTexture);
DbgFuncHexArgs(pResource, cPath, bWriteSurfaceAsTexture);
// TODO: If necessary, either reverse the .xbx and .xpr file formats
// and write the surface/texture to a file, or output a generic .xbx
@ -336,8 +304,6 @@ HRESULT WINAPI XTL::EmuXGWriteSurfaceOrTextureToXPR
EmuWarning("(Temporarily) ignoring EmuXGWriteSurfaceOrTextureToXPR. Need file specs.");
return S_OK;
}
@ -357,19 +323,7 @@ VOID WINAPI XTL::EmuXGSetTextureHeader
UINT Pitch
)
{
DbgFuncArgs(
" Width : 0x%.08X\n"
" Height : 0x%.08X\n"
" Levels : 0x%.08X\n"
" Usage : 0x%.08X\n"
" Format : 0x%.08X\n"
" Pool : 0x%.08X\n"
" pTexture : 0x%.08X\n"
" Data : 0x%.08X\n"
" Pitch : 0x%.08X\n",
Width, Height, Levels, Usage,
DbgFuncHexArgs(Width, Height, Levels, Usage,
Format, Pool, pTexture, Data, Pitch);
// NOTES: This function simply creates a texture that needs to be registered
@ -420,7 +374,6 @@ VOID WINAPI XTL::EmuXGSetTextureHeader
// D3DCOLOR_XRGB(
DbgPrintf( "pTexture->Format:= 0x%.08X\n", pTexture->Format );
}
// ******************************************************************
@ -435,11 +388,7 @@ VOID WINAPI XTL::EmuXGSetTextureHeader
//{
//
//
// DbgFuncArgs(
// " pFontData : 0x%.08X\n"
// " uFontDataSize : 0x%.08X\n"
// " ppFont : 0x%.08X\n",
// pFontData, uFontDataSize, ppFont);
// DbgFuncHexArgs(pFontData, uFontDataSize, ppFont);
//
// __asm int 3;
//

View File

@ -56,18 +56,11 @@ int WINAPI XTL::EmuWSAStartup
WSADATA *lpWSAData
)
{
DbgFuncArgs(
" wVersionRequested : 0x%.08X\n"
" lpWSAData : 0x%.08X\n",
wVersionRequested, lpWSAData);
DbgFuncHexArgs(wVersionRequested, lpWSAData);
int ret = WSAStartup(wVersionRequested, lpWSAData);
return ret;
return ret;
}
// ******************************************************************
@ -78,15 +71,9 @@ INT WINAPI XTL::EmuXNetStartup
const PVOID pDummy
)
{
DbgFuncHexArgs(pDummy);
DbgFuncArgs(
" pDummy : 0x%.08X\n",
pDummy);
// Fake Successfull...hehehe...sucker...hehehehehe
// Fake Successfull...hehehe...sucker...hehehehehe
return 0;
}
@ -95,13 +82,9 @@ INT WINAPI XTL::EmuXNetStartup
// ******************************************************************
DWORD WINAPI XTL::EmuXNetGetEthernetLinkStatus()
{
DbgFuncHexArgs();
DbgFuncArgs();
// for now, no ethernet connection is available
// for now, no ethernet connection is available
return XNET_ETHERNET_LINK_ACTIVE | XNET_ETHERNET_LINK_100MBPS;
}
@ -115,20 +98,11 @@ SOCKET XTL::EmuThis::Emusocket
int protocol
)
{
DbgFuncArgs(
" this : 0x%.08X\n"
" af : 0x%.08X\n"
" type : 0x%.08X\n"
" protocol : 0x%.08X\n",
this, af, type, protocol);
DbgFuncHexArgs(this, af, type, protocol);
SOCKET ret = socket(af, type, protocol);
return ret;
return ret;
}
// ******************************************************************
@ -136,22 +110,13 @@ SOCKET XTL::EmuThis::Emusocket
// ******************************************************************
int XTL::EmuThis::Emubind(SOCKET s, const struct sockaddr FAR *name, int namelen)
{
DbgFuncArgs(
" this : 0x%.08X\n"
" s : 0x%.08X\n"
" name : 0x%.08X\n"
" namelen : 0x%.08X\n",
this, s, name, namelen);
DbgFuncHexArgs(this, s, name, namelen);
// TODO: Host-To-Network order if necessary (probably not?)
int ret = bind(s, name, namelen);
return ret;
return ret;
}
// ******************************************************************
@ -159,21 +124,13 @@ int XTL::EmuThis::Emubind(SOCKET s, const struct sockaddr FAR *name, int namelen
// ******************************************************************
int XTL::EmuThis::Emulisten(SOCKET s, int backlog)
{
DbgFuncArgs(
" this : 0x%.08X\n"
" s : 0x%.08X\n"
" listen : 0x%.08X\n",
this, s, backlog);
DbgFuncHexArgs(this, s, backlog);
// TODO: Host-To-Network order if necessary (probably not?)
int ret = listen(s, backlog);
return ret;
return ret;
}
// ******************************************************************
@ -181,20 +138,11 @@ int XTL::EmuThis::Emulisten(SOCKET s, int backlog)
// ******************************************************************
int XTL::EmuThis::Emuioctlsocket(SOCKET s, long cmd, u_long FAR *argp)
{
DbgFuncArgs(
" this : 0x%.08X\n"
" s : 0x%.08X\n"
" cmd : 0x%.08X\n"
" argp : 0x%.08X\n",
this, s, cmd, argp);
DbgFuncHexArgs(this, s, cmd, argp);
int ret = ioctlsocket(s, cmd, argp);
return ret;
return ret;
}
// ******************************************************************
@ -208,7 +156,7 @@ HRESULT WINAPI XOnlineLaunchNewImage
{
DbgFuncArgs(
DbgFuncFmtArgs(
" lpImagePath : 0x%.08X (%s)\n"
" pLaunchData : 0x%.08X\n",
lpImagePath, lpImagePath, pLaunchData);
@ -232,19 +180,9 @@ HRESULT WINAPI XTL::EmuXOnlineLogon
HANDLE pHandle
)
{
DbgFuncArgs(
" pUsers : 0x%.08X\n"
" pdwServiceIDs : 0x%.08X\n"
" dwServices : 0x%.08X\n"
" hEvent : 0x%.08X\n"
" pHandle : 0x%.08X\n",
pUsers, pdwServiceIDs, dwServices, hEvent, pHandle);
DbgFuncHexArgs(pUsers, pdwServiceIDs, dwServices, hEvent, pHandle);
// TODO: What will it take to log on to Xbox Live?
return HRESULT(0x80151000L); // XONLINE_E_LOGON_NO_NETWORK_CONNECTION
}

View File

@ -68,12 +68,7 @@ HRESULT WINAPI XTL::EmuXACTEngineCreate
X_XACTEngine** ppEngine
)
{
DbgFuncArgs(
" pParams : 0x%.08X\n"
" ppEngine : 0x%.08X\n",
pParams, ppEngine);
DbgFuncHexArgs(pParams, ppEngine);
// TODO: Any other form of initialization?
@ -89,9 +84,7 @@ HRESULT WINAPI XTL::EmuXACTEngineCreate
// ******************************************************************
void WINAPI XTL::EmuXACTEngineDoWork()
{
DbgFuncArgs();
DbgFuncHexArgs();
// TODO: Anything else required here?
// AFAIK, this function just calls DirectSoundDoWork()
@ -114,21 +107,12 @@ HRESULT WINAPI XTL::EmuIXACTEngine_RegisterWaveBank
X_XACTWaveBank** ppWaveBank
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pvData : 0x%.08X\n"
" dwSize : 0x%.08X\n"
" ppWaveBank : 0x%.08X\n",
pThis, pvData, dwSize, ppWaveBank);
DbgFuncHexArgs(pThis, pvData, dwSize, ppWaveBank);
// TODO: Implement
*ppWaveBank = (X_XACTWaveBank*) CxbxMalloc( sizeof( X_XACTWaveBank ) );
return S_OK;
}
@ -142,20 +126,12 @@ HRESULT WINAPI XTL::EmuIXACTEngine_RegisterStreamedWaveBank
X_XACTWaveBank** ppWaveBank
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pParams : 0x%.08X\n"
" ppWaveBank : 0x%.08X\n",
pThis, pParams, ppWaveBank);
DbgFuncHexArgs(pThis, pParams, ppWaveBank);
// TODO: Implement
*ppWaveBank = (X_XACTWaveBank*) CxbxMalloc( sizeof( X_XACTWaveBank ) );
return S_OK;
}
@ -170,21 +146,12 @@ HRESULT WINAPI XTL::EmuIXACTEngine_CreateSoundBank
X_XACTSoundBank** ppSoundBank
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pvData : 0x%.08X\n"
" dwSize : 0x%.08X\n"
" ppSoundBank : 0x%.08X\n",
pThis, pvData, dwSize, ppSoundBank);
DbgFuncHexArgs(pThis, pvData, dwSize, ppSoundBank);
// TODO: Implement
*ppSoundBank = (X_XACTSoundBank*) CxbxMalloc( sizeof( X_XACTSoundBank ) );
return S_OK;
}
@ -200,20 +167,10 @@ HRESULT WINAPI XTL::EmuIXACTEngine_DownloadEffectsImage
LPVOID* ppImageDesc
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pvData : 0x%.08X\n"
" dwSize : 0x%.08X\n"
" pEffectLoc : 0x%.08X\n"
" ppImageDesc : 0x%.08X\n",
pThis, pvData, dwSize, pEffectLoc, ppImageDesc);
DbgFuncHexArgs(pThis, pvData, dwSize, pEffectLoc, ppImageDesc);
// TODO: Implement
return S_OK;
}
@ -227,18 +184,10 @@ HRESULT WINAPI XTL::EmuIXACTEngine_CreateSoundSource
X_XACTSoundSource** ppSoundSource
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" dwFlags : 0x%.08X\n"
" ppSoundSource : 0x%.08X\n",
pThis, dwFlags, ppSoundSource);
DbgFuncHexArgs(pThis, dwFlags, ppSoundSource);
*ppSoundSource = (X_XACTSoundSource*) CxbxMalloc( sizeof( X_XACTSoundSource ) );
return S_OK;
}
@ -251,14 +200,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_EnableHeadphones
BOOL fEnabled
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" fEnabled : 0x%.08X\n",
pThis, fEnabled);
DbgFuncHexArgs(pThis, fEnabled);
return S_OK;
}
@ -280,7 +222,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_SetListenerOrientation
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThis : 0x%.08X\n"
" xFront : %f"
" yFront : %f"
@ -310,7 +252,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_SetListenerPosition
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThis : 0x%.08X\n"
" x : %f"
" y : %f"
@ -337,7 +279,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_SetListenerVelocity
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThis : 0x%.08X\n"
" x : %f"
" y : %f"
@ -360,15 +302,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_SetMasterVolume
LONG lVolume
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" wCategory : 0x%.08X\n"
" lVolume : 0x%.08X\n",
pThis, wCategory, lVolume);
DbgFuncHexArgs(pThis, wCategory, lVolume);
return S_OK;
}
@ -378,13 +312,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_SetMasterVolume
// ******************************************************************
HRESULT WINAPI XTL::EmuIXACTEngine_CommitDeferredSettings(X_XACTEngine* pThis)
{
DbgFuncArgs(
" pThis : 0x%.08X\n",
pThis);
DbgFuncHexArgs(pThis);
return S_OK;
}
@ -401,7 +329,7 @@ HRESULT WINAPI XTL::EmuIXACTSoundBank_GetSoundCueIndexFromFriendlyName
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThis : 0x%.08X\n"
" pFriendlyName : (%s)\n"
" pdwSoundCueIndex : 0x%.08X\n",
@ -424,17 +352,7 @@ HRESULT WINAPI XTL::EmuIXACTSoundBank_Play
X_XACTSoundCue** ppSoundCue
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" dwSoundCueIndex : 0x%.08X\n"
" pSoundSource : 0x%.08X\n"
" dwFlags : 0x%.08X\n"
" ppSoundCue : 0x%.08X\n",
pThis, dwSoundCueIndex, pSoundSource, dwFlags, ppSoundCue);
DbgFuncHexArgs(pThis, dwSoundCueIndex, pSoundSource, dwFlags, ppSoundCue);
return S_OK;
}
@ -450,16 +368,7 @@ HRESULT WINAPI XTL::EmuIXACTSoundBank_Stop
X_XACTSoundCue* pSoundCue
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" dwSoundCueIndex : 0x%.08X\n"
" dwFlags : 0x%.08X\n"
" pSoundCue : 0x%.08X\n",
pThis, dwSoundCueIndex, dwFlags, pSoundCue);
DbgFuncHexArgs(pThis, dwSoundCueIndex, dwFlags, pSoundCue);
return S_OK;
}
@ -478,7 +387,7 @@ HRESULT WINAPI XTL::EmuIXACTSoundSource_SetPosition
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThis : 0x%.08X\n"
" x : %f\n"
" y : %f\n"
@ -505,7 +414,7 @@ HRESULT WINAPI XTL::EmuIXACTSoundSource_SetVelocity
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThis : 0x%.08X\n"
" x : %f\n"
" y : %f\n"
@ -527,14 +436,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_RegisterNotification
PCXACT_NOTIFICATION_DESCRIPTION pNotificationDesc
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pNotificationDesc : 0x%.08X\n",
pThis, pNotificationDesc);
DbgFuncHexArgs(pThis, pNotificationDesc);
return S_OK;
}
@ -549,19 +451,11 @@ HRESULT WINAPI XTL::EmuIXACTEngine_GetNotification
LPVOID pNotification
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pNotificationDesc : 0x%.08X\n"
" pNotification : 0x%.08X\n",
pThis, pNotificationDesc, pNotification);
DbgFuncHexArgs(pThis, pNotificationDesc, pNotification);
// TODO: The contents of XACT_NOTIFICATION can vary from one XDK to the next.
// The definition for 4627 is different than 5558.
return S_OK;
}
@ -574,12 +468,7 @@ HRESULT WINAPI XTL::EmuIXACTEngine_UnRegisterWaveBank
X_XACTWaveBank* pWaveBank
)
{
DbgFuncArgs(
" pThis : 0x%.08X\n"
" pWaveBank : 0x%.08X\n",
pThis, pWaveBank);
DbgFuncHexArgs(pThis, pWaveBank);
// Even though the documentation doesn't tell us much, I'm
// assuming that after this function is called, the pointer
@ -588,7 +477,5 @@ HRESULT WINAPI XTL::EmuIXACTEngine_UnRegisterWaveBank
// if(pWaveBank)
// free(pWaveBank);
return S_OK;
}

View File

@ -84,7 +84,7 @@ XTL::LAUNCH_DATA g_SavedLaunchData;
// ******************************************************************
BOOL WINAPI XTL::EmuXFormatUtilityDrive()
{
DbgFuncArgs();
DbgFuncHexArgs();
// TODO: yeah... we'll format... riiiiight
@ -99,17 +99,11 @@ DWORD WINAPI XTL::EmuGetTimeZoneInformation
OUT LPTIME_ZONE_INFORMATION lpTimeZoneInformation
)
{
DbgFuncArgs(
" lpTimeZoneInformation : 0x%.08X\n",
lpTimeZoneInformation);
DbgFuncHexArgs(lpTimeZoneInformation);
DWORD dwRet = GetTimeZoneInformation(lpTimeZoneInformation);
return dwRet;
return dwRet;
}
// ******************************************************************
@ -120,20 +114,14 @@ BOOL WINAPI XTL::EmuQueryPerformanceCounter
PLARGE_INTEGER lpPerformanceCount
)
{
DbgFuncArgs(
" lpPerformanceCount : 0x%.08X\n",
lpPerformanceCount);
DbgFuncHexArgs(lpPerformanceCount);
BOOL bRet = QueryPerformanceCounter(lpPerformanceCount);
// debug - 4x speed
//lpPerformanceCount->QuadPart *= 4;
return bRet;
return bRet;
}
// ******************************************************************
@ -144,17 +132,11 @@ BOOL WINAPI XTL::EmuQueryPerformanceFrequency
PLARGE_INTEGER lpFrequency
)
{
DbgFuncArgs(
" lpFrequency : 0x%.08X\n",
lpFrequency);
DbgFuncHexArgs(lpFrequency);
BOOL bRet = QueryPerformanceFrequency(lpFrequency);
return bRet;
return bRet;
}
// ******************************************************************
@ -165,9 +147,7 @@ BOOL WINAPI XTL::EmuXMountUtilityDrive
BOOL fFormatClean
)
{
DbgFuncArgs(
" fFormatClean : 0x%.08X\n",
fFormatClean);
DbgFuncHexArgs(fFormatClean);
CxbxMountUtilityDrive(fFormatClean);
@ -183,12 +163,7 @@ VOID WINAPI XTL::EmuXInitDevices
PXDEVICE_PREALLOC_TYPE PreallocTypes
)
{
DbgFuncArgs(
" dwPreallocTypeCount : 0x%.08X\n"
" PreallocTypes : 0x%.08X\n",
dwPreallocTypeCount, PreallocTypes);
DbgFuncHexArgs(dwPreallocTypeCount, PreallocTypes);
/*for( DWORD i = 0; i < dwPreallocTypeCount; i++ )
{
@ -225,11 +200,7 @@ DWORD WINAPI XTL::EmuXGetDevices
PXPP_DEVICE_TYPE DeviceType
)
{
DbgFuncArgs(
" DeviceType : 0x%.08X\n",
DeviceType);
DbgFuncHexArgs(DeviceType);
DWORD ret = 0;
@ -253,13 +224,7 @@ BOOL WINAPI XTL::EmuXGetDeviceChanges
PDWORD pdwRemovals
)
{
DbgFuncArgs(
" DeviceType : 0x%.08X\n"
" pdwInsertions : 0x%.08X\n"
" pdwRemovals : 0x%.08X\n",
DeviceType, pdwInsertions, pdwRemovals);
DbgFuncHexArgs(DeviceType, pdwInsertions, pdwRemovals);
BOOL bRet = FALSE;
static BOOL bFirst = TRUE;
@ -302,14 +267,7 @@ HANDLE WINAPI XTL::EmuXInputOpen
IN PXINPUT_POLLING_PARAMETERS pPollingParameters OPTIONAL
)
{
DbgFuncArgs(
" DeviceType : 0x%.08X\n"
" dwPort : 0x%.08X\n"
" dwSlot : 0x%.08X\n"
" pPollingParameters : 0x%.08X\n",
DeviceType, dwPort, dwSlot, pPollingParameters);
DbgFuncHexArgs(DeviceType, dwPort, dwSlot, pPollingParameters);
POLLING_PARAMETERS_HANDLE *pph = 0;
@ -374,11 +332,7 @@ VOID WINAPI XTL::EmuXInputClose
IN HANDLE hDevice
)
{
DbgFuncArgs(
" hDevice : 0x%.08X\n",
hDevice);
DbgFuncHexArgs(hDevice);
POLLING_PARAMETERS_HANDLE *pph = (POLLING_PARAMETERS_HANDLE*)hDevice;
@ -407,9 +361,7 @@ VOID WINAPI XTL::EmuXInputClose
}
//*/
return;
return;
}
// ******************************************************************
@ -420,11 +372,7 @@ DWORD WINAPI XTL::EmuXInputPoll
IN HANDLE hDevice
)
{
DbgFuncArgs(
" hDevice : 0x%.08X\n",
hDevice);
DbgFuncHexArgs(hDevice);
POLLING_PARAMETERS_HANDLE *pph = (POLLING_PARAMETERS_HANDLE*)hDevice;
@ -479,12 +427,7 @@ DWORD WINAPI XTL::EmuXInputGetCapabilities
OUT PXINPUT_CAPABILITIES pCapabilities
)
{
DbgFuncArgs(
" hDevice : 0x%.08X\n"
" pCapabilities : 0x%.08X\n",
hDevice, pCapabilities);
DbgFuncHexArgs(hDevice, pCapabilities);
DWORD ret = ERROR_INVALID_HANDLE;
@ -518,12 +461,7 @@ DWORD WINAPI XTL::EmuXInputGetState
OUT PXINPUT_STATE pState
)
{
DbgFuncArgs(
" hDevice : 0x%.08X\n"
" pState : 0x%.08X\n",
hDevice, pState);
DbgFuncHexArgs(hDevice, pState);
DWORD ret = ERROR_INVALID_HANDLE;
@ -574,12 +512,7 @@ DWORD WINAPI XTL::EmuXInputSetState
IN OUT PXINPUT_FEEDBACK pFeedback
)
{
DbgFuncArgs(
" hDevice : 0x%.08X\n"
" pFeedback : 0x%.08X\n",
hDevice, pFeedback);
DbgFuncHexArgs(hDevice, pFeedback);
DWORD ret = ERROR_IO_PENDING;
@ -655,21 +588,14 @@ BOOL WINAPI XTL::EmuSetThreadPriorityBoost
BOOL DisablePriorityBoost
)
{
DbgFuncArgs(
" hThread : 0x%.08X\n"
" DisablePriorityBoost: 0x%.08X\n",
hThread, DisablePriorityBoost);
DbgFuncHexArgs(hThread, DisablePriorityBoost);
BOOL bRet = SetThreadPriorityBoost(hThread, DisablePriorityBoost);
if(bRet == FALSE)
EmuWarning("SetThreadPriorityBoost Failed!");
return bRet;
return bRet;
}
// ******************************************************************
@ -681,21 +607,14 @@ BOOL WINAPI XTL::EmuSetThreadPriority
int nPriority
)
{
DbgFuncArgs(
" hThread : 0x%.08X\n"
" nPriority : 0x%.08X\n",
hThread, nPriority);
DbgFuncHexArgs(hThread, nPriority);
BOOL bRet = SetThreadPriority(hThread, nPriority);
if(bRet == FALSE)
EmuWarning("SetThreadPriority Failed!");
return bRet;
return bRet;
}
@ -707,20 +626,14 @@ int WINAPI XTL::EmuGetThreadPriority
HANDLE hThread
)
{
DbgFuncArgs(
" hThread : 0x%.08X\n",
hThread);
DbgFuncHexArgs(hThread);
int iRet = GetThreadPriority(hThread);
if(iRet == THREAD_PRIORITY_ERROR_RETURN)
EmuWarning("GetThreadPriority Failed!");
return iRet;
return iRet;
}
// ******************************************************************
@ -732,18 +645,11 @@ BOOL WINAPI XTL::EmuGetExitCodeThread
LPDWORD lpExitCode
)
{
DbgFuncArgs(
" hThread : 0x%.08X\n"
" lpExitCode : 0x%.08X\n",
hThread, lpExitCode);
DbgFuncHexArgs(hThread, lpExitCode);
BOOL bRet = GetExitCodeThread(hThread, lpExitCode);
return bRet;
return bRet;
}
// ******************************************************************
@ -755,16 +661,9 @@ VOID WINAPI XTL::EmuXapiThreadStartup
DWORD dwDummy2
)
{
DbgDbgFuncNewFuncArgs(dwDummy1, dwDummy2);
DbgFuncArgs(
" dwDummy1 : 0x%.08X\n"
" dwDummy2 : 0x%.08X\n",
dwDummy1, dwDummy2);
typedef int (__stdcall *pfDummyFunc)(DWORD dwDummy);
typedef int (__stdcall *pfDummyFunc)(DWORD dwDummy);
pfDummyFunc func = (pfDummyFunc)dwDummy1;
@ -796,7 +695,7 @@ VOID WINAPI XTL::EmuXRegisterThreadNotifyRoutine
{
DbgFuncArgs(
DbgFuncFmtArgs(
" pThreadNotification : 0x%.08X (0x%.08X)\n"
" fRegister : 0x%.08X\n",
pThreadNotification, pThreadNotification->pfnNotifyRoutine, fRegister);
@ -848,13 +747,7 @@ DWORD WINAPI XTL::EmuQueueUserAPC
DWORD dwData
)
{
DbgFuncArgs(
" pfnAPC : 0x%.08X\n"
" hThread : 0x%.08X\n"
" dwData : 0x%.08X\n",
pfnAPC, hThread, dwData);
DbgFuncHexArgs(pfnAPC, hThread, dwData);
DWORD dwRet = 0;
@ -869,8 +762,6 @@ DWORD WINAPI XTL::EmuQueueUserAPC
if(!dwRet)
EmuWarning("QueueUserAPC failed!");
return dwRet;
}
@ -885,22 +776,13 @@ BOOL WINAPI XTL::EmuGetOverlappedResult
BOOL bWait
)
{
DbgFuncArgs(
" hFile : 0x%.08X\n"
" lpOverlapped : 0x%.08X\n"
" lpNumberOfBytesTransformed : 0x%.08X\n"
" bWait : 0x%.08X\n",
hFile, lpOverlapped, lpNumberOfBytesTransferred, bWait);
DbgFuncHexArgs(hFile, lpOverlapped, lpNumberOfBytesTransferred, bWait);
BOOL bRet = GetOverlappedResult( hFile, lpOverlapped, lpNumberOfBytesTransferred, bWait );
// if(bWait)
// bRet = TRUE; // Sucker...
return bRet;
}
@ -915,7 +797,7 @@ DWORD WINAPI XTL::EmuXLaunchNewImage
{
DbgFuncArgs(
DbgFuncFmtArgs(
" lpTitlePath : 0x%.08X (%s)\n"
" pLaunchData : 0x%.08X\n",
lpTitlePath, lpTitlePath, pLaunchData);
@ -996,12 +878,7 @@ DWORD WINAPI XTL::EmuXGetLaunchInfo
PLAUNCH_DATA pLaunchData
)
{
DbgFuncArgs(
" pdwLaunchDataType : 0x%.08X\n"
" pLaunchData : 0x%.08X\n",
pdwLaunchDataType, pLaunchData);
DbgFuncHexArgs(pdwLaunchDataType, pLaunchData);
// The title was launched by turning on the Xbox console with the title disc already in the DVD drive
DWORD dwRet = ERROR_NOT_FOUND;
@ -1063,16 +940,10 @@ VOID WINAPI XTL::EmuXSetProcessQuantumLength
DWORD dwMilliseconds
)
{
DbgFuncArgs(
" dwMilliseconds : 0x%.08X\n",
dwMilliseconds);
DbgFuncHexArgs(dwMilliseconds);
// TODO: Implement?
EmuWarning("XSetProcessQuantumLength is being ignored!");
}
// ******************************************************************
@ -1080,16 +951,12 @@ VOID WINAPI XTL::EmuXSetProcessQuantumLength
// ******************************************************************
DWORD WINAPI XTL::EmuXGetFileCacheSize()
{
DbgFuncArgs();
DbgFuncHexArgs();
// Return the default cache size for now.
// TODO: Save the file cache size if/when set.
DWORD dwRet = 64 * 1024;
return dwRet;
}
@ -1104,19 +971,10 @@ DWORD WINAPI XTL::EmuSignalObjectAndWait
BOOL bAlertable
)
{
DbgFuncArgs(
" hObjectToSignal : 0x%.08X\n"
" hObjectToWaitOn : 0x%.08X\n"
" dwMilliseconds : 0x%.08X\n"
" bAlertable : 0x%.08X\n",
hObjectToSignal, hObjectToWaitOn, dwMilliseconds, bAlertable);
DbgFuncHexArgs(hObjectToSignal, hObjectToWaitOn, dwMilliseconds, bAlertable);
DWORD dwRet = SignalObjectAndWait( hObjectToSignal, hObjectToWaitOn, dwMilliseconds, bAlertable );
return dwRet;
}
@ -1125,19 +983,13 @@ DWORD WINAPI XTL::EmuSignalObjectAndWait
// ******************************************************************
BOOL WINAPI XTL::EmuPulseEvent( HANDLE hEvent )
{
DbgFuncArgs(
" hEvent : 0x%.08X\n",
hEvent);
DbgFuncHexArgs(hEvent);
// TODO: This function might be a bit too high level. If it is,
// feel free to implement NtPulseEvent in EmuKrnl.cpp
BOOL bRet = PulseEvent( hEvent );
return bRet;
}
@ -1153,20 +1005,10 @@ MMRESULT WINAPI XTL::EmutimeSetEvent
UINT fuEvent
)
{
DbgFuncArgs(
" uDelay : 0x%.08X\n"
" uResolution : 0x%.08X\n"
" fptc : 0x%.08X\n"
" dwUser : 0x%.08X\n"
" fuEvent : 0x%.08X\n",
uDelay, uResolution, fptc, dwUser, fuEvent);
DbgFuncHexArgs(uDelay, uResolution, fptc, dwUser, fuEvent);
MMRESULT Ret = timeSetEvent( uDelay, uResolution, fptc, (DWORD_PTR) dwUser, fuEvent );
return Ret;
}
@ -1178,16 +1020,10 @@ MMRESULT WINAPI XTL::EmutimeKillEvent
UINT uTimerID
)
{
DbgFuncArgs(
" uTimerID : 0x%.08X\n",
uTimerID);
DbgFuncHexArgs(uTimerID);
MMRESULT Ret = timeKillEvent( uTimerID );
return Ret;
}
@ -1202,19 +1038,10 @@ VOID WINAPI XTL::EmuRaiseException
CONST ULONG_PTR *lpArguments // array of arguments
)
{
DbgFuncArgs(
" dwExceptionCode : 0x%.08X\n"
" dwExceptionFlags : 0x%.08X\n"
" nNumberOfArguments: 0x%.08X\n"
" lpArguments : 0x%.08X\n",
dwExceptionCode, dwExceptionFlags, nNumberOfArguments, lpArguments);
DbgFuncHexArgs(dwExceptionCode, dwExceptionFlags, nNumberOfArguments, lpArguments);
// TODO: Implement or not?
// RaiseException(dwExceptionCode, dwExceptionFlags, nNumberOfArguments, (*(ULONG_PTR**) &lpArguments));
}
// ******************************************************************
@ -1227,7 +1054,7 @@ DWORD WINAPI XTL::EmuGetFileAttributesA
{
DbgFuncArgs(
DbgFuncFmtArgs(
" lpFileName : (%s)\n",
lpFileName);
@ -1268,7 +1095,7 @@ DWORD WINAPI XTL::EmuXMountMUA
{
DbgFuncArgs(
DbgFuncFmtArgs(
" dwPort : 0x%.08X\n"
" dwSlot : 0x%.08X\n"
" pchDrive : 0x%.08X (%s)\n",
@ -1294,7 +1121,7 @@ HANDLE WINAPI XTL::EmuCreateWaitableTimerA
{
DbgFuncArgs(
DbgFuncFmtArgs(
" lpTimerAttributes : 0x%.08X\n"
" bManualReset : 0x%.08X\n"
" lpTimerName : 0x%.08X (%s)\n",
@ -1324,17 +1151,7 @@ BOOL WINAPI XTL::EmuSetWaitableTimer
BOOL fResume // resume state
)
{
DbgFuncArgs(
" hTimer : 0x%.08X\n"
" pDueTime : 0x%.08X\n"
" lPeriod : 0x%.08X\n"
" pfnCompletionRoutine : 0x%.08X\n"
" lpArgToCompletionRoutine : 0x%.08X\n"
" fResume : 0x%.08X\n",
hTimer, pDueTime, lPeriod, pfnCompletionRoutine,
DbgFuncHexArgs(hTimer, pDueTime, lPeriod, pfnCompletionRoutine,
lpArgToCompletionRoutine, fResume);
BOOL Ret = SetWaitableTimer( hTimer, pDueTime, lPeriod, pfnCompletionRoutine,
@ -1342,8 +1159,6 @@ BOOL WINAPI XTL::EmuSetWaitableTimer
if(!Ret)
EmuWarning("SetWaitableTimer failed!");
return Ret;
}
@ -1359,7 +1174,7 @@ DWORD WINAPI XTL::EmuXMountAlternateTitle
{
DbgFuncArgs(
DbgFuncFmtArgs(
" lpRootPath : 0x%.08X (%s)\n"
" dwAltTitleId : 0x%.08X\n"
" pchDrive : 0x%.08X (%s)\n",
@ -1379,7 +1194,7 @@ DWORD WINAPI XTL::EmuXUnmountAlternateTitle(CHAR chDrive)
{
DbgFuncArgs(
DbgFuncFmtArgs(
" chDrive : 0x%.08X (%c)\n",
chDrive, chDrive);
@ -1393,11 +1208,7 @@ DWORD WINAPI XTL::EmuXUnmountAlternateTitle(CHAR chDrive)
// ******************************************************************
DWORD WINAPI XTL::EmuXGetDeviceEnumerationStatus()
{
DbgFuncArgs();
DbgFuncHexArgs();
return XDEVICE_ENUMERATION_IDLE;
}
@ -1411,17 +1222,10 @@ DWORD WINAPI XTL::EmuXInputGetDeviceDescription
PVOID pDescription
)
{
DbgFuncArgs(
" hDevice : 0x%.08X\n"
" pDescription : 0x%.08X\n",
hDevice, pDescription);
DbgFuncHexArgs(hDevice, pDescription);
// TODO: Lightgun support?
return ERROR_NOT_SUPPORTED; // ERROR_DEVICE_NOT_CONNECTED;
}
@ -1430,15 +1234,10 @@ DWORD WINAPI XTL::EmuXInputGetDeviceDescription
// ******************************************************************
int WINAPI XTL::EmuXAutoPowerDownResetTimer()
{
DbgFuncArgs();
DbgFuncHexArgs();
// Meh, that's what the 'X' is for! =]
return TRUE;
}
@ -1455,7 +1254,7 @@ DWORD WINAPI XTL::EmuXMountMURootA
DbgFuncArgs(
DbgFuncFmtArgs(
" dwPort : 0x%.08X\n"
" dwSlot : 0x%.08X\n"
" pchDrive : 0x%.08X (%s)\n",