2019-10-28 18:28:42 +00:00
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
2020-02-19 22:08:45 +00:00
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos.
2020-02-19 22:44:22 +00:00
// Copyright (C) 2019-2020 by Sonic Team Junior.
2019-10-28 18:28:42 +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_patch.h
/// \brief Patch generation.
# ifndef __R_PATCH__
# define __R_PATCH__
# include "r_defs.h"
# include "doomdef.h"
2019-12-04 18:26:51 +00:00
// Structs
2019-11-13 15:36:44 +00:00
typedef enum
{
2019-12-04 18:26:51 +00:00
ROTAXIS_X , // Roll (the default)
ROTAXIS_Y , // Pitch
ROTAXIS_Z // Yaw
2019-11-13 15:47:30 +00:00
} rotaxis_t ;
2019-11-13 15:36:44 +00:00
2019-10-28 18:28:42 +00:00
typedef struct
{
INT32 x , y ;
2019-11-13 15:47:30 +00:00
rotaxis_t rotaxis ;
2019-10-28 18:28:42 +00:00
} spriteframepivot_t ;
typedef struct
{
spriteframepivot_t pivot [ 64 ] ;
boolean available ;
} spriteinfo_t ;
2020-08-08 08:16:47 +00:00
// Patch functions
patch_t * Patch_Create ( softwarepatch_t * source , size_t srcsize , void * dest ) ;
void Patch_Free ( patch_t * patch ) ;
# ifdef HWRENDER
void * Patch_AllocateHardwarePatch ( patch_t * patch ) ;
void * Patch_CreateGL ( patch_t * patch ) ;
# endif
2020-08-15 23:14:36 +00:00
boolean Patch_CheckIfDoom ( softwarepatch_t * patch , size_t length ) ;
2019-12-04 18:26:51 +00:00
// Conversions between patches / flats / textures...
2019-10-28 18:28:42 +00:00
void R_TextureToFlat ( size_t tex , UINT8 * flat ) ;
void R_PatchToFlat ( patch_t * patch , UINT8 * flat ) ;
2020-01-01 20:46:26 +00:00
void R_PatchToMaskedFlat ( patch_t * patch , UINT16 * raw , boolean flip ) ;
2020-08-08 08:16:47 +00:00
softwarepatch_t * R_FlatToPatch ( UINT8 * raw , UINT16 width , UINT16 height , UINT16 leftoffset , UINT16 topoffset , size_t * destsize , boolean transparency ) ;
softwarepatch_t * R_MaskedFlatToPatch ( UINT16 * raw , UINT16 width , UINT16 height , UINT16 leftoffset , UINT16 topoffset , size_t * destsize ) ;
2019-10-28 18:28:42 +00:00
2020-08-08 08:16:47 +00:00
// PNGs
2019-12-04 18:26:51 +00:00
boolean R_IsLumpPNG ( const UINT8 * d , size_t s ) ;
# define W_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic
2019-10-28 18:28:42 +00:00
# ifndef NO_PNG_LUMPS
UINT8 * R_PNGToFlat ( UINT16 * width , UINT16 * height , UINT8 * png , size_t size ) ;
2020-08-08 08:16:47 +00:00
softwarepatch_t * R_PNGToPatch ( const UINT8 * png , size_t size , size_t * destsize ) ;
2019-10-28 18:28:42 +00:00
boolean R_PNGDimensions ( UINT8 * png , INT16 * width , INT16 * height , size_t size ) ;
# endif
2019-12-04 18:26:51 +00:00
// SpriteInfo
extern spriteinfo_t spriteinfo [ NUMSPRITES ] ;
2019-10-28 18:28:42 +00:00
void R_LoadSpriteInfoLumps ( UINT16 wadnum , UINT16 numlumps ) ;
void R_ParseSPRTINFOLump ( UINT16 wadNum , UINT16 lumpNum ) ;
2019-12-04 18:26:51 +00:00
// Sprite rotation
2019-10-28 18:28:42 +00:00
# ifdef ROTSPRITE
2019-12-27 00:27:30 +00:00
INT32 R_GetRollAngle ( angle_t rollangle ) ;
2019-10-28 18:28:42 +00:00
void R_CacheRotSprite ( spritenum_t sprnum , UINT8 frame , spriteinfo_t * sprinfo , spriteframe_t * sprframe , INT32 rot , UINT8 flip ) ;
2020-08-08 08:16:47 +00:00
void R_FreeRotSprite ( spritedef_t * spritedef ) ;
2019-11-14 17:12:36 +00:00
void R_FreeSkinRotSprite ( size_t skinnum ) ;
2019-12-27 00:27:30 +00:00
extern fixed_t rollcosang [ ROTANGLES ] ;
extern fixed_t rollsinang [ ROTANGLES ] ;
2019-10-28 18:28:42 +00:00
# endif
# endif // __R_PATCH__