1 // SONIC ROBO BLAST 2 2 //----------------------------------------------------------------------------- 3 // Copyright (C) 1993-1996 by id Software, Inc. 4 // Copyright (C) 1998-2000 by DooM Legacy Team. 5 // Copyright (C) 1999-2020 by Sonic Team Junior. 6 // 7 // This program is free software distributed under the 8 // terms of the GNU General Public License, version 2. 9 // See the 'LICENSE' file for more details. 10 //----------------------------------------------------------------------------- 11 /// \file v_video.h 12 /// \brief Gamma correction LUT 13 14 #ifndef __V_VIDEO__ 15 #define __V_VIDEO__ 16 17 #include "doomdef.h" 18 #include "doomtype.h" 19 #include "r_defs.h" 20 21 // 22 // VIDEO 23 // 24 25 // Screen 0 is the screen updated by I_Update screen. 26 // Screen 1 is an extra buffer. 27 28 extern UINT8 *screens[5]; 29 30 extern consvar_t cv_ticrate, cv_constextsize, 31 cv_globalgamma, cv_globalsaturation, 32 cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue, 33 cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma, 34 cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation; 35 36 // Allocates buffer screens, call before R_Init. 37 void V_Init(void); 38 39 // Recalculates the viddef (dupx, dupy, etc.) according to the current screen resolution. 40 void V_Recalc(void); 41 42 // Color look-up table 43 #define CLUTINDEX(r, g, b) (((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3) 44 45 typedef struct 46 { 47 boolean init; 48 RGBA_t palette[256]; 49 UINT16 table[0xFFFF]; 50 } colorlookup_t; 51 52 void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors); 53 UINT8 GetColorLUT(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b); 54 UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b); 55 56 // Set the current RGB palette lookup to use for palettized graphics 57 void V_SetPalette(INT32 palettenum); 58 59 void V_SetPaletteLump(const char *pal); 60 61 const char *R_GetPalname(UINT16 num); 62 const char *GetPalette(void); 63 64 extern RGBA_t *pLocalPalette; 65 extern RGBA_t *pMasterPalette; 66 67 void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); 68 69 // Retrieve the ARGB value from a palette color index 70 #define V_GetColor(color) (pLocalPalette[color&0xFF]) 71 #define V_GetMasterColor(color) (pMasterPalette[color&0xFF]) 72 73 // Bottom 8 bits are used for parameter (screen or character) 74 #define V_PARAMMASK 0x000000FF 75 76 // flags hacked in scrn (not supported by all functions (see src)) 77 // patch scaling uses bits 9 and 10 78 #define V_SCALEPATCHSHIFT 8 79 #define V_SCALEPATCHMASK 0x00000300 80 #define V_NOSCALEPATCH 0x00000100 81 #define V_SMALLSCALEPATCH 0x00000200 82 #define V_MEDSCALEPATCH 0x00000300 83 84 // string spacing uses bits 11 and 12 85 #define V_SPACINGMASK 0x00000C00 86 #define V_6WIDTHSPACE 0x00000400 // early 2.1 style spacing, variable widths, 6 character space 87 #define V_OLDSPACING 0x00000800 // Old style spacing, 8 per character 4 per space 88 #define V_MONOSPACE 0x00000C00 // Don't do width checks on characters, all characters 8 width 89 90 // use bits 13-16 for colors 91 // though we only have 7 colors now, perhaps we can introduce 92 // more as needed later 93 #define V_CHARCOLORSHIFT 12 94 #define V_CHARCOLORMASK 0x0000F000 95 // for simplicity's sake, shortcuts to specific colors 96 #define V_MAGENTAMAP 0x00001000 97 #define V_YELLOWMAP 0x00002000 98 #define V_GREENMAP 0x00003000 99 #define V_BLUEMAP 0x00004000 100 #define V_REDMAP 0x00005000 101 #define V_GRAYMAP 0x00006000 102 #define V_ORANGEMAP 0x00007000 103 #define V_SKYMAP 0x00008000 104 #define V_PURPLEMAP 0x00009000 105 #define V_AQUAMAP 0x0000A000 106 #define V_PERIDOTMAP 0x0000B000 107 #define V_AZUREMAP 0x0000C000 108 #define V_BROWNMAP 0x0000D000 109 #define V_ROSYMAP 0x0000E000 110 #define V_INVERTMAP 0x0000F000 111 112 // use bits 17-20 for alpha transparency 113 #define V_ALPHASHIFT 16 114 #define V_ALPHAMASK 0x000F0000 115 // define specific translucencies 116 #define V_10TRANS 0x00010000 117 #define V_20TRANS 0x00020000 118 #define V_30TRANS 0x00030000 119 #define V_40TRANS 0x00040000 120 #define V_TRANSLUCENT 0x00050000 // TRANS50 121 #define V_60TRANS 0x00060000 122 #define V_70TRANS 0x00070000 123 #define V_80TRANS 0x00080000 // used to be V_8020TRANS 124 #define V_90TRANS 0x00090000 125 #define V_HUDTRANSHALF 0x000D0000 126 #define V_HUDTRANS 0x000E0000 // draw the hud translucent 127 #define V_HUDTRANSDOUBLE 0x000F0000 128 // Macros follow 129 #define V_USERHUDTRANSHALF ((10-(cv_translucenthud.value/2))<<V_ALPHASHIFT) 130 #define V_USERHUDTRANS ((10-cv_translucenthud.value)<<V_ALPHASHIFT) 131 #define V_USERHUDTRANSDOUBLE ((10-min(cv_translucenthud.value*2, 10))<<V_ALPHASHIFT) 132 133 #define V_AUTOFADEOUT 0x00100000 // used by CECHOs, automatic fade out when almost over 134 #define V_RETURN8 0x00200000 // 8 pixel return instead of 12 135 #define V_OFFSET 0x00400000 // account for offsets in patches 136 #define V_ALLOWLOWERCASE 0x00800000 // (strings only) allow fonts that have lowercase letters to use them 137 #define V_FLIP 0x00800000 // (patches only) Horizontal flip 138 #define V_CENTERNAMETAG 0x00800000 // (nametag only) center nametag lines 139 140 #define V_SNAPTOTOP 0x01000000 // for centering 141 #define V_SNAPTOBOTTOM 0x02000000 // for centering 142 #define V_SNAPTOLEFT 0x04000000 // for centering 143 #define V_SNAPTORIGHT 0x08000000 // for centering 144 145 #define V_WRAPX 0x10000000 // Don't clamp texture on X (for HW mode) 146 #define V_WRAPY 0x20000000 // Don't clamp texture on Y (for HW mode) 147 148 #define V_NOSCALESTART 0x40000000 // don't scale x, y, start coords 149 #define V_PERPLAYER 0x80000000 // automatically adjust coordinates/scaling for splitscreen mode 150 151 // defines for old functions 152 #define V_DrawPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, s|V_NOSCALESTART|V_NOSCALEPATCH, p, NULL) 153 #define V_DrawTranslucentMappedPatch(x,y,s,p,c) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, s, p, c) 154 #define V_DrawSmallTranslucentMappedPatch(x,y,s,p,c) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, s, p, c) 155 #define V_DrawTinyTranslucentMappedPatch(x,y,s,p,c) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, s, p, c) 156 #define V_DrawMappedPatch(x,y,s,p,c) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, s, p, c) 157 #define V_DrawSmallMappedPatch(x,y,s,p,c) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, s, p, c) 158 #define V_DrawTinyMappedPatch(x,y,s,p,c) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, s, p, c) 159 #define V_DrawScaledPatch(x,y,s,p) V_DrawFixedPatch((x)*FRACUNIT, (y)<<FRACBITS, FRACUNIT, s, p, NULL) 160 #define V_DrawSmallScaledPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, s, p, NULL) 161 #define V_DrawTinyScaledPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, s, p, NULL) 162 #define V_DrawTranslucentPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT, s, p, NULL) 163 #define V_DrawSmallTranslucentPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/2, s, p, NULL) 164 #define V_DrawTinyTranslucentPatch(x,y,s,p) V_DrawFixedPatch((x)<<FRACBITS, (y)<<FRACBITS, FRACUNIT/4, s, p, NULL) 165 #define V_DrawSciencePatch(x,y,s,p,sc) V_DrawFixedPatch(x,y,sc,s,p,NULL) 166 #define V_DrawFixedPatch(x,y,sc,s,p,c) V_DrawStretchyFixedPatch(x,y,sc,sc,s,p,c) 167 void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap); 168 void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); 169 170 void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT16 skincolor); 171 172 // Draw a linear block of pixels into the view buffer. 173 void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const UINT8 *src); 174 175 // draw a pic_t, SCALED 176 void V_DrawScaledPic (INT32 px1, INT32 py1, INT32 scrn, INT32 lumpnum); 177 178 // fill a box with a single color 179 void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c); 180 void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c); 181 // fill a box with a flat as a pattern 182 void V_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatnum); 183 184 // fade down the screen buffer before drawing the menu over 185 void V_DrawFadeScreen(UINT16 color, UINT8 strength); 186 // available to lua over my dead body, which will probably happen in this heat 187 void V_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c, UINT16 color, UINT8 strength); 188 189 void V_DrawFadeConsBack(INT32 plines); 190 void V_DrawPromptBack(INT32 boxheight, INT32 color); 191 192 // draw a single character 193 void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); 194 // draw a single character, but for the chat 195 void V_DrawChatCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed, UINT8 *colormap); 196 197 UINT8 *V_GetStringColormap(INT32 colorflags); 198 199 void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string); 200 201 // wordwrap a string using the hu_font 202 char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string); 203 UINT8 *V_GetStringColormap(INT32 colorflags); 204 205 // draw a string using the hu_font 206 void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string); 207 void V_DrawCenteredString(INT32 x, INT32 y, INT32 option, const char *string); 208 void V_DrawRightAlignedString(INT32 x, INT32 y, INT32 option, const char *string); 209 210 // draw a string using the hu_font, 0.5x scale 211 void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string); 212 void V_DrawCenteredSmallString(INT32 x, INT32 y, INT32 option, const char *string); 213 void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string); 214 215 // draw a string using the tny_font 216 void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string); 217 void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string); 218 void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string); 219 220 // draw a string using the tny_font, 0.5x scale 221 void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); 222 void V_DrawCenteredSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); 223 void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string); 224 225 // draw a string using the hu_font at fixed_t coordinates 226 void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 227 void V_DrawCenteredStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 228 void V_DrawRightAlignedStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 229 230 // draw a string using the hu_font at fixed_t coordinates, 0.5x scale 231 void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 232 void V_DrawCenteredSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 233 void V_DrawRightAlignedSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 234 235 // draw a string using the tny_font at fixed_t coordinates 236 void V_DrawThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 237 void V_DrawCenteredThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 238 void V_DrawRightAlignedThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 239 240 // draw a string using the tny_font at fixed_t coordinates, 0.5x scale 241 void V_DrawSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 242 void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 243 void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string); 244 245 // Draw tall nums, used for menu, HUD, intermission 246 void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num); 247 void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits); 248 void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, UINT8 num); 249 250 // Find string width from lt_font chars 251 INT32 V_LevelNameWidth(const char *string); 252 INT32 V_LevelNameHeight(const char *string); 253 INT16 V_LevelActNumWidth(UINT8 num); // act number width 254 255 void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string); 256 INT32 V_CreditStringWidth(const char *string); 257 258 // Draw a string using the nt_font 259 void V_DrawNameTag(INT32 x, INT32 y, INT32 option, fixed_t scale, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string); 260 INT32 V_CountNameTagLines(const char *string); 261 INT32 V_NameTagWidth(const char *string); 262 263 // Find string width from hu_font chars 264 INT32 V_StringWidth(const char *string, INT32 option); 265 // Find string width from hu_font chars, 0.5x scale 266 INT32 V_SmallStringWidth(const char *string, INT32 option); 267 // Find string width from tny_font chars 268 INT32 V_ThinStringWidth(const char *string, INT32 option); 269 // Find string width from tny_font chars, 0.5x scale 270 INT32 V_SmallThinStringWidth(const char *string, INT32 option); 271 272 void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param); 273 274 void V_DrawPatchFill(patch_t *pat); 275 276 void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, 277 size_t destrowbytes); 278 279 #endif 280