Advertisement
Guest User

add lag counter & global frame counter display

a guest
Jan 30th, 2011
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.48 KB | None | 0 0
  1. From 0775c3016d62c0a479400d0fffc8dff1692d9dcd Mon Sep 17 00:00:00 2001
  2. From: gocha <gochaism@gmail.com>
  3. Date: Sun, 30 Jan 2011 19:47:45 +0900
  4. Subject: [PATCH] - added lag counter and Settings.DisplayLagCounter (TODO: add GUI item for it).
  5.  - changed the position of input display text to avoid overlapping frame counter.
  6.  - Settings.DisplayMovieFrame now becomes Settings.DisplayFrameCounter, and displays IPPU.TotalEmulatedFrames when movie is not active.
  7.  - Made those frame counters a little more deterministic. (i.e. reset the values on SNES reset)
  8.  
  9. TODO: add IPPU.TotalEmulatedFrames and IPPU.TotalLagFrames to snapshot, as well as pad_read.
  10. ---
  11. controls.cpp      |    5 +++++
  12.  gfx.cpp           |    4 ++--
  13.  memmap.cpp        |    2 --
  14.  movie.cpp         |   17 +++++++++++++++--
  15.  ppu.cpp           |   17 +++++++++++++----
  16.  ppu.h             |    1 +
  17.  snes9x.cpp        |    3 ++-
  18.  snes9x.h          |    3 ++-
  19.  win32/wconfig.cpp |    3 ++-
  20.  9 files changed, 42 insertions(+), 13 deletions(-)
  21.  
  22. diff --git a/controls.cpp b/controls.cpp
  23. index 5985781..d0ec914 100644
  24. --- a/controls.cpp
  25. +++ b/controls.cpp
  26. @@ -3319,6 +3319,11 @@ void S9xControlEOF (void)
  27.  
  28.     S9xMovieUpdate();
  29.  
  30. +   if (!pad_read)
  31. +   {
  32. +       IPPU.TotalLagFrames++;
  33. +   }
  34. +
  35.     pad_read_last = pad_read;
  36.     pad_read      = false;
  37.  }
  38. diff --git a/gfx.cpp b/gfx.cpp
  39. index f7bb546..9397b89 100644
  40. --- a/gfx.cpp
  41. +++ b/gfx.cpp
  42. @@ -2044,7 +2044,7 @@ static void DisplayPressedKeys (void)
  43.     static int  KeyOrder[] = { 8, 10, 7, 9, 0, 6, 14, 13, 5, 1, 4, 3, 2, 11, 12 }; // < ^ > v   A B Y X  L R  S s
  44.  
  45.     enum controllers    controller;
  46. -   int                 line = 1;
  47. +   int                 line = 2;
  48.     int8                ids[4];
  49.     char                string[255];
  50.  
  51. @@ -2194,7 +2194,7 @@ void S9xDisplayMessages (uint16 *screen, int ppl, int width, int height, int sca
  52.     if (Settings.DisplayPressedKeys)
  53.         DisplayPressedKeys();
  54.  
  55. -   if (Settings.DisplayMovieFrame && S9xMovieActive())
  56. +   if (Settings.DisplayFrameCounter)
  57.         S9xDisplayString(GFX.FrameDisplayString, 1, 1, false);
  58.  
  59.     if (GFX.InfoString && *GFX.InfoString)
  60. diff --git a/memmap.cpp b/memmap.cpp
  61. index 4844e52..8c5c042 100644
  62. --- a/memmap.cpp
  63. +++ b/memmap.cpp
  64. @@ -2597,8 +2597,6 @@ void CMemory::InitROM (void)
  65.     Timings.NMIDMADelay  = 24;
  66.     Timings.IRQPendCount = 0;
  67.  
  68. -   IPPU.TotalEmulatedFrames = 0;
  69. -
  70.     //// Hack games
  71.  
  72.     ApplyROMFixes();
  73. diff --git a/movie.cpp b/movie.cpp
  74. index f4b018b..779ab61 100644
  75. --- a/movie.cpp
  76. +++ b/movie.cpp
  77. @@ -1172,7 +1172,7 @@ void S9xMovieToggleRecState (void)
  78.  
  79.  void S9xMovieToggleFrameDisplay (void)
  80.  {
  81. -   Settings.DisplayMovieFrame = !Settings.DisplayMovieFrame;
  82. +   Settings.DisplayFrameCounter = !Settings.DisplayFrameCounter;
  83.     S9xReRefresh();
  84.  }
  85.  
  86. @@ -1182,7 +1182,7 @@ void S9xUpdateFrameCounter (int offset)
  87.  
  88.     offset++;
  89.  
  90. -   if (!Settings.DisplayMovieFrame)
  91. +   if (!Settings.DisplayFrameCounter)
  92.         *GFX.FrameDisplayString = 0;
  93.     else
  94.     if (Movie.State == MOVIE_STATE_RECORD)
  95. @@ -1198,4 +1198,17 @@ void S9xUpdateFrameCounter (int offset)
  96.         sprintf(GFX.FrameDisplayString, "%s frame: %d", Settings.NetPlayServer ? "Server" : "Client",
  97.             max(0, (int) (NetPlay.FrameCount + offset)));
  98.  #endif
  99. +   else
  100. +       sprintf(GFX.FrameDisplayString, "Playing frame: %d",
  101. +           max(0, (int) IPPU.TotalEmulatedFrames));
  102. +
  103. +   if (Settings.DisplayLagCounter)
  104. +   {
  105. +       char LagCounterString[24];
  106. +       sprintf(LagCounterString, "%d", IPPU.TotalLagFrames);
  107. +
  108. +       if (Settings.DisplayFrameCounter)
  109. +           strcat(GFX.FrameDisplayString, " | ");
  110. +       strcat(GFX.FrameDisplayString, LagCounterString);
  111. +   }
  112.  }
  113. diff --git a/ppu.cpp b/ppu.cpp
  114. index a9dc271..26c3926 100644
  115. --- a/ppu.cpp
  116. +++ b/ppu.cpp
  117. @@ -1671,14 +1671,14 @@ uint8 S9xGetCPU (uint16 Address)
  118.  {
  119.     if (Address < 0x4200)
  120.     {
  121. -   #ifdef SNES_JOY_READ_CALLBACKS
  122.         extern bool8 pad_read;
  123.         if (Address == 0x4016 || Address == 0x4017)
  124.         {
  125. +       #ifdef SNES_JOY_READ_CALLBACKS
  126.             S9xOnSNESPadRead();
  127. +       #endif
  128.             pad_read = TRUE;
  129.         }
  130. -   #endif
  131.  
  132.         switch (Address)
  133.         {
  134. @@ -1783,14 +1783,14 @@ uint8 S9xGetCPU (uint16 Address)
  135.             case 0x421d: // JOY3H
  136.             case 0x421e: // JOY4L
  137.             case 0x421f: // JOY4H
  138. -           #ifdef SNES_JOY_READ_CALLBACKS
  139.                 extern bool8 pad_read;
  140.                 if (Memory.FillRAM[0x4200] & 1)
  141.                 {
  142.                     S9xOnSNESPadRead();
  143. +               #ifdef SNES_JOY_READ_CALLBACKS
  144.                     pad_read = TRUE;
  145. +               #endif
  146.                 }
  147. -           #endif
  148.                 return (Memory.FillRAM[Address]);
  149.  
  150.             default:
  151. @@ -1977,6 +1977,15 @@ void S9xSoftResetPPU (void)
  152.     IPPU.SkippedFrames = 0;
  153.     IPPU.FrameSkip = 0;
  154.  
  155. +   if (!S9xMovieActive())
  156. +   {
  157. +       extern bool8 pad_read, pad_read_last;
  158. +       IPPU.TotalEmulatedFrames = 0;
  159. +       IPPU.TotalLagFrames = 0;
  160. +       pad_read = 0;
  161. +       pad_read_last = 0;
  162. +   }
  163. +
  164.     S9xFixColourBrightness();
  165.  
  166.     for (int c = 0; c < 0x8000; c += 0x100)
  167. diff --git a/ppu.h b/ppu.h
  168. index c5cb9d7..11d7fb1 100644
  169. --- a/ppu.h
  170. +++ b/ppu.h
  171. @@ -234,6 +234,7 @@ struct InternalPPU
  172.     uint32  RenderedFramesCount;
  173.     uint32  DisplayedRenderedFrameCount;
  174.     uint32  TotalEmulatedFrames;
  175. +   uint32  TotalLagFrames;
  176.     uint32  SkippedFrames;
  177.     uint32  FrameSkip;
  178.  };
  179. diff --git a/snes9x.cpp b/snes9x.cpp
  180. index a467614..4d470af 100644
  181. --- a/snes9x.cpp
  182. +++ b/snes9x.cpp
  183. @@ -414,7 +414,8 @@ void S9xLoadConfigFiles (char **argv, int argc)
  184.     Settings.DisplayFrameRate           =  conf.GetBool("Display::DisplayFrameRate",           false);
  185.     Settings.DisplayWatchedAddresses    =  conf.GetBool("Display::DisplayWatchedAddresses",    false);
  186.     Settings.DisplayPressedKeys         =  conf.GetBool("Display::DisplayInput",               false);
  187. -   Settings.DisplayMovieFrame          =  conf.GetBool("Display::DisplayFrameCount",          false);
  188. +   Settings.DisplayFrameCounter        =  conf.GetBool("Display::DisplayFrameCount",          false);
  189. +   Settings.DisplayLagCounter          =  conf.GetBool("Display::LagCounter",                 false);
  190.     Settings.AutoDisplayMessages        =  conf.GetBool("Display::MessagesInImage",            true);
  191.     Settings.InitialInfoStringTimeout   =  conf.GetInt ("Display::MessageDisplayTime",         120);
  192.  
  193. diff --git a/snes9x.h b/snes9x.h
  194. index ccab877..fd8c5c0 100644
  195. --- a/snes9x.h
  196. +++ b/snes9x.h
  197. @@ -387,7 +387,8 @@ struct SSettings
  198.     bool8   DisplayFrameRate;
  199.     bool8   DisplayWatchedAddresses;
  200.     bool8   DisplayPressedKeys;
  201. -   bool8   DisplayMovieFrame;
  202. +   bool8   DisplayFrameCounter;
  203. +   bool8   DisplayLagCounter;
  204.     bool8   AutoDisplayMessages;
  205.     uint32  InitialInfoStringTimeout;
  206.     uint16  DisplayColor;
  207. diff --git a/win32/wconfig.cpp b/win32/wconfig.cpp
  208. index 28242ee..95c3ab2 100644
  209. --- a/win32/wconfig.cpp
  210. +++ b/win32/wconfig.cpp
  211. @@ -857,7 +857,8 @@ void WinRegisterConfigItems()
  212.     AddBoolC("MessagesInImage", Settings.AutoDisplayMessages, false, "true to draw text inside the SNES image (will get into AVIs, screenshots, and filters)");
  213.     AddBool2C("FrameRate", Settings.DisplayFrameRate, false, "on to display the framerate (will be inaccurate if AutoMaxSkipFrames is too small)");
  214.     AddBoolC("DisplayInput", Settings.DisplayPressedKeys, false, "true to show which buttons are pressed");
  215. -   AddBoolC("DisplayFrameCount", Settings.DisplayMovieFrame, true, "true to show the frame count when a movie is playing");
  216. +   AddBoolC("DisplayFrameCount", Settings.DisplayFrameCounter, true, "true to show the frame count");
  217. +   AddBoolC("DisplayLagCounter", Settings.DisplayLagCounter, true, "true to show the \"ignored\" frame count which increments when input was not used by the SNES");
  218.  #undef CATEGORY
  219.  #define CATEGORY "Display\\Win"
  220.     AddUIntC("OutputMethod", GUI.outputMethod, 1, "0=DirectDraw, 1=Direct3D");
  221. --
  222. 1.7.3.1.msysgit.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement