How do you edit your BASIC programs?

Discuss all aspects of programming here. From 8-bit through to modern architectures.
User avatar
jgharston
Posts: 3409
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: How do you edit your BASIC programs?

Post by jgharston » Tue Jan 29, 2019 3:38 pm

Richard Russell wrote:
Tue Jan 29, 2019 1:40 pm
lurkio wrote:
Tue Jan 29, 2019 9:37 am
Just to clarify: you’re looking for BASIC code that would construct a blank .SSD in memory; add a file to the .SSD — the content of the file being a tokenised BASIC program which the user has been editing and wants to test in BeebEm (or another emulator); and then write the .SSD to a file on the host filesystem?
Yes, that's one option.
MkImg creates disk images from a specified list of files, and is written in BASIC, so the core can be ripped out of it. The simplest way to create a disk image is just the catalogue followed by each file, one after another, each padded to 256 bytes. BeebEm can be started up with a disk image selected on the command line, eg BeebEm filename.ssd, and if the boot option is set it boots it as though Shift-Break has been pressed (and the correct filing system is the default for the selected disk image).

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
jgharston
Posts: 3409
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: How do you edit your BASIC programs?

Post by jgharston » Tue Jan 29, 2019 3:44 pm

Richard Russell wrote:
Sat Jan 26, 2019 5:30 pm
I've been experimenting with doing that using BeebEm, but it's seemingly not as straightforward as I expected. What's the simplest way of running a BASIC program from the Windows command line? Will I have to make a .ssd or .uef file, and if so which is the simpler of the two to build? Do any of the other Beeb emulators make it any easier?
The -KbdCmd option allows a string of key presses to be passed to BeebEm. So, if you have VDFS loaded and enabled by default (which gives you access to the host machine's file system), something like:
BeebEm -KbdCmd *VDFS\nCHAIN\s2\Sfilename\s2\S\n
I haven't checked if this is subject to the size of the keyboard buffer, or if it is fed in from a "higher" level.

Edit: Ah ha. It is 'typed' into the system, and depends on your keyboard map, and is specified by keynames, not characters. So, on my system:
C:\Apps\Emulators\BeebEm\BeebEm.exe -KbdCmd \s'\SVDFS\nCHAIN\s2\S'H.DEVELOP.BASICTESTS.COLOURS\s2\S\n
selects VDFS and CHAINs "H:\Develop\BasicTests\Colours"
Last edited by jgharston on Tue Jan 29, 2019 3:52 pm, edited 1 time in total.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
lurkio
Posts: 1910
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: How do you edit your BASIC programs?

Post by lurkio » Tue Jan 29, 2019 3:51 pm

Richard Russell wrote:
Tue Jan 29, 2019 3:22 pm
lurkio wrote:
Tue Jan 29, 2019 2:54 pm
I suppose I was thinking more of the delay while the user waits for the program encoded in the UEF to load into the emulated Beeb's memory from the emulated cassette recorder.
So is the default to load at the same speed as a real Beeb would load from a tape?
Yes. For most, if not all, Beeb emulators, that seems to be the case. It's certainly true of BeebEm.

Richard Russell wrote:
Tue Jan 29, 2019 3:22 pm
I might argue that's taking emulation too far!
Some original tape software from BITD had clever loaders that did "entertaining" things -- like printing "humorous" messages on screen -- while the large main program was loading. We'd miss out on such rich amusements if tape loading wasn't emulated in real time. :wink:

Richard Russell wrote:
Tue Jan 29, 2019 3:22 pm
what about leveraging the ROM Filing System?
Is that actually much faster than loading from tape? I use RFS a bit because it's part of the utility software for my modern SWROM/SWRAM board in my real Beeb, and it doesn't strike me as being fast -- or it's not as fast as disc, anyway.

I do think that the most user-friendly way to achieve what you seem to be aiming for is to create a .SSD: most (probably all) Beeb emulators start up in Model B mode, with DFS installed, by default; and programs are quick to load from .SSD; and you won't need to rely on software or utility ROMs that don't come as part of the standard BeebEm installation package. I strongly suspect that that's why the creators of BeebAsm chose to export assembled code to .SSD rather than any other emulated media format.

Anyway, just a thought. You may have other requirements that I haven't fully appreciated.

:idea:

User avatar
jgharston
Posts: 3409
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield
Contact:

Re: How do you edit your BASIC programs?

Post by jgharston » Tue Jan 29, 2019 4:02 pm

Doing:
cd H:\Develop\BasicTests
H:\Develop\FileTools\Images\MkImg H:\test.ssd Colours -opt 3
C:\Apps\Emulators\BeebEm\BeebEm.exe H:\test.ssd

sort-a works, but my system is configured to boot into ADFS. Doing *DISK shows Colours is there, you'd need a !BOOT file to CHAIN it, and if using MkImg to create the disk image you'd have to use an external file list as I haven't got around to adding a -add switch yet.
Theoretically:
cd H:\Develop\BasicTests
H:\Develop\FileTools\Images\MkImg H:\test.ssd Colours
H:\Develop\FileTools\Images\MkImg H:\test.ssd -a !BOOT -opt 3
C:\Apps\Emulators\BeebEm\BeebEm.exe H:\test.ssd

with !BOOT containing CHAIN"Colours"<cr> would do it. If doing it from an IDE it would be simpler to write it all out from the IDE manually.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

User avatar
Richard Russell
Posts: 619
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: How do you edit your BASIC programs?

Post by Richard Russell » Tue Jan 29, 2019 5:17 pm

lurkio wrote:
Tue Jan 29, 2019 3:51 pm
Anyway, just a thought. You may have other requirements that I haven't fully appreciated.
I don't have any "requirements" since I'm not the OP! I'm personally not interested in running programs on a Beeb (or an emulator) or in 'retro-computing' of any sort. I get my kicks from pushing BBC BASIC to its limits on modern hardware, most recently in leveraging the power of GPU shaders (see this YouTube video and this one, both from BBC BASIC for SDL 2.0).

I was simply offering a suggestion that one might be able to modify SDLIDE to run the program not in BBCSDL, which of course is what normally happens, but in an emulator like BeebEm. Unfortunately doing so seems to be far more complicated than I ever imagined, so I'll leave it to others to experiment with if they are so inclined. SDLIDE is itself written in BBC BASIC and Open Source.

dominicbeesley
Posts: 694
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: How do you edit your BASIC programs?

Post by dominicbeesley » Thu Jan 31, 2019 11:30 am

Thanks All,

The responses in this thread have helped me to get somewhere. My current temporary solution is to use SLIDE/BBCB4W editor and save in RTR's BASIC format. I'd not realised how trivial the differences where between that and Acorn format so I've just got a simple script to convert.

Next, when I get a minute I intend to build that script into the Perl TubeHost script to automatically convert on the fly any files named .bas and present an alternate without the extension in Acorn format. When I get time I'll have a go at changing SLIDE to save as Acorn format too.

Incidentally, RTR - how/why did the different BASIC formats come about?

D

User avatar
Richard Russell
Posts: 619
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: How do you edit your BASIC programs?

Post by Richard Russell » Thu Jan 31, 2019 2:00 pm

dominicbeesley wrote:
Thu Jan 31, 2019 11:30 am
Incidentally, RTR - how/why did the different BASIC formats come about?
There were two main factors. Firstly, the CPU families for which I've written BBC BASIC interpreters (Z80, 8086, IA-32) are all little-endian, that is they expect 16-bit values stored in memory to have the least-significant 8-bits in the lower address and the most-significant 8-bits in the higher address. Secondly, the format in which tokenised BBC BASIC programs are saved to file is the same as how they are stored in memory, so for example you can load a program using *LOAD and save it using *SAVE.

With those processor families It therefore made much more sense for the 16-bit line number (at the start of each program line) to be in little-endian format rather than the big-endian format used by Acorn. Had I not reversed the order of those bytes (in memory) the speed of GOTO, GOSUB and RESTORE would have been adversely affected, because it depends crucially on how quickly you can scan the program to find the destination line. Being able to take advantage of the 16-bit loads supported by those CPUs gave a worthwhile benefit.

It would in principle have been possible to change the memory format but keep the file format the same, by juggling the bytes on CHAIN/LOAD and SAVE, but losing the ability to *LOAD/*SAVE programs would have been a big price to pay. Being able to do that is particularly valuable for overlays and modular programs.

Swapping the order of the line number bytes does not of itself explain why the line-length byte was also moved (from after the line number to before it) but having decided to use a different format it gave me the flexibility to make more changes. Having the line-length byte first 'felt' more natural to me (and still does), and reversing the order of all three 'header' bytes had a kind of symmetry!

Soruk
Posts: 262
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: How do you edit your BASIC programs?

Post by Soruk » Thu Jan 31, 2019 2:48 pm

Richard Russell wrote:
Thu Jan 24, 2019 9:38 am
tom_seddon wrote:
Thu Jan 24, 2019 12:54 am
JSBeeb's tokenizer does something interesting: it runs the tokenizer from the BASIC 4 ROM!
All versions of BBC BASIC (with the possible exception of Brandy, I need to check that) allow you to run their built-in tokeniser via a cheat involving EVAL.
A bit late to the party here, but no, this will not work in Brandy. Its internal structures are not visible to a running BASIC program, indeed PAGE = 0 on Linux and Windows builds.

User avatar
Richard Russell
Posts: 619
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: How do you edit your BASIC programs?

Post by Richard Russell » Thu Jan 31, 2019 4:04 pm

Soruk wrote:
Thu Jan 31, 2019 2:48 pm
this will not work in Brandy. Its internal structures are not visible to a running BASIC program, indeed PAGE = 0 on Linux and Windows builds.
So what memory is visible to a running BASIC program? Presumably everything between LOMEM and HIMEM is, otherwise indirection would not work. What about above HIMEM? Would a workaround be for the tokeniser to copy its output to somewhere in that range, maybe at END?

Soruk
Posts: 262
Joined: Mon Jul 09, 2018 10:31 am
Location: Basingstoke, Hampshire
Contact:

Re: How do you edit your BASIC programs?

Post by Soruk » Fri Feb 01, 2019 11:32 am

Richard Russell wrote:
Thu Jan 31, 2019 4:04 pm
Soruk wrote:
Thu Jan 31, 2019 2:48 pm
this will not work in Brandy. Its internal structures are not visible to a running BASIC program, indeed PAGE = 0 on Linux and Windows builds.
So what memory is visible to a running BASIC program? Presumably everything between LOMEM and HIMEM is, otherwise indirection would not work. What about above HIMEM? Would a workaround be for the tokeniser to copy its output to somewhere in that range, maybe at END?
Memory between LOMEM and HIMEM is certainly visible, HIMEM is, by default, the top of the memory allocated to BASIC programs and data, with a couple of exceptions nothing is readable above HIMEM.
The exceptions are:
1) Raspberry Pi GPIO MMIO space - as returned by SYS "RaspberryPi_GPIOInfo" TO present%,gpiomem% - 4K is accessible though less than that is significant.
2) MODE 7 video memory at &FFFF7C00 to &FFFF7FFF. (&FFFF7FE8-&FFFF7FFF writes are ignored, reads return 0 - unlike the BBC Micro, scrolling updates the screen memory so &FFFF7C00 is always the top left character cell).

I'd need to look at what the tokeniser does - while Brandy can load tokenised files (both yours and Acorn), it saves as plain-text.
Last edited by Soruk on Fri Feb 01, 2019 12:22 pm, edited 2 times in total.

User avatar
Richard Russell
Posts: 619
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: How do you edit your BASIC programs?

Post by Richard Russell » Sat Feb 02, 2019 3:14 pm

dominicbeesley wrote:
Thu Jan 31, 2019 11:30 am
When I get time I'll have a go at changing SDLIDE to save as Acorn format too.
Version 1.00a of SDLIDE, released today, supports loading (but not saving) of Acorn-format programs.

LordVaderUK
Posts: 8
Joined: Thu Jan 31, 2019 12:26 am
Contact:

Re: How do you edit your BASIC programs?

Post by LordVaderUK » Tue Feb 12, 2019 10:39 pm

Hello all,

Can someone help out a newbie (to retro computing, but not to computing generally) with what is probably a really BASIC question...

I am writing a BASIC program, using the BBC Basic adaptation called SDLIDE, which seems pretty good. I can test and run the program in emulated mode on my Mac, perfect.

However I want to run it on the BBC Micro. I have RetroClinic's excellent DataCentre which allows me to save the program onto a USB stick and then load it onto the BBC. However, this is where I'm getting stuck.

If I save the program as tokenised basic, it has a .BBC file type, so for example the file is called MYPROG.BBC - but The BBC won't load this, keeps saying "bad name". If I remove the extension, it just says "file not found".

I'm obviously making a fundamental mistake, so my apologies for asking. But I am just getting (re)started in the world of BBCs...

Thanks in advance.

User avatar
lurkio
Posts: 1910
Joined: Tue Apr 09, 2013 11:30 pm
Location: Doomawangara
Contact:

Re: How do you edit your BASIC programs?

Post by lurkio » Wed Feb 13, 2019 6:41 pm

LordVaderUK wrote:
Tue Feb 12, 2019 10:39 pm
I am writing a BASIC program, using the BBC Basic adaptation called SDLIDE, which seems pretty good. I can test and run the program in emulated mode on my Mac, perfect. However I want to run it on the BBC Micro. I have RetroClinic's excellent DataCentre which allows me to save the program onto a USB stick and then load it onto the BBC. However, this is where I'm getting stuck. If I save the program as tokenised basic, it has a .BBC file type, so for example the file is called MYPROG.BBC - but The BBC won't load this, keeps saying "bad name". If I remove the extension, it just says "file not found". I'm obviously making a fundamental mistake, so my apologies for asking. But I am just getting (re)started in the world of BBCs...
The way I normally transfer a BASIC program from Mac to Beeb via DataCentre is to first use BeebEm to save the program to a .SSD disc-image. (You can paste the program listing into BeebEm first.) Then *IMPORT the .SSD into RAM drive 0 on the DataCentre: *IMPORT -0 Prog.SSD

But if you want to load the tokenised BASIC program-file straight from the USB stick into your Beeb's RAM (bypassing the .SSD stage altogether), then you have to do this:

Code: Select all

[Ctrl-Break]
*RAM
*DRIVE 5
*LOAD Prog 1900
I'm assuming that PAGE is at &1900 on your Beeb. If not, then amend the last line accordingly.

Is this what you were after?

:?:

mr-macrisc
Posts: 54
Joined: Wed Feb 07, 2018 3:35 pm
Contact:

Re: How do you edit your BASIC programs?

Post by mr-macrisc » Wed Feb 13, 2019 9:14 pm

What about Risc OS on a raspberry pi and use something like strongEd.

That's assuming risc os on pi can read and write bbc compatible floppy.

dominicbeesley
Posts: 694
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: How do you edit your BASIC programs?

Post by dominicbeesley » Thu Feb 14, 2019 9:06 am

The problem you're encountering is that SLIDE uses Richard Russel's newer tokenized format instead of Acorns.

You should be able to save as text format from SLIDE then load it into the beeb using *EXEC.

D

User avatar
Richard Russell
Posts: 619
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: How do you edit your BASIC programs?

Post by Richard Russell » Thu Feb 14, 2019 9:38 am

dominicbeesley wrote:
Thu Feb 14, 2019 9:06 am
The problem you're encountering is that SLIDE uses Richard Russel's newer tokenized format instead of Acorns.
As I've mentioned, since SDLIDE is itself written in BBC BASIC adapting it to output Acorn-format tokenised programs would not be difficult (the latest version already loads Acorn format files). Saving would be somewhat slower but that's not likely to be relevant with the size of program you can fit in a BBC Micro!

The code would need to be something like this, instead of the current code in FNsave(). Note that the only significant change is to reverse the order of the first three bytes in every line:

Code: Select all

      BPUT #F%,&D
      FOR N% = 0 TO nLines% - 1
        a$ = Buffer$(N%)
        BPUT #F%, MID$(a$,3,1)+MID$(a$,2,1)+MID$(a$,1,1)+MID$(a$,4);
      NEXT
      BPUT #F%,&FF      

dominicbeesley
Posts: 694
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: How do you edit your BASIC programs?

Post by dominicbeesley » Thu Feb 14, 2019 10:30 am

It's on my round tuits pile!

D

User avatar
fordp
Posts: 971
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England
Contact:

Re: How do you edit your BASIC programs?

Post by fordp » Thu Feb 14, 2019 1:35 pm

I am not sure how it works but Windows allows you to dig in to zips and treat them like a subdirectory. You could do the same for SSD, DSD and MMB files and then you could use any editor on the PC to edit basic programs.
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
Richard Russell
Posts: 619
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: How do you edit your BASIC programs?

Post by Richard Russell » Thu Feb 14, 2019 1:51 pm

fordp wrote:
Thu Feb 14, 2019 1:35 pm
you could use any editor on the PC to edit basic programs.
Not 'tokenised' (internal format) BASIC programs, which is what programs in an SSD are likely to be. "Any editor on the PC" is only going to be useful for plain text files, such as might be created by *SPOOL and/or loaded with *EXEC, but they are the exception.

Post Reply