From e2303a4166ec3b78219115c18a0113e24fa48cf6 Mon Sep 17 00:00:00 2001 From: neonloop Date: Sat, 3 Apr 2021 00:38:20 +0000 Subject: Adds overscan scaler and fps display --- source/gfx.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'source/gfx.c') 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 @@ -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); + } +} -- cgit v1.2.3