]> icculus.org git repositories - btb/d2x.git/blob - arch/win32/include/debug.h
apply patch from bluecow to fix hmiplay sync issues and lack of midi reset (d1x r1.5)
[btb/d2x.git] / arch / win32 / include / debug.h
1 #ifndef DEBUG_H
2 #define DEBUG_H
3 /*
4 **-----------------------------------------------------------------------------
5 **  File:       Debug.h
6 **  Purpose:    Sample Debug code
7 **  Notes:
8 **
9 **  Copyright (c) 1995 - 1997 by Microsoft, all rights reserved
10 **-----------------------------------------------------------------------------
11 */
12
13 /*
14 **-----------------------------------------------------------------------------
15 **  Include files
16 **-----------------------------------------------------------------------------
17 */
18
19
20
21 /*
22 **-----------------------------------------------------------------------------
23 **  Defines
24 **-----------------------------------------------------------------------------
25 */
26
27 #ifndef NDEBUG
28 // Note:  Define DEBUG_PROMPTME if you want MessageBox Error prompting
29 //                This can get annoying quickly...
30 // #define DEBUG_PROMPTME
31
32         // Pre and Post debug string info
33 //      #define START_STR       TEXT ("D3DDESCENT: ")
34         #define START_STR       TEXT ("")
35         #define END_STR         TEXT ("\r\n")
36 #endif // NDEBUG
37
38 // Debug Levels
39 #define DEBUG_ALWAYS    0L
40 #define DEBUG_CRITICAL  1L
41 #define DEBUG_ERROR             2L
42 #define DEBUG_MINOR             3L
43 #define DEBUG_WARN              4L
44 #define DEBUG_DETAILS   5L
45
46
47 // Sample Errors
48 #define APPERR_GENERIC                  MAKE_DDHRESULT (10001)
49 #define APPERR_INVALIDPARAMS    MAKE_DDHRESULT (10002)
50 #define APPERR_NOTINITIALIZED   MAKE_DDHRESULT (10003)
51 #define APPERR_OUTOFMEMORY              MAKE_DDHRESULT (10004)
52 #define APPERR_NOTFOUND                 MAKE_DDHRESULT (10005)
53
54
55
56 /*
57 **-----------------------------------------------------------------------------
58 **  Macros
59 **-----------------------------------------------------------------------------
60 */
61
62 #ifndef NDEBUG
63     #define DPF dprintf
64 /*
65     #define ASSERT(x) \
66         if (! (x)) \
67         { \
68             DPF (DEBUG_ALWAYS, TEXT("Assertion violated: %s, File = %s, Line = #%ld\n"), \
69                  TEXT(#x), TEXT(__FILE__), (DWORD)__LINE__ ); \
70             abort (); \
71         }
72 */
73
74    #define REPORTERR(x) \
75        ReportDDError ((x), TEXT("%s(%ld)"), \
76                       TEXT(__FILE__), (DWORD)__LINE__ );
77
78    #define FATALERR(x) \
79        ReportDDError ((x), TEXT("%s(%ld)"), \
80                       TEXT(__FILE__), (DWORD)__LINE__ ); \
81        OnPause (TRUE); \
82        DestroyWindow (g_hWnd);
83 #else
84    #define REPORTERR(x)
85    #define DPF 1 ? (void)0 : (void)
86 /*
87    #define ASSERT(x)
88 */
89    #define FATALERR(x) \
90        OnPause (TRUE); \
91        DestroyWindow (g_hWnd);
92 #endif // NDEBUG
93
94
95
96 /*
97 **-----------------------------------------------------------------------------
98 **  Global Variables
99 **-----------------------------------------------------------------------------
100 */
101
102 // Debug Variables
103 #ifndef NDEBUG
104         extern DWORD g_dwDebugLevel;
105 #endif
106
107 extern BOOL  g_fDebug;
108
109
110
111 /*
112 **-----------------------------------------------------------------------------
113 **  Function Prototypes
114 **-----------------------------------------------------------------------------
115 */
116
117 // Debug Routines
118 #ifndef NDEBUG
119         void __cdecl dprintf (DWORD dwDebugLevel, LPCTSTR szFormat, ...);
120 #endif //NDEBUG
121
122 void _cdecl ReportDDError (HRESULT hResult, LPCTSTR szFormat, ...);
123
124 #ifndef NDEBUG
125 struct CDebugTracker
126 {
127         CDebugTracker (LPCSTR lpsz);
128         ~CDebugTracker ();
129
130         void __cdecl Return (LPCSTR szFormat, ...);
131
132 protected:
133         LPCSTR m_psz;
134         BOOL m_bReturned;
135         static ULONG s_cLevels;
136         static char szsp [80];
137 };
138
139 #define TRACKER_ENTER(str)\
140         CDebugTracker __tracker (str);
141 #else   // NDEBUG
142 #define TRACKER_ENTER(str) while(0);
143 #endif  // NDEBUG
144
145 /*
146 **-----------------------------------------------------------------------------
147 **  End of File
148 **-----------------------------------------------------------------------------
149 */
150 #endif // End DEBUG_H
151
152