This month let's discuss a few more things concerning the line-drawing and character-drawing routines presented in the last couple of columns. Some of you may have noted that the character-drawing routines did not support the multicolor mode. This could be done with some additional time and effort. However, because of the increased complexities of handling multicolor mode, there probably won't be room for the routines in the $C000 to $C7FF region of RAM where the other routines were located.
Multiuse Vector Bytes
There were some other things which were not implemented as well. First, vector byte strings were provided only for the uppercase character set. The remaining characters weren't implemented due to the space they would require. You could implement the remaining characters yourself, or even create an entire character set of your own design. Also, you are not restricted to drawing characters. The vector byte strings could be used to draw almost any design.
If you have studied the machine language listing for the character-drawing routines, you may have noticed there was some provision made for additional special function vector bytes. One I had in mind, but didn't get around to implementing, was a "clear character cell" special function code. This would clear a character cell of a specified size. The function would be useful if you wanted to draw characters on top of some other design. Another useful function would be contour fill function—that is, fill the area inside a boundary. With this, large solid characters could be made much more easily. Unfortunately, I doubt there is enough room in the code to have such a routine. Perhaps we can discuss contour filling in a future article.
As you might guess, there are lots of other things which could be implemented. Unfortunately, there isn't enough room to implement them all. This is where the machine language source code listing should come in handy. You can combine routines from various sources to construct the set of routines you require.
Easy To Understand
I hope the comments provided in the source code are sufficient to make most of the routines understandable. The thoroughness of the comments is not consistent throughout the source code. The variation is largely due to an effort to keep the source code from growing too large.
Having good comments in a program can be extremely useful. Unfortunately, there are a couple of factors which tend to discourage commenting. The first factor is that it makes the source code longer. With the speed of the 1541 disk drive, the extra size can noticeably affect the length of time it takes to edit or assemble the source file. The second factor is that it takes extra time to write the comments. Usually, writing the comments will be less interesting than writing the program.
However, if the machine language you plan to write will be of some importance, I highly recommend thoroughly commenting the program. You can use comments to understand how the program was intended to work after you've forgotten. You'd be surprised how fast you can forget.
There are two basic places to put your comments. One is to the side of the machine language instructions, on the same line as the instructions. The other is between routines, where the comments would document the routine which follows. It is here that the extra effort commenting pays off the best. Ideally, the comments should include a description of what the routine is supposed to do, plus the entry and exit conditions that apply. This would allow you to use the routine, once it is written, without having to study the routine itself to determine what it does. In the long run, such comments can actually save a lot of time. Especially if someone else has to make use of your source code. In the source code I've provided so far, most of the time I've included the entry and exit conditions, but have omitted the description to conserve space.
Program 2 and Program 3 which follow are continuations of last month's column on drawing characters to the bitmap. They facilitate the drawing of letters to a hi-res screen.