-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv_psx.h
154 lines (130 loc) · 3.89 KB
/
v_psx.h
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 2013 James Haley
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//-----------------------------------------------------------------------------
//
// DESCRIPTION:
// PSX Graphics Formats
//
//-----------------------------------------------------------------------------
#ifndef V_PSX_H__
#define V_PSX_H__
#include "doomtype.h"
#include "z_zone.h"
class qstring;
class WadDirectory;
struct ziparchive_t;
struct rgba_t
{
uint8_t r, g, b, a;
};
struct hsl_t
{
double h, s, l;
};
//
// VPSXImage
//
// Class to encapsulate image data extracted from a PSX graphic lump.
//
class VPSXImage : public ZoneObject
{
public:
struct rect_t
{
int16_t x;
int16_t y;
int16_t width;
int16_t height;
};
protected:
int16_t top;
int16_t left;
int16_t width;
int16_t height;
uint8_t *pixels;
uint8_t *mask;
void readImage(const void *data);
void adjustOffsets(const char *name);
public:
VPSXImage(WadDirectory &dir, int lumpnum);
VPSXImage(WadDirectory &dir, const char *lumpname);
VPSXImage(const VPSXImage &parent, const rect_t &subrect,
int16_t topoffs = 0, int16_t leftoffs = 0);
~VPSXImage();
int16_t getTop() const { return top; }
int16_t getLeft() const { return left; }
int16_t getWidth() const { return width; }
int16_t getHeight() const { return height; }
const uint8_t *getPixels() const { return pixels; }
const uint8_t *getMask() const { return mask; }
uint8_t *releasePixels()
{
uint8_t *ret = pixels;
pixels = nullptr;
return ret;
}
void *toPatch(size_t &size) const;
void scaleForFourThree();
};
// Known PSX PLAYPAL palette numbers
enum psxpalette_e
{
PAL_NORMAL,
PAL_DAMAGE1,
PAL_DAMAGE2,
PAL_DAMAGE3,
PAL_DAMAGE4,
PAL_DAMAGE5,
PAL_DAMAGE6,
PAL_DAMAGE7,
PAL_DAMAGE8,
PAL_ITEM1,
PAL_ITEM2,
PAL_ITEM3,
PAL_ITEM4,
PAL_RADSUIT,
PAL_GODMODE, // Used for godmode instead of a colormap
PAL_FIRESKY, // Used for realtime fire sky effect
PAL_LEGALS, // Used for LEGALS lump
PAL_DOOMTITLE, // Used for DOOM and TITLE lumps
PAL_IDCRED1, // Used for IDCRED1 lump
PAL_WMSCRED1, // Used for WMSCRED1 lump
PAL_NUMPLAYPALS
};
int V_FindNearestColour(rgba_t colours[256], rgba_t colour);
void V_ColoursFromPLAYPAL(size_t palnum, rgba_t outpal[256]);
void V_BuildTranMap(rgba_t colours[256], byte *map, int pct);
void V_LoadPLAYPAL(WadDirectory &dir);
void V_GenerateCOLORMAP();
void V_LoadLIGHTS(WadDirectory &dir);
void V_ConvertSpritesToZip(WadDirectory &dir, ziparchive_t *zip);
void V_ConvertTexturesToZip(WadDirectory &dir, ziparchive_t *zip);
void V_ConvertFlatsToZip(WadDirectory &dir, ziparchive_t *zip);
void V_ConvertGraphicsToZip(WadDirectory &dir, ziparchive_t *zip);
void V_ConvertPLAYPALToZip(ziparchive_t *zip);
void V_ConvertCOLORMAPToZip(ziparchive_t *zip);
void V_ConvertLIGHTSToZip(ziparchive_t *zip);
void V_ExtractMovie(const qstring &infile, const qstring &outfile,
int offset, int length);
#ifndef NO_UNIT_TESTS
void V_ExplodePLAYPAL(WadDirectory &dir);
#endif
#endif
// EOF