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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
|
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC([email protected]).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
**
**
** $Header: /cvsroot/glide/glide3x/h3/glide3/src/gerror.c,v 1.2 2000/02/15 22:35:58 joseph Exp $
** $Log: gerror.c,v $
** Revision 1.2 2000/02/15 22:35:58 joseph
** Changes to support FreeBSD (patch submitted by Doug Rabson)
**
** Revision 1.1.1.1 1999/11/24 21:44:56 joseph
** Initial checkin for SourceForge
**
**
** 4 4/06/99 3:54p Dow
** Alt tab again.
**
** 13 4/05/99 8:25p Dow
** Alt tab mostly happy
**
** 12 4/04/99 8:51p Atai
** Partial check-in for alt-tab issue. set FX_GLIDE_ALT_TAB=1 to build
** glide3x with hwcQueryContext built into GR_BEGIN_NOFIFOCHECK. It works
** with DEBUG glide only. In the non-debug glide, we can still see the
** desktop corruption.
**
** 11 3/19/99 11:26a Peter
** expose direct fifo for gl
**
** 10 3/02/99 2:04p Peter
** made error tracing output use consistent address bases for the fifo
** output
**
** 9 10/22/98 11:45a Atai
** be consistent with fatal error
**
** 8 7/18/98 1:45p Jdt
** Removed TACO_MEMORY_FIFO_HACK
**
** 7 7/16/98 8:17a Jdt
** fxcmd.h
**
** protected some direct hardware reads from TACO_MEMORY_FIFO_HACK
**
** 6 7/01/98 12:40p Jdt
** Changed grErrorWindowsCallback to grErrorDefault Callback,
** this removes some conditional compilation from grSstWinOpen
**
** 5 4/30/98 5:01p Peter
** first pass glide3 merge
**
** 3 4/22/98 4:57p Peter
** glide2x merge
**
** 2 1/22/98 10:35a Atai
** 1. introduce GLIDE_VERSION, g3\glide.h, g3\glideutl.h, g2\glide.h,
** g2\glideutl.h
** 2. fixed grChromaRange, grSstOrigin, and grGetProcAddress
*
* 1 1/16/98 4:29p Atai
* create glide 3 src
*
* 26 12/18/97 2:13p Peter
* cleaned up the error code
*
* 25 12/09/97 12:20p Peter
* mac glide port
*
* 24 12/05/97 4:38p Peter
* sli vs assertions
*
* 23 12/03/97 11:34a Peter
* dos debugging
*
* 22 11/17/97 4:55p Peter
* watcom warnings/chipfield stuff
*
* 21 11/15/97 8:55p Peter
* Removed OutputDebugString
*
* 20 11/15/97 7:43p Peter
* more comdex silliness
*
* 19 11/12/97 2:27p Peter
*
* 18 11/12/97 11:16a Peter
* cleaned up assertions
*
* 17 11/04/97 5:04p Peter
* cataclysm part deux
*
* 16 11/03/97 4:02p Peter
* cataclysm fix
*
* 15 11/03/97 3:43p Peter
* h3/cvg cataclysm
*
* 14 10/23/97 5:28p Peter
* sli fifo thing
*
* 13 9/24/97 1:29p Peter
* more assertion spewage
*
* 12 9/05/97 5:29p Peter
* changes for direct hw
*
* 11 5/30/97 5:44p Peter
* Version that does basic triangles/registers w/ command fifo. Does not
* currently download textures correctly.
*
* 10 5/28/97 9:05a Peter
* Merge w/ latest glide changes
*
* 9 5/27/97 1:16p Peter
* Basic cvg, w/o cmd fifo stuff.
*
* 8 5/21/97 6:05a Peter
*
* 7 5/20/97 9:47a Pgj
* Use OutputDebugString for non-fatal errors under windows
*
* 6 5/19/97 7:35p Pgj
* Print cogent error message if h/w not found
*
* 5 3/09/97 10:31a Dow
* Added GR_DIENTRY for di glide functions
*
* 4 12/23/96 1:37p Dow
* chagnes for multiplatform glide
**
*/
#include <stdio.h>
#ifdef __DOS__
# include <malloc.h>
#endif
#ifdef __WIN32__
# include <windows.h>
#endif
#include <3dfx.h>
#define FX_DLL_DEFINITION
#include <fxdll.h>
#include <glide.h>
#include "fxglide.h"
#include "fxcmd.h"
void (*GrErrorCallback)( const char *string, FxBool fatal );
void _doGrErrorCallback( const char *name, const char *msg, FxBool fatal )
{
char buf[1024];
#if GDBG_INFO_ON
/* Neuter any fifo checking from the failing
* call. Otherwise entries into the shutdown
* calls cause spurious crap.
*/
if (fatal) {
GR_DCL_GC;
gc->checkCounter =
gc->expected_counter = 0;
gc->checkCounter =
gc->checkPtr = 0UL;
}
#endif /* GDBG_INFO_ON */
gdbg_printf("%s: %s.\n", name, msg);
sprintf(buf,"%s: %s.\n", name, msg);
GrErrorCallback(buf, fatal);
if (fatal) exit(1);
}
GR_DIENTRY(grErrorSetCallback, void,
( void (*function) ( const char *string, FxBool fatal ) ))
{
GDBG_INFO(80,"grErrorSetCallback(0x%x)",function);
GrErrorCallback = function;
}
#ifdef __WIN32__
void
_grErrorDefaultCallback( const char *s, FxBool fatal )
{
if ( fatal ) {
GDBG_ERROR("glide", s);
grGlideShutdown();
MessageBox(NULL, s, NULL, MB_OK);
exit(1);
}
}
#else
void
_grErrorDefaultCallback( const char *s, FxBool fatal )
{
if ( fatal ) {
GDBG_ERROR("glide",s);
grGlideShutdown();
#if (GLIDE_PLATFORM & GLIDE_OS_MACOS)
{
Str255 errBuf;
errBuf[0] = sprintf((char*)(errBuf 1), "%s", s);
DebugStr(errBuf);
}
#endif /* (GLIDE_PLATFORM * GLIDE_OS_MACOS) */
}
}
#endif
#ifdef __DOS__
int _guHeapCheck( void )
{
int i = _heapchk();
if ( i != _HEAPOK )
printf( "heapchk: %d\n", i );
return ( i == 0 );
}
#endif
#if !defined(__linux__) && !defined(__FreeBSD__)
void
i3(void)
{
__asm int 3;
}
#endif
void
_grAssert(char *exp, char *fileName, int lineNo)
{
static int depth;
return;
if (depth)
return;
depth ;
#if GLIDE_INIT_HAL
#else /* !GLIDE_INIT_HAL */
/* initRestoreVideo(); */
#endif /* !GLIDE_INIT_HAL */
gdbg_printf("ASSERTION FAILED:\n");
gdbg_printf("\tExpression: %s\n", exp);
gdbg_printf("\tFile: %s\n", fileName);
gdbg_printf("\tLine: %d\n", lineNo);
#if USE_PACKET_FIFO
/* Spew about the state of the fifo since that's what most of the
* assertions are about anyway.
*/
{
GR_DCL_GC;
GR_DCL_HW;
gdbg_printf("Command Fifo:\n");
gdbg_printf("\tSoftware:\n");
gdbg_printf("\t\tfifoPtr: 0x%X\n", (AnyPtr)gc->cmdTransportInfo.fifoPtr - (AnyPtr) gc->rawLfb);
gdbg_printf("\t\tfifoOffset: 0x%X\n", gc->cmdTransportInfo.fifoOffset);
gdbg_printf("\t\tfifoEnd: 0x%X\n", gc->cmdTransportInfo.fifoEnd - gc->rawLfb);
gdbg_printf("\t\tfifoSize: 0x%X\n", gc->cmdTransportInfo.fifoSize);
gdbg_printf("\t\tfifoRoom: 0x%X\n", gc->cmdTransportInfo.fifoRoom);
gdbg_printf("\t\troomToReadPtr: 0x%X\n", gc->cmdTransportInfo.roomToReadPtr);
gdbg_printf("\t\troomToEnd: 0x%X\n", gc->cmdTransportInfo.roomToEnd);
if ( !gc->windowed ) {
gdbg_printf("\tHardware:\n");
gdbg_printf("\t\treadPtrL: 0x%X\n", HW_FIFO_PTR(FXTRUE) - (AnyPtr)gc->rawLfb);
gdbg_printf("\t\tdepth: 0x%X\n", GR_CAGP_GET(depth));
gdbg_printf("\t\tholeCount: 0x%X\n", GR_CAGP_GET(holeCount));
gdbg_printf("\t\tbaseAddrL: 0x%X\n", GR_CAGP_GET(baseAddrL));
gdbg_printf("\t\taMin: 0x%X\n", GR_CAGP_GET(aMin));
gdbg_printf("\t\taMax: 0x%X\n", GR_CAGP_GET(aMax));
gdbg_printf("\t\tStatus: 0x%X\n", GR_GET(hw->status));
}
}
#endif /* (GLIDE_PLATFORM & GLIDE_HW_CVG) && USE_PACKET_FIFO */
gdbg_printf("ABNORMAL TERMINATION\n");
grGlideShutdown();
depth--;
exit(-1);
} /* _grAssert */
|