Converting Liberty Basic to BBC Basic

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Hated Moron

Converting Liberty Basic to BBC Basic

Post by Hated Moron »

On 05/11/2023 11:55, R NBW wrote (cross-posted from the Discussion Group):
I am sure this has been asked before and received a negative answer, but is it possible to modify LBLIB.BBCC to BBC SDL format instead of Windows. It would be very useful if it could.
What exactly do you mean by "BBCSDL format"? If you mean such that it will run in BBC BASIC for SDL 2.0 but still only in 32-bit Windows then, yes, that might indeed be possible. After all it's not all that different from the task of porting the WINLIB libraries from BB4W to BBCSDL, which has been extensively discussed here and was - I thought - being attempted by DDRM until he admitted that work hadn't yet started. :(

It might even be possible to go further than that, and adapt it to run in 64-bit Windows instead of 32-bit, which might help in making it more future-proof. The main difficulty with that would be the extensive amount of assembly language code in LBLIB, all of which would have to be translated from 32-bit i386 code to 64-bit x86-64 code. But that's largely mechanical.

But of course if by "BBCSDL format" you mean so that it could run on platforms other than Windows, that is an entirely different kettle of fish. LBLIB.BBC contains dozens, probably hundreds, of SYS calls to the Win32 API (some from BASIC, some from assembly language code). Every one would have to be replaced with a cross-platform alternative. :shock:

Whilst that might not be too difficult for a few of the API calls, the great majority would require a large amount of code to be written (in BASIC or C) to emulate the functionality that the Windows API provides. So never say never, I don't like to say something is impossible, but I doubt that there is anybody - and that certainly includes me - with the skills and determination to do that.
Hated Moron

Re: Converting Liberty Basic to BBC Basic

Post by Hated Moron »

On 05/11/2023 14:25, R NBW wrote (cross-posted from the Discussion Group):
It was BBC SDL.
Now I'm confused. Are you making a distinction between 'BBCSDL' and 'BBC SDL'? What's the difference? I use BBCSDL as shorthand for BBC BASIC for SDL 2.0 just as I use BB4W as shorthand for BBC BASIC for Windows. I don't use 'BBC SDL' (with a space) at all, what do you mean by it?

My previous reply was entirely about BBC BASIC for SDL 2.0 but you hadn't made clear whether you were referring to running it in 32-bit Windows, 64-bit Windows or platforms other than Windows, and I'm still none the wiser. As I explained, that makes a big difference to the practicality of porting LBLIB.

If you wanted to attempt to make LBLIB independent of Windows my suggestion would be to list every Win32 API SYS call that it makes (both from BASIC and from assembler) and then categorise each as one of:
  1. Having a direct or near-direct SDL2 equivalent.
  2. Corresponding in functionality to something which already has a cross-platform near-equivalent, e.g. in dlglib.bbc, menulib.bbc, editbox.bbc, msgbox.bbc etc.
  3. Having neither an SDL2 equivalent nor an emulation in an existing BBCSDL library.
It's the third category that you would have to concentrate on.