Personal Computer News


Double Height Characters

 
Published in Personal Computer News #092

Stretch your letters to their full height with this easy routine for the Amstrad from John Keneally.

Amstrad: Stretch Your Characters

Stretch your letters to their full height with this easy routine for the Amstrad from John Keneally

This machine code program for the Amstrad CPC464 allows you to print double height characters on the screen, for use both in games and serious software. The characters can be printed in windows and can be user-defined using SYMBOL as normal. Used for headings, they give a professional look to your software.

As well as providing a useful facility to the Basic programmer, the assembly language listing demonstrates the use of many of the Amstrad's powerful features, including some ROM routines.

To get it running, type in the Basic Loader listing, taking particular care with the DATA statements (don't confuse 8's with B's), and then save it onto tape. When run, the screen should clear and the program is ready to use.

There are no messy calls to machine code from now on. All that is required is to type PRINT CHR$(254) to turn on double height printing, and PRINT CHR$(255) to revert back to normal printing. These characters no longer print and are used as control codes by the software - so redefining these will have no useful effect.

Obviously, by mixing these characters in a print string, it is possible to print double and normal height characters on the same line. The only restriction is that double height characters cannot be printed via the TAG command.

The program will work in all three modes as the short demo program listing shows. In Mode 0 you get double size characters, in Mode 1 you get double height characters, similarly in Mode 2.

The program operates by intercepting the operating system's character output routine. The character codes 254 and 255 are used to turn the routine on and off, and internally these are used to print a double height character as follows. If the routine is turned off, then the character to be printed is sent to the normal ROM routine.

If the routine is on, then the matrix for the particular character is looked up in the ROM (or RAM if it is user-defined) via an OS routine at BBA5, which returns the start address of the matrix for the character in the 'A' register in the HL register pair. This matrix is then copied to reserved RAM, but each line is copied twice - giving 16 lines in all.

Character 254 is defined as the top eight lines, and character 255 is defined as the lower eight lines, by loading the ASCII code into the A register and the address of the matrix into HL and calling the OS routine at BBA8.

Having defined these characters, the cursor position is obtained by calling BB78 and moved up a line, the top of the character is printed - code 254, and then the cursor position is restored and the bottom half of the character - code 255 is printed.

Control codes are always printed as normal whether or not double height is on or off (so that they are not printed twice which could cause havoc). The exception to this is the line feed character; if this is printed, an extra line is skipped to account for the extra height of the characters.

Although the software will work in direct mode, it is advisable to use it only from programs where you know where the output is being sent. Also note that lines input by the user will always be printed in normal height, regardless of whether the routine is on or off.

John Keneally