mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
New addr param to checkAndDeliver so address can be passed back to
comms; Add debug-only menus to toggle logging to file and memopad.
This commit is contained in:
parent
07f21767fc
commit
3645481a53
4 changed files with 71 additions and 50 deletions
|
@ -159,8 +159,9 @@ static void palm_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
|
||||||
const CommsAddrRec* newAddr );
|
const CommsAddrRec* newAddr );
|
||||||
#endif
|
#endif
|
||||||
#ifdef XWFEATURE_BLUETOOTH
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
static void btDataHandler( PalmAppGlobals* globals, const XP_U8* data,
|
static void btDataHandler( PalmAppGlobals* globals,
|
||||||
XP_U16 len );
|
const CommsAddrRec* fromAddr,
|
||||||
|
const XP_U8* data, XP_U16 len );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
|
@ -1933,6 +1934,16 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame )
|
||||||
} /* initAndStartBoard */
|
} /* initAndStartBoard */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
static void
|
||||||
|
toggleBoolFtr( XP_U16 ftr )
|
||||||
|
{
|
||||||
|
UInt32 val;
|
||||||
|
FtrGet( APPID, ftr, &val );
|
||||||
|
val = !val;
|
||||||
|
FtrSet( APPID, ftr, val );
|
||||||
|
XP_WARNF( "Turned %s.", val==0? "OFF" : "ON" );
|
||||||
|
} /* toggleBoolFtr */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
askOnClose( XWStreamCtxt* stream, void* closure )
|
askOnClose( XWStreamCtxt* stream, void* closure )
|
||||||
{
|
{
|
||||||
|
@ -2445,23 +2456,16 @@ mainViewHandleEvent( EventPtr event )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case XW_DEBUGSHOW_PULLDOWN_ID:
|
case XW_LOGFILE_PULLDOWN_ID:
|
||||||
globals->gState.showDebugstrs = true;
|
toggleBoolFtr( LOG_FILE_FEATURE );
|
||||||
break;
|
break;
|
||||||
case XW_DEBUGHIDE_PULLDOWN_ID:
|
case XW_LOGMEMO_PULLDOWN_ID:
|
||||||
globals->gState.showDebugstrs = false;
|
toggleBoolFtr( LOG_MEMO_FEATURE );
|
||||||
board_invalAll( globals->game.board );
|
|
||||||
draw = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XW_DEBUGMEMO_PULLDOWN_ID:
|
case XW_CLEARLOGS_PULLDOWN_ID:
|
||||||
globals->gState.logToMemo = true;
|
PalmClearLogs();
|
||||||
break;
|
break;
|
||||||
case XW_DEBUGSCREEN_PULLDOWN_ID:
|
|
||||||
globals->gState.logToMemo = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
# if 0
|
# if 0
|
||||||
case XW_RESET_PULLDOWN_ID: {
|
case XW_RESET_PULLDOWN_ID: {
|
||||||
EventType eventToPost;
|
EventType eventToPost;
|
||||||
|
@ -3487,10 +3491,11 @@ palm_send( const XP_U8* buf, XP_U16 len,
|
||||||
} /* palm_send */
|
} /* palm_send */
|
||||||
|
|
||||||
void
|
void
|
||||||
checkAndDeliver( PalmAppGlobals* globals, XWStreamCtxt* instream )
|
checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr,
|
||||||
|
XWStreamCtxt* instream )
|
||||||
{
|
{
|
||||||
if ( comms_checkIncomingStream( globals->game.comms,
|
if ( comms_checkIncomingStream( globals->game.comms,
|
||||||
instream, NULL ) ) {
|
instream, addr ) ) {
|
||||||
globals->msgReceivedDraw =
|
globals->msgReceivedDraw =
|
||||||
server_receiveMessage( globals->game.server, instream );
|
server_receiveMessage( globals->game.server, instream );
|
||||||
globals->msgReceivedDraw = true;
|
globals->msgReceivedDraw = true;
|
||||||
|
@ -3546,13 +3551,14 @@ palm_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
||||||
#ifdef BEYOND_IR
|
#ifdef BEYOND_IR
|
||||||
#ifdef XWFEATURE_BLUETOOTH
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
static void
|
static void
|
||||||
btDataHandler( PalmAppGlobals* globals, const XP_U8* data, XP_U16 len )
|
btDataHandler( PalmAppGlobals* globals, const CommsAddrRec* fromAddr,
|
||||||
|
const XP_U8* data, XP_U16 len )
|
||||||
{
|
{
|
||||||
XWStreamCtxt* instream;
|
XWStreamCtxt* instream;
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
instream = makeSimpleStream( globals, NULL );
|
instream = makeSimpleStream( globals, NULL );
|
||||||
stream_putBytes( instream, data, len );
|
stream_putBytes( instream, data, len );
|
||||||
checkAndDeliver( globals, instream );
|
checkAndDeliver( globals, fromAddr, instream );
|
||||||
LOG_RETURN_VOID();
|
LOG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -127,7 +127,6 @@ typedef struct XWords4PreferenceType {
|
||||||
Boolean showColors;
|
Boolean showColors;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Boolean showDebugstrs;
|
Boolean showDebugstrs;
|
||||||
Boolean logToMemo;
|
|
||||||
Boolean reserved1;
|
Boolean reserved1;
|
||||||
Boolean reserved2;
|
Boolean reserved2;
|
||||||
#else
|
#else
|
||||||
|
@ -336,6 +335,9 @@ enum { dictSelectedEvent = firstUserEvent /* 0x6000 */
|
||||||
enum {
|
enum {
|
||||||
PNOLET_STORE_FEATURE = 1 /* where FtrPtr to pnolet code lives */
|
PNOLET_STORE_FEATURE = 1 /* where FtrPtr to pnolet code lives */
|
||||||
, GLOBALS_FEATURE /* for passing globals to form handlers */
|
, GLOBALS_FEATURE /* for passing globals to form handlers */
|
||||||
|
, LOG_FILE_FEATURE /* these three for debugging */
|
||||||
|
, LOG_MEMO_FEATURE
|
||||||
|
, LOG_SCREEN_FEATURE
|
||||||
#ifdef FEATURE_DUALCHOOSE
|
#ifdef FEATURE_DUALCHOOSE
|
||||||
, FEATURE_WANTS_68K /* support for (pre-ship) ability to choose
|
, FEATURE_WANTS_68K /* support for (pre-ship) ability to choose
|
||||||
armlet or 68K */
|
armlet or 68K */
|
||||||
|
@ -377,7 +379,8 @@ void writeNameToGameRecord( PalmAppGlobals* globals, XP_S16 index,
|
||||||
XP_UCHAR* getResString( PalmAppGlobals* globals, XP_U16 strID );
|
XP_UCHAR* getResString( PalmAppGlobals* globals, XP_U16 strID );
|
||||||
Boolean palmask( PalmAppGlobals* globals, XP_UCHAR* str, XP_UCHAR* altButton,
|
Boolean palmask( PalmAppGlobals* globals, XP_UCHAR* str, XP_UCHAR* altButton,
|
||||||
XP_S16 titleID );
|
XP_S16 titleID );
|
||||||
void checkAndDeliver( PalmAppGlobals* globals, XWStreamCtxt* instream );
|
void checkAndDeliver( PalmAppGlobals* globals, const CommsAddrRec* addr,
|
||||||
|
XWStreamCtxt* instream );
|
||||||
|
|
||||||
#ifdef XW_TARGET_PNO
|
#ifdef XW_TARGET_PNO
|
||||||
# define READ_UNALIGNED16(n) read_unaligned16((unsigned char*)(n))
|
# define READ_UNALIGNED16(n) read_unaligned16((unsigned char*)(n))
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
#include "palmmain.h"
|
#include "palmmain.h"
|
||||||
#include "comtypes.h"
|
#include "comtypes.h"
|
||||||
|
|
||||||
|
#define MEMO "MemoDB"
|
||||||
|
#define LOGFILE "XWLogfile"
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* This is meant to be replaced by an actual beep....
|
* This is meant to be replaced by an actual beep....
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -457,7 +460,6 @@ doNothing( EventPtr event )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
void
|
void
|
||||||
logEvent( eventsEnum eType )
|
logEvent( eventsEnum eType )
|
||||||
{
|
{
|
||||||
|
@ -659,10 +661,44 @@ logToDB( const char* buf, const char* dbName, XP_U32 dbCreator, XP_U32 dbType )
|
||||||
DmCloseDatabase( ref );
|
DmCloseDatabase( ref );
|
||||||
} /* logToDB */
|
} /* logToDB */
|
||||||
|
|
||||||
|
static void
|
||||||
|
deleteDB( const char* dbName )
|
||||||
|
{
|
||||||
|
LocalID dbID;
|
||||||
|
dbID = DmFindDatabase( CARD_0, dbName );
|
||||||
|
if ( 0 != dbID ) {
|
||||||
|
Err err = DmDeleteDatabase( CARD_0, dbID );
|
||||||
|
XP_ASSERT( errNone == err );
|
||||||
|
} else {
|
||||||
|
XP_WARNF( "%s(%s): got back 0", __FUNCTION__, dbName );
|
||||||
|
}
|
||||||
|
} /* deleteDB */
|
||||||
|
|
||||||
|
void
|
||||||
|
PalmClearLogs( void )
|
||||||
|
{
|
||||||
|
deleteDB( MEMO );
|
||||||
|
deleteDB( LOGFILE );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
logToMemo( const char* buf )
|
logToMemo( const char* buf )
|
||||||
{
|
{
|
||||||
logToDB( buf, "MemoDB", 'memo', 'DATA' );
|
UInt32 val = 0L;
|
||||||
|
Err err = FtrGet( APPID, LOG_MEMO_FEATURE, (UInt32*)&val );
|
||||||
|
if ( errNone == err && val != 0 ) {
|
||||||
|
logToDB( buf, MEMO, 'memo', 'DATA' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
logToFile( const char* buf )
|
||||||
|
{
|
||||||
|
UInt32 val = 0L;
|
||||||
|
Err err = FtrGet( APPID, LOG_FILE_FEATURE, (UInt32*)&val );
|
||||||
|
if ( errNone == err && val != 0 ) {
|
||||||
|
logToDB( buf, LOGFILE, 'XWLG', 'TEXT' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -676,6 +712,7 @@ palm_debugf( char* format, ...)
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
logToMemo( buf );
|
logToMemo( buf );
|
||||||
|
logToFile( buf );
|
||||||
} /* debugf */
|
} /* debugf */
|
||||||
|
|
||||||
/* if -0 isn't passed to compiler it wants to find this!!! */
|
/* if -0 isn't passed to compiler it wants to find this!!! */
|
||||||
|
@ -692,33 +729,7 @@ palm_logf( char* format, ... )
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
|
|
||||||
logToMemo( buf );
|
logToMemo( buf );
|
||||||
logToDB( buf, "XWLogfile", 'XWLG', 'TEXT' );
|
logToFile( buf );
|
||||||
} /* palm_logf */
|
} /* palm_logf */
|
||||||
|
|
||||||
#define ROWSIZE 8
|
|
||||||
|
|
||||||
void
|
|
||||||
palm_logmem( unsigned char* ptr, int nBytes )
|
|
||||||
{
|
|
||||||
XP_U16 nRows = (nBytes + ROWSIZE-1) / ROWSIZE;
|
|
||||||
char buf[(ROWSIZE*3)+5];
|
|
||||||
char* bp;
|
|
||||||
unsigned char* end = ptr + nBytes;
|
|
||||||
XP_U16 i, j;
|
|
||||||
|
|
||||||
for ( i = 0; i < nRows; ++i ) {
|
|
||||||
bp = buf;
|
|
||||||
bp += StrPrintF( (Char*)buf, "%3x:", i * ROWSIZE );
|
|
||||||
|
|
||||||
for ( j = 0; j < ROWSIZE && ptr < end; ++j ) {
|
|
||||||
char sbuf[6];
|
|
||||||
StrPrintF( sbuf, "%x ", (XP_U16)*ptr++ );
|
|
||||||
StrCat( buf, &sbuf[2] );
|
|
||||||
bp += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
logToMemo( buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
|
@ -77,6 +77,7 @@ void fitButtonToString( XP_U16 id );
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
void PalmClearLogs( void );
|
||||||
void logEvent( eventsEnum eType );
|
void logEvent( eventsEnum eType );
|
||||||
#else
|
#else
|
||||||
# define logEvent(e)
|
# define logEvent(e)
|
||||||
|
|
Loading…
Add table
Reference in a new issue