Mercurial > mm7
annotate LOD.h @ 2363:7966fc2949a7
Merge
author | Grumpy7 |
---|---|
date | Thu, 01 May 2014 12:59:50 +0200 |
parents | d04017f3d2fa |
children | e07e297f292d |
rev | line source |
---|---|
0 | 1 #pragma once |
2 #include <stdio.h> | |
3 #include <memory.h> | |
4 | |
5 #include "Texture.h" | |
6 | |
1103 | 7 class Sprite; |
0 | 8 |
1632 | 9 |
10 #define MAX_LOD_TEXTURES 1000 | |
11 #define MAX_LOD_SPRITES 1500 | |
12 | |
0 | 13 /* 354 */ |
14 enum TEXTURE_TYPE | |
15 { | |
16 TEXTURE_DEFAULT = 0, | |
17 TEXTURE_24BIT_PALETTE = 0x1, | |
18 TEXTURE_16BIT_PALETTE = 0x2, | |
19 }; | |
20 | |
21 namespace LOD | |
22 { | |
23 #pragma pack(push, 1) | |
24 struct FileHeader | |
25 { | |
982 | 26 //----- (004617B6) -------------------------------------------------------- |
0 | 27 inline FileHeader() |
28 { | |
29 memset(pSignature, 0, 4); | |
30 memset(LodVersion, 0, 80); | |
31 memset(LodDescription, 0, 80); | |
32 memset(array_0000B0, 0, 28); | |
33 memset(array_0000CC, 0, 52); | |
982 | 34 |
35 pSignature[0] = 0; | |
36 LodVersion[0] = 0; | |
37 LodDescription[0] = 0; | |
38 LODSize = 0; | |
39 dword_0000A8 = 0; | |
40 uNumIndices = 0; | |
0 | 41 } |
42 | |
43 char pSignature[4]; | |
44 char LodVersion[80]; | |
45 //char field_C[32]; | |
46 //char field_2C[40]; | |
47 char LodDescription[80]; | |
48 int LODSize; | |
49 int dword_0000A8; | |
50 unsigned int uNumIndices; | |
51 char array_0000B0[28]; | |
52 char array_0000CC[52]; | |
53 }; | |
54 #pragma pack(pop) | |
55 | |
56 | |
57 #pragma pack(push, 1) | |
58 struct Directory | |
59 { | |
60 Directory(); | |
61 | |
982 | 62 char pFilename[15]; |
63 char field_F; | |
0 | 64 unsigned int uOfsetFromSubindicesStart; |
65 unsigned int uDataSize; | |
66 int dword_000018; | |
67 unsigned __int16 uNumSubIndices; | |
68 __int16 word_00001E; | |
69 }; | |
70 #pragma pack(pop) | |
71 | |
72 | |
73 #pragma pack(push, 1) | |
74 struct File | |
75 { | |
76 File(); | |
77 virtual ~File(); | |
78 void *LoadRaw(const char *pContainer, int a3); | |
79 FILE *FindContainer(const char *pContainerName, bool bLinearSearch); | |
80 bool DoesContainerExist(const char *pContainer); | |
81 int CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName); | |
82 bool LoadHeader(const char *pFilename, bool bWriting); | |
83 int LoadSubIndices(const char *pContainer); | |
84 void AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize); | |
85 void FreeSubIndexAndIO(); | |
86 bool AppendDirectory(LOD::Directory *pDir, const void *pData); | |
87 void ResetSubIndices(); | |
88 void Close(); | |
89 | |
90 FILE *pFile; | |
91 char pLODName[256]; | |
2165 | 92 bool isFileOpened; |
0 | 93 unsigned __int8 *pIOBuffer; |
94 unsigned int uIOBufferSize; | |
95 struct FileHeader header; | |
96 struct Directory *pRoot; | |
97 char pContainerName[16]; | |
98 unsigned int uCurrentIndexDir; | |
99 unsigned int uLODDataSize; | |
837 | 100 unsigned int uNumSubDirs; |
0 | 101 struct Directory *pSubIndices; |
102 unsigned int uOffsetToSubIndex; | |
103 FILE *pOutputFileHandle; | |
104 }; | |
105 #pragma pack(pop) | |
106 }; | |
107 | |
108 | |
109 | |
110 | |
111 | |
112 | |
113 /* 6 */ | |
114 #pragma pack(push, 1) | |
115 struct LODWriteableFile: public LOD::File | |
116 { | |
117 bool LoadFile(const char *pFilename, bool bWriting); | |
118 unsigned int Write(const LOD::Directory *pDir, const void *pDirData, int a4); | |
119 void CloseWriteFile(); | |
120 int CreateTempFile(); | |
837 | 121 int FixDirectoryOffsets(); |
0 | 122 bool _4621A7(); |
837 | 123 int CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source); |
0 | 124 |
125 /*FILE *pFile; | |
126 char pLODName[256]; | |
127 unsigned int isFileOpened; | |
128 unsigned __int8 *pIOBuffer; | |
129 unsigned int uIOBufferSize; | |
130 struct LOD::FileHeader header; | |
131 struct LOD::Directory *pRoot; | |
132 unsigned __int8 pContainerName[16]; | |
133 unsigned int uCurrentIndexDir; | |
134 unsigned int uLODDataSize; | |
135 unsigned int uNumSubIndices; | |
136 struct LOD::Directory *pSubIndices; | |
137 unsigned int uOffsetToSubIndex; | |
138 FILE *pOutputFileHandle;*/ | |
139 }; | |
140 #pragma pack(pop) | |
141 | |
142 | |
143 | |
144 | |
145 #pragma pack(push, 1) | |
146 struct LODFile_IconsBitmaps: public LOD::File | |
147 { | |
148 LODFile_IconsBitmaps(); | |
149 virtual ~LODFile_IconsBitmaps(); | |
1006 | 150 void SyncLoadedFilesCount(); |
0 | 151 unsigned int FindTextureByName(const char *pName); |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
152 bool Load(const char *pFilename, const char *pFolderName); |
0 | 153 void ReleaseAll(); |
154 unsigned int LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); | |
1262 | 155 struct Texture *LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); |
156 int LoadTextureFromLOD(struct Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType); | |
157 int ReloadTexture(struct Texture *pDst, const char *pContainer, int mode); | |
0 | 158 void ReleaseHardwareTextures(); |
159 void ReleaseLostHardwareTextures(); | |
160 void _410423_move_textures_to_device(); | |
1262 | 161 int _410522(struct Texture *pDst, const char *pContainer, unsigned int uTextureType); |
0 | 162 void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits); |
163 void ReleaseAll2(); | |
1405
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
164 void RemoveTexturesPackFromTextureList(); |
c0b273d33338
RemoveTexturesPackFromTextureList and RemoveTexturesFromTextureList
Ritor1
parents:
1404
diff
changeset
|
165 void RemoveTexturesFromTextureList(); |
762 | 166 void _inlined_sub0(); |
167 void _inlined_sub1(); | |
168 void _inlined_sub2(); | |
0 | 169 |
1632 | 170 inline int LoadDummyTexture() |
434 | 171 { |
1632 | 172 for (unsigned int i = 0; i < uNumLoadedFiles; ++i) |
173 if (!strcmp(pTextures[i].pName, "pending")) | |
174 return i; | |
175 return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE); | |
176 } | |
177 | |
2336 | 178 Texture *GetTexture(int idx); |
434 | 179 |
0 | 180 |
181 /*FILE *pFile; | |
182 unsigned __int8 pLODName[256]; | |
183 unsigned int isFileOpened; | |
184 unsigned __int8 *pIOBuffer; | |
185 unsigned int uIOBufferSize; | |
186 struct LOD::FileHeader header; | |
187 struct LOD::Directory *pRoot; | |
188 unsigned __int8 pContainerName[16]; | |
189 unsigned int uCurrentIndexDir; | |
190 unsigned int uLODDataSize; | |
191 unsigned int uNumSubIndices; | |
192 struct LOD::Directory *pSubIndices; | |
193 unsigned int uOffsetToSubIndex; | |
194 FILE *pOutputFileHandle;*/ | |
1632 | 195 Texture pTextures[MAX_LOD_TEXTURES]; |
0 | 196 unsigned int uNumLoadedFiles; |
197 int dword_11B80; | |
198 int dword_11B84; | |
199 int dword_11B88; | |
200 int uTextureRedBits; | |
201 int uTextureGreenBits; | |
202 int uTextureBlueBits; | |
203 int uNumPrevLoadedFiles; | |
204 int uTexturePacksCount; | |
33 | 205 int pFacesLock; |
0 | 206 int dword_011BA4; |
2154 | 207 //int can_load_hardware_sprites; |
0 | 208 struct IDirectDrawSurface **pHardwareSurfaces; |
209 struct IDirect3DTexture2 **pHardwareTextures; | |
210 char *ptr_011BB4; | |
211 }; | |
212 #pragma pack(pop) | |
213 | |
214 | |
215 | |
216 | |
217 | |
218 | |
219 #pragma pack(push, 1) | |
220 struct LODSprite | |
221 { | |
222 //----- (0046244C) -------------------------------------------------------- | |
223 inline LODSprite() | |
224 { | |
225 uHeight = 0; | |
226 uPaletteId = 0; | |
227 word_1A = 0; | |
228 pSpriteLines = nullptr; | |
229 pDecompressedBytes = nullptr; | |
230 } | |
231 ~LODSprite(); | |
232 | |
233 void Release(); | |
733 | 234 int DrawSprite_sw(struct RenderBillboardTransform_local0 *a2, char a3); |
0 | 235 int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3); |
236 | |
670 | 237 char pName[12]; //0 |
238 int uSpriteSize; //C | |
239 __int16 uWidth; //10 | |
240 __int16 uHeight; //12 | |
241 __int16 uPaletteId; //14 | |
242 __int16 word_16; //16 | |
243 __int16 uTexturePitch; //18 | |
244 __int16 word_1A; //1a | |
245 int uDecompressedSize; //1c | |
246 struct LODSprite_stru0 *pSpriteLines; //20 | |
247 void *pDecompressedBytes; //24 | |
0 | 248 }; |
249 #pragma pack(pop) | |
250 | |
251 /* 15 */ | |
252 #pragma pack(push, 1) | |
253 struct LODFile_Sprites: public LOD::File | |
254 { | |
255 LODFile_Sprites(); | |
256 virtual ~LODFile_Sprites(); | |
257 | |
258 void DeleteSomeSprites(); | |
259 void DeleteSpritesRange(int uStartIndex, int uStopIndex); | |
260 int _461397(); | |
261 void DeleteSomeOtherSprites(); | |
262 int LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer); | |
263 bool LoadSprites(const char *pFilename); | |
264 int LoadSprite(const char *pContainerName, unsigned int uPaletteID); | |
265 void ReleaseLostHardwareSprites(); | |
266 void ReleaseAll(); | |
267 void MoveSpritesToVideoMemory(); | |
762 | 268 void _inlined_sub0(); |
269 void _inlined_sub1(); | |
0 | 270 |
271 | |
272 /*FILE *pFile; | |
273 unsigned __int8 pLODName[256]; | |
274 unsigned int isFileOpened; | |
275 unsigned __int8 *pIOBuffer; | |
276 unsigned int uIOBufferSize; | |
277 struct LOD::FileHeader header; | |
278 struct LOD::Directory *pRoot; | |
279 unsigned __int8 pContainerName[16]; | |
280 unsigned int uCurrentIndexDir; | |
281 unsigned int uLODDataSize; | |
282 unsigned int uNumSubIndices; | |
283 struct LOD::Directory *pSubIndices; | |
284 unsigned int uOffsetToSubIndex; | |
285 FILE *pOutputFileHandle;*/ | |
1632 | 286 struct LODSprite pSpriteHeaders[MAX_LOD_SPRITES]; |
670 | 287 signed int uNumLoadedSprites; |
0 | 288 int field_ECA0; |
289 int field_ECA4; | |
290 int field_ECA8; | |
2154 | 291 //int can_load_hardware_sprites; |
1103 | 292 Sprite *pHardwareSprites; |
0 | 293 int field_ECB4; |
294 }; | |
295 #pragma pack(pop) | |
296 | |
297 /* 17 */ | |
298 #pragma pack(push, 1) | |
299 struct LODSprite_stru0 | |
300 { | |
301 int dword_0; | |
302 void *ptr_4; | |
303 }; | |
304 #pragma pack(pop) | |
305 | |
306 | |
307 | |
308 | |
309 extern LODFile_IconsBitmaps *pEvents_LOD; | |
1541 | 310 |
0 | 311 extern LODFile_IconsBitmaps *pIcons_LOD; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
312 extern LODFile_IconsBitmaps *pIcons_LOD_mm6; |
1541 | 313 extern LODFile_IconsBitmaps *pIcons_LOD_mm8; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
314 |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
315 extern LODFile_IconsBitmaps *pBitmaps_LOD; |
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
316 extern LODFile_IconsBitmaps *pBitmaps_LOD_mm6; |
1541 | 317 extern LODFile_IconsBitmaps *pBitmaps_LOD_mm8; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
318 |
0 | 319 extern LODFile_Sprites *pSprites_LOD; |
1477
7ef4b64f6329
* LODFile::LoadBitmaps & LODFile::LoadIconsOrEvents are merged into LODFile::Load
Nomad
parents:
1464
diff
changeset
|
320 extern LODFile_Sprites *pSprites_LOD_mm6; |
1541 | 321 extern LODFile_Sprites *pSprites_LOD_mm8; |
0 | 322 |
323 extern LODWriteableFile *pNew_LOD; | |
324 extern LODWriteableFile *pGames_LOD; | |
325 | |
326 | |
327 | |
328 | |
329 extern int _6A0CA4_lod_binary_search; // weak | |
330 extern int _6A0CA8_lod_unused; // weak |