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
|
|
|
|
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"
|
2008-02-16 22:27:08 +00:00
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
#ifdef EXTERNC
|
2007-01-29 01:18:16 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-07-06 22:38:02 +00:00
|
|
|
extern int32_t app_main(int32_t argc, const char **argv);
|
|
|
|
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;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t vsync;
|
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 *);
|
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;
|
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;
|
2011-09-15 17:03:50 +00:00
|
|
|
extern int32_t xres, yres, bpp, fullscreen, bytesperline;
|
2008-02-16 22:27:08 +00:00
|
|
|
extern intptr_t frameplace;
|
2007-01-29 01:18:16 +00:00
|
|
|
extern char offscreenrendering;
|
|
|
|
|
2012-12-14 19:28:17 +00:00
|
|
|
void calc_ylookup(int32_t bpl, int32_t lastyidx);
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
#ifdef USE_OPENGL
|
2013-08-13 01:07:41 +00:00
|
|
|
extern int32_t (*baselayer_osdcmd_vidmode_func)(const osdfuncparm_t *parm);
|
2013-08-12 15:18:19 +00:00
|
|
|
|
2012-12-10 18:17:44 +00:00
|
|
|
void fullscreen_tint_gl(uint8_t r, uint8_t g, uint8_t b, uint8_t f);
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t osdcmd_glinfo(const osdfuncparm_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;
|
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;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern void setvsync(int32_t sync);
|
2007-01-29 01:18:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern char inputdevices;
|
|
|
|
|
|
|
|
// keys
|
2014-05-17 12:36:40 +00:00
|
|
|
#define NUMKEYS 256
|
2014-01-27 10:30:25 +00:00
|
|
|
#define KEYSTATUSSIZ 256
|
2007-01-29 01:18:16 +00:00
|
|
|
#define KEYFIFOSIZ 64
|
2014-10-29 17:05:15 +00:00
|
|
|
extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyasciififo[KEYFIFOSIZ];
|
|
|
|
extern uint8_t keyasciififoplc, keyasciififoend, keyfifoplc, keyfifoend;
|
2014-05-17 12:36:40 +00:00
|
|
|
extern char scantoasc[128], remap[KEYSTATUSSIZ], key_names[NUMKEYS][24];
|
2010-05-25 10:56:00 +00:00
|
|
|
extern int32_t remapinit;
|
|
|
|
|
2011-03-04 07:04:42 +00:00
|
|
|
extern int32_t defaultres[][2];
|
|
|
|
|
2014-01-27 10:30:25 +00:00
|
|
|
extern int32_t GetKey(int32_t key);
|
2010-05-25 10:56:00 +00:00
|
|
|
extern void SetKey(int32_t key, int32_t state);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
// mouse
|
2014-09-30 04:11:50 +00:00
|
|
|
extern int32_t mousex, mousey, mouseb, mouseabsx, mouseabsy;
|
2014-11-17 07:39:12 +00:00
|
|
|
extern uint8_t mousegrab, moustat, mouseinwindow, AppMouseGrab;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
// joystick
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t *joyaxis, *joyhat, joyb;
|
2007-01-29 01:18:16 +00:00
|
|
|
extern char joyisgamepad, joynumaxes, joynumbuttons, joynumhats;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t joyaxespresent;
|
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
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t flushlogwindow;
|
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);
|
|
|
|
extern void (*mousepresscallback)(int32_t,int32_t);
|
|
|
|
extern void (*joypresscallback)(int32_t,int32_t);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t initinput(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
void uninitinput(void);
|
|
|
|
void releaseallbuttons(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void setkeypresscallback(void (*callback)(int32_t,int32_t));
|
|
|
|
void setmousepresscallback(void (*callback)(int32_t,int32_t));
|
|
|
|
void setjoypresscallback(void (*callback)(int32_t,int32_t));
|
|
|
|
const char *getkeyname(int32_t num);
|
|
|
|
const char *getjoyname(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat
|
|
|
|
|
|
|
|
char bgetchar(void);
|
2010-05-02 23:27:30 +00:00
|
|
|
#define bkbhit() (keyasciififoplc != keyasciififoend)
|
|
|
|
|
2013-10-27 21:12:13 +00:00
|
|
|
static inline int keyascfifo_isfull(void)
|
|
|
|
{
|
|
|
|
return ((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void keyascfifo_insert(char code)
|
|
|
|
{
|
|
|
|
keyasciififo[keyasciififoend] = code;
|
|
|
|
keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1));
|
|
|
|
}
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
void bflushchars(void);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t initmouse(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
void uninitmouse(void);
|
|
|
|
void grabmouse(char a);
|
2014-11-17 07:39:12 +00:00
|
|
|
void AppGrabMouse(char a);
|
2009-01-09 09:29:17 +00:00
|
|
|
void readmousexy(int32_t *x, int32_t *y);
|
2014-11-17 07:39:12 +00:00
|
|
|
int32_t readmouseabsxy(int32_t *x, int32_t *y);
|
2009-01-09 09:29:17 +00:00
|
|
|
void readmousebstatus(int32_t *b);
|
2012-06-03 16:11:22 +00:00
|
|
|
void readjoybstatus(int32_t *b);
|
2009-01-09 09:29:17 +00:00
|
|
|
void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur);
|
|
|
|
void getjoydeadzone(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
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t inittimer(int32_t);
|
2007-01-29 01:18:16 +00:00
|
|
|
void uninittimer(void);
|
|
|
|
void sampletimer(void);
|
2014-11-22 12:33:47 +00:00
|
|
|
#ifdef RENDERTYPESDL
|
|
|
|
static inline uint32_t getticks(void) { return (uint32_t)SDL_GetTicks(); }
|
|
|
|
#else
|
2009-01-09 09:29:17 +00:00
|
|
|
uint32_t getticks(void);
|
2014-11-22 12:33:47 +00:00
|
|
|
#endif
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t gettimerfreq(void);
|
2013-07-07 20:59:00 +00:00
|
|
|
uint64_t getu64ticks(void);
|
|
|
|
uint64_t getu64tickspersec(void);
|
2013-07-07 20:59:05 +00:00
|
|
|
double gethiticks(void);
|
2007-01-29 01:18:16 +00:00
|
|
|
void (*installusertimercallback(void (*callback)(void)))(void);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t checkvideomode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t forced);
|
|
|
|
int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs);
|
2007-01-29 01:18:16 +00:00
|
|
|
void getvalidmodes(void);
|
|
|
|
void resetvideomode(void);
|
|
|
|
|
|
|
|
void begindrawing(void);
|
|
|
|
void enddrawing(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void showframe(int32_t);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t setpalette(int32_t start, int32_t num);
|
|
|
|
//int32_t getpalette(int32_t start, int32_t num, char *dapal);
|
|
|
|
int32_t setgamma(void);
|
2014-09-30 04:06:32 +00:00
|
|
|
extern float vid_gamma, vid_contrast, vid_brightness;
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2014-09-30 04:06:32 +00:00
|
|
|
#define DEFAULT_GAMMA 1.0f
|
|
|
|
#define DEFAULT_CONTRAST 1.0f
|
|
|
|
#define DEFAULT_BRIGHTNESS 0.0f
|
2008-07-20 11:03:57 +00:00
|
|
|
|
2014-09-30 04:06:32 +00:00
|
|
|
#define GAMMA_CALC ((int32_t)(min(max((float)((vid_gamma-1.0f)*10.0f),0.f),15.f)))
|
2010-07-03 08:53:57 +00:00
|
|
|
|
2012-05-05 22:23:44 +00:00
|
|
|
//int32_t switchrendermethod(int32_t,int32_t); // 0 = software, 1 = opengl | bool = reinit
|
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
|
|
|
|
2012-11-05 02:49:08 +00:00
|
|
|
#ifdef EXTERNC
|
2007-01-29 01:18:16 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // baselayer_h_
|
2007-01-29 01:18:16 +00:00
|
|
|
|