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

version 1.3, 2004/06/14 13:35:40 version 1.6, 2005/03/24 04:40:33
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        <stdarg.h>  #include        <stdarg.h>
 #include        "strres.h"  #include        "strres.h"
   #if defined(UNICODE) && defined(OSLANG_UTF8)
   #include        "codecnv.h"
   #endif
 #include        "dosio.h"  #include        "dosio.h"
 #include        "ini.h"  #include        "ini.h"
   
Line 47  enum { Line 50  enum {
         IDM_TRACECL          IDM_TRACECL
 };  };
   
 static const TCHAR ProgTitle[] = STRLITERAL("console");  static const TCHAR ProgTitle[] = _T("console");
 static const TCHAR ClassName[] = STRLITERAL("TRACE-console");  static const TCHAR ClassName[] = _T("TRACE-console");
 static const TCHAR ClassEdit[] = STRLITERAL("EDIT");  static const TCHAR ClassEdit[] = _T("EDIT");
 static const TCHAR viewfont[] = STRLITERAL(VIEW_TEXT);  static const TCHAR viewfont[] = _T(VIEW_TEXT);
 static const TCHAR trace1[] = STRLITERAL("TRACE");  static const TCHAR trace1[] = _T("TRACE");
 static const TCHAR trace2[] = STRLITERAL("VERBOSE");  static const TCHAR trace2[] = _T("VERBOSE");
 static const TCHAR traceen[] = STRLITERAL("Enable");  static const TCHAR traceen[] = _T("Enable");
 static const TCHAR tracefh[] = STRLITERAL("File out");  static const TCHAR tracefh[] = _T("File out");
 static const TCHAR tracecl[] = STRLITERAL("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 65  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 88  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;
         int             overleng;          int             overleng;
         TCHAR   *p;          TCHAR   *p;
   
 #if defined(UNICODE)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         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)
           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 120  static void View_AddString(const char *l Line 125  static void View_AddString(const char *l
                 }                  }
         }          }
         p = szView + vlen;          p = szView + vlen;
 #if defined(UNICODE)  #if defined(UNICODE) && defined(OSLANG_SJIS)
         MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszString, -1, p, len);          MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpszString, -1, p, len + 1);
   #elif defined(UNICODE) && defined(OSLANG_UTF8)
           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 163  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 172  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 284  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 390  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 429  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 451  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.3  
changed lines
  Added in v.1.6


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