//----------------------------------------------------------------------------- // globals //----------------------------------------------------------------------------- SpewRetval_t DefaultSpewFunc( SpewType_t type, const tchar *pMsg ) { #ifdef _X360 if ( XBX_IsConsoleConnected() ) { // send to console XBX_DebugString( XMAKECOLOR( 0,0,0 ), pMsg ); } else #endif { _tprintf( _T("%s"), pMsg ); #ifdef _WIN32 Plat_DebugString( pMsg ); #endif } if ( type == SPEW_ASSERT ) return SPEW_DEBUGGER; else if ( type == SPEW_ERROR ) return SPEW_ABORT; else return SPEW_CONTINUE; }
//----------------------------------------------------------------------------- // Low level string output. // Input string should be stack based, can get clobbered. //----------------------------------------------------------------------------- static void OutputStringToDevice( unsigned int color, char *pString, bool bRemoteValid ) { if ( !bRemoteValid ) { // local debug only OutputDebugStringA( pString ); return; } // remote debug valid // non pure colors don't translate well - find closest pure hue unsigned int bestColor = color; int r = ( bestColor & 0xFF ); int g = ( bestColor >> 8 ) & 0xFF; int b = ( bestColor >> 16 ) & 0xFF; if ( ( r && r != 255 ) || ( g && g != 255 ) || ( b && b != 255 ) ) { int r0, g0, b0; unsigned int minDist = 0xFFFFFFFF; for ( int i=0; i<8; i++ ) { r0 = g0 = b0 = 0; if ( i&4 ) r0 = 255; if ( i&2 ) g0 = 255; if ( i&1 ) b0 = 255; unsigned int d = ( r-r0 )*( r-r0 ) + ( g-g0 )*( g-g0 ) + ( b-b0 )*( b-b0 ); if ( minDist > d ) { minDist = d; bestColor = XMAKECOLOR( r0, g0, b0 ); } } } // create color string char colorString[16]; sprintf( colorString, XBX_DBGCOLORPREFIX "[%8.8x]", bestColor ); // chunk line out, for each cr char strBuffer[XBX_MAX_RCMDLENGTH]; char *pStart = pString; char *pEnd = pStart + strlen( pStart ); char *pNext; while ( pStart < pEnd ) { pNext = strchr( pStart, '\n' ); if ( !pNext ) pNext = pEnd; else *pNext = '\0'; int length = _snprintf( strBuffer, XBX_MAX_RCMDLENGTH, "%s!%s%s", XBX_DBGPRINTPREFIX, colorString, pStart ); if ( length == -1 ) { strBuffer[sizeof( strBuffer )-1] = '\0'; } // Send the string DmSendNotificationString( strBuffer ); // advance past cr pStart = pNext+1; } }