home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / checkers.frm / engine / debugio.cpp < prev    next >
Encoding:
Text File  |  1996-04-11  |  3.2 KB  |  74 lines

  1. /* --------------------------------------------------------------------------
  2. Print Board is a debugging routine and should not be used for any other purpose
  3. -------------------------------------------------------------------------- */
  4.  
  5. int p(BOARD b, int x)
  6. {
  7.     int c=' '; /* empty square */
  8.     if (b[x] & RED)   c = 'r';
  9.     if (b[x] & BLACK) c = 'b';
  10.     if (b[x] & KING)  c = toupper(c);
  11.     return c;
  12. }
  13.  
  14. void PrintBoard(BOARD b, int d)
  15. {
  16.     const unsigned char rs=254; /* red square */
  17.     static char buf[256];
  18.  
  19.     pdebug(stddbg," ");
  20.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",( rs),     (p(b, 1)), ( rs),     (p(b, 2)), ( rs),     (p(b, 3)), ( rs),     (p(b, 4)) );
  21.     pdebug(stddbg,buf);
  22.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",(p(b, 5)), ( rs),     (p(b, 6)), ( rs),     (p(b, 7)), ( rs),     (p(b, 8)), ( rs)     );
  23.     pdebug(stddbg,buf);
  24.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",( rs),     (p(b, 9)), ( rs),     (p(b,10)), ( rs),     (p(b,11)), ( rs),     (p(b,12)) );
  25.     pdebug(stddbg,buf);
  26.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",(p(b,13)), ( rs),     (p(b,14)), ( rs),     (p(b,15)), ( rs),     (p(b,16)), ( rs)     );
  27.     pdebug(stddbg,buf);
  28.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",( rs),     (p(b,17)), ( rs),     (p(b,18)), ( rs),     (p(b,19)), ( rs),     (p(b,20)) );
  29.     pdebug(stddbg,buf);
  30.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",(p(b,21)), ( rs),     (p(b,22)), ( rs),     (p(b,23)), ( rs),     (p(b,24)), ( rs)     );
  31.     pdebug(stddbg,buf);
  32.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",( rs),     (p(b,25)), ( rs),     (p(b,26)), ( rs),     (p(b,27)), ( rs),     (p(b,28)) );
  33.     pdebug(stddbg,buf);
  34.     wsprintf(buf,"  %c%c%c%c%c%c%c%c",(p(b,29)), ( rs),     (p(b,30)), ( rs),     (p(b,31)), ( rs),     (p(b,32)), ( rs)     );
  35.     pdebug(stddbg,buf);
  36.     pdebug(stddbg," ");
  37.  
  38. }
  39.  
  40. /* --------------------------------------------------------------------------
  41. TextizeBoard produces a text version of the board for people who did
  42. not install this form.
  43. -------------------------------------------------------------------------- */
  44. char* TextizeBoard(BOARD b)
  45. {
  46.     const unsigned char rs='='; /* red square */
  47.     static char buf[2048];
  48.  
  49.  
  50.     wsprintf(buf,
  51.         "IPM.Checkers\r\n\r\n"
  52.         "  %c%c%c%c%c%c%c%c\r\n"
  53.         "  %c%c%c%c%c%c%c%c\r\n"
  54.         "  %c%c%c%c%c%c%c%c\r\n"
  55.         "  %c%c%c%c%c%c%c%c\r\n"
  56.         "  %c%c%c%c%c%c%c%c\r\n"
  57.         "  %c%c%c%c%c%c%c%c\r\n"
  58.         "  %c%c%c%c%c%c%c%c\r\n"
  59.         "  %c%c%c%c%c%c%c%c\r\n",
  60.  
  61.  
  62.     ( rs),     (p(b, 1)), ( rs),     (p(b, 2)), ( rs),     (p(b, 3)), ( rs),     (p(b, 4)) ,
  63.     (p(b, 5)), ( rs),     (p(b, 6)), ( rs),     (p(b, 7)), ( rs),     (p(b, 8)), ( rs)     ,
  64.     ( rs),     (p(b, 9)), ( rs),     (p(b,10)), ( rs),     (p(b,11)), ( rs),     (p(b,12)) ,
  65.     (p(b,13)), ( rs),     (p(b,14)), ( rs),     (p(b,15)), ( rs),     (p(b,16)), ( rs)     ,
  66.     ( rs),     (p(b,17)), ( rs),     (p(b,18)), ( rs),     (p(b,19)), ( rs),     (p(b,20)) ,
  67.     (p(b,21)), ( rs),     (p(b,22)), ( rs),     (p(b,23)), ( rs),     (p(b,24)), ( rs)     ,
  68.     ( rs),     (p(b,25)), ( rs),     (p(b,26)), ( rs),     (p(b,27)), ( rs),     (p(b,28)) ,
  69.     (p(b,29)), ( rs),     (p(b,30)), ( rs),     (p(b,31)), ( rs),     (p(b,32)), ( rs)     );
  70.  
  71.     return buf;
  72.  
  73. }
  74.