diff --git a/menu.cpp b/menu.cpp index 33e5c3b..90c115e 100644 --- a/menu.cpp +++ b/menu.cpp @@ -360,7 +360,10 @@ void substrcpy(char *d, char *s, char idx) *d++ = *s; if (*s == ',') + { + if (p == idx) break; p++; + } s++; } diff --git a/user_io.cpp b/user_io.cpp index fdceab9..7f24e91 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -1641,6 +1641,24 @@ void user_io_file_tx_write(const uint8_t *addr, uint16_t len) DisableFpga(); } +static void show_core_info(int info_n) +{ + int i = 2; + while (1) + { + char *p = user_io_get_confstr(i++); + if (!p) break; + + if (p[0] == 'I') + { + static char str[256]; + substrcpy(str, p, info_n); + if (strlen(str)) Info(str); + break; + } + } +} + static int process_ss(const char *rom_name) { static char ss_name[1024] = {}; @@ -1931,34 +1949,26 @@ void user_io_read_confstr() char *user_io_get_confstr(int index) { - unsigned char i, lidx = 0, j = 0; - static char buffer[128 + 1]; // max 128 bytes per config item - // clear buffer - buffer[0] = 0; - int pos = 0; + int lidx = 0; + static char buffer[(1024*2) + 1]; // max bytes per config item - i = cfgstr[pos++]; - while (i && (j < sizeof(buffer))) + char *start = cfgstr; + while (lidx < index) { - if (i == ';') - { - if (lidx == index) buffer[j++] = 0; - lidx++; - } - else - { - if (lidx == index) buffer[j++] = i; - } - - i = cfgstr[pos++]; + start = strchr(start, ';'); + if (!start) return NULL; + start++; + lidx++; } - // if this was the last string in the config string list, then it still - // needs to be terminated - if (lidx == index) buffer[j] = 0; + char *end = strchr(start, ';'); + int len = end ? end - start : strlen(start); + if (!len) return NULL; - // also return NULL for empty strings - return buffer[0] ? buffer : NULL; + if ((uint32_t)len > sizeof(buffer) - 1) len = sizeof(buffer) - 1; + memcpy(buffer, start, len); + buffer[len] = 0; + return buffer; } uint32_t user_io_8bit_set_status(uint32_t new_status, uint32_t mask, int ex) @@ -3005,7 +3015,8 @@ void user_io_poll() keyboard_leds = leds; - + uint8_t info_n = spi_uio_cmd(UIO_INFO_GET); + if (info_n) show_core_info(info_n); } if (!res_timer) diff --git a/user_io.h b/user_io.h index 728d799..ed7726a 100644 --- a/user_io.h +++ b/user_io.h @@ -74,6 +74,7 @@ #define UIO_SET_GAMCURV 0x33 // Set Gamma curve #define UIO_CD_GET 0x34 #define UIO_CD_SET 0x35 +#define UIO_INFO_GET 0x36 // codes as used by 8bit for file loading from OSD #define UIO_FILE_TX 0x53