comparison mm7_3.cpp @ 1439:468f434a8d8a

Слияние
author Ritor1
date Mon, 22 Jul 2013 18:00:58 +0600
parents bc99e1a48bea 3161094869e0
children b67a3e0d6fc3
comparison
equal deleted inserted replaced
1438:bc99e1a48bea 1439:468f434a8d8a
2096 if (uFaceEvent) 2096 if (uFaceEvent)
2097 EventProcessor(uFaceEvent, 0, 1); 2097 EventProcessor(uFaceEvent, 0, 1);
2098 } 2098 }
2099 2099
2100 //----- (00473893) -------------------------------------------------------- 2100 //----- (00473893) --------------------------------------------------------
2101 void __cdecl ODM_ProcessPartyActions() 2101 void ODM_ProcessPartyActions()
2102 { 2102 {
2103 //int _zero; // esi@1 2103 //int _zero; // esi@1
2104 int v1; // edi@1 2104 int v1; // edi@1
2105 int v2; // ebx@1 2105 int v2; // ebx@1
2106 int v3; // eax@14 2106 int v3; // eax@14
2281 { 2281 {
2282 //LOBYTE(pParty->uFlags) &= 0x7Fu; 2282 //LOBYTE(pParty->uFlags) &= 0x7Fu;
2283 bWaterWalk = 1; 2283 bWaterWalk = 1;
2284 *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; 2284 *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u;
2285 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) && 2285 if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) &&
2286 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster-1].sMana <= 0 ) 2286 pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 )
2287 //*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 10] <= 0 )
2288 bWaterWalk = 0; 2287 bWaterWalk = 0;
2289 } 2288 }
2290 v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk); 2289 v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk);
2291 v111 = v3; 2290 v111 = v3;
2292 if ( bFeatherFall ) 2291 if ( bFeatherFall )
3038 if ( v114 && (!bJumping || v101) ) 3037 if ( v114 && (!bJumping || v101) )
3039 { 3038 {
3040 if ( !v107 3039 if ( !v107
3041 && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) 3040 && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) )
3042 { 3041 {
3043 3042 pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0);
3044 v90 = -1;
3045 v89 = 1;
3046 v88 = 804;
3047 v87 = 64;
3048 pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
3049 } 3043 }
3050 else 3044 else
3051 { 3045 {
3052 v90 = -1;
3053 v89 = 1;
3054 v88 = 804;
3055 v86 = 1;
3056 //LABEL_255:
3057 v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; 3046 v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
3058 v64 = WorldPosToGridCellX(pParty->vPosition.x); 3047 v64 = WorldPosToGridCellX(pParty->vPosition.x);
3059 v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86); 3048 v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 1);
3060 pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0); 3049 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
3061 } 3050 }
3062 } 3051 }
3063 else 3052 else
3064 { 3053 {
3065 if ( v124 && (!bJumping || v101) ) 3054 if ( v124 && (!bJumping || v101) )
3066 { 3055 {
3067 if ( v107 3056 if ( v107
3068 || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) 3057 || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 )
3069 { 3058 {
3070
3071 v90 = -1;
3072 v89 = 1;
3073 v88 = 804;
3074 v86 = 0;
3075 v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; 3059 v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1;
3076 v64 = WorldPosToGridCellX(pParty->vPosition.x); 3060 v64 = WorldPosToGridCellX(pParty->vPosition.x);
3077 v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86); 3061 v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 0);
3078 pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0); 3062 pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0);
3079 } 3063 }
3080 else 3064 else
3081 { 3065 pAudioPlayer->PlaySound((SoundID)103, 804, 1, -1, 0, 0, 0, 0);
3082 v90 = -1;
3083 v89 = 1;
3084 v88 = 804;
3085 v87 = 103;
3086 //LABEL_257:
3087 pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0);
3088 }
3089 } 3066 }
3090 else 3067 else
3091 { 3068 {
3092 //LABEL_344:
3093 pAudioPlayer->_4AA258(804); 3069 pAudioPlayer->_4AA258(804);
3094 pParty->walk_sound_timer = 64; 3070 pParty->walk_sound_timer = 64;
3095 } 3071 }
3096 } 3072 }
3097 } 3073 }
3150 { 3126 {
3151 v74 = &pPlayers[1]; 3127 v74 = &pPlayers[1];
3152 do 3128 do
3153 { 3129 {
3154 v110 = (*v74)->GetMaxHealth(); 3130 v110 = (*v74)->GetMaxHealth();
3155 (*v74)->ReceiveDamage( 3131 (*v74)->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
3156 (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256,
3157 DMGT_PHISYCAL); 3132 DMGT_PHISYCAL);
3158 v75 = (*v74)->GetActualEndurance(); 3133 v75 = (*v74)->GetActualEndurance();
3159 v110 = 20 - (*v74)->GetParameterBonus(v75); 3134 v110 = 20 - (*v74)->GetParameterBonus(v75);
3160 (*v74)->SetRecoveryTime( 3135 (*v74)->SetRecoveryTime(
3161 (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); 3136 (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333));
3852 pActions[i] = pActions[i + 1]; 3827 pActions[i] = pActions[i + 1];
3853 --uNumActions; 3828 --uNumActions;
3854 3829
3855 return result; 3830 return result;
3856 } 3831 }
3857 // 47730C: using guessed type int __stdcall const_1(int);
3858 3832
3859 //----- (004775ED) -------------------------------------------------------- 3833 //----- (004775ED) --------------------------------------------------------
3860 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2) 3834 int stru6_stru1_indoor_sw_billboard::_4775ED(float a2)
3861 { 3835 {
3862 char *v2; // edi@1 3836 char *v2; // edi@1
3897 int v37; // [sp+C8h] [bp-10h]@6 3871 int v37; // [sp+C8h] [bp-10h]@6
3898 int v38; // [sp+CCh] [bp-Ch]@1 3872 int v38; // [sp+CCh] [bp-Ch]@1
3899 float v39; // [sp+D0h] [bp-8h]@6 3873 float v39; // [sp+D0h] [bp-8h]@6
3900 int *v40; // [sp+D4h] [bp-4h]@2 3874 int *v40; // [sp+D4h] [bp-4h]@2
3901 3875
3902 v2 = (char *)&this->field_14[4 * this->field_10 + 20]; 3876 v2 = (char *)&this->field_64[4 * this->uNumVertices];
3903 v38 = 0; 3877 v38 = 0;
3904 *(int *)v2 = this->field_14[20]; 3878 *(int *)v2 = this->field_64[0];
3905 v2 += 4; 3879 v2 += 4;
3906 *(int *)v2 = this->field_14[21]; 3880 *(int *)v2 = this->field_64[1];
3907 v2 += 4; 3881 v2 += 4;
3908 *(int *)v2 = this->field_14[22]; 3882 *(int *)v2 = this->field_64[2];
3909 *((int *)v2 + 1) = this->field_14[23]; 3883 *((int *)v2 + 1) = this->field_64[3];
3910 v3 = this->field_10; 3884 v3 = this->uNumVertices;
3911 v35 = this; 3885 v35 = this;
3912 if ( v3 > 0 ) 3886 if ( v3 > 0 )
3913 { 3887 {
3914 v40 = &this->field_14[40]; 3888 v40 = &this->field_64[20];
3915 v4 = (char *)&this->field_14[23] + 3; 3889 v4 = (char *)&this->field_64[3] + 3;
3916 v34 = v3; 3890 v34 = v3;
3917 while ( 1 ) 3891 while ( 1 )
3918 { 3892 {
3919 v5 = v4 - 15; 3893 v5 = v4 - 15;
3920 if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 ) 3894 if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 )
3996 //this = v35; 3970 //this = v35;
3997 v5 = (char *)&v30 + 4; 3971 v5 = (char *)&v30 + 4;
3998 goto LABEL_10; 3972 goto LABEL_10;
3999 } 3973 }
4000 LABEL_12: 3974 LABEL_12:
4001 result = v38; 3975 return this->uNumVertices = v38;
4002 this->field_10 = v38;
4003 return result;
4004 } 3976 }
4005 3977
4006 //----- (00477927) -------------------------------------------------------- 3978 //----- (00477927) --------------------------------------------------------
4007 int stru6_stru1_indoor_sw_billboard::_477927(float a2) 3979 int stru6_stru1_indoor_sw_billboard::_477927(float a2)
4008 { 3980 {
4044 int v37; // [sp+C8h] [bp-10h]@6 4016 int v37; // [sp+C8h] [bp-10h]@6
4045 int v38; // [sp+CCh] [bp-Ch]@1 4017 int v38; // [sp+CCh] [bp-Ch]@1
4046 float v39; // [sp+D0h] [bp-8h]@6 4018 float v39; // [sp+D0h] [bp-8h]@6
4047 int *v40; // [sp+D4h] [bp-4h]@2 4019 int *v40; // [sp+D4h] [bp-4h]@2
4048 4020
4049 v2 = (char *)&this->field_14[4 * this->field_10 + 20]; 4021 v2 = (char *)&this->field_64[4 * this->uNumVertices];
4050 v38 = 0; 4022 v38 = 0;
4051 *(int *)v2 = this->field_14[20]; 4023 *(int *)v2 = this->field_64[0];
4052 v2 += 4; 4024 v2 += 4;
4053 *(int *)v2 = this->field_14[21]; 4025 *(int *)v2 = this->field_64[1];
4054 v2 += 4; 4026 v2 += 4;
4055 *(int *)v2 = this->field_14[22]; 4027 *(int *)v2 = this->field_64[2];
4056 *((int *)v2 + 1) = this->field_14[23]; 4028 *((int *)v2 + 1) = this->field_64[3];
4057 v3 = this->field_10; 4029 v3 = this->uNumVertices;
4058 v35 = this; 4030 v35 = this;
4059 if ( v3 > 0 ) 4031 if ( v3 > 0 )
4060 { 4032 {
4061 v40 = &this->field_14[40]; 4033 v40 = &this->field_64[20];
4062 v4 = (char *)&this->field_14[23] + 3; 4034 v4 = (char *)&this->field_64[3] + 3;
4063 v34 = v3; 4035 v34 = v3;
4064 while ( 1 ) 4036 while ( 1 )
4065 { 4037 {
4066 v5 = v4 - 15; 4038 v5 = v4 - 15;
4067 if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 ) 4039 if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 )
4143 //this = v35; 4115 //this = v35;
4144 v5 = (char *)&v30 + 4; 4116 v5 = (char *)&v30 + 4;
4145 goto LABEL_10; 4117 goto LABEL_10;
4146 } 4118 }
4147 LABEL_12: 4119 LABEL_12:
4148 result = v38; 4120 return this->uNumVertices = v38;
4149 this->field_10 = v38;
4150 return result;
4151 } 4121 }
4152 4122
4153 //----- (00477C61) -------------------------------------------------------- 4123 //----- (00477C61) --------------------------------------------------------
4154 int stru6_stru1_indoor_sw_billboard::sub_477C61() 4124 int stru6_stru1_indoor_sw_billboard::sub_477C61()
4155 { 4125 {
4197 4167
4198 //v1 = this; 4168 //v1 = this;
4199 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 4169 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
4200 { 4170 {
4201 v2 = 0; 4171 v2 = 0;
4202 if ( this->field_10 > 0 ) 4172 if ( this->uNumVertices > 0 )
4203 { 4173 {
4204 v3 = (int)&this->field_14[1]; 4174 v3 = (int)&this->field_14[1];
4205 do 4175 do
4206 { 4176 {
4207 v4 = *(float *)(v3 - 4); 4177 v4 = *(float *)(v3 - 4);
4250 *(float *)(v3 + 76) = v10; 4220 *(float *)(v3 + 76) = v10;
4251 *(int *)(v3 + 88) = v14; 4221 *(int *)(v3 + 88) = v14;
4252 *(float *)(v3 + 80) = v11; 4222 *(float *)(v3 + 80) = v11;
4253 v3 += 16; 4223 v3 += 16;
4254 } 4224 }
4255 while ( v2 < this->field_10 ); 4225 while ( v2 < this->uNumVertices );
4256 } 4226 }
4257 } 4227 }
4258 else 4228 else
4259 { 4229 {
4260 v15 = (char *)&this->field_14[1]; 4230 v15 = (char *)&this->field_14[1];
4296 v15 += 16; 4266 v15 += 16;
4297 --v31; 4267 --v31;
4298 } 4268 }
4299 while ( v31 ); 4269 while ( v31 );
4300 } 4270 }
4301 this->field_10 = 3; 4271 this->uNumVertices = 3;
4302 return 1; 4272 return 1;
4303 } 4273 }
4304 4274
4305 //----- (00477F63) -------------------------------------------------------- 4275 //----- (00477F63) --------------------------------------------------------
4306 bool stru6_stru1_indoor_sw_billboard::sub_477F63() 4276 bool stru6_stru1_indoor_sw_billboard::sub_477F63()
4328 else 4298 else
4329 { 4299 {
4330 v10 = (double)pOutdoorCamera->shading_dist_mist; 4300 v10 = (double)pOutdoorCamera->shading_dist_mist;
4331 v3 = 8.0; 4301 v3 = 8.0;
4332 } 4302 }
4333 v4 = a1->field_10; 4303 v4 = a1->uNumVertices;
4334 if ( v4 <= 0 ) 4304 if ( v4 <= 0 )
4335 goto LABEL_16; 4305 goto LABEL_16;
4336 v5 = (char *)&a1->field_14[20]; 4306 v5 = (char *)&a1->field_14[20];
4337 v6 = v4; 4307 v6 = v4;
4338 do 4308 do
4351 if ( !v1 ) 4321 if ( !v1 )
4352 { 4322 {
4353 if ( v9 ) 4323 if ( v9 )
4354 { 4324 {
4355 v2->_477927(v10); 4325 v2->_477927(v10);
4356 return v2->field_10 != 0; 4326 return v2->uNumVertices != 0;
4357 } 4327 }
4358 LABEL_16: 4328 LABEL_16:
4359 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); 4329 memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4);
4360 return v2->field_10 != 0; 4330 return v2->uNumVertices != 0;
4361 } 4331 }
4362 v7 = v3; 4332 v7 = v3;
4363 _4775ED(v7); 4333 _4775ED(v7);
4364 return v2->field_10 != 0; 4334 return v2->uNumVertices != 0;
4365 } 4335 }
4366 4336
4367 //----- (0047802A) -------------------------------------------------------- 4337 //----- (0047802A) --------------------------------------------------------
4368 int stru6_stru1_indoor_sw_billboard::sub_47802A() 4338 int stru6_stru1_indoor_sw_billboard::sub_47802A()
4369 { 4339 {
4376 auto a1 = this; 4346 auto a1 = this;
4377 4347
4378 v16 = 0; 4348 v16 = 0;
4379 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 4349 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
4380 { 4350 {
4381 for(int i = 0; i < a1->field_10; i++) 4351 for(int i = 0; i < a1->uNumVertices; i++)
4382 { 4352 {
4383 v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / a1->field_B4[i*4]; 4353 v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / a1->field_B4[i*4];
4384 if ( pRenderer->pRenderD3D ) 4354 if ( pRenderer->pRenderD3D )
4385 { 4355 {
4386 pGame->pIndoorCameraD3D->Project( 4356 pGame->pIndoorCameraD3D->Project(
4407 v16 = 1; 4377 v16 = 1;
4408 } 4378 }
4409 } 4379 }
4410 else 4380 else
4411 { 4381 {
4412 for(int i = 0; i < a1->field_10; i++) 4382 for(int i = 0; i < a1->uNumVertices; i++)
4413 { 4383 {
4414 v12 = (double)pOutdoorCamera->int_fov_rad / a1->field_B4[i*4]; 4384 v12 = (double)pOutdoorCamera->int_fov_rad / a1->field_B4[i*4];
4415 a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1]; 4385 a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1];
4416 a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2]; 4386 a1->field_B4[i*4+21] = (double)pViewport->uScreenCenterY - v12 * a1->field_B4[i*4+2];
4417 *((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4]; 4387 *((int *)&a1->field_B4[i*4+22]) = (int)a1->field_B4[i*4];
4444 } 4414 }
4445 4415
4446 //----- (0047840D) -------------------------------------------------------- 4416 //----- (0047840D) --------------------------------------------------------
4447 char Render::DrawBuildingsD3D() 4417 char Render::DrawBuildingsD3D()
4448 { 4418 {
4449 IndoorCameraD3D *v0; // eax@3 4419 //IndoorCameraD3D *v0; // eax@3
4450 char result; // al@3 4420 char result; // al@3
4451 BSPModel *v2; // ebx@4 4421 BSPModel *v2; // ebx@4
4452 int v3; // eax@6 4422 int v3; // eax@6
4453 ODMFace *pFace; // esi@6 4423 ODMFace *pFace; // esi@6
4454 Vec3_int_ *v5; // ecx@8 4424 Vec3_int_ *v5; // ecx@8
4455 int v6; // eax@8 4425 int v6; // eax@8
4456 stru148 *v7; // ebx@8 4426 struct Polygon *v7; // ebx@8
4457 LightmapBuilder *v8; // eax@8 4427 LightmapBuilder *v8; // eax@8
4458 int v9; // ecx@8 4428 int v9; // ecx@8
4459 char v10; // zf@8 4429 char v10; // zf@8
4460 Texture *pFaceTexture; // eax@10 4430 Texture *pFaceTexture; // eax@10
4461 signed int v12; // ecx@10 4431 signed int v12; // ecx@10
4475 int v24; // eax@50 4445 int v24; // eax@50
4476 int v25; // ecx@55 4446 int v25; // ecx@55
4477 int v26; // eax@57 4447 int v26; // eax@57
4478 int v27; // eax@57 4448 int v27; // eax@57
4479 int v28; // eax@58 4449 int v28; // eax@58
4480 int v29; // edx@58 4450 //int v29; // edx@58
4481 double v30; // st7@59 4451 //double v30; // st7@59
4482 LightmapBuilder *v31; // edi@63 4452 //LightmapBuilder *v31; // edi@63
4483 signed int v32; // eax@73 4453 signed int v32; // eax@73
4484 int v33; // eax@78 4454 int v33; // eax@78
4485 unsigned int v34; // eax@80 4455 unsigned int v34; // eax@80
4486 std::string v35; // [sp-18h] [bp-70h]@2 4456 std::string v35; // [sp-18h] [bp-70h]@2
4487 int v36; // [sp-14h] [bp-6Ch]@69 4457 int v36; // [sp-14h] [bp-6Ch]@69
4488 RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69 4458 RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69
4489 int v38; // [sp-Ch] [bp-64h]@69 4459 int v38; // [sp-Ch] [bp-64h]@69
4490 LightmapBuilder *v39; // [sp-8h] [bp-60h]@2 4460 //LightmapBuilder *v39; // [sp-8h] [bp-60h]@2
4491 int v40; // [sp-4h] [bp-5Ch]@2 4461 int v40; // [sp-4h] [bp-5Ch]@2
4492 std::string *v41; // [sp+Ch] [bp-4Ch]@2 4462 //std::string *v41; // [sp+Ch] [bp-4Ch]@2
4493 int v41b; 4463 int v41b;
4494 int v42; // [sp+10h] [bp-48h]@6 4464 int v42; // [sp+10h] [bp-48h]@6
4495 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8 4465 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8
4496 float v44; // [sp+18h] [bp-40h]@10 4466 float v44; // [sp+18h] [bp-40h]@10
4497 float v45; // [sp+1Ch] [bp-3Ch]@10 4467 float v45; // [sp+1Ch] [bp-3Ch]@10
4498 ODMFace *v46; // [sp+20h] [bp-38h]@6 4468 ODMFace *v46; // [sp+20h] [bp-38h]@6
4499 IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3 4469 //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3
4500 unsigned int v48; // [sp+28h] [bp-30h]@8 4470 unsigned int v48; // [sp+28h] [bp-30h]@8
4501 int v49; // [sp+2Ch] [bp-2Ch]@10 4471 int v49; // [sp+2Ch] [bp-2Ch]@10
4502 int v50; // [sp+30h] [bp-28h]@34 4472 int v50; // [sp+30h] [bp-28h]@34
4503 int v51; // [sp+34h] [bp-24h]@35 4473 int v51; // [sp+34h] [bp-24h]@35
4504 int v52; // [sp+38h] [bp-20h]@36 4474 int v52; // [sp+38h] [bp-20h]@36
4510 int unused; // [sp+50h] [bp-8h]@3 4480 int unused; // [sp+50h] [bp-8h]@3
4511 int a3; // [sp+57h] [bp-1h]@2 4481 int a3; // [sp+57h] [bp-1h]@2
4512 4482
4513 if ( !pRenderer->pRenderD3D ) 4483 if ( !pRenderer->pRenderD3D )
4514 { 4484 {
4515 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); 4485 MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0);
4516 } 4486 }
4487
4517 unused = 0; 4488 unused = 0;
4518 v0 = pGame->pIndoorCameraD3D;
4519 a1 = 0; 4489 a1 = 0;
4520 v47 = v0;
4521 result = LOBYTE(pOutdoor->pBModels); 4490 result = LOBYTE(pOutdoor->pBModels);
4522 v41b = pOutdoor->uNumBModels; 4491 v41b = pOutdoor->uNumBModels;
4523 if ( (signed int)pOutdoor->uNumBModels > 0 ) 4492 if ( (signed int)pOutdoor->uNumBModels > 0 )
4524 { 4493 {
4525 v2 = pOutdoor->pBModels; 4494 v2 = pOutdoor->pBModels;
4551 goto LABEL_85; 4520 goto LABEL_85;
4552 //v5 = (int)*(v2 - 1); 4521 //v5 = (int)*(v2 - 1);
4553 v5 = v2->pVertices.pVertices; 4522 v5 = v2->pVertices.pVertices;
4554 v6 = pFace->pVertexIDs[0]; 4523 v6 = pFace->pVertexIDs[0];
4555 v53 = 0; 4524 v53 = 0;
4556 v7 = &array_77EC08[pOutdoorCamera->numStru148s]; 4525 v7 = &array_77EC08[pOutdoorCamera->uNumPolygons];
4557 //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8); 4526 //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8);
4558 v8 = (LightmapBuilder *)v5[v6].z; 4527 v8 = (LightmapBuilder *)v5[v6].z;
4559 *(int *)&v7->flags = 0; 4528 v7->flags = 0;
4529 v7->field_32 = 0;
4560 pLightmapBuilder = v8; 4530 pLightmapBuilder = v8;
4561 v9 = pFace->uTextureID; 4531 v9 = pFace->uTextureID;
4562 v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0; 4532 v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0;
4563 v48 = pFace->uTextureID; 4533 v48 = pFace->uTextureID;
4564 if ( !v10 ) 4534 if ( !v10 )
4693 { 4663 {
4694 //if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) ) 4664 //if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) )
4695 if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z ) 4665 if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z )
4696 ++v53; 4666 ++v53;
4697 //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u); 4667 //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u);
4698 v47->ViewTransform(v23, 1u); 4668 pGame->pIndoorCameraD3D->ViewTransform(v23, 1u);
4699 if ( v23->vWorldViewPosition.x < 8.0 || (double)pOutdoorCamera->shading_dist_mist < v23->vWorldViewPosition.x ) 4669 if ( v23->vWorldViewPosition.x < 8.0 || (double)pOutdoorCamera->shading_dist_mist < v23->vWorldViewPosition.x )
4700 { 4670 {
4701 if ( v23->vWorldViewPosition.x >= 8.0 ) 4671 if ( v23->vWorldViewPosition.x >= 8.0 )
4702 v49 = 1; 4672 v49 = 1;
4703 else 4673 else
4704 v50 = 1; 4674 v50 = 1;
4705 } 4675 }
4706 else 4676 else
4707 { 4677 {
4708 v47->Project(v23, 1u, 0); 4678 pGame->pIndoorCameraD3D->Project(v23, 1u, 0);
4709 } 4679 }
4710 ++v23;// += 48; 4680 ++v23;// += 48;
4711 --v51; 4681 --v51;
4712 } 4682 }
4713 while ( v51 ); 4683 while ( v51 );
4733 v7->dimming_level = result; 4703 v7->dimming_level = result;
4734 if ( result < 0 ) 4704 if ( result < 0 )
4735 v7->dimming_level = 0; 4705 v7->dimming_level = 0;
4736 if ( v7->dimming_level > 31 ) 4706 if ( v7->dimming_level > 31 )
4737 v7->dimming_level = 31; 4707 v7->dimming_level = 31;
4738 if ( pOutdoorCamera->numStru148s >= 1999 + 5000) 4708 if ( pOutdoorCamera->uNumPolygons >= 1999 + 5000)
4739 return result; 4709 return result;
4740 ++pOutdoorCamera->numStru148s; 4710 ++pOutdoorCamera->uNumPolygons;
4741 ++pOutdoorCamera->field_44; 4711 ++pOutdoorCamera->field_44;
4742 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) ) 4712 if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) )
4743 { 4713 {
4744 LOBYTE(v25) = (char)v54; 4714 LOBYTE(v25) = (char)v54;
4745 v26 = a1; 4715 v26 = a1;
4748 LOWORD(v25) = (unsigned __int8)v25; 4718 LOWORD(v25) = (unsigned __int8)v25;
4749 v7->uBModelID = v26; 4719 v7->uBModelID = v26;
4750 v27 = 8 * (v25 | (v26 << 6)); 4720 v27 = 8 * (v25 | (v26 << 6));
4751 LOBYTE(v27) = v27 | 6; 4721 LOBYTE(v27) = v27 | 6;
4752 v7->field_50 = v27; 4722 v7->field_50 = v27;
4753 if ( v18 > 0 ) 4723
4724 for (v28 = 0; v28 < v18; ++v28)
4754 { 4725 {
4755 v28 = 0;
4756 v29 = v18;
4757 do
4758 {
4759 v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
4760 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28])); 4726 memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28]));
4761 ++v28; 4727 array_50AC10[v28]._rhw = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001);
4762 --v29; 4728
4763 array_50A2B0[v28 + 49]._rhw = v30;
4764 }
4765 while ( v29 );
4766 pFace = v46; 4729 pFace = v46;
4767 } 4730 }
4768 4731
4769 static stru154 static_RenderBuildingsD3D_stru_73C834; 4732 static stru154 static_RenderBuildingsD3D_stru_73C834;
4770 /*static bool __init_flag = false; 4733 /*static bool __init_flag = false;
4776 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); 4739 stru154::stru154(&static_RenderBuildingsD3D_stru_73C834);
4777 atexit(loc_4789D4); 4740 atexit(loc_4789D4);
4778 }*/ 4741 }*/
4779 4742
4780 v40 = (int)pFace; 4743 v40 = (int)pFace;
4781 pLightmapBuilder = pGame->pLightmapBuilder; 4744 pGame->pLightmapBuilder->ApplyLights_OutdoorFace(pFace);
4782 v31 = pLightmapBuilder;
4783 pLightmapBuilder->ApplyLights_OutdoorFace(pFace);
4784 pDecalBuilder->ApplyDecals_OutdoorFace(pFace); 4745 pDecalBuilder->ApplyDecals_OutdoorFace(pFace);
4785 v31->std__vector_000004_size = 0; 4746 pGame->pLightmapBuilder->std__vector_000004_size = 0;
4786 LOBYTE(v31) = 0; 4747
4748 int v31 = 0;
4787 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) 4749 if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 )
4788 { 4750 {
4789 v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0); 4751 v31 = v50 ? 3 : v49 != 0 ? 5 : 0;
4790 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices); 4752 static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices);
4791 if ( pDecalBuilder->uNumDecals > 0 ) 4753 if ( pDecalBuilder->uNumDecals > 0 )
4792 { 4754 {
4793 v40 = -1; 4755 v40 = -1;
4794 v39 = v31;
4795 v38 = 0; 4756 v38 = 0;
4796 v37 = array_50AC10; 4757 v37 = array_50AC10;
4797 v36 = uNumVertices; 4758 v36 = uNumVertices;
4798 pDecalBuilder->ApplyDecals(31 - v7->dimming_level, 4759 pDecalBuilder->ApplyDecals(31 - v7->dimming_level,
4799 2, 4760 2,
4804 (char)v31, 4765 (char)v31,
4805 -1); 4766 -1);
4806 } 4767 }
4807 } 4768 }
4808 if ( stru_F8AD28.uNumLightsApplied > 0 ) 4769 if ( stru_F8AD28.uNumLightsApplied > 0 )
4809 pLightmapBuilder->ApplyLights( 4770 pGame->pLightmapBuilder->ApplyLights(
4810 &stru_F8AD28, 4771 &stru_F8AD28,
4811 &static_RenderBuildingsD3D_stru_73C834, 4772 &static_RenderBuildingsD3D_stru_73C834,
4812 uNumVertices, 4773 uNumVertices,
4813 array_50AC10, 4774 array_50AC10,
4814 0, 4775 0,
4843 } 4804 }
4844 pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40); 4805 pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40);
4845 } 4806 }
4846 goto LABEL_85; 4807 goto LABEL_85;
4847 } 4808 }
4848 --pOutdoorCamera->numStru148s; 4809 --pOutdoorCamera->uNumPolygons;
4849 --pOutdoorCamera->field_44; 4810 --pOutdoorCamera->field_44;
4850 LABEL_85: 4811 LABEL_85:
4851 v54 = (Vec3_int_ *)((char *)v54 + 1); 4812 v54 = (Vec3_int_ *)((char *)v54 + 1);
4852 v2 = v56; 4813 v2 = v56;
4853 ++pFace; 4814 ++pFace;
4858 } 4819 }
4859 return result; 4820 return result;
4860 } 4821 }
4861 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag; 4822 // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag;
4862 4823
4863 //----- (004789DE) --------------------------------------------------------
4864 BSPModel *Render::DrawBuildingsSW()
4865 {
4866 BSPModel *result; // eax@1
4867 BSPModel *v1; // ebx@2
4868 int v2; // eax@4
4869 ODMFace *v3; // edi@4
4870 int v4; // ecx@6
4871 int v5; // eax@6
4872 int v6; // ecx@6
4873 int v7; // ecx@6
4874 double v8; // st7@7
4875 char *v9; // ebx@7
4876 int v10; // eax@9
4877 double v11; // st7@9
4878 stru148 *v12; // ebx@19
4879 double v13; // st7@21
4880 double v14; // ST4C_8@23
4881 int v15; // eax@23
4882 int v16; // eax@27
4883 int v17; // ecx@29
4884 unsigned __int8 v18; // sf@29
4885 unsigned __int8 v19; // of@29
4886 int v20; // ecx@30
4887 int v21; // eax@31
4888 int v22; // eax@31
4889 int v23; // eax@35
4890 int v24; // eax@39
4891 Texture *v25; // eax@43
4892 int v26; // esi@43
4893 signed int v27; // ecx@43
4894 double v28; // st6@43
4895 double v29; // st5@43
4896 unsigned short *v30; // edx@44
4897 int v31; // eax@44
4898 double v32; // st4@45
4899 int v33; // ecx@45
4900 char v34; // zf@45
4901 BSPVertexBuffer *v35; // eax@50
4902 unsigned int v36; // eax@53
4903 signed int v37; // esi@53
4904 int v38; // eax@54
4905 signed int v39; // edx@55
4906 char *v40; // ecx@56
4907 double v41; // ST1C_8@57
4908 double v42; // ST24_8@57
4909 signed int v43; // eax@60
4910 signed int v44; // esi@60
4911 int v45; // eax@61
4912 signed int v46; // edx@62
4913 char *v47; // ecx@63
4914 double v48; // ST34_8@64
4915 double v49; // ST44_8@64
4916 int v50; // eax@66
4917 signed int v51; // ecx@67
4918 char *v52; // edx@68
4919 double v53; // ST3C_8@69
4920 double v54; // ST2C_8@69
4921 float v55; // [sp+44h] [bp-7Ch]@50
4922 float v56; // [sp+48h] [bp-78h]@50
4923 float v57; // [sp+4Ch] [bp-74h]@50
4924 float v58; // [sp+50h] [bp-70h]@64
4925 int v59; // [sp+54h] [bp-6Ch]@64
4926 int v60; // [sp+58h] [bp-68h]@69
4927 float v61; // [sp+5Ch] [bp-64h]@64
4928 float v62; // [sp+60h] [bp-60h]@69
4929 float v63; // [sp+64h] [bp-5Ch]@57
4930 float v64; // [sp+68h] [bp-58h]@57
4931 int v65; // [sp+6Ch] [bp-54h]@64
4932 int v66; // [sp+70h] [bp-50h]@1
4933 int v67; // [sp+74h] [bp-4Ch]@6
4934 int v68; // [sp+78h] [bp-48h]@4
4935 int v69; // [sp+7Ch] [bp-44h]@57
4936 int v70; // [sp+80h] [bp-40h]@69
4937 int v71; // [sp+84h] [bp-3Ch]@23
4938 float v72; // [sp+88h] [bp-38h]@69
4939 int v73; // [sp+8Ch] [bp-34h]@57
4940 int v74; // [sp+90h] [bp-30h]@6
4941 int v75; // [sp+94h] [bp-2Ch]@6
4942 ODMFace *v76; // [sp+98h] [bp-28h]@4
4943 int v77; // [sp+9Ch] [bp-24h]@6
4944 BSPModel *v78; // [sp+A0h] [bp-20h]@2
4945 int v79; // [sp+A4h] [bp-1Ch]@4
4946 int a1; // [sp+A8h] [bp-18h]@1
4947 unsigned short *v81; // [sp+ACh] [bp-14h]@7
4948 int v82; // [sp+B0h] [bp-10h]@6
4949 int v83; // [sp+B4h] [bp-Ch]@6
4950 signed int v84; // [sp+B8h] [bp-8h]@7
4951 int a2; // [sp+BCh] [bp-4h]@1
4952
4953 a2 = 0;
4954 a1 = 0;
4955 result = (BSPModel *)pOutdoor->pBModels;
4956 v66 = pOutdoor->uNumBModels;
4957 if ( (signed int)pOutdoor->uNumBModels > 0 )
4958 {
4959 v1 = pOutdoor->pBModels;
4960 v78 = pOutdoor->pBModels;
4961 while ( 1 )
4962 {
4963 if ( IsBModelVisible(a1, &a2) )
4964 {
4965 v1->field_40 |= 1u;
4966 v2 = v1->uNumFaces;
4967 v3 = v1->pFaces;
4968 v74 = 0;
4969 v76 = v3;
4970 v68 = v2;
4971 if ( v2 > 0 )
4972 break;
4973 }
4974 LABEL_73:
4975 ++a1;
4976 ++v1;
4977 result = (BSPModel *)a1;
4978 v78 = v1;
4979 if ( a1 >= v66 )
4980 return result;
4981 }
4982 while ( 1 )
4983 {
4984 if ( !v3->Invisible() )
4985 {
4986 v4 = 3 * v3->pVertexIDs[0];
4987 v5 = (int)((char *)v1 - 8);
4988 v67 = (int)((char *)v1 - 8);
4989 v6 = *(_DWORD *)(*(&v1->uNumConvexFaces - 2) + 4 * v4 + 8) + 4;
4990 v82 = 0;
4991 v83 = v6;
4992 v74 = 0;
4993 v7 = v3->uNumVertices;
4994 v75 = 0;
4995 v77 = v7;
4996 if ( v7 > 0 )
4997 {
4998 v8 = (double)v83;
4999 v9 = (char *)&array_73D150[0].vWorldViewPosition;
5000 v81 = v3->pVertexIDs;
5001 v83 = v7;
5002 *(float *)&v84 = v8;
5003 while ( 1 )
5004 {
5005 v10 = *(int *)(v5 + 4) + 12 * *(short *)v81;
5006 *((float *)v9 - 3) = (double)*(signed int *)v10 + 4.0;
5007 *((float *)v9 - 2) = (double)*(signed int *)(v10 + 4) + 4.0;
5008 v11 = (double)*(signed int *)(v10 + 8) + 4.0;
5009 *((float *)v9 - 1) = v11;
5010 if ( *(float *)&v84 == v11 )
5011 ++v82;
5012 pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)(v9 - 12), 1u);
5013 if ( *(float *)v9 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v9 )
5014 {
5015 if ( *(float *)v9 >= 8.0 )
5016 v75 = 1;
5017 else
5018 v74 = 1;
5019 }
5020 else
5021 {
5022 pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0);
5023 }
5024 v81 += 2;
5025 v9 += 48;
5026 --v83;
5027 if ( !v83 )
5028 break;
5029 v5 = v67;
5030 }
5031 v7 = v77;
5032 }
5033 v12 = &array_77EC08[pOutdoorCamera->numStru148s];
5034 *(int *)&v12->flags = 0;
5035 if ( v82 == v7 )
5036 *(int *)&v12->flags = 65536;
5037 v12->pODMFace = v3;
5038 v12->uNumVertices = v7;
5039 v12->field_59 = 5;
5040 v84 = v3->pFacePlane.vNormal.x;
5041 v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16;
5042 v82 = -pOutdoor->vSunlight.y;
5043 v84 = v3->pFacePlane.vNormal.y;
5044 v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16;
5045 v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z;
5046 v84 = v3->pFacePlane.vNormal.z;
5047 v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
5048 v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16);
5049 v13 = (double)v84 * 0.000015258789;
5050 if ( v13 < 0.0 )
5051 v13 = 0.0;
5052 *(float *)&v84 = v13 * 31.0;
5053 v14 = *(float *)&v84 + 6.7553994e15;
5054 v71 = LODWORD(v14);
5055 v15 = (int)&v12->dimming_level;
5056 v12->dimming_level = 31 - LOBYTE(v14);
5057 if ( (char)(31 - LOBYTE(v14)) < 0 )
5058 *(char *)v15 = 0;
5059 if ( *(char *)v15 > 31 )
5060 *(char *)v15 = 31;
5061 v16 = v3->uTextureID;
5062 if ( BYTE1(v3->uAttributes) & 0x40 )
5063 v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed);
5064 v17 = v16;
5065 result = (BSPModel *)&pBitmaps_LOD->pTextures[v16];
5066 v19 = __OFSUB__(pOutdoorCamera->numStru148s, 1999);
5067 v18 = pOutdoorCamera->numStru148s - 1999 < 0;
5068 v12->pTexture = (Texture *)(v17 != -1 ? (int)result : 0);
5069 if ( !(v18 ^ v19) )
5070 return result;
5071 ++pOutdoorCamera->numStru148s;
5072 ++pOutdoorCamera->field_44;
5073 if ( !ODMFace::IsBackfaceCulled(v3, array_73D150, v12) )
5074 {
5075 LABEL_71:
5076 --pOutdoorCamera->numStru148s;
5077 --pOutdoorCamera->field_44;
5078 goto LABEL_72;
5079 }
5080 LOBYTE(v20) = v79;
5081 v21 = a1;
5082 v3->bVisible = 1;
5083 v12->uBModelFaceID = v20;
5084 LOWORD(v20) = (unsigned __int8)v20;
5085 v12->uBModelID = v21;
5086 v22 = 8 * (v20 | (v21 << 6));
5087 LOBYTE(v22) = v22 | 6;
5088 v12->field_50 = v22;
5089 if ( v3->uAttributes & 0x10 )
5090 *(int *)&v12->flags |= 2u;
5091 if ( BYTE2(v3->uAttributes) & 0x40 )
5092 HIBYTE(v12->flags) |= 4u;
5093 v23 = v3->uAttributes;
5094 if ( v23 & 4 )
5095 {
5096 HIBYTE(v12->flags) |= 4u;
5097 }
5098 else
5099 {
5100 if ( v23 & 0x20 )
5101 HIBYTE(v12->flags) |= 8u;
5102 }
5103 v24 = v3->uAttributes;
5104 if ( BYTE1(v24) & 8 )
5105 {
5106 HIBYTE(v12->flags) |= 0x20u;
5107 }
5108 else
5109 {
5110 if ( v24 & 0x40 )
5111 HIBYTE(v12->flags) |= 0x10u;
5112 }
5113 v25 = v12->pTexture;
5114 v26 = v77;
5115 v27 = v25->uTextureWidth;
5116 v84 = v25->uTextureHeight;
5117 v28 = 1.0 / (double)v27;
5118 v29 = 1.0 / (double)v84;
5119 if ( v77 > 0 )
5120 {
5121 v30 = v3->pTextureVIDs;
5122 v31 = 0;
5123 v83 = v77;
5124 do
5125 {
5126 v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001);
5127 memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31]));
5128 ++v31;
5129 array_50A2B0[v31 + 49]._rhw = v32;
5130 v84 = v12->sTextureDeltaU + *(short *)(v30 - 40);
5131 array_50A2B0[v31 + 49].u = (double)v84 * v28;
5132 v33 = v12->sTextureDeltaV + *(short *)v30;
5133 v30 += 2;
5134 v34 = v83-- == 1;
5135 v84 = v33;
5136 array_50A2B0[v31 + 49].v = (double)v33 * v29;
5137 }
5138 while ( !v34 );
5139 v3 = v76;
5140 v26 = v77;
5141 }
5142
5143 static stru154 static_sub_004789DE_stru_73C818; // idb
5144 /*static bool __init_flag = false;
5145 if (!__init_flag)
5146 {
5147 __init_flag = true;
5148
5149 static_sub_004789DE_byte_73C830__init_flag |= 1u;
5150 stru154::stru154(&static_sub_004789DE_stru_73C818);
5151 }*/
5152
5153 pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3);
5154 if ( stru_F8AD28.uNumLightsApplied <= 0 )
5155 {
5156 v12->field_108 = 0;
5157 }
5158 else
5159 {
5160 v35 = (BSPVertexBuffer *)(v78 - 2);
5161 v12->field_108 = 1;
5162
5163 static_sub_004789DE_stru_73C818.GetFacePlaneAndClassify((ODMFace *)v3, v35);
5164 v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x;
5165 v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y;
5166 v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z;
5167 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55);
5168 }
5169 if ( v74 )
5170 {
5171 v36 = sr_4250FE(v26);
5172 v37 = v36;
5173 if ( !v36 || (OutdoorCamera::Project(v36), v38 = sr_4254D2(v37), (v12->uNumVertices = v38) == 0) )
5174 goto LABEL_71;
5175 v12->_48276F_sr();
5176 v39 = 0;
5177 if ( (signed int)v12->uNumVertices > 0 )
5178 {
5179 v40 = (char *)&array_508690[0].vWorldViewProjY;
5180 do
5181 {
5182 LODWORD(v64) = *((int *)v40 - 1);
5183 v41 = v64 + 6.7553994e15;
5184 v69 = LODWORD(v41);
5185 dword_50B638[v39] = LODWORD(v41);
5186 LODWORD(v63) = *(int *)v40;
5187 v42 = v63 + 6.7553994e15;
5188 v73 = LODWORD(v42);
5189 v40 += 48;
5190 dword_50B570[v39++] = LODWORD(v42);
5191 }
5192 while ( v39 < (signed int)v12->uNumVertices );
5193 }
5194 }
5195 else
5196 {
5197 if ( v75 )
5198 {
5199 v43 = sr_4252E8(v26);
5200 v44 = v43;
5201 if ( !v43 || (OutdoorCamera::Project(v43), v45 = sr_4254D2(v44), (v12->uNumVertices = v45) == 0) )
5202 goto LABEL_71;
5203 v12->_48276F_sr();
5204 v46 = 0;
5205 if ( (signed int)v12->uNumVertices > 0 )
5206 {
5207 v47 = (char *)&array_508690[0].vWorldViewProjY;
5208 do
5209 {
5210 LODWORD(v61) = *((int *)v47 - 1);
5211 v48 = v61 + 6.7553994e15;
5212 v65 = LODWORD(v48);
5213 dword_50B638[v46] = LODWORD(v48);
5214 LODWORD(v58) = *(int *)v47;
5215 v49 = v58 + 6.7553994e15;
5216 v59 = LODWORD(v49);
5217 v47 += 48;
5218 dword_50B570[v46++] = LODWORD(v49);
5219 }
5220 while ( v46 < (signed int)v12->uNumVertices );
5221 }
5222 }
5223 else
5224 {
5225 v50 = sr_4254D2(v26);
5226 v12->uNumVertices = v50;
5227 if ( !v50 )
5228 goto LABEL_71;
5229 sr_sub_4829B9(
5230 &array_73D150[v3->uGradientVertex1],
5231 &array_73D150[v3->uGradientVertex2],
5232 &array_73D150[v3->uGradientVertex3],
5233 v12,
5234 0);
5235 v51 = 0;
5236 if ( (signed int)v12->uNumVertices > 0 )
5237 {
5238 v52 = (char *)&array_508690[0].vWorldViewProjY;
5239 do
5240 {
5241 LODWORD(v62) = *((int *)v52 - 1);
5242 v53 = v62 + 6.7553994e15;
5243 v60 = LODWORD(v53);
5244 dword_50B638[v51] = LODWORD(v53);
5245 LODWORD(v72) = *(int *)v52;
5246 v54 = v72 + 6.7553994e15;
5247 v70 = LODWORD(v54);
5248 v52 += 48;
5249 dword_50B570[v51++] = LODWORD(v54);
5250 }
5251 while ( v51 < (signed int)v12->uNumVertices );
5252 }
5253 }
5254 }
5255 sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638.data(), dword_50B570.data(), v12);
5256 }
5257 LABEL_72:
5258 ++v79;
5259 v1 = v78;
5260 ++v3;
5261 v76 = v3;
5262 if ( v79 >= v68 )
5263 goto LABEL_73;
5264 }
5265 }
5266 return result;
5267 }
5268 // 50B570: using guessed type int dword_50B570[];
5269 // 50B638: using guessed type int dword_50B638[];
5270 // 73C830: using guessed type char static_sub_004789DE_byte_73C830__init_flag;
5271 4824
5272 //----- (00479089) -------------------------------------------------------- 4825 //----- (00479089) --------------------------------------------------------
5273 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) 4826 bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable)
5274 { 4827 {
5275 BSPModel *v2; // eax@1 4828 BSPModel *v2; // eax@1
5337 } 4890 }
5338 return false; 4891 return false;
5339 } 4892 }
5340 4893
5341 //----- (00479295) -------------------------------------------------------- 4894 //----- (00479295) --------------------------------------------------------
5342 int stru148::_479295() 4895 int Polygon::_479295()
5343 { 4896 {
5344 stru148 *v1; // edi@1
5345 ODMFace *v2; // esi@1 4897 ODMFace *v2; // esi@1
5346 int v3; // ecx@4 4898 int v3; // ecx@4
5347 int v4; // eax@4 4899 int v4; // eax@4
5348 int v5; // edx@4 4900 int v5; // edx@4
5349 int v6; // ST14_4@5 4901 int v6; // ST14_4@5
5350 int v7; // ST04_4@5 4902 int v7; // ST04_4@5
5351 stru149 *v8; // ecx@5 4903 stru149 *v8; // ecx@5
5352 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8 4904 Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8
5353 int v11; // [sp+18h] [bp-4h]@4 4905 int v11; // [sp+18h] [bp-4h]@4
5354 4906
5355 v1 = this;
5356 v2 = this->pODMFace; 4907 v2 = this->pODMFace;
5357 if ( !v2->pFacePlane.vNormal.z ) 4908 if ( !v2->pFacePlane.vNormal.z )
5358 { 4909 {
5359 v3 = v2->pFacePlane.vNormal.x; 4910 v3 = v2->pFacePlane.vNormal.x;
5360 v4 = -v2->pFacePlane.vNormal.y; 4911 v4 = -v2->pFacePlane.vNormal.y;
5377 v4 = 65536; 4928 v4 = 65536;
5378 v11 = 0; 4929 v11 = 0;
5379 v5 = -65536; 4930 v5 = -65536;
5380 LABEL_5: 4931 LABEL_5:
5381 v6 = v11; 4932 v6 = v11;
5382 v1->sTextureDeltaU = v2->sTextureDeltaU; 4933 sTextureDeltaU = v2->sTextureDeltaU;
5383 v7 = v3; 4934 v7 = v3;
5384 v8 = v1->ptr_38; 4935 v8 = ptr_38;
5385 v1->sTextureDeltaV = v2->sTextureDeltaV; 4936 sTextureDeltaV = v2->sTextureDeltaV;
5386 v8->_48616B(v4, v7, 0, 0, v5, v6); 4937 v8->_48616B(v4, v7, 0, 0, v5, v6);
5387 return 1; 4938 return 1;
5388 } 4939 }
5389 4940
5390 //----- (00479332) --------------------------------------------------------
5391 int Render::OnOutdoorRedrawSW()
5392 {
5393 signed int result; // eax@1
5394 unsigned int v1; // edi@1
5395 char *v2; // esi@2
5396 char v3; // cl@3
5397 double v4; // st7@4
5398 float v5; // ST34_4@6
5399 double v6; // ST24_8@6
5400 int v7; // eax@6
5401 unsigned int v8; // eax@11
5402 signed int v9; // eax@13
5403 Vec3_float_ *v10; // eax@14
5404 double v11; // st7@17
5405 float v12; // ST34_4@19
5406 double v13; // ST1C_8@19
5407 float v14; // [sp+4h] [bp-34h]@1
5408 float v15; // [sp+8h] [bp-30h]@1
5409 float v16; // [sp+Ch] [bp-2Ch]@1
5410
5411 v14 = (double)pOutdoor->vSunlight.x / 65536.0;
5412 result = 0;
5413 v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s];
5414 v15 = (double)pOutdoor->vSunlight.y / 65536.0;
5415 v16 = (double)pOutdoor->vSunlight.z / 65536.0;
5416 if ( v1 > (unsigned int)array_77EC08.data() )
5417 {
5418 v2 = (char *)&array_77EC08[0].pODMFace;
5419 while ( 1 )
5420 {
5421 v3 = v2[5];
5422 if ( v3 == 5 )
5423 break;
5424 if ( v3 == 1 )
5425 {
5426 v9 = pTerrainNormalIndices[((*((int *)v2 - 9) >> 15) & 1)
5427 + 2 * ((unsigned __int8)v2[9] + ((unsigned __int8)v2[8] << 7))];
5428 if ( v9 > (signed int)(uNumTerrainNormals - 1) )
5429 v10 = 0;
5430 else
5431 v10 = &pTerrainNormals[v9];
5432 if ( v10 )
5433 {
5434 v11 = -(v16 * v10->z + v15 * v10->y + v14 * v10->x);
5435 if ( v11 < 0.0 )
5436 v11 = 0.0;
5437 v12 = v11 * 31.0;
5438 v13 = v12 + 6.7553994e15;
5439 v2[4] = 31 - LOBYTE(v13);
5440 }
5441 else
5442 {
5443 v2[4] = 0;
5444 }
5445 if ( v2[4] < 0 )
5446 v2[4] = 0;
5447 goto LABEL_23;
5448 }
5449 LABEL_24:
5450 v2 += 268;
5451 if ( (unsigned int)(v2 - 84) >= v1 )
5452 return result;
5453 }
5454 v4 = (double)(signed int)(((unsigned __int64)(**(int **)v2 * (signed __int64)-pOutdoor->vSunlight.x) >> 16)
5455 + ((unsigned __int64)(*(int *)(*(int *)v2 + 4) * (signed __int64)-pOutdoor->vSunlight.y) >> 16)
5456 + ((unsigned __int64)(*(int *)(*(int *)v2 + 8) * (signed __int64)-pOutdoor->vSunlight.z) >> 16))
5457 * 0.000015258789;
5458 if ( v4 < 0.0 )
5459 v4 = 0.0;
5460 v5 = v4 * 31.0;
5461 v6 = v5 + 6.7553994e15;
5462 v7 = (int)(v2 + 4);
5463 v2[4] = 31 - LOBYTE(v6);
5464 if ( (char)(31 - LOBYTE(v6)) < 0 )
5465 *(char *)v7 = 0;
5466 if ( *(char *)v7 > 31 )
5467 *(char *)v7 = 31;
5468 if ( *(char *)(*(int *)v2 + 29) & 0x40 )
5469 {
5470 v8 = pTextureFrameTable->GetFrameTexture(
5471 *((short *)v2 - 4),
5472 pEventTimer->uTotalGameTimeElapsed);
5473 *((int *)v2 - 6) = v8 != -1 ? (int)&pBitmaps_LOD->pTextures[v8] : 0;
5474 }
5475 LABEL_23:
5476 result = 1;
5477 goto LABEL_24;
5478 }
5479 return result;
5480 }
5481 4941
5482 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) 4942 unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr)
5483 { 4943 {
5484 #pragma pack(push, 1) 4944 #pragma pack(push, 1)
5485 struct TGAHeader 4945 struct TGAHeader
5967 int v14; // ecx@6 5427 int v14; // ecx@6
5968 //int v15; // eax@8 5428 //int v15; // eax@8
5969 int v16; // eax@12 5429 int v16; // eax@12
5970 signed __int64 v17; // qtt@13 5430 signed __int64 v17; // qtt@13
5971 signed int pShading; // ecx@13 5431 signed int pShading; // ecx@13
5972 stru148 pSky; // [sp+14h] [bp-150h]@1 5432 struct Polygon pSky; // [sp+14h] [bp-150h]@1
5973 float v28; // [sp+12Ch] [bp-38h]@2 5433 float v28; // [sp+12Ch] [bp-38h]@2
5974 int v29; // [sp+130h] [bp-34h]@4 5434 int v29; // [sp+130h] [bp-34h]@4
5975 int v30; // [sp+134h] [bp-30h]@1 5435 int v30; // [sp+134h] [bp-30h]@1
5976 int v32; // [sp+13Ch] [bp-28h]@6 5436 int v32; // [sp+13Ch] [bp-28h]@6
5977 int v33; // [sp+140h] [bp-24h]@2 5437 int v33; // [sp+140h] [bp-24h]@2
6030 array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X; 5490 array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;
6031 array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y; 5491 array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;
6032 //-------------------------------------------------------------------------- 5492 //--------------------------------------------------------------------------
6033 5493
6034 //pParty->sRotationY / 2048.0f 5494 //pParty->sRotationY / 2048.0f
6035 // move sky( )--------------include----------------------------- 5495 // move sky( )--------------include-----------------------------
6036 float t = (GetTickCount() % 96000) / 96000.0f; 5496 float t = (GetTickCount() % 96000) / 96000.0f;
6037 array_50AC10[0].u = t - pParty->sRotationY / 1024.0f; 5497 array_50AC10[0].u = t - pParty->sRotationY / 1024.0f;
6038 array_50AC10[0].v = t - pParty->sRotationX / 512.0f; 5498 array_50AC10[0].v = t - pParty->sRotationX / 512.0f;
6039 5499
6040 array_50AC10[1].u = t - pParty->sRotationY / 1024.0f; 5500 array_50AC10[1].u = t - pParty->sRotationY / 1024.0f;
6138 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; 5598 array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0;
6139 array_50AC10[3].vWorldViewProjY = v38; 5599 array_50AC10[3].vWorldViewProjY = v38;
6140 5600
6141 pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]); 5601 pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]);
6142 //} 5602 //}
6143 }
6144
6145 //----- (00479A53) --------------------------------------------------------
6146 void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID)
6147 {
6148 BLVFace *pFace; // esi@1
6149 unsigned int v3; // edi@1
6150 PolygonType v4; // al@1
6151 double v5; // st7@3
6152 signed __int64 v6; // qax@3
6153 PolygonType v7; // cl@3
6154 int v8; // esi@7
6155 int v9; // eax@7
6156 unsigned int v10; // eax@7
6157 double v11; // st6@7
6158 int v12; // edx@7
6159 int v13; // eax@7
6160 char *v14; // esi@8
6161 void *v15; // ecx@9
6162 int v16; // eax@9
6163 int v17; // edi@9
6164 double v18; // st7@9
6165 signed int v19; // ebx@9
6166 void *v20; // ecx@9
6167 int v21; // ebx@11
6168 int v22; // eax@14
6169 signed __int64 v23; // qtt@16
6170 double v24; // st7@16
6171 unsigned __int8 v25; // sf@16
6172 unsigned __int8 v26; // of@16
6173 Render *v27; // ecx@17
6174 double v28; // st7@20
6175 char *v29; // ebx@20
6176 char *v30; // edx@20
6177 unsigned __int8 v31; // c0@21
6178 unsigned __int8 v32; // c3@21
6179 double v33; // st6@23
6180 char *v34; // esi@30
6181 const void *v35; // ecx@31
6182 int v36; // eax@31
6183 const void *v37; // edi@31
6184 signed __int64 v38; // qax@31
6185 int v39; // ecx@31
6186 int v40; // ebx@33
6187 int v41; // eax@36
6188 signed __int64 v42; // qtt@39
6189 int v43; // eax@39
6190 char v44; // zf@39
6191 double v45; // st7@39
6192 double v46; // st7@39
6193 unsigned int v47; // edx@40
6194 double v48; // st7@41
6195 RenderVertexSoft *v49; // ebx@41
6196 void *v50; // edi@43
6197 double v51; // st7@46
6198 RenderVertexSoft *v52; // edx@46
6199 void *v53; // edi@48
6200 char *v54; // ebx@52
6201 unsigned int v55; // eax@53
6202 unsigned int v56; // eax@55
6203 int v57; // ST10_4@55
6204 Texture *v58; // eax@55
6205 signed int v59; // [sp-4h] [bp-178h]@17
6206 stru148 *v60; // [sp+0h] [bp-174h]@17
6207 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
6208 stru148 v62; // [sp+14h] [bp-160h]@6
6209 unsigned int v63; // [sp+120h] [bp-54h]@7
6210 double v64; // [sp+124h] [bp-50h]@7
6211 unsigned int v65; // [sp+128h] [bp-4Ch]@1
6212 unsigned int v66; // [sp+12Ch] [bp-48h]@7
6213 float v67; // [sp+130h] [bp-44h]@7
6214 __int64 v68; // [sp+134h] [bp-40h]@3
6215 __int64 v69; // [sp+13Ch] [bp-38h]@3
6216 int v70; // [sp+144h] [bp-30h]@3
6217 int X; // [sp+148h] [bp-2Ch]@9
6218 int v72; // [sp+14Ch] [bp-28h]@7
6219 float v73; // [sp+150h] [bp-24h]@16
6220 unsigned int v74; // [sp+154h] [bp-20h]@3
6221 RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3
6222 float v76; // [sp+15Ch] [bp-18h]@9
6223 int v77; // [sp+160h] [bp-14h]@9
6224 int v78; // [sp+164h] [bp-10h]@7
6225 void *v79; // [sp+168h] [bp-Ch]@9
6226 float v80; // [sp+16Ch] [bp-8h]@3
6227 const void *v81; // [sp+170h] [bp-4h]@7
6228
6229 __debugbreak();
6230
6231 pFace = &pIndoor->pFaces[uFaceID];
6232 v65 = uFaceID;
6233 v3 = uNumVertices;
6234 v4 = pFace->uPolygonType;
6235 if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor )
6236 {
6237 if ( (signed int)uNumVertices > 0 )
6238 {
6239 v54 = (char *)&array_507D30[0].u;
6240 LODWORD(v80) = uNumVertices;
6241 do
6242 {
6243 v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x;
6244 *(float *)v54 = (double)v69 + *(float *)v54;
6245 *(float *)v54 = *(float *)v54 * 0.25;
6246 v55 = GetTickCount();
6247 v54 += 48;
6248 v44 = LODWORD(v80)-- == 1;
6249 v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5);
6250 *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25;
6251 }
6252 while ( !v44 );
6253 uFaceID = v65;
6254 }
6255 v56 = 8 * uFaceID;
6256 LOBYTE(v56) = PID(OBJECT_BModel,uFaceID);
6257 v57 = v56;
6258 v58 = pFace->GetTexture();
6259 pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0);
6260 return;
6261 }
6262 HIDWORD(v69) = pIndoorCamera->sRotationX;
6263 HIDWORD(v68) = pIndoorCamera->pos.z;
6264 *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY;
6265 v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z)
6266 / (((double)pBLVRenderParams->field_40 + 16192.0)
6267 * 65536.0)
6268 + *(float *)&v74);
6269 v5 = (double)pIndoorCamera->sRotationX * 0.0030664064;
6270 *(float *)&v75 = v5;
6271 v80 = cos(v5) * 16192.0;
6272 v6 = (signed __int64)(*(float *)&v74
6273 - (double)pBLVRenderParams->field_40
6274 / ((v80 + 0.0000001)
6275 * 65535.0)
6276 * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68)));
6277 v7 = pFace->uPolygonType;
6278 if ( v7 == 4 || v7 == 3 )
6279 v70 = v6;
6280 stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0);
6281 v62._48607B(&stru_8019C8);
6282 v62.uTileBitmapID = pFace->uBitmapID;
6283 v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0);
6284 if ( !v62.pTexture )
6285 return;
6286 v8 = pBLVRenderParams->sPartyRotX;
6287 v62.dimming_level = 0;
6288 v62.uNumVertices = v3;
6289 v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16);
6290 v62.v_18.y = 0;
6291 v62.v_18.x = -v9;
6292 v62.v_18.z = -stru_5C6E00->Cos(v8 + 16);
6293 v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX;
6294 memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3]));
6295 LODWORD(v80) = v10;
6296 v62.field_24 = 33554432;
6297 v64 = (double)(signed int)v10 * 0.5;
6298 v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5);
6299 LODWORD(v80) = v62.pTexture->uTextureWidth;
6300 v11 = 1.0 / (double)SLODWORD(v80);
6301 LODWORD(v80) = v62.pTexture->uTextureHeight;
6302 v12 = v62.pTexture->uWidthMinus1;
6303 v13 = v62.pTexture->uHeightMinus1;
6304 v67 = v11;
6305 v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13;
6306 v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12;
6307 v78 = 0;
6308 v81 = 0;
6309 *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80);
6310 if ( (signed int)v62.uNumVertices <= 0 )
6311 {
6312 LABEL_17:
6313 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
6314 v27 = pRenderer;
6315 v60 = &v62;
6316 v59 = v62.uNumVertices;
6317 goto LABEL_18;
6318 }
6319 v14 = (char *)&array_507D30[0].vWorldViewProjY;
6320 while ( 2 )
6321 {
6322 v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14));
6323 LODWORD(v80) = v62.ptr_38->field_14;
6324 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
6325 v16 = v77 + v62.ptr_38->field_C;
6326 v77 = (int)v15;
6327 v74 = v16;
6328 LODWORD(v80) = v62.ptr_38->field_20;
6329 v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16;
6330 v79 = v15;
6331 v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18);
6332 LODWORD(v80) = v62.v_18.z;
6333 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16);
6334 v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1));
6335 v18 = *(float *)v14 - 1.0;
6336 v19 = -v62.field_24;
6337 v77 = -v62.field_24;
6338 X = (int)((char *)v79 + v62.v_18.x);
6339 LODWORD(v76) = (signed __int64)v18;
6340 v20 = (void *)(v72 * (v70 - LODWORD(v76)));
6341 while ( 1 )
6342 {
6343 v79 = v20;
6344 if ( !X )
6345 goto LABEL_14;
6346 v21 = abs(v19 >> 14);
6347 if ( v21 <= abs(X) )
6348 break;
6349 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
6350 break;
6351 v19 = v77;
6352 v20 = v79;
6353 LABEL_14:
6354 LODWORD(v80) = v62.v_18.z;
6355 v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16);
6356 v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16;
6357 --LODWORD(v76);
6358 v20 = (char *)v20 + v72;
6359 X = v22 + v62.v_18.x;
6360 v78 = 1;
6361 }
6362 if ( !v78 )
6363 {
6364 LODWORD(v23) = v77 << 16;
6365 HIDWORD(v23) = v77 >> 16;
6366 v79 = (void *)(v23 / X);
6367 v77 = v17;
6368 LODWORD(v80) = v62.ptr_38->field_10;
6369 v77 = v17;
6370 LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16);
6371 LODWORD(v80) = v62.ptr_38->field_1C;
6372 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16));
6373 v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16;
6374 LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16;
6375 v14 += 48;
6376 LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4);
6377 v81 = (char *)v81 + 1;
6378 v24 = (double)SLODWORD(v80) * 0.000015259022;
6379 LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4);
6380 v26 = __OFSUB__((int)v81, v62.uNumVertices);
6381 v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0;
6382 *((float *)v14 - 10) = v24 * v67;
6383 *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1);
6384 *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79;
6385 if ( !(v25 ^ v26) )
6386 goto LABEL_17;
6387 continue;
6388 }
6389 break;
6390 }
6391 LODWORD(v73) = 0;
6392 v80 = v76;
6393 if ( (signed int)v62.uNumVertices > 0 )
6394 {
6395 v28 = (double)SLODWORD(v76);
6396 LODWORD(v76) = (int)(char *)array_50AC10 + 28;
6397 v29 = (char *)&array_50AC10[0].vWorldViewProjX;
6398 v30 = (char *)&array_507D30[1].vWorldViewProjY;
6399 v79 = array_50AC10;
6400 v81 = array_507D30;
6401 v78 = v62.uNumVertices;
6402 do
6403 {
6404 v31 = v28 < *((float *)v30 - 12);
6405 v32 = v28 == *((float *)v30 - 12);
6406 ++LODWORD(v73);
6407 memcpy(v79, v81, 0x30u);
6408 v79 = (char *)v79 + 48;
6409 LODWORD(v76) += 48;
6410 v29 += 48;
6411 if ( v31 | v32 || v28 >= *(float *)v30 )
6412 {
6413 if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 )
6414 goto LABEL_28;
6415 v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12))
6416 + *((float *)v30 - 1);
6417 }
6418 else
6419 {
6420 v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30)
6421 + *((float *)v30 - 13);
6422 }
6423 *(float *)v29 = v33;
6424 v79 = (char *)v79 + 48;
6425 v29 += 48;
6426 ++LODWORD(v73);
6427 *(unsigned int *)LODWORD(v76) = v28;
6428 LODWORD(v76) += 48;
6429 LABEL_28:
6430 v81 = (char *)v81 + 48;
6431 v30 += 48;
6432 --v78;
6433 }
6434 while ( v78 );
6435 }
6436 if ( SLODWORD(v73) <= 0 )
6437 goto LABEL_40;
6438 v34 = (char *)&array_50AC10[0].vWorldViewProjY;
6439 v65 = v77 >> 14;
6440 HIDWORD(v69) = LODWORD(v73);
6441 do
6442 {
6443 v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34));
6444 v78 = v62.ptr_38->field_14;
6445 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
6446 v36 = (int)((char *)v81 + v62.ptr_38->field_C);
6447 v81 = v35;
6448 v74 = v36;
6449 v78 = v62.ptr_38->field_20;
6450 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16);
6451 v78 = (int)v35;
6452 v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18);
6453 v81 = (const void *)v62.v_18.z;
6454 v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16;
6455 v37 = (const void *)(v72
6456 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1)));
6457 v38 = (signed __int64)(*(float *)v34 - 1.0);
6458 v81 = 0;
6459 LODWORD(v76) = v38;
6460 v39 = v72 * (v70 - v38);
6461 while ( 1 )
6462 {
6463 v78 = v39;
6464 if ( !X )
6465 goto LABEL_36;
6466 v40 = abs(X);
6467 if ( abs((signed __int64)v65) <= v40 )
6468 break;
6469 if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y )
6470 break;
6471 v39 = v78;
6472 LABEL_36:
6473 v78 = v62.v_18.z;
6474 v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16;
6475 --LODWORD(v76);
6476 v39 += v72;
6477 X = v41 + v62.v_18.x;
6478 v81 = (const void *)1;
6479 }
6480 if ( v81 )
6481 {
6482 v79 = (void *)v62.v_18.z;
6483 v78 = 2 * LODWORD(v76);
6484 v81 = (const void *)((unsigned __int64)(v62.v_18.z
6485 * (signed __int64)(signed int)(signed __int64)(((double)v70
6486 - ((double)(2 * LODWORD(v76))
6487 - *(float *)v34))
6488 * (double)v72)) >> 16);
6489 X = (int)((char *)v81 + v62.v_18.x);
6490 }
6491 LODWORD(v42) = v77 << 16;
6492 HIDWORD(v42) = v77 >> 16;
6493 v79 = (void *)(v42 / X);
6494 v81 = v37;
6495 v78 = v62.ptr_38->field_10;
6496 v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
6497 v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16);
6498 v74 = (unsigned int)v37;
6499 LODWORD(v76) = v43;
6500 v78 = v62.ptr_38->field_1C;
6501 v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16));
6502 v74 = (unsigned __int64)(v43 * v42 / X) >> 16;
6503 v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16);
6504 v34 += 48;
6505 v78 = v66 + ((signed int)v74 >> 4);
6506 v44 = HIDWORD(v69)-- == 1;
6507 v45 = (double)v78 * 0.000015259022;
6508 v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4);
6509 *((float *)v34 - 10) = v45 * v67;
6510 *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1);
6511 v46 = (double)(signed int)v79;
6512 *((float *)v34 - 16) = 0.000015258789 * v46;
6513 *((float *)v34 - 11) = 65536.0 / v46;
6514 }
6515 while ( !v44 );
6516 LABEL_40:
6517 v47 = 0;
6518 if ( SLODWORD(v73) > 0 )
6519 {
6520 v48 = (double)SLODWORD(v80);
6521 v75 = array_507D30;
6522 v49 = array_50AC10;
6523 HIDWORD(v69) = LODWORD(v73);
6524 do
6525 {
6526 if ( v48 >= v49->vWorldViewProjY )
6527 {
6528 v50 = v75;
6529 ++v47;
6530 ++v75;
6531 memcpy(v50, v49, 0x30u);
6532 }
6533 ++v49;
6534 --HIDWORD(v69);
6535 }
6536 while ( HIDWORD(v69) );
6537 }
6538 v62.uNumVertices = v47;
6539 pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]);
6540 *(float *)&v74 = 0.0;
6541 if ( SLODWORD(v73) > 0 )
6542 {
6543 v51 = (double)SLODWORD(v80);
6544 v75 = array_507D30;
6545 v52 = array_50AC10;
6546 v80 = v73;
6547 do
6548 {
6549 if ( v51 <= v52->vWorldViewProjY )
6550 {
6551 v53 = v75;
6552 ++v74;
6553 ++v75;
6554 memcpy(v53, v52, 0x30u);
6555 }
6556 ++v52;
6557 --LODWORD(v80);
6558 }
6559 while ( v80 != 0.0 );
6560 }
6561 v62.uNumVertices = v74;
6562 v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID];
6563 v60 = &v62;
6564 v59 = v74;
6565 v27 = pRenderer;
6566 LABEL_18:
6567 v27->_4A2ED5(v59, v60, v61);
6568 } 5603 }
6569 5604
6570 //----- (0047A384) -------------------------------------------------------- 5605 //----- (0047A384) --------------------------------------------------------
6571 void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa) 5606 void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa)
6572 { 5607 {
6809 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); 5844 return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1);
6810 } 5845 }
6811 v7 = 0; 5846 v7 = 0;
6812 return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); 5847 return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1);
6813 } 5848 }
6814 // 6BE030: using guessed type int day_attrib;
6815 // 6BE040: using guessed type int day_fogrange_1;
6816 // 6BE044: using guessed type int day_fogrange_2;
6817
6818 //----- (0047BEB1) --------------------------------------------------------
6819 int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8)
6820 {
6821 stru148 *v8; // ebx@1
6822 signed int v9; // edx@1
6823 int v10; // eax@5
6824 signed int v11; // eax@9
6825 signed int v12; // eax@15
6826 signed __int64 v13; // qtt@21
6827 int *v14; // ecx@30
6828 int *v15; // edi@30
6829 int v16; // ebx@32
6830 signed __int64 v17; // qtt@37
6831 double v18; // ST10_8@37
6832 double v19; // ST10_8@38
6833 int v20; // edi@39
6834 int result; // eax@46
6835 int *v22; // eax@48
6836 signed int v23; // edx@51
6837 signed __int64 v24; // qtt@51
6838 int v25; // ecx@51
6839 signed int v26; // [sp+14h] [bp-4h]@1
6840 float v27; // [sp+28h] [bp+10h]@37
6841 float v28; // [sp+28h] [bp+10h]@38
6842 int v29; // [sp+2Ch] [bp+14h]@37
6843
6844 v8 = a2;
6845 v9 = a1;
6846 v26 = a1;
6847 if ( pParty->armageddon_timer )
6848 {
6849 *a5 = -1;
6850 *a6 = -1;
6851 *(char *)a7 = 1;
6852 LABEL_46:
6853 result = a8;
6854 *(char *)a8 = 0;
6855 return result;
6856 }
6857 if ( a1 < 0 )
6858 {
6859 v26 = v8->field_34 << 16;
6860 v9 = v8->field_34 << 16;
6861 }
6862 v10 = pWeather->bNight;
6863 if ( bUnderwater == 1 )
6864 v10 = 0;
6865 if ( !v10 )
6866 {
6867 if ( !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater )
6868 {
6869 v14 = a5;
6870 v15 = a6;
6871 if ( !v9 )
6872 {
6873 *a5 = 31;
6874 *a6 = -1;
6875 }
6876 v16 = v8->dimming_level - terrain_gamma;
6877 if ( v16 >= 0 )
6878 {
6879 if ( v16 > 27 )
6880 v16 = 27;
6881 }
6882 else
6883 {
6884 v16 = 0;
6885 }
6886 *a6 = 27;
6887 if ( a4 )
6888 {
6889 v28 = pOutdoor->fFogDensity * 27.0;
6890 v19 = v28 + 6.7553994e15;
6891 v29 = LODWORD(v19);
6892 }
6893 else
6894 {
6895 LODWORD(v17) = v9 << 16;
6896 HIDWORD(v17) = v9 >> 16;
6897 v27 = (double)(signed int)(((unsigned __int64)(v17 / (pOutdoorCamera->shading_dist_shade << 16) * (31 - *a6)) >> 16)
6898 + *a6)
6899 * pOutdoor->fFogDensity;
6900 v18 = v27 + 6.7553994e15;
6901 v29 = LODWORD(v18);
6902 }
6903 *v14 = v16 + v29;
6904 v20 = *v15;
6905 if ( v16 + v29 > v20 )
6906 *v14 = v20;
6907 if ( *v14 < v16 )
6908 *v14 = v16;
6909 if ( *v14 > pOutdoor->max_terrain_dimming_level )
6910 *v14 = pOutdoor->max_terrain_dimming_level;
6911 goto LABEL_45;
6912 }
6913 if ( v9 >= day_fogrange_1 << 16 )
6914 {
6915 if ( v9 <= day_fogrange_2 << 16 )
6916 {
6917 v23 = v9 - (day_fogrange_1 << 16);
6918 LODWORD(v24) = v23 << 16;
6919 HIDWORD(v24) = v23 >> 16;
6920 v25 = (unsigned __int64)(27 * v24 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16;
6921 v22 = a5;
6922 *a5 = v25;
6923 if ( v25 > 27 )
6924 goto LABEL_54;
6925 v9 = v26;
6926 }
6927 else
6928 {
6929 v22 = a5;
6930 *a5 = 27;
6931 }
6932 }
6933 else
6934 {
6935 v22 = a5;
6936 *a5 = 0;
6937 }
6938 if ( v9 )
6939 {
6940 LABEL_55:
6941 if ( a4 )
6942 *v22 = 31;
6943 *a6 = 31;
6944 *(char *)a7 = 0;
6945 goto LABEL_59;
6946 }
6947 LABEL_54:
6948 *v22 = 27;
6949 goto LABEL_55;
6950 }
6951 if ( v10 == 1 )
6952 {
6953 v11 = 1;
6954 if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x10 )
6955 {
6956 v12 = 0;
6957 }
6958 else
6959 {
6960 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 )
6961 {
6962 if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime <= 0 )
6963 v11 = 0;
6964 else
6965 v11 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower;
6966 }
6967 v12 = v11 << 26;
6968 }
6969 if ( a4 )
6970 goto LABEL_24;
6971 if ( v9 <= v12 )
6972 {
6973 if ( v9 > 0 )
6974 {
6975 LODWORD(v13) = v9 << 16;
6976 HIDWORD(v13) = v9 >> 16;
6977 v9 = v26;
6978 *a5 = (unsigned __int64)(27 * v13 / v12) >> 16;
6979 }
6980 if ( *a5 > 27 )
6981 goto LABEL_24;
6982 }
6983 else
6984 {
6985 *a5 = 27;
6986 }
6987 if ( v9 )
6988 {
6989 LABEL_25:
6990 if ( v8->field_32 & 4 )
6991 *a5 = 27;
6992 *a6 = 27;
6993 LABEL_45:
6994 *(char *)a7 = 0;
6995 goto LABEL_46;
6996 }
6997 LABEL_24:
6998 *a5 = 27;
6999 goto LABEL_25;
7000 }
7001 *a5 = -1;
7002 *a6 = -1;
7003 *(char *)a7 = 1;
7004 LABEL_59:
7005 result = a8;
7006 *(char *)a8 = 1;
7007 return result;
7008 }
7009
7010 //----- (0047C178) --------------------------------------------------------
7011 void *__fastcall sr_sub_47C178(signed int a1, stru148 *a2, int terrain_gamma, int a4)
7012 {
7013 stru148 *v4; // esi@1
7014 void *result; // eax@2
7015 int v6; // [sp+4h] [bp-8h]@3
7016 int v7; // [sp+8h] [bp-4h]@3
7017
7018 v4 = a2;
7019 if ( pParty->armageddon_timer )
7020 {
7021 result = PaletteManager::Get(a2->pTexture->palette_id2);
7022 }
7023 else
7024 {
7025 sr_sub_47BEB1(a1, a2, terrain_gamma, a4, &v6, &v7, (int)((char *)&terrain_gamma + 3), (int)((char *)&a4 + 3));
7026 result = sr_sub_47C1CA(v4, SBYTE3(a4), v6, v7);
7027 }
7028 return result;
7029 }
7030
7031 //----- (0047C1CA) --------------------------------------------------------
7032 void *__fastcall sr_sub_47C1CA(stru148 *a1, char a2, int a3, signed int a4)
7033 {
7034 stru148 *v4; // esi@1
7035 void *result; // eax@2
7036 int v6; // edx@3
7037 int v7; // ecx@8
7038 int a3a; // [sp+4h] [bp-8h]@1
7039 char v9; // [sp+8h] [bp-4h]@1
7040
7041 v9 = a2;
7042 v4 = a1;
7043 a3a = 1;
7044 if ( pParty->armageddon_timer )
7045 {
7046 result = PaletteManager::Get(a1->pTexture->palette_id2);
7047 }
7048 else
7049 {
7050 v6 = pGame->_44EC23(a1, &a3a, a4);
7051 if ( v6 == -1 )
7052 v6 = a3;
7053 if ( v9 == 1 )
7054 {
7055 if ( v6 != -1 || a4 != -1 )
7056 {
7057 v7 = v4->pTexture->palette_id2;
7058 }
7059 else
7060 {
7061 v6 = 0;
7062 v7 = 0;
7063 }
7064 result = PaletteManager::Get_Mist_or_Red_LUT(v7, v6, a3a);
7065 }
7066 else
7067 {
7068 result = PaletteManager::Get_Dark_or_Red_LUT(v4->pTexture->palette_id2, v6, a3a);
7069 }
7070 }
7071 return result;
7072 }
7073
7074 //----- (0047C24C) --------------------------------------------------------
7075 unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4)
7076 {
7077 int v4; // esi@1
7078 int v5; // eax@2
7079 int a3a; // [sp+4h] [bp-4h]@1
7080
7081 v4 = a2;
7082 a3a = 1;
7083 if ( a4 )
7084 {
7085 v5 = pGame->_44ED0A(a1, &a3a, 31);
7086 if ( v5 != -1 )
7087 a3 = v5;
7088 }
7089 return PaletteManager::Get_Dark_or_Red_LUT(v4, a3, a3a);
7090 }
7091
7092 //----- (0047C28C) --------------------------------------------------------
7093 char *__fastcall sr_sub_47C28C_get_palette(stru148 *a1, char a2, signed int a3, signed int a4)
7094 {
7095 stru148 *v4; // esi@1
7096 char *result; // eax@2
7097 signed int v6; // eax@3
7098 int v7; // ecx@8
7099 int a2a; // [sp+4h] [bp-8h]@1
7100 char v9; // [sp+8h] [bp-4h]@1
7101
7102 v9 = a2;
7103 v4 = a1;
7104 a2a = 1;
7105 if ( pParty->armageddon_timer )
7106 {
7107 result = (char *)pPaletteManager->field_199600_palettes[a1->pTexture->palette_id2];
7108 }
7109 else
7110 {
7111 v6 = pGame->_44EC23(a1, &a2a, a4);
7112 if ( v6 != -1 )
7113 a3 = v6;
7114 if ( v9 == 1 )
7115 {
7116 if ( a3 != -1 || a4 != -1 )
7117 v7 = v4->pTexture->palette_id2;
7118 else
7119 v7 = 0;
7120 result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a);
7121 }
7122 else
7123 {
7124 result = (char *)PaletteManager::_47C33F_get_palette(v4->pTexture->palette_id2, a2a);
7125 }
7126 }
7127 return result;
7128 }
7129 // 4D864C: using guessed type char byte_4D864C;
7130 5849
7131 //----- (0047C370) -------------------------------------------------------- 5850 //----- (0047C370) --------------------------------------------------------
7132 unsigned int __cdecl GetLevelFogColor() 5851 unsigned int __cdecl GetLevelFogColor()
7133 { 5852 {
7134 unsigned int result; // eax@2 5853 unsigned int result; // eax@2
7443 } 6162 }
7444 //while ( (signed int)v4 < (signed int)arary_77E5C8 ); 6163 //while ( (signed int)v4 < (signed int)arary_77E5C8 );
7445 } 6164 }
7446 6165
7447 //----- (004811A3) -------------------------------------------------------- 6166 //----- (004811A3) --------------------------------------------------------
7448 void stru148::DrawBorderTiles() 6167 void Polygon::DrawBorderTiles()
7449 { 6168 {
7450 //__debugbreak(); 6169 //__debugbreak();
7451 6170
7452 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); 6171 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false);
7453 pRenderer->DrawTerrainPolygon(uNumVertices, this, 6172 pRenderer->DrawTerrainPolygon(uNumVertices, this,
7455 6174
7456 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); 6175 pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true);
7457 //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true); 6176 //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true);
7458 } 6177 }
7459 6178
7460 //----- (00481DB2) --------------------------------------------------------
7461 char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, stru148 *a3)
7462 {
7463 int v3; // eax@2
7464 int v4; // esi@2
7465 signed int v5; // esi@2
7466 char *v6; // edi@3
7467 double v7; // ST14_8@4
7468 double v8; // ST0C_8@4
7469 char result; // al@5
7470
7471 if ( a2 >= 3 )
7472 {
7473 v3 = a3->uTileBitmapID;
7474 v4 = a3->uTileBitmapID;
7475 a3->ptr_38 = &stru_8019C8;
7476 a3->pTexture = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0);
7477 v5 = 0;
7478 if ( (signed int)a3->uNumVertices > 0 )
7479 {
7480 v6 = (char *)&array_508690[0].vWorldViewProjY;
7481 do
7482 {
7483 v7 = *((float *)v6 - 1) + 6.7553994e15;
7484 dword_50B638[v5] = LODWORD(v7);
7485 v8 = *(float *)v6 + 6.7553994e15;
7486 v6 += 48;
7487 dword_50B570[v5++] = LODWORD(v8);
7488 }
7489 while ( v5 < (signed int)a3->uNumVertices );
7490 }
7491 result = sr_sub_486B4E_push_outdoor_edges(a1, dword_50B638.data(), dword_50B570.data(), a3);
7492 }
7493 return result;
7494 }
7495 // 50B570: using guessed type int dword_50B570[];
7496 // 50B638: using guessed type int dword_50B638[];
7497 6179
7498 //----- (00481EB7) -------------------------------------------------------- 6180 //----- (00481EB7) --------------------------------------------------------
7499 void __cdecl ResetStru148s() 6181 void __cdecl ResetPolygons()
7500 { 6182 {
7501 int v0; // ecx@1 6183 int v0; // ecx@1
7502 char *v1; // eax@2 6184 char *v1; // eax@2
7503 6185
7504 v0 = pOutdoorCamera->numStru148s; 6186 v0 = pOutdoorCamera->uNumPolygons;
7505 if ( pOutdoorCamera->numStru148s > 0 ) 6187 if ( pOutdoorCamera->uNumPolygons > 0 )
7506 { 6188 {
7507 v1 = (char *)&array_77EC08[0].prolly_tail; 6189 v1 = (char *)&array_77EC08[0].prolly_tail;
7508 do 6190 do
7509 { 6191 {
7510 *((int *)v1 - 1) = 0; 6192 *((int *)v1 - 1) = 0;
7519 6201
7520 //----- (00481ED9) -------------------------------------------------------- 6202 //----- (00481ED9) --------------------------------------------------------
7521 void __cdecl sub_481ED9_MessWithOutdoorCamera() 6203 void __cdecl sub_481ED9_MessWithOutdoorCamera()
7522 { 6204 {
7523 stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0); 6205 stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0);
7524 pOutdoorCamera->numStru148s = 0; 6206 pOutdoorCamera->uNumPolygons = 0;
7525 pOutdoorCamera->uNumEdges = 0; 6207 pOutdoorCamera->uNumEdges = 0;
7526 pOutdoorCamera->uNumSpans = 0; 6208 pOutdoorCamera->uNumSpans = 0;
7527 pOutdoorCamera->uNumSurfs = 0; 6209 pOutdoorCamera->uNumSurfs = 0;
7528 pOutdoorCamera->uNumBillboards = 0; 6210 pOutdoorCamera->uNumBillboards = 0;
7529 pOutdoorCamera->field_44 = 0; 6211 pOutdoorCamera->field_44 = 0;
7559 v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), 6241 v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1),
7560 !(v13 & v14 & v15 & v12)); 6242 !(v13 & v14 & v15 & v12));
7561 } 6243 }
7562 6244
7563 //----- (00481FC9) -------------------------------------------------------- 6245 //----- (00481FC9) --------------------------------------------------------
7564 int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4)//Rotate camera 6246 int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera
7565 { 6247 {
7566 float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; 6248 float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14;
7567 6249
7568 if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) 6250 if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y)
7569 a4->flags |= 0x10; 6251 a4->flags |= 0x10;
7759 } 6441 }
7760 else 6442 else
7761 return y_x1z1; 6443 return y_x1z1;
7762 } 6444 }
7763 6445
7764 //----- (0048276F) --------------------------------------------------------
7765 void stru148::_48276F_sr()
7766 {
7767 unsigned int v1; // ebx@1
7768 float v2; // edx@2
7769 double v3; // st7@2
7770 char *v4; // ecx@3
7771 float v5; // eax@5
7772 float v6; // eax@7
7773 float v7; // eax@9
7774 float v8; // ecx@13
7775 int i; // eax@16
7776 int v10; // edx@20
7777 RenderVertexSoft *v11; // ecx@22
7778 RenderVertexSoft *v12; // edx@22
7779 RenderVertexSoft *v13; // esi@22
7780 int v14; // ebx@26
7781 RenderVertexSoft *v15; // ebx@27
7782 double v16; // st6@28
7783 double v17; // st5@28
7784 double v18; // st4@28
7785 int v19; // [sp+4h] [bp-2Ch]@20
7786 int v20; // [sp+8h] [bp-28h]@22
7787 int v21; // [sp+Ch] [bp-24h]@22
7788 stru148 *v22; // [sp+10h] [bp-20h]@1
7789 float v23; // [sp+14h] [bp-1Ch]@11
7790 float v24; // [sp+18h] [bp-18h]@7
7791 float v25; // [sp+1Ch] [bp-14h]@5
7792 float v26; // [sp+20h] [bp-10h]@2
7793 float v27; // [sp+24h] [bp-Ch]@2
7794 float v28; // [sp+28h] [bp-8h]@2
7795 float v29; // [sp+2Ch] [bp-4h]@9
7796
7797 v1 = this->uNumVertices;
7798 v22 = this;
7799 if ( (signed int)v1 >= 3 )
7800 {
7801 LODWORD(v2) = 0;
7802 v26 = 10000.0;
7803 v28 = 10000.0;
7804 v3 = -10000.0;
7805 v27 = -10000.0;
7806 if ( (signed int)v1 > 0 )
7807 {
7808 v4 = (char *)&array_508690[0].vWorldViewProjY;
7809 do
7810 {
7811 if ( *((float *)v4 - 1) < (double)v26 )
7812 {
7813 LODWORD(v5) = *((int *)v4 - 1);
7814 v25 = v2;
7815 v26 = v5;
7816 }
7817 if ( *((float *)v4 - 1) > (double)v27 )
7818 {
7819 LODWORD(v6) = *((int *)v4 - 1);
7820 v24 = v2;
7821 v27 = v6;
7822 }
7823 if ( *(float *)v4 < (double)v28 )
7824 {
7825 LODWORD(v7) = *(int *)v4;
7826 v29 = v2;
7827 v28 = v7;
7828 }
7829 if ( v3 < *(float *)v4 )
7830 {
7831 v3 = *(float *)v4;
7832 v23 = v2;
7833 }
7834 ++LODWORD(v2);
7835 v4 += 48;
7836 }
7837 while ( SLODWORD(v2) < (signed int)v1 );
7838 }
7839 v8 = v29;
7840 if ( LODWORD(v29) == LODWORD(v25) || LODWORD(v29) == LODWORD(v24) )
7841 v8 = v23;
7842 v29 = 0.0;
7843 for ( i = 0; i < (signed int)v1; ++i )
7844 {
7845 if ( i == LODWORD(v25) || i == LODWORD(v24) || i == LODWORD(v8) )
7846 {
7847 v10 = LODWORD(v29)++;
7848 *(&v19 + v10) = i;
7849 }
7850 }
7851 v11 = &array_508690[v19];
7852 v12 = &array_508690[v20];
7853 v13 = &array_508690[v21];
7854 if ( LODWORD(v29) != 3 )
7855 {
7856 v11 = array_508690;
7857 v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3));
7858 v12 = &array_508690[1];
7859 v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x;
7860 v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y;
7861 v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z;
7862 v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x;
7863 v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y;
7864 v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z;
7865 if ( v24 * v27 - v25 * v29 == 0.0 )
7866 {
7867 if ( v26 * v29 - v24 * v28 == 0.0 )
7868 {
7869 if ( v25 * v28 - v26 * v27 == 0.0 )
7870 {
7871 v14 = v1 - 2;
7872 LODWORD(v26) = v14;
7873 if ( v14 >= 2 )
7874 {
7875 v15 = &array_508690[v14];
7876 do
7877 {
7878 v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x;
7879 v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y;
7880 v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z;
7881 v13 = v15;
7882 if ( v27 * v18 - v17 * v29 != 0.0 )
7883 break;
7884 if ( v16 * v29 - v18 * v28 != 0.0 )
7885 break;
7886 if ( v28 * v17 - v16 * v27 != 0.0 )
7887 break;
7888 --LODWORD(v26);
7889 --v15;
7890 }
7891 while ( SLODWORD(v26) >= 2 );
7892 }
7893 }
7894 }
7895 }
7896 }
7897 sr_sub_4829B9(v11, v12, v13, v22, 1);
7898 }
7899 }
7900
7901 //----- (004829B9) --------------------------------------------------------
7902 stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5)
7903 {
7904 double v5; // st7@1
7905 RenderVertexSoft *v6; // esi@1
7906 double v7; // st6@1
7907 stru148 *result; // eax@3
7908 double v9; // st6@3
7909 double v10; // st5@3
7910 float v11; // ST0C_4@3
7911 float v12; // ST04_4@3
7912 double v13; // st4@3
7913 float v14; // [sp+8h] [bp-Ch]@1
7914 float v15; // [sp+10h] [bp-4h]@1
7915 float v16; // [sp+1Ch] [bp+8h]@1
7916 float v17; // [sp+1Ch] [bp+8h]@3
7917
7918 v5 = a2->vWorldViewProjX - a1->vWorldViewProjX;
7919 v6 = a3;
7920 v16 = a3->vWorldViewProjY - a1->vWorldViewProjY;
7921 v15 = a2->vWorldViewProjY - a1->vWorldViewProjY;
7922 v14 = v6->vWorldViewProjX - a1->vWorldViewProjX;
7923 v7 = v16 * v5 - v14 * v15;
7924 if ( v7 == 0.0 )
7925 v7 = 0.0000001;
7926 result = a4;
7927 v9 = 1.0 / v7;
7928 v10 = 1.0 / a1->vWorldViewPosition.x;
7929 v11 = 1.0 / a2->vWorldViewPosition.x - v10;
7930 v12 = 1.0 / v6->vWorldViewPosition.x - v10;
7931 v13 = (v11 * v16 - v12 * v15) * v9;
7932 v17 = (v11 * v14 - v12 * v5) * -v9;
7933 a4->field_C = a1->vWorldViewProjX;
7934 a4->field_10 = a1->vWorldViewProjY;
7935 a4->field_0 = v10;
7936 a4->field_8 = v17;
7937 a4->field_4 = v13;
7938 return result;
7939 }
7940
7941 //----- (00482A90) -------------------------------------------------------- 6446 //----- (00482A90) --------------------------------------------------------
7942 signed int __cdecl const_1_0() 6447 signed int __cdecl const_1_0()
7943 { 6448 {
7944 return 1; 6449 return 1;
7945 } 6450 }
7946 6451
7947 //----- (00482A94) -------------------------------------------------------- 6452
7948 int sr_sub_482A94(Span *_this) 6453
7949 { 6454
7950 stru315 *v1; // ebp@0
7951 Span *v2; // edi@1
7952 stru148 *v3; // esi@1
7953 int v4; // ecx@1
7954 stru149 *v5; // eax@1
7955 stru149 *v6; // eax@1
7956 int v7; // edx@1
7957 int v8; // eax@1
7958 int v9; // ecx@1
7959 int v10; // edx@1
7960 int v11; // ebx@1
7961 int v12; // eax@1
7962 signed int v13; // ebx@1
7963 int v14; // ebx@2
7964 signed __int64 v15; // qtt@3
7965 stru149 *v16; // eax@3
7966 signed int v17; // ebx@3
7967 Texture *v18; // eax@14
7968 unsigned __int16 *v19; // eax@15
7969 stru149 *v20; // eax@21
7970 signed int v21; // eax@21
7971 int v22; // eax@21
7972 int v23; // ecx@21
7973 Texture *v24; // edx@21
7974 signed int v25; // eax@21
7975 signed int v27; // [sp-4h] [bp-A4h]@8
7976 int v28; // [sp+Ch] [bp-94h]@1
7977 int v29; // [sp+10h] [bp-90h]@1
7978 stru316 a2; // [sp+14h] [bp-8Ch]@21
7979 stru315 a1; // [sp+3Ch] [bp-64h]@1
7980 int v32; // [sp+80h] [bp-20h]@1
7981 int v33; // [sp+84h] [bp-1Ch]@1
7982 int v34; // [sp+88h] [bp-18h]@1
7983 int v35; // [sp+8Ch] [bp-14h]@1
7984 int v36; // [sp+90h] [bp-10h]@1
7985 int v37; // [sp+94h] [bp-Ch]@1
7986 int v38; // [sp+98h] [bp-8h]@1
7987 int X; // [sp+9Ch] [bp-4h]@1
7988
7989 v2 = _this;
7990 v3 = _this->pParent;
7991 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
7992 v5 = v3->ptr_38;
7993 v38 = v4;
7994 v37 = v5->field_14;
7995 v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
7996 v6 = v3->ptr_38;
7997 v7 = v38 + v6->field_C;
7998 v37 = v6->field_20;
7999 v33 = v7;
8000 v8 = ((unsigned __int64)(v37 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
8001 v38 = v4;
8002 v34 = v8;
8003 v37 = v3->v_18.z;
8004 v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16;
8005 v9 = v3->v_18.x;
8006 v28 = v3->sTextureDeltaU << 16;
8007 v35 = v3->sTextureDeltaV << 16;
8008 v10 = v2->field_8;
8009 v29 = pOutdoorCamera->camera_rotation_y_int_sine;
8010 v32 = pOutdoorCamera->camera_rotation_y_int_cosine;
8011 a1.field_28 = v2->field_C;
8012 v11 = v3->field_24;
8013 v37 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v10);
8014 v12 = v3->v_18.y;
8015 v13 = -v11;
8016 v36 = v13;
8017 X = ((unsigned __int64)(v37 * (signed __int64)v12) >> 16) + v38 + v9;
8018 if ( !X || (v14 = abs(v13 >> 14), v14 > abs(X)) )
8019 return 0;
8020 LODWORD(v15) = v36 << 16;
8021 HIDWORD(v15) = v36 >> 16;
8022 v38 = v15 / X;
8023 v16 = v3->ptr_38;
8024 X = v37;
8025 v36 = v16->field_10;
8026 X = v37;
8027 v36 = v33 + ((unsigned __int64)(v36 * (signed __int64)v37) >> 16);
8028 v33 = v3->ptr_38->field_1C;
8029 X = (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
8030 v34 += (unsigned __int64)(v33 * (signed __int64)v37) >> 16;
8031 v17 = 2;
8032 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
8033 if ( v38 >= mipmapping_building_mm1 << 16 )
8034 {
8035 if ( v38 >= mipmapping_building_mm2 << 16 )
8036 {
8037 if ( v38 >= mipmapping_building_mm3 << 16 )
8038 {
8039 if ( bUseLoResSprites )
8040 goto LABEL_12;
8041 v27 = 3;
8042 }
8043 else
8044 {
8045 v27 = 2;
8046 }
8047 v17 = v27;
8048 goto LABEL_12;
8049 }
8050 v17 = 1;
8051 }
8052 else
8053 {
8054 v17 = 0;
8055 }
8056 LABEL_12:
8057 if ( v17 < (signed int)v3->ptr_48 )
8058 v17 = (signed int)v3->ptr_48;
8059 v18 = v3->pTexture;
8060 if ( v17 )
8061 {
8062 if ( v17 == 1 )
8063 {
8064 v19 = (unsigned __int16 *)v18->pLevelOfDetail1;
8065 }
8066 else
8067 {
8068 if ( v17 == 2 )
8069 v19 = (unsigned __int16 *)v18->pLevelOfDetail2;
8070 else
8071 v19 = (unsigned __int16 *)v18->pLevelOfDetail3;
8072 }
8073 }
8074 else
8075 {
8076 v19 = (unsigned __int16 *)v18->pLevelOfDetail0_prolly_alpha_mask;
8077 }
8078 a1.pTextureLOD = v19;
8079 X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16;
8080 v20 = v3->ptr_38;
8081 X = v38;
8082 a1.field_30 = v28 + ((unsigned __int64)(v36 * (signed __int64)v38) >> 16) - v20->field_24;
8083 X = (unsigned __int64)(v34 * (signed __int64)v38) >> 16;
8084 v21 = X - v3->ptr_38->field_28 - v35;
8085 a1.field_30 >>= v17 + bUseLoResSprites;
8086 a1.field_2C = v21 >> (v17 + bUseLoResSprites);
8087 v35 = pOutdoorCamera->int_fov_rad_inv;
8088 v37 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v38) >> 16) >> (v17 + bUseLoResSprites);
8089 a1.field_4 = (unsigned __int64)(v37 * (signed __int64)v29) >> 16;
8090 X = (unsigned __int64)(v37 * (signed __int64)v32) >> 16;
8091 a1.field_0 = -(signed int)((unsigned __int64)(v37 * (signed __int64)v32) >> 16);
8092 v22 = v2->field_A;
8093 a1.pColorBuffer = &pRenderer->pTargetSurface[v2->field_8 + pRenderer->uTargetSurfacePitch * v2->field_A];
8094 HIWORD(v23) = HIWORD(v38);
8095 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v2->field_8 + 640 * v22];
8096 LOWORD(v23) = 0;
8097 a1.field_24 = v23 | v3->field_50;
8098 v24 = v3->pTexture;
8099 v32 = (signed int)v24->uTextureWidth >> v17;
8100 v25 = (signed int)v24->uTextureHeight >> v17;
8101 a1.field_10 = v17 - v24->uWidthLn2 + 16;
8102 a1.field_C = v32 - 1;
8103 a1.field_8 = (v25 << 16) - 65536;
8104 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v38, v3, pOutdoorCamera->building_gamme, 1u, 1);
8105 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8106 sr_sub_485975(&a1, (stru315 *)&a2);
8107 else
8108 sr_sub_4D6FB0(v1);
8109 return 1;
8110 }
8111
8112 //----- (00482E07) --------------------------------------------------------
8113 signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget)
8114 {
8115 stru315 *v2; // ebp@0
8116 stru148 *v3; // esi@1
8117 int v4; // edi@1
8118 int v5; // edi@1
8119 stru149 *v6; // eax@1
8120 stru149 *v7; // eax@1
8121 int v8; // edx@1
8122 int v9; // eax@1
8123 int v10; // edi@1
8124 int v11; // eax@1
8125 unsigned __int64 v12; // qax@1
8126 int v13; // eax@1
8127 signed __int64 v14; // qtt@3
8128 int v15; // ebx@4
8129 signed __int64 v16; // qtt@5
8130 int v17; // eax@5
8131 unsigned __int16 *v18; // eax@7
8132 Texture *v19; // eax@8
8133 Texture *v20; // eax@10
8134 Texture *v21; // eax@12
8135 Texture *v22; // eax@14
8136 int v23; // ecx@17
8137 Texture *v24; // ebx@17
8138 signed int v25; // edx@17
8139 signed int v26; // eax@17
8140 char v27; // bl@17
8141 stru149 *v28; // eax@18
8142 stru149 *v29; // eax@18
8143 int v30; // eax@18
8144 int v31; // eax@18
8145 unsigned int v32; // edx@18
8146 int v33; // edi@21
8147 signed __int64 v34; // qtt@22
8148 signed int v35; // ecx@22
8149 int v36; // eax@24
8150 stru149 *v37; // eax@24
8151 int v38; // edi@24
8152 int v39; // eax@24
8153 int v40; // edi@35
8154 signed __int64 v41; // qtt@36
8155 int v42; // edx@36
8156 stru149 *v43; // eax@36
8157 int v44; // edi@36
8158 int v45; // eax@36
8159 Span *v46; // edi@44
8160 stru149 *v47; // eax@44
8161 stru149 *v48; // eax@44
8162 int v49; // eax@44
8163 int v50; // ecx@44
8164 unsigned int v51; // edx@44
8165 int v52; // edi@46
8166 signed __int64 v53; // qtt@47
8167 unsigned int v54; // ecx@47
8168 int v55; // eax@49
8169 stru149 *v56; // eax@49
8170 int v57; // edi@49
8171 int v58; // eax@49
8172 int v59; // edi@60
8173 signed __int64 v60; // qtt@61
8174 int v61; // edx@61
8175 stru149 *v62; // eax@61
8176 int v63; // edi@61
8177 int v64; // eax@61
8178 int v66; // [sp+Ch] [bp-B8h]@1
8179 int v67; // [sp+10h] [bp-B4h]@1
8180 int v68; // [sp+14h] [bp-B0h]@1
8181 int v69; // [sp+18h] [bp-ACh]@1
8182 int v70; // [sp+1Ch] [bp-A8h]@5
8183 int v71; // [sp+20h] [bp-A4h]@1
8184 signed int v72; // [sp+24h] [bp-A0h]@1
8185 stru316 a2; // [sp+28h] [bp-9Ch]@18
8186 int v74; // [sp+50h] [bp-74h]@17
8187 stru315 a1; // [sp+54h] [bp-70h]@5
8188 Span *v76; // [sp+98h] [bp-2Ch]@1
8189 unsigned __int16 *v77; // [sp+9Ch] [bp-28h]@1
8190 int v78; // [sp+A0h] [bp-24h]@17
8191 int v79; // [sp+A4h] [bp-20h]@3
8192 int v80; // [sp+A8h] [bp-1Ch]@3
8193 int v81; // [sp+ACh] [bp-18h]@1
8194 int X; // [sp+B0h] [bp-14h]@2
8195 int v83; // [sp+B4h] [bp-10h]@1
8196 int v84; // [sp+B8h] [bp-Ch]@1
8197 int v85; // [sp+BCh] [bp-8h]@1
8198 int v86; // [sp+C0h] [bp-4h]@18
8199
8200 v85 = ecx0->field_C;
8201 v3 = ecx0->pParent;
8202 v4 = pViewport->uScreenCenterY - ecx0->field_A;
8203 v77 = pRenderTarget;
8204 v5 = pOutdoorCamera->int_fov_rad_inv * v4;
8205 v6 = v3->ptr_38;
8206 v76 = ecx0;
8207 v81 = v5;
8208 v83 = v6->field_14;
8209 v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
8210 v7 = v3->ptr_38;
8211 v8 = v81 + v7->field_C;
8212 v83 = v7->field_20;
8213 v67 = v8;
8214 v9 = ((unsigned __int64)(v83 * (signed __int64)v5) >> 16) + v3->ptr_38->field_18;
8215 v81 = v5;
8216 v71 = v9;
8217 v83 = v3->v_18.z;
8218 v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16;
8219 v68 = v3->sTextureDeltaU << 16;
8220 v69 = v3->sTextureDeltaV << 16;
8221 v72 = -v3->field_24;
8222 v10 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - ecx0->field_8);
8223 v11 = v3->v_18.y;
8224 v66 = v81 + v3->v_18.x;
8225 v83 = v10;
8226 v12 = v10 * (signed __int64)v11;
8227 v81 = v12 >> 16;
8228 v13 = v66 + (v12 >> 16);
8229 v84 = v13;
8230 if ( !v13
8231 || (X = v72 >> 15, v83 = abs(v13), abs(v72 >> 15) >= v83)
8232 || (LODWORD(v14) = v72 << 16,
8233 HIDWORD(v14) = v72 >> 16,
8234 v79 = v14 / v84,
8235 v80 = v10 - v85 * pOutdoorCamera->int_fov_rad_inv,
8236 v81 = (unsigned __int64)(v80 * (signed __int64)v3->v_18.y) >> 16,
8237 (v84 = v66 + v81) == 0)
8238 || (v15 = abs(v66 + v81), abs(X) >= v15) )
8239 return 0;
8240 LODWORD(v16) = v72 << 16;
8241 HIDWORD(v16) = v72 >> 16;
8242 v70 = v16 / v84;
8243 v17 = v16 / v84;
8244 a1.field_24 = v79;
8245 if ( v79 >= v17 )
8246 a1.field_24 = v17;
8247 v18 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
8248 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
8249 v84 = 2;
8250 if ( a1.field_24 >= mipmapping_building_mm1 << 16 )
8251 {
8252 if ( a1.field_24 >= mipmapping_building_mm2 << 16 )
8253 {
8254 if ( a1.field_24 >= mipmapping_building_mm3 << 16 )
8255 {
8256 if ( bUseLoResSprites )
8257 goto LABEL_16;
8258 v22 = v3->pTexture;
8259 v84 = 3;
8260 v18 = (unsigned __int16 *)v22->pLevelOfDetail3;
8261 }
8262 else
8263 {
8264 v21 = v3->pTexture;
8265 v84 = 2;
8266 v18 = (unsigned __int16 *)v21->pLevelOfDetail2;
8267 }
8268 }
8269 else
8270 {
8271 v20 = v3->pTexture;
8272 v84 = 1;
8273 v18 = (unsigned __int16 *)v20->pLevelOfDetail1;
8274 }
8275 }
8276 else
8277 {
8278 v19 = v3->pTexture;
8279 v84 = 0;
8280 v18 = (unsigned __int16 *)v19->pLevelOfDetail0_prolly_alpha_mask;
8281 }
8282 a1.pTextureLOD = v18;
8283 LABEL_16:
8284 if ( v18 )
8285 {
8286 v23 = v3->field_5A;
8287 v83 = v3->field_52;
8288 v24 = v3->pTexture;
8289 v74 = v23;
8290 v78 = v85 >> v23;
8291 v25 = v24->uTextureWidth;
8292 v81 = v85 - (v85 >> v23 << v23);
8293 v26 = (signed int)v24->uTextureHeight >> v84;
8294 a1.field_10 = v84 - v24->uWidthLn2 + 16;
8295 v27 = v84 + bUseLoResSprites;
8296 a1.field_8 = (v26 << 16) - 65536;
8297 a1.field_C = (v25 >> v84) - 1;
8298 if ( v79 >= v70 )
8299 {
8300 v46 = v76;
8301 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v70, v3, pOutdoorCamera->building_gamme, 0, 1);
8302 v47 = v3->ptr_38;
8303 v79 = v80;
8304 v86 = v47->field_10;
8305 v79 = v80;
8306 v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
8307 v86 = v3->ptr_38->field_1C;
8308 v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16);
8309 v79 = (unsigned __int64)(v84 * (signed __int64)v70) >> 16;
8310 v48 = v3->ptr_38;
8311 v79 = v70;
8312 a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v70) >> 16) - v48->field_24;
8313 v79 = (unsigned __int64)(v86 * (signed __int64)v70) >> 16;
8314 v49 = ((unsigned __int64)(v86 * (signed __int64)v70) >> 16) - v3->ptr_38->field_28;
8315 a1.field_30 >>= v27;
8316 a1.field_2C = (v69 + v49) >> v27;
8317 a1.field_14 = dword_80AA20 >> v27;
8318 a1.field_18 = dword_80AA1C >> v27;
8319 a1.field_1C = dword_80AA18 >> v27;
8320 v50 = v46->field_8;
8321 a1.field_20 = dword_80AA14 >> v27;
8322 v51 = v50 + pRenderer->uTargetSurfacePitch * v46->field_A;
8323 a1.pDepthBuffer = (unsigned int *)(&pRenderer->pActiveZBuffer[640 * v46->field_A - 1] + v85 + v50);
8324 a1.pColorBuffer = &v77[v85 - 1] + v51;
8325 v80 += pOutdoorCamera->int_fov_rad_inv << v74;
8326 if ( v78 > 0 )
8327 {
8328 do
8329 {
8330 v77 = (unsigned __int16 *)v3->v_18.y;
8331 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16;
8332 v84 = v66 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16);
8333 if ( v66 + (unsigned int)((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)
8334 && (v52 = abs((signed __int64)v66 + ((__int64)((signed int)v77 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v52) )
8335 {
8336 LODWORD(v53) = v72 << 16;
8337 HIDWORD(v53) = v72 >> 16;
8338 v86 = v53 / v84;
8339 v54 = v53 / v84;
8340 v84 = v53 / v84;
8341 }
8342 else
8343 {
8344 v84 = 0x40000000u;
8345 v54 = 0x40000000u;
8346 }
8347 HIWORD(v55) = HIWORD(v54);
8348 LOWORD(v55) = 0;
8349 a1.field_24 = v3->field_50 | v55;
8350 v77 = (unsigned __int16 *)v3->ptr_38->field_10;
8351 v77 = (unsigned __int16 *)(v67 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
8352 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
8353 v56 = v3->ptr_38;
8354 v57 = ((unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16) - v56->field_24;
8355 v77 = (unsigned __int16 *)v56->field_1C;
8356 v77 = (unsigned __int16 *)(v71 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16));
8357 v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16;
8358 v58 = (((v69 + v86 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
8359 a1.field_4 = (((v68 + v57) >> v27) - a1.field_30) >> v74;
8360 a1.field_0 = v58;
8361 a1.field_28 = v83;
8362 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8363 {
8364 if ( v3->pODMFace->uPolygonType == 1 )
8365 sr_sub_485BAE(&a1, &a2);
8366 else
8367 sr_sub_485AFF(&a1, &a2);
8368 }
8369 else
8370 {
8371 if ( v3->pODMFace->uPolygonType == 1 )
8372 sr_sub_4D71F8(&a1);
8373 else
8374 sr_sub_4D714C(&a1);
8375 }
8376 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
8377 &a2,
8378 v76,
8379 v84,
8380 v3,
8381 pOutdoorCamera->building_gamme,
8382 0,
8383 0);
8384 v80 += pOutdoorCamera->int_fov_rad_inv << v74;
8385 --v78;
8386 }
8387 while ( v78 );
8388 }
8389 if ( !v81 )
8390 return 1;
8391 v83 = v3->v_18.y;
8392 v86 = (unsigned __int64)(v83 * (signed __int64)v80) >> 16;
8393 v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8394 if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
8395 {
8396 v59 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
8397 if ( abs(X) < v59 )
8398 {
8399 LODWORD(v60) = v72 << 16;
8400 HIDWORD(v60) = v72 >> 16;
8401 v86 = v60 / v84;
8402 HIWORD(v61) = (unsigned int)(v60 / v84) >> 16;
8403 LOWORD(v61) = 0;
8404 a1.field_24 = v61 | v3->field_50;
8405 v83 = v3->ptr_38->field_10;
8406 v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8407 v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
8408 v62 = v3->ptr_38;
8409 v63 = ((unsigned __int64)(v83 * v60 / v84) >> 16) - v62->field_24;
8410 v83 = v62->field_1C;
8411 v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8412 v86 = (unsigned __int64)(v83 * v60 / v84) >> 16;
8413 v64 = (((signed int)(v69 + ((unsigned __int64)(v83 * v60 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
8414 - a1.field_2C) >> v74;
8415 a1.field_4 = (((v68 + v63) >> v27) - a1.field_30) >> v74;
8416 a1.field_0 = v64;
8417 a1.field_28 = v81;
8418 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8419 {
8420 if ( v3->pODMFace->uPolygonType == 1 )
8421 sr_sub_485BAE(&a1, &a2);
8422 else
8423 sr_sub_485AFF(&a1, &a2);
8424 }
8425 else
8426 {
8427 if ( v3->pODMFace->uPolygonType == 1 )
8428 sr_sub_4D71F8(&a1);
8429 else
8430 sr_sub_4D714C(&a1);
8431 }
8432 return 1;
8433 }
8434 }
8435 }
8436 else
8437 {
8438 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v79, v3, pOutdoorCamera->building_gamme, 1u, 1);
8439 v28 = v3->ptr_38;
8440 v85 = v10;
8441 v86 = v28->field_10;
8442 v85 = v10;
8443 v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
8444 v86 = v3->ptr_38->field_1C;
8445 v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16);
8446 v85 = (unsigned __int64)(v84 * (signed __int64)v79) >> 16;
8447 v29 = v3->ptr_38;
8448 v85 = v79;
8449 a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v79) >> 16) - v29->field_24;
8450 v85 = (unsigned __int64)(v86 * (signed __int64)v79) >> 16;
8451 v30 = ((unsigned __int64)(v86 * (signed __int64)v79) >> 16) - v3->ptr_38->field_28;
8452 a1.field_30 >>= v27;
8453 a1.field_2C = (v69 + v30) >> v27;
8454 a1.field_14 = dword_80AA20 >> v27;
8455 a1.field_18 = dword_80AA1C >> v27;
8456 a1.field_1C = dword_80AA18 >> v27;
8457 a1.field_20 = dword_80AA14 >> v27;
8458 v31 = v76->field_A;
8459 v32 = pRenderer->uTargetSurfacePitch * v76->field_A;
8460 v86 = v76->field_8;
8461 a1.pColorBuffer = &v77[v86 + v32];
8462 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v86 + 640 * v31];
8463 v80 = v10 - (pOutdoorCamera->int_fov_rad_inv << v74);
8464 if ( v78 > 0 )
8465 {
8466 v86 = v78;
8467 do
8468 {
8469 v78 = v3->v_18.y;
8470 v85 = (unsigned __int64)(v78 * (signed __int64)v80) >> 16;
8471 v84 = v66 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
8472 if ( v66 + (unsigned int)((unsigned __int64)(v78 * (signed __int64)v80) >> 16)
8473 && (v33 = abs((signed __int64)v66 + ((__int64)(v78 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v33) )
8474 {
8475 LODWORD(v34) = v72 << 16;
8476 HIDWORD(v34) = v72 >> 16;
8477 v85 = v34 / v84;
8478 v35 = v34 / v84;
8479 v84 = v34 / v84;
8480 }
8481 else
8482 {
8483 v84 = 1073741824;
8484 v35 = 1073741824;
8485 }
8486 HIWORD(v36) = HIWORD(v35);
8487 LOWORD(v36) = 0;
8488 a1.field_24 = v3->field_50 | v36;
8489 v78 = v3->ptr_38->field_10;
8490 v78 = v67 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
8491 v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
8492 v37 = v3->ptr_38;
8493 v38 = ((unsigned __int64)(v78 * (signed __int64)v35) >> 16) - v37->field_24;
8494 v78 = v37->field_1C;
8495 v78 = v71 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16);
8496 v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16;
8497 v39 = (((v69 + v85 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74;
8498 a1.field_4 = (((v68 + v38) >> v27) - a1.field_30) >> v74;
8499 a1.field_0 = v39;
8500 a1.field_28 = v83;
8501 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8502 {
8503 if ( v3->pODMFace->uPolygonType == 1 )
8504 sr_sub_485A24(&a1, (stru315 *)&a2);
8505 else
8506 sr_sub_485975(&a1, (stru315 *)&a2);
8507 }
8508 else
8509 {
8510 if ( v3->pODMFace->uPolygonType == 1 )
8511 sr_sub_4D705A(v2);
8512 else
8513 sr_sub_4D6FB0(v2);
8514 }
8515 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(
8516 &a2,
8517 v76,
8518 v84,
8519 v3,
8520 pOutdoorCamera->building_gamme,
8521 1u,
8522 0);
8523 v80 -= pOutdoorCamera->int_fov_rad_inv << v74;
8524 --v86;
8525 }
8526 while ( v86 );
8527 }
8528 if ( !v81 )
8529 return 1;
8530 v83 = v3->v_18.y;
8531 v76 = (Span *)((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8532 v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8533 if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) )
8534 {
8535 v40 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16));
8536 if ( abs(X) < v40 )
8537 {
8538 LODWORD(v41) = v72 << 16;
8539 HIDWORD(v41) = v72 >> 16;
8540 X = v41 / v84;
8541 HIWORD(v42) = (unsigned int)(v41 / v84) >> 16;
8542 LOWORD(v42) = 0;
8543 a1.field_24 = v42 | v3->field_50;
8544 v83 = v3->ptr_38->field_10;
8545 v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8546 X = (unsigned __int64)(v83 * v41 / v84) >> 16;
8547 v43 = v3->ptr_38;
8548 v44 = ((unsigned __int64)(v83 * v41 / v84) >> 16) - v43->field_24;
8549 v83 = v43->field_1C;
8550 v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16);
8551 X = (unsigned __int64)(v83 * v41 / v84) >> 16;
8552 v45 = (((signed int)(v69 + ((unsigned __int64)(v83 * v41 / v84) >> 16) - v3->ptr_38->field_28) >> v27)
8553 - a1.field_2C) >> v74;
8554 a1.field_4 = (((v68 + v44) >> v27) - a1.field_30) >> v74;
8555 a1.field_0 = v45;
8556 a1.field_28 = v81;
8557 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8558 {
8559 if ( v3->pODMFace->uPolygonType == 1 )
8560 sr_sub_485A24(&a1, (stru315 *)&a2);
8561 else
8562 sr_sub_485975(&a1, (stru315 *)&a2);
8563 }
8564 else
8565 {
8566 if ( v3->pODMFace->uPolygonType == 1 )
8567 sr_sub_4D705A(v2);
8568 else
8569 sr_sub_4D6FB0(v2);
8570 }
8571 return 1;
8572 }
8573 }
8574 }
8575 }
8576 return 0;
8577 }
8578
8579 //----- (004839BD) --------------------------------------------------------
8580 signed int __fastcall sr_sub_4839BD(Span *ecx0, unsigned __int16 *pTargetSurface)
8581 {
8582 stru315 *v2; // ebp@0
8583 int v3; // eax@1
8584 int v4; // edi@1
8585 stru148 *v5; // esi@1
8586 unsigned int v6; // ebx@1
8587 int v7; // ecx@1
8588 int v8; // ebx@1
8589 int v9; // ecx@1
8590 int v10; // eax@1
8591 stru149 *v11; // eax@1
8592 int v12; // edx@1
8593 int v13; // eax@1
8594 int v14; // edi@1
8595 int v15; // ecx@1
8596 int v16; // eax@1
8597 signed int v17; // edi@1
8598 int v18; // edi@2
8599 signed __int64 v19; // qtt@3
8600 int v20; // edi@3
8601 unsigned __int16 *v21; // eax@3
8602 Texture *v22; // eax@4
8603 Texture *v23; // eax@6
8604 Texture *v24; // eax@8
8605 Texture *v25; // eax@10
8606 stru149 *v26; // eax@13
8607 int v27; // edi@13
8608 signed int v28; // edx@13
8609 Texture *v29; // ebx@13
8610 int v30; // edi@13
8611 signed int v31; // edx@13
8612 signed int v32; // eax@13
8613 signed int v33; // eax@13
8614 int v34; // ebx@13
8615 int v35; // eax@15
8616 int v36; // ebx@15
8617 int v37; // eax@16
8618 signed __int64 v38; // qtt@17
8619 int v39; // ecx@17
8620 int v40; // eax@19
8621 stru149 *v41; // eax@21
8622 int v42; // ebx@21
8623 int v43; // ebx@21
8624 int v44; // eax@21
8625 char v45; // zf@25
8626 int v46; // eax@28
8627 int v47; // eax@28
8628 int v48; // ebx@28
8629 int v49; // eax@29
8630 signed __int64 v50; // qtt@30
8631 int v51; // ecx@30
8632 int v52; // eax@30
8633 int v53; // edx@31
8634 stru149 *v54; // eax@33
8635 int v55; // ebx@33
8636 signed int v56; // ebx@33
8637 int v57; // eax@33
8638 unsigned __int64 v58; // qax@33
8639 int v60; // [sp+Ch] [bp-BCh]@1
8640 Span *v61; // [sp+10h] [bp-B8h]@1
8641 int v62; // [sp+14h] [bp-B4h]@2
8642 int v63; // [sp+18h] [bp-B0h]@1
8643 stru315 a1; // [sp+1Ch] [bp-ACh]@1
8644 stru316 a2; // [sp+60h] [bp-68h]@13
8645 int v66; // [sp+88h] [bp-40h]@13
8646 int v67; // [sp+8Ch] [bp-3Ch]@1
8647 int v68; // [sp+90h] [bp-38h]@13
8648 int v69; // [sp+94h] [bp-34h]@3
8649 int v70; // [sp+98h] [bp-30h]@1
8650 int v71; // [sp+9Ch] [bp-2Ch]@1
8651 int v72; // [sp+A0h] [bp-28h]@1
8652 int v73; // [sp+A4h] [bp-24h]@13
8653 int v74; // [sp+A8h] [bp-20h]@1
8654 int v75; // [sp+ACh] [bp-1Ch]@3
8655 int v76; // [sp+B0h] [bp-18h]@1
8656 int v77; // [sp+B4h] [bp-14h]@1
8657 int X; // [sp+B8h] [bp-10h]@1
8658 int v79; // [sp+BCh] [bp-Ch]@21
8659 int v80; // [sp+C0h] [bp-8h]@13
8660 unsigned int v81; // [sp+C4h] [bp-4h]@1
8661
8662 v3 = ecx0->field_A;
8663 v4 = ecx0->field_8;
8664 v5 = ecx0->pParent;
8665 v6 = v4 + pRenderer->uTargetSurfacePitch * ecx0->field_A;
8666 v61 = ecx0;
8667 v7 = ecx0->field_C;
8668 a1.pColorBuffer = &pTargetSurface[v6];
8669 v74 = v7;
8670 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v4 + 640 * v3];
8671 v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
8672 v9 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v3);
8673 v10 = v5->ptr_38->field_14;
8674 v76 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4);
8675 v72 = v10;
8676 v81 = (unsigned __int64)(v10 * (signed __int64)v9) >> 16;
8677 v11 = v5->ptr_38;
8678 v12 = v81 + v11->field_C;
8679 v72 = v11->field_20;
8680 v67 = v12;
8681 v13 = ((unsigned __int64)(v72 * (signed __int64)v9) >> 16) + v5->ptr_38->field_18;
8682 v81 = v9;
8683 v70 = v13;
8684 v72 = v5->v_18.z;
8685 v81 = (unsigned __int64)(v72 * (signed __int64)v9) >> 16;
8686 v14 = v5->field_24;
8687 v15 = v81 + v5->v_18.x;
8688 v71 = v5->sTextureDeltaU << 16;
8689 v63 = v5->sTextureDeltaV << 16;
8690 v16 = v5->v_18.y;
8691 v17 = -v14;
8692 v60 = v15;
8693 v77 = v17;
8694 v81 = (unsigned __int64)(v76 * (signed __int64)v16) >> 16;
8695 X = v81 + v15;
8696 if ( !(v81 + v15) || (v62 = v17 >> 14, v18 = abs(v17 >> 14), v18 > abs(X)) )
8697 return 0;
8698 LODWORD(v19) = v77 << 16;
8699 HIDWORD(v19) = v77 >> 16;
8700 v69 = v19 / X;
8701 v20 = v19 / X;
8702 v21 = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
8703 a1.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
8704 v75 = 2;
8705 if ( v20 >= mipmapping_building_mm1 << 16 )
8706 {
8707 if ( v20 >= mipmapping_building_mm2 << 16 )
8708 {
8709 if ( v20 >= mipmapping_building_mm3 << 16 )
8710 {
8711 if ( bUseLoResSprites )
8712 goto LABEL_12;
8713 v25 = v5->pTexture;
8714 v75 = 3;
8715 v21 = (unsigned __int16 *)v25->pLevelOfDetail3;
8716 }
8717 else
8718 {
8719 v24 = v5->pTexture;
8720 v75 = 2;
8721 v21 = (unsigned __int16 *)v24->pLevelOfDetail2;
8722 }
8723 }
8724 else
8725 {
8726 v23 = v5->pTexture;
8727 v75 = 1;
8728 v21 = (unsigned __int16 *)v23->pLevelOfDetail1;
8729 }
8730 }
8731 else
8732 {
8733 v22 = v5->pTexture;
8734 v75 = 0;
8735 v21 = (unsigned __int16 *)v22->pLevelOfDetail0_prolly_alpha_mask;
8736 }
8737 a1.pTextureLOD = v21;
8738 LABEL_12:
8739 if ( v21 )
8740 {
8741 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, v20, v5, pOutdoorCamera->building_gamme, 1u, 1);
8742 a1.field_28 = 16;
8743 v66 = v74 >> 4;
8744 v81 = v8;
8745 v26 = v5->ptr_38;
8746 v72 = v74 - 16 * (v74 >> 4);
8747 v76 = v26->field_10;
8748 v81 = v8;
8749 v74 = v67 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
8750 v76 = v5->ptr_38->field_1C;
8751 v76 = v70 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16);
8752 v81 = (unsigned __int64)(v74 * (signed __int64)v20) >> 16;
8753 v27 = ((unsigned __int64)(v74 * (signed __int64)v20) >> 16) - v5->ptr_38->field_24;
8754 v81 = (unsigned __int64)(v76 * (signed __int64)v69) >> 16;
8755 v28 = v63 + ((unsigned __int64)(v76 * (signed __int64)v69) >> 16) - v5->ptr_38->field_28;
8756 v76 = v75 + bUseLoResSprites;
8757 v73 = v8 - 16 * pOutdoorCamera->int_fov_rad_inv;
8758 v29 = v5->pTexture;
8759 v30 = (v71 + v27) >> v76;
8760 v31 = v28 >> v76;
8761 v32 = (signed int)v29->uTextureWidth >> v75;
8762 v74 = (signed __int16)v75;
8763 v68 = v31;
8764 v80 = v32;
8765 v33 = (signed int)v29->uTextureHeight >> v75;
8766 v34 = v75 - v29->uWidthLn2;
8767 a1.field_8 = (v33 << 16) - 65536;
8768 v81 = 2 * pMiscTimer->uTotalGameTimeElapsed;
8769 a1.field_10 = v34 + 16;
8770 a1.field_C = v80 - 1;
8771 if ( v66 > 0 )
8772 {
8773 v74 = v66;
8774 v66 = 12 - v75;
8775 do
8776 {
8777 v80 = v5->v_18.y;
8778 v35 = (unsigned __int64)(v80 * (signed __int64)v73) >> 16;
8779 v36 = v35 + v60;
8780 X = v35 + v60;
8781 if ( v35 + v60 && (v80 = abs(v62), v37 = abs(v36), v80 <= v37) )
8782 {
8783 LODWORD(v38) = v77 << 16;
8784 HIDWORD(v38) = v77 >> 16;
8785 v80 = v38 / X;
8786 v39 = v38 / X;
8787 X = v38 / X;
8788 }
8789 else
8790 {
8791 X = 0x40000000u;
8792 v39 = 0x40000000u;
8793 }
8794 HIWORD(v40) = HIWORD(v39);
8795 if ( v39 <= v69 )
8796 HIWORD(v40) = HIWORD(v69);
8797 LOWORD(v40) = 0;
8798 a1.field_24 = v5->field_50 | v40;
8799 v79 = v5->ptr_38->field_10;
8800 v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
8801 v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
8802 v41 = v5->ptr_38;
8803 v42 = ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v41->field_24;
8804 v79 = v41->field_1C;
8805 v79 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
8806 v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16;
8807 v43 = (v71 + v42) >> v76;
8808 v79 = (signed int)(v63 + ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v5->ptr_38->field_28) >> v76;
8809 a1.field_4 = (v43 - v30) >> 4;
8810 a1.field_0 = (v79 - v68) >> 4;
8811 a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v68 >> v66));
8812 v44 = stru_5C6E00->Sin(v81 + (v30 >> v66));
8813 a1.field_2C = v68 + 4 * v44;
8814 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8815 sr_sub_485975(&a1, (stru315 *)&a2);
8816 else
8817 sr_sub_4D6FB0(v2);
8818 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, X, v5, pOutdoorCamera->building_gamme, 1u, 0);
8819 v73 -= 16 * pOutdoorCamera->int_fov_rad_inv;
8820 v45 = v74-- == 1;
8821 a1.field_28 = 16;
8822 v30 = v43;
8823 v68 = v79;
8824 }
8825 while ( !v45 );
8826 v31 = v79;
8827 }
8828 if ( !v72 )
8829 return 1;
8830 v66 = 12 - v75;
8831 a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v31 >> (12 - v75)));
8832 v46 = stru_5C6E00->Sin(v81 + (v30 >> v66));
8833 a1.field_2C = v68 + 4 * v46;
8834 v79 = v5->v_18.y;
8835 v80 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
8836 v47 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
8837 v48 = v47 + v60;
8838 X = v47 + v60;
8839 if ( v47 + v60 )
8840 {
8841 v79 = abs(v62);
8842 v49 = abs(v48);
8843 if ( v79 <= v49 )
8844 {
8845 LODWORD(v50) = v77 << 16;
8846 HIDWORD(v50) = v77 >> 16;
8847 v77 = v50 / X;
8848 v51 = v50 / X;
8849 HIWORD(v52) = HIWORD(v69);
8850 if ( v51 <= v69 )
8851 {
8852 LOWORD(v52) = 0;
8853 a1.field_24 = v52 | v5->field_50;
8854 }
8855 else
8856 {
8857 HIWORD(v53) = HIWORD(v51);
8858 LOWORD(v53) = 0;
8859 a1.field_24 = v53 | v5->field_50;
8860 }
8861 v79 = v5->ptr_38->field_10;
8862 v77 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
8863 v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
8864 v67 = (unsigned __int64)(v79 * (signed __int64)v51) >> 16;
8865 v54 = v5->ptr_38;
8866 v55 = v67 - v54->field_24;
8867 v79 = v54->field_1C;
8868 v56 = v71 + v55;
8869 v71 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16;
8870 v57 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16);
8871 v79 = v57;
8872 v58 = v57 * (signed __int64)v51;
8873 v70 = v58 >> 16;
8874 LODWORD(v58) = (signed int)(v63 + (v58 >> 16) - v5->ptr_38->field_28) >> v76;
8875 a1.field_4 = ((v56 >> v76) - v30) >> 4;
8876 a1.field_0 = ((signed int)v58 - v68) >> 4;
8877 a1.field_28 = v72;
8878 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
8879 sr_sub_485975(&a1, (stru315 *)&a2);
8880 else
8881 sr_sub_4D6FB0(v2);
8882 return 1;
8883 }
8884 }
8885 }
8886 return 0;
8887 }
8888 // 4D864C: using guessed type char byte_4D864C;
8889 // 6BE0E4: using guessed type int mipmapping_building_mm1;
8890 // 6BE0E8: using guessed type int mipmapping_building_mm2;
8891 // 6BE0EC: using guessed type int mipmapping_building_mm3;
8892
8893 //----- (0048408A) --------------------------------------------------------
8894 signed int sr_sub_48408A_prolly_odm_water_no_waves(Span *_this)
8895 {
8896 stru315 *v1; // ebp@0
8897 Span *v2; // edi@1
8898 stru148 *v3; // esi@1
8899 int v4; // ecx@1
8900 stru149 *v5; // eax@1
8901 stru149 *v6; // eax@1
8902 int v7; // edx@1
8903 int v8; // eax@1
8904 int v9; // ebx@1
8905 int v10; // eax@1
8906 int v11; // ecx@1
8907 int v12; // eax@1
8908 int v13; // ecx@1
8909 int v14; // eax@1
8910 signed int v15; // ecx@1
8911 int v16; // ebx@1
8912 signed __int64 v17; // qtt@3
8913 stru149 *v18; // eax@3
8914 int v19; // ebx@3
8915 Texture *v20; // eax@4
8916 unsigned __int16 *v21; // eax@4
8917 Texture *v22; // eax@6
8918 Texture *v23; // ecx@8
8919 Texture *v24; // eax@10
8920 stru149 *v25; // eax@12
8921 signed int v26; // eax@12
8922 int v27; // ecx@12
8923 int v28; // eax@14
8924 int v29; // edx@14
8925 int v30; // ecx@14
8926 Texture *v31; // esi@14
8927 int v32; // edx@14
8928 int v33; // eax@14
8929 int v35; // [sp+Ch] [bp-8Ch]@1
8930 int v36; // [sp+10h] [bp-88h]@1
8931 stru316 a2; // [sp+14h] [bp-84h]@14
8932 stru315 a1; // [sp+3Ch] [bp-5Ch]@1
8933 int v39; // [sp+80h] [bp-18h]@1
8934 int v40; // [sp+84h] [bp-14h]@1
8935 int v41; // [sp+88h] [bp-10h]@1
8936 int v42; // [sp+8Ch] [bp-Ch]@1
8937 int v43; // [sp+90h] [bp-8h]@2
8938 int v44; // [sp+94h] [bp-4h]@1
8939
8940 v2 = _this;
8941 v3 = _this->pParent;
8942 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
8943 v5 = v3->ptr_38;
8944 v44 = v4;
8945 v42 = v5->field_14;
8946 v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
8947 v6 = v3->ptr_38;
8948 v7 = v44 + v6->field_C;
8949 v42 = v6->field_20;
8950 v39 = v7;
8951 v8 = ((unsigned __int64)(v42 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
8952 v44 = v4;
8953 v41 = v8;
8954 v42 = v3->v_18.z;
8955 v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16;
8956 v9 = v44 + v3->v_18.x;
8957 v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
8958 v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
8959 v11 = v2->field_8;
8960 v36 = v10;
8961 a1.field_28 = v2->field_C;
8962 v12 = pViewport->uScreenCenterX - v11;
8963 v13 = v3->field_24;
8964 v42 = pOutdoorCamera->int_fov_rad_inv * v12;
8965 v14 = v3->v_18.y;
8966 v15 = -v13;
8967 v40 = v15;
8968 v16 = ((unsigned __int64)(v42 * (signed __int64)v14) >> 16) + v9;
8969 v44 = v16;
8970 if ( !v16 || (v43 = abs(v15 >> 14), v43 > abs(v16)) )
8971 return 0;
8972 LODWORD(v17) = v40 << 16;
8973 HIDWORD(v17) = v40 >> 16;
8974 v43 = v17 / v44;
8975 v18 = v3->ptr_38;
8976 v44 = v42;
8977 v40 = v18->field_10;
8978 v44 = v42;
8979 v40 = v39 + ((unsigned __int64)(v40 * (signed __int64)v42) >> 16);
8980 v39 = v3->ptr_38->field_1C;
8981 v44 = (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
8982 v19 = v43;
8983 v41 += (unsigned __int64)(v39 * (signed __int64)v42) >> 16;
8984 a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
8985 v44 = 2;
8986 if ( v43 < mipmapping_terrain_mm1 << 16 )
8987 {
8988 v20 = v3->pTexture;
8989 v44 = 0;
8990 v21 = (unsigned __int16 *)v20->pLevelOfDetail0_prolly_alpha_mask;
8991 LABEL_11:
8992 a1.pTextureLOD = v21;
8993 goto LABEL_12;
8994 }
8995 if ( v43 < mipmapping_terrain_mm2 << 16 )
8996 {
8997 v22 = v3->pTexture;
8998 v44 = 1;
8999 v21 = (unsigned __int16 *)v22->pLevelOfDetail1;
9000 goto LABEL_11;
9001 }
9002 if ( v43 >= mipmapping_terrain_mm3 << 16 )
9003 {
9004 if ( !bUseLoResSprites )
9005 {
9006 v24 = v3->pTexture;
9007 v44 = 3;
9008 v21 = (unsigned __int16 *)v24->pLevelOfDetail3;
9009 goto LABEL_11;
9010 }
9011 }
9012 else
9013 {
9014 v23 = v3->pTexture;
9015 v44 = 2;
9016 a1.pTextureLOD = (unsigned __int16 *)v23->pLevelOfDetail2;
9017 }
9018 LABEL_12:
9019 v43 = (unsigned __int64)(v40 * (signed __int64)v43) >> 16;
9020 v25 = v3->ptr_38;
9021 v43 = v19;
9022 a1.field_30 = ((unsigned __int64)(v40 * (signed __int64)v19) >> 16) - v25->field_24;
9023 v43 = (unsigned __int64)(v41 * (signed __int64)v19) >> 16;
9024 v26 = ((unsigned __int64)(v41 * (signed __int64)v19) >> 16) - v3->ptr_38->field_28;
9025 v27 = bUseLoResSprites + v44 + 2;
9026 a1.field_30 >>= v27;
9027 v41 = bUseLoResSprites + v44 + 2;
9028 a1.field_2C = v26 >> v27;
9029 if ( byte_80AA10 )
9030 {
9031 a1.field_14 = dword_80AA20 >> v27;
9032 a1.field_18 = dword_80AA1C >> v27;
9033 a1.field_1C = dword_80AA18 >> v27;
9034 a1.field_20 = dword_80AA14 >> v27;
9035 }
9036 v41 = pOutdoorCamera->int_fov_rad_inv;
9037 v42 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v19) >> 16) >> v27;
9038 a1.field_4 = (unsigned __int64)(v42 * (signed __int64)v35) >> 16;
9039 v43 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
9040 a1.field_0 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16;
9041 a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v19, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
9042 LOWORD(v19) = 0;
9043 v28 = v2->field_A;
9044 v29 = v2->field_A;
9045 a1.field_24 = v19;
9046 v30 = v2->field_8;
9047 a1.pColorBuffer = &pRenderer->pTargetSurface[v30 + pRenderer->uTargetSurfacePitch * v29];
9048 a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v30 + 640 * v28];
9049 v31 = v3->pTexture;
9050 v32 = ((signed int)v31->uTextureWidth >> v44) - 1;
9051 v33 = ((signed int)v31->uTextureHeight >> v44 << 16) - 65536;
9052 a1.field_10 = v44 - v31->uWidthLn2 + 16;
9053 a1.field_C = v32;
9054 a1.field_8 = v33;
9055 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9056 {
9057 if ( byte_80AA10 )
9058 sr_sub_485A24(&a1, (stru315 *)&a2);
9059 else
9060 sr_sub_485975(&a1, (stru315 *)&a2);
9061 }
9062 else
9063 {
9064 if ( byte_80AA10 )
9065 sr_sub_4D705A(v1);
9066 else
9067 sr_sub_4D6FB0(v1);
9068 }
9069 return 1;
9070 }
9071
9072 //----- (00484442) --------------------------------------------------------
9073 signed int sr_sub_484442(Span *_this)
9074 {
9075 int v1; // ebp@0
9076 Span *v2; // edi@1
9077 stru148 *v3; // esi@1
9078 int v4; // ecx@1
9079 stru149 *v5; // eax@1
9080 stru149 *v6; // eax@1
9081 int v7; // edx@1
9082 int v8; // eax@1
9083 int v9; // ebx@1
9084 int v10; // eax@1
9085 int v11; // ecx@1
9086 int v12; // eax@1
9087 int v13; // ecx@1
9088 signed int v14; // ecx@1
9089 int v15; // ebx@1
9090 signed __int64 v16; // qtt@3
9091 int v17; // ecx@3
9092 int v18; // ebx@3
9093 int v19; // eax@3
9094 signed int v20; // ebx@3
9095 unsigned __int16 *v21; // eax@4
9096 stru149 *v22; // eax@12
9097 signed int v23; // eax@12
9098 int v24; // ecx@12
9099 int v25; // ecx@14
9100 unsigned int *v26; // eax@14
9101 Texture *v27; // esi@14
9102 signed int v28; // edi@14
9103 signed int v29; // eax@14
9104 signed int v31; // [sp+Ch] [bp-90h]@1
9105 int v32; // [sp+10h] [bp-8Ch]@1
9106 int v33; // [sp+14h] [bp-88h]@1
9107 stru316 v34; // [sp+18h] [bp-84h]@14
9108 stru315 v35; // [sp+40h] [bp-5Ch]@1
9109 int v36; // [sp+84h] [bp-18h]@1
9110 int v37; // [sp+88h] [bp-14h]@1
9111 int v38; // [sp+8Ch] [bp-10h]@1
9112 int v39; // [sp+90h] [bp-Ch]@1
9113 int v40; // [sp+94h] [bp-8h]@1
9114 int v41; // [sp+98h] [bp-4h]@1
9115
9116 v2 = _this;
9117 v3 = _this->pParent;
9118 v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A);
9119 v5 = v3->ptr_38;
9120 v40 = v4;
9121 v39 = v5->field_14;
9122 v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
9123 v6 = v3->ptr_38;
9124 v7 = v40 + v6->field_C;
9125 v39 = v6->field_20;
9126 v36 = v7;
9127 v8 = ((unsigned __int64)(v39 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18;
9128 v40 = v4;
9129 v38 = v8;
9130 v39 = v3->v_18.z;
9131 v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16;
9132 v9 = v40 + v3->v_18.x;
9133 v32 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
9134 v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
9135 v11 = v2->field_8;
9136 v33 = v10;
9137 v35.field_28 = v2->field_C;
9138 v12 = pViewport->uScreenCenterX - v11;
9139 v13 = v3->field_24;
9140 v41 = pOutdoorCamera->int_fov_rad_inv * v12;
9141 v14 = -v13;
9142 v31 = v14;
9143 v15 = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * v12 * (signed __int64)v3->v_18.y) >> 16) + v9;
9144 v37 = v15;
9145 if ( !v15 || (v39 = abs(v14 >> 14), v39 > abs(v15)) )
9146 return 0;
9147 LODWORD(v16) = v31 << 16;
9148 HIDWORD(v16) = v31 >> 16;
9149 v40 = v16 / v37;
9150 v17 = v16 / v37;
9151 v18 = v41;
9152 HIWORD(v19) = (unsigned int)(v16 / v37) >> 16;
9153 LOWORD(v19) = 0;
9154 v35.field_24 = v19;
9155 v37 = v36 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v41) >> 16);
9156 v36 = v3->ptr_38->field_1C;
9157 v41 = (unsigned __int64)(v36 * (signed __int64)v41) >> 16;
9158 v38 += (unsigned __int64)(v36 * (signed __int64)v18) >> 16;
9159 v20 = 2;
9160 v35.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
9161 if ( v17 < mipmapping_terrain_mm1 << 16 )
9162 {
9163 v20 = 0;
9164 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0_prolly_alpha_mask;
9165 LABEL_11:
9166 v35.pTextureLOD = v21;
9167 goto LABEL_12;
9168 }
9169 if ( v17 < mipmapping_terrain_mm2 << 16 )
9170 {
9171 v20 = 1;
9172 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail1;
9173 goto LABEL_11;
9174 }
9175 if ( v17 < mipmapping_terrain_mm3 << 16 )
9176 {
9177 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2;
9178 goto LABEL_11;
9179 }
9180 if ( !bUseLoResSprites )
9181 {
9182 v20 = 3;
9183 v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail3;
9184 goto LABEL_11;
9185 }
9186 LABEL_12:
9187 v41 = (unsigned __int64)(v37 * (signed __int64)v17) >> 16;
9188 v22 = v3->ptr_38;
9189 v41 = v17;
9190 v35.field_30 = ((unsigned __int64)(v37 * (signed __int64)v17) >> 16) - v22->field_24;
9191 v23 = ((unsigned __int64)(v38 * (signed __int64)v17) >> 16) - v3->ptr_38->field_28;
9192 v24 = bUseLoResSprites + v20 + 2;
9193 v35.field_30 >>= v24;
9194 v38 = bUseLoResSprites + v20 + 2;
9195 v35.field_2C = v23 >> v24;
9196 if ( byte_80AA10 )
9197 {
9198 v35.field_14 = dword_80AA20 >> v24;
9199 v35.field_18 = dword_80AA1C >> v24;
9200 v35.field_1C = dword_80AA18 >> v24;
9201 v35.field_20 = dword_80AA14 >> v24;
9202 }
9203 v38 = pOutdoorCamera->int_fov_rad_inv;
9204 v39 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v40) >> 16) >> v24;
9205 v35.field_4 = (unsigned __int64)(v39 * (signed __int64)v32) >> 16;
9206 v41 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
9207 v35.field_0 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16;
9208 v35.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&v34, v2, v40, v3, pOutdoorCamera->terrain_gamma, 1u, 1);
9209 v25 = v2->field_8;
9210 v26 = (unsigned int *)&pRenderer->pActiveZBuffer[v25 + 640 * v2->field_A];
9211 v35.pColorBuffer = &pRenderer->pTargetSurface[v25 + pRenderer->uTargetSurfacePitch * v2->field_A];
9212 v35.pDepthBuffer = v26;
9213 v27 = v3->pTexture;
9214 v28 = (signed int)v27->uTextureWidth >> v20;
9215 v29 = (signed int)v27->uTextureHeight >> v20;
9216 v35.field_10 = v20 - v27->uWidthLn2 + 16;
9217 v35.field_C = v28 - 1;
9218 v35.field_8 = (v29 << 16) - 65536;
9219 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9220 {
9221 if ( byte_80AA10 )
9222 sr_sub_485D3E(&v35, &v34);
9223 else
9224 sr_sub_485C89(&v35, &v34);
9225 }
9226 else
9227 {
9228 if ( byte_80AA10 )
9229 sr_sub_4D72EC(v1);
9230 else
9231 sr_sub_4D73DF(v1);
9232 }
9233 return 1;
9234 }
9235
9236 //----- (004847EB) --------------------------------------------------------
9237 int sr_sub_4847EB(Span *_this)
9238 {
9239 stru315 *v1; // ebp@0
9240 int v2; // ebx@1
9241 int v3; // edx@1
9242 stru148 *v4; // esi@1
9243 int v5; // eax@1
9244 signed int v6; // eax@3
9245 int v7; // edi@3
9246 stru149 *v8; // eax@3
9247 stru149 *v9; // eax@3
9248 int v10; // edx@3
9249 int v11; // eax@3
9250 signed int v12; // ebx@3
9251 int v13; // ebx@4
9252 signed __int64 v14; // qtt@5
9253 int v15; // eax@5
9254 signed int v16; // ebx@5
9255 unsigned __int16 *v17; // ecx@6
9256 stru149 *v18; // eax@14
9257 stru149 *v19; // eax@14
9258 signed int v20; // eax@14
9259 int v21; // ecx@14
9260 Texture *v22; // edx@16
9261 signed int v23; // eax@16
9262 int v24; // ebx@16
9263 int v25; // edi@17
9264 int v26; // ebx@17
9265 int v27; // eax@17
9266 int v28; // edi@17
9267 int v29; // eax@18
9268 signed __int64 v30; // qtt@19
9269 int v31; // ecx@19
9270 int v32; // eax@19
9271 stru149 *v33; // eax@21
9272 signed int v34; // edi@21
9273 int v35; // ebx@21
9274 signed int v36; // edi@21
9275 signed __int64 v37; // qtt@21
9276 signed int v38; // ebx@21
9277 int v39; // ebx@29
9278 int v40; // eax@32
9279 unsigned __int64 v41; // qax@32
9280 int v42; // edi@32
9281 int v43; // eax@33
9282 signed __int64 v44; // qtt@34
9283 int v45; // ecx@34
9284 int v46; // eax@34
9285 stru149 *v47; // eax@36
9286 signed int v48; // edi@36
9287 int v49; // eax@36
9288 int v50; // eax@47
9289 unsigned __int64 v51; // qax@47
9290 int v52; // edi@47
9291 int v53; // eax@48
9292 signed __int64 v54; // qtt@49
9293 int v55; // ecx@49
9294 int v56; // eax@49
9295 stru149 *v57; // eax@51
9296 signed int v58; // edi@51
9297 int v59; // eax@51
9298 Span *v61; // [sp+Ch] [bp-B0h]@1
9299 int v62; // [sp+10h] [bp-ACh]@3
9300 int v63; // [sp+14h] [bp-A8h]@3
9301 int v64; // [sp+18h] [bp-A4h]@3
9302 int v65; // [sp+1Ch] [bp-A0h]@3
9303 signed int v66; // [sp+20h] [bp-9Ch]@3
9304 signed int v67; // [sp+24h] [bp-98h]@3
9305 int v68; // [sp+28h] [bp-94h]@1
9306 char v69; // [sp+2Ch] [bp-90h]@1
9307 stru315 sr; // [sp+30h] [bp-8Ch]@1
9308 stru316 sr2; // [sp+74h] [bp-48h]@14
9309 int v72; // [sp+9Ch] [bp-20h]@5
9310 int v73; // [sp+A0h] [bp-1Ch]@1
9311 int v74; // [sp+A4h] [bp-18h]@3
9312 int v75; // [sp+A8h] [bp-14h]@21
9313 int v76; // [sp+ACh] [bp-10h]@1
9314 int v77; // [sp+B0h] [bp-Ch]@14
9315 int v78; // [sp+B4h] [bp-8h]@3
9316 int v79; // [sp+B8h] [bp-4h]@3
9317
9318 v2 = _this->field_A;
9319 v3 = _this->field_8;
9320 v4 = _this->pParent;
9321 v73 = 0;
9322 v61 = _this;
9323 sr.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
9324 v76 = v3;
9325 v5 = _this->field_C;
9326 sr.pColorBuffer = &pRenderer->pTargetSurface[v3 + pRenderer->uTargetSurfacePitch * v2];
9327 v68 = texmapping_terrain_subdivsize;
9328 v69 = texmapping_terrain_subdivpow2;
9329 if ( v5 >= texmapping_terrain_subdivsize )
9330 v73 = texmapping_terrain_subdivsize - (v3 & (texmapping_terrain_subdivsize - 1));
9331 v6 = v5 - v73;
9332 v67 = v6 >> texmapping_terrain_subdivpow2;
9333 v62 = v6 - (v6 >> texmapping_terrain_subdivpow2 << texmapping_terrain_subdivpow2);
9334 v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
9335 v8 = v4->ptr_38;
9336 v79 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76);
9337 v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
9338 v76 = v8->field_14;
9339 v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
9340 v9 = v4->ptr_38;
9341 v10 = v78 + v9->field_C;
9342 v76 = v9->field_20;
9343 v65 = v10;
9344 v11 = ((unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16)
9345 + v4->ptr_38->field_18;
9346 v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
9347 v64 = v11;
9348 v76 = v4->v_18.z;
9349 v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16;
9350 v12 = -v4->field_24;
9351 v63 = v78 + v4->v_18.x;
9352 v66 = -v4->field_24;
9353 v78 = (unsigned __int64)(v79 * (signed __int64)v4->v_18.y) >> 16;
9354 v74 = v78 + v63;
9355 if ( !(v78 + v63) || (v76 = v12 >> 14, v13 = abs(v12 >> 14), v13 > abs(v74)) )
9356 return 0;
9357 LODWORD(v14) = v66 << 16;
9358 HIDWORD(v14) = v66 >> 16;
9359 v72 = v14 / v74;
9360 sr.pTextureLOD = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
9361 v15 = v14 / v74;
9362 v16 = 2;
9363 if ( v15 >= mipmapping_terrain_mm1 << 16 )
9364 {
9365 if ( v15 >= mipmapping_terrain_mm2 << 16 )
9366 {
9367 if ( v15 >= mipmapping_terrain_mm3 << 16 )
9368 {
9369 if ( bUseLoResSprites )
9370 goto LABEL_14;
9371 v16 = 3;
9372 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail3;
9373 }
9374 else
9375 {
9376 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2;
9377 }
9378 }
9379 else
9380 {
9381 v16 = 1;
9382 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail1;
9383 }
9384 }
9385 else
9386 {
9387 v16 = 0;
9388 v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0_prolly_alpha_mask;
9389 }
9390 sr.pTextureLOD = v17;
9391 LABEL_14:
9392 sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v15, v4, pOutdoorCamera->terrain_gamma, 1u, 1);
9393 v18 = v4->ptr_38;
9394 v78 = v7;
9395 v79 = v18->field_10;
9396 v78 = v7;
9397 v77 = v65 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
9398 v79 = v4->ptr_38->field_1C;
9399 v79 = v64 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16);
9400 v78 = (unsigned __int64)(v77 * (signed __int64)v72) >> 16;
9401 v19 = v4->ptr_38;
9402 v78 = v72;
9403 sr.field_30 = ((unsigned __int64)(v77 * (signed __int64)v72) >> 16) - v19->field_24;
9404 v78 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16;
9405 v20 = ((unsigned __int64)(v79 * (signed __int64)v72) >> 16) - v4->ptr_38->field_28;
9406 v21 = bUseLoResSprites + v16 + 2;
9407 sr.field_30 >>= v21;
9408 v78 = bUseLoResSprites + v16 + 2;
9409 sr.field_2C = v20 >> v21;
9410 if ( byte_80AA10 )
9411 {
9412 sr.field_14 = dword_80AA20 >> v21;
9413 sr.field_18 = dword_80AA1C >> v21;
9414 sr.field_1C = dword_80AA18 >> v21;
9415 sr.field_20 = dword_80AA14 >> v21;
9416 }
9417 v22 = v4->pTexture;
9418 v79 = (signed int)v22->uTextureWidth >> v16;
9419 v23 = (signed int)v22->uTextureHeight >> v16;
9420 v24 = v16 - v22->uWidthLn2 + 16;
9421 sr.field_8 = (v23 << 16) - 65536;
9422 sr.field_10 = v24;
9423 sr.field_C = v79 - 1;
9424 if ( v73 )
9425 {
9426 v25 = v7 - v73 * pOutdoorCamera->int_fov_rad_inv;
9427 v26 = v25;
9428 v77 = v4->v_18.y;
9429 v79 = v25;
9430 v27 = (unsigned __int64)(v77 * (signed __int64)v25) >> 16;
9431 v28 = v27 + v63;
9432 v74 = v27 + v63;
9433 if ( !(v27 + v63) || (v77 = abs(v76), v29 = abs(v28), v77 > v29) )
9434 return 0;
9435 LODWORD(v30) = v66 << 16;
9436 HIDWORD(v30) = v66 >> 16;
9437 v77 = v30 / v74;
9438 v31 = v30 / v74;
9439 HIWORD(v32) = HIWORD(v72);
9440 if ( v72 <= v31 )
9441 HIWORD(v32) = HIWORD(v31);
9442 LOWORD(v32) = 0;
9443 v77 = v26;
9444 sr.field_24 = v32;
9445 v74 = v4->ptr_38->field_10;
9446 v74 = v65 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
9447 v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
9448 v33 = v4->ptr_38;
9449 v77 = v26;
9450 v34 = ((unsigned __int64)(v74 * (signed __int64)v31) >> 16) - v33->field_24;
9451 v74 = v33->field_1C;
9452 v74 = v64 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16);
9453 v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16;
9454 v35 = (v77 - v4->ptr_38->field_28) >> v78;
9455 v74 = v73 << 16;
9456 v36 = (v34 >> v78) - sr.field_30;
9457 LODWORD(v37) = v36 << 16;
9458 HIDWORD(v37) = v36 >> 16;
9459 v38 = v35 - sr.field_2C;
9460 sr.field_4 = v37 / (v73 << 16);
9461 v75 = v73 << 16;
9462 LODWORD(v37) = v38 << 16;
9463 HIDWORD(v37) = v38 >> 16;
9464 v77 = v37 / (v73 << 16);
9465 sr.field_0 = v37 / (v73 << 16);
9466 sr.field_28 = v73;
9467 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9468 {
9469 if ( byte_80AA10 )
9470 sr_sub_485A24(&sr, (stru315 *)&sr2);
9471 else
9472 sr_sub_485975(&sr, (stru315 *)&sr2);
9473 }
9474 else
9475 {
9476 if ( byte_80AA10 )
9477 sr_sub_4D705A(v1);
9478 else
9479 sr_sub_4D6FB0(v1);
9480 }
9481 v39 = v79 - (pOutdoorCamera->int_fov_rad_inv << v69);
9482 }
9483 else
9484 {
9485 v79 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
9486 v39 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69);
9487 }
9488 sr.field_28 = v68;
9489 while ( v67 > 0 )
9490 {
9491 v40 = v4->v_18.y;
9492 --v67;
9493 v75 = v40;
9494 v41 = v40 * (signed __int64)v39;
9495 v79 = v41 >> 16;
9496 LODWORD(v41) = v41 >> 16;
9497 v42 = v41 + v63;
9498 v74 = v41 + v63;
9499 if ( !((int)v41 + v63) || (v75 = abs(v76), v43 = abs(v42), v75 > v43) )
9500 return 0;
9501 LODWORD(v44) = v66 << 16;
9502 HIDWORD(v44) = v66 >> 16;
9503 v73 = v44 / v74;
9504 v45 = v44 / v74;
9505 HIWORD(v46) = HIWORD(v72);
9506 if ( v72 <= v45 )
9507 HIWORD(v46) = HIWORD(v45);
9508 LOWORD(v46) = 0;
9509 v79 = v39;
9510 sr.field_24 = v46;
9511 v75 = v4->ptr_38->field_10;
9512 v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
9513 v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
9514 v47 = v4->ptr_38;
9515 v79 = v39;
9516 v48 = ((unsigned __int64)(v75 * (signed __int64)v45) >> 16) - v47->field_24;
9517 v75 = v47->field_1C;
9518 v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
9519 v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16;
9520 v49 = (((v79 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
9521 sr.field_4 = ((v48 >> v78) - sr.field_30) >> v69;
9522 sr.field_0 = v49;
9523 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9524 {
9525 if ( byte_80AA10 )
9526 sr_sub_485A24(&sr, (stru315 *)&sr2);
9527 else
9528 sr_sub_485975(&sr, (stru315 *)&sr2);
9529 }
9530 else
9531 {
9532 if ( byte_80AA10 )
9533 sr_sub_4D705A(v1);
9534 else
9535 sr_sub_4D6FB0(v1);
9536 }
9537 sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v73, v4, pOutdoorCamera->terrain_gamma, 1u, 0);
9538 sr.field_28 = v68;
9539 v39 -= pOutdoorCamera->int_fov_rad_inv << v69;
9540 }
9541 if ( !v62 )
9542 return 1;
9543 v50 = v4->v_18.y;
9544 v75 = v50;
9545 v51 = v50 * (signed __int64)v39;
9546 v79 = v51 >> 16;
9547 LODWORD(v51) = v51 >> 16;
9548 v52 = v51 + v63;
9549 v74 = v51 + v63;
9550 if ( (int)v51 + v63 )
9551 {
9552 v75 = abs(v76);
9553 v53 = abs(v52);
9554 if ( v75 <= v53 )
9555 {
9556 LODWORD(v54) = v66 << 16;
9557 HIDWORD(v54) = v66 >> 16;
9558 v76 = v54 / v74;
9559 v55 = v54 / v74;
9560 HIWORD(v56) = HIWORD(v72);
9561 if ( v72 <= v55 )
9562 HIWORD(v56) = HIWORD(v55);
9563 LOWORD(v56) = 0;
9564 v76 = v39;
9565 sr.field_24 = v56;
9566 v75 = v4->ptr_38->field_10;
9567 v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
9568 v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
9569 v57 = v4->ptr_38;
9570 v76 = v39;
9571 v58 = ((unsigned __int64)(v75 * (signed __int64)v55) >> 16) - v57->field_24;
9572 v75 = v57->field_1C;
9573 v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16);
9574 v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16;
9575 v59 = (((v76 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69;
9576 sr.field_4 = ((v58 >> v78) - sr.field_30) >> v69;
9577 sr.field_0 = v59;
9578 sr.field_28 = v62;
9579 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9580 {
9581 if ( byte_80AA10 )
9582 sr_sub_485A24(&sr, (stru315 *)&sr2);
9583 else
9584 sr_sub_485975(&sr, (stru315 *)&sr2);
9585 }
9586 else
9587 {
9588 if ( byte_80AA10 )
9589 sr_sub_4D705A(v1);
9590 else
9591 sr_sub_4D6FB0(v1);
9592 }
9593 return 1;
9594 }
9595 }
9596 return 0;
9597 }
9598 // 4D864C: using guessed type char byte_4D864C;
9599 // 6BE050: using guessed type int texmapping_terrain_subdivsize;
9600 // 6BE054: using guessed type int texmapping_terrain_subdivpow2;
9601 // 6BE0F0: using guessed type int mipmapping_terrain_mm1;
9602 // 6BE0F4: using guessed type int mipmapping_terrain_mm2;
9603 // 6BE0F8: using guessed type int mipmapping_terrain_mm3;
9604 // 80AA10: using guessed type char byte_80AA10;
9605 // 80AA14: using guessed type int dword_80AA14;
9606 // 80AA18: using guessed type int dword_80AA18;
9607 // 80AA1C: using guessed type int dword_80AA1C;
9608 // 80AA20: using guessed type int dword_80AA20;
9609
9610 //----- (00485407) --------------------------------------------------------
9611 signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(Span *a1)
9612 {
9613 stru315 *v1; // ebp@0
9614 int v2; // eax@1
9615 int v3; // edx@1
9616 unsigned int v4; // edi@1
9617 stru148 *v5; // esi@1
9618 int v6; // ecx@1
9619 int v7; // ebx@1
9620 int v8; // ecx@1
9621 stru149 *v9; // eax@1
9622 stru149 *v10; // eax@1
9623 int v11; // edx@1
9624 int v12; // eax@1
9625 int v13; // eax@1
9626 int v14; // ecx@1
9627 signed int v15; // edi@1
9628 int v16; // edi@2
9629 signed __int64 v17; // qtt@3
9630 int v18; // edi@3
9631 int v19; // eax@3
9632 unsigned __int8 *pLOD; // eax@3
9633 Texture *v21; // eax@4
9634 Texture *v22; // eax@6
9635 Texture *v23; // eax@8
9636 Texture *v24; // eax@10
9637 stru149 *v25; // eax@13
9638 stru149 *v26; // eax@13
9639 signed int v27; // ebx@13
9640 stru149 *v28; // eax@13
9641 Texture *v29; // esi@13
9642 signed int v30; // ebx@13
9643 signed int v31; // edi@13
9644 signed int v32; // edx@13
9645 signed int v33; // eax@13
9646 int v34; // esi@13
9647 int v35; // eax@13
9648 unsigned __int64 v36; // qax@13
9649 int v37; // eax@13
9650 unsigned __int64 v38; // qax@13
9651 char v39; // cl@14
9652 stru316 a2; // [sp+Ch] [bp-90h]@13
9653 stru315 a1a; // [sp+34h] [bp-68h]@1
9654 Span *v43; // [sp+78h] [bp-24h]@1
9655 int v44; // [sp+7Ch] [bp-20h]@1
9656 int v45; // [sp+80h] [bp-1Ch]@1
9657 int v46; // [sp+84h] [bp-18h]@1
9658 Span *v47; // [sp+88h] [bp-14h]@1
9659 int v48; // [sp+8Ch] [bp-10h]@1
9660 int v49; // [sp+90h] [bp-Ch]@3
9661 int i; // [sp+94h] [bp-8h]@3
9662 int X; // [sp+98h] [bp-4h]@1
9663
9664 v2 = a1->field_A;
9665 v3 = a1->field_8;
9666 v4 = v3 + pRenderer->uTargetSurfacePitch * a1->field_A;
9667 v5 = a1->pParent;
9668 v43 = a1;
9669 v6 = a1->field_C;
9670 a1a.pColorBuffer = &pRenderer->pTargetSurface[v4];
9671 v46 = v6;
9672 v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v3);
9673 v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2);
9674 a1a.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2];
9675 v9 = v5->ptr_38;
9676 v47 = (Span *)v7;
9677 X = v8;
9678 v48 = v9->field_14;
9679 X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
9680 v10 = v5->ptr_38;
9681 v11 = X + v10->field_C;
9682 v48 = v10->field_20;
9683 v44 = v11;
9684 v12 = ((unsigned __int64)(v48 * (signed __int64)v8) >> 16) + v5->ptr_38->field_18;
9685 X = v8;
9686 v45 = v12;
9687 v48 = v5->v_18.z;
9688 X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16;
9689 v13 = v5->v_18.y;
9690 v14 = X + v5->v_18.x;
9691 v15 = -v5->field_24;
9692 v48 = -v5->field_24;
9693 X = ((unsigned __int64)(v7 * (signed __int64)v13) >> 16) + v14;
9694 if ( !X || (v16 = abs(v15 >> 14), v16 > abs(X)) )
9695 return 0;
9696 LODWORD(v17) = v48 << 16;
9697 HIDWORD(v17) = v48 >> 16;
9698 i = v17 / X;
9699 v18 = v17 / X;
9700 HIWORD(v19) = (unsigned int)(v17 / X) >> 16;
9701 LOWORD(v19) = 0;
9702 a1a.field_24 = v19;
9703 pLOD = v5->pTexture->pLevelOfDetail2;
9704 a1a.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2;
9705 v49 = 2;
9706 if ( v18 >= mipmapping_terrain_mm1 << 16 )
9707 {
9708 if ( v18 >= mipmapping_terrain_mm2 << 16 )
9709 {
9710 if ( v18 >= mipmapping_terrain_mm3 << 16 )
9711 {
9712 if ( bUseLoResSprites )
9713 goto LABEL_12;
9714 v24 = v5->pTexture;
9715 v49 = 3;
9716 pLOD = v24->pLevelOfDetail3;
9717 }
9718 else
9719 {
9720 v23 = v5->pTexture;
9721 v49 = 2;
9722 pLOD = v23->pLevelOfDetail2;
9723 }
9724 }
9725 else
9726 {
9727 v22 = v5->pTexture;
9728 v49 = 1;
9729 pLOD = v22->pLevelOfDetail1;
9730 }
9731 }
9732 else
9733 {
9734 v21 = v5->pTexture;
9735 v49 = 0;
9736 pLOD = v21->pLevelOfDetail0_prolly_alpha_mask;
9737 }
9738 a1a.pTextureLOD = (unsigned __int16 *)pLOD;
9739 LABEL_12:
9740 if ( !pLOD )
9741 return 0;
9742 a1a.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v43, v18, v5, pOutdoorCamera->terrain_gamma, 1u, 1);
9743 a1a.field_28 = 16;
9744 v43 = (Span *)(v46 >> 4);
9745 X = v7;
9746 v25 = v5->ptr_38;
9747 v48 = v46 - 16 * (v46 >> 4);
9748 v46 = v25->field_10;
9749 X = v7;
9750 v46 = v44 + ((unsigned __int64)(v46 * (signed __int64)v7) >> 16);
9751 v44 = v5->ptr_38->field_1C;
9752 v45 += (unsigned __int64)(v44 * (signed __int64)v7) >> 16;
9753 X = (unsigned __int64)(v46 * (signed __int64)v18) >> 16;
9754 v26 = v5->ptr_38;
9755 X = v18;
9756 v27 = ((unsigned __int64)(v46 * (signed __int64)v18) >> 16) - v26->field_24;
9757 X = (unsigned __int64)(v45 * (signed __int64)v18) >> 16;
9758 v28 = v5->ptr_38;
9759 v29 = v5->pTexture;
9760 v44 = bUseLoResSprites + v49 + 2;
9761 v30 = v27 >> v44;
9762 v31 = (signed int)(((unsigned __int64)(v45 * (signed __int64)v18) >> 16) - v28->field_28) >> v44;
9763 v32 = (signed int)v29->uTextureWidth >> v49;
9764 v33 = (signed int)v29->uTextureHeight >> v49;
9765 v34 = v49 - v29->uWidthLn2;
9766 a1a.field_8 = (v33 << 16) - 65536;
9767 X = 2 * pMiscTimer->uTotalGameTimeElapsed;
9768 v45 = pOutdoorCamera->int_fov_rad_inv;
9769 a1a.field_10 = v34 + 16;
9770 a1a.field_C = v32 - 1;
9771 i = (unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)i) >> 16;
9772 v47 = (Span *)(i >> v44);
9773 v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
9774 v36 = (signed int)v47 * (signed __int64)v35;
9775 i = v36 >> 16;
9776 a1a.field_4 = v36 >> 16;
9777 v37 = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
9778 v38 = (signed int)v47 * (signed __int64)v37;
9779 i = v38 >> 16;
9780 a1a.field_0 = v38 >> 16;
9781 if ( (signed int)v43 > 0 )
9782 {
9783 v47 = v43;
9784 v39 = 12 - v49;
9785 for ( i = 12 - v49; ; v39 = i )
9786 {
9787 a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> v39));
9788 a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i));
9789 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9790 sr_sub_485975(&a1a, (stru315 *)&a2);
9791 else
9792 sr_sub_4D6FB0(v1);
9793 a1a.field_28 = 16;
9794 v30 += 16 * a1a.field_4;
9795 v31 += 16 * a1a.field_0;
9796 v47 = (Span *)((char *)v47 - 1);
9797 if ( !v47 )
9798 break;
9799 }
9800 }
9801 if ( v48 )
9802 {
9803 i = 12 - v49;
9804 a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> (12 - v49)));
9805 a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i));
9806 a1a.field_28 = v48;
9807 if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 )
9808 sr_sub_485975(&a1a, (stru315 *)&a2);
9809 else
9810 sr_sub_4D6FB0(v1);
9811 }
9812 return 1;
9813 }
9814
9815 //----- (0048585C) --------------------------------------------------------
9816 signed int __fastcall sr_sub_48585C_mb_DrawSpan(Span *a1, unsigned __int16 *pRenderTarget, int a4)
9817 {
9818 Span *v3; // esi@1
9819 stru148 *v4; // edi@1
9820 int v5; // ebx@2
9821 signed __int64 v6; // qtt@3
9822 int v7; // ebx@3
9823 signed int v8; // ecx@3
9824 void *v9; // eax@5
9825 int v10; // ecx@5
9826 unsigned __int16 *pPixels; // [sp+Ch] [bp-14h]@1
9827 signed int v13; // [sp+10h] [bp-10h]@1
9828 int X; // [sp+18h] [bp-8h]@1
9829
9830 v3 = a1;
9831 pPixels = pRenderTarget;
9832 v4 = a1->pParent;
9833 v13 = -v4->field_24;
9834 X = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv
9835 * (pViewport->uScreenCenterX - (signed int)a1->field_8)
9836 * (signed __int64)v4->v_18.y) >> 16)
9837 + ((unsigned __int64)(v4->v_18.z
9838 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv
9839 * (pViewport->uScreenCenterY - (signed int)a1->field_A))) >> 16)
9840 + v4->v_18.x;
9841 if ( X && (v5 = abs(-v4->field_24 >> 14), v5 <= abs(X)) )
9842 {
9843 LODWORD(v6) = v13 << 16;
9844 HIDWORD(v6) = v13 >> 16;
9845 v7 = v6 / X;
9846 v8 = v6 / X;
9847 }
9848 else
9849 {
9850 v7 = pOutdoorCamera->shading_dist_mist << 16;
9851 v8 = pOutdoorCamera->shading_dist_mist << 16;
9852 }
9853 v9 = sr_sub_47C178(v8, v4, pOutdoorCamera->terrain_gamma, a4);
9854 fill_pixels_fast(*((short *)v9 + v4->pTexture->uDecompressedSize), pPixels, v3->field_C);
9855 HIWORD(v10) = HIWORD(v7);
9856 LOWORD(v10) = 0;
9857 j_memset32(v10, &pRenderer->pActiveZBuffer[v3->field_8 + 640 * v3->field_A], v3->field_C);
9858 return 1;
9859 }
9860
9861 //----- (00485975) --------------------------------------------------------
9862 stru315 *__fastcall sr_sub_485975(stru315 *a1, stru315 *a2)
9863 {
9864 stru315 *result; // eax@1
9865 int i; // ecx@1
9866 int v4; // esi@2
9867 int v5; // esi@2
9868 int v6; // ecx@2
9869 int v7; // esi@3
9870 int v8; // edi@3
9871 int v9; // ebx@3
9872 int v10; // ecx@8
9873 unsigned __int16 *v11; // esi@10
9874 unsigned int *v12; // ecx@12
9875 int v13; // esi@12
9876 int v14; // [sp+0h] [bp-4h]@2
9877
9878 result = a1;
9879 for ( i = a1->field_28; i; i = result->field_28 )
9880 {
9881 v4 = result->field_8 & result->field_2C;
9882 result->field_28 = i - 1;
9883 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
9884 v6 = *((char *)result->pTextureLOD + v5);
9885 v14 = *((char *)result->pTextureLOD + v5);
9886 if ( a2->field_20 )
9887 {
9888 v7 = HIWORD(a2->field_10);
9889 v8 = a2->field_C;
9890 v9 = v7;
9891 if ( v7 >= v8 )
9892 v9 = a2->field_C;
9893 if ( a2->field_8 - v9 <= 0 )
9894 {
9895 v10 = 0;
9896 }
9897 else
9898 {
9899 if ( v7 >= v8 )
9900 v7 = a2->field_C;
9901 v10 = a2->field_8 - v7;
9902 }
9903 v11 = (unsigned __int16 *)a2->field_24;
9904 v6 = v14 + (v10 << 8);
9905 }
9906 else
9907 {
9908 v11 = result->field_34_palette;
9909 }
9910 *result->pColorBuffer = v11[v6];
9911 v12 = result->pDepthBuffer;
9912 v13 = result->field_24;
9913 ++result->pColorBuffer;
9914 *v12 = v13;
9915 ++result->pDepthBuffer;
9916 a2->field_10 += a2->field_18;
9917 result->field_30 += result->field_4;
9918 result->field_2C += result->field_0;
9919 }
9920 --result->field_28;
9921 return result;
9922 }
9923
9924 //----- (00485A24) --------------------------------------------------------
9925 stru315 *__fastcall sr_sub_485A24(stru315 *a1, stru315 *a2)
9926 {
9927 stru315 *result; // eax@1
9928 int i; // ecx@1
9929 int v4; // ecx@2
9930 int v5; // ecx@4
9931 int v6; // ecx@6
9932 int v7; // ecx@8
9933 int v8; // esi@10
9934 int v9; // ecx@10
9935 int v10; // esi@11
9936 int v11; // edi@11
9937 int v12; // ebx@11
9938 int v13; // ecx@16
9939 unsigned __int16 *v14; // esi@18
9940 unsigned int *v15; // ecx@20
9941 int v16; // esi@20
9942 int v17; // [sp+0h] [bp-4h]@10
9943
9944 result = a1;
9945 for ( i = a1->field_28; i; i = result->field_28 )
9946 {
9947 result->field_28 = i - 1;
9948 v4 = result->field_18;
9949 if ( result->field_30 > v4 )
9950 result->field_30 = v4;
9951 v5 = result->field_20;
9952 if ( result->field_2C > v5 )
9953 result->field_2C = v5;
9954 v6 = result->field_14;
9955 if ( result->field_30 < v6 )
9956 result->field_30 = v6;
9957 v7 = result->field_1C;
9958 if ( result->field_2C < v7 )
9959 result->field_2C = v7;
9960 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
9961 v9 = *((char *)result->pTextureLOD + v8);
9962 v17 = *((char *)result->pTextureLOD + v8);
9963 if ( a2->field_20 )
9964 {
9965 v10 = HIWORD(a2->field_10);
9966 v11 = a2->field_C;
9967 v12 = v10;
9968 if ( v10 >= v11 )
9969 v12 = a2->field_C;
9970 if ( a2->field_8 - v12 <= 0 )
9971 {
9972 v13 = 0;
9973 }
9974 else
9975 {
9976 if ( v10 >= v11 )
9977 v10 = a2->field_C;
9978 v13 = a2->field_8 - v10;
9979 }
9980 v14 = (unsigned __int16 *)a2->field_24;
9981 v9 = v17 + (v13 << 8);
9982 }
9983 else
9984 {
9985 v14 = result->field_34_palette;
9986 }
9987 *result->pColorBuffer = v14[v9];
9988 v15 = result->pDepthBuffer;
9989 v16 = result->field_24;
9990 ++result->pColorBuffer;
9991 *v15 = v16;
9992 ++result->pDepthBuffer;
9993 a2->field_10 += a2->field_18;
9994 result->field_30 += result->field_4;
9995 result->field_2C += result->field_0;
9996 }
9997 --result->field_28;
9998 return result;
9999 }
10000
10001 //----- (00485AFF) --------------------------------------------------------
10002 stru315 *__fastcall sr_sub_485AFF(stru315 *a1, stru316 *a2)
10003 {
10004 stru315 *result; // eax@1
10005 int i; // ecx@1
10006 int v4; // esi@2
10007 int v5; // esi@2
10008 int v6; // ecx@2
10009 int v7; // esi@3
10010 int v8; // edi@3
10011 int v9; // ebx@3
10012 int v10; // ecx@8
10013 unsigned __int16 *v11; // esi@10
10014 unsigned int *v12; // ecx@12
10015 int v13; // esi@12
10016 int v14; // [sp+0h] [bp-4h]@2
10017
10018 result = a1;
10019 for ( i = a1->field_28; i; i = result->field_28 )
10020 {
10021 v4 = result->field_8 & result->field_2C;
10022 result->field_28 = i - 1;
10023 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
10024 v6 = *((char *)result->pTextureLOD + v5);
10025 v14 = *((char *)result->pTextureLOD + v5);
10026 if ( a2->field_20 )
10027 {
10028 v7 = HIWORD(a2->field_14);
10029 v8 = a2->field_C;
10030 v9 = v7;
10031 if ( v7 >= v8 )
10032 v9 = a2->field_C;
10033 if ( a2->field_8 - v9 <= 0 )
10034 {
10035 v10 = 0;
10036 }
10037 else
10038 {
10039 if ( v7 >= v8 )
10040 v7 = a2->field_C;
10041 v10 = a2->field_8 - v7;
10042 }
10043 v11 = a2->field_24_palette;
10044 v6 = v14 + (v10 << 8);
10045 }
10046 else
10047 {
10048 v11 = result->field_34_palette;
10049 }
10050 *result->pColorBuffer = v11[v6];
10051 v12 = result->pDepthBuffer;
10052 v13 = result->field_24;
10053 --result->pColorBuffer;
10054 *v12 = v13;
10055 --result->pDepthBuffer;
10056 a2->field_14 -= a2->field_18;
10057 result->field_30 += result->field_4;
10058 result->field_2C += result->field_0;
10059 }
10060 --result->field_28;
10061 return result;
10062 }
10063
10064 //----- (00485BAE) --------------------------------------------------------
10065 stru315 *__fastcall sr_sub_485BAE(stru315 *a1, stru316 *a2)
10066 {
10067 stru315 *result; // eax@1
10068 int i; // ecx@1
10069 int v4; // ecx@2
10070 int v5; // ecx@4
10071 int v6; // ecx@6
10072 int v7; // ecx@8
10073 int v8; // esi@10
10074 int v9; // ecx@10
10075 int v10; // esi@11
10076 int v11; // edi@11
10077 int v12; // ebx@11
10078 int v13; // ecx@16
10079 unsigned __int16 *v14; // esi@18
10080 unsigned int *v15; // ecx@20
10081 int v16; // esi@20
10082 int v17; // [sp+0h] [bp-4h]@10
10083
10084 result = a1;
10085 for ( i = a1->field_28; i; i = result->field_28 )
10086 {
10087 result->field_28 = i - 1;
10088 v4 = result->field_18;
10089 if ( result->field_30 > v4 )
10090 result->field_30 = v4;
10091 v5 = result->field_20;
10092 if ( result->field_2C > v5 )
10093 result->field_2C = v5;
10094 v6 = result->field_14;
10095 if ( result->field_30 < v6 )
10096 result->field_30 = v6;
10097 v7 = result->field_1C;
10098 if ( result->field_2C < v7 )
10099 result->field_2C = v7;
10100 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
10101 v9 = *((char *)result->pTextureLOD + v8);
10102 v17 = *((char *)result->pTextureLOD + v8);
10103 if ( a2->field_20 )
10104 {
10105 v10 = HIWORD(a2->field_14);
10106 v11 = a2->field_C;
10107 v12 = v10;
10108 if ( v10 >= v11 )
10109 v12 = a2->field_C;
10110 if ( a2->field_8 - v12 <= 0 )
10111 {
10112 v13 = 0;
10113 }
10114 else
10115 {
10116 if ( v10 >= v11 )
10117 v10 = a2->field_C;
10118 v13 = a2->field_8 - v10;
10119 }
10120 v14 = a2->field_24_palette;
10121 v9 = v17 + (v13 << 8);
10122 }
10123 else
10124 {
10125 v14 = result->field_34_palette;
10126 }
10127 *result->pColorBuffer = v14[v9];
10128 v15 = result->pDepthBuffer;
10129 v16 = result->field_24;
10130 --result->pColorBuffer;
10131 *v15 = v16;
10132 --result->pDepthBuffer;
10133 a2->field_14 -= a2->field_18;
10134 result->field_30 += result->field_4;
10135 result->field_2C += result->field_0;
10136 }
10137 --result->field_28;
10138 return result;
10139 }
10140
10141 //----- (00485C89) --------------------------------------------------------
10142 stru315 *__fastcall sr_sub_485C89(stru315 *a1, stru316 *a2)
10143 {
10144 stru315 *result; // eax@1
10145 int i; // ecx@1
10146 int v4; // esi@2
10147 int v5; // esi@2
10148 int v6; // ecx@2
10149 int v7; // esi@4
10150 int v8; // edi@4
10151 int v9; // ecx@9
10152 unsigned __int16 *v10; // esi@11
10153 unsigned int *v11; // ecx@14
10154 int v12; // esi@14
10155 int v13; // [sp+0h] [bp-4h]@2
10156
10157 result = a1;
10158 for ( i = a1->field_28; i; i = result->field_28 )
10159 {
10160 v4 = result->field_8 & result->field_2C;
10161 result->field_28 = i - 1;
10162 v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10);
10163 v6 = *((char *)result->pTextureLOD + v5);
10164 v13 = *((char *)result->pTextureLOD + v5);
10165 if ( *((char *)result->pTextureLOD + v5) )
10166 {
10167 if ( a2->field_20 )
10168 {
10169 v7 = HIWORD(a2->field_10);
10170 v8 = v7;
10171 if ( v7 >= a2->field_C )
10172 v8 = a2->field_C;
10173 if ( a2->field_8 - v8 <= 0 )
10174 {
10175 v9 = 0;
10176 }
10177 else
10178 {
10179 if ( v7 >= a2->field_C )
10180 v7 = a2->field_C;
10181 v9 = a2->field_8 - v7;
10182 }
10183 v10 = a2->field_24_palette;
10184 v6 = v13 + (v9 << 8);
10185 }
10186 else
10187 {
10188 v10 = result->field_34_palette;
10189 }
10190 *result->pColorBuffer = v10[v6];
10191 }
10192 v11 = result->pDepthBuffer;
10193 v12 = result->field_24;
10194 ++result->pColorBuffer;
10195 *v11 = v12;
10196 ++result->pDepthBuffer;
10197 a2->field_10 += a2->field_18;
10198 result->field_30 += result->field_4;
10199 result->field_2C += result->field_0;
10200 }
10201 --result->field_28;
10202 return result;
10203 }
10204
10205 //----- (00485D3E) --------------------------------------------------------
10206 stru315 *__fastcall sr_sub_485D3E(stru315 *a1, stru316 *a2)
10207 {
10208 stru315 *result; // eax@1
10209 int i; // ecx@1
10210 int v4; // ecx@2
10211 int v5; // ecx@4
10212 int v6; // ecx@6
10213 int v7; // ecx@8
10214 int v8; // esi@10
10215 int v9; // ecx@10
10216 int v10; // esi@12
10217 int v11; // edi@12
10218 int v12; // ecx@17
10219 unsigned __int16 *v13; // esi@19
10220 unsigned int *v14; // ecx@22
10221 int v15; // esi@22
10222 int v16; // [sp+0h] [bp-4h]@10
10223
10224 result = a1;
10225 for ( i = a1->field_28; i; i = result->field_28 )
10226 {
10227 result->field_28 = i - 1;
10228 v4 = result->field_18;
10229 if ( result->field_30 > v4 )
10230 result->field_30 = v4;
10231 v5 = result->field_20;
10232 if ( result->field_2C > v5 )
10233 result->field_2C = v5;
10234 v6 = result->field_14;
10235 if ( result->field_30 < v6 )
10236 result->field_30 = v6;
10237 v7 = result->field_1C;
10238 if ( result->field_2C < v7 )
10239 result->field_2C = v7;
10240 v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10);
10241 v9 = *((char *)result->pTextureLOD + v8);
10242 v16 = *((char *)result->pTextureLOD + v8);
10243 if ( *((char *)result->pTextureLOD + v8) )
10244 {
10245 if ( a2->field_20 )
10246 {
10247 v10 = HIWORD(a2->field_10);
10248 v11 = v10;
10249 if ( v10 >= a2->field_C )
10250 v11 = a2->field_C;
10251 if ( a2->field_8 - v11 <= 0 )
10252 {
10253 v12 = 0;
10254 }
10255 else
10256 {
10257 if ( v10 >= a2->field_C )
10258 v10 = a2->field_C;
10259 v12 = a2->field_8 - v10;
10260 }
10261 v13 = a2->field_24_palette;
10262 v9 = v16 + (v12 << 8);
10263 }
10264 else
10265 {
10266 v13 = result->field_34_palette;
10267 }
10268 *result->pColorBuffer = v13[v9];
10269 }
10270 v14 = result->pDepthBuffer;
10271 v15 = result->field_24;
10272 ++result->pColorBuffer;
10273 *v14 = v15;
10274 ++result->pDepthBuffer;
10275 a2->field_10 += a2->field_18;
10276 result->field_30 += result->field_4;
10277 result->field_2C += result->field_0;
10278 }
10279 --result->field_28;
10280 return result;
10281 }
10282
10283 //----- (00485E1F) --------------------------------------------------------
10284 void *__fastcall sr_sub_485E1F(stru316 *a1, Span *a2, int a3, stru148 *a4, int a5, unsigned __int8 a6, char a7)
10285 {
10286 stru316 *v7; // esi@1
10287 signed int *v8; // edi@1
10288 signed int *v9; // ebx@1
10289 char v10; // zf@1
10290 int v11; // eax@1
10291 Span *v12; // ecx@3
10292 double v13; // ST24_8@3
10293 double v14; // ST24_8@3
10294 int v15; // eax@3
10295 signed int v16; // ST14_4@4
10296 char v17; // dl@4
10297 signed int v18; // ST10_4@4
10298 void *v19; // eax@4
10299 signed int v20; // ST14_4@5
10300 char v21; // dl@5
10301 int v22; // ST10_4@5
10302 signed int v23; // ST14_4@6
10303 char v24; // dl@6
10304 Span *v26; // [sp+10h] [bp-8h]@1
10305 char v27; // [sp+16h] [bp-2h]@1
10306 char v28; // [sp+17h] [bp-1h]@1
10307 float v29; // [sp+30h] [bp+18h]@3
10308 float v30; // [sp+30h] [bp+18h]@3
10309
10310 v7 = a1;
10311 v26 = a2;
10312 v8 = &a1->field_C;
10313 v9 = &a1->field_8;
10314 v10 = a1->field_0 == 0;
10315 v27 = a1->field_4 != 0;
10316 v28 = !v10;
10317 sr_sub_47BEB1(a3, a4, a5, 0, &a1->field_8, &a1->field_C, (int)&v27, (int)&v28);
10318 v7->field_24_palette = (unsigned __int16 *)sr_sub_47C28C_get_palette(a4, v28, *v9, *v8);
10319 v11 = a4->field_108;
10320 v7->field_20 = v11;
10321 if ( v11 )
10322 {
10323 if ( a7 )
10324 {
10325 v12 = v26;
10326 v29 = v26->field_10 * 31.0;
10327 v13 = v29 + 6.7553994e15;
10328 v7->field_10 = LODWORD(v13) << 16;
10329 v30 = v12->field_14 * 31.0;
10330 v14 = v30 + 6.7553994e15;
10331 v15 = v7->field_10;
10332 v7->field_14 = LODWORD(v14) << 16;
10333 v7->field_18 = -((v15 - (LODWORD(v14) << 16)) / v12->field_C);
10334 }
10335 v16 = *v8;
10336 v17 = v28;
10337 v18 = *v9;
10338 v7->field_1C = a6;
10339 v19 = sr_sub_47C28C_get_palette(a4, v17, v18, v16);
10340 }
10341 else
10342 {
10343 v20 = *v8;
10344 v21 = v28;
10345 v7->field_10 = 0;
10346 v7->field_14 = 0;
10347 v22 = *v9;
10348 v7->field_18 = 0;
10349 v7->field_1C = 0;
10350 v19 = sr_sub_47C1CA(a4, v21, v22, v20);
10351 }
10352 v23 = *v8;
10353 v24 = v28;
10354 v7->field_24_palette = (unsigned __int16 *)v19;
10355 return sr_sub_47C1CA(a4, v24, *v9, v23);
10356 }
10357 6455
10358 //----- (00485F53) -------------------------------------------------------- 6456 //----- (00485F53) --------------------------------------------------------
10359 void __thiscall sub_485F53(Vec2_int_ *v) 6457 void __thiscall sr_485F53(Vec2_int_ *v)
10360 { 6458 {
10361 ++v->y; 6459 ++v->y;
10362 if ( v->y > 1000 ) 6460 if ( v->y > 1000 )
10363 v->y = 0; 6461 v->y = 0;
10364 } 6462 }
10365 6463
10366 //----- (0048607B) -------------------------------------------------------- 6464 //----- (0048607B) --------------------------------------------------------
10367 void stru148::_48607B(stru149 *a2) 6465 void Polygon::_48607B(stru149 *a2)
10368 { 6466 {
10369 this->pTexture = 0; 6467 this->pTexture = 0;
10370 this->ptr_38 = a2; 6468 this->ptr_38 = a2;
10371 } 6469 }
10372 6470
10373 //----- (00486089) -------------------------------------------------------- 6471 //----- (00486089) --------------------------------------------------------
10374 void stru148::_486089_normalize_v_18() 6472 void Polygon::_486089_normalize_v_18()
10375 { 6473 {
10376 //stru148 *v1; // esi@1 6474 //Polygon *v1; // esi@1
10377 double v2; // st7@1 6475 double v2; // st7@1
10378 double v3; // st6@1 6476 double v3; // st6@1
10379 float v4; // ST18_4@2 6477 float v4; // ST18_4@2
10380 double v5; // st5@1 6478 double v5; // st5@1
10381 float v6; // ST14_4@2 6479 float v6; // ST14_4@2
10526 this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16); 6624 this->field_28 = v29 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
10527 return result; 6625 return result;
10528 } 6626 }
10529 6627
10530 //----- (0048694B) -------------------------------------------------------- 6628 //----- (0048694B) --------------------------------------------------------
10531 void stru149::sky_48694B() 6629 int stru149::sky_48694B()
10532 { 6630 {
6631 int v1; // eax@1
6632 int v2; // ST04_4@1
6633 int v3; // ST00_4@1
6634 int v4; // eax@1
6635 int v5; // ST0C_4@1
6636 int result; // eax@1
6637
6638 v1 = this->field_C;
10533 this->field_18 = -this->field_18; 6639 this->field_18 = -this->field_18;
10534 this->field_1C = -this->field_1C; 6640 this->field_1C = -this->field_1C;
10535 this->field_20 = -this->field_20; 6641 this->field_20 = -this->field_20;
10536 this->field_24 = (unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16 6642 v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0_party_dir_x) >> 16;
6643 v3 = this->field_18;
6644 v4 = this->field_0_party_dir_x;
6645 this->field_24 = v2
10537 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16) 6646 + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16)
10538 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16); 6647 + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16);
10539 this->field_28 = (unsigned __int64)(this->field_18 * (signed __int64)this->field_0_party_dir_x) >> 16 6648 v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16;
10540 + (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16 6649 result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16;
10541 + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16); 6650 this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16);
10542 } 6651 return result;
10543 6652 }
10544 //----- (00486B4E) -------------------------------------------------------- 6653
10545 char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)//maybe DrawPolygonSW
10546 {
10547 stru148 *v4; // esi@1
10548 RenderVertexSoft *v5; // edi@1
10549 char v6; // zf@1
10550 unsigned int v7; // eax@3
10551 int v8; // ebx@3
10552 int *v9; // ecx@7
10553 int v10; // ebx@8
10554 int v11; // eax@10
10555 double v12; // st7@14
10556 int *v13; // edx@14
10557 double v14; // st6@14
10558 double v15; // st7@16
10559 int v16; // edi@16
10560 double v17; // st7@16
10561 double v18; // st7@16
10562 int v19; // edi@18
10563 double v20; // st7@18
10564 double v21; // st7@18
10565 Edge *i; // edx@20
10566 double v23; // st7@28
10567 Edge *v24; // eax@28
10568 std::string v26; // [sp-18h] [bp-98h]@2
10569 const char *v27; // [sp-8h] [bp-88h]@2
10570 int v28; // [sp-4h] [bp-84h]@2
10571 double v29; // [sp+Ch] [bp-74h]@28
10572 double v30; // [sp+14h] [bp-6Ch]@28
10573 double v31; // [sp+1Ch] [bp-64h]@20
10574 double v32; // [sp+24h] [bp-5Ch]@16
10575 double v33; // [sp+2Ch] [bp-54h]@14
10576 unsigned int v34; // [sp+34h] [bp-4Ch]@2
10577 unsigned __int64 v35; // [sp+38h] [bp-48h]@28
10578 int v36; // [sp+40h] [bp-40h]@28
10579 int v37; // [sp+44h] [bp-3Ch]@20
10580 float v38; // [sp+48h] [bp-38h]@18
10581 int v39; // [sp+4Ch] [bp-34h]@16
10582 int v40; // [sp+50h] [bp-30h]@14
10583 int v41; // [sp+54h] [bp-2Ch]@3
10584 RenderVertexSoft *v42; // [sp+58h] [bp-28h]@1
10585 int v43; // [sp+5Ch] [bp-24h]@14
10586 int v44; // [sp+60h] [bp-20h]@6
10587 int v45; // [sp+64h] [bp-1Ch]@6
10588 unsigned int v46; // [sp+68h] [bp-18h]@7
10589 int *v47; // [sp+6Ch] [bp-14h]@1
10590 int v48; // [sp+70h] [bp-10h]@7
10591 float *v49; // [sp+74h] [bp-Ch]@7
10592 float v50; // [sp+78h] [bp-8h]@10
10593 float v51; // [sp+7Ch] [bp-4h]@14
10594
10595 v4 = a4;
10596 v5 = a1;
10597 v47 = a2;
10598 v6 = (HIBYTE(a4->flags) & 0x40) == 0;
10599 v42 = a1;
10600 if ( !v6 )
10601 {
10602 MessageBoxW(nullptr, L"The Texture Frame Table is not a supported feature.", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odspan.cpp:162", 0);
10603 }
10604 LOBYTE(v7) = v4->field_108;
10605 v8 = v4->uNumVertices;
10606 v4->field_108 = 0;
10607 BYTE3(a4) = v7;
10608 v41 = v8;
10609 if ( v8 > 0 )
10610 {
10611 if ( (signed int)pOutdoorCamera->uNumSurfs < 1999 )
10612 {
10613 v7 = pOutdoorCamera->uNumEdges;
10614 if ( (signed int)pOutdoorCamera->uNumEdges < 5979 )
10615 {
10616 v4->uEdgeList1Size = 0;
10617 v4->uEdgeList2Size = 0;
10618 v45 = -1;
10619 v34 = v7;
10620 v28 = v8;
10621 v27 = (const char *)v5;
10622 v44 = 10000;
10623 pGame->pLightmapBuilder->_45CB89(v5, v8);
10624 if ( v8 > 0 )
10625 {
10626 v9 = a3;
10627 v48 = 1;
10628 v49 = &v5->flt_2C;
10629 v46 = (char *)v47 - (char *)a3;
10630 do
10631 {
10632 v10 = v48;
10633 ++pOutdoorCamera->uNumEdges;
10634 if ( v48 >= v41 )
10635 v10 = 0;
10636 v11 = *v9;
10637 LODWORD(v50) = *v9;
10638 if ( SLODWORD(v50) > v45 )
10639 v45 = v11;
10640 if ( v11 < v44 )
10641 v44 = v11;
10642 v12 = (double)SLODWORD(v50);
10643 v13 = &a3[v10];
10644 v51 = v12;
10645 v14 = (double)*v13;
10646 v50 = v14;
10647 *(float *)&v40 = v14 - v12;
10648 v33 = *(float *)&v40 + 6.7553994e15;
10649 v43 = LODWORD(v33);
10650 if ( LODWORD(v33) )
10651 {
10652 if ( SLODWORD(v33) >= 0 )
10653 {
10654 v19 = (int)((char *)v9 + v46);
10655 ptr_80C978_Edges->field_8 = 1;
10656 LODWORD(v38) = (int)&v47[v10];
10657 v40 = *(unsigned int *)LODWORD(v38) - *(int *)v19;
10658 v6 = BYTE3(a4) == 0;
10659 v20 = (double)v40;
10660 v40 = *v13 - *v9;
10661 v21 = v20 / (double)v40;
10662 ptr_80C978_Edges->field_4 = v21;
10663 ptr_80C978_Edges->field_0 = (v51 - (double)*v9) * v21 + (double)*(signed int *)v19;
10664 if ( !v6 )
10665 {
10666 ptr_80C978_Edges->field_1C = *v49;
10667 ptr_80C978_Edges->field_20 = v42[v10].flt_2C;
10668 ptr_80C978_Edges->field_24 = (double)*(signed int *)v19;
10669 ptr_80C978_Edges->field_28 = (double)(signed int)*(unsigned int *)LODWORD(v38);
10670 ptr_80C978_Edges->field_2C = (double)*v9;
10671 ptr_80C978_Edges->field_30 = (double)*v13;
10672 v4->pEdgeList1[v4->uEdgeList1Size++] = ptr_80C978_Edges;
10673 }
10674 }
10675 else
10676 {
10677 v32 = v51 + 6.7553994e15;
10678 v39 = LODWORD(v32);
10679 v51 = v50;
10680 v15 = (double)SLODWORD(v32);
10681 ptr_80C978_Edges->field_8 = 0;
10682 v16 = (int)&v47[v10];
10683 v50 = v15;
10684 v40 = *(int *)((char *)v9 + v46) - *(int *)v16;
10685 v6 = BYTE3(a4) == 0;
10686 v17 = (double)v40;
10687 v40 = *v9 - *v13;
10688 v18 = v17 / (double)v40;
10689 ptr_80C978_Edges->field_4 = v18;
10690 ptr_80C978_Edges->field_0 = (v51 - (double)*v13) * v18 + (double)*(signed int *)v16;
10691 if ( !v6 )
10692 {
10693 ptr_80C978_Edges->field_1C = v42[v10].flt_2C;
10694 ptr_80C978_Edges->field_20 = *v49;
10695 ptr_80C978_Edges->field_24 = (double)*(signed int *)v16;
10696 ptr_80C978_Edges->field_28 = (double)*(int *)((char *)v9 + v46);
10697 ptr_80C978_Edges->field_2C = (double)*v13;
10698 ptr_80C978_Edges->field_30 = (double)*v9;
10699 v4->pEdgeList2[v4->uEdgeList2Size++] = ptr_80C978_Edges;
10700 }
10701 }
10702 v31 = v51 + 6.7553994e15;
10703 v37 = LODWORD(v31);
10704 for ( i = &pNewEdges[LODWORD(v31)]; i->pNext->field_0 < (double)ptr_80C978_Edges->field_0; i = i->pNext )
10705 ;
10706 if ( i->field_0 != ptr_80C978_Edges->field_0 || i->field_8 || ptr_80C978_Edges->field_8 != 1 )
10707 {
10708 ptr_80C978_Edges->pNext = i->pNext;
10709 i->pNext = ptr_80C978_Edges;
10710 }
10711 else
10712 {
10713 ptr_80C978_Edges->pNext = i;
10714 i->pPrev->pNext = ptr_80C978_Edges;
10715 }
10716 v23 = v50 - 1.0;
10717 *(float *)&v40 = v23;
10718 v38 = v23;
10719 v30 = v38 + 6.7553994e15;
10720 v36 = LODWORD(v30);
10721 ptr_80C978_Edges->ptr_18 = ptr_80CA10[LODWORD(v30)];
10722 v29 = *(float *)&v40 + 6.7553994e15;
10723 v35 = __PAIR__(v40, LODWORD(v29));
10724 v24 = ptr_80C978_Edges;
10725 ptr_80CA10[LODWORD(v29)] = ptr_80C978_Edges;
10726 v24->pSurf = ptr_80C97C_Surfs;
10727 if ( ptr_80C978_Edges < &pEdges[5999] )
10728 ++ptr_80C978_Edges;
10729 }
10730 ++v48;
10731 v49 += 12;
10732 ++v9;
10733 }
10734 while ( v48 - 1 < v41 );
10735 }
10736 LOBYTE(v7) = v34;
10737 if ( pOutdoorCamera->uNumEdges != v34 )
10738 {
10739 v4->ptr_48 = 0;
10740 ptr_80C97C_Surfs->field_22 = 0;
10741 ptr_80C97C_Surfs->pParent = v4;
10742 ptr_80C97C_Surfs->field_4 = v4->field_4;
10743 ptr_80C97C_Surfs->field_8 = v4->field_8;
10744 ptr_80C97C_Surfs->field_0 = v4->field_0;
10745 ptr_80C97C_Surfs->field_C = v4->field_C;
10746 ptr_80C97C_Surfs->field_10 = v4->field_10;
10747 LOBYTE(v7) = (char)pSurfs + 28;
10748 if ( ptr_80C97C_Surfs < &pSurfs[1999] )
10749 {
10750 ++ptr_80C97C_Surfs;
10751 ++pOutdoorCamera->uNumSurfs;
10752 }
10753 if ( BYTE3(a4) )
10754 v4->field_108 = 1;
10755 }
10756 }
10757 }
10758 }
10759 return v7;
10760 }
10761 6654
10762 //----- (00440DF5) -------------------------------------------------------- 6655 //----- (00440DF5) --------------------------------------------------------
10763 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr) 6656 int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr)
10764 { 6657 {
10765 int result; // eax@1 6658 int result; // eax@1