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
C64 character font binary
- LoneWolf33
- Posts: 92
- 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
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
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 (1.6 KiB) Viewed 124202 times
-
- Posts: 11
- 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
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.
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.
-
- Posts: 11
- 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
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.
-
- Posts: 4
- Joined: Sun Aug 18, 2013 4:24 pm
- Are you a real person?: No... I am a spambot, delete my account!
Re: C64 character font binary
Yes, indeed, but where is the fun?HarmlessHal wrote: ↑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.
-
- Posts: 4
- Joined: Sun Aug 18, 2013 4:24 pm
- Are you a real person?: No... I am a spambot, delete my account!
Re: C64 character font binary
Sorry, I stumbled into this thread late ... but it took my attention anyway.
Another change regards the interrupt handling and bank switching. These parts are capsuled into subroutines and are used by the gap printing code to allow interruption by Run/Stop.
The optimizations based on the prevention of have operations like a division. Using AND for masking out bits and a logical expression (..>0) gives a 0 (false) or -1 (true) which maps (the very fast function ABS) to 0 and 1, which can be used as index for B$().
Same for the gap-line detection: To prevent division here we could use masking the value by 7 gives zero (cheap equivalent to calculate modulo because the address are out of range for binary operations (only integer in range -32768 to 32767 are allowed), we subtract 32768 before.
In some instances a constant (like 32768, which take lot of time to be converted into a binary floating point number each time parsed) is better put into a variable (in this case variable O).
There are lot of more optimization potential (like using "." instead of "0" and so on)
Using STR$() for numeric variables is not necessary because PRINT does the conversion implicitly.
A side-effect of the original and even the modified version arises when using it with a SpeedDOS+ ROM. There is a modified keyboard scanning routine which causes the program hang on the first scrolling event, as far as I can see because the interrupts are off.
Because I don't want to rely on any emulator's functionality, it would be nice to use the normal Run/Stop key. That's what is achived in the modified version of the program below.HarmlessHal wrote: ↑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.
[..]
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.
Let me suggest a slightly optimized version, which does a faster binary destruction and visualizing the characters with a ball character for any set bit (change B$() as you like). The binary destruction and gap printing every 8 lines saves overall 35 % just for the conversion. The scrolling slows it down anyway, so the speed-up won't be recognized that dramatic. I know, on an emulator speed is not the issue if one could just changing to warp mode.
Another change regards the interrupt handling and bank switching. These parts are capsuled into subroutines and are used by the gap printing code to allow interruption by Run/Stop.
Code: Select all
10 b$(0)=" ":b$(1)="Q":o=32768
20 goto 100
50 poke 56334,peek(56334)and254:rem turn off interrupts
51 poke 1,peek(1)and251:rem switch out i/o for character rom
52 return
60 poke 1,peek(1)or4:rem switch out character rom for i/o
61 poke 56334,peek(56334)or1:rem turn on interrupts
62 return
100 gosub50
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 =abs((xand128)>0)
160 b1 =abs((xand64)>0)
170 b2 =abs((xand32)>0)
180 b3 =abs((xand16)>0)
190 b4 =abs((xand8)>0)
200 b5 =abs((xand4)>0)
210 b6 =abs((xand2)>0)
220 b7 =xand1
230 if ((i-o)and7)=0 then gosub60:print:gosub50
240 print i" "b$(b0)b$(b1)b$(b2)b$(b3)b$(b4)b$(b5)b$(b6)b$(b7)x
250 next
260 gosub60
Same for the gap-line detection: To prevent division here we could use masking the value by 7 gives zero (cheap equivalent to calculate modulo because the address are out of range for binary operations (only integer in range -32768 to 32767 are allowed), we subtract 32768 before.
In some instances a constant (like 32768, which take lot of time to be converted into a binary floating point number each time parsed) is better put into a variable (in this case variable O).
There are lot of more optimization potential (like using "." instead of "0" and so on)
Using STR$() for numeric variables is not necessary because PRINT does the conversion implicitly.
A side-effect of the original and even the modified version arises when using it with a SpeedDOS+ ROM. There is a modified keyboard scanning routine which causes the program hang on the first scrolling event, as far as I can see because the interrupts are off.
-
- Posts: 11
- 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
Thanks for the update -- very nicely improved upon! What's not to like in a threat spanning 2014-2020, about a computer released in 1983?
-
- Posts: 11
- 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
(er, thread, that is. sorry for the typo)