From 1df402f35da3534787e3345905884f6f7c8d715f Mon Sep 17 00:00:00 2001 From: Aurora Date: Thu, 24 Mar 2016 16:27:03 +0100 Subject: [PATCH] Misc stuff --- source/draw.c | 29 ++++++++++++----------------- source/installer.c | 5 ++--- source/main.c | 8 -------- source/start.s | 6 ++---- source/utils.h | 2 +- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/source/draw.c b/source/draw.c index 9c64ec6..67f34b4 100644 --- a/source/draw.c +++ b/source/draw.c @@ -11,29 +11,25 @@ static const struct fb { u8 *bottom; } *const fb = (struct fb *)0x23FFFE00; -static int strlen(const char *string) -{ +static int strlen(const char *string){ char *stringEnd = (char *)string; - while (*stringEnd) stringEnd++; + while(*stringEnd) stringEnd++; return stringEnd - string; } -void clearScreens(void) -{ +void clearScreens(void){ memset32(fb->top_left, 0, 0x46500); memset32(fb->top_right, 0, 0x46500); memset32(fb->bottom, 0, 0x38400); } -void drawCharacter(char character, int pos_x, int pos_y, u32 color) -{ - u8 *select = fb->top_left; +void drawCharacter(char character, int pos_x, int pos_y, u32 color){ + u8 *const select = fb->top_left; - for (int y = 0; y < 8; y++) { + for(int y = 0; y < 8; y++){ unsigned char char_pos = font[character * 8 + y]; - for (int x = 7; x >= 0; x--) { - // I'll just assume both screens have the same height. + for(int x = 7; x >= 0; x--){ int screen_pos = (pos_x * SCREEN_TOP_HEIGHT * 3 + (SCREEN_TOP_HEIGHT - y - pos_y - 1) * 3) + (7 - x) * 3 * SCREEN_TOP_HEIGHT; if ((char_pos >> x) & 1) { @@ -45,20 +41,19 @@ void drawCharacter(char character, int pos_x, int pos_y, u32 color) } } -int drawString(const char *string, int pos_x, int pos_y, u32 color) -{ +int drawString(const char *string, int pos_x, int pos_y, u32 color){ int length = strlen(string); - for (int i = 0, line_i = 0; i < length; i++, line_i++) { - if (string[i] == '\n') { + for(int i = 0, line_i = 0; i < length; i++, line_i++){ + if(string[i] == '\n'){ pos_y += SPACING_VERT; line_i = 0; i++; - } else if (line_i >= (SCREEN_TOP_WIDTH - pos_x) / SPACING_HORIZ) { + } else if(line_i >= (SCREEN_TOP_WIDTH - pos_x) / SPACING_HORIZ){ // Make sure we never get out of the screen. pos_y += SPACING_VERT; line_i = 2; // Little offset so we know the same string continues. - if (string[i] == ' ') i++; // Spaces at the start look weird + if(string[i] == ' ') i++; // Spaces at the start look weird } drawCharacter(string[i], pos_x + line_i * SPACING_HORIZ, pos_y, color); diff --git a/source/installer.c b/source/installer.c index 070073d..1801c36 100755 --- a/source/installer.c +++ b/source/installer.c @@ -27,9 +27,8 @@ static void installStage2(u32 mode){ if(!mode){ pos_y = drawString("You are about to update stage2 only", 10, pos_y + 10, COLOR_RED); pos_y = drawString("Doing this could brick your console!", 10, pos_y, COLOR_RED); - pos_y = drawString("If you would like to continue, enter:", 10, pos_y, COLOR_WHITE); - pos_y = drawString(", , , ,", 10, pos_y, COLOR_WHITE); - pos_y = drawString(", ,