Character Redefinition

Michael Jackson

 

Issue 3

May/Jun 83

Next Article >>

<< Prev Article

 

The Atari computer is truly an electronic marvel which offers fabulous graphics and sounds. It is for these qualities the Atari Home Computers are best known. There is, however, another feature that the Atari possesses which, when used to best effect, can be just as stunning - if not more so - than all those very impressive graphics modes.

How would you like Roman-style numerals instead of the normal numbers? Or perhaps some artistic script writing (like the writing you see in Scott Adams Adventures!)? What about some trees or perhaps grass? Some mountains might be nice! How can all this be done? It's called character redefinition.

Probably the best place to start understanding the principles of character redefinition is to examine what makes up a single character in the first place. Each character can be mapped on an 8 x 8 grid which represents 8 bytes of memory inside the computer. A character is best thought of as being composed of 8 layers - see figure 1 - with each layer representing a consecutive address in memory.

As you can see from figure 1, the shape of the character is decided by which 'bits' are filled in (on) and which are not (off) in each layer.

This image is stored in memory and the value stored at each memory address (representing each layer) is determined by the placement of the 'on' bits. Let's suppose that layer 1 starts at address 30000. To create the shape in figure 1 you would POKE 30000,0;30001,24;30002,60 and so on. Address 30008 would represent the first layer of another character.

Now you know the basic principle of creating a character, let's get down to practicalities.

WHERE TO STORE YOUR CHARACTER DATA

The memory of your Atari is grouped together in lots of 256 address locations. Each group or lot of memory is referred to as a 'page'. You must decide which memory page to start storing your character set data. Care must be taken to avoid occupying memory which may be taken by your Basic program. The bigger your Basic program (which needs your custom character set), the higher up in memory you must go to store your character data, i.e. the page number must be bigger. I have found that page 120 (on a 32K machine) works well enough for me. With a page number of 120, this means that the starting, address for your custom set is 120x256 which equals 30720. Try poking 756,120. If the screen goes blank, this means that there is nothing in that area of memory and that you can store your character data there. It is wise to do this while you have the program which is going to use your character set already in memory. If the screen is full of weird characters then you must try a higher page.

SELECTING CERTAIN CHARACTERS ONLY

Up till now I have assumed that you want to redefine every keystroke character or will only use those characters that you have redefined. Sometimes, however, you may want to change only one or two characters and keep the rest the same as the Atari set. For example, if you have a business program, you will probably want a '£' sign rather than the '$' sign! Perhaps a proper division sign instead of '/'.

If this is the case, then two things must be done. First, the whole Atari character set must be copied over into the spare memory pages you have selected and then selective areas that relate to the character/keystroke you want to change must be POKED with new values. In case you're thinking of giving up, I should add that the CHARACTER GENERATION UTILITY program does everything for you, but I will explain it here so you can understand the mechanics better.

The following short program would deal with the first task:

10 FOR I=0 TO 1023: POKE 120*256+I, PEEK(224*256+I): NEXT I

Page number 224, by the way, is the page which the computer uses to store its permanent character set. This page cannot be changed which is why you need to copy the character set to another location. As you will see, this program simply peeks what is in page 224 and then copies it into page 120. If you want to actually see the copying process taking place, then switch off the computer and re-enter the program but with Line 5 POKE 756,120. Run it. Weird, isn't it?

The second task, picking out that group of 8 memory addresses for your particular character, requires consultation of your Atari Basic Reference Manual at page 55. Here you will find a table which details the relative positions of characters. Let us suppose you want to poke data that creates a £ sign into the area of memory that currently holds the $ sign. Consider the following program, which does this.

10 FOR I=0 TO 7:READ A

20 POKE 120*256+4*8+I,A

30 NEXT I

40 DATA 28,32,32,32,120,32,98,126

Let's see now. Line 10 reads each of your data values. There are 8 values - one for each layer of your character. In this case it is a pound sign. Line 20 identifies the starting point of your character set (120*256), then it calculates the first of the 8 addresses you want (+5*8) - where 4 is the internal number representing the $ sign (see page 55 of your manual) and 8 since there are 8 memory addresses involved to make up each character. Line 30 repeats the process 8 times and Line 40 holds your data.

The utility program actually writes these programs for each key you choose for each custom character you create!

Once you have stored the values of your new character set into memory, you will want to see the fruits of your labour on the screen. POKE 756 with the page number you are using, in this case it is 120, and voila!

NOTE. Entering a new Graphics command returns you to the Atari standard character set. You must POKE 756,120 (or whatever page you are using) straight after a new Graphics command. A GOSUB may help you here.

See next article for program

top