home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / smapper.zip / smexample.txt < prev    next >
Text File  |  2000-03-09  |  32KB  |  702 lines

  1.  
  2. /* =============================================================================
  3. A = Sourcefile
  4. B = Total number of lines: 363
  5. C = Empty lines..........: 43 (11%)
  6. D = Commentlines.........: 35 (9%)
  7. E = Lines with code......: 285 (78%)
  8. F = Functions............: 15
  9. G = Blocks of comment....: 28
  10.  
  11.        A:          B:      C:      D:      E:      F:      G:      Glob.lin.:
  12. ------------------------------------------------------------------------------------------
  13. F-1    example.c   26      7       12      7       1       2       G-1
  14. F-2    destroy.c   30      3       3       24      2       3       G-27
  15. F-3    init.c      79      8       2       69      2       6       G-57
  16. F-4    run.c       121     13      14      94      6       11      G-136
  17. F-5    utils.c     48      3       3       42      3       3       G-257
  18. F-6    vars.c      17      2       0       15      0       2       G-305
  19. F-7    wndproc.c   42      7       1       34      1       1       G-322
  20. ------------------------------------------------------------------------------------------
  21.        Totaly      363     43      35      285     15      28      
  22. ============================================================================= */
  23.  
  24.  
  25.  
  26. /* =============================================================================
  27. Index of functions:
  28.  
  29. F-1    ClientWndProc ()    G-325    (L-4:    wndproc.c)
  30. F-2    ClrScr ()        G-280    (L-24:    utils.c)
  31. F-3    GetScrSize ()        G-259    (L-3:    utils.c)
  32. F-4    InitScreen ()        G-95    (L-39:    init.c)
  33. F-5    Initialize ()        G-59    (L-3:    init.c)
  34. F-6    MoveHorizontally ()    G-189    (L-54:    run.c)
  35. F-7    MoveVertically ()    G-209    (L-74:    run.c)
  36. F-8    PaintBall ()        G-228    (L-93:    run.c)
  37. F-9    Pause ()        G-296    (L-40:    utils.c)
  38. F-10    RestoreScreen ()    G-29    (L-3:    destroy.c)
  39. F-11    Run ()            G-139    (L-4:    run.c)
  40. F-12    RunBall ()        G-178    (L-43:    run.c)
  41. F-13    RunBalls ()        G-157    (L-22:    run.c)
  42. F-14    Terminate ()        G-51    (L-25:    destroy.c)
  43. F-15    main ()            G-19    (L-19:    example.c) */
  44.  
  45.  
  46.  
  47. /* =============================================================================
  48. List of calling sequences:
  49.  
  50.  
  51. L-1    ClientWndProc ()
  52. L-2    |    ClrScr ()
  53. L-3    |    |    WinFillRect () External
  54. L-4    |    |    WinQueryWindowRect () External
  55. L-5    |    |    cleardevice () External
  56. L-6    |    |    clrscr () External
  57. L-7    |    GetScrSize ()
  58. L-8    |    |    WinQueryWindowRect () External
  59. L-9    |    |    getmaxx () External
  60. L-10    |    |    getmaxy () External
  61. L-11    |    |    gettextinfo () External
  62. L-12    |    MRFROMLONG () External
  63. L-13    |    PaintBall ()
  64. L-14    |    |    GpiFullArc () External
  65. L-15    |    |    GpiMove () External
  66. L-16    |    |    GpiSetColor () External
  67. L-17    |    |    MAKEFIXED () External
  68. L-18    |    |    circle () External
  69. L-19    |    |    gotoxy () External
  70. L-20    |    |    putch () External
  71. L-21    |    |    setcolor () External
  72. L-22    |    |    textcolor () External
  73. L-23    |    RunBalls ()
  74. L-24    |    |    RunBall ()
  75. L-25    |    |    |    MoveHorizontally ()
  76. L-26    |    |    |    |    NEWCOLOR () External
  77. L-27    |    |    |    |    NEWSPEED () External
  78. L-28    |    |    |    MoveVertically ()
  79. L-29    |    |    |    |    NEWSPEED () External
  80. L-30    |    |    |    PaintBall () ... [L-13]
  81. L-31    |    |    WinQueryFocus () External
  82. L-32    |    WinBeginPaint () External
  83. L-33    |    WinDefWindowProc () External
  84. L-34    |    WinEndPaint () External
  85.  
  86.  
  87. --------------------------------------------------------------------------------
  88. L-35    main ()
  89. L-36    |    Initialize ()
  90. L-37    |    |    InitScreen ()
  91. L-38    |    |    |    ClrScr () ... [L-2]
  92. L-39    |    |    |    DosSetPriority () External
  93. L-40    |    |    |    GetScrSize () ... [L-7]
  94. L-41    |    |    |    GpiCreatePS () External
  95. L-42    |    |    |    GpiSetArcParams () External
  96. L-43    |    |    |    GpiSetDrawingMode () External
  97. L-44    |    |    |    WinCreateMsgQueue () External
  98. L-45    |    |    |    WinCreateStdWindow () External
  99. L-46    |    |    |    WinInitialize () External
  100. L-47    |    |    |    WinOpenWindowDC () External
  101. L-48    |    |    |    WinRegisterClass () External
  102. L-49    |    |    |    WinStartTimer () External
  103. L-50    |    |    |    _setcursortype () External
  104. L-51    |    |    |    cprintf () External
  105. L-52    |    |    |    exit () External
  106. L-53    |    |    |    grapherrormsg () External
  107. L-54    |    |    |    graphresult () External
  108. L-55    |    |    |    initgraph () External
  109. L-56    |    |    NEWCOLOR () External
  110. L-57    |    |    NEWSPEED () External
  111. L-58    |    |    atoi () External
  112. L-59    |    |    memset () External
  113. L-60    |    |    random () External
  114. L-61    |    |    randomize () External
  115. L-62    |    Run ()
  116. L-63    |    |    Pause ()
  117. L-64    |    |    |    DosSleep () External
  118. L-65    |    |    |    delay () External
  119. L-66    |    |    RunBalls () ... [L-23]
  120. L-67    |    |    WinDispatchMsg () External
  121. L-68    |    |    WinGetMsg () External
  122. L-69    |    |    getch () External
  123. L-70    |    |    kbhit () External
  124. L-71    |    Terminate ()
  125. L-72    |    |    RestoreScreen ()
  126. L-73    |    |    |    ClrScr () ... [L-2]
  127. L-74    |    |    |    WinDestroyMsgQueue () External
  128. L-75    |    |    |    WinDestroyWindow () External
  129. L-76    |    |    |    WinReleasePS () External
  130. L-77    |    |    |    WinStopTimer () External
  131. L-78    |    |    |    WinTerminate () External
  132. L-79    |    |    |    _setcursortype () External
  133. L-80    |    |    |    closegraph () External
  134. L-81    |    |    |    gotoxy () External
  135. L-82    |    |    |    normvideo () External
  136.  
  137.  
  138.  
  139. --------------------------------------------------------------------------------
  140. Index to list of calling sequences:
  141.  
  142.  
  143. F-1    ClientWndProc ()    L-1
  144. F-2    ClrScr ()        L-2
  145. F-3    GetScrSize ()        L-7
  146. F-4    InitScreen ()        L-37
  147. F-5    Initialize ()        L-36
  148. F-6    MoveHorizontally ()    L-25
  149. F-7    MoveVertically ()    L-28
  150. F-8    PaintBall ()        L-13
  151. F-9    Pause ()        L-63
  152. F-10    RestoreScreen ()    L-72
  153. F-11    Run ()            L-62
  154. F-12    RunBall ()        L-24
  155. F-13    RunBalls ()        L-23
  156. F-14    Terminate ()        L-71
  157. F-15    main ()            L-35 */
  158.  
  159.  
  160.  
  161. /* =============================================================================
  162. Sourcefile...........: example.c
  163. Total number of lines: 26
  164. Empty lines..........: 7 (26%)
  165. Commentlines.........: 12 (46%)
  166. Lines with code......: 7 (26%)
  167. Functions............: 1
  168. Blocks of comment....: 2 */
  169.  
  170.  
  171.  
  172. /* G-1      L-1      Comment  | *//* --------------------------------------------------------------------------
  173.    G-2      L-2      Comment  |   ** This dummy program is just developed as an example source code for the
  174.    G-3      L-3      Comment  |   ** Source Mapper (SM). The program is divided into more functions than
  175.    G-4      L-4      Comment  |   ** actually makes sense. That's just to have functions enough to show you
  176.    G-5      L-5      Comment  |   ** what SM can do.
  177.    G-6      L-6      Comment  |   **
  178.    G-7      L-7      Comment  |   ** Compiler options:
  179.    G-8      L-8      Comment  |   ** OS2 = Compile for OS/2.
  180.    G-9      L-9      Comment  |   ** DOS = Compile for grand old DOS.
  181.    G-10     L-10     Comment  |   ** GUI = Compile GUI version (supported for both DOS and OS2 version).
  182.    G-11     L-11     Comment  |   ** ------------------------------------------------------------------------ */
  183. /* G-12     L-12              | */
  184. /* G-13     L-13              | */
  185. /* G-14     L-14              | */
  186.                                   #include "example.h"
  187. /* G-16     L-16              | */
  188. /* G-17     L-17              | */
  189. /* G-18     L-18              | */
  190. /* G-19     L-19              | */void main ( int iArgC, char *pcArgP[] )
  191. /* G-20     L-20     Comment  | *//* Program entry point.  */
  192. /*
  193.                                   List of callers of 'main ()':
  194.  
  195.                                   No caller
  196. */
  197. /* G-21     L-21              | */{
  198. /* G-22     L-22     B1       | */   Initialize (iArgC, pcArgP, &Balls);
  199. /* G-23     L-23     B1       | */   Run (&Balls);
  200. /* G-24     L-24     B1       | */   Terminate ();
  201. /* G-25     L-25              | */}
  202. /* G-26     L-26              | */
  203.  
  204.  
  205.  
  206. /* =============================================================================
  207. Sourcefile...........: destroy.c
  208. Total number of lines: 30
  209. Empty lines..........: 3 (10%)
  210. Commentlines.........: 3 (10%)
  211. Lines with code......: 24 (80%)
  212. Functions............: 2
  213. Blocks of comment....: 3 */
  214.  
  215.  
  216.  
  217.                                   #include "example.h"
  218. /* G-28     L-2               | */
  219. /* G-29     L-3               | */void RestoreScreen ( void )
  220. /* G-30     L-4      Comment  | *//* Restore screen (color, mode, etc.) back to what it was when the program
  221.    G-31     L-5      Comment  |      was started. */
  222. /*
  223.                                   List of callers of 'RestoreScreen ()':
  224.  
  225.                                   Terminate ()    G-51
  226. */
  227. /* G-32     L-6               | */{
  228.                                      #ifdef GUI
  229.                                      #ifdef OS2
  230. /* G-35     L-9      B1       | */   WinStopTimer (hAB, hWndClient, TID_MOVE);
  231. /* G-36     L-10     B1       | */   WinReleasePS (hPS);
  232. /* G-37     L-11     B1       | */   WinDestroyWindow (hWndFrame);
  233. /* G-38     L-12     B1       | */   WinDestroyMsgQueue (hMQ);
  234. /* G-39     L-13     B1       | */   WinTerminate (hAB);
  235.                                      #else
  236. /* G-41     L-15     B1       | */   closegraph (); /* Return the system to text mode */
  237.                                      #endif
  238.                                      #else
  239. /* G-44     L-18     B1       | */   ClrScr ();
  240. /* G-45     L-19     B1       | */   normvideo ();
  241. /* G-46     L-20     B1       | */   gotoxy (0, iScreenH - 1);
  242. /* G-47     L-21     B1       | */   _setcursortype (_NORMALCURSOR);
  243.                                      #endif
  244. /* G-49     L-23              | */}
  245. /* G-50     L-24              | */
  246. /* G-51     L-25              | */void Terminate ( void )
  247. /* G-52     L-26     Comment  | *//* Get ready to exit this silly program */
  248. /*
  249.                                   List of callers of 'Terminate ()':
  250.  
  251.                                   main ()    G-19
  252. */
  253. /* G-53     L-27              | */{
  254. /* G-54     L-28     B1       | */   RestoreScreen ();
  255. /* G-55     L-29              | */}
  256. /* G-56     L-30              | */
  257.  
  258.  
  259.  
  260. /* =============================================================================
  261. Sourcefile...........: init.c
  262. Total number of lines: 79
  263. Empty lines..........: 8 (10%)
  264. Commentlines.........: 2 (2%)
  265. Lines with code......: 69 (87%)
  266. Functions............: 2
  267. Blocks of comment....: 6 */
  268.  
  269.  
  270.  
  271.                                   #include "example.h"
  272. /* G-58     L-2               | */
  273. /* G-59     L-3               | */void Initialize ( int iArgC, char *pcArgP[], BALLS *pBalls )
  274. /* G-60     L-4      Comment  | *//* Perform everything that's neccessary to run the balls. */
  275. /*
  276.                                   List of callers of 'Initialize ()':
  277.  
  278.                                   main ()    G-19
  279. */
  280. /* G-61     L-5               | */{
  281. /* G-62     L-6      B1       | */   int iC1;
  282. /* G-63     L-7      B1       | */   BALL *pBall;
  283. /* G-64     L-8               | */
  284. /* G-65     L-9      B1       | */   memset (pBalls, 0, sizeof (BALLS));
  285. /* G-66     L-10              | */
  286. /* G-67     L-11     B1       | */   InitScreen ();
  287. /* G-68     L-12              | */
  288. /* G-69     L-13     B1       | */   randomize ();
  289. /* G-70     L-14              | */
  290. /* G-71     L-15     B1       | */   for (iC1 = 0;
  291. /* G-72     L-16     B1       | */        iC1 < MAXBALLS;
  292. /* G-73     L-17     B1       | */        iC1++)
  293. /* G-74     L-18     B1       | */   {
  294. /* G-75     L-19     B-2      | */      pBall = &pBalls->Ball[iC1];
  295. /* G-76     L-20     B-2      | */      NEWCOLOR (pBall->iColor);
  296. /* G-77     L-21     B-2      | */      pBall->iXPos = random (iScreenW) + 1;
  297. /* G-78     L-22     B-2      | */      pBall->iYPos = random (iScreenH) + 1;
  298. /* G-79     L-23     B-2      | */      pBall->iHSpeed = (iC1%2) ? NEWSPEED (MAXHSPEED) : -NEWSPEED (MAXHSPEED);
  299. /* G-80     L-24     B-2      | */      pBall->iVSpeed = (iC1%2) ? NEWSPEED (MAXVSPEED) : -NEWSPEED (MAXVSPEED);
  300. /* G-81     L-25     B1       | */   }
  301. /* G-82     L-26              | */
  302. /* G-83     L-27     B1       | */   if (iArgC > 1)
  303. /* G-84     L-28     B1       | */   {
  304. /* G-85     L-29     B-2      | */      pBalls->iNr = atoi (pcArgP[1]);
  305. /* G-86     L-30     B-2      | */      pBalls->iNr = pBalls->iNr > 0 ? pBalls->iNr : 10;
  306. /* G-87     L-31     B-2      | */      pBalls->iNr = pBalls->iNr <= MAXBALLS ? pBalls->iNr : MAXBALLS;
  307. /* G-88     L-32     B1       | */   }
  308. /* G-89     L-33     B1       | */   else
  309. /* G-90     L-34     B1       | */   {
  310. /* G-91     L-35     B-2      | */      pBalls->iNr = 10;
  311. /* G-92     L-36     B1       | */   }
  312. /* G-93     L-37              | */}
  313. /* G-94     L-38              | */
  314. /* G-95     L-39              | */void InitScreen ( void )
  315. /* G-96     L-40     Comment  | *//* Prepare screen to show the running balls. */
  316. /*
  317.                                   List of callers of 'InitScreen ()':
  318.  
  319.                                   Initialize ()    G-59
  320. */
  321. /* G-97     L-41              | */{
  322.                                      #ifdef GUI
  323.                                      #ifdef OS2
  324. /* G-100    L-44     B1       | */   SIZEL Size = { 0, 0 };
  325. /* G-101    L-45     B1       | */   ARCPARAMS ap = { 4, 4, 0, 0 };
  326. /* G-102    L-46     B1       | */   hAB = WinInitialize (0);
  327. /* G-103    L-47     B1       | */   hMQ = WinCreateMsgQueue (hAB, 0);
  328. /* G-104    L-48     B1       | */   WinRegisterClass (hAB, "SillyExample", ClientWndProc, CS_SIZEREDRAW, 0);
  329. /* G-105    L-49     B1       | */   hWndFrame = WinCreateStdWindow (HWND_DESKTOP, WS_VISIBLE | WS_ANIMATE,
  330. /* G-106    L-50     B1       | */                                   &ulFrameFlags,
  331. /* G-107    L-51     B1       | */                                   "SillyExample", "Bounching balls",
  332. /* G-108    L-52     B1       | */                                   0, 0, 100, &hWndClient);
  333. /* G-109    L-53     B1       | */   hDC = WinOpenWindowDC (hWndClient);
  334. /* G-110    L-54     B1       | */   hPS = GpiCreatePS (hAB, hDC, &Size, PU_PELS | GPIF_DEFAULT |
  335. /* G-111    L-55     B1       | */                                       GPIT_MICRO | GPIA_ASSOC);
  336. /* G-112    L-56     B1       | */   GpiSetDrawingMode (hPS, DM_DRAW);
  337. /* G-113    L-57     B1       | */   WinStartTimer (hAB, hWndClient, TID_MOVE, DELAY);
  338. /* G-114    L-58     B1       | */   GpiSetArcParams (hPS, &ap);
  339. /* G-115    L-59     B1       | */   DosSetPriority (0, 1, 31, 0); /* Change to a low priority (IDLE class) */
  340.                                      #else
  341. /* G-117    L-61     B1       | */   int iErrorCode;
  342. /* G-118    L-62     B1       | */   int iGraphDriver;
  343. /* G-119    L-63     B1       | */   int iGraphMode;
  344. /* G-120    L-64              | */
  345. /* G-121    L-65     B1       | */   iGraphDriver = DETECT;        /* Request auto-detection */
  346. /* G-122    L-66     B1       | */   initgraph (&iGraphDriver, &iGraphMode, "");
  347. /* G-123    L-67     B1       | */   iErrorCode = graphresult ();  /* Read result of initialization */
  348. /* G-124    L-68     B1       | */   if (iErrorCode != grOk)       /* Error occured during init */
  349. /* G-125    L-69     B1       | */   {
  350. /* G-126    L-70     B-2      | */      cprintf ("Graphics System Error: %s\n\r", grapherrormsg (iErrorCode));
  351. /* G-127    L-71     B-2      | */      exit (1);
  352. /* G-128    L-72     B1       | */   }
  353.                                      #endif
  354.                                      #else
  355. /* G-131    L-75     B1       | */   _setcursortype (_NOCURSOR);
  356.                                      #endif
  357. /* G-133    L-77     B1       | */   ClrScr ();
  358. /* G-134    L-78     B1       | */   GetScrSize (&iScreenW, &iScreenH);
  359. /* G-135    L-79              | */}
  360.  
  361.  
  362.  
  363. /* =============================================================================
  364. Sourcefile...........: run.c
  365. Total number of lines: 121
  366. Empty lines..........: 13 (10%)
  367. Commentlines.........: 14 (11%)
  368. Lines with code......: 94 (77%)
  369. Functions............: 6
  370. Blocks of comment....: 11 */
  371.  
  372.  
  373.  
  374.                                   #include "example.h"
  375. /* G-137    L-2               | */
  376.                                   #pragma argsused
  377. /* G-139    L-4               | */void Run ( BALLS *pBalls )
  378. /* G-140    L-5      Comment  | *//* Main loop of the program. */
  379. /*
  380.                                   List of callers of 'Run ()':
  381.  
  382.                                   main ()    G-19
  383. */
  384. /* G-141    L-6               | */{
  385.                                      #if defined (OS2) && defined (GUI)
  386. /* G-143    L-8      B1       | */   while (WinGetMsg (hAB, &QMsg, 0, 0, 0))
  387. /* G-144    L-9      B1       | */   {
  388. /* G-145    L-10     B-2      | */      WinDispatchMsg (hAB, &QMsg);
  389. /* G-146    L-11     B1       | */   }
  390.                                      #else
  391. /* G-148    L-13     B1       | */   while (!kbhit ())
  392. /* G-149    L-14     B1       | */   {
  393. /* G-150    L-15     B-2      | */      RunBalls (pBalls);
  394. /* G-151    L-16     B-2      | */      Pause (DELAY);
  395. /* G-152    L-17     B1       | */   }
  396. /* G-153    L-18     B1       | */   getch ();   /* Remove that termination key from keyboard buffer */
  397.                                      #endif
  398. /* G-155    L-20              | */}
  399. /* G-156    L-21              | */
  400. /* G-157    L-22              | */void RunBalls ( BALLS *pBalls )
  401. /* G-158    L-23     Comment  | *//* Let every running ball take a new step. Heading to their current direction,
  402.    G-159    L-24     Comment  |      and moving in their current speed. Change direction of each ball so that
  403.    G-160    L-25     Comment  |      no balls run outside visible screen area. */
  404. /*
  405.                                   List of callers of 'RunBalls ()':
  406.  
  407.                                   Run ()    G-139
  408.                                   ClientWndProc ()    G-325
  409. */
  410. /* G-161    L-26              | */{
  411. /* G-162    L-27     B1       | */   int iC1;
  412. /* G-163    L-28              | */
  413.                                      #if defined (OS2) && defined (GUI)
  414. /* G-165    L-30     B1       | */   if (WinQueryFocus (HWND_DESKTOP) != hWndClient)
  415. /* G-166    L-31     B1       | */   {
  416. /* G-167    L-32     Comment  | */      /* Don't hogg the single input queue of OS/2 when user work in some
  417.    G-168    L-33     Comment  |            other window than this stupid one. */
  418. /* G-169    L-34     B-2      | */      return;     
  419. /* G-170    L-35     B1       | */   }
  420.                                      #endif
  421. /* G-172    L-37              | */
  422. /* G-173    L-38     B1       | */   for (iC1 = 0;
  423. /* G-174    L-39     B1       | */        iC1 < pBalls->iNr;
  424. /* G-175    L-40     B1       | */        RunBall (&pBalls->Ball[iC1++]));
  425. /* G-176    L-41              | */}
  426. /* G-177    L-42              | */
  427. /* G-178    L-43              | */void RunBall ( BALL *pBall )
  428. /* G-179    L-44     Comment  | *//* Kernel function of RunBalls(). */
  429. /*
  430.                                   List of callers of 'RunBall ()':
  431.  
  432.                                   RunBalls ()    G-157
  433. */
  434. /* G-180    L-45              | */{
  435. /* G-181    L-46     B1       | */   PaintBall (pBall, BLACK);         /* Hide the ball from old position */
  436. /* G-182    L-47              | */
  437. /* G-183    L-48     B1       | */   MoveHorizontally (pBall);
  438. /* G-184    L-49     B1       | */   MoveVertically (pBall);
  439. /* G-185    L-50              | */
  440. /* G-186    L-51     B1       | */   PaintBall (pBall, pBall->iColor); /* Show the ball at new position */
  441. /* G-187    L-52              | */}
  442. /* G-188    L-53              | */
  443. /* G-189    L-54              | */void MoveHorizontally ( BALL *pBall )
  444. /* G-190    L-55     Comment  | *//* Move specified ball left/right.
  445.    G-191    L-56     Comment  |      Change speed and direction when the  ball reach any edge of screen. */
  446. /*
  447.                                   List of callers of 'MoveHorizontally ()':
  448.  
  449.                                   RunBall ()    G-178
  450. */
  451. /* G-192    L-57              | */{
  452. /* G-193    L-58     B1       | */   pBall->iXPos += pBall->iHSpeed;
  453. /* G-194    L-59              | */
  454. /* G-195    L-60     B1       | */   if (pBall->iXPos > iScreenW)
  455. /* G-196    L-61     B1       | */   {
  456. /* G-197    L-62     B-2      | */      pBall->iHSpeed = -NEWSPEED (MAXHSPEED);
  457. /* G-198    L-63     B-2      | */      pBall->iXPos = iScreenW;
  458. /* G-199    L-64     B-2      | */      NEWCOLOR (pBall->iColor);
  459. /* G-200    L-65     B1       | */   }
  460. /* G-201    L-66     B1       | */   else
  461. /* G-202    L-67     B1       | */   if (pBall->iXPos <= 0)
  462. /* G-203    L-68     B1       | */   {
  463. /* G-204    L-69     B-2      | */      pBall->iXPos = 1;
  464. /* G-205    L-70     B-2      | */      pBall->iHSpeed = NEWSPEED (MAXHSPEED);
  465. /* G-206    L-71     B1       | */   }
  466. /* G-207    L-72              | */}
  467. /* G-208    L-73              | */
  468. /* G-209    L-74              | */void MoveVertically ( BALL *pBall )
  469. /* G-210    L-75     Comment  | *//* Move specified ball up/down.
  470.    G-211    L-76     Comment  |      Change speed and direction when the  ball reach any edge of screen. */
  471. /*
  472.                                   List of callers of 'MoveVertically ()':
  473.  
  474.                                   RunBall ()    G-178
  475. */
  476. /* G-212    L-77              | */{
  477. /* G-213    L-78     B1       | */   pBall->iYPos += pBall->iVSpeed;
  478. /* G-214    L-79              | */
  479. /* G-215    L-80     B1       | */   if (pBall->iYPos > iScreenH)
  480. /* G-216    L-81     B1       | */   {
  481. /* G-217    L-82     B-2      | */      pBall->iYPos = iScreenH;
  482. /* G-218    L-83     B-2      | */      pBall->iVSpeed = -NEWSPEED (MAXVSPEED);
  483. /* G-219    L-84     B1       | */   }
  484. /* G-220    L-85     B1       | */   else
  485. /* G-221    L-86     B1       | */   if (pBall->iYPos <= 0)
  486. /* G-222    L-87     B1       | */   {
  487. /* G-223    L-88     B-2      | */      pBall->iYPos = 1;
  488. /* G-224    L-89     B-2      | */      pBall->iVSpeed = NEWSPEED (MAXVSPEED);
  489. /* G-225    L-90     B1       | */   }
  490. /* G-226    L-91              | */}
  491. /* G-227    L-92              | */
  492. /* G-228    L-93              | */void PaintBall ( BALL *pBall, int iColor )
  493. /* G-229    L-94     Comment  | *//* Paint specified ball at its current position, using specified color */
  494. /*
  495.                                   List of callers of 'PaintBall ()':
  496.  
  497.                                   RunBall ()    G-178
  498.                                   ClientWndProc ()    G-325
  499. */
  500. /* G-230    L-95              | */{
  501.                                      #ifdef GUI
  502.                                      #ifdef OS2
  503. /* G-233    L-98     B1       | */   POINTL pt;
  504. /* G-234    L-99     B1       | */   pt.x = pBall->iXPos;
  505. /* G-235    L-100    B1       | */   pt.y = pBall->iYPos;
  506. /* G-236    L-101    B1       | */   GpiMove (hPS, &pt);
  507. /* G-237    L-102    B1       | */   GpiSetColor (hPS, iColor);
  508. /* G-238    L-103    B1       | */   GpiFullArc (hPS, DRO_OUTLINE, MAKEFIXED (1, 0));
  509.                                      #else
  510. /* G-240    L-105    B1       | */   setcolor (iColor);
  511. /* G-241    L-106    B1       | */   circle (pBall->iXPos, pBall->iYPos, 5);
  512.                                      #endif
  513.                                      #else
  514. /* G-244    L-109    Comment  | */   /* Prevent text screen from being vertically scrolled if the ball is
  515.    G-245    L-110    Comment  |         positioned at bottom right corner of screen (text modes only) */
  516. /* G-246    L-111    B1       | */   if ((pBall->iXPos == iScreenW) &&
  517. /* G-247    L-112    B1       | */       (pBall->iYPos == iScreenH))
  518. /* G-248    L-113    B1       | */   {
  519. /* G-249    L-114    B-2      | */      return;
  520. /* G-250    L-115    B1       | */   }
  521. /* G-251    L-116             | */
  522. /* G-252    L-117    B1       | */   textcolor (iColor);
  523. /* G-253    L-118    B1       | */   gotoxy (pBall->iXPos, pBall->iYPos);
  524. /* G-254    L-119    B1       | */   putch ('*');
  525.                                      #endif
  526. /* G-256    L-121             | */}
  527.  
  528.  
  529.  
  530. /* =============================================================================
  531. Sourcefile...........: utils.c
  532. Total number of lines: 48
  533. Empty lines..........: 3 (6%)
  534. Commentlines.........: 3 (6%)
  535. Lines with code......: 42 (87%)
  536. Functions............: 3
  537. Blocks of comment....: 3 */
  538.  
  539.  
  540.  
  541.                                   #include "example.h"
  542. /* G-258    L-2               | */
  543. /* G-259    L-3               | */void GetScrSize ( int *piScrW, int *piScrH )
  544. /* G-260    L-4      Comment  | *//* Fetch out current width and height of screen */
  545. /*
  546.                                   List of callers of 'GetScrSize ()':
  547.  
  548.                                   InitScreen ()    G-95
  549.                                   ClientWndProc ()    G-325
  550. */
  551. /* G-261    L-5               | */{
  552.                                      #ifdef GUI
  553.                                      #ifdef OS2
  554. /* G-264    L-8      B1       | */   RECTL Rect;
  555. /* G-265    L-9      B1       | */   WinQueryWindowRect (hWndClient, &Rect);
  556. /* G-266    L-10     B1       | */   *piScrW = Rect.xRight;
  557. /* G-267    L-11     B1       | */   *piScrH = Rect.yTop;
  558.                                      #else
  559. /* G-269    L-13     B1       | */   *piScrW = getmaxx ();
  560. /* G-270    L-14     B1       | */   *piScrH = getmaxy ();
  561.                                      #endif
  562.                                      #else
  563. /* G-273    L-17     B1       | */   struct text_info ti;
  564. /* G-274    L-18     B1       | */   gettextinfo (&ti);
  565. /* G-275    L-19     B1       | */   *piScrW = ti.screenwidth;
  566. /* G-276    L-20     B1       | */   *piScrH = ti.screenheight;
  567.                                      #endif
  568. /* G-278    L-22              | */}
  569. /* G-279    L-23              | */
  570. /* G-280    L-24              | */void ClrScr ( void )
  571. /* G-281    L-25     Comment  | *//* Clear the screen */
  572. /*
  573.                                   List of callers of 'ClrScr ()':
  574.  
  575.                                   RestoreScreen ()    G-29
  576.                                   InitScreen ()    G-95
  577.                                   ClientWndProc ()    G-325
  578. */
  579. /* G-282    L-26              | */{
  580.                                      #ifdef GUI
  581.                                      #ifdef OS2
  582. /* G-285    L-29     B1       | */   RECTL Rect;
  583. /* G-286    L-30     B1       | */   WinQueryWindowRect (hWndClient, &Rect);
  584. /* G-287    L-31     B1       | */   WinFillRect (hPS, &Rect, CLR_BLACK);
  585.                                      #else
  586. /* G-289    L-33     B1       | */   cleardevice ();
  587.                                      #endif
  588.                                      #else
  589. /* G-292    L-36     B1       | */   clrscr ();
  590.                                      #endif
  591. /* G-294    L-38              | */}
  592. /* G-295    L-39              | */
  593. /* G-296    L-40              | */void Pause ( int iMilliSeconds )
  594. /* G-297    L-41     Comment  | *//* Sleep specified number of milliseconds */
  595. /*
  596.                                   List of callers of 'Pause ()':
  597.  
  598.                                   Run ()    G-139
  599. */
  600. /* G-298    L-42              | */{
  601.                                      #ifdef OS2
  602. /* G-300    L-44     B1       | */   DosSleep (iMilliSeconds);
  603.                                      #else
  604. /* G-302    L-46     B1       | */   delay (iMilliSeconds);
  605.                                      #endif
  606. /* G-304    L-48              | */}
  607.  
  608.  
  609.  
  610. /* =============================================================================
  611. Sourcefile...........: vars.c
  612. Total number of lines: 17
  613. Empty lines..........: 2 (11%)
  614. Commentlines.........: 0 (0%)
  615. Lines with code......: 15 (88%)
  616. Functions............: 0
  617. Blocks of comment....: 2 */
  618.  
  619.  
  620.  
  621.                                   #include "example.h"
  622. /* G-306    L-2               | */
  623. /* G-307    L-3               | */int iScreenW;              /* Width of screen */
  624. /* G-308    L-4               | */int iScreenH;              /* Height of screen */
  625. /* G-309    L-5               | */BALLS Balls;
  626. /* G-310    L-6               | */
  627.                                   #if defined (OS2) && defined (GUI)
  628. /* G-312    L-8               | */HAB hAB;
  629. /* G-313    L-9               | */HMQ hMQ;
  630. /* G-314    L-10              | */HPS hPS;
  631. /* G-315    L-11              | */HDC hDC;
  632. /* G-316    L-12              | */QMSG QMsg;
  633. /* G-317    L-13              | */HWND hWndFrame;
  634. /* G-318    L-14              | */HWND hWndClient;
  635. /* G-319    L-15              | */ULONG ulFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
  636. /* G-320    L-16              | */                     FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST | FCF_ICON;
  637.                                   #endif
  638.  
  639.  
  640.  
  641. /* =============================================================================
  642. Sourcefile...........: wndproc.c
  643. Total number of lines: 42
  644. Empty lines..........: 7 (16%)
  645. Commentlines.........: 1 (2%)
  646. Lines with code......: 34 (80%)
  647. Functions............: 1
  648. Blocks of comment....: 1 */
  649.  
  650.  
  651.  
  652.                                   #include "example.h"
  653. /* G-323    L-2               | */
  654.                                   #if defined (OS2) && defined (GUI)
  655. /* G-325    L-4               | */MRESULT EXPENTRY ClientWndProc ( HWND hWnd, ULONG ulMsg,
  656. /* G-326    L-5               | */                                 MPARAM mp1, MPARAM mp2 )
  657. /* G-327    L-6      Comment  | *//* Handle OS2 PM messages. */
  658. /*
  659.                                   List of callers of 'ClientWndProc ()':
  660.  
  661.                                   No caller
  662. */
  663. /* G-328    L-7               | */{
  664. /* G-329    L-8      B1       | */   int iC1;
  665. /* G-330    L-9      B1       | */   HPS hPS;
  666. /* G-331    L-10              | */
  667. /* G-332    L-11     B1       | */   switch (ulMsg)
  668. /* G-333    L-12     B1       | */   {
  669. /* G-334    L-13     B-2      | */      case WM_TIMER:
  670. /* G-335    L-14     B-2      | */           RunBalls (&Balls);
  671. /* G-336    L-15     B-2      | */           break;
  672. /* G-337    L-16              | */
  673. /* G-338    L-17     B-2      | */      case WM_SIZE:
  674. /* G-339    L-18     B-2      | */           GetScrSize (&iScreenW, &iScreenH);
  675. /* G-340    L-19     B-2      | */           break;
  676. /* G-341    L-20              | */
  677. /* G-342    L-21     B-2      | */      case WM_PAINT:
  678. /* G-343    L-22     B-2      | */           hPS = WinBeginPaint (hWnd, 0, 0);
  679. /* G-344    L-23     B-2      | */           for (iC1 = 0;
  680. /* G-345    L-24     B-2      | */                iC1 < Balls.iNr;
  681. /* G-346    L-25     B-2      | */                iC1++)
  682. /* G-347    L-26     B-2      | */           {
  683. /* G-348    L-27     B--3     | */              PaintBall (&Balls.Ball[iC1], Balls.Ball[iC1].iColor);
  684. /* G-349    L-28     B-2      | */           }
  685. /* G-350    L-29     B-2      | */           WinEndPaint (hPS);
  686. /* G-351    L-30     B-2      | */           break;
  687. /* G-352    L-31              | */
  688. /* G-353    L-32     B-2      | */      case WM_ERASEBACKGROUND:
  689. /* G-354    L-33     B-2      | */           ClrScr ();
  690. /* G-355    L-34     B-2      | */           break;
  691. /* G-356    L-35              | */
  692. /* G-357    L-36     B-2      | */      default:
  693. /* G-358    L-37     B-2      | */           return WinDefWindowProc (hWnd, ulMsg, mp1, mp2);
  694. /* G-359    L-38     B1       | */   }
  695. /* G-360    L-39              | */
  696. /* G-361    L-40     B1       | */   return MRFROMLONG (FALSE);
  697. /* G-362    L-41              | */}
  698.                                   #endif
  699.  
  700.  
  701.  
  702.