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-2021 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 r_draw.h 12 /// \brief Low-level span/column drawer functions 13 14 #ifndef __R_DRAW__ 15 #define __R_DRAW__ 16 17 #include "r_defs.h" 18 19 // ------------------------------- 20 // COMMON STUFF FOR 8bpp AND 16bpp 21 // ------------------------------- 22 extern UINT8 *ylookup[MAXVIDHEIGHT*4]; 23 extern UINT8 *ylookup1[MAXVIDHEIGHT*4]; 24 extern UINT8 *ylookup2[MAXVIDHEIGHT*4]; 25 extern INT32 columnofs[MAXVIDWIDTH*4]; 26 extern UINT8 *topleft; 27 28 // ------------------------- 29 // COLUMN DRAWING CODE STUFF 30 // ------------------------- 31 32 extern lighttable_t *dc_colormap; 33 extern INT32 dc_x, dc_yl, dc_yh; 34 extern fixed_t dc_iscale, dc_texturemid; 35 extern UINT8 dc_hires; 36 37 extern UINT8 *dc_source; // first pixel in a column 38 39 // translucency stuff here 40 extern UINT8 *dc_transmap; 41 42 // translation stuff here 43 44 extern UINT8 *dc_translation; 45 46 extern struct r_lightlist_s *dc_lightlist; 47 extern INT32 dc_numlights, dc_maxlights; 48 49 //Fix TUTIFRUTI 50 extern INT32 dc_texheight; 51 52 // ----------------------- 53 // SPAN DRAWING CODE STUFF 54 // ----------------------- 55 56 extern INT32 ds_y, ds_x1, ds_x2; 57 extern lighttable_t *ds_colormap; 58 extern lighttable_t *ds_translation; 59 60 extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; 61 extern INT32 ds_waterofs, ds_bgofs; 62 63 extern UINT16 ds_flatwidth, ds_flatheight; 64 extern boolean ds_powersoftwo; 65 66 extern UINT8 *ds_source; 67 extern UINT8 *ds_transmap; 68 69 typedef struct { 70 float x, y, z; 71 } floatv3_t; 72 73 // Vectors for Software's tilted slope drawers 74 extern floatv3_t *ds_su, *ds_sv, *ds_sz; 75 extern floatv3_t *ds_sup, *ds_svp, *ds_szp; 76 extern float focallengthf, zeroheight; 77 78 // Variable flat sizes 79 extern UINT32 nflatxshift; 80 extern UINT32 nflatyshift; 81 extern UINT32 nflatshiftup; 82 extern UINT32 nflatmask; 83 84 /// \brief Top border 85 #define BRDR_T 0 86 /// \brief Bottom border 87 #define BRDR_B 1 88 /// \brief Left border 89 #define BRDR_L 2 90 /// \brief Right border 91 #define BRDR_R 3 92 /// \brief Topleft border 93 #define BRDR_TL 4 94 /// \brief Topright border 95 #define BRDR_TR 5 96 /// \brief Bottomleft border 97 #define BRDR_BL 6 98 /// \brief Bottomright border 99 #define BRDR_BR 7 100 101 extern lumpnum_t viewborderlump[8]; 102 103 // ------------------------------------------------ 104 // r_draw.c COMMON ROUTINES FOR BOTH 8bpp and 16bpp 105 // ------------------------------------------------ 106 107 #define GTC_CACHE 1 108 109 enum 110 { 111 TC_BOSS = INT8_MIN, 112 TC_METALSONIC, // For Metal Sonic battle 113 TC_ALLWHITE, // For Cy-Brak-demon 114 TC_RAINBOW, // For single colour 115 TC_BLINK, // For item blinking, according to kart 116 TC_DASHMODE, // For Metal Sonic's dashmode 117 118 TC_DEFAULT 119 }; 120 121 // Custom player skin translation 122 // Initialize color translation tables, for player rendering etc. 123 UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags); 124 void R_FlushTranslationColormapCache(void); 125 UINT16 R_GetColorByName(const char *name); 126 UINT16 R_GetSuperColorByName(const char *name); 127 128 extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] 129 130 enum 131 { 132 blendtab_add, 133 blendtab_subtract, 134 blendtab_reversesubtract, 135 blendtab_modulate, 136 NUMBLENDMAPS 137 }; 138 139 extern UINT8 *blendtables[NUMBLENDMAPS]; 140 141 void R_InitTranslucencyTables(void); 142 void R_GenerateBlendTables(void); 143 144 UINT8 *R_GetTranslucencyTable(INT32 alphalevel); 145 UINT8 *R_GetBlendTable(int style, INT32 alphalevel); 146 147 boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel); 148 149 // Color ramp modification should force a recache 150 extern UINT8 skincolor_modified[]; 151 152 void R_InitViewBuffer(INT32 width, INT32 height); 153 void R_InitViewBorder(void); 154 void R_VideoErase(size_t ofs, INT32 count); 155 156 // Rendering function. 157 #if 0 158 void R_FillBackScreen(void); 159 160 // If the view size is not full screen, draws a border around it. 161 void R_DrawViewBorder(void); 162 #endif 163 164 #define TRANSPARENTPIXEL 255 165 166 // ----------------- 167 // 8bpp DRAWING CODE 168 // ----------------- 169 170 void R_DrawColumn_8(void); 171 void R_DrawShadeColumn_8(void); 172 void R_DrawTranslucentColumn_8(void); 173 void R_DrawTranslatedColumn_8(void); 174 void R_DrawTranslatedTranslucentColumn_8(void); 175 void R_Draw2sMultiPatchColumn_8(void); 176 void R_Draw2sMultiPatchTranslucentColumn_8(void); 177 void R_DrawFogColumn_8(void); 178 void R_DrawColumnShadowed_8(void); 179 180 #define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) 181 182 void R_DrawSpan_8(void); 183 void R_DrawTranslucentSpan_8(void); 184 void R_DrawTiltedSpan_8(void); 185 void R_DrawTiltedTranslucentSpan_8(void); 186 187 void R_DrawSplat_8(void); 188 void R_DrawTranslucentSplat_8(void); 189 void R_DrawTiltedSplat_8(void); 190 191 void R_DrawFloorSprite_8(void); 192 void R_DrawTranslucentFloorSprite_8(void); 193 void R_DrawTiltedFloorSprite_8(void); 194 void R_DrawTiltedTranslucentFloorSprite_8(void); 195 196 void R_CalcTiltedLighting(fixed_t start, fixed_t end); 197 extern INT32 tiltlighting[MAXVIDWIDTH]; 198 199 void R_DrawTranslucentWaterSpan_8(void); 200 void R_DrawTiltedTranslucentWaterSpan_8(void); 201 202 void R_DrawFogSpan_8(void); 203 204 // Lactozilla: Non-powers-of-two 205 void R_DrawSpan_NPO2_8(void); 206 void R_DrawTranslucentSpan_NPO2_8(void); 207 void R_DrawTiltedSpan_NPO2_8(void); 208 void R_DrawTiltedTranslucentSpan_NPO2_8(void); 209 210 void R_DrawSplat_NPO2_8(void); 211 void R_DrawTranslucentSplat_NPO2_8(void); 212 void R_DrawTiltedSplat_NPO2_8(void); 213 214 void R_DrawFloorSprite_NPO2_8(void); 215 void R_DrawTranslucentFloorSprite_NPO2_8(void); 216 void R_DrawTiltedFloorSprite_NPO2_8(void); 217 void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void); 218 219 void R_DrawTranslucentWaterSpan_NPO2_8(void); 220 void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void); 221 222 #ifdef USEASM 223 void ASMCALL R_DrawColumn_8_ASM(void); 224 void ASMCALL R_DrawShadeColumn_8_ASM(void); 225 void ASMCALL R_DrawTranslucentColumn_8_ASM(void); 226 void ASMCALL R_Draw2sMultiPatchColumn_8_ASM(void); 227 228 void ASMCALL R_DrawColumn_8_MMX(void); 229 230 void ASMCALL R_Draw2sMultiPatchColumn_8_MMX(void); 231 void ASMCALL R_DrawSpan_8_MMX(void); 232 #endif 233 234 // ------------------ 235 // 16bpp DRAWING CODE 236 // ------------------ 237 238 #ifdef HIGHCOLOR 239 void R_DrawColumn_16(void); 240 void R_DrawWallColumn_16(void); 241 void R_DrawTranslucentColumn_16(void); 242 void R_DrawTranslatedColumn_16(void); 243 void R_DrawSpan_16(void); 244 #endif 245 246 // ========================================================================= 247 #endif // __R_DRAW__ 248