BBC BASIC
« VDU stream 'icons' »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:44pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

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


member is offline

Avatar




Homepage PM


Posts: 803
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 »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls