The Build Engine

- Main Page
- Classes
- Files

- File List
- File Members

display.h
1 /*
2 * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
3 * Ken Silverman's official web site: "http://www.advsys.net/ken"
4 * See the included license file "BUILDLIC.TXT" for license info.
5 * This file IS NOT A PART OF Ken Silverman's original release
6 */
7
8 #ifndef _INCLUDE_DISPLAY_H_
9 #define _INCLUDE_DISPLAY_H_
10
11 #include "platform.h"
12
13 #if (defined PLATFORM_SUPPORTS_SDL)
14 #include "SDL.h"
15
16 /* environment variables names... */
17 /* These are only honored by the SDL driver. */
18 #define BUILD_NOMOUSEGRAB "BUILD_NOMOUSEGRAB"
19 #define BUILD_WINDOWED "BUILD_WINDOWED"
20 #define BUILD_SDLDEBUG "BUILD_SDLDEBUG"
21 #define BUILD_RENDERER "BUILD_RENDERER"
22 #define BUILD_GLLIBRARY "BUILD_GLLIBRARY"
23 #define BUILD_USERSCREENRES "BUILD_USERSCREENRES"
24 #define BUILD_MAXSCREENRES "BUILD_MAXSCREENRES"
25 #define BUILD_HALLOFMIRRORS "BUILD_HALLOFMIRRORS"
26 #define BUILD_GLDUMP "BUILD_GLDUMP"
27 #define BUILD_SDLJOYSTICK "BUILD_SDLJOYSTICK"
28
29 /* This part sucks. */
30 #if (defined __WATCOMC__)
31 #pragma aux (__cdecl) SDL_Init;
32 #pragma aux (__cdecl) SDL_PumpEvents;
33 #pragma aux (__cdecl) SDL_PollEvent;
34 #pragma aux (__cdecl) SDL_GetMouseState;
35 #pragma aux (__cdecl) SDL_WM_GrabInput;
36 #pragma aux (__cdecl) SDL_GetError;
37 #pragma aux (__cdecl) SDL_SetEventFilter;
38 #pragma aux (__cdecl) SDL_WM_SetCaption;
39 #pragma aux (__cdecl) SDL_ClearError;
40 #pragma aux (__cdecl) SDL_SetVideoMode;
41 #pragma aux (__cdecl) SDL_ClearError;
42 #pragma aux (__cdecl) SDL_Quit;
43 #pragma aux (__cdecl) SDL_QuitSubSystem;
44 #pragma aux (__cdecl) SDL_GetTicks;
45 #pragma aux (__cdecl) SDL_GetVideoInfo;
46 #pragma aux (__cdecl) SDL_ListModes;
47 #pragma aux (__cdecl) SDL_SetColors;
48 #pragma aux (__cdecl) SDL_ShowCursor;
49 #pragma aux (__cdecl) SDL_LockSurface;
50 #pragma aux (__cdecl) SDL_UnlockSurface;
51 #pragma aux (__cdecl) SDL_FillRect;
52 #pragma aux (__cdecl) SDL_Delay;
53 #pragma aux (__cdecl) SDL_AddTimer;
54 #pragma aux (__cdecl) SDL_RemoveTimer;
55 #pragma aux (__cdecl) SDL_Flip;
56 #pragma aux (__cdecl) SDL_UpdateRect;
57 #pragma aux (__cdecl) SDL_GetVideoSurface;
58 #pragma aux (__cdecl) SDL_VideoDriverName;
59 #pragma aux (__cdecl) SDL_SetPalette;
60 #pragma aux (__cdecl) SDL_VideoModeOK;
61 #pragma aux (__cdecl) SDL_GetClipRect;
62 #pragma aux (__cdecl) SDL_SetClipRect;
63 #pragma aux (__cdecl) SDL_WM_ToggleFullScreen;
64 #pragma aux (__cdecl) SDL_Linked_Version;
65 #endif /* defined __WATCOMC__ */
66
67 #endif /* defined PLATFORM_SUPPORTS_SDL */
68
69 /* set these in your _platform_init() implementation. */
70 extern int _argc;
71 extern char **_argv;
72
73 /* !!! gads, look at all the namespace polution... */
74 extern long xres, yres, bytesperline, imageSize, maxpages;
75 extern char *screen, vesachecked;
76 extern long buffermode, origbuffermode, linearmode;
77 extern char permanentupdate, vgacompatible;
78 extern char moustat;
79 extern long *horizlookup, *horizlookup2, horizycent;
80 extern long oxdimen, oviewingrange, oxyaspect;
81 extern long curbrightness;
82 extern long qsetmode;
83 extern long frameplace, pageoffset, ydim16;
84 extern char textfont[1024], smalltextfont[1024];
85 extern char pow2char[8];
86 extern volatile long stereomode, visualpage, activepage, whiteband, blackband;
87 extern long searchx, searchy;
88 extern long wx1, wy1, wx2, wy2, ydimen;
89 extern long xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale;
90
91 /*
92 * !!! used to be static. If we ever put the original setgamemode() back, this
93 * !!! can be made static again. --ryan.
94 * !!! (Actually, most of these extern declarations used to be static...rcg.)
95 */
96 extern unsigned char permanentlock;
97
98
99 /* these need to be implemented by YOUR driver. */
100 void _platform_init(int argc, char **argv, const char *title, const char *icon);
101 void _idle(void);
102 void _handle_events(void);
103 void *_getVideoBase(void);
104 void initkeys(void);
105 void uninitkeys(void);
106 void _nextpage(void);
107 void _uninitengine(void);
108 void _joystick_init(void);
109 void _joystick_deinit(void);
110 int _joystick_update(void);
111 int _joystick_axis(int axis);
112 int _joystick_hat(int hat);
113 int _joystick_button(int button);
114
115 /*
116 * VESA replacement code: The Unix (not-actually-VESA) version of this is
117 * originally using SDL (Simple Directmedia Layer: http://www.libsdl.org/),
118 * and is stored in sdl_driver.c, but there's no reason another driver
119 * couldn't be dropped in, so long as it implements these functions. Please
120 * reference sdl_driver.c and ves2.h (the original code) for all the nuances
121 * and global variables that need to get set up correctly.
122 */
123 void getvalidvesamodes(void);
124 int VBE_getPalette(long start, long num, char *dapal);
125 int VBE_setPalette(long start, long num, char *palettebuffer);
126 int setvesa(long x, long y);
127 void uninitvesa(void);
128 void setvmode(int mode);
129 unsigned char readpixel(long offset);
130 void drawpixel(long offset, Uint8 pixel);
131 void drawpixels(long offset, Uint16 pixels);
132 void drawpixelses(long offset, Uint32 pixelses);
133 void drawpixel16(long offset);
134 void fillscreen16 (long input1, long input2, long input3);
135 void limitrate(void);
136 void setactivepage(long dapagenum);
137 void clear2dscreen(void);
138 void _updateScreenRect(long x, long y, long w, long h);
139
140 /* mouse/keystuff stuff. Also implemented in sdl_driver.c ... */
141 int setupmouse(void);
142 void readmousexy(short *x, short *y);
143 void readmousebstatus(short *bstatus);
144 void __interrupt __far keyhandler(void);
145 unsigned char _readlastkeyhit(void);
146
147 /* timer krap. */
148 void inittimer(void);
149 void uninittimer(void);
150
151 /* this is implemented in the game, and your driver calls it. */
152 void __interrupt __far timerhandler(void);
153
154 /* resolution inits. sdl_driver.c ... */
155 int _setgamemode(char davidoption, long daxdim, long daydim);
156 void qsetmode640350(void);
157 void qsetmode640480(void);
158
159 unsigned long getticks();
160
161 void drawline16(long XStart, long YStart, long XEnd, long YEnd, char Color);
162 void setcolor16(int i1);
163
164 int using_opengl(void);
165
166 #endif /* _INCLUDE_DISPLAY_H_ */
167
168 /* end of display.h ... */
169
170