Need help with adding custom character set

Basic and Machine Language

Moderator: Moderators

Post Reply
ricky_derocher
Vic 20 Newbie
Posts: 12
Joined: Mon Feb 05, 2024 11:56 pm
Location: New Hampshire

Need help with adding custom character set

Post by ricky_derocher »

I'd like to add a custom font to my Tiny Quest BASIC text adventure game.

On the C64, this process seems fairly easy. Just "bload" the font 9 block font file into place, and then POKE the right address to change to the font. On the VIC, it seems like this is more complicated (?).

Is it possible to use a 9 block C64 font file (made with a character editor) on the VIC? If not, is there a way to convert it so it can used on the VIC? Or do I need to start from scratch with a VIC character editor?

On this disk image is my game, and the font file that I'd like to use. (I'll work on converting all the text in the game to make use of Upper / Lower case later)
https://www.mediafire.com/file_premium/ ... t.d64/file

This game was originally coded for unexpanded VIC, but I realize that if I'm going to enhance it, then it will need at least 8K expansion.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Need help with adding custom character set

Post by Mike »

ricky_derocher wrote:Just "bload" the font 9 block font file into place, and then POKE the right address to change to the font.
That works quite the same on the VIC-20. VIC register 36869 sets the character generator base address (bottom 4 bits) and the screen start (top 4 bits, together with the top bit of 36866). On both C64 and VIC-20 you will want to protect the character set, so it does not collide with the BASIC program or its variables.

Only the internal RAM is usable for this - you will need to place a full 2 KB font within the range $1000..$1FFF.

With at least a +8K RAM expansion, the screen base is moved from 7680 ($1E00) to 4096 ($1000). The BASIC start then is at $1201 (4609), but you will need to move it to $1C01 (7169) to place the character set at 5120 ($1400).

The procedure to raise the BASIC start is: POKE43,1:POKE44,28:POKE7168,0:NEW

You load the font file into place with: DN=PEEK(186):SYS57809"font",DN:POKE780,0:POKE781,0:POKE782,20:SYS65493 (note this requires the font file to have a proper load address still)

The font is then activated with: POKE36869,205

You would normally need a boot loader to automatically raise the BASIC start and then load and run your own program. That would look quite the same on the C64:

Code: Select all

1 PRINT"{CLR}LOAD"CHR$(34)"TINY QUEST"CHR$(34)","PEEK(186)
2 POKE631,19:POKE632,131:POKE198,2
3 POKE43,1:POKE44,28:POKE7168,0:NEW
Then, the first lines of your user program should be:

Code: Select all

1 DN=PEEK(186):SYS57809"F.FONT",DN:POKE780,0:POKE781,0:POKE782,20:SYS65493
2 POKE36869,205
... followed by your own code.
ricky_derocher
Vic 20 Newbie
Posts: 12
Joined: Mon Feb 05, 2024 11:56 pm
Location: New Hampshire

Re: Need help with adding custom character set

Post by ricky_derocher »

Mike wrote: Sat Feb 10, 2024 1:45 am
ricky_derocher wrote:Just "bload" the font 9 block font file into place, and then POKE the right address to change to the font.
That works quite the same on the VIC-20. VIC register 36869 sets the character generator base address (bottom 4 bits) and the screen start (top 4 bits, together with the top bit of 36866). On both C64 and VIC-20 you will want to protect the character set, so it does not collide with the BASIC program or its variables.

Only the internal RAM is usable for this - you will need to place a full 2 KB font within the range $1000..$1FFF.
What would be the poke(s) needed to set the font for $1000?
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Need help with adding custom character set

Post by Mike »

ricky_derocher wrote:What would be the poke(s) needed to set the font for $1000?
You normally would not want to do that as then the text screen and character set are at the same position.

The first usable position for the font then is at $1400, see my edited post above for more details.
ricky_derocher
Vic 20 Newbie
Posts: 12
Joined: Mon Feb 05, 2024 11:56 pm
Location: New Hampshire

Re: Need help with adding custom character set

Post by ricky_derocher »

Mike wrote: Sat Feb 10, 2024 2:17 am
ricky_derocher wrote:What would be the poke(s) needed to set the font for $1000?
You normally wouldn't want to do that as then the text screen and character set are at the same position.

The first usable position for the font then is at $1400, see my edited post above for more details.
Not too different from the C64, just different addresses used.

For the C64, raising Basic from 2048 to 4096, and then putting the font at 2048. (Which would need a loader program)

How can I make sure the font file has the proper load address?

Thanks very much for your help!
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Need help with adding custom character set

Post by Mike »

ricky_derocher wrote:How can I make sure the font file has the proper load address?
The load procedure with SYS57809 ... SYS65493 that I highlighted above forcibly loads the font file to $1400, yet still a load address needs to be present as first 2 bytes of the file (making it 2050 bytes total).

I have checked the file, and it indeed contains a load address (of $3800).

Please re-check my first post above, I have added DN=PEEK(186) to the font load procedure to make it work from drive numbers other than 8.


P.S. Nice font! 8)
ricky_derocher
Vic 20 Newbie
Posts: 12
Joined: Mon Feb 05, 2024 11:56 pm
Location: New Hampshire

Re: Need help with adding custom character set

Post by ricky_derocher »

Mike wrote: Sat Feb 10, 2024 2:45 am
ricky_derocher wrote:How can I make sure the font file has the proper load address?
The load procedure with SYS57809 ... SYS65493 that I highlighted above forcibly loads the font file to $1400, yet still a load address needs to be present as first 2 bytes of the file (making it 2050 bytes total).
OK, cool! I use this technique all the time on the C64 as a "bload" command.
I have checked the file, and it indeed contains a load address (of $3800).
Thanks!
Please re-check my first post above, I have added DN=PEEK(186) to the font load procedure to make it work from drive numbers other than 8.
I'm a Loadstar veteran (the Commodore disk magazine), and Fender Tucker drilled the peek(186) method into my head. That peek is in the same as the C64. :-)
P.S. Nice font! 8)
Thanks! Another habit I developed from Loadstar is that programs NEED a custom font to look professional. :-)
Post Reply