home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume38 / tessel / part01 / colours.h < prev    next >
Text File  |  1993-06-20  |  4KB  |  101 lines

  1. /*
  2.  *+-----------------------------------------------------------------------+
  3.  *| This header file contains definitions for 32-bit colour pixels and    |
  4.  *| Z-buffer.                                                             |
  5.  *|                                                                       |
  6.  *| Author: Michael S. A. Robb         Version: 1.2        Date: 16/06/93 |
  7.  *+-----------------------------------------------------------------------+
  8.  */
  9.  
  10. typedef unsigned long ADDRESS; /* 32-bit memory address.   */
  11. typedef unsigned int  WORD;    /* 16-bit data.             */
  12. typedef unsigned char BYTE;    /*  8-bit data.             */
  13. typedef unsigned long LONG;    /* 32-bit unsigned integer. */
  14.  
  15. /*
  16.  *+-----------------------------------------------------------------------+
  17.  *| The following data structure is used to represent a 32-bit Z-buffer   |
  18.  *| value.                                                                |
  19.  *+-----------------------------------------------------------------------+
  20.  */
  21.  
  22. typedef struct zbufferhl_st
  23.   {
  24.   WORD zbuf_lo;
  25.   WORD zbuf_hi;
  26.   } ZBUFFER_HL;
  27.  
  28. typedef union zbuffer_st
  29.   {
  30.   long       zbuf_value;       /* Used for calculations.             */
  31.   ZBUFFER_HL zbuf_hilo;        /* Used for read/writing TIGA memory. */
  32.   } ZBUFFER;
  33.  
  34. #define ZBUFFER_MAX 0x7FFFFFFFL
  35.  
  36. #define MAX_BLEND   255        /* Maximum blend value         */
  37. #define PIXEL_SIZE   32        /* 1 pixel = 32 bits           */
  38. #define ZBUFFER_SIZE 32        /* 1 Z-buffer entry = 32 bits. */
  39.  
  40. /*+-----------------------------------------------------------------------+
  41.  *| Hercules Video RAM is located at location 0x00000000 and is 1 Mbyte   |
  42.  *| in size. However, the TMS34010 addresses memory using bit addresses.  |
  43.  *| So in fact, the end of video RAM is at location 0x800000.             |
  44.  *|                                                                       |
  45.  *| Since each pixel is 32-bits in length, this makes it possible for the |
  46.  *| graphics board to have two 512x256x32 bit screens. Alternatively, the |
  47.  *| second screen can be used as a 32-bit Z-buffer. If the optional 2     |
  48.  *| Mbytes of DRAM is present, this allows the use of two screens with    |
  49.  *| 512x256x32 resolution, both of which have Z-buffers.                  |
  50.  *+-----------------------------------------------------------------------+
  51.  */
  52.  
  53. #define OFFSET_VRAM             0x0L           /* Start of VRAM       */
  54. #define OFFSET_ZBUFFER          0x400000L      /* Second half of VRAM */
  55.  
  56. /*+-----------------------------------------------------------------------+
  57.  *| Useful macros for converting XY addresses to linear offsets.          |
  58.  *+-----------------------------------------------------------------------+
  59.  */
  60.  
  61. #define ADDRESS_PIXEL(X,Y)\
  62.   (( (ADDRESS)(X)+(ADDRESS)(Y)*screen_width)*PIXEL_SIZE+OFFSET_VRAM)
  63.  
  64. #define ADDRESS_ZBUFFER(X,Y)\
  65.   (( (ADDRESS)(X)+(ADDRESS)(Y+256)*screen_width)*PIXEL_SIZE+OFFSET_ZBUFFER)
  66.  
  67. /*+-----------------------------------------------------------------------+
  68.  *| The following data structure is used to represent a 32-bit colour     |
  69.  *| pixel plus an 8-bit overlay.                                          |
  70.  *+-----------------------------------------------------------------------+
  71.  */
  72.  
  73. typedef struct rgb32_st
  74.   {
  75.   BYTE  col_blue;              /* Amount of BLUE.    */
  76.   BYTE  col_overlay;           /* Amount of OVERLAY. */
  77.   BYTE  col_green;             /* Amount of GREEN.   */
  78.   BYTE  col_red;               /* Amount of RED.     */
  79.   } RGB32;
  80.  
  81. typedef struct rgb32hl_st
  82.   {
  83.   WORD  col_lo;                /* Low 16 bits  */
  84.   WORD  col_hi;                /* High 16 bits */
  85.   } RGB32_HL;
  86.  
  87. /*+-----------------------------------------------------------------------+
  88.  *| The following data structure is used to represent a 32-bit colour     |
  89.  *| pixel as well as permitting Boolean operations such as AND, OR & NOT. |
  90.  *+-----------------------------------------------------------------------+
  91.  */
  92.  
  93. typedef union colour32
  94.   {
  95.   RGB32    col_rgb;            /* Structured representation. */
  96.   RGB32_HL col_hilo;           /* Integer    representation. */
  97.   ADDRESS  col_value;          /* Integer    representation. */
  98.   } COLOUR32;
  99.  
  100.  
  101.