Descent3/lib/grdefs.h

105 lines
2.5 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
/*
* $Logfile: /DescentIII/Main/lib/grdefs.h $
* $Revision: 8 $
* $Date: 10/21/98 11:54p $
* $Author: Samir $
*
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
*
* $Log: /DescentIII/Main/lib/grdefs.h $
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 8 10/21/98 11:54p Samir
* added GR_NULL
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 7 5/06/98 4:33p Samir
* added fixed screen width and height to grdefs.h (default res.)
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 6 4/23/98 6:38p Jason
* made bitmaps use 1555 format
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 5 12/29/97 5:50p Samir
* Moved GR_COLOR_CHAR to grdefs.h from gr.h.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 4 12/22/97 7:39p Samir
* Moved color constants from gr.h to grdefs.h
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 3 12/22/97 7:34p Samir
* Added transparent color info.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* $NoKeywords: $
*/
#ifndef GRDEFS_H
#define GRDEFS_H
#include "pstypes.h"
// bit depth info
2024-04-16 18:56:40 +00:00
#define BPP_TO_BYTESPP(x) (((x) + 7) >> 3)
#define BPP_DEFAULT 0 // default for current display
#define BPP_8 8 // 8-bit paletted.
#define BPP_15 15 // 5-5-5 + chroma Hicolor
#define BPP_16 16 // 5-6-5 Hicolor
#define BPP_24 24 // 24 bit true color
#define BPP_32 32 // 32 bit true color
#define FIXED_SCREEN_WIDTH 640
#define FIXED_SCREEN_HEIGHT 480
2024-04-16 03:43:29 +00:00
// transparent color constant here.
2024-04-16 18:56:40 +00:00
#define OPAQUE_FLAG16 0x8000
2024-04-16 03:43:29 +00:00
#define TRANSPARENT_COLOR32 0x0000FF00
2024-04-16 18:56:40 +00:00
#define NEW_TRANSPARENT_COLOR 0x0000
#define OPAQUE_FLAG OPAQUE_FLAG16
2024-04-16 03:43:29 +00:00
// a new color definition
typedef uint ddgr_color;
// Color constants
2024-04-16 18:56:40 +00:00
const ddgr_color GR_NULL = 0xffffffff, // don't do a thing with this.
GR_BLACK = 0x00000000, GR_GREEN = 0x0000ff00, GR_RED = 0x00ff0000, GR_BLUE = 0x000000ff, GR_DARKGRAY = 0x00404040,
GR_LIGHTGRAY = 0x00c0c0c0, GR_WHITE = 0x00ffffff;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
#define GR_COLOR_CHAR 1 // ASCII 1 and (r,g,b) changes current text color in string.
2024-04-16 03:43:29 +00:00
// MACROS
2024-04-16 18:56:40 +00:00
inline ddgr_color GR_RGB(int r, int g, int b) { return ((r << 16) + (g << 8) + b); }
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
inline ushort GR_RGB16(int r, int g, int b) { return (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)); }
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
inline ushort GR_COLOR_TO_16(ddgr_color c) {
int r, g, b;
r = ((c & 0x00ff0000) >> 16);
g = ((c & 0x0000ff00) >> 8);
b = (c & 0x000000ff);
return (ushort)(((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3));
2024-04-16 03:43:29 +00:00
}
2024-04-16 18:56:40 +00:00
inline int GR_COLOR_RED(ddgr_color c) {
int r = ((c & 0x00ff0000) >> 16);
return (int)r;
2024-04-16 03:43:29 +00:00
}
2024-04-16 18:56:40 +00:00
inline int GR_COLOR_GREEN(ddgr_color c) {
int g = ((c & 0x0000ff00) >> 8);
return (int)g;
2024-04-16 03:43:29 +00:00
}
2024-04-16 18:56:40 +00:00
inline int GR_COLOR_BLUE(ddgr_color c) {
int b = (c & 0x000000ff);
return (int)b;
2024-04-16 03:43:29 +00:00
}
2024-04-16 18:56:40 +00:00
inline ddgr_color GR_16_TO_COLOR(ushort col) {
int r, g, b;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
r = (col & 0x7c00) >> 7;
g = (col & 0x03e0) >> 2;
b = (col & 0x001f) << 3;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
return GR_RGB(r, g, b);
2024-04-16 03:43:29 +00:00
}
#endif