home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / 32PMCHES.ZIP / TEST.C < prev    next >
Text File  |  1990-12-17  |  4KB  |  132 lines

  1. //
  2. //  Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  3. //  Copyright (c) 1988, 1989, 1990  John Stanback
  4. //
  5. //  Project:    OS/2 PM Port of GNU CHESS 3.1 (PmChess)
  6. //
  7. //  Version:    1.02  1990-12-17
  8. //
  9. //   Module:    Promote User Query Dialog (Promote.c)
  10. //
  11. //   Porter:    Ported to Windows 3.0 by Darly Baker
  12. //
  13. //   Porter:    Ported to OS/2 1.2+ by Kent Cedola
  14. //
  15. //   System:    OS2 1.2 using Microsoft C 6.0
  16. //
  17. //  Remarks:    This code converted from Windows to PM using a straight port
  18. //              method with some editing improvements.
  19. //
  20. //  License:
  21. //
  22. //    CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  23. //    WARRANTY.  No author or distributor accepts responsibility to anyone for
  24. //    the consequences of using it or for whether it serves any particular
  25. //    purpose or works at all, unless he says so in writing.  Refer to the
  26. //    CHESS General Public License for full details.
  27. //
  28. //    Everyone is granted permission to copy, modify and redistribute CHESS,
  29. //    but only under the conditions described in the CHESS General Public
  30. //    License.  A copy of this license is supposed to have been given to you
  31. //    along with CHESS so you can know your rights and responsibilities.  It
  32. //    should be in a file named COPYING.  Among other things, the copyright
  33. //    notice and this notice must be preserved on all copies.
  34. //
  35.  
  36. #define INCL_DOS
  37. #define INCL_PM
  38. #include <os2.h>
  39. #include <time.h>
  40. #include "PmChess.h"
  41. #include "GnuChess.h"
  42. #include "Defs.h"
  43. #include "Resource.h"
  44.  
  45.  
  46. //
  47. //  Define dialog procedure's prototypes.
  48. //
  49. MRESULT EXPENTRY TestProc(HWND hWnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  50.  
  51.  
  52. //***************************************************************************
  53. //
  54. //  Routine: TestDialog(In)
  55. //
  56. //  Remarks: This routine displays a dialog that test the speed of the GNU
  57. //           logic.
  58. //
  59. //  Returns: None.
  60. //
  61. void TestDialog(HWND hWnd)
  62.   {
  63.   WinDlgBox(HWND_DESKTOP, hWnd, TestProc, 0, IDD_TEST, NULL);
  64.   }
  65.  
  66.  
  67. void
  68. TestSpeed(HWND hWnd, int cnt, void (*f) (short int side, short int ply))
  69. {
  70.   register short i;
  71.   long t1, t2, evrate;
  72.   char tmp[40];
  73.  
  74.  
  75.   t1 = time (0);
  76.   for (i = 0; i < 10000; i++)
  77.     {
  78.       f (opponent, 2);
  79.     }
  80.   t2 = time (0);
  81.   NodeCnt = 10000L * (TrPnt[3] - TrPnt[2]);
  82.   evrate = NodeCnt / (t2 - t1);
  83.  
  84.   sprintf ( tmp, "Nodes= %8ld, Nodes/Sec= %5ld", NodeCnt, evrate);
  85.   WinSetDlgItemText (hWnd, cnt, tmp);
  86. }
  87.  
  88.  
  89. //***************************************************************************
  90. //
  91. //  Routine: TestProc(In, In, In, In)
  92. //
  93. //  Remarks: This routine displays a dialog that queries the user of which
  94. //           type of piece to promote a pawn.
  95. //
  96. //  Returns: The piece selected.
  97. //
  98. MRESULT EXPENTRY TestProc(HWND hDlg, USHORT msg, MPARAM mp1, MPARAM mp2)
  99.   {
  100.   HPOINTER hCurrent, hWait;
  101.  
  102.  
  103.   switch (msg)
  104.     {
  105.     case WM_INITDLG:
  106.       WinPostMsg(hDlg, WM_USER+1, NULL, NULL);
  107.       return (FALSE);
  108.  
  109.     case WM_COMMAND:
  110.       switch (SHORT1FROMMP(mp1))
  111.         {
  112.         case IDC_OK:
  113.           WinDismissDlg(hDlg, TRUE);
  114.           break;
  115.         }
  116.       return (0);
  117.  
  118.     case WM_USER+1:
  119.       hCurrent = WinQueryPointer(HWND_DESKTOP);
  120.       hWait    = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
  121.       WinSetPointer(HWND_DESKTOP, hWait);
  122.  
  123.       TestSpeed(hDlg, IDC_TEST_MOVELIST,    MoveList);
  124.       TestSpeed(hDlg, IDC_TEST_CAPTURELIST, CaptureList);
  125.  
  126.       WinSetPointer(HWND_DESKTOP, hCurrent);
  127.       break;
  128.     }
  129.  
  130.   return (WinDefDlgProc(hDlg, msg, mp1, mp2));
  131.   }
  132.