MODE 7 is compatible with the Videotex (Viewdata) and Teletext formats, and uses the same control codes. The only difference is that the 'start box' and 'end box' control codes, which in the case of a Teletext display allow text to be superimposed on a television picture, are not implemented.
Symbol Key [ ] ^ ½ \ ¼ { ¾ } − _ (underscore) ÷ ~ (tilde) £ ` or £ || | small block CTRL-backspace
As with the BBC Micro, the codes for # (hash) £ (pound) and _ (underscore) are 'shuffled' so as to display as expected, rather than using the Videotex codes. To force use of the standard Videotex codes (such as would be required for displaying a Teletext page) set bit 7 of the stored characters, i.e. add 128 to their normal ASCII values.
So to write some yellow text you could do any of the following:
where the symbol • corresponds to that obtained by entering Alt-0-1-3-1.MODE 7 PRINT CHR$131;"Yellow text" VDU 131 : PRINT "Yellow text" PRINT "•Yellow text"
Normally control codes display as a space (in the current background colour) but see the Held graphics section for exceptions. Control codes affect subsequent characters in the row; all rows start off as steady, single-height alphanumeric white characters on a black background.
Codes 128, 144 and 155 must be enabled using VDU 23,18,3,1;0;0;0; (and disabled using VDU 23,18,3,0,0;0;0;). See the MODE7LIB library for details of how to change the character sets; every row starts in the primary character set.
Code Attribute 129 alphanumeric red 130 alphanumeric green 131 alphanumeric yellow 132 alphanumeric blue 133 alphanumeric magenta 134 alphanumeric cyan 135 alphanumeric white 136 flash 137 steady 140 normal height 141 double height 145 graphics red 146 graphics green 147 graphics yellow 148 graphics blue 149 graphics magenta 150 graphics cyan 151 graphics white 152 conceal 153 contiguous graphics 154 separated graphics 156 black background 157 new background 158 hold graphics 159 release graphics BBC BASIC for Windows v6.14a or later, or BBCSDL, only: 128 alphanumeric black 144 graphics black 155 toggle between character sets
128 black text (only if enabled with VDU 23,18,3,1;0;0;0;) 129 red text 130 green text 131 yellow text 132 blue text 133 magenta text 134 cyan text 135 white text
MODE 7 PRINT CHR$130;"Green text"
For example to select a blue background you can insert code 132 followed by code 157 (which will together occupy two consecutive character positions on the screen). Remember to change the text colour back to something different, since blue text on a blue background isn't very useful!
To switch back to a black background insert control code 156.MODE 7 PRINT CHR$132;CHR$157;CHR$131"Yellow text on blue background"
Once a graphics mode is selected each of the 64 possible patterns of sixels corresponds to an alphanumeric character code. The following table shows the correspondence between each code and the displayed graphic:
144 black graphics (only if enabled with VDU 23,18,3,1;0;0;0;) 145 red graphics 146 green graphics 147 yellow graphics 148 blue graphics 149 magenta graphics 150 cyan graphics 151 white graphics
160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | ||||||||
168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | ||||||||
176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | ||||||||
184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | ||||||||
224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | ||||||||
232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | ||||||||
240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | ||||||||
248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |
As with control codes, these character codes can be entered with PRINT CHR$, VDU or by holding down Alt and typing a four digit decimal value on the numeric keypad.
MODE 7 PRINT "A red box:"CHR$145;CHR$247;CHR$251
To switch back to contiguous graphics on the same row, insert the control code 153.
The held graphics character is displayed in the same contiguous/separated mode as when it was first displayed. If there has been a change in the text/graphics mode or the normal/double-height mode since the last graphics character was displayed, the held graphics character is cleared and control codes once again display as spaces.
To switch held graphics mode off, on the same row, insert control code 159.
All rows begin as steady, single-height, white alphanumeric characters on a black background.
MODE 7 PRINT CHR$136"Some flashing text"
The characters in the first row of a double-height pair are not automatically duplicated in the second row (as would be the case for a conventional hardware implementation) so you must arrange for two consecutive display rows to contain identical data. The BBC Micro had the same requirement and it is what BBC BASIC programs expect. It has the advantage of allowing special effects such as the top and bottom halves of double-height characters being in different colours. Software drivers for Viewdata or Teletext emulations must take account of this feature and carry out the duplication themselves.
There is no need to, nor can you, specify which row should contain the top halves of the characters and which the bottom; this is worked out automatically by the MODE 7 display driver. The consequence of this is that if you delete all the double-height control codes (141) in the first row of the pair, the characters in the 'second' row will instantly change from bottom halves to top halves.
MODE 7 PRINT CHR$141"Double-height text" PRINT CHR$141"Double-height text"
The two procedures below are taken from the demonstration program 'MODE7DEM.BBC'. The first procedure converts all conceal characters (&98) to escape characters (&9B). The second converts all escape characters back to conceal characters.
DEF PROCreveal LOCAL N%,X%,Y% X%=POS:Y%=VPOS:VDU 30 FOR N%=1 TO 24*40 IF (&FF00 AND USR&FFF4)DIV256=&98 VDU &9B ELSE VDU 9 NEXT PRINTTAB(X%,Y%); ENDPROC DEF PROCconceal LOCAL N%,X%,Y% X%=POS:Y%=VPOS:VDU 30 FOR N%=1 TO 24*40 IF (&FF00 AND USR&FFF4)DIV256=&9B VDU &98 ELSE VDU 9 NEXT PRINTTAB(X%,Y%); ENDPROC
CONTENTS |
CONTINUE |