New: Console Mode editions of BBC BASIC

for discussion of bbc basic for windows/sdl, brandy and more
Soruk
Posts: 1136
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk »

Richard has updated the Console Mode editions of BBC BASIC to version 0.41. The changes in this version are:
  • Added support for serial I/O, for example the EXT# function returns the number of characters waiting in the input buffer.
  • Added a new example program animal.bbc which is the famous 'guess the animal' program, which learns from its mistakes (sort of).
Version 0.41 may be downloaded from the usual place.
Matrix Brandy BASIC VI (work in progress) The Distillery (another work in progress) Note Quiz (New educational software for the BBC and modern kit)
BBC Master 128, PiTubeDirect (Pi 3B), Pi1MHz, 5.25+3.5in dual floppy.
User avatar
roland
Posts: 5148
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by roland »

I have been playing with BBC Basic on the Pico. It's great. I am trying to do some I/O. I can set a bit to output and make it high with:

Code: Select all

SYS "gpio_set_dir", pin%, 1
SYS "gpio_put", pin%, 1
And I can make it an input with:

Code: Select all

SYS "gpio_set_dir", pin%, 0
And read it's state with

Code: Select all

SYS "gpio_get", pin%
But how can I get the state of a pin into a variable? state%=SYS "gpio_get", dataPin% throws an error...
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:
User avatar
hoglet
Posts: 12663
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by hoglet »

roland wrote: Sun Mar 19, 2023 4:57 pm And read it's state with

Code: Select all

SYS "gpio_get", pin%
But how can I get the state of a pin into a variable? state%=SYS "gpio_get", dataPin% throws an error...
Try:

Code: Select all

SYS "gpio_get", pin% TO value%
Dave
User avatar
roland
Posts: 5148
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by roland »

Thanks Dave, that works :)
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:
Soruk
Posts: 1136
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk »

Richard has updated his Console Mode editions of BBC BASIC to version 0.42. The changes in this version are:
  • Added new command-line options: -help, -load and -quit:
    • -help lists a brief description of these options.
    • -load loads the (tokenised) program specified subsequently on the command line, but doesn't run it (it enters immediate mode).
    • -quit runs the subsequently-specified tokenised program, but when that program terminates (either normally or because of an error) quits rather than entering immediate mode. In the event of an error the exit code is set to the BBC BASIC error number.
  • Enabled the *FLOAT 80 command in ARM editions, because it's the only way of reading & writing 64-bit integers in a file!
  • Added two new libraries: socklib.bbc and mysqllib.bbc. These provide the same capabilities as the libraries with the same names supplied with BBC BASIC for Windows and BBC BASIC for SDL 2.0.
  • Added new example programs: client.bbc, server.bbc, lanchat.bbc and mysqldem.bbc. These work the same as the example programs with the same names supplied with BBC BASIC for Windows and BBC BASIC for SDL 2.0.
Version 0.42 may be downloaded from the usual place.
Matrix Brandy BASIC VI (work in progress) The Distillery (another work in progress) Note Quiz (New educational software for the BBC and modern kit)
BBC Master 128, PiTubeDirect (Pi 3B), Pi1MHz, 5.25+3.5in dual floppy.
User avatar
roland
Posts: 5148
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by roland »

Another challenge .... does somebody have an example for I2C on the Pi Pico with BBC Basic? Searches on the internet only come up with micropython or C examples.

This is a part of an example program I found:

Code: Select all

int main() {
    // Pins
    const uint sda_pin = 16;
    const uint scl_pin = 17;

    // Ports
    i2c_inst_t *i2c = i2c0;          <----- how do I do this in BBC Basic?

    //Initialize I2C port at 400 kHz
    i2c_init(i2c, 400 * 1000);

    // Initialize I2C pins
    gpio_set_function(sda_pin, GPIO_FUNC_I2C);
    gpio_set_function(scl_pin, GPIO_FUNC_I2C);
So for example ... how can I initiate the i2c instance just like the marked line in BBC Basic. The other functions will probably be sys-calls like

Code: Select all

sda_pin%=16
sdc_pin%=17
SYS "gpio_set_function", sda_pin, GPIO_FUNC_I2C 
And replace GPIO_FUNC_I2C with it's value, whatever that may be.... (probably 3)
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:
User avatar
scruss
Posts: 653
Joined: Sun Jul 01, 2018 4:12 pm
Location: Toronto
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by scruss »

this might be better asked here: Introduction to BBC BASIC - Page 41 - Raspberry Pi Forums or on the developer's github: Memotech-Bill/PicoBB: BBC BASIC for Raspberry Pi Pico.

I agree, there appears to be no documented way to access this.
Soruk
Posts: 1136
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk »

Matrix Brandy BASIC VI (work in progress) The Distillery (another work in progress) Note Quiz (New educational software for the BBC and modern kit)
BBC Master 128, PiTubeDirect (Pi 3B), Pi1MHz, 5.25+3.5in dual floppy.
User avatar
scruss
Posts: 653
Joined: Sun Jul 01, 2018 4:12 pm
Location: Toronto
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by scruss »

yeah, that one too. Does Memotech Bill hang out there, though? Richard hasn't done much on the Pico version
Soruk
Posts: 1136
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by Soruk »

scruss wrote: Thu Mar 30, 2023 10:59 pm yeah, that one too. Does Memotech Bill hang out there, though? Richard hasn't done much on the Pico version
No, but Richard might have some input on addressing the GPIO from BBC BASIC.
Matrix Brandy BASIC VI (work in progress) The Distillery (another work in progress) Note Quiz (New educational software for the BBC and modern kit)
BBC Master 128, PiTubeDirect (Pi 3B), Pi1MHz, 5.25+3.5in dual floppy.
paulb
Posts: 1767
Joined: Mon Jan 20, 2014 9:02 pm
Contact:

Re: New: Console Mode editions of BBC BASIC

Post by paulb »

roland wrote: Wed Mar 29, 2023 8:15 pm Another challenge .... does somebody have an example for I2C on the Pi Pico with BBC Basic? Searches on the internet only come up with micropython or C examples.

This is a part of an example program I found:

Code: Select all

    // Ports
    i2c_inst_t *i2c = i2c0;          <----- how do I do this in BBC Basic?
Since i2c_inst_t is likely to be a structure type, with i2c initialised to being a pointer to the predefined i2c0 structure, you probably want to find out what the details of i2c_inst_t are and what i2c0 is defined as.

I can imagine that i2c_inst_t just reflects the memory layout of the I2C peripheral in the microcontroller, and i2c0 is the address of the first I2C peripheral. Then, the i2c_init function probably just accesses locations relative to the supplied i2c address.

You could probably define a BASIC procedure equivalent to i2c_init...

Code: Select all

DEF PROCi2c_init(i2c, frequency)
i2c!xxx = frequency
ENDPROC
Obviously, the xxx member of the i2c structure would need to be determined. Hope this is somewhat helpful!
Post Reply

Return to “modern implementations of classic programming languages”