home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sm099e.zip / example / example.h < prev    next >
C/C++ Source or Header  |  1997-01-26  |  3KB  |  125 lines

  1. /* --------------------------------------------------------------------------
  2. ** This dummy program is just developed as an example source code for the
  3. ** Source Mapper (SM). The program is divided into more functions than
  4. ** actually makes sense. That's just to have functions enough to show you
  5. ** what SM can do.
  6. **
  7. ** Compiler options:
  8. ** OS2 = Compile for OS/2.
  9. ** DOS = Compile for grand old DOS.
  10. ** GUI = Compile GUI version (supported for both DOS and OS2 version).
  11. ** ------------------------------------------------------------------------ */
  12.  
  13.  
  14.  
  15. #if defined (DOS) && defined (OS2)
  16. #  error "Only one of these macros must be defined!"
  17. #endif
  18.  
  19. #if !defined (DOS) && !defined (OS2)
  20. #  error "You must define one and only one of these macros!"
  21. #endif
  22.  
  23. #ifdef __BORLANDC__
  24. #  include <conio.h>
  25. #else
  26. #  error "This program is to be compiled by Borland C++"
  27. #endif
  28.  
  29. #ifdef OS2
  30. #  define INCL_DOSDATETIME
  31. #  define INCL_DOSPROCESS
  32. #  ifdef GUI
  33. #     define INCL_WIN
  34. #     define INCL_GPI
  35. #  endif
  36. #  include <os2.h>
  37. #endif
  38.  
  39. #ifdef DOS
  40. #  include <dos.h>
  41. #  ifdef GUI
  42. #     ifndef __LARGE__
  43. #        error "Graphics library needs large memory model!"
  44. #     endif
  45. #     include <graphics.h>
  46. #  endif
  47. #endif
  48.  
  49. #ifdef GUI
  50. #  define MAXHSPEED 8
  51. #  define MAXVSPEED 8
  52. #  define DELAY     20
  53. #  ifdef OS2
  54. #     define BLACK  CLR_BLACK
  55. #     define WHITE  CLR_WHITE
  56. #  else
  57. #     define BLACK  0x0
  58. #     define WHITE  0xF
  59. #  endif
  60. #else
  61. #  define MAXHSPEED 2
  62. #  define MAXVSPEED 1
  63. #  define DELAY     50
  64. #  define BLACK     0x0
  65. #  define WHITE     0xF
  66. #endif
  67.  
  68. #define MAXBALLS  50
  69. #define MAXCOLOR  16
  70.  
  71. #define NEWSPEED(max) (random (max) + 1)
  72. #define NEWCOLOR(c) { (c) = random (MAXCOLOR); (c) = ((c) == BLACK) ? WHITE : (c); }
  73.  
  74. #include <mem.h>
  75. #include <time.h>
  76. #include <stdlib.h>
  77.  
  78. typedef struct
  79. {
  80.    int iColor;            /* Color of the ball */
  81.    int iXPos;             /* Horizontal position of the ball */
  82.    int iYPos;             /* Vertical position of the ball */
  83.    int iHSpeed;           /* Horizontal speed of the ball */
  84.    int iVSpeed;           /* Vertical speed of the ball */
  85. }
  86.    BALL;
  87.  
  88. typedef struct
  89. {
  90.    int iNr;               /* Number of balls */
  91.    BALL Ball[MAXBALLS];   /* CB of every possible ball */
  92. }
  93.    BALLS;
  94.  
  95. extern void GetScrSize ( int *, int * );
  96. extern void RunBalls ( BALLS * );
  97. extern void MoveHorizontally ( BALL * );
  98. extern void MoveVertically ( BALL * );
  99. extern void RunBall ( BALL * );
  100. extern void PaintBall ( BALL *, int );
  101. extern void Pause ( int );
  102. extern void ClrScr ( void );
  103. extern void RestoreScreen ( void );
  104. extern void Initialize ( int, char *[], BALLS * );
  105. extern void Run ( BALLS * );
  106. extern void Terminate ( void );
  107. extern void InitScreen ( void );
  108.  
  109. extern int iScreenW;              /* Width of screen */
  110. extern int iScreenH;              /* Height of screen */
  111. extern BALLS Balls;
  112.  
  113. #if defined (OS2) && defined (GUI)
  114. MRESULT EXPENTRY ClientWndProc ( HWND, ULONG, MPARAM, MPARAM );
  115. extern HAB hAB;
  116. extern HMQ hMQ;
  117. extern HPS hPS;
  118. extern HDC hDC;
  119. extern QMSG QMsg;
  120. extern HWND hWndFrame;
  121. extern HWND hWndClient;
  122. extern ULONG ulFrameFlags;
  123. #define TID_MOVE (TID_USERMAX - 1)
  124. #endif
  125.