summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve/screen/font.c
blob: ae0ac8865bb19e6387661f710ab7705598683897 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdlib.h>

#include "eve.h"
#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_strw(EVEFont *font, char *s) {
    uint16_t r = 0;

    while (*s) {
        r += font->w_ch[*s];
        s++;
    }

    return r;
}

uint16_t eve_font_bufw(EVEFont *font, char *buf, uint16_t buf_len) {
    int i;
    uint16_t r = 0;

    for (i=0; i<buf_len; i++) {
        r += font->w_ch[*(buf + i)];
    }

    return r;
}

uint8_t eve_font_h(EVEFont *font) {
    return font->h;
}