home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / cbgi111 / src / tecmar / tecmar.h < prev   
Encoding:
C/C++ Source or Header  |  1990-07-03  |  3.9 KB  |  108 lines

  1. /**************************** TECMAR.H **********************************/
  2. /*    Tecmar driver header file.  Contains driver specific macros and    */
  3. /*  structures.                                */
  4. /************************************************************************/
  5.  
  6. #include <dos.h>        /* Outport etc.                */
  7.  
  8. #define MAX_MODES 1        /* The maximum number of modes.        */
  9. #define TECMAR_SEGMENT 0xA000    /* Where the screen memory is.        */
  10.  
  11.                 /* A macro to calculate the current    */
  12.                 /*  addres from (x,y) position info.    */
  13.                 /* y is modified by the macro.        */
  14. #define CALC_ADDR( x, y)   { bank_para_index = (y) & 3;\
  15.               current_bank = bank_para[bank_para_index].bank;\
  16.               outportb( 0x39a, current_bank);\
  17.               current_mask = mask[ (x)&1];\
  18.               (y) &= 0xfffc;\
  19.               current_address = screen_buffer + ((x) >> 1) +\
  20.                           (bank_para[bank_para_index]).para +\
  21.                     ((y) << 4) + ((y) << 6);\
  22.             }
  23.  
  24.                     /* A macro to change the current address*/
  25.                 /*  by 1 in the x direction.        */
  26. #define X_INCREMENT_CALC() { current_mask = ~current_mask;\
  27.                  if( current_mask == (char)0xf0) {\
  28.                           current_address++;}\
  29.                }
  30.  
  31.                     /* A macro to change the current address*/
  32.                 /*  by 1 in the y direction.        */
  33. #define Y_INCREMENT_CALC() { bank_para_index = (++bank_para_index) & 3;\
  34.               outportb( 0x39a, bank_para[bank_para_index].bank);\
  35.               current_address += bank_para[bank_para_index].yinc;\
  36.               }
  37.  
  38.                     /* A macro to change the current address*/
  39.                 /*  by -1 in the y direction.        */
  40. #define Y_DECREMENT_CALC() { bank_para_index = (--bank_para_index) & 3;\
  41.               outportb( 0x39a, bank_para[bank_para_index].bank);\
  42.               current_address += bank_para[bank_para_index].ydec;\
  43.               }
  44.  
  45.                       /* A macro to put a pixel of colour     */
  46.                 /*  colour on the screen at the current    */
  47.                 /*  address.                */
  48. #define POINT( colour)    { *current_address = ((*current_address) &\
  49.                            ~current_mask) |\
  50.               ( (colour) & current_mask);\
  51.                 }
  52.  
  53.                       /* A macro to xor a pixel of colour     */
  54.                 /*  colour on the screen at the current    */
  55.                 /*  address.                */
  56. #define XOR_POINT( colour) { *current_address = ((*current_address) &\
  57.                            ~current_mask) |\
  58.                (((*current_address) ^ (colour))& current_mask);\
  59.                    }
  60.  
  61.                       /* A macro to read a pixel from the        */
  62.                 /*  screen at the current address.    */
  63. #define RD_POINT()    ( (current_mask == (char)0xf0) ? ((*current_address\
  64.                            & current_mask) >> 4) : (*current_address\
  65.                & current_mask)\
  66.                 )
  67.  
  68. /* Combinations of the address calculation macros with the draw pixel    */
  69. /*  macro using the current colour.                    */
  70.  
  71. #define DRAW_POINT( x, y)   { CALC_ADDR( (x), (y));\
  72.                   POINT( current_colour);\
  73.                     }
  74.  
  75. #define X_INCREMENT_POINT() { X_INCREMENT_CALC();\
  76.                   POINT( current_colour);\
  77.                     }
  78.  
  79. #define Y_INCREMENT_POINT() { Y_INCREMENT_CALC();\
  80.                   POINT( current_colour);\
  81.                     }
  82.  
  83. #define Y_DECREMENT_POINT() { Y_DECREMENT_CALC();\
  84.                   POINT( current_colour);\
  85.                     }
  86.  
  87.  
  88. struct BANK_PARA {        /* Bank/paragraph description.        */
  89.     unsigned char bank;    /* In Bank.                */
  90.     unsigned int yinc;    /* Add this much to get offset from    */
  91.                 /*  previous line.            */
  92.     unsigned int ydec;    /* Add this much to get offset from     */
  93.                 /*  next line.                */
  94.     unsigned int para;    /* Which half of the bank.        */
  95.     };
  96.  
  97. extern const struct BANK_PARA bank_para[4];    /* An array of 4 of them*/
  98.                     /* describes all bank/paragraph    */
  99.                     /* combinations.        */
  100. extern const unsigned char mask[2];    /* Two pixels/byte to mask.    */
  101.  
  102. extern unsigned char far * const screen_buffer;    /* Point to base of    */
  103.                         /*  video memory.    */
  104. extern unsigned char far *current_address; /* Current offset into video.*/
  105. extern int current_bank,         /* Current bank and paragraph.    */
  106.        bank_para_index;
  107. extern char current_mask;        /* Current pixel address.    */
  108.