summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve/screen
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-06-12 00:51:04 +0200
committerUros Majstorovic <majstor@majstor.org>2020-06-12 00:51:04 +0200
commite5fcdeda041831cb326f1d1963c0651b78041788 (patch)
tree3763f5c596b068ec7b3a71c1db02f6c9936a3bcb /code/fe310/eos/eve/screen
parent6d868629c96f53358f1b7e2f6ac687d7b7195b35 (diff)
implemented font metrics
Diffstat (limited to 'code/fe310/eos/eve/screen')
-rw-r--r--code/fe310/eos/eve/screen/font.c9
-rw-r--r--code/fe310/eos/eve/screen/font.h3
2 files changed, 10 insertions, 2 deletions
diff --git a/code/fe310/eos/eve/screen/font.c b/code/fe310/eos/eve/screen/font.c
index 26e7cf0..1be462d 100644
--- a/code/fe310/eos/eve/screen/font.c
+++ b/code/fe310/eos/eve/screen/font.c
@@ -4,14 +4,21 @@
#include "font.h"
void eve_font_init(EVEFont *font, uint8_t font_id) {
+ uint32_t p;
+
+ p = eve_read32(EVE_ROM_FONT_ADDR);
+ p += (148 * (font_id - 16));
font->id = font_id;
+ font->w = eve_read32(p + 136);
+ font->h = eve_read32(p + 140);
+ eve_readb(p, font->w_ch, 128);
}
uint16_t eve_font_string_width(EVEFont *font, char *s) {
uint16_t r = 0;
while (*s) {
- r += font->w[*s];
+ r += font->w_ch[*s];
s++;
}
return r;
diff --git a/code/fe310/eos/eve/screen/font.h b/code/fe310/eos/eve/screen/font.h
index 24b745e..a46c942 100644
--- a/code/fe310/eos/eve/screen/font.h
+++ b/code/fe310/eos/eve/screen/font.h
@@ -2,8 +2,9 @@
typedef struct EVEFont {
uint8_t id;
- uint8_t w[128];
+ uint8_t w;
uint8_t h;
+ uint8_t w_ch[128];
} EVEFont;
void eve_font_init(EVEFont *font, uint8_t font_id);