Guest User

Untitled

a guest
Jun 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1. Index: Core/Common/Src/PluginVideo.cpp
  2. ===================================================================
  3. --- Core/Common/Src/PluginVideo.cpp (revision 3626)
  4. +++ Core/Common/Src/PluginVideo.cpp (working copy)
  5. @@ -29,6 +29,7 @@
  6. Video_ExitLoop = 0;
  7. Video_Screenshot = 0;
  8. Video_AddMessage = 0;
  9. + Video_AccessEFB = 0;
  10.  
  11. Video_Prepare = reinterpret_cast<TVideo_Prepare>
  12. (LoadSymbol("Video_Prepare"));
  13. @@ -44,6 +45,8 @@
  14. (LoadSymbol("Video_ExitLoop"));
  15. Video_AddMessage = reinterpret_cast<TVideo_AddMessage>
  16. (LoadSymbol("Video_AddMessage"));
  17. + Video_AccessEFB = reinterpret_cast<TVideo_AccessEFB>
  18. + (LoadSymbol("Video_AccessEFB"));
  19.  
  20. if ((Video_Prepare != 0) &&
  21. (Video_SendFifoData != 0) &&
  22. @@ -51,7 +54,8 @@
  23. (Video_EnterLoop != 0) &&
  24. (Video_ExitLoop != 0) &&
  25. (Video_Screenshot != 0) &&
  26. - (Video_AddMessage != 0))
  27. + (Video_AddMessage != 0) &&
  28. + (Video_AccessEFB != 0))
  29. validVideo = true;
  30. }
  31.  
  32. Index: Core/Common/Src/PluginVideo.h
  33. ===================================================================
  34. --- Core/Common/Src/PluginVideo.h (revision 3626)
  35. +++ Core/Common/Src/PluginVideo.h (working copy)
  36. @@ -30,6 +30,7 @@
  37. typedef void (__cdecl* TVideo_EnterLoop)();
  38. typedef void (__cdecl* TVideo_ExitLoop)();
  39. typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
  40. +typedef u32 (__cdecl* TVideo_AccessEFB)(EFBAccessType, u32, u32);
  41.  
  42. class PluginVideo : public CPlugin
  43. {
  44. @@ -43,6 +44,7 @@
  45. TVideo_EnterLoop Video_EnterLoop;
  46. TVideo_ExitLoop Video_ExitLoop;
  47. TVideo_UpdateXFB Video_UpdateXFB;
  48. + TVideo_AccessEFB Video_AccessEFB;
  49.  
  50. TVideo_AddMessage Video_AddMessage;
  51. TVideo_Screenshot Video_Screenshot;
  52. Index: Core/Core/Src/HW/MemmapFunctions.cpp
  53. ===================================================================
  54. --- Core/Core/Src/HW/MemmapFunctions.cpp (revision 3626)
  55. +++ Core/Core/Src/HW/MemmapFunctions.cpp (working copy)
  56. @@ -21,6 +21,7 @@
  57. #include "WII_IOB.h"
  58. #include "../Core.h"
  59. #include "../PowerPC/PowerPC.h"
  60. +#include "../PluginManager.h"
  61.  
  62. namespace Memory
  63. {
  64. @@ -35,8 +36,8 @@
  65. 80322df8: or r0, r3, r0 a |= x;
  66. 80322dfc: rlwinm r0, r0, 0, 10, 7 (ff3fffff) a &= 0xff3fffff
  67. 80322e00: oris r3, r0, 0x0040 x = a | 0x00400000
  68. -80322e04: lwz r0, 0 (r3)
  69. -80322e08: stw r0, 0 (r5)
  70. +80322e04: lwz r0, 0 (r3) r0 = *r3
  71. +80322e08: stw r0, 0 (r5) z =
  72. 80322e0c: blr
  73. */
  74.  
  75. @@ -125,15 +126,14 @@
  76. {
  77. if (em_address < 0xcc000000)
  78. {
  79. - // TODO: glReadPixels :p
  80. - _var = 0;
  81. -
  82. int x = (em_address & 0xfff) >> 2;
  83. int y = (em_address >> 12) & 0x3ff;
  84. if (em_address & 0x00400000) {
  85. - DEBUG_LOG(MEMMAP, "EFB Z Read @ %i, %i", x, y);
  86. + _var = CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(EFBAccessType::PEEK_Z, x, y);
  87. + DEBUG_LOG(MEMMAP, "EFB Z Read @ %i, %i\t= %i", x, y, _var);
  88. } else {
  89. - DEBUG_LOG(MEMMAP, "EFB Color Read @ %i, %i", x, y);
  90. + _var = CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(EFBAccessType::PEEK_COLOR, x, y);
  91. + DEBUG_LOG(MEMMAP, "EFB Color Read @ %i, %i\t= %i", x, y, _var);
  92. }
  93. }
  94. else if (em_address <= 0xcc009000)
  95. @@ -203,8 +203,10 @@
  96. int x = (em_address & 0xfff) >> 2;
  97. int y = (em_address >> 12) & 0x3ff;
  98. if (em_address & 0x00400000) {
  99. + CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(EFBAccessType::POKE_Z, x, y);
  100. DEBUG_LOG(MEMMAP, "EFB Z Write %08x @ %i, %i", data, x, y);
  101. } else {
  102. + CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(EFBAccessType::POKE_COLOR, x, y);
  103. DEBUG_LOG(MEMMAP, "EFB Color Write %08x @ %i, %i", data, x, y);
  104. }
  105. return;
  106. Index: Plugins/Plugin_VideoOGL/Src/main.cpp
  107. ===================================================================
  108. --- Plugins/Plugin_VideoOGL/Src/main.cpp (revision 3626)
  109. +++ Plugins/Plugin_VideoOGL/Src/main.cpp (working copy)
  110. @@ -458,3 +458,35 @@
  111. }
  112. }
  113.  
  114. +u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
  115. +{
  116. + switch (type)
  117. + {
  118. + case EFBAccessType::PEEK_Z:
  119. + {
  120. + u32 z = 0;
  121. + TRectangle source, scaledTargetSource;
  122. + ComputeBackbufferRectangle(&source);
  123. + source.Scale(Renderer::GetTargetScaleX(), Renderer::GetTargetScaleY(), &scaledTargetSource);
  124. + GLuint depth_tex = Renderer::ResolveAndGetDepthTarget(scaledTargetSource);
  125. + glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, &z);
  126. + GL_REPORT_ERRORD();
  127. + return z;
  128. + }
  129. + break;
  130. +
  131. + case EFBAccessType::POKE_Z:
  132. + break;
  133. +
  134. + case EFBAccessType::PEEK_COLOR:
  135. + break;
  136. +
  137. + case EFBAccessType::POKE_COLOR:
  138. + break;
  139. +
  140. + default:
  141. + break;
  142. + }
  143. + return 0;
  144. +}
  145. +
  146. Index: PluginSpecs/pluginspecs_video.h
  147. ===================================================================
  148. --- PluginSpecs/pluginspecs_video.h (revision 3626)
  149. +++ PluginSpecs/pluginspecs_video.h (working copy)
  150. @@ -23,6 +23,14 @@
  151. typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title
  152. typedef void (*TKeyPressed)(int keycode, bool shift, bool control); // sets the window title
  153.  
  154. +enum EFBAccessType
  155. +{
  156. + PEEK_Z = 0,
  157. + POKE_Z,
  158. + PEEK_COLOR,
  159. + POKE_COLOR
  160. +};
  161. +
  162. typedef struct
  163. {
  164. // fifo registers
  165. @@ -113,6 +121,13 @@
  166. EXPORT void CALL Video_UpdateXFB(u32 _dwXFBAddr, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset, bool scheduling);
  167.  
  168. // __________________________________________________________________________________________________
  169. +// Function: Video_AccessEFB
  170. +// input: type of access (r/w, z/color, ...), x coord, y coord
  171. +// output: response to the access request (ex: peek z data at specified coord)
  172. +//
  173. +EXPORT u32 CALL Video_AccessEFB(EFBAccessType type, u32 x, u32 y);
  174. +
  175. +// __________________________________________________________________________________________________
  176. // Function: Video_Screenshot
  177. // input: Filename
  178. // output: TRUE if all was okay
Add Comment
Please, Sign In to add comment