Mercurial > mm7
changeset 2131:651b24553ae9
savegame screenshot fix
author | Ritor1 |
---|---|
date | Sat, 28 Dec 2013 16:49:21 +0600 |
parents | 4f6c52ed6f7c |
children | 49de109bbab5 |
files | Game.cpp Render.cpp SaveLoad.cpp Texture.cpp |
diffstat | 4 files changed, 92 insertions(+), 171 deletions(-) [+] |
line wrap: on
line diff
--- a/Game.cpp Sat Dec 28 13:13:54 2013 +0600 +++ b/Game.cpp Sat Dec 28 16:49:21 2013 +0600 @@ -2651,7 +2651,7 @@ screenshot = MakeScreenshot(155, 117); pRenderer->SavePCXImage("gamma.pcx", screenshot, 155, 117); free(screenshot); - stru_506E40._40E55E("gamma.pcx", 0); + stru_506E40.LoadPCXFile("gamma.pcx", 0); continue; } pGUIWindow_Settings->Release(); @@ -3923,7 +3923,7 @@ screenshot = MakeScreenshot(155, 117); pRenderer->SavePCXImage("gamma.pcx", screenshot, 155, 117); free(screenshot); - stru_506E40._40E55E("gamma.pcx", 0); + stru_506E40.LoadPCXFile("gamma.pcx", 0); GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton, (int)pBtn_GameSettings, 0); //LABEL_453: /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 )
--- a/Render.cpp Sat Dec 28 13:13:54 2013 +0600 +++ b/Render.cpp Sat Dec 28 16:49:21 2013 +0600 @@ -2573,19 +2573,15 @@ //----- (0049F5A2) -------------------------------------------------------- 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 unsigned short* v11; // eax@4 - //int v12; // eax@6 int v13; // eax@8 int v14; // ecx@8 signed int v15; // eax@11 char v16; // zf@20 int result; // eax@21 char v18[58]; // [sp+Ch] [bp-ACh]@3 - // __int16 v19; // [sp+44h] [bp-74h]@3 char v20[48]; // [sp+48h] [bp-70h]@3 char *lineG; // [sp+78h] [bp-40h]@7 char *lineB; // [sp+7Ch] [bp-3Ch]@7 @@ -2603,7 +2599,14 @@ byte test_byte; unsigned char pict_byte; - //v7 = this; + int num_r_bits = 5; + int num_g_bits = 6; + int num_b_bits = 5; + + int r_mask = 0xF800; + int g_mask = 0x7E0; + int b_mask = 0x1F; + pitch = wight; if ( wight & 1 ) pitch = wight + 1; @@ -2661,7 +2664,6 @@ lineRGB = (char*)malloc(3 * (wight + 2)); if ( heidth > 0 ) { - //v10 = pitch; v26 = 3 * pitch; v23 = 2 * wight; v11 = picture_data; @@ -2675,10 +2677,10 @@ lineB = (char *)lineRGB + 2 * pitch; for ( uint i = 0; i < wight; i++ ) { - lineRGB[i] = (signed int)(this->uTargetRMask & *line_pictute_data) >> (this->uTargetGBits + this->uTargetBBits + this->uTargetRBits - 8); - lineG[i] = (signed int)(this->uTargetGMask & *line_pictute_data) >> ( this->uTargetBBits + this->uTargetGBits- 8); - lineB[i] = (this->uTargetBMask & *line_pictute_data) << (8 - this->uTargetBBits); - line_pictute_data += 2; + lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); + lineG[i] = (signed int)(g_mask & *line_pictute_data) >> ( num_b_bits + num_g_bits- 8); + lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); + line_pictute_data += 1; } } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) @@ -2704,7 +2706,6 @@ i += test_byte; } v11 += wight; - //v10 = pitch; } } free(lineRGB); @@ -2714,19 +2715,15 @@ //----- (0049F8B5) -------------------------------------------------------- FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) { - //Render *v5; // esi@1 FILE *result; // eax@1 FILE *pOutFile; // edi@4 - //int v8; // ecx@5 unsigned short* v9; // eax@5 int v10; // eax@7 - //int v11; // ecx@9 signed int v12; // eax@12 char v13; // zf@21 char v14[56]; // [sp+4h] [bp-A0h]@4 __int16 v15; // [sp+3Ch] [bp-68h]@4 char color_map[48]; // [sp+40h] [bp-64h]@4 - int v17; // [sp+70h] [bp-34h]@5 int v18; // [sp+74h] [bp-30h]@5 char *v19; // [sp+78h] [bp-2Ch]@5 int image_width; // [sp+7Ch] [bp-28h]@5 @@ -2791,15 +2788,10 @@ fwrite(v14, 0x3Au, 1, pOutFile); lineRGB = (char *)malloc(3 * (width + 2)); - //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя - //указывается цвет группы пикселей и их количество. - //if ( height > 0 ) - //{ - //v8 = pitch; + //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя + //указывается цвет группы пикселей и их количество. image_width = 3 * pitch; - v17 = 2 * width; v9 = picture_data; - //v19 = pPixels; for ( v18 = 0; v18 < height; v18++ )//столбец { line_pictute_data = v9; @@ -2811,13 +2803,12 @@ lineRGB[i] = (signed int)(r_mask & *line_pictute_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); lineG[i] = (signed int)(g_mask & *line_pictute_data) >> (num_b_bits + num_g_bits - 8); lineB[i] = (b_mask & *line_pictute_data) << (8 - num_b_bits); - line_pictute_data += 2; + line_pictute_data += 1; } test_byte = 1; - for ( int i = 0; (signed int)i < image_width; i += test_byte )// += BYTE3(pPixels) ) + for ( int i = 0; (signed int)i < image_width; i += test_byte ) { unsigned char pic_byte = lineRGB[i]; - //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) ) for ( test_byte; test_byte < 63; ++test_byte )// расчёт количества одинаковых цветов { v12 = i + test_byte; @@ -2836,11 +2827,7 @@ fwrite(&pic_byte, 1, 1, pOutFile); } v9 += width; - //v19 += v17; - //pPixels += v17; - //v8 = pitch; - } - //} + } free(lineRGB); result = (FILE *)fclose(pOutFile); }
--- a/SaveLoad.cpp Sat Dec 28 13:13:54 2013 +0600 +++ b/SaveLoad.cpp Sat Dec 28 16:49:21 2013 +0600 @@ -672,18 +672,13 @@ //----- (0045E03A) -------------------------------------------------------- unsigned short *MakeScreenshot( signed int width, signed int height ) { - //signed int v2; // edi@1 unsigned __int16 *v3; // ebx@1 int v4; // edx@7 unsigned __int8 v5; // cf@9 unsigned int v6; // ecx@9 unsigned __int16 *v7; // edi@9 int j; // ecx@9 - //unsigned __int16 *v9; // edi@15 - //int v10; // ecx@15 - //LONG v11; // esi@15 unsigned int screen_x; // qax@18 - //unsigned int v13; // ST10_4@21 HRESULT v14; // eax@21 int v15; // edi@29 signed __int64 v16; // qax@30 @@ -696,16 +691,10 @@ unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 float interval_y; // [sp+8Ch] [bp-18h]@1 unsigned int screen_y; // [sp+90h] [bp-14h]@17 - //int v27; // [sp+94h] [bp-10h]@1 int v28; // [sp+98h] [bp-Ch]@16 int v29; // [sp+9Ch] [bp-8h]@15 - //int v30; // [sp+A0h] [bp-4h]@1 - //v30 = width; - //v2 = height; - //v27 = height; interval_x = game_viewport_width / (double)width; - interval_y = game_viewport_height / (double)height; pPixels = (unsigned __int16 *)malloc(2 * height * width); memset(pPixels, 0 , 2 * height * width); @@ -727,34 +716,18 @@ if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) { - ushort* screen_data = (unsigned __int16 *)Dst.lpSurface; - ulong screen_data_width = (Dst.lPitch / sizeof(short)); - ulong screen_data_height = Dst.dwHeight; - ushort* dst = pPixels; for (uint y = 0; y < height; ++y) { - //uint src_y = (game_viewport_y + y * v25) * (Dst.lPitch / sizeof(short)); - //uint src_y = game_viewport_y + y * v25; - //screen_y = pRenderer->uTargetSurfacePitch * (y * interval_y + 8.0);//(unsigned __int64)(signed __int64)((double)y * interval_y + 8.0); - //Assert(game_viewport_y + y * v25 < src_height); - //Assert(y < height); - for (uint x = 0; x < width; ++x) { - //uint src_x = game_viewport_x + x * v23; - //uint src_x = game_viewport_x + x * v23; - //screen_x = (unsigned int)((double)x * interval_x + 8.0); - //Assert(src_x < src_width); - //Assert(x < width); - //dst[y * width + x] = (((63*y)/117) << 5) | 31*x/155;//31*y/117;//src[src_y * src_width + src_x]; //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)]; - if (pRenderer->ddpfPrimarySuface.dwRGBBitCount == 32) + if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) { - auto p = (unsigned __int32 *)Dst.lpSurface + x + y * Dst.lPitch; + auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x* interval_x + 8.0) + y * Dst.lPitch; *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); } - else if (pRenderer->ddpfPrimarySuface.dwRGBBitCount == 16) + else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) { auto p = (unsigned __int16 *)Dst.lpSurface + x + y * Dst.lPitch; *v3 = *p; @@ -763,7 +736,6 @@ ++v3; } } - //pPixels = dst; ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); } else
--- a/Texture.cpp Sat Dec 28 13:13:54 2013 +0600 +++ b/Texture.cpp Sat Dec 28 16:49:21 2013 +0600 @@ -1128,6 +1128,14 @@ short int width, height; BYTE color_map[48]; // Colormap for 16-color images + unsigned int num_r_bits = 5; + unsigned int num_g_bits = 6; + unsigned int num_b_bits = 5; + + unsigned int r_mask = 0xF800; + unsigned int g_mask = 0x07E0; + unsigned int b_mask = 0x001F; + if (!pFile) return 1; @@ -1163,9 +1171,6 @@ } } - - - ushort* pOutPixels = pPixels; memset(pOutPixels, 0, uNumPixels * sizeof(__int16)); @@ -1216,7 +1221,6 @@ case 12: field_1E = 4095; break; } - fseek(pFile, 128 - 70, SEEK_CUR); @@ -1235,15 +1239,11 @@ 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)); + pDst[x++] = r_mask & (clr << (num_g_bits + num_r_bits + num_b_bits - 8)); } else { - pDst[x++] = pRenderer->uTargetRMask & (ctrl << (pRenderer->uTargetGBits + - pRenderer->uTargetRBits + - pRenderer->uTargetBBits - 8)); + pDst[x++] = r_mask & (ctrl << (num_g_bits + num_r_bits + num_b_bits - 8)); } } while (x < psx_head2.pitch); @@ -1258,13 +1258,11 @@ 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)); + pDst[x++] |= g_mask & (clr << (num_g_bits + num_b_bits - 8)); } else { - pDst[x++] |= pRenderer->uTargetGMask & (ctrl << (pRenderer->uTargetGBits + - pRenderer->uTargetBBits - 8)); + pDst[x++] |= g_mask & (ctrl << (num_g_bits + num_b_bits - 8)); } } while (x < psx_head2.pitch); @@ -1279,11 +1277,11 @@ uint clr = 0; fread(&clr, 1, 1, pFile); for (uint i = 0; i < uNumPixels; ++i) - pDst[x++] |= pRenderer->uTargetBMask & (clr >> (8 - pRenderer->uTargetBBits)); + pDst[x++] |= b_mask & (clr >> (8 - num_b_bits)); } else { - pDst[x++] |= pRenderer->uTargetBMask & (ctrl >> (8 - pRenderer->uTargetRBits)); + pDst[x++] |= b_mask & (ctrl >> (8 - num_b_bits)); } } while (x < psx_head2.pitch); } @@ -1313,7 +1311,6 @@ //----- (0040E55E) -------------------------------------------------------- int RGBTexture::LoadPCXFile(const char *Filename, unsigned int a3) { - //RGBTexture *v3; // esi@1 signed int result; // eax@2 char *v6; // eax@3 int v7; // edx@3 @@ -1323,7 +1320,7 @@ int v16; // eax@57 unsigned __int16 *v17; // ecx@57 unsigned __int16 *v18; // edi@57 - signed int v19; // eax@59 + signed int x; // eax@59 unsigned __int16 *v20; // edi@64 signed int v21; // eax@66 unsigned __int16 *v22; // edi@71 @@ -1333,7 +1330,6 @@ PCXHeader1 pcx_header1; PCXHeader2 pcx_header2; int y; // [sp+54h] [bp-Ch]@3 - int x; // [sp+58h] [bp-8h]@57 FILE *File; // [sp+5Ch] [bp-4h]@1 unsigned int num_r_bits = 5; @@ -1375,14 +1371,12 @@ { if ( this->pPixels ) free(this->pPixels); - //v13 = malloc(2 * this->uNumPixels + 4); this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); } if ( a3 == 2 ) { - //v13 = malloc(4 * this->uNumPixels + 8); this->_allocation_flags |= 1; - this->pPixels = (unsigned __int16 *)malloc(4 * this->uNumPixels + 8); + this->pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16)); } if ( this->pPixels ) { @@ -1428,101 +1422,70 @@ } fseek(File, 128, 0); ftell(File); - if ( pcx_header2.planes == 1 ) + if ( pcx_header2.planes == 1 ) Error("24bit PCX Only!"); if ( pcx_header2.planes == 3 ) { - //if ( this->uHeight > 0 ) - //{ - for ( y = 0; y < this->uHeight; ++y ) + for ( y = 0; y < this->uHeight; ++y ) + { + unsigned __int16 *pDst = pPixels + y * uWidth; + uint x = 0; + do { - v16 = y * this->uWidth; - v17 = this->pPixels; - v18 = &v17[v16]; - //if ( pcx_header2.pitch ) - //{ - for ( x = 0; x < (unsigned __int16)pcx_header2.pitch; ++x ) - { - fread((char *)&Filename + 3, 1, 1, File); - if ( (BYTE3(Filename) & 0xC0) == -64 ) - { - BYTE3(Filename) &= 0x3Fu; - fread((char *)&a3 + 3, 1, 1, File); - - if ( BYTE3(Filename) ) - { - for ( v19 = 0; v19 < BYTE3(Filename); ++v19 ) - { - *v18 = r_mask & (BYTE3(a3) << (num_r_bits + num_g_bits + num_b_bits - 8)); - ++v18; - } - } - } - else - { - *v18 = r_mask & (BYTE3(Filename) << (num_g_bits + num_r_bits + num_b_bits - 8)); - ++v18; - } - } - //while ( v38 < (unsigned __int16)pcx_header2.pitch); - //} - v20 = &this->pPixels[y * this->uWidth]; - while ( x < 2 * (unsigned __int16)pcx_header2.pitch ) + uint ctrl = 0; + fread(&ctrl, 1, 1, File); + if ( (ctrl & 0xC0) == 0xC0 ) + { + uint uNumPixels = ctrl & 0x3F; + uint clr = 0; + ctrl &= 0x3F; + fread(&clr, 1, 1, File); + for ( uint i = 0; i < uNumPixels; ++i ) + pDst[x++] = r_mask & (clr << (num_r_bits + num_g_bits + num_b_bits - 8)); + } + else + pDst[x++] = r_mask & (ctrl << (num_g_bits + num_r_bits + num_b_bits - 8)); + } + while ( x < pcx_header2.pitch ); + + x = 0; + do + { + uint ctrl = 0; + fread(&ctrl, 1, 1, File); + if ( (ctrl & 0xC0) == 0xC0 ) { - fread((char *)&Filename + 3, 1, 1, File); - if ( (BYTE3(Filename) & 0xC0) == -64 ) - { - BYTE3(Filename) &= 0x3Fu; - fread((char *)&a3 + 3, 1, 1, File); - - if ( BYTE3(Filename) ) - { - for ( v21 = 0; v21 < BYTE3(Filename); ++v21 ) - { - *v20 |= g_mask & (unsigned __int16)(BYTE3(a3) << (num_g_bits + num_b_bits - 8)); - //++v38; - ++v20; - } - } - } - else - { - *v20 |= g_mask & (unsigned __int16)(BYTE3(Filename) << (num_g_bits + num_b_bits - 8)); - //++v38; - ++v20; - } + uint uNumPixels = ctrl & 0x3F; + uint clr = 0; + ctrl &= 0x3F; + fread(&clr, 1, 1, File); + for ( uint i = 0; i < uNumPixels; ++i ) + pDst[x++] |= g_mask & (clr << (num_g_bits + num_b_bits - 8)); } - v22 = &this->pPixels[y * this->uWidth]; - while ( x < 3 * (unsigned __int16)pcx_header2.pitch ) + else + pDst[x++] |= g_mask & (ctrl << (num_g_bits + num_b_bits - 8)); + } + while (x < pcx_header2.pitch); + + x = 0; + do + { + uint ctrl = 0; + fread(&ctrl, 1, 1, File); + if ( (ctrl & 0xC0) == 0xC0 ) { - fread((char *)&Filename + 3, 1, 1, File); - if ( (BYTE3(Filename) & 0xC0) == -64 ) - { - BYTE3(Filename) &= 0x3Fu; - fread((char *)&a3 + 3, 1, 1, File); - if ( BYTE3(Filename) ) - { - for ( v23 = 0; v23 < BYTE3(Filename); ++v23 ) - { - *v22 |= BYTE3(a3) >> (8 - num_b_bits); - //++v38; - ++v22; - } - } - } - else - { - *v22 |= BYTE3(Filename) >> (8 - num_b_bits); - //++v38; - ++v22; - } + uint uNumPixels = ctrl & 0x3F; + uint clr = 0; + fread(&clr, 1, 1, File); + for ( uint i = 0; i < uNumPixels; ++i ) + pDst[x++] |= b_mask & (clr >> (8 - num_b_bits)); } - //v24 = this->uHeight; - //++v37; + else + pDst[x++] |= b_mask & (ctrl >> (8 - num_b_bits)); } - //while ( v37 < v24 ); - //} + while (x < pcx_header2.pitch); + } } fclose(File); result = 0; @@ -1534,7 +1497,6 @@ return result; } - //----- (0040D73D) -------------------------------------------------------- RGBTexture::RGBTexture() {