V-Gears 0
Free Final Fantasy VII engine.
TxzFileSerializer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warrantexture_y of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <array>
21
22namespace VGears {
23
24 class TxzFile;
25
27
28 public:
29
30#ifdef _MSC_VER
31#pragma pack(push)
32#pragma pack(1)
33#endif
34
35
37 unsigned int clut_x:6;
38 unsigned int clut_y:10;
39 unsigned int texture_x:4;
40 unsigned int texture_y:1;
41 unsigned int abr:2;
42 unsigned int tp:2;
43 unsigned int reserved:7;
44#ifdef _MSC_VER
45 };
46#pragma pack(pop)
47#else
48 } __attribute__((packed)); // Assume GCC
49#endif
50
51#ifdef _MSC_VER
52#pragma pack(push)
53#pragma pack(1)
54#endif
55
59 struct PsxPixel{
60
65
70
75
80
81#ifdef _MSC_VER
82 };
83#pragma pack(pop)
84#else
85 } __attribute__((packed)); // Assume GCC
86#endif
87
88#ifdef _MSC_VER
89#pragma pack(push)
90#pragma pack(1)
91#endif
92
97
102
107
108#ifdef _MSC_VER
109 };
110#pragma pack(pop)
111#else
112 } __attribute__((packed)); // Assume GCC
113#endif
114
115#ifdef _MSC_VER
116#pragma pack(push)
117#pragma pack(1)
118#endif
119
123 struct Rgba{
124
128 unsigned char r = 0;
129
133 unsigned char g = 0;
134
138 unsigned char b = 0;
139
143 unsigned char a = 0;
144#ifdef _MSC_VER
145 };
146#pragma pack(pop)
147#else
148 } __attribute__((packed)); // Assume GCC
149#endif
150
154 struct VRamBlock{
155
159 uint32 block_size = 0;
160
164 uint16 x = 0;
165
169 uint16 y = 0;
170
174 uint16 width = 0;
175
179 uint16 height = 0;
180
186 std::vector<uint8> pixels;
187 };
188
193
197 virtual ~TxzFileSerializer();
198
202 void Import(Ogre::DataStreamPtr& stream, TxzFile& dest);
203
211 std::vector<std::vector<Rgba>> GetWorldMapTexture(uint32 id);
212
213 private:
214
218 std::vector<VRamBlock> v_ram_blocks_;
219
226 void ImportDecompressed(Ogre::DataStream& stream, TxzFile& dest);
227
236 void ImportTextureSection(
237 Ogre::DataStream& stream, TxzFile& dest, size_t section_end
238 );
239
246 void ExtractTexture(
247 const std::array<WorldMapTexture,512>& pallete_table
248 );
249
253 std::map<uint32, std::vector<std::vector<Rgba>>> textures_;
254 };
255
256 static_assert(
258 "WorldMapTexture is not packed"
259 );
260
261 static_assert(
262 sizeof(TxzFileSerializer::PsxPixel) == 2, "PsxPixel is not packed"
263 );
264
265}
uint16 a
Alpha component.
Definition: TxzFileSerializer.h:19
uint16 b
Blue component.
Definition: TxzFileSerializer.h:14
uint16 g
Green component.
Definition: TxzFileSerializer.h:9
uint16 r
Red component.
Definition: TxzFileSerializer.h:4
Handles file serialization.
Definition: VGearsSerializer.h:30
Definition: TxzFileSerializer.h:26
std::map< uint32, std::vector< std::vector< Rgba > > > textures_
The list of textures.
Definition: TxzFileSerializer.h:253
std::vector< VRamBlock > v_ram_blocks_
The list of video RAM blocks.
Definition: TxzFileSerializer.h:218
Handles TXZ files.
Definition: TxzFile.h:27
Definition: FF7NameLookup.h:24
Ogre::uint16 uint16
Definition: TypeDefine.h:32
Ogre::uint32 uint32
Definition: TypeDefine.h:33
Ogre::uint8 uint8
Definition: TypeDefine.h:31
Play station pixel representation (4 bits).
Definition: TxzFileSerializer.h:96
uint8 index2
Second pixel index.
Definition: TxzFileSerializer.h:106
uint8 index1
First pixel index.
Definition: TxzFileSerializer.h:101
A play station pixel representation.
Definition: TxzFileSerializer.h:59
uint16 b
Blue component.
Definition: TxzFileSerializer.h:74
uint16 g
Green component.
Definition: TxzFileSerializer.h:69
uint16 a
Alpha component.
Definition: TxzFileSerializer.h:79
uint16 r
Red component.
Definition: TxzFileSerializer.h:64
RGBA colour representation.
Definition: TxzFileSerializer.h:123
A video RAM block representation.
Definition: TxzFileSerializer.h:154
std::vector< uint8 > pixels
The list of pixels.
Definition: TxzFileSerializer.h:186
Definition: TxzFileSerializer.h:36
unsigned int abr
Definition: TxzFileSerializer.h:41
unsigned int clut_x
Definition: TxzFileSerializer.h:37
unsigned int tp
Definition: TxzFileSerializer.h:42
unsigned int texture_x
Definition: TxzFileSerializer.h:39
unsigned int clut_y
Definition: TxzFileSerializer.h:38
unsigned int reserved
Definition: TxzFileSerializer.h:43
unsigned int texture_y
Definition: TxzFileSerializer.h:40