Personal Computer News


Double-Height Characters On The C64

 
Published in Personal Computer News #074

An easy way to produce double-height characters on your Commodore 64 from Ian Metcalfe.

Tall Stories

An easy way to produce double-height characters on your Commodore 64 from Ian Metcalfe

The Commodore 64 is highly versatile in the manipulation of graphics and the use of alternative character sets. But often a program isn't complex enough to make it worth your while going to the trouble of producing a new user-defined character set just to produce a better layout.

This utility, D HEIGHT.PAK 64, provides a simple and effective way to produce double-height characters on the screen.

Layout And Use

The program is organised as four subroutines with line numbers from 60000 onwards; they'll usually be easy to merge with your own programs. The routine from line 60000 to line 60270 reads the machine code into memory and executes it. The large number at the end of the data statements is a checksum so the program can tell if the machine code section has been typed in correctly.

The routine should be called at the very beginning of your own program since it resets the top of memory and erases any variables you have stored. Once the routine has been called with GOSUB 60000 it's possible to return to the normal character set with POKE 53272,4 and you can switch back to double height characters with POKE 53272,8

The subroutine at line 60300 is the most frequently used. To write text onto the screen the vertical position, counting down from the top of the screen, is placed in DN, the horizontal position in LE, and the message is displayed in ME$. A call to 60300 is then made: the example listing shows use of this routine.

When the double height characters are set up, the cursor is overwritten by a space so it no longer appears to flash. Two more subroutines deal with this. GOSUB 60400 re-enables the flashing cursor, while GOSUB 60410 replaces it with a space so that double-height spaces appear correctly when programs are running.

Memory Organisation

To create enough space for the double height characters certain areas of memory must be mvoed. This is done automatically within the machine code. Screen memroy is moved up to decimal 32768, hex $8000, which means any programs which POKE directly to the screen must be altered.

The new characters are stored below Basic, starting at decimal 40960, hex $A000. To protect these changes, the top of memory is lowered to 32768, leaving about 8K less RAM available for Basic use.

The only way you can reverse these changes is by pressing RUN/STOP and RESTORE simultaneously: POKE 648,4 tells Basic the screen has been returned to its normal state. You can get the double height characters back by calling the subroutine at 60000 again.

The machine code is stored in the cassette buffer where it shouldn't conflict with other programs. It won't affect the use of tape for data files and the like, since it can be overwritten once it has been called. If you still need to change the location of the program it's just a matter of changing the number 828 in line 60000 and 60270 to whatever start location you prefer.

Other Techniques

As the area of memory the video chip looks as to find its screen information is changed by the programs, the locations you can store sprites and user-defined characters in are also altered. The sprite data pointers are moved up from their normal start location at 2040 to 33784, and a whole new area for storage of sprite data is created between 33792 and 40960, hex $8400 and $A000. This makes room for 112 possible sprite definitions.

User-defined graphics are not entirely prevented by the new double height characters, since there are still 64 character spaces left where shifted reversed chracters normally fit. These spaces lie between 42496 and 43008, hex $A600 and $A800. The whole of the alternative character set (lower case letters) is also available between 43008 and 45056, hex $A800 and $B000.

The only problem with user-defined graphics at these places is that they can only be set (with POKE) and not read (with PEEK) by Basic, as they lie underneath the Basic ROM. This doesn't affect the way they are displayed, because the video chip automatically disregards the Basic ROM when it is reading its character data.

Ian Metcalfe