VDU is a BASIC statement to send characters to the screen, printer, serial port or other output device. It is usually used to generate VDU sequences that control the display.
|Availability||Present in all original versions of BBC BASIC.|
|Syntax||BASIC I-III|| |
|BASIC IV-V|| |
|Token (hex)||BASIC I-V|| |
|Description||BASIC I-V|| Sends the <numeric> arguments as little-endian character pairs (if followed by |
In BASIC V, a <numeric> followed by a vertical bar
|Associated keywords|| |
VDU is a versatile statement to control features of the BBC
Micro's display that do not have their own BASIC keywords -- and a few that
do. It can also be used to send binary data to the printer, serial port,
*SPOOL file or any other device attached to the output
All the facilities of
VDU are available to machine code
programs as it is just a veneer for the MOS routine, OSWRCH.
VDU interprets each of the <numeric> values following the
keyword as an ASCII value. Any value between 0 and 255 inclusive is
accepted, and maps to a unique character. If the <numeric> is followed by a
; then the value is a little-endian word from 0
to 65535 inclusive. It is broken down into two ASCII values; first the word
MOD 256, then its value
This word syntax is useful for graphics coordinates or for
crunching BASIC programs.
In BASIC IV onwards, if the <numeric> is followed by a vertical bar
| then the <numeric> is treated as a single ASCII
value, followed by nine ASCII values of zero. This ensures that the current
VDU sequence is completed as the longest sequence length is nine characters.
It is a useful shorthand to fill in the trailing zeroes of
VDU 23 commands.
In each case, the ASCII value or values are sent to OSWRCH one at a time. From there they are delivered to the output device or devices. Beware as certain characters are blocked from going to the printer. See VDUCHR and OSBYTE &06.
The commands in the list below are provided by the MOS, not by BASIC. They are only of interest to VDUCHR, the screen driver routine that is part of OSWRCH. The attached printer or serial device may have its own meanings for these commands, although VDUCHR may still be listening and can affect the flow of characters to the printer.
VDUCHR parses the incoming characters looking for these commands. When it finds one it opens a VDU sequence or VDU queue to collect the required number of extra bytes (if any), then executes the command it forms. While a VDU queue is open, all incoming characters go into the queue and do not have their usual effect on the screen.
The table is based on the B+ User Guide:
|Hex||Decimal||CTRL||ASCII abreviation||Bytes extra||Meaning|
|&01||1||A||SOH||1||Send next character to printer only|
|&02||2||B||STX||0||Start print job|
|&03||3||C||ETX||0||End print job|
|&04||4||D||EOT||0||Write text at text cursor|
|&05||5||E||ENQ||0||Write text at graphics cursor|
|&06||6||F||ACK||0||Enable VDU drivers|
|&07||7||G||BEL||0||Make a short beep|
|&08||8||H||BS||0||Backspace cursor one character|
|&09||9||I||HT||0||Advance cursor one character|
|&0A||10||J||LF||0||Move cursor down one line|
|&0B||11||K||VT||0||Move cursor up one line|
|&0C||12||L||FF||0|| Clear text area (|
|&0D||13||M||CR||0||Move cursor to start of current line|
|&0E||14||N||SO||0||Page mode on|
|&0F||15||O||SI||0||Page mode off|
|&10||16||P||DLE||0|| Clear graphics area (|
|&11||17||Q||DC1||1|| Define text colour (|
|&12||18||R||DC2||2|| Define graphics colour (|
|&13||19||S||DC3||4|| Define logical colour (|
|&14||20||T||DC4||0||Restore default logical colours|
|&15||21||U||NAK||0||Disable VDU drivers or delete current line|
|&16||22||V||SYN||1|| Select screen mode (|
|&17||23||W||ETB||9|| Define display character and other commands
(used by |
|&18||24||X||CAN||8||Define graphics window|
|&1A||26||Z||SUB||0||Restore default windows|
|&1C||28||\||FS||4||Define text window|
|&1D||29||]||GS||4|| Define graphics origin (|
|&1E||30||^||RS||0||Home text cursor to top left|
|&1F||31||_||US||2|| Move text cursor to x,y (|
|&7F||127||n/a||DEL||0||Backspace and delete|