Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .---------------------------------------------------.
- ( A P P E N D I X A . U S E C U S T O M F O N T S )
- `---------------------------------------------------ยด
- general contents: pastebin.com/hmpJmurr
- o==========o
- | CONTENTS |
- o==========o
- A. General
- 1. Procedure
- 2. Example using VIC bank 0
- 3. Example using VIC bank 2
- 4. Example using VIC bank 3
- B. BASIC
- C. Assembly
- X. References
- o============o
- | A. General |
- o============o
- Summary: use DD00_hex to set bank number. Set scr RAM (char pos) and char RAM with D018_hex. Set input pointer in 0288_hex.
- 1. Procedure
- ~~~~~~~~~~~~
- a. Open file w/ hex editor to determine high byte/low byte of place where font will be loaded into memory.
- b. If needed use Hex editor to change that mem. position to fit your configuration.
- c. If needed change VIC bank w/ DD00_hex (set write access to this register with DD02_hex).
- d. Configure VIC bank for custom font/character RAM. Use register D018_hex.
- e. Don't forget to set the high byte of the pointer to screen RAM in register 0288_hex. That place in RAM is the place where character codes are written to (by the CPU/Kernal) if you type someting with the keyboard. This is *input* (it's also used to read from during scrolling). To a computer this *input* is something different than the place in RAM that the VIC reads from to actually *output* those characters to the screen. So $288 stands for "Kernal" and $D018 stands for "VIC".
- 2. Example using VIC bank 0
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Bank 0 is default so that does not have to change. Keep screen RAM (character position) on its default position at 0400_hex so set bit 4 to 7 of D018_hex to 0001_xxxx_bin. Bits 1 to 3 set the position of character RAM. Some configs of D018_hex:
- Value of $D018 for chr. mem.:
- 0001_000x_bin => 0000_hex (overwrites zero page and screen RAM, NOT recommended)
- 0001_001x_bin => 0800_hex (overwrites 0800 and 0801 where BASIC usually starts)
- 0001_010x_bin => 1000_hex (selects ROM instead!)
- 0001_011x_bin => 1800_hex (selects ROM instead!)
- 0001_100x_bin => 2000_hex
- 0001_101x_bin => 2800_hex
- 0001_110x_bin => 3000_hex
- 0001_111x_bin => 3800_hex
- Notice that a full set of characters is 4 kB in size (two sets of 2 kB each) but most custom sets only contain 1 kB (i.e. no reverse mode, no choice between upper and lower case sets). Usually one switches between sets with Shift + C= and between reverse on/off with Ctrl + 9 or 0. If that works if one uses (a) custom character set(s) is not known/tested at the time of writing.
- If one wants as much space as possible for BASIC then one may want to load the font from 0800 to 1000_hex (exclusive) and set the pointer to the start of free BASIC RAM to 1001_hex (use 002B & 002C_hex). Problem that can arise that way is that, at the time of writing, the author of this document does not know if the restriction of the byte 0800_hex having the be zero is still valid (needed for a BASIC prog to be allowed to RUN). It might be re-located too by setting tose bytes, it might not. Most character sets have byte 0 set to zero so it will not often be a probem anyway, but one must check this w/ a hex editor.
- 3. Example using VIC bank 2
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
- One may want to load the custom char set from 3800 to A000_bin. That way the font occupies the last 2 kB of free BASIC RAM. And then set the end of free RAM to 3800_hex with registers 0037 & 0038_hex. However, that would require bits 1 to 3 of D018_hex to be set to 011_bin. That appears to select the character ROM chip again (see memory map [4]).
- Load font into the location of the BASIC ROM. Screen RAM = (8000 +) 2000_bin = A000. Char RAM = (8000 +) 2800_bin = A800.
- $DD00 = xxxx_xx01 = OR 1
- $D018 = 1000_101x = e.g. 139_dec
- $0228 = $A0 = 160_dec
- The font seems to work, BASIC commands, however, do not...
- 4. Example using VIC bank 3
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Change to bank 3 by setting register DD00_hex to xxxx_xx00_bin (set write access to this register with DD02). One may want to place screen RAM (char pos) and char RAM to the 4 kB of upper free RAM (C000 to D000_hex). For a config of the upper free RAM like this:
- Free RAM 1 kB C000 - C400_hex
- Screen RAM 1 kB C400 - C800_hex
- Char RAM 2 kB C800 - D000_hex
- set D018_hex to 0001_001x_bin
- One might also try:
- Screen RAM 1 kB C000 - C400_hex
- Free RAM 1 kB C400 - C800_hex
- Char RAM 2 kB C800 - D000_hex
- and set D018_hex to 0000_001x_bin
- Set the high byte of pointer to screen RAM in register 0288_hex (648_dec) to $C4 (196_dec) in the first config of this example.
- Some programmers use Bank 3 and put a font in RAM under the shadow of the Kernal ROM. Beware for the bug where the kernal writes to RAM underneath it (see Part "The VIC chip").
- o==========o
- | B. BASIC |
- o==========o
- Download a font from [3].
- Example using bank 0 after loading the font to 3800_hex:
- LOAD "robocop",8,1 (load font to 3800_hex)
- POKE 53272,31 (set D018_hex to 0001_1111_bin)
- Example using bank 3 after loading char mem to C800_hex. Set scr. mem to C000_hex:
- 5 rem set bank number to 3 with $dd00
- 10 poke 56576,peek(56576)and252or0
- 15 rem setup bank with $d018
- 16 rem scr mem $0000 and chr mem $0800
- 20 poke 53272,2
- 25 rem set high byte of pointer to scr mem to $c0
- 30 poke 648,192
- o=============o
- | C. Assembly |
- o=============o
- To be written.
- o===============o
- | X. References |
- o===============o
- [1] Lemon64 forum topic:
- www.lemon64.com/forum/viewtopic.php?t=23355
- [2] Font "RoboCop":
- www.lemon64.com/forum/viewtopic.php?t=70713
- [3] Lots of fonts (character sets):
- http://kofler.dot.at/c64
- [4] HTML C64 memory map by Joe Forster:
- https://sta.c64.org/cbm64mem.html
- =======================================================================
- Forum Entry:
- [https://everythingc64.boards.net/thread/679/use-custom-font-basic-programming?page=1&scrollTo=3906]
- [QOUTE]
- 4 Apr 2020 at 22:18 virtualsky said:
- I don't know about the fonts available at the link you've specified, but this program [www.my64.in.nf/lib/exe/fetch.php?media=media:d64:font_customizer.d64] allows you to create your own fonts and use them in your programs. It was published in Loadstar Issue #53.
- LOAD "CUSTOMIZER BOOT",8 and RUN for the font program.
- LOAD "LOADSTAR READER",8 for the user manual.
- [/QUOTE]
- Thanks. That program was the last hint that I needed. The disk that you referred to not only contains a font creator but also a sort of "Read me" (run the prog "Loadstar Reader"). What you need is a file that contains a font (i.e. a data file with a replacement for the 4 kB character ROM that's on the C64 motherboard). Usually people produce data files (eg. fonts) in such a way that they can be loaded into RAM with the LOAD command from BASIC (i.e. no Assembly program required). Such files start with two bytes that state where in memory the file should be loaded. In this case $3800 (check w/ hex editor of DirMaster).
- I did the following:
- 1. I downloaded a font called "RoboCop" (link [https://www.lemon64.com/forum/viewtopic.php?t=70713&start=0]). Fonts usually have the extension ".64C".
- 2. I made a floppy disk image that contains said font file (I used 'c1541' in Linux, used the command "write RoboCop.64c robocop,p").
- 3. Started my C64 (or emulator) with that floppy disk image.
- 4. LOAD "robocop",8,1
- 5. POKE 53272,31
- That changes everything on screen to the new font. :)
- Now what exactly happens here? In step 4 the font file is loaded (in most cases) to $3800. In step 5 the VIC memory bank is set up by changing RAM address $D018 (53272 decimal). When the C64 is turned on then it uses VIC bank 0 (from $0000 to $4000 in RAM). We do not change this. The decimal value "31" that is put in register $D018 reads in binary: 0001 1111. Using the memory map from sta.c64.org/cbm64mem.html we deduce that the character RAM is no longer read from $1000 to $2000 (or rather: re-directed from there to the ROM chip so one can use that RAM for a program) but from $3800 onward (which is what we want) and that screen memory is still read from $0400 to $0800 (which is the default after boot up: no change here). Since the default character ROM is no longer used now, but rather a character-set that is in RAM from $3800 to $4000, the letters on screen change (immediately). Notice the subtle difference between Character ROM and Character RAM.
- P.S. Return to standard font with POKE 53272,21
- ============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement