1 /*
2 
3 Copyright (C) 2015-2018 Night Dive Studios, LLC.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 /*
20  * $Source: r:/prj/cit/src/inc/RCS/frparams.h $
21  * $Revision: 1.3 $
22  * $Author: dc $
23  * $Date: 1994/07/20 23:05:51 $
24  *
25  * Citadel Renderer
26  *  global parameters structures, setting, and defines
27  *
28  * $Log: frparams.h $
29  * Revision 1.3  1994/07/20  23:05:51  dc
30  * odrop
31  *
32  * Revision 1.2  1994/01/30  01:54:53  dc
33  * global lighting
34  *
35  * Revision 1.1  1994/01/02  17:16:32  dc
36  * Initial revision
37  *
38  */
39 
40 #include "frctxt.h"
41 
42 #define TM_SIZE_CNT 3 /* # of different tmap sizes */
43 
44 typedef struct {
45     struct {
46         uchar main : 1;       /* any textures? */
47         uchar wall : 1;       /*  if any, any walls */
48         uchar floor : 1;      /*          any floor */
49         uchar ceiling : 1;    /*          any ceiling */
50         uchar cyber : 1;      /* cyberspace instead */
51         uchar cyber_full : 1; /* full cursors */
52     } faces;
53     struct {
54         uchar highlights : 1; /* tilemap highlights of cones */
55         uchar tilecursor : 1; /* show the tilemap cursor in 3d */
56         uchar nodraw : 1;     /* dont actually render FB */
57     } features;
58     struct {
59 #ifdef C_WERE_SUPER_COOL
60         uchar lighting : 1;   /* any lighting at all? */
61         uchar terrain : 1;    /* terrain light values checked and used? */
62         uchar camera : 1;     /* camera light values used */
63         uchar normal_chk : 1; /* use normal when computing wall lighting */
64 #else
65         uchar flags; /* 0,0,0,0,any,terr,cam,normal */
66 #endif
67         int normal_shf;   /* what to shift normal by when adding to dist */
68         uchar rad[2];     /* inner, outer lighting radius */
69         uchar base[2];    /* inner, outer light values */
70         fix slope;        /* slope and yintercept */
71         fix yint;         /*  of lighting line */
72         short global_mod; /* change to all lighting */
73     } lighting;
74     struct {
75         uchar qscale_obj;             /* radius at which to qscale objects */
76         uchar qscale_crit;            /* radius at which to qscale critters */
77         uchar qscale_texture;         /* radius at which to qscale textures */
78         uchar detail;                 /* detail setting */
79         uchar clear_color;            /* color to clear background too */
80         uchar drop_rad[TM_SIZE_CNT];  /* radii to switch to lower res tmaps */
81         uchar odrop_rad[TM_SIZE_CNT]; /* original (base) drop radii to switch to lower res tmaps */
82         uchar radius;                 /* maximal view radius */
83         uchar show_all : 1;           /* render whole world - no clip */
84         uchar cone_only : 1;          /* no 2 1/2D clip, cone only */
85     } view;
86     struct {
87         long last_chk_time;
88         long last_frame_cnt;
89         long tot_frame_cnt;
90         long last_frame_len;
91     } time;
92 } fauxrend_parameters;
93 
94 #ifndef __FRSETUP_SRC
95 extern fauxrend_parameters _frp;
96 #define get_frp() (_frp)
97 #endif
98 
99 #define LIGHT_BITS_MASK 0xfu
100 #define LIGHT_BITS_ANY 0x8u
101 #define LIGHT_BITS_TERR 0x4u
102 #define LIGHT_BITS_CAM 0x2u
103 #define LIGHT_BITS_NORM 0x1u
104 #define LIGHT_BITS_HOW (LIGHT_BITS_NORM | LIGHT_BITS_CAM | LIGHT_BITS_TERR)
105 
106 #define _frp_light_bits_any() (_frp.lighting.flags & LIGHT_BITS_ANY)
107 #define _frp_light_bits_how() (_frp.lighting.flags & LIGHT_BITS_HOW)
108 #define _frp_light_bits_cam() (_frp.lighting.flags & LIGHT_BITS_CAM)
109 #define _frp_light_bits_norm() (_frp.lighting.flags & LIGHT_BITS_NORM)
110 #define _frp_light_bits_terr() (_frp.lighting.flags & LIGHT_BITS_TERR)
111 
112 #define _frp_light_bits_set(m) (_frp.lighting.flags |= m)
113 #define _frp_light_bits_clear(m) (_frp.lighting.flags &= ~m)
114 #define _frp_light_bits_tog(m)   \
115     if (_frp.lighting.flags | m) \
116     _frp_light_bits_clear(m) else _frp_light_bits_set(m)
117