C64 character font binary

If you want help with your PET, VIC, 128 or Plus4 programming, this is the place for you!

Moderators: wiskow, Trazan

Post Reply
User avatar
Olivier
Posts: 1
Joined: Fri Apr 04, 2014 9:57 pm
Are you a real person?: No... I am a spambot, delete my account!

C64 character font binary

Post by Olivier » Fri Apr 04, 2014 10:04 pm

Hi everyone,

I am adapting the character font set of the Commodore 64 on my Amstrad CPC computer.

The 8x8 matrix of all characters is in the ROM of the C64, but I don't know this computer well.

Can someone (if you know the exact address) send me a ASCII binary file contains this matrix of 256(=32) characters font ?

I would like to put in in the Amstrad CPC computer, to get the C64 font.

Thank you very much for you help,

Olivier

User avatar
LoneWolf33
Posts: 59
Joined: Tue May 14, 2013 9:42 am
Are you a real person?: No... I am a spambot, delete my account!
Location: Budapest, Hungary

Re: C64 character font binary

Post by LoneWolf33 » Mon Apr 07, 2014 11:20 am

Hi Olivier,

Do you need ASCII or binary file? Because they're two different kind of data types: numeric and text.
For example ASCII representation of the fisrt three character pattern from the ROM would look similar to the attached picture,
where the leftmost pixel in a line is the MSB.
These patterns in binary would be stored as number sequences. e.g. if we translate back the bits to decimal bytes the following
number sequence represents the pictured three characters:
60, 102, 110, 110, 96, 98, 60, 0, 24, 60, 102, 126, 102, 102, 102, 0, 124, 102, 102, 124, 102, 102, 124, 0
Attachments
ascii_representation.png
ascii_representation.png (1.6 KiB) Viewed 3236 times

HarmlessHal
Posts: 9
Joined: Mon Dec 24, 2018 4:00 pm
Are you a real person?: No... I am a spambot, delete my account!

Re: C64 character font binary

Post by HarmlessHal » Wed Feb 27, 2019 9:54 pm

This question has aged a bit, but I thought I'd provide my own two cents for future Googlers who might land here.
The OP would like a listing of the 8x8 matrix for each and all PETSCII characters.
I recommend using the VICE emulator, which appears to work faithfully and well.
Just copy the appended BASIC code (see below) onto your clipboard.
In the vice emulator, paste it at the READY prompt using either ALT-Insert or the VICE Edit/Paste menu option.

Type RUN.

Voila: You should see the C64 PETSCII character map presented for all C64 characters. It will list memory address, binary bitmap, and decimal value. You should be able to recognize the characters themselves from the binary data as it streams by.

In the VICE emulator, use ALT-Pause to pause and unpause the listing as the program is running.

A note from the C64 Programmer's Reference Guide:

"...you may need to get to the character ROM if you are going to use programmable characters and want to copy some of the character ROM for some of your character definitions. In this case you must switch out the I/O register, switch in the character ROM, and do your copying. When you're finished, you must switch the I/O registers back in again. During the copying process (when I/O is switched out) no interrupts can be allowed to take place. This is because the I/O registers are needed to service the interrupts. If you forget and perform an interrupt, really strange things happen." I will paraphrase the following sentence to say, "The keyboard [WILL] not be read during the copying process."

In other words, once you hit RUN, it won't read the keyboard until the program completes, so you're stuck waiting 2 or 3 minutes for the complete listing of all keycodes.

However, the VICE emulator allows you to terminate any program early by hitting CTRL-ALT-R, which resets the emulator to startup configuration.

Also, please note that your BASIC code must be in lower case, in Windows, to appear properly on the C64 VICE emulator.

Basic code follows:

100 poke 56334,peek(56334)and254:rem turn off interrupts
110 poke 1,peek(1)and251:rem switch out i/o for character rom
120 for i=53248 to 57343:rem step through character rom
130 x=peek(i):rem read character rom
140 rem convert character rom into binary bits
150 b0$=mid$(str$((x/128) and 1),2,1)
160 b1$=mid$(str$((x/64) and 1),2,1)
170 b2$=mid$(str$((x/32) and 1),2,1)
180 b3$=mid$(str$((x/16) and 1),2,1)
190 b4$=mid$(str$((x/8) and 1),2,1)
200 b5$=mid$(str$((x/4) and 1),2,1)
210 b6$=mid$(str$((x/2) and 1),2,1)
220 b7$=mid$(str$(x and 1),2,1)
230 if i-int(i/8)*8=0 then print:rem insert row between characters
240 print str$(i)+" "+b0$+b1$+b2$+b3$+b4$+b5$+b6$+b7$+str$(x)
250 next
260 poke 1,peek(1)or4:rem switch out character rom for i/o
270 poke 56334,peek(56334)or1:rem turn on interrupts

I hope this has been helpful to a few of the no doubt MANY questors after the mysterious PETSCII character ROMs.

HarmlessHal
Posts: 9
Joined: Mon Dec 24, 2018 4:00 pm
Are you a real person?: No... I am a spambot, delete my account!

Re: C64 character font binary

Post by HarmlessHal » Wed Feb 27, 2019 10:08 pm

Alternatively, if you're going to install WinVICE, it already has this file available. Just look under the C64 folder for the 4K file entitled "chargen." A hex editor reveals that this file contains the same data that the above BASIC program lists.

Post Reply