home *** CD-ROM | disk | FTP | other *** search
/ Monster Disc 2: The Best of 1992 / MONSTER2.ISO / prog / djgpp / cbgrx102.a01 / CONTRIB / LIBGRX / TEST / TEST.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-12  |  3.0 KB  |  113 lines

  1. /** 
  2.  ** TEST.H 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24.  
  25. #ifndef _TEST_H_
  26. #define _TEST_H_
  27.  
  28. #include <grx.h>
  29. #include <mousex.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32.  
  33. #ifdef __TURBOC__
  34. # undef  random
  35. # define random() rand()
  36. # include <conio.h>
  37. #endif
  38.  
  39. #define TESTFUNC(name) \
  40.     void name(void); \
  41.     void (*testfunc)(void) = name; \
  42.     void name(void)
  43.  
  44. extern void (*testfunc)(void);
  45.  
  46. char exit_message[400] = { "" };
  47.  
  48. int Argc;
  49. char **Argv;
  50.  
  51. void main(int argc,char **argv)
  52. {
  53.     int x = 0;
  54.     int y = 0;
  55.     int c = 0;
  56.  
  57.     Argc = argc - 1;
  58.     Argv = argv + 1;
  59.     if((Argc >= 2) &&
  60.        (sscanf(Argv[0],"%d",&x) == 1) && (x >= 320) &&
  61.        (sscanf(Argv[1],"%d",&y) == 1) && (y >= 200)) {
  62.         Argc -= 2;
  63.         Argv += 2;
  64.         if((Argc > 0) && (sscanf(Argv[0],"%d",&c) == 1) && (c >= 2)) {
  65.         Argc--;
  66.         Argv++;
  67.         }
  68.     }
  69.     if(c >= 2)
  70.         GrSetMode(GR_width_height_color_graphics,x,y,c);
  71.     else if((x >= 320) && (y >= 200))
  72.         GrSetMode(GR_width_height_graphics,x,y);
  73.     else GrSetMode(GR_default_graphics);
  74.     (*testfunc)();
  75.     GrSetMode(GR_default_text);
  76.     if(exit_message[0] != '\0') {
  77.         puts(exit_message);
  78.         puts("type any key to continue...");
  79.         getkey();
  80.     }
  81.     exit(0);
  82. }
  83.  
  84. #define XP(x)    (int)((((long)(x) * (long)xsize) / 100L) + xpos)
  85. #define YP(y)    (int)((((long)(y) * (long)ysize) / 100L) + ypos)
  86.  
  87. void drawing(int xpos,int ypos,int xsize,int ysize,int fg,int bg)
  88. {
  89.     int ii;
  90.  
  91.     if(bg != GrNOCOLOR) {
  92.         GrFilledBox(xpos,ypos,xpos+xsize-1,ypos+ysize-1,bg);
  93.     }
  94.     GrLine(XP(10),YP(10),XP(40),YP(40),fg);
  95.     GrLine(XP(40),YP(10),XP(10),YP(40),fg);
  96.     GrLine(XP(35),YP(10),XP(65),YP(40),fg);
  97.     GrLine(XP(35),YP(40),XP(65),YP(10),fg);
  98.     GrLine(XP(70),YP(10),XP(90),YP(40),fg);
  99.     GrLine(XP(70),YP(40),XP(90),YP(10),fg);
  100.     for(ii = 0; ii < 5; ii++) {
  101.         GrBox(XP(70+2*ii),YP(10+3*ii),XP(90-2*ii),YP(40-3*ii),fg);
  102.     }
  103.     GrFilledBox(XP(10),YP(50),XP(60),YP(90),fg);
  104.     GrBox(XP(70),YP(50),XP(90),YP(90),fg);
  105.     for(ii = 0; ii < 100; ii++) {
  106.         GrPlot(XP((random() % 20) + 70),YP((random() % 40) + 50),fg);
  107.     }
  108. }
  109.  
  110.  
  111. #endif /* _TEST_H_ */
  112.  
  113.