diff --git a/CMakeLists.txt b/CMakeLists.txt index dce6aad..74b20e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,9 +26,10 @@ set(SOURCES src/gint/dsp.s src/gint/dump.c src/gint/gray.c + src/gint/image.c src/gint/keyboard.c src/gint/kmalloc.c - src/gint/image.c + src/gint/overclock.c src/gint/ram.c src/gint/rtc.c src/gint/spuram.c diff --git a/include/gintctl/gint.h b/include/gintctl/gint.h index c87f3a5..9bd00f3 100644 --- a/include/gintctl/gint.h +++ b/include/gintctl/gint.h @@ -26,6 +26,9 @@ void gintctl_gint_drivers(void); /* gintctl_gint_tlb(): TLB miss handler and TLB management */ void gintctl_gint_tlb(void); +/* gintctl_gint_overclock(): Clock speed detection and setting */ +void gintctl_gint_overclock(void); + /* gintct_gint_keyboard: Real-time keyboard visualization */ void gintctl_gint_keyboard(void); diff --git a/src/gint/image.c b/src/gint/image.c index e3e3b93..a67e7b2 100644 --- a/src/gint/image.c +++ b/src/gint/image.c @@ -156,13 +156,7 @@ static void scene_2(void) int cx2=cx1, cy2=cy1; image_rotate_around_scale(train, 1.4, 1.3*65536, true, &cx2, &cy2, &map); - int new_format = - IMAGE_IS_RGB16(train->format) ? IMAGE_RGB565A : IMAGE_P8_RGB565A; - image_t *tmp = image_alloc(map.dst_w, map.dst_h, new_format); - image_copy_palette(train, tmp, -1); - image_clear(tmp); - - image_linear(train, tmp, &map); + image_t *tmp = image_linear_alloc(train, &map); image_copy(tmp, image_at(vram, 10, 10), true); dprint(4, 116, C_BLACK, "Center: %d %d -> %d %d", cx1, cy1, cx2, cy2); diff --git a/src/gint/overclock.c b/src/gint/overclock.c new file mode 100644 index 0000000..ec91cc1 --- /dev/null +++ b/src/gint/overclock.c @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#ifdef FXCG50 + +#define CPG SH7305_CPG +#define BSC SH7305_BSC + +char const *level_string(int level) +{ + static char str[32]; + + if(level == CLOCK_SPEED_UNKNOWN) + return "UNKNOWN"; + if(level == CLOCK_SPEED_F1) + return "Ftune's F1"; + if(level == CLOCK_SPEED_F2) + return "Ftune's F2"; + if(level == CLOCK_SPEED_F3) + return "Ftune's F3"; + if(level == CLOCK_SPEED_F4) + return "Ftune's F4"; + if(level == CLOCK_SPEED_F5) + return "Ftune's F5"; + + snprintf(str, 32, "", level); + return str; +} + +static int callback(volatile int *counter, volatile int *update) +{ + (*counter)++; + *update = 1; + return TIMER_CONTINUE; +} + +void gintctl_gint_overclock(void) +{ + int key = 0; + volatile int counter = 0; + volatile int update = 0; + + int t = timer_configure(TIMER_TMU, 100000, + GINT_CALL(callback, &counter, &update)); + if(t >= 0) + timer_start(t); + + while(key != KEY_EXIT) { + int level = clock_get_speed(); + + uint32_t time_dclear = prof_exec({ + dclear(C_WHITE); + }); + row_title("Clock speed detection and setting"); + + row_print( 1, 29, "FLLFRQ:"); + row_print( 2, 29, "FRQCR:"); + row_print( 3, 29, "CS0BCR:"); + row_print( 4, 29, "CS2BCR:"); + row_print( 5, 29, "CS3BCR:"); + row_print( 6, 29, "CS5aBCR:"); + row_print( 7, 29, "CS0WCR:"); + row_print( 8, 29, "CS2WCR:"); + row_print( 9, 29, "CS3WCR:"); + row_print(10, 29, "CS5aWCR:"); + + row_print( 1, 38, "0x%08x", CPG.FLLFRQ.lword); + row_print( 2, 38, "0x%08x", CPG.FRQCR.lword); + row_print( 3, 38, "0x%08x", BSC.CS0BCR.lword); + row_print( 4, 38, "0x%08x", BSC.CS2BCR.lword); + row_print( 5, 38, "0x%08x", BSC.CS3BCR.lword); + row_print( 6, 38, "0x%08x", BSC.CS5ABCR.lword); + row_print( 7, 38, "0x%08x", BSC.CS0WCR.lword); + row_print( 8, 38, "0x%08x", BSC.CS2WCR.lword); + row_print( 9, 38, "0x%08x", BSC.CS3WCR.lword); + row_print(10, 38, "0x%08x", BSC.CS5AWCR.lword); + + row_print(1, 1, "Detected level: %s", level_string(level)); + row_print(2, 1, "dclear(): %d us", time_dclear); + if(t >= 0) + row_print(3, 1, "Timer: %.1D s", counter); + else + row_print(3, 1, "Timer: none available"); + + fkey_button(1, "Set: F1"); + fkey_button(2, "Set: F2"); + fkey_button(3, "Set: F3"); + fkey_button(4, "Set: F4"); + fkey_button(5, "Set: F5"); + dupdate(); + + key = getkey_opt(GETKEY_DEFAULT, &update).key; + update = 0; + + if(key == KEY_F1) clock_set_speed(CLOCK_SPEED_F1); + if(key == KEY_F2) clock_set_speed(CLOCK_SPEED_F2); + if(key == KEY_F3) clock_set_speed(CLOCK_SPEED_F3); + if(key == KEY_F4) clock_set_speed(CLOCK_SPEED_F4); + if(key == KEY_F5) clock_set_speed(CLOCK_SPEED_F5); + } + + if(t >= 0) + timer_stop(t); +} + +#endif diff --git a/src/gintctl.c b/src/gintctl.c index 66d4717..a44771c 100644 --- a/src/gintctl.c +++ b/src/gintctl.c @@ -43,6 +43,9 @@ struct menu menu_gint = { { "Memory dump", gintctl_gint_dump, 0 }, { "Drivers and worlds", gintctl_gint_drivers, 0 }, { "TLB management", gintctl_gint_tlb, 0 }, + #ifdef FXCG50 + { "Overclocking", gintctl_gint_overclock, MENU_SH4_ONLY }, + #endif { "Memory allocation", gintctl_gint_kmalloc, 0 }, { "Keyboard", gintctl_gint_keyboard, 0 }, { "Timers", gintctl_gint_timer, 0 },