DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

BBC BASIC for the RPi 2

Sat Mar 28, 2015 7:04 pm

[EDIT: Please note that I named this thread "Something for the RPi 2," but a mod changed it to "BBC BASIC for the RPi 2"]

BBC BASIC is certainly quite zippy on the Raspberry Pi 2!

http://www.proggies.uk/risc_os/rotating_rpi_logo
http://www.proggies.uk/risc_os/rotating_rool_logo

RPi 2 only, sorry. Set filetype to &FFB or BASIC.

-----------
EDIT: I have updated the programs so that they will run better on non-Raspberry Pi RISC OS systems (as long as they're fast!). At the beginning of the program, non-RPi users should set the RPi% flag to FALSE. I will look into automatic RPi detection. Also, there's an issue where, on the RPi, the program runs practically flicker-free at 60 fps on one occassion, but after a reboot of the machine it may show horrible flickering and run at only 30 fps. Another reboot and it might run just fine! I am trying to fix this problem (I suspect it's something to do with misaligned arrays or whatnot, but I may be entirely mistaken).
-----------


There may be some flicker/tearing. I can't figure out how to prevent it. I've tried to minimize it by placing the WAIT statement just before the screenbank swap (and, somewhat unusually, the same bank number is specified for both OS_Byte calls):

bank = 1
REPEAT
<clear screen & draw the graphics>
WAIT
SYS "OS_Byte", 112, bank
SYS "OS_Byte", 113, bank
bank = bank EOR 3
UNTIL FALSE

It seems to work - or at least it should be an improvement on the awful flicker you get doing it the 'normal' way.


David.
--
Last edited by DaveW75 on Mon Mar 30, 2015 4:45 pm, edited 3 times in total.

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Sat Mar 28, 2015 11:46 pm

A starfield (60 fps on RPi 2):

http://www.proggies.uk/risc_os/starfield

Crunched version (slightly better performance):
http://www.proggies.uk/risc_os/starfieldx

Set the filetype to &FFB or BASIC.

Non-RPi users can set the RPi% variable near the start of the program to FALSE in order to remove or reduce screen flicker.

I learnt one thing this evening: ColourTrans_SetGCOL is faster than BASIC's GCOL statement (at least under RISC OS 5.21 on the RPi 2).


David.
--

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 9:43 am

I'm pretty sure I named this thread "Something for the RPi 2" ?

I wake up ten-or-so hours later to find that it's been changed to "BBC BASIC for the RPi 2". Had me questioning my own sanity!

Admittedly, the original thread title wasn't very descriptive, but I think I might've preferred "BBC BASIC on the RPi 2". :)

Incidentally, if anyone's wondering about the apparent focus on the RPi 2 (as opposed to just the RPi in general), it's because I'm treating the RPi 2 as a 'minimum spec' system on which to target my programs.

David.
--

User avatar
Burngate
Posts: 5892
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 9:48 am

Nice ones!

When I get time, I'll try them on all my Pi's. What surprised me was that they run happily on my VirtualRPC, Adjust 4.39

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 10:11 am

Burngate wrote:Nice ones!

When I get time, I'll try them on all my Pi's. What surprised me was that they run happily on my VirtualRPC, Adjust 4.39
If you don't mind, what frame rate were you getting? It's 59/60 fps on the Pi 2.

The rotating RPi & ROOL logo programs must have flickered horribly on VRPC, no? (And so would the 'starfield' unless the RPi% flag was set to FALSE!).

I'll upload modified versions of the programs later so that they run nicely on other (fast) RISC OS systems. On my laptop PC, under RPCEmu, the starfield program runs at a fairly miserable 14 fps (unless I'm mistaken, setting the graphics colour - especially with GCOL & ColourTrans - is a relatively slow affair on RISC OS).

David.
--

User avatar
Burngate
Posts: 5892
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 10:39 am

Flickering? yes; horribly? not really, for some definition of the word!
And setting that flag to FALSE made starfield a lot smoother.

Dunno about frame-rate - I don't know how to measure that!

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 11:24 am

Burngate wrote:Flickering? yes; horribly? not really, for some definition of the word!
And setting that flag to FALSE made starfield a lot smoother.

Dunno about frame-rate - I don't know how to measure that!
The frame rate (in frames per second) is displayed at the top-left corner of the screen by all three programs (rotating RPi & ROOL logo, and starfield).

David.
--

User avatar
Burngate
Posts: 5892
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 3:23 pm

DaveW75 wrote:... top-left corner of the screen ...
Ah. Where the flashing is worst. I could see something, but couldn't read it!

59 fps

EDIT:
Just tried on B+ and on a Bv2 (The rest are in various states of non-working. Note to self - must finish what I started before starting something new)

All ran at 29-32 fps. Flashing sometimes noticable. Long discussion with daughter about the origin of the starfield. Was it Startrek, or did it come from 2001?

User avatar
Burngate
Posts: 5892
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 4:34 pm

If it's of any interest, here's something I wrote for my first Archimedes - and it still works!
Not quite as polished as yours. Sorry.
galaxy.zip
(1.16 KiB) Downloaded 161 times

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Sun Mar 29, 2015 4:37 pm

Burngate wrote:
DaveW75 wrote:... top-left corner of the screen ...
Ah. Where the flashing is worst. I could see something, but couldn't read it!
I had a feeling that was the case!
Burngate wrote:59 fps

EDIT:
Just tried on B+ and on a Bv2 (The rest are in various states of non-working. Note to self - must finish what I started before starting something new)

All ran at 29-32 fps. Flashing sometimes noticable. Long discussion with daughter about the origin of the starfield. Was it Startrek, or did it come from 2001?
Thanks for the feedback, much appreciated.

I've modified the programs so that they should run better (but not necessarily faster) on non-RPi RISC OS hardware. The flag variable RPi% near the beginning of the programs should be set to FALSE for non-RPi users.

On RPCEmu there's absolutely no flicker - ever.

I hope that the folks at Raspberry Pi and ROOL are able to find a solution to this problem because most RISC OS games and demos use double buffering, which appears to be 'broken' on the Pi (for software-based graphics rendering) due to the way the hardware or firmware works.

Ah, the starfield... yes more likely came from Star Trek :) . Even likelier however, is that it came from the multitude of old-skool Acorn demos that almost invariably featured a starfield effect!

http://www.proggies.uk/risc_os/starfield
http://www.proggies.uk/risc_os/starfieldx
http://www.proggies.uk/risc_os/rotating_rpi_logo
http://www.proggies.uk/risc_os/rotating_rool_logo


David.
--

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Mon Mar 30, 2015 4:55 pm

Ok, here's a the ROOL logo flying through the starfield. Linear starfields like this one tend to be boring, so perhaps it's time for a proper 3D one. :)

Still runs at about 60 fps on an RPi 2, but occasionally, for reasons currently unknown to me, it may run at only half that frame rate.

http://www.proggies.uk/risc_os/rool_logo_2

As usual, set the filetype to &FFB or BASIC.

Reminder: Non-RPi users will have to set the RPi% flag to FALSE (it's near the start of the code).

David.
--

User avatar
DavidS
Posts: 4308
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BBC BASIC for the RPi 2

Fri Apr 03, 2015 4:12 am

As to the speed, why write something so simple to run so slow?

Though I remember someone figuring out how to sync to the screen quite well on the RPi in RISC OS. I do not remember how though, it would be nice to have the normal vertical blank.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Sun Apr 26, 2015 11:53 am

For those it might interest, I've updated my website with a few more BBC BASIC programs (they're mostly BASIC; one or two programs have a little bit of ASM where I felt it was necessary or practically unavoidable).

http://www.proggies.uk

The programs are crunched (with StrongBS) for improved performance, not to hide or obfuscate anything.


David.
--

GavinNY
Posts: 28
Joined: Thu Dec 22, 2011 1:03 am

Re: BBC BASIC for the RPi 2

Mon May 18, 2015 10:24 pm

Really enjoyed those, David. Bookmarked!

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Mon Nov 30, 2015 2:50 am

I recently updated my website with some new programs (RndAliens, Worm, Nematodes, Spinny).

They are written for the Raspberry Pi 2, and may not run as well (or at all) on an RPi 1, and other slower hardware.

I try to keep everything 100% BASIC, but sometimes assembler code is needed to prepare sprite masks in reasonable time (such tasks would take ages in BASIC).

http://www.proggies.uk


David.
--

DaveW75
Posts: 19
Joined: Fri Oct 11, 2013 1:50 am

Re: BBC BASIC for the RPi 2

Thu Dec 24, 2015 10:28 pm

Just uploaded a YouTube video showing most of the BASIC demos (well, mostly BASIC) I've made this year (2015).

https://youtu.be/FjYfqd9PbCI



http://www.proggies.uk

Return to “RISCOS”