★ APPLICATIONS ★ DIVERS ★ SAVING SPACE ★![]() |
Remove Double Line Spacing In Print (Computing Today) | Applications Divers |
Remove unwanted line feeds from your listings with this short routine for the Amstrad CPC464 In the CPC 464, a stream of ASCII characters may be directed freely to either the VDU or to a printer. In order to make the format acceptable to the VDU, each line is terminated with both the CR code (value 13) to return the print position to the head of the current line, and the LF code (value 10) to advance to the next line. Most printers will interpret either of these codes as a combined CR/LF operation; with the consequence that where both are sent to the printer a double line spacing will Whilst the best solution must be an adjustment (e.g. a dip switch) at the printer which will remove the response to either one of the codes, the AMSTRAD published firmware contains a mechanism which may be employed to achieve the same effect. The disadvantage is that the software mechanism is reset by a general machine reset, and therefore may not be use able with commercial software. The essential routine in the printer driver is MC WAIT PRINTER, whose entry is to be found in the indirections block at BDF1. The 3-byte block at this address will be found to contain the jump instruction JP 07F8. It is therefore possible to replace this jump address by the address of a suitable machine code routine whose function is to replace the CR code by an innocuous value (e.g. zero) and so eliminate the redundant line. The 16-byte routine is poked by the program into locations from AB00. Lines 20 - 50 plant a jump to AB00 into the indirections block. The routine itself first preserves register A (which holds the character to be printed) by pushing the register pair A, F onto the stack. The exclusive OR of the character with value 13 can only be zero if A itself contains the value 13, ie the CR control code. If the result is non-zero (any other character) the jump to AB0C results in the registers A, F being restored from the stack. Otherwise, A and F are restored and A is replaced by zero. In either case control reaches AB0D, where the original jump from the indirection block is obeyed to print the character. The final line (220) sets the top of BASIC memory to the address immediately below the head of the routine. (AAFF) In use, the program is loaded and run before any use is made of the system, and will remain available unless a general machine reset is performed. It will not be destroyed by a NEW command. In order to make the routine generally relocatable, it is only necessary to replace the jumps in lines 90 -110 and 150 -170 by the equivalent relative jumps, and modify the indirection replacement.
|