BBC BASIC
« Search Results »

Welcome Guest. Please Login or Register.
May 29th, 2017, 07:32am


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

Search Results

Total results: 10


 1   Raspberry Pi / Buttonz, PROCcolor, and more for Pi 3 (efficient)  on: May 22nd, 2017, 2:48pm
Started by michael | Post by michael
I have tested this program and it works well on the Pi 3

You will need to look carefully at the way it cycles through the standby mode.
It is necessary to keep the pi cool.

PROCcolor and a few other tools are included.

Code:
      PROCgraphics(1000,500)
      REPEAT
        resp$=FNbuttonz(100,100,"clearitall")
        resp$=FNbuttonz(100,100,"Show me a circle ")
        WAIT 1
        REPEAT
          k% = INKEY(4)
          resp%=FNmoucheck
        UNTIL k%<>-1 OR resp% >0
      UNTIL resp$="Show me a circle "
      PROCcolor("f","yellow")
      CIRCLE FILL 500,500,150
      END
      DEF FNmoucheck
      PRIVATE mx%,my%,mb%,x%,y%,b%
      MOUSE x%,y%,b%
      IF mx%=0 AND my%=0 AND mb%=0 THEN mx%=x%:my%=y%:mb%=b%: =-1
      IF mx%=x% AND my%=y% AND mb%=b% THEN =-1 ELSE  mx%=x%:my%=y%:mb%=b%:=1
      DEF PROCgraphics(x,y)
      VDU 23,22,x;y;8,15,16,1
      OFF
      VDU 5
      ENDPROC
      DEFFNbuttonz(X,Y,msg$)
      LOCAL initialx%,fi%,reduction%,tx,ty,mx%,my%,mb%,ad%,ady%,c$
      PRIVATE st$
      IF msg$<> "clearitall" THEN
        initialx%=LEN(msg$)
        LET tx= X+initialx%+25
        LET ty= Y:reduction%=0
        reduction%=initialx%/2
        reduction%=reduction%*6
        IF initialx%<20 THEN reduction%=reduction%/2
        initialx%=initialx%*22-reduction%
        MOUSE mx%,my%,mb%
        ad%=initialx%+8:ad%+=X:ady%=Y-28
        IF mx% >X AND mx%<ad% AND my%<Y+8 AND my%>ady% THEN
          c$="255,255,255"
          IF mb%=4 THEN st$=msg$
        ELSE c$="200,200,200"
        ENDIF
        IF FNrgb(X,Y)="000,000,000" THEN c$="200,200,200"
        PROCcolor("f",c$)
        IF FNrgb(X,Y)<>c$ THEN
          FOR fi%=12 TO 48
            LINE X-3,Y+20-fi%,X+initialx%+8,Y+20-fi%
          NEXT
          PROCcolor("f","000,000,000")
          MOVE tx,ty
          PRINT msg$
        ENDIF
      ENDIF
      IF msg$="clearitall" THEN st$=""
      MOVE 0,0 REM hide that thing
      =st$
      DEF PROCcolor(fb$,rgb$)
      PRIVATE assemble$,br%,bg%,bb%
      IF rgb$="0" OR rgb$="black" THEN rgb$="000,000,000"
      IF rgb$="1" OR rgb$="red" THEN rgb$="200,000,000"
      IF rgb$="2" OR rgb$="green" THEN rgb$="000,200,000"
      IF rgb$="3" OR rgb$="yellow" THEN rgb$="200,200,000"
      IF rgb$="4" OR rgb$="blue" THEN rgb$="000,000,200"
      IF rgb$="5" OR rgb$="magenta" THEN rgb$="200,000,200"
      IF rgb$="6" OR rgb$="cyan" THEN rgb$="000,200,200"
      IF rgb$="7" OR rgb$="white" THEN rgb$="200,200,200"
      IF rgb$="8" OR rgb$="grey" THEN rgb$="056,056,056"
      IF rgb$="9" OR rgb$="light red" THEN rgb$="248,056,056"
      IF rgb$="10" OR rgb$="light green" THEN rgb$="056,248,056"
      IF rgb$="11" OR rgb$="light yellow" THEN rgb$="248,248,056"
      IF rgb$="12" OR rgb$="light blue" THEN rgb$="056,056,248"
      IF rgb$="13" OR rgb$="light magenta" THEN rgb$="248,056,248"
      IF rgb$="14" OR rgb$="light cyan" THEN rgb$="056,248,248"
      IF rgb$="15" OR rgb$="light white" THEN rgb$="248,248,248"
      assemble$=rgb$
      br%=VAL(MID$(assemble$,1,3)):bg%=VAL(MID$(assemble$,5,3)):bb%=VAL(MID$(assemble$,9,3))
      IF fb$="f" OR fb$="F" THEN COLOUR 0,br%,bg%,bb% : GCOL 0
      IF fb$="b" OR fb$="B" THEN COLOUR 1,br%,bg%,bb% : GCOL 128+1
      ENDPROC
      DEFFNrgb(x%,y%)
      LOCAL rgb%, r&, g&, b&
      rgb%=TINT(x%,y%)
      r&=rgb%    :REM Use byte variable as mask.
      g&=rgb% >>8
      b&=rgb% >>16
      =FNnumstr(r&)+","+FNnumstr(g&)+","+FNnumstr(b&)
      DEFFNnumstr(num)
      LOCAL cov$,l%
      cov$=STR$(num)
      l%=LEN(cov$)
      IF l%=1 THEN ret$="00"+cov$
      IF l%=2 THEN ret$="0"+cov$
      IF l%=3 THEN ret$=cov$
      =ret$

 

 
  Reply Quote Notify of replies

 2   BBC BASIC Language / Re: COMLIB failing parameter passing to FN_getvalu  on: May 15th, 2017, 11:30am
Started by Edja | Post by Richard Russell
on May 15th, 2017, 10:21am, Edja wrote:
the Yahoo site is still accessible

Not to me, but I vaguely remember being banned from that group just after I created the 'bb4w' group as a replacement. My recollection is that somebody unhappy with BB4W and/or me somehow managed to contact the original group owner (who had been 'absent' for years) and persuaded him to take it over again. One of his actions was to set it so all messages require approval, and another was to ban me. If you can see the message archive you may be able to remind yourself of the sequence of events.

Anyway, anybody uploading a file to that group now is just 'having a laugh' because it hasn't had anything to do with BBC BASIC for Windows for many years. Even being able to upload files at all is an anomaly, because since messages can't be posted no discussions about the file(s) could take place.

I would just ignore any uploads there as rogue and irrelevant.

Richard.
 
  Reply Quote Notify of replies

 3   BBC BASIC Language / Re: COMLIB failing parameter passing to FN_getvalu  on: May 15th, 2017, 10:21am
Started by Edja | Post by Edja
Quote:
When you say that it was uploaded a few weeks ago, do you actually mean many years ago?
The upload dates from 30 april 2017.
Quote:
There are only three groups/forums currently used to support BB4W and BBCSDL
OK, but the Yahoo site is still accessible and as you can see Malcolm has succeeded to upload a file and sent a mail (to all members ?). I still have access to the Yahoo Group and could navigate around to find the file and download it.
I've just made a check. Since 2006 there have been no downloads.
Except : just recently since 30 april 2017 Malcolm has downloaded 4 .
Quote:
https://groups.yahoo.com/neo/groups/bbcbasic/files/Libraries/COMLIBZ.bbc
https://groups.yahoo.com/neo/groups/bbcbasic/files/Tools/DlgEditCE13.bbc
https://groups.yahoo.com/neo/groups/bbcbasic/files/Tools/WINCONSTlookup2_08.bbc
https://groups.yahoo.com/neo/groups/bbcbasic/files/Event%20Programming/Lib/VElib.bbc
Just follow the links. Maybe if you're not a member anymore, you may have to register first, I'm not sure.
Or, if you prefer, I can send you the files directly. Just let me know.
Quote:
There are only three groups/forums currently used to support BB4W and BBCSDL: the Wiggio group (which is due to close down soon), the Groups.io group and this Conforums group
The general conclusion, I think, is that Malcolm just needs to be reminded to upload to one of the new groups (Groups.io or this Conforum)
It would be a waste to loose his, and possibly, though not likely, other people's contributions

Eddy

 
  Reply Quote Notify of replies

 4   BBC BASIC Language / Re: COMLIB failing parameter passing to FN_getvalu  on: May 15th, 2017, 06:31am
Started by Edja | Post by Richard Russell
on May 14th, 2017, 6:33pm, Edja wrote:
here's the mail that Malcolm send out to announce the availibility of COMLIBZ. I just followed the link(s).

That seems to refer to the original 'bbcbasic' Yahoo! group (the pre-existing group that I temporarily 'adopted'), which was subsequently replaced by the 'bb4w' Yahoo group, which was in turn replaced by the 'groups.io' group! When you say that it was uploaded a few weeks ago, do you actually mean many years ago?

There are only three groups/forums currently used to support BB4W and BBCSDL: the Wiggio group (which is due to close down soon), the Groups.io group and this Conforums group. All other earlier groups are either inaccessible, closed or defunct.

Richard.

 
  Reply Quote Notify of replies

 5   BBC BASIC Language / Re: COMLIB failing parameter passing to FN_getvalu  on: May 14th, 2017, 6:33pm
Started by Edja | Post by Edja
Richard,

here's the mail that Malcolm send out to announce the availibility of COMLIBZ. I just followed the link(s).

Eddy

Quote:
Hello,

This email message is a notification to let you know that
a file has been uploaded to the Files area of the bbcbasic
group.

File : /Libraries/COMLIBZ.bbc
Uploaded by : mgmarten <mgmarten@...>
Description : A version of COMLIB what works correctly when static variables are used as parameters. Data types now need a leading "*" so "* F var" would indicate a floating point variable. "*B" not really needed, TRUE and FALSE need no prefix now.

You can access this file at the URL:
https://groups.yahoo.com/neo/groups/bbcbasic/files/Libraries/COMLIBZ.bbc

To learn more about file sharing for your group, please visit:
https://help.yahoo.com/kb/index?page=content&y=PROD_GRPS&locale=en_US&id=SLN15398

Regards,

mgmarten <mgmarten@...>

 
  Reply Quote Notify of replies

 6   BBC BASIC Language / Re: COMLIB failing parameter passing to FN_getvalu  on: May 14th, 2017, 5:06pm
Started by Edja | Post by Richard Russell
on May 14th, 2017, 4:40pm, Edja wrote:
A few weeks ago Malcolm has uploaded COMLIBZ, an adapted version of COMLIB.

It's the first I've heard of it, and a search for 'COMLIBZ' over a period of 777 days returns only your post! So I'm thoroughly puzzled. As far as I'm aware the only way to evaluate variables passed in a string is using EVAL, with all the attendant issues that raises.

Richard.
 
  Reply Quote Notify of replies

 7   BBC BASIC Language / Re: COMLIB failing parameter passing to FN_getvalu  on: May 14th, 2017, 4:40pm
Started by Edja | Post by Edja
A few weeks ago Malcolm has uploaded COMLIBZ, an adapted version of COMLIB. While at the time I had already sorted out (with your help) my problems, I did modify my existing program.
With COMLIBZ lines like
Code:
A$=FN_getvaluestr(Xlbook%,"ActiveSheet.cells(M%,N%).value") 
no longer need to be written with encapsulation, as in :
Code:
A$=FN_getvaluestr(Xlbook%,"ActiveSheet.cells("+STR$(M%)+","+STR$(N%)+").value")  

Also the variable prefixes B, G, ... are no longer required (at least when working with Excel, as in my case) or are to be preceded with a *, giving more freedom in the choice of variable names.
Adapting my program took me about 5 min and it now is definitely more readable and easier to debug. I admit that I didn't test all possible scenarios and I didn't compile anything.
Considering the quality of the since long time available and tested COMLIB, this adapted version COMLIBZ is perhaps not really a major leap forward but rather a convenient face lift of the existing library. Nice !

Eddy



 
  Reply Quote Notify of replies

 8   Raspberry Pi / Re: Wait - for action  on: May 4th, 2017, 03:45am
Started by michael | Post by michael
Here is a possible sleep mode control for mouse and keyboard. ( I fixed a flaw )
Code:
 WAIT 1
      REPEAT
        k% = INKEY(4)
        resp%=FNmoucheck
      UNTIL k%<>-1 OR resp% >0
      PRINT "done"
      END
      DEF FNmoucheck
      PRIVATE mx%,my%,mb%,x%,y%,b%
      MOUSE x%,y%,b%
      IF mx%=0 AND my%=0 AND mb%=0 THEN mx%=x%:my%=y%:mb%=b%: =-1
      IF mx%=x% AND my%=y% AND mb%=b% THEN =-1 ELSE mx%=x%:my%=y%:mb%=b%:=1
  


 
  Reply Quote Notify of replies

 9   Announcements / Re: BBC BASIC for SDL 2.0 v0.17a released  on: May 2nd, 2017, 11:39am
Started by Richard Russell | Post by Richard Russell
on May 1st, 2017, 10:44am, Richard Russell wrote:
Fixed a cache-coherency problem when using the inline ARM assembler (Android and Raspberry Pi editions). I will post separately on this issue.

BBC BASIC's integral assembler unavoidably involves writing code to 'data' memory and then executing that code. This causes a particular issue for modern processors, because typically 'data' and 'code' are cached separately.

x86 CPUs make specific provision for this situation (the so-called SMC or Self Modifying Code condition) so that when you store data in memory the associated instruction cache line is automatically flushed. This has both good and bad consequences: it means you don't need to worry about the instruction cache containing 'stale' data, but it can severely affect execution speed if you allow your assembler code to write to memory in the vicinity of the code (you will sometimes see 'guard bands' or 'gaps' declared in DIM statements to ensure sufficient separation).

The ARM CPU, in keeping with its RISC credentials, makes no specific provision for this situation. Whilst this means that writing to code memory won't have an effect on execution speed, crucially it can mean that if you try to run code immediately after having assembled it, you actually execute something completely different that happened to be in the instruction cache previously. The inevitable consequence is a catastrophic crash.

I've seen this happen on a number of occasions, so I've now modified BBCSDL v0.17a so that the ARM assembler automatically flushes the instruction cache, guaranteeing that when you run the program it really is the assembled code that gets executed. But there may still be a problem when the 'machine code' comes from somewhere other than the BBC BASIC assembler (e.g. from DATA statements or a file). I've seen programs that 'poke' code into memory using conventional indirection operators, for example:

Code:
      FOR addr% = start% TO finish% STEP 4
        READ code%
        !addr% = code%
      NEXT addr%
      CALL start% 

This may crash when executed, because the instruction cache is 'stale', and the v0.17a mod doesn't help. So I would strongly recommend that code of this sort be adapted so that it takes advantage of the modification I have made to the assembler, for example:

Code:
      FOR addr% = start% TO finish% STEP 4
        READ code%
        P% = addr% : [OPT 0 : EQUD code% : ]
      NEXT addr%
      CALL start% 

This won't be quite as fast, but that shouldn't be important (it will usually be code that is run, just once, during initialisation). It will however guarantee cache coherency.

Richard.

 
  Reply Quote Notify of replies

 10   Interpreter & Run-Time Engine / Re: MKDIR error?  on: May 1st, 2017, 3:50pm
Started by mavison | Post by mavison
Quote:
The Help documentation for BB4W doesn't always apply in detail to BBCSDL; sometimes differences in the underlying Operating System make that inevitable.

I thought that might be the case. I am now using...
Code:
DEF PROCmkdir(dir$)               :REM Create directory if does not exist
ON ERROR LOCAL :IF ERR=254 THEN ENDPROC ELSE RESTORE ERROR :ERROR ERR,REPORT$+" at "+STR$ERL
OSCLI("mkdir """+dir$+"""")
ENDPROC 

which is has the same effect as your suggestion, but reports any other errors, and seems to work on both Windows and Mac (unlike the open /NULL). I note your concerns about using 254.

Thanks for your reply Richard.

Martin

 
  Reply Quote Notify of replies


Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls