Difference between revisions of "VDU 2"
m (1 revision) |
m (1 revision) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 32: | Line 32: | ||
chosen with [[OSBYTE &06]]. | chosen with [[OSBYTE &06]]. | ||
− | If VDU output has been disabled with [[OSBYTE &03]] and | + | If VDU output has been disabled with [[OSBYTE &03]] and independent printer |
output has not been enabled, then the VDU driver never receives characters | output has not been enabled, then the VDU driver never receives characters | ||
and never signals the OSWRCH code to send characters to the printer. | and never signals the OSWRCH code to send characters to the printer. | ||
Line 54: | Line 54: | ||
* VDU 2 should be sent to OSWRCH with VDU drivers enabled to start a print job. | * VDU 2 should be sent to OSWRCH with VDU drivers enabled to start a print job. | ||
* To output to both the screen and the printer, characters should be sent to OSWRCH with the VDU drivers enabled and the printer driver enabled, by clearing bit 1 and bit 2 of OSBYTE 3. | * To output to both the screen and the printer, characters should be sent to OSWRCH with the VDU drivers enabled and the printer driver enabled, by clearing bit 1 and bit 2 of OSBYTE 3. | ||
− | * To output to just the screen, the printer driver should be disabled by setting bit | + | * To output to just the screen, the printer driver should be disabled by setting bit 2 of OSBYTE 3. |
− | * To output to just the printer, the VDU driver should be disabled by setting bit 1 of OSBYTE 3, and the | + | * To output to just the printer, the VDU driver should be disabled by setting bit 1 of OSBYTE 3, and the independent printer driver should be enabled by setting bit 3 of OSBYTE 3. |
* VDU 3 should be send to OSWRCH with VDU drivers enabled to end a print job. | * VDU 3 should be send to OSWRCH with VDU drivers enabled to end a print job. | ||
− | * You should never enable the | + | * You should never enable the independent printer driver, or issue a VDU 1,n sequence, without first starting a print job by sending VDU 2 to the VDU driver. |
=== Example code === | === Example code === |
Latest revision as of 19:13, 8 March 2015
Starts a print job.
Syntax | VDU 2
|
Keyboard equivalent | CTRL B |
Character stream (hex) | 02
|
Description | Starts a print job and causes all subsequent 'printable' characters sent to the screen to be copied to the printer. |
Description
VDU 2
, or CTRL B, starts a print job. From this point all
characters 'printed' on the screen are also sent to the currently selected
printer device, selected with OSBYTE &05. Note that this is a
distinction from enabling printer output, which is controlled with
OSBYTE &03.
A selection of control codes are also sent to the printer driver to
control printer operatation. These are BS, HT,
LF, VT, FF and CR. All other
VDU
commands including their parameters are held
back. The printer ignore character is suppressed too, though it can be
chosen with OSBYTE &06.
If VDU output has been disabled with OSBYTE &03 and independent printer output has not been enabled, then the VDU driver never receives characters and never signals the OSWRCH code to send characters to the printer.
When the printer is unavailable (eg, absent, busy or offline), the outgoing characters will overflow the printer buffer and halt the machine. On the BBC Micro the CAPS LOCK and SHIFT LOCK lights will glow dimly or flash. Pressing ESCAPE will flush the buffer, abandoning any buffered data, and restore control.
To finish the printer job use VDU 3
.
VDU 2 and OSBYTE 3
You shouldn't use VDU 2/VDU 3 to select printer output, you should use OSBYTE &03. If you use VDU 2/3, unexpected things may happen. The currently selected printer driver has the complete right to do absolutely anything between a VDU 3 and a VDU 2. This includes, but is not limited to, such things as sending a form feed, printing a header and footer, putting the kettle on, burning the toast, kicking the cat, etc.
- VDU 2 should be sent to OSWRCH with VDU drivers enabled to start a print job.
- To output to both the screen and the printer, characters should be sent to OSWRCH with the VDU drivers enabled and the printer driver enabled, by clearing bit 1 and bit 2 of OSBYTE 3.
- To output to just the screen, the printer driver should be disabled by setting bit 2 of OSBYTE 3.
- To output to just the printer, the VDU driver should be disabled by setting bit 1 of OSBYTE 3, and the independent printer driver should be enabled by setting bit 3 of OSBYTE 3.
- VDU 3 should be send to OSWRCH with VDU drivers enabled to end a print job.
- You should never enable the independent printer driver, or issue a VDU 1,n sequence, without first starting a print job by sending VDU 2 to the VDU driver.
Example code
OSCLI "FX3,0" :VDU 2:REM Start print job OSCLI "FX3,4" :PRINT "SCREEN ONLY" OSCLI "FX3,10":PRINT "PRINTER ONLY" OSCLI "FX3,0" :PRINT "SCREEN AND PRINTER" OSCLI "FX3,0" :VDU 3:REM End print job
Note that you should really read the current output destination and change only the bits you require, and then restore the destination afterwards. OSBYTE 3 also returns the old status which can be used later to restore it.
A%=FNbyte(3,FNbyte(236,0,&FF) AND &FD,0) :REM Enable VDU driver A%=FNbyte(3,FNbyte(236,0,&FF) OR 4,0) :REM Disable printer driver A%=FNbyte(3,FNbyte(236,0,&FF) OR 10,0) :REM Disable VDU, enable printer
Jgharston 13:16, 13 December 2007 (UTC) -- beardo 21:55, 19 September 2007 (BST)