Mercurial > mm7
comparison mm7_4.cpp @ 2069:259df09dfb50
32bits almost there
author | Nomad |
---|---|
date | Tue, 03 Dec 2013 20:18:17 +0200 |
parents | 72177f3603da |
children | 9f4d5a9d6fd8 |
comparison
equal
deleted
inserted
replaced
2061:b2a434d65344 | 2069:259df09dfb50 |
---|---|
1705 strcat(pTmpBuf2.data(), pText); | 1705 strcat(pTmpBuf2.data(), pText); |
1706 dst = strlen(pTmpBuf2.data()); | 1706 dst = strlen(pTmpBuf2.data()); |
1707 i += 2; | 1707 i += 2; |
1708 break; | 1708 break; |
1709 case 24://название товара в продаже | 1709 case 24://название товара в продаже |
1710 sprintfex(a1, format_4E2D80, TargetColor(255, 255, 155), a3->GetDisplayName()); | 1710 sprintfex(a1, format_4E2D80, Color16(255, 255, 155), a3->GetDisplayName()); |
1711 strcat(pTmpBuf2.data(), a1); | 1711 strcat(pTmpBuf2.data(), a1); |
1712 dst = strlen(pTmpBuf2.data()); | 1712 dst = strlen(pTmpBuf2.data()); |
1713 i += 2; | 1713 i += 2; |
1714 break; | 1714 break; |
1715 case 25: | 1715 case 25: |
2029 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; | 2029 v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; |
2030 v13 = v12 + 6.7553994e15; | 2030 v13 = v12 + 6.7553994e15; |
2031 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ | 2031 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ |
2032 } | 2032 } |
2033 | 2033 |
2034 //----- (004A46E6) -------------------------------------------------------- | 2034 void Present32(unsigned __int32 *src, unsigned int src_pitch, |
2035 int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor) | 2035 unsigned __int32 *dst, unsigned int dst_pitch) |
2036 { | 2036 { |
2037 int v5; // eax@1 | 2037 for (uint y = 0; y < 8; ++y) |
2038 int z; // eax@1 | 2038 memcpy(dst + y * dst_pitch, |
2039 unsigned int v7; // eax@9 | 2039 src + y * src_pitch, src_pitch * sizeof(__int32)); |
2040 unsigned int v8; // ecx@9 | 2040 |
2041 int v9; // eax@9 | 2041 for (uint y = 8; y < 352; ++y) |
2042 unsigned int v10; // eax@10 | |
2043 int *v11; // esi@10 | |
2044 int *v12; // edi@10 | |
2045 int v13; // ecx@10 | |
2046 int v14; // edx@10 | |
2047 unsigned int v15; // eax@22 | |
2048 int *v16; // esi@22 | |
2049 int *v17; // edi@22 | |
2050 int v18; // ecx@22 | |
2051 int v19; // edx@22 | |
2052 unsigned __int16 *pTarget; // [sp+Ch] [bp-8h]@9 | |
2053 int *pTargetZ; // [sp+10h] [bp-4h]@9 | |
2054 unsigned int v22; // [sp+1Ch] [bp+8h]@9 | |
2055 signed int v23; // [sp+20h] [bp+Ch]@1 | |
2056 | |
2057 v5 = a4; | |
2058 v23 = _z >> 16; | |
2059 z = x + v5; | |
2060 if ( z >= (signed int)pViewport->uViewportTL_X | |
2061 && (signed int)x <= (signed int)pViewport->uViewportBR_X | |
2062 && y >= (signed int)pViewport->uViewportTL_Y | |
2063 && y <= (signed int)pViewport->uViewportBR_Y ) | |
2064 { | |
2065 if ( (signed int)x < (signed int)pViewport->uViewportTL_X ) | |
2066 x = pViewport->uViewportTL_X; | |
2067 if ( z > (signed int)pViewport->uViewportBR_X ) | |
2068 z = pViewport->uViewportBR_X; | |
2069 pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch]; | |
2070 v22 = z - x; | |
2071 pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y]; | |
2072 v7 = lightColor >> 3; | |
2073 v8 = lightColor & 0xF0; | |
2074 v9 = v7 & 0x1E0000; | |
2075 if ( pRenderer->uTargetGBits == 5 ) | |
2076 { | |
2077 v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4; | |
2078 v11 = (int *)pTarget; | |
2079 v12 = pTargetZ; | |
2080 v13 = v22; | |
2081 v14 = (v10 << 16) | v10; | |
2082 z = (unsigned __int8)pTarget & 2; | |
2083 if ( (unsigned __int8)pTarget & 2 ) | |
2084 { | |
2085 z = (unsigned int)*pTargetZ >> 16; | |
2086 if ( z > v23 ) | |
2087 { | 2042 { |
2088 z = v14 + ((*pTarget & 0x7BDEu) >> 1); | 2043 memcpy(dst + y * dst_pitch, |
2089 *pTarget = z; | 2044 src + y * src_pitch, 8 * sizeof(__int32)); |
2045 memcpy(dst + 8 + game_viewport_width + y * dst_pitch, | |
2046 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32)); | |
2090 } | 2047 } |
2091 v13 = v22 - 1; | 2048 |
2092 v11 = (int *)(pTarget + 1); | 2049 for (uint y = 352; y < 480; ++y) |
2093 v12 = pTargetZ + 1; | 2050 memcpy(dst + y * dst_pitch, |
2094 } | 2051 src + y * src_pitch, src_pitch * sizeof(__int32)); |
2095 while ( v13 != 1 ) | 2052 |
2096 { | 2053 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) |
2097 if ( v13 < 1 ) | |
2098 return z; | |
2099 z = (unsigned int)*v12 >> 16; | |
2100 if ( z <= v23 ) | |
2101 { | 2054 { |
2102 v13 -= 2; | 2055 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) |
2103 ++v11; | 2056 { |
2104 v12 += 2; | 2057 //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) |
2058 if (src[x + y * src_pitch] != 0xFFF8FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) | |
2059 dst[x + y * dst_pitch] = src[x + y * src_pitch]; | |
2060 } | |
2105 } | 2061 } |
2106 else | |
2107 { | |
2108 v12 += 2; | |
2109 z = v14 + ((*v11 & 0x7BDE7BDEu) >> 1); | |
2110 v13 -= 2; | |
2111 *v11 = z; | |
2112 ++v11; | |
2113 } | |
2114 } | |
2115 z = (unsigned int)*v12 >> 16; | |
2116 if ( z > v23 ) | |
2117 { | |
2118 z = v14 + ((*(short *)v11 & 0x7BDEu) >> 1); | |
2119 *(short *)v11 = z; | |
2120 } | |
2121 } | |
2122 else | |
2123 { | |
2124 v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4; | |
2125 v16 = (int *)pTarget; | |
2126 v17 = pTargetZ; | |
2127 v18 = v22; | |
2128 v19 = (v15 << 16) | v15; | |
2129 z = (unsigned __int8)pTarget & 2; | |
2130 if ( (unsigned __int8)pTarget & 2 ) | |
2131 { | |
2132 z = (unsigned int)*pTargetZ >> 16; | |
2133 if ( z > v23 ) | |
2134 { | |
2135 z = v19 + ((*pTarget & 0xF7DEu) >> 1); | |
2136 *pTarget = z; | |
2137 } | |
2138 v18 = v22 - 1; | |
2139 v16 = (int *)(pTarget + 1); | |
2140 v17 = pTargetZ + 1; | |
2141 } | |
2142 while ( v18 != 1 ) | |
2143 { | |
2144 if ( v18 < 1 ) | |
2145 return z; | |
2146 z = (unsigned int)*v17 >> 16; | |
2147 if ( z <= v23 ) | |
2148 { | |
2149 v18 -= 2; | |
2150 ++v16; | |
2151 v17 += 2; | |
2152 } | |
2153 else | |
2154 { | |
2155 v17 += 2; | |
2156 z = v19 + ((*v16 & 0xF7DEF7DEu) >> 1); | |
2157 v18 -= 2; | |
2158 *v16 = z; | |
2159 ++v16; | |
2160 } | |
2161 } | |
2162 z = (unsigned int)*v17 >> 16; | |
2163 if ( z > v23 ) | |
2164 { | |
2165 z = v19 + ((*(short *)v16 & 0xF7DEu) >> 1); | |
2166 *(short *)v16 = z; | |
2167 } | |
2168 } | |
2169 } | |
2170 return z; | |
2171 } | |
2172 | |
2173 //----- (004A57E9) -------------------------------------------------------- | |
2174 void Present_ColorKey() | |
2175 { | |
2176 HRESULT v0; // eax@3 | |
2177 HRESULT v1; // eax@3 | |
2178 HRESULT v2; // eax@3 | |
2179 HRESULT v3; // eax@3 | |
2180 HRESULT v4; // eax@3 | |
2181 RECT a2; // [sp+4h] [bp-14h]@3 | |
2182 //CheckHRESULT_stru0 this; // [sp+14h] [bp-4h]@3 | |
2183 | |
2184 if ( !pRenderer->uNumSceneBegins ) | |
2185 { | |
2186 if ( pRenderer->field_40110 ) | |
2187 { | |
2188 a2.bottom = pViewport->uViewportTL_Y; | |
2189 a2.left = 0; | |
2190 a2.top = 0; | |
2191 a2.right = 640; | |
2192 ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u)); | |
2193 a2.right = 640; | |
2194 a2.left = 0; | |
2195 a2.top = pViewport->uViewportBR_Y + 1; | |
2196 a2.bottom = 480; | |
2197 ErrD3D(pRenderer->pBackBuffer4->BltFast( | |
2198 0, | |
2199 pViewport->uViewportBR_Y + 1, | |
2200 pRenderer->pColorKeySurface4, | |
2201 &a2, | |
2202 16u)); | |
2203 a2.right = pViewport->uViewportTL_X; | |
2204 a2.bottom = pViewport->uViewportBR_Y + 1; | |
2205 a2.left = 0; | |
2206 a2.top = pViewport->uViewportTL_Y; | |
2207 ErrD3D(pRenderer->pBackBuffer4->BltFast( | |
2208 0, | |
2209 pViewport->uViewportTL_Y, | |
2210 pRenderer->pColorKeySurface4, | |
2211 &a2, | |
2212 16u)); | |
2213 a2.left = pViewport->uViewportBR_X; | |
2214 a2.top = pViewport->uViewportTL_Y; | |
2215 a2.right = 640; | |
2216 a2.bottom = pViewport->uViewportBR_Y + 1; | |
2217 ErrD3D(pRenderer->pBackBuffer4->BltFast( | |
2218 pViewport->uViewportBR_X, | |
2219 pViewport->uViewportTL_Y, | |
2220 pRenderer->pColorKeySurface4, | |
2221 &a2, | |
2222 16u)); | |
2223 a2.right = pViewport->uViewportBR_X; | |
2224 a2.bottom = pViewport->uViewportBR_Y + 1; | |
2225 a2.left = pViewport->uViewportTL_X; | |
2226 a2.top = pViewport->uViewportTL_Y; | |
2227 ErrD3D(pRenderer->pBackBuffer4->BltFast( | |
2228 pViewport->uViewportTL_X, | |
2229 pViewport->uViewportTL_Y, | |
2230 pRenderer->pColorKeySurface4, | |
2231 &a2, | |
2232 17u)); | |
2233 } | |
2234 } | |
2235 } | 2062 } |
2236 | 2063 |
2237 //----- (004A597D) -------------------------------------------------------- | 2064 //----- (004A597D) -------------------------------------------------------- |
2238 void Present_NoColorKey() | 2065 void Present_NoColorKey() |
2239 { | 2066 { |
2254 int v15; // eax@13 | 2081 int v15; // eax@13 |
2255 int v16; // eax@14 | 2082 int v16; // eax@14 |
2256 int v17; // eax@16 | 2083 int v17; // eax@16 |
2257 HRESULT v18; // eax@22 | 2084 HRESULT v18; // eax@22 |
2258 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 | 2085 DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3 |
2259 int v20; // [sp+88h] [bp-1Ch]@10 | 2086 //int v20; // [sp+88h] [bp-1Ch]@10 |
2260 int v21; // [sp+8Ch] [bp-18h]@10 | 2087 int v21; // [sp+8Ch] [bp-18h]@10 |
2261 __int32 v22; // [sp+90h] [bp-14h]@10 | 2088 __int32 v22; // [sp+90h] [bp-14h]@10 |
2262 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 | 2089 //unsigned __int32 v23; // [sp+94h] [bp-10h]@10 |
2263 unsigned int v24; // [sp+98h] [bp-Ch]@4 | 2090 unsigned int v24; // [sp+98h] [bp-Ch]@4 |
2264 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 | 2091 //unsigned int _this; // [sp+9Ch] [bp-8h]@10 |
2265 //LPVOID v26; // [sp+A0h] [bp-4h]@4 | 2092 //LPVOID v26; // [sp+A0h] [bp-4h]@4 |
2266 | 2093 |
2267 if ( !pRenderer->uNumSceneBegins ) | 2094 if ( !pRenderer->uNumSceneBegins ) |
2268 { | 2095 { |
2269 if ( pRenderer->field_40110 ) | 2096 if ( pRenderer->using_software_screen_buffer ) |
2270 { | 2097 { |
2271 memset(&Dst, 0, 0x7Cu); | 2098 memset(&Dst, 0, 0x7Cu); |
2272 Dst.dwSize = 124; | 2099 Dst.dwSize = 124; |
2273 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) | 2100 if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) |
2274 { | 2101 { |
2275 //v26 = Dst.lpSurface; | 2102 //v26 = Dst.lpSurface; |
2276 pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; | 2103 //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface; |
2277 v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask | | 2104 v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask | |
2278 ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16); | 2105 ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16); |
2279 pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; | 2106 //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface; |
2280 pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; | 2107 //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch; |
2281 v1 = pRenderer->pTargetSurface; | 2108 //v1 = pRenderer->pTargetSurface; |
2282 v2 = Dst.lpSurface; | 2109 v2 = Dst.lpSurface; |
2283 | 2110 |
2284 | 2111 |
2285 /*for (uint y = 0; y < 480; ++y) | 2112 /*for (uint y = 0; y < 480; ++y) |
2286 { | 2113 { |
2287 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); | 2114 auto pDst = (unsigned short *)((char *)Dst.lpSurface + y * Dst.lPitch); |
2288 for (uint x = 0; x < 640; ++x) | 2115 for (uint x = 0; x < 640; ++x) |
2289 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; | 2116 pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask; |
2290 }*/ | 2117 }*/ |
2291 | 2118 |
2292 ushort* pSrc = pRenderer->pTargetSurface; | 2119 if (!FORCE_16_BITS) |
2120 Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4); | |
2121 else | |
2122 { | |
2123 ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface; | |
2293 short* pDst = (__int16 *)Dst.lpSurface; | 2124 short* pDst = (__int16 *)Dst.lpSurface; |
2294 | 2125 |
2295 for (uint y = 0; y < 8; ++y) | 2126 for (uint y = 0; y < 8; ++y) |
2296 memcpy(pDst + y * Dst.lPitch / 2, | 2127 memcpy(pDst + y * Dst.lPitch / 2, |
2297 | 2128 |
2321 | 2152 |
2322 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; | 2153 //auto uNumLines = pViewport->uViewportW - pViewport->uViewportY + 1; |
2323 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); | 2154 //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1); |
2324 v10 = (int)pSrc_x1y1; | 2155 v10 = (int)pSrc_x1y1; |
2325 v11 = (int)pDst_x1y1; | 2156 v11 = (int)pDst_x1y1; |
2326 int uHalfWidth = v20 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; | 2157 int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2; |
2327 v13 = v24; | 2158 v13 = v24; |
2328 | 2159 |
2329 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) | 2160 for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y) |
2330 { | 2161 { |
2331 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, | 2162 //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2, |
2333 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) | 2164 for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) |
2334 { | 2165 { |
2335 if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) | 2166 if (pSrc[y * 640 + x] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) |
2336 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x]; | 2167 pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x]; |
2337 } | 2168 } |
2169 } | |
2338 } | 2170 } |
2339 | 2171 |
2340 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); | 2172 ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); |
2341 | 2173 |
2342 /* while ( 1 ) | 2174 /* while ( 1 ) |
2539 a1.uFrameWidth -= 12; | 2371 a1.uFrameWidth -= 12; |
2540 a1.uFrameHeight -= 12; | 2372 a1.uFrameHeight -= 12; |
2541 v7 = pSpellStats->pInfos[v1].pName; | 2373 v7 = pSpellStats->pInfos[v1].pName; |
2542 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; | 2374 a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; |
2543 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; | 2375 a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; |
2544 v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu); | 2376 v8 = Color16(0xFFu, 0xFFu, 0x9Bu); |
2545 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u); | 2377 a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u); |
2546 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0); | 2378 a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0); |
2547 a1.uFrameZ = a1.uFrameX + 107; | 2379 a1.uFrameZ = a1.uFrameX + 107; |
2548 a1.uFrameWidth = 108; | 2380 a1.uFrameWidth = 108; |
2549 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v11 / 4 + 12], 3u); | 2381 a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v11 / 4 + 12], 3u); |