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

Re: Introduction to BBC BASIC

Tue Aug 25, 2020 9:46 pm

If anybody wants to try porting my BBC BASIC to the Micro:Bit the source code is readily available at GitHub. It's very much designed to keep the generic interpreter (bbmain.c, bbexec.c, bbeval.c) and the platform-specific modules (bbcmos.c, bbccli.c, bbcvdu.c etc.) separate, in keeping with the way the BBC Micro itself kept the 'language' and the 'MOS' separate.

So to get something running it's basically just a case of compiling the generic modules and satisfying the unresolved external references with I/O routines and non-functional stubs as appropriate to the platform. Global data declarations are currently in an assembler module (e.g. bbdata_arm_32.s) in order that their layout in memory can be fixed, but that's not essential for a functioning interpreter.

ejolson
Posts: 6037
Joined: Tue Mar 18, 2014 11:47 am

Re: Introduction to BBC BASIC

Wed Aug 26, 2020 2:29 am

I posted the Unix variant of Hunt the Wumpus written by Ken Thompson in 1973 along with a few minor changes to the C program needed to compile the program using gcc on the Raspberry Pi at

viewtopic.php?p=1713113#p1713113

Surprisingly, the changes to the original BASIC program written by Gregory Yob needed for BBC BASIC are even fewer. Namely, I had to change not equals from # to <> and GOTO N OF to ON N GOTO and RND(0) to RND(1). The modified BASIC code reads as

Code: Select all

0010  REM- HUNT THE WUMPUS
0015  REM:  BY GREGORY YOB
0020  PRINT "INSTRUCTIONS (Y-N)";
0030  INPUT I$
0040  IF I$="N" THEN 52
0050  GOSUB 1000
0052  REM- ANNOUNCE WUMPUSII FOR ALL AFICIONADOS ... ADDED BY DAVE
0054  PRINT
0056  PRINT "     ATTENTION ALL WUMPUS LOVERS!!!"
0058  PRINT "     THERE ARE NOW TWO ADDITIONS TO THE WUMPUS FAMILY";
0060  PRINT " OF PROGRAMS."
0062  PRINT
0064  PRINT "     WUMP2:  SOME DIFFERENT CAVE ARRANGEMENTS"
0066  PRINT "     WUMP3:  DIFFERENT HAZARDS"
0067  PRINT
0068  REM- SET UP CAVE (DODECAHEDRAL NODE LIST)
0070  DIM S(20,3)
0080   FOR J=1 TO 20
0090    FOR K=1 TO 3
0100    READ S(J,K)
0110    NEXT K
0120   NEXT J
0130  DATA 2,5,8,1,3,10,2,4,12,3,5,14,1,4,6
0140  DATA 5,7,15,6,8,17,1,7,9,8,10,18,2,9,11
0150  DATA 10,12,19,3,11,13,12,14,20,4,13,15,6,14,16
0160  DATA 15,17,20,7,16,18,9,17,19,11,18,20,13,16,19
0170  DEF FNA(X)=INT(20*RND(1))+1
0180  DEF FNB(X)=INT(3*RND(1))+1
0190  DEF FNC(X)=INT(4*RND(1))+1
0200  REM-LOCATE L ARRAY ITEMS
0210  REM-1-YOU,2-WUMPUS,3&4-PITS,5&6-BATS
0220  DIM L(6)
0230  DIM M(6)
0240   FOR J=1 TO 6
0250   L(J)=FNA(0)
0260   M(J)=L(J)
0270   NEXT J
0280  REM-CHECK FOR CROSSOVERS (IE L(1)=L(2),ETC)
0290   FOR J=1 TO 6
0300    FOR K=J TO 6
0310    IF J=K THEN 330
0320    IF L(J)=L(K) THEN 240
0330    NEXT K
0340   NEXT J
0350  REM-SET# ARROWS
0360  A=5
0365  L=L(1)
0370  REM-RUN THE GAME
0375  PRINT "HUNT THE WUMPUS"
0380  REM-HAZARD WARNINGS & LOCATION
0390  GOSUB 2000
0400  REM-MOVE OR SHOOT
0410  GOSUB 2500
0420  ON O GOTO 440,480
0430  REM-SHOOT
0440  GOSUB 3000
0450  IF F=0 THEN 390
0460  GOTO 500
0470  REM-MOVE
0480  GOSUB 4000
0490  IF F=0 THEN 390
0500  IF F>0 THEN 550
0510  REM-LOSE
0520  PRINT "HA HA HA - YOU LOSE!"
0530  GOTO 560
0540  REM-WIN
0550  PRINT "HEE HEE HEE - THE WUMPUS'LL GETCHA NEXT TIME!!"
0560   FOR J=1 TO 6
0570   L(J)=M(J)
0580   NEXT J
0590  PRINT "SAME SET-UP (Y-N)";
0600  INPUT I$
0610  IF I$<>"Y" THEN 240
0620  GOTO 360
1000  REM-INSTRUCTIONS
1010  PRINT "WELCOME TO 'HUNT THE WUMPUS'"
1020  PRINT "  THE WUMPUS LIVES IN A CAVE OF 20 ROOMS. EACH ROOM"
1030  PRINT "HAS 3 TUNNELS LEADING TO OTHER ROOMS. (LOOK AT A"
1040  PRINT "DODECAHEDRON TO SEE HOW THIS WORKS-IF YOU DON'T KNOW"
1050  PRINT "WHAT A DODECAHEDRON IS, ASK SOMEONE)"
1060  PRINT
1070  PRINT "     HAZARDS:"
1080  PRINT " BOTTOMLESS PITS - TWO ROOMS HAVE BOTTOMLESS PITS IN THEM"
1090  PRINT "     IF YOU GO THERE, YOU FALL INTO THE PIT (& LOSE!)"
1100  PRINT " SUPER BATS - TWO OTHER ROOMS HAVE SUPER BATS. IF YOU"
1110  PRINT "     GO THERE, A BAT GRABS YOU AND TAKES YOU TO SOME OTHER"
1120  PRINT "     ROOM AT RANDOM. (WHICH MIGHT BE TROUBLESOME)"
1130  PRINT
1140  PRINT "     WUMPUS:"
1150  PRINT " THE WUMPUS IS NOT BOTHERED BY THE HAZARDS (HE HAS SUCKER"
1160  PRINT " FEET AND IS TOO BIG FOR A BAT TO LIFT).  USUALLY"
1170  PRINT " HE IS ASLEEP. TWO THINGS WAKE HIM UP: YOUR ENTERING"
1180  PRINT " HIS ROOM OR YOUR SHOOTING AN ARROW."
1190  PRINT "     IF THE WUMPUS WAKES, HE MOVES (P=.75) ONE ROOM"
1200  PRINT " OR STAYS STILL (P=.25). AFTER THAT, IF HE IS WHERE YOU"
1210  PRINT " ARE, HE EATS YOU UP (& YOU LOSE!)"
1220  PRINT
1230  PRINT "     YOU:"
1240  PRINT " EACH TURN YOU MAY MOVE OR SHOOT A CROOKED ARROW"
1250  PRINT "   MOVING: YOU CAN GO ONE ROOM (THRU ONE TUNNEL)"
1260  PRINT "   ARROWS: YOU HAVE 5 ARROWS. YOU LOSE WHEN YOU RUN OUT."
1270  PRINT "   EACH ARROW CAN GO FROM 1 TO 5 ROOMS. YOU AIM BY TELLING"
1280  PRINT "   THE COMPUTER THE ROOM#S YOU WANT THE ARROW TO GO TO."
1290  PRINT "   IF THE ARROW CAN'T GO THAT WAY (IE NO TUNNEL) IT MOVES"
1300  PRINT "   AT RAMDOM TO THE NEXT ROOM."
1310  PRINT "     IF THE ARROW HITS THE WUMPUS, YOU WIN."
1320  PRINT "     IF THE ARROW HITS YOU, YOU LOSE."
1330  PRINT
1340  PRINT "    WARNINGS:"
1350  PRINT "     WHEN YOU ARE ONE ROOM AWAY FROM WUMPUS OR HAZARD,"
1360  PRINT "    THE COMPUTER SAYS:"
1370  PRINT " WUMPUS-  'I SMELL A WUMPUS'"
1380  PRINT " BAT   -  'BATS NEARBY'"
1390  PRINT " PIT   -  'I FEEL A DRAFT'"
1400  PRINT ""
1410  RETURN
2000  REM-PRINT LOCATION & HAZARD WARNINGS
2010  PRINT
2020   FOR J=2 TO 6
2030    FOR K=1 TO 3
2040    IF S(L(1),K)<>L(J) THEN 2110
2050    ON J-1 GOTO 2060,2080,2080,2100,2100
2060    PRINT "I SMELL A WUMPUS!"
2070    GOTO 2110
2080    PRINT "I FEEL A DRAFT"
2090    GOTO 2110
2100    PRINT "BATS NEARBY!"
2110    NEXT K
2120   NEXT J
2130  PRINT "YOU ARE IN ROOM "L(1)
2140  PRINT "TUNNELS LEAD TO "S(L,1),S(L,2),S(L,3)
2150  PRINT
2160  RETURN
2500  REM-CHOOSE OPTION
2510  PRINT "SHOOT OR MOVE (S-M)";
2520  INPUT I$
2530  IF I$<>"S" THEN 2560
2540  O=1
2550  RETURN
2560  IF I$<>"M" THEN 2510
2570  O=2
2580  RETURN
3000  REM-ARROW ROUTINE
3010  F=0
3020  REM-PATH OF ARROW
3030  DIM P(5)
3040  PRINT "NO. OF ROOMS(1-5)";
3050  INPUT J9
3060  IF J9<1 OR J9>5 THEN 3040
3070   FOR K=1 TO J9
3080   PRINT "ROOM #";
3090   INPUT P(K)
3095   IF K <= 2 THEN 3115
3100   IF P(K) <> P(K-2) THEN 3115
3105   PRINT "ARROWS AREN'T THAT CROOKED - TRY ANOTHER ROOM"
3110   GOTO 3080
3115   NEXT K
3120  REM-SHOOT ARROW
3130  L=L(1)
3140   FOR K=1 TO J9
3150    FOR K1=1 TO 3
3160    IF S(L,K1)=P(K) THEN 3295
3170    NEXT K1
3180   REM-NO TUNNEL FOR ARROW
3190   L=S(L,FNB(1))
3200   GOTO 3300
3210   NEXT K
3220  PRINT "MISSED"
3225  L=L(1)
3230  REM-MOVE WUMPUS
3240  GOSUB 3370
3250  REM-AMMO CHECK
3255  A=A-1
3260  IF A>0 THEN 3280
3270  F=-1
3280  RETURN
3290  REM-SEE IF ARROW IS AT L(1) OR L(2)
3295  L=P(K)
3300  IF L<>L(2) THEN 3340
3310  PRINT "AHA! YOU GOT THE WUMPUS!"
3320  F=1
3330  RETURN
3340  IF L<>L(1) THEN 3210
3350  PRINT "OUCH! ARROW GOT YOU!"
3360  GOTO 3270
3370  REM-MOVE WUMPUS ROUTINE
3380  K=FNC(0)
3390  IF K=4 THEN 3410
3400  L(2)=S(L(2),K)
3410  IF L(2)<>L THEN 3440
3420  PRINT "TSK TSK TSK- WUMPUS GOT YOU!"
3430  F=-1
3440  RETURN
4000  REM- MOVE ROUTINE
4010  F=0
4020  PRINT "WHERE TO";
4030  INPUT L
4040  IF L<1 OR L>20 THEN 4020
4050   FOR K=1 TO 3
4060   REM- CHECK IF LEGAL MOVE
4070   IF S(L(1),K)=L THEN 4130
4080   NEXT K
4090  IF L=L(1) THEN 4130
4100  PRINT "NOT POSSIBLE -";
4110  GOTO 4020
4120  REM-CHECK FOR HAZARDS
4130  L(1)=L
4140  REM-WUMPUS
4150  IF L<>L(2) THEN 4220
4160  PRINT "...OOPS! BUMPED A WUMPUS!"
4170  REM-MOVE WUMPUS
4180  GOSUB 3380
4190  IF F=0 THEN 4220
4200  RETURN
4210  REM-PIT
4220  IF L<>L(3) AND L<>L(4) THEN 4270
4230  PRINT "YYYIIIIEEEE . . . FELL IN PIT"
4240  F=-1
4250  RETURN
4260  REM-BATS
4270  IF L<>L(5) AND L<>L(6) THEN 4310
4280  PRINT "ZAP--SUPER BAT SNATCH! ELSEWHEREVILLE FOR YOU!"
4290  L=FNA(1)
4300  GOTO 4130
4310  RETURN
5000  END
A sample run looks like

Code: Select all

>RUN
INSTRUCTIONS (Y-N)? N

     ATTENTION ALL WUMPUS LOVERS!!!
     THERE ARE NOW TWO ADDITIONS TO THE WUMPUS FAMILY OF PROGRAMS.

     WUMP2:  SOME DIFFERENT CAVE ARRANGEMENTS
     WUMP3:  DIFFERENT HAZARDS

HUNT THE WUMPUS

YOU ARE IN ROOM         19
TUNNELS LEAD TO         11            18        20

SHOOT OR MOVE (S-M)? M
WHERE TO? 20

BATS NEARBY!
YOU ARE IN ROOM         20
TUNNELS LEAD TO         13            16        19

*** There are bats either in room 13 or 16.  Go back.

SHOOT OR MOVE (S-M)? M
WHERE TO? 19

YOU ARE IN ROOM         19
TUNNELS LEAD TO         11            18        20

SHOOT OR MOVE (S-M)? M
WHERE TO? 18

YOU ARE IN ROOM         18
TUNNELS LEAD TO          9            17        19

SHOOT OR MOVE (S-M)? M
WHERE TO? 17

I FEEL A DRAFT
BATS NEARBY!
YOU ARE IN ROOM         17
TUNNELS LEAD TO          7            16        18

*** Either bats in room 7 and a pit in room 16 or the
*** other way around.  Go back.

SHOOT OR MOVE (S-M)? M
WHERE TO? 18

YOU ARE IN ROOM         18
TUNNELS LEAD TO          9            17        19

SHOOT OR MOVE (S-M)? M
WHERE TO? 9

I FEEL A DRAFT
YOU ARE IN ROOM          9
TUNNELS LEAD TO          8            10        18

*** There is a pit in either room 8 or room 10.

SHOOT OR MOVE (S-M)? M
WHERE TO? 18

YOU ARE IN ROOM         18
TUNNELS LEAD TO          9            17        19

SHOOT OR MOVE (S-M)? M
WHERE TO? 19

YOU ARE IN ROOM         19
TUNNELS LEAD TO         11            18        20

SHOOT OR MOVE (S-M)? M
WHERE TO? 11

BATS NEARBY!
YOU ARE IN ROOM         11
TUNNELS LEAD TO         10            12        19

*** There is a bat in either room 10 or room 12.  Since there
*** are only two bats, this means that the bats seen earlier
*** must be in room 16.  Go back.

SHOOT OR MOVE (S-M)? M
WHERE TO? 19

YOU ARE IN ROOM         19
TUNNELS LEAD TO         11            18        20

SHOOT OR MOVE (S-M)? M
WHERE TO? 20

BATS NEARBY!
YOU ARE IN ROOM         20
TUNNELS LEAD TO         13            16        19

SHOOT OR MOVE (S-M)? M
WHERE TO? 13

BATS NEARBY!
YOU ARE IN ROOM         13
TUNNELS LEAD TO         12            14        20

*** There is a bat in either room 12 or 14.  As this must be
*** the other bat, then it's in 12.

SHOOT OR MOVE (S-M)?  M
WHERE TO? 14

YOU ARE IN ROOM         14
TUNNELS LEAD TO          4            13        15

SHOOT OR MOVE (S-M)? M
WHERE TO? 4

YOU ARE IN ROOM          4
TUNNELS LEAD TO          3             5        14

SHOOT OR MOVE (S-M)? M
WHERE TO? 5

YOU ARE IN ROOM          5
TUNNELS LEAD TO          1             4         6

SHOOT OR MOVE (S-M)? M
WHERE TO? 1

I SMELL A WUMPUS!
I FEEL A DRAFT
YOU ARE IN ROOM          1
TUNNELS LEAD TO          2             5         8

*** There is a bat in either room 8 or room 2 and the Wumpus
*** is in either room 8 or room 2.  But if the Wumpus were in
*** room 8 then we would have smelled it from 9, so it must
*** be in room 2.  Time to shoot an arrow!

SHOOT OR MOVE (S-M)? S
NO. OF ROOMS(1-5)? 1
ROOM #? 2
AHA! YOU GOT THE WUMPUS!
HEE HEE HEE - THE WUMPUS'LL GETCHA NEXT TIME!!
SAME SET-UP (Y-N)? N
HUNT THE WUMPUS

I SMELL A WUMPUS!
BATS NEARBY!
YOU ARE IN ROOM         20
TUNNELS LEAD TO         13            16        19

SHOOT OR MOVE (S-M)? 
Escape at line 2520
>
Note that I've added commentary prefixed by *** in the transcript of the run to indicate the minesweeper-like deductions that were made while playing the game.

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

Re: Introduction to BBC BASIC

Wed Aug 26, 2020 6:51 pm

RichardRussell wrote:
Tue Aug 25, 2020 9:46 pm
If anybody wants to try porting my BBC BASIC to the Micro:Bit the source code is readily available at GitHub. It's very much designed to keep the generic interpreter (bbmain.c, bbexec.c, bbeval.c) and the platform-specific modules (bbcmos.c, bbccli.c, bbcvdu.c etc.) separate, in keeping with the way the BBC Micro itself kept the 'language' and the 'MOS' separate.

So to get something running it's basically just a case of compiling the generic modules and satisfying the unresolved external references with I/O routines and non-functional stubs as appropriate to the platform. Global data declarations are currently in an assembler module (e.g. bbdata_arm_32.s) in order that their layout in memory can be fixed, but that's not essential for a functioning interpreter.
What surprises me is that the Mico:Bit wasn't developed
using BBCBasic . Python has become all the rage .......
( for whatever reason ? )
http://www.hitswares.com/

User avatar
scruss
Posts: 3513
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Thu Aug 27, 2020 6:46 am

hitsware wrote:
Wed Aug 26, 2020 6:51 pm
What surprises me is that the Mico:Bit wasn't developed
using BBCBasic . Python has become all the rage .......
( for whatever reason ? )
The BBC only had an initial guiding hand in the process, and the rest seems to have been what other tech companies could donate. It runs a very small ARM microcontroller - 16 K RAM, 256 K flash - and in fact the power regulator/wireless chip is a more powerful ARM µc than the main one. It doesn't have a filesystem, or a display, or an input device. There isn't a readily-available BBC BASIC interpreter that runs on ARM Cortex-M0 (there is a BASIC, I discover, from Coridium, though: BASIC for ARM). Microsoft had MakeCode (a blocks programming tool) and Micropython can be squeezed (just!) onto the CPU.

While I think that Python looks rather ugly, it does work. BASIC's just for nostalgic olds like us.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

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

Re: Introduction to BBC BASIC

Thu Aug 27, 2020 8:26 am

scruss wrote:
Thu Aug 27, 2020 6:46 am
BASIC's just for nostalgic olds like us.
It's perhaps worth noting, again, that as recently as 2012 an entire chapter was devoted to BBC BASIC in the OCR Computing for GCSE students' book, and there were UK schoolkids being taught it in the classroom up to about 5 years ago. So there will be plenty of young people who are very familiar with it.

User avatar
scruss
Posts: 3513
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Fri Aug 28, 2020 12:23 pm

Someone who did their GCSEs in 2012 would be 23-24: more likely to be teaching than learning.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

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

Re: Introduction to BBC BASIC

Fri Aug 28, 2020 1:16 pm

scruss wrote:
Fri Aug 28, 2020 12:23 pm
Someone who did their GCSEs in 2012 would be 23-24: more likely to be teaching than learning.
2012 was when that particular curriculum came in (hence the students' book being published) so schools were teaching BBC BASIC for some time afterwards. My records of sales of BBC BASIC for Windows to schools give a good indication of how its popularity rose and waned; site licences were a worthwhile source of income for some time! I know of some teachers who would still like to teach it, but the curriculum has become more prescriptive so they can probably do little more than mention it in passing now.

Anyway, by my standards 23-24 is still very young, it doesn't come close to qualifying as "nostalgic olds like us"!

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

Re: Introduction to BBC BASIC

Sun Aug 30, 2020 7:05 pm

Post deleted.
Last edited by RichardRussell on Mon Aug 31, 2020 12:05 am, edited 1 time in total.

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

Re: Introduction to BBC BASIC

Sun Aug 30, 2020 9:30 pm

Here is what I get :
bbc.png
bbc.png (91.58 KiB) Viewed 1550 times
http://www.hitswares.com/

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

Re: Introduction to BBC BASIC

Mon Aug 31, 2020 12:04 am

hitsware wrote:
Sun Aug 30, 2020 9:30 pm
Here is what I get :
That seems to be Chromium. I didn't say it ran in Chromium, and I wouldn't expect it to. Perhaps it was inappropriate to post the message to this forum, as there's no way it could possibly run on a Raspberry Pi anyway.

If you want to try it, use (up to date) Microsoft Edge or Google Chrome on a fast PC.

ejolson
Posts: 6037
Joined: Tue Mar 18, 2014 11:47 am

Re: Introduction to BBC BASIC

Mon Aug 31, 2020 12:09 am

RichardRussell wrote:
Mon Aug 31, 2020 12:04 am
hitsware wrote:
Sun Aug 30, 2020 9:30 pm
Here is what I get :
That seems to be Chromium. I didn't say it ran in Chromium, and I wouldn't expect it to. Perhaps it was inappropriate to post the message to this forum, as there's no way it could possibly run on a Raspberry Pi anyway.

If you want to try it, use (up to date) Microsoft Edge or Google Chrome on a fast PC.
If it works in Chrome, why wouldn't it work in Chromium?

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

Re: Introduction to BBC BASIC

Mon Aug 31, 2020 12:50 am

ejolson wrote:
Mon Aug 31, 2020 12:09 am
If it works in Chrome, why wouldn't it work in Chromium?
In the posted screen shot it says "Exception thrown, see Javascript console" so that might answer your question. It could be that Chromium lacks a feature that it relies on, or it could be a lack of resources. It won't even run in Firefox currently (I believe there may be a workaround by arranging for the web server to send specific headers which enable multi-threading in WebAssembly, but I don't know precisely how to do that).

cjketle
Posts: 16
Joined: Mon Jan 14, 2019 6:29 pm

Re: Introduction to BBC BASIC

Mon Aug 31, 2020 4:36 pm

Looks like there may be a build problem with the current console version as it won't run on a pi0/pi1b - halts with 'illegal instruction'. OK in pi2/3. Is it intended to support the earlier processors?

Chris K

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

Re: Introduction to BBC BASIC

Mon Aug 31, 2020 5:54 pm

cjketle wrote:
Mon Aug 31, 2020 4:36 pm
Is it intended to support the earlier processors?
Probably not. These are the compiler flags I specify:

Code: Select all

-march=armv7-a -mthumb -munaligned-access -mfloat-abi=hard

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

Re: Introduction to BBC BASIC

Tue Sep 01, 2020 10:05 pm

RichardRussell wrote:
Mon Aug 12, 2019 8:38 am

Code: Select all

emcc -s USE_PTHREADS=1 -s WASM=1 -s USE_SDL=2 -s USE_SDL_TTF=2 -s USE_SDL_NET=2
I went through this whole exercise months ago and built a complete BBC BASIC binary (as an HTML5 file) using Emscripten, but it doesn't run. I'll revisit it sometime when the multi-threaded support is more mature.
Replying to a post made more than a year ago probably isn't good form, but one reason for it not working back then turns out to have been because another switch is necessary:

Code: Select all

emcc -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=1 -s WASM=1 -s USE_SDL=2 -s USE_SDL_TTF=2 -s USE_SDL_NET=2
Without the PTHREAD_POOL_SIZE=1 the SDL_CreateThread function hangs, but no errors or warnings are issued.

Soruk
Posts: 23
Joined: Thu Jun 20, 2019 11:25 am
Location: Basingstoke, UK
Contact: Website

Re: Introduction to BBC BASIC

Wed Sep 09, 2020 8:43 pm

RichardRussell wrote:
Wed Aug 12, 2020 5:19 pm
scruss wrote:
Wed Aug 12, 2020 4:51 pm
It's very heartening to see you and Michael McC engage on the other forum
And not for a moment was I implying that his might be the version that "gains new features on an almost weekly basis". Oh, wait... :oops:
No worries! (I really ought to browse this forum more often...!)

I will however point out, looking at my recent ChangeLog entries that most changes to the BASIC language handling are to add features that are in BBCSDL but missing in Matrix Brandy like your GET(x,y) function or bug fixes (like some RENUMBER edge cases that popped out recently), but the vast majority of feature updates are in the MOS emulation layer and the RISC OS graphics and teletext emulation. Other new features have been implemented as SYS calls and the occasional *-command, which is like loading an additional module in RISC OS or calling a new DLL in BB4W. I have been extremely careful to (try) not break the BASIC itself, and have backed out what might otherwise have been promising new additions like variant data types as while it was mostly working, it was just breaking far too many traditionally-written programs to warrant keeping it.
RichardRussell wrote:
Wed Aug 12, 2020 8:35 pm
scruss wrote:
Wed Aug 12, 2020 7:26 pm
At least there is some engagement in trying to keep features common and compatible.
Absolutely, and naturally I have no problem with Michael improving the compatibility of Matrix Brandy with my BASICs. We are rather different in our approaches to software development: I prefer to be slow and careful, whereas I don't think he'd mind me saying that he's rather more impetuous.
We come from rather different backgrounds. And yes, it does mean there are some checkins in to my git tree that are hopelessly broken, but I have also found a relatively frequent checkin regime has overall been more of a blessing than a curse - when I find something has regressed badly that I didn't spot in time, being able to find which commit broke it (and even better if it's a small commit) is a great pointer to what I need to do to fix it.
Matrix Brandy BASIC VI - http://brandy.matrixnetwork.co.uk/

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

Re: Introduction to BBC BASIC

Fri Sep 11, 2020 4:17 pm

I've released version 1.15a of BBC BASIC for SDL 2.0 - the cross-platform programming language for Windows, MacOS, Linux, Raspbian, Android, iOS and WebAssembly (Chrome/Edge/Firefox). The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine:

    Added the PTR()= syntax to set the pointer of a structure, array or string.

    Extended =PTR() to return the pointer of a structure or array as well as a string.

    Added = SYS("function") to return the address of an API function, or zero if it doesn't exist.

    Added support for @cmd$ possibly being longer than 255 bytes.

    Changed TIME from unsigned to signed, since code like 'T% = TIME' is very common.

    Fixed a minor problem with the 'pending newline' mode (VDU 23,16,1|) (needs fixing in BB4W too!).

    Fixed a bug (in the 64-bit and ARM editions only) causing assigning a string to a numeric variable not to result in the expected 'Type mismatch' error.

  2. IDEs and Utilities:

    SDLIDE: Implemented breakpoints, very similar to those in LBB and bbcide (double-click in the left margin to add or remove a breakpoint).

    SDLIDE: Enabled the Print option in the File menu and toolbar. This prints the current program to the default printer.

  3. Libraries:

    Modified filedlg to fix an incompatibility with *HEX 64 mode.

    Modified dlglib to reduce CPU usage when idling, especially when a List Box has the input focus.

    Modified socklib to prevent a 'double-free' error if PROC_exitsockets is called twice.

  4. Example Programs:

    Modified Ceefax.bbc to recognise the word Thunder in the weather description and display the 'storm' indication.

    Modified telstar.bbc to include 'ANSItex BBS' in the list of services, and to disable 'pending newline' mode.
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, 64-bit Linux and in-browser editions, currently).

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

Re: Introduction to BBC BASIC

Sat Sep 12, 2020 2:40 pm

I have updated the Console Mode editions of BBC BASIC to version 0.26, principally to bring them into line with the latest release of BBC BASIC for SDL 2.0. The main changes in this version are:

  • File pointers and lengths (PTR#, EXT#) are now 64-bits on all platforms.
  • Added the SYS function to return the entry point of an API, e.g. `memcpy` = SYS("memcpy").
  • Added the PTR()= statement to set the pointer of an array or structure.
  • Extended the =PTR() function to return the pointer of an array or structure.
A typical use for the PTR()= statement is to set the pointer of a linked-list node:

Code: Select all

      DIM node{link, ...}
      ...
      REPEAT
        PTR(node{}) = node.link : REM traverse linked-list
      UNTIL node.link = 0

Version 0.26 may be downloaded as follows:


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

Re: Introduction to BBC BASIC

Sun Sep 13, 2020 4:54 pm

In case of TL;DR can I draw attention to the two main new features in SDLIDE, printing and breakpoints:

Printing
The Print option in the File menu and the Print button in the toolbar are now active. They both result in the current program (as displayed in the editing pane) being listed on your default printer. SDLIDE gives no control over layout, font etc. but your Operating System should provide a way of configuring the default printing options, either at a command prompt or via a GUI.

Breakpoints
You can set (or clear) a breakpoint on a program line by double-clicking in the left margin, pressing Ctrl+B or using the Run... Toggle Breakpoint menu option. When such a breakpoint is set, the program will pause on that line (if it is ever executed) when run in Debug mode; breakpoints have no effect if the program is run 'normally'.

In the paused state you can examine variables, stop the program, run to the next breakpoint (if any) or single-step execution (Step Into or Step Over); adding or removing breakpoints will have no effect until the next time the program is run. You can clear all breakpoints by pressing F4 or using the Run... Clear Breakpoints menu option.

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

Re: Introduction to BBC BASIC

Mon Sep 14, 2020 5:00 pm

If you've noticed some Ceefax pages not displaying correctly recently, you're not alone. The BBC has changed the HTML format of some of its news pages and this has broken the parser in Ceefax.bbc. I've now fixed this and updated both BBC BASIC for SDL 2.0 and the standalone Android app, although it's always going to be a case of catch-up as the BBC is bound to change things again. :(
ceefax195.png
ceefax195.png (121.14 KiB) Viewed 911 times

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

Re: Introduction to BBC BASIC

Tue Sep 15, 2020 2:57 am

Richard ,
Would You help out a countryman
( and me again ) here :
( Scroll down to towards the end )
http://www.thebackshed.com/forum/ViewTo ... &TID=12749
I followed those directions some time ago , and they worked .
Now the BBCB screen flashes , but only for a moment .
And :

Code: Select all

pi@raspberrypi:~ $ cd /home/pi/bbc
pi@raspberrypi:~/bbc $ ./bbcsdl
./bbcsdl: symbol lookup error: ./bbcsdl: undefined symbol: SDL_ComposeCustomBlendMode
pi@raspberrypi:~/bbc $ 
http://www.hitswares.com/

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

Re: Introduction to BBC BASIC

Tue Sep 15, 2020 8:44 am

hitsware wrote:
Tue Sep 15, 2020 2:57 am
./bbcsdl: symbol lookup error: ./bbcsdl: undefined symbol: SDL_ComposeCustomBlendMode
The SDL_ComposeCustomBlendMode function was added in SDL 2.0.6 so if it cannot be found the implication is that the version of SDL installed is even earlier than that. Which model of Raspberry Pi are we talking about and what version of SDL 2 is installed?

If you cannot install SDL 2.0.6 or later let me know and I'll rebuild BBCSDL with the call to SDL_ComposeCustomBlendMode disabled.

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

Re: Introduction to BBC BASIC

Tue Sep 15, 2020 4:10 pm

Code: Select all

pi@raspberrypi:~ $ dpkg -l | grep sdl
ii  libsdl-image1.2:armhf                 1.2.12-5+deb9u2                   armhf        Image loading library for Simple DirectMedia Layer 1.2, libraries
ii  libsdl-mixer1.2:armhf                 1.2.12-11+b1                      armhf        Mixer library for Simple DirectMedia Layer 1.2, libraries
ii  libsdl-ttf2.0-0:armhf                 2.0.11-3                          armhf        TrueType Font library for Simple DirectMedia Layer 1.2, libraries
ii  libsdl1.2debian:armhf                 1.2.15+dfsg1-4+rpt2               armhf        Simple DirectMedia Layer
ii  libsdl2-2.0-0:armhf                   2.0.5+dfsg1-2+rpt1                armhf        Simple DirectMedia Layer
ii  libsdl2-net-2.0-0:armhf               2.0.1+dfsg1-2                     armhf        Network library for Simple DirectMedia Layer 2, libraries
ii  libsdl2-ttf-2.0-0:armhf               2.0.14+dfsg1-1                    armhf        TrueType Font library for Simple DirectMedia Layer 2, libraries
pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~ $  cat /proc/cpuinfo | grep Model
pi@raspberrypi:~ $ cat /proc/device-tree/model
Raspberry Pi 3 Model B Plus Rev 1.3pi@raspberrypi:~ $ cat /proc/device-tree/model
http://www.hitswares.com/

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

Re: Introduction to BBC BASIC

Tue Sep 15, 2020 6:34 pm

hitsware wrote:
Tue Sep 15, 2020 4:10 pm
ii libsdl2-2.0-0:armhf 2.0.5+dfsg1-2+rpt1 armhf Simple DirectMedia Layer
I'm not sure why you listed all the other stuff, but there you go: 2.0.5 is less than 2.0.6! If you can't install a later version of SDL2, try again with the latest update in which I've disabled the call to SDL_ComposeCustomBlendMode (it's a fallback, so not essential).

User avatar
scruss
Posts: 3513
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Tue Sep 15, 2020 6:41 pm

Richard - you might want to update the installation file, as it's missing the libsdl2-net-2.0-0 requirement. These are all the packages you need to run it:

Code: Select all

sudo apt install libsdl2-2.0-0 libsdl2-net-2.0-0 libsdl2-net-2.0-0 libsdl2-ttf-2.0-0 mesa-utils
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Other programming languages”