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