//************************************************************************** //** //** ## ## ## ## ## #### #### ### ### //** ## ## ## ## ## ## ## ## ## ## #### #### //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## //** ## ## ######## ## ## ## ## ## ## ## ### ## //** ### ## ## ### ## ## ## ## ## ## //** # ## ## # #### #### ## ## //** //** $Id: d_local.h 2243 2007-05-19 21:47:12Z dj_jl $ //** //** Copyright (C) 1999-2006 Jānis Legzdiņš //** //** This program is free software; you can redistribute it and/or //** modify it under the terms of the GNU General Public License //** as published by the Free Software Foundation; either version 2 //** of the License, or (at your option) any later version. //** //** This program is distributed in the hope that it will be useful, //** but WITHOUT ANY WARRANTY; without even the implied warranty of //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //** GNU General Public License for more details. //** //************************************************************************** //** //** Local header for software drawer //** //************************************************************************** #ifndef _D_LOCAL_H #define _D_LOCAL_H // HEADER FILES ------------------------------------------------------------ #include "gamedefs.h" #include "cl_local.h" #include "r_shared.h" // MACROS ------------------------------------------------------------------ //========================================================================== // // Fixed point, 32bit as 16.16. // //========================================================================== #define FRACBITS 16 #define FRACUNIT (1<> 3) & 0x1f)]; } //========================================================================== // // Inlines for 15bpp // //========================================================================== inline vuint32 MakeCol15(vuint8 r, vuint8 g, vuint8 b) { return ((r >> 3) << rshift) | ((g >> 3) << gshift) | ((b >> 3) << bshift); } inline vuint8 GetCol15R(vuint32 col) { return vuint8((col >> rshift) << 3); } inline vuint8 GetCol15G(vuint32 col) { return vuint8((col >> gshift) << 3); } inline vuint8 GetCol15B(vuint32 col) { return vuint8((col >> bshift) << 3); } //========================================================================== // // Inlines for 16bpp // //========================================================================== inline vuint32 MakeCol16(vuint8 r, vuint8 g, vuint8 b) { return ((r >> 3) << rshift) | ((g >> 2) << gshift) | ((b >> 3) << bshift); } inline vuint8 GetCol16R(vuint32 col) { return vuint8((col >> rshift) << 3); } inline vuint8 GetCol16G(vuint32 col) { return vuint8((col >> gshift) << 2); } inline vuint8 GetCol16B(vuint32 col) { return vuint8((col >> bshift) << 3); } //========================================================================== // // Inlines for 32bpp // //========================================================================== inline vuint32 MakeCol32(vuint8 r, vuint8 g, vuint8 b) { return (r << rshift) | (g << gshift) | (b << bshift); } inline vuint8 GetCol32R(vuint32 col) { return vuint8(col >> rshift); } inline vuint8 GetCol32G(vuint32 col) { return vuint8(col >> gshift); } inline vuint8 GetCol32B(vuint32 col) { return vuint8(col >> bshift); } //========================================================================== // // Inlines for colour making // //========================================================================== inline vuint32 MakeCol(vuint8 r, vuint8 g, vuint8 b) { if (ScreenBPP == 8) { return MakeCol8(r, g, b); } if (ScreenBPP == 15) { return MakeCol15(r, g, b); } if (ScreenBPP == 16) { return MakeCol16(r, g, b); } if (ScreenBPP == 32) { return MakeCol32(r, g, b); } return 0; } inline vuint8 GetColR(vuint32 col) { if (ScreenBPP == 15) { return GetCol15R(col); } if (ScreenBPP == 16) { return GetCol16R(col); } if (ScreenBPP == 32) { return GetCol32R(col); } return 0; } inline vuint8 GetColG(vuint32 col) { if (ScreenBPP == 15) { return GetCol15G(col); } if (ScreenBPP == 16) { return GetCol16G(col); } if (ScreenBPP == 32) { return GetCol32G(col); } return 0; } inline vuint8 GetColB(vuint32 col) { if (ScreenBPP == 15) { return GetCol15B(col); } if (ScreenBPP == 16) { return GetCol16B(col); } if (ScreenBPP == 32) { return GetCol32B(col); } return 0; } #endif