1 2 3 4 5 6 7 8 9 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "gsCommon.h"
#include "gsDebug.h"
// This is the platform specific default assert condition handler
extern void _gsDebugAssert (const char * string);
static gsDebugAssertCallback gsDebugAssertHandler = _gsDebugAssert;
// Call this function to override the default assert handler
// New function should render message / log message based on string passed
void gsDebugAssertCallbackSet(gsDebugAssertCallback theCallback)
{
if (theCallback)
gsDebugAssertHandler = theCallback;
else
gsDebugAssertHandler = _gsDebugAssert;
}
// This is the default assert condition handler
void gsDebugAssert (const char *szError,const char *szText, const char *szFile, int line)
{
char String[256];
// format into buffer
sprintf(&String[0], szError,szText,szFile,line);
// call plat specific handler
(*gsDebugAssertHandler)(String);
}
// ****************************************************
// Todo: move to platform specific modules
#ifdef _XBOX
// ErrorMessage: Displays message and goes into an infinite loop
// continues rendering
void _gsDebugAssert (const char *string)
{
//DebugBreak();
OutputDebugString( string);
exit(0);
}
#elif defined _WIN32
#include <windows.h>
#pragma warning(disable: 4127) // disable warnings from "conditional expression is constant"
// ErrorMessage: Displays message and goes into an infinite loop
// continues rendering
void _gsDebugAssert (const char *string)
{
//DebugBreak();
#ifdef _CONSOLE //,_MBCS
printf("%s",string);
while(1)
{
};
#else
{
OutputDebugStringA( string);
#ifndef GS_ASSERT_NO_MESSAGEBOX
{
int rcode = MessageBoxA(NULL,string,"Assert Failed",MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
if(rcode == IDABORT)
{
exit(0);
}
if(rcode == IDRETRY)
{
DebugBreak();
return;
}
}
#else
DebugBreak();
#endif
}
#endif
}
#elif defined _PSP
// ToDo:
// ErrorMessage: Displays message and goes into an infinite loop
// continues rendering
void _gsDebugAssert (const char *string)
{
printf("%s", string);
while(1)
{
};
}
#elif defined _PS2
// already included in gsPlatform.h
/*
#include <eetypes.h>
#include <eekernel.h>
*/
// ErrorMessage: Displays message and goes into an infinite loop
// continues rendering
void _gsDebugAssert (const char *string)
{
scePrintf("%s", string);
while(1);;
}
#elif defined _MACOSX
void _gsDebugAssert (const char *string)
{
printf("%s", string);
while(1)
{
};
}
#elif defined _LINUX
void _gsDebugAssert (const char *string)
{
printf("%s", string);
while(1)
{
};
}
#elif defined _NITRO
void _gsDebugAssert (const char *string)
{
#if SDK_FINALROM != 1
OS_TPanic("%s",string);
#else
GSI_UNUSED(string);
#endif
}
#elif defined(_REVOLUTION)
void _gsDebugAssert(const char *string)
{
OSHalt(string);
}
#else
// ErrorMessage: Displays message and goes into an infinite loop
// continues rendering
void _gsDebugAssert (const char *string)
{
printf("%s", string);
while(1);;
}
#endif
|