mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
add dprintf from ts-ddraw
This commit is contained in:
parent
0600b75932
commit
9aa457c8b8
@ -8,6 +8,7 @@ double CounterStop();
|
||||
void DebugPrint(const char *format, ...);
|
||||
void DrawFrameInfoStart();
|
||||
void DrawFrameInfoEnd();
|
||||
int dprintf(const char *fmt, ...);
|
||||
|
||||
extern double DebugFrameTime;
|
||||
extern DWORD DebugFrameCount;
|
||||
@ -24,6 +25,8 @@ extern DWORD DebugFrameCount;
|
||||
|
||||
#ifdef _DEBUG_S
|
||||
#define printf(format, ...) DebugPrint("xDBG " format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define printf(format, ...) dprintf(format, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
30
src/debug.c
30
src/debug.c
@ -35,6 +35,36 @@ void DebugPrint(const char *format, ...)
|
||||
OutputDebugStringA(buffer);
|
||||
}
|
||||
|
||||
int dprintf(const char *fmt, ...)
|
||||
{
|
||||
static CRITICAL_SECTION cs;
|
||||
static BOOL initialized;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = TRUE;
|
||||
InitializeCriticalSection(&cs);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&cs);
|
||||
|
||||
va_list args;
|
||||
int ret;
|
||||
|
||||
SYSTEMTIME st;
|
||||
GetLocalTime(&st);
|
||||
|
||||
fprintf(stdout, "[%lu] %02d:%02d:%02d.%03d ", GetCurrentThreadId(), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
|
||||
|
||||
va_start(args, fmt);
|
||||
ret = vfprintf(stdout, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
LeaveCriticalSection(&cs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DrawFrameInfoStart()
|
||||
{
|
||||
static DWORD tick_fps = 0;
|
||||
|
@ -1646,7 +1646,7 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
|
||||
#if _DEBUG
|
||||
if(!stdout_open)
|
||||
{
|
||||
freopen("ra95stdout.txt", "w", stdout);
|
||||
freopen("cnc-ddraw.log", "w", stdout);
|
||||
setvbuf(stdout, NULL, _IOLBF, 1024);
|
||||
stdout_open = 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user