diff --git a/.gitignore b/.gitignore index ea4a8f5..1fda17e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,3 @@ build.cg/ # Targets gintctl.g1a gintctl.g3a - -# Full, heavier version of libfxcg -libfxcg-full.a diff --git a/Makefile b/Makefile index 1217959..57ed664 100755 --- a/Makefile +++ b/Makefile @@ -14,13 +14,14 @@ cf-cg := $(cf) -m4-nofpu -DFXCG50 # Linker flags lf-fx := -Tfx9860g.ld -lprof -lgint-fx -lgcc -Wl,-Map=build.fx/map -lf-cg := -Tfxcg50.ld -lprof -lgint-cg -lgcc -Wl,-Map=build.cg/map -L. -lfxcg +lf-cg := -Tfxcg50.ld -lprof -lgint-cg -lgcc -Wl,-Map=build.cg/map dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP cpflags := -R .bss -R .gint_bss -g1af := -i icon-fx.png -n gintctl --internal=@GINTCTL -g3af := -n basic:" " -i uns:icon-cg-uns.png -i sel:icon-cg-sel.png +g1af := -i assets-fx/icon.png -n gintctl --internal=@GINTCTL +g3af := -n basic:" " -i uns:assets-cg/icon-uns.png \ + -i sel:assets-cg/icon-sel.png # # File listings @@ -33,13 +34,14 @@ target-cg := gintctl.g3a # Source and object files src := $(shell find src -name '*.c') -res := $(wildcard resources/*.png) -obj-fx := $(src:%.c=build.fx/%.o) $(res:resources/%=build.fx/%.o) -obj-cg := $(src:%.c=build.cg/%.o) $(res:resources/%=build.cg/%.o) +assets-fx := $(wildcard assets-fx/*.png) +assets-cg := $(wildcard assets-cg/*.png) +obj-fx := $(src:%.c=build.fx/%.o) $(assets-fx:assets-fx/%=build.fx/%.o) +obj-cg := $(src:%.c=build.cg/%.o) $(assets-ch:assets-cg/%=build.cg/%.o) # Additional dependencies -deps-fx := icon-fx.png -deps-cg := icon-cg-uns.png icon-cg-sel.png +deps-fx := assets-fx/icon.png +deps-cg := assets-cg/icon-uns.png assets-cg/icon-sel.png # # Build rules @@ -71,10 +73,10 @@ build.cg/%.o: %.c sh4eb-elf-gcc -c $< -o $@ $(cf-cg) $(dflags) # Images -build.fx/%.png.o: resources/%.png +build.fx/%.png.o: assets-fx/%.png @ mkdir -p $(dir $@) fxconv -i $< -o $@ name:$* -build.cg/%.png.o: resources/%.png +build.cg/%.png.o: assets-cg/%.png @ echo -e "\e[31;1mWARNING: conversion for fxcg50 not supported yet\e[0m" @ mkdir -p $(dir $@) fxconv -i $< -o $@ name:$* diff --git a/TODO b/TODO deleted file mode 100644 index ebe3322..0000000 --- a/TODO +++ /dev/null @@ -1 +0,0 @@ -* perf: Try 284x124 at (-60,-28) (all disadvantages) diff --git a/icon-cg-sel.png b/assets-cg/icon-sel.png similarity index 100% rename from icon-cg-sel.png rename to assets-cg/icon-sel.png diff --git a/icon-cg-uns.png b/assets-cg/icon-uns.png similarity index 100% rename from icon-cg-uns.png rename to assets-cg/icon-uns.png diff --git a/icon-fx.png b/assets-fx/icon.png similarity index 100% rename from icon-fx.png rename to assets-fx/icon.png diff --git a/assets-fx/opt_gint_timers.png b/assets-fx/opt_gint_timers.png new file mode 100644 index 0000000..7e54142 Binary files /dev/null and b/assets-fx/opt_gint_timers.png differ diff --git a/assets-fx/opt_main.png b/assets-fx/opt_main.png new file mode 100644 index 0000000..d6c17ce Binary files /dev/null and b/assets-fx/opt_main.png differ diff --git a/assets-fx/opt_perf_libprof.png b/assets-fx/opt_perf_libprof.png new file mode 100644 index 0000000..9259a6f Binary files /dev/null and b/assets-fx/opt_perf_libprof.png differ diff --git a/assets-fx/opt_perf_render.png b/assets-fx/opt_perf_render.png new file mode 100644 index 0000000..9259a6f Binary files /dev/null and b/assets-fx/opt_perf_render.png differ diff --git a/resources/pattern.png b/assets-fx/pattern.png similarity index 100% rename from resources/pattern.png rename to assets-fx/pattern.png diff --git a/resources/pattern2.png b/assets-fx/pattern2.png similarity index 100% rename from resources/pattern2.png rename to assets-fx/pattern2.png diff --git a/include/gintctl/menu.h b/include/gintctl/menu.h index 48998f5..4353df4 100644 --- a/include/gintctl/menu.h +++ b/include/gintctl/menu.h @@ -20,15 +20,17 @@ struct menu { int len; int offset; int pos; - int visible; + int top; + int bottom; struct menuentry entries[]; }; /* menu_init(): Initialize a menu list - @menu Any list menu, even unitialized - @visible Number of lines that can be shown simultaneously */ -void menu_init(struct menu *menu, int visible); + @menu Any list menu, even uninitialized + @top Number of lines reserved on top (including title on fx9860g) + @bottom Number of lines reserved at bottom */ +void menu_init(struct menu *menu, int top, int bottom); /* menu_move(): Move the cursor in a menu @menu Initialized list menu diff --git a/include/gintctl/prof-contexts.h b/include/gintctl/prof-contexts.h index 8130ede..f8c71d0 100644 --- a/include/gintctl/prof-contexts.h +++ b/include/gintctl/prof-contexts.h @@ -10,6 +10,7 @@ enum { PROFCTX_BASICS = 0, + PROFCTX_EMPTY, PROFCTX_DCLEAR, PROFCTX_DUPDATE, diff --git a/include/gintctl/util.h b/include/gintctl/util.h index 5746add..1e34526 100644 --- a/include/gintctl/util.h +++ b/include/gintctl/util.h @@ -36,7 +36,7 @@ void row_highlight(int row); void row_right(int row, char const *character); /* scrollbar(): Show a scrollbar */ -void scrollbar(int offset, int length); +void scrollbar(int offset, int length, int top, int bottom); /* row_count(): Number of rows available to row_print() */ int row_count(void); diff --git a/libfxcg.a b/libfxcg.a deleted file mode 100644 index a8f407f..0000000 Binary files a/libfxcg.a and /dev/null differ diff --git a/res-cg/opt_main.png b/res-cg/opt_main.png deleted file mode 100644 index 59bf4ac..0000000 Binary files a/res-cg/opt_main.png and /dev/null differ diff --git a/resources/opt_main.png b/resources/opt_main.png deleted file mode 100644 index c81b9b4..0000000 Binary files a/resources/opt_main.png and /dev/null differ diff --git a/src/gint/hardware.c b/src/gint/hardware.c index 49e94bc..c39ad37 100644 --- a/src/gint/hardware.c +++ b/src/gint/hardware.c @@ -39,8 +39,8 @@ static void hw_mpucpu(int *row) else put(" %s", mpu_names[mpu]); if(!isSH4()) return; - put(_(" PVR"," Processor Version Register") ": %08x", gint[HWCPUVR]); - put(_(" PRR"," Product Register") ": %08x", gint[HWCPUPR]); + put(_(" PVR:"," Processor Version Register: ") "%08x", gint[HWCPUVR]); + put(_(" PRR:"," Product Register: ") "%08x", gint[HWCPUPR]); } /* Memory */ @@ -54,10 +54,10 @@ static void hw_memory(int *row) put("Memory and MMU" _(,":")); load_barrier(mmu); - put(" ROM: %dM", rom >> 20); + put(" ROM:" _(," ") "%dM", rom >> 20); #ifdef FX9860G - put(" RAM: %dk (%dk user)", ram >> 10, uram >> 10); + put(" RAM:%dk (%dk user)", ram >> 10, uram >> 10); #else put(" RAM: %dM (%dk mapped in userspace)", ram >> 20, uram >> 10); #endif @@ -72,13 +72,13 @@ static void hw_cpg(int *row) { int cpg = gint[HWCPG]; - put("Clock Pulse Generator" _(,":")); + put(_("Clock Generator", "Clock Pulse Generator:")); load_barrier(cpg); if(cpg & HWCPG_COMP) put( _(" Input freq known"," Input clock frequency is known")); if(cpg & HWCPG_EXT) put( - _(" CPG is extended"," SH7724-style extended module")); + _(" SH7724-style CPG"," SH7724-style extended module")); } /* Direct Memory Access Controller */ @@ -224,10 +224,13 @@ void gintctl_gint_hardware(void) while(key != KEY_EXIT) { dclear(C_WHITE); - row_title(_("Hardware", "Hardware and loaded drivers")); + + #ifdef FXCG50 + row_title("Hardware and loaded drivers"); + #endif max = display_data(offset); - scrollbar(offset, max); + scrollbar(offset, max, 1, row_count() + 1); dupdate(); diff --git a/src/gint/timer.c b/src/gint/timer.c index f3bd3fa..9d9d1f8 100644 --- a/src/gint/timer.c +++ b/src/gint/timer.c @@ -7,52 +7,77 @@ #include #include -/* tmu_print(): Print a TMU's details */ -void tmu_print(int x, int y, char const *name, tmu_t *tmu, int running) +/* timer_print(): Print a timer's details */ +void timer_print(int x, int y, char const *name, uint32_t TCOR, uint32_t TCNT, + int UNIE, int UNF, int STR) { - int dx = _(27,45), dy = _(8,14); + int dy = _(8,14); print(x, y, "%s:", name); - if(!tmu) - { - print(x, y + dy, "(null)"); - return; - } - print(x, y + dy, "TCOR"); - print(x + dx, y + dy, "%08x", tmu->TCOR); + #ifdef FXCG50 + print(x, y+dy, "TCOR"); + print(x, y+2*dy, "TCNT"); + #endif - print(x, y + 2 * dy, "TCNT"); - print(x + dx, y + 2 * dy, "%08x", tmu->TCNT); + print(_(x+6, x+45), y+dy, "%08x", TCOR); + print(_(x+60, x+45), _(y+dy, y+2*dy), "%08x", TCNT); - print(x, y + 3 * dy, "%s%s%s", - tmu->TCR.UNIE ? "UNIE " : "", - tmu->TCR.UNF ? "UNF " : "", - running ? "TSTR " : "" + print(_(x+36, x), _(y, y+3*dy), "%s%s%s", + UNIE ? "UNIE " : "", + UNF ? "UNF " : "", + STR ? "STR " : "" ); } +/* tmu_print(): Print a TMU's details */ +void tmu_print(int x, int y, char const *name, tmu_t *tmu, int STR) +{ + timer_print(x, y, name, tmu->TCOR, tmu->TCNT, tmu->TCR.UNIE, + tmu->TCR.UNF, STR); +} + /* etmu_print(): Print an ETMU's details */ void etmu_print(int x, int y, char const *name, etmu_t *etmu) { - int dx = _(27,45), dy = _(8,14); - print(x, y, "%s:", name); - if(!etmu) - { - print(x, y + dy, "(null)"); - return; - } + timer_print(x, y, name, etmu->TCOR, etmu->TCNT, etmu->TCR.UNIE, + etmu->TCR.UNF, etmu->TSTR); +} - print(x, y + dy, "TCOR"); - print(x + dx, y + dy, "%08x", etmu->TCOR); - print(x, y + 2 * dy, "TCNT"); - print(x + dx, y + 2 * dy, "%08x", etmu->TCNT); +#ifdef FX9860G +static int x[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1 }; +static int y[] = { 0, 16, 32, 0, 16, 32, 0, 16, 32 }; +#else +static int x[] = { 6, 138, 270, 6, 138, 270, 6, 138, 270 }; +static int y[] = { 24, 24, 24, 84, 84, 84, 144, 144, 144 }; +#endif - print(x, y + 3 * dy, "%s%s%s", - etmu->TCR.UNIE ? "UNIE " : "", - etmu->TCR.UNF ? "UNF " : "", - etmu->TSTR ? "TSTR " : "" - ); +void show_tmu(void) +{ + volatile uint8_t *TSTR; + timer_address(0, &TSTR); + + tmu_print(x[0], y[0], "TMU0", timer_address(0, NULL), *TSTR & 0x1); + tmu_print(x[1], y[1], "TMU1", timer_address(1, NULL), *TSTR & 0x2); + tmu_print(x[2], y[2], "TMU2", timer_address(2, NULL), *TSTR & 0x4); +} + +void show_etmu_1(void) +{ + etmu_print(x[3], y[3], "ETMU0", timer_address(3, NULL)); + + if(isSH3()) return; + etmu_print(x[4], y[4], "ETMU1", timer_address(4, NULL)); + etmu_print(x[5], y[5], "ETMU2", timer_address(5, NULL)); +} + +void show_etmu_2(void) +{ + if(isSH3()) return; + + etmu_print(x[6], y[6], "ETMU3", timer_address(6, NULL)); + etmu_print(x[7], y[7], "ETMU4", timer_address(7, NULL)); + etmu_print(x[8], y[8], "ETMU5", timer_address(8, NULL)); } /* gintctl_gint_timer(): Show the timer status in real-time */ @@ -64,30 +89,29 @@ void gintctl_gint_timer(void) program to ~90 FPS.) */ int key = 0, timeout = 1; + #ifdef FX9860G + int tab = 1; + #endif + while(key != KEY_EXIT) { dclear(C_WHITE); #ifdef FX9860G - #warning gintctl_gint_timer not implemented yet + if(tab == 1) show_tmu(); + if(tab == 2) show_etmu_1(); + if(tab == 3) show_etmu_2(); + + extern image_t opt_gint_timers; + dimage(0, 56, &opt_gint_timers); #endif #ifdef FXCG50 row_title("Timer status"); - volatile uint8_t *TSTR; - timer_address(0, &TSTR); - - tmu_print(6, 24, "TMU0", timer_address(0, NULL),*TSTR & 0x1); - tmu_print(138, 24, "TMU1", timer_address(1, NULL),*TSTR & 0x2); - tmu_print(270, 24, "TMU2", timer_address(2, NULL),*TSTR & 0x4); - - etmu_print(6, 84, "ETMU0", timer_address(3, NULL)); - etmu_print(138, 84, "ETMU1", timer_address(4, NULL)); - etmu_print(270, 84, "ETMU2", timer_address(5, NULL)); - etmu_print(6, 144, "ETMU3", timer_address(6, NULL)); - etmu_print(138, 144, "ETMU4", timer_address(7, NULL)); - etmu_print(270, 144, "ETMU5", timer_address(8, NULL)); + show_tmu(); + show_etmu_1(); + show_etmu_2(); fkey_button(1, "SLEEP"); #endif @@ -95,15 +119,22 @@ void gintctl_gint_timer(void) dupdate(); key = getkey_opt(GETKEY_DEFAULT, &timeout).key; - /* On F1, pretend to sleep and just see what happens */ if(key == KEY_F1) { volatile int flag = 0; + int tid = 0; - int free = timer_setup(5, timer_delay(5, 1000000), 0, - timer_timeout, &flag); - if(free >= 0) timer_start(5); + int free = timer_setup(tid, timer_delay(tid, 1000000), + 0, timer_timeout, &flag); + if(free == tid) timer_start(tid); } + + #ifdef FX9860G + /* On F4, F5 and F6, switch tabs */ + if(key == KEY_F4) tab = 1; + if(key == KEY_F5) tab = 2; + if(key == KEY_F6) tab = 3; + #endif } } diff --git a/src/gintctl.c b/src/gintctl.c index b2e436e..06e08f9 100644 --- a/src/gintctl.c +++ b/src/gintctl.c @@ -50,8 +50,8 @@ struct menu menu_gint = { struct menu menu_perf = { _("Performance", "Performance benchmarks"), .entries = { - { "libprof basics", gintctl_perf_libprof }, - { "Rendering primitives", gintctl_perf_render }, + { "libprof basics", gintctl_perf_libprof }, + { "Rendering functions", gintctl_perf_render }, { NULL, NULL }, }}; @@ -115,18 +115,19 @@ void gintctl_main(void) { #ifdef FX9860G row_title("gint @%07x", GINT_VERSION); - row_print(2, 1, "F2:gint tests"); - row_print(3, 1, "F3:MPU registers"); - row_print(4, 1, "F4:Memory map/dump"); - row_print(5, 1, "F5:Performance"); + + 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: MPU register browser"); - row_print(3, 1, "F4: Hexadecimal memory editor"); - row_print(4, 1, "F5: Performance benchmarks"); + 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]; @@ -142,22 +143,22 @@ void gintctl_main(void) int main(GUNUSED int isappli, GUNUSED int optnum) { /* Initialize menu metadata */ - menu_init(&menu_gint, row_count()); - menu_init(&menu_perf, row_count()); + 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 tab = 1, key = 0; + int key = 0; struct menu *menu = NULL; while(key != KEY_EXIT) { dclear(C_WHITE); - if(tab == 1) gintctl_main(); - else if(menu) menu_show(menu); - else row_title("Nothing, essentially"); + if(menu) menu_show(menu); + else gintctl_main(); #ifdef FX9860G extern image_t opt_main; @@ -165,24 +166,24 @@ int main(GUNUSED int isappli, GUNUSED int optnum) #else fkey_action(1, "INFO"); fkey_menu(2, "GINT"); - fkey_menu(3, "REGS"); - fkey_button(4, "MEMORY"); - fkey_menu(5, "PERF"); + fkey_menu(3, "PERF"); + fkey_button(5, "REGS"); + fkey_button(6, "MEMORY"); #endif dupdate(); key = getkey().key; if(key == KEY_F1) - tab = 1, menu = NULL; + menu = NULL; if(key == KEY_F2) - tab = 2, menu = &menu_gint; + menu = &menu_gint; if(key == KEY_F3) - tab = 3, menu = NULL; - if(key == KEY_F4) - /* TODO: Launch memory explorer */ { } + menu = &menu_perf; if(key == KEY_F5) - tab = 5, menu = &menu_perf; + gintctl_regs(); + if(key == KEY_F6) + /* TODO: Launch memory explorer */ { } if(!menu) continue; diff --git a/src/menu.c b/src/menu.c index 3705420..31b3235 100644 --- a/src/menu.c +++ b/src/menu.c @@ -4,20 +4,22 @@ #include /* menu_init(): Initialize a menu list */ -void menu_init(struct menu *menu, int visible) +void menu_init(struct menu *menu, int top, int bottom) { menu->len = 0; while(menu->entries[menu->len].name) menu->len++; menu->offset = 0; menu->pos = 0; - menu->visible = visible; + menu->top = top + 1; + menu->bottom = row_count() - bottom + 1; } /* menu_move(): Move the cursor in a menu */ void menu_move(struct menu *menu, int key, int wrap) { - int max_offset = max(menu->len - menu->visible, 0); + int visible = menu->bottom - menu->top; + int max_offset = max(menu->len - visible, 0); if(key == KEY_UP && menu->pos > 0) { @@ -33,8 +35,8 @@ void menu_move(struct menu *menu, int key, int wrap) if(key == KEY_DOWN && menu->pos + 1 < menu->len) { menu->pos++; - if(menu->pos > menu->offset + menu->visible - 1 - && menu->offset + 1 < max_offset) + if(menu->pos > menu->offset + visible - 1 + && menu->offset + 1 <= max_offset) { menu->offset++; } @@ -51,21 +53,28 @@ void menu_show(struct menu const *menu) { struct menuentry const *items = menu->entries; int offset = menu->offset, pos = menu->pos; - int i = 0; - row_title(menu->name); + /* Min and max writable rows */ + int top = menu->top, bottom = menu->bottom; - while(i+1 <= menu->visible && items[offset+i].name) + int i = 0, j = top; + + /* On fx9860g, only show the title if row is left for it */ + if(_(top > 0, 1)) row_title(menu->name); + + while(j < bottom && items[offset+i].name) { - row_print(i+1, 2, items[offset+i].name); - i++; + row_print(j, 2, items[offset+i].name); + i++, j++; } - if(offset > 0) row_right(1, "^"); - if(items[offset+i].name) row_right(row_count(), "v"); + if(menu->len > bottom - top) + { + scrollbar(offset, menu->len, top, bottom); + } - int selected = pos - offset + 1; - if(selected >= 1 && selected <= menu->visible) row_highlight(selected); + int selected = top + (pos - offset); + if(selected >= top && selected < bottom) row_highlight(selected); } /* menu_exec(): Execute the currently-selected function of a menu */ diff --git a/src/perf/libprof.c b/src/perf/libprof.c index 23bd6ef..6576b62 100644 --- a/src/perf/libprof.c +++ b/src/perf/libprof.c @@ -8,45 +8,59 @@ #include -/* Waits 1s and returns the libprof output in microseconds */ -static uint32_t run_test(void) +/* Waits some time and returns the libprof output in microseconds */ +static uint32_t run_sleep(int us) { int ctx = PROFCTX_BASICS; - prof_clear(ctx); - prof_enter(ctx); - static int delay = 100000; - sleep_us(1, delay); + sleep_us(1, us); prof_leave(ctx); - delay += 256; + return prof_time(ctx); +} + +/* Measure overhead of an empty context */ +static uint32_t run_empty(void) +{ + int ctx = PROFCTX_EMPTY; + prof_clear(ctx); + prof_enter(ctx); + + prof_leave(ctx); return prof_time(ctx); } /* gintctl_perf_libprof(): Test the libprof implementation */ void gintctl_perf_libprof(void) { - int key = 0, test = 0; - uint32_t elapsed = 0; + int key=0, test=0, delay=10000; + + uint32_t sleep_delay = 0; + uint32_t empty = 0; while(key != KEY_EXIT) { dclear(C_WHITE); - row_title("libprof basics"); #ifdef FX9860G - #warning gintctl_perf_libprof incomplete on fx9860g + row_print(1, 1, "Measures time for"); + row_print(2, 1, "10ms sleep +1us each"); + row_print(3, 1, "time, and empty code."); - row_print(2, 2, "Checks that libprof"); - row_print(3, 2, "Press F1 to start."); - row_print(5, 2, "Delay: 1s"); + if(test) + { + row_print(5, 1, "Sleep: %.3j ms", sleep_delay); + row_print(6, 1, "Empty: %d us", empty); + } - if(test == 1) row_print(6, 2, "Elapsed: %8xus", elapsed); - #endif + extern image_t opt_perf_libprof; + dimage(0, 56, &opt_perf_libprof); + #endif /* FX9860G */ #ifdef FXCG50 + row_title("libprof basics"); row_print(1, 1, "This program shows the execution time " "measured"); row_print(2, 1, "by libprof for a 100 ms sleep, with 256us " @@ -54,16 +68,26 @@ void gintctl_perf_libprof(void) row_print(3, 1, "each time."); row_print(5, 1, "Press F1 to start the test."); - if(test) row_print(7, 1, "Elapsed: %.1j ms (%#08x us)", - elapsed / 100, elapsed); - if(test) row_print(8, 1, "Tests: %d", test); + if(test) + { + row_print(7, 1, "Sleep: %.3j us", sleep_delay); + row_print(8, 1, "Empty: %d us", empty); + row_print(9, 1, "Tests: %d", test); + } fkey_button(1, "START"); - #endif + #endif /* FXCG50 */ dupdate(); key = getkey().key; - if(key == KEY_F1) elapsed = run_test(), test++; + if(key == KEY_F1) + { + sleep_delay = run_sleep(delay); + empty = run_empty(); + + delay++; + test++; + } } } diff --git a/src/perf/render.c b/src/perf/render.c index bb197a0..d9f60a7 100644 --- a/src/perf/render.c +++ b/src/perf/render.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -36,12 +37,22 @@ static void run_test(struct elapsed *time) drect(1, 1, 32, 32, C_WHITE) ); test(PROFCTX_DRECT3, time->rect3, - drect(0, 0, 395, 223, C_WHITE) + drect(0, 0, _(127,395), _(63,223), C_WHITE) ); #undef test } +char *printtime(uint32_t us) +{ + static char str[20]; + + if(us < 1000) sprintf(str, "%d us", us); + else sprintf(str, "%.1j ms", us / 100); + + return str; +} + /* gintctl_perf_render(): Profile the display primitives */ void gintctl_perf_render(void) { @@ -51,13 +62,25 @@ void gintctl_perf_render(void) while(key != KEY_EXIT) { dclear(C_WHITE); - row_title("Rendering primitives"); #ifdef FX9860G - #warning gintctl_perf_render not implemented on fx9860g + row_print(1, 1, "Rendering functions"); + + if(test) + { + row_print(2, 1, "dclear: %s", printtime(time.clear)); + row_print(3, 1, "dupdate: %s", printtime(time.update)); + row_print(4, 1, "rect1: %s", printtime(time.rect1)); + row_print(5, 1, "rect2: %s", printtime(time.rect2)); + row_print(6, 1, "rect3: %s", printtime(time.rect3)); + } + + extern image_t opt_perf_render; + dimage(0, 56, &opt_perf_render); #endif #ifdef FXCG50 + row_title("Rendering functions"); row_print(1, 1, "This program measures the execution time of"); row_print(2, 1, "common drawing functions."); @@ -66,24 +89,19 @@ void gintctl_perf_render(void) if(test) { print(6, 90, "dclear:"); - print(6, 105, "%.1j ms", time.clear / 100); - print(6, 120, "%05x us", time.clear); + print(6, 105, "%s", printtime(time.clear)); print(83, 90, "dupdate:"); - print(83, 105, "%.1j ms", time.update / 100); - print(83, 120, "%05x us", time.update); + print(83, 105, "%s", printtime(time.update)); print(160, 90, "rect1:"); - print(160, 105, "%.1j ms", time.rect1 / 100); - print(160, 120, "%05x us", time.rect1); + print(160, 105, "%s", printtime(time.rect1)); print(237, 90, "rect2:"); - print(237, 105, "%.1j ms", time.rect2 / 100); - print(237, 120, "%05x us", time.rect2); + print(237, 105, "%s", printtime(time.rect2)); print(314, 90, "rect3:"); - print(314, 105, "%.1j ms", time.rect3 / 100); - print(314, 120, "%05x us", time.rect3); + print(314, 105, "%s", printtime(time.rect3)); } fkey_button(1, "START"); diff --git a/src/regs/regs.c b/src/regs/regs.c new file mode 100644 index 0000000..19b7945 --- /dev/null +++ b/src/regs/regs.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +#include + +void gintctl_regs(void) +{ + if(isSH3()) return; + + #ifdef FX9860G + #warning gintctl_regs not implemented on SH3 + #endif + + #define IPR(X) SH7305_INTC._->IPR##X.word + #define IMR(X) SH7305_INTC.MSK->IMR##X + + dclear(C_WHITE); + row_title("Register browser"); + + row_print(2, 1, "A:%04x B:%04x C:%04x", IPR(A), IPR(B), IPR(C)); + row_print(3, 1, "D:%04x E:%04x F:%04x", IPR(D), IPR(E), IPR(F)); + row_print(4, 1, "G:%04x H:%04x I:%04x", IPR(G), IPR(H), IPR(I)); + row_print(5, 1, "J:%04x K:%04x L:%04x", IPR(J), IPR(K), IPR(L)); + + dupdate(); + getkey(); + + dclear(C_WHITE); + row_title("Register browser"); + + row_print(2, 1, "0:%02x 1:%02x 2:%02x 3:%02x", + IMR(0), IMR(1), IMR(2), IMR(3)); + row_print(3, 1, "4:%02x 5:%02x 6:%02x 7:%02x", + IMR(4), IMR(5), IMR(6), IMR(7)); + row_print(4, 1, "8:%02x 9:%02x A:%02x B:%02x", + IMR(8), IMR(9), IMR(10), IMR(11)); + row_print(5, 1, "C:%02x", IMR(12)); + + dupdate(); + getkey(); +} diff --git a/src/util.c b/src/util.c index c71398f..01080be 100644 --- a/src/util.c +++ b/src/util.c @@ -19,10 +19,10 @@ #ifdef FX9860G #define ROW_X 1 #define ROW_W 6 -#define ROW_Y 8 +#define ROW_Y 0 #define ROW_YPAD 0 #define ROW_H 8 -#define ROW_COUNT 6 +#define ROW_COUNT 8 #endif /* FX9860G */ #ifdef FXCG50 @@ -54,7 +54,7 @@ void row_title(char const *format, ...) /* row_print(): Formatted printing in a predefined row */ void row_print(int row, int x, char const *format, ...) { - if(row < 1 || row > ROW_COUNT) return; + if(row < _(0,1) || row > ROW_COUNT) return; char str[80]; shortprint(str, format); @@ -70,7 +70,7 @@ void row_highlight(int row) int y2 = y1 + ROW_H; #ifdef FX9860G - drect(0, y1, 127, y2 - 1, C_INVERT); + drect(0, y1, 125, y2 - 1, C_INVERT); #endif #ifdef FXCG50 @@ -93,15 +93,15 @@ void row_right(int row, char const *character) } /* scrollbar(): Show a scrollbar */ -void scrollbar(int offset, int length) +void scrollbar(int offset, int length, int top, int bottom) { int area_x = _(127, 391); int area_width = _(1, 2); - int area_top = ROW_Y; - int area_height = ROW_H * ROW_COUNT; + int area_top = ROW_Y + ROW_H * (top - 1); + int area_height = ROW_H * (bottom - top); int bar_top = (offset * area_height) / length; - int bar_height = (ROW_COUNT * area_height) / length; + int bar_height = ((bottom - top) * area_height) / length; drect(area_x, area_top + bar_top, area_x + area_width - 1, area_top + bar_top + bar_height, C_BLACK);