BBC BASIC
« VDU stream 'icons' »

Welcome Guest. Please Login or Register.
Jan 20th, 2018, 6:11pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: VDU stream 'icons'  (Read 312 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx VDU stream 'icons'
« Thread started on: Sep 5th, 2016, 1:19pm »

One of the unusual features of BBC BASIC, which it inherits from the original 1982 BBC Microcomputer, is that graphics are drawn by outputting special codes to the 'VDU stream'. This allows you to store graphics objects in string variables, which can occasionally be useful.

I took advantage of this feature in the file selector of SDLIDE. I wanted to be able to display a simple icon alongside each entry, indicating whether it is a BBC BASIC program or a directory. Modifying my listbox emulation to support such icons would have been a lot of work, so instead I incorporated the icon in the filename string! Now, simply printing the filename (in VDU 5 mode) automatically plots the icon alongside.

If you're not familiar with this feature of BBC BASIC the end result can seem a bit like magic! Try running the program below to see what I mean:

Code:
      VDU 23,22,640;512;8,16,16,128

      REM Create the 'icon' as a VDU stream in string variable BBfile$:
      C% = (1.5 * @vdu%!220 + 7) AND -8
      VDU 21
      OSCLI "spool """ + @tmp$ + "bbfile.vdu"""
      GCOL 11+128
      PLOT 0,C%,0 : PLOT 99,C%*0.75,-C%*0.75 : PLOT 0,C%/4,C%/4 : PLOT 0,-C%*0.75,0
      PLOT 115,-C%/2,-C%/2 : PLOT 0,C%/4,C%/4 : PLOT 98,C%*0.75,C%*0.75 : PLOT 0,0,-C%/2
      PLOT 1,C%/4,0 : PLOT 1,-C%/2,-C%/2 : PLOT 1,-C%*0.75,0 : PLOT 1,C%/4,C%/4
      PLOT 0,C%*1.25,C%*0.75
      *spool
      VDU 6
      F% = OPENIN(@tmp$ + "bbfile.vdu")
      BBfile$ = GET$#F% BY EXT#F%
      CLOSE #F%

      REM Now demonstrate plotting the 'icon':
      VDU 5
      REPEAT
        MOVE RND(1000), RND(1000)
        PRINT BBfile$ " Hello icon!"
        WAIT 100
      UNTIL FALSE 

Obviously this technique is not well suited to complex graphics, but it works well for simple line drawings.

Richard.
« Last Edit: Sep 5th, 2016, 2:56pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls