home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / cbgi111 / src / revn9 / nn9.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-15  |  3.3 KB  |  109 lines

  1. /**************************** NN9.H *************************************/
  2. /*    Revolution 1024 x 8 driver header file.  Contains driver     */
  3. /*  specific macros and structures.                    */
  4. /************************************************************************/
  5.  
  6. #include <dos.h>        /* MK_FP etc.                */
  7.  
  8. typedef unsigned char far * SCREEN_PTR;
  9.  
  10. typedef struct {
  11.   unsigned char length;            /* # of color entries in palette*/
  12.   unsigned char colora[256*3];        /* Up to 256 color entries    */
  13.   } NN9PALETTE;
  14.  
  15. #define MAX_MODES     1        /* The maximum number of modes.    */
  16.  
  17. #define NN9_SEGMENT    0xa000
  18. #define NN9_PALETTE     0xC100
  19. #define BANKS        16
  20.  
  21. #define BANK_SWITCH      (MK_FP(0xC040, 0))
  22.  
  23. #define BANK_SELECT()    {\
  24.             unsigned char far *bankSwitch = \
  25.                 (unsigned char far *)BANK_SWITCH;\
  26.             *bankSwitch = current_bank;\
  27.             }
  28.  
  29.                 /* A macro to calculate the current    */
  30.                 /*  address from (x,y) position info.    */
  31. #define CALC_ADDR( x, y)   { current_bank = (y) / 64;\
  32.                  current_address = screen_buffer + 1 +\
  33.                                    ((unsigned)(x)) + \
  34.                           ((unsigned)((y) & 63)) * 1024u;\
  35.                  BANK_SELECT();\
  36.                }
  37.  
  38.  
  39.                     /* A macro to change the current address*/
  40.                 /*  by 1 in the x direction.        */
  41. #define X_INCREMENT_CALC() { current_address++; }
  42.  
  43.                     /* A macro to change the current address*/
  44.                 /*  by 1 in the y direction.        */
  45. #define Y_INCREMENT_CALC() { old_address = current_address;\
  46.                  current_address += 1024;\
  47.                  if( FP_OFF( current_address) < \
  48.                      FP_OFF( old_address))\
  49.                 {\
  50.                 current_bank++;\
  51.                 BANK_SELECT();\
  52.                 }\
  53.                }
  54.  
  55.                     /* A macro to change the current address*/
  56.                 /*  by -1 in the y direction.        */
  57. #define Y_DECREMENT_CALC() { old_address = current_address;\
  58.                  current_address -= 1024;\
  59.                  if( FP_OFF( current_address) > \
  60.                      FP_OFF( old_address))\
  61.                 {\
  62.                 current_bank--;\
  63.                 BANK_SELECT();\
  64.                 }\
  65.                }
  66.  
  67.                       /* A macro to put a pixel of colour     */
  68.                 /*  colour on the screen at the current    */
  69.                 /*  address.                */
  70. #define POINT( colour)    { *current_address = colour;}
  71.  
  72.                       /* A macro to xor a pixel of colour     */
  73.                 /*  colour on the screen at the current    */
  74.                 /*  address.                */
  75. #define XOR_POINT( colour) { *current_address = (*current_address) ^\
  76.                            colour; }
  77.  
  78.                       /* A macro to read a pixel from the        */
  79.                 /*  screen at the current address.    */
  80. #define RD_POINT()    ( (unsigned char)*current_address)
  81.  
  82. /* Combinations of the address calculation macros with the draw pixel    */
  83. /*  macro using the current colour.                    */
  84.  
  85. #define DRAW_POINT( x, y)   { CALC_ADDR( (x), (y));\
  86.                   POINT( current_colour);\
  87.                     }
  88.  
  89. #define X_INCREMENT_POINT() { X_INCREMENT_CALC();\
  90.                   POINT( current_colour);\
  91.                     }
  92.  
  93. #define Y_INCREMENT_POINT() { Y_INCREMENT_CALC();\
  94.                   POINT( current_colour);\
  95.                     }
  96.  
  97. #define Y_DECREMENT_POINT() { Y_DECREMENT_CALC();\
  98.                   POINT( current_colour);\
  99.                     }
  100.  
  101.  
  102. extern SCREEN_PTR const screen_buffer;    /* Point to base of video     */
  103.                     /*  memory.            */
  104. extern SCREEN_PTR current_address,    /* Current offset into video.    */
  105.           old_address;        /* For Incrementing calc's.    */
  106. extern unsigned char current_bank;    /* Current bank.        */
  107.  
  108.  
  109.