NOTICE:

The Arnor products for the Amstrad CPC and Amstrad PCW are © Copyright 1997-2001 Brian Watson. All rights reserved

For support and printed manuals for these products please contact Brian at:

Brian Watson,
"Number Six",
Windmill Walk,
Sutton,
ELY
Cambs
CB6 2NH
ENGLAND

or

brian@spheroid.demon.co.uk

Brian Watson has given permission for this document to be made available through the "Unofficial Amstrad WWW Resource". The original document was provided by Richard Wildey, then scanned and OCR'ed by Kevin Thacker.


PROTEXT TECHNICAL INFORMATION

Introduction: how the PROTEXT workspace is organised

As a sideways ROM, PROTEXT takes 512 bytes for its own workspace when it is initialised. The location of this workspace depends on the number and positioning of other sideways ROMS, so any references to this workspace must be dynamically evaluated. The IY register is set by the firmware to contain the start of this workspace when PROTEXT is entered, so the IY-relative instructions can be used. However, this is VERY inconvenient when coding the program, so PROTEXT uses a different technique. A static workspace area is chosen (at present this is &AC00, which is the start of the BASIC workspace). Whenever PROTEXT is entered the contents of this static workspace area is swapped with part of the dynamic workspace area (pointed to by IY). On exit from PROTEXT they are swapped back again. This does not affect BASIC because the BASIC memory is always restored before BASIC needs it. The advantage is that the coding of PROTEXT is much easier, and the resulting code is probably considerably shorter.

There are four sections to this documentation:

  1. calls that can be made to PROTEXT which either return some information or perform some function.
  2. vectors that may be intercepted to change the operation of some feature of PROTEXT or to add a new feature.
  3. printer driver format.
  4. PROTEXT key translation table

(i) CALLS

Each routine has a number. Routine n is called by executing the external command CTRL-P n (i.e. the two character name 16 n). The firmware routine KL FAR PCHL may be used.

Care must be taken that the PROTEXT workspace has been swapped into the static area before calling routines 5 to 12, or before changing vectors. If this is not the case the SWAPIN routine must be called first and the SWAPOUT routine afterwards. The rules for determining whether this is necessary are:

  1. if your code has been called as an external command, or has been called in any way from outside PROTEXT you will need to use SWAPIN and SWAPOUT.
  2. if your code has been called by intercepting a vector then do not use SWAPIN and SWAPOUT.

For all these calls PROTEXT version 1.00 or later is required.

n name input output and effect
0PROBEnoneCHL=version number
DE=dynamic workspace address
B=static workspace address (high byte)
1SWAPINnoneSwaps workspace areas - to put PROTEXT workspace in static area.
Flags: NC if not enough memory to run PROTEXT.
2 SWAPOUTnoneSwaps workspace areas - to return PROTEXT workspace to dynamic area.
3VECTORSnoneHL=address of first vector.
4ENVIRONMENTnoneHL=address of environment.
BC=length of environment.
5LOCATEDE=memory addrSets current page/line/column corresponding to address within text.
6SET LINEDE=line numberSets current line number.
7SET COLUMNDE=column numberSets current column number.
8INSERTDE=numberInsert a number of spaces at the current position.
HL=current position (address)
Flags: NC if not enough memory.
9DELETEDE=numberDelete a number of characters forwards from the current position.
10GET TEXTnoneHL=start of text
DE=end of text
11reserved
12GET CURSORnoneHL=current position (address)
13GET COMMANDSnoneHL=address of PROTEXT command table
(each command is followed by its abbreviation)
DE=jump table (2 bytes addresses)

(ii) VECTORS

The addresses of the vectors are given as an offset to the address returned by the call CTRL-P 3. User routines called via these vectors should preserve the ROM states and selection and, except where indicated, preserve all registers (especially IX and IY!).

These vectors are present in PROTEXT version 1.00 or later.

address name description
0DRIVER ADDRContains the two byte address of the printer driver in memory.
2DRIVER LENContains the two byte length of the printer driver in memory (by default this is &100).
4PRONVECThis address is called at the start of any PRINT command (P, PS, PF, PB, etc.). It initially contains a RET instruction, and can be changed to any 3 byte instruction (esp. JP, RST 3, etc. ). The new routine may corrupt AF, BC, DE, and HL.
7PROFFVECThis is similar to PRONVEC and is called at the end of any PRINT command. The new routine may corrupt AF, BC, DE, and HL.
10PRINVECThis is called to print every character. It initially contains a jump to the PROTEXT routine, and can be changed to jump to a substitute routine, or to a routine which does something before printing and then jumps to the PROTEXT routine (the address of which was saved when the vector was intercepted).

Entry conditions are as follows:

A=character to print.
D bit 0 is set if PRINT (to printer).
D bit 1 is set if PRINTF (to file).
D bit 2 is set if PRINTS (to screen).

If the routine completely replaces the PROTEXT routine it should return flags as follows:

Cif successful.
NC, NZto retry (e.g. printer not online).
NC, Zto abort printing.

Alternatively, jump to the PROTEXT routine, preserving all registers (careful with the ROM state!).

13FINDVECCalled when COPY is pressed for next find. Initially contains a RET instruction.
16COMMVECCalled before PROTEXT processes a command (command mode). Initially contains RET.

Entry conditions:

HL=address of command string, terminated by zero.

Exit conditions:

C, Zif command processed, return to command mode.
NCif command processed, enter edit mode.
C, NZif PROTEXT should interpret command. All registers must be preserved.

19 EDITVECCalled to interpret edit mode command. Initially contains jump to PROTEXT routine. Enters with A=character from keyboard. Can be intercepted to add command. Currently CTRL-U, and CTRL-Y are unused. New routine must jump to PROTEXT routine if it is not acting on the character so that PROTEXT performs the command normally.
22READVECCalled to read command string. Initially jumps to PROTEXT routine.
25SCSYNVECStored command syntax check. Initially contains RET. Called during pre-printing syntax check. Can be intercepted to add stored commands.

Entry conditions:

HL=address of first byte of string after stored command name (i.e. after >XX). To check the command the routine must:

  1. step back from HL until it finds one of: 0 (start of text) , &A (line feed) , &8A (soft line feed).
  2. Move forwards ignoring &80-&89 (place markers) and &8B,&8C (block markers).

Exit conditions:

C=1 if command recognised. Otherwise PROTEXT will check its own list of stored commands.

28SCPRINVECStored command processor. Initially contains RET. Called during printing.

Entry conditions:

HL=address of first byte of string after stored command name (i.e. after >XX).

Exit conditions:

HL=address of next byte in text to be printed/interpreted.
All other registers preserved.

So if the command is not intercepted, return preserving all registers. If the command is acted on, return with HL pointing to the first byte of the line after the stored command line.

(iii) PRINTER DRIVER FORMAT

An enlarged printer driver can be set up by changing the DRIVER ADDR and DRIVER LEN (see VECTORS, above). The driver must be at least 256 bytes long.

byte default description
0-120Offset of first redefined character.
2-394The number of free bytes in the printer driver.
4-50Reserved
666Page length
73Top margin
82Header margin
92Footer margin
103Bottom margin
111Flags. Effect if bit set:

0=continuous printing, 1=Page number at top
2=Page number at bottom, 3=form feeds on, 4=NLQ on
7=New page after print

125Even side margin
135Odd side margin
141Line spacing
15-161Start page number
17-1865535End page number
191Number of copies
(20)Character definitions.
Each definition takes the form: ASCII code being redefined, length of code sequence, code sequence.
A zero byte marks the end of the definitions.
Followed by:

Printer control code definitions.
There are 27 of these: @, then a-z.

Each code consists of a sequence of codes for off, followed by a sequence of codes for on. Each sequence is preceded by the length of the sequence. If a code is undefined there are two zero bytes, if there is an on code and no off code there is a zero byte followed by the sequence for on.

The end of the table is marked by -1.

(iv) PROTEXT key translation table

The default key translation table is not suitable for PROTEXT to use because various key combinations return the same tokens (e.g. COPY and SHIFT-COPY), while PROTEXT needs different tokens. The tokens listed below can be put in function key expansions to enable the easy entry of a string of PROTEXT commands.

CTRL-@0CTRL-[27
CTRL-A1CTRL-\28
CTRL-B2CTRL-]29
CTRL-C3CTRL-£30
CTRL-D4CTRL-031
CTRL-E5CTRL-<2
CTRL-F6CTRL->31
CTRL-G7COPY&E0
CTRL-H8CTRL-TAB&E1
CTRL-I&EDCTRL-hyphen&E3
CTRL-J10SHIFT-TAB&E4
CTRL-K11SHIFT-CLR&E5
CTRL-L12CTRL-CLR&E6
CTRL-M&EECTRL-/&E7
CTRL-N14CTRL-DEL&E8
CTRL-O15SHIFT-COPY&E9
CTRL-P&E2CTRL-COPY&EA
CTRL-Q17CTRL-space&EB
CTRL-R18SHIFT-ENTER&EC
CTRL-S19CTRL-ENTER&EC
CTRL-T20cursor-up&F0
CTRL-U21cursor-down&F1
CTRL-V22cursor-left&F2
CTRL-W23cursor-right&F3
CTRL-X24SHIFT-up&F4
CTRL-Y25SHIFT-down&F5
CTRL-Z26SHIFT-left&F6
SHIFT-right&F7
ESC&FCCTRL-up&F8
CTRL-down&F9
CTRL-left&FA
CTRL-right&FB

Copyright (c) Arnor Ltd., 1985 Issue 3 06/12/1985