diff --git a/include/core/std.h b/include/core/std.h index 9fc6b55..c5973cc 100644 --- a/include/core/std.h +++ b/include/core/std.h @@ -20,6 +20,9 @@ void *memset(void *dest, int byte, size_t n); /* strlen() - length of a NUL-terminated string */ size_t strlen(const char *str); +/* strncpy() - copy a string with a size limit*/ +char *strncpy(char *dst, const char *src, size_t n); + /* vsprintf() - an almost-empty subset of the real one */ void vsprintf(char *str, const char *format, va_list args); diff --git a/include/gint/drivers.h b/include/gint/drivers.h index 8a7394d..9814d28 100644 --- a/include/gint/drivers.h +++ b/include/gint/drivers.h @@ -12,16 +12,16 @@ // Driver procedure flow // // Drivers are initialized in priority order, and in linking order within -// the same priority (which is pretty much undefined). Make sure every +// the same priority level (pretty much undefined). Make sure every // driver's priority level is higher than those of its dependencies. // // At initialization, the following functions are called: -// 1. driver_sh3() [if not NULL, SH3 fx9860G only] +// 1. driver_sh3() [if not NULL, SH3 fx9860g only] // 2. ctx_save(sys_ctx) [if not NULL] // 3. init() [if not NULL] // // Then, if the on-screen boot log is enabled, the status() function is -// called and the returned function is displayed (21 characters max). +// called and the returned string is displayed (21 characters max). // 4. status() [if not NULL, if GINT_BOOT_LOG is defined] // // If the gint_switch() function is called to temporarily give back diff --git a/include/gint/gint.h b/include/gint/gint.h index 8162f27..fea9b73 100644 --- a/include/gint/gint.h +++ b/include/gint/gint.h @@ -9,7 +9,7 @@ /* GINT_VERSION - the library version number - gint is versioned from it's repository commits on the master branch. The + gint is versioned from its repository commits on the master branch. The GINT_VERSION integer contains the short commit hash. For instance, 0x03f7c0a0 means commit 3f7c0a0. */ diff --git a/src/core/bootlog.c b/src/core/bootlog.c index ed82f66..f825bc0 100644 --- a/src/core/bootlog.c +++ b/src/core/bootlog.c @@ -14,14 +14,19 @@ #include #include +#ifdef GINT_BOOT_LOG + #ifdef FXCG50 void Bdisp_AllClr_VRAM(void); void Bdisp_PutDisp_DD(void); - +void PrintXY(int x, int y, const char *str, int fg, int bg); #define dclear(c) Bdisp_AllClr_VRAM() #define dupdate() Bdisp_PutDisp_DD() #endif +/* A copy of the bootlog */ +GDATA char gint_bootlog[22*9] = { 0 }; + /* Linker script symbols - see core/start.c for details */ extern char brom, srom, @@ -38,13 +43,15 @@ static void print(int x, int y, const char *format, ...) vsprintf(str + 2, format, args); #ifdef FX9860G - dtext(6 * (x - 1) + 1, 7 * (y - 1), str + 2, color_black, color_white); + dtext(6 * (x-1) + 1, 7 * (y-1), str + 2, color_black, color_white); #endif #ifdef FXCG50 PrintXY(x, y, str, 0, 0); #endif + strncpy(gint_bootlog + 22 * (y-1) + (x-1), str + 2, 21 - (x-1)); + va_end(args); } @@ -90,7 +97,7 @@ void bootlog_loaded(void) /* bootlog_mapped() - ROM mapping stage */ GSECTION(".pretext") -void bootlog_mapped(int rom, int ram) +void bootlog_mapped(int rom, GUNUSED int ram) { /* Check whether all ROM is mapped */ uint32_t rom_size = (uint32_t)&srom; @@ -186,3 +193,5 @@ void bootlog_driver_summary(void) dupdate(); } + +#endif /* GINT_BOOT_LOG */ diff --git a/src/dma/dma.c b/src/dma/dma.c index bfe9589..546b5a4 100644 --- a/src/dma/dma.c +++ b/src/dma/dma.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/src/std/string.c b/src/std/string.c index 5478c28..804e29e 100644 --- a/src/std/string.c +++ b/src/std/string.c @@ -13,13 +13,20 @@ GWEAK size_t strlen(const char *str) return len; } +GWEAK char *strncpy(char *dst, const char *src, size_t n) +{ + size_t i = 0; + while(i < n && (dst[i] = src[i])) i++; + return dst; +} + /* vsprintf() - a trimmed-down version of the function - This function supports formats '%%', '%nd', '%nx' and '%s' where 'n' is a - 1-digit size, and is mandatory. For '%d' and '%x', '0' is always set. + This function supports formats '%%', '%d', '%x' and '%s' where 'n' is + a 1-digit size, and is mandatory. For '%d' and '%x', flag '0' is always set. Always outputs exactly the requested number of characters, even if it's not enough to completely print the value. Does whatever it wants if the format is invalid. This is really a basic - function to format output without needing 18 kB of code. */ + function to format output without needing 18 kB of fxlib code. */ GWEAK void vsprintf(char *str, const char *format, va_list args) { #define in() (c = *format++)