diff --git a/build.sh b/build.sh index fa12b6b..6a0adb0 100755 --- a/build.sh +++ b/build.sh @@ -40,7 +40,12 @@ build_n64 () { if [ "$FORCE_CLEAN" = true ]; then make clean fi - make all -j USER_FLAGS="$USER_FLAGS -DGIT_BRANCH='$GIT_BRANCH' -DGIT_TAG='$GIT_TAG' -DGIT_SHA='$GIT_SHA' -DGIT_MESSAGE='$GIT_MESSAGE'" + N64_FLAGS="$USER_FLAGS" + if [ ! -z "${GIT_BRANCH+x}" ]; then N64_FLAGS+=" -DGIT_BRANCH='\"$GIT_BRANCH\"'"; fi + if [ ! -z "${GIT_TAG+x}" ]; then N64_FLAGS+=" -DGIT_TAG='\"$GIT_TAG\"'"; fi + if [ ! -z "${GIT_SHA+x}" ]; then N64_FLAGS+=" -DGIT_SHA='\"$GIT_SHA\"'"; fi + if [ ! -z "${GIT_MESSAGE+x}" ]; then N64_FLAGS+=" -DGIT_MESSAGE='\"$GIT_MESSAGE\"'"; fi + make all -j USER_FLAGS="$N64_FLAGS" popd > /dev/null BUILT_N64=true diff --git a/sw/n64/src/exception.c b/sw/n64/src/exception.c index ef07192..72c9db7 100644 --- a/sw/n64/src/exception.c +++ b/sw/n64/src/exception.c @@ -145,9 +145,23 @@ static void exception_init_screen (void) { io_write(&VI->CR, cfg->CR); } -static void exception_draw_character (int x, int y, char c) { +static void exception_draw_character (char c) { + static int x = BORDER_WIDTH + (START_X_OFFSET * FONT_WIDTH); + static int y = BORDER_HEIGHT; + + if (c == '\n') { + x = BORDER_WIDTH; + y += LINE_HEIGHT; + return; + } + + if ((x + FONT_WIDTH) > (SCREEN_WIDTH - BORDER_WIDTH)) { + x = BORDER_WIDTH; + y += LINE_HEIGHT; + } + if ((c < ' ') || (c > '~')) { - c = 127; + c = '\x7F'; } for (int i = 0; i < (FONT_WIDTH * FONT_HEIGHT); i++) { @@ -163,25 +177,13 @@ static void exception_draw_character (int x, int y, char c) { io_write(&exception_framebuffer[screen_offset], FOREGROUND_COLOR); } } + + x += FONT_WIDTH; } static void exception_print_string (const char *s) { - static int x = BORDER_WIDTH + (START_X_OFFSET * FONT_WIDTH); - static int y = BORDER_HEIGHT; - while (*s != '\0') { - if (*s == '\n') { - x = BORDER_WIDTH; - y += LINE_HEIGHT; - s++; - } else { - if (x + FONT_WIDTH > (SCREEN_WIDTH - BORDER_WIDTH)) { - x = BORDER_WIDTH; - y += LINE_HEIGHT; - } - exception_draw_character(x, y, *s++); - x += FONT_WIDTH; - } + exception_draw_character(*s++); } } @@ -233,7 +235,8 @@ void exception_fatal_handler (uint32_t exception_code, uint32_t interrupt_mask, exception_init_screen(); exception_print("----- SummerCart64 n64boot -----\n"); - exception_print("branch: %s | tag: %s\n", version->git_branch, version->git_tag); + exception_print("branch: %s\n", version->git_branch); + exception_print("tag: %s\n", version->git_tag); exception_print("sha: %s\n", version->git_sha); exception_print("msg: %s\n\n", version->git_message); exception_print("%s at pc: 0x%08lX\n", exception_get_description(exception_code), e->epc.u32); diff --git a/sw/n64/src/version.c b/sw/n64/src/version.c index a535680..1f1b0ef 100644 --- a/sw/n64/src/version.c +++ b/sw/n64/src/version.c @@ -1,15 +1,27 @@ #include "version.h" -#define STR(x...) #x -#define XSTR(s) STR(s) - - version_t version = { - .git_branch = XSTR(GIT_BRANCH), - .git_tag = XSTR(GIT_TAG), - .git_sha = XSTR(GIT_SHA), - .git_message = XSTR(GIT_MESSAGE), +#ifdef GIT_BRANCH + .git_branch = GIT_BRANCH, +#else +#warning "No GIT_BRANCH provided" +#endif +#ifdef GIT_TAG + .git_tag = GIT_TAG, +#else +#warning "No GIT_TAG provided" +#endif +#ifdef GIT_SHA + .git_sha = GIT_SHA, +#else +#warning "No GIT_SHA provided" +#endif +#ifdef GIT_MESSAGE + .git_message = GIT_MESSAGE, +#else +#warning "No GIT_MESSAGE provided" +#endif };