SRB2/src/screen.h

236 lines
6.2 KiB
C
Raw Normal View History

2014-03-15 16:59:03 +00:00
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1998-2000 by DooM Legacy Team.
2022-03-03 19:24:46 +00:00
// Copyright (C) 1999-2022 by Sonic Team Junior.
2014-03-15 16:59:03 +00:00
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file screen.h
/// \brief Handles multiple resolutions, 8bpp/16bpp(highcolor) modes
#ifndef __SCREEN_H__
#define __SCREEN_H__
#include "command.h"
2017-09-29 22:25:34 +00:00
#if defined (_WIN32) && !defined (__CYGWIN__)
2014-03-15 16:59:03 +00:00
#define RPC_NO_WINDOWS_H
#include <windows.h>
#define DNWH HWND
#else
#define DNWH void * // unused in DOS version
#endif
// quickhack for V_Init()... to be cleaned up
2017-09-29 22:25:34 +00:00
#ifdef NOPOSTPROCESSING
2014-03-15 16:59:03 +00:00
#define NUMSCREENS 2
#else
#define NUMSCREENS 5
#endif
// Size of statusbar.
#define ST_HEIGHT 32
#define ST_WIDTH 320
// used now as a maximum video mode size for extra vesa modes.
// we try to re-allocate a minimum of buffers for stability of the memory,
// so all the small-enough tables based on screen size, are allocated once
// and for all at the maximum size.
#define MAXVIDWIDTH 1920 // don't set this too high because actually
#define MAXVIDHEIGHT 1200 // lots of tables are allocated with the MAX size.
#define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original
#define BASEVIDHEIGHT 200 // resolution of the graphics.
// global video state
typedef struct viddef_s
{
INT32 modenum; // vidmode num indexes videomodes list
UINT8 *buffer; // invisible screens buffer
size_t rowbytes; // bytes per scanline of the VIDEO mode
INT32 width; // PIXELS per scanline
INT32 height;
union { // don't need numpages for OpenGL, so we can use it for fullscreen/windowed mode
INT32 numpages; // always 1, page flipping todo
INT32 windowed; // windowed or fullscren mode?
} u;
INT32 recalc; // if true, recalc vid-based stuff
UINT8 *direct; // linear frame buffer, or vga base mem.
INT32 dupx, dupy; // scale 1, 2, 3 value for menus & overlays
INT32/*fixed_t*/ fdupx, fdupy; // same as dupx, dupy, but exact value when aspect ratio isn't 320/200
INT32 bpp; // BYTES per pixel: 1 = 256color, 2 = highcolor
INT32 baseratio; // Used to get the correct value for lighting walls
// for Win32 version
DNWH WndParent; // handle of the application's window
UINT8 smalldupx, smalldupy; // factor for a little bit of scaling
UINT8 meddupx, meddupy; // factor for moderate, but not full, scaling
#ifdef HWRENDER
INT32/*fixed_t*/ fsmalldupx, fsmalldupy;
INT32/*fixed_t*/ fmeddupx, fmeddupy;
2020-08-15 01:27:16 +00:00
INT32 glstate;
2014-03-15 16:59:03 +00:00
#endif
} viddef_t;
2020-08-15 01:27:16 +00:00
enum
{
VID_GL_LIBRARY_NOTLOADED = 0,
VID_GL_LIBRARY_LOADED = 1,
VID_GL_LIBRARY_ERROR = -1,
};
2014-03-15 16:59:03 +00:00
// internal additional info for vesa modes only
typedef struct
{
INT32 vesamode; // vesa mode number plus LINEAR_MODE bit
void *plinearmem; // linear address of start of frame buffer
} vesa_extra_t;
// a video modes from the video modes list,
// note: video mode 0 is always standard VGA320x200.
typedef struct vmode_s
{
struct vmode_s *pnext;
char *name;
UINT32 width, height;
UINT32 rowbytes; // bytes per scanline
UINT32 bytesperpixel; // 1 for 256c, 2 for highcolor
INT32 windowed; // if true this is a windowed mode
INT32 numpages;
vesa_extra_t *pextradata; // vesa mode extra data
2017-09-29 18:27:17 +00:00
#ifdef _WIN32
2014-03-15 16:59:03 +00:00
INT32 (WINAPI *setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode);
#else
INT32 (*setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode);
#endif
INT32 misc; // misc for display driver (r_opengl.dll etc)
} vmode_t;
#define NUMSPECIALMODES 4
extern vmode_t specialmodes[NUMSPECIALMODES];
// ---------------------------------------------
// color mode dependent drawer function pointers
// ---------------------------------------------
2019-12-13 15:26:47 +00:00
#define BASEDRAWFUNC 0
enum
{
COLDRAWFUNC_BASE = BASEDRAWFUNC,
COLDRAWFUNC_FUZZY,
COLDRAWFUNC_TRANS,
COLDRAWFUNC_SHADE,
COLDRAWFUNC_SHADOWED,
COLDRAWFUNC_TRANSTRANS,
COLDRAWFUNC_TWOSMULTIPATCH,
COLDRAWFUNC_TWOSMULTIPATCHTRANS,
COLDRAWFUNC_FOG,
COLDRAWFUNC_MAX
};
2014-03-15 16:59:03 +00:00
extern void (*colfunc)(void);
2019-12-13 15:26:47 +00:00
extern void (*colfuncs[COLDRAWFUNC_MAX])(void);
enum
{
SPANDRAWFUNC_BASE = BASEDRAWFUNC,
SPANDRAWFUNC_TRANS,
2020-11-05 03:00:08 +00:00
SPANDRAWFUNC_TILTED,
SPANDRAWFUNC_TILTEDTRANS,
2019-12-13 15:26:47 +00:00
SPANDRAWFUNC_SPLAT,
SPANDRAWFUNC_TRANSSPLAT,
2020-11-05 03:00:08 +00:00
SPANDRAWFUNC_TILTEDSPLAT,
SPANDRAWFUNC_SPRITE,
SPANDRAWFUNC_TRANSSPRITE,
2020-10-14 01:42:07 +00:00
SPANDRAWFUNC_TILTEDSPRITE,
SPANDRAWFUNC_TILTEDTRANSSPRITE,
2020-11-05 03:00:08 +00:00
2019-12-13 15:26:47 +00:00
SPANDRAWFUNC_WATER,
SPANDRAWFUNC_TILTEDWATER,
2020-11-05 03:00:08 +00:00
SPANDRAWFUNC_SOLID,
SPANDRAWFUNC_TRANSSOLID,
SPANDRAWFUNC_TILTEDSOLID,
SPANDRAWFUNC_TILTEDTRANSSOLID,
SPANDRAWFUNC_WATERSOLID,
SPANDRAWFUNC_TILTEDWATERSOLID,
2020-11-05 03:00:08 +00:00
SPANDRAWFUNC_FOG,
SPANDRAWFUNC_TILTEDFOG,
2019-12-13 15:26:47 +00:00
SPANDRAWFUNC_MAX
};
2014-03-15 16:59:03 +00:00
extern void (*spanfunc)(void);
2019-12-13 15:26:47 +00:00
extern void (*spanfuncs[SPANDRAWFUNC_MAX])(void);
extern void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void);
2014-03-15 16:59:03 +00:00
// -----
// CPUID
// -----
extern boolean R_ASM;
extern boolean R_486;
extern boolean R_586;
extern boolean R_MMX;
extern boolean R_3DNow;
extern boolean R_MMXExt;
extern boolean R_SSE2;
// ----------------
// screen variables
// ----------------
extern viddef_t vid;
extern INT32 setmodeneeded; // mode number to set if needed, or 0
2020-08-15 01:27:16 +00:00
extern UINT8 setrenderneeded;
extern double averageFPS;
2019-09-09 19:31:30 +00:00
void SCR_ChangeRenderer(void);
2014-03-15 16:59:03 +00:00
extern CV_PossibleValue_t cv_renderer_t[];
2014-03-15 16:59:03 +00:00
extern INT32 scr_bpp;
extern UINT8 *scr_borderpatch; // patch used to fill the view borders
2019-09-08 21:27:35 +00:00
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_fullscreen;
2014-03-15 16:59:03 +00:00
// wait for page flipping to end or not
extern consvar_t cv_vidwait;
extern consvar_t cv_timescale;
2014-03-15 16:59:03 +00:00
2020-08-15 01:27:16 +00:00
// Initialize the screen
void SCR_Startup(void);
2014-03-15 16:59:03 +00:00
// Change video mode, only at the start of a refresh.
void SCR_SetMode(void);
2020-08-15 01:27:16 +00:00
// Set drawer functions for Software
2019-09-08 21:27:35 +00:00
void SCR_SetDrawFuncs(void);
2020-08-15 01:27:16 +00:00
2014-03-15 16:59:03 +00:00
// Recalc screen size dependent stuff
void SCR_Recalc(void);
2020-08-15 01:27:16 +00:00
2014-03-15 16:59:03 +00:00
// Check parms once at startup
void SCR_CheckDefaultMode(void);
2020-08-15 01:27:16 +00:00
// Set the mode number which is saved in the config
void SCR_SetDefaultMode(void);
2014-03-15 16:59:03 +00:00
void SCR_CalculateFPS(void);
2016-06-12 19:58:03 +00:00
FUNCMATH boolean SCR_IsAspectCorrect(INT32 width, INT32 height);
2014-03-15 16:59:03 +00:00
// move out to main code for consistency
void SCR_DisplayTicRate(void);
void SCR_ClosedCaptions(void);
2019-11-18 01:22:47 +00:00
void SCR_DisplayLocalPing(void);
Introducing Marathon Run. (I was going to call it Marathon Mode, but NiGHTS Mode being right next to it on the menu looked terrible.) Basically a dedicated Record Attack-like experience for speedrunning the game as a continuous chunk rather than ILs. Has several quality of life features. Benefits include: * An unambiguous real-time bar across the bottom of the screen, always displaying the current time, ticking up until you reach the ending. * Disable the console (pausing is still allowed, but the timer will still increment). * Automatically skip intermissions as if you're holding down the spin button. * Show centiseconds on HUD automatically, like record attack. * "Live Event Backups" - a category of run fit for major events like GDQ, where recovery from crashes or chokes makes for better entertainment. Essentially a modified SP savefile, down to using the same basic functions, but has its own filename and tweaked internal layout. * "spmarathon_start" MainCfg block parameter and "marathonnext" mapheader parameter, allowing for a customised flow (makes this fit for purpose for an eventual SUGOI port). * Disabling inter-level custom cutscenes by default with a menu option to toggle this (won't show up if the mod doesn't *have* any custom cutscenes), although either way ending cutscenes (vanilla or custom) remain intact since is time is called before them. * Won't show up if you have a mod that consists of only one level (determined by spmarathon_start's nextlevel; this won't trip if you manually set its marathonnext). * Unconditional gratitude on the evaluation screen, instead of a negging "Try again..." if you didn't get all the emeralds (which you may not have been aiming for). * Gorgeous new menu (no new assets required, unless you wanna give it a header later). Changes which were required for the above but affect other areas of the game include: * "useBlackRock" MainCFG block parameter, which can be used to disable the presence of the Black Rock or Egg Rock in both the Evaluation screen and the Marathon Run menu (for total conversions with different stories). * Disabling Continues in NiGHTS mode, to match the most common singleplayer experience post 2.2.4's release (is reverted if useContinues is set to true). * Hiding the exitmove "powerup" outside of multiplayer. (Okay, this isn't really related, I just saw this bug in action a lot while doing test runs and got annoyed enough to fix it here.) * The ability to use V_DrawPromptBack (in hardcode only at the moment, but) to draw in terms of pixels rather than rows of text, by providing negative instead of positive inputs). * A refactoring of redundant game saves smattered across the ending, credits, and evaluation - in addition to saving the game slightly earlier. * Minor m_menu.c touchups and refactorings here and there. Built using feedback from the official server's #speedruns channel, among other places.
2020-05-14 22:10:00 +00:00
void SCR_DisplayMarathonInfo(void);
2014-03-15 16:59:03 +00:00
#undef DNWH
#endif //__SCREEN_H__