★ APPLICATIONS ★ BUREAUTIQUE ★ Rushing into print ★ |
Turbotext (Computing with the Amstrad) | Applications Bureautique |
CHRIS NIXON knows how to turbocharge your cursor LOCOMOTIVE Basic is quite a fast version of the language but have you ever wondered whether it could be made to go any quicker? Wonder no longer! With Turbotext, Basic programs which print on the screen can run up to 87 per cent faster. When a character is printed an incredible amount of work is carried out before anything appears. Finding how many bytes make up a letter in the current mode, what the pen value is, what the byte masks are for that colour, where the shape matrix is, and calculating the character's position in the screen memory are just a few of the operations involved. As you can imagine, this really slows things down, and forms a bottleneck in an otherwise fast system. By replacing most of the in-built routines used to print characters with faster, more dedicated pieces of code. Turbotext achieves a useful speed increase. In Mode 1 it is 44 per cent faster, in Mode 0 it's 67 per cent and in Mode 2 the figure rises to 87 per cent. When you run Program I you will have two RSX commands, |TURBO and |NORMAL. As the names suggest , |TURBO activates fast printing mode, while |NORMAL restores things to normal. To obtain the speed increase I restricted some of the facilities available, and you need to take account of this when writing programs. In normal printing internal adjustments are made when the screen scrolls. Turbotext avoids having to do the necessary calculations by clearing the screen when printing a character would cause it to roll. The text then continues from the top of the screen. This is to avoid a crash and not a feature of the program so don't rely on it. In Modes 0 and 1 the quick-'n'-dirty method I used can lose the first character to be printed on the newly-cleared screen. For this reason you may wish to keep Turbotext dormant while you are typing in. To speed things up further, transparent mode is ignored and text windows are not taken into account. All characters printed while Turbotext is active will appear at their physical screen positions, that is with location 1,1 at the top left of the screen. You may find that some control codes such as CHR$(24) don't work. PEN and PAPER commands will function normally except in Mode 2. Here Turbotext shows some intelligence and will reverse pen and paper by just using PEN 0, or PEN 1 to switch them back again. Remember that although Turbotext will speed up the printing of text it won't affect other aspects of your Amstrad's operation. Therefore, in worst case situations where printing is not a frequent occurrence, the overall speed improvement will be low. The extra speed is achieved by replacing the firmware jumpblock entry TXT OUTPUT at &BB5A -through which most printing is channelled - with a jump to the Turbotext routine. This first checks whether the character is a control code. If so, it is sent to the firmware. If not. Turbotext gathers all the information needed to print the character and bungs the result into the screen memory with a sprite subroutine. For those of you reaching for your disassemblers, there are two things which may cause confusion. One is that the program uses self-modifying code, the other is that I cheated in the program loop which prints in Modes 0 and 1. HL, DE and BC were taken up and I was going to use IX to point to the character matrix for reading the shape data. The problem is that operations involving IX and IY are relatively slow and should be avoided in speed-critical situations. To get round this I used some illegal opcodes detailed in the April 1986 issue of Computing with the Amstrad which treat the 16 bit IX register as two 8 bit registers. This isn't quite as fast as using normal 8 bit registers, but gives a net speed increase of 3 to 5 per cent by allowing me to keep HL and DE free for pointing to the screen and matrix.
|