2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2020-02-19 22:08:45 +00:00
|
|
|
// Copyright (C) 1999-2020 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// This program is free software distributed under the
|
|
|
|
// terms of the GNU General Public License, version 2.
|
|
|
|
// See the 'LICENSE' file for more details.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// \file r_things.h
|
|
|
|
/// \brief Rendering of moving objects, sprites
|
|
|
|
|
|
|
|
#ifndef __R_THINGS__
|
|
|
|
#define __R_THINGS__
|
|
|
|
|
|
|
|
#include "r_plane.h"
|
2019-10-28 18:28:42 +00:00
|
|
|
#include "r_patch.h"
|
2020-01-06 21:22:23 +00:00
|
|
|
#include "r_picformats.h"
|
2019-06-05 14:35:48 +00:00
|
|
|
#include "r_portal.h"
|
2019-08-18 17:16:48 +00:00
|
|
|
#include "r_defs.h"
|
2020-03-08 21:17:30 +00:00
|
|
|
#include "r_skins.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// --------------
|
|
|
|
// SPRITE LOADING
|
|
|
|
// --------------
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-11-06 23:41:55 +00:00
|
|
|
#define FEETADJUST (4<<FRACBITS) // R_AddSingleSpriteDef
|
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump);
|
|
|
|
|
|
|
|
//faB: find sprites in wadfile, replace existing, add new ones
|
|
|
|
// (only sprites from namelist are added or replaced)
|
|
|
|
void R_AddSpriteDefs(UINT16 wadnum);
|
|
|
|
|
|
|
|
// ---------------------
|
|
|
|
// MASKED COLUMN DRAWING
|
|
|
|
// ---------------------
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// vars for R_DrawMaskedColumn
|
|
|
|
extern INT16 *mfloorclip;
|
|
|
|
extern INT16 *mceilingclip;
|
|
|
|
extern fixed_t spryscale;
|
|
|
|
extern fixed_t sprtopscreen;
|
|
|
|
extern fixed_t sprbotscreen;
|
|
|
|
extern fixed_t windowtop;
|
|
|
|
extern fixed_t windowbottom;
|
2020-01-11 16:24:00 +00:00
|
|
|
extern INT32 lengthcol;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
void R_DrawMaskedColumn(column_t *column);
|
2020-01-11 16:24:00 +00:00
|
|
|
void R_DrawFlippedMaskedColumn(column_t *column);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// ----------------
|
|
|
|
// SPRITE RENDERING
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
// Constant arrays used for psprite clipping
|
|
|
|
// and initializing clipping.
|
|
|
|
extern INT16 negonearray[MAXVIDWIDTH];
|
|
|
|
extern INT16 screenheightarray[MAXVIDWIDTH];
|
2017-05-06 14:52:53 +00:00
|
|
|
|
2020-01-09 05:19:52 +00:00
|
|
|
fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope);
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
//SoM: 6/5/2000: Light sprites correctly!
|
|
|
|
void R_AddSprites(sector_t *sec, INT32 lightlevel);
|
|
|
|
void R_InitSprites(void);
|
|
|
|
void R_ClearSprites(void);
|
2019-06-04 18:15:42 +00:00
|
|
|
|
2020-01-18 04:45:55 +00:00
|
|
|
boolean R_ThingVisible (mobj_t *thing);
|
|
|
|
|
|
|
|
boolean R_ThingVisibleWithinDist (mobj_t *thing,
|
|
|
|
fixed_t draw_dist,
|
|
|
|
fixed_t nights_draw_dist);
|
|
|
|
|
|
|
|
boolean R_PrecipThingVisible (precipmobj_t *precipthing,
|
|
|
|
fixed_t precip_draw_dist);
|
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
boolean R_ThingHorizontallyFlipped (mobj_t *thing);
|
|
|
|
boolean R_ThingVerticallyFlipped (mobj_t *thing);
|
|
|
|
|
|
|
|
boolean R_ThingIsPaperSprite (mobj_t *thing);
|
|
|
|
boolean R_ThingIsFloorSprite (mobj_t *thing);
|
|
|
|
|
|
|
|
boolean R_ThingIsFullBright (mobj_t *thing);
|
|
|
|
boolean R_ThingIsFullDark (mobj_t *thing);
|
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// --------------
|
|
|
|
// MASKED DRAWING
|
|
|
|
// --------------
|
2019-06-04 18:15:42 +00:00
|
|
|
/** Used to count the amount of masked elements
|
|
|
|
* per portal to later group them in separate
|
|
|
|
* drawnode lists.
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
size_t drawsegs[2];
|
|
|
|
size_t vissprites[2];
|
2019-06-06 11:30:50 +00:00
|
|
|
fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */
|
|
|
|
sector_t* viewsector;
|
2019-06-04 18:15:42 +00:00
|
|
|
} maskcount_t;
|
|
|
|
|
|
|
|
void R_DrawMasked(maskcount_t* masks, UINT8 nummasks);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// ----------
|
|
|
|
// VISSPRITES
|
|
|
|
// ----------
|
2020-03-08 19:32:07 +00:00
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// number of sprite lumps for spritewidth,offset,topoffset lookup tables
|
|
|
|
// Fab: this is a hack : should allocate the lookup tables per sprite
|
|
|
|
#define MAXVISSPRITES 2048 // added 2-2-98 was 128
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
#define VISSPRITECHUNKBITS 6 // 2^6 = 64 sprites per chunk
|
|
|
|
#define VISSPRITESPERCHUNK (1 << VISSPRITECHUNKBITS)
|
|
|
|
#define VISSPRITEINDEXMASK (VISSPRITESPERCHUNK - 1)
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2017-06-26 13:44:10 +00:00
|
|
|
// actual cuts
|
2020-10-12 03:13:22 +00:00
|
|
|
SC_NONE = 0,
|
|
|
|
SC_TOP = 1,
|
|
|
|
SC_BOTTOM = 1<<1,
|
2017-06-26 13:44:10 +00:00
|
|
|
// other flags
|
2020-10-12 03:13:22 +00:00
|
|
|
SC_PRECIP = 1<<2,
|
|
|
|
SC_LINKDRAW = 1<<3,
|
2017-06-26 13:44:10 +00:00
|
|
|
SC_FULLBRIGHT = 1<<4,
|
2020-10-12 03:13:22 +00:00
|
|
|
SC_FULLDARK = 1<<5,
|
|
|
|
SC_VFLIP = 1<<6,
|
|
|
|
SC_ISSCALED = 1<<7,
|
|
|
|
SC_ISROTATED = 1<<8,
|
|
|
|
SC_SHADOW = 1<<9,
|
|
|
|
SC_SHEAR = 1<<10,
|
|
|
|
SC_SPLAT = 1<<11,
|
2017-06-26 13:44:10 +00:00
|
|
|
// masks
|
2020-10-12 03:13:22 +00:00
|
|
|
SC_CUTMASK = SC_TOP|SC_BOTTOM,
|
|
|
|
SC_FLAGMASK = ~SC_CUTMASK
|
2014-03-15 16:59:03 +00:00
|
|
|
} spritecut_e;
|
|
|
|
|
|
|
|
// A vissprite_t is a thing that will be drawn during a refresh,
|
|
|
|
// i.e. a sprite object that is partly visible.
|
|
|
|
typedef struct vissprite_s
|
|
|
|
{
|
|
|
|
// Doubly linked list.
|
|
|
|
struct vissprite_s *prev;
|
|
|
|
struct vissprite_s *next;
|
|
|
|
|
2017-06-26 13:44:10 +00:00
|
|
|
// Bonus linkdraw pointer.
|
2017-06-25 19:46:30 +00:00
|
|
|
struct vissprite_s *linkdraw;
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
mobj_t *mobj; // for easy access
|
|
|
|
|
|
|
|
INT32 x1, x2;
|
|
|
|
|
|
|
|
fixed_t gx, gy; // for line side calculation
|
|
|
|
fixed_t gz, gzt; // global bottom/top for silhouette clipping
|
|
|
|
fixed_t pz, pzt; // physical bottom/top for sorting with 3D floors
|
|
|
|
|
|
|
|
fixed_t startfrac; // horizontal position of x1
|
2016-09-16 16:09:33 +00:00
|
|
|
fixed_t scale, sortscale; // sortscale only differs from scale for paper sprites and MF2_LINKDRAW
|
|
|
|
fixed_t scalestep; // only for paper sprites, 0 otherwise
|
2019-12-27 10:57:16 +00:00
|
|
|
fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle
|
2014-03-15 16:59:03 +00:00
|
|
|
fixed_t xiscale; // negative if flipped
|
|
|
|
|
2019-12-27 10:57:16 +00:00
|
|
|
angle_t centerangle; // for paper sprites
|
|
|
|
|
2020-01-09 03:52:10 +00:00
|
|
|
struct {
|
|
|
|
fixed_t tan; // The amount to shear the sprite vertically per row
|
|
|
|
INT32 offset; // The center of the shearing location offset from x1
|
|
|
|
} shear;
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
fixed_t texturemid;
|
2019-08-18 17:16:48 +00:00
|
|
|
patch_t *patch;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
lighttable_t *colormap; // for color translation and shadow draw
|
|
|
|
// maxbright frames as well
|
|
|
|
|
|
|
|
UINT8 *transmap; // for MF2_SHADOW sprites, which translucency table to use
|
|
|
|
|
|
|
|
INT32 mobjflags;
|
|
|
|
|
|
|
|
INT32 heightsec; // height sector for underwater/fake ceiling support
|
|
|
|
|
|
|
|
extracolormap_t *extra_colormap; // global colormaps
|
|
|
|
|
|
|
|
fixed_t xscale;
|
|
|
|
|
|
|
|
// Precalculated top and bottom screen coords for the sprite.
|
|
|
|
fixed_t thingheight; // The actual height of the thing (for 3D floors)
|
|
|
|
sector_t *sector; // The sector containing the thing.
|
|
|
|
INT16 sz, szt;
|
|
|
|
|
|
|
|
spritecut_e cut;
|
2020-10-12 03:13:22 +00:00
|
|
|
UINT32 renderflags;
|
|
|
|
UINT8 rotateflags;
|
|
|
|
|
2020-10-12 20:25:18 +00:00
|
|
|
fixed_t spritexscale, spriteyscale;
|
2020-10-12 03:13:22 +00:00
|
|
|
fixed_t shadowscale;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2014-11-12 00:55:07 +00:00
|
|
|
INT16 clipbot[MAXVIDWIDTH], cliptop[MAXVIDWIDTH];
|
|
|
|
|
2015-11-23 16:39:32 +00:00
|
|
|
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
|
2014-03-15 16:59:03 +00:00
|
|
|
} vissprite_t;
|
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
extern UINT32 visspritecount;
|
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
void R_ClipSprites(drawseg_t* dsstart, portal_t* portal);
|
|
|
|
void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, drawseg_t* dsstart, portal_t* portal);
|
|
|
|
|
|
|
|
boolean R_SpriteIsFlashing(vissprite_t *vis);
|
|
|
|
UINT8 *R_GetSpriteTranslation(vissprite_t *vis);
|
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// ----------
|
|
|
|
// DRAW NODES
|
|
|
|
// ----------
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// A drawnode is something that points to a 3D floor, 3D side, or masked
|
|
|
|
// middle texture. This is used for sorting with sprites.
|
|
|
|
typedef struct drawnode_s
|
|
|
|
{
|
|
|
|
visplane_t *plane;
|
|
|
|
drawseg_t *seg;
|
|
|
|
drawseg_t *thickseg;
|
|
|
|
ffloor_t *ffloor;
|
|
|
|
vissprite_t *sprite;
|
|
|
|
|
|
|
|
struct drawnode_s *next;
|
|
|
|
struct drawnode_s *prev;
|
|
|
|
} drawnode_t;
|
|
|
|
|
|
|
|
void R_InitDrawNodes(void);
|
|
|
|
|
2020-03-08 21:17:30 +00:00
|
|
|
// -----------------------
|
|
|
|
// SPRITE FRAME CHARACTERS
|
|
|
|
// -----------------------
|
|
|
|
|
2014-04-14 05:14:58 +00:00
|
|
|
// Functions to go from sprite character ID to frame number
|
|
|
|
// for 2.1 compatibility this still uses the old 'A' + frame code
|
|
|
|
// The use of symbols tends to be painful for wad editors though
|
|
|
|
// So the future version of this tries to avoid using symbols
|
|
|
|
// as much as possible while also defining all 64 slots in a sane manner
|
|
|
|
// 2.1: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ]]
|
|
|
|
// Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]]
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame)
|
|
|
|
{
|
2017-10-09 19:24:04 +00:00
|
|
|
#if 0 // 2.1 compat
|
2014-04-14 05:14:58 +00:00
|
|
|
return 'A' + frame;
|
|
|
|
#else
|
|
|
|
if (frame < 26) return 'A' + frame;
|
|
|
|
if (frame < 36) return '0' + (frame - 26);
|
|
|
|
if (frame < 62) return 'a' + (frame - 36);
|
|
|
|
if (frame == 62) return '!';
|
|
|
|
if (frame == 63) return '@';
|
|
|
|
return '\xFF';
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn)
|
|
|
|
{
|
2017-10-09 19:24:04 +00:00
|
|
|
#if 0 // 2.1 compat
|
2018-12-13 19:59:12 +00:00
|
|
|
if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead
|
2014-04-14 05:14:58 +00:00
|
|
|
return cn - 'A';
|
|
|
|
#else
|
2020-01-08 20:49:14 +00:00
|
|
|
if (cn >= 'A' && cn <= 'Z') return (cn - 'A');
|
2014-04-14 05:14:58 +00:00
|
|
|
if (cn >= '0' && cn <= '9') return (cn - '0') + 26;
|
|
|
|
if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36;
|
|
|
|
if (cn == '!') return 62;
|
|
|
|
if (cn == '@') return 63;
|
|
|
|
return 255;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-01-08 20:49:14 +00:00
|
|
|
// "Left" and "Right" character symbols for additional rotation functionality
|
|
|
|
#define ROT_L 17
|
|
|
|
#define ROT_R 18
|
|
|
|
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE char R_Rotation2Char(UINT8 rot)
|
2016-07-18 23:04:00 +00:00
|
|
|
{
|
2020-01-08 20:49:14 +00:00
|
|
|
if (rot <= 9) return '0' + rot;
|
|
|
|
if (rot <= 16) return 'A' + (rot - 10);
|
|
|
|
if (rot == ROT_L) return 'L';
|
|
|
|
if (rot == ROT_R) return 'R';
|
|
|
|
return '\xFF';
|
|
|
|
}
|
|
|
|
|
|
|
|
FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Rotation(char cn)
|
|
|
|
{
|
|
|
|
if (cn >= '0' && cn <= '9') return (cn - '0');
|
|
|
|
if (cn >= 'A' && cn <= 'G') return (cn - 'A') + 10;
|
|
|
|
if (cn == 'L') return ROT_L;
|
|
|
|
if (cn == 'R') return ROT_R;
|
|
|
|
return 255;
|
2016-07-18 23:04:00 +00:00
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
#endif //__R_THINGS__
|