Mercurial > might-and-magic-trilogy
changeset 61:05e4b4bd4d64
Savegame preview thumbnails
author | Nomad |
---|---|
date | Fri, 26 Oct 2012 03:27:59 +0200 |
parents | 30ec77bbd018 |
children | 1520e3385fed |
files | SaveLoad.cpp Texture.cpp |
diffstat | 2 files changed, 166 insertions(+), 319 deletions(-) [+] |
line wrap: on
line diff
--- a/SaveLoad.cpp Fri Oct 26 02:42:38 2012 +0200 +++ b/SaveLoad.cpp Fri Oct 26 03:27:59 2012 +0200 @@ -42,45 +42,13 @@ //----- (0045EE8A) -------------------------------------------------------- void __fastcall LoadGame(unsigned int uSlot) { - //unsigned int v1; // ebx@1 - //char v2; // zf@1 - //signed int v3; // esi@3 - //signed int v4; // esi@8 - //char *v5; // eax@9 - //unsigned int v6; // eax@12 - //unsigned int v7; // esi@13 - //char *v8; // ecx@14 - //FILE *v9; // eax@22 - //FILE *v10; // eax@26 - //FILE *v11; // eax@29 - //FILE *v12; // eax@32 - //FILE *v13; // eax@35 - //FILE *v14; // eax@38 - //unsigned int v15; // edi@41 - //Player *v16; // esi@41 - //int *v17; // esi@46 - //int v18; // edi@46 - //int v19; // ebx@46 - //int v20; // ecx@49 - //int v21; // eax@51 - //int v22; // ecx@56 - //bool v23; // edx@56 - //AudioPlayer *v24; // ebx@60 bool v25; // esi@62 bool v26; // eax@62 - //signed int v27; // esi@66 - //RGBTexture *v28; // edi@67 - std::string v29; // [sp-18h] [bp-108h]@25 int v30; // [sp-Ch] [bp-FCh]@65 int v31; // [sp-8h] [bp-F8h]@4 - //signed int v32; // [sp-4h] [bp-F4h]@4 char DstBuf[100]; // [sp+Ch] [bp-E4h]@23 - //char pContainer; // [sp+20h] [bp-D0h]@62 char Str[123]; // [sp+70h] [bp-80h]@25 - //char a3[5]; // [sp+EBh] [bp-5h]@2 - //v1 = uSlot; - //v2 = pSavegameUsedSlots[uSlot] == 0; dword_5B65C8 = 0; if (!pSavegameUsedSlots[uSlot]) {
--- a/Texture.cpp Fri Oct 26 02:42:38 2012 +0200 +++ b/Texture.cpp Fri Oct 26 03:27:59 2012 +0200 @@ -1114,315 +1114,194 @@ //----- (0040EAD8) -------------------------------------------------------- unsigned int RGBTexture::LoadFromFILE(FILE *pFile, unsigned int mode, unsigned int bCloseFile) { - RGBTexture *v4; // esi@1 - unsigned int result; // eax@2 - unsigned int v6; // ebx@3 - unsigned __int16 v7; // cx@5 - unsigned __int16 v8; // ax@5 - unsigned int v9; // eax@5 - char v10; // zf@5 - signed int v11; // ecx@14 - int v12; // ebx@19 - signed int v13; // ecx@19 - int v14; // ebx@52 - unsigned __int16 *v15; // edi@52 - __int16 v16; // ax@54 - unsigned __int16 *v17; // edi@59 - __int16 v18; // ax@61 - unsigned __int16 *v19; // edi@66 - unsigned __int16 v20; // ax@68 - int v21; // eax@73 - char DstBuf[60]; // [sp+Ch] [bp-90h]@3 - char pColorMap[48]; // [sp+48h] [bp-54h]@3 - PCXHeader1 pcxh1; // [sp+78h] [bp-24h]@3 - PCXHeader2 pcxh2; // [sp+88h] [bp-14h]@3 - int v26; // [sp+90h] [bp-Ch]@51 - int v27; // [sp+94h] [bp-8h]@54 - unsigned __int8 v28; // [sp+9Bh] [bp-1h]@54 + signed int result; // eax@2 + unsigned char test_byte; // edx@3 + //unsigned int read_offset; // ebx@37 + unsigned int row_position; // edi@40 + unsigned char value; // cl@63 + char count; // [sp+50h] [bp-Ch]@43 + unsigned short current_line; // [sp+54h] [bp-8h]@38 + unsigned short *dec_position; + unsigned short *temp_dec_position; + PCXHeader1 psx_head1; + PCXHeader2 psx_head2; + short int width, height; + BYTE color_map[48]; // Colormap for 16-color images - v4 = this; if (!pFile) return 1; + + + fread(&psx_head1, 1, 16, pFile); + fread(&color_map, 1, 48, pFile); + fread(&psx_head2, 1, 6, pFile); + + if (psx_head1.bpp!=8) + return 3; + uWidth=(short int )(psx_head1.right-psx_head1.left+1); // word @ 000014 + uHeight=(short int )(psx_head1.bottom-psx_head1.up+1); // word @ 000016 - fread(&pcxh1, 1u, 1u, pFile); - fread(&pcxh1.version, 1u, 1u, pFile); - fread(&pcxh1.encoding, 1u, 1u, pFile); - fread(&pcxh1.bpp, 1u, 1u, pFile); - v6 = 2; - fread(&pcxh1.left, 2u, 1u, pFile); - fread(&pcxh1.up, 2u, 1u, pFile); - fread(&pcxh1.right, 2u, 1u, pFile); - fread(&pcxh1.bottom, 2u, 1u, pFile); - fread(&pcxh1.hres, 2u, 1u, pFile); - fread(&pcxh1.vres, 2u, 1u, pFile); - fread(pColorMap, 0x30u, 1u, pFile); - fread(&pcxh2, 1u, 1u, pFile); - fread(&pcxh2.planes, 1u, 1u, pFile); - fread(&pcxh2.pitch, 2u, 1u, pFile); - fread(&pcxh2.palette_info, 2u, 1u, pFile); - fread(DstBuf, 58u, 1u, pFile); - if ( pcxh1.bpp == 8 ) - { - v7 = pcxh1.right - pcxh1.left + 1; - v8 = pcxh1.bottom - pcxh1.up; - v4->uWidth = v7; - ++v8; - v4->uHeight = v8; - v9 = (signed __int16)v7 * (signed __int16)v8; - v10 = mode == 0; - v4->uNumPixels = v9; - if ( v10 ) + uNumPixels=uWidth*uHeight; // dword @ 000010 + + + if ( mode == 0 ) { - if ( v4->pPixels ) + if ( pPixels ) { - pAllocator->FreeChunk(v4->pPixels); - v4->pPixels = 0; + pAllocator->FreeChunk(pPixels); + pPixels = 0; } - v4->pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk( - v4->pPixels, - 2 * v4->uNumPixels + 4, - v4->pName); - v6 = 2; + pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk( + pPixels, + 2 * uNumPixels + 4, + pName); } else { if ( mode != 1 && mode == 2 ) { - operator new(2 * v9 + 4); - v4->pPixels = 0; - *(unsigned int *)&v4->field_20 |= 1u; + pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16)); + field_20 |= 1; } } - if ( v4->pPixels ) + + + + + auto pOutPixels = pPixels; + + memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); + + short i=1; + while ( (1<<i) !=uWidth) + { + ++i; + if (i >= 15) + break; + } + field_18=i; + short i_=1; + while ( (1<<i_) !=uHeight) + { + ++i_; + if (i_ >= 15) + break; + } + field_1A=i_; + switch (field_18) + { + case 2: field_1C = 3; break; + case 3: field_1C = 7; break; + case 4: field_1C = 15; break; + case 5: field_1C = 31; break; + case 6: field_1C = 63; break; + case 7: field_1C = 127; break; + case 8: field_1C = 255; break; + case 9: field_1C = 511; break; + case 10: field_1C = 1023; break; + case 11: field_1C = 2047; break; + case 12: field_1C = 4095; break; + } + + switch (field_1A) + { + case 2: field_1E = 3; break; + case 3: field_1E = 7; break; + case 4: field_1E = 15; break; + case 5: field_1E = 31; break; + case 6: field_1E = 63; break; + case 7: field_1E = 127; break; + case 8: field_1E = 255; break; + case 9: field_1E = 511; break; + case 10: field_1E = 1023; break; + case 11: field_1E = 2047; break; + case 12: field_1E = 4095; break; + } + + + fseek(pFile, 128 - 70, SEEK_CUR); + + + for (uint y = 0; y < uHeight; ++y) + { + unsigned __int16 *pDst = pPixels + y * uWidth; + + uint x = 0; + do + { + uint ctrl = 0; + fread(&ctrl, 1, 1, pFile); + if ((ctrl & 0xC0) == 0xC0) { - v11 = 1; - while ( 1 << v11 != v4->uWidth ) - { - ++v11; - if ( v11 >= 15 ) - goto LABEL_19; - } - v4->field_18 = v11; -LABEL_19: - v12 = v4->uHeight; - v13 = 1; - while ( 1 << v13 != v12 ) - { - ++v13; - if ( v13 >= 15 ) - goto LABEL_24; - } - v4->field_1A = v13; -LABEL_24: - switch ( v4->field_18 ) - { - case 2: - v4->field_1C = 3; - break; - case 3: - v4->field_1C = 7; - break; - case 4: - v4->field_1C = 15; - break; - case 5: - v4->field_1C = 31; - break; - case 6: - v4->field_1C = 63; - break; - case 7: - v4->field_1C = 127; - break; - case 8: - v4->field_1C = 255; - break; - case 9: - v4->field_1C = 511; - break; - case 10: - v4->field_1C = 1023; - break; - case 11: - v4->field_1C = 2047; - break; - case 12: - v4->field_1C = 4095; - break; - default: - break; - } - switch ( v4->field_1A ) - { - case 2: - v4->field_1E = 3; - break; - case 3: - v4->field_1E = 7; - break; - case 4: - v4->field_1E = 15; - break; - case 5: - v4->field_1E = 31; - break; - case 6: - v4->field_1E = 63; - break; - case 7: - v4->field_1E = 127; - break; - case 8: - v4->field_1E = 255; - break; - case 9: - v4->field_1E = 511; - break; - case 10: - v4->field_1E = 1023; - break; - case 11: - v4->field_1E = 2047; - break; - case 12: - v4->field_1E = 4095; - break; - default: - break; - } - if ( pcxh2.planes == 1 ) - Abortf("24bit PCX Only!"); - if ( pcxh2.planes == 3 ) - { - v26 = 0; - if ( v12 > 0 ) - { - do - { - v14 = 0; - v15 = &v4->pPixels[v26 * v4->uWidth]; - if ( pcxh2.pitch ) - { - do - { - fread((char *)&mode + 3, 1u, 1u, pFile); - if ( (BYTE3(mode) & 0xC0) == -64 ) - { - BYTE3(mode) &= 0x3Fu; - fread(&v28, 1u, 1u, pFile); - v27 = 0; - v16 = v28; - if ( BYTE3(mode) ) - { - do - { - ++v14; - *v15 = LOWORD(pRenderer->uTargetRMask) & (v16 << (pRenderer->uTargetGBits - + pRenderer->uTargetRBits - + pRenderer->uTargetBBits - - 8)); - ++v15; - ++v27; - } - while ( v27 < BYTE3(mode) ); - } - } - else - { - ++v14; - *v15 = LOWORD(pRenderer->uTargetRMask) & (BYTE3(mode) << (pRenderer->uTargetGBits - + pRenderer->uTargetRBits - + pRenderer->uTargetBBits - - 8)); - ++v15; - } - } - while ( v14 < (unsigned __int16)pcxh2.pitch ); - } - v17 = &v4->pPixels[v26 * v4->uWidth]; - while ( v14 < 2 * (unsigned __int16)pcxh2.pitch ) - { - fread((char *)&mode + 3, 1u, 1u, pFile); - if ( (BYTE3(mode) & 0xC0) == -64 ) - { - BYTE3(mode) &= 0x3Fu; - fread(&v28, 1u, 1u, pFile); - v27 = 0; - v18 = v28; - if ( BYTE3(mode) ) - { - do - { - *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(v18 << (pRenderer->uTargetGBits - + pRenderer->uTargetBBits - - 8)); - ++v14; - ++v17; - ++v27; - } - while ( v27 < BYTE3(mode) ); - } - } - else - { - *v17 |= pRenderer->uTargetGMask & (unsigned __int16)(BYTE3(mode) << (pRenderer->uTargetGBits - + pRenderer->uTargetBBits - - 8)); - ++v14; - ++v17; - } - } - v19 = &v4->pPixels[v26 * v4->uWidth]; - while ( v14 < 3 * (unsigned __int16)pcxh2.pitch ) - { - fread((char *)&mode + 3, 1u, 1u, pFile); - if ( (BYTE3(mode) & 0xC0) == -64 ) - { - BYTE3(mode) &= 0x3Fu; - fread(&v28, 1u, 1u, pFile); - v27 = 0; - v20 = v28; - if ( BYTE3(mode) ) - { - do - { - *v19 |= v20 >> (8 - pRenderer->uTargetBBits); - ++v14; - ++v19; - ++v27; - } - while ( v27 < BYTE3(mode) ); - } - } - else - { - *v19 |= BYTE3(mode) >> (8 - pRenderer->uTargetBBits); - ++v14; - ++v19; - } - } - v21 = v4->uHeight; - ++v26; - } - while ( v26 < v21 ); - } - } - if ( bCloseFile ) - fclose(pFile); - result = 0; + uint uNumPixels = ctrl & 0x3F; + uint clr = 0; + fread(&clr, 1, 1, pFile); + for (uint i = 0; i < uNumPixels; ++i) + pDst[x++] = pRenderer->uTargetRMask & (clr << (pRenderer->uTargetGBits + + pRenderer->uTargetRBits + + pRenderer->uTargetBBits - 8)); } else { - result = v6; + pDst[x++] = pRenderer->uTargetRMask & (ctrl << (pRenderer->uTargetGBits + + pRenderer->uTargetRBits + + pRenderer->uTargetBBits - 8)); } - } - else + } while (x < psx_head2.pitch); + + + + + + x = 0; + do { - result = 3; - } + uint ctrl = 0; + fread(&ctrl, 1, 1, pFile); + if ((ctrl & 0xC0) == 0xC0) + { + uint uNumPixels = ctrl & 0x3F; + uint clr = 0; + fread(&clr, 1, 1, pFile); + for (uint i = 0; i < uNumPixels; ++i) + pDst[x++] |= pRenderer->uTargetGMask & (clr << (pRenderer->uTargetGBits + + pRenderer->uTargetBBits - 8)); + } + else + { + pDst[x++] |= pRenderer->uTargetGMask & (ctrl << (pRenderer->uTargetGBits + + pRenderer->uTargetBBits - 8)); + } + } while (x < psx_head2.pitch); + + + + - return result; + x = 0; + do + { + uint ctrl = 0; + fread(&ctrl, 1, 1, pFile); + if ((ctrl & 0xC0) == 0xC0) + { + uint uNumPixels = ctrl & 0x3F; + uint clr = 0; + fread(&clr, 1, 1, pFile); + for (uint i = 0; i < uNumPixels; ++i) + pDst[x++] |= pRenderer->uTargetBMask & (clr >> (8 - pRenderer->uTargetBBits)); + } + else + { + pDst[x++] |= pRenderer->uTargetBMask & (ctrl >> (8 - pRenderer->uTargetRBits)); + } + } while (x < psx_head2.pitch); + } + + if (bCloseFile) + fclose(pFile); + return 0; } //----- (0040E51F) --------------------------------------------------------