pokemon/font.cpp
Zack Buhman a56def6074 add font and text data
The original font is a bit of a mess, and includes many duplicate
characters.

I decided to reorganize the characters in a new set of glyphs, in
derivced/font.png.

This also includes very basic parsing for text data.
2023-07-30 03:09:20 +00:00

53 lines
1.4 KiB
C++

#include "font.hpp"
#include "vram.hpp"
#include "start_size.hpp"
#include "res/font.2bpp.h"
#include "font.hpp"
#include "control.hpp"
constexpr inline uint8_t ascii_to_font(uint8_t c)
{
if (c >= 'A' && c <= 'Z')
return (c - 'A') + 0;
if (c >= 'a' && c <= 'z')
return (c - 'a') + 32;
if (c >= '0' && c <= '9')
return (c - '0') + 64;
switch (c) {
case '!': return 0x1a;
case '(': return 0x1b;
case ')': return 0x1c;
case ',': return 0x1d;
case '-': return 0x1e;
case '.': return 0x1f;
case '/': return 0x3a;
case ':': return 0x3b;
case ';': return 0x3c;
case '?': return 0x3d;
case '[': return 0x3e;
case ']': return 0x3f;
case '`': return 0x5c; // ‘
case '\'':return 0x5d; // ’
case '^': return 0x5e; // “
case '"': return 0x5f; // ”
case extended_t::e: return 0x4a; // é
case extended_t::ellipsis: return 0x65; // …
case extended_t::pk: return 0x72; // ᴾₖ
case extended_t::mn: return 0x73; // ᴹₙ
case extended_t::jpy: return 0x78; // ¥
case extended_t::times: return 0x79; // ×
default: return 0x7e; // "invalid" character
}
}
uint32_t load_font(uint32_t top)
{
static start_size_t start_size = {
reinterpret_cast<uint8_t*>(&_binary_res_font_2bpp_start),
reinterpret_cast<uint32_t>(&_binary_res_font_2bpp_size),
};
return cell_data(start_size, top);
}