The printer stream can be enabled by OS_Byte 3 or using VDU codes. The selection of the printer is done by OS_Byte 5. The printer can be made to ignore a specific character by using OS_Byte 6.
Three bits in the byte sent to OS_Byte 3 to select output streams control whether a character is sent to the printer. In addition, a character may also be sent to the printer under the control of the VDU stream.
Bit 2 provides global control over the printer. If this bit is set, then it is not possible for OS_WriteC to cause a character to be inserted into the printer buffer. If it is clear, then the character may or may not be sent to the printer, depending on the state of the other bits.
Bit 6 acts in a similar way: if it is clear, characters may be sent to the printer, but if it is set, they are stopped. There is still one way of getting characters to the printer if bit 6 is set; this is described below.
Assuming bits 2 and 6 are clear, then the simplest way of enabling the printer is by setting bit 3. When this is done, all characters sent to OS_WriteC (except the printer ignore character) will be inserted into the printer buffer.
The most common way of controlling the printer is through the VDU driver. If the VDU stream is enabled (bit 1 of the output stream's byte is clear), then sending the code ASCII 2 (Ctrl-B) to OS_WriteC enables the VDU printer stream. Once this is done, all printable characters and some control characters sent to the VDU stream will also go to the printer. Sending ASCII 3 (Ctrl-C) to the VDU disables the copying of characters to the printer.
A further control code, ASCII 1 (Ctrl-A), causes the next character to be sent to the printer (if enabled by Ctrl-B), but not to the screen. All characters may be sent this way, including the control codes which are usually ignored by the VDU printer stream, and the printer ignore character.
If either bit 6 or bit 2 of the streams byte is set, then the VDU printer stream has no effect. The exception is when the character is preceded by a Ctrl-A. In this case, bit 6 will not prevent the character from being sent, although bit 2 will.
More details of the VDU printer stream control codes are given in the chapter entitled VDU Drivers.
The flow of control of the filtering - which controls which characters sent to the VDU stream also get sent to the printer - is summarised by the diagram below:
Regardless of how a character gets to the printer stream, it is then sent to the current printer device. This is set by OS_Byte 5. It is passed a byte which can select one of 256 potential drivers, 4 of which are supplied with RISC OS.
When an OS_Byte 5 is used, the new destination streams come into effect only when all the current contents of the printer buffer have been sent to the previously-selected driver. This means that when you issue this OS_Byte, the calling task may appear to hang until the current printer buffer's contents are cleared. This may be forced by generating an escape condition.
The default printer device is stored in CMOS RAM and is set by *Configure Print.
OS_Byte 245 (SWI &F5) may be used to read the current printer type, but not to set it, as it does not wait for the printer buffer to empty first. Because of this, it does not enable interrupts, so may be used to read the printer type from within an interrupt routine.
The printer ignore character is one which is suppressed from the printer stream, unless it got there via the VDU printer stream and was preceded by ASCII 1 (Ctrl-A). The character can be set and read using OS_Byte 246. For compatibility with older Acorn operating systems, OS_Byte 6 can also set it and OS_Byte 245 can read it.
*Ignore can be used to set the printer ignore character from the CLI. *Configure Ignore will set it permanently in CMOS RAM. The default value is 10, an ASCII linefeed.
There may be no printer ignore character, in which case all characters are sent. This is called the NoIgnore state and can be set with OS_Byte 182.
*Ignore with no parameter has the same effect from the CLI. *Configure Ignore with no other parameters will set the NoIgnore state permanently in CMOS RAM.
R0 = character to write
R0 preserved
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call sends the byte in R0 to all of the active output streams. This is called as a low level writer by several other routines.
OS_WriteC calls the Write character vector WrchV, the default action of which is to send the character to all active output streams. If this vector is replaced using OS_Claim (see OS_Claim), then all of the SWIs that use this vector will be funnelled into the replacement routine.
All the routines that call OS_WriteC may not actually call OS_WriteC or even WrchV unless there is some pressing reason to do so. For example, if WrchV is being intercepted by someone else as well as the default ROM routine, or if a spool file is active, or if the printer is active etc.
OS_WriteS, OS_Write0, OS_NewLine, OS_PrettyPrint, OS_WriteN, OS_WriteI, OS_Byte 3
WrchV
Writes the following string to all of the active output streams
--
--
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call sends the string that immediately follows the SWI instruction to all of the active output streams. It uses OS_WriteC directly a character at a time. The string is terminated by a null byte.
This SWI alters its return address so that execution continues at the word after the end of the string. Consequently you must not conditionally execute this SWI.
WrchV
Writes an indirect string to all of the active output streams
R0 = pointer to null-terminated string to write
R0 = pointer to the byte after the null byte
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call sends the string pointed to by R0 to all of the active output streams. It uses OS_WriteC directly a character at a time. The string is terminated by a null byte.
WrchV
Writes a line feed followed by a carriage return to all of the active output streams.
--
--
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call writes a line feed followed by a carriage return to all of the active output streams. It uses two calls to OS_WriteI to do so, which in turn call OS_WriteC.
WrchV
R0 = 3 (reason code)
R1 = bit mask for output streams
R0 preserved
R1 = previous stream specification
R2 corrupted
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call selects which output stream(s) are active, and will hence receive all subsequent output. A bit mask in R1 determines this:
The interpretations of all of these bits are described in subsequent sections. All bits are zero by default. This means that the VDU drivers, the VDU printer stream and the spool stream are enabled, and other streams disabled
Details of how bits 1, 2, 3 and 6 interact is described in the Technical Details onwards.
ByteV, VDUXV, WrchV
Sets which PrinterType$... variable holds the printer output path
R0 = 5 (reason code)
R1 = number n of PrinterType$n variable to use (0 - 255)
R0 = preserved
R1 = previous printer driver type
R2 = corrupted
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call sets which PrinterType$... variable holds the path to use for subsequent printer output.
For R1 = n the path held in the variable PrinterType$n is used. The default values of these variables route printed output as follows:
Under RISC OS 2 values of 0, 1 or 2 explicitly set output as given above, rather than by consulting the variables PrinterType$0, $1 and $2.
The default variable to use is set by *Configure Print; for this purpose, n is restricted to the range 0 - 7.
Note that if the current PrinterType$... variable is set to the serial device's path, and the serial port is enabled by setting bit 0 of the stream's byte, then the character is inserted into both buffers. This means that eventually the character is printed twice (first from the serial output buffer), so this practice is not recommended.
The new PrinterType$... variable comes into effect only when all the current contents of the printer buffer have been sent to the path held in the previously selected variable. This means that when this OS_Byte is issued, or the corresponding *FX command, the machine may appear to hang until the current printer buffer's contents are cleared. (You may force this to happen by acknowledging an escape condition from the foreground, provided that the escape side effects are enabled.)
ByteV
R0 = 6 (reason code)
R1 = ASCII code of ignore character
R0 = preserved
R1 = previous ignore character
R2 = corrupted
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call sets the printer ignore character to the specified ASCII code. This character is filtered out when printing is enabled via the VDU printer stream or OS_Byte 5.
The default value of the printer ignore character is set by *Configure Ignore. You may temporarily change it using this OS_Byte, or *Ignore. The latter has the advantage that it also allows a NoIgnore state to be set.
ByteV
Reads/writes the printer NoIgnore state
R0 = 182 (reason code)
R1 = 0 to read or new state to write
R2 = 255 to read or 0 to write
R0 = preserved
R1 = state before being overwritten
R2 = corrupted
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
Not defined
The state stored is changed by being masked with R2 and then exclusive ORd with R1: ie ((state AND R2) XOR R1). This means that R2 controls which bits are changed and R1 supplies the new bits.
This call allows reading the current NoIgnore state or changing it to a new value.
If the value read or written is &80 (ie has bit 7 set), then the printer ignore character is not used. If bit 7 is clear, then the current printer ignore character is filtered out.
The default setting of this flag is controlled by *Configure Ignore and may be changed temporarily using *Ignore.
R0 = 199 (reason code)
R1 = 0 to read or new handle (as returned by OS_Find) to write
R2 = 255 to read or 0 to write
R0 = preserved
R1 = handle before being overwritten
R2 = corrupted
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call reads/writes the spool file handle, which sets the destination of spooled data. The handle must have been correctly returned from a previous call to OS_Find. If the file handle is zero, or if spooling is disabled by OS_Byte 3, then no spooled data is sent.
ByteV
R0 = 236 (reason code)
R1 = 0 when reading or new status when writing
R2 = 255 to read or 0 to write
R0 = preserved
R1 = status before being overwritten
R2 = cursor key status (see OS_Byte 237, OS_Byte 237)
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
Not defined
The status stored is changed by being masked with R2 and then exclusive ORd with R1. ie ((status AND R2) XOR R1). This means that R2 controls which bits are changed and R1 supplies the new bits.
This call reads and writes the output stream's value. This can also be written by OS_Byte 3. See OS_Byte 3 for a list of the bit values.
ByteV
Reads which PrinterType$... variable holds the printer output path
R0 = 245 (reason code)
R1 = 0
R2 = 255
R0 = preserved
R1 = value before being overwritten
R2 = value of printer ignore character (see OS_Byte 246, OS_Byte 246)
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call reads which PrinterType$... variable holds the path to use for subsequent printer output
For R1 = n the path held in the variable PrinterType$n is used. The default values of these variables route printed output as follows:
Under RISC OS 2 values of 0, 1 or 2 explicitly set output as given above, rather than by consulting the variables PrinterType$0, $1 and $2.
The value stored must not be changed by making R1 and R2 other than the values stated above. Use OS_Byte 5 instead to write.
This call does not wait for the printer buffer to empty first. Because of this, it does not enable interrupts, and so may be used to read the printer type from within an interrupt routine.
ByteV
R0 = 246 (reason code)
R1 = 0 to read or new ASCII value to write
R2 = 255 to read or 0 to write
R0 = preserved
R1 = value before being overwritten
R2 = corrupted
Interrupt status is not altered
Fast interrupts are enabled
Processor is in SVC mode
Not defined
The value stored is changed by being masked with R2 and then exclusive ORd with R1: ie ((value AND R2) XOR R1). This means that R2 controls which bits are changed and R1 supplies the new bits.
This call allows reading the current state of the printer ignore character or changing it to a new value.
ByteV
Write an indirect string with some formatting to all of the active output streams
R0 = pointer to null-terminated string to write
R1 = pointer to dictionary (0 means use the internal RISC OS dictionary)
R2 = pointer to null-terminated special string
R0 = preserved
R1 = preserved
R2 = preserved
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call acts like OS_Write0, with several differences:
The following characters in the string have special meanings:
Compacted text uses an escape character in the print string to indicate a dictionary entry. It is followed immediately by a byte which is the dictionary entry number. If this byte is in the range 1 to 255, then the appropriate string in the dictionary is substituted. If it is 0, then the special string pointed to by R2 on entry is substituted. (This is used in particular by the *Help command.)
The format of a dictionary is a linear list of entries, which can recursively refer to other dictionary entries; each entry is a length byte followed by a null-terminated string. This means that a dictionary does not have to have 255 entries. It can be ended at any point with a zero length entry.
The content of the RISC OS dictionary is summarised below:
None
R0 = character to print
R0 = preserved
Interrupt status is undefined
Fast interrupts are enabled
Processor is in SVC mode
Not defined
This call sends a character to the printer. OS_Bytes 3 and 5 control whether there is a printer selected and which device it is.
Note that the printer ignore character (see OS_Byte 6, OS_Byte 6) is not used by this call.
None
None
R0 = pointer to string to write
R1 = number of bytes to write
R0, R1 preserved
Interrupt status is undefined
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
If the VDU is the only active stream, this call uses the low-level VDU drivers directly, and is therefore much more efficient than using multiple calls to OS_WriteC. Also, because no special character is used to mark the end of the string, any VDU sequence may be sent.
WrchV
Write an immediate byte to all of the active output streams
--
--
Interrupts are enabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant
This call writes the character contained in the bottom byte of the SWI number, using OS_WriteC. It has the advantage of being more compact and quicker for a program using it than the equivalent usage of OS_WriteC. For example, to write a 'J' character, you would use:
SWI OS_WriteI + ASC"J"
WrchV
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3