diff mm7_4.cpp @ 2069:259df09dfb50

32bits almost there
author Nomad
date Tue, 03 Dec 2013 20:18:17 +0200
parents 72177f3603da
children 9f4d5a9d6fd8
line wrap: on
line diff
--- a/mm7_4.cpp	Mon Dec 02 15:13:49 2013 +0200
+++ b/mm7_4.cpp	Tue Dec 03 20:18:17 2013 +0200
@@ -1707,7 +1707,7 @@
           i += 2;
           break;
         case 24://название товара в продаже
-          sprintfex(a1, format_4E2D80, TargetColor(255, 255, 155), a3->GetDisplayName());
+          sprintfex(a1, format_4E2D80, Color16(255, 255, 155), a3->GetDisplayName());
           strcat(pTmpBuf2.data(), a1);
           dst = strlen(pTmpBuf2.data());
           i += 2;
@@ -2031,207 +2031,34 @@
   return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/
 }
 
-//----- (004A46E6) --------------------------------------------------------
-int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
+void Present32(unsigned __int32 *src, unsigned int src_pitch,
+               unsigned __int32 *dst, unsigned int dst_pitch)
 {
-  int v5; // eax@1
-  int z; // eax@1
-  unsigned int v7; // eax@9
-  unsigned int v8; // ecx@9
-  int v9; // eax@9
-  unsigned int v10; // eax@10
-  int *v11; // esi@10
-  int *v12; // edi@10
-  int v13; // ecx@10
-  int v14; // edx@10
-  unsigned int v15; // eax@22
-  int *v16; // esi@22
-  int *v17; // edi@22
-  int v18; // ecx@22
-  int v19; // edx@22
-  unsigned __int16 *pTarget; // [sp+Ch] [bp-8h]@9
-  int *pTargetZ; // [sp+10h] [bp-4h]@9
-  unsigned int v22; // [sp+1Ch] [bp+8h]@9
-  signed int v23; // [sp+20h] [bp+Ch]@1
+        for (uint y = 0; y < 8; ++y)
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, src_pitch * sizeof(__int32));
 
-  v5 = a4;
-  v23 = _z >> 16;
-  z = x + v5;
-  if ( z >= (signed int)pViewport->uViewportTL_X
-    && (signed int)x <= (signed int)pViewport->uViewportBR_X
-    && y >= (signed int)pViewport->uViewportTL_Y
-    && y <= (signed int)pViewport->uViewportBR_Y )
-  {
-    if ( (signed int)x < (signed int)pViewport->uViewportTL_X )
-      x = pViewport->uViewportTL_X;
-    if ( z > (signed int)pViewport->uViewportBR_X )
-      z = pViewport->uViewportBR_X;
-    pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
-    v22 = z - x;
-    pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
-    v7 = lightColor >> 3;
-    v8 = lightColor & 0xF0;
-    v9 = v7 & 0x1E0000;
-    if ( pRenderer->uTargetGBits == 5 )
-    {
-      v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
-      v11 = (int *)pTarget;
-      v12 = pTargetZ;
-      v13 = v22;
-      v14 = (v10 << 16) | v10;
-      z = (unsigned __int8)pTarget & 2;
-      if ( (unsigned __int8)pTarget & 2 )
-      {
-        z = (unsigned int)*pTargetZ >> 16;
-        if ( z > v23 )
-        {
-          z = v14 + ((*pTarget & 0x7BDEu) >> 1);
-          *pTarget = z;
-        }
-        v13 = v22 - 1;
-        v11 = (int *)(pTarget + 1);
-        v12 = pTargetZ + 1;
-      }
-      while ( v13 != 1 )
-      {
-        if ( v13 < 1 )
-          return z;
-        z = (unsigned int)*v12 >> 16;
-        if ( z <= v23 )
-        {
-          v13 -= 2;
-          ++v11;
-          v12 += 2;
-        }
-        else
-        {
-          v12 += 2;
-          z = v14 + ((*v11 & 0x7BDE7BDEu) >> 1);
-          v13 -= 2;
-          *v11 = z;
-          ++v11;
-        }
-      }
-      z = (unsigned int)*v12 >> 16;
-      if ( z > v23 )
-      {
-        z = v14 + ((*(short *)v11 & 0x7BDEu) >> 1);
-        *(short *)v11 = z;
-      }
-    }
-    else
-    {
-      v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
-      v16 = (int *)pTarget;
-      v17 = pTargetZ;
-      v18 = v22;
-      v19 = (v15 << 16) | v15;
-      z = (unsigned __int8)pTarget & 2;
-      if ( (unsigned __int8)pTarget & 2 )
-      {
-        z = (unsigned int)*pTargetZ >> 16;
-        if ( z > v23 )
+        for (uint y = 8; y < 352; ++y)
         {
-          z = v19 + ((*pTarget & 0xF7DEu) >> 1);
-          *pTarget = z;
-        }
-        v18 = v22 - 1;
-        v16 = (int *)(pTarget + 1);
-        v17 = pTargetZ + 1;
-      }
-      while ( v18 != 1 )
-      {
-        if ( v18 < 1 )
-          return z;
-        z = (unsigned int)*v17 >> 16;
-        if ( z <= v23 )
-        {
-          v18 -= 2;
-          ++v16;
-          v17 += 2;
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, 8 * sizeof(__int32));
+          memcpy(dst + 8 + game_viewport_width + y * dst_pitch,
+                 src + 8 + game_viewport_width + y * src_pitch, 174/*172*/ * sizeof(__int32));
         }
-        else
-        {
-          v17 += 2;
-          z = v19 + ((*v16 & 0xF7DEF7DEu) >> 1);
-          v18 -= 2;
-          *v16 = z;
-          ++v16;
-        }
-      }
-      z = (unsigned int)*v17 >> 16;
-      if ( z > v23 )
-      {
-        z = v19 + ((*(short *)v16 & 0xF7DEu) >> 1);
-        *(short *)v16 = z;
-      }
-    }
-  }
-  return z;
-}
 
-//----- (004A57E9) --------------------------------------------------------
-void  Present_ColorKey()
-{
-  HRESULT v0; // eax@3
-  HRESULT v1; // eax@3
-  HRESULT v2; // eax@3
-  HRESULT v3; // eax@3
-  HRESULT v4; // eax@3
-  RECT a2; // [sp+4h] [bp-14h]@3
-  //CheckHRESULT_stru0 this; // [sp+14h] [bp-4h]@3
+        for (uint y = 352; y < 480; ++y)
+          memcpy(dst + y * dst_pitch,
+                 src + y * src_pitch, src_pitch * sizeof(__int32));
 
-  if ( !pRenderer->uNumSceneBegins )
-  {
-    if ( pRenderer->field_40110 )
-    {
-      a2.bottom = pViewport->uViewportTL_Y;
-      a2.left = 0;
-      a2.top = 0;
-      a2.right = 640;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(0, 0, pRenderer->pColorKeySurface4, &a2, 16u));
-      a2.right = 640;
-      a2.left = 0;
-      a2.top = pViewport->uViewportBR_Y + 1;
-      a2.bottom = 480;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             0,
-             pViewport->uViewportBR_Y + 1,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             16u));
-      a2.right = pViewport->uViewportTL_X;
-      a2.bottom = pViewport->uViewportBR_Y + 1;
-      a2.left = 0;
-      a2.top = pViewport->uViewportTL_Y;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             0,
-             pViewport->uViewportTL_Y,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             16u));
-      a2.left = pViewport->uViewportBR_X;
-      a2.top = pViewport->uViewportTL_Y;
-      a2.right = 640;
-      a2.bottom = pViewport->uViewportBR_Y + 1;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             pViewport->uViewportBR_X,
-             pViewport->uViewportTL_Y,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             16u));
-      a2.right = pViewport->uViewportBR_X;
-      a2.bottom = pViewport->uViewportBR_Y + 1;
-      a2.left = pViewport->uViewportTL_X;
-      a2.top = pViewport->uViewportTL_Y;
-      ErrD3D(pRenderer->pBackBuffer4->BltFast(
-             pViewport->uViewportTL_X,
-             pViewport->uViewportTL_Y,
-             pRenderer->pColorKeySurface4,
-             &a2,
-             17u));
-    }
-  }
+        for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
+        {
+          for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x)
+          {
+            //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask))
+            if (src[x + y * src_pitch] != 0xFFF8FCF8)  // FFF8FCF8 =  Color32(Color16(g_mask | b_mask))
+              dst[x + y * dst_pitch] = src[x + y * src_pitch];
+          }
+        }
 }
 
 //----- (004A597D) --------------------------------------------------------
@@ -2256,7 +2083,7 @@
   int v17; // eax@16
   HRESULT v18; // eax@22
   DDSURFACEDESC2 Dst; // [sp+Ch] [bp-98h]@3
-  int v20; // [sp+88h] [bp-1Ch]@10
+  //int v20; // [sp+88h] [bp-1Ch]@10
   int v21; // [sp+8Ch] [bp-18h]@10
   __int32 v22; // [sp+90h] [bp-14h]@10
   //unsigned __int32 v23; // [sp+94h] [bp-10h]@10
@@ -2266,19 +2093,19 @@
 
   if ( !pRenderer->uNumSceneBegins )
   {
-    if ( pRenderer->field_40110 )
+    if ( pRenderer->using_software_screen_buffer )
     {
       memset(&Dst, 0, 0x7Cu);
       Dst.dwSize = 124;
       if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) )
       {
         //v26 = Dst.lpSurface;
-        pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
+        //pRenderer->pCurrentlyLockedSurfaceDataPtr = (unsigned __int16 *)Dst.lpSurface;
         v24 = pRenderer->uTargetGMask | pRenderer->uTargetBMask |
               ((pRenderer->uTargetGMask | pRenderer->uTargetBMask) << 16);
-        pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
-        pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
-        v1 = pRenderer->pTargetSurface;
+        //pRenderer->pCurrentlyLockedSoftSurface = pRenderer->pTargetSurface;
+        //pRenderer->uCurrentlyLockedSurfacePitch = Dst.lPitch;
+        //v1 = pRenderer->pTargetSurface;
         v2 = Dst.lpSurface;
 
 
@@ -2288,8 +2115,12 @@
           for (uint x = 0; x < 640; ++x)
             pDst[x] = pRenderer->uTargetRMask | pRenderer->uTargetBMask;
         }*/
-        
-        ushort* pSrc = pRenderer->pTargetSurface;
+
+        if (!FORCE_16_BITS)
+          Present32((unsigned __int32 *)pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, (unsigned __int32 *)Dst.lpSurface, Dst.lPitch / 4);
+        else
+        {        
+        ushort* pSrc = (unsigned short *)pRenderer->pTargetSurface;
         short* pDst = (__int16 *)Dst.lpSurface;
 
         for (uint y = 0; y < 8; ++y)
@@ -2323,7 +2154,7 @@
         //v26 = (LPVOID)(pViewport->uViewportW - pViewport->uViewportY + 1);
         v10 = (int)pSrc_x1y1;
         v11 = (int)pDst_x1y1;
-        int uHalfWidth = v20 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
+        int uHalfWidth = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;
         v13 = v24;
 
         for (uint y = pViewport->uViewportTL_Y; y < pViewport->uViewportBR_Y + 1; ++y)
@@ -2336,6 +2167,7 @@
               pDst[y * Dst.lPitch / 2 + x] = pSrc[y * 640 + x];
           }
         }
+        }
 
               ErrD3D(pRenderer->pBackBuffer4->Unlock(0));
 
@@ -2541,7 +2373,7 @@
   v7 = pSpellStats->pInfos[v1].pName;
   a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
-  v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+  v8 = Color16(0xFFu, 0xFFu, 0x9Bu);
   a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
   a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0);
   a1.uFrameZ = a1.uFrameX + 107;