|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Appendix 2 : VDU codesThe VDU command sends the numbers or values of variables which follow it to the screen. Numbers between 32 and 126 are ASCII codes for characters which are printed on the screen. Code 127 is backspace and delete. Numbers above 127 also produce characters on the screen. VDU codes below 32 have various control functions and are explained in this appendix.
VDU 0Does nothing.VDU 1The next VDU character is sent to the printer only and not to the screen. The printer must have already been turned on with VDU 2. Printers frequently use sequences of codes beginning with an escape character, which is sent as number 27. If these numbers were also sent to the screen, VDU 27 would do nothing but the following characters may cause havoc. A printer may, for example, use a sequence consisting of Esc E, meaning 'Set emphasised mode'. This would be sent as 27, followed by 69 which, if sent to the screen, would display an unwanted 'E'. This may be prevented by using:
VDU 1,27,1,69
VDU 2Turns on the printer. Anything sent to the screen will also be sent to the printer. VDU 3Turns off the printer, cancelling the effect of VDU 2. VDU 4Text is printed at the text cursor position with the text foreground colour. This is the usual situation. This call cancels the effect of VDU 5. VDU 5Text is printed at the graphics cursor position using the graphics foreground colour which is set by GCOL. The text position is set with a MOVE command, not a TAB command. VDU 6Turns on output to the screen. This cancels the effect of VDU 21. VDU 7Produces a beep. VDU 8Moves the cursor back one space. This does not delete the previous character, but positions the cursor under it. VDU 9Moves the cursor forwards one space. VDU 10Line Feed. Moves the cursor down one line. VDU 11Moves the cursor up one line. VDU 12If VDU 5 mode is not set, this call clears the text window (or whole screen, if it isn't set) to the text background colour (CLS). If VDU 5 mode is set, the call clears the graphics window (or whole screen, if not set) to the graphics background window (CLG). VDU 13Carriage Return. The cursor is moved back to the beginning of the line which it is on. This is usually accompanied by a line feed (VDU 10) to move the cursor down one line. VDU 14Puts the screen into page mode, which limits scrolling to less than one screen height. The scrolling action then waits for Shift to be pressed. VDU 15Turns off page mode, cancelling VDU 14. VDU 16Clears the graphics window (CLG). VDU 17+1 characterSets the text colour. VDU 17,2 is the equivalent of COLOUR 2. VDU 18+2 charactersSets the graphics colour and the way graphics appear on the screen. VDU 18,0,3 is the equivalent of GCOL 0,3. VDU 19+5 charactersRedefines the colour palette. This command takes the form VDU 19,col%,action%,red%,green%,blue%. For action% values between 0 and 15, red%, green% and blue% are not used. Colour col% is redefined as colour action%. This is the equivalent of COLOUR col%,action%. If action% is 16, colour col% is redefined in terms of red%, green% and blue%. This is the equivalent of COLOUR col%,red%,green%,blue%. VDU 20Puts all colours back to normal. This cancels out the effect of VDU 19. VDU 21Prevents character output from reaching the screen until VDU 6 is sent. Characters will still be sent to the printer if it has already been turned on with VDU 2. VDU 22+1 characterChanges screen mode. VDU 22,12 is equivalent to MODE 12. VDU 23+9 charactersMiscellaneous commands. The first byte following VDU 23 determines which action is carried out - the remaining eight bytes carry the necessary data. Many of these commands are outside the scope of this guide. The following, though, are of interest: VDU 23,1,action%,0,0,0,0,0,0,0 Controls the appearance of the cursor:
VDU 23,17,5,0,0,0,0,0,0,0 Exchanges text foreground and background colours. A second call changes them back again. VDU 23,32 to 255, + 8 characters Redefines the shapes of characters. Each text character consists of a rectangle measuring eight pixels in either direction. Any character can be redefined by this call, by changing which pixels have the foreground colour and which have the background. The number immediately following VDU 23 is the ASCII code for the character to be redefined. Each of the eight numbers following contains the pattern for one row of pixels, from top to bottom. In each number, the least significant bit sets the state of the right-hand pixel and the most significant bit the state of the left-hand pixel. For example, VDU,23,128,24,60,90,153,24,24,24,24 will redefine the character with ASCII code 128 to be an arrow pointing upwards. VDU 128 will plot it on the screen. This technique was used by earlier Acorn computers such as the BBC Model B to produce user-defined graphics. It has been superseded in 32-bit machines by the use of sprites. VDU 24+8 charactersDefines the graphics window. Each coordinate is specified by two bytes - the coordinate MOD 256 followed by the coordinate DIV 256. These may be sent as one number by following it with a semi-colon (;). For example, VDU 24,300;200;800;600; consists of a total of nine bytes. This call defines a graphics window whose bottom left-hand corner is at (300,200) and whose top right-hand corner is at (800,600). VDU 25+5 charactersPLOT command. The first byte after VDU 25 contains the PLOT code. The remaining four specify the x and y coordinates in pairs. Each pair may be given as one number followed by a semi-colon, as in VDU 24. For example, VDU 25,85,400;500; will plot a filled triangle between (400,500) and the previous two locations of the graphics cursor. See Appendix 3 for a full list of PLOT codes. Although VDU 25 may be used for a PLOT command in this way, it is actually much quicker to use Basic's PLOT instruction. The VDU method requires six calls to the operating system - PLOT does it in one call, using a special software interrupt or SWI (see section 14). VDU 26Reset both text and graphics windows to cover the entire screen. This cancels the effect of VDU 24 and VDU 28. VDU 27Does nothing. VDU 28+4 bytesRedefines the text window. For example, VDU 28,5,25,45,10 defines the text window as having its bottom left-hand corner five spaces in from the left and 25 rows down from the top, and its top right-hand corner 45 spaces in from the left and 10 rows down from the top. VDU 29+4 bytesChanges the position of the graphics origin. The four bytes following VDU 29 contain the x and y coordinates in pairs. Each pair may be given by one number followed by a semi-colon (;) as in VDU 24. For example, VDU 29,500;400; will redefine the graphics origin (0,0) to be the point on the screen that was originally (500,400). VDU 30Moves the text cursor to its 'home' position in the top left-hand corner of the screen. If VDU 5 operation is in force, the graphics cursor is moved to this position instead. VDU 31+2 bytesPosition the text cursor. For example, VDU 31,20,10 is the equivalent of TAB(20,10) in a PRINT command and will cause the next text character to be displayed 20 spaces in from the left and 10 rows down from the top. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|