comparison Render.cpp @ 2131:651b24553ae9

savegame screenshot fix
author Ritor1
date Sat, 28 Dec 2013 16:49:21 +0600
parents 0d0aa7c1ccdd
children 49de109bbab5
comparison
equal deleted inserted replaced
2130:4f6c52ed6f7c 2131:651b24553ae9
2571 // 4EFA84: using guessed type int dword_4EFA84; 2571 // 4EFA84: using guessed type int dword_4EFA84;
2572 2572
2573 //----- (0049F5A2) -------------------------------------------------------- 2573 //----- (0049F5A2) --------------------------------------------------------
2574 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size ) 2574 void Render::PackPCXpicture( unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size )
2575 { 2575 {
2576 //Render *v7; // ebx@1
2577 void *v8; // esi@3 2576 void *v8; // esi@3
2578 void *v9; // esi@3 2577 void *v9; // esi@3
2579 //int v10; // ecx@4
2580 unsigned short* v11; // eax@4 2578 unsigned short* v11; // eax@4
2581 //int v12; // eax@6
2582 int v13; // eax@8 2579 int v13; // eax@8
2583 int v14; // ecx@8 2580 int v14; // ecx@8
2584 signed int v15; // eax@11 2581 signed int v15; // eax@11
2585 char v16; // zf@20 2582 char v16; // zf@20
2586 int result; // eax@21 2583 int result; // eax@21
2587 char v18[58]; // [sp+Ch] [bp-ACh]@3 2584 char v18[58]; // [sp+Ch] [bp-ACh]@3
2588 // __int16 v19; // [sp+44h] [bp-74h]@3
2589 char v20[48]; // [sp+48h] [bp-70h]@3 2585 char v20[48]; // [sp+48h] [bp-70h]@3
2590 char *lineG; // [sp+78h] [bp-40h]@7 2586 char *lineG; // [sp+78h] [bp-40h]@7
2591 char *lineB; // [sp+7Ch] [bp-3Ch]@7 2587 char *lineB; // [sp+7Ch] [bp-3Ch]@7
2592 int v23; // [sp+80h] [bp-38h]@4 2588 int v23; // [sp+80h] [bp-38h]@4
2593 int v24; // [sp+84h] [bp-34h]@4 2589 int v24; // [sp+84h] [bp-34h]@4
2601 int i; // [sp+B4h] [bp-4h]@6 2597 int i; // [sp+B4h] [bp-4h]@6
2602 unsigned short* line_pictute_data; 2598 unsigned short* line_pictute_data;
2603 byte test_byte; 2599 byte test_byte;
2604 unsigned char pict_byte; 2600 unsigned char pict_byte;
2605 2601
2606 //v7 = this; 2602 int num_r_bits = 5;
2603 int num_g_bits = 6;
2604 int num_b_bits = 5;
2605
2606 int r_mask = 0xF800;
2607 int g_mask = 0x7E0;
2608 int b_mask = 0x1F;
2609
2607 pitch = wight; 2610 pitch = wight;
2608 if ( wight & 1 ) 2611 if ( wight & 1 )
2609 pitch = wight + 1; 2612 pitch = wight + 1;
2610 Src.left = 0; 2613 Src.left = 0;
2611 Src.up = 0; 2614 Src.up = 0;
2659 v9 = (char *)v8 + 58; 2662 v9 = (char *)v8 + 58;
2660 2663
2661 lineRGB = (char*)malloc(3 * (wight + 2)); 2664 lineRGB = (char*)malloc(3 * (wight + 2));
2662 if ( heidth > 0 ) 2665 if ( heidth > 0 )
2663 { 2666 {
2664 //v10 = pitch;
2665 v26 = 3 * pitch; 2667 v26 = 3 * pitch;
2666 v23 = 2 * wight; 2668 v23 = 2 * wight;
2667 v11 = picture_data; 2669 v11 = picture_data;
2668 v24 = (int)picture_data; 2670 v24 = (int)picture_data;
2669 for ( v25 = heidth; v25; v25-- ) 2671 for ( v25 = heidth; v25; v25-- )
2673 { 2675 {
2674 lineG = (char *)lineRGB + pitch; 2676 lineG = (char *)lineRGB + pitch;
2675 lineB = (char *)lineRGB + 2 * pitch; 2677 lineB = (char *)lineRGB + 2 * pitch;
2676 for ( uint i = 0; i < wight; i++ ) 2678 for ( uint i = 0; i < wight; i++ )
2677 { 2679 {
2678 lineRGB[i] = (signed int)(this->uTargetRMask & *line_pictute_data) >> (this->uTargetGBits + this->uTargetBBits + this->uTargetRBits - 8); 2680 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8);
2679 lineG[i] = (signed int)(this->uTargetGMask & *line_pictute_data) >> ( this->uTargetBBits + this->uTargetGBits- 8); 2681 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> ( num_b_bits + num_g_bits- 8);
2680 lineB[i] = (this->uTargetBMask & *line_pictute_data) << (8 - this->uTargetBBits); 2682 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits);
2681 line_pictute_data += 2; 2683 line_pictute_data += 1;
2682 } 2684 }
2683 } 2685 }
2684 for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) 2686 for ( i = 0; i < v26; v9 = (char *)v9 + 1 )
2685 { 2687 {
2686 pict_byte = lineRGB[i]; 2688 pict_byte = lineRGB[i];
2702 } 2704 }
2703 memcpy(v9, &pict_byte, 1); 2705 memcpy(v9, &pict_byte, 1);
2704 i += test_byte; 2706 i += test_byte;
2705 } 2707 }
2706 v11 += wight; 2708 v11 += wight;
2707 //v10 = pitch;
2708 } 2709 }
2709 } 2710 }
2710 free(lineRGB); 2711 free(lineRGB);
2711 *(int *)packed_size = (char *)v9 - data_buff; 2712 *(int *)packed_size = (char *)v9 - data_buff;
2712 } 2713 }
2713 2714
2714 //----- (0049F8B5) -------------------------------------------------------- 2715 //----- (0049F8B5) --------------------------------------------------------
2715 FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) 2716 FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height)
2716 { 2717 {
2717 //Render *v5; // esi@1
2718 FILE *result; // eax@1 2718 FILE *result; // eax@1
2719 FILE *pOutFile; // edi@4 2719 FILE *pOutFile; // edi@4
2720 //int v8; // ecx@5
2721 unsigned short* v9; // eax@5 2720 unsigned short* v9; // eax@5
2722 int v10; // eax@7 2721 int v10; // eax@7
2723 //int v11; // ecx@9
2724 signed int v12; // eax@12 2722 signed int v12; // eax@12
2725 char v13; // zf@21 2723 char v13; // zf@21
2726 char v14[56]; // [sp+4h] [bp-A0h]@4 2724 char v14[56]; // [sp+4h] [bp-A0h]@4
2727 __int16 v15; // [sp+3Ch] [bp-68h]@4 2725 __int16 v15; // [sp+3Ch] [bp-68h]@4
2728 char color_map[48]; // [sp+40h] [bp-64h]@4 2726 char color_map[48]; // [sp+40h] [bp-64h]@4
2729 int v17; // [sp+70h] [bp-34h]@5
2730 int v18; // [sp+74h] [bp-30h]@5 2727 int v18; // [sp+74h] [bp-30h]@5
2731 char *v19; // [sp+78h] [bp-2Ch]@5 2728 char *v19; // [sp+78h] [bp-2Ch]@5
2732 int image_width; // [sp+7Ch] [bp-28h]@5 2729 int image_width; // [sp+7Ch] [bp-28h]@5
2733 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 2730 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4
2734 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 2731 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4
2789 fwrite(&header2.pitch, 2, 1, pOutFile); 2786 fwrite(&header2.pitch, 2, 1, pOutFile);
2790 fwrite(&header2.palette_info, 2, 1, pOutFile); 2787 fwrite(&header2.palette_info, 2, 1, pOutFile);
2791 fwrite(v14, 0x3Au, 1, pOutFile); 2788 fwrite(v14, 0x3Au, 1, pOutFile);
2792 2789
2793 lineRGB = (char *)malloc(3 * (width + 2)); 2790 lineRGB = (char *)malloc(3 * (width + 2));
2794 //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя 2791 //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя
2795 //указывается цвет группы пикселей и их количество. 2792 //указывается цвет группы пикселей и их количество.
2796 //if ( height > 0 )
2797 //{
2798 //v8 = pitch;
2799 image_width = 3 * pitch; 2793 image_width = 3 * pitch;
2800 v17 = 2 * width;
2801 v9 = picture_data; 2794 v9 = picture_data;
2802 //v19 = pPixels;
2803 for ( v18 = 0; v18 < height; v18++ )//столбец 2795 for ( v18 = 0; v18 < height; v18++ )//столбец
2804 { 2796 {
2805 line_pictute_data = v9; 2797 line_pictute_data = v9;
2806 lineG = (char *)lineRGB + pitch; 2798 lineG = (char *)lineRGB + pitch;
2807 lineB = (char *)lineRGB + 2 * pitch; 2799 lineB = (char *)lineRGB + 2 * pitch;
2809 for ( int i = 0; i < width; i++ )//строка 2801 for ( int i = 0; i < width; i++ )//строка
2810 { 2802 {
2811 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); 2803 lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8);
2812 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); 2804 lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8);
2813 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); 2805 lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits);
2814 line_pictute_data += 2; 2806 line_pictute_data += 1;
2815 } 2807 }
2816 test_byte = 1; 2808 test_byte = 1;
2817 for ( int i = 0; (signed int)i < image_width; i += test_byte )// += BYTE3(pPixels) ) 2809 for ( int i = 0; (signed int)i < image_width; i += test_byte )
2818 { 2810 {
2819 unsigned char pic_byte = lineRGB[i]; 2811 unsigned char pic_byte = lineRGB[i];
2820 //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) )
2821 for ( test_byte; test_byte < 63; ++test_byte )// расчёт количества одинаковых цветов 2812 for ( test_byte; test_byte < 63; ++test_byte )// расчёт количества одинаковых цветов
2822 { 2813 {
2823 v12 = i + test_byte; 2814 v12 = i + test_byte;
2824 if ( lineRGB[v12] != pic_byte ) 2815 if ( lineRGB[v12] != pic_byte )
2825 break; 2816 break;
2834 fwrite(&v43, 1, 1, pOutFile); 2825 fwrite(&v43, 1, 1, pOutFile);
2835 } 2826 }
2836 fwrite(&pic_byte, 1, 1, pOutFile); 2827 fwrite(&pic_byte, 1, 1, pOutFile);
2837 } 2828 }
2838 v9 += width; 2829 v9 += width;
2839 //v19 += v17; 2830 }
2840 //pPixels += v17;
2841 //v8 = pitch;
2842 }
2843 //}
2844 free(lineRGB); 2831 free(lineRGB);
2845 result = (FILE *)fclose(pOutFile); 2832 result = (FILE *)fclose(pOutFile);
2846 } 2833 }
2847 return result; 2834 return result;
2848 } 2835 }