[Fangames] What are you working on?

Yup. Preview of documentation:

The data for each glyph is a 72-byte struct, with an 8-byte header and 64 bytes of bitmap data - 16x16 pixels (even if the character isn’t that wide) x 2 bits, oriented left-to-right, then top-to-bottom (so the first 4 bytes are the top row). The header is a pointer followed by four single-byte values: a “code page” number, the width of the glyph, and two more values (might not actually be used, or maybe I already figured them out and forgot them again). The pointer is used only for the shift-JIS encoding, to make a linked list of glyphs for a “group” of characters using the same second byte in the character encoding; the “code page” byte is compared against the first byte, and the linked list is searched until a match is found. (The code is set up to theoretically support multiple languages in the same build, even in the US English-only version.) Also there are tables that I’ll just call “font maps” that are basically just arrays of 256 pointers to glyph structs; for ASCII it’s a straight lookup, for shift-JIS it subtracts 0x40 first (because the second byte of a 2-byte shift-JIS sequence is at least 0x40) and then whatever glyph it finds from there is the start of the linked list. Basically, it’s complicated and ugly hax that I’d like to redesign (but there are higher priorities).

For an example glyph you can look at, there’s an exclamation mark encoded at 0xB89B40. Oh, and you know those 0x1f codes that seem not to do anything? They’re essentially just ordinary characters that have zero width (but if you have them in cutscene text, and you haven’t set text speed to max, they’ll still cause bloops to play). So there’s that.

Anyway, the game font really only uses 3 colours of the 4 that 2bpp makes available: ‘main’, ‘shadow’ and ‘background’. The way you’d set up fake boldface is to draw a font that uses all four colours (call them ‘dark’, ‘mid’, ‘light’ and ‘background’) and then set up two 2bpp->4bpp mappings: one that makes ‘dark’ and ‘mid’ go to one palette index and ‘light’ to another, and another that makes ‘mid’ go to the same palette index as ‘light’. (The “normal” speech bubble text setup uses indices 6 and 7, with background as 0; red text uses 14 and 15 with background as 0; world map text uses 14 and 15 with background as 4 - super weird shit!)

3 Likes