aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/gfx.c52
-rw-r--r--source/gfx.h1
-rw-r--r--source/ppu.c2
-rw-r--r--source/ppu.h2
4 files changed, 55 insertions, 2 deletions
diff --git a/source/gfx.c b/source/gfx.c
index 0cf0ac8..a17f80c 100644
--- a/source/gfx.c
+++ b/source/gfx.c
@@ -9,6 +9,7 @@
#include "gfx.h"
#include "apu.h"
#include "cheats.h"
+#include "config.h"
#include <retro_inline.h>
@@ -344,6 +345,7 @@ void S9xStartScreenRefresh(void)
GFX.ZPitch = GFX.RealPitch;
GFX.ZPitch >>= 1;
}
+ IPPU.RenderedFramesCount++;
}
PPU.RecomputeClipWindows = true;
@@ -351,8 +353,11 @@ void S9xStartScreenRefresh(void)
GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;
}
- if (++IPPU.FrameCount % Memory.ROMFramesPerSecond == 0)
- IPPU.FrameCount = 0;
+ if (++IPPU.FrameCount % Memory.ROMFramesPerSecond == 0) {
+ IPPU.DisplayedRenderedFrameCount = IPPU.RenderedFramesCount;
+ IPPU.RenderedFramesCount = 0;
+ IPPU.FrameCount = 0;
+ }
}
void RenderLine(uint8_t C)
@@ -415,6 +420,8 @@ void S9xEndScreenRefresh(void)
GFX.Pitch = GFX.Pitch2 = GFX.RealPitch;
GFX.PPL = GFX.PPLx2 >> 1;
+
+ if (option.showfps == 1) S9xDisplayFrameRate();
}
#ifdef LAGFIX
finishedFrame = true;
@@ -3207,3 +3214,44 @@ void S9xUpdateScreen(void)
#endif
IPPU.PreviousLine = IPPU.CurrentLine;
}
+
+#include "font.h"
+
+void DisplayChar(uint8_t* Screen, uint8_t c)
+{
+ int line = (((c & 0x7f) - 32) >> 4) * font_height;
+ int offset = (((c & 0x7f) - 32) & 15) * font_width;
+ int h, w;
+ uint16_t* s = (uint16_t*) Screen;
+ for (h = 0; h < font_height; h++, line++,
+ s += IPPU.RenderedScreenWidth - font_width)
+ {
+ for (w = 0; w < font_width; w++, s++)
+ {
+ uint8_t p = font [line][offset + w];
+
+ if (p == '#')
+ *s = 0xffff;
+ else if (p == '.')
+ *s = BLACK;
+ }
+ }
+}
+
+void S9xDisplayFrameRate()
+{
+ char string[16];
+ uint8_t *Screen = GFX.Screen;
+#ifdef TRIMUI
+ if (option.fullscreen == 4) { // for Overscan
+ Screen += IPPU.RenderedScreenWidth * 16 +16;
+ if (IPPU.RenderedScreenHeight == SNES_HEIGHT_EXTENDED) Screen += IPPU.RenderedScreenWidth * 16;
+ }
+#endif
+ sprintf(string, "%02d/%02d", IPPU.DisplayedRenderedFrameCount, (int)Memory.ROMFramesPerSecond);
+
+ for (int i = 0; i < 5; i++) {
+ DisplayChar(Screen, string[i]);
+ Screen += (font_width - 1) * sizeof(uint16_t);
+ }
+}
diff --git a/source/gfx.h b/source/gfx.h
index fc4806b..f6fc3ee 100644
--- a/source/gfx.h
+++ b/source/gfx.h
@@ -16,6 +16,7 @@ void S9xSetupOBJ(void);
void S9xUpdateScreen(void);
void RenderLine(uint8_t line);
void S9xBuildDirectColourMaps(void);
+void S9xDisplayFrameRate(void);
bool S9xInitGFX(void);
void S9xDeinitGFX(void);
diff --git a/source/ppu.c b/source/ppu.c
index 1f5df0b..5db22be 100644
--- a/source/ppu.c
+++ b/source/ppu.c
@@ -1758,6 +1758,8 @@ static void CommonPPUReset()
IPPU.RenderThisFrame = true;
IPPU.DirectColourMapsNeedRebuild = true;
IPPU.FrameCount = 0;
+ IPPU.RenderedFramesCount = 0;
+ IPPU.DisplayedRenderedFrameCount = 0;
memset(IPPU.TileCached [TILE_2BIT], 0, MAX_2BIT_TILES);
memset(IPPU.TileCached [TILE_4BIT], 0, MAX_4BIT_TILES);
memset(IPPU.TileCached [TILE_8BIT], 0, MAX_8BIT_TILES);
diff --git a/source/ppu.h b/source/ppu.h
index 447f7f1..934df06 100644
--- a/source/ppu.h
+++ b/source/ppu.h
@@ -40,6 +40,8 @@ typedef struct
bool RenderThisFrame;
bool DirectColourMapsNeedRebuild;
uint32_t FrameCount;
+ uint32_t RenderedFramesCount;
+ uint32_t DisplayedRenderedFrameCount;
uint8_t* TileCache [3];
uint8_t* TileCached [3];
bool FirstVRAMRead;