much better user interface for litenes

This commit is contained in:
Yanyan Jiang 2020-08-12 22:06:06 +08:00 committed by Zihao Yu
parent 891375d8fa
commit ef885890c1
3 changed files with 14 additions and 9 deletions

View file

@ -6,7 +6,7 @@
#include <klib.h>
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;
}
}

View file

@ -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);

View file

@ -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();