comparison mm7_2.cpp @ 692:066e2b29b30f

viewport.cpp added
author Gloval
date Sat, 16 Mar 2013 21:57:32 +0400
parents 551f74425b17
children e0a1fccc89b1
comparison
equal deleted inserted replaced
691:c93f29773f84 692:066e2b29b30f
2881 LABEL_43: 2881 LABEL_43:
2882 bGameoverLoop = 0; 2882 bGameoverLoop = 0;
2883 return result; 2883 return result;
2884 } 2884 }
2885 2885
2886
2887 //----- (004C0262) --------------------------------------------------------
2888 void Viewport::SetScreen(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
2889 {
2890 unsigned int x; // edx@1
2891 unsigned int z; // esi@1
2892 unsigned int y; // edi@3
2893 unsigned int w; // eax@3
2894 char no_3d; // zf@5
2895 int v10; // eax@7
2896
2897 x = uX;
2898 z = uZ;
2899 if ( (signed int)uX > (signed int)uZ )
2900 {
2901 z = uZ ^ uX ^ uZ; // swap x and z
2902 x = z ^ uZ ^ uX;
2903 }
2904 y = uY;
2905 w = uW;
2906 if ( (signed int)uY > (signed int)uW )
2907 {
2908 w = uW ^ uY ^ uW; // swap y and w
2909 y = w ^ uW ^ uY;
2910 }
2911 this->uScreenX = x;
2912 this->uScreenY = y;
2913 this->uScreenZ = z;
2914 this->uScreenW = w;
2915 no_3d = pRenderer->pRenderD3D == 0;
2916 this->uScreenWidth = z - x + 1;
2917 this->uScreenCenterX = (signed int)(z + x) >> 1;
2918 if ( no_3d )
2919 {
2920 v10 = w - y + 1;
2921 this->uScreenHeight = v10;
2922 this->uScreenCenterY = this->uScreenW - ((unsigned __int64)(this->field_30 * (signed __int64)v10) >> 16);
2923 }
2924 else
2925 {
2926 this->uScreenHeight = w - y + 1;
2927 this->uScreenCenterY = (signed int)(w + y) >> 1;
2928 }
2929 SetViewport(this->uScreenX, this->uScreenY, this->uScreenZ, this->uScreenW);
2930 }
2931
2932 //----- (004C02F8) --------------------------------------------------------
2933 void Viewport::_4C02F8(int a2)
2934 {
2935 unsigned int v2; // ST0C_4@1
2936
2937 v2 = this->uScreenW;
2938 this->field_30 = a2;
2939 SetScreen(this->uScreenX, this->uScreenY, this->uScreenZ, v2);
2940 }
2941
2942 //----- (004C0312) --------------------------------------------------------
2943 void Viewport::SetViewport(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW)
2944 {
2945 unsigned int x; // ebx@1
2946 unsigned int y; // edi@3
2947 unsigned int z; // edx@5
2948 unsigned int w; // eax@7
2949
2950 x = uX;
2951 if ( (signed int)uX < (signed int)this->uScreenX )
2952 x = this->uScreenX;
2953 y = uY;
2954 if ( (signed int)uY < (signed int)this->uScreenY )
2955 y = this->uScreenY;
2956 z = uZ;
2957 if ( (signed int)uZ > (signed int)this->uScreenZ )
2958 z = this->uScreenZ;
2959 w = uW;
2960 if ( (signed int)uW > (signed int)this->uScreenW )
2961 w = this->uScreenW;
2962 this->uViewportY = y;
2963 this->uViewportX = x;
2964 this->uViewportZ = z;
2965 this->uViewportW = w;
2966 }
2967 2886
2968 2887
2969 2888
2970 2889
2971 2890
9832 pViewport->_4C02F8((signed __int64)(flt_6BE3A0 * 65536.0)); 9751 pViewport->_4C02F8((signed __int64)(flt_6BE3A0 * 65536.0));
9833 9752
9834 pIndoorCamera = new IndoorCamera; 9753 pIndoorCamera = new IndoorCamera;
9835 pIndoorCamera->Initialize( 9754 pIndoorCamera->Initialize(
9836 65, 9755 65,
9837 viewparams->uScreenZ - viewparams->uScreenX + 1, 9756 viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1,
9838 viewparams->uScreenW - viewparams->uScreenY + 1); 9757 viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1);
9839 9758
9840 InitializeTurnBasedAnimations(&stru_50C198); 9759 InitializeTurnBasedAnimations(&stru_50C198);
9841 pBitmaps_LOD->dword_11B84 = pBitmaps_LOD->uNumLoadedFiles; 9760 pBitmaps_LOD->dword_11B84 = pBitmaps_LOD->uNumLoadedFiles;
9842 pSprites_LOD->field_ECA0 = pSprites_LOD->uNumLoadedSprites; 9761 pSprites_LOD->field_ECA0 = pSprites_LOD->uNumLoadedSprites;
9843 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; 9762 pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles;
11194 unsigned int v9; // [sp+184h] [bp-4h]@28 11113 unsigned int v9; // [sp+184h] [bp-4h]@28
11195 11114
11196 //_getcwd(v5, 120); 11115 //_getcwd(v5, 120);
11197 //sprintfex(pIniFilename, "%s\\mm6.ini", v5); 11116 //sprintfex(pIniFilename, "%s\\mm6.ini", v5);
11198 viewparams = new ViewingParams; 11117 viewparams = new ViewingParams;
11199 viewparams->uScreenX = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); 11118 viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename);
11200 viewparams->uScreenY = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); 11119 viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename);
11201 viewparams->uScreenZ = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); 11120 viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename);
11202 viewparams->uScreenW = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); 11121 viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename);
11203 11122
11204 11123
11205 pAudioPlayer = new AudioPlayer; 11124 pAudioPlayer = new AudioPlayer;
11206 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); 11125 pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename);
11207 if ( pAudioPlayer->uMixerChannels > 16 ) 11126 if ( pAudioPlayer->uMixerChannels > 16 )
11350 else 11269 else
11351 { 11270 {
11352 LOBYTE(viewparams->field_20) = 0; 11271 LOBYTE(viewparams->field_20) = 0;
11353 } 11272 }
11354 pParty->uFlags |= 2u; 11273 pParty->uFlags |= 2u;
11355 viewparams->uSomeY = viewparams->uScreenY; 11274 viewparams->uSomeY = viewparams->uScreen_topL_Y;
11356 viewparams->uSomeX = viewparams->uScreenX; 11275 viewparams->uSomeX = viewparams->uScreen_topL_X;
11357 viewparams->uSomeZ = viewparams->uScreenZ; 11276 viewparams->uSomeZ = viewparams->uScreen_BttmR_X;
11358 viewparams->uSomeW = viewparams->uScreenW; 11277 viewparams->uSomeW = viewparams->uScreen_BttmR_Y;
11359 11278
11360 pViewport->SetScreen(viewparams->uScreenX, viewparams->uScreenY, viewparams->uScreenZ, viewparams->uScreenW); 11279 pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y);
11361 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) 11280 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
11362 pOutdoorCamera->_485F64(); 11281 pOutdoorCamera->_485F64();
11363 } 11282 }
11364 11283
11365 11284
12683 v1 = (int *)pGame->pVisInstance->get_picked_object_zbuf_val(); 12602 v1 = (int *)pGame->pVisInstance->get_picked_object_zbuf_val();
12684 if ( v1 != (int *)-1 ) 12603 if ( v1 != (int *)-1 )
12685 DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3); 12604 DoInteractionWithTopmostZObject((unsigned __int16)v1, (signed int)(unsigned __int16)v1 >> 3);
12686 } 12605 }
12687 v22 = 0; 12606 v22 = 0;
12688 v1 = (int *)((signed int)(viewparams->uScreenZ + viewparams->uScreenX) >> 1); 12607 v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);
12689 if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW ) 12608 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
12690 { 12609 {
12691 v2 = (char *)v1 - 50; 12610 v2 = (char *)v1 - 50;
12692 v1 = (int *)((char *)v1 + 50); 12611 v1 = (int *)((char *)v1 + 50);
12693 v3 = 640 * viewparams->uScreenY; 12612 v3 = 640 * viewparams->uScreen_topL_Y;
12694 v17 = v2; 12613 v17 = v2;
12695 v20 = v1; 12614 v20 = v1;
12696 v18 = ((viewparams->uScreenW - viewparams->uScreenY - 1) >> 1) + 1; 12615 v18 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
12697 do 12616 do
12698 { 12617 {
12699 if ( (signed int)v2 < (signed int)v20 ) 12618 if ( (signed int)v2 < (signed int)v20 )
12700 { 12619 {
12701 v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; 12620 v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]];
12977 result = sub_46A7C8(a1, a2, a3); 12896 result = sub_46A7C8(a1, a2, a3);
12978 } 12897 }
12979 else 12898 else
12980 { 12899 {
12981 v16 = 0; 12900 v16 = 0;
12982 v4 = viewparams->uScreenX; 12901 v4 = viewparams->uScreen_topL_X;
12983 v12 = viewparams->uScreenZ; 12902 v12 = viewparams->uScreen_BttmR_X;
12984 if ( (signed int)viewparams->uScreenY < (signed int)viewparams->uScreenW ) 12903 if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y )
12985 { 12904 {
12986 v15 = &pRenderer->pActiveZBuffer[viewparams->uScreenX + 640 * viewparams->uScreenY]; 12905 v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y];
12987 v13 = ((viewparams->uScreenW - viewparams->uScreenY - 1) >> 1) + 1; 12906 v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1;
12988 do 12907 do
12989 { 12908 {
12990 if ( (signed int)v4 < (signed int)v12 ) 12909 if ( (signed int)v4 < (signed int)v12 )
12991 { 12910 {
12992 v5 = v15; 12911 v5 = v15;
13223 int v30; // [sp+18h] [bp-Ch]@1 13142 int v30; // [sp+18h] [bp-Ch]@1
13224 signed int v31; // [sp+1Ch] [bp-8h]@3 13143 signed int v31; // [sp+1Ch] [bp-8h]@3
13225 int v32; // [sp+20h] [bp-4h]@1 13144 int v32; // [sp+20h] [bp-4h]@1
13226 13145
13227 v0 = 0; 13146 v0 = 0;
13228 v1 = (signed int)(viewparams->uScreenW + viewparams->uScreenY) >> 1; 13147 v1 = (signed int)(viewparams->uScreen_BttmR_Y + viewparams->uScreen_topL_Y) >> 1;
13229 v2 = (signed int)(viewparams->uScreenX + viewparams->uScreenZ) >> 1; 13148 v2 = (signed int)(viewparams->uScreen_topL_X + viewparams->uScreen_BttmR_X) >> 1;
13230 v3 = v1 - 50; 13149 v3 = v1 - 50;
13231 v32 = 0; 13150 v32 = 0;
13232 v4 = 100; 13151 v4 = 100;
13233 v30 = v1 - 50; 13152 v30 = v1 - 50;
13234 v28 = v1 + 50; 13153 v28 = v1 + 50;