Debian Codegraph @

lib/grdefs.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/lib/grdefs.h $
21 * $Revision: 8 $
22 * $Date: 10/21/98 11:54p $
23 * $Author: Samir $
24 *
25 *
26 *
27 * $Log: /DescentIII/Main/lib/grdefs.h $
28 *
29 * 8 10/21/98 11:54p Samir
30 * added GR_NULL
31 *
32 * 7 5/06/98 4:33p Samir
33 * added fixed screen width and height to grdefs.h (default res.)
34 *
35 * 6 4/23/98 6:38p Jason
36 * made bitmaps use 1555 format
37 *
38 * 5 12/29/97 5:50p Samir
39 * Moved GR_COLOR_CHAR to grdefs.h from gr.h.
40 *
41 * 4 12/22/97 7:39p Samir
42 * Moved color constants from gr.h to grdefs.h
43 *
44 * 3 12/22/97 7:34p Samir
45 * Added transparent color info.
46 *
47 * $NoKeywords: $
48 */
49
50 #ifndef GRDEFS_H
51 #define GRDEFS_Hcxx . . $ `lib/grdefs.h:51:9`!
52
53 #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/
54
55 // bit depth info
56 #define BPP_TO_BYTESPPcxx . . $ `lib/grdefs.h:56:9`!(x) (((x) + 7) >> 3)
57
58 #define BPP_DEFAULTcxx . . $ `lib/grdefs.h:58:9`! 0 // default for current display
59 #define BPP_8cxx . . $ `lib/grdefs.h:59:9`! 8 // 8-bit paletted.
60 #define BPP_15cxx . . $ `lib/grdefs.h:60:9`! 15 // 5-5-5 + chroma Hicolor
61 #define BPP_16cxx . . $ `lib/grdefs.h:61:9`! 16 // 5-6-5 Hicolor
62 #define BPP_24cxx . . $ `lib/grdefs.h:62:9`! 24 // 24 bit true color
63 #define BPP_32cxx . . $ `lib/grdefs.h:63:9`! 32 // 32 bit true color
64
65 #define FIXED_SCREEN_WIDTHcxx . . $ `lib/grdefs.h:65:9`! 640
66 #define FIXED_SCREEN_HEIGHTcxx . . $ `lib/grdefs.h:66:9`! 480
67
68 // transparent color constant here.
69 #define OPAQUE_FLAG16cxx . . $ `lib/grdefs.h:69:9`! 0x8000
70 #define TRANSPARENT_COLOR32cxx . . $ `lib/grdefs.h:70:9`! 0x0000FF00
71 #define NEW_TRANSPARENT_COLORcxx . . $ `lib/grdefs.h:71:9`! 0x0000
72 #define OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! OPAQUE_FLAG16cxx . . $ `lib/grdefs.h:69:9`!
73
74 // a new color definition
75 typedef uint32_tcxx . . $ uint32_t# ddgr_colorcxx . . $ ddgr_color#;
76
77 // Color constants
78 static const ddgr_colorcxx . . $ ddgr_color# GR_NULLcxx . . $ GR_NULL. = 0xffffffff, // don't do a thing with this.
79 GR_BLACKcxx . . $ GR_BLACK. = 0x00000000, GR_GREENcxx . . $ GR_GREEN. = 0x0000ff00, GR_REDcxx . . $ GR_RED. = 0x00ff0000, GR_BLUEcxx . . $ GR_BLUE. = 0x000000ff, GR_DARKGRAYcxx . . $ GR_DARKGRAY. = 0x00404040,
80 GR_LIGHTGRAYcxx . . $ GR_LIGHTGRAY. = 0x00c0c0c0, GR_WHITEcxx . . $ GR_WHITE. = 0x00ffffff;
81
82 #define GR_COLOR_CHARcxx . . $ `lib/grdefs.h:82:9`! 1 // ASCII 1 and (r,g,b) changes current text color in string.
83
84 // MACROS
85 static inline ddgr_colorcxx . . $ ddgr_color# GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(int r, int g, int b) { return ((r << 16) + (g << 8) + b); }
86
87 static inline uint16_tcxx . . $ uint16_t# GR_RGB16cxx . . $ GR_RGB16(6461fafb79bad5b9).(int r, int g, int b) { return (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)); }
88
89 static inline uint16_tcxx . . $ uint16_t# GR_COLOR_TO_16cxx . . $ GR_COLOR_TO_16(6557041c941ab807).(ddgr_colorcxx . . $ ddgr_color# c) {
90 int r, g, b;
91 r = ((c & 0x00ff0000) >> 16);
92 g = ((c & 0x0000ff00) >> 8);
93 b = (c & 0x000000ff);
94
95 return (uint16_tcxx . . $ uint16_t#)(((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3));
96 }
97
98 static inline int GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(ddgr_colorcxx . . $ ddgr_color# c) {
99 int r = ((c & 0x00ff0000) >> 16);
100 return (int)r;
101 }
102
103 static inline int GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(ddgr_colorcxx . . $ ddgr_color# c) {
104 int g = ((c & 0x0000ff00) >> 8);
105 return (int)g;
106 }
107
108 static inline int GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(ddgr_colorcxx . . $ ddgr_color# c) {
109 int b = (c & 0x000000ff);
110 return (int)b;
111 }
112
113 static inline ddgr_colorcxx . . $ ddgr_color# GR_16_TO_COLORcxx . . $ GR_16_TO_COLOR(909d59720f161188).(uint16_tcxx . . $ uint16_t# col) {
114 int r, g, b;
115
116 r = (col & 0x7c00) >> 7;
117 g = (col & 0x03e0) >> 2;
118 b = (col & 0x001f) << 3;
119
120 return GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(r, g, b);
121 }
122
123 #endif