1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: v_video.h 1543 2020-08-22 02:36:35Z wesleyjohnson $
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 // Portions Copyright (C) 1998-2000 by DooM Legacy Team.
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 //
20 // $Log: v_video.h,v $
21 // Revision 1.11  2003/08/11 13:50:00  hurdler
22 // go final + translucent HUD + fix spawn in net game
23 //
24 // Revision 1.10  2001/05/16 21:21:15  bpereira
25 // no message
26 //
27 // Revision 1.9  2001/04/17 22:26:07  calumr
28 // Initial Mac add
29 //
30 // Revision 1.8  2001/04/01 17:35:07  bpereira
31 // Revision 1.7  2001/02/24 13:35:21  bpereira
32 //
33 // Revision 1.6  2001/01/25 22:15:44  bpereira
34 // added heretic support
35 //
36 // Revision 1.5  2000/11/02 19:49:37  bpereira
37 // Revision 1.4  2000/08/31 14:30:56  bpereira
38 // Revision 1.3  2000/03/29 20:10:50  hurdler
39 // Revision 1.2  2000/02/27 00:42:11  hurdler
40 // Revision 1.1.1.1  2000/02/22 20:32:32  hurdler
41 // Initial import into CVS (v1.29 pr3)
42 //
43 //
44 // DESCRIPTION:
45 //      Gamma correction LUT.
46 //      Functions to draw patches (by post) directly to screen.
47 //      Functions to blit a block to the screen.
48 //
49 //-----------------------------------------------------------------------------
50 
51 
52 #ifndef V_VIDEO_H
53 #define V_VIDEO_H
54 
55 #include "doomdef.h"
56 #include "doomtype.h"
57 #include "r_defs.h"
58   // patch_t
59 #include "command.h"
60   // consvar_t
61 
62 
63 //
64 // VIDEO
65 //
66 
67 // Screen 0 is the screen updated by I_Update screen, (= vid.display).
68 // Screen 1 is an extra buffer, background, status bar.
69 // Screen 2,3 are used for wipes.
70 
71 #define NUMSCREENS    4
72 // someone stuck in an extra screen ptr
73 extern  byte*   screens[NUMSCREENS+1];
74 
75 #ifdef DIRTY_RECT
76 extern  int     dirtybox[4];
77 #endif
78 
79 extern  CV_PossibleValue_t drawmode_sel_t[];  // for menu
80 extern  consvar_t cv_drawmode;
81 extern  consvar_t cv_ticrate;
82 extern  consvar_t cv_darkback;
83 extern  consvar_t cv_con_fontsize;
84 extern  consvar_t cv_msg_fontsize;
85 extern  consvar_t cv_usegamma;
86 // Gamma Funcs
87 extern  consvar_t cv_gammafunc;
88 extern  consvar_t cv_black;	// input to gammafunc
89 extern  consvar_t cv_bright;	// input to gammafunc
90 
91 extern  consvar_t cv_textout;
92 
93 extern byte  set_drawmode;
94 extern byte  drawmode_recalc;
95 extern byte  rendermode_recalc;
96 extern byte  HWR_patchstore;  // patches are stored in HWR format
97 
98 extern const byte num_drawmode_sel;
99 extern byte drawmode_to_drawmode_sel_t[];
100 extern byte drawmode_sel_avail[];
101 #if 0
102 extern const char * rendermode_name[];
103 #endif
104 
105 extern const byte vid_mode_table[2];  // window, fullscreen
106 
107 //  drawmode : drawmode_sel_t
108 byte  V_switch_drawmode( byte drawmode, byte change_config );
109 
110 // Early setup of video controls, register cv_ vars
111 void V_Init_VideoControl( void );
112 
113 // Allocates buffer screens, call before R_Init.
114 // Must be called after every video Init and SetMode
115 void V_Setup_VideoDraw (void);
116 // Setup wad loadable video resources.
117 void V_Setup_Wad_VideoResc(void);
118 
119 // Set the current RGB palette lookup to use for palettized graphics
120 void V_SetPalette( int palettenum );
121 
122 void V_SetPaletteLump( const char *pal );
123 
124 extern RGBA_t  *pLocalPalette;
125 
126 // Retrieve the ARGB value from a palette color index
127 #define V_GetColor(color)  (pLocalPalette[color&0xFF])
128 
129 // Use the built-in font (font1), for Launch (before fonts are loaded)
130 extern byte  use_font1;
131 extern byte  ci_black, ci_white, ci_green, ci_grey;
132 
133 // Font info for spacing lines and text on menus
134 typedef struct {
135    int width, height;
136    int xinc, yinc;
137 } fontinfo_t;
138 
139 fontinfo_t * V_FontInfo( void );
140 
141 // position and width is in src pixels
142 void V_CopyRect ( int srcx, int srcy, int srcscrn,
143                   int width, int height,
144                   int destx, int desty, int destscrn );
145 
146 
147 // V_Drawinfo flags (not uniformly supported by all functions (see src))
148 typedef enum {
149   V_SCREENMASK =         0x0000FF,
150   V_CENTERHORZ =         0x000100,   // center horizontally the whole screen
151   V_CENTERMENU =         0x000200,   // menu centering, vert and horz.
152   V_NOSCALE =            0x004000,   // dont scale x,y, start coords
153                                      // console, statusbar, crosshair, patch
154   V_DRAWINFO =           0x008000,   // enable using drawinfo, where option
155   V_SCALESTART =         0x010000,   // scale x,y, start coords
156   V_SCALEPATCH =         0x020000,   // scale patch
157   V_FINESCALEPATCH =     0x040000,   // fine scale patch by drawfront
158 // effects
159   V_EFFECTMASK =        0xFF00000,
160   V_WHITEMAP =           0x100000,   // draw white (for v_drawstring)
161   V_FLIPPEDPATCH =       0x200000,   // flipped in y
162                                      // finale
163   V_TRANSLUCENTPATCH =   0x400000,   // draw patch translucent
164                                      // statusbar
165 } drawflags_e;
166 
167 typedef struct {
168 // drawing
169     byte * drawp;  // screen buffer, with centering offsets
170     byte * screen_start;  // screen buffer [0]
171     unsigned int  start_offset; // offset, centering
172     // [WDJ] These are unsigned values kept in signed vars.
173     // When unsigned vars are 64 bit multiplied with signed offsets,
174     // it gives large unsigned results, which leads to segfault.
175     // Keep these as signed to prevent sign errors when they are multiplied
176     // by signed patch offsets.
177     int  ybytes;   // dupy * ybytes, bytes per source line
178     int  xbytes;   // dupx * bytepp, bytes per source pixel
179     int  y0bytes;   // bytes per source line per SCALESTART
180     int  x0bytes;   // bytes per source pixel per SCALESTART
181     // Some software draw is using fdupx.
182     float  fdupx, fdupy; // dup pixels per SCALEPATCH
183 #ifdef HWRENDER
184     float  fdupx0, fdupy0;  // dup per SCALESTART
185 #endif
186     byte  dupx, dupy; // dup pixels for some screen sizes, per SCALEPATCH
187     byte  dupx0, dupy0; // dup per SCALESTART
188     fixed_t  y_unitfrac, x_unitfrac;  // per SCALEPATCH
189     byte  screen;
190 // externally setable
191     uint32_t  effectflags;  // special effects
192         // V_WHITEMAP, V_FLIPPEDPATCH, V_TRANSLUCENTPATCH
193 // save/restore
194     uint32_t  screen_effectflags;  // special effects from screenflags
195         // can restore by effectsflags = screen_effectsflags
196     uint32_t  screenflags;   // screen and drawflags_e set by screenflags
197     uint32_t  prev_screenflags;  // for restore
198         // can restore by V_SetupDrawinfo( prev_screenflags );
199 
200     unsigned int  x0bytes_saved, y0bytes_saved;   // saved copy
201 #ifdef HWRENDER
202     float  fdupx0_saved, fdupy0_saved;  // per SCALESTART
203 #endif
204 } drawinfo_t;
205 
206 // current draw info
207 extern drawinfo_t  drawinfo;
208 
209 // Setup drawinfo for draw screen, scaled, and centering
210 // Can use saved V_drawinfo.screenflags or use V_drawinfo.prev_screenflags
211 void V_SetupDraw( uint32_t screenflags );  // screen + drawflags_e
212 
213 
214 // Font draw information.
215 typedef struct {
216     float  scale;  // scale of font 1.0 .. 5.0
217     float  ratio;  // ratio of font sizing, 0.0 .. 1.0
218     unsigned int  xinc, yinc;  // draw fixed sizes, scaled
219     byte   dupx0, dupy0;  // dup for SCALESTART
220     float  fdupx0, fdupy0;  // per SCALESTART
221     byte   font_height;  // unscaled
222 } drawfont_t;
223 
224 // Current draw font info.
225 extern drawfont_t  drawfont;
226 
227 // Setup drawfont for DrawCharacter and DrawString.
228 // Uses V_SetupDraw.
229 //  option : V_SCALESTART
230 void  V_SetupFont( int font_size, fontinfo_t * fip, uint32_t option );
231 
232 
233 //added:03-02-98:like V_DrawPatch, + using a colormap.
234 void V_DrawMappedPatch ( int x, int y,
235                          patch_t*      patch,
236                          byte*         colormap );
237 
238 // Limited by box
239 void V_DrawMappedPatch_Box(int x, int y, patch_t * patch, byte * colormap,
240                            int box_x, int box_y, int box_w, int box_h );
241 
242 // with temp patch load to cache
243 void V_DrawMappedPatch_Name ( int x, int y,
244                               const char*   name,
245                               byte*         colormap );
246 
247 //added:05-02-98:V_DrawPatch scaled 2,3,4 times size and position.
248 // default params : scale patch and scale start
249 void V_DrawScaledPatch ( int x, int y,
250                          patch_t*   patch );
251 
252 // with temp patch load to cache
253 void V_DrawScaledPatch_Name(int x, int y, const char * name );
254 void V_DrawScaledPatch_Num(int x, int y, int patch_num );
255 
256 //added:16-02-98: like V_DrawScaledPatch, plus translucency
257 void V_DrawTranslucentPatch ( int x, int y,
258                               patch_t*  patch );
259 
260 
261 void V_DrawPatch ( int x, int y,
262                    int       scrn,
263                    patch_t*  patch);
264 
265 #if 0
266 // [WDJ] Replaced by VID_BlitLinearScreen and V_CopyRect because
267 // were being used to copy screens
268 
269 // Draw a linear block of pixels into the view buffer.
270 // src: is not a screen
271 void V_DrawBlock ( int x, int y,
272                    int    scrn,
273                    int width, int height,
274                    byte*  src );
275 
276 // Reads a linear block of pixels into the view buffer.
277 // dest: is not a screen
278 void V_GetBlock ( int x, int y,
279                   int    scrn,
280                   int width, int height,
281                   byte*  dest );
282 #endif
283 
284 // draw a pic_t, SCALED
285 void V_DrawScalePic_Num ( int x1, int y1, lumpnum_t lumpnum );
286 
287 // Heretic raw pic
288 void V_DrawRawScreen_Num(int x, int y,
289                          lumpnum_t lumpnum,
290                          int width, int height);
291 
292 #ifdef DIRTY_RECT
293 void V_MarkRect ( int x, int y,
294                   int width, int height );
295 #endif
296 
297 //added:05-02-98: fill a box with a single color
298 // Scaled to vid screen.
299 //  x, y : screen coord.
300 void V_DrawVidFill(int x, int y, int w, int h, byte color);
301 // Scaled to (320,200).
302 void V_DrawFill(int x, int y, int w, int h, byte color);
303 // Scaled by drawinfo.
304 void V_DrawScaledFill(int x, int y, int w, int h, byte color);
305 
306 //  Per drawinfo, scaled, centering.
307 //  For fullscreen, set w=vid.width.
308 //   x, y, w, h : screen coordinates
309 //   scale : 0 .. 15
310 void V_DrawFlatFill(int x, int y, int w, int h, int scale, lumpnum_t flatnum);
311 // Fill entire screen with flat.
312 void V_ScreenFlatFill( lumpnum_t flatnum );
313 
314 //added:10-02-98: fade down the screen buffer before drawing the menu over
315 void V_FadeScreen (void);
316 
317 // Fade the console background with fade alpha and green tint per cv_darkback.
318 //added:20-03-98: test console
319 //   x1, x2, y2 : affected ranges in pixels,  (always y1 = 0)
320 void V_FadeConsBack (int x1, int x2, int y2);
321 
322 //  General Fade Rectangle.
323 //   x1, x2, y2 : affected ranges in pixels,  (always y1 = 0)
324 //   fade_alpha : 1 (no fade) .. 255 (faded)
325 //   fade_index : from fadescreen_draw8, or fadecons_draw8 table
326 //   tint_rgba : added color tint, small color values only
327 void V_FadeRect(int x1, int x2, int y2,
328                 uint32_t fade_alpha, unsigned int fade_index,
329                 uint32_t tint_rgba );
330 
331 //added:20-03-98: draw a single character
332 // Return pixel width.
333 int V_DrawCharacter (int x, int y, byte c);
334 
335 //added:05-02-98: draw a string using the hu_font
336 void V_DrawString (int x, int y, int option, const char* string);
337 
338 // Find string width from hu_font chars
339 int V_StringWidth (const char* string);
340 
341 // Find string height from hu_font chars
342 int V_StringHeight (const char* string);
343 
344 // draw text with fontB (big font)
345 extern lumpnum_t  FontBBaseLump;
346 void V_DrawTextB(const char *text, int x, int y);
347 void V_DrawTextBGray(const char *text, int x, int y);
348 int V_TextBWidth(const char *text);
349 int V_TextBHeight(const char *text);
350 
351 //added:12-02-98:
352 void V_DrawTiltView (byte *viewbuffer);
353 
354 //added:05-04-98: test persp. correction !!
355 void V_DrawPerspView (byte *viewbuffer, int aiming);
356 
357 // width is in bytes (defined by ASM routine)
358 void VID_BlitLinearScreen (byte *srcptr, byte *destptr, int width,
359                            int height, int srcrowbytes, int destrowbytes);
360 
361 // clear to black
362 void V_Clear_Display( void );
363 
364 // [WDJ] 2012-02-06 Draw functions for all bpp, bytepp, and padded lines.
365 
366 // [WDJ] Common calc of the display buffer address for an x and y
367 byte * V_GetDrawAddr( int x, int y );
368 
369 // [WDJ] Draw a palette color to a single pixel
370 void V_DrawPixel(byte * line, int x, byte color);
371 
372 // [WDJ] Draw a palette src to a screen line
373 void V_DrawPixels(byte * line, int x, int count, byte* src);
374 
375 void V_Draw_ticrate_graph( void );
376 
377 // [WDJ] Conversion func to deal with patch_t and MipPatch_t both
378 // being stored as patch_t.
379 // This identifies where in the code the identical fields are used,
380 // and may become a function later if MipPatch_t differs.
381 //   p : may be patch_t or MipPatch_t, depending on rendermode
382 // Returns a patch_t compatible ptr that can access
383 // width, height, topoffset, and leftoffset.
384 #define  V_patch( p )       (p)
385 
386 #endif
387