aboutsummaryrefslogtreecommitdiff
path: root/source/gfx.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/gfx.c')
-rw-r--r--source/gfx.c52
1 files changed, 50 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);
+ }
+}