1 // SONIC ROBO BLAST 2 2 //----------------------------------------------------------------------------- 3 // Copyright (C) 1998-2000 by DooM Legacy Team. 4 // Copyright (C) 1999-2020 by Sonic Team Junior. 5 // 6 // This program is free software distributed under the 7 // terms of the GNU General Public License, version 2. 8 // See the 'LICENSE' file for more details. 9 //----------------------------------------------------------------------------- 10 /// \file screen.h 11 /// \brief Handles multiple resolutions, 8bpp/16bpp(highcolor) modes 12 13 #ifndef __SCREEN_H__ 14 #define __SCREEN_H__ 15 16 #include "command.h" 17 18 #if defined (_WIN32) && !defined (__CYGWIN__) 19 #define RPC_NO_WINDOWS_H 20 #include <windows.h> 21 #define DNWH HWND 22 #else 23 #define DNWH void * // unused in DOS version 24 #endif 25 26 // quickhack for V_Init()... to be cleaned up 27 #ifdef NOPOSTPROCESSING 28 #define NUMSCREENS 2 29 #else 30 #define NUMSCREENS 5 31 #endif 32 33 // Size of statusbar. 34 #define ST_HEIGHT 32 35 #define ST_WIDTH 320 36 37 // used now as a maximum video mode size for extra vesa modes. 38 39 // we try to re-allocate a minimum of buffers for stability of the memory, 40 // so all the small-enough tables based on screen size, are allocated once 41 // and for all at the maximum size. 42 #define MAXVIDWIDTH 1920 // don't set this too high because actually 43 #define MAXVIDHEIGHT 1200 // lots of tables are allocated with the MAX size. 44 #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original 45 #define BASEVIDHEIGHT 200 // resolution of the graphics. 46 47 // global video state 48 typedef struct viddef_s 49 { 50 INT32 modenum; // vidmode num indexes videomodes list 51 52 UINT8 *buffer; // invisible screens buffer 53 size_t rowbytes; // bytes per scanline of the VIDEO mode 54 INT32 width; // PIXELS per scanline 55 INT32 height; 56 union { // don't need numpages for OpenGL, so we can use it for fullscreen/windowed mode 57 INT32 numpages; // always 1, page flipping todo 58 INT32 windowed; // windowed or fullscren mode? 59 } u; 60 INT32 recalc; // if true, recalc vid-based stuff 61 UINT8 *direct; // linear frame buffer, or vga base mem. 62 INT32 dupx, dupy; // scale 1, 2, 3 value for menus & overlays 63 INT32/*fixed_t*/ fdupx, fdupy; // same as dupx, dupy, but exact value when aspect ratio isn't 320/200 64 INT32 bpp; // BYTES per pixel: 1 = 256color, 2 = highcolor 65 66 INT32 baseratio; // Used to get the correct value for lighting walls 67 68 // for Win32 version 69 DNWH WndParent; // handle of the application's window 70 UINT8 smalldupx, smalldupy; // factor for a little bit of scaling 71 UINT8 meddupx, meddupy; // factor for moderate, but not full, scaling 72 #ifdef HWRENDER 73 INT32/*fixed_t*/ fsmalldupx, fsmalldupy; 74 INT32/*fixed_t*/ fmeddupx, fmeddupy; 75 INT32 glstate; 76 #endif 77 } viddef_t; 78 79 enum 80 { 81 VID_GL_LIBRARY_NOTLOADED = 0, 82 VID_GL_LIBRARY_LOADED = 1, 83 VID_GL_LIBRARY_ERROR = -1, 84 }; 85 86 // internal additional info for vesa modes only 87 typedef struct 88 { 89 INT32 vesamode; // vesa mode number plus LINEAR_MODE bit 90 void *plinearmem; // linear address of start of frame buffer 91 } vesa_extra_t; 92 // a video modes from the video modes list, 93 // note: video mode 0 is always standard VGA320x200. 94 typedef struct vmode_s 95 { 96 struct vmode_s *pnext; 97 char *name; 98 UINT32 width, height; 99 UINT32 rowbytes; // bytes per scanline 100 UINT32 bytesperpixel; // 1 for 256c, 2 for highcolor 101 INT32 windowed; // if true this is a windowed mode 102 INT32 numpages; 103 vesa_extra_t *pextradata; // vesa mode extra data 104 #ifdef _WIN32 105 INT32 (WINAPI *setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); 106 #else 107 INT32 (*setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); 108 #endif 109 INT32 misc; // misc for display driver (r_opengl.dll etc) 110 } vmode_t; 111 112 #define NUMSPECIALMODES 4 113 extern vmode_t specialmodes[NUMSPECIALMODES]; 114 115 // --------------------------------------------- 116 // color mode dependent drawer function pointers 117 // --------------------------------------------- 118 119 #define BASEDRAWFUNC 0 120 121 enum 122 { 123 COLDRAWFUNC_BASE = BASEDRAWFUNC, 124 COLDRAWFUNC_FUZZY, 125 COLDRAWFUNC_TRANS, 126 COLDRAWFUNC_SHADE, 127 COLDRAWFUNC_SHADOWED, 128 COLDRAWFUNC_TRANSTRANS, 129 COLDRAWFUNC_TWOSMULTIPATCH, 130 COLDRAWFUNC_TWOSMULTIPATCHTRANS, 131 COLDRAWFUNC_FOG, 132 133 COLDRAWFUNC_MAX 134 }; 135 136 extern void (*colfunc)(void); 137 extern void (*colfuncs[COLDRAWFUNC_MAX])(void); 138 139 enum 140 { 141 SPANDRAWFUNC_BASE = BASEDRAWFUNC, 142 SPANDRAWFUNC_TRANS, 143 SPANDRAWFUNC_TILTED, 144 SPANDRAWFUNC_TILTEDTRANS, 145 146 SPANDRAWFUNC_SPLAT, 147 SPANDRAWFUNC_TRANSSPLAT, 148 SPANDRAWFUNC_TILTEDSPLAT, 149 150 SPANDRAWFUNC_SPRITE, 151 SPANDRAWFUNC_TRANSSPRITE, 152 SPANDRAWFUNC_TILTEDSPRITE, 153 SPANDRAWFUNC_TILTEDTRANSSPRITE, 154 155 SPANDRAWFUNC_WATER, 156 SPANDRAWFUNC_TILTEDWATER, 157 158 SPANDRAWFUNC_FOG, 159 160 SPANDRAWFUNC_MAX 161 }; 162 163 extern void (*spanfunc)(void); 164 extern void (*spanfuncs[SPANDRAWFUNC_MAX])(void); 165 extern void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); 166 167 // ----- 168 // CPUID 169 // ----- 170 extern boolean R_ASM; 171 extern boolean R_486; 172 extern boolean R_586; 173 extern boolean R_MMX; 174 extern boolean R_3DNow; 175 extern boolean R_MMXExt; 176 extern boolean R_SSE2; 177 178 // ---------------- 179 // screen variables 180 // ---------------- 181 extern viddef_t vid; 182 extern INT32 setmodeneeded; // mode number to set if needed, or 0 183 extern UINT8 setrenderneeded; 184 185 void SCR_ChangeRenderer(void); 186 187 extern CV_PossibleValue_t cv_renderer_t[]; 188 189 extern INT32 scr_bpp; 190 extern UINT8 *scr_borderpatch; // patch used to fill the view borders 191 192 extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_fullscreen; 193 // wait for page flipping to end or not 194 extern consvar_t cv_vidwait; 195 196 // Initialize the screen 197 void SCR_Startup(void); 198 199 // Change video mode, only at the start of a refresh. 200 void SCR_SetMode(void); 201 202 // Set drawer functions for Software 203 void SCR_SetDrawFuncs(void); 204 205 // Recalc screen size dependent stuff 206 void SCR_Recalc(void); 207 208 // Check parms once at startup 209 void SCR_CheckDefaultMode(void); 210 211 // Set the mode number which is saved in the config 212 void SCR_SetDefaultMode(void); 213 214 FUNCMATH boolean SCR_IsAspectCorrect(INT32 width, INT32 height); 215 216 // move out to main code for consistency 217 void SCR_DisplayTicRate(void); 218 void SCR_ClosedCaptions(void); 219 void SCR_DisplayLocalPing(void); 220 void SCR_DisplayMarathonInfo(void); 221 #undef DNWH 222 #endif //__SCREEN_H__ 223