From e2f2cd904ff134b221a811c4b9dd5548789ff070 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 13 Jun 2023 22:25:02 +0100 Subject: Add bitmap font's put_text --- TODO.md | 8 +++----- src/data.h | 2 ++ src/text.c | 15 +++++++++++++++ src/text.h | 6 ++++++ 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 src/text.c create mode 100644 src/text.h diff --git a/TODO.md b/TODO.md index 35075cc..31c8dc3 100644 --- a/TODO.md +++ b/TODO.md @@ -1,15 +1,13 @@ # TODO -- drawing - - bitmap font -- entity system - - free/used lists - - player - map - importer - renderer - collision detection - deadly blocks +- entity system + - free/used lists + - player - hud - lives - score diff --git a/src/data.h b/src/data.h index 46e497f..d7f2f4c 100644 --- a/src/data.h +++ b/src/data.h @@ -4,5 +4,7 @@ /* embedded data */ extern const uint8_t binary_palette_start[]; extern const uint8_t binary_sprites_start[]; +extern const uint8_t binary_tiles_start[]; +extern const uint8_t binary_font_start[]; #endif /* _DATA_H */ diff --git a/src/text.c b/src/text.c new file mode 100644 index 0000000..c59b5e6 --- /dev/null +++ b/src/text.c @@ -0,0 +1,15 @@ +#include + +#include "vga.h" +#include "data.h" + +void put_text(uint16_t x, uint16_t y, const char *text) +{ + Rect dst = { x, y, 8, 8}; + + while (*text) + { + blit(binary_font_start + ((*text++ - ' ') << 6), &dst); + dst.x += 8; + } +} diff --git a/src/text.h b/src/text.h new file mode 100644 index 0000000..c43b199 --- /dev/null +++ b/src/text.h @@ -0,0 +1,6 @@ +#ifndef _TEXT_H +#define _TEXT_H + +void put_text(uint16_t x, uint16_t y, const char *text); + +#endif /* _TEXT_H */ -- cgit v1.2.3