home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FNTPAK32.ZIP / C.EXE / DEMO_GMS.C < prev    next >
C/C++ Source or Header  |  1995-08-16  |  5KB  |  157 lines

  1. /**********************************************************************
  2.  
  3.     Demo_GMX.C                Copyright 1994, Rob W. Smetana
  4.  
  5.     Turn Screen Swapping ON if appropriate.
  6.  
  7.     Demonstrate how to:
  8.  
  9.      1.  Select GRAPHICS-mode mouse cursor shapes from Font Pak's library.
  10.  
  11.      2.  Determine how many mouse shapes there are.
  12.  
  13.     Requires:
  14.      a.  Graphics.Lib
  15.  
  16.      1.  Mouse.Obj     (which contains mouse functions)
  17.      2.  LdGFXCsr.OBJ  (graphics-mode mouse shapes)
  18.  
  19.  
  20.     Notes:
  21.           It is CRITICAL that you be in GRAPHICS-mode when you call the
  22.           graphics-mode procedures.  A crash awaits you if you're not.
  23.  
  24. *************************************************************************\
  25.  
  26. /* #include <dos.h> */
  27.  
  28. #include <graph.h>
  29. #include <font_pak.h>
  30.  
  31.  
  32. /* We'll demonstrate these.  Prototypes are in Font_Pak.H.
  33.  
  34.    void extern pascal far RSLOADGFXCURSOR (int, int, int);
  35.    int  extern pascal far NUMGFXSHAPES ();
  36. */
  37.  
  38.  
  39. /* GetMonitor function is in video.obj */
  40.  
  41. extern int GetMonitor ();
  42.  
  43.  
  44. int FontSize ();                /* local get-monitor function to detect EGA/VGA
  45.                                    and return size of default font (14/16)
  46.                                    -or- print error message if appropriate
  47.                                 */
  48.  
  49. int main (void)
  50. {
  51.     int FSize, WhichShape, HotSpotX, HotSpotY, Button, Row, Col, GFXorText;
  52.     int NumShapes;
  53.  
  54.     NumShapes = NUMGFXSHAPES (); /* how many graphics-mode cursors are there?*/
  55.  
  56.     _setvideomode(_TEXTC80);
  57.  
  58.     FSize = FontSize ();        /* FontSize returns 14, 16 or 0 (no EGA/VGA) */
  59.  
  60.     if (FSize == 0)             /* Bail out if no EGA/VGA */
  61.        return (-99);
  62.  
  63.     FSize = RSTHEREISAMOUSE;
  64.     if (FSize == 0)             /* Bail out if there's no mouse */
  65.        {
  66.          printf ("Sorry. This demo requires a mouse/mouse driver.  I found none.");
  67.          getch();
  68.          return (-99);
  69.        }
  70.  
  71.     _setvideomode(_ERESCOLOR);          /* BE SURE you're in graphics mode
  72.                                            BEFORE calling gfx-mode functions!
  73.                                         */
  74.  
  75.     printf("   Demonstrate how to select one of %d GRAPHICS-mode mouse cursor shapes.\n\n",NumShapes);
  76.     printf("Here's the normal (default) mouse shape.  Click a mouse button to try a new one.");
  77.  
  78.     GFXorText = -1;                     /* -1 = return graphics mode row/col */
  79.  
  80.     RSSHOWCURSOR ();
  81.  
  82.     for (WhichShape = 0; WhichShape < NumShapes+1; WhichShape++)
  83.        {
  84.          /* scrub any remaining button clicks */
  85.          while (Button > 0)
  86.                 Button = RSBUTTONPRESSED (&Row, &Col, GFXorText);
  87.  
  88.          /* now wait for a button click */
  89.          Button = 0;
  90.          while (Button == 0)
  91.                 Button = RSBUTTONPRESSED (&Row, &Col, GFXorText);
  92.  
  93.          /* load the next cursor shape */
  94.          RSHIDECURSOR ();
  95.          RSLOADGFXCURSOR (WhichShape + 1, HotSpotX, HotSpotY);
  96.          RSSHOWCURSOR ();
  97.  
  98.          /* gotoxy (30,4); write('This is cursor # ', WhichShape); */
  99.      }
  100.  
  101.  
  102.     /* restore default by loading shape #16 */
  103.     RSLOADGFXCURSOR (16, HotSpotX, HotSpotY);
  104.  
  105.     FSize = RSTHEREISAMOUSE;
  106.  
  107.  
  108.     _setvideomode(_DEFAULTMODE);
  109.  
  110.     printf ("That's all . . .");
  111.     return (0);
  112.  
  113. }   /* end main */
  114.  
  115. /*******************************************************************
  116.  Function:  FontSize
  117.  
  118.  Purpose:   Check for EGA/VGA and return 14 (EGA 8x14), 16 (VGA 8x16)
  119.             or 0 if we're not using an EGA/VGA
  120.  
  121.             Print error message and end if no EGA/VGA
  122.  
  123. GetMonitor returns an integer (0 - 8) indicating the type of monitor
  124.            in use.  If two monitors are being used, GetMonitor returns
  125.            the type of the primary monitor.
  126.  
  127.            0 = None (no monitor)    3 = EGA (or MultiSync)
  128.            4 = Color (CGA)          5 = Monochrome
  129.            7 = VGA Monochrome       8 = VGA Color (or MultiSync)
  130.  
  131. *******************************************************************/
  132.  
  133. int FontSize ()
  134.  
  135. {
  136.     int MonType;
  137.     MonType = GETMONITOR();
  138.  
  139.     switch (MonType)  {
  140.        case 0, 4, 5:        /* no monitor, Mono or CGA */
  141.          printf ("Sorry.  An EGA or VGA monitor is required to run this demo. \n\n");
  142.          return (0);
  143.          break;
  144.        case 3:              /* EGA.  Set fontsize to 8x14 */
  145.          return (14);
  146.          break;
  147.        case 7, 8:           /* VGA.  Set fontsize to 8x16 */
  148.          return (16);
  149.          break;
  150.        default:
  151.          printf ("Unknown monitor type.  Sorry.  An EGA or VGA monitor is required to run this. \n\n");
  152.          return (0);
  153.          break;
  154.     }
  155. }
  156.  
  157.