BBC BASIC
« BBC BASIC for SDL 2.0 v0.16a released »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:51pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: BBC BASIC for SDL 2.0 v0.16a released  (Read 2504 times)
mavison
New Member
Image


member is offline

Avatar




PM


Posts: 27
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #5 on: Feb 5th, 2017, 10:10pm »

Thanks Richard for that comprehensive and quick reply.

I think I can do what I want in pure Basic without using Windows or SDL APIs - even if I have to Spool some *dir output and read it back to get a list of files in a directory!

If I get my slashes sloping in the right way it could even run on Windows & Mac. Just in case, is there a way for a program to discover which it is running on? (apart from cheating by recognising the @dir$ value!)

I will have access to the Mac for testing, and I can install BBCSDL there, but most development would be done on Windows.

The programs are currently being run on the Mac using RPCEmu to emulate a RISC PC, then running RISC OS 5 under that, then running the programs - so even using BBCSDL would be a big improvement!

You have given me the confidence to try some experimenting, and to remind myself how to move a program from RISC OS to BB4W.

Thanks for your work, and your help.
Martin


User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #6 on: Feb 6th, 2017, 08:49am »

on Feb 5th, 2017, 10:10pm, mavison wrote:
even if I have to Spool some *dir output and read it back to get a list of files in a directory!

You can 'borrow' code for doing that from either touchide.bbc or SDLIDE.bbc (they use basically the same code). Using a sneaky trick with WIDTH 20 they even manage to parse the *dir output to cope with filenames containing spaces!

Quote:
is there a way for a program to discover which it is running on? (apart from cheating by recognising the @dir$ value!)

INKEY(-256) will tell you if it is running in RISC OS, BB4W or BBCSDL. Having ascertained that it is running in BBCSDL you can test the least-significant byte of the @platform% variable which is 0 for Windows, 1 for Linux, 2 for MacOS and 3 for Android.

Quote:
to remind myself how to move a program from RISC OS to BB4W.

BB4W will read and automatically convert Acorn's tokenised program format, but BBCSDL won't. So if you want to import that format go through BB4W first. Otherwise spool your program to plain text (.bas); both BB4W and BBCSDL will read that.

Richard.
User IP Logged

mavison
New Member
Image


member is offline

Avatar




PM


Posts: 27
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #7 on: Feb 6th, 2017, 10:18am »

Thanks for all the hints. Most useful.

Is the only current way to run a program using SDL is to start an IDE, navigate to the program.bas and then run it?

I only realised double-clicking it externally simply used BB4W - hard to tell the difference until I used INKEY(-256)!

Thanks
Martin
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #8 on: Feb 6th, 2017, 1:53pm »

on Feb 6th, 2017, 10:18am, mavison wrote:
Is the only current way to run a program using SDL is to start an IDE, navigate to the program.bas and then run it?

On most platforms you can simply specify the name of a BASIC program (as a tokenized .bbc file) on the command line. For example on both Windows and Linux you can do:

Code:
bbcsdl path/to/program.bbc 

and it will run that program. Indeed if you omit the command-line argument BBCSDL will search for the file bbcsdl.bbc in the current directory and run it if found. That's the mechanism by which the 'choose IDE' launcher is executed.

I have to confess that Mac OS is more of a mystery to me, because rather than a simple executable file like bbcsdl there is an 'application package', and I'm not sure whether the concept of 'command line arguments' applies.

If the worst comes to the worst and that facility isn't directly available on the Mac all you would need to do is take a copy of the BBC Basic application, navigate 'inside' the package using Finder, and replace the supplied bbcsdl.bbc with your own program of the same name.

BBC BASIC will not realise your subterfuge and will automatically run your program when the application is executed. The only 'gotcha' is that the resulting application won't have a valid digital signature which might cause issues during deployment.

Quote:
I only realised double-clicking it externally simply used BB4W - hard to tell the difference until I used INKEY(-256)!

I'm not too sure what you mean. BBCSDL has no dependence on BB4W, and the latter doesn't even need to be installed.

Edit: Unless you mean double-clicking on a .bbc file, when of course what application gets executed depends entirely on the 'file associations'. It could be BB4W or it could be BBCSDL, depending on how you've configured Windows.

Richard.
« Last Edit: Feb 6th, 2017, 3:31pm by Richard Russell » User IP Logged

mavison
New Member
Image


member is offline

Avatar




PM


Posts: 27
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #9 on: Feb 6th, 2017, 5:27pm »

Thanks for the parameter info. I will include that when I do some experiments - and if I discover anything about the Mac I will post again.

Quote:
It could be BB4W or it could be BBCSDL, depending on how you've configured Windows.
Yes - obvious when you realise what is happening!

Martin
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #10 on: Feb 8th, 2017, 9:28pm »

I've updated the Android edition of BBC BASIC once again, this time to version 0.16d. Changes in this release are:
  • Fixed another issue affecting displays with a resolution in excess of 2048 pixels.

  • Fixed pasting BBC BASIC code put on the clipboard by another Android app.
Version 0.16d may be downloaded from the usual place:

http://www.rtr.myzen.co.uk/BBCBasic.apk

Android should recognise this as an upgrade and your personal files should not be affected.

Richard.
« Last Edit: Feb 8th, 2017, 9:33pm by Richard Russell » User IP Logged

DDRM
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 36
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #11 on: Feb 9th, 2017, 12:44pm »

Hi Richard,

Upgrading to 0.16d for Android results in BBC Basic failing to start with a "couldn't allocate memory" error on my Google Nexus 7. Any ideas about why? I'm currently running Android 4.4.4.

Best wishes,

David
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #12 on: Feb 9th, 2017, 2:35pm »

on Feb 9th, 2017, 12:44pm, DDRM wrote:
Any ideas about why?

It means what it says! I'm surprised that there isn't enough memory available on your device for BBC BASIC (it tries to allocate 256 Mbytes initially, but will fall back to smaller amounts if it has to). It probably means you have several apps open 'in the background'.

The first thing to try is closing all those background apps (press on the 'square' or 'menu' button; depending on the version of Android there may be a 'close all' selection or you may have to close each one individually). Failing that a full reboot is the next step.

I'm no Android expert, but it may be that Java apps are able to cooperate more closely in their use of memory, but a native app like BBC BASIC gets what it is given and no more. sad

I've put a program 'mmap.bbc' in the tools directory which you can use to get more information than you could possibly want about the current memory map.

Richard.
« Last Edit: Feb 9th, 2017, 3:02pm by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #13 on: Feb 10th, 2017, 10:32am »

on Feb 9th, 2017, 2:35pm, Richard Russell wrote:
The first thing to try is closing all those background apps (press on the 'square' or 'menu' button; depending on the version of Android there may be a 'close all' selection or you may have to close each one individually). Failing that a full reboot is the next step.

Did that fix the problem?

Once it's working again you can get a (very) rough feel for how close you are to running out of memory by checking the value of PAGE. e.g. by running 'about.bbc'. BBC BASIC tries to allocate memory starting from the bottom, so the higher the resulting address the nearer you were to getting the error message.

Different versions of Android seem to be quite variable in how they allocate memory, and on the machines I have here BBC BASIC seems typically to end up at a lower address in Marshmallow (Android 6.0) than it does in KitKat (Android 4.4).

Richard.
User IP Logged

DDRM
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 36
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #14 on: Feb 11th, 2017, 6:19pm »

Hi Richard,

No, even with all apps shut and after a restart .16d wouldn't run. I've uninstalled it and reinstalled .16a, which runs fine, though I haven't had much chance to play with it.

That reports PAGE=&20031700, and HIMEM as &20231700, with available memory as 2,097,152 bytes.

I make that PAGE value a bit over 500MB. The Nexus has 2GB of memory, so there shouldn't be an issue...

Best wishes,

D
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #15 on: Feb 11th, 2017, 7:55pm »

on Feb 11th, 2017, 6:19pm, DDRM wrote:
I've uninstalled it and reinstalled .16a, which runs fine, though I haven't had much chance to play with it.

UNDER NO CIRCUMSTANCES must you use 0.16a. It has a MAJOR BUG which is liable to crash your device.

Are you saying that 0.16d does not run after a full reboot? I would find that surprising, but if it is the case it unfortunately means that your device is not suitable for running BBC BASIC since it cannot make available the necessary memory.

It may be worth upgrading to a newer version of Android, if available, to see if that helps.

Richard.
« Last Edit: Feb 11th, 2017, 8:05pm by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #16 on: Feb 12th, 2017, 11:45am »

I've updated BBCSDL once again (all editions), this time to v0.16e. This version uses an even more aggressive memory-allocation strategy - it will attempt to squeeze itself into a smaller gap - in the hope that it may solve the reported "Couldn't allocate memory" message.

Version 0.16e may be downloaded for the various platforms as follows:It's not impossible that the new memory allocation strategy might itself cause problems so if you notice anything untoward please report it.

Richard.
User IP Logged

DDRM
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 36
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #17 on: Feb 13th, 2017, 1:02pm »

Hi Richard,

I've found out how to check my memory, and .16d won't run even when there is 1.4GB of RAM free!

However, I downloaded .16e, and that appears to run fine - so thanks for that. I'll let you know if I run into any problems.

Best wishes,

D
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #18 on: Feb 13th, 2017, 1:57pm »

on Feb 13th, 2017, 1:02pm, DDRM wrote:
I've found out how to check my memory, and .16d won't run even when there is 1.4GB of RAM free!

It's the old fragmentation problem. It doesn't matter how much memory is free if there isn't a contiguous block big enough to contain BBC BASIC's heap/stack (it attempts to allocate 256 Mbytes). It's a problem on Windows too, but Android has a less sophisticated memory management system so is likely to suffer more.

Quote:
However, I downloaded .16e, and that appears to run fine

It takes more liberties than 0.16d! As I mentioned previously, you can run mmap.bbc (in the tools directory) to get a feel for how fragmented your memory is. If the screen fills with allocations you can tap on it to scroll through more; if that proves to be necessary it gives you an idea of the problem!

Richard.
User IP Logged

DDRM
Global Moderator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 36
xx Re: BBC BASIC for SDL 2.0 v0.16a released
« Reply #19 on: Feb 14th, 2017, 08:34am »

Hmm. Obviously I couldn't run mmap until I had a recent working version. It's certainly a sobering insight into a modern operating system!

I note that you said "reboot" the device. Is that different from turning it off (i.e. power down, not just sleep) and back on? IS there a generic Android way of doing that? I'm guessing that things might then take consecutive blocks of memory, rather than being scattered all over.

I don't really want to put it back to factory defaults, deleting all apps etc...

Best wishes,

D
User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls