home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / cbgi111 / src / ati / ati.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-13  |  4.6 KB  |  153 lines

  1. /**************************** ATI.H *************************************/
  2. /*    ATI Wonder driver header file.  Contains driver specific macros    */
  3. /*  and structures.                            */
  4. /************************************************************************/
  5.  
  6. #include <dos.h>        /* Outport 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 16 color entries    */
  13.   } ATIPALETTE;
  14.  
  15. #define MAX_MODES     3        /* The maximum number of modes.    */
  16. #define ATI256LO    0
  17. #define ATI256MED    1
  18. #define ATI256HI    2
  19.  
  20. #define PLANE_SELECT    0xb2
  21. #define PLANE_MASK    0xe1
  22. #define EXTENDED_REG    0x1ce
  23.  
  24. #define ATI_SEGMENT    0xa000
  25.  
  26. #define BANK_SELECT()    {\
  27.             int BANK_SELECT_temp;\
  28.             disable();\
  29.             outportb( EXTENDED_REG, PLANE_SELECT);\
  30.             BANK_SELECT_temp = inportb( EXTENDED_REG+1) & \
  31.                                PLANE_MASK;\
  32.             BANK_SELECT_temp |= current_bank << 1;\
  33.             outport( EXTENDED_REG, (BANK_SELECT_temp << 8) |\
  34.                      PLANE_SELECT);\
  35.             enable();\
  36.             }
  37.  
  38.                 /* A macro to calculate the current    */
  39.                 /*  address from (x,y) position info.    */
  40. #define CALC_ADDR( x, y)   { int CALC_ADDR_temp_i; \
  41.                  for( CALC_ADDR_temp_i = 0; CALC_ADDR_temp_i \
  42.                           < maximum_bank; CALC_ADDR_temp_i++)\
  43.                    { \
  44.                    if( y < bank[CALC_ADDR_temp_i].rowmax)\
  45.                    { \
  46.                    current_bank = CALC_ADDR_temp_i; \
  47.                    BANK_SELECT();\
  48.                    current_address = screen_buffer + \
  49.                        (y - bank[CALC_ADDR_temp_i].rowmin)*rowsize + \
  50.                        x - bank[CALC_ADDR_temp_i].colmin;\
  51.                    break;\
  52.                    }\
  53.                    else if( y == bank[CALC_ADDR_temp_i].rowmax && \
  54.                             x <= bank[CALC_ADDR_temp_i].colmax)\
  55.                    { \
  56.                    current_bank = CALC_ADDR_temp_i; \
  57.                    BANK_SELECT();\
  58.                    current_address = screen_buffer + \
  59.                        (y - bank[CALC_ADDR_temp_i].rowmin)*rowsize + \
  60.                        x - bank[CALC_ADDR_temp_i].colmin;\
  61.                    break;\
  62.                    }\
  63.                    }\
  64.                }
  65.  
  66.  
  67.                     /* A macro to change the current address*/
  68.                 /*  by 1 in the x direction.        */
  69. #define X_INCREMENT_CALC() { current_address++;\
  70.                  if( FP_OFF( current_address) == 0){\
  71.                     current_bank++;\
  72.                     BANK_SELECT();}\
  73.                 }
  74.  
  75.                     /* A macro to change the current address*/
  76.                 /*  by 1 in the y direction.        */
  77. #define Y_INCREMENT_CALC() { old_address = current_address;\
  78.                  current_address += rowsize;\
  79.                  if( FP_OFF( current_address) < \
  80.                      FP_OFF( old_address))\
  81.                 {\
  82.                 current_bank++;\
  83.                 BANK_SELECT();\
  84.                 }\
  85.                }
  86.  
  87.                     /* A macro to change the current address*/
  88.                 /*  by -1 in the y direction.        */
  89. #define Y_DECREMENT_CALC() { old_address = current_address;\
  90.                  current_address -= rowsize;\
  91.                  if( FP_OFF( current_address) > \
  92.                      FP_OFF( old_address))\
  93.                 {\
  94.                 current_bank--;\
  95.                 BANK_SELECT();\
  96.                 }\
  97.                }
  98.  
  99.                       /* A macro to put a pixel of colour     */
  100.                 /*  colour on the screen at the current    */
  101.                 /*  address.                */
  102. #define POINT( colour)    { *current_address = colour;}
  103.  
  104.                       /* A macro to xor a pixel of colour     */
  105.                 /*  colour on the screen at the current    */
  106.                 /*  address.                */
  107. #define XOR_POINT( colour) { *current_address = (*current_address) ^\
  108.                            colour; }
  109.  
  110.                       /* A macro to read a pixel from the        */
  111.                 /*  screen at the current address.    */
  112. #define RD_POINT()    ( (unsigned char)*current_address)
  113.  
  114. /* Combinations of the address calculation macros with the draw pixel    */
  115. /*  macro using the current colour.                    */
  116.  
  117. #define DRAW_POINT( x, y)   { CALC_ADDR( (x), (y));\
  118.                   POINT( current_colour);\
  119.                     }
  120.  
  121. #define X_INCREMENT_POINT() { X_INCREMENT_CALC();\
  122.                   POINT( current_colour);\
  123.                     }
  124.  
  125. #define Y_INCREMENT_POINT() { Y_INCREMENT_CALC();\
  126.                   POINT( current_colour);\
  127.                     }
  128.  
  129. #define Y_DECREMENT_POINT() { Y_DECREMENT_CALC();\
  130.                   POINT( current_colour);\
  131.                     }
  132.  
  133.  
  134. struct BANK {            /* Bank description.            */
  135.     unsigned int rowmin;
  136.     unsigned int rowmax;
  137.     unsigned int colmin;
  138.     unsigned int colmax;
  139.     };
  140.  
  141. extern struct BANK bank[8];        /* An array of 8 of them,     */
  142.                     /* describes all bank.        */
  143.  
  144. extern SCREEN_PTR const screen_buffer;    /* Point to base of video     */
  145.                     /*  memory.            */
  146. extern SCREEN_PTR current_address,    /* Current offset into video.    */
  147.           old_address;        /* For Incrementing calc's.    */
  148. extern unsigned char current_bank;         /* Current bank.        */
  149. extern unsigned char maximum_bank;         /* Maximum bank available.    */
  150. extern int rowsize;
  151.  
  152.  
  153.