Page 1 of 1

X16 Font Editor (in BASIC!)

Posted: Sun Oct 01, 2023 7:06 am
by voidstar
This is a utility to help make custom fonts from within BASIC.

In the TryItNow, press "Q" to import a sample modified font. [waiting for web emulator to update to R45 ROMs]

The fonts can be SAVED and LOADED, and also EXPORTED to a BASIC text file that has the VPOKE code needed to prepare the font.

The screen is divided into three parts.

Top left is the full current CharacterSet as stored in VRAM (indexed by "display codes"). You can select these characters using WASD to navigate.

Top right is a "zoom" of the currently selected character font. You use the arrow keys to navigate around these bits and spacebar to toggle bits.

You can also INVERT bits (along column or rows or both), Copy (sorry had to use K for Copy since I implemented Clear first and used C for that), or Clear/Set all the bits.

For now SAVE the filenames are fixed. An asterisk appears on rows that you've modified but have not yet SAVED (V).

For EXPORT, I have is export to a different file for each 16 character row (so you'll end up with FONT 1.BAS, FONT 2.BAS, on up to FONT 16.BAS corresponding to these rows). If you only need a few custom characters, then grab whichever file contains those (and try to keep the custom fonts clustered near each other).

The bottom portion of the screen is the "PRINT CODES" which is how the font will appear when using BASIC PRINT statements (like PRINT "ABC" or PRINT CHR(70) ). BASIC has its own decisions on how it translates characters into DISPLAY CODES. And some PRINT codes are "non-printable" in that they get reinterpreted to do actions (HOME or CLEAR SCREEN or move cursor) or change colors. These are the first 32-characters of each "half" of the character set. You can still print a symbol correspond to these by output of CHR$($80) prior to using these normally-non-printable characters.

Working with DISPLAY CODES can get annoying in BASIC, so it's nice to see how you can make use of a custom font just using regular BASIC PRINT statements. In the screenshot, for example, notice how DisplayCode $4C corresponds to CHR$ code of $CC.


Showing these DISPLAY CODES from within BASIC required some POKE tricks that are near the end of the source code.

BASLOAD was used for this project also. So the .BAS is actually a text file, not a tokenized BASIC file. BASLOAD is available in the X16 download section. But if you load the PRG (which is the tokenized version), do a REN (renumber), and re-save -- you can get a tokenized BASIC source that way also.

V1.1:
- Fixed formatting issue in revised export
- Swap order of the PRINT-CODES (col/row order) and removed the [ ]'s to make it more concise
- Think fixed bug where INPUT during K-Copy operation would bleed into a keyboard scan code of main loop (making some indexes unable to be copied)

V1.2:
- Added "YGHJ feature" where you can press YGHJ to shift the bits UP,LEFT,DOWN,RIGHT (so you can copy an existing font, then quickly shift it around to adjust the position)
- Copy (K) no longer using INPUT (was causing issues); now uses its own custom input function
- N=xx at the top now shows your current working DisplayCode row (making it easier to know what N equals when doing SAVE/LOAD)
- Few other cosmetic updates to show HELP (and after SAVE/LOAD, "ST=" shows the result of the OPEN, should be ST=0 if all OK)
- PrintCodes now shift by 64 instead of 8 (full screen at a time instead of just one row at a time)

v1.3:
- Another re-arrangement to how print-codes are shown (16 wide, to better match the DisplayCode section)
- The "non-printable" print-codes are shown as gray (instead of ".") as reminders that they can actually be printed (but must be prefixed with CHR$($80), so they'll be slower to use)
- Fixed bug in CHR$(34) double quote output
- Some re-arrangement in the help; and "B" can now be used to toggle between two background colors (blue and black for now), in case it helps for certain monitors on visualizing the fonts

v1.4: updated for R45
- using new TILE command for a little faster load up
- new Z and Q commands to "export" and "import" the entire font (import uses BVLOAD and is incredibly fast at loading an entire font set)
- change display-code from hex back to decimal, to be easier to use with the K-COPY command (which uses dec)


Try It Now!

Re: X16 Font Editor (in BASIC!)

Posted: Fri Oct 11, 2024 9:07 am
by schristis
This is a REALLY nice font editor lol.... Now that I know about lt HAHa .... :idea: