aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorneonloop2021-04-03 00:38:20 +0000
committerneonloop2021-04-03 00:38:20 +0000
commite2303a4166ec3b78219115c18a0113e24fa48cf6 (patch)
tree5026ec21d6f5770122e23142e8abd4ba88cf6131 /source
parent7c6c5f3bb6f8084ed5ae6eaafe0db14c5afe49bc (diff)
downloadsnesemu-e2303a4166ec3b78219115c18a0113e24fa48cf6.tar.gz
snesemu-e2303a4166ec3b78219115c18a0113e24fa48cf6.tar.bz2
snesemu-e2303a4166ec3b78219115c18a0113e24fa48cf6.zip
Adds overscan scaler and fps display
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;