Searching for "final fantasy 4 nes font" eventually led me to
this site and this image:
I modified it a bit:
We can now load that bitmap, extract a character's area and print it on the emulator output:
Language: Avisynth
# create the font clip (1 frame, completely white, alpha layer is transparent where the FontMask image is black)
FontMask = ImageSource(path="FontMask.png", start=0, end=0).ConvertToRGB32
BlankClip(clip=FontMask, length=1, color=$FFFFFF)
Mask(clip=last, mask_clip=FontMask)
global Font = last
BlankClip(length=1, width=256, height=244, pixel_type="RGB32", fps=60, color=$000063) # the NES frame
Print_Index(last, 0, 0, 1)
function Print_Index(clip c, int x, int y, int i) {
src_x = (i % 5) * 16
src_y = (i / 5) * 16
Font.Crop(left=src_x, top=src_y, right=8, bottom=8)
Layer(base_clip=c, overlay_clip=last, x=x, y=y)
}
Printing a "char" instead of an "int" requires a conversion:
Language: Avisynth
function Print_Char(clip c, int x, int y, string s) {
Assert(StrLen(s) == 1, "Print_Char: '" + s + "' is not a character")
i = FindStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>-.abcdefghijklmnopqrstuvwxyz!?%/:", s) - 1
Assert(i >= 0, "Print_Char: character '" + s + "' is not in the font")
Print_Index(c, x, y, i)
}
Printing a string is done with a bit of recursion:
Language: Avisynth
function Print(clip c, int x, int y, string s) {
(StrLen(s) == 0) ? c : c.Print_Char(x, y, s.LeftStr(1)).Print(x + 8, y, MidStr(s, 2))
}
(This creates one additional frame per letter, but the overhead
should not be a problem, I guess.)
A decimal or hexadecimal number can be easily converted with the standard Avisynth string functions (see the installed manual files).
Reading values from a file can be done with
ConditionalReader (one variable per file). So the biggest problem for me would be writing a Lua script that writes the values into text files, because I don't know Lua scripting (in- or outside of emulators). :)