annotate LOD.h @ 792:41b4e9769863

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