jahboater
Posts: 5434
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Introduction to BBC BASIC

Thu Oct 31, 2019 2:31 pm

RichardRussell wrote:
Thu Oct 31, 2019 2:02 pm
The redefining of fabsl to fabs (and others similar) is because the ARM FPU doesn't support 'long double' as meaning the 80-bit (padded to 128-bit) type that the x86 FPU supports.
In 32-bit mode on ARM "long double" is the same as "double", that is 64-bits.
In 64-bit mode, ARM "long double" is 128-bits!

For Intel, the compiler option "-mlong-double-128" gives true 128-bit floating point like aarch64.

jahboater
Posts: 5434
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Introduction to BBC BASIC

Thu Oct 31, 2019 2:37 pm

RichardRussell wrote:
Thu Oct 31, 2019 12:18 pm
The global variables 'esi' and 'esp' (you can see the assembly language origins of the code there!) are assigned to registers r10 and r11 respectively on ARM. From the warning you are getting these aren't suitable registers for that purpose with your system's ABI; try changing them to different registers.
Or perhaps just remove the asm("r10") part if there is no specific reason to place the variables in those registers.
You will almost certainly get worse code otherwise. As you say modern register allocater's do a good job, and an even better job if there are no pointless constraints.

Inline system calls are the only reason I have found to use "register".

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

Re: Introduction to BBC BASIC

Thu Oct 31, 2019 3:37 pm

jahboater wrote:
Thu Oct 31, 2019 2:31 pm
In 32-bit mode on ARM "long double" is the same as "double", that is 64-bits.
In 64-bit mode, ARM "long double" is 128-bits!
Indeed (and the 128-bit 'long double' is currently a software emulation) which is why I redefine those 'long double' library functions to their ordinary 'double' equivalents. I think there's a GCC compiler switch to do that on x86 but surprisingly not on ARM. I could explain why BBC BASIC uses the 'long double' type at all but unless you're as obsessively interested in the history of the language as I am it probably wouldn't be welcome!
Or perhaps just remove the asm("r10") part if there is no specific reason to place the variables in those registers.
Well, there is a "specific reason" in that those global variables are very frequently accessed and have their own dedicated registers in the assembly language implementations of BBC BASIC. That, and the comment I found that the only residual value of register variables was in exactly such a language interpreter, led me to conclude that they are probably beneficial. But one would need to do some careful benchmarking to establish that.

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

Re: Introduction to BBC BASIC

Mon Nov 04, 2019 12:04 pm

I found a rather nasty bug yesterday, which (in admittedly statistically unlikely circumstances) could cause the INSTALL statement to hang. The source at GitHub has been updated with the fix.

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

Re: Introduction to BBC BASIC

Sun Nov 10, 2019 6:23 pm

Congratulations are due to David Williams (aka BasicBoy) whose BBC BASIC game 'Tyoob' has won Second Prize at the recent SyntaxBomb game coding competition. Here's a YouTube video of the game running on a Raspberry Pi 3 (apparently it runs rather more smoothly on a RPi 4).

David has had great success with the BBC BASIC games he has submitted to SyntaxBomb; of his three contest entries ('Forces of Darkness' in the Halloween-themed contest in 2017, 'Maizie Bones' in the maze-themed contest in 2018 and 'Tyoob' in the mix-it-up contest this year) two have won First Prize and one Second Prize! In another SyntaxBomb competition (which David didn't enter) a game written in BBC BASIC also won.

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

Re: Introduction to BBC BASIC

Sun Dec 01, 2019 11:10 am

Just released, version 1.08a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, MacOS, Linux, Raspbian, Android and iOS. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    The version of SDL supplied with the Windows, MacOS and iOS editions has been updated to 2.0.10. This version has the new float-coordinate rendering functions, in case you want to experiment with them. Note that there are significant changes in SDL which impact BBC BASIC, so if you notice anything not working properly please report it. (The Android edition is still at 2.0.5; the build tools being used don't work with later versions).

    Fixed a bug which sometimes required the use of '*run command' when '*command' should have worked (64-bit and ARM editions only).

    Fixed a bug which, in rare circumstances, could cause the INSTALL statement to hang (64-bit and ARM editions only).

  2. IDEs and Utilities

    SDLIDE: Goto Line (Ctrl+G) can now be executed by pressing Enter as well as clicking the OK button.

    SDLIDE: The customisable 'wheelspeed' value no longer affects clicking on the scrollbar arrows.

    Compiler: Fixed a bug causing single-capital-letter variables like A&, B# and C$ not to be crunched to 'fast' variables (they still won't be if also used as structure members).

  3. Libraries

    Modified 'arraylib.bbc' so that if an error occurs in PROC_invert() the LOCAL variables are restored (an error is to be expected if the matrix is non-invertible).

    Modified 'dlglib.bbc' to improve the listbox drag-scroll functionality.

    Updated 'eventlib.bbc' to be 64-bit compatible.

  4. Example Programs

    Added 'ellipsefit.bbc' (in the examples/general folder) which demonstrates that an axis-aligned ellipse can be defined by four points. This program is also compatible with BBC BASIC for Windows.

    Added 'bezierfit.bbc' (in the examples/general folder) to demonstrate fitting a smooth curve to a set of data points. This program is also compatible with BBC BASIC for Windows.

    Added 'multitouch.bbc' (in the examples/general folder) to demonstrate detecting multiple touch points. Requires a touchscreen or a multi-touch trackpad.

    Modified 'SkyBaby' to include a 'dynamic grid' in the SkyView display (requested by a user). As you zoom in the grid spacing gets finer; the grid lines are labelled with the altitude and azimuth in degrees.
This new version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspbian, iOS and 64-bit Linux editions, currently).

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

Re: Introduction to BBC BASIC

Thu Dec 05, 2019 12:39 pm

RichardRussell wrote:
Sun Dec 01, 2019 11:10 am
Added 'bezierfit.bbc' (in the examples/general folder) to demonstrate fitting a smooth curve to a set of data points. This program is also compatible with BBC BASIC for Windows.
Image

Heater
Posts: 15410
Joined: Tue Jul 17, 2012 3:02 pm

Re: Introduction to BBC BASIC

Thu Dec 05, 2019 10:46 pm

Cool.

Watching that is the most relaxing thing I have done all day.

Thank you.
Memory in C++ is a leaky abstraction .

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

Re: Introduction to BBC BASIC

Sun Jan 12, 2020 1:38 pm

I've released version 1.09a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, MacOS, Linux, Raspbian, Android and iOS. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Worked around a regression in SDL 2.0.10, which caused the fern demo not to run on some platforms.

    Improved compatibility with GCC 4.9.

  2. IDEs and Utilities

    SDLIDE: Added the Memory Usage Monitor (similar to the BB4W equivalent) to the Utilities menu. Now you can find out how close your program is to running out of memory (or whether you have allocated much more memory than you need!). The BASIC program must be run in Debug mode for this to work.

  3. Libraries

    Modified dlglib.bbc to improve the responsiveness of the listbox to slow mouse button clicks.

  4. Example Programs

    Updated Ceefax.bbc (and capitalised its name!) to include Weather, Traffic and Local News pages, and to be navigable using an Amazon Fire TV remote. With the demise of the BBC's digital ('red button') text service at the end of this month, this is my attempt to provide a substitute! This program also runs in BBC BASIC for Windows if you copy 'Bedstead-ext.otf' into BB4W's LIB directory.
This new version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspbian, iOS and 64-bit Linux editions, currently).

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

Re: Introduction to BBC BASIC

Mon Jan 20, 2020 2:01 pm

Some screen shots from the Ceefax simulator:
Ceefax100.png
Ceefax100.png (46.26 KiB) Viewed 1503 times
Ceefax122.png
Ceefax122.png (45.23 KiB) Viewed 1503 times
Ceefax137.png
Ceefax137.png (37.83 KiB) Viewed 1503 times

User avatar
rpdom
Posts: 16737
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Introduction to BBC BASIC

Mon Jan 20, 2020 8:41 pm

Very nice screenshots :)

I did a lot of MODE 7 stuff in the old days. Used your BASIC a lot on PC and RM Nimbus.

I did hack together a bare metal system on a Pi 1B that displayed MODE 7 screens with correct flashing text and blinking cursors at one point. I used some of the pages from my old Viewdata type bulletin board.
Unreadable squiggle

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

Re: Introduction to BBC BASIC

Mon Jan 20, 2020 9:31 pm

rpdom wrote:
Mon Jan 20, 2020 8:41 pm
Very nice screenshots :)
I did a lot of MODE 7 stuff in the old days. Used your BASIC a lot on PC and RM Nimbus.
The key to achieving a realistic teletext display is the Bedstead font which solves the problem of emulating the non-square pixels of the BBC Micro's MODE 7 on a display with square pixels.

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

Re: Introduction to BBC BASIC

Sat Feb 15, 2020 2:33 pm

I've released version 1.10a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, MacOS, Linux, Raspbian, Android and iOS. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Bundled the Box2D physics engine (as famously used by the Angry Birds games) with all editions.

    Fixed a bug causing ON GOTO statements to be incorrectly tokenised (64-bit and ARM editions only).

    Improved plotting accuracy of 'thick' diagonal lines, outline circles and outline ellipses.

    Updated the Android edition to SDL 2.0.10. This has necessitated moving to a different build process (Android Studio) meaning you will need to uninstall then reinstall; see below.

  2. IDEs and Utilities

    Updated BBCEdit to version 0.32.3, many thanks to Andy Parkes for this new release.

    Fixed a minor problem in SDLIDE with pasting Unicode text containing the à (a-grave) character.

    Fixed a bug in the Compiler utility which could cause creation of an app bundle to fail on MacOS if the installation path contains a space character.

    Modified the List Variables utility so that a mouse right-click clears the listbox selection.

  3. Libraries

    Added box2dlib.bbc and box2dgfx.bbcb to support the Box2D physics engine.

    Fixed a bug in dlglib.bbc which affected the 'Save As' dialogue in SDLIDE, also improved operability by the Amazon Fire TV remote.

  4. Example Programs

    Added kaleidoscope.bbc in examples\graphics, adapted from David Williams's BB4W demo.

    Added three Box2D demonstration programs in examples\physics; these are also compatible with BBC BASIC for Windows if the Box2D libraries are installed:

    crates.bbc: Falling boxes; on mobile devices tilting the screen has an interesting effect!
    dangle.bbc: Touch the screen or use the mouse to grab the chain; also responds to tilting.
    lotto.bbc: A simulation of a lottery selection machine. Sorry, there's no prize if you win!
This new version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspbian, iOS and 64-bit Linux editions, currently).

If you are using the iOS edition you should install this latest release to update the certificate, otherwise BBC BASIC will stop working when the current certificate expires on 23rd February.

If you are using the Android edition you will need to uninstall the previous version before installing this one. Please check whether you have any personal files or folders stored in @usr$ and back them up (e.g. via a USB connection to a PC) so you can restore them after re-installation.

Please remember that if you use the BBC2APK Android Application Generator you should download a new APK template to ensure that any updates to the run-time engine are incorporated in your own apps.

hitsware
Posts: 205
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: Introduction to BBC BASIC

Tue Feb 18, 2020 9:32 pm

Richard ,
Out of curiosity , how and when did the BBCBasic SOUND morph
into how it works now as opposed to as explained here :

http://www.riscos.com/support/developer ... sound.html

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

Re: Introduction to BBC BASIC

Tue Feb 18, 2020 10:07 pm

hitsware wrote:
Tue Feb 18, 2020 9:32 pm
Out of curiosity , how and when did the BBCBasic SOUND morph
into how it works now as opposed to as explained here
The 'morphing' was in the other direction! What you have linked to describes the SOUND statement in RISC OS, which is quite different from how SOUND originally worked on the earlier BBC Micro, Electron etc. For example it lacks the ENVELOPE statement entirely (it is recognised but does nothing).

I have no idea why Acorn made this incompatible, and arguably retrograde, change; not least because of the huge amount of existing software that relied on the earlier implementation. When it came to developing my versions of BBC BASIC there was no way I was going to emulate RISC OS sound; instead I emulate reasonably closely - but not perfectly - the Beeb's SOUND and ENVELOPE statements.

In BBC BASIC for SDL 2.0 (and also available via a library for BBC BASIC for Windows) I have enhanced the sound capability by supporting stereo, multiple waveforms ('stops'), four 'tone' channels (instead of 3 tone and one 'noise') and full 16-bit 44.1 kHz sampling. Crucially this has been achieved without sacrificing compatibility with the BBC Micro.

hitsware
Posts: 205
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 12:59 am

RichardRussell wrote:
Tue Feb 18, 2020 10:07 pm
In BBC BASIC for SDL 2.0 (and also available via a library for BBC BASIC for Windows) I have enhanced the sound capability by supporting stereo, multiple waveforms ('stops'), four 'tone' channels (instead of 3 tone and one 'noise') and full 16-bit 44.1 kHz sampling. Crucially this has been achieved without sacrificing compatibility with the BBC Micro.
Where may one find the documentation on using the ' stops ' ?
FNfreqout(f) seems not to work on RPi 3B+ ?

User avatar
rpdom
Posts: 16737
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 7:37 am

RichardRussell wrote:
Tue Feb 18, 2020 10:07 pm
I have no idea why Acorn made this incompatible, and arguably retrograde, change
I think it may have been due to hardware capabilities. The Envelope function (IIRC) was a feature of the sound chip used on the BBC Micro. The RISC OS systems didn't have that chip, so they designed their own stuff. I suspect they were more concentrating on being able to play reasonable quality digitised sounds that the old beeps and whistles. (I did once have part of a document that discussed the possible audio features of the original Archimedes. It was very interesting. As well as stereo audio output, it discussed an audio input, which I don't believe happened - "too much sand" said the document).
Unreadable squiggle

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

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 9:08 am

rpdom wrote:
Wed Feb 19, 2020 7:37 am
I think it may have been due to hardware capabilities. The Envelope function (IIRC) was a feature of the sound chip used on the BBC Micro.
I don't believe that's right. My understanding is that ENVELOPE was implemented entirely in software, i.e. in the BBC Micro's MOS, not in the sound chip. If you check the specification of the chip concerned (SN76489) I think you will find that it has no such capability.

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

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 9:30 am

hitsware wrote:
Wed Feb 19, 2020 12:59 am
Where may one find the documentation on using the ' stops ' ?
It's described under Star Commands here, the syntax is:

Code: Select all

      *VOICE channel,voice
(where channel is 0-3 and voice is 0-7).

The eight 'voices' are based on those used by my ancient Z80 Music program, which was a 4-voice polyphonic synthesiser achieved entirely in software (Z80 machine code). Voice 0 is an approximation to a square wave (up to 9th harmonic), voice 1 is an approximation to a triangular wave (up to 9th harmonic) and voice 4 is a sine wave (fundamental only). The others (2, 3, 5, 6, 7) are combinations of harmonics to which I probably once attached 'stop' names, but it's too long ago to remember (we are talking about the 1970s or 1980s)!

I should point out that switching voices 'dynamically' does not work well because there is an instantaneous switch between the waveforms (causing a click) and it is not synchronised with the queued SOUNDs.

User avatar
rpdom
Posts: 16737
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 11:34 am

RichardRussell wrote:
Wed Feb 19, 2020 9:08 am
rpdom wrote:
Wed Feb 19, 2020 7:37 am
I think it may have been due to hardware capabilities. The Envelope function (IIRC) was a feature of the sound chip used on the BBC Micro.
I don't believe that's right. My understanding is that ENVELOPE was implemented entirely in software, i.e. in the BBC Micro's MOS, not in the sound chip. If you check the specification of the chip concerned (SN76489) I think you will find that it has no such capability.
You're probably right. It's been a long time since I looked at any of that stuff.
Unreadable squiggle

User avatar
PeterO
Posts: 5725
Joined: Sun Jul 22, 2012 4:14 pm

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 11:40 am

rpdom wrote:
Wed Feb 19, 2020 11:34 am
RichardRussell wrote:
Wed Feb 19, 2020 9:08 am
rpdom wrote:
Wed Feb 19, 2020 7:37 am
I think it may have been due to hardware capabilities. The Envelope function (IIRC) was a feature of the sound chip used on the BBC Micro.
I don't believe that's right. My understanding is that ENVELOPE was implemented entirely in software, i.e. in the BBC Micro's MOS, not in the sound chip. If you check the specification of the chip concerned (SN76489) I think you will find that it has no such capability.
You're probably right. It's been a long time since I looked at any of that stuff.
You're probably remembering the General Instruments (GI) sound chips (AY-3-8900) that did have crude envelope generation. I had two of them in my Z80 CP/M machine,.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

hitsware
Posts: 205
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 3:19 pm

No ' FNfreqout(f) ' for SDL ?

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

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 4:56 pm

hitsware wrote:
Wed Feb 19, 2020 3:19 pm
No ' FNfreqout(f) ' for SDL ?
I don't remember what that is, you'll have to remind me. I know I did some horrible hacks involving actually patching the code of BB4W (e.g. the HQSOUND library), maybe it was one of them. Obviously you cannot 'patch' the code of a multi-platform product such as BBCSDL because, well, there is no one piece of code, there are lots (and anyway patching the code in Android or iOS is almost certainly impossible).

SOUND and ENVELOPE are there primarily to support legacy programs, and for those 'retro programming' enthusiasts who like to do things as they were done decades ago (and there's nothing wrong with that). But when writing code from scratch to generate music, or sounds in general, it's not the way to tackle it. Now everything is done with 'samples', either stored in a file or generated on-the-fly at run time.

Take for example a 'modern' BBC BASIC video game such as David Williams' 'Tyoob'. The background music is an MP3 file and the sound effects are all samples stored in files, not a SOUND or ENVELOPE in sight!

hitsware
Posts: 205
Joined: Sat Mar 26, 2016 10:12 pm
Location: sacramento , california , usa
Contact: Website

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 6:29 pm

DEF FNfreqout(f)
LOCAL I% : PRIVATE ftab%, indx&
IF ftab% = 0 THEN
LOCAL base%
SYS "GetModuleHandle", 0 TO base%
FOR I% = base% TO base% + 65534 STEP 2
IF !I% = &03550354 IF I%!4 = &06060606 EXIT FOR
NEXT
IF I% > base% + 65534 ERROR 100, "Cannot locate frequency table"
ftab% = I% + 8
SYS "VirtualProtect", ftab% AND -&1000, &2000, &40, ^I% TO I%
IF I% = 0 ERROR 100, "Cannot make memory image writable"
ENDIF
indx& += 1 : IF indx& = 0 indx& = 1
I% = 2 * indx&
ftab%!I% = ftab%!I% AND &FFFF0000 OR INT(f * &10000 / 22050 + 0.5)
= indx&

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

Re: Introduction to BBC BASIC

Wed Feb 19, 2020 6:47 pm

hitsware wrote:
Wed Feb 19, 2020 6:29 pm

Code: Select all

SYS "VirtualProtect", ftab% AND -&1000, &2000, &40, ^I% TO I%
IF I% = 0 ERROR 100, "Cannot make memory image writable"
As you can see, and as I suspected, it patches the executable in memory. Hence not an option for BBCSDL (not a sensible option ever, but I was evidently persuaded to do it for BB4W anyway!). What was its purpose: generating non-equal-tempered music or something?

Return to “Other programming languages”