gocha

DeSmuME 0.9.8-gfx3dHack patch

Jan 13th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.52 KB | None | 0 0
  1. Index: desmume/src/gfx3d.cpp
  2. ===================================================================
  3. --- desmume/src/gfx3d.cpp   (revision 4477)
  4. +++ desmume/src/gfx3d.cpp   (working copy)
  5. @@ -2138,6 +2138,16 @@
  6.         std::sort(gfx3d.indexlist.list + opaqueCount, gfx3d.indexlist.list + polycount, gfx3d_ysort_compare);
  7.     }
  8.  
  9. +   // apply user visibility settings
  10. +   for(int i=0; i<polycount; i++)
  11. +   {
  12. +       POLY &poly = polylist->list[polycount-i-1];
  13. +       int polyRange = polycount; //POLYLIST_SIZE;
  14. +       int minPolyIndex = (int)((double)polyRange * gfx3d.visibilityRangeStart);
  15. +       int maxPolyIndex = (int)((double)polyRange * gfx3d.visibilityRangeEnd);
  16. +       poly.enabled = (i >= minPolyIndex) && (i <= maxPolyIndex);
  17. +   }
  18. +
  19.     //switch to the new lists
  20.     twiddleLists();
  21.  
  22. Index: desmume/src/gfx3d.h
  23. ===================================================================
  24. --- desmume/src/gfx3d.h (revision 4477)
  25. +++ desmume/src/gfx3d.h (working copy)
  26. @@ -141,6 +141,7 @@
  27.     u32 polyAttr, texParam, texPalette; //the hardware rendering params
  28.     u32 viewport;
  29.     float miny, maxy;
  30. +   bool enabled; // user settings
  31.  
  32.     void setVertIndexes(int a, int b, int c, int d=-1)
  33.     {
  34. @@ -366,6 +367,8 @@
  35.     GFX3D()
  36.         : polylist(0)
  37.         , vertlist(0)
  38. +       , visibilityRangeStart(0.0)
  39. +       , visibilityRangeEnd(1.0)
  40.         , frameCtr(0)
  41.         , frameCtrRaw(0) {
  42.     }
  43. @@ -380,6 +383,9 @@
  44.     VERTLIST* vertlist;
  45.     INDEXLIST indexlist;
  46.  
  47. +   double visibilityRangeStart;
  48. +   double visibilityRangeEnd;
  49. +
  50.     //ticks every time flush() is called
  51.     int frameCtr;
  52.  
  53. Index: desmume/src/lua-engine.cpp
  54. ===================================================================
  55. --- desmume/src/lua-engine.cpp  (revision 4477)
  56. +++ desmume/src/lua-engine.cpp  (working copy)
  57. @@ -29,6 +29,7 @@
  58.  #include "GPU_osd.h"
  59.  #include "saves.h"
  60.  #include "emufile.h"
  61. +#include "gfx3d.h"
  62.  #if defined(WIN32) && !defined(WXPORT)
  63.  #include <windows.h>
  64.  #include "main.h"
  65. @@ -4421,6 +4422,22 @@
  66.     return 0;
  67.  }
  68.  
  69. +// gui.setgfx3dvisibility(double bgStart, double bgEnd)
  70. +//
  71. +static int gui_setgfx3dvisibility(lua_State *L)
  72. +{
  73. +   double gfx3dStart = luaL_checknumber(L,1);
  74. +   double gfx3dEnd = luaL_checknumber(L,2);
  75. +
  76. +   gfx3dStart = std::min(std::max(gfx3dStart, 0.0), 1.0);
  77. +   gfx3dEnd = std::min(std::max(gfx3dEnd, 0.0), 1.0);
  78. +
  79. +   gfx3d.visibilityRangeStart = gfx3dStart;
  80. +   gfx3d.visibilityRangeEnd = gfx3dEnd;
  81. +
  82. +   return 0;
  83. +}
  84. +
  85.  DEFINE_LUA_FUNCTION(stylus_read, "")
  86.  {
  87.    
  88. @@ -4559,6 +4576,7 @@
  89.     {"gdoverlay", gui_gdoverlay},
  90.     {"redraw", emu_redraw}, // some people might think of this as more of a GUI function
  91.     {"osdtext", gui_osdtext},
  92. +   {"setgfx3dvisibility", gui_setgfx3dvisibility},
  93.     // alternative names
  94.     {"drawtext", gui_text},
  95.     {"drawbox", gui_box},
  96. Index: desmume/src/OGLRender.cpp
  97. ===================================================================
  98. --- desmume/src/OGLRender.cpp   (revision 4477)
  99. +++ desmume/src/OGLRender.cpp   (working copy)
  100. @@ -1078,6 +1078,9 @@
  101.             POLY *poly = &gfx3d.polylist->list[gfx3d.indexlist.list[i]];
  102.             int type = poly->type;
  103.  
  104. +           if (!poly->enabled)
  105. +               continue;
  106. +
  107.             //a very macro-level state caching approach:
  108.             //these are the only things which control the GPU rendering state.
  109.             if(i==0 || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette || lastPolyAttr != poly->polyAttr)
  110. Index: desmume/src/rasterize.cpp
  111. ===================================================================
  112. --- desmume/src/rasterize.cpp   (revision 4477)
  113. +++ desmume/src/rasterize.cpp   (working copy)
  114. @@ -1060,7 +1060,8 @@
  115.  
  116.             polyAttr.backfacing = engine->polyBackfacing[i];
  117.  
  118. -           shape_engine<SLI>(type,!polyAttr.backfacing, (poly->vtxFormat & 4) && CommonSettings.GFX3D_LineHack);
  119. +           if(poly->enabled)
  120. +               shape_engine<SLI>(type,!polyAttr.backfacing, (poly->vtxFormat & 4) && CommonSettings.GFX3D_LineHack);
  121.         }
  122.     }
  123.  
  124. Index: desmume/src/version.cpp
  125. ===================================================================
  126. --- desmume/src/version.cpp (revision 4477)
  127. +++ desmume/src/version.cpp (working copy)
  128. @@ -82,7 +82,7 @@
  129.  #endif
  130.  
  131.  #define DESMUME_VERSION_NUMERIC 90800
  132. -#define DESMUME_VERSION_STRING " " "0.9.8" DESMUME_SUBVERSION_STRING DESMUME_FEATURE_STRING DESMUME_PLATFORM_STRING DESMUME_CPUEXT_STRING DESMUME_COMPILER
  133. +#define DESMUME_VERSION_STRING " " "0.9.8-gfx3dHack" DESMUME_SUBVERSION_STRING DESMUME_FEATURE_STRING DESMUME_PLATFORM_STRING DESMUME_CPUEXT_STRING DESMUME_COMPILER
  134.  #define DESMUME_NAME_AND_VERSION DESMUME_NAME DESMUME_VERSION_STRING
  135.  
  136.  u32 EMU_DESMUME_VERSION_NUMERIC() { return DESMUME_VERSION_NUMERIC; }
Add Comment
Please, Sign In to add comment