From ef885890c1bda92d97e3aeb6153184015f649105 Mon Sep 17 00:00:00 2001 From: Yanyan Jiang Date: Wed, 12 Aug 2020 22:06:06 +0800 Subject: [PATCH] much better user interface for litenes --- kernels/litenes/src/fce.c | 10 ++++++---- kernels/litenes/src/fce.h | 7 ++++--- kernels/litenes/src/main.c | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/kernels/litenes/src/fce.c b/kernels/litenes/src/fce.c index 28b2cbd..b4ffac7 100644 --- a/kernels/litenes/src/fce.c +++ b/kernels/litenes/src/fce.c @@ -6,7 +6,7 @@ #include static int frame_cnt; -bool candraw() { return frame_cnt % 3 == 0; } +static inline bool candraw() { return frame_cnt % (1 + FRAME_SKIP) == 0; } static uint32_t canvas[SCR_W * SCR_H]; @@ -112,9 +112,11 @@ void fce_run() { } nr_draw ++; - if (uptime_ms() - last > 1000) { - last = uptime_ms(); - printf("FPS = %d\n", nr_draw); + int upt = uptime_ms(); + if (upt - last > 1000) { + last = upt; + for (int i = 0; i < 80; i++) putch('\b'); + printf("(System time: %ds) FPS = %d", upt / 1000, nr_draw); nr_draw = 0; } } diff --git a/kernels/litenes/src/fce.h b/kernels/litenes/src/fce.h index 4109ebd..4795874 100644 --- a/kernels/litenes/src/fce.h +++ b/kernels/litenes/src/fce.h @@ -3,9 +3,10 @@ #include "common.h" -#define FPS 60 -#define SCR_W 256 -#define SCR_H 240 +#define FPS 60 +#define SCR_W 256 +#define SCR_H 240 +#define FRAME_SKIP 1 void fce_update_screen(); int fce_load_rom(char *rom); diff --git a/kernels/litenes/src/main.c b/kernels/litenes/src/main.c index 4139e97..491f155 100644 --- a/kernels/litenes/src/main.c +++ b/kernels/litenes/src/main.c @@ -7,11 +7,13 @@ extern char rom_mario_nes[]; int main() { ioe_init(); - printf("Play: [%s] SELECT [%s] START [%s]\n" - " [%s] [%s] [%s] A [%s] B [%s]\n", + printf("==================== LiteNES Emulator ====================\n\n"); + printf("Control: [%s] SELECT [%s] START [%s]\n" + " [%s] [%s] [%s] A [%s] B [%s]\n\n", TOSTRING(KEY_UP), TOSTRING(KEY_SELECT), TOSTRING(KEY_START), TOSTRING(KEY_LEFT), TOSTRING(KEY_DOWN), TOSTRING(KEY_RIGHT), TOSTRING(KEY_A), TOSTRING(KEY_B)); + printf("==========================================================\n"); fce_load_rom((void *)rom_mario_nes); fce_init();