Mercurial > mm7
comparison Render.cpp @ 1583:75fafd8ced59
Allocator (CMemory) bye-bye
author | Nomad |
---|---|
date | Tue, 10 Sep 2013 21:07:07 +0200 |
parents | 2d9c8f609a3c |
children | cff02d7d3460 |
comparison
equal
deleted
inserted
replaced
1577:1b6217e07b26 | 1583:75fafd8ced59 |
---|---|
24 #include "Game.h" | 24 #include "Game.h" |
25 #include "LightmapBuilder.h" | 25 #include "LightmapBuilder.h" |
26 #include "ObjectList.h" | 26 #include "ObjectList.h" |
27 #include "SpriteObject.h" | 27 #include "SpriteObject.h" |
28 #include "DecorationList.h" | 28 #include "DecorationList.h" |
29 #include "Allocator.h" | |
30 #include "OSInfo.h" | 29 #include "OSInfo.h" |
31 #include "Actor.h" | 30 #include "Actor.h" |
32 #include "Log.h" | 31 #include "Log.h" |
33 #include "TileFrameTable.h" | 32 #include "TileFrameTable.h" |
34 #include "texts.h" | 33 #include "texts.h" |
2016 Render::~Render() | 2015 Render::~Render() |
2017 { | 2016 { |
2018 Render *v1; // esi@1 | 2017 Render *v1; // esi@1 |
2019 | 2018 |
2020 v1 = this; | 2019 v1 = this; |
2021 pAllocator->FreeChunk(this->pDefaultZBuffer); | 2020 free(this->pDefaultZBuffer); |
2022 v1->pD3DBitmaps.Release(); | 2021 v1->pD3DBitmaps.Release(); |
2023 v1->pD3DSprites.Release(); | 2022 v1->pD3DSprites.Release(); |
2024 Release(); | 2023 Release(); |
2025 v1->bWindowMode = 1; | 2024 v1->bWindowMode = 1; |
2026 //nullsub_1(); | 2025 //nullsub_1(); |
2316 fwrite(&header2, 1u, 1u, v6); | 2315 fwrite(&header2, 1u, 1u, v6); |
2317 fwrite(&header2.planes, 1u, 1u, v6); | 2316 fwrite(&header2.planes, 1u, 1u, v6); |
2318 fwrite(&header2.pitch, 2u, 1u, v6); | 2317 fwrite(&header2.pitch, 2u, 1u, v6); |
2319 fwrite(&header2.palette_info, 2u, 1u, v6); | 2318 fwrite(&header2.palette_info, 2u, 1u, v6); |
2320 fwrite(v15, 0x3Au, 1u, v6); | 2319 fwrite(v15, 0x3Au, 1u, v6); |
2321 ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); | 2320 ptr = malloc(3 * var38 + 6); |
2322 if ( v29 > 0 ) | 2321 if ( v29 > 0 ) |
2323 { | 2322 { |
2324 v7 = v30; | 2323 v7 = v30; |
2325 File = (FILE *)v29; | 2324 File = (FILE *)v29; |
2326 v29 = 3 * v30; | 2325 v29 = 3 * v30; |
2389 else | 2388 else |
2390 { | 2389 { |
2391 pRenderer->EndScene(); | 2390 pRenderer->EndScene(); |
2392 } | 2391 } |
2393 | 2392 |
2394 pAllocator->FreeChunk(ptr); | 2393 free(ptr); |
2395 fclose(v6); | 2394 fclose(v6); |
2396 } | 2395 } |
2397 } | 2396 } |
2398 } | 2397 } |
2399 // 4EFA80: using guessed type int dword_4EFA80; | 2398 // 4EFA80: using guessed type int dword_4EFA80; |
2513 fwrite(&v37, 1u, 1u, v7); | 2512 fwrite(&v37, 1u, 1u, v7); |
2514 fwrite(&v38, 1u, 1u, v7); | 2513 fwrite(&v38, 1u, 1u, v7); |
2515 fwrite(&v39, 2u, 1u, v7); | 2514 fwrite(&v39, 2u, 1u, v7); |
2516 fwrite(&v40, 2u, 1u, v7); | 2515 fwrite(&v40, 2u, 1u, v7); |
2517 fwrite(&v16, 0x3Au, 1u, v7); | 2516 fwrite(&v16, 0x3Au, 1u, v7); |
2518 ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); | 2517 ptr = malloc(3 * v25 + 6); |
2519 if ( (signed int)a1 > 0 ) | 2518 if ( (signed int)a1 > 0 ) |
2520 { | 2519 { |
2521 v8 = v43; | 2520 v8 = v43; |
2522 File = (FILE *)a1; | 2521 File = (FILE *)a1; |
2523 v24 = 3 * v43; | 2522 v24 = 3 * v43; |
2585 } | 2584 } |
2586 else | 2585 else |
2587 { | 2586 { |
2588 pRenderer->EndScene(); | 2587 pRenderer->EndScene(); |
2589 } | 2588 } |
2590 pAllocator->FreeChunk(ptr); | 2589 free(ptr); |
2591 fclose(v7); | 2590 fclose(v7); |
2592 } | 2591 } |
2593 } | 2592 } |
2594 } | 2593 } |
2595 // 4EFA84: using guessed type int dword_4EFA84; | 2594 // 4EFA84: using guessed type int dword_4EFA84; |
2680 memcpy(v8, &v27.palette_info, 2u); | 2679 memcpy(v8, &v27.palette_info, 2u); |
2681 v8 = (char *)v8 + 2; | 2680 v8 = (char *)v8 + 2; |
2682 memcpy(v8, &v18, 0x3Au); | 2681 memcpy(v8, &v18, 0x3Au); |
2683 v9 = (char *)v8 + 58; | 2682 v9 = (char *)v8 + 58; |
2684 | 2683 |
2685 lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); | 2684 lineRGB = (char*)malloc(3 * (wight + 2)); |
2686 if ( heidth > 0 ) | 2685 if ( heidth > 0 ) |
2687 { | 2686 { |
2688 v10 = pitch; | 2687 v10 = pitch; |
2689 v25 = heidth; | 2688 v25 = heidth; |
2690 v26 = 3 * pitch; | 2689 v26 = 3 * pitch; |
2741 if ( v16 ) | 2740 if ( v16 ) |
2742 break; | 2741 break; |
2743 v10 = pitch; | 2742 v10 = pitch; |
2744 } | 2743 } |
2745 } | 2744 } |
2746 pAllocator->FreeChunk(lineRGB); | 2745 free(lineRGB); |
2747 *(int *)packed_size = (char *)v9 - data_buff; | 2746 *(int *)packed_size = (char *)v9 - data_buff; |
2748 | 2747 |
2749 } | 2748 } |
2750 | 2749 |
2751 //----- (0049F8B5) -------------------------------------------------------- | 2750 //----- (0049F8B5) -------------------------------------------------------- |
2812 fwrite(&header2, 1u, 1u, v7); | 2811 fwrite(&header2, 1u, 1u, v7); |
2813 fwrite(&header2.planes, 1u, 1u, v7); | 2812 fwrite(&header2.planes, 1u, 1u, v7); |
2814 fwrite(&header2.pitch, 2u, 1u, v7); | 2813 fwrite(&header2.pitch, 2u, 1u, v7); |
2815 fwrite(&header2.palette_info, 2u, 1u, v7); | 2814 fwrite(&header2.palette_info, 2u, 1u, v7); |
2816 fwrite(v14, 0x3Au, 1u, v7); | 2815 fwrite(v14, 0x3Au, 1u, v7); |
2817 ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); | 2816 ptr = malloc(3 * a4 + 6); |
2818 if ( a5 > 0 ) | 2817 if ( a5 > 0 ) |
2819 { | 2818 { |
2820 v8 = v24; | 2819 v8 = v24; |
2821 v18 = a5; | 2820 v18 = a5; |
2822 v20 = 3 * v24; | 2821 v20 = 3 * v24; |
2875 if ( v13 ) | 2874 if ( v13 ) |
2876 break; | 2875 break; |
2877 v8 = v24; | 2876 v8 = v24; |
2878 } | 2877 } |
2879 } | 2878 } |
2880 pAllocator->FreeChunk(ptr); | 2879 free(ptr); |
2881 result = (FILE *)fclose(v7); | 2880 result = (FILE *)fclose(v7); |
2882 } | 2881 } |
2883 return result; | 2882 return result; |
2884 } | 2883 } |
2885 | 2884 |
2980 void Render::CreateZBuffer() | 2979 void Render::CreateZBuffer() |
2981 { | 2980 { |
2982 if (!pDefaultZBuffer) | 2981 if (!pDefaultZBuffer) |
2983 { | 2982 { |
2984 pDefaultZBuffer = pActiveZBuffer = nullptr; | 2983 pDefaultZBuffer = pActiveZBuffer = nullptr; |
2985 pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); | 2984 pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); |
2986 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) | 2985 memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) |
2987 } | 2986 } |
2988 } | 2987 } |
2989 | 2988 |
2990 //----- (0049FE05) -------------------------------------------------------- | 2989 //----- (0049FE05) -------------------------------------------------------- |
3333 { | 3332 { |
3334 pBeforePresentFunction = 0;//nullsub_1; | 3333 pBeforePresentFunction = 0;//nullsub_1; |
3335 } | 3334 } |
3336 bWindowMode = 0; | 3335 bWindowMode = 0; |
3337 pParty->uFlags |= 2u; | 3336 pParty->uFlags |= 2u; |
3338 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; | 3337 LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; __debugbreak(); // replace with actual float |
3339 pViewport->_4C02F8(36044); | 3338 pViewport->_4C02F8(36044); |
3340 return v15 != 0; | 3339 return v15 != 0; |
3341 } | 3340 } |
3342 // 6BE3A0: using guessed type float flt_6BE3A0; | |
3343 | 3341 |
3344 //----- (004A05F3) -------------------------------------------------------- | 3342 //----- (004A05F3) -------------------------------------------------------- |
3345 bool Render::SwitchToWindow(HWND hWnd) | 3343 bool Render::SwitchToWindow(HWND hWnd) |
3346 { | 3344 { |
3347 //Render *v2; // esi@1 | 3345 //Render *v2; // esi@1 |
8492 | 8490 |
8493 | 8491 |
8494 //----- (004524D8) -------------------------------------------------------- | 8492 //----- (004524D8) -------------------------------------------------------- |
8495 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) | 8493 HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) |
8496 { | 8494 { |
8497 int v11; // eax@13 | 8495 //int v11; // eax@13 |
8498 int v12; // ecx@13 | 8496 //int v12; // ecx@13 |
8499 void *v13; // eax@13 | 8497 void *v13; // eax@13 |
8500 unsigned __int8 v14; // zf@13 | 8498 //unsigned __int8 v14; // zf@13 |
8501 unsigned __int8 v15; // sf@13 | 8499 //unsigned __int8 v15; // sf@13 |
8502 int v16; // esi@14 | 8500 int v16; // esi@14 |
8503 int v17; // ecx@16 | 8501 int v17; // ecx@16 |
8504 int v18; // esi@16 | 8502 int v18; // esi@16 |
8505 unsigned __int16 *v19; // eax@16 | 8503 unsigned __int16 *v19; // eax@16 |
8506 int v20; // edx@16 | 8504 int v20; // edx@16 |
8567 delete [] pCompressedData; | 8565 delete [] pCompressedData; |
8568 } | 8566 } |
8569 else | 8567 else |
8570 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); | 8568 fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); |
8571 | 8569 |
8572 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 | 8570 if ( scale_hwls_to_half ) |
8573 { | 8571 { |
8574 v11 = pTex->uHeight / 2; | 8572 pTex->uHeight /= 2; |
8575 v12 = pTex->uWidth / 2; | 8573 pTex->uWidth /= 2; |
8576 pTex->uHeight = v11; | 8574 v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; |
8577 pTex->uWidth = v12; | |
8578 v13 = new unsigned __int16[v12 * v11]; | |
8579 v28 = 0; | 8575 v28 = 0; |
8580 v14 = pTex->uHeight == 0; | |
8581 v15 = (pTex->uHeight & 0x80000000u) != 0; | |
8582 v26 = (unsigned __int16 *)v13; | 8576 v26 = (unsigned __int16 *)v13; |
8583 if ( !(v15 | v14) ) | 8577 if ( pTex->uHeight > 0 ) |
8584 { | 8578 { |
8585 v16 = pTex->uWidth; | 8579 v16 = pTex->uWidth; |
8586 v27 = 1; | 8580 v27 = 1; |
8587 do | 8581 do |
8588 { | 8582 { |
8598 v21 = (int)&v19[2 * (pDestb + v17)]; | 8592 v21 = (int)&v19[2 * (pDestb + v17)]; |
8599 v22 = (int)&v19[2 * v20]; | 8593 v22 = (int)&v19[2 * v20]; |
8600 LOWORD(v20) = *(unsigned short *)(v21 + 2); | 8594 LOWORD(v20) = *(unsigned short *)(v21 + 2); |
8601 LOWORD(v21) = *(unsigned short *)v21; | 8595 LOWORD(v21) = *(unsigned short *)v21; |
8602 v23 = pDestb++ + v18; | 8596 v23 = pDestb++ + v18; |
8603 v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | 8597 extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); |
8598 v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); | |
8604 v16 = pTex->uWidth; | 8599 v16 = pTex->uWidth; |
8605 } | 8600 } |
8606 while (pDestb < pTex->uWidth); | 8601 while (pDestb < pTex->uWidth); |
8607 } | 8602 } |
8608 ++v28; | 8603 ++v28; |
8612 } | 8607 } |
8613 delete [] pTex->pPixels; | 8608 delete [] pTex->pPixels; |
8614 pTex->pPixels = v26; | 8609 pTex->pPixels = v26; |
8615 } | 8610 } |
8616 return pTex; | 8611 return pTex; |
8617 //result = pTex; | |
8618 // } | |
8619 // else | |
8620 // { | |
8621 //LABEL_8: | |
8622 // return nullptr; | |
8623 // } | |
8624 } | 8612 } |
8625 | 8613 |
8626 //----- (0045271F) -------------------------------------------------------- | 8614 //----- (0045271F) -------------------------------------------------------- |
8627 bool RenderHWLContainer::Release() | 8615 bool RenderHWLContainer::Release() |
8628 { | 8616 { |
8666 this->pFile = 0; | 8654 this->pFile = 0; |
8667 uSignature = 0; | 8655 uSignature = 0; |
8668 this->uDataOffset = 0; | 8656 this->uDataOffset = 0; |
8669 memset(&this->uNumItems, 0, 0x61A84u); | 8657 memset(&this->uNumItems, 0, 0x61A84u); |
8670 this->uNumItems = 0; | 8658 this->uNumItems = 0; |
8671 this->field_61A94_scale_hwls_to_half = 0; | 8659 this->scale_hwls_to_half = false; |
8672 } | 8660 } |
8673 | 8661 |
8674 //----- (0045237F) -------------------------------------------------------- | 8662 //----- (0045237F) -------------------------------------------------------- |
8675 bool RenderHWLContainer::Load(const wchar_t *pFilename) | 8663 bool RenderHWLContainer::Load(const wchar_t *pFilename) |
8676 { | 8664 { |