lurk101
Posts: 965
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: BBC BASIC on the Raspberry Pi Pico?

Fri Sep 17, 2021 3:09 pm

hippy wrote:
Fri Sep 17, 2021 2:58 pm
lurk101 wrote:
Fri Sep 17, 2021 2:13 pm
DarkElvenAngel wrote:
Fri Sep 17, 2021 1:13 pm
Might be better to stick with something you can control and not pull in a sub module. Unless it's a fork you have control over.
Yes, for that very reason Github is poluted with duplicated cruft rapidly falling out of date. If a Github project you depend on is updated there's probably a good reason.
Absolutely. It's a nightmare if a user does an update and ends up with something they can't build or no longer works because a third-party has pulled the rug from under everyone's feet.
That's not how git works. Submodules tagged at a specific commit are not updated automatically when the source repo changes.
You may only discover that what you provide has broken once it has and then users will be expecting you to fix things immediately and quickly, especially if they depend on it working. I have had that a few times when Raspberry Pi OS has had unannounced updates which have broken software I have provided to others.

Far better to provide end-users with files you know will work and take on the burden of updating files you use from third-parties to the latest if you ever need to or choose to.
Disagree. More likely you are preserving bugs, long since fixed.
Last edited by lurk101 on Fri Sep 17, 2021 3:23 pm, edited 2 times in total.

lurk101
Posts: 965
Joined: Mon Jan 27, 2020 2:35 pm
Location: Cumming, GA (US)

Re: BBC BASIC on the Raspberry Pi Pico?

Fri Sep 17, 2021 3:18 pm

If you insist on supporting multiple file systems then they should probably be better integrated as independent components. You can't currently build a Pico BBCBasic with FatFS that excludes LittleFS.

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

Re: BBC BASIC on the Raspberry Pi Pico?

Fri Sep 17, 2021 3:23 pm

ejolson wrote:
Thu Sep 16, 2021 12:51 am
RichardRussell wrote:
Wed Sep 15, 2021 11:53 pm
ejolson wrote:
Wed Sep 15, 2021 10:25 pm
The main question is which do you want?
This is all getting too complicated for me, I can't get my head around it. If it's something I can fix myself, can you give me instructions? If it can only be fixed by a pull request, can you make one?
You first have to flip a coin:
  • heads -- link to a 3rd-party repository as a Git submodule.
    • tails -- keep all the files in the master repository.
    Post here how the coin lands. After that, the instructions should be pretty simple to tidy things up either way.
    Given the feedback on this thread, the tail option appears the better choice. Having said this I noticed that Fido's tail is also wagging--a clear sign of approval.

    To tidy the current tree up, the main thing needed is to delete the file

    .gitmodules

    from the root directory of the repository and push that change back to master.

    I think the pull request from Bill will also delete .gitmodules among other things. I have not checked how much more that pull request might do, so if it looks scary, let's just manually delete the .gitmodules file for now by hand.

    lurk101
    Posts: 965
    Joined: Mon Jan 27, 2020 2:35 pm
    Location: Cumming, GA (US)

    Re: BBC BASIC on the Raspberry Pi Pico?

    Fri Sep 17, 2021 3:31 pm

    ejolson wrote:
    Fri Sep 17, 2021 3:23 pm
    ejolson wrote:
    Thu Sep 16, 2021 12:51 am
    RichardRussell wrote:
    Wed Sep 15, 2021 11:53 pm


    This is all getting too complicated for me, I can't get my head around it. If it's something I can fix myself, can you give me instructions? If it can only be fixed by a pull request, can you make one?
    You first have to flip a coin:
    • heads -- link to a 3rd-party repository as a Git submodule.
      • tails -- keep all the files in the master repository.
      Post here how the coin lands. After that, the instructions should be pretty simple to tidy things up either way.
      Given the feedback on this thread, the tail option appears the better choice. Having said this I noticed that Fido's tail is also wagging--a clear sign of approval.

      To tidy the current tree up, the main thing needed is to delete the file

      .gitmodules

      from the root directory of the repository and push that change back to master.

      I think the pull request from Bill will also delete .gitmodules among other things. I have not checked how much more that pull request might do, so if it looks scary, let's just manually delete the .gitmodules file for now by hand.
      More simply, Richard can go to his Github repo page. Click on the .gitmodules file, when the file pops up click on the garbage can then save. Will then be prompted to commit directly to master, say yes.

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

      Re: BBC BASIC on the Raspberry Pi Pico?

      Fri Sep 17, 2021 3:36 pm

      lurk101 wrote:
      Fri Sep 17, 2021 3:18 pm
      If you insist on supporting multiple file systems then they should probably be better integrated as independent components. You can't currently build a Pico BBCBasic with FatFS that excludes LittleFS.
      I'm pretty sure building only with FatFS is part of the original design. When I made the Makefile in console/pico I set it up to automatically build a version with
      • USB console and LittleFS
      • UART console, LittleFS and FatFS.
      Other combinations used to work and should still work.

      Ideally it would be nice to autodetect and switch between types of consoles based on which receives input first. There are interactions with autorun, the initial EOF bug in the UART code as well as technical considerations how to actually reassign stdin and stdout within newlib.

      I think the best way forward would be to create a standalone C program that can autodetect the console first. Maybe the wumpus program

      viewtopic.php?f=144&t=311703

      would make for a good foundation upon which to build a proof of concept.
      Last edited by ejolson on Fri Sep 17, 2021 7:21 pm, edited 2 times in total.

      Memotech Bill
      Posts: 324
      Joined: Sun Nov 18, 2018 9:23 am

      Re: BBC BASIC on the Raspberry Pi Pico?

      Fri Sep 17, 2021 3:40 pm

      lurk101 wrote:
      Fri Sep 17, 2021 3:18 pm
      If you insist on supporting multiple file systems then they should probably be better integrated as independent components. You can't currently build a Pico BBCBasic with FatFS that excludes LittleFS.
      Yes you can. Just specify:

      Code: Select all

      cmake -DPICOBOARD=vgaboard -DSTDIO=UART -DLFS=N -DFAT=Y ..
      
      You can also use -DSTDIO=USB or -DSTDIO=PICO

      lurk101
      Posts: 965
      Joined: Mon Jan 27, 2020 2:35 pm
      Location: Cumming, GA (US)

      Re: BBC BASIC on the Raspberry Pi Pico?

      Fri Sep 17, 2021 3:44 pm

      ejolson wrote:
      Fri Sep 17, 2021 3:36 pm
      lurk101 wrote:
      Fri Sep 17, 2021 3:18 pm
      If you insist on supporting multiple file systems then they should probably be better integrated as independent components. You can't currently build a Pico BBCBasic with FatFS that excludes LittleFS.
      I'm pretty sure building only with FatFS is part of the original design. When made the Makefile in console/pico I set it up to automatically built a version with
      Just looked, and I think you're right. It didn't work at one point when I tried it but probably something I messed up.

      lfswrap.c and lfswrap.h could be renamed to fswrap.c and fswrap.h.

      DarkElvenAngel
      Posts: 1910
      Joined: Tue Mar 20, 2018 9:53 pm

      Re: BBC BASIC on the Raspberry Pi Pico?

      Fri Sep 17, 2021 5:55 pm

      lurk101 wrote:
      Fri Sep 17, 2021 2:47 pm
      DarkElvenAngel wrote:
      Fri Sep 17, 2021 1:13 pm
      Another thing I noticed with that library is it recently switched from C to C++ and the code base change a lot.
      As far as I can tell, the fatfs code was copied from here. No C++ there, released April 17, 2021.
      I was referring to the https://bestofcpp.com/repo/carlk3-no-OS ... I-RPi-Pico not to FatFs directly.

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

      Re: BBC BASIC on the Raspberry Pi Pico?

      Sat Sep 18, 2021 5:41 pm

      ejolson wrote:
      Wed Sep 15, 2021 3:19 pm
      RichardRussell wrote:
      Wed Sep 15, 2021 1:06 pm
      RichardRussell wrote:
      Wed Sep 15, 2021 8:44 am
      I have manually merged picostuff into master but I do not understand what GitHub is telling me when I now compare the two branches.
      I am still mystified by this, there is clearly something I don't understand about GitHub's branch compare. Before my most recent commit, it was reporting 56 changed files, the majority of which were files in the mcu/ directory, present in the picostuff branch but absent from the master branch.

      Now, after my commit, the master branch contains the mcu/ directory and the files within it. But compare is still reporting the same 56 changed files, as if it is unaware of the commit. Can somebody explain what it is I am missing?
      Is master now up to date and ready to test on the Pico? If it's fine with you, let's keep the picostuff branch around for a little while longer until everyone has had time to check that the upstream merge works.

      I think the reason Git reports differences is because those files, while identical in contents, were committed by different people. As tracking who did what is one of the main purposes of Git, the report now reflects differences at the level of who made the changes.

      I'm not too worried about losing the change history of the files in /mcu. I think the meta data tracking who made which changes to those files was already confounded before picostuff. For a project that is not Linux-kernel huge like this one, my opinion is that good and reliable backups are more important anyway. Woohoo! I'll report whether upstream builds for the Pico later today and whether it still works!

      As always, others are welcome to join in the development and testing. Thanks for all the help from everyone in making this project successful.
      I decided to take a look at the differences between picostuff and master. To do this I first cloned the respective branches of the two repositories:

      Code: Select all

      $ git clone -b master --single-branch https://github.com/rtrussell/BBCSDL.git master
      $ git clone -b picostuff --single-branch https://github.com/rtrussell/BBCSDL.git picostuff
      $ diff -w -c -r -x .git -x build picostuff/ master/ >compare.diff
      
      Then I typed

      Code: Select all

      $ grep "^Only" compare.diff 
      Only in master/: Pico.md
      Only in picostuff/: bbcbasicuart.elf
      Only in picostuff/: bbcbasicusb.elf
      Only in picostuff/examples: pico
      Only in picostuff/: filesystem.elf
      Only in master/mcu/fatfs: LICENSE.txt
      Only in master/mcu/fatfs: README.asc
      Only in master/mcu/fatfs: documents
      Only in master/mcu/fatfs: source
      Only in master/mcu/littlefs: .github
      Only in master/mcu/littlefs: .gitignore
      Only in master/mcu/littlefs: DESIGN.md
      Only in master/mcu/littlefs: LICENSE.md
      Only in master/mcu/littlefs: Makefile
      Only in master/mcu/littlefs: README.md
      Only in master/mcu/littlefs: SPEC.md
      Only in master/mcu/littlefs: bd
      Only in master/mcu/littlefs: lfs.c
      Only in master/mcu/littlefs: lfs.h
      Only in master/mcu/littlefs: lfs_util.c
      Only in master/mcu/littlefs: lfs_util.h
      Only in master/mcu/littlefs: scripts
      Only in master/mcu/littlefs: tests
      Only in master/src: bbpico.c
      
      The files which have disappeared from picostuff are build artifacts which were there only for testing purposes in the first place and the examples/pico directory. It's possible deleting the examples will cause the Makefile in mcu to fail when building the LittleFS image.

      I'll check that later.

      As far as additions to master that aren't in picostuff, the tails option of including the repositories for fatfs and littlefs in tree has already been noted. Given the recent discussion, this seems like a good way forward for now.

      The other addition is bbpico.c. Comparing this with bbccon.c in picostuff

      Code: Select all

      $ diff -w -c picostuff/src/bbccon.c master/src/bbpico.c 
      *** picostuff/src/bbccon.c  2021-09-18 10:06:47.094437268 -0700
      --- master/src/bbpico.c 2021-09-18 10:07:41.193716685 -0700
      ***************
      *** 113,121 ****
        int MaximumRAM = MAXIMUM_RAM ;
        timer_t UserTimerID ;
        unsigned int palette[256] ;
      - #ifdef PICO
      - void *libtop;
      - #endif
        
        // Array of VDU command lengths:
        static int vdulen[] = {
      --- 113,118 ----
      
      reveals that libtop has been removed from bbpico when it was renamed. I suspect libtop is actually defined in the interpreter and the declaration needed for its use in bbpico now appears in one of the headers. This'll become clear when building things.

      The only other file added to master is Pico.md. Thanks for that.

      In my next post, I'll look at the differences between the files that are common and then check how the Pico build works.

      Sorry for the delay. Pandemic problems are causing quite a bit of personal concern around here so I took a break to watch

      https://www.bbc.co.uk/archive/basic-pal ... or/zk7cf4j

      from a comforting time before there were any deadly coronaviruses.

      As with everything there are drawbacks--Fido has now regressed to saying STEP ON NO PETS when asked anything about BBC Basic or palindromes.

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

      Re: BBC BASIC on the Raspberry Pi Pico?

      Sat Sep 18, 2021 9:35 pm

      ejolson wrote:
      Sat Sep 18, 2021 5:41 pm
      As with everything there are drawbacks--Fido has now regressed to saying STEP ON NO PETS when asked anything about BBC Basic or palindromes.
      I think I've found a solution. When the dog developer says STEP ON NO PETS, my response is WAS IT A CAT I SAW? This immediately redirects the conversation back to the merge of BBC Basic.

      Since bbccon.c was not merged, I removed it from the diff.

      Code: Select all

      diff -w -c -r -x .git -x build -x bbccon.c picostuff/ master/ >compare.diff
      
      The result is

      Code: Select all

      diff -w -c -r -x .git -x build -x bbccon.c picostuff/.gitignore master/.gitignore
      *** picostuff/.gitignore	2021-09-18 10:06:46.755429250 -0700
      --- master/.gitignore	2021-09-18 10:07:40.842708385 -0700
      ***************
      *** 47,53 ****
        *~
        #*
        .#*
      - 
      - # Work in progress
      - vdu/
      - test/
      --- 47,49 ----
      Only in master/: Pico.md
      Only in picostuff/: bbcbasicuart.elf
      Only in picostuff/: bbcbasicusb.elf
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/console/pico/CMakeLists.txt master/console/pico/CMakeLists.txt
      *** picostuff/console/pico/CMakeLists.txt	2021-09-18 10:06:46.845431379 -0700
      --- master/console/pico/CMakeLists.txt	2021-09-18 10:07:40.894709614 -0700
      ***************
      *** 18,24 ****
        if (TARGET tinyusb_device)
          add_executable(bbcbasic 
            ../../src/bbmain.c ../../src/bbexec.c ../../src/bbeval.c
      ! 	../../src/bbasmb_arm_32.c ../../src/bbccos.c ../../src/bbccon.c
            ../../src/bbdata_arm_32.s
        	../../mcu/sympico.c ../../mcu/lfswrap.c 
            ../../mcu/m0FaultDispatch/m0FaultDispatch.c 
      --- 18,24 ----
        if (TARGET tinyusb_device)
          add_executable(bbcbasic 
            ../../src/bbmain.c ../../src/bbexec.c ../../src/bbeval.c
      ! 	../../src/bbasmb_arm_32.c ../../src/bbccos.c ../../src/bbpico.c
            ../../src/bbdata_arm_32.s
        	../../mcu/sympico.c ../../mcu/lfswrap.c 
            ../../mcu/m0FaultDispatch/m0FaultDispatch.c 
      Only in picostuff/examples: pico
      Only in picostuff/: filesystem.elf
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/include/BBC.h master/include/BBC.h
      *** picostuff/include/BBC.h	2021-09-18 10:06:47.031435778 -0700
      --- master/include/BBC.h	2021-09-18 10:07:41.093714321 -0700
      ***************
      *** 3,14 ****
        *       Copyright (c) R. T. Russell, 2000-2021                     *
        *                                                                  *
        *       BBC.h constant, variable and structure declarations        *
      ! *       Version 1.25b, 22-Aug-2021                                 *
        \******************************************************************/
        
        // Constants:
        #define STACK_NEEDED 512
        #define ACCSLEN 65536 // Must be the same in bbcsdl.h and bbccon.h
        
        // Sentinels:
        #define CALCHK	0xC3414C43
      --- 3,19 ----
        *       Copyright (c) R. T. Russell, 2000-2021                     *
        *                                                                  *
        *       BBC.h constant, variable and structure declarations        *
      ! *       Version 1.25d, 02-Sep-2021                                 *
        \******************************************************************/
        
        // Constants:
        #define STACK_NEEDED 512
      + #ifdef PICO
      + void *libtop;
      + #define ACCSLEN 1024  // Must be the same in bbcsdl.h and bbccon.h
      + #else
        #define ACCSLEN 65536 // Must be the same in bbcsdl.h and bbccon.h
      + #endif
        
        // Sentinels:
        #define CALCHK	0xC3414C43
      ***************
      *** 355,366 ****
        extern const char szNotice [] ;
        extern void *userRAM ;
        
      - // Defined in bbccon.c
      - #ifdef PICO
      - extern void *libtop;
      - #endif
      - 
      - // NOTE: the following alignment macros must match those in bbccon.c exactly
        // Alignment helper types:
        typedef __attribute__((aligned(1))) int unaligned_int;
        typedef __attribute__((aligned(1))) intptr_t unaligned_intptr_t;
      --- 360,365 ----
      ***************
      *** 371,378 ****
      --- 370,383 ----
        typedef __attribute__((aligned(1))) VAR unaligned_VAR;
        
        // Helper macros to fix alignment problem:
      + #ifdef PICO
      + static inline int ILOAD(void* p){ return (intptr_t)p&3 ? *((unaligned_int*)p) : *((int*)p); }
      + static inline void ISTORE(void* p, int i){ if ((intptr_t)p&3) *((unaligned_int*)p) = i; else *((int *)p) = i; }
      + #else
        #define ILOAD(p)    *((unaligned_int*)(p))
        #define ISTORE(p,i) *((unaligned_int*)(p)) = i
      + #endif 
      + 
        #define TLOAD(p)    *((unaligned_intptr_t*)(p))
        #define TSTORE(p,i) *((unaligned_intptr_t*)(p)) = i 
        #define ULOAD(p)    *((unaligned_uint*)(p))
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/include/bbccon.h master/include/bbccon.h
      *** picostuff/include/bbccon.h	2021-09-18 10:06:47.032435802 -0700
      --- master/include/bbccon.h	2021-09-18 10:07:41.094714344 -0700
      ***************
      *** 3,22 ****
        *       Copyright (c) R. T. Russell, 2000-2021                     *
        *                                                                  *
        *       bbccon.h constant definitions                              *
      ! *       Version v0.36, 21-Aug-2021                                 *
        \******************************************************************/
        
        // System constants :
        
        #define YEAR    "2021"          // Copyright year
      ! #define VERSION "v0.36c"         // Version string
        #ifdef PICO
      ! #define ACCSLEN 1024            // Must be the same in BBC.h
        #define DEFAULT_RAM PAGE_OFFSET+0x20000  // Initial amount of RAM to allocate
        #else
      ! #define	ACCSLEN 65536		// Must be the same in BBC.h
        #define DEFAULT_RAM PAGE_OFFSET+0x200000 // Initial amount of RAM to allocate
        #endif
        #define PAGE_OFFSET ACCSLEN + 0x1300     // Offset of PAGE from memory base
        #define MINIMUM_RAM PAGE_OFFSET+0x20000  // Minimum amount of RAM to allocate
        #define MAXIMUM_RAM 0x10000000  // Maximum amount of RAM to allocate
      --- 3,23 ----
        *       Copyright (c) R. T. Russell, 2000-2021                     *
        *                                                                  *
        *       bbccon.h constant definitions                              *
      ! *       Version v0.37, 14-Sep-2021                                 *
        \******************************************************************/
        
        // System constants :
        
        #define YEAR    "2021"          // Copyright year
      ! #define VERSION "v0.37"         // Version string
        #ifdef PICO
      ! #define ACCSLEN 1024  // Must be the same in bbcsdl.h and bbccon.h
        #define DEFAULT_RAM PAGE_OFFSET+0x20000 // Initial amount of RAM to allocate
        #else
      ! #define ACCSLEN 65536 // Must be the same in bbcsdl.h and bbccon.h
        #define DEFAULT_RAM PAGE_OFFSET+0x200000 // Initial amount of RAM to allocate
        #endif
      + 
        #define PAGE_OFFSET ACCSLEN + 0x1300     // Offset of PAGE from memory base
        #define MINIMUM_RAM PAGE_OFFSET+0x20000  // Minimum amount of RAM to allocate
        #define MAXIMUM_RAM 0x10000000  // Maximum amount of RAM to allocate
      ***************
      *** 44,50 ****
        #define	BIT6		0x40
        #define	BIT7		0x80
        
      ! // Bits in _flags byte (must be the same as in BBCEQUS.INC):
        
        #define	IOFLAG		BIT0	// Insert/overtype
        #define	EGAFLG		BIT1	// EGA-compatible modes (*EGA [ON])
      --- 45,51 ----
        #define	BIT6		0x40
        #define	BIT7		0x80
        
      ! // Bits in [vflags]:
        
        #define	IOFLAG		BIT0	// Insert/overtype
        #define	EGAFLG		BIT1	// EGA-compatible modes (*EGA [ON])
      ***************
      *** 195,197 ****
      --- 196,199 ----
        extern int bChanged ;		// Display refresh required
        extern unsigned int platform ;	// OS platform
        extern unsigned int palette[256] ;
      + 
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/include/version.h master/include/version.h
      *** picostuff/include/version.h	2021-09-18 10:06:47.035435873 -0700
      --- master/include/version.h	2021-09-18 10:07:41.096714391 -0700
      ***************
      *** 1,6 ****
        #define YEAR    "2021"          // Copyright year
      ! #define VERSION "1.23a"         // Version string
      ! #define VER_RES 1,23,1,00       // For VERSIONINFO resource
        #define DEFAULT_RAM PAGE_OFFSET+0x200000 // Initial amount of RAM to allocate
        #ifdef __EMSCRIPTEN__
        #define MAXIMUM_RAM 0x1000000   // Maximum amount of RAM to allocate
      --- 1,6 ----
        #define YEAR    "2021"          // Copyright year
      ! #define VERSION "1.24a"         // Version string
      ! #define VER_RES 1,24,1,00       // For VERSIONINFO resource
        #define DEFAULT_RAM PAGE_OFFSET+0x200000 // Initial amount of RAM to allocate
        #ifdef __EMSCRIPTEN__
        #define MAXIMUM_RAM 0x1000000   // Maximum amount of RAM to allocate
      Only in master/mcu/fatfs: LICENSE.txt
      Only in master/mcu/fatfs: README.asc
      Only in master/mcu/fatfs: documents
      Only in master/mcu/fatfs: source
      Only in master/mcu/littlefs: .github
      Only in master/mcu/littlefs: .gitignore
      Only in master/mcu/littlefs: DESIGN.md
      Only in master/mcu/littlefs: LICENSE.md
      Only in master/mcu/littlefs: Makefile
      Only in master/mcu/littlefs: README.md
      Only in master/mcu/littlefs: SPEC.md
      Only in master/mcu/littlefs: bd
      Only in master/mcu/littlefs: lfs.c
      Only in master/mcu/littlefs: lfs.h
      Only in master/mcu/littlefs: lfs_util.c
      Only in master/mcu/littlefs: lfs_util.h
      Only in master/mcu/littlefs: scripts
      Only in master/mcu/littlefs: tests
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/src/bbccos.c master/src/bbccos.c
      *** picostuff/src/bbccos.c	2021-09-18 10:06:47.094437268 -0700
      --- master/src/bbccos.c	2021-09-18 10:07:41.189716591 -0700
      ***************
      *** 1,8 ****
        /******************************************************************\
        *       BBC BASIC Minimal Console Version                         *
        *       Copyright (C) R. T. Russell, 2021                         *
        *       bbccos.c: Command Line Interface, ANSI VDU drivers        *
      ! *       Version 0.36a, 09-Aug-2021                                *
        \*****************************************************************/
        
        #include <stdlib.h>
      --- 1,9 ----
        /******************************************************************\
        *       BBC BASIC Minimal Console Version                         *
        *       Copyright (C) R. T. Russell, 2021                         *
      + *                                                                 *
        *       bbccos.c: Command Line Interface, ANSI VDU drivers        *
      ! *       Version 0.37a, 14-Sep-2021                                *
        \*****************************************************************/
        
        #include <stdlib.h>
      ***************
      *** 13,19 ****
        #include <string.h>
        #ifdef PICO
        #include "lfswrap.h"
      ! extern char __StackLimit;
        #else
        #include <dirent.h>
        #endif
      --- 14,21 ----
        #include <string.h>
        #ifdef PICO
        #include "lfswrap.h"
      ! extern char *szLoadDir ;  // @dir$
      ! extern int dirlen;
        #else
        #include <dirent.h>
        #endif
      ***************
      *** 35,43 ****
        #endif
        
        #undef MAX_PATH
      ! #define NCMDS 40	// number of OSCLI commands
        #define POWR2 32	// largest power-of-2 less than NCMDS
        #define COPYBUFLEN 512	// length of buffer used for *COPY command
        #define _S_IWRITE 0x0080
        #define _S_IREAD 0x0100
        #define MAX_PATH 260
      --- 37,49 ----
        #endif
        
        #undef MAX_PATH
      ! #define NCMDS 39	// number of OSCLI commands
        #define POWR2 32	// largest power-of-2 less than NCMDS
      + #ifdef PICO
        #define COPYBUFLEN 512	// length of buffer used for *COPY command
      + #else
      + #define COPYBUFLEN 4096	// length of buffer used for *COPY command
      + #endif
        #define _S_IWRITE 0x0080
        #define _S_IREAD 0x0100
        #define MAX_PATH 260
      ***************
      *** 82,88 ****
        		"dump", "era", "erase", "esc", "exec", "float", "fx",
        		"help", "hex", "input", "key", "list", "load", "lock", "lowercase",
        		"md", "mkdir", "output", "quit", "rd", "refresh",
      ! 		"ren", "rename", "rmdir", "run", "save", "sbrk", "spool", "spoolon",
        		"timer", "tv", "type", "unlock" } ;
        
        enum {
      --- 88,94 ----
        		"dump", "era", "erase", "esc", "exec", "float", "fx",
        		"help", "hex", "input", "key", "list", "load", "lock", "lowercase",
        		"md", "mkdir", "output", "quit", "rd", "refresh",
      ! 		"ren", "rename", "rmdir", "run", "save", "spool", "spoolon",
        		"timer", "tv", "type", "unlock" } ;
        
        enum {
      ***************
      *** 90,96 ****
        		DUMP, ERA, ERASE, ESC, EXEC, FLOAT, FX,
        		HELP, HEX, INPUT, KEY, LIST, LOAD, LOCK, LOWERCASE,
        		MD, MKDIR, OUTPUT, QUIT, RD, REFRESH,
      ! 		REN, RENAME, RMDIR, RUN, SAVE, SBRK, SPOOL, SPOOLON,
        		TIMER, TV, TYPE, UNLOCK } ;
        
        // Change to a new screen mode:
      --- 96,102 ----
        		DUMP, ERA, ERASE, ESC, EXEC, FLOAT, FX,
        		HELP, HEX, INPUT, KEY, LIST, LOAD, LOCK, LOWERCASE,
        		MD, MKDIR, OUTPUT, QUIT, RD, REFRESH,
      ! 		REN, RENAME, RMDIR, RUN, SAVE, SPOOL, SPOOLON,
        		TIMER, TV, TYPE, UNLOCK } ;
        
        // Change to a new screen mode:
      ***************
      *** 566,579 ****
        	return 0 ;
        }
        
      - extern char *szLoadDir ;  // @dir$
      - extern int dirlen;
        void oscli (char *cmd)
        {
        	int b = 0, h = POWR2, n ;
        	char cpy[256] ;
        	char path[MAX_PATH], path2[MAX_PATH] ;
        	FILE *srcfile, *dstfile ;
        	char *p, *q, dd ;
        	unsigned char flag ;
        
      --- 572,584 ----
        	return 0 ;
        }
        
        void oscli (char *cmd)
        {
        	int b = 0, h = POWR2, n ;
        	char cpy[256] ;
        	char path[MAX_PATH], path2[MAX_PATH] ;
        	FILE *srcfile, *dstfile ;
      + 	DIR *d ;
        	char *p, *q, dd ;
        	unsigned char flag ;
        
      ***************
      *** 646,656 ****
        			    }
        			if (chdir (path))
        				error (206, "Bad directory") ;
        			getcwd (szLoadDir,255) ;
        			dirlen = strlen (szLoadDir) ;
      - #ifdef _WIN32
      - 			szLoadDir[dirlen++] = '\\' ;
      - #else
        			szLoadDir[dirlen++] = '/' ;
        #endif
        			return ;
      --- 651,659 ----
        			    }
        			if (chdir (path))
        				error (206, "Bad directory") ;
      + #ifdef PICO
        			getcwd (szLoadDir,255) ;
        			dirlen = strlen (szLoadDir) ;
        			szLoadDir[dirlen++] = '/' ;
        #endif
        			return ;
      ***************
      *** 730,736 ****
        			text (p) ;
        			crlf () ;
        
      ! 			DIR *d = opendir (q) ;
        			if (d == NULL)
        				error (254, "Bad command") ;
        
      --- 733,739 ----
        			text (p) ;
        			crlf () ;
        
      ! 			d = opendir (q) ;
        			if (d == NULL)
        				error (254, "Bad command") ;
        
      ***************
      *** 1073,1087 ****
        			crlf () ; // Zero COUNT
        			return ;
        
      - 		case SBRK:
      - 			printf("Current sbrk address is %p.\r\n",sbrk(0)) ;
      - 			printf("Current stack address: %p.\r\n",&b) ;
      - #ifdef PICO
      - 			printf("System malloc heap remaining %llu.\r\n",
      - 			(unsigned long long int)(&__StackLimit-(char *)sbrk(0))) ;
      - #endif
      - 			return ;
      - 
        		case UNLOCK:
        			setup (path, p, ".bbc", ' ', NULL) ;
        			if (0 != chmod (path, _S_IREAD | _S_IWRITE))
      --- 1076,1081 ----
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/src/bbcmos.c master/src/bbcmos.c
      *** picostuff/src/bbcmos.c	2021-09-18 10:06:47.094437268 -0700
      --- master/src/bbcmos.c	2021-09-18 10:07:41.190716615 -0700
      ***************
      *** 45,51 ****
        unsigned int rnd (void) ;	// Return a pseudo-random number
        
        // Declared in bbccli.c:
      ! char *setup (char *, char *, char *, char, int *) ;
        void oscli (char *) ;		// Execute an emulated OS command
        
        // Interpreter entry point:
      --- 45,51 ----
        unsigned int rnd (void) ;	// Return a pseudo-random number
        
        // Declared in bbccli.c:
      ! char *setup (char *, char *, char *, char, unsigned char *) ;
        void oscli (char *) ;		// Execute an emulated OS command
        
        // Interpreter entry point:
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/src/bbcvdu.c master/src/bbcvdu.c
      *** picostuff/src/bbcvdu.c	2021-09-18 10:06:47.095437292 -0700
      --- master/src/bbcvdu.c	2021-09-18 10:07:41.190716615 -0700
      ***************
      *** 7,13 ****
        *                                                                 *
        *       bbcvdu.c  VDU emulator and graphics drivers               *
        *       This module runs in the context of the GUI thread         *
      ! *       Version 1.24a, 24-Jul-2021                                *
        \*****************************************************************/
        
        #include <stdlib.h>
      --- 7,13 ----
        *                                                                 *
        *       bbcvdu.c  VDU emulator and graphics drivers               *
        *       This module runs in the context of the GUI thread         *
      ! *       Version 1.25a, 11-Sep-2021                                *
        \*****************************************************************/
        
        #include <stdlib.h>
      ***************
      *** 1180,1186 ****
        		txtfor = 0 ;
        		bakgnd = colmsk << 8 ;
        		txtbak = colmsk ;
      - 		palette[(int) colmsk] = 0xFFFFFFFF ; // opaque peak white
        	    }
        
        	vflags &= ~UFONT ;
      --- 1180,1185 ----
      ***************
      *** 1487,1494 ****
        	case 8:		// PLOT 64-71, Plot a single 'dot' (size depends on mode)
        		rect.x = cx ;
        		rect.y = cy ;
      ! 		rect.w = pixelx & 0xffff;
      ! 		rect.h = pixely & 0xffff;
        		setcol (col) ;
        		SDL_RenderFillRect(memhdc, &rect) ;
        		break ;
      --- 1486,1493 ----
        	case 8:		// PLOT 64-71, Plot a single 'dot' (size depends on mode)
        		rect.x = cx ;
        		rect.y = cy ;
      ! 		rect.w = pixelx & 0xFFFF ;
      ! 		rect.h = pixely & 0xFFFF ;
        		setcol (col) ;
        		SDL_RenderFillRect(memhdc, &rect) ;
        		break ;
      diff -w -c -r -x .git -x build -x bbccon.c picostuff/src/bbexec.c master/src/bbexec.c
      *** picostuff/src/bbexec.c	2021-09-18 10:06:47.098437363 -0700
      --- master/src/bbexec.c	2021-09-18 10:07:41.193716685 -0700
      ***************
      *** 1236,1242 ****
        	while (1) // for each statement
        	    {
        #ifdef PICO
      ! 		if(&al < (signed char *)libtop + 0x800)
        			error(0, "Recursion too deep!");
        #endif
        	 	if (flags & (KILL + PAUSE + ALERT + ESCFLG))
      --- 1236,1242 ----
        	while (1) // for each statement
        	    {
        #ifdef PICO
      ! 		if((&al < (signed char *)libtop + 0x800) && (&al >= (signed char *)userRAM))
        			error(0, "Recursion too deep!");
        #endif
        	 	if (flags & (KILL + PAUSE + ALERT + ESCFLG))
      Only in master/src: bbpico.c
      
      which except for bbexec.c seems pretty straight forward.

      I'll comment on each difference:
      • .gitignore -- This seems related to git so I'll ignore it.
        • CMakeLists.txt -- The change reflects renaming bbccon to bbpico.
          • BBC.h -- That's where the definition of libtop went. I think not distinguishing between where an external symbol is defined and where it's declared may generate warnings with some compilers but never mind that.
              BBC.h -- Thanks for adding aligned writes to the 32-bit integer ILOAD and ISTORE macros.
              • bbccon.h -- Changes to comments.
                • version.h -- Only the version number.
                  • bbccos.c -- Removed __StackLimit, the *sbrk command and changed NCMDS to 39.
                      bbccos.c -- Changed where some variables are defined and the syntax possibly to preserve compatibility with older compilers.
                      • bbccli.c -- Upstream changes.
                        • bbcvdu.c -- Revert to upstream.
                          • bbexec.c -- I don't understand the addition of &al >= (signed char *)userRAM to the stack overflow check. How could the system stack end up near the system heap when the Basic program and everything else is in between? Is this for compatibility with a different linker script than the one which appears in pico/console?
                          So these are my comments. Other than the change to the stack check in bbexec.c everything looks understandable to me.

                          Does anyone know what the purpose of that change is?

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

                          Re: BBC BASIC on the Raspberry Pi Pico?

                          Sun Sep 19, 2021 2:09 am

                          ejolson wrote:
                          Sat Sep 18, 2021 9:35 pm
                          Other than the change to the stack check in bbexec.c everything looks understandable to me.
                          Having examined the changes between master and picostuff, I entered my clone of the master repository and typed

                          Code: Select all

                          $ cd console/pico
                          $ PICO_SDK_PATH=/usr/local/pico-sdk make
                          make: *** No rule to make target '../../mcu/littlefs/.git', needed by 'buildusb/CMakeCache.txt'.  Stop.
                          
                          As the same happens for picostuff, this is not a problem with the merge but some other problem.

                          I quickly arranged a Zoom conference with the head of quality assurance and barking, but the only advice I received was STEP ON NO PETS. Undeterred, I made minimal changes to the makefiles in console/pico and mcu/lfswrap and then unzipped the Pico examples
                            extra.zip
                            (28.03 KiB) Downloaded 19 times
                              in mcu/lfswrap where they won't cause trouble.

                              For reference the context difference for the makefiles is

                              Code: Select all

                              Only in master: .gitmodules
                              diff -cr -x extra master/console/pico/Makefile master-new/console/pico/Makefile
                              *** master/console/pico/Makefile	2021-09-18 18:01:15.000000000 -0700
                              --- master-new/console/pico/Makefile	2021-09-18 18:18:05.236284659 -0700
                              ***************
                              *** 5,11 ****
                                uart: builduart/bbcbasic.uf2
                                filesystem:	../../mcu/lfsutil/filesystem.uf2
                                
                              ! buildusb/CMakeCache.txt: CMakeLists.txt ../../mcu/littlefs/.git
                                	rm -rf buildusb
                                	mkdir -p buildusb
                                	cd buildusb && PICO_SDK_PATH=$(PICO_SDK_PATH) \
                              --- 5,11 ----
                                uart: builduart/bbcbasic.uf2
                                filesystem:	../../mcu/lfsutil/filesystem.uf2
                                
                              ! buildusb/Makefile: CMakeLists.txt
                                	rm -rf buildusb
                                	mkdir -p buildusb
                                	cd buildusb && PICO_SDK_PATH=$(PICO_SDK_PATH) \
                              ***************
                              *** 43,60 ****
                                	ln -s ../../mcu/fatfs/source/diskio.h ../../mcu/fatfs/diskio.h
                                
                                
                              ! builduart/CMakeCache.txt: CMakeLists.txt $(FATFS_SOURCES) ../../mcu/littlefs/.git ../../mcu/fatfs/.git
                                	rm -rf builduart
                                	mkdir -p builduart
                                	cd builduart && PICO_SDK_PATH=$(PICO_SDK_PATH) \
                                		cmake .. -DSTDIO=UART -DLFS=Y -DFAT=Y
                                
                              ! buildusb/bbcbasic.uf2: buildusb/CMakeCache.txt $(SOURCES)
                                	cd buildusb && make
                                	cp buildusb/bbcbasic.uf2 bbcbasicusb.uf2
                                	cp buildusb/bbcbasic.elf bbcbasicusb.elf
                                
                              ! builduart/bbcbasic.uf2: builduart/CMakeCache.txt $(SOURCES)
                                	cd builduart && make
                                	cp builduart/bbcbasic.uf2 bbcbasicuart.uf2
                                	cp builduart/bbcbasic.elf bbcbasicuart.elf
                              --- 43,60 ----
                                	ln -s ../../mcu/fatfs/source/diskio.h ../../mcu/fatfs/diskio.h
                                
                                
                              ! builduart/Makefile: CMakeLists.txt $(FATFS_SOURCES)
                                	rm -rf builduart
                                	mkdir -p builduart
                                	cd builduart && PICO_SDK_PATH=$(PICO_SDK_PATH) \
                                		cmake .. -DSTDIO=UART -DLFS=Y -DFAT=Y
                                
                              ! buildusb/bbcbasic.uf2: buildusb/Makefile $(SOURCES)
                                	cd buildusb && make
                                	cp buildusb/bbcbasic.uf2 bbcbasicusb.uf2
                                	cp buildusb/bbcbasic.elf bbcbasicusb.elf
                                
                              ! builduart/bbcbasic.uf2: builduart/Makefile $(SOURCES)
                                	cd builduart && make
                                	cp builduart/bbcbasic.uf2 bbcbasicuart.uf2
                                	cp builduart/bbcbasic.elf bbcbasicuart.elf
                              diff -cr -x extra master/mcu/lfsutil/Makefile master-new/mcu/lfsutil/Makefile
                              *** master/mcu/lfsutil/Makefile	2021-09-18 18:01:15.000000000 -0700
                              --- master-new/mcu/lfsutil/Makefile	2021-09-18 18:30:25.561618062 -0700
                              ***************
                              *** 25,31 ****
                                
                                filesystem.lfs: ../../lib/* mklfsimage tree
                                	rm -f filesystem.lfs
                              ! 	./mklfsimage tree ../../examples/pico
                                	./mklfsimage -p tests ../../tests
                                
                                mklfsimage: $(SOURCES)
                              --- 25,31 ----
                                
                                filesystem.lfs: ../../lib/* mklfsimage tree
                                	rm -f filesystem.lfs
                              ! 	./mklfsimage tree extra
                                	./mklfsimage -p tests ../../tests
                                
                                mklfsimage: $(SOURCES)
                              
                              With the above changes the make in console/pico finishes with

                              Code: Select all

                              $ ls
                              CMakeLists.txt  bbc_pico.ld       bbcbasicusb.uf2  filesystem.uf2
                              Makefile        bbcbasicuart.elf  builduart
                              Pico.md         bbcbasicuart.uf2  buildusb
                              README.md       bbcbasicusb.elf   filesystem.elf
                              
                              The next step is to test those binaries by writing some new Basic programs.

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

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Sun Sep 19, 2021 3:29 am

                              ejolson wrote:
                              Sat Sep 18, 2021 5:41 pm
                              I took a break to watch

                              https://www.bbc.co.uk/archive/basic-pal ... or/zk7cf4j

                              from a comforting time before there were any deadly coronaviruses.
                              Here is a recreation of the programming exercise from that historic BBC broadcast of 24 January 1983 running on the Pico:

                              Code: Select all

                              >LIST
                                 10 INPUT word$
                                 20 FOR place=LEN(word$) TO 1 STEP -1
                                 30   backward$=backward$+MID$(word$,place,1)
                                 40 NEXT place
                                 50 IF backward$=word$ THEN PRINT word$ " is a palindrome" ELSE PRINT word$ "
                               is not a palindrome"
                              >RUN
                              ? ADAM
                              ADAM is not a palindrome
                              >RUN
                              ? MADAM
                              MADAM is a palindrome
                              >RUN
                              ? MADAM I'M ADAM
                              MADAM I'M ADAM is not a palindrome
                              >
                              
                              Woohoo! The binaries created from the upstream master work.

                              I wonder how difficult it would be to wire up the GPIO to ring a bell every time a palindrome is detected.

                              Memotech Bill
                              Posts: 324
                              Joined: Sun Nov 18, 2018 9:23 am

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Sun Sep 19, 2021 8:55 am

                              Making progress on the Pico VGA version. I have now implemented plotting functions up to 127.
                              Pico_Plotting.jpg
                              Pico_Plotting.jpg (68.48 KiB) Viewed 1335 times
                              Beyond that, flood fills tend to be highly recursive and require a lot of stack. I will also need to research efficient ellipse drawing routines.

                              Memotech Bill
                              Posts: 324
                              Joined: Sun Nov 18, 2018 9:23 am

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Sun Sep 19, 2021 2:14 pm

                              Richard, is there a definitive list of all the codes you use for non-printing keys? For example Home = 131 and F1 = 145. I have not yet been able to find a list in the documentation.

                              I could probably work it out eventually from bbcsdl.c but it would be easier if there is an existing list.

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

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Mon Sep 20, 2021 4:49 am

                              Memotech Bill wrote:
                              Sun Sep 19, 2021 2:14 pm
                              Richard, is there a definitive list of all the codes you use for non-printing keys? For example Home = 131 and F1 = 145. I have not yet been able to find a list in the documentation.

                              I could probably work it out eventually from bbcsdl.c but it would be easier if there is an existing list.
                              When I was working with VICE the Versatile Commodore Emulator

                              viewtopic.php?p=1752911#p1752911

                              see also

                              viewtopic.php?p=1755242#p1755242

                              getting the keyboard mapping to work nicely over RDP was complicated by SDL itself not documenting the key symbols clearly. I eventually looked at the SDL source code in order to make my keyboard map. I expect you may have to do something similar in this case as well.

                              Memotech Bill
                              Posts: 324
                              Joined: Sun Nov 18, 2018 9:23 am

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Mon Sep 20, 2021 7:53 am

                              Memotech Bill wrote:
                              Sun Sep 19, 2021 2:14 pm
                              I could probably work it out eventually from bbcsdl.c but it would be easier if there is an existing list.
                              Unless I have made a mistake I get the following list:

                              Code: Select all

                              Code	Key
                              9	Menu
                              32	Audio Play
                              128	GUI + Left
                              128	Audio Rewind
                              129	GUI + Right
                              129	Audio Fast Forward
                              130	Home
                              130	Control + Left
                              131	End
                              131	Control + Right
                              132	Page Up
                              133	Page Down
                              134	Insert
                              135	Delete
                              136	Left
                              137	Right
                              138	Down
                              139	Up
                              145	F1
                              146	F2
                              147	F3
                              148	F4
                              149	F5
                              150	F6
                              151	F7
                              152	F8
                              153	F9
                              154	F10
                              155	Shift + Tab
                              155	F11
                              156	Control + Home
                              156	GUI + Up
                              156	F12
                              157	Control + End
                              157	GUI + Down
                              157	F13
                              158	Control + Page Up
                              158	F14
                              159	Control + Page Down
                              159	F15
                              161	Shift + F1
                              162	Shift + F2
                              163	Shift + F3
                              164	Shift + F4
                              165	Shift + F5
                              166	Shift + F6
                              167	Shift + F7
                              168	Shift + F8
                              169	Shift + F9
                              170	Shift + F10
                              171	Shift + F11
                              172	Shift + F12
                              173	Shift + F13
                              174	Shift + F14
                              175	Shift + F15
                              177	Control + F1
                              178	Control + F2
                              179	Control + F3
                              180	Control + F4
                              181	Control + F5
                              182	Control + F6
                              183	Control + F7
                              184	Control + F8
                              185	Control + F9
                              186	Control + F10
                              187	Control + F11
                              188	Control + F12
                              189	Control + F13
                              190	Control + F14
                              191	Control + F15
                              193	Shift + Control + F1
                              194	Shift + Control + F2
                              195	Shift + Control + F3
                              196	Shift + Control + F4
                              197	Shift + Control + F5
                              198	Shift + Control + F6
                              199	Shift + Control + F7
                              200	Shift + Control + F8
                              201	Shift + Control + F9
                              202	Shift + Control + F10
                              203	Shift + Control + F11
                              204	Shift + Control + F12
                              205	Shift + Control + F13
                              206	Shift + Control + F14
                              207	Shift + Control + F15
                              

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

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Mon Sep 20, 2021 2:14 pm

                              Memotech Bill wrote:
                              Mon Sep 20, 2021 7:53 am
                              Memotech Bill wrote:
                              Sun Sep 19, 2021 2:14 pm
                              I could probably work it out eventually from bbcsdl.c but it would be easier if there is an existing list.
                              Unless I have made a mistake I get the following list:

                              Code: Select all

                              Code	Key
                              9	Menu
                              32	Audio Play
                              128	GUI + Left
                              128	Audio Rewind
                              129	GUI + Right
                              129	Audio Fast Forward
                              130	Home
                              130	Control + Left
                              131	End
                              131	Control + Right
                              132	Page Up
                              133	Page Down
                              134	Insert
                              135	Delete
                              136	Left
                              137	Right
                              138	Down
                              139	Up
                              145	F1
                              146	F2
                              147	F3
                              148	F4
                              149	F5
                              150	F6
                              151	F7
                              152	F8
                              153	F9
                              154	F10
                              155	Shift + Tab
                              155	F11
                              156	Control + Home
                              156	GUI + Up
                              156	F12
                              157	Control + End
                              157	GUI + Down
                              157	F13
                              158	Control + Page Up
                              158	F14
                              159	Control + Page Down
                              159	F15
                              161	Shift + F1
                              162	Shift + F2
                              163	Shift + F3
                              164	Shift + F4
                              165	Shift + F5
                              166	Shift + F6
                              167	Shift + F7
                              168	Shift + F8
                              169	Shift + F9
                              170	Shift + F10
                              171	Shift + F11
                              172	Shift + F12
                              173	Shift + F13
                              174	Shift + F14
                              175	Shift + F15
                              177	Control + F1
                              178	Control + F2
                              179	Control + F3
                              180	Control + F4
                              181	Control + F5
                              182	Control + F6
                              183	Control + F7
                              184	Control + F8
                              185	Control + F9
                              186	Control + F10
                              187	Control + F11
                              188	Control + F12
                              189	Control + F13
                              190	Control + F14
                              191	Control + F15
                              193	Shift + Control + F1
                              194	Shift + Control + F2
                              195	Shift + Control + F3
                              196	Shift + Control + F4
                              197	Shift + Control + F5
                              198	Shift + Control + F6
                              199	Shift + Control + F7
                              200	Shift + Control + F8
                              201	Shift + Control + F9
                              202	Shift + Control + F10
                              203	Shift + Control + F11
                              204	Shift + Control + F12
                              205	Shift + Control + F13
                              206	Shift + Control + F14
                              207	Shift + Control + F15
                              
                              Nicely done! I haven't checked it, due to not having 15 function keys? Where did you get a keyboard with more than 12?

                              I haven't heard from Richard for a few days. Do you think he's working on an assembler? Hopefully he's well.

                              Memotech Bill
                              Posts: 324
                              Joined: Sun Nov 18, 2018 9:23 am

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Mon Sep 20, 2021 2:43 pm

                              ejolson wrote:
                              Mon Sep 20, 2021 2:14 pm
                              Nicely done! I haven't checked it, due to not having 15 function keys? Where did you get a keyboard with more than 12?
                              I haven't got one. I derived this list from the code in bbcsdl.c.

                              The USB HID standard has codes for up to 24 function keys.

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

                              Re: BBC BASIC on the Raspberry Pi Pico?

                              Tue Sep 21, 2021 3:57 am

                              Memotech Bill wrote:
                              Mon Sep 20, 2021 2:43 pm
                              ejolson wrote:
                              Mon Sep 20, 2021 2:14 pm
                              Nicely done! I haven't checked it, due to not having 15 function keys? Where did you get a keyboard with more than 12?
                              I haven't got one. I derived this list from the code in bbcsdl.c.

                              The USB HID standard has codes for up to 24 function keys.
                              I found some documentation on the official website discussing the key codes.
                                keycodes.png
                                keycodes.png (89.75 KiB) Viewed 1109 times
                                http://www.bbcbasic.co.uk/bbcbasic/manual/bbckey2.html

                                The values appear consistent with those you wrote earlier.

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

                                Re: BBC BASIC on the Raspberry Pi Pico?

                                Tue Sep 21, 2021 4:58 am

                                RichardRussell wrote:
                                Wed Sep 15, 2021 12:51 pm
                                hippy wrote:
                                Wed Sep 15, 2021 12:10 pm
                                I am interested in discovering how this porting and merging issue is resolved because I am facing similar issues with a MicroPython port. I have no interest in what anyone's backup regime is, how good BBC Basic is for solving algorithms, or wading through posts not related to that effort..
                                My sincere apologies, I listed the code only because Eric expressed an interest in the challenge. I have removed it.
                                Maybe it's better that you removed it, because I've ending up doing a lot of testing in some bumbling attempts to find dual-base palindromes.

                                My latest program

                                Code: Select all

                                BBC BASIC for Pico Console v0.37
                                (C) Copyright R. T. Russell, 2021
                                >LOAD lshift
                                >LIST
                                   10 a%=1
                                   20 FOR n=1 TO 30
                                   30   a%=2*a%
                                   40 NEXT n
                                   50 PRINT a%
                                
                                created the output

                                Code: Select all

                                >RUN
                                1.07374182E9
                                
                                This made me think I found another printf problem with the Pico SDK; however, a quick comparison to the Linux version produced the exact same result.

                                Then I remembered the @% variable.

                                Code: Select all

                                >@%=&01020000 
                                >RUN
                                1073741824
                                
                                Unlike many languages running on the 8-bit computers of the past, the integer data type in early versions of BBC Basic was already 32-bit. I find it interesting how well that decision has worn over time. On the other hand, Waterloo MicroPascal on the SuperPET--also designed for teaching--fell short and included only 16-bit integers.

                                It appears displaying integers with more than 9 digits using scientific notation was part of the original design as
                                Z80 Manual wrote: It is possible to display up to 10 digits before switching to exponential (scientific) notation (PRINT and STR$). This is of little use when displaying real numbers because the accuracy of the last digit is suspect, but it does allow the full range of integers to be displayed.
                                https://www.bbcbasic.co.uk/bbcbasic/mancpm/bbc2.html

                                Even though the Pico version of BBC Basic is running natively on a very different processor than the 6502 and Z80 used for the original, it's notable that the language has remained compatible at this level of detail. My opinion is this kind of long-term stability is important for the educational market where it takes years to develop good textbooks, videos tutorials and other course materials.

                                In a way, the rapid evolution of Linux has worked against a similar accumulation of learning resources for the Raspberry Pi.

                                While riding the stationary bike last night I watched

                                https://www.youtube.com/watch?v=xEzOrL_vhbA

                                The quality of that show and how the physical computing projects described therein are still relevant to modern makers working with the Pico is astonishing. The show also illustrates how using indirection to talk to memory-mapped input-output devices was part of the original purpose of BBC Basic.
                                Last edited by ejolson on Wed Sep 22, 2021 9:59 am, edited 2 times in total.

                                Memotech Bill
                                Posts: 324
                                Joined: Sun Nov 18, 2018 9:23 am

                                Re: BBC BASIC on the Raspberry Pi Pico?

                                Tue Sep 21, 2021 6:35 am

                                ejolson wrote:
                                Tue Sep 21, 2021 3:57 am
                                I found some documentation on the official website discussing the key codes.
                                http://www.bbcbasic.co.uk/bbcbasic/manual/bbckey2.html

                                The values appear consistent with those you wrote earlier.
                                That documentation is for the x86 version of BBC Basic rather than the SDL version. But as you say they are mostly consistent, The obvious differences are:
                                • Codes 128 & 129: Control + Cursor keys instead of GUI + Cursor keys
                                • Codes 193 - 202: Alt + Function keys instead of Control + Shift + Function keys

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

                                Re: BBC BASIC on the Raspberry Pi Pico?

                                Tue Sep 21, 2021 3:03 pm

                                Memotech Bill wrote:
                                Tue Sep 21, 2021 6:35 am
                                ejolson wrote:
                                Tue Sep 21, 2021 3:57 am
                                I found some documentation on the official website discussing the key codes.
                                http://www.bbcbasic.co.uk/bbcbasic/manual/bbckey2.html

                                The values appear consistent with those you wrote earlier.
                                That documentation is for the x86 version of BBC Basic rather than the SDL version. But as you say they are mostly consistent, The obvious differences are:
                                • Codes 128 & 129: Control + Cursor keys instead of GUI + Cursor keys
                                • Codes 193 - 202: Alt + Function keys instead of Control + Shift + Function keys
                                I see what you mean. I find it surprising there would be any differences between SDL and x86 versions. I wonder if the documentation needs updating.

                                For a discussion of function key codes in a different Pico-based Basic see

                                viewtopic.php?p=1915901#p1915901

                                Why is it the function keys always cause so much trouble?
                                Last edited by ejolson on Tue Sep 21, 2021 5:19 pm, edited 1 time in total.

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

                                Re: BBC BASIC on the Raspberry Pi Pico?

                                Tue Sep 21, 2021 4:57 pm

                                ejolson wrote:
                                Tue Sep 21, 2021 4:58 am
                                Maybe it's better that you removed it, because I've ending up doing a lot of testing in some bumbling attempts to find dual-base palindromes.
                                I was looking at the MicroMite Basic code posted at

                                viewtopic.php?p=1916145#p1916145

                                and realized that this would work on BBC Basic except for lack of a bin$ function.

                                As linking in a C routine that converts an integer to a binary string is a good test of the symbol table code in sympico, I set about trying to write such a routine.

                                I think I might have succeeded if not for an emergency in which Fido claimed the microwave antenna on the dog house was causing canine Havana syndrome and promptly disconnected the Internet.

                                I tried to reason, but the head of security and cyber-ops adopted that now familiar strategy of whoever barks loudest wins the argument. Does anyone know an easy way for additional C code running within the interpreter to allocate Basic strings?

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

                                Re: BBC BASIC on the Raspberry Pi Pico?

                                Tue Sep 21, 2021 9:29 pm

                                ejolson wrote:
                                Tue Sep 21, 2021 4:57 pm
                                As linking in a C routine that converts an integer to a binary string is a good test of the symbol table code in sympico, I set about trying to write such a routine.
                                Adding the symbol strbin to sympico.sh and the code

                                Code: Select all

                                static char *strbin(unsigned int x){
                                    static char buf[33];
                                    int i=32;
                                    buf[i]=0;
                                    if(x==0){
                                        buf[--i]='0';
                                    } else do {
                                        buf[--i]='0'+(x&1);
                                        x>>=1;
                                    } while(x);
                                    return &buf[i];
                                }
                                
                                to the file sympico.c in the /mcu directory led to

                                Code: Select all

                                BBC BASIC for Pico Console v0.37
                                (C) Copyright R. T. Russell, 2021
                                >*lowercase
                                >sys "strbin", 7 to b%
                                >print $$b% 
                                111
                                
                                Woohoo! That was easy and leads to a pretty quick way of adding any C extension that one wants.

                                During the above exercise it was discovered the version of sympico.sh in the master repository does not have the execute bit set. Is there any way to fix this?

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

                                Re: BBC BASIC on the Raspberry Pi Pico?

                                Wed Sep 22, 2021 12:56 am

                                Hey, can we please have a sticky on where the current uf2s are? It took me ages to find what I was looking for, and even that may not be current: Re: BBC BASIC on the Raspberry Pi Pico? - 2021-09-11 18:41:25
                                ‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
                                Pronouns: he/him

                                Return to “General”