aboutsummaryrefslogtreecommitdiff
path: root/laichzeit/tpl.h
blob: 443dc525e2fbfc85ca46a69a978b1014fc020205 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*****************************************************************************/
/*  Laichzeit                                                                */
/*  Part of the Benzin Project                                               */
/*  Copyright (c)2009 HACKERCHANNEL. Protected under the GNU GPLv2.          */
/* ------------------------------------------------------------------------- */
/*  tpl.h                                                                    */
/*  The header file for all the TPL stuff. Include this!                     */
/* ------------------------------------------------------------------------- */
/*  Most code contributed by:                                                */
/*          SquidMan                                                         */
/*****************************************************************************/

#ifndef TPL_H
#define TPL_H

#include "types.h"

#define USE_TPL

typedef enum {
	// I4 (4 bit intensity, 8x8 tiles)
	TPL_FORMAT_I4		= 0,
	// I8 (8 bit intensity, 8x4 tiles)
	TPL_FORMAT_I8		= 1,
	// IA4 (4 bit intensity with 4 bit alpha, 8x4 tiles)
	TPL_FORMAT_IA4		= 2,
	// IA8 (8 bit intensity with 8 bit alpha, 4x4 tiles)
	TPL_FORMAT_IA8		= 3,

	// RGB565 (4x4 tiles)
	TPL_FORMAT_RGB565	= 4,
	// RGB5A3 (*) (4x4 tiles)
	TPL_FORMAT_RGB5A3	= 5,
	// RGBA8 (4x4 tiles in two cache lines - first is AR and second is GB)
	TPL_FORMAT_RGBA8	= 6,

	// CI4 (4 bit color index, 8x8 tiles)
	TPL_FORMAT_CI4		= 8,
	// CI8 (8 bit color index, 8x4 tiles)
	TPL_FORMAT_CI8		= 9,
	// CI14X2 (14 bit color index, 4x4 tiles)
	TPL_FORMAT_CI14X2	= 10,

	// CMP (S3TC compressed, 2x2 blocks of 4x4 tiles)
	TPL_FORMAT_CMP		= 14
} TPLFormat;

typedef struct {
	u16		height;			// Height of the TPL image.
	u16		width;			// Width of the TPL image.
	TPLFormat	format;			// Format of the TPL image.
	u32		offs;			// Offset to actual image data.
	u32		wrap_s;			// Wrap S.
	u32		wrap_t;			// Wrap T.
	u32		min;			// Min filter.
	u32		mag;			// Mag filter.
	f32		lod_bias;		// LOD Bias?
	u8		edge_lod;		// Edge LOD?
	u8		min_lod;		// Minimum LOD?
	u8		max_lod;		// Maximum LOD?
	u8		unpacked;		// Unpacked?
} TPLHeader;

typedef struct {
	char		filename[256];		// Filename.
	TPLHeader	header;			// Header.
	int		done;			// Is it done?
} TPLImage;

typedef struct {
	int		imgcnt;			// How many TPLs
	TPLImage*	imgs;			// The TPLs
} TPL;

TPL*	LaichTPL_Start();
int	LaichTPL_StartImage(TPL* tpl, char* file);
void	LaichTPL_SetImageFormat(TPL* tpl, int img, TPLFormat format);
void	LaichTPL_SetImageWrap(TPL* tpl, int img, u32 s, u32 t);
void	LaichTPL_SetImageFilters(TPL* tpl, int img, u32 min, u32 mag);
void	LaichTPL_SetImageLOD(TPL* tpl, int img, \
			f32 lod_bias, u8 edge_lod, u8 min_lod, u8 max_lod);
void	LaichTPL_EndImage(TPL* tpl, int img);
u8*	LaichTPL_CompileTPL(TPL* tpl, u32* fsize);

#endif //TPL_H