comparison Render.cpp @ 810:f5156b8c61ad

savegame refactoring
author Gloval
date Tue, 26 Mar 2013 00:57:54 +0400
parents 41b4e9769863
children 6dd2b94efce7 710cf848ad24
comparison
equal deleted inserted replaced
796:14beae4f1723 810:f5156b8c61ad
5202 } 5202 }
5203 } 5203 }
5204 // 4EFA84: using guessed type int dword_4EFA84; 5204 // 4EFA84: using guessed type int dword_4EFA84;
5205 5205
5206 //----- (0049F5A2) -------------------------------------------------------- 5206 //----- (0049F5A2) --------------------------------------------------------
5207 int Render::_49F5A2(int a2, int a3, int a4, void *Dst, int a6, int a7) 5207 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size )
5208 { 5208 {
5209 Render *v7; // ebx@1 5209 Render *v7; // ebx@1
5210 void *v8; // esi@3 5210 void *v8; // esi@3
5211 void *v9; // esi@3 5211 void *v9; // esi@3
5212 int v10; // ecx@4 5212 int v10; // ecx@4
5213 int v11; // eax@4 5213 unsigned short* v11; // eax@4
5214 int v12; // eax@6 5214 int v12; // eax@6
5215 int v13; // eax@8 5215 int v13; // eax@8
5216 int v14; // ecx@8 5216 int v14; // ecx@8
5217 signed int v15; // eax@11 5217 signed int v15; // eax@11
5218 char v16; // zf@20 5218 char v16; // zf@20
5219 int result; // eax@21 5219 int result; // eax@21
5220 char v18[58]; // [sp+Ch] [bp-ACh]@3 5220 char v18[58]; // [sp+Ch] [bp-ACh]@3
5221 // __int16 v19; // [sp+44h] [bp-74h]@3 5221 // __int16 v19; // [sp+44h] [bp-74h]@3
5222 char v20[48]; // [sp+48h] [bp-70h]@3 5222 char v20[48]; // [sp+48h] [bp-70h]@3
5223 char *v21; // [sp+78h] [bp-40h]@7 5223 char *lineG; // [sp+78h] [bp-40h]@7
5224 char *v22; // [sp+7Ch] [bp-3Ch]@7 5224 char *lineB; // [sp+7Ch] [bp-3Ch]@7
5225 int v23; // [sp+80h] [bp-38h]@4 5225 int v23; // [sp+80h] [bp-38h]@4
5226 int v24; // [sp+84h] [bp-34h]@4 5226 int v24; // [sp+84h] [bp-34h]@4
5227 int v25; // [sp+88h] [bp-30h]@4 5227 int v25; // [sp+88h] [bp-30h]@4
5228 int v26; // [sp+8Ch] [bp-2Ch]@4 5228 int v26; // [sp+8Ch] [bp-2Ch]@4
5229 char Src; // [sp+90h] [bp-28h]@3 5229 PCXHeader_1 Src; // [sp+90h] [bp-28h]@3
5230 char v28; // [sp+91h] [bp-27h]@3 5230 PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3
5231 char v29; // [sp+92h] [bp-26h]@3 5231 char *lineRGB; // [sp+A8h] [bp-10h]@3
5232 char v30; // [sp+93h] [bp-25h]@3 5232 int pitch; // [sp+ACh] [bp-Ch]@1
5233 __int16 v31; // [sp+94h] [bp-24h]@3
5234 __int16 v32; // [sp+96h] [bp-22h]@3
5235 __int16 v33; // [sp+98h] [bp-20h]@3
5236 __int16 v34; // [sp+9Ah] [bp-1Eh]@3
5237 __int16 v35; // [sp+9Ch] [bp-1Ch]@3
5238 __int16 v36; // [sp+9Eh] [bp-1Ah]@3
5239 char v37; // [sp+A0h] [bp-18h]@3
5240 char v38; // [sp+A1h] [bp-17h]@3
5241 __int16 v39; // [sp+A2h] [bp-16h]@3
5242 __int16 v40; // [sp+A4h] [bp-14h]@3
5243 void *ptr; // [sp+A8h] [bp-10h]@3
5244 int v42; // [sp+ACh] [bp-Ch]@1
5245 char v43; // [sp+B3h] [bp-5h]@18 5233 char v43; // [sp+B3h] [bp-5h]@18
5246 int i; // [sp+B4h] [bp-4h]@6 5234 int i; // [sp+B4h] [bp-4h]@6
5235 unsigned short* line_pictute_data;
5236 byte test_byte;
5237 unsigned char pict_byte;
5247 5238
5248 v7 = this; 5239 v7 = this;
5249 v42 = a3; 5240 pitch = wight;
5250 if ( a3 & 1 ) 5241 if ( wight & 1 )
5251 v42 = a3 + 1; 5242 pitch = wight + 1;
5252 v31 = 0; 5243 Src.left = 0;
5253 v32 = 0; 5244 Src.up = 0;
5254 v33 = a3 - 1; 5245 Src.right = wight - 1;
5255 v34 = a4 - 1; 5246 Src.bottom = heidth - 1;
5256 v39 = v42; 5247 v27.pitch = pitch;
5257 memset(&v20, 0, 0x30u); 5248 memset(&v20, 0, 0x30u);
5258 memset(&v18, 0, 0x38u); 5249 memset(&v18, 0, 0x38u);
5259 v8 = Dst; 5250 v8 = data_buff;
5260 v37 = 0; 5251 v27.reserved = 0;
5261 *(_WORD *)&v18[56] = 0; 5252 *(_WORD *)&v18[56] = 0;
5262 Src = 10; 5253 Src.manufacturer = 10;
5263 v28 = 5; 5254 Src.version = 5;
5264 v29 = 1; 5255 Src.encoding = 1;
5265 v30 = 8; 5256 Src.bpp = 8;
5266 v35 = 75; 5257 Src.hdpi = 75;
5267 v36 = 75; 5258 Src.vdpi = 75;
5268 v38 = 3; 5259 v27.planes = 3;
5269 v40 = 1; 5260 v27.palette_info = 1;
5270 memcpy(Dst, &Src, 1u); 5261 memcpy(data_buff, &Src, 1u);
5271 v8 = (char *)v8 + 1; 5262 v8 = (char *)v8 + 1;
5272 memcpy(v8, &v28, 1u); 5263 memcpy(v8, &Src.version, 1u);
5273 v8 = (char *)v8 + 1; 5264 v8 = (char *)v8 + 1;
5274 memcpy(v8, &v29, 1u); 5265 memcpy(v8, &Src.encoding, 1u);
5275 v8 = (char *)v8 + 1; 5266 v8 = (char *)v8 + 1;
5276 memcpy(v8, &v30, 1u); 5267 memcpy(v8, &Src.bpp, 1u);
5277 v8 = (char *)v8 + 1; 5268 v8 = (char *)v8 + 1;
5278 memcpy(v8, &v31, 2u); 5269 memcpy(v8, &Src.left, 2u);
5279 v8 = (char *)v8 + 2; 5270 v8 = (char *)v8 + 2;
5280 memcpy(v8, &v32, 2u); 5271 memcpy(v8, &Src.up, 2u);
5281 v8 = (char *)v8 + 2; 5272 v8 = (char *)v8 + 2;
5282 memcpy(v8, &v33, 2u); 5273 memcpy(v8, &Src.right, 2u);
5283 v8 = (char *)v8 + 2; 5274 v8 = (char *)v8 + 2;
5284 memcpy(v8, &v34, 2u); 5275 memcpy(v8, &Src.bottom, 2u);
5285 v8 = (char *)v8 + 2; 5276 v8 = (char *)v8 + 2;
5286 memcpy(v8, &v35, 2u); 5277 memcpy(v8, &Src.hdpi, 2u);
5287 v8 = (char *)v8 + 2; 5278 v8 = (char *)v8 + 2;
5288 memcpy(v8, &v36, 2u); 5279 memcpy(v8, &Src.vdpi, 2u);
5289 v8 = (char *)v8 + 2; 5280 v8 = (char *)v8 + 2;
5290 memcpy(v8, &v20, 0x30u); 5281 memcpy(v8, &v20, 0x30u);
5291 v8 = (char *)v8 + 48; 5282 v8 = (char *)v8 + 48;
5292 memcpy(v8, &v37, 1u); 5283 memcpy(v8, &v27, 1u);
5293 v8 = (char *)v8 + 1; 5284 v8 = (char *)v8 + 1;
5294 memcpy(v8, &v38, 1u); 5285 memcpy(v8, &v27.planes, 1u);
5295 v8 = (char *)v8 + 1; 5286 v8 = (char *)v8 + 1;
5296 memcpy(v8, &v39, 2u); 5287 memcpy(v8, &v27.pitch, 2u);
5297 v8 = (char *)v8 + 2; 5288 v8 = (char *)v8 + 2;
5298 memcpy(v8, &v40, 2u); 5289 memcpy(v8, &v27.palette_info, 2u);
5299 v8 = (char *)v8 + 2; 5290 v8 = (char *)v8 + 2;
5300 memcpy(v8, &v18, 0x3Au); 5291 memcpy(v8, &v18, 0x3Au);
5301 v9 = (char *)v8 + 58; 5292 v9 = (char *)v8 + 58;
5302 ptr = pAllocator->AllocNamedChunk(0, 3 * a3 + 6, 0); 5293
5303 if ( a4 > 0 ) 5294 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0);
5304 { 5295 if ( heidth > 0 )
5305 v10 = v42; 5296 {
5306 v25 = a4; 5297 v10 = pitch;
5307 v26 = 3 * v42; 5298 v25 = heidth;
5308 v23 = 2 * a3; 5299 v26 = 3 * pitch;
5309 v11 = a2; 5300 v23 = 2 * wight;
5310 v24 = a2; 5301 v11 = picture_data;
5302 v24 = (int)picture_data;
5311 while ( 1 ) 5303 while ( 1 )
5312 { 5304 {
5313 a4 = v11; 5305 line_pictute_data = v11;
5314 v12 = 0; 5306 v12 = 0;
5315 i = 0; 5307 i = 0;
5316 if ( a3 > 0 ) 5308 if ( wight > 0 )
5317 { 5309 {
5318 v21 = (char *)ptr + v10; 5310 lineG = (char *)lineRGB + pitch;
5319 v22 = (char *)ptr + 2 * v42; 5311 lineB = (char *)lineRGB + 2 * pitch;
5320 do 5312 do
5321 { 5313 {
5322 *((char *)ptr + v12) = (signed int)(v7->uTargetRMask & *(short *)a4) >> (LOBYTE(v7->uTargetGBits) 5314 lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8);
5323 + LOBYTE(v7->uTargetBBits) 5315 lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8);
5324 + v7->uTargetRBits 5316 lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits);
5325 - 8); 5317
5326 v13 = i; 5318 v12++;
5327 v21[i] = (signed int)(v7->uTargetGMask & *(short *)a4) >> (LOBYTE(v7->uTargetBBits) 5319 }
5328 + LOBYTE(v7->uTargetGBits) 5320 while ( v12 < wight );
5329 - 8);
5330 v14 = a4;
5331 a4 += 2;
5332 v22[v13] = (v7->uTargetBMask & *(char *)v14) << (8 - LOBYTE(v7->uTargetBBits));
5333 v12 = v13 + 1;
5334 i = v12;
5335 }
5336 while ( v12 < a3 );
5337 } 5321 }
5338 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) 5322 for ( i = 0; i < v26; v9 = (char *)v9 + 1 )
5339 { 5323 {
5340 BYTE3(a4) = 1; 5324 test_byte = 1;
5341 BYTE3(a2) = *((char *)ptr + i); 5325 pict_byte = lineRGB [i];
5342 do 5326 do
5343 { 5327 {
5344 v15 = i + BYTE3(a4); 5328 v15 = i + test_byte;
5345 if ( *((char *)ptr + v15) != BYTE3(a2) ) 5329 if ( *((char *)lineRGB + v15) != pict_byte )
5346 break; 5330 break;
5347 if ( !(v15 % v42) ) 5331 if ( !(v15 % pitch) )
5348 break; 5332 break;
5349 ++BYTE3(a4); 5333 ++test_byte;
5350 } 5334 }
5351 while ( BYTE3(a4) < 0x3Fu ); 5335 while ( test_byte < 0x3Fu );
5352 if ( i + BYTE3(a4) > v26 ) 5336 if ( i + test_byte > v26 )
5353 BYTE3(a4) = 3 * v42 - i; 5337 test_byte = 3 * pitch - i;
5354 if ( BYTE3(a4) > 1u || BYTE3(a2) >= 0xC0u ) 5338 if ( test_byte > 1u || pict_byte >= 0xC0u )
5355 { 5339 {
5356 v43 = BYTE3(a4) | 0xC0; 5340 v43 = test_byte | 0xC0;
5357 memcpy(v9, &v43, 1u); 5341 memcpy(v9, &v43, 1u);
5358 v9 = (char *)v9 + 1; 5342 v9 = (char *)v9 + 1;
5359 } 5343 }
5360 memcpy(v9, (char *)&a2 + 3, 1u); 5344 memcpy(v9, &pict_byte, 1u);
5361 i += BYTE3(a4); 5345 i += test_byte;
5362 } 5346 }
5363 v11 = v23 + v24; 5347 v11 +=wight ;
5364 v16 = v25-- == 1; 5348 v16 = v25-- == 1;
5365 v24 += v23; 5349
5366 if ( v16 ) 5350 if ( v16 )
5367 break; 5351 break;
5368 v10 = v42; 5352 v10 = pitch;
5369 } 5353 }
5370 } 5354 }
5371 pAllocator->FreeChunk(ptr); 5355 pAllocator->FreeChunk(lineRGB);
5372 result = a7; 5356 *(int *)packed_size = (char *)v9 - data_buff;
5373 *(int *)a7 = (char *)v9 - Dst; 5357
5374 return result;
5375 } 5358 }
5376 5359
5377 //----- (0049F8B5) -------------------------------------------------------- 5360 //----- (0049F8B5) --------------------------------------------------------
5378 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) 5361 FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5)
5379 { 5362 {