Mercurial > mm7
diff Render.cpp @ 810:f5156b8c61ad
savegame refactoring
author | Gloval |
---|---|
date | Tue, 26 Mar 2013 00:57:54 +0400 |
parents | 41b4e9769863 |
children | 6dd2b94efce7 710cf848ad24 |
line wrap: on
line diff
--- a/Render.cpp Mon Mar 25 14:56:50 2013 +0200 +++ b/Render.cpp Tue Mar 26 00:57:54 2013 +0400 @@ -5204,13 +5204,13 @@ // 4EFA84: using guessed type int dword_4EFA84; //----- (0049F5A2) -------------------------------------------------------- -int Render::_49F5A2(int a2, int a3, int a4, void *Dst, int a6, int a7) -{ +void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) + { Render *v7; // ebx@1 void *v8; // esi@3 void *v9; // esi@3 int v10; // ecx@4 - int v11; // eax@4 + unsigned short* v11; // eax@4 int v12; // eax@6 int v13; // eax@8 int v14; // ecx@8 @@ -5220,158 +5220,141 @@ char v18[58]; // [sp+Ch] [bp-ACh]@3 // __int16 v19; // [sp+44h] [bp-74h]@3 char v20[48]; // [sp+48h] [bp-70h]@3 - char *v21; // [sp+78h] [bp-40h]@7 - char *v22; // [sp+7Ch] [bp-3Ch]@7 + char *lineG; // [sp+78h] [bp-40h]@7 + char *lineB; // [sp+7Ch] [bp-3Ch]@7 int v23; // [sp+80h] [bp-38h]@4 int v24; // [sp+84h] [bp-34h]@4 int v25; // [sp+88h] [bp-30h]@4 int v26; // [sp+8Ch] [bp-2Ch]@4 - char Src; // [sp+90h] [bp-28h]@3 - char v28; // [sp+91h] [bp-27h]@3 - char v29; // [sp+92h] [bp-26h]@3 - char v30; // [sp+93h] [bp-25h]@3 - __int16 v31; // [sp+94h] [bp-24h]@3 - __int16 v32; // [sp+96h] [bp-22h]@3 - __int16 v33; // [sp+98h] [bp-20h]@3 - __int16 v34; // [sp+9Ah] [bp-1Eh]@3 - __int16 v35; // [sp+9Ch] [bp-1Ch]@3 - __int16 v36; // [sp+9Eh] [bp-1Ah]@3 - char v37; // [sp+A0h] [bp-18h]@3 - char v38; // [sp+A1h] [bp-17h]@3 - __int16 v39; // [sp+A2h] [bp-16h]@3 - __int16 v40; // [sp+A4h] [bp-14h]@3 - void *ptr; // [sp+A8h] [bp-10h]@3 - int v42; // [sp+ACh] [bp-Ch]@1 + PCXHeader_1 Src; // [sp+90h] [bp-28h]@3 + PCXHeader_2 v27; // [sp+A0h] [bp-18h]@3 + char *lineRGB; // [sp+A8h] [bp-10h]@3 + int pitch; // [sp+ACh] [bp-Ch]@1 char v43; // [sp+B3h] [bp-5h]@18 int i; // [sp+B4h] [bp-4h]@6 + unsigned short* line_pictute_data; + byte test_byte; + unsigned char pict_byte; v7 = this; - v42 = a3; - if ( a3 & 1 ) - v42 = a3 + 1; - v31 = 0; - v32 = 0; - v33 = a3 - 1; - v34 = a4 - 1; - v39 = v42; + pitch = wight; + if ( wight & 1 ) + pitch = wight + 1; + Src.left = 0; + Src.up = 0; + Src.right = wight - 1; + Src.bottom = heidth - 1; + v27.pitch = pitch; memset(&v20, 0, 0x30u); memset(&v18, 0, 0x38u); - v8 = Dst; - v37 = 0; + v8 = data_buff; + v27.reserved = 0; *(_WORD *)&v18[56] = 0; - Src = 10; - v28 = 5; - v29 = 1; - v30 = 8; - v35 = 75; - v36 = 75; - v38 = 3; - v40 = 1; - memcpy(Dst, &Src, 1u); + Src.manufacturer = 10; + Src.version = 5; + Src.encoding = 1; + Src.bpp = 8; + Src.hdpi = 75; + Src.vdpi = 75; + v27.planes = 3; + v27.palette_info = 1; + memcpy(data_buff, &Src, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v28, 1u); + memcpy(v8, &Src.version, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v29, 1u); + memcpy(v8, &Src.encoding, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v30, 1u); + memcpy(v8, &Src.bpp, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v31, 2u); + memcpy(v8, &Src.left, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v32, 2u); + memcpy(v8, &Src.up, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v33, 2u); + memcpy(v8, &Src.right, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v34, 2u); + memcpy(v8, &Src.bottom, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v35, 2u); + memcpy(v8, &Src.hdpi, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v36, 2u); + memcpy(v8, &Src.vdpi, 2u); v8 = (char *)v8 + 2; memcpy(v8, &v20, 0x30u); v8 = (char *)v8 + 48; - memcpy(v8, &v37, 1u); + memcpy(v8, &v27, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v38, 1u); + memcpy(v8, &v27.planes, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v39, 2u); + memcpy(v8, &v27.pitch, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &v40, 2u); + memcpy(v8, &v27.palette_info, 2u); v8 = (char *)v8 + 2; memcpy(v8, &v18, 0x3Au); v9 = (char *)v8 + 58; - ptr = pAllocator->AllocNamedChunk(0, 3 * a3 + 6, 0); - if ( a4 > 0 ) - { - v10 = v42; - v25 = a4; - v26 = 3 * v42; - v23 = 2 * a3; - v11 = a2; - v24 = a2; + + lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); + if ( heidth > 0 ) + { + v10 = pitch; + v25 = heidth; + v26 = 3 * pitch; + v23 = 2 * wight; + v11 = picture_data; + v24 = (int)picture_data; while ( 1 ) { - a4 = v11; + line_pictute_data = v11; v12 = 0; i = 0; - if ( a3 > 0 ) - { - v21 = (char *)ptr + v10; - v22 = (char *)ptr + 2 * v42; + if ( wight > 0 ) + { + lineG = (char *)lineRGB + pitch; + lineB = (char *)lineRGB + 2 * pitch; do { - *((char *)ptr + v12) = (signed int)(v7->uTargetRMask & *(short *)a4) >> (LOBYTE(v7->uTargetGBits) - + LOBYTE(v7->uTargetBBits) - + v7->uTargetRBits - - 8); - v13 = i; - v21[i] = (signed int)(v7->uTargetGMask & *(short *)a4) >> (LOBYTE(v7->uTargetBBits) - + LOBYTE(v7->uTargetGBits) - - 8); - v14 = a4; - a4 += 2; - v22[v13] = (v7->uTargetBMask & *(char *)v14) << (8 - LOBYTE(v7->uTargetBBits)); - v12 = v13 + 1; - i = v12; - } - while ( v12 < a3 ); + lineRGB[v12] = (signed int)(v7->uTargetRMask & *line_pictute_data) >> (v7->uTargetGBits + v7->uTargetBBits + v7->uTargetRBits - 8); + lineG[v12] = (signed int)(v7->uTargetGMask & *line_pictute_data) >> ( v7->uTargetBBits + v7->uTargetGBits- 8); + lineB[v12] = (v7->uTargetBMask & *line_pictute_data) << (8 - v7->uTargetBBits); + + v12++; + } + while ( v12 < wight ); } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) { - BYTE3(a4) = 1; - BYTE3(a2) = *((char *)ptr + i); + test_byte = 1; + pict_byte = lineRGB [i]; do { - v15 = i + BYTE3(a4); - if ( *((char *)ptr + v15) != BYTE3(a2) ) + v15 = i + test_byte; + if ( *((char *)lineRGB + v15) != pict_byte ) break; - if ( !(v15 % v42) ) + if ( !(v15 % pitch) ) break; - ++BYTE3(a4); - } - while ( BYTE3(a4) < 0x3Fu ); - if ( i + BYTE3(a4) > v26 ) - BYTE3(a4) = 3 * v42 - i; - if ( BYTE3(a4) > 1u || BYTE3(a2) >= 0xC0u ) - { - v43 = BYTE3(a4) | 0xC0; + ++test_byte; + } + while ( test_byte < 0x3Fu ); + if ( i + test_byte > v26 ) + test_byte = 3 * pitch - i; + if ( test_byte > 1u || pict_byte >= 0xC0u ) + { + v43 = test_byte | 0xC0; memcpy(v9, &v43, 1u); v9 = (char *)v9 + 1; } - memcpy(v9, (char *)&a2 + 3, 1u); - i += BYTE3(a4); - } - v11 = v23 + v24; + memcpy(v9, &pict_byte, 1u); + i += test_byte; + } + v11 +=wight ; v16 = v25-- == 1; - v24 += v23; + if ( v16 ) break; - v10 = v42; - } - } - pAllocator->FreeChunk(ptr); - result = a7; - *(int *)a7 = (char *)v9 - Dst; - return result; + v10 = pitch; + } + } + pAllocator->FreeChunk(lineRGB); + *(int *)packed_size = (char *)v9 - data_buff; + } //----- (0049F8B5) --------------------------------------------------------