When the default output stream is selected (*OPT 0), all the console output is passed to a software emulator of the BBC Micro's VDU driver. In this mode, the VDU codes perform a function which is as similar as possible to those of the BBC Micro. Inevitably, the difference in hardware imposes limitations on this emulation. The effect of the various VDU codes is described below, with particular emphasis on the differences between the emulation and the BBC Micro.
The VDU statement takes a list of numeric arguments (constants or variables) and sends their least significant bytes as characters to the currently selected output stream.
A 16 bit value (word) can be sent if the value is followed by a semi-colon. It is sent as a pair of characters, the least significant byte first.
See the keyword VDU for other uses of the VDU command.
Number | Meaning |
---|---|
0 | Null - it does nothing. |
1 | Send the next character to the printer ONLY. |
2 | Enable the printer. |
3 | Disable the printer. |
4 | Write text at the text cursor position. |
5 | Write text at the graphics cursor position. |
6 | Enable output to the screen. |
7 | Bell - make a short 'beep'. |
8 | Move the text cursor backwards one character. |
9 | Move the text cursor forwards one character. |
10 | Move the text cursor down one line. |
11 | Move the text cursor up one line. |
12 | Clear the text area - identical to CLS. |
13 | Move the text cursor to the start of the current line. |
14 | Enable the auto-paging mode. |
15 | Disable the auto-paging mode. |
16 | Clear the graphics area - identical to CLG. |
17 | Define a text colour - identical to COLOUR. |
18 | Define a graphics colour - identical to GCOL. |
19 | Select a colour palette. |
20 | Restore the default logical colours. |
21 | Disable output to the screen. |
22 | Select the screen mode - identical to MODE. |
23 | Program characters and control the cursor. |
24 | Define a graphics window. |
25 | Identical to PLOT. |
26 | Restore the default text and graphics windows. |
27 | Send the next character to the screen. |
28 | Define a text window. |
29 | Set the graphics origin. |
30 | Home the text cursor to the top left of the screen. |
31 | Move the text cursor - identical to TAB(x,y). |
127 | Backspace and delete. |
VDU 1 provides a simple way of sending control characters to the printer (see VDU 2). It works whether the VDU has been disabled with the VDU 21 command or not.
The only control characters sent to the printer are BS (8), HT (9), LF (10), VT (11), FF (12) and CR (13). Other control characters are NOT sent to the printer.
Bytes which are parameters for VDU commands are not sent to the printer. For example,
does not send 'A' to the printer. VDU 1 must be used to send control characters to the printer.VDU 17,65
Typing ^P has the effect of alternately selecting VDU 2 and VDU 3 (it toggles the printer on and off).
The characters are 'opaque' and they can be positioned only at text coordinates within the text window. The text within the window scrolls as necessary.
User defined characters may only be written at the text cursor position if a CGA mode (mode < 8) is selected.
As explained in the Colours and Graphics section, if an EGA or VGA mode is selected (mode > 7) user defined characters may only be written at the graphics cursor position. If a CGA mode is selected, user defined characters may be written at either the graphics or text cursor position.
The characters have a 'transparent' background and they are plotted according to the current foreground GCOL rules and colour. VDU 127 (DEL) is an exception; it backspaces and deletes just as it does in the normal text mode, using the current background GCOL rules and colour.
In the graphics modes, characters may be positioned at any graphics coordinate within the graphics window. The top left of the character cell is the reference point. Characters are clipped to the limits of the graphics window if necessary. No scrolling takes place.
If a text window has been defined, the cursor is constrained to remain within the window.
If a text window has been defined, the cursor is constrained to remain within the window.
If a text window has been defined, the cursor is constrained to remain within the window.
If a text window has been defined, the cursor is constrained to remain within the window.
If a text window has been defined, the cursor is constrained to remain within the window.
VDU 17,1
andVDU 18,mode,colour
have the same effect. See the Graphics and Colours section for more details.GCOL mode,colour
You can (with certain limitations) set the actual colour displayed by a colour number to any one of the physical colours available. You could, if you wished, set all the colour numbers to the same physical colour. Because you can change the actual colour displayed by a colour number to any one of the physical colours available to you, these numbers are called logical colours.
It may help you to visualise the logical colours as an artist's palette with up to 16 numbered areas where colours may be placed. You could place any of the colours available to you in any one of the areas on the palette. Once the colours were in place on the palette, you could 'paint by numbers'.
As explained in the Graphics and Colours section, the number of logical colours available depends upon the chosen display mode.
VDU 19,logical,physical,0,0,0
It is not possible to provide a true palette when a CGA is used because of limitations imposed by the hardware. The facilities available depend upon the mode used.
Colour Number Physical Colour 0 Black (normal background) 1 Red 2 Green 3 Yellow (Brown) 4 Blue 5 Magenta (blue-red) 6 Cyan (blue-green) 7 White (normal foreground) 8 Intensified Black (grey) 9 Intensified Red 10 Intensified Green 11 Intensified Yellow 12 Intensified Blue 13 Intensified Magenta 14 Intensified Cyan 15 Intensified White
With a CGA, the foreground colour (logical colour 1) can be set to any colour between 0 and 15.
and the background colour (logical colour 0) cannot be changed from black. Thus,VDU 19,1,physical,0,0,0
has no effect.VDU 19,0,physical,0,0,0
With an EGA, the palette for mode 0 behaves in a peculiar manner. Instead of altering the foreground colour, setting logical colour 1 alters the background colour and the foreground colour is set to cyan.
If the logical colour number is greater than 0 (a foreground logical colour), the VDU 19 command selects which of two foreground colour palettes will be used depending on the value of the physical colour number. It is not possible to change the foreground colours independently and logical colour numbers between 1 and 3 have the same effect.
The physical colour number selects which of the two palettes are to be used for the foreground colours. If the physical colour number is 0, 1, 2 or 3, then palette No 1 is selected. If the physical colour number is 4, 5, 6 or 7, then palette No 2 is selected. The colours of the two palettes are listed below.
The first example below selects palette No 1 and the second selects palette No 2.
Palette 1 Palette 2 Logical Colour Physical Colour Physical Colour 1 Red Magenta 2 Green Cyan 3 Yellow White
By specifying a logical colour of 0, the background/border colour can be set to any colour between 0 and 15. The example below sets logical colour 0 to blue.VDU 19,1,2,0,0,0 VDU 19,3,4,0,0,0
VDU 19,0,4,0,0,0
For example,
would set logical colour 1 to blue.VDU 19,1,4,0,0,0
Unfortunately, this is not as straightforward as it might seem. The actual colours depend upon the mode in use, whether the monitor has 4 or 6 inputs and how it is adjusted.
A 6 input monitor has 2 blue, 2 green and 2 red inputs. A 4 input monitor has a blue, green, red and intensity input. The former is capable of displaying 64 colours and the latter 16 colours. If the monitor is truly IBM compatible, it will only act as a 6 input monitor in mode 16. In all other modes, it will act as a 4 input monitor. This restriction is imposed by the monitor and not by the graphics adapter.
The colour number on a 6 input monitor (in mode 16) is made up as shown below.
Not Used | Not Used | Red' | Green' | Blue' | Red | Green | Blue |
MSB | LSB |
Thus, colour 18 would give you a combination of Green' and Green; in other words, bright green, and colour 17 would give you a combination of Green' and Blue.
The colour number on a 4 input monitor (or an IBM compatible 6 input monitor in modes other than 16) is made up in a similar manner as shown below.
Not Used | Not Used | Not used | Intensity | Not Used | Red | Green | Blue |
MSB | LSB |
With a 4 input monitor, the colour 18 will still give bright green (Intensity and Green), but colour 17 gives bright blue (Intensity and Blue).
Consequently, the colours displayed on a 4 input monitor are only the same as those displayed on a 6 input monitor for physical colours 0 to 7 (plus some other odd numbers). Thus, you need to know the type of monitor you are programming for.
For example,
would set logical colour 1 to bright cyan with either a 4 or 6 input monitor (27 is binary 00011011),VDU 19,129,27,0,0,0
and
would set logical colour 2 to a combination of Green', Green and Blue on a 6 input monitor and bright green on a 4 input monitor (26 is binary 00011010).VDU 19,130,26,0,0,0
Whilst a 4 input monitor only displays 16 colours, the colour numbers in the enhanced palette differ from the normal palette because the normal palette numbers have been translated to maximise compatibility with the BBC Micro.
The enhanced (IBM) colour numbers are not contiguous. With a 4 input VDU, colours 8 to 15, 32 to 39 and 40 to 47 are the same as the 'normal' colours 0 to 7 and colours 24 to 31, 48 to 55 and 56 to 63 are the same as the intensified colours 16 to 23. On the other hand, the enhanced palette colours are in ascending order of luminance and they display as a grey scale on a colour-input-compatible monochrome monitor.
For example, the following command will set logical colour 1 to green.
The text enhanced palette is the same as the graphics enhanced palette.VDU 19,129,2,0,0,0
The alternative mode provides an 'analogue' palette by allowing you to set the Red, Green and Blue intensities to any value between 0 and 63. The format of the VGA 'analogue' colour palette command is shown below.
As before, bit 7 of the logical colour needs to be set in order to indicate that an enhanced palette is to be used. In addition, the 'physical' colour is set to -1 to indicate that the following 3 numbers specify the Red, Green and Blue intensities respectively. These may be set to any value between 0 and 63.VDU 19,logical,-1,red,green,blue
The following example sets colour 0 to a dull blue.
VDU 19,128,-1,0,0,10
The border is specified by using -1 as the logical colour number.
The following example sets the border colour to green.
VDU 19,-1,2,0,0,0
COLOUR 7 COLOUR 128 GCOL 0,7 GCOL 0,128
Some EGA cards come with a software utility which improves their CGA emulation.
VDU 22 also resets all the screen driver variables (colour, palette, windows, cursor position, graphics origin, etc). In particular, VDU 22 performs the actions of VDU 4, VDU 12, VDU 20 and VDU 26.VDU 22,3
See the Graphics and Colours section or the keyword MODE for further details.
In the EGA and VGA modes (8, 9, 10, 12, 13, 15, 16 and 18), user defined characters programmed with VDU 23 are active only in the VDU 5 mode (plot character at graphics cursor position). In VDU 4 mode, the standard ROM font is used for characters 128 to 255.
The format of the VDU 23 command is;
'Char_no' is the character number to be programmed and 'r1' to 'r8' are the values of the bytes which define the character, top to bottom. For example, the character illustrated below is defined as character 130 by the following VDU 23 command.VDU 23,char_no,r1,r2,r3,r4,r5,r6,r7,r8
Because of hardware limitations, characters up to &7F (127) are not re-programmable.VDU 23,130,24,36,66,255,24,24,24,255 . . . * * . . . r1 = 24 . . * . . * . . r2 = 36 . * . . . . * . r3 = 66 * * * * * * * * r4 = 255 . . . * * . . . r5 = 24 . . . * * . . . r6 = 24 . . . * * . . . r7 = 24 * * * * * * * * r8 = 255
Since user defined characters occupy a 'cell' which is 8 pixels by 8 pixels, the number of rows of user defined text which may be displayed on the screen depends upon the vertical resolution of the display mode in use.
In all modes other than modes 16 and 18, 25 lines of 'VDU 5' text may be displayed. In mode 16, 43 lines of 'VDU 5' text may be displayed. In mode 18, 60 lines of 'VDU 5' text may be displayed.
VDU 23,1,0;0;0;0; Disable cursor VDU 23,1,1;0;0;0; Enable cursor
The VDU 23 command may be used to write to the control registers of the 6845 CRT controller. The command
writes 'value' to register number 'reg' of the 6845 CRT controller.VDU 23,0,reg,value,0;0;0;
If any of the edges of the new graphics window would be off the screen, the command is ignored. It is particularly easy to select invalid window limits if the graphics origin has been moved. It is advisable, therefore, to precede a VDU 24 command with a VDU 26 command to reset the windows and the graphics origin.
The following example defines a graphics window with the bottom left corner at 200,100 (X,Y) and the top right corner at 500,300 (X,Y).
VDU 24,200;100;500;300;
The following example draws a line in the current foreground colour to the point 350,525 (X,Y).VDU 25,mode,x_coord;y_coord;
VDU 25,5,350;525;
If the text cursor is outside the new window, it is moved to the new home position (top left of the window). If it is inside the new window, it is not moved.
If any of the edges of the new text window would be off the screen, the command is ignored.
The following example defines a text window with the bottom left corner at 0,15 (X across, Y down) and the top right corner at 30,3 (X across, Y down).
VDU 28,0,15,30,3
The following example sets the graphics origin to the centre of the screen (except for modes 16 and 18).
VDU 29,640;400;
See the keyword TAB for further details.VDU 31,15,10
CONTENTS |
CONTINUE |