1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: screen.h 1543 2020-08-22 02:36:35Z wesleyjohnson $
5 //
6 // Copyright (C) 1998-2000 by DooM Legacy Team.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 //
19 // $Log: screen.h,v $
20 // Revision 1.14  2004/05/16 20:34:47  hurdler
21 //
22 // Revision 1.13  2004/05/16 19:11:44  hurdler
23 // that should fix issues some people were having in 1280x1024 mode (and now support up to 1600x1200)
24 //
25 // Revision 1.12  2003/05/30 22:44:08  hurdler
26 // add checkcvar function to FS
27 //
28 // Revision 1.11  2003/05/04 04:16:25  sburke
29 // Allow 1280x1024 for full-screen video on Solaris.
30 //
31 // Revision 1.10  2002/11/12 00:06:05  ssntails
32 // Support for translated translucent columns in software mode.
33 //
34 // Revision 1.9  2001/05/16 21:21:14  bpereira
35 //
36 // Revision 1.8  2001/04/17 22:26:07  calumr
37 // Initial Mac add
38 //
39 // Revision 1.7  2001/03/13 22:14:20  stroggonmeth
40 // Long time no commit. 3D floors, FraggleScript, portals, ect.
41 //
42 // Revision 1.6  2001/01/25 22:15:44  bpereira
43 // added heretic support
44 //
45 // Revision 1.5  2000/11/02 19:49:37  bpereira
46 // Revision 1.4  2000/08/31 14:30:56  bpereira
47 //
48 // Revision 1.3  2000/04/22 20:27:35  metzgermeister
49 // support for immediate fullscreen switching
50 //
51 // Revision 1.2  2000/02/27 00:42:11  hurdler
52 // Revision 1.1.1.1  2000/02/22 20:32:32  hurdler
53 // Initial import into CVS (v1.29 pr3)
54 //
55 //
56 // DESCRIPTION:
57 //
58 //-----------------------------------------------------------------------------
59 
60 
61 #ifndef SCREEN_H
62 #define SCREEN_H
63 
64 #include "doomdef.h"
65   // HORIZONTALDRAW
66 #include "doomtype.h"
67 #include "command.h"
68   // consvar_t
69 #include "i_video.h"
70   // modenum_t
71 
72 
73 // Size of statusbar.
74 #define ST_HEIGHT    32
75 #define ST_WIDTH     320
76 // Heretic, status bar height at bottom of screen.
77 #define H_STBAR_HEIGHT   42
78 
79 
80 extern int stbar_height;   // status bar, may be scaled
81 
82 //added:20-01-98: used now as a maximum video mode size for extra vesa modes.
83 
84 // we try to re-allocate a minimum of buffers for stability of the memory,
85 // so all the small-enough tables based on screen size, are allocated once
86 // and for all at the maximum size.
87 #define MAXVIDWIDTH    1600
88 #define MAXVIDHEIGHT   1200
89 
90 #define BASEVIDWIDTH    320   //NEVER CHANGE THIS! this is the original
91 #define BASEVIDHEIGHT   200  // resolution of the graphics.
92 
93 
94 // WDJ 2012-2-6, provide structure to complete the draw capability
95 // optimized for test speed, array indexing
96 typedef enum {
97   DRAW8PAL, DRAW15, DRAW16, DRAW24, DRAW32, DRAWGL
98 } sw_drawmode_e;
99 
100 
101 // WDJ 2012-2-6, Provide structure and isolation of driver problems.
102 // Mac has padded video buffers, some drivers can provide direct access and
103 // some cannot, some have 15, 24, or 32 bpp drawing.
104 // [WDJ] do not need union, minimal wastage, do not make access difficult
105 // global video state
106 typedef struct viddef_s
107 {
108     // If hardware allows direct access then display could be video memory,
109     // but usually is in buffer allocation.  Decided by driver.
110     // Horz. scanlines could be padded (Mac).
111     // Screens have same size as display, and same padding.
112     byte      * display;         // buffer that gets displayed, screen[0]
113     byte      * screen1;         // allocated memory screen[1]
114 
115  // Display and screen drawing with correct padding.
116  // Sometimes is not the same as direct_size.
117  // Use these, they are corrected for padded scanlines and multibyte pixels
118     unsigned int screen_size;    // screens and display
119  // [WDJ] These are unsigned values, kept in signed vars.
120  // When unsigned vars are 64 bit multiplied with signed offsets,
121  // it gives large unsigned results, which leads to segfault.
122  // Keep these as signed to prevent sign errors when they are multiplied
123  // by signed parameters.
124     int   widthbytes;     // width * bytepp, to save multiplies
125     int   ybytes;         // addr line = & display[ y * ybytes ]
126 
127  // basic video mode attributes
128  // [WDJ] signed width, height for easy math, (draw errors if unsigned)
129     int         width;          // PIXELS per scanline
130     int         height;
131     int         bytepp;          // BYTES per pixel: 1=256color, 2, 4
132     modenum_t   modenum;         // vidmode num, same as setmodeneeded
133     byte        drawmode;        // drawing mode, optimized for tables and switch stmts, drawmode_e
134     byte        bitpp;		 // BITS per pixel: 8, 15, 16, 24, 32
135     byte        numpages;        // always 1, PAGE FLIPPING TODO!!!
136 //    byte        windowed;        // windowed or fullscreen mode ?
137     byte        fullscreen;      // windowed or fullscreen mode ?
138     byte        recalc;          // if true, recalc vid-based stuff
139     byte        draw_ready;      // true after vid and buffers are setup
140  // special uses
141     int         dupx,dupy;       // scale 1,2,3 value for menus & overlays
142     float       fdupx,fdupy;     // same as dupx,dupy but exact value when aspect ratio isn't 320/200
143     float       fx_center,fy_center; // half width height
144     float       fx_scale2,fy_scale2; // 2.0 / width, 2.0 / height
145     int         centerofs;       // centering for the scaled menu gfx
146 
147     //int         baseratio;       // SoM: Used to get the correct value for lighting walls //Hurdler: not used anymore
148  // PRIVATE TO DRIVER
149     byte        *buffer;         // allocated invisible buffers
150     byte        *direct;         // linear frame buffer, or vga base mem.
151     unsigned int direct_rowbytes; // bytes per scanline of the VIDEO mode
152     unsigned int direct_size;    // correct size for copy (up to 6400x4800x64)
153  // END PRIVATE
154 } viddef_t;
155 
156 // [WDJ] Do not hide what these are, it makes it more difficult to track effects.
157 //#define VIDWIDTH    vid.width
158 //#define VIDHEIGHT   vid.height
159 
160 
161 // internal additional info for vesa modes only
162 typedef struct {
163     int         vesamode;         // vesa mode number plus LINEAR_MODE bit
164     void        *linearmem;      // linear address of start of frame buffer
165 } vesa_extra_t;
166 // a video modes from the video modes list,
167 typedef struct vmode_s {
168 
169     struct vmode_s  *next;
170     char         *name;
171     unsigned int width;
172     unsigned int height;
173     unsigned int rowbytes;          //bytes per scanline
174     byte         bytesperpixel;     // 1 for 256c, 2 for highcolor
175     byte         modetype;          // from modetype_e
176     byte         numpages;
177     vesa_extra_t *extradata;       //vesa mode extra data
178     int          (*setmode_func)(viddef_t *lvid, struct vmode_s *pcurrentmode);
179     int          misc;              //misc for display driver (r_glide.dll etc)
180 } vmode_t;
181 
182 
183 // [WDJ] definitions for 15bpp, 16bpp, 24bpp, 32bpp
184 
185 typedef struct {
186 #ifdef __BIG_ENDIAN__
187    byte r, g, b;
188 #else
189    byte b, g, r;
190 #endif
191 } pixel24_t;
192 
193 typedef struct {
194 #ifdef __BIG_ENDIAN__
195    byte alpha, r, g, b;
196 #else
197    byte b, g, r, alpha;
198 #endif
199 } pixel32_t;
200 
201 typedef union {
202    uint32_t      ui32;
203    pixel24_t     pix24;  // for speed, does not line up with pix32
204    struct {
205 #ifdef __BIG_ENDIAN__
206       byte unused;
207       pixel24_t  rgb24;
208 #else
209       pixel24_t  rgb24;  // aligns with pix32, rgb
210       byte unused;
211 #endif
212    } s24;
213    pixel32_t     pix32;
214 } pixelunion32_t;
215 
216 // hicolor masks  15 bit / 16 bit
217 extern uint16_t mask_01111, mask_01110, mask_11110, mask_11100, mask_11000;
218 extern uint16_t mask_r, mask_g, mask_b, mask_rb;
219 extern byte     shift_r, shift_g, shift_b;
220 
221 // ---------------------------------------------
222 // color mode dependent drawer function pointers
223 // ---------------------------------------------
224 
225 extern void     (*skycolfunc) (void);
226 extern void     (*colfunc) (void);
227 #ifdef HORIZONTALDRAW
228 extern void     (*hcolfunc) (void);    //Fab 17-06-98
229 #endif
230 extern void     (*basecolfunc) (void);
231 extern void     (*fuzzcolfunc) (void);  // fuzzy
232 extern void     (*skincolfunc) (void);  // skin translated
233 extern void     (*transcolfunc) (void);  // translucent
234 extern void     (*skintranscolfunc) (void); // SSNTails 11-11-2002
235 extern void     (*shadecolfunc) (void);
236 extern void     (*fogcolfunc) (void);
237 #ifdef ENABLE_DRAW_ALPHA
238 extern void     (*alpha_colfunc) (void);
239 #endif
240 extern void     (*spanfunc) (void);
241 extern void     (*basespanfunc) (void);
242 extern void     (*fogspanfunc) (void);
243 extern void     (*transspanfunc) (void);
244 
245 
246 // ----------------
247 // screen variables
248 // ----------------
249 extern viddef_t vid;
250 
251 // mode numbers
252 extern modenum_t  setmodeneeded;   // mode number to set
253 // mode index 0 is NULL, when passed does default (INITIAL_WINDOW_WIDTH)
254 
255 extern byte*  scr_borderflat;  // flat used to fill the view borders
256 
257 extern consvar_t cv_scr_width;
258 extern consvar_t cv_scr_height;
259 extern consvar_t cv_scr_depth;
260 extern consvar_t cv_fullscreen;
261 
262 extern consvar_t cv_fuzzymode;
263 
264 // quick fix for tall/short skies, depending on bytesperpixel
265 extern void (*skydrawerfunc[2]) (void);
266 
267 #ifdef PARNOIA
268 void SCR_Set_dummy_draw(void);
269 #endif
270 
271 // Change video mode, only at the start of a refresh.
272 void SCR_SetMode( byte change_flag );
273 // Recalc screen size dependent stuff
274 void SCR_Recalc (void);
275 // Apply config or command line settings.
276 void SCR_apply_video_settings( void );
277 // Set the mode number which is saved in the config
278 void SCR_SetDefaultMode (void);
279 
280 void SCR_Startup (void);
281 
282 void SCR_ChangeFullscreen (void);
283 
284 #endif // SCREEN_H
285