Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void __cdecl MakeDdsFile(DDS_HEADER_WITH_MAGIC *ddsHeader, const void *pSrcData, signed int width, signed int height, __int16 a5)
- {
- unsigned int widthCopy; // edx
- unsigned int v6; // ebp
- DWORD v7; // ecx
- DWORD v8; // ecx
- DWORD v9; // ecx
- DWORD v10; // ecx
- DWORD v11; // ecx
- DWORD v12; // ecx
- unsigned int rgbBitCount; // eax
- DWORD pitchOrLinearSize; // eax
- DWORD v15; // eax
- DWORD v16; // eax
- int v17; // [esp+10h] [ebp-4h]
- widthCopy = height;
- v6 = a5 & 0xFF00;
- v17 = 0;
- ddsHeader->dwSize = 124;
- ddsHeader->dwFlags = 0x1007;
- ddsHeader->dwHeight = height;
- ddsHeader->dwWidth = width;
- if ( v6 <= 0x7600 )
- {
- if ( v6 == 0x7600 )
- {
- ddsHeader->dwFlags = 0xA1007;
- ddsHeader->ddspf.dwFlags = 4;
- ddsHeader->ddspf.dwFourCC = '2TXD';
- ddsHeader->dwCaps = 0x401008;
- v17 = 1;
- goto LABEL_31;
- }
- if ( v6 > 0x7300 )
- {
- if ( v6 == 0x7400 )
- {
- ddsHeader->dwFlags = 0xA1007;
- ddsHeader->ddspf.dwFlags = 4;
- ddsHeader->ddspf.dwFourCC = '1TXD';
- ddsHeader->dwCaps = 0x401008;
- v17 = 1;
- goto LABEL_31;
- }
- if ( v6 != 0x7500 )
- goto LABEL_31;
- ddsHeader->ddspf.dwFourCC = '2TXD';
- }
- else
- {
- if ( v6 != 0x7300 )
- {
- if ( v6 != 0x7000 )
- {
- if ( v6 == 0x7100 )
- {
- ddsHeader->ddspf.dwFlags = 0x40;
- ddsHeader->ddspf.dwFourCC = 0;
- ddsHeader->dwFlags = 0x2100F;
- ddsHeader->dwCaps = 0x401008;
- goto LABEL_31;
- }
- if ( v6 != 29184 )
- goto LABEL_31;
- }
- ddsHeader->dwFlags = 0x100F;
- ddsHeader->ddspf.dwFlags = 0x40;
- ddsHeader->ddspf.dwFourCC = 0;
- goto LABEL_30;
- }
- ddsHeader->ddspf.dwFourCC = 827611204;
- }
- LABEL_29:
- ddsHeader->dwFlags = 0x81007;
- ddsHeader->ddspf.dwFlags = 4;
- v17 = 1;
- LABEL_30:
- ddsHeader->dwCaps = 0x1000;
- goto LABEL_31;
- }
- if ( v6 <= 0x7A00 )
- {
- switch ( v6 )
- {
- case 0x7A00u:
- ddsHeader->dwFlags = 0xA1007;
- ddsHeader->ddspf.dwFlags = 4;
- ddsHeader->ddspf.dwFourCC = '4TXD';
- ddsHeader->dwCaps = (DWORD)sub_401008;
- v17 = 1;
- goto LABEL_31;
- case 0x7700u:
- ddsHeader->ddspf.dwFourCC = '3TXD';
- break;
- case 0x7800u:
- ddsHeader->dwFlags = 0xA1007;
- ddsHeader->ddspf.dwFlags = 4;
- ddsHeader->ddspf.dwFourCC = '3TXD';
- ddsHeader->dwCaps = (DWORD)sub_401008;
- v17 = 1;
- goto LABEL_31;
- case 0x7900u:
- ddsHeader->ddspf.dwFourCC = '4TXD';
- break;
- default:
- goto LABEL_31;
- }
- goto LABEL_29;
- }
- if ( v6 == 0x7B00 )
- {
- ddsHeader->ddspf.dwFourCC = '5TXD';
- goto LABEL_29;
- }
- if ( v6 == 0x7C00 )
- {
- ddsHeader->dwFlags = 0xA1007;
- ddsHeader->ddspf.dwFlags = 4;
- ddsHeader->ddspf.dwFourCC = '5TXD';
- ddsHeader->dwCaps = (DWORD)sub_401008;
- v17 = 1;
- }
- LABEL_31:
- ddsHeader->dwDepth = 0;
- ddsHeader->dwMipMapCount = 0;
- if ( v6 > 0x7800 )
- {
- if ( v6 != 0x7A00 && v6 != 0x7C00 )
- goto LABEL_52;
- goto LABEL_60;
- }
- if ( v6 == 0x7800 )
- {
- LABEL_60:
- if ( width < height )
- widthCopy = width;
- if ( widthCopy <= 0x40 )
- {
- if ( widthCopy == 64 )
- {
- LABEL_45:
- ddsHeader->dwMipMapCount = 5;
- }
- else
- {
- switch ( widthCopy )
- {
- case 4u:
- ddsHeader->dwMipMapCount = 1;
- break;
- case 8u:
- goto LABEL_42;
- case 0x10u:
- goto LABEL_43;
- case 0x20u:
- goto LABEL_44;
- default:
- goto LABEL_72;
- }
- }
- goto LABEL_52;
- }
- if ( widthCopy <= 0x200 )
- {
- if ( widthCopy != 512 )
- {
- if ( widthCopy == 128 )
- {
- LABEL_46:
- ddsHeader->dwMipMapCount = 6;
- goto LABEL_52;
- }
- if ( widthCopy == 256 )
- goto LABEL_70;
- LABEL_72:
- ddsHeader->dwMipMapCount = 0;
- goto LABEL_52;
- }
- LABEL_53:
- ddsHeader->dwMipMapCount = 8;
- goto LABEL_52;
- }
- if ( widthCopy != 1024 )
- goto LABEL_72;
- LABEL_51:
- ddsHeader->dwMipMapCount = 9;
- goto LABEL_52;
- }
- if ( v6 != 0x7100 )
- {
- if ( v6 != 0x7400 && v6 != 0x7600 )
- goto LABEL_52;
- goto LABEL_60;
- }
- if ( width < height )
- widthCopy = width;
- if ( widthCopy > 0x40 )
- {
- if ( widthCopy > 0x200 )
- {
- if ( widthCopy == 1024 )
- {
- ddsHeader->dwMipMapCount = 11;
- goto LABEL_52;
- }
- }
- else
- {
- switch ( widthCopy )
- {
- case 0x200u:
- ddsHeader->dwMipMapCount = 10;
- goto LABEL_52;
- case 0x80u:
- goto LABEL_53;
- case 0x100u:
- goto LABEL_51;
- }
- }
- LABEL_56:
- ddsHeader->dwMipMapCount = 0;
- goto LABEL_52;
- }
- if ( widthCopy == 64 )
- {
- LABEL_70:
- ddsHeader->dwMipMapCount = 7;
- goto LABEL_52;
- }
- switch ( widthCopy )
- {
- case 2u:
- LABEL_42:
- ddsHeader->dwMipMapCount = 2;
- break;
- case 4u:
- LABEL_43:
- ddsHeader->dwMipMapCount = 3;
- break;
- case 8u:
- LABEL_44:
- ddsHeader->dwMipMapCount = 4;
- break;
- case 0x10u:
- goto LABEL_45;
- case 0x20u:
- goto LABEL_46;
- default:
- goto LABEL_56;
- }
- LABEL_52:
- ddsHeader->ddspf.dwSize = 32;
- ddsHeader->dwReserved1[0] = 0;
- ddsHeader->dwReserved1[1] = 0;
- ddsHeader->dwReserved1[2] = 0;
- ddsHeader->dwReserved1[3] = 0;
- ddsHeader->dwReserved1[4] = 0;
- ddsHeader->dwReserved1[5] = 0;
- ddsHeader->dwReserved1[6] = 0;
- ddsHeader->dwReserved1[7] = 0;
- ddsHeader->dwReserved1[8] = 0;
- ddsHeader->dwReserved1[9] = 0;
- ddsHeader->dwReserved1[10] = 0;
- switch ( (char)a5 )
- {
- case 0:
- case 1:
- case 9:
- case 10:
- ddsHeader->ddspf.dwRGBBitCount = 8;
- goto LABEL_91;
- case 2:
- v7 = ddsHeader->ddspf.dwFlags | 1;
- ddsHeader->ddspf.dwRBitMask = 0x7C00;
- ddsHeader->ddspf.dwGBitMask = 0x3E0;
- ddsHeader->ddspf.dwBBitMask = 0x1F;
- ddsHeader->ddspf.dwABitMask = 0x8000;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- ddsHeader->ddspf.dwFlags = v7;
- break;
- case 3:
- ddsHeader->ddspf.dwRBitMask = 0x7C00;
- goto LABEL_79;
- case 4:
- v8 = ddsHeader->ddspf.dwFlags | 1;
- ddsHeader->ddspf.dwRBitMask = 0xF00;
- ddsHeader->ddspf.dwGBitMask = 0xF0;
- ddsHeader->ddspf.dwBBitMask = 0xF;
- ddsHeader->ddspf.dwABitMask = 61440;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- ddsHeader->ddspf.dwFlags = v8;
- break;
- case 5:
- case 19:
- ddsHeader->ddspf.dwRBitMask = 0xF800;
- ddsHeader->ddspf.dwGBitMask = 0x7E0;
- ddsHeader->ddspf.dwBBitMask = 0x1F;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- goto LABEL_93;
- case 6:
- ddsHeader->ddspf.dwRBitMask = 0xFF0000;
- ddsHeader->ddspf.dwBBitMask = 0xFF;
- goto LABEL_88;
- case 7:
- ddsHeader->ddspf.dwRBitMask = 0xFF0000;
- ddsHeader->ddspf.dwGBitMask = 0xFF00;
- ddsHeader->ddspf.dwBBitMask = 0xFF;
- ddsHeader->ddspf.dwRGBBitCount = 32;
- goto LABEL_93;
- case 8:
- case 18:
- case 22:
- case 26:
- ddsHeader->ddspf.dwRGBBitCount = 32;
- goto LABEL_91;
- case 11:
- v9 = ddsHeader->ddspf.dwFlags | 1;
- ddsHeader->ddspf.dwRBitMask = 0;
- ddsHeader->ddspf.dwGBitMask = 0;
- ddsHeader->ddspf.dwBBitMask = 0;
- ddsHeader->ddspf.dwABitMask = 0xFF00;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- ddsHeader->ddspf.dwFlags = v9;
- break;
- case 12:
- ddsHeader->ddspf.dwRBitMask = 0xFC00;
- LABEL_79:
- ddsHeader->ddspf.dwGBitMask = 0x3E0;
- ddsHeader->ddspf.dwBBitMask = 0x1F;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- goto LABEL_93;
- case 13:
- case 14:
- case 17:
- case 25:
- ddsHeader->ddspf.dwRGBBitCount = 16;
- LABEL_91:
- ddsHeader->ddspf.dwGBitMask = 0;
- ddsHeader->ddspf.dwBBitMask = 0;
- goto LABEL_92;
- case 15:
- ddsHeader->ddspf.dwGBitMask = 0xFF00;
- ddsHeader->ddspf.dwBBitMask = 0xFF;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- LABEL_92:
- ddsHeader->ddspf.dwRBitMask = 0;
- goto LABEL_93;
- case 16:
- ddsHeader->ddspf.dwRBitMask = 0xFF00;
- ddsHeader->ddspf.dwGBitMask = 0;
- ddsHeader->ddspf.dwBBitMask = 0xFF;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- LABEL_93:
- ddsHeader->ddspf.dwABitMask = 0;
- break;
- case 20:
- v10 = ddsHeader->ddspf.dwFlags | 1;
- ddsHeader->ddspf.dwRBitMask = 0xF000;
- ddsHeader->ddspf.dwGBitMask = 0xF00;
- ddsHeader->ddspf.dwBBitMask = 0xF0;
- ddsHeader->ddspf.dwABitMask = 0xF;
- ddsHeader->ddspf.dwRGBBitCount = 16;
- ddsHeader->ddspf.dwFlags = v10;
- break;
- case 21:
- case 24:
- v12 = ddsHeader->ddspf.dwFlags | 1;
- ddsHeader->ddspf.dwRBitMask = 0xFF;
- ddsHeader->ddspf.dwGBitMask = 0xFF00;
- ddsHeader->ddspf.dwBBitMask = 0xFF0000;
- ddsHeader->ddspf.dwABitMask = 0xFF000000;
- ddsHeader->ddspf.dwRGBBitCount = 32;
- ddsHeader->ddspf.dwFlags = v12;
- break;
- case 23:
- ddsHeader->ddspf.dwRBitMask = 0xFF;
- ddsHeader->ddspf.dwBBitMask = 0xFF0000;
- LABEL_88:
- v11 = ddsHeader->ddspf.dwFlags | 1;
- ddsHeader->ddspf.dwGBitMask = 0xFF00;
- ddsHeader->ddspf.dwABitMask = 0xFF000000;
- ddsHeader->ddspf.dwRGBBitCount = 32;
- ddsHeader->ddspf.dwFlags = v11;
- break;
- default:
- break;
- }
- ddsHeader->dwCaps2 = 0;
- ddsHeader->dwCaps3 = 0;
- ddsHeader->dwCaps4 = 0;
- ddsHeader->dwReserved2 = 0;
- rgbBitCount = ddsHeader->ddspf.dwRGBBitCount;
- if ( (ddsHeader->dwFlags & 8) != 0 )
- pitchOrLinearSize = width * (rgbBitCount >> 2);
- else
- pitchOrLinearSize = MakeDdsCalculatePitchOrLinearSize(width, height, rgbBitCount, ddsHeader->dwMipMapCount, v17);
- ddsHeader->dwPitchOrLinearSize = pitchOrLinearSize;
- // 'DDS '
- LOBYTE(ddsHeader->Magic) = 68;
- BYTE1(ddsHeader->Magic) = 68;
- BYTE2(ddsHeader->Magic) = 83;
- HIBYTE(ddsHeader->Magic) = 32;
- if ( v6 == 0x7000 )
- {
- v16 = ddsHeader->ddspf.dwRGBBitCount;
- switch ( v16 )
- {
- case 8u:
- sub_543530((int)&ddsHeader[1], (char *)pSrcData, width, height);
- break;
- case 16u:
- sub_543980(&ddsHeader[1], pSrcData, width, height);
- break;
- case 32u:
- sub_543DE0(&ddsHeader[1], pSrcData, width, height);
- break;
- }
- }
- else if ( v6 == 0x7100 )
- {
- v15 = ddsHeader->ddspf.dwRGBBitCount;
- switch ( v15 )
- {
- case 8u:
- sub_543920((int)&ddsHeader[1], (int)pSrcData, width, height);
- break;
- case 16u:
- sub_543D80(&ddsHeader[1], pSrcData, width, height);
- break;
- case 32u:
- sub_5441D0(&ddsHeader[1], pSrcData, width, height);
- break;
- }
- }
- else
- {
- qmemcpy(
- &ddsHeader[1],
- pSrcData,
- MakeDdsCalculatePitchOrLinearSize(width, height, ddsHeader->ddspf.dwRGBBitCount, ddsHeader->dwMipMapCount, v17));
- }
- }
Add Comment
Please, Sign In to add comment