gintctl/src/gintctl.c

154 lines
3.4 KiB
C

#define GINT_NEED_VRAM
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/syscalls.h>
#include <gint/gint.h>
#include <gint/hardware.h>
#include <gintctl/util.h>
#include <gintctl/menu.h>
#include <gintctl/prof-contexts.h>
#include <gintctl/gint.h>
#include <gintctl/perf.h>
#include <gintctl/mem.h>
#include <libprof.h>
/* Drawing functions:
* ...
Keyboard tests:
* ...
Timer tests:
* Do more in-depth things than previous application
* Stress testing for number of interrupts
* ...
TODO:
* Add-in size and mappings
* Interrupt controller state?
* Clock frequencies
* F2 to save hardware data to file */
/* gint test menu */
struct menu menu_gint = {
_("gint tests", "gint features and driver tests"), .entries = {
{ "Hardware", gintctl_gint_hardware },
{ "RAM discovery", gintctl_gint_ram },
{ "Memory dump", gintctl_gint_dump },
{ "Keyboard", NULL },
{ "Timers", gintctl_gint_timer },
#ifdef FXCG50
{ "DMA Control", gintctl_gint_dma },
#endif
{ "Real-time clock", NULL },
{ "Image rendering", gintctl_gint_bopti },
{ "Text rendering", NULL },
#ifdef FX9860G
{ "Gray engine", gintctl_gint_gray },
{ "Gray rendering", gintctl_gint_grayrender },
#endif
{ "printf family", gintctl_gint_printf },
{ NULL, NULL },
}};
/* Performance menu */
struct menu menu_perf = {
_("Performance", "Performance benchmarks"), .entries = {
{ "libprof basics", gintctl_perf_libprof },
{ "Rendering functions", gintctl_perf_render },
{ NULL, NULL },
}};
//---
// Main application
//---
/* gintctl_main(): Show the main tab */
void gintctl_main(void)
{
#ifdef FX9860G
row_title("gint @%07x", GINT_VERSION);
row_print(3, 1, "F2:gint tests");
row_print(4, 1, "F3:Performance");
row_print(5, 1, "F5:MPU registers");
row_print(6, 1, "F6:Memory map/dump");
#endif /* FX9860G */
#ifdef FXCG50
row_title("gint @%07x for fx-CG 50", GINT_VERSION);
row_print(1, 1, "F2: gint features and driver tests");
row_print(2, 1, "F3: Performance benchmarks");
row_print(3, 1, "F5: MPU register browser");
row_print(4, 1, "F6: Hexadecimal memory editor");
#ifdef GINT_BOOTLOG
extern char gint_bootlog[22 * 8];
extern font_t *gint_default_font;
for(int i = 1; i < 8; i++) dtext(8, 85 + 13 * i, gint_bootlog + 22 * i,
C_BLACK, C_NONE);
#endif /* GINT_BOOTLOG */
#endif /* FXCG50 */
}
int main(GUNUSED int isappli, GUNUSED int optnum)
{
/* Initialize menu metadata */
int top = _(1, 0), bottom = _(1, 0);
menu_init(&menu_gint, top, bottom);
menu_init(&menu_perf, top, bottom);
/* Start the profiling library */
prof_init(PROFCTX_COUNT, 2);
int key = 0;
struct menu *menu = NULL;
while(key != KEY_EXIT)
{
dclear(C_WHITE);
if(menu) menu_show(menu);
else gintctl_main();
#ifdef FX9860G
extern image_t img_opt_main;
dimage(0, 56, &img_opt_main);
#else
fkey_action(1, "INFO");
fkey_menu(2, "GINT");
fkey_menu(3, "PERF");
fkey_button(5, "REGS");
fkey_button(6, "MEMORY");
#endif
dupdate();
key = getkey().key;
if(key == KEY_F1)
menu = NULL;
if(key == KEY_F2)
menu = &menu_gint;
if(key == KEY_F3)
menu = &menu_perf;
if(key == KEY_F5)
gintctl_regs();
if(key == KEY_F6)
gintctl_mem();
if(!menu) continue;
if(key == KEY_UP || key == KEY_DOWN)
menu_move(menu, key, 0);
if(key == KEY_EXE)
menu_exec(menu);
}
prof_quit();
return 0;
}