Raspberry BASIC

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Richard Russell

Pages: 1 ... 3 4 [5]
61
BBC BASIC / Re: Simple GPIO demo
« on: April 30, 2019, 10:19:02 PM »
Have you had any luck with the RPi Sense HAT board? Will your GPIO library allow use of the Sense HAT emulator that comes with Raspbian?

I don't have a Sense HAT here.  My understanding is that it's an I2C device and therefore not really accessible via the GPIO (I know that the I2C clock and data lines appear on GPIO pins, but it would be a bit daft to try to interface with I2C devices that way!).   So to that extent my GPIO library isn't really relevant to the Sense HAT, but BBC BASIC could no doubt access it via the virtual I2C device at /dev/i2c-*.

62
BBC BASIC / Simple GPIO demo
« on: April 30, 2019, 05:00:57 PM »
This is a very simple demo of the Raspberry Pi's GPIO being controlled by BBC BASIC, using the supplied 'gpiolib' library.  It cycles through six of the outputs, setting each one high in sequence.  The code is listed below, and this is the result (with LEDs fitted to monitor the outputs):



Code: [Select]
      REM Initialise GPIO:
      INSTALL @lib$ + "gpiolib"
      GPIO% = FN_gpio_setup

      REM Pin numbers to activate, in sequence:
      DATA 17, 23, 25, 12, 16, 26

      REM Set to input first:
      RESTORE
      FOR I% = 1 TO 6
        READ pin%
        PROC_gpio_inp(GPIO%, pin%)
      NEXT

      REM Set pins to output:
      RESTORE
      FOR I% = 1 TO 6
        READ pin%
        PROC_gpio_out(GPIO%, pin%)
      NEXT

      REM Cycle LEDs in sequence:
      REPEAT
        RESTORE
        FOR I% = 1 TO 6
          READ pin%
          PROC_gpio_set(GPIO%, 2^pin%)
          WAIT 20
          PROC_gpio_clr(GPIO%, 2^pin%)
        NEXT
      UNTIL FALSE
      END

63
BBC BASIC / Re: BBC BASIC Compiler?
« on: April 19, 2019, 04:37:25 PM »
On Windows, Charles Pegge (OxygenBasic author) wrote an extension module that provides a dynamic FFI definition and full use of the O2.JIT compiler to create virtual DLLs and code in ASM.
It's a shame it's Windows only.  I want to discourage platform-specific extensions to BBC BASIC for SDL 2.0, especially as one of its great strengths is the cross-platform compatibility.  So although the assembler is invaluable for debugging (notably the profiler, list variables and trace features rely on it) I generally don't use it in application programs.

I've recently been experimenting with shader programming in BBC BASIC, and that opens up the possibility of using the GPU to provide acceleration.  Of course it isn't ideally suited to 'general purpose' programming, but increasingly GPUs are used in applications other than graphics.  It potentially has the advantage of being fully cross-platform because all GPUs will run the same source code (it even gets around Apple's prohibition on running arbitrary code in iOS!).

64
BBC BASIC / Re: BBC BASIC Compiler?
« on: April 17, 2019, 05:54:18 PM »
This was the reason I thought BBC BASIC was a BASIC to ASM compiler.

An assembler and a compiler are very different things!

Traditionally BBC BASIC has incorporated an assembler as part of its run-time engine, making it easy to include assembly language subroutines in what is otherwise a BASIC program, typically when interpreted BASIC isn't fast enough or to do things that BBC BASIC doesn't support (such as callbacks).

So the original BBC Micro had an integral 6502 assembler, ARM BBC BASIC had an ARM assembler, BBC BASIC for Windows has a 32-bit x86 assembler etc.  The various editions of BBC BASIC for SDL 2.0 have an assembler appropriate to the platform (32-bit x86, 64-bit 86 or 32-bit ARM).

The exception to this rule is Brandy (and its offspring Napoleon Brandy and Matrix Brandy).  Although 'BBC BASIC' they don't include an assembler, and indeed they are generally less extensible and adaptable than most versions of BBC BASIC are.

65
BBC BASIC / Introduction to BBC BASIC
« on: April 14, 2019, 09:58:19 AM »
BBC BASIC is the programming language originally specified and adopted by the British Broadcasting Corporation for its groundbreaking Computer Literacy Project of the early 1980s. It has since been extended and ported onto at least seven CPUs and more than thirty different platforms.  Today BBC BASIC is a modern, structured, language capable of most programming tasks.

The Raspbian edition of BBC BASIC is free and open-source.  It is highly compatible with the Windows, MacOS, Linux, Android and iOS editions, and generally BASIC programs will run on all these platforms with no modification, even if they use 2D or 3D graphics, sound, joystick input, file or network access etc. More than 100 example programs are supplied with BBC BASIC to demonstrate its capabilities.

Raspbian BBC BASIC needs at least an RPi 2; an RPi 3 or later is recommended for best performance.  It may be downloaded as a precompiled binary in the form of a Zip file or the source code, libraries and examples may be obtained from GitHub.  There is a makefile in the bin/raspi directory (the SDL2 development libraries must first be installed from the Raspbian repository).

Here are some YouTube videos which illustrate things that BBC BASIC can achieve on the Raspberry Pi:

Video games
2D graphics
3D graphics
Ceefax simulator
Sprites
Music and 3D animation
Shader programming

66
Interpreters / BBC BASIC
« on: April 13, 2019, 03:57:06 PM »
Will there be a child board for BBC BASIC?

Pages: 1 ... 3 4 [5]