summaryrefslogtreecommitdiff
path: root/stage3/font.c
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2022-10-07 18:05:02 +0200
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2022-10-07 18:05:02 +0200
commit8b9f33dd745ebba0e819927ab3906635bfb3bf34 (patch)
treeb76b534f7846ae3d47638d42b0a15d37e4896ac9 /stage3/font.c
parent1155e97dab101fd1215e12ff8737048b0f6bedaf (diff)
downloadcuddles-8b9f33dd745ebba0e819927ab3906635bfb3bf34.tar.xz
Implement fully ascii printing
Diffstat (limited to 'stage3/font.c')
-rw-r--r--stage3/font.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/stage3/font.c b/stage3/font.c
index c9ef520..5933c14 100644
--- a/stage3/font.c
+++ b/stage3/font.c
@@ -1,28 +1,28 @@
#include "font.h"
+#include "letters.h"
#include "gfx.h"
-#define FONT_SIZE 3
+#define FONT_SIZE 2
-static const u16 outer_width = (CHAR_WIDTH + 2) * FONT_SIZE;
-static const u16 outer_height = (CHAR_HEIGHT + 2) * FONT_SIZE;
+static const u16 outer_width = (LETTER_WIDTH + 2) * FONT_SIZE;
+static const u16 outer_height = (LETTER_HEIGHT + 2) * FONT_SIZE;
-extern u8 letters['z' - 'a' + 1][CHAR_HEIGHT * CHAR_WIDTH];
+static u16 cursor_x = 0;
+static u16 cursor_y = 0;
-static u16 line_count = 0;
-
-static void print_chr(u16 at_x, u16 at_y, char c)
+static void print_chr(u16 at_x, u16 at_y, u8 c)
{
u16 base_x = at_x * outer_width;
u16 base_y = at_y * outer_height;
- gfx_set_area(base_x, base_y, outer_width, outer_height, 0xFF000000);
+ //gfx_set_area(base_x, base_y, outer_width, outer_height, 0xFF000000);
- if (c > 'z' || c < 'a')
+ if (c > 127)
return;
- for (u16 x = 0; x < CHAR_WIDTH; x++)
- for (u16 y = 0; y < CHAR_HEIGHT; y++) {
- if (!letters[c - 'a'][y * CHAR_WIDTH + x])
+ for (u16 x = 0; x < LETTER_WIDTH; x++)
+ for (u16 y = 0; y < LETTER_HEIGHT; y++) {
+ if (!letters[c].data[y * LETTER_WIDTH + x])
continue;
gfx_set_area(
@@ -32,11 +32,12 @@ static void print_chr(u16 at_x, u16 at_y, char c)
}
}
-void print(char *line)
+void println(char *line)
{
- for (u16 x = 0; *line != '\0'; ++x, ++line)
- print_chr(x, line_count, *line);
+ for (; *line != '\0'; ++cursor_x, ++line)
+ print_chr(cursor_x, cursor_y, *line);
- line_count++;
+ cursor_y++;
+ cursor_x = 0;
}