diff Render.cpp @ 1583:75fafd8ced59

Allocator (CMemory) bye-bye
author Nomad
date Tue, 10 Sep 2013 21:07:07 +0200
parents 2d9c8f609a3c
children cff02d7d3460
line wrap: on
line diff
--- a/Render.cpp	Tue Sep 10 18:43:52 2013 +0200
+++ b/Render.cpp	Tue Sep 10 21:07:07 2013 +0200
@@ -26,7 +26,6 @@
 #include "ObjectList.h"
 #include "SpriteObject.h"
 #include "DecorationList.h"
-#include "Allocator.h"
 #include "OSInfo.h"
 #include "Actor.h"
 #include "Log.h"
@@ -2018,7 +2017,7 @@
   Render *v1; // esi@1
 
   v1 = this;
-  pAllocator->FreeChunk(this->pDefaultZBuffer);
+  free(this->pDefaultZBuffer);
   v1->pD3DBitmaps.Release();
   v1->pD3DSprites.Release();
   Release();
@@ -2318,7 +2317,7 @@
       fwrite(&header2.pitch, 2u, 1u, v6);
       fwrite(&header2.palette_info, 2u, 1u, v6);
       fwrite(v15, 0x3Au, 1u, v6);
-      ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0);
+      ptr = malloc(3 * var38 + 6);
       if ( v29 > 0 )
       {
         v7 = v30;
@@ -2391,7 +2390,7 @@
         pRenderer->EndScene();
       }
 
-      pAllocator->FreeChunk(ptr);
+      free(ptr);
       fclose(v6);
     }
   }
@@ -2515,7 +2514,7 @@
       fwrite(&v39, 2u, 1u, v7);
       fwrite(&v40, 2u, 1u, v7);
       fwrite(&v16, 0x3Au, 1u, v7);
-      ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0);
+      ptr = malloc(3 * v25 + 6);
       if ( (signed int)a1 > 0 )
       {
         v8 = v43;
@@ -2587,7 +2586,7 @@
       {
         pRenderer->EndScene();
       }
-      pAllocator->FreeChunk(ptr);
+      free(ptr);
       fclose(v7);
     }
   }
@@ -2682,7 +2681,7 @@
   memcpy(v8, &v18, 0x3Au);
   v9 = (char *)v8 + 58;
 
-  lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0);
+  lineRGB = (char*)malloc(3 * (wight + 2));
   if ( heidth > 0 )
   {
     v10 = pitch;
@@ -2743,7 +2742,7 @@
       v10 = pitch;
     }
   }
-  pAllocator->FreeChunk(lineRGB);
+  free(lineRGB);
   *(int *)packed_size = (char *)v9 - data_buff;
  
 }
@@ -2814,7 +2813,7 @@
     fwrite(&header2.pitch, 2u, 1u, v7);
     fwrite(&header2.palette_info, 2u, 1u, v7);
     fwrite(v14, 0x3Au, 1u, v7);
-    ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0);
+    ptr = malloc(3 * a4 + 6);
     if ( a5 > 0 )
     {
       v8 = v24;
@@ -2877,7 +2876,7 @@
         v8 = v24;
       }
     }
-    pAllocator->FreeChunk(ptr);
+    free(ptr);
     result = (FILE *)fclose(v7);
   }
   return result;
@@ -2982,7 +2981,7 @@
   if (!pDefaultZBuffer)
   {
     pDefaultZBuffer = pActiveZBuffer = nullptr;
-    pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf.");
+    pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000);
     memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); //    // inlined Render::ClearActiveZBuffer  (mm8::004A085B)
   }
 }
@@ -3335,11 +3334,10 @@
   }
   bWindowMode = 0;
   pParty->uFlags |= 2u;
-  LODWORD(flt_6BE3A0) = 0x3F0CCCCDu;
+  LODWORD(flt_6BE3A0) = 0x3F0CCCCDu;  __debugbreak(); // replace with actual float
   pViewport->_4C02F8(36044);
   return v15 != 0;
 }
-// 6BE3A0: using guessed type float flt_6BE3A0;
 
 //----- (004A05F3) --------------------------------------------------------
 bool Render::SwitchToWindow(HWND hWnd)
@@ -8494,11 +8492,11 @@
 //----- (004524D8) --------------------------------------------------------
 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps)
 {
-  int v11; // eax@13
-  int v12; // ecx@13
+  //int v11; // eax@13
+  //int v12; // ecx@13
   void *v13; // eax@13
-  unsigned __int8 v14; // zf@13
-  unsigned __int8 v15; // sf@13
+  //unsigned __int8 v14; // zf@13
+  //unsigned __int8 v15; // sf@13
   int v16; // esi@14
   int v17; // ecx@16
   int v18; // esi@16
@@ -8569,18 +8567,14 @@
     else
       fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile);
 
-    if ( field_61A94_scale_hwls_to_half )     //is it even possible to ever get here? field_61A94_scale_hwls_to_half is only set to zero
-    {
-      v11 = pTex->uHeight / 2;
-      v12 = pTex->uWidth / 2;
-      pTex->uHeight = v11;
-      pTex->uWidth = v12;
-      v13 = new unsigned __int16[v12 * v11];
+    if ( scale_hwls_to_half )
+    {
+      pTex->uHeight /= 2;
+      pTex->uWidth /= 2;
+      v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight];
       v28 = 0;
-      v14 = pTex->uHeight == 0;
-      v15 = (pTex->uHeight & 0x80000000u) != 0;
       v26 = (unsigned __int16 *)v13;
-      if ( !(v15 | v14) )
+      if ( pTex->uHeight > 0 )
       {
         v16 = pTex->uWidth;
         v27 = 1;
@@ -8600,7 +8594,8 @@
               LOWORD(v20) = *(unsigned short *)(v21 + 2);
               LOWORD(v21) = *(unsigned short *)v21;
               v23 = pDestb++ + v18;
-              v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20);
+              extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4);
+              v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20);
               v16 = pTex->uWidth;
             }
             while (pDestb < pTex->uWidth);
@@ -8614,13 +8609,6 @@
       pTex->pPixels = v26;
     }
     return pTex;
-    //result = pTex;
-//  }
-//  else
-//  {
-//LABEL_8:
-//    return nullptr;
-//  }
 }
 
 //----- (0045271F) --------------------------------------------------------
@@ -8668,7 +8656,7 @@
   this->uDataOffset = 0;
   memset(&this->uNumItems, 0, 0x61A84u);
   this->uNumItems = 0;
-  this->field_61A94_scale_hwls_to_half = 0;
+  this->scale_hwls_to_half = false;
 }
 
 //----- (0045237F) --------------------------------------------------------