User avatar
RichardRussell
Posts: 1396
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Feb 17, 2024 9:47 pm

ash73 wrote:
Sat Feb 17, 2024 8:14 pm
My comments are just first impressions so take them with a pinch of salt, but the logical coordinates stand out as a bit odd given the screen doesn't stretch when you maximise the window, i.e. it's just using physical pixels, so why not use physical resolution?
I'm a little confused about whether you're talking about the BBC Micro and how it was designed in 1981, or whether you're talking about BBC BASIC running on modern hardware platforms like PCs with 'windowed' interfaces. The two situations are very different.

The BBC Micro had screen modes which were all the same physical size, but had different sized pixels (e.g. MODE 0 with 640 pixels across the width of the screen, or MODE 2 with 160 pixels). Modern systems (generally) can't change the size of the pixels but can have variable sized windows.

Logical coordinates relate to physical dimensions, so it follows that when the size of a pixel changes the logical coordinates don't change, but when the window size changes the range of logical coordinates does change. That's hopefully what you would expect.

But I suspect I may not have fully understood your point; if so feel free to ask again.
One thing that would be great is a 80 column mode 7
Assuming you mean a mode which is twice the width, not characters that are half the size, that's easy (but it doesn't use MODE 7 control characters to change colour etc., they are specific to a 40-column screen).

Code: Select all

VDU 23,22,1280;500;16,20,16,0

User avatar
ash73
Posts: 85
Joined: Mon Jan 30, 2017 12:52 pm

Re: Introduction to BBC BASIC

Sat Feb 17, 2024 10:24 pm

RichardRussell wrote:
Sat Feb 17, 2024 9:47 pm

Code: Select all

VDU 23,22,1280;500;16,20,16,0
Perfect, thanks!

Re logical coords I was talking about modern BASIC in a window on the Pi5. Sorry, reminiscing about the Beeb in the same post was probably confusing.

I'm intrigued what's special about mode 0 (and mode 4) that lets me do this...
Attachments
screenshot.png
screenshot.png (9.11 KiB) Viewed 1285 times

User avatar
RichardRussell
Posts: 1396
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Feb 17, 2024 10:56 pm

ash73 wrote:
Sat Feb 17, 2024 10:24 pm
Sorry, reminiscing about the Beeb in the same post was probably confusing.
On the contrary it's having to maintain a degree of compatibility with the BBC Micro that determines how it behaves on a modern platform.

If you're suggesting that compatibility with the BBC Micro be abandoned, and the way graphics coordinates etc. work be revisited from scratch, then one might well choose to do things differently. But although one could reasonably make the argument that it's BBC BASIC not a BBC Micro emulator, I'd get a tremendous amount of push-back against such a move.
I'm intrigued what's special about mode 0 (and mode 4) that lets me do this...
Special in what way? I explained that modern displays are not hardware-paletted (colour-indexed), so you aren't restricted to only two, four or 16 different colours as you would have been on the BBC Micro (two colours in MODEs 0 and 4). So what is it that you find surprising?

Incidentally shouldn't your RECTANGLE FILL statement be RECTANGLE FILL X, Y, 10, 10 ?

This is how I might have coded it:

Code: Select all

      MODE 0
      FOR X = 1 TO 1280 STEP 10
        FOR Y = 1 TO 1024 STEP 10
          R = X DIV 5
          G = Y DIV 4
          B = (1280-X) DIV 5
          COLOUR 1,R,G,B
          RECTANGLE FILL X,Y,10,10
        NEXT
      NEXT

User avatar
ash73
Posts: 85
Joined: Mon Jan 30, 2017 12:52 pm

Re: Introduction to BBC BASIC

Sun Feb 18, 2024 12:05 am

RichardRussell wrote:
Sat Feb 17, 2024 10:56 pm
Special in what way? I explained that modern displays are not hardware-paletted (colour-indexed), so you aren't restricted to only two, four or 16 different colours as you would have been on the BBC Micro (two colours in MODEs 0 and 4). So what is it that you find surprising?
Special in that it doesn't work in any other modes, if you run the same code in say mode 1 it displays only one colour.

I'm reading this, but not seeing what's different about modes 0 & 4 (other than they are nominally 2 colour modes).
https://www.bbcbasic.co.uk/bbcwin/manual/bbcwin3.html

p.s. thanks for the correction.

User avatar
RichardRussell
Posts: 1396
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Feb 18, 2024 10:15 am

ash73 wrote:
Sun Feb 18, 2024 12:05 am
Special in that it doesn't work in any other modes, if you run the same code in say mode 1 it displays only one colour.
This works for me in MODE 1:

Code: Select all

      MODE 1
      FOR X = 1 TO 1280 STEP 10
        FOR Y = 1 TO 1024 STEP 10
          R = X DIV 5
          G = Y DIV 4
          B = (1280-X) DIV 5
          COLOUR 3,R,G,B
          RECTANGLE FILL X,Y,10,10
        NEXT
      NEXT
I'm wondering if you forgot to change the logical colour (palette index) from 1 to 3 in the COLOUR 3,R,G,B statement. Because your program doesn't explicitly set the plotting colour (using GCOL) you are using the default logical colour for the mode. In 2-colour modes that's GCOL 1, in 4-colour modes it's GCOL 3 and in 16-colour modes it's GCOL 7.

If you are plotting with the default logical colour, obviously it's necessary to specify that colour (1, 3 or 7) in the COLOUR n,r,g,b statement otherwise you're changing a palette entry that you're not using! The alternative, and arguably better, approach is to set the plotting colour explicitly (here to logical colour 1):

Code: Select all

      MODE 1
      GCOL 1
      FOR X = 1 TO 1280 STEP 10
        FOR Y = 1 TO 1024 STEP 10
          R = X DIV 5
          G = Y DIV 4
          B = (1280-X) DIV 5
          COLOUR 1,R,G,B
          RECTANGLE FILL X,Y,10,10
        NEXT
      NEXT

User avatar
ash73
Posts: 85
Joined: Mon Jan 30, 2017 12:52 pm

Re: Introduction to BBC BASIC

Sun Feb 18, 2024 11:04 am

Ah that explains it, thanks - I forgot GCOL defaults to 3 in mode 1, 7 in mode 2, etc... my bad!

I'm so glad I went down the Pi5 + modern BASIC route, there's tons more to play with than an old Beeb.

Does BASIC have a MySql connector? Just pondering options for something I might write.

User avatar
RichardRussell
Posts: 1396
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Feb 18, 2024 11:47 am

ash73 wrote:
Sun Feb 18, 2024 11:04 am
Does BASIC have a MySql connector? Just pondering options for something I might write.
Yes, check out the mysqllib.bbc library and the mysqldem.bbc demo program (in examples/general/), this queries a publicly-accessible database.

User avatar
RichardRussell
Posts: 1396
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Feb 27, 2024 3:48 pm

I have released version 1.39a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, Mac OS, Linux, Raspberry Pi OS, Android, iOS and in-browser. The changes in this version are as follows:

  1. Environment

    Updated SDL2 to version 2.30.0 and SDL2_ttf to version 2.22.0 (Windows, MacOS, Android, iOS).

    Increased the initial value of HIMEM to 32 Mbytes above PAGE.

    Increased the maximum heap size, in 64-bit editions only, to 4 Gbytes (heap pointers are 32-bits so this is the largest possible size).

  2. BASIC Interpreter / Run Time Engine

    Extended VDU 19 to be able to set colours with an alpha (opacity) value.

    Added *FX 19 as a synonym for *REFRESH.

  3. IDEs and Utilities

    Modified the 'compiler' to support wildcards in REM!Embed directives.

    Modified SDLIDE for compatibility with 'self-examining' programs.

  4. Libraries

    Added PROC_slice() and PROC_redim() (etc.) to the arraylib library.

    Modified the gpiolib library for compatibility with 64-bit PiOS and the Raspberry Pi 5.

  5. Example Programs

    Added smithchart.bbc, an antialiased Smith Chart graticule, in examples/graphics.

    Added keywords.bbc, a list of one-line keyword descriptions, principally for the Android and iOS editions.

    Added server_multi.bbc (in examples/general, desktop editions only) which can accept up to 8 concurrent connections.

    Added gpiotest.bbc (in examples/general, Raspberry Pi only) to test the gpiolib library.
This version may be downloaded, for all the supported platforms, from the usual location (the Android and iOS editions should be installed from the appropriate App Store). The GitHub repository has also been updated.
Last edited by RichardRussell on Wed Feb 28, 2024 11:47 am, edited 1 time in total.

User avatar
RichardRussell
Posts: 1396
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Feb 27, 2024 10:42 pm

RichardRussell wrote:
Tue Feb 27, 2024 3:48 pm
Modified the gpiolib library for compatibility with 64-bit PiOS and the Raspberry Pi 5.
As it's easily missed amongst the other changes, can I draw attention to this as the most important change as far as the Raspberry Pi is concerned.

Not only does the updated gpiolib.bbc library now support 64-bit PiOS and the Raspberry Pi 5, it also supports the different way of controlling the input pull-ups and pull-downs of the Raspberry Pi 4.

BBC BASIC comes with the example programs gpiotest.bbc, which tests both outputs and inputs (it could fail if there are existing devices connected to the pins it uses), and gpiodemo.bbc which was used in the creation of this YouTube video:

https://www.youtube.com/watch?v=S9AGVMOw918

User avatar
ash73
Posts: 85
Joined: Mon Jan 30, 2017 12:52 pm

Re: Introduction to BBC BASIC

Wed Mar 06, 2024 2:14 am

Like the new alpha function!
Attachments
alpha.png
alpha.png (7.25 KiB) Viewed 985 times

Return to “Other programming languages”