aboutsummaryrefslogtreecommitdiff
path: root/fmdsp/font_rom.c
diff options
context:
space:
mode:
Diffstat (limited to 'fmdsp/font_rom.c')
-rw-r--r--fmdsp/font_rom.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fmdsp/font_rom.c b/fmdsp/font_rom.c
new file mode 100644
index 0000000..de6bc19
--- /dev/null
+++ b/fmdsp/font_rom.c
@@ -0,0 +1,24 @@
+#include "font.h"
+
+static const void *font_rom_get(const struct fmdsp_font *font,
+ uint16_t jis, enum fmdsp_font_type type) {
+ const uint8_t *fontdata = font->data;
+ const uint8_t *fontptr;
+ if (type == FMDSP_FONT_ANK) {
+ fontptr = fontdata + 0x800 + (jis<<4);
+ } else {
+ uint8_t row = jis >> 8;
+ uint8_t cell = jis;
+ fontptr = fontdata + (0x800 + (0x60*16*2*(row-0x20)) + (cell<<5));
+ if (type == FMDSP_FONT_JIS_RIGHT) fontptr += 16;
+ }
+ if ((fontptr + (16*16/8)) > (fontdata + FONT_ROM_FILESIZE)) fontptr = 0;
+ return fontptr;
+}
+
+void fmdsp_font_from_font_rom(struct fmdsp_font *font, const void *data) {
+ font->data = data;
+ font->width_half = 8;
+ font->height = 16;
+ font->get = font_rom_get;
+}