DOOM64-RE

DOOM 64 Reverse Engineering
Log | Files | Refs | README | LICENSE

r_local.h (9484B)


      1 /* R_local.h */
      2 
      3 #ifndef __R_LOCAL__
      4 #define __R_LOCAL__
      5 
      6 /* proper screen size would be 160*100, stretched to 224 is 2.2 scale */
      7 #define	STRETCH				(22*FRACUNIT/10)
      8 
      9 #define	CENTERX				(SCREENWIDTH/2)
     10 #define	CENTERY				(SCREENHEIGHT/2)
     11 #define	CENTERXFRAC			(SCREENWIDTH/2*FRACUNIT)
     12 #define	CENTERYFRAC			(SCREENHEIGHT/2*FRACUNIT)
     13 #define	PROJECTION			CENTERXFRAC
     14 
     15 #define	ANGLETOSKYSHIFT		22		/* sky map is 256*128*4 maps */
     16 
     17 #define	BASEYCENTER			100
     18 
     19 #define	CENTERY				(SCREENHEIGHT/2)
     20 #define	WINDOWHEIGHT		(SCREENHEIGHT-SBARHEIGHT)
     21 
     22 #define	MINZ				8
     23 #define	MAXZ				256
     24 
     25 #define	FIELDOFVIEW			2048   /* fineangles in the SCREENWIDTH wide window */
     26 
     27 /* */
     28 /* Seg flags */
     29 /* */
     30 #define SGF_VISIBLE_COLS    1       /* The seg has at least 1 visible (non fully occluded column) */
     31 
     32 
     33 /* */
     34 /* lighting constants */
     35 /* */
     36 #define	LIGHTLEVELS			256		/* number of diminishing */
     37 #define	INVERSECOLORMAP		255
     38 
     39 /*
     40 ==============================================================================
     41 
     42 					INTERNAL MAP TYPES
     43 
     44 ==============================================================================
     45 */
     46 
     47 /*================ used by play and refresh */
     48 
     49 typedef struct
     50 {
     51 	fixed_t	x, y, dx, dy;
     52 } divline_t;
     53 
     54 typedef struct
     55 {
     56 	fixed_t x, y;
     57 	fixed_t vx, vy;
     58 	int     validcount;
     59 } vertex_t;
     60 
     61 struct line_s;
     62 struct subsector_s;
     63 
     64 typedef	struct
     65 {
     66 	fixed_t		floorheight, ceilingheight;
     67 	VINT		floorpic, ceilingpic;	/* if ceilingpic == -1,draw sky */
     68 	int		    colors[5];			// Doom 64 New
     69 	int		    lightlevel;
     70 	VINT		special, tag;
     71 
     72 	VINT        xoffset, yoffset;   // Doom 64 New
     73 
     74 	VINT		soundtraversed;		/* 0 = untraversed, 1,2 = sndlines -1 */
     75 	mobj_t		*soundtarget;		/* thing that made a sound (or null) */
     76 
     77 	VINT	    flags;	            // Psx Doom / Doom 64 New
     78 	VINT		blockbox[4];		/* mapblock bounding box for height changes */
     79 	degenmobj_t	soundorg;			/* for any sounds played by the sector */
     80 
     81 	int			validcount;			/* if == validcount, already checked */
     82 	mobj_t		*thinglist;			/* list of mobjs in sector */
     83 	void		*specialdata;		/* thinker_t for reversable actions */
     84 	VINT		linecount;
     85 	struct line_s	**lines;			/* [linecount] size */
     86 } sector_t;
     87 
     88 typedef struct
     89 {
     90 	fixed_t		textureoffset;		/* add this to the calculated texture col */
     91 	fixed_t		rowoffset;			/* add this to the calculated texture top */
     92 	VINT		toptexture, bottomtexture, midtexture;
     93 	sector_t	*sector;
     94 } side_t;
     95 
     96 typedef enum {ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE} slopetype_t;
     97 
     98 typedef struct line_s
     99 {
    100 	vertex_t	*v1, *v2;
    101 	fixed_t		dx,dy;				/* v2 - v1 for side checking */
    102 	VINT		flags;
    103 	VINT		special, tag;
    104 	VINT		sidenum[2];			/* sidenum[1] will be -1 if one sided */
    105 	fixed_t		bbox[4];
    106 	slopetype_t	slopetype;			/* to aid move clipping */
    107 	sector_t	*frontsector, *backsector;
    108 	int			validcount;			/* if == validcount, already checked */
    109 	void		*specialdata;		/* thinker_t for reversable actions */
    110 	int			fineangle;			/* to get sine / cosine for sliding */
    111 } line_t;
    112 
    113 typedef struct vissprite_s
    114 {
    115     int         zdistance;  //*
    116     mobj_t      *thing;     //*4
    117     int         lump;       //*8
    118     boolean     flip;       //*12
    119     sector_t    *sector;    //*16
    120     struct		vissprite_s *next;//*20
    121 } vissprite_t;
    122 
    123 typedef struct subsector_s
    124 {
    125 	sector_t	*sector;	//*
    126 	vissprite_t *vissprite; //*4
    127 	short		numlines;	//*8
    128 	short		firstline;	//*10
    129 	short       numverts;	//*12
    130 	short       leaf;	    //*14
    131     short       drawindex;	//*16
    132 	short       padding;	//*18
    133 } subsector_t;
    134 
    135 typedef struct seg_s
    136 {
    137 	vertex_t	*v1, *v2;
    138 	fixed_t		offset;
    139 	angle_t		angle;				/* this is not used (keep for padding) */
    140 	side_t		*sidedef;
    141 	line_t		*linedef;
    142 	sector_t	*frontsector;
    143 	sector_t	*backsector;		/* NULL for one sided lines */
    144 	short       flags;
    145 	short       length;
    146 } seg_t;
    147 
    148 typedef struct
    149 {
    150 	//fixed_t		x,y,dx,dy;		//old
    151 	divline_t	line;				/* partition line */
    152 	fixed_t		bbox[2][4];			/* bounding box for each child */
    153 	int			children[2];		/* if NF_SUBSECTOR its a subsector */
    154 } node_t;
    155 
    156 typedef struct {
    157 	vertex_t    *vertex;
    158 	seg_t       *seg;//*(A24 + 4)
    159 } leaf_t;
    160 
    161 //
    162 // Light Data Doom64
    163 //
    164 typedef struct {
    165 	int rgba;
    166 	int tag;
    167 } light_t;
    168 
    169 //
    170 // Macros Doom64
    171 //
    172 typedef struct
    173 {
    174     int id, tag, special;
    175 } macro_t;
    176 
    177 /*
    178 ==============================================================================
    179 
    180 						OTHER TYPES
    181 
    182 ==============================================================================
    183 */
    184 
    185 /* Sprites are patches with a special naming convention so they can be  */
    186 /* recognized by R_InitSprites.  The sprite and frame specified by a  */
    187 /* thing_t is range checked at run time. */
    188 /* a sprite is a patch_t that is assumed to represent a three dimensional */
    189 /* object and may have multiple rotations pre drawn.  Horizontal flipping  */
    190 /* is used to save space. Some sprites will only have one picture used */
    191 /* for all views.   */
    192 
    193 #ifdef MARS
    194 
    195 int spritelump[NUMSPRITES];	/* no rotations, so just add frame num... */
    196 
    197 #else
    198 
    199 typedef struct
    200 {
    201 	boolean		rotate;		/* if false use 0 for any position */
    202 	int			lump[8];	/* lump to use for view angles 0-7 */
    203 	byte		flip[8];	/* flip (1 = flip) to use for view angles 0-7 */
    204 } spriteframe_t;
    205 
    206 typedef struct
    207 {
    208 	spriteframe_t	*spriteframes;
    209 	int				numframes;
    210 } spritedef_t;
    211 
    212 extern	spritedef_t		sprites[NUMSPRITES];
    213 
    214 #endif
    215 
    216 /*
    217 ===============================================================================
    218 
    219 							MAP DATA
    220 
    221 ===============================================================================
    222 */
    223 
    224 extern	int			numvertexes;
    225 extern	vertex_t	*vertexes;
    226 
    227 extern	int			numsegs;
    228 extern	seg_t		*segs;
    229 
    230 extern	int			numsectors;
    231 extern	sector_t	*sectors;
    232 
    233 extern	int			numsubsectors;
    234 extern	subsector_t	*subsectors;
    235 
    236 extern	int			numnodes;
    237 extern	node_t		*nodes;
    238 
    239 extern	int			numlines;
    240 extern	line_t		*lines;
    241 
    242 extern	int			numsides;
    243 extern	side_t		*sides;
    244 
    245 extern	int			numleafs;
    246 extern	leaf_t		*leafs;
    247 
    248 extern light_t      *lights;
    249 extern int          numlights;
    250 
    251 extern macro_t      **macros;
    252 extern int          nummacros;
    253 
    254 //extern int          skyflatnum;
    255 
    256 /*============================================================================= */
    257 
    258 /*------*/
    259 /*R_main*/
    260 /*------*/
    261 extern mobj_t   *cameratarget;  // 800A5D70
    262 extern angle_t  camviewpitch;   // 800A811C
    263 extern fixed_t  scrollfrac;     // 800A812C
    264 extern sector_t *frontsector;   // 800A6340
    265 extern int      globallump;     // 800A68f8
    266 extern int      globalcm;       // 800A68fC
    267 extern int      infraredFactor; // 800A810C
    268 extern int      FlashEnvColor;  // 800A8110
    269 extern fixed_t  quakeviewx;     // 800A8118
    270 extern fixed_t  quakeviewy;     // 800A8114
    271 
    272 /*------*/
    273 /*R_data*/
    274 /*------*/
    275 void	R_InitData (void);
    276 
    277 /*--------*/
    278 /*r_phase1*/
    279 /*--------*/
    280 void	R_BSP (void);
    281 void	R_RenderBSPNode (int bspnum);
    282 
    283 /*--------*/
    284 /*r_phase2*/
    285 /*--------*/
    286 typedef void(*skyfunc_t)();
    287 extern fixed_t  FogNear;            // 800A8120
    288 extern int      FogColor;           // 800A8124
    289 skyfunc_t       R_RenderSKY;        // 800A8130
    290 extern int      Skyfadeback;        // 800A814C
    291 
    292 void R_SetupSky(void);
    293 
    294 /*--------*/
    295 /*r_phase3*/
    296 /*--------*/
    297 void R_RenderAll(void);
    298 void R_RenderPSprites(void);
    299 
    300 
    301 /* to get a global angle from cartesian coordinates, the coordinates are */
    302 /* flipped until they are in the first octant of the coordinate system, then */
    303 /* the y (<=x) is scaled and divided by x to get a tangent (slope) value */
    304 /* which is looked up in the tantoangle[] table.  The +1 size is to handle */
    305 /* the case when x==y without additional checking. */
    306 #define	SLOPERANGE	2048
    307 #define	SLOPEBITS	11
    308 #define	DBITS		(FRACBITS-SLOPEBITS)
    309 
    310 extern	angle_t	tantoangle[SLOPERANGE+1];
    311 
    312 
    313 #define	VIEW_3D_H 200
    314 //extern	fixed_t	yslope[VIEW_3D_H];
    315 
    316 #define	HEIGHTBITS			6
    317 #define	SCALEBITS			9
    318 
    319 #define	FIXEDTOSCALE		(FRACBITS-SCALEBITS)
    320 #define	FIXEDTOHEIGHT		(FRACBITS-HEIGHTBITS)
    321 
    322 
    323 #define	HALF_SCREEN_W       (SCREENWIDTH/2)
    324 
    325 extern	fixed_t		viewx, viewy, viewz;    //80077D0C, 80077D10, 80077D18
    326 extern	angle_t		viewangle;              //800780B8
    327 extern	fixed_t		viewcos, viewsin;       //80077EC8, 80077EE0
    328 
    329 extern	player_t	*viewplayer;            //80077D60
    330 
    331 extern	fixed_t		finetangent[FINEANGLES/2];
    332 
    333 extern	int			validcount; //800779F4
    334 //extern	int			framecount;
    335 
    336 
    337 
    338 
    339 /* */
    340 /* R_data.c */
    341 /* */
    342 extern boolean rendersky;                           // 800A68A8
    343 extern byte solidcols[320];				            // 800A6348
    344 
    345 #define	MAXSUBSECTORS	256		/* Maximum number of subsectors to scan */
    346 extern subsector_t *solidsubsectors[MAXSUBSECTORS];	// 800A6488 /* List of valid ranges to scan through */
    347 extern subsector_t **endsubsector;				    // 800A6888 /* Pointer to the first free entry */
    348 extern int numdrawsubsectors;                       // 800A68AC
    349 
    350 #define	MAXVISSPRITES       256
    351 extern	vissprite_t	vissprites[MAXVISSPRITES];  // 800A6908
    352 extern	vissprite_t	*visspritehead;             // 800A8108
    353 extern int numdrawvissprites;                   // 800A68B0
    354 
    355 
    356 //extern	short		skypalette;
    357 //extern	psxobj_t	*skytexturep;
    358 
    359 extern	int firsttex, lasttex, numtextures,firstswx;
    360 extern	int *textures;
    361 extern	int skytexture;
    362 
    363 //extern	int			*flattranslation;		/* for global animation */
    364 //extern	int			*texturetranslation;	/* for global animation */
    365 
    366 //extern	int			firstflat, lastflat,  numflats;
    367 //extern	psxobj_t	*texflats;
    368 
    369 extern	int firstsprite, lastsprite, numsprites;
    370 //extern	int *texsprites;
    371 
    372 //#define MAX_PALETTES 26 //Final Doom 20 to 26
    373 //extern	short palette[MAX_PALETTES];
    374 //extern	short palettebase;
    375 //extern	light_t		*lights;
    376 
    377 #endif		/* __R_LOCAL__ */
    378