home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / bcpp / file10 / video.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  9.1 KB  |  331 lines

  1. /**********************************************************************\
  2. *                                                                      *
  3. *  video.c -- things on the video menu                                 *
  4. *                                                                      *
  5. \**********************************************************************/
  6.  
  7. #include "defs.h"
  8.  
  9. /**********************************************************************\
  10. *                                                                      *
  11. *  about_modes -- information about video modes                        *
  12. *                                                                      *
  13. \**********************************************************************/
  14.  
  15. int about_modes()
  16. {
  17.    static char *string[] = {
  18.    "Video Modes",
  19.    "Fastgraph supports 22 video modes.  One of the",
  20.    "major advantages of programming with Fastgraph",
  21.    "is the ability to write code one time to work in",
  22.    "many video modes.  This demo, for example, will",
  23.    "work in your choice of four video modes."
  24.    };
  25.  
  26.    /* clear the screen and display the info window */
  27.  
  28.    fg_mousevis(OFF);
  29.    fg_restore(0,xlimit,menu_bottom,ylimit);
  30.    info_window(120,520,60,string,6);
  31.  
  32.    /* wait for keystroke or mouse button */
  33.  
  34.    fg_mousevis(ON);
  35.    wait_for_keystroke();
  36.  
  37.    /* clear the screen and return to the menu */
  38.  
  39.    fg_mousevis(OFF);
  40.    fg_restore(0,xlimit,menu_bottom,ylimit);
  41.  
  42.    fg_mousevis(ON);
  43.    redraw = TRUE;
  44.  
  45.    return(OK);
  46. }
  47.  
  48. /**********************************************************************\
  49. *                                                                      *
  50. *  auto_detect -- what modes are available on your machine?            *
  51. *                                                                      *
  52. \**********************************************************************/
  53.  
  54. int auto_detect()
  55. {
  56.    int x1,x2,y1,y2;
  57.    int row,col;
  58.  
  59.    static char *string[] = {
  60.    "Automatic Mode Detection",
  61.    "Your system will support the following graphics modes:",
  62.    "","","","","","","","","","","","","","","","",""
  63.    };
  64.  
  65.    static char mode_string[] = {"This program is running in mode    "};
  66.  
  67.    static char *mode_description[] = {
  68.    "  Mode  4  320x200 CGA 4-color",
  69.    "  Mode  5  320x200 CGA 4-color \"colorless\"",
  70.    "  Mode  6  640x200 CGA 2-color",
  71.    "  Mode  9  320x200 Tandy/PCjr 16-color",
  72.    "  Mode 11  720x348 Hercules monochrome",
  73.    "  Mode 12  320x200 Hercules monochrome",
  74.    "  Mode 13  320x200 EGA 16-color",
  75.    "  Mode 14  640x200 EGA 16-color",
  76.    "  Mode 15  640x350 EGA monochrome",
  77.    "  Mode 16  640x350 EGA 16-color",
  78.    "  Mode 17  640x480 VGA/MCGA 2-color",
  79.    "  Mode 18  640x480 VGA 16-color",
  80.    "  Mode 19  320x200 VGA/MCGA 256-color",
  81.    "  Mode 20  320x200 VGA 256-color",
  82.    "  Mode 21  320x400 VGA 256-color",
  83.    "  Mode 22  320x240 VGA 256-color (mode X)",
  84.    "  Mode 23  320x480 VGA 256-color"
  85.    };
  86.  
  87.    static int mode_number[] = {
  88.    4,5,6,9,11,12,13,14,15,16,17,18,19,20,21,22,23
  89.    };
  90.  
  91.    register int i, j;
  92.  
  93.    /* test the modes and build an array of description strings */
  94.  
  95.    j = 2;
  96.    for (i = 0; i <= sizeof(mode_number)/sizeof(int); i++)
  97.    {
  98.       if (fg_testmode(mode_number[i],1))
  99.          string[j++] = mode_description[i];
  100.    }
  101.  
  102.    /* insert the current mode in the last string */
  103.  
  104.    sprintf(&mode_string[32],"%d.",fg_getmode());
  105.    string[j++] = mode_string;
  106.  
  107.    /* clear the screen and display the info window */
  108.  
  109.    fg_mousevis(OFF);
  110.    fg_restore(0,xlimit,menu_bottom,ylimit);
  111.  
  112.    fg_setpage(hidden);
  113.  
  114.    if (mode11)
  115.    {
  116.       x1 = 80;
  117.       x2 = 592;
  118.    }
  119.    else
  120.    {
  121.       x1 = 100;
  122.       x2 = 562;
  123.    }
  124.    y1 = fg_yconvert(4);
  125.    y2 = fg_yconvert(5+j)+scale(10);
  126.  
  127.    draw_window(x1,x2,y1,y2,string[0]);
  128.    fg_setcolor(0);
  129.  
  130.    row = 6;
  131.    if (mode11)
  132.       col = 11;
  133.    else
  134.       col = 15;
  135.    for (i = 1; i < j; i++)
  136.    {
  137.       put_tstring(string[i],row,col);
  138.       row++;
  139.    }
  140.  
  141.    fg_setcolor(0);
  142.    fg_setpage(visual);
  143.    fg_restore(0,xlimit,menu_bottom,ylimit);
  144.  
  145.    fg_setpage(hidden);
  146.  
  147.    /* redraw the screen under the window */
  148.  
  149.    x2 += 3;
  150.  
  151.    if (mode06 || mode11)
  152.       fg_drect(x1,x2,y1,y2+2,matrix1);
  153.    else
  154.    {
  155.       fg_setcolor(15);
  156.       fg_rect(x1,x2,y1,y2+2);
  157.       fg_setcolor(14);
  158.       fg_drect(x1,x2,y1,y2+2,matrix2);
  159.    }
  160.  
  161.    /* wait for keystroke or mouse button */
  162.  
  163.    fg_setpage(visual);
  164.    fg_mousevis(ON);
  165.    wait_for_keystroke();
  166.  
  167.    /* clear the screen and return to the menu */
  168.  
  169.    fg_mousevis(OFF);
  170.    fg_restore(0,xlimit,menu_bottom,ylimit);
  171.  
  172.    fg_mousevis(ON);
  173.    redraw = TRUE;
  174.  
  175.    return(OK);
  176. }
  177.  
  178. /**********************************************************************\
  179. *                                                                      *
  180. *  coordinates -- about coordinate systems                             *
  181. *                                                                      *
  182. \**********************************************************************/
  183.  
  184. int coordinates()
  185. {
  186.    static char *string[] = {
  187.    "Coordinate Systems",
  188.    "Fastgraph supports 3 coordinate systems:  Character",
  189.    "Space, Screen Space and World Space.  Character Space",
  190.    "is defined in rows and columns.  Screen Space is defined",
  191.    "by the pixel resolution of the video mode.  World Space",
  192.    "is a floating point coordinate system defined by the",
  193.    "programmer."
  194.    };
  195.  
  196.    /* clear the screen and display the info window */
  197.  
  198.    fg_mousevis(OFF);
  199.    fg_restore(0,xlimit,menu_bottom,ylimit);
  200.    info_window(90,550,60,string,7);
  201.  
  202.    /* wait for keystroke or mouse button */
  203.  
  204.    fg_mousevis(ON);
  205.    wait_for_keystroke();
  206.  
  207.    /* clear the screen and return to the menu */
  208.  
  209.    fg_mousevis(OFF);
  210.    fg_restore(0,xlimit,menu_bottom,ylimit);
  211.  
  212.    fg_mousevis(ON);
  213.    redraw = TRUE;
  214.  
  215.    return(OK);
  216. }
  217.  
  218.  
  219. /**********************************************************************\
  220. *                                                                      *
  221. *  virtual_pages -- about virtual pages                                *
  222. *                                                                      *
  223. \**********************************************************************/
  224.  
  225. int logical_pages()
  226. {
  227.    static char *string[] = {
  228.    "Logical Pages",
  229.    "Logical pages let you swap out the contents of a",
  230.    "physical or virtual page to conventional memory,",
  231.    "expanded memory (EMS), or extended memory (XMS)",
  232.    "and then swap it back in when you need it.  Logical",
  233.    "pages are available in all video modes."
  234.    };
  235.  
  236.    /* clear the screen and display the info window */
  237.  
  238.    fg_mousevis(OFF);
  239.    fg_restore(0,xlimit,menu_bottom,ylimit);
  240.    info_window(100,540,60,string,6);
  241.  
  242.    /* wait for keystroke or mouse button */
  243.  
  244.    fg_mousevis(ON);
  245.    wait_for_keystroke();
  246.  
  247.    /* clear the screen and return to the menu */
  248.  
  249.    fg_mousevis(OFF);
  250.    fg_restore(0,xlimit,menu_bottom,ylimit);
  251.  
  252.    fg_mousevis(ON);
  253.    redraw = TRUE;
  254.  
  255.    return(OK);
  256. }
  257. /**********************************************************************\
  258. *                                                                      *
  259. *  physical_pages -- about physical pages                              *
  260. *                                                                      *
  261. \**********************************************************************/
  262.  
  263. int physical_pages()
  264. {
  265.    static char *string[] = {
  266.    "Physical Pages",
  267.    "Physical pages are useful for fast image display",
  268.    "and animation.  The number of physical pages",
  269.    "available is dependent on the video mode and the",
  270.    "amount of memory on your video card."
  271.    };
  272.  
  273.    /* clear the screen and display the info window */
  274.  
  275.    fg_mousevis(OFF);
  276.    fg_restore(0,xlimit,menu_bottom,ylimit);
  277.    info_window(120,520,60,string,5);
  278.  
  279.    /* wait for keystroke or mouse button */
  280.  
  281.    fg_mousevis(ON);
  282.    wait_for_keystroke();
  283.  
  284.    /* clear the screen and return to the menu */
  285.  
  286.    fg_mousevis(OFF);
  287.    fg_restore(0,xlimit,menu_bottom,ylimit);
  288.  
  289.    fg_mousevis(ON);
  290.    redraw = TRUE;
  291.  
  292.    return(OK);
  293. }
  294.  
  295. /**********************************************************************\
  296. *                                                                      *
  297. *  virtual_pages -- about virtual pages                                *
  298. *                                                                      *
  299. \**********************************************************************/
  300.  
  301. int virtual_pages()
  302. {
  303.    static char *string[] = {
  304.    "Virtual Pages",
  305.    "If you don't have enough memory on your video card",
  306.    "for physical pages, Fastgraph will let you use RAM to",
  307.    "create virtual pages in some video modes."
  308.    };
  309.  
  310.    /* clear the screen and display the info window */
  311.  
  312.    fg_mousevis(OFF);
  313.    fg_restore(0,xlimit,menu_bottom,ylimit);
  314.    info_window(100,540,60,string,4);
  315.  
  316.    /* wait for keystroke or mouse button */
  317.  
  318.    fg_mousevis(ON);
  319.    wait_for_keystroke();
  320.  
  321.    /* clear the screen and return to the menu */
  322.  
  323.    fg_mousevis(OFF);
  324.    fg_restore(0,xlimit,menu_bottom,ylimit);
  325.  
  326.    fg_mousevis(ON);
  327.    redraw = TRUE;
  328.  
  329.    return(OK);
  330. }
  331.