| 1 | /* |
| 2 | Copyright (C) 2002 Rice1964 |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License |
| 6 | as published by the Free Software Foundation; either version 2 |
| 7 | of the License, or (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #if !defined(DEBUGGER_H) |
| 21 | #define DEBUGGER_H |
| 22 | |
| 23 | #include "typedefs.h" |
| 24 | |
| 25 | #if defined(DEBUGGER) |
| 26 | |
| 27 | // Debugger.h : header file |
| 28 | // |
| 29 | |
| 30 | ///////////////////////////////////////////////////////////////////////////// |
| 31 | // CDebugger dialog |
| 32 | extern bool debuggerWinOpened; |
| 33 | |
| 34 | extern bool logCombiners; |
| 35 | extern bool logTriangles; |
| 36 | extern bool logVertex; |
| 37 | extern bool logWarning; |
| 38 | extern bool logTextures; |
| 39 | extern bool logTextureBuffer; |
| 40 | extern bool logMatrix; |
| 41 | extern bool logToScreen; |
| 42 | extern bool logToFile; |
| 43 | extern bool logUcodes; |
| 44 | extern bool logMicrocode; |
| 45 | extern bool logFog; |
| 46 | extern bool logDetails; |
| 47 | |
| 48 | |
| 49 | extern bool debuggerEnableTexture; |
| 50 | extern bool debuggerEnableZBuffer; |
| 51 | extern bool debuggerEnableCullFace; |
| 52 | extern bool debuggerEnableTestTris; |
| 53 | extern bool debuggerEnableAlphaTest; |
| 54 | extern bool debuggerContinueWithUnknown; |
| 55 | |
| 56 | extern bool debuggerPause; |
| 57 | extern bool pauseAtNext; |
| 58 | extern int eventToPause; |
| 59 | extern int debuggerPauseCount; |
| 60 | extern int countToPause; |
| 61 | |
| 62 | extern bool debuggerDropCombiners; |
| 63 | extern bool debuggerDropGeneralCombiners; |
| 64 | extern bool debuggerDropDecodedMux; |
| 65 | extern bool debuggerDropCombinerInfos; |
| 66 | |
| 67 | enum { |
| 68 | NEXT_FRAME, |
| 69 | NEXT_FLUSH_TRI, |
| 70 | NEXT_TEXTRECT, |
| 71 | NEXT_TRIANGLE, |
| 72 | NEXT_SET_CIMG, |
| 73 | NEXT_OBJ_TXT_CMD, |
| 74 | NEXT_OBJ_BG, |
| 75 | NEXT_SPRITE_2D, |
| 76 | NEXT_FILLRECT, |
| 77 | NEXT_DLIST, |
| 78 | NEXT_UCODE, |
| 79 | NEXT_RENDER_TEXTURE, |
| 80 | NEXT_MATRIX_CMD, |
| 81 | NEXT_VERTEX_CMD, |
| 82 | NEXT_NEW_TEXTURE, |
| 83 | NEXT_SET_TEXTURE, |
| 84 | NEXT_MUX, |
| 85 | NEXT_SET_LIGHT, |
| 86 | NEXT_SET_MODE_CMD, |
| 87 | NEXT_SET_PRIM_COLOR, |
| 88 | NEXT_TEXTURE_CMD, |
| 89 | NEXT_UNKNOWN_OP, |
| 90 | NEXT_SCALE_IMG, |
| 91 | NEXT_LOADTLUT, |
| 92 | NEXT_SWITCH_UCODE, |
| 93 | }; |
| 94 | |
| 95 | void DebuggerPause(); |
| 96 | void __cdecl DebuggerAppendMsg(const char * Message, ...); |
| 97 | void DumpHex(uint32 rdramAddr, int count); |
| 98 | |
| 99 | void DumpMatrix(const Matrix &mtx, const char* prompt); |
| 100 | |
| 101 | //Some common used macros |
| 102 | #define DEBUG_DUMP_VERTEXES(str, v0, v1, v2) \ |
| 103 | if( (pauseAtNext && (eventToPause == NEXT_TRIANGLE || eventToPause == NEXT_FLUSH_TRI)) && logTriangles ) \ |
| 104 | { \ |
| 105 | DebuggerAppendMsg("%s:%d(%08X),%d(%08X),%d(%08X)\n", (str),\ |
| 106 | (v0), GetVertexDiffuseColor((v0)), \ |
| 107 | (v1), GetVertexDiffuseColor((v1)), \ |
| 108 | (v2), GetVertexDiffuseColor((v2))); \ |
| 109 | } |
| 110 | |
| 111 | #define DEBUGGER_IF(op) if(op) |
| 112 | #define DEBUGGER_PAUSE(op) if(pauseAtNext && eventToPause == op){pauseAtNext = false;CGraphicsContext::Get()->UpdateFrame(); debuggerPause = true;} |
| 113 | extern void DEBUGGER_PAUSE_COUNT_N(uint32 event); |
| 114 | extern void DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(uint32 val); |
| 115 | #define DebuggerPauseCountN DEBUGGER_PAUSE_COUNT_N |
| 116 | #define DEBUGGER_PAUSE_AND_DUMP(op,dumpfuc) \ |
| 117 | if(pauseAtNext && eventToPause == op) \ |
| 118 | { pauseAtNext = false;debuggerPause = true; CGraphicsContext::Get()->UpdateFrame(); dumpfuc;} |
| 119 | #define DEBUGGER_PAUSE_AND_DUMP_NO_UPDATE(op,dumpfuc) \ |
| 120 | if(pauseAtNext && eventToPause == op) \ |
| 121 | { pauseAtNext = false;debuggerPause = true; dumpfuc;} |
| 122 | |
| 123 | #define DEBUGGER_PAUSE_AND_DUMP_COUNT_N(op,dumpfuc) \ |
| 124 | if(pauseAtNext && eventToPause == op) \ |
| 125 | { if( debuggerPauseCount > 0 ) debuggerPauseCount--; if( debuggerPauseCount == 0 ){pauseAtNext = false;debuggerPause = true; CGraphicsContext::Get()->UpdateFrame(); dumpfuc;}} |
| 126 | |
| 127 | #define DEBUGGER_PAUSE_AT_COND_AND_DUMP_COUNT_N(cond,dumpfuc) \ |
| 128 | if(pauseAtNext && (cond) ) \ |
| 129 | { if( debuggerPauseCount > 0 ) debuggerPauseCount--; if( debuggerPauseCount == 0 ){pauseAtNext = false;debuggerPause = true; CGraphicsContext::Get()->UpdateFrame(); dumpfuc;}} |
| 130 | |
| 131 | void RDP_NOIMPL_Real(const char* op,uint32,uint32) ; |
| 132 | #define RSP_RDP_NOIMPL RDP_NOIMPL_Real |
| 133 | #define DEBUGGER_IF_DUMP(cond, dumpfunc) {if(cond) {dumpfunc}} |
| 134 | #define TXTRBUF_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTextureBuffer), dumpfunc) |
| 135 | #define TXTRBUF_DETAIL_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTextureBuffer&&logDetails), dumpfunc) |
| 136 | #define TXTRBUF_OR_CI_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTextureBuffer || (pauseAtNext && eventToPause == NEXT_SET_CIMG)), dumpfunc) |
| 137 | #define TXTRBUF_OR_CI_DETAIL_DUMP(dumpfunc) DEBUGGER_IF_DUMP(((logTextureBuffer || (pauseAtNext && eventToPause == NEXT_SET_CIMG))&&logDetails), dumpfunc) |
| 138 | #define VTX_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logVertex && pauseAtNext), dumpfunc) |
| 139 | #define TRI_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTriangles && pauseAtNext), dumpfunc) |
| 140 | #define LIGHT_DUMP(dumpfunc) DEBUGGER_IF_DUMP((eventToPause == NEXT_SET_LIGHT && pauseAtNext), dumpfunc) |
| 141 | #define WARNING(dumpfunc) DEBUGGER_IF_DUMP(logWarning, dumpfunc) |
| 142 | #define FOG_DUMP(dumpfunc) DEBUGGER_IF_DUMP(logFog, dumpfunc) |
| 143 | #define LOG_TEXTURE(dumpfunc) DEBUGGER_IF_DUMP((logTextures || (pauseAtNext && eventToPause==NEXT_TEXTURE_CMD) ), dumpfunc) |
| 144 | #define DEBUGGER_ONLY_IF DEBUGGER_IF_DUMP |
| 145 | #define DEBUGGER_ONLY(func) {func} |
| 146 | |
| 147 | #define TRACE0(arg0) {DebuggerAppendMsg(arg0);} |
| 148 | #define TRACE1(arg0,arg1) {DebuggerAppendMsg(arg0,arg1);} |
| 149 | #define TRACE2(arg0,arg1,arg2) {DebuggerAppendMsg(arg0,arg1,arg2);} |
| 150 | #define TRACE3(arg0,arg1,arg2,arg3) {DebuggerAppendMsg(arg0,arg1,arg2,arg3);} |
| 151 | #define TRACE4(arg0,arg1,arg2,arg3,arg4) {DebuggerAppendMsg(arg0,arg1,arg2,arg3,arg4);} |
| 152 | #define TRACE5(arg0,arg1,arg2,arg3,arg4,arg5) {DebuggerAppendMsg(arg0,arg1,arg2,arg3,arg4,arg5);} |
| 153 | |
| 154 | #define DEBUG_TRIANGLE(dumpfunc) { if(pauseAtNext && eventToPause==NEXT_TRIANGLE ) { eventToPause = NEXT_FLUSH_TRI; debuggerPause = true; DEBUGGER_PAUSE(NEXT_FLUSH_TRI); dumpfunc} } |
| 155 | |
| 156 | #else |
| 157 | #define DEBUG_DUMP_VERTEXES(str, v0, v1, v2) |
| 158 | #define DEBUGGER_IF(op) |
| 159 | #define DEBUGGER_PAUSE(op) |
| 160 | #define DEBUGGER_PAUSE_COUNT_N(op) |
| 161 | #define DEBUGGER_PAUSE_AND_DUMP(op,dumpfuc) |
| 162 | #define DebuggerPauseCountN DEBUGGER_PAUSE_COUNT_N |
| 163 | #define DEBUGGER_PAUSE_AT_COND_AND_DUMP_COUNT_N(cond,dumpfuc) |
| 164 | #define DEBUGGER_PAUSE_AND_DUMP_COUNT_N(op,dumpfuc) |
| 165 | #define DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(op) |
| 166 | #define DEBUGGER_PAUSE_AND_DUMP_NO_UPDATE(op,dumpfuc) |
| 167 | #define RSP_RDP_NOIMPL(a,b,c) |
| 168 | void __cdecl DebuggerAppendMsg(const char * Message, ...); |
| 169 | #define DumpHex(rdramAddr, count) |
| 170 | #define DEBUGGER_IF_DUMP(cond, dumpfunc) |
| 171 | #define TXTRBUF_DUMP(dumpfunc) |
| 172 | #define TXTRBUF_DETAIL_DUMP(dumpfunc) |
| 173 | #define TXTRBUF_OR_CI_DUMP(dumpfunc) |
| 174 | #define TXTRBUF_OR_CI_DETAIL_DUMP(dumpfunc) |
| 175 | #define VTX_DUMP(dumpfunc) |
| 176 | #define TRI_DUMP(dumpfunc) |
| 177 | #define LIGHT_DUMP(dumpfunc) |
| 178 | #define WARNING(dumpfunc) |
| 179 | #define FOG_DUMP(dumpfunc) |
| 180 | #define LOG_TEXTURE(dumpfunc) |
| 181 | #define DEBUGGER_ONLY_IF DEBUGGER_IF_DUMP |
| 182 | #define DEBUGGER_ONLY(func) |
| 183 | #define DumpMatrix(a,b) |
| 184 | |
| 185 | #define TRACE0(arg0) {} |
| 186 | #define TRACE1(arg0,arg1) {} |
| 187 | #define TRACE2(arg0,arg1,arg2) {} |
| 188 | #define TRACE3(arg0,arg1,arg2,arg3) {} |
| 189 | #define TRACE4(arg0,arg1,arg2,arg3,arg4) {} |
| 190 | #define TRACE5(arg0,arg1,arg2,arg3,arg4,arg5) {} |
| 191 | |
| 192 | #define DEBUG_TRIANGLE(arg0) {} |
| 193 | |
| 194 | #endif |
| 195 | |
| 196 | #endif // !defined(DEBUGGER_H) |
| 197 | |