# HG changeset patch # User Paul Boddie # Date 1541717376 -3600 # Node ID 309b07bc17b8b43a56b25c1d951f753289b3cae2 # Parent ac6df9915caed1b5745cea6b2b2866e5a9d5692b Wrap the text properly when filling the screen with characters. diff -r ac6df9915cae -r 309b07bc17b8 examples/vga/main.c --- a/examples/vga/main.c Thu Nov 08 23:40:26 2018 +0100 +++ b/examples/vga/main.c Thu Nov 08 23:49:36 2018 +0100 @@ -339,6 +339,7 @@ static void write_chars(void) { + const int line_height = 9; int x = 0, y = 0; char c; @@ -347,16 +348,21 @@ font_config.base = fontbase; font_config.limit = fontlimit; - while (y < display_config.line_count) + while (y + line_height < display_config.line_count) + { for (c = (char) font_config.base; c < (char) font_config.limit; c++) { - x = write_char(&display_config, &font_config, c, x, y, 0xff); - - if (x > display_config.line_length) + if (x + get_char_definition(&font_config, c)->width > display_config.line_length) { - x = 0; y += 9; + x = 0; y += line_height; } + + if (y + line_height >= display_config.line_count) + break; + + x = write_char(&display_config, &font_config, c, x, y, 0xff); } + } } /* Set up a background. */