# HG changeset patch # User Ritor1 # Date 1388169128 -21600 # Node ID 0d0aa7c1ccddc1d6581a5435218397d323da74f5 # Parent 400f3db2e4e59401f8d79cffdb05545844a525f9 Savegame_screenshot continue diff -r 400f3db2e4e5 -r 0d0aa7c1ccdd Game.cpp --- a/Game.cpp Fri Dec 27 17:52:31 2013 +0600 +++ b/Game.cpp Sat Dec 28 00:32:08 2013 +0600 @@ -1360,6 +1360,7 @@ char a1[64]; // [sp+1F8h] [bp-404h]@467 char Str2[128]; // [sp+238h] [bp-3C4h]@527 Actor actor; // [sp+2B8h] [bp-344h]@4 + unsigned short* screenshot; dword_50CDC8 = 0; if ( !pEventTimer->bPaused ) @@ -2647,9 +2648,9 @@ pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(6, 1, 0, 0); viewparams->field_48 = 1; stru_506E40.Release(); - uNumSeconds = (unsigned int)MakeScreenshot(155, 117); - pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117); - free((void *)uNumSeconds); + screenshot = MakeScreenshot(155, 117); + pRenderer->SavePCXImage("gamma.pcx", screenshot, 155, 117); + free(screenshot); stru_506E40._40E55E("gamma.pcx", 0); continue; } @@ -3919,9 +3920,9 @@ viewparams->bRedrawGameUI = 1; } stru_506E40.Release(); - uNumSeconds = (unsigned int)MakeScreenshot(155, 117); - pRenderer->SavePCXImage("gamma.pcx", (char *)uNumSeconds, 155, 117); - free((void *)uNumSeconds); + screenshot = MakeScreenshot(155, 117); + pRenderer->SavePCXImage("gamma.pcx", screenshot, 155, 117); + free(screenshot); stru_506E40._40E55E("gamma.pcx", 0); GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton, (int)pBtn_GameSettings, 0); //LABEL_453: diff -r 400f3db2e4e5 -r 0d0aa7c1ccdd Render.cpp --- a/Render.cpp Fri Dec 27 17:52:31 2013 +0600 +++ b/Render.cpp Sat Dec 28 00:32:08 2013 +0600 @@ -2576,7 +2576,7 @@ //Render *v7; // ebx@1 void *v8; // esi@3 void *v9; // esi@3 - int v10; // ecx@4 + //int v10; // ecx@4 unsigned short* v11; // eax@4 //int v12; // eax@6 int v13; // eax@8 @@ -2625,21 +2625,21 @@ Src.vdpi = 75; v27.planes = 3; v27.palette_info = 1; - memcpy(data_buff, &Src, 1u); + memcpy(data_buff, &Src, 1); v8 = (char *)v8 + 1; - memcpy(v8, &Src.version, 1u); + memcpy(v8, &Src.version, 1); v8 = (char *)v8 + 1; - memcpy(v8, &Src.encoding, 1u); + memcpy(v8, &Src.encoding, 1); v8 = (char *)v8 + 1; - memcpy(v8, &Src.bpp, 1u); + memcpy(v8, &Src.bpp, 1); v8 = (char *)v8 + 1; - memcpy(v8, &Src.left, 2u); + memcpy(v8, &Src.left, 2); v8 = (char *)v8 + 2; - memcpy(v8, &Src.up, 2u); + memcpy(v8, &Src.up, 2); v8 = (char *)v8 + 2; - memcpy(v8, &Src.right, 2u); + memcpy(v8, &Src.right, 2); v8 = (char *)v8 + 2; - memcpy(v8, &Src.bottom, 2u); + memcpy(v8, &Src.bottom, 2); v8 = (char *)v8 + 2; memcpy(v8, &Src.hdpi, 2); v8 = (char *)v8 + 2; @@ -2661,7 +2661,7 @@ lineRGB = (char*)malloc(3 * (wight + 2)); if ( heidth > 0 ) { - v10 = pitch; + //v10 = pitch; v26 = 3 * pitch; v23 = 2 * wight; v11 = picture_data; @@ -2678,15 +2678,16 @@ 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; } } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) { - pict_byte = lineRGB [i]; + pict_byte = lineRGB[i]; for ( test_byte = 1; test_byte < 63; ++test_byte ) { v15 = i + test_byte; - if ( *((char *)lineRGB + v15) != pict_byte ) + if ( lineRGB[v15] != pict_byte ) break; if ( !(v15 % pitch) ) break; @@ -2702,8 +2703,8 @@ memcpy(v9, &pict_byte, 1); i += test_byte; } - v11 +=wight ; - v10 = pitch; + v11 += wight; + //v10 = pitch; } } free(lineRGB); @@ -2711,13 +2712,13 @@ } //----- (0049F8B5) -------------------------------------------------------- -FILE *Render::SavePCXImage(const char *Filename, char *pPixels, int width, int height) +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 - int v9; // eax@5 + //int v8; // ecx@5 + unsigned short* v9; // eax@5 int v10; // eax@7 //int v11; // ecx@9 signed int v12; // eax@12 @@ -2731,9 +2732,13 @@ 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 *for_rad; // [sp+98h] [bp-Ch]@4 - int new_width; // [sp+9Ch] [bp-8h]@2 - char *for_blue; // [sp+A0h] [bp-4h]@8 + char *lineRGB; // [sp+98h] [bp-Ch]@4 + int pitch; // [sp+9Ch] [bp-8h]@2 + char *lineB; // [sp+A0h] [bp-4h]@8 + char *lineG; + unsigned short* line_pictute_data; + byte test_byte; + char v43; int num_r_bits = 5; int num_g_bits = 6; @@ -2747,14 +2752,14 @@ Filename = (const char *)result; if ( result ) { - new_width = width; + pitch = width; if ( width & 1 ) - new_width = width + 1; + pitch = width + 1; header1.left = 0; header1.up = 0; header1.right = width - 1; header1.bottom = height - 1; - header2.pitch = new_width; + header2.pitch = pitch; memset(color_map, 0, sizeof(color_map)); header2.reserved = 0; memset(v14, 0, sizeof(v14)); @@ -2784,58 +2789,59 @@ fwrite(&header2.pitch, 2, 1, pOutFile); fwrite(&header2.palette_info, 2, 1, pOutFile); fwrite(v14, 0x3Au, 1, pOutFile); - for_rad = malloc(3 * width + 6); + + lineRGB = (char *)malloc(3 * (width + 2)); //При сохранении изображения подряд идущие пиксели одинакового цвета объединяются и вместо указания цвета для каждого пикселя //указывается цвет группы пикселей и их количество. //if ( height > 0 ) //{ - v8 = new_width; - image_width = 3 * new_width; + //v8 = pitch; + image_width = 3 * pitch; v17 = 2 * width; - //v9 = (int)pPixels; + v9 = picture_data; //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); + line_pictute_data = v9; + lineG = (char *)lineRGB + pitch; + lineB = (char *)lineRGB + 2 * pitch; + + for ( int i = 0; i < width; i++ )//строка + { + 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; + } + test_byte = 1; + for ( int i = 0; (signed int)i < image_width; i += test_byte )// += BYTE3(pPixels) ) + { + unsigned char pic_byte = lineRGB[i]; //for ( BYTE3(pPixels) = 1; BYTE3(pPixels) < 0x3F; ++BYTE3(pPixels) ) - for ( int j = 1; j < 0x3F; ++j )// расчёт количества одинаковых цветов + for ( test_byte; test_byte < 63; ++test_byte )// расчёт количества одинаковых цветов { - v12 = (signed int)&for_blue[BYTE3(pPixels)]; - if ( *((char *)for_rad + j) != test_byte ) + v12 = i + test_byte; + if ( lineRGB[v12] != pic_byte ) break; - if ( !(v12 % new_width) ) + if ( !(v12 % pitch) ) break; } - if ( (signed int)&for_blue[BYTE3(pPixels)] > image_width ) - BYTE3(pPixels) = 3 * new_width - (char)i; - if ( BYTE3(pPixels) > 1 || test_byte >= 0xC0 ) + if ( i + test_byte > image_width ) + test_byte = 3 * pitch - i; + if ( test_byte > 1 || pic_byte >= 0xC0 ) { - BYTE3(for_green) = BYTE3(pPixels) | 0xC0;//тест-байт объединения - fwrite((char *)&for_green + 3, 1, 1, pOutFile); + v43 = test_byte | 0xC0;//тест-байт объединения + fwrite(&v43, 1, 1, pOutFile); } - fwrite((char *)&Filename + 3, 1, 1, pOutFile); - } - //v9 = (int)&v19[v17]; + fwrite(&pic_byte, 1, 1, pOutFile); + } + v9 += width; //v19 += v17; - pPixels += v17; - v8 = new_width; + //pPixels += v17; + //v8 = pitch; } //} - free(for_rad); + free(lineRGB); result = (FILE *)fclose(pOutFile); } return result; diff -r 400f3db2e4e5 -r 0d0aa7c1ccdd Render.h --- a/Render.h Fri Dec 27 17:52:31 2013 +0600 +++ b/Render.h Sat Dec 28 00:32:08 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 *pPixels, int width, int height); + FILE *SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height); void ClearTarget(unsigned int uColor); void Release2(); void Present(); diff -r 400f3db2e4e5 -r 0d0aa7c1ccdd SaveLoad.cpp --- a/SaveLoad.cpp Fri Dec 27 17:52:31 2013 +0600 +++ b/SaveLoad.cpp Sat Dec 28 00:32:08 2013 +0600 @@ -747,7 +747,19 @@ //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 = 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) + { + auto p = (unsigned __int32 *)Dst.lpSurface + x + y * Dst.lPitch; + *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); + } + else if (pRenderer->ddpfPrimarySuface.dwRGBBitCount == 16) + { + auto p = (unsigned __int16 *)Dst.lpSurface + x + y * Dst.lPitch; + *v3 = *p; + } + else __debugbreak(); ++v3; } } @@ -841,9 +853,9 @@ //----- (0045E26C) -------------------------------------------------------- void SaveScreenshot(const char *pFilename) { - unsigned __int16 *v2; // esi@1 + unsigned short *screenshot; // esi@1 - v2 = MakeScreenshot(92, 68); - pRenderer->SavePCXImage(pFilename, (char *)v2, 92, 68); - free(v2); + screenshot = MakeScreenshot(92, 68); + pRenderer->SavePCXImage(pFilename, screenshot, 92, 68); + free(screenshot); } \ No newline at end of file diff -r 400f3db2e4e5 -r 0d0aa7c1ccdd mm7_2.cpp --- a/mm7_2.cpp Fri Dec 27 17:52:31 2013 +0600 +++ b/mm7_2.cpp Sat Dec 28 00:32:08 2013 +0600 @@ -4242,7 +4242,7 @@ bool new_sky = false; bool new_draw_object_dist = true; -bool change_seasons = true;//Ritor1: temporarily for demonstration snow +bool change_seasons = false; bool all_magic = true; bool wizard_eye = false; bool debug_information = false; diff -r 400f3db2e4e5 -r 0d0aa7c1ccdd mm7_3.cpp --- a/mm7_3.cpp Fri Dec 27 17:52:31 2013 +0600 +++ b/mm7_3.cpp Sat Dec 28 00:32:08 2013 +0600 @@ -2685,7 +2685,7 @@ pFilename = pLevelFilename; //thisa->AllocSoftwareDrawBuffers(); pODMRenderParams->Initialize(); - pWeather->bRenderSnow = true;//Ritor1: temporarily for demonstration snow + pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (ODMRenderParams *)1; GetAlertStatus();