r_picformats.h 3.33 KB
Newer Older
Jaime Ita Passos committed
1 2 3
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
Jaime Ita Passos committed
4 5
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos.
// Copyright (C) 2019-2020 by Sonic Team Junior.
Jaime Ita Passos committed
6 7 8 9 10
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
Jaime Ita Passos committed
11
/// \file  r_picformats.h
Jaime Ita Passos committed
12 13
/// \brief Patch generation.

14 15
#ifndef __R_PICFORMATS__
#define __R_PICFORMATS__
Jaime Ita Passos committed
16 17 18 19

#include "r_defs.h"
#include "doomdef.h"

Jaime Ita Passos committed
20 21 22 23 24 25 26
typedef enum
{
	PICFMT_NONE = 0,

	// Doom formats
	PICFMT_PATCH,
	PICFMT_FLAT,
27
	PICFMT_DOOMPATCH,
Jaime Ita Passos committed
28 29 30 31 32 33 34

	// PNG
	PICFMT_PNG,

	// 16bpp
	PICFMT_PATCH16,
	PICFMT_FLAT16,
35
	PICFMT_DOOMPATCH16,
Jaime Ita Passos committed
36 37 38

	// 32bpp
	PICFMT_PATCH32,
39 40
	PICFMT_FLAT32,
	PICFMT_DOOMPATCH32
Jaime Ita Passos committed
41 42 43 44 45 46 47 48
} pictureformat_t;

typedef enum
{
	PICFLAGS_XFLIP = 1,
	PICFLAGS_YFLIP = 1<<1
} pictureflags_t;

Jaime Ita Passos committed
49 50 51 52 53 54 55 56
enum
{
	PICDEPTH_NONE = 0,
	PICDEPTH_8BPP = 8,
	PICDEPTH_16BPP = 16,
	PICDEPTH_32BPP = 32
};

Jaime Ita Passos committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
void *Picture_Convert(
	pictureformat_t informat, void *picture, pictureformat_t outformat,
	size_t insize, size_t *outsize,
	INT32 inwidth, INT32 inheight, INT32 inleftoffset, INT32 intopoffset,
	pictureflags_t flags);

void *Picture_PatchConvert(
	pictureformat_t informat, void *picture, pictureformat_t outformat,
	size_t insize, size_t *outsize,
	INT16 inwidth, INT16 inheight, INT16 inleftoffset, INT16 intopoffset,
	pictureflags_t flags);
void *Picture_FlatConvert(
	pictureformat_t informat, void *picture, pictureformat_t outformat,
	size_t insize, size_t *outsize,
	INT16 inwidth, INT16 inheight, INT16 inleftoffset, INT16 intopoffset,
	pictureflags_t flags);
void *Picture_GetPatchPixel(
	patch_t *patch, pictureformat_t informat,
	INT32 x, INT32 y,
	pictureflags_t flags);

Jaime Ita Passos committed
78 79
void *Picture_TextureToFlat(size_t trickytex);

Jaime Ita Passos committed
80 81
INT32 Picture_FormatBPP(pictureformat_t format);
boolean Picture_IsPatchFormat(pictureformat_t format);
82 83
boolean Picture_IsInternalPatchFormat(pictureformat_t format);
boolean Picture_IsDoomPatchFormat(pictureformat_t format);
Jaime Ita Passos committed
84
boolean Picture_IsFlatFormat(pictureformat_t format);
85
boolean Picture_CheckIfDoomPatch(softwarepatch_t *patch, size_t size);
Jaime Ita Passos committed
86

Jaime Ita Passos committed
87
// Structs
88 89
typedef enum
{
Jaime Ita Passos committed
90 91 92
	ROTAXIS_X, // Roll (the default)
	ROTAXIS_Y, // Pitch
	ROTAXIS_Z  // Yaw
93
} rotaxis_t;
94

Jaime Ita Passos committed
95 96 97
typedef struct
{
	INT32 x, y;
98
	rotaxis_t rotaxis;
Jaime Ita Passos committed
99 100 101 102 103 104 105 106
} spriteframepivot_t;

typedef struct
{
	spriteframepivot_t pivot[64];
	boolean available;
} spriteinfo_t;

Jaime Ita Passos committed
107
// Portable Network Graphics
Jaime Ita Passos committed
108 109
boolean Picture_IsLumpPNG(const UINT8 *d, size_t s);
#define Picture_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
Jaime Ita Passos committed
110

Jaime Ita Passos committed
111
#ifndef NO_PNG_LUMPS
Jaime Ita Passos committed
112 113 114 115 116 117
void *Picture_PNGConvert(
	const UINT8 *png, pictureformat_t outformat,
	INT32 *w, INT32 *h,
	INT16 *topoffset, INT16 *leftoffset,
	size_t insize, size_t *outsize,
	pictureflags_t flags);
118
boolean Picture_PNGDimensions(UINT8 *png, INT32 *width, INT32 *height, INT16 *topoffset, INT16 *leftoffset, size_t size);
Jaime Ita Passos committed
119 120
#endif

121 122
#define PICTURE_PNG_USELOOKUP

Jaime Ita Passos committed
123 124
// SpriteInfo
extern spriteinfo_t spriteinfo[NUMSPRITES];
Jaime Ita Passos committed
125 126 127
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps);
void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);

128
#endif // __R_PICFORMATS__