SB BBC @ GBR Oldie hints/tips #047-051 Hints and tips from the archives of Wakefield BBC Micro User Group... 47. Mode 7 box ~~~~~~~~~~ This is a very handy little Procedure for drawing a box around text in Mode 7. You can print the text before or after drawing the box. You call the Procedure by giving the 4 co-ordinates in the same order as in the VDU28 command, (see User Guide page 387). You also give the first letter of the colour required, such as "G" for green. In order to leave room for control codes, you must not print any text within one space to the left or right of each vertical line, but you can print text immediately above or below the horizontal lines. For the same reasons, X1% must be at least 1, and X2% must be less than 38, but Y1% can be as low as 0, and Y2% can be as high as 24. Do not try to make the box very small, or strange things may happen! In this example, I have defined the entire usable space inside the box as a text window, so try LISTing the program as soon as you have run it. Thanks to Andrew G8YHI for bringing the original of this Procedure to my attention. 10 MODE7:PROCbox(5,12,34,6,"G") 20 PRINTTAB(13,9)"THIS IS A BOX" 30 VDU28,7,11,32,7:END 100 DEF PROCbox(X1%,Y1%,X2%,Y2%,C$):LOCAL C%,Y%:X1%=X1%-1 110 C%=144+INSTR("RGYBMCW",C$):VDU31,X1%,Y2%,C%,55 120 REPEAT VDU96:UNTIL POS=X2%:VDU107,135 130 FOR Y%=Y2%+1 TO Y1%-1 140 VDU31,X1%,Y%,C%,53,135,31,X2%-1,Y%,C%,106,135:NEXT 150 VDU31,X1%,Y1%,C%,117:REPEAT VDU112:UNTIL POS=X2% 160 VDU122,135:ENDPROC 48. Centred text ~~~~~~~~~~~~ This is a Procedure for automatically centering a short piece of text on a line, without having to figure out what value TAB to use. You call it with PROCcentre(40,"HELLO THERE") or PROCcentre(80,A$) and so on, where the figure is the width of the screen in the current Mode; 20, 40 or 80. 100 DEFPROCcentre(width%,text$) 110 PRINTTAB((width%-LEN(text$))DIV2)text$ 120 ENDPROC 49. Screen border ~~~~~~~~~~~~~ As an alternative to using teletext Mode 7, try the following at the start of your program. Using Mode 1 or 4, it selects yellow text on a blue background, draws a neat border round the edge of the screen, and protects it with text and graphics windows. This still leaves you almost the full screen free to use. Of course, there won't be as much free user memory as in Mode 7, so you can't use this for very large programs. In Mode 1, you could in fact have a red border, blue background, yellow text and white graphics if you wanted to be very flash. 10 MODE 1 :REM or Mode 4 20 VDU19,0,4,0,0;19,3,3,0,0; :REM select yellow/blue 30 MOVE 0,0:DRAW 0,1023:DRAW 1279,1023 :REM draw border 40 DRAW 1279,0:DRAW 0,0 :REM draw border 50 VDU 28,1,30,38,1 :REM set up text window 60 VDU 24,8;8;1271;1015; :REM set up graphics window 50. Novel screen clearing ~~~~~~~~~~~~~~~~~~~~~ These two procedures give different ways of clearing the screen of text and graphics in Modes 0,1,2,4 & 5. The first wipes from the borders inwards, rather like a fadeout on TV or films. The second clears the screen in a way similar to curtains closing. You must alter line 110 slightly for Mode 0, which will clear more slowly than the others. You can speed up the second procedure, but not the first, in Modes 2 & 5 if you wish; see the REM statement. Simply use PROCclearscreen or PROCclosescreen instead of CLS or CLG. 100 DEFPROCclearscreen:LOCAL t%:GCOL0,0 110 FOR t%=0 TO 512 STEP 4:REM Use STEP 2 in Mode 0 120 MOVE t%,t%:DRAW t%,1023-t%:DRAW 1279-t%,1023-t% 130 DRAW 1279-t%,t%:DRAW t%,t%:NEXT:GCOL0,7:ENDPROC 100 DEFPROCclosescreen:LOCAL t%:GCOL0,0 110 FOR t%=0 TO 640 STEP 4:REM Use STEP 2 in Mode 0, and STEP 8 in Modes 2 & 5 120 MOVE t%,0:DRAW t%,1023:MOVE 1279-t%,0:DRAW 1279-t%,1023 130 NEXT:GCOL0,7:ENDPROC 51. Reverse colour text ~~~~~~~~~~~~~~~~~~~ It is useful to be able to print certain words in reverse colours, ie. black on white. This is very easy on a Commodore or Sinclair, but not so easy on the BBC micro. Here are two sets of Functions to achieve this; the first pair is for Mode 7 only, and the second pair is for all other Modes. Note that in Mode 7 there are unavoidable spaces just before and after the lettering, which is actually blue on white. Also, you must use FNrevr again on each new line, but these problems do not arise in the other Modes. The second pair of Functions is used like Procedures, hence the rather odd looking :="" purely to satisfy the syntax. 10 PRINT "NORMAL" FNrevr "REVERSE" FNnorm "NORMAL":END 20 DEF FNrevr:=CHR$(135)+CHR$(157)+CHR$(132):REM Mode 7 only 30 DEF FNnorm:=CHR$(135)+CHR$(32)+CHR$(156) 20 DEF FNrevr:COLOUR 0:COLOUR 135:="":REM Modes 0 to 6 30 DEF FNnorm:COLOUR 7:COLOUR 128:="" 73 Rick G4BLT @ GB7WRG