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

  1. /**********************************************************************
  2.     DemoFnt1.C                      Copyright 1994, Rob W. Smetana
  3.  
  4.     Turn Screen Swapping ON if appropriate.
  5.  
  6.  
  7.     Demonstrate how to CALL fonts.  Use Font2Asm to create ASM/OBJ fonts.
  8.  
  9.     Also demonstrates how to:
  10.  
  11.       1. Determine whether an EGA/VGA monitor is being used.
  12.  
  13.       2. Determine the default fontsize (8x14 (EGA) or 8x16 (VGA)).
  14.  
  15.  
  16.     Run DemoFnt2.C to see how to load Font Pak fonts from disk.
  17.  
  18.  
  19.     Requires:
  20.  
  21.     Graphics.Lib
  22.  
  23.        FONTS.obj          <-- font-related ASM functions
  24.  
  25.     HOLLOW9C.obj          <-- these are CALLable fonts were
  26.      SCRIPT1.obj              created by Font2Asm and A86.Com
  27.      FRAZZLE.obj
  28.  
  29. **********************************************************************/
  30.  
  31. #include <font_pak.h>       /* for declarations -- PLEASE READ */
  32.  
  33. #include <stdio.h>
  34. #include <graph.h>
  35.  
  36. void printdemo ();
  37.  
  38. /* ASM/OBJ fonts we'll CALL to load */
  39.  
  40. void extern pascal far HOLLOW9  (int Block);
  41. void extern pascal far SCRIPT1  (int Block);
  42.  
  43. /* alternate line-draw characters; note how we load these on TOP of text */
  44.  
  45. void extern pascal far FRAZZLE (int Block);
  46.  
  47. /*  "Block" would be 0-3 (EGA or VGA) or 0-7 (VGA only)
  48.  
  49. Syntax: RSLOADDefault(FontSize, Block);  FontSize = 8, 14 or 16
  50. Syntax: RSWHICHFONTS (Block1, Block2);
  51.  
  52. Syntax: HOLLOW9  (Block);
  53. Syntax: SCRIPT1  (Block);
  54.  
  55. Syntax: FRAZZLE  (Block);
  56.  
  57. */
  58.  
  59. int GetFontSize ();          /* local get-monitor function to detect EGA/VGA
  60.                                 and return size of default font (14/16)
  61.                     -or- print error message if appropriate */
  62.  
  63. int main (void)
  64.  
  65. {
  66.  
  67.     int Block0, Block1, Block2, Fontsize;
  68.     long BKColor;
  69.     short LOforeColor, HIforeColor;
  70.  
  71.     BKColor = 1, LOforeColor = 7, HIforeColor = 14;
  72.  
  73.     _setvideomode(_TEXTC80);
  74.  
  75.     _setbkcolor(BKColor);
  76.  
  77.     /*
  78.       Load fonts into Blocks 1 & 2 ; leave the default (0) alone.
  79.  
  80.       Note that "loading" fonts does NOT "turn 'em on" (unless you
  81.       overwrite Block 0).  We'll "activate" Blocks 1 - 3 shortly.
  82.     */
  83.  
  84.     Block0 = 0;
  85.     Block1 = 1;             /* use Blocks 0 - 3 to ensure those with EGA */
  86.     Block2 = 2;             /* monitors can see everything (ie., avoid 4-7) */
  87.  
  88.     /*
  89.       PRE-Load Blocks 1 & 2.  We're loading PARTIAL fonts, so this
  90.       step ensures we'll have something to use in each block.
  91.     */
  92.  
  93.     Fontsize = GetFontSize ();
  94.     if (Fontsize == 0)
  95.         return (-99);
  96.  
  97.     RSLOADDEFAULT (Fontsize, Block1);
  98.     RSLOADDEFAULT (Fontsize, Block2);
  99.  
  100.     /*
  101.       load custom fonts  --  and 1 set of line characters.
  102.     */
  103.  
  104.     HOLLOW9 (Block1);
  105.     FRAZZLE (Block1);
  106.  
  107.     SCRIPT1(Block2);
  108.  
  109.  
  110.     /* display some text, then "activate" different sets of Blocks */
  111.  
  112.     _settextcolor(LOforeColor);             /* 1st in LOW intensity */
  113.     printdemo();
  114.  
  115.     _settextcolor(HIforeColor);             /* then in HIGH intensity */
  116.     printdemo();
  117.     getch();
  118.  
  119.     RSWHICHFONTS (Block1, Block2);
  120.     getch();
  121.  
  122.     RSWHICHFONTS (Block2, Block0);
  123.     getch();
  124.  
  125.     RSWHICHFONTS (Block2, Block1);
  126.     getch();
  127.  
  128.     RSWHICHFONTS (Block0, Block2);
  129.     getch();
  130.  
  131.  
  132.     /*
  133.       Reload the default font into Blocks 1 and 2 (not really necessary)
  134.     */
  135.  
  136.     RSLOADDEFAULT (Fontsize, Block1);
  137.     RSLOADDEFAULT (Fontsize, Block2);
  138.  
  139.     /*
  140.  
  141.       To see what happens if you restore the wrong size font, un-comment this.
  142.       Try Fontsize = 8 and note the gaps in vertical lines.
  143.  
  144.       Fontsize = 8;
  145.       RSLOADDEFAULT (Fontsize, Block1);
  146.       RSLOADDEFAULT (Fontsize, Block2);
  147.       getch();
  148.  
  149.      */
  150.  
  151.     /* now return to Block 0 (the default) exclusively */
  152.     RSWHICHFONTS (Block0, Block0);
  153.  
  154.     return(0);
  155.  
  156. }   /* end main */
  157.  
  158.  
  159. void printdemo ()
  160. {
  161.     _outtext("\n ┌─░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓ FONT DEMO ▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░─┐ \n");
  162.     _outtext("░│ Note the different fonts here -- AND the different line-draw characters! │ \n");
  163.     _outtext("░│                                           ╒═══════╕   ╓──╖        ╓───╖  │ \n");
  164.     _outtext("░│ ┌──────┼─────┐ ╔══════╦═══════╗     ╒═════╧═════╕ │   ║ ─╫───╫────╜   ║  │ \n");
  165.     _outtext("░│ │      ├──── │ ║      ╚════╗  ╬═╗   │     ╒═════╪═╛   ║  ║   ║        ║  │ \n");
  166.     _outtext("░│ └──────┼─────┘ ╚═══════════╬══╝ ║   ╘═════╪═════╛     ║  ╙───╫────────╜  │ \n");
  167.     _outtext("░│        │                   ╚════╝         ╘═════════  ╙──────╜           │ \n");
  168.     _outtext("░└──────────────────────────────────────────────────────────────────────────┘ \n");
  169.     _outtext("░░░░░░░░░░░░░░░░░░░░░░░░░press <SPACE> to change fonts░░░░░░░░░░░░░░░░░░░░░░  \n\n");
  170. }
  171.  
  172. /*******************************************************************
  173. Function:  GetFontSize
  174.  
  175. Purpose:   Check for EGA/VGA and return 14 (EGA 8x14), 16 (VGA 8x16).
  176.            Print an error message and return 0 if we're no EGA/VGA found.
  177.  
  178. GetMonitor returns an integer (0 - 8) indicating the type of monitor
  179.            in use.  If two monitors are being used, GetMonitor returns
  180.            the type of the primary monitor.
  181.  
  182. *******************************************************************/
  183.  
  184. int GetFontSize ()
  185.  
  186. {
  187.     int MonType;
  188.     MonType = GETMONITOR();
  189.  
  190.     switch (MonType)  {
  191.        case 0, 1, 2:        /* no monitor, Mono or CGA */
  192.          printf ("Sorry.  An EGA or VGA monitor is required to run this demo. \n\n");
  193.          return (0);
  194.          break;
  195.        case 4:              /* EGA.  Set fontsize to 8x14 */
  196.          return (14);
  197.          break;
  198.        case 7, 8:           /* VGA.  Set fontsize to 8x16 */
  199.          return (16);
  200.          break;
  201.        default:
  202.          printf ("Unknown monitor type.  Sorry.  An EGA or VGA monitor is required to run this. \n\n");
  203.          return (0);
  204.          break;
  205.     }
  206.  
  207. }
  208.  
  209.