COMM.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. #include "COMM.h"
  2. #include "XSYS.h"
  3. #include "SNDGAME.h"
  4. COMM_Info COMM_tInfo;
  5. const char *X_sCommFile[1234];
  6. static int dword_47DF94, dword_47DF94_1, dword_47DF90, dword_47DF94_2, dword_47DF8C;
  7. //0x001d25ac ^_^
  8. int COMM_CheckCommentaryTime(ECommType eCommType0, int int1) {
  9. int *r3 = &COMM_tInfo.byte_16C[int1];
  10. if (int1 == -1)
  11. r3 = &COMM_tInfo.info[eCommType0 + 1];
  12. return *r3;
  13. }
  14. //0x001d26cc
  15. uint COMM_FindFile(const char *cc0) {
  16. char var_11C[0x100];
  17. if (strstr(cc0, ".wav")) {
  18. strlcpy((unsigned char *)var_11C, (unsigned char *)cc0, 0x100);
  19. } else {
  20. //loc_1D26FC
  21. snprintf(var_11C, 0x100, "%s.wav", cc0);
  22. }
  23. for (int r4 = 0; r4 <= 0x7A3; r4++) {
  24. if (!strcmp(X_sCommFile[r4], var_11C))
  25. return r4;
  26. }
  27. return -1;
  28. }
  29. extern int tGame;
  30. ushort* X_iCommCnt[70];
  31. // static short **X_iCommXRef;
  32. /*0x001d243c COMM_PlayCommentary 96*/
  33. void COMM_PlayCommentary(ECommType eCommType0, int int1, int int2) {
  34. /*PUSH.W {R4-R10,LR}
  35. .text:001D2440 MOV R5, R0
  36. .text:001D2442 MOV R8, R1
  37. .text:001D2444 ADDS R0, #1
  38. .text:001D2446 BEQ locret_1D2532*/
  39. int r2, r6, r7;
  40. COMM_Info_S0_14 *r3;
  41. if (eCommType0 == ECommType_Err) {
  42. return;
  43. }
  44. /* .text:001D2448 LDR R0, =(tGame_ptr - 0x1D244E)
  45. .text:001D244A ADD R0, PC ; tGame_ptr
  46. .text:001D244C LDR.W R9, [R0] ; tGame
  47. .text:001D2450 LDR.W R0, [R9]
  48. .text:001D2454 CMP R0, #0xF1
  49. .text:001D2456 BLT loc_1D2494*/
  50. if (tGame >= 0xf1) {
  51. /*.text:001D2458 LDR R1, =(COMM_tInfo_ptr - 0x1D245E)
  52. .text:001D245A ADD R1, PC ; COMM_tInfo_ptr
  53. .text:001D245C LDR R1, [R1] ; COMM_tInfo
  54. .text:001D245E ADD.W R3, R1, R5,LSL#2
  55. .text:001D2462 LDR R3, [R3,#4]
  56. .text:001D2464 SUBS R3, R0, R3
  57. .text:001D2466 CMP R3, #0xF0
  58. .text:001D2468 BLT locret_1D2532*/
  59. if (tGame - COMM_tInfo.info[eCommType0] < 0xF0)
  60. return;
  61. /* .text:001D246A CMP R2, #0
  62. .text:001D246C BLT loc_1D2494
  63. .text:001D246E CMP.W R0, #0x258
  64. .text:001D2472 BLE loc_1D2494*/
  65. if (int2 >= 0 && tGame > 0x258) {
  66. /* .text:001D2474 LDR R3, =(X_iCommXRef_ptr - 0x1D247A)
  67. .text:001D2476 ADD R3, PC ; X_iCommXRef_ptr
  68. .text:001D2478 LDR R3, [R3] ; X_iCommXRef
  69. .text:001D247A LDR.W R3, [R3,R5,LSL#2]
  70. .text:001D247E LDRH.W R3, [R3,R2,LSL#1]
  71. .text:001D2482 ADD.W R1, R1, R3,LSL#2
  72. .text:001D2486 LDR.W R1, [R1,#0x16C]
  73. .text:001D248A SUBS R1, R0, R1
  74. .text:001D248C CMP.W R1, #0x258
  75. .text:001D2490 BGE loc_1D24E4
  76. .text:001D2492 B locret_1D2532*/
  77. //if (tGame - COMM_tInfo.byte_16C[(X_iCommXRef[eCommType0])[int1]] >= 0x258)
  78. return;
  79. }
  80. }
  81. /*.text:001D2494 ADDS R1, R2, #1
  82. .text:001D2496 BNE loc_1D24E4*/
  83. if (int2 == -1) {
  84. /*
  85. .text:001D2498 LDR R0, =(X_iCommCnt_ptr - 0x1D24A0)
  86. .text:001D249A MOVS R1, #0xA
  87. .text:001D249C ADD R0, PC ; X_iCommCnt_ptr
  88. .text:001D249E LDR.W R10, [R0] ; X_iCommCnt
  89. .text:001D24A2 LDR R0, =(X_iCommXRef_ptr - 0x1D24A8)
  90. .text:001D24A4 ADD R0, PC ; X_iCommXRef_ptr
  91. .text:001D24A6 LDR R4, [R0] ; X_iCommXRef
  92. .text:001D24A8 LDR R0, =(COMM_tInfo_ptr - 0x1D24AE)
  93. .text:001D24AA ADD R0, PC ; COMM_tInfo_ptr
  94. text:001D24AC LDR R6, [R0] ; COMM_tInfo*/
  95. r7 = 0xA;
  96. // do {
  97. // /*.text:001D24AE LDRH.W R0, [R10,R5,LSL#1]
  98. // .text:001D24B2 MOV R7, R1
  99. // .text:001D24B4 BLX j__Z17XSYS_RandomNoSynci ; XSYS_RandomNoSync(int)
  100. // .text:001D24B8 MOV R2, R0*/
  101. // //r2 = XSYS_RandomNoSync(X_iCommCnt[eCommType0]);
  102. // /*.text:001D24BA LDR.W R0, [R9]
  103. // .text:001D24BE CBZ R7, loc_1D24E0*/
  104. // if (!r7) {
  105. // break;
  106. // }
  107. // /*.text:001D24C0 CMP.W R0, #0x258
  108. // .text:001D24C4 BLE loc_1D24E0*/
  109. // if (tGame <= 0x258) {
  110. // break;
  111. // }
  112. // r7--;
  113. /*
  114. .text:001D24C6 LDR.W R1, [R4,R5,LSL#2]
  115. .text:001D24CA LDRH.W R1, [R1,R2,LSL#1]
  116. .text:001D24CE ADD.W R1, R6, R1,LSL#2
  117. .text:001D24D2 LDR.W R1, [R1,#0x16C]
  118. .text:001D24D6 SUBS R3, R0, R1
  119. .text:001D24D8 SUBS R1, R7, #1
  120. .text:001D24DA CMP.W R3, #0x258
  121. .text:001D24DE BLT loc_1D24AE*/
  122. // } while (tGame - COMM_tInfo.byte_16C[(X_iCommXRef[eCommType0])[r2]] < 0x258);
  123. ////loc_1D24E0
  124. /*text:001D24E0 CMP R7, #2
  125. .text:001D24E2 BLT locret_1D2532*/
  126. if (r7 < 2)
  127. return;
  128. }
  129. //loc_1D24E4
  130. /*.text:001D24E4 LDR R1, =(COMM_tInfo_ptr - 0x1D24EE)
  131. .text:001D24E6 MOVS R7, #0
  132. .text:001D24E8 MOVS R6, #0
  133. .text:001D24EA ADD R1, PC ; COMM_tInfo_ptr
  134. .text:001D24EC LDR R1, [R1] ; COMM_tInfo
  135. .text:001D24EE ADD.W R3, R1, #0x11C
  136. .text:001D24F2 B loc_1D2504*/
  137. r3 = COMM_tInfo.struct_11C;
  138. r7 = 0;
  139. r6 = 0;
  140. /*.text:001D2504 CMP R6, #3
  141. .text:001D2506 BLS loc_1D24F4*/
  142. while (r6 <= 3) {
  143. /*.text:001D24F4 LDR R4, [R3]
  144. .text:001D24F6 CBZ R4, loc_1D2500*/
  145. if (r3->dword_0) {
  146. /*.text:001D24F8 LDR R4, [R3,#8]
  147. .text:001D24FA CMP R4, R8
  148. .text:001D24FC BGT locret_1D2532*/
  149. if (r3->dword_8 > int1) {
  150. return;
  151. }
  152. /*.text:001D24FE STR R7, [R3]*/
  153. r3->dword_0 = r7;
  154. }
  155. /*.text:001D2500 ADDS R3, #0x14
  156. .text:001D2502 ADDS R6, #1*/
  157. r3++;
  158. r6++;
  159. }
  160. /*.text:001D2508 LDR R3, =(X_iCommXRef_ptr - 0x1D2512)
  161. .text:001D250A ADD.W R7, R1, R5,LSL#2
  162. .text:001D250E ADD R3, PC ; X_iCommXRef_ptr
  163. .text:001D2510 STR R0, [R7,#4]*/
  164. COMM_tInfo.info[eCommType0 + 1] = tGame;
  165. /*.text:001D2512 LDR R3, [R3] ; X_iCommXRef
  166. .text:001D2514 LDR.W R3, [R3,R5,LSL#2]
  167. .text:001D2518 LDRH.W R3, [R3,R2,LSL#1]
  168. .text:001D251C ADD.W R1, R1, R3,LSL#2
  169. .text:001D2520 STR.W R0, [R1,#0x16C]*/
  170. //COMM_tInfo.byte_16C[(X_iCommXRef[eCommType0])[r2]] = tGame;
  171. /*.text:001D2524 MOV R1, R2
  172. .text:001D2526 MOV R0, R5
  173. .text:001D2528 MOV R2, R8
  174. .text:001D252A POP.W {R4-R10,LR}
  175. .text:001D252E B.W j_j__Z37SNDGAME_Commentary_QueueTypeXPriorityiii ; j_SNDGAME_Commentary_QueueTypeXPriority(int,int,int)*/
  176. SNDGAME_Commentary_QueueTypeXPriority(eCommType0, r2, int1);
  177. /*.text:001D2532 POP.W {R4-R10,PC}*/
  178. }
  179. /*0x001d2564 COMM_PlayCommentaryDelay 18*/
  180. void COMM_PlayCommentaryDelay(int i0, ECommType eCommType1, int i2, int i3, bool b4) {
  181. COMM_Info_S0_14 *p = COMM_tInfo.struct_11C;
  182. for (int R4 = 0; R4 <= 3; R4++) {
  183. if (p->dword_0 == 0) {
  184. p->dword_0 = i0;
  185. p->dword_4 = eCommType1;
  186. p->dword_8 = i2;
  187. p->dword_C = i3;
  188. p->char_10 = b4;
  189. return;
  190. }
  191. p++;
  192. }
  193. }
  194. /*0x001d2558 ^_^*/
  195. void COMM_PlayCommentaryID(int i0, int i1) {
  196. if (i0 != -1)
  197. SNDGAME_Commentary_QueueXPriority(i0, i1);
  198. }
  199. // 0x001d2430 ^_^
  200. int COMM_PlayCommentaryKeeper(int, int) {
  201. return 0;
  202. }
  203. //.0x001d2598 COMM_PlayCommentaryKick 9
  204. void COMM_PlayCommentaryKick(ECommType eCommType0, int i1, int i2) {
  205. COMM_PlayCommentaryDelay(10, eCommType0, i1, i2, 1);
  206. }
  207. // 0x001d242c COMM_PlayCommentaryName 2 ^-^
  208. int COMM_PlayCommentaryName(int, int, int) {
  209. return 0;
  210. }
  211. char *dword_3A27BC;
  212. // 0x001d2658 COMM_Process 28
  213. void COMM_Process() {
  214. /*.text:001D2658 PUSH {R3-R7,LR}
  215. .text:001D265A LDR R0, =(COMM_tInfo_ptr - 0x1D2666)
  216. .text:001D265C MOVS R4, #0
  217. .text:001D265E MOVW R7, #(dword_3A27BC - 0x39BB88)
  218. .text:001D2662 ADD R0, PC ; COMM_tInfo_ptr
  219. .text:001D2664 LDR R5, [R0] ; COMM_tInfo
  220. .text:001D2666 LDR R0, =(tGame_ptr - 0x1D266C)
  221. .text:001D2668 ADD R0, PC ; tGame_ptr
  222. .text:001D266A LDR R6, [R0] ; tGame
  223. .text:001D266C B loc_1D2696*/
  224. /*.text:001D2696 CMP R4, #0x50 ; 'P'
  225. .text:001D2698 BNE loc_1D266E*/
  226. for (int i = 0; i < 4; i++) {
  227. /*.text:001D266E ADDS R2, R5, R4
  228. .text:001D2670 LDR.W R0, [R2,#0x11C]
  229. .text:001D2674 CBZ R0, loc_1D2694*/
  230. int r0 = COMM_tInfo.struct_11C[i].dword_0;
  231. if (r0) {
  232. /*.text:001D2676 SUBS R0, #1
  233. .text:001D2678 STR.W R0, [R2,#0x11C]
  234. .text:001D267C BNE loc_1D2694*/
  235. r0--;
  236. COMM_tInfo.struct_11C[i].dword_0 = r0;
  237. if (r0) {
  238. /*.text:001D267E LDRB.W R0, [R2,#0x12C]
  239. .text:001D2682 CBZ R0, loc_1D268A*/
  240. if (COMM_tInfo.struct_11C[i].char_10
  241. /* .text:001D2684 LDR R0, [R6,R7]
  242. .text:001D2686 CMP R0, #9
  243. .text:001D2688 BLT loc_1D2694*/
  244. || dword_3A27BC[tGame] >= 9) {
  245. /*text:001D268A ADD.W R2, R2, #0x120
  246. .text:001D268E LDM R2, {R0-R2}
  247. .text:001D2690 BLX j__Z19COMM_PlayCommentary9ECommTypeii ; COMM_PlayCommentary(ECommType,int,int)*/
  248. COMM_PlayCommentary((ECommType)COMM_tInfo.struct_11C[i].dword_4, COMM_tInfo.struct_11C[i].dword_8, COMM_tInfo.struct_11C[i].dword_C);
  249. }
  250. }
  251. }
  252. /*.text:001D2694 ADDS R4, #0x14*/
  253. i++;
  254. }
  255. /*.text:001D269A POP {R3-R7,PC}*/
  256. }
  257. //0x001d2608 COMM_Reset 15
  258. void COMM_Reset() {
  259. LOGE("COMM_Reset");
  260. //memset(&COMM_tInfo, 0, sizeof(COMM_Info));
  261. // dword_47DF94 = -1;
  262. // dword_47DF90 = -1;
  263. // dword_47DF8C = -1;
  264. }
  265. //0x001d2638 COMM_ResetAfterRewind 11 ^_^
  266. void COMM_ResetAfterRewind() {
  267. /*.text:001D2638 LDR R1, =(COMM_tInfo_ptr - 0x1D2642)
  268. .text:001D263A MOVS R0, #1
  269. .text:001D263C MOVS R2, #0
  270. .text:001D263E ADD R1, PC ; COMM_tInfo_ptr
  271. .text:001D2640 LDR R1, [R1] ; COMM_tInfo
  272. .text:001D2642
  273. .text:001D2642 loc_1D2642 ; CODE XREF: COMM_ResetAfterRewind(void)+16��j
  274. .text:001D2642 CMP R0, #0x47 ; 'G'
  275. .text:001D2644 IT EQ
  276. .text:001D2646 BXEQ LR
  277. .text:001D2648 STR.W R2, [R1,R0,LSL#2]
  278. .text:001D264C ADDS R0, #1
  279. .text:001D264E B loc_1D2642*/
  280. for (int r0 = 1; r0 != 0x47; r0++) {
  281. COMM_tInfo.info[r0] = 0;
  282. }
  283. }
  284. // 0x001d2438 COMM_StopCommentary 1 ^_^
  285. void COMM_StopCommentary() {
  286. SNDGAME_Commentary_Stop();
  287. }