#include "CGFXSpec.h"
#include "CGfxCrowd.h"

#include "CCrowdNewShader.h"
#include "CFTTBatchModelManager.h"
#include "CFTTCamera.h"
#include "CFTTMaterialManager.h"
#include "CFTTShaderBuiltInConstants.h"
#include "CFTTTextureManager.h"
#include "CGaussianNewShader.h"
#include "CGfxEnvironmentMap.h"
#include "CGfxKits.h"
#include "CGfxPlayer.h"
#include "CGraphicsTexLoadOptions.h"
#include "CModelManager.h"
#include "CPlayerShader.h"
#include "FTT2D.h"
#include "GFXSCENE.h"
#include "Matrix.h"
#include "TGame.h"
#include "XSYS.h"
#include "memctrl.h"
#include <algorithm>
#include "FTTArray.h"
CGfxCrowd *CGfxCrowd::ms_pInstance = nullptr;

MYCONST uchar byte_2FDF94[] = {0, 0, 0, 0, 1, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4};
MYCONST uchar byte_2FEFF4[15] = {5, 4, 0, 0xC, 1, 5, 4, 0, 0xC, 1, 3, 2, 0, 3, 3};
MYCONST uchar byte_2FF003[180] = {
    3,    3,   0xE,  0xE, 0x10, 0,   0, 0, 0,   0, 0, 0, 2, 3,   6,
    0x11, 0,   0,    0,   0,    0,   0, 0, 0,   0, 0, 0, 0, 0,   0,
    0,    0,   0,    0,   0,    0,   0, 1, 5,   4, 7, 8, 9, 0xA, 0xC,
    0xD,  0xE, 0xF,  3,   0,    0,   0, 0, 0,   0, 0, 0, 0, 0,   0,
    3,    3,   0xE,  0xE, 0x10, 0,   0, 0, 0,   0, 0, 0, 2, 3,   6,
    0x11, 0,   0,    0,   0,    0,   0, 0, 0,   0, 0, 0, 0, 0,   0,
    0,    0,   0,    0,   0,    0,   0, 1, 5,   4, 7, 8, 9, 0xA, 0xC,
    0xD,  0xE, 0xF,  3,   0,    0,   0, 0, 0,   0, 0, 0, 0, 0,   0,
    3,    3,   0x10, 0,   0,    0,   0, 0, 0,   0, 0, 0, 2, 3,   0,
    0,    0,   0,    0,   0,    0,   0, 0, 0,   0, 0, 0, 0, 0,   0,
    0,    0,   0,    0,   0,    0,   3, 4, 0xA, 0, 0, 0, 0, 0,   0,
    0,    0,   0,    3,   4,    0xA, 0, 0, 0,   0, 0, 0, 0, 0,   0};

MYCONST uchar byte_2FF0B7[] = {0x12, 0x13, 0x14, 0, 0, 0, 0, 0, 0, 0, 0, 0};

MYCONST uchar byte_2FF0C3[] = {0, 0, 0, 0, 0};
MYCONST int dword_2FF0C8[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
                            2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};

struct byte5 {
  uchar b_0;
  uchar b_1;
  uchar b_2;
  uchar b_3;
  uchar b_4;
};
MYCONST byte5 byte5_2FF148[] = {
    {5, 4, 0, 0xC, 1}, {5, 4, 0, 0xC, 1}, {2, 2, 2, 0, 0}};

MYCONST uchar byte_2FF157[] = {
    3, 6, 0xE, 0xE, 0x10, 0,   0,   0,   0, 0, 0, 0, 2, 3, 6, 0x11, 0, 0, 0, 0,
    0, 0, 0,   0,   0,    0,   0,   0,   0, 0, 0, 0, 0, 0, 0, 0,    0, 1, 5, 4,
    7, 8, 9,   0xA, 0xC,  0xD, 0xE, 0xF, 3, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0,
    3, 6, 0xE, 0xE, 0x10, 0,   0,   0,   0, 0, 0, 0, 2, 3, 6, 0x11, 0, 0, 0, 0,
    0, 0, 0,   0,   0,    0,   0,   0,   0, 0, 0, 0, 0, 0, 0, 0,    0, 1, 5, 4,
    7, 8, 9,   0xA, 0xC,  0xD, 0xE, 0xF, 3, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0,
    3, 3, 0,   0,   0,    0,   0,   0,   0, 0, 0, 0, 2, 3, 0, 0,    0, 0, 0, 0,
    0, 0, 0,   0,   4,    0xA, 0,   0,   0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0,
    0, 0, 0,   0,   0,    0,   0,   0,   0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0,
    0};
struct Unknow_4630E0 {
  uchar byte_4630E0[8];
  uchar byte_4630E8[0x10];
} t_4630e0;
//0019ED8C ^_-
//单元测试等级: 游戏运行正常
//单元测试内容: 启动游戏到第10关
//单元测试结果: 正常
void sub_19ED8C(CFTTMatrix32 &r0_pmatrix, CFTTVector32 *r1_pvector32,
                CFTTVector32 *r2_pvector32, CFTTVector32 *r3_pvector32,
                CFTTVector32 *sp0_pvector32) {
  // r12=sp0_pvector32
  float s2_f = sp0_pvector32->float_0 - r3_pvector32->float_0;
  float s0_f = r2_pvector32->float_0 - r1_pvector32->float_0;
  r0_pmatrix.d[0][0] = s2_f / s0_f;
  r0_pmatrix.d[0][1] = 0;
  r0_pmatrix.d[1][0] = 0;
  r0_pmatrix.d[2][0] = 0;
  s2_f = r3_pvector32->float_0 * r2_pvector32->float_0 -
         sp0_pvector32->float_0 * r1_pvector32->float_0;
  s0_f = r2_pvector32->float_0 - r1_pvector32->float_0;
  r0_pmatrix.d[3][0] = s2_f / s0_f;

  s0_f = r2_pvector32->float_4 - r1_pvector32->float_4;
  r0_pmatrix.d[2][1] = 0;
  s2_f = sp0_pvector32->float_4 - r3_pvector32->float_4;
  r0_pmatrix.d[1][1] = s2_f / s0_f;

  s2_f = r3_pvector32->float_4 * r2_pvector32->float_4 -
         sp0_pvector32->float_4 * r1_pvector32->float_4;
  ;
  s0_f = r2_pvector32->float_4 - r1_pvector32->float_4;
  r0_pmatrix.d[0][2] = 0;
  r0_pmatrix.d[1][2] = 0;
  r0_pmatrix.d[3][1] = s2_f / s0_f;


  s0_f = r2_pvector32->float_8 - r1_pvector32->float_8;
  s2_f = sp0_pvector32->float_8 - r3_pvector32->float_8;
  r0_pmatrix.d[2][2] = s2_f / s0_f;
  s2_f = r3_pvector32->float_8 * r2_pvector32->float_8-sp0_pvector32->float_8 *r1_pvector32->float_8;
  s0_f = r2_pvector32->float_8 - r1_pvector32->float_8;
  r0_pmatrix.d[0][3] = 0;
  r0_pmatrix.d[1][3] = 0;
  r0_pmatrix.d[2][3] = 0;
  r0_pmatrix.d[3][3] = 1.0f;
  r0_pmatrix.d[3][2] = s2_f/s0_f;
}

//00189C0C ^_-
//单元测试等级: 游戏运行正常
//单元测试内容: 启动游戏到第7关
//单元测试结果: 正常
//！！！！！！！这里要更新FTTArray头文件 否则函数签名不一致
void SetupGaussian(FTTArray<FTTPair<float,float>,PointType_16> &r0_parr,float r1_f)
{

  uchar r7_uc=0;
  float s4_f=r1_f+r1_f;
  float s2_f=r1_f*6.28318548f;
  float s18_f=s4_f*r1_f;
  float s0_f=s2_f*r1_f;
  float s20_f=sqrt(s0_f);
  
  float f_sp1c[0x20];
  while(1){
    //loc_189C72 OK
    //check
    LOGE("SetupGaussian_1");
    float s0_f=s20_f;
    float s24_f=1.0f/s0_f;
    float s2_f=(short)r7_uc*(short)r7_uc;
    s2_f=-s2_f;
    s2_f/=s18_f;
    s0_f=powf(2.71828175f,s2_f);
    s0_f=s24_f*s0_f;
    if(s0_f<=0.00999999978f)
      break;
    //loc_189C4A
    f_sp1c[r7_uc++]=s0_f;
    

  };
  //00189CA8
  //r1=-4 s2=0.0 r2=sp20 s0=sp1c[0]
   s2_f=0.0f;
  int r1_i=r7_uc-1;
  int i=1;
  while(r1_i){
    //loc_189CBE  Ok
    LOGE("SetupGaussian_2");
   s2_f=s2_f+ f_sp1c[i];
   i++;
   r1_i--;
  }
  //00189CCE
  s2_f=s2_f+s2_f;
  s0_f=1.0f/(f_sp1c[0]+s2_f);
  //loc_189CF2
  int r0_i=0;
  while(r0_i!=r7_uc){
    //loc_189CE2  OK 
    LOGE("SetupGaussian_3");
    f_sp1c[r0_i]=s0_f*f_sp1c[r0_i];
    r0_i++;
  }
  //00189CF6
  uchar r4_uc=r7_uc-1;
  //loc_189D38
  while(r4_uc!=1){
    //loc_189CFC
    if(r4_uc!=0){
      //00189CFE  OK
      LOGE("SetupGaussian_4");
      s0_f=f_sp1c[r4_uc];
      s4_f=r4_uc-1;
      s2_f=f_sp1c[r4_uc-1];
      s2_f=s2_f+s0_f;
      s0_f/=s2_f;
      s0_f+=s4_f;
      FTTPair<float, float> pair_sp14;
      pair_sp14.m_t1=s0_f;
      pair_sp14.m_t2=s2_f;
      r0_parr.Insert(std::move(pair_sp14));
      r4_uc-=2;
    }else{
      //loc_189D64
      break;
    }
  }
  if(r4_uc==1){
    //00189D3E
    LOGE("SetupGaussian_5");
    s4_f=f_sp1c[r4_uc];
    s2_f=f_sp1c[0];
    float s6_f=s4_f+s2_f*0.5f;
    s0_f=s4_f/s6_f;
    FTTPair<float, float> pair_sp14;
      pair_sp14.m_t1=s0_f;
      pair_sp14.m_t2=s6_f;
      //！！！！！！！这里的函数签名不对要注意修改
    r0_parr.Insert(std::move(pair_sp14));
  }else if(r4_uc==0){
    //loc_189D64  OK
    LOGE("SetupGaussian_6");
    FTTPair<float, float> pair_sp14;
      pair_sp14.m_t1=0;
      pair_sp14.m_t2=f_sp1c[0];
    r0_parr.Insert(std::move(pair_sp14));
  }
  //00189D74
  FTTArray<FTTPair<float,float>,PointType_16>::Iterator it_spc(r0_parr.array_0);
  //it_spc.m_buf=&r0_parr;
  FTTArray<FTTPair<float,float>,PointType_16>::Iterator it_sp4(r0_parr.array_0+r0_parr.m_count);
  //it_sp4.m_buf=&r0_parr+r0_parr.m_count;
  //FTTALG::Reverse<FTTArray<FTTPair<float,float>,16u>::Iterator>(FTTArray<FTTPair<float,float>,16u>::Iterator,FTTArray<FTTPair<float,float>,16u>::Iterator)
 // FTTALG::Reverse<FTTArray<FTTPair<float,float>,16u>::Iterator>(FTTArray<FTTPair<float,float>,16u>::Iterator,FTTArray<FTTPair<float,float>,16u>::Iterator)
  FTTALG::Reverse(it_spc,it_sp4);
  LOGE("SetupGaussian_end");
}

void GaussianBlur(CFTTRenderToTexture *a1, CFTTRenderToTexture *a2,
                  CFTTRenderToTexture *a3, float a4, int a5, bool a6, bool a7) {
LOGE("GaussianBlur=%x%x%x%x%x%x%x",a1,a2,a3,a4,a5,a6,a7);
}
// 00185e1a ^_-
// void GetFaceData(TFTTModel *pModel0, ushort *&pUS1, int &i2, int i3) {
//   int iR1 = 0;
//   i2 = 0;
//   //.text:00185E2E                 B               loc_185E58
//   for (int iR6 = 0; iR6 < pModel0->us_10; iR6++) {  // loc_185E30
//     bool b = i3 == -1;
//     // text:00185E32                 IT NE
//     if (i3 != -1)
//       b = i3 == iR6;
//     //.text:00185E36                 BNE             loc_185E54
//     if (b) {
//       uint iR7 = pModel0->u_28.list_C[iR6].field_4;
//       //.text:00185E40                 CBZ             R7, loc_185E4C
//       if (iR7) {
//         iR1 += iR7 - 2;
//         i2 = iR1;
//       }
//       // loc_185E4C
//       iR1 += pModel0->u_28.list_C[iR6].field_6;
//       i2 = iR1;
//     }
//     // loc_185E54
//   }
//   //.text:00185E5E                 BCC             loc_185E30

//   pUS1 = new ushort[iR1 * 3];
//   int offsetR9 = 0;
//   int posR7 = 0;
//   // LOGE("pppp");
//   //.text:00185E86                 B               loc_185F9A
//   for (int iR6 = 0; iR6 < pModel0->us_10; iR6++) {  // loc_185E88
//     bool b = i3 == -1;
//     //.text:00185E8A                 IT NE
//     if (i3 != -1)
//       b = i3 == iR6;
//     int sizeR12;
//     //.text:00185E8E                 BNE             loc_185EDE
//     if (b) {  //.text:00185E90
//       memcpy(&pUS1[3 * offsetR9],
//              (char *)&pModel0->u_24.pmodel_union_struct_2[posR7],
//              6 * pModel0->u_28.list_C[iR6].field_6);
//       sizeR12 = pModel0->u_28.list_C[iR6].field_6;
//       int lenR3 = pModel0->u_28.list_C[iR6].field_4;
//       offsetR9 += sizeR12;
//       int sLR, eR0;
//       //.text:00185ED0                 CBZ             R3, loc_185EF0
//       if (lenR3) {  //.text:00185ED2

//         sLR = pModel0->u_28.list_C[iR6].field_2;
//         eR0 = pModel0->u_28.list_C[iR6].field_0;
//         //.text:00185EDC                 B               loc_185EF6
//       } else {  // loc_185EF0
//         eR0 = 0;
//         sLR = 0;
//       }
//       // loc_185EF6
//       //.text:00185EFC                 BCS             loc_185F92
//       for (int iR2 = 2; iR2 < lenR3; iR2++) {
//         int iR3 = 3 * offsetR9;
//         pUS1[iR3] = eR0;
//         //.text:00185F0C                 BNE             loc_185F26
//         if (iR2 << 31) {  // loc_185F26
//           pUS1[iR3 + 1] = (&pModel0->u_28.list_C[iR6].field_0)[iR2];
//           pUS1[iR3 + 2] = sLR;
//         } else {  //.text:00185F0E
//           pUS1[iR3 + 1] = sLR;
//           pUS1[iR3 + 2] = (&pModel0->u_28.list_C[iR6].field_0)[iR2];
//         }
//         // loc_185F3E

//         //.text:00185F62                 BEQ             loc_185F72
//         if (pUS1[3 * offsetR9] == pUS1[3 * offsetR9 + 1]
//             //.text:00185F70                 BNE             loc_185F8C
//             || pUS1[3 * offsetR9 + 1] == pUS1[3 * offsetR9 + 2] || pUS1[3 *
//             offsetR9] == pUS1[3 * offsetR9 + 2]) {
//           --i2;

//         } else {  // loc_185F8C
//           ++offsetR9;
//         }

//         eR0 = sLR;
//         sLR = (&pModel0->u_28.list_C[iR6].field_0)[iR2];
//       }

//     } else {  // oc_185EDE
//       sizeR12 = pModel0->u_28.list_C[iR6].field_6;
//     }
//     posR7 += sizeR12;
//   }  //.text:00185FA0                 BCC.W           loc_185E88
// }
//-------------------------------------------------------------------------------------------------
// 0019691C 经过单元测试功能正常 (前5关)
CGfxCrowd::CGfxCrowd() {
  // pRender2Tex_9C = nullptr;
  // pRender2Tex_A0 = nullptr;
  // pRender2Tex_A4 = nullptr;

  // b_CBB4 = false;

  // // 001969D0
  // CFTTTexParam var_28(1);
  // dCrowdNewShaderID_CBBC[0] =
  // CCrowdNewShader::s_tInstance.CreateMat(ECrowdNewShader_Quads_1,
  //                                                                    ECrowdNewShader_Alphatest_0,
  //                                                                    var_28,
  //                                                                    ECrowdNewShader_CullMode_1);

  // // 001969E4
  // dCrowdNewShaderID_CBBC[1] =
  // CCrowdNewShader::s_tInstance.CreateMat(ECrowdNewShader_Quads_1,
  //                                                                    ECrowdNewShader_Alphatest_1,
  //                                                                    var_28,
  //                                                                    ECrowdNewShader_CullMode_1);

  // // 001969F8
  // dCrowdNewShaderID_CBBC[2] =
  // CCrowdNewShader::s_tInstance.CreateMat(ECrowdNewShader_Quads_0,
  //                                                                    ECrowdNewShader_Alphatest_0,
  //                                                                    var_28,
  //                                                                    ECrowdNewShader_CullMode_1);
}
//-------------------------------------------------------------------------------------------------
// 00196A10
CGfxCrowd::~CGfxCrowd() {
  Shut();
  for (int r5 = 0; r5 != 3; r5++) {  // loc_196A48
    // loc_196A3C
    FTT_pMtlL->ReleaseMaterial(dCrowdNewShaderID_CBBC[r5]);
  }

  // 00196A4C
}
//-------------------------------------------------------------------------------------------------
// 001968CC ^_^
void CGfxCrowd::Initialise() { ms_pInstance = new CGfxCrowd; }
//-------------------------------------------------------------------------------------------------
// 001968EC
void CGfxCrowd::Shutdown() {
  if (CGfxCrowd::ms_pInstance != nullptr) {
    delete CGfxCrowd::ms_pInstance;
  }
  CGfxCrowd::ms_pInstance = nullptr;
}
//-------------------------------------------------------------------------------------------------
// 0019690C
CGfxCrowd *CGfxCrowd::Get() { return CGfxCrowd::ms_pInstance; }
//-------------------------------------------------------------------------------------------------
// 00196AF8
void CGfxCrowd::Shut() { LOGX("CGfxCrowd::Shut 00196AF8"); }
//-------------------------------------------------------------------------------------------------
// 00196E72 ^_^
void CGfxCrowd::Init() { f_CBB8 = 0; }
//-------------------------------------------------------------------------------------------------
// 00197140
void CGfxCrowd::AddStand(CFTTModel *, CFTTMatrix32) {
  LOGX("CGfxCrowd::AddStand 00197140");
}
//-------------------------------------------------------------------------------------------------
// 00199D4C
void CGfxCrowd::GetCapacity(CFTTModel *, CFTTMatrix32) {
  LOGX("CGfxCrowd::GetCapacity 00199D4C");
}
//-------------------------------------------------------------------------------------------------
// 00199E08 ^_^ 经过单元测试，功能正常(前5关)
// void CGfxCrowd::AssessDesirability(TGfxCrowdSeat &tSeat) {
//   tSeat.f_18 =
//       powf(XSYS_RandomNoSyncF(17.5f), 1.5f) + (20.0f - (tSeat.f_4 + tSeat.f_4));
// }
//-------------------------------------------------------------------------------------------------
// 00199E3C 经过单元测试，功能正常(前5关)
// void CGfxCrowd::AssessDesirability(TGfxCrowdSeat &tSeat1, bool b2) {
//   float fr6 = powf(XSYS_RandomNoSyncF(20.0f), 1.5f);
//   float fs16 = -1.0f;
//   // 00199E62
//   if (b2) {
//     // 00199E6A
//     fs16 = 1.0;
//   }

//   // 00199E70
//   float fs6 = XMATH_ClampFloat(tSeat1.f_8, -60.0f, 60.0f);
//   float fs0 = fr6 + (20.0f - (tSeat1.f_4 + tSeat1.f_4));
//   float fs8 = 10.0f + (fabs(tSeat1.f_0) * -0.5f);

//   /*
//     以下写法与原始汇编一致，但是可读性差，我改成逻辑一致，可读性更强的代码
//     float32x2_t f32_1{fs8, 0.0f};
//     float32x2_t f32_2{0.0f, 0.0f};
//     float32x2_t ff32 = vmax_f32(f32_1, f32_2);
//     float dfs8 = ff32[0];
//     -----
//     我改成直接调用 fmaxf API
//   */

//   tSeat1.f_18 =
//       (fs0 + (fs16 * fs6)) + fmaxf(10.0f + (fabs(tSeat1.f_0) * -0.5f), 0.0f);
// }
//-------------------------------------------------------------------------------------------------
// 00199ED0
void CGfxCrowd::Distribute(uint) { LOGX("CGfxCrowd::Distribute 00199ED0"); }
//-------------------------------------------------------------------------------------------------
// 0019CBA0 ^_-
//单元测试等级: 游戏运行正常
//单元测试内容: 启动游戏到第10关
//单元测试结果: 正常
void CGfxCrowd::UpdateCrowdTextures(uint r1_u) {
  // sp30=this
  // sp2c=r1_u
  LOGE("CGfxCrowd::UpdateCrowdTextures=%x",r1_u);
  switch (r1_u) {
      // sp28=m_st_D0
      // r11=m_st_D0
    case 0: {
      // loc_19CBE6  OK
      // sp28=m_st_D0
      LOGE("case 0");
      CrowdTextureCreationData *r1_pdata = new CrowdTextureCreationData;
      r1_pdata->mpFTTAtlasGenerator_194C.pType_0 = 0;
      r1_pdata->miCFTTMaterialIndex_0 = -1;
      r1_pdata->name_texture_5C = 0;
      r1_pdata->name_texture_60 = 0;
      r1_pdata->name_texture_64 = 0;
      r1_pdata->pmembers_34.pType_0 = 0;
      r1_pdata->pprenderToTexture_38[0] = 0;
      r1_pdata->pprenderToTexture_38[1] = 0;
      r1_pdata->prenderToTexture_40 = 0;
      r1_pdata->prenderToTexture_44 = 0;
      tPtrTextureData_D0 = r1_pdata;
      g_pGraphicsDevice->setDither(false);
      // 0019CC38
      tPtrTextureData_D0.pType_0->miCFTTMaterialIndex_0 =
          CGaussianNewShader::s_tInstance.CreateMat(
              EGaussianNewShader_Channel_1, EGaussianNewShader_Blend_1);
      CFTTTexLoadOptions options_sp78 =
          g_tGlobalTexLoadOptions.mTexLoadOptions_4;
      // r9=spd0
      TBuildKitTeamTextures team_textures_spd0[2];
      for (int r1_i = 0; r1_i < 2; r1_i++) {
        // loc_19CC72
        //team_textures_spd0[r1_i].pCTeam_0 = 0;
        team_textures_spd0[r1_i].filed_4 = -1;
        // team_textures_spd0[r1_i].pTexture_8 = 0;
        // team_textures_spd0[r1_i].pTexture_C = 0;
        // team_textures_spd0[r1_i].pTexture_10=0;
        // team_textures_spd0[r1_i].pTexture_14=0;
      }
      CGfxKits::LoadKitTeamTextures(
          &tGame.CTeam_2C60[0], &team_textures_spd0[0],
          g_tGlobalTexLoadOptions.mTexLoadOptions_4, 0);
      CGfxKits::LoadKitTeamTextures(
          &tGame.CTeam_2C60[1], &team_textures_spd0[1],
          g_tGlobalTexLoadOptions.mTexLoadOptions_4, 0);
      CGfxKits::BeginBuildKit(0);
     
      CGfxKits::GetTexture(tPtrTextureData_D0.pType_0->texture_4,
                           team_textures_spd0, 0, EKitTextureType_0, NULL);
      CGfxKits::GetTexture(tPtrTextureData_D0.pType_0->texture_8,
                           team_textures_spd0, 1, EKitTextureType_0, NULL);
      // 0019CCDE
      CGfxKits::GetTexture(tPtrTextureData_D0.pType_0->texture_C,
                           &team_textures_spd0[1], 0, EKitTextureType_0, NULL);
      CGfxKits::GetTexture(tPtrTextureData_D0.pType_0->texture_10,
                           &team_textures_spd0[1], 1, EKitTextureType_0, NULL);
      CGfxKits::EndBuildKit();
      // 0019CD02
      CGfxKits::FreeKitTeamTextures(team_textures_spd0);
      CGfxKits::FreeKitTeamTextures(&team_textures_spd0[1]);
      // 0019CD0E
      tPtrTextureData_D0.pType_0->model_2C = CModelManager::LoadModel(
          "data/models/crowd/crowd1.FTM", "data/models/crowd/",
          EModelLoadFlags_2, true);
      // 0019CD20
      tPtrTextureData_D0.pType_0->model_30 = CModelManager::LoadModel(
          "data/models/crowd/crowd2.FTM", "data/models/crowd/",
          EModelLoadFlags_2, true);
      // 0019CD34
      tPtrTextureData_D0.pType_0->texture_48 = FTT_pTex->LoadTexture(
          "data/models/Player/Textures/kit_dyn_n.p", options_sp78);
      // 0019CD50
      tPtrTextureData_D0.pType_0->texture_4C = FTT_pTex->LoadTexture(
          "data/models/Player/Textures/kit_dyn_a.p", options_sp78);
      // 0019CD5E
      tPtrTextureData_D0.pType_0->texture_50 = FTT_pTex->LoadTexture(
          "data/models/Player/Textures/atlas_n.png", options_sp78);
      // 0019CD6C
      tPtrTextureData_D0.pType_0->texture_58 = FTT_pTex->LoadTexture(
          "data/models/Player/Textures/atlas_s.png", options_sp78);
      // 0019CD7A
      options_sp78.eMinFilter_18 = EFTTTex_MinFilter_0;
      CFTTTexture *r4_name_texture = CFTTTexture::LoadName(
          "data/models/Crowd/jeans.png", options_sp78, true);
      if (tPtrTextureData_D0.pType_0->name_texture_5C) {  // 0019CD98
        delete tPtrTextureData_D0.pType_0->name_texture_5C;
      }
      // loc_19CD9E
      tPtrTextureData_D0.pType_0->name_texture_5C = r4_name_texture;
      options_sp78.eMinFilter_18=EFTTTex_MinFilter_0;
      r4_name_texture = CFTTTexture::LoadName("data/models/Crowd/steward.png",
                                              options_sp78, true);
      if (tPtrTextureData_D0.pType_0->name_texture_60) {  // 0019CDB6
        delete tPtrTextureData_D0.pType_0->name_texture_60;
      }
      // loc_19CDBC
      tPtrTextureData_D0.pType_0->name_texture_60 = r4_name_texture;

      r4_name_texture = CFTTTexture::LoadName("data/models/Crowd/jacket.png",
                                              options_sp78, true);
      if (tPtrTextureData_D0.pType_0->name_texture_64) {  // 0019CDD4
        delete tPtrTextureData_D0.pType_0->name_texture_64;
      }
      // loc_19CDDA
      tPtrTextureData_D0.pType_0->name_texture_64 = r4_name_texture;
      GFXSCENE_Apply(NULL);
      CFTTVector32 vrctor32_sp50;
      vrctor32_sp50.float_0 = 0;
      vrctor32_sp50.float_4 = 0.300000012f;
      vrctor32_sp50.float_8 = -1.0f;
     // CFTTVector32 
      GFXSCENE_vLightDir = Normalize(vrctor32_sp50);
      // 0019CDFA
      // GFXSCENE_vLightDir=vrctor32_sp120;
      CPBRLighting::Get()->Reinitialise(true);
      CGfxEnvironmentMap::Get()->SetForced(EEnvMapOverride_1);
      // loc_19CE38
      // 0019CE48 这里的符号不对 可能会造成内存泄漏 
      // FTTUPtr<TCrowdMember []>::operator=(TCrowdMember*)
      LOGE("tPtrTextureData_D0.pType_0->pmembers_34=%x",((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0));
      TCrowdMember* r5_pmem = new TCrowdMember [0x20];
      //FTTUPtr<TCrowdMember[0x20]> r5_pmem(new TCrowdMember [0x20]);
      tPtrTextureData_D0.pType_0->pmembers_34= r5_pmem;
      CPlayerShader::s_tInstance.SetCinematic(EPlayerShader_Cinematic_1);
      CFTTVector32x4 vector32x4_sp120;
      vector32x4_sp120.my[0] = 1.0f;
      vector32x4_sp120.my[1] = 1.0f;
      vector32x4_sp120.my[2] = 0;
      vector32x4_sp120.my[3] = 0;
      CPlayerShader::s_tInstance.SetCinematicLightingCloth(vector32x4_sp120);
      vector32x4_sp120.my[0] = 1.0f;
      vector32x4_sp120.my[1] = 1.0f;
      vector32x4_sp120.my[2] = 0;
      vector32x4_sp120.my[3] = 0;
      CPlayerShader::s_tInstance.SetCinematicLightingSkin(vector32x4_sp120);
      break;
    }
    case 1: {
      // 0019CE84 OK
      LOGE("case 1");
      
      for (int r4_i = 0; r4_i != 0x20; r4_i++) {
        // loc_19CE9E
        float s0_f = XSYS_RandomNoSyncF(0.0799999982f);
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_4 = 0;
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_8 = 0;

        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_0 =
            (-6.975f + r4_i * 0.449999988f) + (s0_f - 0.0399999991f);
      }
      // 0019CEDA
      CGfxPlayer::SetupBatchConstants();
      CPlayerShader::s_tInstance.SetShadowMap(EPlayerShader_ShadowMap_0);
      CPlayerShader::s_tInstance.SetBlendMode(EPlayerShader_BlendMode_0);
      CPlayerShader::s_tInstance.SetModel(EPlayerShader_Model_0);
      CPlayerShader::s_tInstance.SetQuality(EPlayerShader_Quality_2);
      break;
    }
    case 2:
    case 4: {  // loc_19CFB4 OK
               // sp4c=tPtrTextureData_D0
               LOGE("case 2 4");
      
      CFTTRenderToTexture *r5_prenderToTexture =
          g_pGraphicsDevice->createRenderToTexture(
              EFTTTexFormat_2, 0x400, 0x400, 0x1, 0x18, EFTTRTTZBufMode_1,
              false, EFTTTextureType_0, 1);
      ECrowdMemberType r4_member_type = ECrowdMemberType_0;
      if (r1_u != 2) r4_member_type = ECrowdMemberType_1;
      // 0019CFE0
      if (tPtrTextureData_D0.pType_0
              ->pprenderToTexture_38[(uint)r4_member_type])  // 0019CFF4
        delete tPtrTextureData_D0.pType_0
            ->pprenderToTexture_38[(uint)r4_member_type];
      // loc_19CFFA
      tPtrTextureData_D0.pType_0->pprenderToTexture_38[(uint)r4_member_type] =
          r5_prenderToTexture;
      // loc_19D022
      for (uint r6_u = 0; r6_u != 0x20; r6_u++) {
        // loc_19D002
        if (r6_u <= 5) {  // 0019D00C
          ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r6_u].Setup(
              r4_member_type, r6_u);
        } else {
          // loc_19D012
          ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r6_u].Setup(
              ECrowdMemberType_2, r6_u - 6);
        }
        // loc_19D018
      }
     
      // 0019D026
      FTTALG::Shuffle(((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0),
                      &((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[0x20]);
     
      // 0019D032
      // loc_19D084
      for (int r4_i = 0; r4_i != 0x20; r4_i++) {
        // loc_19D04C
        float s0_f = XSYS_RandomNoSyncF(0.0399999991f);
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_4 = 0;
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_8 = 0;

        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_0 =
            (-6.975f + r4_i * 0.449999988f) + (s0_f - 0.0199999996f);
      }
      // 0019D088
      // sp38=unk_2FEFF4
      // sp34=unk_2FF003
      // r1=0
      int r1_i = 0;
      // loc_19D128
      for (int r2_i = 0; r2_i != 0x20; r2_i++) {
        // loc_19D0A2
        // sp44=r2_i
        // sp48=r1
        int r1_i = (int)((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r2_i]
                       .m_eCrowdMemberType_0 *
                   5;
        const uchar *r4_pb = &byte_2FEFF4[r1_i];
        int i_sp40 = XSYS_RandomNoSync(byte_2FEFF4[r1_i]);
        // sp3c=r4_pb[4]
        int r10_i = XSYS_RandomNoSync(r4_pb[1]);
        int r5_i = XSYS_RandomNoSync(r4_pb[2]);
        int r0_i = XSYS_RandomNoSync(r4_pb[3]);
        const uchar *r6_pb =
            &byte_2FF003[((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r2_i]
                             .m_eCrowdMemberType_0 *
                         60];
        //
        int r0_i1 = XSYS_RandomNoSync(r4_pb[4]);
        tPtrTextureData_D0.pType_0->buff_68[r2_i][0] = *(r6_pb + (uchar)i_sp40);
        tPtrTextureData_D0.pType_0->buff_68[r2_i][1] =
            *(r6_pb + (uchar)r10_i + 0xC);
        tPtrTextureData_D0.pType_0->buff_68[r2_i][2] =
            *(r6_pb + (uchar)r5_i + 0x18);
        tPtrTextureData_D0.pType_0->buff_68[r2_i][3] =
            *(r6_pb + (uchar)r0_i + 0x24);
        tPtrTextureData_D0.pType_0->buff_68[r2_i][4] =
            *(r6_pb + (uchar)r0_i1 + 0x30);
      }
      // 0019D12C
      // sp48=byte_2FDF94
      // sp44=byte_4630E0
      // loc_19D1DC
      for (int r9_i = 0; r9_i != 0x20; r9_i++) {
        // 0019D146
        // loc_19D1D0
        for (int r5_i = 0; r5_i != 0x10; r5_i++) {
          // loc_19D14A
          tPtrTextureData_D0.pType_0->field_10c[r9_i][r5_i].b_0 =
              tPtrTextureData_D0.pType_0->buff_68[r9_i][byte_2FDF94[r5_i]];
          ushort r0_us =
              GetAnim(tPtrTextureData_D0.pType_0->field_10c[r9_i][r5_i].b_0)
                  ->filed_4;
          int r0_i;
          int r6_i = t_4630e0.byte_4630E0[byte_2FDF94[r5_i] * 2];
          if (r5_i == r6_i) {
            // 0019D17A
            // check UXTH
            r0_i = XSYS_RandomNoSync((ushort)r0_us);
          } else {  // loc_19D182
            float s0_f = t_4630e0.byte_4630E0[byte_2FDF94[r5_i * 2] + 1] - r6_i;
            float s2_f = r5_i - r6_i;
            s0_f = s2_f / s0_f;
            // check UXTH
            s2_f = r0_us;
            // check 寻址 s4
            float s4_f = tPtrTextureData_D0.pType_0->field_10c[r9_i][r6_i].us_2;
            s4_f += s0_f * s2_f;
            r0_i = (uint)s4_f % r0_us;
          }
          // loc_19D1CA
          // check
          tPtrTextureData_D0.pType_0->field_10c[r9_i][r5_i].us_2 = r0_i;
        }
        // 0019D1D4
      }
      
      break;
    }
    case 3:
    case 5: {
      // loc_19D20E OK
      // check 赋值
      LOGE("case 3_5");
      
      CFTTClearSettings clear_setting_sp120 = g_tBlankCanvasClearSettings;
      clear_setting_sp120.dRGBA_8 = 0xFFFFFF;
      int r0_i = 0;
      if (r1_u != 3) {
        r0_i = 1;
      }
      // sp40=tPtrTextureData_D0.pType_0[r0_i].texture_38
      tPtrTextureData_D0.pType_0
          ->pprenderToTexture_38[r0_i]->BeginRenderToTexture(clear_setting_sp120);
      // 0019D24A
      CFTTVector32 vector_sp50;
      vector_sp50.float_0 = -7.19999981f;
      vector_sp50.float_4 = -0.100000001f;
      vector_sp50.float_8 = 0;
      CFTTVector32 vector_sp114;
      vector_sp114.float_0 = 7.19999981f;
      vector_sp114.float_4 = 2.4000001f;
      vector_sp114.float_8 = 20.0f;
      CFTTCamera::SetOrthographic(1.0f, 20.0f, 2.4000001f, -0.100000001f,
                                  -7.19999981, 7.19999981f);
      CFTTVector32 vector32_spD0;
      vector32_spD0.float_0 = 0;
      vector32_spD0.float_4 = 0;
      vector32_spD0.float_8 = -10.0f;
      CFTTCamera::SetPosition(vector32_spD0);
      vector32_spD0.float_0 = 0;
      vector32_spD0.float_4 = 0;
      vector32_spD0.float_8 = 1.0f;
      CFTTCamera::SetDirection(vector32_spD0, NULL);
      CFTTCamera::SetViewport(0x400, 0x400, 0);
      CFTTCamera::ApplyCameraSettings();
      g_pGraphicsDevice->setDepthTest(EFTTDepthTest_8, true);
      CFTTShaderBuiltInConstants::SetViewMatrix(CFTTMatrix32::s_matIdentity);
      CFTTShaderBuiltInConstants::SetProjMatrix(CFTTMatrix32::s_matIdentity);
      // 0019D2C6
      // sp3c=GFXPLAYER_pBatch
      GFXPLAYER_pBatch->cfttbmmmatrixcache_0.field_20 = false;
      GFXPLAYER_pBatch->Begin();
      // sp48=r11
      // sp44=g_pGraphicsDevice
      // s18=-1.0f
      // s20=1.0f r10=0 r6=0xaf0 s16=0.0625f
     
      // loc_19D41E
      for (int r10_i = 0; r10_i != 0x20; r10_i++) {
        // loc_19D2F4
        // loc_19D40C
        for (int r4_i = 0; r4_i != 0x10; r4_i++) {
          // loc_19D348
          // tPtrTextureData_D0
          float s22_f = (float)r4_i * 0.0625f;
          float s24_f = (float)(r4_i + 1) * 0.0625f;
          if (g_pGraphicsDevice->Matrices_FlipsRTT() == 0) {
            // 0019D36E
            if (g_pGraphicsDevice->Matrices_FlipsY() == 0) {
              s24_f = 1.0f - s24_f;
              s22_f = 1.0f - s22_f;
            }
          }
        
          // loc_19D380
          float s2_f = s22_f + s22_f - 1.0f;
          float s0_f = s24_f + s24_f - 1.0f;
          // spc4=
          // vector_sp50
          CFTTMatrix32 matrix32_spd0;
          CFTTVector32 vector32_spc4;

          vector32_spc4.float_0 = -1.0f;
          vector32_spc4.float_8 = 0;
          CFTTVector32 vector32_spb8;
          vector32_spb8.float_0 = 1.0f;
          vector32_spb8.float_4 = s2_f;
          vector32_spb8.float_8 = 1.0f;
          vector32_spc4.float_4 = s0_f;

          sub_19ED8C(matrix32_spd0, &vector_sp50, &vector_sp114, &vector32_spc4,
                     &vector32_spb8);
          // 0019D3BC
          TSATAnim_TSX *r9_panim =
              GetAnim(tPtrTextureData_D0.pType_0->field_10c[r10_i][r4_i].b_0);

          TSATAnim_TSX *r3_panim = GetLegAnim(
              tPtrTextureData_D0.pType_0->field_10c[r10_i][r4_i].b_0);
          CFTTMatrix32 matrix_sp78 =
              ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r10_i].Animate(
                  r9_panim, r3_panim,
                  tPtrTextureData_D0.pType_0->field_10c[r10_i][r4_i].us_2);
          // 0019D3EE
        
          MatrixMultiply(&matrix_sp78, &matrix32_spd0, &CFTTCamera::s_matView);
         
          ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r10_i].Render(
              &matrix_sp78);
        
        }
        // 0019D410
      }
     
      // 0019D426
      GFXPLAYER_pBatch->End();
      CGfxPlayer::FlushPlayerSkins();
      GFXPLAYER_pBatch->ResetCache(false);
      GFXPLAYER_pBatch->cfttbmmmatrixcache_0.field_20 = true;
      // check ptype0
      tPtrTextureData_D0.pType_0->pprenderToTexture_38[r0_i]->EndRenderToTexture(
          EFTTRTTCopyMode_0);
      
      break;
    }
    case 6: {
      // 0019D470 OK
      // r8=tPtrTextureData_D0
      LOGE("case 6");
      CFTTRenderToTexture *r11_prenderToTexture =
          g_pGraphicsDevice->createRenderToTexture(
              EFTTTexFormat_2, 0x200, 0x400, 1, 0, EFTTRTTZBufMode_1, false,
              EFTTTextureType_0, 1);
      // 0019D49E
      CFTTRenderToTexture *prenderToTexture_sp48 =
          g_pGraphicsDevice->createRenderToTexture(
              EFTTTexFormat_2, 0x200, 0x400, 1, 0, EFTTRTTZBufMode_1, false,
              EFTTTextureType_0, 1);
      // 0019D4C2
      CFTTRenderToTexture *prenderToTexture_sp44 =
          g_pGraphicsDevice->createRenderToTexture(
              EFTTTexFormat_2, 0x200, 0x400, 1, 0, EFTTRTTZBufMode_1, false,
              EFTTTextureType_0, 1);
      // 0019D4E4
      r11_prenderToTexture->BeginRenderToTexture(g_tBlankCanvasClearSettings);
      FTT2D_Begin();
      // 0019D4FA
      FTT2D_SetDefaultMatBlend(EFTT2D_Blend_5);
      FTT2D_SetTexture(
          tPtrTextureData_D0.pType_0->pprenderToTexture_38[0]->GetTexture(), 0);
      // 0019D51A
      FTT2D_DrawTexturedRect(0, 0, 512.0f, 512.0f, -1, 0, -999999.0f,
                             -999999.0f);
      // 0019D53C
      FTT2D_SetTexture(
          tPtrTextureData_D0.pType_0->pprenderToTexture_38[1]->GetTexture(), 0);
      FTT2D_DrawTexturedRect(0, 512.0f, 512.0f, 512.0f, -1, 0, -999999.0f,
                             -999999.0f);
      FTT2D_End();
      r11_prenderToTexture->EndRenderToTexture(EFTTRTTCopyMode_0);
      CFTTVector32x4 vector32x4_spd0;
      vector32x4_spd0.my[0] = 1.0f;
      vector32x4_spd0.my[1] = 1.0f;
      vector32x4_spd0.my[2] = 1.0f;
      vector32x4_spd0.my[3] = 0;
      CGaussianNewShader::s_tInstance.SetColourMultiplier(vector32x4_spd0);
      // 0019D58C
      GaussianBlur(
          r11_prenderToTexture, prenderToTexture_sp44, prenderToTexture_sp48,
          2.0f, tPtrTextureData_D0.pType_0->miCFTTMaterialIndex_0, true, true);
      FTT2D_Begin();
      FTT2D_SetDefaultMatBlend(EFTT2D_Blend_5);
      // 0019D5B0
      // sp3c=r11
      FTT2D_SetTexture(r11_prenderToTexture->GetTexture(), 0);
      // 0019D5C2
      FTT2D_DrawTexturedRect(0, 0, 512.0f, 1024.0f, -1, 0, -999999.0f,
                             -999999.0f);
      FTT2D_SetDefaultMatBlend(EFTT2D_Blend_7);

      for (int r6_i = 0; r6_i != 0x20; r6_i++) {
        // loc_19D5E2
        FTT2D_DrawRect4(0, r6_i * 0x20, 512.0f, 32.0f, -1, -1, 0xFF404040,
                        0xFF404040, 0, -999999.0f, -999999.0f);
      }
      // 0019D612
      FTT2D_End();
      //这里check r5_ptexture ptexture_9C的类型
      CFTTTexture *r5_ptexture =
          prenderToTexture_sp44->EndRenderToTexture(EFTTRTTCopyMode_2);
      if (ptexture_9C) {  // 0019D62C
        delete ptexture_9C;
      }
      // loc_19D632
      ptexture_9C = r5_ptexture;

      switch (GFXSPEC_pSpecification->eCrowdQuality_4C) {
        case 2:
        case 3:
        case 4:
          // loc_19D654
          r5_ptexture->SetMinFilter(EFTTTex_MinFilter_5);
          break;

        case 1:
        default:
          r5_ptexture->SetMinFilter(EFTTTex_MinFilter_4);
          // 0019D65A
          break;
      }
      // 0019D664
      CFTTTexParam parm;
      // check 这里传参
      parm.setTexture(ptexture_9C);

      CCrowdNewShader::s_tInstance.SetDiffuse(parm, dCrowdNewShaderID_CBBC[0]);
      if (tPtrTextureData_D0.pType_0->pprenderToTexture_38[0]) {
        // 0019D688
        delete tPtrTextureData_D0.pType_0->pprenderToTexture_38[0];
      }
      // loc_19D68E
      tPtrTextureData_D0.pType_0->pprenderToTexture_38[0] = NULL;
      if (tPtrTextureData_D0.pType_0->pprenderToTexture_38[1]) {
        // 0019D6B0
        delete tPtrTextureData_D0.pType_0->pprenderToTexture_38[1];
      }
      // loc_19D69E
      tPtrTextureData_D0.pType_0->pprenderToTexture_38[1] = NULL;
      delete prenderToTexture_sp44;
      if (prenderToTexture_sp48) {
        // 0019D6B0
        delete prenderToTexture_sp48;
      }
      // loc_19D6B6
      if (r11_prenderToTexture) {
        delete r11_prenderToTexture;
      }
      // loc_19D6C0

      break;
    }
    case 7: {
      // 0019D724   OK
      LOGE("case 7"); 
      CFTTRenderToTexture *r4_prenderToTexture =
          g_pGraphicsDevice->createRenderToTexture(
              EFTTTexFormat_2, 0x100, 0x200, 0x1, 0x18, EFTTRTTZBufMode_1,
              false, EFTTTextureType_0, 1);
      if (tPtrTextureData_D0.pType_0->prenderToTexture_40) {
        // 0019D758
        delete tPtrTextureData_D0.pType_0->prenderToTexture_40;
      }
      // loc_19D75E
      tPtrTextureData_D0.pType_0->prenderToTexture_40 = r4_prenderToTexture;
      // s16=-1.5f r8=r0=0.0799999982f s18=-0.0399999991f r6=0xAE4
      // loc_19D7AA
      for (int r4_i = 0; r4_i != 4; r4_i++) {
        // loc_19D776
        float s0_f = XSYS_RandomNoSyncF(0.0799999982f);
        float s2_f = (float)r4_i - 1.5f;
        s0_f -= 0.0399999991f;
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_8 = 0;
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_4 = 0;
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i]
            .m_cVec32_ADC.float_0 = s2_f + s0_f;
      }
      // 0019D7AE
      CFTTClearSettings clearSetting_spd0 = g_tBlankCanvasClearSettings;
      clearSetting_spd0.dRGBA_8 = 0xFFFFFF;
      CGfxPlayer::SetupBatchConstants();
      CPlayerShader::s_tInstance.SetShadowMap(EPlayerShader_ShadowMap_0);
      CPlayerShader::s_tInstance.SetBlendMode(EPlayerShader_BlendMode_0);
      CPlayerShader::s_tInstance.SetModel(EPlayerShader_Model_0);
      CPlayerShader::s_tInstance.SetQuality(EPlayerShader_Quality_2);
      tPtrTextureData_D0.pType_0->prenderToTexture_40->BeginRenderToTexture(
          clearSetting_spd0);
      tPtrTextureData_D0.pType_0->prenderToTexture_40->EndRenderToTexture(
          EFTTRTTCopyMode_0);

      break;
    }
    case 8: {  // loc_19D832 OK
    LOGE("case 8");
      for (int r4_i = 0; r4_i != 4; r4_i++) {
        // loc_19D836
        // check 寻址
        ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r4_i].Setup(
            ECrowdMemberType_2, 0xff);
      }

      // 0019D84E
      FTTALG::Shuffle(((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0),
                      &((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[4]);
      // loc_19D870
      for (int r5_i = 0; r5_i != 4; r5_i++) {
        uchar r0_b = XSYS_RandomNoSync(3);
        tPtrTextureData_D0.pType_0->byte_108[r5_i] = byte_2FF0B7[r0_b];
      }
      // 0019D874
      // sp44= tPtrTextureData_D0.pType_0->buff_90e
      //r8=byte_2FF0C3
      //r9=byte_4630E0
      // loc_19D92A
      for (int r1_i = 0; r1_i != 4; r1_i++) {
        // loc_19D88A

        // sp48=r1_i
        for (int r6_i = 0; r6_i != 4; r6_i++) {
          // loc_19D89C
          // r1=byte_2FF0C3[r6_i]
          // check
          uint r4_u = t_4630e0.byte_4630E0[byte_2FF0C3[r6_i] * 2];
          tPtrTextureData_D0.pType_0->data_90c[r1_i][r6_i].b_0 =
              tPtrTextureData_D0.pType_0->byte_108[r1_i];
          uint r5_u = t_4630e0.byte_4630E0[byte_2FF0C3[r6_i] * 2 + 1];
          ushort r0_us =
              GetAnim(tPtrTextureData_D0.pType_0->byte_108[r1_i])->filed_4;

          if (r6_i == r4_u) {
            // 0019D8BE
            r0_us = XSYS_RandomNoSync(r0_us);
          } else {
            // loc_19D8C6
            float s0_f = r5_u - r4_u;
            float s2_f = r6_i - r4_u;
            s0_f = s2_f / s0_f;
            s2_f = r0_us;
            float s4_f = tPtrTextureData_D0.pType_0->data_90c[r1_i][r4_u].us_2 +
                         s0_f * s2_f;
            r0_us = ((uint)s4_f) % r0_us;
          }
          // loc_19D912
          tPtrTextureData_D0.pType_0->data_90c[r1_i][r6_i].us_2 = r0_us;
        }
      }

      break;
    }
    case 9: {  // loc_19D94A OK
       LOGE("case 9");
      CFTTClearSettings clear_setting_sp78 = g_tBlankCanvasClearSettings;
      clear_setting_sp78.dRGBA_8 = 0xFFFFFF;
      tPtrTextureData_D0.pType_0->prenderToTexture_40->BeginRenderToTexture(
          clear_setting_sp78);
      //0019D978
      CFTTVector32 vector_sp50;
      vector_sp50.float_0 = -2.0f;
      vector_sp50.float_4 = -0.100000001f;
      vector_sp50.float_8 = 0;

      CFTTVector32 vector_sp114;
      vector_sp114.float_0 = 2.0f;
      vector_sp114.float_4 = 3.0f;
      vector_sp114.float_8 = 20.0f;

      CFTTCamera::SetOrthographic(1.0f, 20.0f, 3.0f, -0.100000001f, -2.0f,
                                  2.0f);
      CFTTVector32 vector32_spd0;
      vector32_spd0.float_0 = 0;
      vector32_spd0.float_4 = 0;
      vector32_spd0.float_8 = -10.0f;
      CFTTCamera::SetPosition(vector32_spd0);
      vector32_spd0.float_0 = 0;
      vector32_spd0.float_4 = 0;
      vector32_spd0.float_8 = 1.0f;
      CFTTCamera::SetDirection(vector32_spd0, NULL);
      CFTTCamera::SetViewport(0x100, 0x200, 0);
      CFTTCamera::ApplyCameraSettings();
      g_pGraphicsDevice->setDepthTest(EFTTDepthTest_8, true);

      // s16=0.25f s18=-1.0f r9= tPtrTextureData_D0.pType_0->data_90c
      // s20=1.0f r4=g_pGraphicsDevice R6=sp120
      // sp44=g_pGraphicsDevice
      // loc_19DB34
      
      for (int r5_i = 0; r5_i != 4; r5_i++) {
        // loc_19DA00
        float s0_f = (float)r5_i;
        float s2_f = (float)(r5_i+1);
        // check 虚函数顺序
        float s24_f = s2_f * 0.25f;
        float s22_f = s0_f * 0.25f;
        if (g_pGraphicsDevice->Matrices_FlipsRTT() == 0) {
          // 0019DA28
          if (g_pGraphicsDevice->Matrices_FlipsY() == 0) {
            s24_f = 1.0f - s24_f;
            s22_f = 1.0f - s22_f;
          }
        }
        // loc_19DA3A
        s2_f = s22_f + s22_f;
        s0_f = s24_f + s24_f;

        CFTTMatrix32 mat32_spd0;
        CFTTVector32 vector32_spc4;
        CFTTVector32 vector32_spb8;
        vector32_spc4.float_0 = -1.0f;
        vector32_spc4.float_4 = s0_f - 1.0f;
        vector32_spc4.float_8 = 0;

        vector32_spb8.float_0 = 1.0f;
        vector32_spb8.float_4 = s2_f - 1.0f;
        vector32_spb8.float_8 = 1.0f;
        // check mat32_spd0 是否是传出参数
        sub_19ED8C(mat32_spd0, &vector_sp50, &vector_sp114, &vector32_spc4,
                   &vector32_spb8);
        CFTTShaderBuiltInConstants::SetProjMatrix(mat32_spd0);
        GFXPLAYER_pBatch->Begin();
        // loc_19DB12
        for (int r10_i = 0; r10_i != 4; r10_i++) {
          // loc_19DAD4
          // check 寻址
        
          TSATAnim_TSX *r5_panim =
              GetAnim(tPtrTextureData_D0.pType_0->data_90c[r10_i][r5_i].b_0);
       
          TSATAnim_TSX *r3_plegAnim =
              GetLegAnim(tPtrTextureData_D0.pType_0->data_90c[r10_i][r5_i].b_0);
         
          CFTTMatrix32 mat32_sp120 =
              ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r10_i].Animate(
                  r5_panim, r3_plegAnim,
                  tPtrTextureData_D0.pType_0->data_90c[r10_i][r5_i].us_2);
          
          ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r10_i].Render(NULL);
       
        }
        // 0019DB18
        GFXPLAYER_pBatch->End();
        CGfxPlayer::FlushPlayerSkins();
        GFXPLAYER_pBatch->ResetCache(false);
      }
      // 0019DB3A
      tPtrTextureData_D0.pType_0->prenderToTexture_40->EndRenderToTexture(
          EFTTRTTCopyMode_0);
      LOGE("9 end");
      break;
    }
    case 10: {
      // loc_19DB64 OK
      LOGE("case 10");
      CFTTRenderToTexture *r11_prenderToTexture =
          g_pGraphicsDevice->createRenderToTexture(EFTTTexFormat_2, 0x80, 0x100,
                                                   0x1, 0, EFTTRTTZBufMode_1,
                                                   false, EFTTTextureType_0, 1);
      // 0019DB8E
      // r10=r11
      CFTTRenderToTexture *prenderToTexture_sp48 =
          g_pGraphicsDevice->createRenderToTexture(EFTTTexFormat_2, 0x80, 0x100,
                                                   0x1, 0, EFTTRTTZBufMode_1,
                                                   false, EFTTTextureType_0, 1);
      CFTTRenderToTexture *r9_prenderToTexture =
          g_pGraphicsDevice->createRenderToTexture(EFTTTexFormat_2, 0x80, 0x100,
                                                   0x1, 0, EFTTRTTZBufMode_1,
                                                   false, EFTTTextureType_0, 1);
      // 0019DBD2
      r11_prenderToTexture->BeginRenderToTexture(g_tBlankCanvasClearSettings);
      FTT2D_Begin();
      FTT2D_SetDefaultMatBlend(EFTT2D_Blend_5);
      FTT2D_SetTexture(
          tPtrTextureData_D0.pType_0->prenderToTexture_40->GetTexture(), 0);
      // 0019DBFC
      FTT2D_DrawTexturedRect(0, 0, 128.0f, 256.0f, -1, 0, -999999.0f,
                             -999999.0f);
      FTT2D_End();
      r11_prenderToTexture->EndRenderToTexture(EFTTRTTCopyMode_0);
      // 0019DC2A
      CFTTVector32x4 vector32x4_spd0;
      vector32x4_spd0.my[0] = 1.0f;
      vector32x4_spd0.my[1] = 1.0f;
      vector32x4_spd0.my[2] = 1.0f;
      vector32x4_spd0.my[3] = 0;

      CGaussianNewShader::s_tInstance.SetColourMultiplier(vector32x4_spd0);
      GaussianBlur(
          r11_prenderToTexture, r9_prenderToTexture, prenderToTexture_sp48,
          2.0f, tPtrTextureData_D0.pType_0->miCFTTMaterialIndex_0, true, true);
      FTT2D_Begin();
      FTT2D_SetDefaultMatBlend(EFTT2D_Blend_5);
      FTT2D_SetTexture(r11_prenderToTexture->GetTexture(), 0);
      FTT2D_DrawTexturedRect(0, 0, 128.0f, 256.0f, -1, 0, -999999.0f,
                             -999999.0f);
      FTT2D_End();
      CFTTTexture *r5_ptexture =
          r9_prenderToTexture->EndRenderToTexture(EFTTRTTCopyMode_2);
      if (ptexture_A0) {  // 0019DCA8
        delete ptexture_A0;
      }
      // loc_19DCAE
      ptexture_A0 = r5_ptexture;
      switch (GFXSPEC_pSpecification->eCrowdQuality_4C) {
        case 2:
        case 3:
        case 4:
          // loc_19DCD2
          r5_ptexture->SetMinFilter(EFTTTex_MinFilter_5);
          break;
        default:
          // 0019E904
          r5_ptexture->SetMinFilter(EFTTTex_MinFilter_4);
          // loc_19E908
          break;
      }
      // 0019E90E
      CFTTTexParam parm;
      // check 这里传参
      parm.setTexture(ptexture_A0);
      LOGE("PARM.SIZE=%x",sizeof(parm));
      
      CCrowdNewShader::s_tInstance.SetDiffuse(parm, dCrowdNewShaderID_CBBC[1]);
      if (tPtrTextureData_D0.pType_0->prenderToTexture_40) {
        // 0019E930
        delete tPtrTextureData_D0.pType_0->prenderToTexture_40;
      }
      // 0019E936
      tPtrTextureData_D0.pType_0->prenderToTexture_40 = 0;
      if (r9_prenderToTexture) {
        // 0019E940
        delete r9_prenderToTexture;
      }
      // loc_19E94A
      if (prenderToTexture_sp48) {
        delete prenderToTexture_sp48;
      }
      // loc_19E954
      if (r11_prenderToTexture) {
        // 0019E95C
        delete r11_prenderToTexture;
      }
      break;
    }
    case 15: {
      // loc_19E9C0 OK
      //  check 虚函数
      LOGE("case 15");
      g_pGraphicsDevice->setDither(true);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_48);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_4C);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_50);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_58);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_4);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_8);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_C);
      FTT_pTex->ReleaseTexture(tPtrTextureData_D0.pType_0->texture_10);
      CModelManager::FreeModel(tPtrTextureData_D0.pType_0->model_2C);
      CModelManager::FreeModel(tPtrTextureData_D0.pType_0->model_30);
      FTT_pMtlL->ReleaseMaterial(
          tPtrTextureData_D0.pType_0->miCFTTMaterialIndex_0);
      tPtrTextureData_D0.pType_0->miCFTTMaterialIndex_0 = -1;
      tPtrTextureData_D0 = NULL;
      CPlayerShader::s_tInstance.SetCinematic(EPlayerShader_Cinematic_0);
      CGfxEnvironmentMap::Get()->SetForced(EEnvMapOverride_0);
      break;
    }
    case 11:
    case 12:
    case 13:
    case 14:
     {
      // check eCrowdQuality_4C
      // 0019CBC0
      LOGE("case default GFXSPEC_pSpecification->eCrowdQuality_4C=%x",GFXSPEC_pSpecification->eCrowdQuality_4C);
      if (GFXSPEC_pSpecification->eCrowdQuality_4C) {
        // 0019CBD0
        // loc_19CF04
        switch (r1_u) {
          case 11: {
            // loc_19DCDA
            LOGE("case 11");
            CFTTRenderToTexture *r4_prenderToTexture =
                g_pGraphicsDevice->createRenderToTexture(
                    EFTTTexFormat_2, 0x800, 0x800, 0x1, 0x18, EFTTRTTZBufMode_1,
                    false, EFTTTextureType_0, 1);
            // 0019DD0C
            if (tPtrTextureData_D0.pType_0->prenderToTexture_44)  // 0019DD0E
              delete tPtrTextureData_D0.pType_0->prenderToTexture_44;

            tPtrTextureData_D0.pType_0->prenderToTexture_44 =
                r4_prenderToTexture;
            break;
          }
          case 12: {
            // loc_19DD1C
            LOGE("case 12");
            for (uchar r5_uc = 0; r5_uc != 0x20; r5_uc++) {
              // loc_19DD22
              if (r5_uc <= 4) {
                // 0019DD26
                ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r5_uc].Setup(
                    ECrowdMemberType_0, r5_uc);

              } else {
                // loc_19DD32
                if (r5_uc <= 9) {
                  // /0019DD3C
                  ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r5_uc].Setup(
                      ECrowdMemberType_1, r5_uc - 0x5);
                } else {
                  // loc_19DD44
                  ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r5_uc].Setup(
                      ECrowdMemberType_2, r5_uc - 0xa);
                }
              }
            }
            // 0019DD5A
            for (int r1_i = 0; r1_i != 0x20; r1_i++) {
              // loc_19DD60
              ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r1_i]
                  .m_cVec32_ADC.float_0 = 0;
              ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r1_i]
                  .m_cVec32_ADC.float_4 = 0;
              ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r1_i]
                  .m_cVec32_ADC.float_8 = 0;
            }
            // 0019DD7C
            // sp48 dword_2FF0C8
            // sp38=unk_2FF157
            // r11=byte_2FF148
            // loc_19DE22
            for (int r9_i = 0; r9_i != 0x20; r9_i++) {
              // loc_19DD9C
              int r6_i = dword_2FF0C8[r9_i];
              uchar r10_uc = XSYS_RandomNoSync(byte5_2FF148[r6_i].b_0);
              uchar r4_uc = XSYS_RandomNoSync(byte5_2FF148[r6_i].b_1);
              uchar r0_uc = XSYS_RandomNoSync(byte5_2FF148[r6_i].b_2);
              const uchar *r5_puc = &byte_2FF157[r6_i * 60];

              tPtrTextureData_D0.pType_0->buff_68[r9_i][1] =
                  r5_puc[r4_uc + 0xc];
              tPtrTextureData_D0.pType_0->buff_68[r9_i][0] = r5_puc[r10_uc];
              tPtrTextureData_D0.pType_0->buff_68[r9_i][2] =
                  r5_puc[r0_uc + 0x18];
              r4_uc = XSYS_RandomNoSync(byte5_2FF148[r6_i].b_3);
              r0_uc = XSYS_RandomNoSync(byte5_2FF148[r6_i].b_4);
              tPtrTextureData_D0.pType_0->buff_68[r9_i][3] =
                  r5_puc[r4_uc + 0x24];
              tPtrTextureData_D0.pType_0->buff_68[r9_i][4] =
                  r5_puc[r0_uc + 0x30];
            }
            // 0019DE28
            // sp38=0 lr r8 r1
            // r12=tPtrTextureData_D0
            // r0 tPtrTextureData_D0.pType_0.2970
            // loc_19DEDA
            // check 寻址
        
            ushort us_sp38 = 0;
            for (int r8_i = 0; r8_i != 0x20; r8_i++) {
              // loc_19DE40
              // r10 = tPtrTextureData_D0.pType_0->buf_2950[r8_i]
              uchar r3_uc = 0;
              int r9_i = dword_2FF0C8[r8_i];
              tPtrTextureData_D0.pType_0->uc_2950[r8_i] = 0;
              // loc_19DEC6
              for (int r2_i = 0; r2_i != 5; r2_i++) {
                // loc_19DE5A
                if (byte_2FF157[r9_i * 5 + r2_i]) {
                  // 0019DE66

                  TGfxCrowdState::uSpan[r8_i][r2_i].b_0 = r3_uc;
                  uchar r6_uc = dword_462764[tPtrTextureData_D0.pType_0
                                                 ->buff_68[r8_i][r2_i]]
                                    .filed_4;
                  TGfxCrowdState::uSpan[r8_i][r2_i].b_1 = r6_uc + r3_uc;
                  // check uxtab
                  uint r1_u = r6_uc + r3_uc;
                  // loc_19DEA0
                  // check 这里
                  while (r3_uc < r1_u) {
                    // loc_19DE9C
                    // check
                    tPtrTextureData_D0.pType_0->buf_2970[r8_i][r3_uc] = r2_i;
                    r3_uc++;
                  }
                  // 0019DEA4
                  tPtrTextureData_D0.pType_0->uc_2950[r8_i] += r6_uc ;
                  r3_uc=r1_u;
                } else {
                  // loc_19DEB2
                  TGfxCrowdState::uSpan[r8_i][r2_i].b_0 = 0;
                  TGfxCrowdState::uSpan[r8_i][r2_i].b_1 = 0;
                }
              }
              // 0019DECA
              us_sp38++;
            }
            // 0019DEE0
            // r2=tPtrTextureData_D0.pType_0->buf_2970
            // r11=tPtrTextureData_D0
            // r10=tPtrTextureData_D0.pType_0.94e
            // sp40=TGfxCrowdState::uSpan
            // loc_19E092
            for (int r5_i = 0; r5_i != 0x20; r5_i++) {
              // loc_19DF34
              // sp48=tPtrTextureData_D0.pType_0->buf_2950[r5_i]
              // sp34=r10=tPtrTextureData_D0.pType_0.94e
              // sp44=r2=tPtrTextureData_D0.pType_0->buf_2970
              // loc_19DF4C
              // r3=r10=tPtrTextureData_D0.pType_0.94e
              for (int r9_u = 0;
                   r9_u < tPtrTextureData_D0.pType_0->uc_2950[r5_i]; r9_u++) {
                // 0019DF56
                // check  寻址以及r4_uc
                uchar r0_uc = tPtrTextureData_D0.pType_0->buf_2970[r5_i][r9_u];
                uchar r4_uc = tPtrTextureData_D0.pType_0->buff_68[r5_i][r0_uc];
                tPtrTextureData_D0.pType_0->buff_94c[r5_i][r9_u].b_0 = r4_uc;

                ushort r1_us = GetAnim(r4_uc)->filed_4;
                uint r0_u;
                if (TGfxCrowdState::uSpan[r5_i][r0_uc].b_0 == r9_u) {
                  // 0019DF90
                  // sp3c=tPtrTextureData_D0.pType_0.94e
                  if ((dword_462764[r4_uc].filed_5 |
                       dword_462764[r4_uc].filed_6) == 0) {
                    // 0019DFAE
                    if (dword_462764[r4_uc].filed_7 == 0) {
                      // 0019DFB2
                      if (dword_462764[r4_uc].filed_8) {
                        // loc_19DFBA
                        r0_u =
                            XSYS_RandomNoSync(1 - dword_462764[r4_uc].filed_5);
                      } else {
                        // loc_19E05A
                        // check continue
                        int r10_i = XSYS_RandomNoSync(r1_us);
                        tPtrTextureData_D0.pType_0->buff_94c[r5_i][r9_u].us_2 =
                            r10_i;
                        r10_i += XSYS_RandomNoSync(r1_us);
                        tPtrTextureData_D0.pType_0
                            ->buff_94c[r5_i]
                                      [TGfxCrowdState::uSpan[r5_i][r0_uc].b_1]
                            .us_2 = r10_i;
                        continue;
                      }
                    } else {
                      // loc_19DFBA
                      r0_u = XSYS_RandomNoSync(1 - dword_462764[r4_uc].filed_5);
                      // 0019DFC6
                    }

                  } else {
                    // loc_19DFBC
                    r0_u = XSYS_RandomNoSync(dword_462764[r4_uc].filed_6 +
                                             (1 - dword_462764[r4_uc].filed_5));
                    // 0019DFC6
                  }
                  // 0019DFC6
                  // check
                  tPtrTextureData_D0.pType_0->buff_94c[r5_i][r9_u].us_2 =
                      r0_u + dword_462764[r4_uc].filed_5;
                  // check
                  r0_u = XSYS_RandomNoSync(dword_462764[r4_uc].filed_8 +
                                           (1 - dword_462764[r4_uc].filed_7));
                  tPtrTextureData_D0.pType_0
                      ->buff_94c[r5_i][TGfxCrowdState::uSpan[r5_i][r0_uc].b_1]
                      .us_2 = r0_u + dword_462764[r4_uc].filed_7;

                } else {
                  // loc_19DFF4
                  float s0_f = TGfxCrowdState::uSpan[r5_i][r0_uc].b_1 -
                               TGfxCrowdState::uSpan[r5_i][r0_uc].b_0;
                  float s2_f = r9_u - TGfxCrowdState::uSpan[r5_i][r0_uc].b_0;
                  ushort r2_us =
                      tPtrTextureData_D0.pType_0
                          ->buff_94c[r5_i]
                                    [TGfxCrowdState::uSpan[r5_i][r0_uc].b_0]
                          .us_2;
                  ushort r0_us =
                      tPtrTextureData_D0.pType_0
                          ->buff_94c[r5_i]
                                    [TGfxCrowdState::uSpan[r5_i][r0_uc].b_1]
                          .us_2;
                  // check 这里一堆的数据类型转换
                  float s4_f = r2_us;
                  s0_f = s2_f / s0_f;
                  s2_f = r0_us - r2_us;
                  s4_f = s4_f + s0_f * s2_f;
                  // check 取余函数 以及寻址
                  tPtrTextureData_D0.pType_0->buff_94c[r5_i][r9_u].us_2 =
                      (uint)s4_f % r1_us;
                }
                // loc_19E052
              }
              // loc_19E086
            }
            // 0019E098
            // check uxth
            // uint u_sp34=(ushort)us_sp38;
            FTTVector<TShot> vectoeShot_sp78;
            vectoeShot_sp78.Resize(us_sp38);
            // r5=tPtrTextureData_D0.pType_0.94c
            // r10=f4
            // loc_19E192
            // r2=0
            uint r2_u = 0;
            for (int r0_i = 0; r0_i != 0x20; r0_i++) {
              // loc_19E0C4
              // sp44=tPtrTextureData_D0.pType_0->buf_2950[r0_i]
              // sp38=r5=tPtrTextureData_D0.pType_0.94c
              // sp3c=r10=tPtrTextureData_D0.pType_0.f4
              // uint r8_u=r2_u;
              for (uint r11_u = 0;
                   r11_u < tPtrTextureData_D0.pType_0->uc_2950[r0_i]; r11_u++) {
                /// loc_19E0DE
                // sp48=r2
                // check 94c 寻址
                TSATAnim_TSX *r4_panim =
                    GetAnim(tPtrTextureData_D0.pType_0->buff_94c[r0_i][r11_u].b_0);
                TSATAnim_TSX *r3_plegAnim = GetLegAnim(
                    tPtrTextureData_D0.pType_0->buff_94c[r0_i][r11_u].b_0);
                CFTTMatrix32 mat_spd0 =
                    ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r0_i]
                        .Animate(
                            r4_panim, r3_plegAnim,
                            tPtrTextureData_D0.pType_0->buff_94c[r0_i][r11_u].us_2);
                // 0019E10E
                CFTTVector32 vector32_sp120;
                vector32_sp120.float_0 = 0.100000001f;
                vector32_sp120.float_4 = 0.150000006f;
                vector32_sp120.float_8 = 0.100000001f;
                // CFTTMatrix32 结构体应该是包含TAABB结构 这里先不改
                ((TAABB *)&mat_spd0)->Inflate(vector32_sp120);
                data_d8[r0_i][r11_u].f_0 = mat_spd0.d[0][0];
                data_d8[r0_i][r11_u].f_4 = mat_spd0.d[0][1];
                // check
                data_d8[r0_i][r11_u].f_8 = mat_spd0.d[0][3];
                data_d8[r0_i][r11_u].f_C = mat_spd0.d[0][1];
                data_d8[r0_i][r11_u].f_10 = mat_spd0.d[0][0];
                data_d8[r0_i][r11_u].f_1C = mat_spd0.d[1][0];
                data_d8[r0_i][r11_u].f_14 = mat_spd0.d[1][0];
                data_d8[r0_i][r11_u].f_18 = mat_spd0.d[0][3];
                vectoeShot_sp78.list_0[r2_u].b_0 = r11_u;
                vectoeShot_sp78.list_0[r2_u].b_1 = r0_i;
                vectoeShot_sp78.list_0[r2_u].f_4 = mat_spd0.d[0][0];
                vectoeShot_sp78.list_0[r2_u].f_8 = mat_spd0.d[0][1];
                vectoeShot_sp78.list_0[r2_u].f_C = mat_spd0.d[0][2];
                vectoeShot_sp78.list_0[r2_u].f_10 = mat_spd0.d[0][3];

                vectoeShot_sp78.list_0[r2_u].f_14 = mat_spd0.d[1][0];
                vectoeShot_sp78.list_0[r2_u].f_18 = mat_spd0.d[1][1];
                //vectoeShot_sp78

                r2_u++;
              }
              // 0019E17E
            }
            // 0019E196
            FTTVector<TShot>::Iterator vectorIt_sp70;
            vectorIt_sp70.list_4 = vectoeShot_sp78.list_0;
            FTTVector<TShot>::Iterator vectorIt_sp68;
            vectorIt_sp68.list_4 =
                vectoeShot_sp78.use_count_C + vectoeShot_sp78.list_0;
            // check 函数符号以及传参是否使用了栈
            
            FTTALG::Quicksort<SortShots,FTTVector<TShot>::Iterator>(vectorIt_sp70, vectorIt_sp68);

            FTTAtlasGenerator *r6_pGenerator =
                new FTTAtlasGenerator(0x800, 0x800, 0x800);
            tPtrTextureData_D0.pType_0->mpFTTAtlasGenerator_194C =
                r6_pGenerator;
     
            float s16_f = us_sp38;
            float s18_f = 80.0f;
            // S20=0.25f s22=-10.0f s18=80.0f  s24=0.5f s19=0.00048828125f
            // r0=1950 s26=-5.0f s28=0.75f s30=-1.0f s17=-2.0f
            // r5 r10 =0
            // r9=tPtrTextureData_D0.pType_0.1950
            // for(uint r10_u=0;r10_u<u_sp34;)

            // loc_19E21C
            uint r5_u = 0;
            int r10_i = 0;
            // loc_19E2EA check 符号
            while (r10_i < us_sp38) {
              // 0019E2F0
              int r1_i = s18_f * (vectoeShot_sp78.list_0[r5_u].f_10 -
                                  vectoeShot_sp78.list_0[r5_u].f_4);
              int r2_i = s18_f * (vectoeShot_sp78.list_0[r5_u].f_14 -
                                  vectoeShot_sp78.list_0[r5_u].f_8);
              FTTAtlasGeneratorNode *r0_node =
                  tPtrTextureData_D0.pType_0->mpFTTAtlasGenerator_194C.pType_0
                      ->Insert(r1_i, r2_i);
              // 0019E32C check
              tPtrTextureData_D0.pType_0
                  ->buf_1950[vectoeShot_sp78.list_0[r5_u].b_1]
                            [vectoeShot_sp78.list_0[r5_u].b_0] = r0_node;

              if (tPtrTextureData_D0.pType_0
                      ->buf_1950[vectoeShot_sp78.list_0[r5_u].b_1]
                                [vectoeShot_sp78.list_0[r5_u].b_0] == 0) {
                // 0019E34A
                tPtrTextureData_D0.pType_0->mpFTTAtlasGenerator_194C.pType_0
                    ->Clear();
                float s0_f = (float)r10_i / s16_f;
                float s2_f = -10.0f;
                if (s0_f >= 0.25f) {
                  // 0019E36C
                  s2_f =  -5.0f;
                  if (s0_f >= 0.5f) {
                    // 0019E37A
                    s2_f =  - 1.0f;
                    if (s0_f < 0.75f) {
                      s2_f =  - 2.0f;
                    }
                  }
                }
                // loc_19E38C
                s18_f += s2_f;
              } else {
                // loc_19E23C
                int r3_i = tPtrTextureData_D0.pType_0
                               ->buf_1950[vectoeShot_sp78.list_0[r5_u].b_1]
                                         [vectoeShot_sp78.list_0[r5_u].b_0]
                               ->field_C;
                int r12_i = tPtrTextureData_D0.pType_0
                                ->buf_1950[vectoeShot_sp78.list_0[r5_u].b_1]
                                          [vectoeShot_sp78.list_0[r5_u].b_0]
                                ->field_10;
                int lr_i = tPtrTextureData_D0.pType_0
                               ->buf_1950[vectoeShot_sp78.list_0[r5_u].b_1]
                                         [vectoeShot_sp78.list_0[r5_u].b_0]
                               ->field_14;
                int r11_i = tPtrTextureData_D0.pType_0
                                ->buf_1950[vectoeShot_sp78.list_0[r5_u].b_1]
                                          [vectoeShot_sp78.list_0[r5_u].b_0]
                                ->field_18;
                data_d8[vectoeShot_sp78.list_0[r5_u].b_1]
                       [vectoeShot_sp78.list_0[r5_u].b_0]
                           .f_20 = (float)r3_i * 0.00048828125f;

                data_d8[vectoeShot_sp78.list_0[r5_u].b_1]
                       [vectoeShot_sp78.list_0[r5_u].b_0]
                           .f_24 = (float)(r3_i + lr_i) * 0.00048828125f;
                data_d8[vectoeShot_sp78.list_0[r5_u].b_1]
                       [vectoeShot_sp78.list_0[r5_u].b_0]
                           .f_28 = (float)r2_i * 0.00048828125f;
                data_d8[vectoeShot_sp78.list_0[r5_u].b_1]
                       [vectoeShot_sp78.list_0[r5_u].b_0]
                           .f_2C = (float)(r12_i + r11_i + 4) * 0.00048828125f;

                r10_i++;
                r5_u++;
                continue;
              }
              // loc_19E21C
              r5_u = 0;
              r10_i = 0;
            }

            break;
          }
          case 13: {
            // loc_19E3B0
            LOGE("case 13");
            CFTTClearSettings clearSetting_sp120 = g_tBlankCanvasClearSettings;
            clearSetting_sp120.dRGBA_8 = 0xFFFFFF;
            tPtrTextureData_D0.pType_0->prenderToTexture_44
                ->BeginRenderToTexture(clearSetting_sp120);
            // 0019E3EC
            CFTTCamera::SetOrthographic(1.0f, 20.0f, 2.0f, 0, -1.0f, 1.0f);
            CFTTVector32 vector32_spd0;
            vector32_spd0.float_0 = 0;
            vector32_spd0.float_4 = 0;
            vector32_spd0.float_8 = -10.0f;
            CFTTCamera::SetPosition(vector32_spd0);
            vector32_spd0.float_0 = 0;
            vector32_spd0.float_4 = 0;
            vector32_spd0.float_8 = 1.0f;
            CFTTCamera::SetDirection(vector32_spd0, 0);
            CFTTCamera::SetViewport(0x800, 0x800, 0);
            CFTTCamera::ApplyCameraSettings();
            g_pGraphicsDevice->setDepthTest(EFTTDepthTest_8, true);
            // s18=1.0f r6=sp50 s20=-1.0f s16=0.00048828125f
            // r5=r11=tPtrTextureData_D0.pType_0
            // sp44=sp5c
            // sp3c=GFXPLAYER_pBatch
            // loc_19E5DE
            for (int r9_i = 0; r9_i != 0x20; r9_i++) {
              // loc_19E46A

              GFXPLAYER_pBatch->Begin();
              // r5=tPtrTextureData_D0.pType_0->buff_94c[r9_i]
              for (int r8_u = 0; tPtrTextureData_D0.pType_0->uc_2950[r9_i];
                   r8_u++) {
                // loc_19E484
                TSATAnim_TSX *r4_panim = GetAnim(
                    tPtrTextureData_D0.pType_0->buff_94c[r9_i][r8_u].b_0);
                TSATAnim_TSX *r3_panim = GetLegAnim(
                    tPtrTextureData_D0.pType_0->buff_94c[r9_i][r8_u].b_0);

                CFTTMatrix32 mat_sp50 =
                    ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r9_i]
                        .Animate(
                            r4_panim, r3_panim,
                            tPtrTextureData_D0.pType_0->buff_94c[r9_i][r8_u]
                                .us_2);
                vector32_spd0.float_0 = 0.100000001f;
                vector32_spd0.float_4 = 0.300000012f;
                vector32_spd0.float_8 = 0.100000001f;
                ((TAABB *)&mat_sp50)->Inflate(vector32_spd0);
                // 0019E4C4
                int r1_i =
                    tPtrTextureData_D0.pType_0->buf_1950[r9_i][r8_u]->field_C;
                int r2_i =
                    tPtrTextureData_D0.pType_0->buf_1950[r9_i][r8_u]->field_10;
                int r3_i =
                    tPtrTextureData_D0.pType_0->buf_1950[r9_i][r8_u]->field_14;
                int r0_i =
                    tPtrTextureData_D0.pType_0->buf_1950[r9_i][r8_u]->field_18;
                float s6_f = r1_i;
                float s4_f = r2_i;
                float s0_f = r0_i + r2_i;
                float s2_f = r3_i + r1_i;
                float s24_f = s0_f * 0.00048828125f;
                float s22_f = s2_f * 0.00048828125f;
                float s28_f = s4_f * 0.00048828125f;
                float s26_f = s6_f * 0.00048828125f;
               
                if (g_pGraphicsDevice->Matrices_FlipsRTT() ||
                    g_pGraphicsDevice->Matrices_FlipsY()) {
                  // loc_19E51E
                  s24_f = 1.0f - s24_f;
                  s28_f = 1.0f - s28_f;
                }
                // loc_19E526
                s4_f = s24_f + s24_f;
                s6_f = s22_f + s22_f;
                s0_f = s28_f + s28_f;
                s2_f = s26_f + s26_f;
                CFTTVector32 vector_sp114;
                vector_sp114.float_8 = 0;
                mat_sp50.d[0][2]=0;
                mat_sp50.d[1][1]=20.0f;
                // sp64= 20f
                s4_f = s4_f - 1.0f;
                s6_f = s6_f - 1.0f;
                s0_f = s0_f - 1.0f;
                s2_f = s2_f - 1.0f;

                CFTTVector32 vector_spc4;
                vector_spc4.float_0 = s6_f;
                vector_spc4.float_4 = s4_f;
                vector_spc4.float_8 = 1.0f;
                vector_sp114.float_0 = s2_f;
                vector_sp114.float_4 = s0_f;
                CFTTMatrix32 mat32_spd0;
                sub_19ED8C(mat32_spd0, (CFTTVector32 *)&mat_sp50,
                           (CFTTVector32 *)&mat_sp50.d[0][3], &vector_sp114,
                           &vector_spc4);
                CFTTShaderBuiltInConstants::SetViewMatrix(
                    CFTTMatrix32::s_matIdentity);
                CFTTShaderBuiltInConstants::SetProjMatrix(
                    CFTTMatrix32::s_matIdentity);
                // 0019E58C
                CFTTMatrix32 mat32_sp78;
                MatrixMultiply(&mat32_sp78, &mat32_spd0,
                               &CFTTCamera::s_matView);
                ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r9_i].Render(
                    &mat32_sp78);
              }
              // 0019E5BE
              GFXPLAYER_pBatch->End();
              CGfxPlayer::FlushPlayerSkins();
              GFXPLAYER_pBatch->ResetCache(false);
            }
            // 0019E5E6
            tPtrTextureData_D0.pType_0->prenderToTexture_44->EndRenderToTexture(
                EFTTRTTCopyMode_0);
            GFXPLAYER_pBatch->cfttbmmmatrixcache_0.field_20 = 1;
            break;
          }
          case 14: {
            // loc_19E602
            LOGE("case 14");
            CFTTRenderToTexture *r4_prenderToTexture =
                g_pGraphicsDevice->createRenderToTexture(
                    EFTTTexFormat_2, 0x400, 0x400, 0x1, 0, EFTTRTTZBufMode_1,
                    false, EFTTTextureType_0, 1);

            CFTTRenderToTexture *prenderToTexture_sp44 =
                g_pGraphicsDevice->createRenderToTexture(
                    EFTTTexFormat_2, 0x400, 0x400, 0x1, 0, EFTTRTTZBufMode_1,
                    false, EFTTTextureType_0, 1);

            CFTTRenderToTexture *r9_prenderToTexture =
                g_pGraphicsDevice->createRenderToTexture(
                    EFTTTexFormat_2, 0x400, 0x400, 0x1, 0, EFTTRTTZBufMode_1,
                    false, EFTTTextureType_0, 1);

            r4_prenderToTexture->BeginRenderToTexture(
                g_tBlankCanvasClearSettings);
            FTT2D_Begin();
            FTT2D_SetDefaultMatBlend(EFTT2D_Blend_5);
            FTT2D_SetTexture(
                tPtrTextureData_D0.pType_0->prenderToTexture_44->GetTexture(),
                0);
            FTT2D_DrawTexturedRect(0, 0, 1024.0f, 1024.0f, -1, 0, -999999.0f,
                                   -999999.0f);
            FTT2D_End();
            r4_prenderToTexture->EndRenderToTexture(EFTTRTTCopyMode_0);
            // 0019E6CE
            CFTTVector32x4 vector32x4_spd0;
            vector32x4_spd0.my[0] = 1.0f;
            vector32x4_spd0.my[1] = 1.0f;
            vector32x4_spd0.my[2] = 1.0f;
            vector32x4_spd0.my[3] = 0;
            CGaussianNewShader::s_tInstance.SetColourMultiplier(
                vector32x4_spd0);
            // sp3c=r9
            GaussianBlur(r4_prenderToTexture, r9_prenderToTexture,
                         prenderToTexture_sp44, 2.0f,
                         tPtrTextureData_D0.pType_0->miCFTTMaterialIndex_0,
                         true, true);
            FTT2D_Begin();

            FTT2D_SetTexture(r4_prenderToTexture->GetTexture(), 0);
            FTT2D_DrawTexturedRect(0, 0, 1024.0f, 1024.0f, -1, 0, -999999.0f,
                                   -999999.0f);
            FTT2D_SetDefaultMatBlend(EFTT2D_Blend_7);
            // sp40=r4

            // s16=2.5f s18=192.0f s20=64.0f s22=255.0f
            // sp48=r11=tPtrTextureData_D0.pType_0
            // loc_19E8B8

            for (int r10_i = 0; r10_i != 0x20; r10_i++) {
              // loc_19E754
              // r8=tPtrTextureData_D0.pType_0.2950[r10_i]
              for (uint r9_u = 0;
                   r9_u < tPtrTextureData_D0.pType_0->uc_2950[r10_i]; r9_u++) {
                // loc_19E7A8
                TSATAnim_TSX *r5_panim = GetAnim(
                    tPtrTextureData_D0.pType_0->buff_94c[r10_i][r9_u].b_0);
                TSATAnim_TSX *r3_panim = GetLegAnim(
                    tPtrTextureData_D0.pType_0->buff_94c[r10_i][r9_u].b_0);
                CFTTMatrix32 mat32_spd0 =
                    ((TCrowdMember*)tPtrTextureData_D0.pType_0->pmembers_34.pType_0)[r10_i]
                        .Animate(
                            r5_panim, r3_panim,
                            tPtrTextureData_D0.pType_0->buff_94c[r10_i][r9_u]
                                .us_2);
                CFTTVector32 vector_sp78;
                vector_sp78.float_0 = 0.100000001f;
                vector_sp78.float_4 = 0.300000012f;
                vector_sp78.float_8 = 0.100000001f;
                ((TAABB *)&mat32_spd0)->Inflate(vector_sp78);
                // 0019E7F2
                float s0_f = mat32_spd0.d[1][0] / 2.5f;
                int r0_i =
                    tPtrTextureData_D0.pType_0->buf_1950[r10_i][r9_u]->field_C /
                    2;
                int r1_i =
                    0x400 - tPtrTextureData_D0.pType_0->buf_1950[r10_i][r9_u]
                                    ->field_10 /
                                2;
                int r2_i = tPtrTextureData_D0.pType_0->buf_1950[r10_i][r9_u]
                               ->field_14 /
                           2;
                           //s8=r3
                int r3_i = 0 - tPtrTextureData_D0.pType_0->buf_1950[r10_i][r9_u]
                                       ->field_18 /
                                   2;

                float s10_f = 64.0f + s0_f * 192.0f;
                float s2_f = r0_i;
                float s8_f = r3_i;
                float s4_f = r1_i;
                float s6_f = r2_i;
                s0_f = 255.0f;
                if (s10_f < 255.0f) {
                  s0_f = s10_f;
                }

                uint r5_u = s0_f;

                r5_u =
                    ((r5_u | (r5_u * 0x100)) | (r5_u * 0x10000)) | 0xFF000000;
                FTT2D_DrawRect4(s2_f, s4_f, s6_f, s8_f, 0xFF404040, 0xFF404040,
                                r5_u, r5_u, 0, -999999.0f, -999999.0f);
              }
              // 0019E8AA
            }
            // 0019E8C0
            FTT2D_End();
            CFTTTexture *r4_ptexture =
                r9_prenderToTexture->EndRenderToTexture(EFTTRTTCopyMode_2);
            if (ptexture_A4) {
              // 0019E8DA
              delete ptexture_A4;
            }
            // loc_19E8E0
            ptexture_A4 = r4_ptexture;
            switch (GFXSPEC_pSpecification->eCrowdQuality_4C) {
              case 1:
              case 2:
              case 3:
              case 4:
                // loc_19E8FE

                // loc_19E96C
                r4_ptexture->SetMinFilter(EFTTTex_MinFilter_5);
                break;

              default:
                // 0019E968
                // loc_19E96C
                r4_ptexture->SetMinFilter(EFTTTex_MinFilter_4);
                break;
            }
            // 0019E972
            CFTTTexParam parm;
            // check 这里传参
            parm.setTexture(ptexture_A4);

            CCrowdNewShader::s_tInstance.SetDiffuse(parm,
                                                    dCrowdNewShaderID_CBBC[2]);
            if (tPtrTextureData_D0.pType_0->prenderToTexture_44) {
              // 0019E994
              delete tPtrTextureData_D0.pType_0->prenderToTexture_44;
            }
            // loc_19E99A
            tPtrTextureData_D0.pType_0->prenderToTexture_44 = NULL;
            delete r9_prenderToTexture;
            // 0019E9A8
            if (prenderToTexture_sp44)  // 0019E9AA
              delete prenderToTexture_sp44;
            // loc_19E9B0
            if (r4_prenderToTexture)  // 0019E9B4
              delete r4_prenderToTexture;
            // loc_19E9BA
            break;
          }

          default:
            break;
        }
      }
      break;
    }
    default:
    break;
  }
  LOGE("end");
}
//-------------------------------------------------------------------------------------------------
// 0019F7E4 ^_^
void CGfxCrowd::Render() {
  // LOGI("CGfxCrowd::Render 0019F7E4");
  // if (aVec_8C[0].GetObj() == nullptr || pRender2Tex_9C == nullptr) {  //
  // 0019F7EC
  //   return;
  // }

  // // 0019F7F4
  // g_pGraphicsDevice->setDepthTest(EFTTDepthTest_8, false);
  // RenderSteward();
  // RenderStatic();
  // RenderDynamic();
  // g_pGraphicsDevice->setDepthTest(EFTTDepthTest_8, true);

  // // 0019F82A
  // for (uint r5 = 0; r5 < vec_64.use_count_C; r5++) {  // loc_19F838
  //   // loc_19F82C
  //   vec_64.GetObj()[r5].GetObj()->Render();
  // }

  // // 0019F83E
  // for (uint r5 = 0; r5 < vec_78.use_count_C; r5++) {  // loc_19F838
  //   // loc_19F82C
  //   vec_78.GetObj()[r5].GetObj()->Render();
  // }
}
//-------------------------------------------------------------------------------------------------
// 0019F85C
void CGfxCrowd::RenderSteward() {
  LOGX("CGfxCrowd::RenderSteward 0019F85C %p", this);
}
//-------------------------------------------------------------------------------------------------
// 0019F990
void CGfxCrowd::RenderStatic() {
  LOGX("CGfxCrowd::RenderStatic 0019F990 %p", this);
}
//-------------------------------------------------------------------------------------------------
// 0019FCC8
void CGfxCrowd::RenderDynamic() {
  LOGX("CGfxCrowd::RenderDynamic 0019FCC8 %p", this);
}
//-------------------------------------------------------------------------------------------------
// 001A101C
void CGfxCrowd::Process() { LOGI("CGfxCrowd::Process 001A101C"); }
//-------------------------------------------------------------------------------------------------
// 001A12C8 ^_^
void CGfxCrowd::GetCrowdState(float &f1, float &f2, float &f3) {
  // f1 = tCrowd_C0EC[0].f_0;
  // f2 = tCrowd_C0EC[4].f_0;
  // f3 = tCrowd_C0EC[8].f_0;
}
//-------------------------------------------------------------------------------------------------
// 001A12E6 ^_^
int CGfxCrowd::GetCapacity() { return vec_0.use_count_C; }
//-------------------------------------------------------------------------------------------------
// 001A12EA ^_^
CrowdTextureCreationData *CGfxCrowd::GetTextureCreationData() {
  return tPtrTextureData_D0.pType_0;
}
//-------------------------------------------------------------------------------------------------
// 001A12F0 ^_^
float CGfxCrowd::GetCrowdValue(ECrowdMemberType eType1) {
  return f_CBC8[eType1];
}
//-------------------------------------------------------------------------------------------------
// 001A12FC ^_^
void CGfxCrowd::SetCrowdValue(ECrowdMemberType eType1, float f2) {
  f_CBC8[eType1] = f2;
}
//-------------------------------------------------------------------------------------------------