BBC BASIC for Raspberry Pi

discuss PC<>Acorn file transfer issues & the use of FDC, XFER, Omniflop/disk etc.
Post Reply
User avatar
Richard Russell
Posts: 279
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

BBC BASIC for Raspberry Pi

Post by Richard Russell » Sun Feb 19, 2017 11:16 am

Hot on the heels of the Android edition, I’ve now released an edition of BBC BASIC for the Raspberry Pi running Linux (Raspbian Jessie).  This is highly compatible with the SDL 2.0 editions for Windows, Linux, Mac OS-X and Android. Details of how to download and install this edition can be found at the forum. For best results it is necessary to enable the GL Driver in raspi-config.

Image

User avatar
roland
Posts: 2898
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: BBC BASIC for Raspberry Pi

Post by roland » Sun Feb 19, 2017 8:17 pm

That looks very nice =D> . On the other forum I read that it should be possible to use the I/O by calling SYS. Can you point us to some examples how to use this SYS? And is it also possible to use the network stack?
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
Richard Russell
Posts: 279
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BBC BASIC for Raspberry Pi

Post by Richard Russell » Sun Feb 19, 2017 11:18 pm

roland wrote:Can you point us to some examples how to use this SYS?
SYS will call SDL, SDL_ttf, FreeType and OpenGL APIs, plus functions in the C Runtime Library. Here for example is how to change the window title:

Code: Select all

      SYS "SDL_SetWindowTitle", @hwnd%, "My new window title"
And is it also possible to use the network stack?
It should be, but you will need to install SDL_net to do so in a cross-platform way. I haven't checked to see if it is available from the RPi repository, but hopefully it is.

Richard.

User avatar
Richard Russell
Posts: 279
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BBC BASIC for Raspberry Pi

Post by Richard Russell » Mon Feb 20, 2017 1:41 pm

roland wrote:I read that it should be possible to use the I/O using SYS
Having investigated what is involved, I can confirm that it is straightforward to access the Raspberry Pi's GPIO from BBC BASIC. I would suggest that the best approach would be to create a library (gpiolib.bbc maybe) containing the main routines for initialising the GPIO, setting pins to input or output etc. This will keep the code in one place and make it easier to update should that be necessary. If there is sufficient interest I will consider writing such a library.

Richard.

User avatar
Richard Russell
Posts: 279
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: BBC BASIC for Raspberry Pi

Post by Richard Russell » Mon Feb 27, 2017 2:55 pm

Richard Russell wrote:I will consider writing such a library.
I've today released a new version of BBC BASIC for the Raspberry Pi (RPi 2 or RPi 3) with a GPIO library included. To illustrate its use here is a simple demo/test program:

Code: Select all

      REM Simple GPIO test program for the Raspberry Pi 2, RPi 3 or RPi Zero

      INSTALL @lib$ + "gpiolib"
      INSTALL @lib$ + "stringlib"

      REM Initialise GPIO:
      gpio% = FN_gpio_setup

      REM Set GPIO pins 7 to 11 inclusive to output mode:
      FOR pin% = 7 TO 11
        PROC_gpio_inp(gpio%,pin%) : REM Must use PROC_gpio_inp() before PROC_gpio_out()
        PROC_gpio_out(gpio%,pin%)
      NEXT pin%

      REM Set GPIO pins 24 and 25 to input mode:
      FOR pin% = 24 TO 25
        PROC_gpio_inp(gpio%,pin%)
      NEXT pin%

      REM Enable pull-ups on GPIO pins 24 and 25:
      PROC_gpio_pull(gpio%,2) : REM Select pull-up
      WAIT 0
      PROC_gpio_pullclk0(gpio%,&3000000)
      WAIT 0
      PROC_gpio_pull(gpio%,0)
      PROC_gpio_pullclk0(gpio%,0)

      REM Output a cycling pattern to GPIO pins 7 to 11:
      previous% = %111110000000
      FOR pattern% = %000000000000 TO %111110000000 STEP %10000000
        PROC_gpio_clr(gpio%, (pattern% EOR previous%) AND NOT pattern%)
        PROC_gpio_set(gpio%, (pattern% EOR previous%) AND pattern%)
        previous% = pattern%
        WAIT 20
        PRINT FN_tobase(gpio%!&34 >> 7 AND %11111, 2, 5)
      NEXT pattern%

      END
Richard.

User avatar
flaxcottage
Posts: 3087
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire
Contact:

Re: BBC BASIC for Raspberry Pi

Post by flaxcottage » Mon Feb 27, 2017 6:53 pm

Thanks for this, Richard. It is looking very good. I shall have to dig my Linux Pi out and have a go.
- John

Why do I keep collecting Acorn gear? I'm going to need a considerably bigger man-cave. :?

User avatar
flaxcottage
Posts: 3087
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire
Contact:

Re: BBC BASIC for Raspberry Pi

Post by flaxcottage » Thu Mar 02, 2017 1:42 pm

This is a great addition to the Raspberry Pi, thanks. A bit quirky then I like quirky.

Now I can run the same program on a real BBC micro, a real Archimedes, a Z88, a DOS PC, a Windows PC, an Android tablet and on a Raspberry Pi running either RISCOS or Linux. =D> =D> =D> =D>
- John

Why do I keep collecting Acorn gear? I'm going to need a considerably bigger man-cave. :?

Post Reply