annotate LOD.h @ 219:f7c268995788

m
author Ritor1
date Sun, 17 Feb 2013 08:50:45 +0600
parents a9e9c6989d04
children 137c59c3dbc4
rev   line source
0
Ritor1
parents:
diff changeset
1 #pragma once
Ritor1
parents:
diff changeset
2 #include <stdio.h>
Ritor1
parents:
diff changeset
3 #include <memory.h>
Ritor1
parents:
diff changeset
4
Ritor1
parents:
diff changeset
5 #include "Texture.h"
Ritor1
parents:
diff changeset
6
Ritor1
parents:
diff changeset
7
Ritor1
parents:
diff changeset
8 /* 354 */
Ritor1
parents:
diff changeset
9 enum TEXTURE_TYPE
Ritor1
parents:
diff changeset
10 {
Ritor1
parents:
diff changeset
11 TEXTURE_DEFAULT = 0,
Ritor1
parents:
diff changeset
12 TEXTURE_24BIT_PALETTE = 0x1,
Ritor1
parents:
diff changeset
13 TEXTURE_16BIT_PALETTE = 0x2,
Ritor1
parents:
diff changeset
14 };
Ritor1
parents:
diff changeset
15
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19 namespace LOD
Ritor1
parents:
diff changeset
20 {
Ritor1
parents:
diff changeset
21 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
22 struct FileHeader
Ritor1
parents:
diff changeset
23 {
Ritor1
parents:
diff changeset
24 inline FileHeader()
Ritor1
parents:
diff changeset
25 {
Ritor1
parents:
diff changeset
26 memset(pSignature, 0, 4);
Ritor1
parents:
diff changeset
27 memset(LodVersion, 0, 80);
Ritor1
parents:
diff changeset
28 memset(LodDescription, 0, 80);
Ritor1
parents:
diff changeset
29 memset(array_0000B0, 0, 28);
Ritor1
parents:
diff changeset
30 memset(array_0000CC, 0, 52);
Ritor1
parents:
diff changeset
31 }
Ritor1
parents:
diff changeset
32
Ritor1
parents:
diff changeset
33 void Reset();
Ritor1
parents:
diff changeset
34
Ritor1
parents:
diff changeset
35 char pSignature[4];
Ritor1
parents:
diff changeset
36 char LodVersion[80];
Ritor1
parents:
diff changeset
37 //char field_C[32];
Ritor1
parents:
diff changeset
38 //char field_2C[40];
Ritor1
parents:
diff changeset
39 char LodDescription[80];
Ritor1
parents:
diff changeset
40 int LODSize;
Ritor1
parents:
diff changeset
41 int dword_0000A8;
Ritor1
parents:
diff changeset
42 unsigned int uNumIndices;
Ritor1
parents:
diff changeset
43 char array_0000B0[28];
Ritor1
parents:
diff changeset
44 char array_0000CC[52];
Ritor1
parents:
diff changeset
45 };
Ritor1
parents:
diff changeset
46 #pragma pack(pop)
Ritor1
parents:
diff changeset
47
Ritor1
parents:
diff changeset
48
Ritor1
parents:
diff changeset
49 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
50 struct Directory
Ritor1
parents:
diff changeset
51 {
Ritor1
parents:
diff changeset
52 Directory();
Ritor1
parents:
diff changeset
53 Directory *Reset();
Ritor1
parents:
diff changeset
54
Ritor1
parents:
diff changeset
55
Ritor1
parents:
diff changeset
56 char pFilename[16];
Ritor1
parents:
diff changeset
57 unsigned int uOfsetFromSubindicesStart;
Ritor1
parents:
diff changeset
58 unsigned int uDataSize;
Ritor1
parents:
diff changeset
59 int dword_000018;
Ritor1
parents:
diff changeset
60 unsigned __int16 uNumSubIndices;
Ritor1
parents:
diff changeset
61 __int16 word_00001E;
Ritor1
parents:
diff changeset
62 };
Ritor1
parents:
diff changeset
63 #pragma pack(pop)
Ritor1
parents:
diff changeset
64
Ritor1
parents:
diff changeset
65
Ritor1
parents:
diff changeset
66 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
67 struct File
Ritor1
parents:
diff changeset
68 {
Ritor1
parents:
diff changeset
69 File();
Ritor1
parents:
diff changeset
70 virtual ~File();
Ritor1
parents:
diff changeset
71 void *LoadRaw(const char *pContainer, int a3);
Ritor1
parents:
diff changeset
72 FILE *FindContainer(const char *pContainerName, bool bLinearSearch);
Ritor1
parents:
diff changeset
73 bool DoesContainerExist(const char *pContainer);
Ritor1
parents:
diff changeset
74 int CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName);
Ritor1
parents:
diff changeset
75 bool LoadHeader(const char *pFilename, bool bWriting);
Ritor1
parents:
diff changeset
76 int LoadSubIndices(const char *pContainer);
Ritor1
parents:
diff changeset
77 void AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize);
Ritor1
parents:
diff changeset
78 void FreeSubIndexAndIO();
Ritor1
parents:
diff changeset
79 bool AppendDirectory(LOD::Directory *pDir, const void *pData);
Ritor1
parents:
diff changeset
80 void ResetSubIndices();
Ritor1
parents:
diff changeset
81 void Close();
Ritor1
parents:
diff changeset
82
Ritor1
parents:
diff changeset
83 FILE *pFile;
Ritor1
parents:
diff changeset
84 char pLODName[256];
Ritor1
parents:
diff changeset
85 unsigned int isFileOpened;
Ritor1
parents:
diff changeset
86 unsigned __int8 *pIOBuffer;
Ritor1
parents:
diff changeset
87 unsigned int uIOBufferSize;
Ritor1
parents:
diff changeset
88 struct FileHeader header;
Ritor1
parents:
diff changeset
89 struct Directory *pRoot;
Ritor1
parents:
diff changeset
90 char pContainerName[16];
Ritor1
parents:
diff changeset
91 unsigned int uCurrentIndexDir;
Ritor1
parents:
diff changeset
92 unsigned int uLODDataSize;
Ritor1
parents:
diff changeset
93 unsigned int uNumSubIndices;
Ritor1
parents:
diff changeset
94 struct Directory *pSubIndices;
Ritor1
parents:
diff changeset
95 unsigned int uOffsetToSubIndex;
Ritor1
parents:
diff changeset
96 FILE *pOutputFileHandle;
Ritor1
parents:
diff changeset
97 };
Ritor1
parents:
diff changeset
98 #pragma pack(pop)
Ritor1
parents:
diff changeset
99 };
Ritor1
parents:
diff changeset
100
Ritor1
parents:
diff changeset
101
Ritor1
parents:
diff changeset
102
Ritor1
parents:
diff changeset
103
Ritor1
parents:
diff changeset
104
Ritor1
parents:
diff changeset
105
Ritor1
parents:
diff changeset
106 /* 6 */
Ritor1
parents:
diff changeset
107 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
108 struct LODWriteableFile: public LOD::File
Ritor1
parents:
diff changeset
109 {
Ritor1
parents:
diff changeset
110 bool LoadFile(const char *pFilename, bool bWriting);
Ritor1
parents:
diff changeset
111 unsigned int Write(const LOD::Directory *pDir, const void *pDirData, int a4);
Ritor1
parents:
diff changeset
112 void CloseWriteFile();
Ritor1
parents:
diff changeset
113 int CreateTempFile();
Ritor1
parents:
diff changeset
114 int Save();
Ritor1
parents:
diff changeset
115 bool _4621A7();
Ritor1
parents:
diff changeset
116 int _461492(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source);
Ritor1
parents:
diff changeset
117
Ritor1
parents:
diff changeset
118 /*FILE *pFile;
Ritor1
parents:
diff changeset
119 char pLODName[256];
Ritor1
parents:
diff changeset
120 unsigned int isFileOpened;
Ritor1
parents:
diff changeset
121 unsigned __int8 *pIOBuffer;
Ritor1
parents:
diff changeset
122 unsigned int uIOBufferSize;
Ritor1
parents:
diff changeset
123 struct LOD::FileHeader header;
Ritor1
parents:
diff changeset
124 struct LOD::Directory *pRoot;
Ritor1
parents:
diff changeset
125 unsigned __int8 pContainerName[16];
Ritor1
parents:
diff changeset
126 unsigned int uCurrentIndexDir;
Ritor1
parents:
diff changeset
127 unsigned int uLODDataSize;
Ritor1
parents:
diff changeset
128 unsigned int uNumSubIndices;
Ritor1
parents:
diff changeset
129 struct LOD::Directory *pSubIndices;
Ritor1
parents:
diff changeset
130 unsigned int uOffsetToSubIndex;
Ritor1
parents:
diff changeset
131 FILE *pOutputFileHandle;*/
Ritor1
parents:
diff changeset
132 };
Ritor1
parents:
diff changeset
133 #pragma pack(pop)
Ritor1
parents:
diff changeset
134
Ritor1
parents:
diff changeset
135
Ritor1
parents:
diff changeset
136
Ritor1
parents:
diff changeset
137
Ritor1
parents:
diff changeset
138 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
139 struct LODFile_IconsBitmaps: public LOD::File
Ritor1
parents:
diff changeset
140 {
Ritor1
parents:
diff changeset
141 LODFile_IconsBitmaps();
Ritor1
parents:
diff changeset
142 virtual ~LODFile_IconsBitmaps();
Ritor1
parents:
diff changeset
143 int _40F9C5();
Ritor1
parents:
diff changeset
144 unsigned int FindTextureByName(const char *pName);
Ritor1
parents:
diff changeset
145 bool LoadBitmaps(const char *pFilename);
Ritor1
parents:
diff changeset
146 bool LoadIconsOrEvents(const char *pLODFilename);
Ritor1
parents:
diff changeset
147 void ReleaseAll();
Ritor1
parents:
diff changeset
148 unsigned int LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT);
Ritor1
parents:
diff changeset
149 Texture *LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT);
Ritor1
parents:
diff changeset
150 int LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType);
Ritor1
parents:
diff changeset
151 int ReloadTexture(Texture *pDst, const char *pContainer, int mode);
Ritor1
parents:
diff changeset
152 void ReleaseHardwareTextures();
Ritor1
parents:
diff changeset
153 void ReleaseLostHardwareTextures();
Ritor1
parents:
diff changeset
154 void _410423_move_textures_to_device();
Ritor1
parents:
diff changeset
155 int _410522(Texture *pDst, const char *pContainer, unsigned int uTextureType);
Ritor1
parents:
diff changeset
156 void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits);
Ritor1
parents:
diff changeset
157 void ReleaseAll2();
Ritor1
parents:
diff changeset
158 void _4114F2();
Ritor1
parents:
diff changeset
159 void _4355F7();
Ritor1
parents:
diff changeset
160
Ritor1
parents:
diff changeset
161
Ritor1
parents:
diff changeset
162 /*FILE *pFile;
Ritor1
parents:
diff changeset
163 unsigned __int8 pLODName[256];
Ritor1
parents:
diff changeset
164 unsigned int isFileOpened;
Ritor1
parents:
diff changeset
165 unsigned __int8 *pIOBuffer;
Ritor1
parents:
diff changeset
166 unsigned int uIOBufferSize;
Ritor1
parents:
diff changeset
167 struct LOD::FileHeader header;
Ritor1
parents:
diff changeset
168 struct LOD::Directory *pRoot;
Ritor1
parents:
diff changeset
169 unsigned __int8 pContainerName[16];
Ritor1
parents:
diff changeset
170 unsigned int uCurrentIndexDir;
Ritor1
parents:
diff changeset
171 unsigned int uLODDataSize;
Ritor1
parents:
diff changeset
172 unsigned int uNumSubIndices;
Ritor1
parents:
diff changeset
173 struct LOD::Directory *pSubIndices;
Ritor1
parents:
diff changeset
174 unsigned int uOffsetToSubIndex;
Ritor1
parents:
diff changeset
175 FILE *pOutputFileHandle;*/
Ritor1
parents:
diff changeset
176 struct Texture pTextures[1000];
Ritor1
parents:
diff changeset
177 unsigned int uNumLoadedFiles;
Ritor1
parents:
diff changeset
178 int dword_11B80;
Ritor1
parents:
diff changeset
179 int dword_11B84;
Ritor1
parents:
diff changeset
180 int dword_11B88;
Ritor1
parents:
diff changeset
181 int uTextureRedBits;
Ritor1
parents:
diff changeset
182 int uTextureGreenBits;
Ritor1
parents:
diff changeset
183 int uTextureBlueBits;
Ritor1
parents:
diff changeset
184 int uNumPrevLoadedFiles;
Ritor1
parents:
diff changeset
185 int uTexturePacksCount;
33
a9e9c6989d04 20.01.13
Ritor1
parents: 0
diff changeset
186 int pFacesLock;
0
Ritor1
parents:
diff changeset
187 int dword_011BA4;
Ritor1
parents:
diff changeset
188 int dword_011BA8;
Ritor1
parents:
diff changeset
189 struct IDirectDrawSurface **pHardwareSurfaces;
Ritor1
parents:
diff changeset
190 struct IDirect3DTexture2 **pHardwareTextures;
Ritor1
parents:
diff changeset
191 char *ptr_011BB4;
Ritor1
parents:
diff changeset
192 };
Ritor1
parents:
diff changeset
193 #pragma pack(pop)
Ritor1
parents:
diff changeset
194
Ritor1
parents:
diff changeset
195
Ritor1
parents:
diff changeset
196
Ritor1
parents:
diff changeset
197
Ritor1
parents:
diff changeset
198
Ritor1
parents:
diff changeset
199
Ritor1
parents:
diff changeset
200 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
201 struct LODSprite
Ritor1
parents:
diff changeset
202 {
Ritor1
parents:
diff changeset
203 //----- (0046244C) --------------------------------------------------------
Ritor1
parents:
diff changeset
204 inline LODSprite()
Ritor1
parents:
diff changeset
205 {
Ritor1
parents:
diff changeset
206 uHeight = 0;
Ritor1
parents:
diff changeset
207 uPaletteId = 0;
Ritor1
parents:
diff changeset
208 word_1A = 0;
Ritor1
parents:
diff changeset
209 pSpriteLines = nullptr;
Ritor1
parents:
diff changeset
210 pDecompressedBytes = nullptr;
Ritor1
parents:
diff changeset
211 }
Ritor1
parents:
diff changeset
212 ~LODSprite();
Ritor1
parents:
diff changeset
213
Ritor1
parents:
diff changeset
214 void Release();
Ritor1
parents:
diff changeset
215 int _4ACC38(struct RenderBillboardTransform_local0 *a2, char a3);
Ritor1
parents:
diff changeset
216 int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3);
Ritor1
parents:
diff changeset
217
Ritor1
parents:
diff changeset
218 char pName[12];
Ritor1
parents:
diff changeset
219 int uSpriteSize;
Ritor1
parents:
diff changeset
220 __int16 uWidth;
Ritor1
parents:
diff changeset
221 __int16 uHeight;
Ritor1
parents:
diff changeset
222 __int16 uPaletteId;
Ritor1
parents:
diff changeset
223 __int16 word_16;
Ritor1
parents:
diff changeset
224 __int16 uTexturePitch;
Ritor1
parents:
diff changeset
225 __int16 word_1A;
Ritor1
parents:
diff changeset
226 int uDecompressedSize;
Ritor1
parents:
diff changeset
227 struct LODSprite_stru0 *pSpriteLines;
Ritor1
parents:
diff changeset
228 void *pDecompressedBytes;
Ritor1
parents:
diff changeset
229 };
Ritor1
parents:
diff changeset
230 #pragma pack(pop)
Ritor1
parents:
diff changeset
231
Ritor1
parents:
diff changeset
232 /* 15 */
Ritor1
parents:
diff changeset
233 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
234 struct LODFile_Sprites: public LOD::File
Ritor1
parents:
diff changeset
235 {
Ritor1
parents:
diff changeset
236 LODFile_Sprites();
Ritor1
parents:
diff changeset
237 virtual ~LODFile_Sprites();
Ritor1
parents:
diff changeset
238
Ritor1
parents:
diff changeset
239 void DeleteSomeSprites();
Ritor1
parents:
diff changeset
240 void DeleteSpritesRange(int uStartIndex, int uStopIndex);
Ritor1
parents:
diff changeset
241 int _461397();
Ritor1
parents:
diff changeset
242 void DeleteSomeOtherSprites();
Ritor1
parents:
diff changeset
243 int LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer);
Ritor1
parents:
diff changeset
244 bool LoadSprites(const char *pFilename);
Ritor1
parents:
diff changeset
245 int LoadSprite(const char *pContainerName, unsigned int uPaletteID);
Ritor1
parents:
diff changeset
246 void ReleaseLostHardwareSprites();
Ritor1
parents:
diff changeset
247 void ReleaseAll();
Ritor1
parents:
diff changeset
248 void MoveSpritesToVideoMemory();
Ritor1
parents:
diff changeset
249
Ritor1
parents:
diff changeset
250
Ritor1
parents:
diff changeset
251 /*FILE *pFile;
Ritor1
parents:
diff changeset
252 unsigned __int8 pLODName[256];
Ritor1
parents:
diff changeset
253 unsigned int isFileOpened;
Ritor1
parents:
diff changeset
254 unsigned __int8 *pIOBuffer;
Ritor1
parents:
diff changeset
255 unsigned int uIOBufferSize;
Ritor1
parents:
diff changeset
256 struct LOD::FileHeader header;
Ritor1
parents:
diff changeset
257 struct LOD::Directory *pRoot;
Ritor1
parents:
diff changeset
258 unsigned __int8 pContainerName[16];
Ritor1
parents:
diff changeset
259 unsigned int uCurrentIndexDir;
Ritor1
parents:
diff changeset
260 unsigned int uLODDataSize;
Ritor1
parents:
diff changeset
261 unsigned int uNumSubIndices;
Ritor1
parents:
diff changeset
262 struct LOD::Directory *pSubIndices;
Ritor1
parents:
diff changeset
263 unsigned int uOffsetToSubIndex;
Ritor1
parents:
diff changeset
264 FILE *pOutputFileHandle;*/
Ritor1
parents:
diff changeset
265 struct LODSprite pSpriteHeaders[1500];
Ritor1
parents:
diff changeset
266 unsigned int uNumLoadedSprites;
Ritor1
parents:
diff changeset
267 int field_ECA0;
Ritor1
parents:
diff changeset
268 int field_ECA4;
Ritor1
parents:
diff changeset
269 int field_ECA8;
Ritor1
parents:
diff changeset
270 int field_ECAC;
Ritor1
parents:
diff changeset
271 struct Sprite *pHardwareSprites;
Ritor1
parents:
diff changeset
272 int field_ECB4;
Ritor1
parents:
diff changeset
273 };
Ritor1
parents:
diff changeset
274 #pragma pack(pop)
Ritor1
parents:
diff changeset
275
Ritor1
parents:
diff changeset
276 /* 17 */
Ritor1
parents:
diff changeset
277 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
278 struct LODSprite_stru0
Ritor1
parents:
diff changeset
279 {
Ritor1
parents:
diff changeset
280 int dword_0;
Ritor1
parents:
diff changeset
281 void *ptr_4;
Ritor1
parents:
diff changeset
282 };
Ritor1
parents:
diff changeset
283 #pragma pack(pop)
Ritor1
parents:
diff changeset
284
Ritor1
parents:
diff changeset
285
Ritor1
parents:
diff changeset
286
Ritor1
parents:
diff changeset
287
Ritor1
parents:
diff changeset
288 extern LODFile_IconsBitmaps *pEvents_LOD;
Ritor1
parents:
diff changeset
289 extern LODFile_IconsBitmaps *pIcons_LOD;
Ritor1
parents:
diff changeset
290 extern LODFile_Sprites *pSprites_LOD;
Ritor1
parents:
diff changeset
291 extern LODFile_IconsBitmaps *pBitmaps_LOD;
Ritor1
parents:
diff changeset
292
Ritor1
parents:
diff changeset
293 extern LODWriteableFile *pNew_LOD;
Ritor1
parents:
diff changeset
294 extern LODWriteableFile *pGames_LOD;
Ritor1
parents:
diff changeset
295
Ritor1
parents:
diff changeset
296
Ritor1
parents:
diff changeset
297
Ritor1
parents:
diff changeset
298
Ritor1
parents:
diff changeset
299 extern int _6A0CA4_lod_binary_search; // weak
Ritor1
parents:
diff changeset
300 extern int _6A0CA8_lod_unused; // weak