2019-03-21 22:00:41 +01:00
|
|
|
#include <gint/display.h>
|
2019-07-17 18:59:17 +02:00
|
|
|
#include <gint/keyboard.h>
|
|
|
|
#include <gint/gint.h>
|
2021-03-11 18:14:52 +01:00
|
|
|
#include <gint/drivers/keydev.h>
|
2019-07-17 18:59:17 +02:00
|
|
|
#include <gint/hardware.h>
|
2021-05-17 15:09:23 +02:00
|
|
|
#include <gint/usb.h>
|
|
|
|
#include <gint/usb-ff-bulk.h>
|
|
|
|
|
|
|
|
#ifdef FX9860G
|
|
|
|
#include <gint/gray.h>
|
|
|
|
#endif
|
2019-07-17 18:59:17 +02:00
|
|
|
|
|
|
|
#include <gintctl/util.h>
|
|
|
|
#include <gintctl/menu.h>
|
2021-03-11 18:14:52 +01:00
|
|
|
#include <gintctl/assets.h>
|
2019-07-17 18:59:17 +02:00
|
|
|
|
|
|
|
#include <gintctl/gint.h>
|
|
|
|
#include <gintctl/perf.h>
|
2020-05-16 15:56:06 +02:00
|
|
|
#include <gintctl/libs.h>
|
2019-07-28 01:54:52 +02:00
|
|
|
#include <gintctl/mem.h>
|
2019-07-17 18:59:17 +02:00
|
|
|
|
|
|
|
#include <libprof.h>
|
2019-03-21 22:00:41 +01:00
|
|
|
|
2021-06-07 19:08:17 +02:00
|
|
|
#include <fxlibc/printf.h>
|
|
|
|
|
2021-03-15 15:11:35 +01:00
|
|
|
/* TODO:
|
2019-07-17 18:59:17 +02:00
|
|
|
* 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 = {
|
|
|
|
|
2021-04-24 16:11:47 +02:00
|
|
|
{ "CPU and memory", gintctl_gint_cpumem, 0 },
|
|
|
|
{ "RAM discovery", gintctl_gint_ram, MENU_SH4_ONLY },
|
2020-10-21 14:28:43 +02:00
|
|
|
#ifdef FXCG50
|
2021-04-24 16:11:47 +02:00
|
|
|
{ "DSP processors", gintctl_gint_dsp, 0 },
|
2020-10-21 14:28:43 +02:00
|
|
|
#endif
|
2021-04-24 16:11:47 +02:00
|
|
|
{ "SPU memory", gintctl_gint_spuram, MENU_SH4_ONLY },
|
|
|
|
{ "Memory dump", gintctl_gint_dump, 0 },
|
|
|
|
{ "Drivers and worlds", gintctl_gint_drivers, 0 },
|
|
|
|
{ "TLB management", gintctl_gint_tlb, 0 },
|
2022-05-15 23:45:19 +02:00
|
|
|
#ifdef FXCG50
|
|
|
|
{ "Overclocking", gintctl_gint_overclock, MENU_SH4_ONLY },
|
|
|
|
#endif
|
2021-04-24 16:11:47 +02:00
|
|
|
{ "Memory allocation", gintctl_gint_kmalloc, 0 },
|
|
|
|
{ "Keyboard", gintctl_gint_keyboard, 0 },
|
|
|
|
{ "Timers", gintctl_gint_timer, 0 },
|
|
|
|
{ "Timer callbacks", gintctl_gint_timer_callbacks, 0 },
|
|
|
|
{ "DMA control", gintctl_gint_dma, MENU_SH4_ONLY },
|
|
|
|
{ "Real-time clock", gintctl_gint_rtc, 0 },
|
|
|
|
{ "USB communication", gintctl_gint_usb, MENU_SH4_ONLY },
|
2022-12-03 13:32:05 +01:00
|
|
|
#ifdef FXCG50
|
|
|
|
{ "USB tracer", gintctl_gint_usbtrace, MENU_SH4_ONLY },
|
|
|
|
#endif
|
2022-11-16 19:14:48 +01:00
|
|
|
{ "Basic rendering", gintctl_gint_render, 0 },
|
2022-05-12 16:38:48 +02:00
|
|
|
{ "Image rendering", gintctl_gint_image, 0 },
|
2021-04-24 16:11:47 +02:00
|
|
|
{ "Text rendering", gintctl_gint_topti, 0 },
|
2019-07-17 18:59:17 +02:00
|
|
|
#ifdef FX9860G
|
2021-04-24 16:11:47 +02:00
|
|
|
{ "Gray engine", gintctl_gint_gray, 0 },
|
|
|
|
{ "Gray rendering", gintctl_gint_grayrender, 0 },
|
2019-07-17 18:59:17 +02:00
|
|
|
#endif
|
2021-01-31 17:08:28 +01:00
|
|
|
{ NULL, NULL, 0 },
|
2019-07-17 18:59:17 +02:00
|
|
|
}};
|
|
|
|
|
|
|
|
/* Performance menu */
|
|
|
|
struct menu menu_perf = {
|
|
|
|
_("Performance", "Performance benchmarks"), .entries = {
|
|
|
|
|
2021-01-31 17:08:28 +01:00
|
|
|
{ "libprof basics", gintctl_perf_libprof, 0 },
|
|
|
|
{ "CPU and cache", gintctl_perf_cpucache, 0 },
|
2021-08-05 16:12:36 +02:00
|
|
|
{ _("CPU parallelism", "Superscalar and pipeline parallelism"),
|
|
|
|
gintctl_perf_cpu, 0 },
|
2021-01-31 17:08:28 +01:00
|
|
|
{ "Interrupt stress", gintctl_perf_interrupts, 0 },
|
2022-03-26 16:22:04 +01:00
|
|
|
#ifdef FXCG50
|
|
|
|
{ "Memory read/write speed",
|
|
|
|
gintctl_perf_memory, 0 },
|
|
|
|
#endif
|
2021-01-31 17:08:28 +01:00
|
|
|
{ "Rendering functions", gintctl_perf_render, 0 },
|
2020-07-06 18:01:30 +02:00
|
|
|
|
|
|
|
/* TODO: Comparison with MonochromeLib */
|
|
|
|
|
2021-01-31 17:08:28 +01:00
|
|
|
{ NULL, NULL, 0 },
|
2019-07-17 18:59:17 +02:00
|
|
|
}};
|
|
|
|
|
2020-05-16 15:56:06 +02:00
|
|
|
/* External libraries */
|
|
|
|
struct menu menu_libs = {
|
2020-05-31 17:06:47 +02:00
|
|
|
_("Libraries", "External and standard libraries"), .entries = {
|
2020-05-16 15:56:06 +02:00
|
|
|
|
2020-10-25 13:28:29 +01:00
|
|
|
{ "libm: " _("OpenLibm", "OpenLibm floating-point functions"),
|
2021-01-31 17:08:28 +01:00
|
|
|
gintctl_libs_openlibm, 0 },
|
2021-03-11 18:17:15 +01:00
|
|
|
{ "JustUI widgets",
|
|
|
|
gintctl_libs_justui, 0 },
|
2021-05-05 10:31:01 +02:00
|
|
|
{ "BFile filesystem",
|
|
|
|
gintctl_libs_bfile, 0 },
|
2021-01-31 17:08:28 +01:00
|
|
|
{ NULL, NULL, 0 },
|
2020-05-16 15:56:06 +02:00
|
|
|
}};
|
|
|
|
|
2021-05-17 15:09:23 +02:00
|
|
|
//---
|
|
|
|
// Global shortcuts
|
|
|
|
//---
|
|
|
|
|
2021-08-11 01:43:53 +02:00
|
|
|
/* Whether we're recording */
|
|
|
|
static bool getkey_recording = false;
|
|
|
|
|
|
|
|
static void getkey_record_video_frame(int onscreen)
|
|
|
|
{
|
|
|
|
#ifdef FX9860G
|
|
|
|
if(dgray_enabled())
|
|
|
|
usb_fxlink_videocapture_gray(true);
|
|
|
|
else
|
|
|
|
usb_fxlink_videocapture(onscreen);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FXCG50
|
|
|
|
usb_fxlink_videocapture(onscreen);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-05-17 15:09:23 +02:00
|
|
|
static bool getkey_global_shortcuts(key_event_t e)
|
|
|
|
{
|
|
|
|
if(usb_is_open() && e.key == KEY_OPTN && !e.shift && !e.alpha) {
|
|
|
|
#ifdef FX9860G
|
|
|
|
if(dgray_enabled())
|
|
|
|
usb_fxlink_screenshot_gray(true);
|
|
|
|
else
|
|
|
|
usb_fxlink_screenshot(true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FXCG50
|
|
|
|
usb_fxlink_screenshot(true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-08-11 01:43:53 +02:00
|
|
|
if(usb_is_open() && e.key == KEY_VARS && e.shift && !e.alpha) {
|
|
|
|
if(!getkey_recording) {
|
|
|
|
dupdate_set_hook(GINT_CALL(getkey_record_video_frame, (int)false));
|
|
|
|
getkey_record_video_frame(true);
|
|
|
|
getkey_recording = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dupdate_set_hook(GINT_CALL_NULL);
|
|
|
|
getkey_recording = false;
|
|
|
|
}
|
|
|
|
}
|
2022-11-19 19:03:26 +01:00
|
|
|
if(e.shift && e.key == KEY_COMMA) {
|
|
|
|
static int stage = 0;
|
|
|
|
stage = (stage + 1) % 8;
|
|
|
|
int border = stage * _(3, 13);
|
|
|
|
struct dwindow win = {
|
|
|
|
.left = border,
|
|
|
|
.top = border,
|
|
|
|
.right = DWIDTH - border,
|
|
|
|
.bottom = DHEIGHT - border,
|
|
|
|
};
|
|
|
|
dwindow_set((struct dwindow){ 0, 0, DWIDTH, DHEIGHT });
|
|
|
|
dclear(_(C_WHITE, 0x5555));
|
|
|
|
dwindow_set(win);
|
|
|
|
}
|
2021-05-17 15:09:23 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-07-17 18:59:17 +02:00
|
|
|
//---
|
|
|
|
// Main application
|
|
|
|
//---
|
|
|
|
|
|
|
|
/* gintctl_main(): Show the main tab */
|
|
|
|
void gintctl_main(void)
|
|
|
|
{
|
|
|
|
#ifdef FX9860G
|
2021-02-01 12:00:22 +01:00
|
|
|
row_title("gint %s %07x", GINT_VERSION, GINT_HASH);
|
2019-07-18 23:53:54 +02:00
|
|
|
|
|
|
|
row_print(3, 1, "F2:gint tests");
|
|
|
|
row_print(4, 1, "F3:Performance");
|
2020-05-16 15:56:06 +02:00
|
|
|
row_print(5, 1, "F4:Libraries");
|
|
|
|
row_print(6, 1, "F5:MPU registers");
|
|
|
|
row_print(7, 1, "F6:Memory map/dump");
|
2019-07-17 18:59:17 +02:00
|
|
|
#endif /* FX9860G */
|
|
|
|
|
|
|
|
#ifdef FXCG50
|
2021-01-25 17:26:57 +01:00
|
|
|
row_title("gint %s (@%07x) for fx-CG 50", GINT_VERSION, GINT_HASH);
|
2020-05-16 15:56:06 +02:00
|
|
|
row_print(1,1, "F2: gint features and driver tests");
|
|
|
|
row_print(2,1, "F3: Performance benchmarks");
|
|
|
|
row_print(3,1, "F4: External libraries");
|
|
|
|
row_print(4,1, "F5: MPU register browser");
|
|
|
|
row_print(5,1, "F6: Hexadecimal memory browser");
|
|
|
|
|
|
|
|
row_print(7,1, "This add-in is running a unikernel called gint by");
|
|
|
|
row_print(8,1, "Lephe'. Information about the project is available");
|
|
|
|
row_print(9,1, "on planet-casio.com.");
|
2019-07-17 18:59:17 +02:00
|
|
|
#endif /* FXCG50 */
|
|
|
|
}
|
|
|
|
|
2020-07-20 20:34:30 +02:00
|
|
|
static void draw(struct menu *menu)
|
|
|
|
{
|
|
|
|
dclear(C_WHITE);
|
|
|
|
|
|
|
|
if(menu) menu_show(menu);
|
|
|
|
else gintctl_main();
|
|
|
|
|
|
|
|
#ifdef FX9860G
|
|
|
|
dimage(0, 56, &img_opt_main);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FXCG50
|
|
|
|
fkey_action(1, "INFO");
|
|
|
|
fkey_menu(2, "GINT");
|
|
|
|
fkey_menu(3, "PERF");
|
|
|
|
fkey_menu(4, "LIBS");
|
|
|
|
fkey_button(5, "REGS");
|
|
|
|
fkey_button(6, "MEMORY");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-07-17 18:59:17 +02:00
|
|
|
int main(GUNUSED int isappli, GUNUSED int optnum)
|
2019-03-21 22:00:41 +01:00
|
|
|
{
|
2019-07-17 18:59:17 +02:00
|
|
|
/* Initialize menu metadata */
|
2020-10-21 18:32:13 +02:00
|
|
|
int top = _(1, 0), bottom = 1;
|
2019-07-18 23:53:54 +02:00
|
|
|
menu_init(&menu_gint, top, bottom);
|
|
|
|
menu_init(&menu_perf, top, bottom);
|
2020-05-16 15:56:06 +02:00
|
|
|
menu_init(&menu_libs, top, bottom);
|
2019-07-17 18:59:17 +02:00
|
|
|
|
2020-07-20 20:34:30 +02:00
|
|
|
gint_setrestart(1);
|
|
|
|
|
2021-05-17 15:09:23 +02:00
|
|
|
/* Enable global getkey() shortcuts */
|
|
|
|
getkey_set_feature_function(getkey_global_shortcuts);
|
|
|
|
|
2019-07-17 18:59:17 +02:00
|
|
|
/* Start the profiling library */
|
2020-10-13 21:32:22 +02:00
|
|
|
prof_init();
|
2019-07-17 18:59:17 +02:00
|
|
|
|
2021-02-02 22:24:24 +01:00
|
|
|
/* Enable floating-point formatters */
|
2021-06-07 19:08:17 +02:00
|
|
|
__printf_enable_fp();
|
2021-06-16 16:02:33 +02:00
|
|
|
/* Enable fixed-point formatters */
|
|
|
|
__printf_enable_fixed();
|
2021-02-02 22:24:24 +01:00
|
|
|
|
2020-07-14 17:35:05 +02:00
|
|
|
#ifdef FX9860G
|
|
|
|
/* Use the Unicode font uf5x7 on fx-9860G */
|
|
|
|
dfont(&font_uf5x7);
|
|
|
|
#endif
|
|
|
|
|
2021-03-11 18:14:52 +01:00
|
|
|
keydev_transform_t tr = keydev_transform(keydev_std());
|
|
|
|
tr.enabled |= KEYDEV_TR_DELAYED_SHIFT | KEYDEV_TR_INSTANT_SHIFT;
|
|
|
|
tr.enabled |= KEYDEV_TR_DELAYED_ALPHA | KEYDEV_TR_INSTANT_ALPHA;
|
|
|
|
keydev_set_transform(keydev_std(), tr);
|
|
|
|
|
2021-02-06 16:42:43 +01:00
|
|
|
key_event_t ev;
|
2019-07-18 23:53:54 +02:00
|
|
|
int key = 0;
|
2019-07-17 18:59:17 +02:00
|
|
|
struct menu *menu = NULL;
|
|
|
|
|
|
|
|
while(key != KEY_EXIT)
|
|
|
|
{
|
2020-07-20 20:34:30 +02:00
|
|
|
draw(menu);
|
2019-07-17 18:59:17 +02:00
|
|
|
dupdate();
|
2021-02-06 16:42:43 +01:00
|
|
|
|
|
|
|
ev = getkey();
|
|
|
|
key = ev.key;
|
2019-07-17 18:59:17 +02:00
|
|
|
|
|
|
|
if(key == KEY_F1)
|
2019-07-18 23:53:54 +02:00
|
|
|
menu = NULL;
|
2019-07-17 18:59:17 +02:00
|
|
|
if(key == KEY_F2)
|
2019-07-18 23:53:54 +02:00
|
|
|
menu = &menu_gint;
|
2019-07-17 18:59:17 +02:00
|
|
|
if(key == KEY_F3)
|
2019-07-18 23:53:54 +02:00
|
|
|
menu = &menu_perf;
|
2020-05-16 15:56:06 +02:00
|
|
|
if(key == KEY_F4)
|
|
|
|
menu = &menu_libs;
|
2019-07-17 18:59:17 +02:00
|
|
|
if(key == KEY_F5)
|
2019-07-18 23:53:54 +02:00
|
|
|
gintctl_regs();
|
|
|
|
if(key == KEY_F6)
|
2019-07-28 01:54:52 +02:00
|
|
|
gintctl_mem();
|
2019-07-17 18:59:17 +02:00
|
|
|
|
|
|
|
if(!menu) continue;
|
|
|
|
|
|
|
|
if(key == KEY_UP || key == KEY_DOWN)
|
2021-02-06 16:42:43 +01:00
|
|
|
menu_move(menu, key, ev.shift || keydown(KEY_SHIFT),0);
|
2019-07-17 18:59:17 +02:00
|
|
|
if(key == KEY_EXE)
|
|
|
|
menu_exec(menu);
|
|
|
|
}
|
|
|
|
|
2020-07-20 20:34:30 +02:00
|
|
|
/* Prepare a main menu frame to maintain the illusion when coming
|
|
|
|
back after a restart */
|
|
|
|
draw(NULL);
|
|
|
|
|
2019-07-17 18:59:17 +02:00
|
|
|
prof_quit();
|
|
|
|
return 0;
|
2019-03-21 22:00:41 +01:00
|
|
|
}
|