home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / FACETV.ZIP / RESPVGA.H < prev    next >
C/C++ Source or Header  |  1994-01-03  |  6KB  |  196 lines

  1. /************************************************************************
  2. **
  3. ** @(#)respvga.h    01/03/94    Chris Ahlstrom
  4. **
  5. **    A convenient, out-of-the-way place to define a simple
  6. ** version of the response-box lights.  The representation is
  7. ** very simple.  We define a virtual screen of 1000 in width,
  8. ** and a 1000 in height.  Then we locate the coordinates in
  9. ** terms of these maximal dimensions.  Basically, the numbers
  10. ** below respresent to coordinates in terms of percentage of
  11. ** full-screen, times 10.
  12. **
  13. **    Note that the virtualBox will be our standard, and we
  14. ** will use that for converting all other representations into
  15. ** the units proper for the display device.
  16. **
  17. **    Guide to conversions.  The "screen_" values are as per
  18. ** "screen.c" and "screen.h" in the AIR library.
  19. **
  20. **  1.  Converting virtual coordinates to characters:
  21. **
  22. **    a.  screen_x = (virtual_x / VIRTmax) * screen_columns
  23. **    b.  screen_y = (virtual_y / VIRTmax) * screen_rows
  24. **
  25. **  2.  Converting virtual coordinates to pixels:
  26. **
  27. **    a.  screen_x = (virtual_x / VIRTmax) * screen_gmax_x
  28. **    b.  screen_y = (virtual_y / VIRTmax) * screen_gmax_y
  29. **        
  30. **  3.    Converting VGA pixel dimensions into EGA pixel dimensions:
  31. **
  32. **    a. X-values are such that EGA_X = VGA_X
  33. **    b. Y-values are such that EGA_X = (3/4)VGA_X
  34. **
  35. *************************************************************************/
  36.  
  37.  
  38. #if !defined(RESPVGA_h)                    /* { RESPVGA_h    */
  39. #define RESPVGA_h
  40.  
  41. #include <graphics.h>
  42.  
  43. #include "respintr.h"        /* for ResponseBox declaration        */
  44.  
  45. #define VIRTmax    1000        /* our standard (100 is too coarse)    */
  46.  
  47.  
  48. /************************************************************************
  49. ** Turbo Vision color support
  50. **
  51. **    Turbo Vision handles colors as object characteristics, rather
  52. ** than as attribute bytes.   You pick "the same color as normal window
  53. ** color", rather than the attribute "yellow on blue", for example.
  54. ** The main application defines a large palette that everything
  55. ** in Turbo Vision will use.  Each object defines a short array that
  56. ** contains indices into this large palette.
  57. **
  58. **    The programmer uses getColor to select an index into the
  59. ** local object's palette, and the local object's palette points
  60. ** to the large palette.
  61. **
  62. **    We set things up so that we can select either attribute bytes
  63. ** or TV palette indices at compile-time.
  64. **
  65. **    Further explanation of Turbo Vision palettes:
  66. **
  67. **    TApplication inherits cpColor (see APP.H) from TProgram, and
  68. ** I've decided (for now) to limit the choice of colors to this palette.
  69. ** See p. 342-3 of the TV manual for a list of the colors.  At present,
  70. ** we use only colors from one section (top of p. 343).  Also, we
  71. ** use the foreground colors (using character RCELL, which fills the
  72. ** whole foreground of the cell).  We could use RBACK (which doesn't
  73. ** fill the foreground with the background color.
  74. **
  75. **    None of the colors in cpColor has the bright red we desire
  76. ** for the READY_LIGHT.  Instead, yellow is used, which makes it
  77. ** at least a warning in American culture.
  78. **
  79. *************************************************************************/
  80.  
  81. #define RCELL    '\xDB'                /* gets foreground color*/
  82. #define RBACK    ' '                /* gets background color*/
  83. #define TV_PALETTES    1
  84.  
  85. #if TV_PALETTES                    /* { TV_PALETTES    */
  86.  
  87.     #define RESPONSE_COLOR     9
  88.     #define INTERVAL_COLOR    10
  89.     #define READY_COLOR        11
  90.     #define ANSWER_COLOR    12
  91.     #define BACKGROUND_COLOR    13
  92.  
  93.     #define RESPONSE_PAL    "\x21"        /* frame-active color    */
  94.     #define INTERVAL_PAL    "\x21"        /* frame-active color    */
  95.     #define READY_PAL        "\x28"        /* label-shortcut color    */
  96.     #define ANSWER_PAL        "\x22"        /* frame-icon color    */
  97.     #define BACK_PAL        "\x25"        /* static-text color    */
  98.  
  99. #else                        /* }{ TV_PALETTES    */
  100.  
  101.     #define RESPONSE_COLOR    WHITE
  102.     #define INTERVAL_COLOR    WHITE
  103.     #define READY_COLOR        LIGHTRED
  104.     #define ANSWER_COLOR    LIGHTGREEN
  105.     #define BACKGROUND_COLOR    BROWN
  106.  
  107. #endif                         /* } TV_PALETTES    */
  108.  
  109.  
  110. #if defined(RESPWIND_cpp)            /* { RESPWIND_cpp    */
  111.  
  112. #define LWDTH    266            /* width of response/interval    */
  113. #define LHGTH    200            /* height of response/interval    */
  114. #define FWDTH     78            /* width of protocol lights    */
  115. #define FHGTH     78            /* height of protocol lights    */
  116.  
  117. #define LEFTX0    156            /* basic left X location    */
  118. #define LEFTX1    (LEFTX0 + LWDTH)
  119. #define RGHTX0    578            /* basic right X location    */
  120. #define RGHTX1    (RGHTX0 + LWDTH)
  121.  
  122. #define INTVY0    334            /* basic Y location        */
  123. #define INTVY1    (INTVY0 + LHGTH)
  124. #define RESPY0    (INTVY1 + LHGTH)    /* offset from interval light    */
  125. #define RESPY1    (RESPY0 + LHGTH)
  126.  
  127. #define READX0     78            /* basic X for protocol lights    */
  128. #define READX1    (READX0 + FWDTH)
  129. #define ANSWX0    844
  130. #define ANSWX1    (ANSWX0 + FWDTH)
  131.  
  132. #define PROTY0     78            /* basic Y for protocol lights    */
  133. #define PROTY1    (PROTY0 + FHGTH)
  134.  
  135. ResponseBox virtualBox =
  136. {
  137.     BACKGROUND_COLOR,            /* screen color        */
  138.     SOLID_FILL,                /* background fill style*/
  139.     {                    /* response_1        */
  140.     SOLID_FILL,
  141.     RESPONSE_COLOR,
  142.     LEFTX0, RESPY0, LEFTX1, RESPY1
  143.     },
  144.     {                    /* response_2        */
  145.     SOLID_FILL,
  146.     RESPONSE_COLOR,
  147.     RGHTX0, RESPY0, RGHTX1, RESPY1
  148.     },
  149.     {                    /* response_3        */
  150.     SOLID_FILL,
  151.     RESPONSE_COLOR,
  152.     0, 0, 0, 0            /* unused by default    */
  153.     },
  154.     {                    /* ready_light        */
  155.     SOLID_FILL,
  156.     READY_COLOR,
  157.     READX0, PROTY0, READX1, PROTY1
  158.     },
  159.     {                    /* answer_light        */
  160.     SOLID_FILL,
  161.     ANSWER_COLOR,
  162.     ANSWX0, PROTY0, ANSWX1, PROTY1
  163.     },
  164.     {                    /* interval_1        */
  165.     SOLID_FILL,
  166.     INTERVAL_COLOR,
  167.     LEFTX0, INTVY0, LEFTX1, INTVY1
  168.     },
  169.     {                    /* interval_2        */
  170.     SOLID_FILL,
  171.     INTERVAL_COLOR,
  172.     RGHTX0, INTVY0, RGHTX1, INTVY1
  173.     },
  174.     {                    /* interval_3        */
  175.     SOLID_FILL,
  176.     INTERVAL_COLOR,
  177.     0, 0, 0, 0            /* unused by default    */
  178.     },
  179.     {                    /* failure_light    */
  180.     SANS_SERIF_FONT,
  181.     HORIZ_DIR,
  182.     4,
  183.     156, 750,
  184.     "ERROR: please stop"
  185.     }
  186. };
  187.  
  188.  
  189. #else                        /* }{ RESPWIND_cpp    */
  190.  
  191. extern ResponseBox virtualBox;
  192.  
  193. #endif                        /* } RESPWIND_cpp    */
  194.  
  195. #endif                            /* } RESPVGA_h    */
  196.