summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2010-02-19 10:23:30 +0100
committerSegher Boessenkool <segher@kernel.crashing.org>2010-02-19 10:23:30 +0100
commit06591f8e49e37677fb041d0bdc956acb348c0c49 (patch)
tree5d096d52b08163945a9ed7e1b0e14bc6db8036f1
parent8b8b3e7489069fdef23c95d5bd4b507095a9113c (diff)
Add new debug key 'f': show framerate bar
-rw-r--r--emu.c4
-rw-r--r--platform-sdl.c1
-rw-r--r--video.c36
-rw-r--r--video.h2
4 files changed, 43 insertions, 0 deletions
diff --git a/emu.c b/emu.c
index 93ad382..cebf4c0 100644
--- a/emu.c
+++ b/emu.c
@@ -883,6 +883,10 @@ static void do_controller(void)
hide_sprites ^= 1;
break;
+ case 'f':
+ show_fps ^= 1;
+ break;
+
case 'x':
dump(0, 0x4000);
break;
diff --git a/platform-sdl.c b/platform-sdl.c
index d586dfc..72ec1e9 100644
--- a/platform-sdl.c
+++ b/platform-sdl.c
@@ -184,6 +184,7 @@ static char handle_debug_key(int key)
case 'q':
case 'w': case 'e':
case 'a': case 's': case 'd':
+ case 'f':
case 'v': case 'c':
return (key);
}
diff --git a/video.c b/video.c
index 8888b19..aa1f7e3 100644
--- a/video.c
+++ b/video.c
@@ -20,9 +20,42 @@ u32 screen[320*240];
int hide_page_1;
int hide_page_2;
int hide_sprites;
+int show_fps = 0;
int trace_unknown_video = 1;
+static void fill_rect(u32 x, u32 y, u32 w, u32 h, u32 rgb)
+{
+ u32 xx, yy;
+ for (yy = y; yy < y + h; yy++)
+ for (xx = x; xx < x + w; xx++)
+ screen[320*yy + xx] = rgb;
+}
+
+static void do_show_fps(void)
+{
+ static u32 fps = 0;
+
+ const int per_n = 10;
+ static int count = 0;
+ count++;
+ if (count == per_n) {
+ static u32 last = 0;
+ u32 now = get_realtime();
+ if (last)
+ fps = 1000000 * per_n / (now - last);
+ last = now;
+ count = 0;
+ }
+
+ if (fps > 50)
+ fps = 50;
+
+ fill_rect(3, 3, 7, 52, 0xffffff);
+ fill_rect(4, 4, 5, 50 - fps, 0x000000);
+ fill_rect(4, 54 - fps, 5, fps, 0x00ff00);
+}
+
static const u8 sizes[] = { 8, 16, 32, 64 };
static const u8 colour_sizes[] = { 2, 4, 6, 8 };
@@ -515,6 +548,9 @@ void blit_screen(void)
if (!hide_sprites)
blit_sprites(depth);
}
+
+ if (show_fps)
+ do_show_fps();
}
void video_init(void)
diff --git a/video.h b/video.h
index 62ec189..729b13f 100644
--- a/video.h
+++ b/video.h
@@ -14,6 +14,8 @@ extern int hide_page_1;
extern int hide_page_2;
extern int hide_sprites;
+extern int show_fps;
+
void video_store(u16 val, u32 addr);
u16 video_load(u32 addr);