2007-01-29 01:18:16 +00:00
|
|
|
// Base services interface declaration
|
|
|
|
// for the Build Engine
|
2012-03-12 04:47:04 +00:00
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2016-03-14 00:07:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef baselayer_h_
|
|
|
|
#define baselayer_h_
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2008-02-16 22:27:08 +00:00
|
|
|
#include "compat.h"
|
2008-07-24 11:16:20 +00:00
|
|
|
#include "osd.h"
|
2019-08-13 14:44:16 +00:00
|
|
|
#include "timer.h"
|
2008-02-16 22:27:08 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
2007-01-29 01:18:16 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-08-27 01:41:04 +00:00
|
|
|
extern int app_main(int argc, char const * const * argv);
|
2014-07-06 22:38:02 +00:00
|
|
|
extern const char* AppProperName;
|
|
|
|
extern const char* AppTechnicalName;
|
|
|
|
|
2014-01-19 20:17:14 +00:00
|
|
|
#ifdef DEBUGGINGAIDS
|
|
|
|
# define DEBUG_MASK_DRAWING
|
|
|
|
extern int32_t g_maskDrawMode;
|
|
|
|
#endif
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
extern char quitevent, appactive;
|
2016-06-21 00:33:39 +00:00
|
|
|
extern char modechange;
|
2019-09-08 01:01:22 +00:00
|
|
|
extern char nogl;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t vsync;
|
2019-08-29 20:06:31 +00:00
|
|
|
extern int32_t r_borderless;
|
|
|
|
extern int32_t r_displayindex;
|
2008-07-22 21:03:09 +00:00
|
|
|
|
2012-11-25 04:26:37 +00:00
|
|
|
extern void app_crashhandler(void);
|
|
|
|
|
2006-07-01 01:40:18 +00:00
|
|
|
// NOTE: these are implemented in game-land so they may be overridden in game specific ways
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t startwin_open(void);
|
|
|
|
extern int32_t startwin_close(void);
|
|
|
|
extern int32_t startwin_puts(const char *);
|
|
|
|
extern int32_t startwin_settitle(const char *);
|
|
|
|
extern int32_t startwin_idle(void *);
|
2014-11-26 04:39:23 +00:00
|
|
|
extern int32_t startwin_run(void);
|
2006-07-01 01:40:18 +00:00
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
// video
|
2010-10-17 14:49:39 +00:00
|
|
|
extern int32_t r_usenewaspect, newaspect_enable;
|
2019-07-06 16:30:18 +00:00
|
|
|
extern int32_t r_fpgrouscan;
|
2012-08-16 21:48:56 +00:00
|
|
|
extern int32_t setaspect_new_use_dimen;
|
2010-10-17 14:49:39 +00:00
|
|
|
extern uint32_t r_screenxy;
|
2019-08-27 13:39:54 +00:00
|
|
|
extern int32_t xres, yres, bpp, fullscreen, bytesperline, refreshfreq;
|
2008-02-16 22:27:08 +00:00
|
|
|
extern intptr_t frameplace;
|
2007-01-29 01:18:16 +00:00
|
|
|
extern char offscreenrendering;
|
2015-02-11 05:22:48 +00:00
|
|
|
extern int32_t nofog;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2012-12-14 19:28:17 +00:00
|
|
|
void calc_ylookup(int32_t bpl, int32_t lastyidx);
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
int32_t videoCheckMode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t forced);
|
|
|
|
int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs);
|
|
|
|
void videoGetModes(void);
|
|
|
|
void videoResetMode(void);
|
|
|
|
void videoEndDrawing(void);
|
|
|
|
void videoShowFrame(int32_t);
|
|
|
|
int32_t videoUpdatePalette(int32_t start, int32_t num);
|
|
|
|
int32_t videoSetGamma(void);
|
|
|
|
int32_t videoSetVsync(int32_t newSync);
|
|
|
|
|
|
|
|
//#define DEBUG_FRAME_LOCKING
|
|
|
|
#if !defined DEBUG_FRAME_LOCKING
|
|
|
|
void videoBeginDrawing(void);
|
|
|
|
#else
|
|
|
|
void begindrawing_real(void);
|
|
|
|
# define BEGINDRAWING_SIZE 256
|
|
|
|
extern uint32_t begindrawing_line[BEGINDRAWING_SIZE];
|
|
|
|
extern const char *begindrawing_file[BEGINDRAWING_SIZE];
|
|
|
|
extern int32_t lockcount;
|
|
|
|
# define videoBeginDrawing() do { \
|
|
|
|
if (lockcount < BEGINDRAWING_SIZE) { \
|
|
|
|
begindrawing_line[lockcount] = __LINE__; \
|
|
|
|
begindrawing_file[lockcount] = __FILE__; \
|
|
|
|
} \
|
|
|
|
begindrawing_real(); \
|
|
|
|
} while(0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern float g_videoGamma, g_videoContrast, g_videoBrightness;
|
|
|
|
|
|
|
|
#define DEFAULT_GAMMA 1.0f
|
|
|
|
#define DEFAULT_CONTRAST 1.0f
|
|
|
|
#define DEFAULT_BRIGHTNESS 0.0f
|
|
|
|
|
|
|
|
#define GAMMA_CALC ((int32_t)(min(max((float)((g_videoGamma - 1.0f) * 10.0f), 0.f), 15.f)))
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
#ifdef USE_OPENGL
|
2018-11-18 18:06:15 +00:00
|
|
|
extern int32_t (*baselayer_osdcmd_vidmode_func)(osdcmdptr_t parm);
|
|
|
|
extern int osdcmd_glinfo(osdcmdptr_t parm);
|
2008-02-24 00:46:57 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
struct glinfo_t {
|
2007-01-29 01:18:16 +00:00
|
|
|
const char *vendor;
|
|
|
|
const char *renderer;
|
|
|
|
const char *version;
|
|
|
|
const char *extensions;
|
|
|
|
|
2009-09-30 01:26:13 +00:00
|
|
|
float maxanisotropy;
|
|
|
|
char bgra;
|
|
|
|
char clamptoedge;
|
|
|
|
char texcompr;
|
|
|
|
char texnpot;
|
|
|
|
char multisample;
|
|
|
|
char nvmultisamplehint;
|
2007-01-29 01:18:16 +00:00
|
|
|
char arbfp;
|
|
|
|
char depthtex;
|
|
|
|
char shadow;
|
|
|
|
char fbos;
|
|
|
|
char rect;
|
|
|
|
char multitex;
|
|
|
|
char envcombine;
|
2007-03-08 03:07:10 +00:00
|
|
|
char vbos;
|
2008-07-22 21:03:09 +00:00
|
|
|
char vsync;
|
2009-02-05 08:56:59 +00:00
|
|
|
char sm4;
|
2009-09-30 01:26:13 +00:00
|
|
|
char occlusionqueries;
|
|
|
|
char glsl;
|
2011-10-02 05:56:35 +00:00
|
|
|
char debugoutput;
|
2015-07-15 08:23:00 +00:00
|
|
|
char bufferstorage;
|
2018-02-16 06:38:48 +00:00
|
|
|
char sync;
|
2019-07-05 21:17:52 +00:00
|
|
|
char depthclamp;
|
|
|
|
char clipcontrol;
|
2008-02-24 00:46:57 +00:00
|
|
|
char dumped;
|
2007-01-29 01:18:16 +00:00
|
|
|
};
|
2009-07-09 02:29:48 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
extern struct glinfo_t glinfo;
|
2007-01-29 01:18:16 +00:00
|
|
|
#endif
|
2018-11-18 18:06:43 +00:00
|
|
|
|
|
|
|
vec2_t CONSTEXPR const g_defaultVideoModes []
|
2018-11-18 18:13:25 +00:00
|
|
|
= { { 2560, 1440 }, { 2560, 1200 }, { 2560, 1080 }, { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, { 1680, 1050 },
|
2018-11-18 18:06:43 +00:00
|
|
|
{ 1600, 1200 }, { 1600, 900 }, { 1366, 768 }, { 1280, 1024 }, { 1280, 960 }, { 1280, 720 }, { 1152, 864 },
|
|
|
|
{ 1024, 768 }, { 1024, 600 }, { 800, 600 }, { 640, 480 }, { 640, 400 }, { 512, 384 }, { 480, 360 },
|
|
|
|
{ 400, 300 }, { 320, 240 }, { 320, 200 }, { 0, 0 } };
|
2018-04-12 21:02:31 +00:00
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
extern char inputdevices;
|
|
|
|
|
|
|
|
// keys
|
2014-05-17 12:36:40 +00:00
|
|
|
#define NUMKEYS 256
|
2007-01-29 01:18:16 +00:00
|
|
|
#define KEYFIFOSIZ 64
|
2018-11-18 18:06:43 +00:00
|
|
|
|
2018-11-18 18:13:25 +00:00
|
|
|
char CONSTEXPR const g_keyAsciiTable[128] = {
|
2018-11-18 18:06:43 +00:00
|
|
|
0 , 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0, 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
|
|
|
|
'[', ']', 0, 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 39, '`', 0, 92, 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',',
|
|
|
|
'.', '/', 0, '*', 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6',
|
|
|
|
'+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
};
|
2010-05-25 10:56:00 +00:00
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
char CONSTEXPR const g_keyAsciiTableShift[128] = {
|
|
|
|
0 , 0, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 0, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P',
|
|
|
|
'{', '}', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<',
|
|
|
|
'>', '?', 0, '*', 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6',
|
|
|
|
'+', '1', '2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
};
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
extern char keystatus[NUMKEYS];
|
|
|
|
extern char g_keyFIFO[KEYFIFOSIZ];
|
|
|
|
extern char g_keyAsciiFIFO[KEYFIFOSIZ];
|
|
|
|
extern uint8_t g_keyAsciiPos;
|
|
|
|
extern uint8_t g_keyAsciiEnd;
|
|
|
|
extern uint8_t g_keyFIFOend;
|
|
|
|
extern char g_keyRemapTable[NUMKEYS];
|
|
|
|
extern char g_keyNameTable[NUMKEYS][24];
|
2011-03-04 07:04:42 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
extern int32_t keyGetState(int32_t key);
|
|
|
|
extern void keySetState(int32_t key, int32_t state);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
// mouse
|
2018-04-12 21:02:31 +00:00
|
|
|
extern vec2_t g_mousePos;
|
|
|
|
extern vec2_t g_mouseAbs;
|
|
|
|
extern int32_t g_mouseBits;
|
|
|
|
extern uint8_t g_mouseClickState;
|
|
|
|
extern bool g_mouseGrabbed;
|
|
|
|
extern bool g_mouseEnabled;
|
|
|
|
extern bool g_mouseInsideWindow;
|
|
|
|
extern bool g_mouseLockedToWindow;
|
|
|
|
|
2014-12-27 18:36:43 +00:00
|
|
|
enum
|
|
|
|
{
|
2018-04-12 21:02:31 +00:00
|
|
|
MOUSE_IDLE = 0,
|
|
|
|
MOUSE_PRESSED,
|
|
|
|
MOUSE_HELD,
|
|
|
|
MOUSE_RELEASED,
|
2014-12-27 18:36:43 +00:00
|
|
|
};
|
2018-04-12 21:02:31 +00:00
|
|
|
extern int32_t mouseAdvanceClickState(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
// joystick
|
2018-04-12 21:02:31 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int32_t *pAxis;
|
|
|
|
int32_t *pHat;
|
|
|
|
void (*pCallback)(int32_t, int32_t);
|
|
|
|
int32_t bits;
|
|
|
|
int32_t numAxes;
|
|
|
|
int32_t numButtons;
|
|
|
|
int32_t numHats;
|
2019-08-12 15:23:15 +00:00
|
|
|
int32_t isGameController;
|
2018-04-12 21:02:31 +00:00
|
|
|
} controllerinput_t;
|
|
|
|
|
|
|
|
extern controllerinput_t joystick;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t qsetmode;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2013-08-24 22:55:49 +00:00
|
|
|
#define in3dmode() (qsetmode==200)
|
2013-05-30 09:13:32 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t initsystem(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
void uninitsystem(void);
|
2013-10-08 10:00:25 +00:00
|
|
|
void system_getcvars(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
extern int32_t g_logFlushWindow;
|
2014-07-24 14:01:44 +00:00
|
|
|
void initputs(const char *);
|
|
|
|
#define buildputs initputs
|
2010-12-19 22:47:10 +00:00
|
|
|
void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
|
2014-07-24 14:01:44 +00:00
|
|
|
#define buildprintf initprintf
|
2010-12-19 22:47:10 +00:00
|
|
|
void debugprintf(const char *,...) ATTRIBUTE((format(printf,1,2)));
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t handleevents(void);
|
2012-09-15 15:28:30 +00:00
|
|
|
int32_t handleevents_peekkeys(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
extern void (*keypresscallback)(int32_t,int32_t);
|
2018-04-12 21:02:31 +00:00
|
|
|
extern void (*g_mouseCallback)(int32_t,int32_t);
|
2010-05-25 10:56:00 +00:00
|
|
|
|
2019-08-14 15:28:59 +00:00
|
|
|
int32_t initinput(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
void uninitinput(void);
|
2018-04-12 21:02:31 +00:00
|
|
|
void keySetCallback(void (*callback)(int32_t,int32_t));
|
|
|
|
void mouseSetCallback(void (*callback)(int32_t,int32_t));
|
|
|
|
void joySetCallback(void (*callback)(int32_t,int32_t));
|
|
|
|
const char *keyGetName(int32_t num);
|
|
|
|
const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat
|
2019-08-14 03:03:52 +00:00
|
|
|
void joyScanDevices(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
char keyGetScan(void);
|
2018-04-12 21:02:31 +00:00
|
|
|
char keyGetChar(void);
|
|
|
|
#define keyBufferWaiting() (g_keyAsciiPos != g_keyAsciiEnd)
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
static FORCE_INLINE int keyBufferFull(void)
|
2013-10-27 21:12:13 +00:00
|
|
|
{
|
2018-04-12 21:02:31 +00:00
|
|
|
return ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1)) == g_keyAsciiPos;
|
2013-10-27 21:12:13 +00:00
|
|
|
}
|
|
|
|
|
2018-04-12 21:02:31 +00:00
|
|
|
static FORCE_INLINE void keyBufferInsert(char code)
|
2013-10-27 21:12:13 +00:00
|
|
|
{
|
2018-04-12 21:02:31 +00:00
|
|
|
g_keyAsciiFIFO[g_keyAsciiEnd] = code;
|
|
|
|
g_keyAsciiEnd = ((g_keyAsciiEnd+1)&(KEYFIFOSIZ-1));
|
2013-10-27 21:12:13 +00:00
|
|
|
}
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
void keyFlushScans(void);
|
2018-04-12 21:02:31 +00:00
|
|
|
void keyFlushChars(void);
|
|
|
|
|
2018-11-18 18:08:53 +00:00
|
|
|
void mouseInit(void);
|
2018-04-12 21:02:31 +00:00
|
|
|
void mouseUninit(void);
|
2018-10-16 06:09:20 +00:00
|
|
|
int32_t mouseReadAbs(vec2_t *pResult, vec2_t const *pInput);
|
2018-04-23 06:35:52 +00:00
|
|
|
void mouseGrabInput(bool grab);
|
2018-04-12 21:02:31 +00:00
|
|
|
void mouseLockToWindow(char a);
|
2019-09-19 20:02:45 +00:00
|
|
|
void mouseMoveToCenter(void);
|
2018-11-18 18:08:53 +00:00
|
|
|
int32_t mouseReadButtons(void);
|
2018-04-12 21:02:51 +00:00
|
|
|
void mouseReadPos(int32_t *x, int32_t *y);
|
2018-04-12 21:02:31 +00:00
|
|
|
|
2018-10-16 06:09:20 +00:00
|
|
|
void joyReadButtons(int32_t *pResult);
|
2018-04-12 21:02:31 +00:00
|
|
|
void joySetDeadZone(int32_t axis, uint16_t dead, uint16_t satur);
|
|
|
|
void joyGetDeadZone(int32_t axis, uint16_t *dead, uint16_t *satur);
|
2013-12-20 07:24:09 +00:00
|
|
|
extern int32_t inputchecked;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2014-07-28 06:43:16 +00:00
|
|
|
int32_t wm_msgbox(const char *name, const char *fmt, ...) ATTRIBUTE((format(printf,2,3)));
|
|
|
|
int32_t wm_ynbox(const char *name, const char *fmt, ...) ATTRIBUTE((format(printf,2,3)));
|
|
|
|
void wm_setapptitle(const char *name);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
// baselayer.c
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t baselayer_init();
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2007-10-24 07:12:50 +00:00
|
|
|
void makeasmwriteable(void);
|
2013-01-06 18:56:29 +00:00
|
|
|
void maybe_redirect_outputs(void);
|
2007-10-24 07:12:50 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
2007-01-29 01:18:16 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-05 10:05:07 +00:00
|
|
|
#include "print.h"
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // baselayer_h_
|
2007-01-29 01:18:16 +00:00
|
|
|
|