Mercurial > mm7
changeset 2127:400f3db2e4e5
Screenshot continue
author | Ritor1 |
---|---|
date | Fri, 27 Dec 2013 17:52:31 +0600 |
parents | a2da7afb41b4 |
children | 0d0aa7c1ccdd 23dbcaa651cc |
files | Render.cpp Render.h SaveLoad.cpp Texture.cpp |
diffstat | 4 files changed, 137 insertions(+), 151 deletions(-) [+] |
line wrap: on
line diff
--- a/Render.cpp Thu Dec 26 22:58:54 2013 +0000 +++ b/Render.cpp Fri Dec 27 17:52:31 2013 +0600 @@ -2572,13 +2572,13 @@ //----- (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 +{ + //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 v12; // eax@6 int v13; // eax@8 int v14; // ecx@8 signed int v15; // eax@11 @@ -2603,7 +2603,7 @@ byte test_byte; unsigned char pict_byte; - v7 = this; + //v7 = this; pitch = wight; if ( wight & 1 ) pitch = wight + 1; @@ -2641,19 +2641,19 @@ v8 = (char *)v8 + 2; memcpy(v8, &Src.bottom, 2u); v8 = (char *)v8 + 2; - memcpy(v8, &Src.hdpi, 2u); + memcpy(v8, &Src.hdpi, 2); v8 = (char *)v8 + 2; - memcpy(v8, &Src.vdpi, 2u); + memcpy(v8, &Src.vdpi, 2); v8 = (char *)v8 + 2; memcpy(v8, &v20, 0x30u); v8 = (char *)v8 + 48; memcpy(v8, &v27, 1u); v8 = (char *)v8 + 1; - memcpy(v8, &v27.planes, 1u); + memcpy(v8, &v27.planes, 1); v8 = (char *)v8 + 1; - memcpy(v8, &v27.pitch, 2u); + memcpy(v8, &v27.pitch, 2); v8 = (char *)v8 + 2; - memcpy(v8, &v27.palette_info, 2u); + memcpy(v8, &v27.palette_info, 2); v8 = (char *)v8 + 2; memcpy(v8, &v18, 0x3Au); v9 = (char *)v8 + 58; @@ -2662,78 +2662,64 @@ if ( heidth > 0 ) { v10 = pitch; - v25 = heidth; v26 = 3 * pitch; v23 = 2 * wight; v11 = picture_data; v24 = (int)picture_data; - while ( 1 ) + for ( v25 = heidth; v25; v25-- ) { line_pictute_data = v11; - v12 = 0; - i = 0; if ( wight > 0 ) { lineG = (char *)lineRGB + pitch; lineB = (char *)lineRGB + 2 * pitch; - do + for ( uint i = 0; i < wight; i++ ) { - 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++; + 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); } - while ( v12 < wight ); } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) { - test_byte = 1; pict_byte = lineRGB [i]; - do + for ( test_byte = 1; test_byte < 63; ++test_byte ) { v15 = i + test_byte; if ( *((char *)lineRGB + v15) != pict_byte ) break; if ( !(v15 % pitch) ) break; - ++test_byte; } - while ( test_byte < 0x3Fu ); if ( i + test_byte > v26 ) test_byte = 3 * pitch - i; - if ( test_byte > 1u || pict_byte >= 0xC0u ) + if ( test_byte > 1 || pict_byte >= 192 ) { v43 = test_byte | 0xC0; - memcpy(v9, &v43, 1u); + memcpy(v9, &v43, 1); v9 = (char *)v9 + 1; } - memcpy(v9, &pict_byte, 1u); + memcpy(v9, &pict_byte, 1); i += test_byte; } v11 +=wight ; - v16 = v25-- == 1; - - if ( v16 ) - break; v10 = pitch; } } free(lineRGB); *(int *)packed_size = (char *)v9 - data_buff; - } //----- (0049F8B5) -------------------------------------------------------- -FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) +FILE *Render::SavePCXImage(const char *Filename, char *pPixels, int width, int height) { //Render *v5; // esi@1 FILE *result; // eax@1 - FILE *v7; // edi@4 + FILE *pOutFile; // edi@4 int v8; // ecx@5 int v9; // eax@5 int v10; // eax@7 - int v11; // ecx@9 + //int v11; // ecx@9 signed int v12; // eax@12 char v13; // zf@21 char v14[56]; // [sp+4h] [bp-A0h]@4 @@ -2742,25 +2728,33 @@ int v17; // [sp+70h] [bp-34h]@5 int v18; // [sp+74h] [bp-30h]@5 char *v19; // [sp+78h] [bp-2Ch]@5 - int v20; // [sp+7Ch] [bp-28h]@5 + int image_width; // [sp+7Ch] [bp-28h]@5 PCXHeader_1 header1; // [sp+80h] [bp-24h]@4 PCXHeader_2 header2; // [sp+90h] [bp-14h]@4 - void *ptr; // [sp+98h] [bp-Ch]@4 - int v24; // [sp+9Ch] [bp-8h]@2 - char *i; // [sp+A0h] [bp-4h]@8 + void *for_rad; // [sp+98h] [bp-Ch]@4 + int new_width; // [sp+9Ch] [bp-8h]@2 + char *for_blue; // [sp+A0h] [bp-4h]@8 + + 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; result = fopen(Filename, "wb"); Filename = (const char *)result; if ( result ) { - v24 = a4; - if ( a4 & 1 ) - v24 = a4 + 1; + new_width = width; + if ( width & 1 ) + new_width = width + 1; header1.left = 0; header1.up = 0; - header1.right = a4 - 1; - header1.bottom = a5 - 1; - header2.pitch = v24; + header1.right = width - 1; + header1.bottom = height - 1; + header2.pitch = new_width; memset(color_map, 0, sizeof(color_map)); header2.reserved = 0; memset(v14, 0, sizeof(v14)); @@ -2773,88 +2767,76 @@ header1.vdpi = 75; header2.planes = 3; header2.palette_info = 1; - fwrite(&header1, 1u, 1u, (FILE *)Filename); - v7 = (FILE *)Filename; - fwrite(&header1.version, 1u, 1u, (FILE *)Filename); - fwrite(&header1.encoding, 1u, 1u, v7); - fwrite(&header1.bpp, 1u, 1u, v7); - fwrite(&header1.left, 2u, 1u, v7); - fwrite(&header1.up, 2u, 1u, v7); - fwrite(&header1.right, 2u, 1u, v7); - fwrite(&header1.bottom, 2u, 1u, v7); - fwrite(&header1.hdpi, 2u, 1u, v7); - fwrite(&header1.vdpi, 2u, 1u, v7); - fwrite(color_map, 0x30u, 1u, v7); - fwrite(&header2, 1u, 1u, v7); - fwrite(&header2.planes, 1u, 1u, v7); - fwrite(&header2.pitch, 2u, 1u, v7); - fwrite(&header2.palette_info, 2u, 1u, v7); - fwrite(v14, 0x3Au, 1u, v7); - ptr = malloc(3 * a4 + 6); - if ( a5 > 0 ) - { - v8 = v24; - v18 = a5; - v20 = 3 * v24; - v17 = 2 * a4; - v9 = (int)a3; - v19 = a3; - while ( 1 ) - { - a5 = v9; - v10 = 0; - if ( a4 > 0 ) + fwrite(&header1, 1, 1, (FILE *)Filename); + pOutFile = (FILE *)Filename; + fwrite(&header1.version, 1, 1, (FILE *)Filename); + fwrite(&header1.encoding, 1, 1, pOutFile); + fwrite(&header1.bpp, 1, 1, pOutFile); + fwrite(&header1.left, 2, 1, pOutFile); + fwrite(&header1.up, 2, 1, pOutFile); + fwrite(&header1.right, 2, 1, pOutFile); + fwrite(&header1.bottom, 2, 1, pOutFile); + fwrite(&header1.hdpi, 2, 1, pOutFile); + fwrite(&header1.vdpi, 2, 1, pOutFile); + fwrite(color_map, 0x30u, 1, pOutFile); + fwrite(&header2, 1, 1, pOutFile); + fwrite(&header2.planes, 1, 1, pOutFile); + fwrite(&header2.pitch, 2, 1, pOutFile); + fwrite(&header2.palette_info, 2, 1, pOutFile); + fwrite(v14, 0x3Au, 1, pOutFile); + for_rad = malloc(3 * width + 6); + //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя + //указывается цвет группы пикселей и их количество. + //if ( height > 0 ) + //{ + v8 = new_width; + image_width = 3 * new_width; + v17 = 2 * width; + //v9 = (int)pPixels; + //v19 = pPixels; + for ( v18 = 0; v18 < height; v18++ )//столбец + { + //pPixels = v9; + char *for_green = (char *)for_rad + v8; + for_blue = (char *)for_rad + 2 * new_width; + + for ( v10 = 0; v10 < width; v10++ )//строка + { + *((char *)for_rad + v10) = (signed int)(r_mask & *(short *)pPixels) >> (num_g_bits + num_b_bits + num_r_bits - 8); + for_green[v10] = (signed int)(g_mask & *(short *)pPixels) >> (num_b_bits + num_g_bits - 8); + for_blue[v10] = (b_mask & *(char *)pPixels) << (8 - num_b_bits); + pPixels += 2; + } + + for ( int i = 0; (signed int)i < image_width; i++ )// += BYTE3(pPixels) ) + { + unsigned char test_byte = *((char *)for_rad + i); + //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) ) + for ( int j = 1; j < 0x3F; ++j )// расчёт количества одинаковых цветов { - a3 = (char *)ptr + v8; - i = (char *)ptr + 2 * v24; - do - { - *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits) - + LOBYTE(this->uTargetBBits) - + this->uTargetRBits - - 8); - a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits) - + LOBYTE(this->uTargetGBits) - - 8); - v11 = a5; - a5 += 2; - i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits)); - } - while ( v10 < a4 ); + v12 = (signed int)&for_blue[BYTE3(pPixels)]; + if ( *((char *)for_rad + j) != test_byte ) + break; + if ( !(v12 % new_width) ) + break; } - for ( i = 0; (signed int)i < v20; i += BYTE3(a5) ) + if ( (signed int)&for_blue[BYTE3(pPixels)] > image_width ) + BYTE3(pPixels) = 3 * new_width - (char)i; + if ( BYTE3(pPixels) > 1 || test_byte >= 0xC0 ) { - BYTE3(a5) = 1; - BYTE3(Filename) = *((char *)ptr + (int)i); - do - { - v12 = (signed int)&i[BYTE3(a5)]; - if ( *((char *)ptr + v12) != BYTE3(Filename) ) - break; - if ( !(v12 % v24) ) - break; - ++BYTE3(a5); - } - while ( BYTE3(a5) < 0x3Fu ); - if ( (signed int)&i[BYTE3(a5)] > v20 ) - BYTE3(a5) = 3 * v24 - (char)i; - if ( BYTE3(a5) > 1u || BYTE3(Filename) >= 0xC0u ) - { - BYTE3(a3) = BYTE3(a5) | 0xC0; - fwrite((char *)&a3 + 3, 1u, 1u, v7); - } - fwrite((char *)&Filename + 3, 1u, 1u, v7); + BYTE3(for_green) = BYTE3(pPixels) | 0xC0;//тест-байт объединения + fwrite((char *)&for_green + 3, 1, 1, pOutFile); } - v9 = (int)&v19[v17]; - v13 = v18-- == 1; - v19 += v17; - if ( v13 ) - break; - v8 = v24; - } - } - free(ptr); - result = (FILE *)fclose(v7); + fwrite((char *)&Filename + 3, 1, 1, pOutFile); + } + //v9 = (int)&v19[v17]; + //v19 += v17; + pPixels += v17; + v8 = new_width; + } + //} + free(for_rad); + result = (FILE *)fclose(pOutFile); } return result; }
--- a/Render.h Thu Dec 26 22:58:54 2013 +0000 +++ b/Render.h Fri Dec 27 17:52:31 2013 +0600 @@ -282,7 +282,7 @@ void SavePCXScreenshot(); void SaveWinnersCertificate(const char *a1); void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size); - FILE *SavePCXImage(const char *Filename, char *a3, int a4, int a5); + FILE *SavePCXImage(const char *Filename, char *pPixels, int width, int height); void ClearTarget(unsigned int uColor); void Release2(); void Present();
--- a/SaveLoad.cpp Thu Dec 26 22:58:54 2013 +0000 +++ b/SaveLoad.cpp Fri Dec 27 17:52:31 2013 +0600 @@ -24,6 +24,7 @@ #include "Log.h" #include "VideoPlayer.h" #include "Level/Decoration.h" +#include "Render.h" #include "mm7_data.h" @@ -321,7 +322,7 @@ pLodDirectory.uDataSize = sizeof(Party); //90680; if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);//Save game corrupted! Code=%d MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); } strcpy(pLodDirectory.pFilename, "clock.bin"); @@ -681,7 +682,7 @@ //unsigned __int16 *v9; // edi@15 //int v10; // ecx@15 //LONG v11; // esi@15 - //signed __int64 v12; // qax@18 + unsigned int screen_x; // qax@18 //unsigned int v13; // ST10_4@21 HRESULT v14; // eax@21 int v15; // edi@29 @@ -691,10 +692,10 @@ int k; // ecx@36 DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 - float v23; // [sp+84h] [bp-20h]@1 + float interval_x; // [sp+84h] [bp-20h]@1 unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 - float v25; // [sp+8Ch] [bp-18h]@1 - unsigned int v26; // [sp+90h] [bp-14h]@17 + 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 @@ -703,8 +704,8 @@ //v30 = width; //v2 = height; //v27 = height; - v23 = game_viewport_width / (double)width; - v25 = game_viewport_height / (double)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); @@ -726,27 +727,31 @@ if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) { - ushort* src = (unsigned __int16 *)Dst.lpSurface; - ulong src_width = (Dst.lPitch / sizeof(short)); - ulong src_height = Dst.dwHeight; + 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; - Assert(game_viewport_y + y * v25 < src_height); - Assert(y < height); + //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; - 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]; + //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)]; + ++v3; } } + //pPixels = dst; ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); } else
--- a/Texture.cpp Thu Dec 26 22:58:54 2013 +0000 +++ b/Texture.cpp Fri Dec 27 17:52:31 2013 +0600 @@ -690,7 +690,8 @@ unsigned int num_g_bits = 6; unsigned int b_mask = 0x001F; unsigned int num_b_bits = 5; - + //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя + //указывается цвет группы пикселей и их количество. read_offset = 128; if (psx_head2.planes != 3) return 0; @@ -709,25 +710,23 @@ { test_byte = pPcx[read_offset]; ++read_offset; - if ((test_byte & 0xC0) == 0xC0) + if ((test_byte & 0xC0) == 0xC0)//имеется ли объединение { value = pPcx[read_offset]; ++read_offset; if ((test_byte & 0x3F) > 0) { - count = test_byte & 0x3F; + count = test_byte & 0x3F;//количество одинаковых пикселей do { - ++row_position; //*temp_dec_position =0xFF000000; - //*temp_dec_position|=(unsigned long)value<<16; + //*temp_dec_position|=(unsigned long)value<<16; *temp_dec_position |= r_mask & ((unsigned __int8)value << (num_g_bits + num_r_bits + num_b_bits - 8)); - - temp_dec_position++; - if (row_position == psx_head2.pitch) - break; + temp_dec_position++; + if (row_position == psx_head2.pitch) + break; } while (count-- != 1); }