Diff for /np2/wince/w32/trace.cpp between versions 1.5 and 1.6

version 1.5, 2005/02/12 12:14:00 version 1.6, 2005/03/24 04:40:33
Line 59  static const TCHAR trace2[] = _T("VERBOS Line 59  static const TCHAR trace2[] = _T("VERBOS
 static const TCHAR traceen[] = _T("Enable");  static const TCHAR traceen[] = _T("Enable");
 static const TCHAR tracefh[] = _T("File out");  static const TCHAR tracefh[] = _T("File out");
 static const TCHAR tracecl[] = _T("Clear");  static const TCHAR tracecl[] = _T("Clear");
 static const char crlf[] = "\r\n";  static const OEMCHAR crlf[] = OEMTEXT("\r\n");
   
 static  TRACEWIN        tracewin;  static  TRACEWIN        tracewin;
 static  HWND            hView = NULL;  static  HWND            hView = NULL;
Line 68  static HBRUSH  hBrush = NULL; Line 68  static HBRUSH  hBrush = NULL;
 static  TCHAR           szView[VIEW_BUFFERSIZE];  static  TCHAR           szView[VIEW_BUFFERSIZE];
 static  TRACECFG        tracecfg;  static  TRACECFG        tracecfg;
   
 static const char       np2trace[] = "np2trace.ini";  static const OEMCHAR np2trace[] = OEMTEXT("np2trace.ini");
 static const char       inititle[] = "TRACE";  static const OEMCHAR inititle[] = OEMTEXT("TRACE");
 static const INITBL     initbl[4] = {  static const PFTBL initbl[4] = {
                         {"posx",        INITYPE_SINT32, &tracecfg.posx,         0},                          PFVAL("posx",   PFTYPE_SINT32,  &tracecfg.posx),
                         {"posy",        INITYPE_SINT32, &tracecfg.posy,         0},                          PFVAL("posy",   PFTYPE_SINT32,  &tracecfg.posy),
                         {"width",       INITYPE_SINT32, &tracecfg.width,        0},                          PFVAL("width",  PFTYPE_SINT32,  &tracecfg.width),
                         {"height",      INITYPE_SINT32, &tracecfg.height,       0}};                          PFVAL("height", PFTYPE_SINT32,  &tracecfg.height)};
   
 static void View_ScrollToBottom(HWND hWnd) {  static void View_ScrollToBottom(HWND hWnd) {
   
Line 91  static void View_ClrString(void) { Line 91  static void View_ClrString(void) {
         SetWindowText(hView, szView);          SetWindowText(hView, szView);
 }  }
   
 static void View_AddString(const char *lpszString) {  static void View_AddString(const OEMCHAR *lpszString) {
   
         int             len;          int             len;
         int             vlen;          int             vlen;
Line 102  static void View_AddString(const char *l Line 102  static void View_AddString(const char *l
         len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszString, -1,          len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszString, -1,
                                                                                                                                 NULL, 0) - 1;                                                                                                                                  NULL, 0) - 1;
 #elif defined(UNICODE) && defined(OSLANG_UTF8)  #elif defined(UNICODE) && defined(OSLANG_UTF8)
         len = codecnv_utf8toucs2(NULL, 0, lpszString, (UINT8)-1) - 1;          len = codecnv_utf8toucs2(NULL, 0, lpszString, (UINT)-1) - 1;
 #else  #else
         len = strlen(lpszString);          len = lstrlen(lpszString);
 #endif  #endif
         if ((len <= 0) || ((len + 3) > VIEW_BUFFERSIZE)) {          if ((len <= 0) || ((len + 3) > VIEW_BUFFERSIZE)) {
                 return;                  return;
Line 128  static void View_AddString(const char *l Line 128  static void View_AddString(const char *l
 #if defined(UNICODE) && defined(OSLANG_SJIS)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszString, -1, p, len + 1);          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszString, -1, p, len + 1);
 #elif defined(UNICODE) && defined(OSLANG_UTF8)  #elif defined(UNICODE) && defined(OSLANG_UTF8)
         codecnv_utf8toucs2(p, len + 1, lpszString, (UINT8)-1);          codecnv_utf8toucs2(p, len + 1, lpszString, (UINT)-1);
 #else  #else
         CopyMemory(p, lpszString, len);          CopyMemory(p, lpszString, len * sizeof(TCHAR));
 #endif  #endif
         p += len;          p += len;
         p[0] = '\r';          p[0] = '\r';
Line 170  static void trfh_close(void) { Line 170  static void trfh_close(void) {
         }          }
 }  }
   
 static void trfh_open(const char *fname) {  static void trfh_open(const OEMCHAR *fname) {
   
         trfh_close();          trfh_close();
         tracewin.fh = file_create(fname);          tracewin.fh = file_create(fname);
Line 179  static void trfh_open(const char *fname) Line 179  static void trfh_open(const char *fname)
 #endif  #endif
 }  }
   
 static void trfh_add(const char *buf) {  static void trfh_add(const OEMCHAR *buf) {
   
         UINT    size;          UINT    size;
   
         size = strlen(buf);          size = OEMSTRLEN(buf);
           size *= sizeof(OEMCHAR);
 #if defined(FILEBUFSIZE)  #if defined(FILEBUFSIZE)
         while(size) {          while(size) {
                 UINT pos = filebufpos & (FILEBUFSIZE - 1);                  UINT pos = filebufpos & (FILEBUFSIZE - 1);
Line 291  static LRESULT CALLBACK traceproc(HWND h Line 292  static LRESULT CALLBACK traceproc(HWND h
                                                 trfh_close();                                                  trfh_close();
                                         }                                          }
                                         else {                                          else {
                                                 trfh_open("traceout.txt");                                                  trfh_open(OEMTEXT("traceout.txt"));
                                         }                                          }
                                         hmenu = GetSystemMenu(hWnd, FALSE);                                          hmenu = GetSystemMenu(hWnd, FALSE);
                                         CheckMenuItem(hmenu, IDM_TRACEFH,                                          CheckMenuItem(hmenu, IDM_TRACEFH,
Line 397  void trace_init(void) { Line 398  void trace_init(void) {
 #else  #else
         tracewin.en = 0;          tracewin.en = 0;
         tracewin.fh = FILEH_INVALID;          tracewin.fh = FILEH_INVALID;
         trfh_open("traces.txt");          trfh_open(OEMTEXT("traces.txt"));
 #endif  #endif
   
         tracecfg.posx = CW_USEDEFAULT;          tracecfg.posx = CW_USEDEFAULT;
Line 436  void trace_fmt(const char *fmt, ...) { Line 437  void trace_fmt(const char *fmt, ...) {
   
         BOOL    en;          BOOL    en;
         va_list ap;          va_list ap;
         char    buf[0x1000];          OEMCHAR buf[0x1000];
   
         en = (tracewin.en & 1) &&          en = (tracewin.en & 1) &&
                 ((tracewin.en & 4) || (tracewin.fh != FILEH_INVALID));                  ((tracewin.en & 4) || (tracewin.fh != FILEH_INVALID));
         if (en) {          if (en) {
                 va_start(ap, fmt);                  va_start(ap, fmt);
   #if defined(_UNICODE) && defined(OSLANG_UCS2)
                   TCHAR cnvfmt[0x800];
                   MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, fmt, -1,
                                                                                                   cnvfmt, NELEMENTS(cnvfmt));
                   vswprintf(buf, cnvfmt, ap);
   #else
                 vsprintf(buf, fmt, ap);                  vsprintf(buf, fmt, ap);
   #endif
                 va_end(ap);                  va_end(ap);
                 if ((tracewin.en & 4) && (hView)) {                  if ((tracewin.en & 4) && (hView)) {
                         View_AddString(buf);                          View_AddString(buf);
Line 458  void trace_fmt2(const char *fmt, ...) { Line 466  void trace_fmt2(const char *fmt, ...) {
   
         BOOL    en;          BOOL    en;
         va_list ap;          va_list ap;
         char    buf[0x1000];          OEMCHAR buf[0x1000];
   
         en = (tracewin.en & 2) &&          en = (tracewin.en & 2) &&
                 ((tracewin.en & 4) || (tracewin.fh != FILEH_INVALID));                  ((tracewin.en & 4) || (tracewin.fh != FILEH_INVALID));
         if (en) {          if (en) {
                 va_start(ap, fmt);                  va_start(ap, fmt);
   #if defined(_UNICODE) && defined(OSLANG_UCS2)
                   TCHAR cnvfmt[0x800];
                   MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, fmt, -1,
                                                                                                   cnvfmt, NELEMENTS(cnvfmt));
                   vswprintf(buf, cnvfmt, ap);
   #else
                 vsprintf(buf, fmt, ap);                  vsprintf(buf, fmt, ap);
   #endif
                 va_end(ap);                  va_end(ap);
                 if ((tracewin.en & 4) && (hView)) {                  if ((tracewin.en & 4) && (hView)) {
                         View_AddString(buf);                          View_AddString(buf);

Removed from v.1.5  
changed lines
  Added in v.1.6


RetroPC.NET-CVS <cvs@retropc.net>