BBC Micro Utilities for Windows

Here you can talk about anything related to BBC BASIC, not covered in another category
User avatar
KaraTheValkyrie
Posts: 12
Joined: Sat 14 Jan 2023, 19:29

BBC Micro Utilities for Windows

Post by KaraTheValkyrie »

I'm new to this forum, so I hope this post is appropriate. I recently got round to repairing my BBC Micro Model B, which I bought 40 years ago, and of course I started grabbing various programs and data from it and transferring to my Windows PC as .dsd files, then using those with Beebem, and I bought a copy of BBC BASIC for Windows so I could play with that too. I wanted some command line utilities to display the content of .dsd files, and decode BBC BASIC files along with "PRINT#"-type BBC data files, so I wrote them as console applications using the .NET6.0 framework. The utilities are:

BBCBasicToText - display a binary BBC Micro BASIC file as text or HTML.
BBCDataFileToText - show BBC "PRINT#" type data files as text or HTML.
BBCReadDiskImage - display *DIR style output of a .DSD or .SSD disk images, with the ability to export files individually, and dump sectors.

They all produce coloured output, e.g. string, keywords and so forth are coloured differently, and can either produce plain text (which is only in colour if output is to a command prompt window, of course), or HTML, optionally launching the browser for the latter. They all take wildcards as input and can traverse down through folders. I realize that not everyone is comfortable downloading such things other than from "official" sites, but I've put a .zip file with the setup.exe and corresponding .MSI at

[Edit: link for latest iteration, which you should open with 7Z, 1.0.60]
https://img1.wsimg.com/blobby/go/8ec357 ... 1673145970

and am currently fiddling around to get them published on the Windows Store (where I recently published contour mapping app to familiarize myself with the process, but it is different, and IMHO fiddlier, for Win32 apps) so if anyone would like to try them, I'd love to get feedback and suggestions. Again, my apologies if this sort of post is not welcome.
Last edited by KaraTheValkyrie on Sun 16 Apr 2023, 19:29, edited 5 times in total.
User avatar
KaraTheValkyrie
Posts: 12
Joined: Sat 14 Jan 2023, 19:29

Re: BBC Micro Utilities for Windows

Post by KaraTheValkyrie »

So just for fun, I added the ability to produce .bbcode output to make it easier to post code examples in this forum. Haven't updated the .zip file yet, but this is and example of the output, using the BBC Micro "Welcome" program as input. I couldn't see a way to get BBCode to set a black background, so I switch the "regular text" colour to black. The command line used here was

C:\...\WelcomeDiskFiles> BBCBasicToText 0_W.WELCOME *.bbcode

and I used BBCReadDiskImage to export the "WELCOME" BBC BASIC program. The HTML version has black background, white "regular text" and is a bit prettier IMHO.

BBCBasicToText: processing 1/1, C:\Users\...\BeebEm\DiscIms\WelcomeDiskFiles\0_W.WELCOME
   10  REM New version of 'INTRO' from
   20  REM Welcome pack
   30  REM By John Coll & Andrew Gordon
   40  ON ERROR GOTO 630
   50 ENVELOPE 1,1,-RND(50),-RND(50),-RND(45),255,255,255,127,0,0,-127,127,0
   60 SOUND 1,1,255,255
   70 DIMCOM%11
   80 M0=650:M1=500:M2=708:M3=104:M4=288:M5=550:M6=720:M7=450:M8=5
   90 MODE5
  100 VDU5
  110 VDU23,255,255,255,255,255,255,255,255,255
  120 GCOL0,135
  130 CLG
  140 VDU18,0,129,24,128;128;1152;896;16,18,0,135,24,256;256;1024;768;16,26
  150 FORI%=M1 TO M2 STEP M3:PROCSWOOSH(M0):PROCLETTER:NEXT
  160 $COM%="DISC SYSTEM"
  170 FORJ%=0TO11:I%=M4+64*J%:PROCSWOOSH(M5):GCOL0,0:MOVEI%,M5:PRINTCHR$(COM%?J%);:NEXT
  180 VDU29,M6;M7;
  190 FORL%=0TO8STEP8:FORM%=0TO4STEP4
  200     RESTORE
  210     FORI%=0TO20:READA%
  220       FORJ%=0TO7:K%=68+(A%AND1):A%=A%DIV2
  230         PLOTK%,L%-J%*32+(I%AND1)*16,M%-I%*8:NEXT
  240       IF(I%AND1)=0:PLOT69,L%+32,M%-I%*8
  250       NEXT:NEXT:NEXT
  260 TI%=TIME:REPEATUNTILTIME-TI%>100*V%
  270 SOUND &11,0,1,1
  280  GOTO 590
  290 DATA&FF,&99,&AA,&66,&A2,&99,&C9,&C2,&FE,&F0,&F8,&F0,&78,&78,&3C,&3C,&1E,&16,&15,&FD,&00,&00
  300 DEF PROCLETTER
  310 GCOL0,1:GCOL0,135
  320 MOVEI%,M0:PRINTCHR$255;
  330 MOVEI%,M0+4:DRAWI%+56,M0+4
  340 MOVEI%+8,M0+8:DRAWI%+48,M0+8
  350 MOVEI%-8,M0:DRAWI%-8,M0-24
  360 MOVEI%+8,M0-32:DRAWI%+48,M0-32
  370 MOVEI%+64,M0:DRAWI%+64,M0-24
  380 GCOL0,7:GCOL0,129
  390 MOVEI%,M0:PRINTCHR$(ASC"B"-(I%=M2));
  400 ENDPROC
  410 DEF PROCSWOOSH(Y%)
  420 XL%=0:XR%=1272:YD%=0:YU%=1020
  430 U1%=(I%+32-XL%)DIVM8:V1%=(Y%-16-YD%)DIVM8
  440 U2%=(I%+32-XR%)DIVM8:V2%=(Y%-16-YU%)DIVM8
  450 X1%=XL%:X2%=XL%:X3%=XR%:X4%=XR%:Y1%=YD%:Y2%=YU%:Y3%=YD%:Y4%=YU%
  460 PROCPLOT
  470 FORJ0%=1TOM8
  480   PROCPLOT
  490   X1%=X1%+U1%:X2%=X2%+U1%:X3%=X3%+U2%:X4%=X4%+U2%
  500   Y1%=Y1%+V1%:Y2%=Y2%+V2%:Y3%=Y3%+V1%:Y4%=Y4%+V2%
  510   PROCPLOT
  520   NEXT
  530 PROCPLOT
  540 ENDPROC
  550 DEFPROCPLOT
  560 MOVEX1%-U1%,Y1%-V1%:PLOT6,X1%,Y1%:MOVEX2%-U1%,Y2%-V2%:PLOT6,X2%,Y2%
  570 MOVEX3%-U2%,Y1%-V1%:PLOT6,X3%,Y3%:MOVEX4%-U2%,Y4%-V2%:PLOT6,X4%,Y4%
  580 ENDPROC
  590  MODE7:FORI%=2TO3:PRINTTAB(3,I%)CHR$&8D"Welcome to the BBC Microcomputer":PRINTTAB(13,I%+3);CHR$&8D;"Disc System":NEXT
  600  PRINTTAB(6,16)"To leave any one program"'TAB(9)"just press ESCAPE.":N%=INKEY(200):PRINTTAB(12,20)"Try it now.";
  610  GOTO610
  620  PROCA(0,0):PROCA(1,0):PROCA(2,0):PROCA(3,0):IFM%<0THEN590
  630  MODE7:PRINTTAB(5,9)"Do you want to go on to"'TAB(5)"the next program (Y/N)? ";:PROCYN:IFY%=0THEN RUN
  640  CHAIN "INDEX"
  650 DEFPROCYN Y%=-1
  660  X%=GET:IF X%=13 AND Y%>=0 THENENDPROC
  670  X%=X%AND&DF:IFX%<>78ANDX%<>89THEN660
  680  Y%=1:IFX%=78THENY%=0
  690  VDUX%,8:GOTO660
BBCBasicToText Success: processed C:\Users\...\BeebEm\DiscIms\WelcomeDiskFiles\0_W.WELCOME
Output: C:\Users\...\BeebEm\DiscIms\WelcomeDiskFiles\0_W.WELCOME.bbcode

BBCBasicToText found and processed 1 file, ignored 0, excluded 0, produced results for 1
User avatar
hellomike
Posts: 192
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: BBC Micro Utilities for Windows

Post by hellomike »

Nice stuff.
I copied line 10 - 690 into the BB4W editor, and added a 'WAIT 1' statement after line 220.
And voila, it works and sounds exactly the same as when I ran the very first Welcome program on the Beeb almost 40 years ago!

Which shows how good BB4W is in running older (virtually the oldest) BBCBASIC programs.

I then tried the same using SDLIDE 1.34a. The sound is equally similar however the Owl is drawn like a checkerboard. Not sure why.

Regards,

Mike
Pete
Posts: 96
Joined: Wed 10 Apr 2019, 17:36

Re: BBC Micro Utilities for Windows

Post by Pete »

I loaded this program on my BBC Micro a few weeks ago, and just now ran the program on BBC Basic for Windows.

I added the WAIT 1 line and great - very similar to when running on the actual Micro.

I got my BBC Micro 2 years ago, great thing is the startup is straight away ready, they don't get slowed down by internet or have any "<application> is not responding" - really fast and impressive computers. BBC Basic for Windows definitely has all that is in original BBC Basic and more. Original BBC Basic is super, I like to use Mode 7 when possible as screen mode which is harder to get on PCs.
User avatar
KaraTheValkyrie
Posts: 12
Joined: Sat 14 Jan 2023, 19:29

Re: BBC Micro Utilities for Windows

Post by KaraTheValkyrie »

Thanks for your replies. I _think_ my utility has all the codes for BBC BASIC for Windows, in addition to the original ones. Please let me know if you find anything missing.

The latest package is at

https://img1.wsimg.com/blobby/go/8ec357 ... 0199576451

That includes the BBCode output, some small bug fixes, and an couple of improvements to the installer. The detached signature is

-----BEGIN PGP SIGNATURE-----

iQFNBAABCAA3FiEEbRotVTbNBS5QuWqPWV58wKNDrqoFAmQl0XcZHGthcmFvdHRl
d2VsbEBvdXRsb29rLmNvbQAKCRBZXnzAo0OuqpK6B/9U2rt7rDsDv1lssb8Rt2Tx
MBTroqUKVvx7W5EPYbeke1lArSqhkWdOa4HY7udj1TPnfDTkBN6aonIjWpMjsX9r
0fsuX3m1vPckwPzFbHXZbVcdtBzqa9s3lvnBX/b2fgJZtbUKbETeC1zTyJuhkVc8
ZLN5w6oFCZ2SmgPDxv4Q4VJXKoSI+cJSaqSu8dXEjuteuOinyCRAV883Bvm0KHq7
J2CQzGNVOfFxlkdP9VPHaBBws+VKG0TXr01zHU92fpEDRndkffVgFFJY4BPxKQhq
DMSOVvOIHDSzeKldQEd6ZX3A8Czj5NihgWD1nL474xoOKIzfYh5nW6wll6+C0X0r
=VHqx
-----END PGP SIGNATURE-----

which you can save off as "BBC Micro Utilities1.0.10.zip.asc" if you wish to verify it, e.g.
gpg --verify "BBC Micro Utilities1.0.10.zip.asc" "BBC Micro Utilities1.0.10.zip"
Last edited by KaraTheValkyrie on Thu 30 Mar 2023, 19:04, edited 1 time in total.
Hated Moron

Re: BBC Micro Utilities for Windows

Post by Hated Moron »

KaraTheValkyrie wrote: Thu 30 Mar 2023, 00:58 So just for fun, I added the ability to produce .bbcode output to make it easier to post code examples in this forum.
I notice that your indentation style is different from what BBC BASIC itself uses, specifically that in a FOR...NEXT loop the NEXT isn't lined up with the FOR:

  460 PROCPLOT
  470 FORJ0%=1TOM8
  480   PROCPLOT
  490   X1%=X1%+U1%:X2%=X2%+U1%:X3%=X3%+U2%:X4%=X4%+U2%
  500   Y1%=Y1%+V1%:Y2%=Y2%+V2%:Y3%=Y3%+V1%:Y4%=Y4%+V2%
  510   PROCPLOT
  520   NEXT
  530 PROCPLOT

Personally I would prefer this:

  460 PROCPLOT
  470 FORJ0%=1TOM8
  480   PROCPLOT
  490   X1%=X1%+U1%:X2%=X2%+U1%:X3%=X3%+U2%:X4%=X4%+U2%
  500   Y1%=Y1%+V1%:Y2%=Y2%+V2%:Y3%=Y3%+V1%:Y4%=Y4%+V2%
  510   PROCPLOT
  520 NEXT
  530 PROCPLOT

I presume the same probably applies to the other indented clauses (REPEAT...UNTIL, WHILE...ENDWHILE, CASE...ENDCASE, IF...ENDIF).

In case it helps, you can always 'borrow' the indentation code from PROCindent() in SDLIDE.bbc:

Code: Select all

      DEF PROCindent(f$, RETURN I%, RETURN M%)
      LOCAL C%, F%, L%, p%%

      IF f$="" THEN ENDPROC

      p%% = PTR(f$) + 3
      F% = 5 : REM initialise to "left" and "first"
      L% = 6 + 2 * I%

      CASE ?p%% OF
        WHEN &ED: I%-=1 : REM NEXT
        WHEN &FD: I%-=1 : REM UNTIL
        WHEN &CE: I%-=1 : REM ENDWHILE
        WHEN &CB: I%-=2 : REM ENDCASE
        WHEN &CD: I%-=1 : REM ENDIF
        WHEN &E3: I%+=1 : REM FOR
        WHEN &F5: I%+=1 : REM REPEAT
        WHEN &C7: I%+=1 : REM WHILE
        WHEN &C8: I%+=2 : REM CASE
        WHEN &28: F% OR= 8 : REM (
      ENDCASE

      WHILE ?p%% <> &D
        C% = ?p%%
        p%% += 1

        IF C% = &22 IF (F% AND &60) = FALSE F% EOR= &80

        IF F% AND &E0 THEN
          L% += 1
        ELSE
          CASE C% OF
            WHEN &8D: p%% += 3 : REM line number
            WHEN &2A: IF F% AND 1 F% OR= &50 : REM *
            WHEN &DC: IF F% AND 1 F% OR= &20 : REM DATA
            WHEN &F4: F% OR= &40 : REM REM
          ENDCASE
          IF C%<32 OR C%>127 L% += LENKeyWd$((C%+128)MOD256) ELSE L% += 1
        ENDIF

        IF C%<>32 F% AND= &FC : REM right mode, clear EXIT flag
        IF C%=&10 F% OR= 2    : REM set EXIT flag
        IF INSTR(Left$,CHR$C%) F% OR= &01 : REM left mode
        IF F% AND 8 IF C%=&29 F% AND= &F7 : REM end of label
        IF C%=&5C IF (F% AND &F4)=FALSE F% OR= &40 : REM \ comment
        F% AND= &FB : REM clear "first"

        IF (F% AND &F2) = FALSE THEN
          CASE ?p%% OF
            WHEN &ED: I%-=1 : REM NEXT
            WHEN &E3: I%+=1 : REM FOR
            WHEN &FD: I%-=1 : REM UNTIL
            WHEN &F5: I%+=1 : REM REPEAT
            WHEN &CE: I%-=1 : REM ENDWHILE
            WHEN &C7: I%+=1 : REM WHILE
            WHEN &C8: I%+=2 : REM CASE
          ENDCASE
        ENDIF
      ENDWHILE

      IF C% = &8C I%+=1 : REM THEN
      IF L% > M% M% = L%
      ENDPROC
User avatar
KaraTheValkyrie
Posts: 12
Joined: Sat 14 Jan 2023, 19:29

Re: BBC Micro Utilities for Windows

Post by KaraTheValkyrie »

I use the same indent as the original BBC Micro, e.g. (copied from Beebem, which is the same)

Code: Select all

  460 PROCPLOT                          
  470 FORJ0%=1TOM8                      
  480   PROCPLOT                        
  490   X1%=X1%+U1%:X2%=X2%+U1%:X3%=X3%+
U2%:X4%=X4%+U2%                         
  500   Y1%=Y1%+V1%:Y2%=Y2%+V2%:Y3%=Y3%+
V1%:Y4%=Y4%+V2%                         
  510   PROCPLOT                        
  520   NEXT                            
  530 PROCPLOT                          
  540 ENDPROC    
I'll look at adding a switch to let people select the indentation behaviour.
Hated Moron

Re: BBC Micro Utilities for Windows

Post by Hated Moron »

hellomike wrote: Thu 30 Mar 2023, 09:11 I then tried the same using SDLIDE 1.34a. The sound is equally similar however the Owl is drawn like a checkerboard.
Wow, you found a genuine bug! :shock:

The technical explanation is that some code in BB4W intended solely to improve performance was copied unchanged into BBCSDL, but because SDL 2.0 draws its graphics differently from Windows GDI it actually breaks the functionality rather than just speeding it up. :(

Evidently none of my test programs exercises this particular feature so this regression was missed. That it hasn't been spotted in more than 5 years shows just how little BBCSDL is used. :cry:

I will fix and release a new version ASAP.
User avatar
hellomike
Posts: 192
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: BBC Micro Utilities for Windows

Post by hellomike »

Wow!
Great to be of service Richard.

Regards,

Mike
Hated Moron

Re: BBC Micro Utilities for Windows

Post by Hated Moron »

hellomike wrote: Fri 31 Mar 2023, 07:30 Great to be of service Richard.
Fortunately the fix is trivial. In the assembler editions:

Code: Select all

-        xor     bx,bx                   ;just move (0)
+        mov     bx,5                    ;just move (0)
and in the C editions:

Code: Select all

-	unsigned char rop = 0, col = 0 ;
+	unsigned char rop = 5, col = 0 ;
All the more inexcusable that the bug was introduced in the first place, you might well say.