]> 4ch.mooo.com Git - 16.git/blob - 16/cawat/ID_VW.H
wwww
[16.git] / 16 / cawat / ID_VW.H
1 /* Catacomb Armageddon Source Code\r
2  * Copyright (C) 1993-2014 Flat Rock Software\r
3  *\r
4  * This program is free software; you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation; either version 2 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * This program is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License along\r
15  * with this program; if not, write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
17  */\r
18 \r
19 // ID_VW.H\r
20 \r
21 #ifndef __TYPES__\r
22 #include "ID_TYPES.H"\r
23 #endif\r
24 \r
25 #ifndef __ID_MM__\r
26 #include "ID_MM.H"\r
27 #endif\r
28 \r
29 #ifndef __ID_GLOB__\r
30 #include "ID_GLOB.H"\r
31 #endif\r
32 \r
33 #define __ID_VW__\r
34 \r
35 //===========================================================================\r
36 \r
37 #define G_P_SHIFT               4       // global >> ?? = pixels\r
38 \r
39 #if GRMODE == EGAGR\r
40 #define SCREENWIDTH             40\r
41 #define CHARWIDTH               1\r
42 #define TILEWIDTH               2\r
43 #define GRPLANES                4\r
44 #define BYTEPIXELS              8\r
45 #endif\r
46 \r
47 #if GRMODE == CGAGR\r
48 #define SCREENWIDTH             128\r
49 #define CHARWIDTH               2\r
50 #define TILEWIDTH               4\r
51 #define GRPLANES                1\r
52 #define BYTEPIXELS              4\r
53 #endif\r
54 \r
55 #define VIRTUALHEIGHT   300\r
56 #define VIRTUALWIDTH    512\r
57 \r
58 \r
59 #if GRMODE == CGAGR\r
60 \r
61 #define MAXSHIFTS               1\r
62 \r
63 #define WHITE                   3                       // graphics mode independant colors\r
64 #define BLACK                   0\r
65 #define FIRSTCOLOR              1\r
66 #define SECONDCOLOR             2\r
67 #define F_WHITE                 0                       // for XOR font drawing\r
68 #define F_BLACK                 3\r
69 #define F_FIRSTCOLOR    2\r
70 #define F_SECONDCOLOR   1\r
71 \r
72 #endif\r
73 \r
74 #if GRMODE == EGAGR\r
75 \r
76 #define MAXSHIFTS               4\r
77 \r
78 #define WHITE                   15                      // graphics mode independant colors\r
79 #define BLACK                   0\r
80 #define LT_GREY         7\r
81 #define FIRSTCOLOR              1\r
82 #define SECONDCOLOR             12\r
83 #define F_WHITE                 0                       // for XOR font drawing\r
84 #define F_BLACK                 15\r
85 #define F_FIRSTCOLOR    14\r
86 #define F_SECONDCOLOR   3\r
87 \r
88 #endif\r
89 \r
90 #if GRMODE == EGAGR\r
91 #define SCREENXMASK             (~7)\r
92 #define SCREENXPLUS             (7)\r
93 #define SCREENXDIV              (8)\r
94 #endif\r
95 \r
96 #if GRMODE == CGAGR\r
97 #define SCREENXMASK             (~3)\r
98 #define SCREENXDIV              (4)\r
99 #endif\r
100 \r
101 //===========================================================================\r
102 \r
103 \r
104 #define SC_INDEX        0x3C4\r
105 #define SC_RESET        0\r
106 #define SC_CLOCK        1\r
107 #define SC_MAPMASK      2\r
108 #define SC_CHARMAP      3\r
109 #define SC_MEMMODE      4\r
110 \r
111 #define CRTC_INDEX      0x3D4\r
112 #define CRTC_H_TOTAL    0\r
113 #define CRTC_H_DISPEND  1\r
114 #define CRTC_H_BLANK    2\r
115 #define CRTC_H_ENDBLANK 3\r
116 #define CRTC_H_RETRACE  4\r
117 #define CRTC_H_ENDRETRACE 5\r
118 #define CRTC_V_TOTAL    6\r
119 #define CRTC_OVERFLOW   7\r
120 #define CRTC_ROWSCAN    8\r
121 #define CRTC_MAXSCANLINE 9\r
122 #define CRTC_CURSORSTART 10\r
123 #define CRTC_CURSOREND  11\r
124 #define CRTC_STARTHIGH  12\r
125 #define CRTC_STARTLOW   13\r
126 #define CRTC_CURSORHIGH 14\r
127 #define CRTC_CURSORLOW  15\r
128 #define CRTC_V_RETRACE  16\r
129 #define CRTC_V_ENDRETRACE 17\r
130 #define CRTC_V_DISPEND  18\r
131 #define CRTC_OFFSET     19\r
132 #define CRTC_UNDERLINE  20\r
133 #define CRTC_V_BLANK    21\r
134 #define CRTC_V_ENDBLANK 22\r
135 #define CRTC_MODE       23\r
136 #define CRTC_LINECOMPARE 24\r
137 \r
138 \r
139 #define GC_INDEX        0x3CE\r
140 #define GC_SETRESET     0\r
141 #define GC_ENABLESETRESET 1\r
142 #define GC_COLORCOMPARE 2\r
143 #define GC_DATAROTATE   3\r
144 #define GC_READMAP      4\r
145 #define GC_MODE         5\r
146 #define GC_MISCELLANEOUS 6\r
147 #define GC_COLORDONTCARE 7\r
148 #define GC_BITMASK      8\r
149 \r
150 #define ATR_INDEX       0x3c0\r
151 #define ATR_MODE        16\r
152 #define ATR_OVERSCAN    17\r
153 #define ATR_COLORPLANEENABLE 18\r
154 #define ATR_PELPAN      19\r
155 #define ATR_COLORSELECT 20\r
156 \r
157 #define STATUS_REGISTER_1    0x3da\r
158 \r
159 //===========================================================================\r
160 \r
161 typedef enum {NOcard,MDAcard,CGAcard,EGAcard,MCGAcard,VGAcard,\r
162                   HGCcard=0x80,HGCPcard,HICcard} cardtype;\r
163 \r
164 typedef struct\r
165 {\r
166   int   width,\r
167         height,\r
168         orgx,orgy,\r
169         xl,yl,xh,yh,\r
170         shifts;\r
171 } spritetabletype;\r
172 \r
173 typedef struct\r
174 {\r
175         unsigned        sourceoffset[MAXSHIFTS];\r
176         unsigned        planesize[MAXSHIFTS];\r
177         unsigned        width[MAXSHIFTS];\r
178         byte            data[];\r
179 } spritetype;           // the memptr for each sprite points to this\r
180 \r
181 typedef struct\r
182 {\r
183         int width,height;\r
184 } pictabletype;\r
185 \r
186 \r
187 typedef struct\r
188 {\r
189         int height;\r
190         int location[256];\r
191         char width[256];\r
192 } fontstruct;\r
193 \r
194 \r
195 typedef enum {CGAgr,EGAgr,VGAgr} grtype;\r
196 \r
197 //===========================================================================\r
198 \r
199 extern  cardtype        videocard;              // set by VW_Startup\r
200 extern  grtype          grmode;                 // CGAgr, EGAgr, VGAgr\r
201 \r
202 extern  unsigned        bufferofs;              // hidden port to draw to before displaying\r
203 extern  unsigned        displayofs;             // origin of port on visable screen\r
204 extern  unsigned        panx,pany;              // panning adjustments inside port in pixels\r
205 extern  unsigned        pansx,pansy;\r
206 extern  unsigned        panadjust;              // panx/pany adjusted by screen resolution\r
207 \r
208 extern  unsigned        screenseg;              // normally 0xa000 or buffer segment\r
209 \r
210 extern  unsigned        linewidth;\r
211 extern  unsigned        ylookup[VIRTUALHEIGHT];\r
212 \r
213 extern  boolean         screenfaded;\r
214 extern  char            colors[7][17];  // pallets for fades\r
215 \r
216 extern  pictabletype    _seg *pictable;\r
217 extern  pictabletype    _seg *picmtable;\r
218 extern  spritetabletype _seg *spritetable;\r
219 \r
220 extern  unsigned        fontnumber;             // 0 based font number for drawing\r
221 extern  int                     px,py;\r
222 extern  byte            pdrawmode,fontcolor;\r
223 \r
224 extern  int                     bordercolor;\r
225 \r
226 //\r
227 // asm globals\r
228 //\r
229 \r
230 extern  unsigned        *shifttabletable[8];\r
231 extern  unsigned        bufferwidth,bufferheight,screenspot;    // used by font drawing stuff\r
232 \r
233 \r
234 \r
235 //===========================================================================\r
236 \r
237 \r
238 void    VW_Startup (void);\r
239 void    VW_Shutdown (void);\r
240 \r
241 cardtype        VW_VideoID (void);\r
242 \r
243 //\r
244 // EGA hardware routines\r
245 //\r
246 \r
247 #define EGAWRITEMODE(x) asm{cli;mov dx,GC_INDEX;mov ax,GC_MODE+256*x;out dx,ax;sti;}\r
248 #define EGABITMASK(x) asm{cli;mov dx,GC_INDEX;mov ax,GC_BITMASK+256*x;out dx,ax;sti;}\r
249 #define EGAMAPMASK(x) asm{cli;mov dx,SC_INDEX;mov ax,SC_MAPMASK+x*256;out dx,ax;sti;}\r
250 #define EGAREADMAP(x) asm{cli;mov dx,GC_INDEX;mov ax,GC_READMAP+x*256;out dx,ax;sti;}\r
251 \r
252 void    VW_SetLineWidth(int width);\r
253 void    VW_SetSplitScreen(int width);\r
254 void    VW_SetScreen (unsigned CRTC, unsigned pelpan);\r
255 \r
256 void    VW_SetScreenMode (int grmode);\r
257 void    VW_ClearVideo (int color);\r
258 void    VW_WaitVBL (int number);\r
259 \r
260 void    VW_ColorBorder (int color);\r
261 void    VW_SetPalette(byte *palette);\r
262 void    VW_SetDefaultColors(void);\r
263 void    VW_FadeOut(void);\r
264 void    VW_FadeIn(void);\r
265 void    VW_FadeUp(void);\r
266 void    VW_FadeDown(void);\r
267 \r
268 void    VW_SetAtrReg (int reg, int value);\r
269 \r
270 //\r
271 // block primitives\r
272 //\r
273 \r
274 void VW_MaskBlock(memptr segm,unsigned ofs,unsigned dest,\r
275         unsigned wide,unsigned height,unsigned planesize);\r
276 void VW_MemToScreen(memptr source,unsigned dest,unsigned width,unsigned height);\r
277 void VW_MemToScreen2x(memptr source,unsigned dest,unsigned width,unsigned height);\r
278 void VW_ScreenToMem(unsigned source,memptr dest,unsigned width,unsigned height);\r
279 void VW_ScreenToScreen(unsigned source,unsigned dest,unsigned width,unsigned height);\r
280 \r
281 \r
282 //\r
283 // block addressable routines\r
284 //\r
285 \r
286 void VW_DrawTile8(unsigned x, unsigned y, unsigned tile);\r
287 \r
288 #if GRMODE == EGAGR\r
289 \r
290 #define VW_DrawTile8M(x,y,t) \\r
291         VW_MaskBlock(grsegs[STARTTILE8M],(t)*40,bufferofs+ylookup[y]+(x),1,8,8)\r
292 #define VW_DrawTile16(x,y,t) \\r
293         VW_MemToScreen(grsegs[STARTTILE16+t],bufferofs+ylookup[y]+(x),2,16)\r
294 #define VW_DrawTile16M(x,y,t) \\r
295         VW_MaskBlock(grsegs[STARTTILE16M],(t)*160,bufferofs+ylookup[y]+(x),2,16,32)\r
296 \r
297 #endif\r
298 \r
299 #if GRMODE == CGAGR\r
300 \r
301 #define VW_DrawTile8M(x,y,t) \\r
302         VW_MaskBlock(grsegs[STARTTILE8M],(t)*32,bufferofs+ylookup[y]+(x),2,8,16)\r
303 #define VW_DrawTile16(x,y,t) \\r
304         VW_MemToScreen(grsegs[STARTTILE16+t],bufferofs+ylookup[y]+(x),4,16)\r
305 #define VW_DrawTile16M(x,y,t) \\r
306         VW_MaskBlock(grsegs[STARTTILE16M],(t)*128,bufferofs+ylookup[y]+(x),4,16,64)\r
307 \r
308 #endif\r
309 \r
310 void VW_DrawPic(unsigned x, unsigned y, unsigned chunknum);\r
311 void VW_DrawPic2x(unsigned x, unsigned y, unsigned chunknum);\r
312 void VW_DrawMPic(unsigned x, unsigned y, unsigned chunknum);\r
313 void VW_ClipDrawMPic(unsigned x, int y, unsigned chunknum);\r
314 \r
315 //\r
316 // pixel addressable routines\r
317 //\r
318 void    VW_MeasurePropString (char far *string, word *width, word *height);\r
319 void    VW_MeasureMPropString  (char far *string, word *width, word *height);\r
320 \r
321 void VW_DrawPropString (char far *string);\r
322 void VW_DrawMPropString (char far *string);\r
323 void VW_DrawSprite(int x, int y, unsigned sprite);\r
324 void VW_Plot(unsigned x, unsigned y, unsigned color);\r
325 void VW_Hlin(unsigned xl, unsigned xh, unsigned y, unsigned color);\r
326 void VW_Vlin(unsigned yl, unsigned yh, unsigned x, unsigned color);\r
327 void VW_Bar (unsigned x, unsigned y, unsigned width, unsigned height,\r
328         unsigned color);\r
329 \r
330 //===========================================================================\r
331 \r
332 //\r
333 // Double buffer management routines\r
334 //\r
335 \r
336 void VW_InitDoubleBuffer (void);\r
337 void VW_FixRefreshBuffer (void);\r
338 int      VW_MarkUpdateBlock (int x1, int y1, int x2, int y2);\r
339 void VW_UpdateScreen (void);\r
340 void VW_CGAFullUpdate (void);\r
341 \r
342 //\r
343 // cursor\r
344 //\r
345 \r
346 void VW_ShowCursor (void);\r
347 void VW_HideCursor (void);\r
348 void VW_MoveCursor (int x, int y);\r
349 void VW_SetCursor (int spritenum);\r
350 void VW_FreeCursor (void);\r
351 \r
352 //\r
353 // mode independant routines\r
354 // coordinates in pixels, rounded to best screen res\r
355 // regions marked in double buffer\r
356 //\r
357 \r
358 void VWB_DrawTile8 (int x, int y, int tile);\r
359 void VWB_DrawTile8M (int x, int y, int tile);\r
360 void VWB_DrawTile16 (int x, int y, int tile);\r
361 void VWB_DrawTile16M (int x, int y, int tile);\r
362 void VWB_DrawPic (int x, int y, int chunknum);\r
363 void VWB_DrawMPic(int x, int y, int chunknum);\r
364 void VWB_Bar (int x, int y, int width, int height, int color);\r
365 \r
366 void VWB_DrawPropString  (char far *string);\r
367 void VWB_DrawMPropString (char far *string);\r
368 void VWB_DrawSprite (int x, int y, int chunknum);\r
369 void VWB_Plot (int x, int y, int color);\r
370 void VWB_Hlin (int x1, int x2, int y, int color);\r
371 void VWB_Vlin (int y1, int y2, int x, int color);\r
372 \r
373 void VWL_MeasureString (char far *string, word *width, word *height, fontstruct _seg *font);\r
374 //===========================================================================\r