# HG changeset patch # User Ritor1 # Date 1388258775 -21600 # Node ID 49de109bbab592a79019372453036cb74b5c9093 # Parent 651b24553ae98c8e4100537b66c70969841ded0b SavePCXScreenshot() continue diff -r 651b24553ae9 -r 49de109bbab5 Game.cpp --- a/Game.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/Game.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -399,7 +399,7 @@ uGameState = GAME_STATE_PLAYING; continue; } - if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) + if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU )//GAME_STATE_NEWGAME_OUT_GAMEMENU, GAME_STATE_LOADING_GAME { game_finished = true; continue; diff -r 651b24553ae9 -r 49de109bbab5 LOD.cpp --- a/LOD.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/LOD.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -2379,40 +2379,41 @@ //----- (004103BB) -------------------------------------------------------- void LODFile_IconsBitmaps::ReleaseHardwareTextures() { - LODFile_IconsBitmaps *v1; // esi@1 + //LODFile_IconsBitmaps *v1; // esi@1 unsigned int v2; // edi@1 - struct IDirect3DTexture2 **v3; // eax@2 - struct IDirect3DTexture2 *v4; // eax@3 - struct IDirectDrawSurface **v5; // eax@5 - struct IDirectDrawSurface *v6; // eax@6 + //struct IDirect3DTexture2 **v3; // eax@2 + //struct IDirect3DTexture2 *v4; // eax@3 + //struct IDirectDrawSurface **v5; // eax@5 + //struct IDirectDrawSurface *v6; // eax@6 - v1 = this; - v2 = this->uNumLoadedFiles; - while ( 1 ) + //v1 = this; + + //while ( 1 ) + for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) { - --v2; - if ( (v2 & 0x80000000u) != 0 ) - break; - v3 = v1->pHardwareTextures; - if ( v3 ) + + //if ( (v2 & 0x80000000u) != 0 ) + //break; + //v3 = this->pHardwareTextures; + if ( this->pHardwareTextures ) { - v4 = v3[v2]; - if ( v4 ) + //v4 = this->pHardwareTextures[v2]; + if ( this->pHardwareTextures[i] ) { - v4->Release(); - v1->pHardwareTextures[v2] = 0; - v1->ptr_011BB4[v2] = 1; + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + this->ptr_011BB4[i] = 1; } } - v5 = v1->pHardwareSurfaces; - if ( v5 ) + //v5 = this->pHardwareSurfaces; + if ( this->pHardwareSurfaces ) { - v6 = v5[v2]; - if ( v6 ) + //v6 = this->pHardwareSurfaces[v2]; + if ( this->pHardwareSurfaces[i] ) { - v6->Release(); - v1->pHardwareSurfaces[v2] = 0; - v1->ptr_011BB4[v2] = 1; + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + this->ptr_011BB4[i] = 1; } } } diff -r 651b24553ae9 -r 49de109bbab5 OSWindow.cpp --- a/OSWindow.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/OSWindow.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -67,6 +67,8 @@ { if (wparam == VK_CONTROL) _507B98_ctrl_pressed = false; + if (wparam == VK_SNAPSHOT) + pRenderer->SavePCXScreenshot(); OnKey(wparam); return *result = 0, true; @@ -693,14 +695,14 @@ default: return false; - case 103: pRenderer->SavePCXScreenshot(); break; + //case 103: pRenderer->SavePCXScreenshot(); break; case 101: // Quit game - case 40001: - pGame->Deinitialize(); + case 40001: // Menu "File"-> "Exit" + pGame->Deinitialize(); SendMessageW(api_handle, WM_DESTROY, 0, 0); break; - case 104: + case 104: //F4 button pRenderer->ChangeBetweenWinFullscreenModes(); if (pArcomageGame->bGameInProgress) pArcomageGame->field_F6 = 1; diff -r 651b24553ae9 -r 49de109bbab5 Outdoor.cpp --- a/Outdoor.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/Outdoor.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -1001,7 +1001,6 @@ signed int result; // eax@2 unsigned __int16 *v5; // edx@3 double v6; // st7@3 - char v7; // bl@3 int v8; // eax@3 int v9; // eax@4 int v10; // eax@5 @@ -1012,10 +1011,6 @@ signed int v15; // ecx@10 char v16[256]; // [sp+4h] [bp-124h]@9 unsigned __int16 *v17; // [sp+104h] [bp-24h]@3 - unsigned int v18; // [sp+108h] [bp-20h]@3 - unsigned int v19; // [sp+10Ch] [bp-1Ch]@3 - unsigned int v20; // [sp+110h] [bp-18h]@3 - unsigned int v21; // [sp+114h] [bp-14h]@3 float v22; // [sp+118h] [bp-10h]@3 float v23; // [sp+11Ch] [bp-Ch]@3 int i; // [sp+120h] [bp-8h]@3 @@ -1025,23 +1020,25 @@ float a3a; // [sp+138h] [bp+10h]@7 int a3b; // [sp+138h] [bp+10h]@9 + 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; + if ( pRenderer->pRenderD3D ) - { result = 0; - } else { + __debugbreak(); v5 = PaletteManager::Get_Dark_or_Red_LUT(a2, 0, 1); v6 = 0.0; - v7 = LOBYTE(pRenderer->uTargetBBits); - v19 = pRenderer->uTargetRMask; - v21 = pRenderer->uTargetGMask; v22 = 0.0; - v20 = pRenderer->uTargetBMask; v8 = 0; v17 = v5; v23 = 0.0; - v18 = pRenderer->uTargetBBits; a2a = 0; for ( i = 0; i < a3; ++i ) { @@ -1049,11 +1046,11 @@ if ( v9 ) { v10 = v5[v9]; - v6 = v6 + (double)((signed int)(v19 & v10) >> (LOBYTE(pRenderer->uTargetBBits) + LOBYTE(pRenderer->uTargetGBits))); + v6 = v6 + (double)((signed int)(r_mask & v10) >> (num_b_bits + num_g_bits)); ++a2a; - v25 = v20 & v10; - v22 = (double)((signed int)(v21 & v10) >> SLOBYTE(pRenderer->uTargetBBits)) + v22; - v23 = (double)(signed int)(v20 & v10) + v23; + v25 = b_mask & v10; + v22 = (double)((signed int)(g_mask & v10) >> num_b_bits) + v22; + v23 = (double)(signed int)(b_mask & v10) + v23; } v8 = i + 1; } @@ -1062,16 +1059,15 @@ v25 = (signed __int64)(a3a * v22); i = (signed __int64)(a3a * v23); v12 = 0; - a2b = pRenderer->uTargetBBits + pRenderer->uTargetGBits; + a2b = num_b_bits + num_g_bits; while ( 1 ) { v13 = v17[v12]; - a3b = abs((__int64)(signed __int64)(v11 * v6) - ((signed int)(v19 & v17[v12]) >> a2b)); - BYTE3(a3b) = abs((signed)v25 - ((signed int)(v21 & v13) >> v7)) + a3b; - v16[v12++] = abs((signed)i - (signed)(v20 & v13)) + BYTE3(a3b); + a3b = abs((__int64)(signed __int64)(v11 * v6) - ((signed int)(r_mask & v17[v12]) >> a2b)); + BYTE3(a3b) = abs((signed)v25 - ((signed int)(g_mask & v13) >> num_b_bits)) + a3b; + v16[v12++] = abs((signed)i - (signed)(b_mask & v13)) + BYTE3(a3b); if ( v12 >= 256 ) break; - v7 = v18; } result = 0; v14 = (char *)&pPaletteManager->field_D1600[42][23][116]; diff -r 651b24553ae9 -r 49de109bbab5 Render.cpp --- a/Render.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/Render.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -2193,84 +2193,74 @@ //----- (0049EDB6) -------------------------------------------------------- void Render::SavePCXScreenshot() { - Render *v1; // esi@1 - __int16 v2; // di@1 - int v3; // eax@4 - int v4; // ecx@4 int v5; // eax@8 - FILE *v6; // edi@10 - int v7; // ecx@11 - int v8; // eax@11 + FILE *pOutFile; // edi@10 + unsigned short * v8; // eax@11 int v9; // eax@13 int v10; // ecx@15 - unsigned __int8 v11; // dl@15 signed int v12; // eax@18 - char v13; // zf@27 HRESULT v14; // eax@29 char v15[56]; // [sp+Ch] [bp-158h]@10 - __int16 v16; // [sp+44h] [bp-120h]@10 DDSURFACEDESC2 Dst; // [sp+48h] [bp-11Ch]@7 char color_map[48]; // [sp+C4h] [bp-A0h]@10 char Filename[40]; // [sp+F4h] [bp-70h]@3 - char *v20; // [sp+11Ch] [bp-48h]@14 - char *v21; // [sp+120h] [bp-44h]@14 - int v24; // [sp+124h] [bp-40h]@11 + char *lineB; // [sp+11Ch] [bp-48h]@14 + char *lineG; // [sp+120h] [bp-44h]@14 + //int v24; // [sp+124h] [bp-40h]@11 FILE *File; // [sp+128h] [bp-3Ch]@3 - int var38; // [sp+12Ch] [bp-38h]@4 PCXHeader_1 header1; // [sp+130h] [bp-34h]@10 PCXHeader_2 header2; // [sp+140h] [bp-24h]@10 - void *ptr; // [sp+148h] [bp-1Ch]@10 - void *v28; // [sp+14Ch] [bp-18h]@8 - int v29; // [sp+150h] [bp-14h]@4 - int v30; // [sp+154h] [bp-10h]@4 + char *lineRGB; // [sp+148h] [bp-1Ch]@10 + void *surface; // [sp+14Ch] [bp-18h]@8 + int image_width; // [sp+150h] [bp-14h]@4 + int pitch; // [sp+154h] [bp-10h]@4 char v31; // [sp+15Ah] [bp-Ah]@25 - unsigned __int8 v32; // [sp+15Bh] [bp-9h]@17 - int i; // [sp+15Ch] [bp-8h]@10 - unsigned __int8 v34; // [sp+163h] [bp-1h]@17 - - v1 = this; - v2 = 0; + unsigned char pict_byte; // [sp+15Bh] [bp-9h]@17 + unsigned short *line_picture_data; // [sp+15Ch] [bp-8h]@10 + byte test_byte; // [sp+163h] [bp-1h]@17 + + 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; + if ( !this->pRenderD3D || this->using_software_screen_buffer ) { - sprintf(Filename, "screen%0.2i.pcx", dword_4EFA80++ % 100); + sprintf(Filename, "screen%0.2i.pcx", ScreenshotFileNumber++ % 100); File = fopen(Filename, "wb"); if ( File ) { - v3 = v1->field_10; - v4 = v1->field_14; - var38 = v3; - v29 = v4; - v30 = v3; - if ( v3 & 1 ) - v30 = v3 + 1; - if ( v1->pRenderD3D ) - { - memset(&Dst, 0, 0x7Cu); + pitch = this->field_10; + if ( this->field_10 & 1 ) + pitch = this->field_10 + 1; + if ( this->pRenderD3D ) + { + memset(&Dst, 0, 0x7C); Dst.dwSize = 124; if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) return; - v28 = Dst.lpSurface; - v5 = Dst.lPitch >> 1; - v2 = 0; + surface = Dst.lpSurface; + v5 = Dst.lPitch / 2; } else { pRenderer->BeginScene(); - v28 = pRenderer->pTargetSurface; + surface = pRenderer->pTargetSurface; v5 = pRenderer->uTargetSurfacePitch; } - i = v5; - header1.right = var38 - 1; - header1.left = v2; - header1.bottom = v29 - 1; - header1.up = v2; - header2.pitch = v30; + header1.right = this->field_10 - 1; + header1.left = 0; + header1.bottom = this->field_14 - 1; + header1.up = 0; + header2.pitch = pitch; memset(color_map, 0, sizeof(color_map)); memset(v15, 0, sizeof(v15)); header2.reserved = 0; header1.manufacturer = 10; - v16 = 0; - v6 = File; + pOutFile = File; header1.version = 5; header1.encoding = 1; header1.bpp = 8; @@ -2278,97 +2268,73 @@ header1.vdpi = 75; header2.planes = 3; header2.palette_info = 1; - fwrite(&header1, 1u, 1u, File); - fwrite(&header1.version, 1u, 1u, v6); - fwrite(&header1.encoding, 1u, 1u, v6); - fwrite(&header1.bpp, 1u, 1u, v6); - fwrite(&header1.left, 2u, 1u, v6); - fwrite(&header1.up, 2u, 1u, v6); - fwrite(&header1.right, 2u, 1u, v6); - fwrite(&header1.bottom, 2u, 1u, v6); - fwrite(&header1.hdpi, 2u, 1u, v6); - fwrite(&header1.vdpi, 2u, 1u, v6); - fwrite(color_map, 0x30u, 1u, v6); - fwrite(&header2, 1u, 1u, v6); - fwrite(&header2.planes, 1u, 1u, v6); - fwrite(&header2.pitch, 2u, 1u, v6); - fwrite(&header2.palette_info, 2u, 1u, v6); - fwrite(v15, 0x3Au, 1u, v6); - ptr = malloc(3 * var38 + 6); - if ( v29 > 0 ) - { - v7 = v30; - File = (FILE *)v29; - v29 = 3 * v30; - v24 = 2 * i; - v8 = (int)v28; - while ( 1 ) + fwrite(&header1, 1, 1, File); + fwrite(&header1.version, 1, 1, pOutFile); + 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(v15, 0x3Au, 1, pOutFile); + lineRGB = (char *)malloc(3 * this->field_10 + 6); + if ( this->field_14 > 0 ) + { + image_width = 3 * pitch; + //v24 = 2 * v5; + v8 = (unsigned short *)surface; + for ( int y = 0; y < this->field_14; y++ ) { - i = v8; - v9 = 0; - if ( var38 > 0 ) + line_picture_data = v8; + if ( this->field_10 > 0 ) { - v21 = (char *)ptr + v7; - v20 = (char *)ptr + 2 * v30; - do + lineG = (char *)lineRGB + pitch; + lineB = (char *)lineRGB + 2 * pitch; + for ( uint x = 0; x < this->field_10; x++ ) { - *((char *)ptr + v9) = (signed int)(v1->uTargetRMask & *(short *)i) >> (LOBYTE(v1->uTargetGBits) - + LOBYTE(v1->uTargetBBits) - + v1->uTargetRBits - - 8); - v21[v9] = (signed int)(v1->uTargetGMask & *(short *)i) >> (LOBYTE(v1->uTargetBBits) - + LOBYTE(v1->uTargetGBits) - - 8); - v10 = i; - v11 = LOBYTE(v1->uTargetBMask); - i += 2; - v20[v9++] = (*(char *)v10 & v11) << (8 - LOBYTE(v1->uTargetBBits)); + lineRGB[x] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); + lineG[x] = (signed int)(g_mask & *line_picture_data) >> (num_b_bits + num_g_bits - 8); + lineB[x] = (b_mask & *line_picture_data) << (8 - num_b_bits); + line_picture_data += 2; } - while ( v9 < var38 ); } - for ( i = 0; i < v29; i += v34 ) + for ( uint i = 0; i < image_width; i += test_byte ) { - v34 = 1; - v32 = *((char *)ptr + i); - do + pict_byte = lineRGB[i]; + for ( test_byte = 1; test_byte < 0x3F; ++test_byte ) { - v12 = i + v34; - if ( *((char *)ptr + v12) != v32 ) + v12 = i + test_byte; + if ( lineRGB[v12] != pict_byte ) break; - if ( !(v12 % v30) ) + if ( !(v12 % pitch) ) break; - ++v34; - } - while ( v34 < 0x3Fu ); - if ( i + v34 > v29 ) - v34 = 3 * v30 - i; - if ( v34 > 1u || v32 >= 0xC0u ) - { - v31 = v34 | 0xC0; - fwrite(&v31, 1u, 1u, v6); } - fwrite(&v32, 1u, 1u, v6); + if ( i + test_byte > image_width ) + test_byte = 3 * pitch - i; + if ( test_byte > 1 || pict_byte >= 0xC0 ) + { + v31 = test_byte | 0xC0; + fwrite(&v31, 1, 1, pOutFile); + } + fwrite(&pict_byte, 1, 1, pOutFile); } - v8 = (int)((char *)v28 + v24); - v13 = File == (FILE *)1; - File = (FILE *)((char *)File - 1); - v28 = (char *)v28 + v24; - if ( v13 ) - break; - v7 = v30; + v8 += v5; } } - if ( v1->pRenderD3D ) - { + if ( this->pRenderD3D ) ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); - } else - { pRenderer->EndScene(); - } - - free(ptr); - fclose(v6); + + free(lineRGB); + fclose(pOutFile); } } } @@ -2595,7 +2561,7 @@ int pitch; // [sp+ACh] [bp-Ch]@1 char v43; // [sp+B3h] [bp-5h]@18 int i; // [sp+B4h] [bp-4h]@6 - unsigned short* line_pictute_data; + unsigned short* line_picture_data; byte test_byte; unsigned char pict_byte; @@ -2670,17 +2636,17 @@ v24 = (int)picture_data; for ( v25 = heidth; v25; v25-- ) { - line_pictute_data = v11; + line_picture_data = v11; if ( wight > 0 ) { lineG = (char *)lineRGB + pitch; lineB = (char *)lineRGB + 2 * pitch; for ( uint i = 0; i < wight; 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 += 1; + lineRGB[i] = (signed int)(r_mask & *line_picture_data) >> (num_g_bits + num_b_bits + num_r_bits - 8); + lineG[i] = (signed int)(g_mask & *line_picture_data) >> ( num_b_bits + num_g_bits- 8); + lineB[i] = (b_mask & *line_picture_data) << (8 - num_b_bits); + line_picture_data += 1; } } for ( i = 0; i < v26; v9 = (char *)v9 + 1 ) @@ -3777,7 +3743,6 @@ //----- (004A0EB6) -------------------------------------------------------- void Render::ParseTargetPixelFormat() { - Render *v1; // eax@1 signed int v2; // ecx@1 DWORD uRedMask; // edx@1 unsigned int uGreenMask; // esi@5 @@ -3786,58 +3751,57 @@ signed int v7; // ecx@9 //unsigned int v8; // ecx@13 - v1 = this; v2 = 0; - uRedMask = v1->ddpfPrimarySuface.dwRBitMask; - v1->uTargetBBits = 0; - v1->uTargetGBits = 0; - v1->uTargetRBits = 0; + uRedMask = this->ddpfPrimarySuface.dwRBitMask; + this->uTargetBBits = 0; + this->uTargetGBits = 0; + this->uTargetRBits = 0; do { if ( (1 << v2) & uRedMask ) - ++v1->uTargetRBits; + ++this->uTargetRBits; ++v2; } while ( v2 < 32 ); - uGreenMask = v1->ddpfPrimarySuface.dwGBitMask; + uGreenMask = this->ddpfPrimarySuface.dwGBitMask; v5 = 0; do { if ( (1 << v5) & uGreenMask ) - ++v1->uTargetGBits; + ++this->uTargetGBits; ++v5; } while ( v5 < 32 ); - uBlueMask = v1->ddpfPrimarySuface.dwBBitMask; + uBlueMask = this->ddpfPrimarySuface.dwBBitMask; v7 = 0; do { if ( (1 << v7) & uBlueMask ) - ++v1->uTargetBBits; + ++this->uTargetBBits; ++v7; } while ( v7 < 32 ); - v1->uTargetGMask = uGreenMask; - v1->uTargetRMask = v1->ddpfPrimarySuface.dwRBitMask; - v1->uTargetBMask = uBlueMask; + this->uTargetGMask = uGreenMask; + this->uTargetRMask = this->ddpfPrimarySuface.dwRBitMask; + this->uTargetBMask = uBlueMask; } //----- (004A0F40) -------------------------------------------------------- bool Render::LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags) { - IDirectDrawSurface4 *v4; // esi@1 + //IDirectDrawSurface4 *v4; // esi@1 HRESULT result; // eax@1 HRESULT v6; // eax@4 int v7; // [sp-8h] [bp-14h]@10 unsigned int v8; // [sp-4h] [bp-10h]@10 char v9; // [sp+Bh] [bp-1h]@1 - v4 = pSurface; + //v4 = pSurface; v9 = 1; result = pSurface->Lock(0, pDesc, uLockFlags, 0); if ( result == DDERR_SURFACELOST ) { - v6 = v4->Restore(); + v6 = pSurface->Restore(); if ( v6 ) { if ( v6 != DDERR_IMPLICITLYCREATED ) @@ -3848,9 +3812,9 @@ goto LABEL_21; } pRenderer->pFrontBuffer4->Restore(); - v4->Restore(); - } - result = v4->Lock(0, pDesc, DDLOCK_WAIT, 0); + pSurface->Restore(); + } + result = pSurface->Lock(0, pDesc, DDLOCK_WAIT, 0); if ( result == DDERR_INVALIDRECT || result == DDERR_SURFACEBUSY ) goto LABEL_20; ErrD3D(result); @@ -4191,17 +4155,15 @@ //----- (004A1605) -------------------------------------------------------- void Render::LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow) { - Render *v3; // esi@1 signed int v4; // eax@3 - v3 = this; if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) { DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - LockSurface_DDraw4(v3->pBackBuffer4, &pDesc, DDLOCK_WAIT); + LockSurface_DDraw4(this->pBackBuffer4, &pDesc, DDLOCK_WAIT); *pOutSurfacePtr = pDesc.lpSurface; v4 = pDesc.lPitch; } @@ -4210,7 +4172,7 @@ DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc.lPitch, 0, 0x6Cu); pDesc.lPitch = 108; - LockSurface_DDraw2(v3->pBackBuffer2, &pDesc, 1u); + LockSurface_DDraw2(this->pBackBuffer2, &pDesc, 1); *pOutSurfacePtr = (void *)pDesc.lpSurface; v4 = pDesc.dwReserved; } @@ -4230,16 +4192,14 @@ //----- (004A172E) -------------------------------------------------------- void Render::LockFrontBuffer(void **pOutSurface, unsigned int *pOutPixelsPerRow) { - Render *v3; // esi@1 signed int v4; // eax@3 - v3 = this; if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) { DDSURFACEDESC2 pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; - LockSurface_DDraw4(v3->pFrontBuffer4, &pDesc, DDLOCK_WAIT); + LockSurface_DDraw4(this->pFrontBuffer4, &pDesc, DDLOCK_WAIT); *pOutSurface = pDesc.lpSurface; v4 = pDesc.lPitch; } @@ -4248,7 +4208,7 @@ DDSURFACEDESC pDesc; // [sp+4h] [bp-7Ch]@3 memset(&pDesc.lPitch, 0, 0x6Cu); pDesc.lPitch = 108; - LockSurface_DDraw2(v3->pFrontBuffer2, &pDesc, 1u); + LockSurface_DDraw2(this->pFrontBuffer2, &pDesc, 1); *pOutSurface = (void *)pDesc.lpSurface; v4 = pDesc.dwReserved; } diff -r 651b24553ae9 -r 49de109bbab5 SaveLoad.cpp --- a/SaveLoad.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/SaveLoad.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -695,6 +695,7 @@ int v29; // [sp+9Ch] [bp-8h]@15 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); @@ -724,12 +725,12 @@ if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) { - auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x* interval_x + 8.0) + y * Dst.lPitch; + auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y /*(int)(y * interval_y + 8.0)*/ * Dst.lPitch; *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); } else if (Dst.ddpfPixelFormat.dwRGBBitCount == 16) { - auto p = (unsigned __int16 *)Dst.lpSurface + x + y * Dst.lPitch; + auto p = (unsigned __int16 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y * Dst.lPitch; *v3 = *p; } else __debugbreak(); diff -r 651b24553ae9 -r 49de109bbab5 UI/UIPopup.cpp --- a/UI/UIPopup.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/UI/UIPopup.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -125,6 +125,10 @@ int v85; char *Str; // [sp+270h] [bp-8h]@65 + int r_mask = 0xF800; + int g_mask = 0x7E0; + int b_mask = 0x1F; + if (!inspect_item->uItemID) return; iteminfo_window.Hint = 0; @@ -409,7 +413,7 @@ } pText = pGlobalTXT_LocalizationStrings[651]; //"Hardened" } - LOWORD(inspect_item->uAttributes) = LOWORD(pRenderer->uTargetRMask); + LOWORD(inspect_item->uAttributes) = r_mask; iteminfo_window.DrawText(pFontComic, pFontComic->GetLineWidth(pTmpBuf.data()) + 132, iteminfo_window.uFrameHeight - LOBYTE(pFontComic->uFontHeight), inspect_item->uAttributes, pText, 0, 0, 0); pRenderer->ResetTextureClipRect(); diff -r 651b24553ae9 -r 49de109bbab5 VideoPlayer.cpp --- a/VideoPlayer.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/VideoPlayer.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -207,69 +207,61 @@ //----- (004C0133) -------------------------------------------------------- bool BinkLockBuffer(_BINKBUF *_this) { - _BINKBUF *v1; // esi@1 IDirectDrawSurface *v2; // edi@5 - DWORD v4; // eax@8 - DWORD v5; // eax@8 IDirectDrawSurface4 *v6; // edi@11 - LPVOID v7; // eax@14 - v1 = _this; + //v1 = _this; if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion >= 5u ) { - DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4 + DDSURFACEDESC2 v8; // [sp+Ch] [bp-7Ch]@4 if ( _this->pTargetDDrawSurface ) { - memset(&v8, 0, 0x7Cu); + memset(&v8, 0, 0x7C); v8.dwSize = 124; while ( 1 ) { - v6 = (IDirectDrawSurface4 *)v1->pTargetDDrawSurface; - if ( !v6->Lock(0, &v8, 1u, 0) ) + v6 = (IDirectDrawSurface4 *)_this->pTargetDDrawSurface; + if ( !v6->Lock(0, &v8, 1, 0) ) break; if (uBinkVersion < 0x0003000000000000) - BYTE3(v1->uBinkDDSurfaceType) |= 0x80u; + BYTE3(_this->uBinkDDSurfaceType) |= 0x80u; else - BYTE3(v1->uBinkDDSurfaceType) |= 0x04; + BYTE3(_this->uBinkDDSurfaceType) |= 0x04; if ( v6->Restore() ) return 0; } - v7 = v8.lpSurface; - v1->pDDrawSurfaceData_ = v8.lpSurface; - v1->pDDrawSurfaceData = v7; - v5 = v8.lPitch; - goto LABEL_15; + _this->pDDrawSurfaceData_ = v8.lpSurface; + _this->pDDrawSurfaceData = v8.lpSurface; + _this->uDDrawSurfacePitch = v8.lPitch; + return 1; } } else { - DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4 + DDSURFACEDESC v8; // [sp+Ch] [bp-7Ch]@4 if ( _this->pTargetDDrawSurface ) { memset(&v8.lPitch, 0, 0x6Cu); v8.lPitch = 108; while ( 1 ) { - v2 = v1->pTargetDDrawSurface; - if ( !v2->Lock(0, (LPDDSURFACEDESC)&v8.lPitch, 1u, 0) ) + v2 = _this->pTargetDDrawSurface; + if ( !v2->Lock(0, (LPDDSURFACEDESC)&v8.lPitch, 1, 0) ) break; if (uBinkVersion < 0x0003000000000000) __asm int 3; else - BYTE3(v1->uBinkDDSurfaceType) |= 4u; + BYTE3(_this->uBinkDDSurfaceType) |= 4u; if ( v2->Restore() ) return 0; } - v4 = (DWORD)v8.lpSurface; - v1->pDDrawSurfaceData_ = (void *)v8.lpSurface; - v1->pDDrawSurfaceData = (void *)v4; - v5 = v8.dwReserved; -LABEL_15: - v1->uDDrawSurfacePitch = v5; + _this->pDDrawSurfaceData_ = v8.lpSurface; + _this->pDDrawSurfaceData = v8.lpSurface; + _this->uDDrawSurfacePitch = v8.dwReserved; return 1; } } diff -r 651b24553ae9 -r 49de109bbab5 mm7_4.cpp --- a/mm7_4.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/mm7_4.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -1826,6 +1826,10 @@ //unsigned int _this; // [sp+9Ch] [bp-8h]@10 //LPVOID v26; // [sp+A0h] [bp-4h]@4 + int r_mask = 0xF800; + int g_mask = 0x7E0; + int b_mask = 0x1F; + if ( !pRenderer->uNumSceneBegins ) { if ( pRenderer->using_software_screen_buffer ) @@ -1836,8 +1840,7 @@ { //v26 = Dst.lpSurface; //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; - v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask | - ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16); + v24 = g_mask | b_mask | ((g_mask | b_mask) << 16); //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; //v1 = pRenderer->pTargetSurface; @@ -1898,7 +1901,7 @@ // pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16)); for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) { - if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) + if (pSrc[y * 640 + x] != (g_mask | b_mask)) pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x]; } } diff -r 651b24553ae9 -r 49de109bbab5 mm7_5.cpp --- a/mm7_5.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/mm7_5.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -199,7 +199,7 @@ ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id], v36->field_61); break; case OBJECT_Item: - sub_43B057(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); + ItemDamageFromActor(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); break; } } @@ -241,7 +241,7 @@ DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); break; case OBJECT_Item: - sub_43B057(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); + ItemDamageFromActor(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); break; } } @@ -274,13 +274,12 @@ } //----- (0043B057) -------------------------------------------------------- -void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) +void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) { int v6; // eax@4 - int v7; // edi@4 + int damage; // edi@4 int a2a; // [sp+Ch] [bp-4h]@8 - __debugbreak();//Ritor1 if ( !pActors[uActorID].IsNotAlive() ) { if ( PID_TYPE(uObjID) == OBJECT_Item) @@ -288,16 +287,16 @@ if ( pSpriteObjects[PID_ID(uObjID)].spell_id ) { v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); - v7 = stru_50C198.CalcMagicalDamageToActor(&pActors[uActorID], 0, v6); - pActors[uActorID].sCurrentHP -= v7; - if ( v7 ) + damage = stru_50C198.CalcMagicalDamageToActor(&pActors[uActorID], 0, v6); + pActors[uActorID].sCurrentHP -= damage; + if ( damage ) { if ( pActors[uActorID].sCurrentHP > 0 ) Actor::AI_Stun(uActorID, uObjID, 0); else Actor::Die(uActorID); - a2a = 20 * v7 / (signed int)pActors[uActorID].pMonsterInfo.uHP; - if ( 20 * v7 / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10 ) + a2a = 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP; + if ( 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10 ) a2a = 10; if ( !MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { @@ -308,7 +307,7 @@ pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); } - Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, v7); + Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, damage); } else Actor::AI_Stun(uActorID, uObjID, 0); diff -r 651b24553ae9 -r 49de109bbab5 mm7_data.cpp --- a/mm7_data.cpp Sat Dec 28 16:49:21 2013 +0600 +++ b/mm7_data.cpp Sun Dec 29 01:26:15 2013 +0600 @@ -809,7 +809,7 @@ int dword_4EED78; // weak _UNKNOWN unk_4EED80; // weak -int dword_4EFA80; // weak +int ScreenshotFileNumber; // dword_4EFA80 int dword_4EFA84; // weak void *off_4EFDB0; // weak int dword_4F031C[777]; // weak diff -r 651b24553ae9 -r 49de109bbab5 mm7_data.h --- a/mm7_data.h Sat Dec 28 16:49:21 2013 +0600 +++ b/mm7_data.h Sun Dec 29 01:26:15 2013 +0600 @@ -482,7 +482,7 @@ extern std::array word_4EE150; extern int dword_4EED78; // weak extern _UNKNOWN unk_4EED80; // weak -extern int dword_4EFA80; // weak +extern int ScreenshotFileNumber; // dword_4EFA80 extern int dword_4EFA84; // weak extern void *off_4EFDB0; // weak extern int dword_4F031C[]; // weak @@ -1130,7 +1130,7 @@ void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2); // idb double __fastcall sub_43AE12(signed int a1); int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4); -void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity); +void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity); void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, struct Vec3_int_ *pVelocity, signed int a4); void CharacterUI_LoadPaperdollTextures(); int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder);