10 REM > OsbA0Vars
   20 REM Test reading VDU variables with OSBYTE &A0
   30 :
   40 PRINT "Screen mode:                 ";FNfx(135,0)DIV256
   50 PRINT "Number of colours:           ";FNbyte(160,96,0)+1
   60 PRINT "Text window width:           ";FNbyte(160,10,0)-FNbyte(160,8,0)+1
   70 PRINT "Text window height:          ";FNbyte(160,9,0)-FNbyte(160,11,0)+1
   80 PRINT "Text foreground colour:      ";(FNbyte(160,87,0)DIV8)ANDFNbyte(160,96,0)
   90 PRINT "Text background colour:      ";(FNbyte(160,88,0)DIV8)ANDFNbyte(160,96,0)
  100 PRINT "Left colour mask:            &";~FNbyte(160,98,0)
  110 PRINT "Right colour mask:           &";~FNbyte(160,99,0)
  120 PRINT "Graphics window width:       ";FNfx(160,4)-FNfx(160,0)+1
  130 PRINT "Graphics window height:      ";FNfx(160,6)-FNfx(160,2)+1
  140 PRINT "Graphics X origin:           ";FNfx(160,12)
  150 PRINT "Graphics Y origin:           ";FNfx(160,14)
  160 PRINT "Graphics foreground (BBC):   ";(FNbyte(160,89,0)DIV8)ANDFNbyte(160,96,0)
  170 PRINT "Graphics background (BBC):   ";(FNbyte(160,90,0)DIV8)ANDFNbyte(160,96,0)
  180 PRINT "Graphics foreground (Other): ";FNbyte(160,109,0)
  190 PRINT "Graphics background (Other): ";FNbyte(160,110,0)
  200 PRINT "Foreground GCOL mode:        ";FNbyte(160,91,0)
  210 PRINT "Background GCOL mode:        ";FNbyte(160,92,0)
  220 PRINT "Cursor address:              &";~FNfx(160,74)
  230 PRINT "Screen start address:        &";~256*FNbyte(160,78,0)
  240 PRINT "Screen display address:      &";~FNfx(160,80)
  250 PRINT "Screen size:                 &";~256*FNbyte(160,84,0)
  260 PRINT "Press SPACE";:A%=GET
  270 :
  280 REM Full colour reading test
  290 A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256
  300 FOR mode%=0 TO 7
  310   MODE mode%
  320   FOR colour%=0 TO 15
  330     COLOUR colour%:PRINT "COLOUR ";
  340     value%=FNcolour
  350     COLOUR 7:PRINT;colour%;" ";value%
  360   NEXT colour%
  370   PRINT "Press SPACE";:A%=GET
  380 NEXT mode%:PRINT
  390 END
  400 :
  410 DEFFNcolour
  420 col%=FNbyte(160,87,0)
  430 num%=FNbyte(160,96,0)
  440 IFos%>7:=col%ANDnum%
  450 FOR loop%=1 TO 3-INTSQR((num%+1)/4)
  460   col%=4*INTSQR((col%DIV16)+1)+SQR((col%AND15)+1)-5
  470 NEXT loop%
  480 =col%
  490 :
  500 DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256
  510 DEFFNfx(A%,X%):LOCAL Y%:Y%=X%DIV256:=((USR&FFF4)AND&FFFF00)DIV256