Character Coder Utility

An invaluable utility that enables you to design and manipulate user defined characters

Volume 1

Number 10

December 1983

BY THE LEFT (PROGRAM) QUICK MARCH!

By MICHAEL MURRAY

THIS program is designed to take the tedium out of defining and manipulating user definable characters and allows any number from 1 to 9 to be redefined at the same time.

The characters are displayed as a block of 3x3, so they may be nine individual shapes or one large one. The whole block may then be manipulated into other orientations, and the program will produce the necessary commands.

The manipulations of the block allowed by the program are:

1. Rotate right.

2. Rotate left.

3. Mirror image (left to right).

There is no limit to how many times each may be carried out, so a great variety of orientations is available. For example, a double rotation right or left will give an inversion.

The characters displayed may be edited at any time, so if the characters are defined and rotated and a change is required in the new orientation, it can be easily carried out and the commands for the new shape will be produced.

The mirror image facility is particularly useful. If characters are drawn to create a man walking from left to right the computer will give the commands needed. Then by using the mirror image, the commands needed to walk in the opposite direction will be produced with no additional effort.

Similarly, the commands to make him walk up the side of the screen may be produced using rotate and mirror image.

When the program is run the user will be presented with a grid representing 3x3 characters, sub-divided into the individual pixels. A cursor will appear in the top left hand pixel, and this may be moved anywhere in the grid using the cursor control keys.

When the cursor is at the correct position the pixel may be set by pressing COPY. To draw a continuous line the COPY key can be held down while the cursor keys are operated.

A diagonal line may be drawn by using two cursor keys at the same time. Any pixel may be unset by moving the cursor to it and pressing Delete. Lines may be deleted by holding the Delete key down while operating the cursor keys.

It is not necessary to use all the characters available, only as many or as few as are wanted. When the characters are completed to the user's satisfaction pressing Return will cause the cursor to disappear.

After a short pause, during which the computer is doing its calculations, the commands that have been used to produce the characters that have been drawn will appear, each character being drawn alongside the relevant command.

At the bottom of the screen the whole block will be printed in two forms. The first is the form of the block in 40 column mode and the second is as it will appear in 20 column mode. After the commands have been examined, and noted if required, pressing the Space bar produces a menu to allow:

A. Start again from scratch.

B. Re-draw the characters just defined (in case changes are wanted

C. Rotate the whole block of characters to the right and display them on the original grid.

D. Rotate to the left and display.

E. Create and display a mirror image.

F. Exit from the program.

When options B-E are selected the resulting display may be edited using the cursor keys, Copy and Delete. Pressing Return will then produce the commands for the amended display.

If options C-E are selected pressing Return without editing will produce the commands for the original characters in the new orientation.

The redefinable characters used in this program are 224-232, as shown in Figure I, but there is no reason why these need to be used.

224

225

226

227

228

229

230

231

232

Figure I

It is the parameters which follow that are important, and these may be used in a VDU23 statement to redefine any character required by the user to give the shape that he has drawn.

If the whole block is to be treated as a single figure it may be printed as a compound VDU statement, for example:

VDU224, 225, 226, 8, 8, 8, 10, 227, 228, 229, 8, 8, 8, 10, 230, 231, 232

This is demonstrated in line 900 of the listing. However if this is to be done frequently it is better to assign the whole figure to a string.

For example, if a figure has been drawn using the four top left hand characters:

FIG$=CHR$(224) + CHR$(225) + CHR$(8) + CHR$(8) + CHR$(10) + CHR$(227) + CHR$(228)

Thus PRINT FIG$ will produce the figure. Printing a string in this manner is faster than using a compound VDU statement.

Note that CHR$(8) moves the print cursor back one space and CHR$(10) moves it down one line. If these were not included the figure would appear in a straight line.

The main program is lines 130-200. Line 150 dimensions the array into which the parameters for each character are to be placed, that is characters 0-8, parameters 0-7.

Lines 160-180 draw the initial figure and produce the commands while line 190 enables repeated changes and manipulations to be made.

PROCGRID draws the basic grid. Each grid square is 40x40, so that when a pixel is filled with a 32x32 character the grid lines are preserved.

Line 260 is to print the lines representing character positions in white and those representing pixels in red.

Line 340 defines the cursor and 350 the pixel filler character.

PROCDRAW is the procedure to draw the characters. Lines 420-430 place the cursor in the top left of the grid. Lines 440-580 control drawing until Return is pressed.

Line 450 is a time delay that can be altered to suit the user. Line 460 stores the current cursor position. Lines 470-500 calculate the new position according to which cursor keys are being pressed, and lines 510-520 keep the cursor within the grid.

Line 530 deletes the cursor from its old position. Lines 540 and 570 draw it in the new position.

Line 550 deletes any pixel in the new

position if Delete is pressed, while line 560 sets the pixel if Copy is pressed.

Line 590 removes the cursor after Return has been pressed.

PROCCOMMANDS examines the grid to determine which pixels are set and calculates the parameters required in a VDU23 statement to produce each of the nine characters.

Line 660 is for the three rows of characters, line 670 is for the three characters in each row and line 680 is for the eight parameters in each character.

Lines 690-720 convert the binary representation of each character into a number, the left hand pixel of each row of each character being worth 27, decreasing to 20 for the rightmost pixel.

As each parameter is calculated it is stored in an array by line 730. Lines 770-790 read the values in the array and use them to redefine characters 224-232.

Lines 800-870 print the commands used to define the characters and display the characters thus defined immediately afterwards.

Lines 890-900 display the 3x3 block of characters at the bottom of the screen while line 910 calls a procedure that simulates the appearance of the block in 20 column modes.

Line 920 holds up the program until the SPACE bar is pressed.

PROCMODES extends the horizontal scale of each character by two to simulate its appearance in the 20 column modes.

PROCROTATE_R reads the array of parameters and manipulates it to produce a display rotated to the right. Lines 1220-1230 determine the start point for each character, and 1240-1250 the start of each row (represented by one parameter) within the character.

Lines 1260-1280 convert the value of each parameter into a binary representation and sets the pixels in the grid to show this. Due to the rotation they will be set top to bottom instead of left to right.

PROCMIRROR and PROC-ROTATE_L are similar to PROC-ROTATE_R, but with slightly different manipulations of the parameters to give a mirror image and a rotation to the left respectively.

PROCCHOICE is a simple menu selection routine to allow the user to choose his next option and execute it.