Index: ddraw/glRenderWindow.cpp |
— | — | @@ -23,6 +23,9 @@ |
24 | 24 |
|
25 | 25 | WNDCLASSEXA wndclass;
|
26 | 26 | bool wndclasscreated = false;
|
| 27 | +#ifdef _DEBUG
|
| 28 | +bool hotkeyregistered = false;
|
| 29 | +#endif
|
27 | 30 |
|
28 | 31 | void WaitForObjectAndMessages(HANDLE object)
|
29 | 32 | {
|
— | — | @@ -100,6 +103,10 @@ |
101 | 104 | "DXGLRenderWindow","Renderer",WS_POPUP,0,0,width,height,0,0,NULL,this);
|
102 | 105 | SetWindowPos(hWnd,HWND_TOP,0,0,width,height,SWP_SHOWWINDOW|SWP_NOACTIVATE);
|
103 | 106 | }
|
| 107 | + #ifdef _DEBUG
|
| 108 | + if(RegisterHotKey(hWnd,1,MOD_CONTROL,VK_CANCEL)) hotkeyregistered = true;
|
| 109 | + else Beep(120,1000);
|
| 110 | + #endif
|
104 | 111 | SetEvent(ReadyEvent);
|
105 | 112 | while((GetMessage(&Msg, NULL, 0, 0) > 0) && !dead)
|
106 | 113 | {
|
— | — | @@ -111,11 +118,22 @@ |
112 | 119 |
|
113 | 120 | glRenderWindow::~glRenderWindow()
|
114 | 121 | {
|
| 122 | + #ifdef _DEBUG
|
| 123 | + if(hotkeyregistered) UnregisterHotKey(hWnd,1);
|
| 124 | + #endif
|
115 | 125 | SendMessage(hWnd,WM_CLOSE,0,0);
|
116 | 126 | WaitForSingleObject(hThread,INFINITE);
|
117 | 127 | CloseHandle(hThread);
|
118 | 128 | }
|
119 | 129 |
|
| 130 | +#ifdef _TRACE
|
| 131 | +DWORD WINAPI BeepThread(void *unused)
|
| 132 | +{
|
| 133 | + Beep(3600,150);
|
| 134 | + return 0;
|
| 135 | +}
|
| 136 | +#endif
|
| 137 | +
|
120 | 138 | LRESULT glRenderWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
121 | 139 | {
|
122 | 140 | int oldx,oldy;
|
— | — | @@ -179,6 +197,18 @@ |
180 | 198 | PostQuitMessage(0);
|
181 | 199 | dead = true;
|
182 | 200 | return 0;
|
| 201 | + #ifdef _DEBUG
|
| 202 | + case WM_HOTKEY:
|
| 203 | + #ifdef _TRACE
|
| 204 | + trace_end = true;
|
| 205 | + CreateThread(NULL,0,BeepThread,NULL,0,NULL);
|
| 206 | + UnregisterHotKey(hWnd,1);
|
| 207 | + hotkeyregistered = false;
|
| 208 | + #else
|
| 209 | + Beep(3600,150);
|
| 210 | + DebugBreak();
|
| 211 | + #endif
|
| 212 | + #endif
|
183 | 213 | default:
|
184 | 214 | return DefWindowProc(hwnd,msg,wParam,lParam);
|
185 | 215 | }
|
Index: ddraw/trace.cpp |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
19 | 19 | #include "common.h"
|
| 20 | +#include "trace.h"
|
20 | 21 |
|
21 | 22 | /* Data types:
|
22 | 23 | -1 - C++ constructor/destructor
|
— | — | @@ -56,6 +57,7 @@ |
57 | 58 | static CRITICAL_SECTION trace_cs;
|
58 | 59 | static bool trace_ready = false;
|
59 | 60 | static bool trace_fail = false;
|
| 61 | +bool trace_end = false;
|
60 | 62 | static HANDLE outfile = INVALID_HANDLE_VALUE;
|
61 | 63 | unsigned int trace_depth = 0;
|
62 | 64 | static void trace_decode_hresult(HRESULT hr)
|
— | — | @@ -1043,11 +1045,25 @@ |
1044 | 1046 | break;
|
1045 | 1047 | }
|
1046 | 1048 | }
|
| 1049 | +static void end_trace()
|
| 1050 | +{
|
| 1051 | + DWORD byteswritten;
|
| 1052 | + WriteFile(outfile,"Trace cancelled by CTRL+Break\r\n",31,&byteswritten,NULL);
|
| 1053 | + CloseHandle(outfile);
|
| 1054 | + outfile = INVALID_HANDLE_VALUE;
|
| 1055 | + trace_fail = true;
|
| 1056 | +}
|
1047 | 1057 | void trace_enter(const char *function, int paramcount, ...)
|
1048 | 1058 | {
|
1049 | 1059 | if(trace_fail) return;
|
1050 | 1060 | if(!trace_ready) init_trace();
|
1051 | 1061 | EnterCriticalSection(&trace_cs);
|
| 1062 | + if(trace_end)
|
| 1063 | + {
|
| 1064 | + end_trace();
|
| 1065 | + LeaveCriticalSection(&trace_cs);
|
| 1066 | + return;
|
| 1067 | + }
|
1052 | 1068 | va_list args;
|
1053 | 1069 | va_start(args,paramcount);
|
1054 | 1070 | DWORD byteswritten;
|
— | — | @@ -1070,6 +1086,12 @@ |
1071 | 1087 | if(trace_fail) return;
|
1072 | 1088 | if(!trace_ready) init_trace();
|
1073 | 1089 | EnterCriticalSection(&trace_cs);
|
| 1090 | + if(trace_end)
|
| 1091 | + {
|
| 1092 | + end_trace();
|
| 1093 | + LeaveCriticalSection(&trace_cs);
|
| 1094 | + return;
|
| 1095 | + }
|
1074 | 1096 | if(trace_depth) trace_depth--;
|
1075 | 1097 | DWORD byteswritten;
|
1076 | 1098 | for(unsigned int i = 0; i < trace_depth; i++)
|
— | — | @@ -1090,6 +1112,12 @@ |
1091 | 1113 | if(trace_fail) return;
|
1092 | 1114 | if(!trace_ready) init_trace();
|
1093 | 1115 | EnterCriticalSection(&trace_cs);
|
| 1116 | + if(trace_end)
|
| 1117 | + {
|
| 1118 | + end_trace();
|
| 1119 | + LeaveCriticalSection(&trace_cs);
|
| 1120 | + return;
|
| 1121 | + }
|
1094 | 1122 | DWORD byteswritten;
|
1095 | 1123 | for(unsigned int i = 0; i < trace_depth-1; i++)
|
1096 | 1124 | WriteFile(outfile," ",4,&byteswritten,NULL);
|
— | — | @@ -1107,6 +1135,12 @@ |
1108 | 1136 | if(trace_fail) return;
|
1109 | 1137 | if(!trace_ready) init_trace();
|
1110 | 1138 | EnterCriticalSection(&trace_cs);
|
| 1139 | + if(trace_end)
|
| 1140 | + {
|
| 1141 | + end_trace();
|
| 1142 | + LeaveCriticalSection(&trace_cs);
|
| 1143 | + return;
|
| 1144 | + }
|
1111 | 1145 | DWORD byteswritten;
|
1112 | 1146 | OSVERSIONINFOA osver;
|
1113 | 1147 | DWORD buildver;
|
Index: ddraw/trace.h |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 |
|
23 | 23 |
|
24 | 24 | #ifdef _TRACE
|
| 25 | +extern bool trace_end;
|
25 | 26 | #define TRACE_ENTER(paramcount,...) trace_enter(__FUNCTION__,paramcount,__VA_ARGS__)
|
26 | 27 | #define TRACE_EXIT(argtype,arg) trace_exit(__FUNCTION__,argtype,(void*)arg)
|
27 | 28 | #define TRACE_VAR(var,argtype,arg) trace_var(__FUNCTION__,var,argtype,(void*)arg)
|