From 664ffe979ca9954ff64386fca4af930446d694dd Mon Sep 17 00:00:00 2001 From: rxi Date: Sat, 14 Jun 2014 14:14:09 +0100 Subject: [PATCH] Moved graphics_initDefaultFont functionality -> font_initEmbedded --- src/font.c | 18 ++++++++++++++++++ src/font.h | 1 + src/graphics.c | 17 +---------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/font.c b/src/font.c index 2b60566..def0cf2 100644 --- a/src/font.c +++ b/src/font.c @@ -22,6 +22,24 @@ const char *font_init(font_t *self, const char *filename) { } +const char *font_initEmbedded(font_t *self) { + #include "font_embedded.c" + memset(self, 0, sizeof(*self)); + image_initBlank(&self->image, font_width, font_height); + int i, j; + char *p = font_data; + for (i = 0; i < font_width * font_height; i += 8) { + for (j = 0; j < 8; j++) { + int res = (*p >> j) & 1; + self->image.data[i + j] = res ? 0xf : 0x00; + self->image.mask[i + j] = res ? 0x0 : 0xff; + } + p++; + } + return NULL; +} + + void font_deinit(font_t *self) { image_deinit(&self->image); } diff --git a/src/font.h b/src/font.h index 815fafa..44eb75a 100644 --- a/src/font.h +++ b/src/font.h @@ -16,6 +16,7 @@ typedef struct { } font_t; const char *font_init(font_t *self, const char *filename); +const char *font_initEmbedded(font_t *self); void font_deinit(font_t *self); void font_blit(font_t *self, pixel_t *buf, int bufw, int bufh, const char *str, int dx, int dy); diff --git a/src/graphics.c b/src/graphics.c index d2dbbb3..ead1b58 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -24,25 +24,10 @@ font_t *graphics_font = &graphics_defaultFont; int graphics_flip = 0; -static void graphics_initDefaultFont(void) { - #include "font_embedded.c" - image_initBlank(&graphics_defaultFont.image, font_width, font_height); - int i, j; - char *p = font_data; - for (i = 0; i < font_width * font_height; i += 8) { - for (j = 0; j < 8; j++) { - int res = (*p >> j) & 1; - graphics_defaultFont.image.data[i + j] = res ? 0xf : 0x00; - graphics_defaultFont.image.mask[i + j] = res ? 0x0 : 0xff; - } - p++; - } -} - void graphics_init(void) { image_initBlank(&graphics_screen, VGA_WIDTH, VGA_HEIGHT); - graphics_initDefaultFont(); + font_initEmbedded(&graphics_defaultFont); }