★ APPLICATIONS ★ DIVERS ★ ECHO: printer utility ★ |
Echo - Printer Utility (The Amstrad User) | Applications Divers |
Many times I have had use for the screen echoing command available from the CP/M using the [CTRL]+[P] key sequence to provide a log of screen activity on the printer. Some computers also provide this facility from Basic, although the Amstrad does not. This program will provide a similar facility via a Resident System Extension (R.S.X.) which will allow the echoing of all screen output to the printer. Two new commands are provided: |ECHO.ON - Will turn on the printer intercept and all the following screen output will be echoed to the printer. |ECHO.OFF - Will turn the intercept off and return things to normal. The Basic program provided is simply a loader to poke the machine code into reserved memory above himem. The code is relocated as required by the basic loader and will work comfortably provided thet any other machine code already present does not result in the loader lowering himem below 16384 (&4000). This is because the R.S.X. needs to be in RAM that is not overlaying ROM. The loader will detect this if it occurs and abort with a memory full error. Once the loading of the code is complete the loader will erase itself from memory, leaving the RSX. Commands |ECHO.ON & |ECHO.OFF ready for use. The Basic loader should be SAVED before it is RUN as it erases itself when complete. The loader is heavily REMarked and should be easily understood. It first checks to see if it has already been loaded by setting up an error trap for the external command. ECHO.OFF. If the R.S.X is already in memory, then this will not cause an error and the program will abort If the command causes an error, then this is detected bv the error trap, and the program will then lower HIMEM to a suitable level and poke in the machine code above HIMEM. Any addresses requiring relocation are signalled by a ## in the data statements. The byte following the ## is an offset from the start of the program, which is added to the start address to give an absolute address. Which is then converted into a low and high byte pair, and poked into place at the current address. The program will attempt to leave the symbol table in the same state as power up, ie. Symbol after 240, provided that there is sufficient memory to do so and the tabic has not been previously divided by lowering himem I without first issuing a Symbol after 256 Command. It does this by using an error trap for the SYMBOI. AFTER command. It should be kept in mind that only characters In the range of ASCII 32-127 will be echoed to the printer, and any characters outside that range wUl be converted to a space. If the printer is not connected, or off line, and a |ECHO.ON command is issued, then I the program will lock up until the printer is connected. The intercept will remain active until I turned off by using the command |ECHO.OFF. The assembler listing is provided for those who are interested in delving into the method used to obtain the screen echo facility. The |ECHO.ON command simplv directs the normal screen output to our intercept routine, where the current screen column is compared with the previous column, and a line feed sent if the current column is less than the previous one. If not then the current column is stored and the outgoing character checked to be sure it can be printed. If it can then it is sent to the printer uncharged. If not then it is converted to a space and sent to the printer. Finally, the original character is restored and a jump to the normal screen handling routine in the ROM is performed. The |ECHO.OFF command simply restore the normal screen handling routine. Some abnormalities will be observed if the editing keys, including [CLR] & [DEL], and the copy cursor an used to correct anything on screen. A line feed will be sent each time the column count is less than before, so the printout may be a bit strange. If screen format commands like LOCATE are used then what appears on the printer will be different to what appears on the screen, due to the action of these commands sometimes causing a line feed due to the column being less than before. As is usual, experimentation will show just what can and cannot be done. The |ECHO.ON, |ECHO.OFF commands will work just as well either in direct mode or in a running program so it is possible to have a routine to print to the screen, and by simply inserting a |ECHO.ON in the program just before the routine, have it display on the printer as well. After the routine is completed, a |ECHO.OFF will put things back to normal. I am sure that with a little thought, you will be able to come up with lots of other uses. TAU
|