FTT2D.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. #include "FTT2D.h"
  2. #include "CFTTUberShader.h"
  3. #include "CFTTTexture.h"
  4. #include "CBlitter.h"
  5. #include "CFTTTime.h"
  6. #include "CFTT2d_Shader.h"
  7. #include "CFTTMaterialManager.h"
  8. #include "CFTTShaderBuiltInConstants.h"
  9. #include "CFTTCamera.h"
  10. #include "CFTTGraphicsDevice.h"
  11. #include "CFTTTextureManager.h"
  12. #include "CFTTGraphicsBufferOGLES.h"
  13. #include "CFTTTextureCache.h"
  14. #include "memctrl.h"
  15. //fixc
  16. float FTT2D_CurrentTextureUV[4]; //005AA788
  17. CFTTTexture *FTT2D_pCurrentTexture; //005AA798
  18. CBlitter *FTT2D_pBlitter; //005AA79C
  19. CFTTTexture *FTT2D_pDrawCallTexture; //005AA7A0
  20. int FTT2D_iOpenScenes; //005AA7A4
  21. MYSTATIC int dword_348A9C = 65532;
  22. MYSTATIC int dword_348AA0 = 98298;
  23. MYSTATIC int linecount_348AA4 = 1024;
  24. MYSTATIC int dMatID_348AA8 = -1;
  25. //-------------------------------------------------------------------------------------------------
  26. //ScaleAlpha(argb5, fs26);
  27. //0020CEB4 //^_^
  28. void ScaleAlpha(uint &argb, float f2) {
  29. uchar *p = reinterpret_cast<uchar *>(&argb);
  30. uchar cr2 = p[3];
  31. float fs0 = ((float)cr2) * f2;
  32. int dr1 = (uint)fs0;
  33. if (dr1 >= 0xFF) {
  34. dr1 = 0xFF;
  35. }
  36. p[3] = dr1 & (~(dr1 >> 31));
  37. }
  38. //-------------------------------------------------------------------------------------------------
  39. //0020C8D8
  40. void FTT2D_SetupBufSizes(int a1, int a2, int dLineCount) {
  41. LOGI("FTT2D_SetupBufSizes: %d %d %d", a1, a2, dLineCount);
  42. }
  43. //-------------------------------------------------------------------------------------------------
  44. //0020C8E4 //^_^
  45. void FTT2D_Init() {
  46. LOGI("FTT2D_Init: Entry");
  47. LOGI("FTT2D_Init: End CFTT2d_Shader::s_tInstance = %d", dMatID_348AA8);
  48. }
  49. //-------------------------------------------------------------------------------------------------
  50. //0020C924
  51. void FTT2D_Shutdown() {
  52. }
  53. //-------------------------------------------------------------------------------------------------
  54. //0020C96C //^_^ 经过单元测试,功能正常
  55. void FTT2D_Begin() {
  56. LOGI("FTT2D_Begin Entry %d", FTT2D_iOpenScenes);
  57. LOGI("FTT2D_Begin End");
  58. }
  59. //-------------------------------------------------------------------------------------------------
  60. //0020C9E4 //^_^
  61. void FTT2D_ClearTexture() {
  62. }
  63. //-------------------------------------------------------------------------------------------------
  64. //0020CA28 //^_^
  65. void FTT2D_SetMaterial(int a1) {
  66. LOGI("FTT2D_SetMaterial entry");
  67. }
  68. //-------------------------------------------------------------------------------------------------
  69. //0020CA4C //^_^
  70. void FTT2D_SetDefaultMatBlend(EFTT2D_Blend eBland) {
  71. LOGE("%x",eBland);
  72. }
  73. //-------------------------------------------------------------------------------------------------
  74. //0020CA68 //^_^ 经过单元测试,功能正常
  75. void FTT2D_End() {
  76. LOGI("FTT2D_End: Entry FTT2D_iOpenScenes = %d", FTT2D_iOpenScenes);
  77. LOGI("FTT2D_End: End");
  78. }
  79. //-------------------------------------------------------------------------------------------------
  80. //0020CA8C //^_^
  81. void FTT2D_ForceFlush() {
  82. }
  83. //-------------------------------------------------------------------------------------------------
  84. //0020CAA8 //^_^
  85. __attribute__((noinline)) void FTT2D_OnFrameEnd() {
  86. //empty
  87. }
  88. //-------------------------------------------------------------------------------------------------
  89. //0020CABC //^_^
  90. int FTT2D_GetMaterial() {
  91. int dret = FTT2D_pBlitter->material_4.dMatID_0;
  92. if (dret == dMatID_348AA8)
  93. dret = -1;
  94. return dret;
  95. }
  96. //-------------------------------------------------------------------------------------------------
  97. //0020CAE0 //^_^ 经过单元测试,功能正常
  98. void FTT2D_SetTexture(CFTTTexture *pTexture, ushort a2) {
  99. LOGI("FTT2D_SetTexture 0020CAE0 Entry %p%x", pTexture,a2);
  100. LOGI("FTT2D_SetTexture End");
  101. }
  102. //-------------------------------------------------------------------------------------------------
  103. //0020CB58 -_- 经过单元测试,功能正常
  104. void FTT2D_SetTextureUV(CFTT2D_TextureUV *pTextureUV, ushort a2) {
  105. LOGI("FTT2D_SetTextureUV entry");
  106. LOGE("%x",pTextureUV);
  107. LOGE("%x",a2);
  108. LOGI("FTT2D_SetTextureUV end");
  109. }
  110. //-------------------------------------------------------------------------------------------------
  111. //0020CC30 ^_- 经过单元测试,功能正常
  112. void FTT2D_SetTexture(CFTTTexture *pTexture, CFTT2D_TextureUV *pTextureUV, ushort a3) {
  113. LOGI("FTT2D_SetTexture 0020CC30 entry");
  114. }
  115. //-------------------------------------------------------------------------------------------------
  116. //0020CC78 ///^_^
  117. __attribute__((noinline))
  118. CFTTTexture *
  119. FTT2D_GetCurrentTexture() {
  120. return FTT2D_pCurrentTexture;
  121. }
  122. //-------------------------------------------------------------------------------------------------
  123. //0020CC88 ^_- 经过单元测试,功能正常
  124. void FTT2D_SetTexture(CFTTTextureAtlas *pTextureAtlas, ushort a2, ushort a3) {
  125. LOGI("FTT2D_SetTexture 0020CC88 entry");
  126. LOGI("FTT2D_SetTexture 0020CC88 end");
  127. }
  128. //-------------------------------------------------------------------------------------------------
  129. //0020CCE8 ^_- 经过单元测试,功能正常
  130. void FTT2D_SetTexture(CFTTTextureAtlas *pTextureAtlas, ushort a2, CFTT2D_TextureUV *pTextureUV, ushort a4) {
  131. LOGI("FTT2D_SetTexture 0020CCE8 entry");
  132. }
  133. //-------------------------------------------------------------------------------------------------
  134. //0020CDA8
  135. void FTT2D_UpdateTextureUVs(CFTT2D_TexturedVert *pTexturedVert, int dCount) {
  136. }
  137. //-------------------------------------------------------------------------------------------------
  138. //0020CDF4
  139. void FTT2D_EnableScissorTesting(int a1, int a2, int a3, int a4) {
  140. }
  141. //-------------------------------------------------------------------------------------------------
  142. //0020CE14
  143. void FTT2D_DisableScissorTesting() {
  144. }
  145. //-------------------------------------------------------------------------------------------------
  146. //0020CE3C
  147. void FTT2D_FlipY(bool b) {
  148. }
  149. //-------------------------------------------------------------------------------------------------
  150. //0020CE50
  151. void FTT2D_FlipX(bool b) {
  152. }
  153. //-------------------------------------------------------------------------------------------------
  154. //0020CEDC //^_^ 经过单元测试,功能正常
  155. void FTT2D_OnMaterialModified(CFTTUberShader *pUberShader, int dIndex) {
  156. LOGI("FTT2D_OnMaterialModified Entry FTT2D_iOpenScenes = %d", FTT2D_iOpenScenes);
  157. //locret_20CEF8
  158. LOGI("FTT2D_OnMaterialModified End");
  159. }
  160. //-------------------------------------------------------------------------------------------------
  161. //0020CF04 //^_^
  162. CFTTTexture *FTT2D_GetCurrentDrawCallTexture() {
  163. return nullptr;
  164. }
  165. //-------------------------------------------------------------------------------------------------
  166. //0020CF14
  167. void FTT2D_OnTextureDeletion(CFTTTexture *pTexture) {
  168. }
  169. //-------------------------------------------------------------------------------------------------
  170. //0020D6AC //^_^ 经过单元测试,功能正常
  171. void FTT2D_GenerateRectUVs(CFTT2D_TexturedVert *list_vert) {
  172. }
  173. //-------------------------------------------------------------------------------------------------
  174. //0020D740
  175. CFTT2D_TexturedVert *FTT2D_DrawLine(float f1, float f2, float f3, float f4) {
  176. return nullptr;
  177. }
  178. //-------------------------------------------------------------------------------------------------
  179. //0020D78C <CFTT2D_TexturedVert>
  180. CFTT2D_TexturedVert *FTT2D_PrepareDrawLine() {
  181. return nullptr;
  182. }
  183. //-------------------------------------------------------------------------------------------------
  184. //0020D7B4
  185. CFTT2D_TexturedVert *FTT2D_DrawLineCol(float f1, float f2, float f3, float f4, uint a5) {
  186. return nullptr;
  187. }
  188. //-------------------------------------------------------------------------------------------------
  189. //0020D818
  190. CFTT2D_TexturedVert *FTT2D_DrawLineCol2(float f1, float f2, float f3, float f4, uint a5, uint a6) {
  191. return nullptr;
  192. }
  193. //-------------------------------------------------------------------------------------------------
  194. //0020D88C
  195. CFTT2D_TexturedVert *FTT2D_DrawLineP2P(float f1, float f2, float f3, float f4) {
  196. return nullptr;
  197. }
  198. //-------------------------------------------------------------------------------------------------
  199. //0020D8B0
  200. CFTT2D_TexturedVert *FTT2D_DrawLineP2PCol(float f1, float f2, float f3, float f4, uint a5) {
  201. return nullptr;
  202. }
  203. //-------------------------------------------------------------------------------------------------
  204. //0020D8D4
  205. CFTT2D_TexturedVert *FTT2D_DrawLineP2PCol2(float f1, float f2, float f3, float f4,
  206. uint a5, uint a6) {
  207. return nullptr;
  208. }
  209. //-------------------------------------------------------------------------------------------------
  210. //0020D8F8
  211. void FTT2D_DrawTriangle(float f1, float f2, float f3, float f4, float f5, float f6,
  212. bool b7, uint a8) {
  213. }
  214. //-------------------------------------------------------------------------------------------------
  215. //0020D920
  216. void FTT2D_DrawTriangle3(float v1_x, float v1_y,
  217. float v2_x, float v2_y,
  218. float v3_x, float v3_y,
  219. bool b7,
  220. uint v1_argb, uint v2_argb, uint v3_argb) {
  221. //locret_20D9D8
  222. }
  223. //-------------------------------------------------------------------------------------------------
  224. //0020D9E0 CFTT2D_TexturedVert
  225. CFTT2D_TexturedVert *FTT2D_PrepareDrawTriangle(bool b) {
  226. CFTT2D_TexturedVert *pvert;
  227. return pvert;
  228. }
  229. //-------------------------------------------------------------------------------------------------
  230. //0020DA1C
  231. void FTT2D_DrawCircle(float f1, float f2, float f3, ushort a4, bool b5, uint argb6) {
  232. }
  233. //-------------------------------------------------------------------------------------------------
  234. //0020DB20
  235. int FTT2D_DrawUnfilledRect(float f1, float f2, float f3, float f4,
  236. uint argb5,
  237. float f6, float f7, float f8) {
  238. //??? 0020DB3E 此处开始的汇编有问题,应该会crash,可能这个函数调用不到
  239. return 0;
  240. }
  241. //-------------------------------------------------------------------------------------------------
  242. //0020DC20 经过单元测试,功能正常
  243. template <typename T>
  244. void FTT2D_GenerateRect(T *pTmp,
  245. float f1, float f2, float f3, float f4,
  246. uint argb5, uint argb6, uint argb7, uint argb8,
  247. float f9, float f10, float f11) {
  248. }
  249. //-------------------------------------------------------------------------------------------------
  250. //0020DD20
  251. void FTT2D_DrawUnfilledRect4(float f1, float f2, float f3, float f4,
  252. uint argb5, uint argb6, uint argb7, uint argb8,
  253. float f9, float f10, float f11) {
  254. }
  255. //-------------------------------------------------------------------------------------------------
  256. //0020DE3C //^_^
  257. void FTT2D_DrawRect(float f1, float f2, float f3, float f4,
  258. uint argb5,
  259. float f6, float f7, float f8) {
  260. LOGI("FTT2D_DrawRect 0020DE3C entry %.4f %.4f %.4f %.4f %x %.4f %.4f %.4f", f1, f2, f3, f4, argb5, f6, f7, f8);
  261. }
  262. //-------------------------------------------------------------------------------------------------
  263. //0020DEAC //^_^ 经过单元测试,功能正常
  264. template <typename T>
  265. T *FTT2D_PrepareDrawFilledRect() {
  266. return nullptr;
  267. }
  268. //-------------------------------------------------------------------------------------------------
  269. //0020DED4
  270. void FTT2D_DrawRect4(float f1, float f2, float f3, float f4,
  271. uint argb5, uint argb6, uint argb7, uint argb8,
  272. float f9, float f10, float f11) {
  273. LOGE("%x%x%x%x%x%x%x%x%x%x%x",f1,f2,f3,f4,argb5,argb6,argb7,argb8,f9,f10,f11);
  274. }
  275. //-------------------------------------------------------------------------------------------------
  276. //0020DF68 -_- 经过单元测试,功能正常
  277. void FTT2D_DrawTexturedRect(float f1, float f2, float f3, float f4,
  278. uint argb5,
  279. float f6, float f7, float f8) {
  280. LOGI("FTT2D_DrawTexturedRect: Entry %.2f, %.2f, %.2f, %.2f", f1, f2, f3, f4);
  281. LOGE("%x%x%x%x%x%x%x%x",f1,f2,f3,f4,argb5,f6,f7,f8);
  282. LOGI("FTT2D_DrawTexturedRect: End");
  283. }
  284. //-------------------------------------------------------------------------------------------------
  285. //0020E028 CFTT2D_TexturedVert //^_^
  286. template <typename T>
  287. T *FTT2D_PrepareDrawTexturedRect() {
  288. return nullptr;
  289. }
  290. //-------------------------------------------------------------------------------------------------
  291. //0020E058
  292. void FTT2D_DrawTexturedRect4(float f1, float f2, float f3, float f4,
  293. uint argb5, uint argb6, uint argb7, uint argb8,
  294. float f9, float f10, float f11) {
  295. //loc_20E158
  296. }
  297. //-------------------------------------------------------------------------------------------------
  298. //0020E174
  299. void FTT2D_DrawTexturedRect5(float f1, float f2, float f3, float f4,
  300. uint a5, uint a6, uint a7, uint a8, uint a9,
  301. float f10, float f11, float f12) {
  302. FTT2D_DrawTexturedRect4(f1, f2, f3, f4, a5, a6, a7, a8, f10, f11, f12);
  303. }
  304. //-------------------------------------------------------------------------------------------------
  305. //0020E1A8
  306. void FTT2D_DrawTexturedVertList(CFTT2D_TexturedVert *pTexturedVert, int a2) {
  307. LOGE("FTT2D_DrawTexturedVertList%p%x",pTexturedVert,a2);
  308. }
  309. //-------------------------------------------------------------------------------------------------
  310. //0020E1E0
  311. void FTT2D_DrawTexturedVertStrip(CFTT2D_TexturedVert *pTexturedVert, int dCount) {
  312. }
  313. //-------------------------------------------------------------------------------------------------
  314. //00202860 经过单元测试,功能正常
  315. void FTTPresentScene(bool b) {
  316. //locret_202870
  317. }
  318. //-------------------------------------------------------------------------------------------------