TPitchLineCircle.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. #include "TPitchLineCircle.h"
  2. #include "memctrl.h"
  3. #include <algorithm>
  4. int TPitchLineCircle::s_eType;
  5. void Intersect(float a1,float a2,float a3,float a4,float &a5,float &a6)
  6. {
  7. LOGE("Intersect%x%x%x%x%x%x",a1,a2,a3,a4,a5,a6);
  8. }
  9. //-------------------------------------------------------------------------------------------------
  10. //001BE194 经过单元测试,功能正常
  11. //^_^---
  12. //001BE1BA开始的三条指令的顺序不同
  13. //001BE1DE开始的三条指令的顺序不同
  14. //寄存器不同
  15. int LineCircleIntersection(CFTTVector32 cfttvector32_r0_begin,
  16. CFTTVector32 cfttvector32_r3_begin,
  17. float f_arg_8,
  18. CFTTVector32 cfttvector32_arg_c_begin,
  19. float f_arg_18,
  20. float* p_f_arg_1c) {
  21. LOGE("%x%x%x",cfttvector32_r0_begin.float_0,cfttvector32_r0_begin.float_4,cfttvector32_r0_begin.float_8);
  22. LOGE("%x%x%x",cfttvector32_r3_begin.float_0,cfttvector32_r3_begin.float_4,cfttvector32_r3_begin.float_8);
  23. LOGE("%x%x%x",cfttvector32_arg_c_begin.float_0,cfttvector32_arg_c_begin.float_4,cfttvector32_arg_c_begin.float_8);
  24. LOGE("%f%f%f%x",f_arg_8,f_arg_18,*p_f_arg_1c,p_f_arg_1c);
  25. return rand();
  26. }
  27. //-------------------------------------------------------------------------------------------------
  28. //001BE690
  29. TPitchLineCircle::~TPitchLineCircle() {
  30. delete this;
  31. }
  32. //-------------------------------------------------------------------------------------------------
  33. //001BE184
  34. int TPitchLineCircle::GetType() {
  35. return TPitchLineCircle::s_eType;
  36. }
  37. //-------------------------------------------------------------------------------------------------
  38. //001BD85C
  39. void TPitchLineCircle::Clamp(CFTTVector32 cVec32_arg1) {
  40. float s0 = -0.5f; // 001BD866
  41. float s2 = 0.5f; // 001BD86C
  42. float s4 = cVec32_arg1.float_0; // 001BD872
  43. float s6 = cVec32_arg1.float_8; // 001BD878
  44. float s18 = s4 * s0; // 001BD888
  45. float s16 = s4 * s2; // 001BD88C
  46. s0 = s6 * s0; // 001BD890
  47. s2 = s6 * s2; // 001BD894
  48. float s8, s10, s12, s17, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28, s29, s30;
  49. int i_sp_20;
  50. int i_sp_24 = 0; // 001BD8EC
  51. uint8 i_sp_28 = 0; // 001BD8F0
  52. float f_sp_2C;
  53. int i_sp_30;
  54. int i_sp_3C;
  55. float f_sp_40;
  56. float f_sp_44;
  57. float f_sp_48[2]; // 48 4C;
  58. float f_sp_50[2]; // 50 54
  59. // float f_sp_58;
  60. // float f_sp_5C;
  61. uchar c_sp_5E[2];
  62. float f_sp_60[2]; // 60 64
  63. CFTTVector32 cVec32_sp_68; // 68 6C 70
  64. CFTTVector32 cVec32_sp_74; // 74 78 7C
  65. CFTTVector32 cVec32_sp_80[4];
  66. cVec32_sp_80[0].float_0 = s18; // 001BD898 80
  67. cVec32_sp_80[0].float_4 = 0; // 001BD870 84
  68. cVec32_sp_80[0].float_8 = s0; // 001BD89C 88
  69. cVec32_sp_80[1].float_0 = s16; // 001BD8A0 8C
  70. cVec32_sp_80[1].float_4 = 0; // 001BD876 90
  71. cVec32_sp_80[1].float_8 = s0; // 001BD8A4 94
  72. cVec32_sp_80[2].float_0 = s16; // 001BD8A8 98
  73. cVec32_sp_80[2].float_4 = 0; // 001BD87C 9C
  74. cVec32_sp_80[2].float_8 = s2; // 001BD8AC A0
  75. cVec32_sp_80[3].float_0 = s18; // 001BD8B0 A4
  76. cVec32_sp_80[3].float_4 = 0; // 001BD87E A8
  77. cVec32_sp_80[3].float_8 = s2; // 001BD8B4 AC
  78. s4 = this->vec32_4.float_8; // 001BD8B8
  79. s20 = this->vec32_4.float_0; // 001BD8BC
  80. i_sp_20 = (s0 <= s4 ? 1 : 0) & (s4 <= s2 ? 1 : 0); // 001BD8DC
  81. int i_r4 = 0;
  82. while (i_r4 != 4) {
  83. // cVec32_sp_68 = cVec32_sp_80[i_r4];
  84. float d16_0 = cVec32_sp_80[i_r4].float_0; // 001BD900
  85. float d16_4 = cVec32_sp_80[i_r4].float_4;
  86. cVec32_sp_68.float_8 = cVec32_sp_80[i_r4].float_8;
  87. cVec32_sp_68.float_0 = d16_0;
  88. cVec32_sp_68.float_4 = d16_4;
  89. i_r4++; // 001BD8FA
  90. // cVec32_sp_74 = cVec32_sp_80[i_r4 & 3];
  91. d16_0 = cVec32_sp_80[i_r4 & 3].float_0;
  92. d16_4 = cVec32_sp_80[i_r4 & 3].float_4;
  93. cVec32_sp_74.float_8 = cVec32_sp_80[i_r4 & 3].float_8;
  94. cVec32_sp_74.float_0 = d16_0;
  95. cVec32_sp_74.float_4 = d16_4;
  96. s23 = cVec32_sp_74.float_4; // 001BD926
  97. s25 = cVec32_sp_68.float_4; // 001BD92A
  98. s19 = cVec32_sp_74.float_0; // 001BD92E
  99. s17 = s23 - s25; // 001BD932
  100. s24 = cVec32_sp_68.float_0; // 001BD932
  101. s21 = cVec32_sp_74.float_8; // 001BD93A
  102. s28 = s19 - s24; // 001BD93E
  103. s26 = cVec32_sp_68.float_8; // 001BD942
  104. s30 = s21 - s26; // 001BD946
  105. s0 = s17 * s17; // 001BD94A
  106. s0 = s0 + s28 * s28; // 001BD94E
  107. s0 = s0 + s30 * s30; // 001BD952
  108. s22 = sqrtf(s0); // 001BD968
  109. float f_r6 = this->vec32_4.float_0;
  110. float f_r10 = this->vec32_4.float_4;
  111. float f_r11 = this->vec32_4.float_8;
  112. s27 = f_r10; // 001BD97A
  113. s29 = f_r11; // 001BD97E
  114. s0 = s25 - s27; // 001BD982
  115. s25 = f_r6; // 001BD986 VMOV S25, R6 ; vec32_4.float_0
  116. s4 = s24 - s25; // 001BD98A VSUB.F32 S4, S24, S25
  117. s24 = this->field_14; // 001BD98E VLDR S24, [R0,#0x92+var_80+2] ; this->field_14
  118. s2 = s0 * s0; // 001BD992 VMUL.F32 S2, S0, S0
  119. s0 = s26 - s29; // 001BD996 VSUB.F32 S0, S26, S29
  120. s26 = this->field_10; // 001BD99A VLDR S26, [R0,#0x92+var_84+2] ; this->field_10
  121. s2 = s2 + s4 * s4; // 001BD99E VMLA.F32 S2, S4, S4
  122. s2 = s2 + s0 * s0; // 001BD9A2 VMLA.F32 S2, S0, S0
  123. s0 = sqrtf(s2); // 001BD9B8
  124. s2 = s23 - s27; // 001BD9C0 VSUB.F32 S2, S23, S27
  125. // cVec32_sp_60.float_0 = s0; //001BD9C4 VSTR S0, [SP,#0xF0+var_92_vec32_94+2] ; sp+0x60,
  126. f_sp_60[0] = s0; // 001BD9C4 VSTR S0, [SP,#0xF0+var_92_vec32_94+2] ; sp+0x60,
  127. s4 = s19 - s25; // 001BD9C8 VSUB.F32 S4, S19, S25
  128. s6 = s21 - s29; // 001BD9CC VSUB.F32 S6, S21, S29
  129. s2 = s2 * s2; // 001BD9D0 VMUL.F32 S2, S2, S2
  130. s2 = s2 + s4 * s4; // 001BD9D4 VMLA.F32 S2, S4, S4
  131. s2 = s2 + s6 * s6; // 001BD9D8 VMLA.F32 S2, S6, S6
  132. s4 = sqrtf(s2); // 001BD9EE
  133. s0 = s17 / s22; // 001BD9F6 VDIV.F32 S0, S17, S22
  134. // cVec32_sp_60.float_4 = s4; //001BD9FE VSTR S4, [SP,#0xF0+var_92_vec32_94+6] ; sp+0x64
  135. f_sp_60[1] = s4; // 001BD9FE VSTR S4, [SP,#0xF0+var_92_vec32_94+6] ; sp+0x64
  136. int i_r0 = 0; // 001BD9FC
  137. while (i_r0 != 2) {
  138. // 001BDA04
  139. char c_r2 = f_sp_60[i_r0] > s24 ? 2 : 1;
  140. if (f_sp_60[i_r0] < s26) {
  141. c_r2 = 0;
  142. }
  143. c_sp_5E[i_r0] = c_r2; // 001BDA24
  144. i_r0++; // 001BDA26
  145. }
  146. s2 = s30 / s22; // 001BDA2C VDIV.F32 S2, S30, S22
  147. uint c_r2 = c_sp_5E[0]; // 001BDA30 LDRB.W R2, [SP,#0xF0+var_92_vec32_94] ; sp_5E
  148. uint c_r0 = c_sp_5E[1]; // 001BDA34 LDRB.W R0, [SP,#0xF0+var_92_vec32_94+1] ; sp_5F
  149. s4 = s28 / s22; // 001BDA3A VDIV.F32 S4, S28, S22
  150. uint c_r1;
  151. if (c_r2 > c_r0) {
  152. // LOGI("clamp 3");
  153. s2 = -s2; // 001BDA40
  154. s0 = -s0; // 001BDA46
  155. d16_0 = cVec32_sp_68.float_0; // 001BDA4A
  156. d16_4 = cVec32_sp_68.float_4;
  157. s4 = -s4; // 001BDA4E
  158. float d17_0 = cVec32_sp_74.float_0;
  159. float d17_4 = cVec32_sp_74.float_4;
  160. f_sp_50[0] = cVec32_sp_68.float_8; // 001BDA5C
  161. // f_sp_50[1] = cVec32_sp_68.float_8; //001BDA5C
  162. cVec32_sp_68.float_8 = cVec32_sp_74.float_8; // 001BDA5E
  163. cVec32_sp_68.float_0 = d17_0; // 001BDA60
  164. cVec32_sp_68.float_4 = d17_4;
  165. cVec32_sp_74.float_8 = f_sp_50[0]; // 001BDA64
  166. c_r1 = c_sp_5E[0]; // 001BDA66
  167. c_sp_5E[0] = c_r0 /*c_r0_sp_5F*/; // 001BDA68
  168. f_sp_48[0] = d16_0; // 001BDA6C
  169. f_sp_48[1] = d16_4;
  170. cVec32_sp_74.float_0 = d16_0; // 001BDA70
  171. cVec32_sp_74.float_4 = d16_4;
  172. c_sp_5E[1] = c_r2; // 001BDA74
  173. } else {
  174. c_r1 = c_sp_5E[1]; // c_r0_sp_5F;
  175. c_r0 = c_sp_5E[0]; // c_r2_sp_5E;
  176. }
  177. float LR = s4; // 001BDA7E
  178. // float f_r5;
  179. uint8 r0_v38 = 0;
  180. if (c_r1 | c_r0) {
  181. // 001BDA94
  182. if (c_r0 == 0 && c_r1 == 1) {
  183. r0_v38 = 1;
  184. } else if (c_r0 == 0 && c_r1 == 2) {
  185. r0_v38 = 2;
  186. } else if (c_r0 == 1 && c_r1 == 1) {
  187. r0_v38 = 3;
  188. } else if (c_r0 == 1 && c_r1 == 2) {
  189. r0_v38 = 4;
  190. } else {
  191. // 001BDAC0
  192. r0_v38 = (c_r0 == 2 && c_r1 == 2) ? 5 : -1;
  193. }
  194. } else {
  195. // 001BDA9E
  196. r0_v38 = 0;
  197. }
  198. // 001BDAE0 loc_1BDAE0
  199. i_sp_3C = r0_v38; // 001BDAE0
  200. // 001BDB0A
  201. CFTTVector32 vec_2;
  202. vec_2.float_0 = LR;
  203. vec_2.float_4 = s0;
  204. vec_2.float_8 = s2;
  205. i_sp_30 = LineCircleIntersection(cVec32_sp_68, vec_2, s22, this->vec32_4, s26, &f_sp_48[0]);
  206. f_sp_44 = LR; // 001BDB06
  207. // 001BDB2E
  208. vec_2.float_0 = f_sp_44;
  209. vec_2.float_4 = s0;
  210. vec_2.float_8 = s2;
  211. int ret_r0 = LineCircleIntersection(cVec32_sp_68, vec_2, s22, this->vec32_4, s24, &f_sp_50[0]);
  212. if ((-3 + (uchar)r0_v38 )>= 2) {
  213. // 001BDB48
  214. if (((uchar)r0_v38) == 5) {
  215. // 001BDB52
  216. if ((i_sp_30 != 2) && (ret_r0 != 2)) {
  217. // if (ret_r0 != 2) {
  218. i_sp_24 = i_sp_24 + (((ret_r0 ^ 2) | i_sp_30) != 0);
  219. /*if ((ret_r0 ^ 2) | ret_sp_30 ) {
  220. i_sp_24 += 1;
  221. }*/
  222. //}
  223. }
  224. } else {
  225. // 001BDB6E
  226. i_sp_28 = (r0_v38 /*i_sp_3C*/ << 0x18) == 0 ? i_sp_28+1 : i_sp_28;
  227. }
  228. }
  229. }
  230. // 001BDB80
  231. int r1_v45 = s18 <= s20 ? 1 : 0;
  232. int r2_v46 = s20 <= s16 ? 1 : 0;
  233. // int i_r3 = (uint32)((uint8)i_sp_24) != 4 ? 1 : -4 + (uint32)((uint8)i_sp_24);
  234. uint8 i_r3 = i_sp_24 != 4 ? 1 : -4 + (uchar)i_sp_24;
  235. // if ((uint32)((uint8)i_sp_28) != 4) {
  236. if ((uchar)i_sp_28 != 4) { // 001BDBB8
  237. r1_v45 &= r2_v46;
  238. r1_v45 &= i_sp_20;
  239. if ((r1_v45 | i_r3)==0) {
  240. this->f_1C = 0;
  241. return ;
  242. }
  243. } else {
  244. if (r1_v45 | i_r3) {
  245. this->f_1C = 0;
  246. return ;
  247. }
  248. }
  249. if (r1_v45 == 0) {
  250. // 001BDBD4
  251. s18 = atan2f(((int)this->vec32_4.float_8) ^ 0x80000000, ((int)this->vec32_4.float_0) ^ 0x80000000);
  252. s16 = 6.28318548f; // 001BDBEA
  253. s20 = s18 + s16; // 001BDBF2
  254. // float* ptrFloat_r4 = &cVec32_sp_80[0].float_8; //001BDBF6
  255. float ptrR6_sp68[4];
  256. for (int i_r5 = 0; i_r5 != 4; i_r5++) {
  257. s4 = cVec32_sp_80[i_r5].float_8; //*ptrFloat_r4;
  258. s6 = cVec32_sp_80[i_r5].float_0; //*(ptrFloat_r4 - 2);
  259. s0 = this->vec32_4.float_0;
  260. s2 = this->vec32_4.float_8;
  261. s0 = s6 - s0;
  262. s2 = s4 - s2;
  263. // 001BDC20
  264. s0 = atan2f(s2, s0);
  265. ptrR6_sp68[i_r5] = s0 < 0.0f ? s0+s16 : s0 ;
  266. }
  267. s0 = -6.28318548f; // 001BDC4C
  268. int i_r0 = 0;
  269. if (s18 < 0.0f) {
  270. s18 = s20; // 001BDC5A
  271. }
  272. while (i_r0 != 4) {
  273. s2 = ptrR6_sp68[i_r0]; // 001BDC62
  274. s8 = s2 + s0;
  275. s4 = s2 + s16;
  276. s6 = s2 - s18;
  277. s10 = s8 - s18;
  278. s12 = s4 - s18;
  279. s4 = fabsf(s6); // 001BDC7A
  280. s10 = fabsf(s10); // 001BDC7E
  281. s6 = fabsf(s12); // 001BDC82
  282. if (s10 < s4) {
  283. s2 = s8;
  284. s8 = s2 + s16;
  285. if (s6 < s4) {
  286. s2 = s8;
  287. }
  288. ptrR6_sp68[i_r0] = s2; // 001BDCB0
  289. }
  290. i_r0++;
  291. }
  292. s0 = 0.0f; // 001BDCBA
  293. i_r0 = 0;
  294. while (i_r0 != 4) {
  295. s2 = ptrR6_sp68[i_r0];
  296. s4 = s0 > s2 ? s0 : s2;
  297. s0 = s4;
  298. if (s16 > s2) {
  299. s16 = s2;
  300. }
  301. i_r0++;
  302. }
  303. // s2 = 6.28318548f;
  304. // s4 = s0 + 6.28318548f; //s2;
  305. // s2 = s16 + 6.28318548f; //s2;
  306. if (s16 < 0.0f) {
  307. s0 = s0 + 6.28318548f; // s4;
  308. s16 = s16 + 6.28318548f; // s2;
  309. }
  310. s0 = s0 - s16; // 001BDD12
  311. Intersect(this->field_18, this->f_1C, s16, s0, this->field_18, this->f_1C);
  312. }
  313. }
  314. //-------------------------------------------------------------------------------------------------
  315. //001BE378
  316. bool TPitchLineCircle::Identical(TPitchLineGen*) {
  317. return false;
  318. }
  319. //-------------------------------------------------------------------------------------------------
  320. //001BE490
  321. void TPitchLineCircle::Render() {
  322. }
  323. //-------------------------------------------------------------------------------------------------
  324. //001BDDE0
  325. void TPitchLineCircle::Transform(uchar) {
  326. }
  327. //-------------------------------------------------------------------------------------------------
  328. //001BD846 //^_^
  329. void TPitchLineCircle::Translate(CFTTVector32 vec32) {
  330. CFTTVector32 vec32_14 = vec32;
  331. vec32_4 -= vec32_14;
  332. }
  333. //-------------------------------------------------------------------------------------------------
  334. //001BDD48 //^_^
  335. bool TPitchLineCircle::Valid() {
  336. return f_1C != 0.0;
  337. }
  338. //-------------------------------------------------------------------------------------------------
  339. //001BE650
  340. TPitchLineGen* TPitchLineCircle::Clone() {
  341. TPitchLineCircle* pCircle = new TPitchLineCircle;
  342. return (TPitchLineGen*)pCircle;
  343. }
  344. //-------------------------------------------------------------------------------------------------