home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / Mesa-3.1 / src / AOS / palettes.i.in < prev    next >
Text File  |  1999-09-23  |  5KB  |  133 lines

  1. //#ifndef    AMIGAMESApal_I
  2. //#define    AMIGAMESApal_I
  3.  
  4. /*
  5.  * $Id: $
  6.  */
  7.  
  8. /*
  9.  * Mesa 3-D graphics library
  10.  * Version:  3.1
  11.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  12.  *
  13.  * This library is free software; you can redistribute it and/or
  14.  * modify it under the terms of the GNU Library General Public
  15.  * License as published by the Free Software Foundation; either
  16.  * version 2 of the License, or (at your option) any later version.
  17.  *
  18.  * This library is distributed in the hope that it will be useful,
  19.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21.  * Library General Public License for more details.
  22.  *
  23.  * You should have received a copy of the GNU Library General Public
  24.  * License along with this library; if not, write to the Free
  25.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26.  */
  27.  
  28. #ifdef    PALETTE_DEFS
  29. /* first part defines amigaMesa-specifig tag
  30.  * second part defines the choosen palette (aka modelling of available colors)
  31.  * third part defines methog to fetch data (aka encoding of given colors
  32.  *
  33.  * at the moment dithering is only available in RGBMode, that means if we are
  34.  * in index-mode the index-pixels are directly (without dither) mapped to
  35.  * pen-pixels, it could be an improvement to offer dithering even for index-modes
  36.  */
  37.  
  38.   /* dithering */
  39. #define    AMESA_HPCR_DITHER    -8                /* hp-color-recovery */
  40. #define    AMESA_GREY_DITHER    -4
  41. #define    AMESA_WEIGHTED_DITHER    -2                /* default standard 0 */
  42. #define    AMESA_TRUECOLOR_DITHER    -1                /* matches below 0 */
  43.   /* matching */
  44. #define    AMESA_HPCR_MATCH    8                /* hp-color-recovery */
  45. #define    AMESA_GREY_MATCH    4
  46. #define    AMESA_WEIGHTED_MATCH    2                /* default standard 0 */
  47. #define    AMESA_TRUECOLOR_MATCH    1                /* matches below 0 */
  48.   /* shifting */
  49. #define    AMESA_TRUECOLOR_SHIFT    0                /* shifts above 0 */
  50.   /* invalid */
  51. #define    AMESA_DEADFOOD        0xDEAD                /* dead man */
  52.  
  53. #define    MATCHtoDITHER(bool)        ((bool) = -(bool))    /* if in shift-mode dither isn't available */
  54. #define    DITHERtoMATCH(bool)        ((bool) = -(bool))    /* if in shift-mode dither isn't available */
  55.  
  56. #define    IS_HPCR(bool)            (((bool) ==  8) || ((bool) == -8))
  57. #define    IS_GREY(bool)            (((bool) ==  4) || ((bool) == -4))
  58. #define    IS_WEIGHTED(bool)        (((bool) ==  2) || ((bool) == -2))
  59. #define    IS_TRUECOLOR(bool)        (((bool) >= -1) && ((bool) <=  1))
  60.  
  61. #define    IS_DITHER(bool)            ((bool) <  0)
  62. #define    IS_MATCH(bool)            ((bool) >  0)
  63. #define    IS_SHIFT(bool)            ((bool) == 0)
  64.  
  65. /*****************************************************************************
  66.  *
  67.  * fetch-macros
  68.  */
  69.  
  70. /* compositions */
  71. #define c8toc32(x)            (((((((x) << 8) | (x)) << 8) | (x)) << 8) | (x))    /* byte-pen to pattern-pen */
  72. #define    c24tocg(r,g,b)            (((r << 5) + (g << 6) + (g << 5) + (b << 3) + b) >> 9)    /* rgb-color to 64-grey (quick approximation) */
  73. #define    c24toc8(r,g,b)            ((((r) & 0xE0) >> 0) |    \
  74.                      (((g) & 0xE0) >> 3) |    \
  75.                      (((b) & 0xE0) >> 6))                    /* rgb-color to 332-color */
  76.  
  77. /* TrueColor-RGB */
  78. #define TC_RGBA(r,g,b)            (((((((r) << 8) | (g)) << 8) | (b)) << 8) | (0))    /* byte-rgb to long-rgba */
  79. #define TC_ARGB(r,g,b)            (((((((0) << 8) | (r)) << 8) | (g)) << 8) | (b))    /* byte-rgb to long-argb */
  80.  
  81. /* Grey-RGB */
  82. #define    GR_RGBA(am, r, g, b)        (am->Palette[c24tocg(r, g, b)].PenNo)            /* rgb-color to grey-pen */
  83.  
  84. /* Palette-Index */
  85. #define PLD_RGBA(am, r, g, b, x, y)    (GetPenDithered(r, g, b, am, x, y))            /* rgb-color to dithered-pen */
  86. #define PLG_RGBA(am, r, g, b)        (GetPen(r, g, b, am))                    /* rgb-color to pen */
  87. #define PL8_RGBA(am, r, g, b)        (am->Palette[c24toc8(r, g, b)].PenNo)            /* rgb-color to 332-pen */
  88.  
  89. /* the format of index is RGBI, red|green|blue|index */
  90. #define MakeRGBP(am, r, g, b, x, y)    (TC_RGBA(r, g, b) | PL_RGBA(am, r, g, b, x, y))        /* rgb to long-rgbp */
  91. /* get the red/green/blue/pen from a given index */
  92. #define    GetRGBP(am, idx)        (am->ItoP[(GLubyte)(idx)])                /* index to pen */
  93. #define    GetRGBPLocal(idx)        (ItoP[(GLubyte)(idx)])                    /* index to pen */
  94. /* get the red/green/blue/index from a given pen */
  95. #define    GetIndex(am, idx)        (am->PtoI[(GLubyte)(idx)])                /* pen to index */
  96. #define    GetIndexLocal(idx)        (PtoI[(GLubyte)(idx)])                    /* pen to index */
  97.  
  98. /*****************************************************************************/
  99.  
  100. #define    ColorEntry_orgEntry_r    %d
  101. #define    ColorEntry_orgEntry_g    %d
  102. #define    ColorEntry_orgEntry_b    %d
  103. #define    ColorEntry_orgEntry_a    %d
  104.  
  105. #define    ColorEntry_mapEntry_r    %d
  106. #define    ColorEntry_mapEntry_g    %d
  107. #define    ColorEntry_mapEntry_b    %d
  108. #define    ColorEntry_mapEntry_a    %d
  109.  
  110. #define    PenNo            ColorEntry_mapEntry_a
  111.  
  112. #define    CACHED            0xFF
  113. #define    INVALID            0x00
  114.  
  115. #define    ColorCache_PenCch    %d
  116. #define    ColorCache_R        %d
  117. #define    ColorCache_B        %d
  118. #define    ColorCache_valid    %d
  119.  
  120. #define palNumCols332        256
  121. #define palNumCols        189
  122. #define palNumColsGrey        64
  123. #define palNumColsHPCR        256
  124.  
  125. #define    palNumColsMax        256
  126.  
  127. #define    ERROR_RANGE        512    /* -255 = 0 - 255, 255 = 255 - 0: -255 -> 255 */
  128. #endif
  129.  
  130. /*****************************************************************************/
  131.  
  132. //#endif
  133.