Automating the creation of SSD's

having trouble with an archived file or want to correct something? report it here!
User avatar
leenew
Posts: 3329
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Automating the creation of SSD's

Postby leenew » Fri May 15, 2015 4:48 pm

Hi there,
One of the projects I am involved in at the moment, is the creation of individual SSDs containing one game each from the Michael Brown disc collection.
This will form a new section of the archive, much like the STH disc SSD archive.
I am quite busy at the moment and I am finding the individual creation of these discs quite time consuming.
I have completed discs 001 to discs 021 and my head is spinning.

Right...

After speaking with Lurkio (who is also extremely busy with too many projects), he has said that there should be a way of automating this process, using PERL or similar.

If I run through the steps I am taking, would anyone capable of doing this, or helping in any way, please chime in [-o<

The Facts:

Michael's DSD games discs each contain 18 games.

9 games per side usually, but not always. (The value side% sets the number of games per side.)

Each disc contains a !BOOT file, which is actually a piece of machine code, and a BASIC menu program.

Later in the BASIC program, there is a list from A to R of GAME NAME, followed by PROGRAM NAME.
PROGRAM NAME is ALWAYS CHAINED.

Files on the discs are in order, e.g. :
!BOOT
INV1
INV2
INV3
MONK-L
MONKpic
MONKobj
HAPPYA
HAPPYB
HAPPYC
where INV1, MONK-L and HAPPYA would be the program names of the first 3 games that are chained.

To create an SSD, I am working with a blank 200K SSD and doing the following:
RENAMING IT to something sensible
loading it into BEEBEM DRIVE 0, and the DSD of the disc I am working on into DRIVE1. Then:

DISABLE WRITE PROTECTION EVERY TIME AS BEEBEM FORGETS ITS SETTINGS...

*TITLE GAMENAME
*BUILD !BOOT
*BASIC
*FX200,3
*FX4,1
PAGE=&1900
CHAIN "GAME"
<escape>
*ACCESS !BOOT L
*COPY 1 0 FILE1
*COPY 1 0 FILE2
*COPY 1 0 FILE3 ETC.
(the reason I do them one at a time is to keep them in the correct order)

Then, because of a BEEBEM fault where I can't eject, and insert another disc without corruption occuring, I have to close BEEBEM and start the process again for the next disc...

21 discs * 18 games is 378 games so far.
There are about 115 discs :shock:

(At this stage, don't ask why the *FX200,3 and *FX4,1 are in every !BOOT)

So, if anyone can help automate this process, I would be very grateful indeed :D

Lee.

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

Re: Automating the creation of SSD's

Postby jgharston » Fri May 15, 2015 5:03 pm

leenew wrote:So, if anyone can help automate this process, I would be very grateful indeed
MkImage will create DFS, ADFS amd HADFS disk images on BBC, RISC OS and Windows. You could us its functionality to create a version for other platforms/other languages.

It will take an input file of files to be included so you can build build-specific files, include them, then throw them away afterwards.

Code: Select all

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

poink
Posts: 963
Joined: Tue Mar 01, 2011 10:27 am

Re: Automating the creation of SSD's

Postby poink » Fri May 15, 2015 5:29 pm

leenew wrote:After speaking with Lurkio (who is also extremely busy with too many projects), he has said that there should be a way of automating this process, using PERL or similar.

Yes; it should be, there's a few tricky bits. Firstly, I've not found anything good for extracting files from DFS disc images. Secondly, automatically working out what the games are might be overly tricky.

For the first, unless someone's got a good suggestion, something can probably be hacked together. For the second, just asking the user for the game name might suffice.

jgharston wrote:MkImage will create DFS, ADFS amd HADFS disk images on BBC, RISC OS and Windows. You could us its functionality to create a version for other platforms/other languages.

For DFS, I'd suggest mkdfs, at for Linux/Unix; saves needing to find and install something like Brandy BASIC.

User avatar
leenew
Posts: 3329
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: Automating the creation of SSD's

Postby leenew » Fri May 15, 2015 5:37 pm

Jonathan, Poink, Thank you.
As far as working out what the games are, (remember I am illiterate when it comes to what is and what is not possible here...), remember that the DSD !BOOT menu has the name of the first file of each game, and that each DSD has the files in order, therefore, in my naive mind, I thought something could interrogate the !boot and firstly look at side%
This tells it how many games are on side 0. (18-side% are on side 2).
More interrogation of the !BOOT menu would yield the 18 program names that are the first one to be CHAINed for each game.
Therefore :wink: it should be easy to spit out 18 fully functional SSD's with no extra user input :lol:
For my next trick ladies and gentlemen... :mrgreen:

Lee.

poink
Posts: 963
Joined: Tue Mar 01, 2011 10:27 am

Re: Automating the creation of SSD's

Postby poink » Fri May 15, 2015 6:01 pm

leenew wrote:As far as working out what the games are, (remember I am illiterate when it comes to what is and what is not possible here...),

There's what's possible, and then what's worth the trouble...of course, not typing 2000+ game names is worth a decent bit of trouble!

If it gets it wrong, though, it'll do a lot wrong very quickly :wink:.

Extracting names really depends on how complex the menu program is, and how similar it is between disks.

I'm going to have a look for one of these discs, because I'm sure it'll be clearer with one in front of me. IIRC, they were posted to this forum...

User avatar
jbnbeeb
Posts: 363
Joined: Sat Apr 03, 2010 8:16 pm

Re: Automating the creation of SSD's

Postby jbnbeeb » Fri May 15, 2015 6:10 pm

Before going in to implementing it.. am I right in thinking you're looking to create a single SSD for each of the games on the DSD collection disks?
If so.. are you looking to automatically work out which files should be copied to the SSD? This bit sounds tricky as there will be a different number of files for each game, in which case how would the "automatic" program work out which files to copy?

Perhaps you could give a bit more detail.. or let me know if I'm barking up the wrong tree :D
I'm going to ..
ABUG North Halifax June 10-12
Image

poink
Posts: 963
Joined: Tue Mar 01, 2011 10:27 am

Re: Automating the creation of SSD's

Postby poink » Fri May 15, 2015 6:35 pm

jbnbeeb wrote:This bit sounds tricky as there will be a different number of files for each game, in which case how would the "automatic" program work out which files to copy?

I think it's possible for many of the games, because you might be CHAINing JmpJet1 and the other files will be labelled JmpJet2 etc.,

Unfortunately, that doesn't hold for every game; actually, almost nothing holds for every game.
Some games aren't CHAINed (eg., Web War), some games need a different PAGE (eg., The Great Wall). Most aren't named in a way a program could see as consistent: Pimania seems to be PIMANIA, PI-DATA, PIMAN2 and maybe PIC. WEB-WAR is WEB-WAR, WEB and WEB1. The Great Wall is probably TGWL, TGW, W1 and WALL? I have no idea where 'CODE' and 'DATA' come from.

User avatar
leenew
Posts: 3329
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: Automating the creation of SSD's

Postby leenew » Fri May 15, 2015 6:52 pm

I am at work now but if you look at the "39th anniversary" thread in the archive submissions section you can look at a !BOOTmenu program and look at some ssds I posted also. See above where I think the key lies... All game files are in order in the DSD and the !BOOT contains the name of all the files to be chained. (they are Always chained)...
Lee.

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

Re: Automating the creation of SSD's

Postby jgharston » Fri May 15, 2015 7:12 pm

Hold on, is it that all you are doing is taking a DSD contining two sides of a DFS disk and you want to creates two SSDs, each of which contain one side of the source double-sided DFS disk?

If that is so, then ignore the contents, just do a raw byte copy from the source DSD to two destination SSDs.

dsd=OPENIN(dsdfile$)
ssd1=OPENOUT(ssdfile1$)
ssd2=OPENOUT(ssdfile2$)
REPEAT
FOR byte=0 TO 10*256-1:BPUT#ssd1,BGET#dsd:NEXT byte
FOR byte=0 TO 10*256-1:BPUT#ssd2,BGET#dsd:NEXT byte
UNFIL EOF#dsd
CLOSE#ssd2
CLOSE#ssd1
CLOSE#dsd

...with some error checking.

Hasn't this question been asked before? I have memories of typing the above code before.

Code: Select all

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

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

Re: Automating the creation of SSD's

Postby lurkio » Fri May 15, 2015 7:33 pm

jgharston wrote:Hold on, is it that all you are doing is taking a DSD contining two sides of a DFS disk and you want to creates two SSDs, each of which contain one side of the source double-sided DFS disk?

No, that's not it. Each of Mick's "30th Anniversary" DSD images contains multiple games. We want to split each game out onto its own SSD.

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

Re: Automating the creation of SSD's

Postby lurkio » Fri May 15, 2015 7:43 pm

jbnbeeb wrote:am I right in thinking you're looking to create a single SSD for each of the games on the DSD collection disks?

Yes. Each SSD will contain all the files that belong to one single game, and nothing else. (Well, nothing else apart from a customised !BOOT to boot the game.)

jbnbeeb wrote:If so.. are you looking to automatically work out which files should be copied to the SSD?

Yes.

jbnbeeb wrote:This bit sounds tricky as there will be a different number of files for each game, in which case how would the "automatic" program work out which files to copy?

The menu program on each DSD contains an ASCII list (in DATA statements) of every loader file for every game on the DSD: i.e. a list of the "first files" for all the games. Mick has carefully written all the files on each DSD in order. (You can see this if you do *INFO *.* on each DSD.) So the files for any particular game will be grouped together on contiguous sectors of the disc -- no interleaving of files from two or more different games.
Last edited by lurkio on Fri May 15, 2015 7:58 pm, edited 4 times in total.

User avatar
Arcadian
Posts: 2733
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Automating the creation of SSD's

Postby Arcadian » Fri May 15, 2015 7:50 pm

Not an automated solution, but surely using GUI-based software like BBC Explorer is going to be faster than the current method with BeebEm etc?

For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk

Image
ABug Leicestershire (17-19 November 2017)

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

Re: Automating the creation of SSD's

Postby jgharston » Fri May 15, 2015 10:07 pm

lurkio wrote:
jgharston wrote:Hold on, is it that all you are doing is taking a DSD contining two sides of a DFS disk and you want to creates two SSDs, each of which contain one side of the source double-sided DFS disk?
No, that's not it. Each of Mick's "30th Anniversary" DSD images contains multiple games. We want to split each game out onto its own SSD.
Ah! That clarifies it. Any chance of a link to a couple of example disk images to actually see the problem?

Code: Select all

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

User avatar
jbnbeeb
Posts: 363
Joined: Sat Apr 03, 2010 8:16 pm

Re: Automating the creation of SSD's

Postby jbnbeeb » Fri May 15, 2015 10:18 pm

The menu program on each DSD contains an ASCII list (in DATA statements) of every loader file for every game on the DSD: i.e. a list of the "first files" for all the games. Mick has carefully written all the files on each DSD in order. (You can see this if you do *INFO *.* on each DSD.) So the files for any particular game will be grouped together on contiguous sectors of the disc -- no interleaving of files from two or more different games.


Conscious that I'm only posing the problem and not the solution (sorry) ..but the files for each game being contiguous probably doesn't help automation (as the next game file will follow on from the last prior game file). ... #-o And in writing that sentence, I suppose that could BE the solution, providing that code can be written to plough through the correct sequence of files UNTIL the next "first" game file is encountered!
I'm going to ..
ABUG North Halifax June 10-12
Image

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

Re: Automating the creation of SSD's

Postby lurkio » Fri May 15, 2015 10:41 pm

jbnbeeb wrote:but the files for each game being contiguous probably doesn't help automation (as the next game file will follow on from the last prior game file). ... #-o And in writing that sentence, I suppose that could BE the solution, providing that code can be written to plough through the correct sequence of files UNTIL the next "first" game file is encountered!

That's exactly what needs to be done.

jgharston wrote:
lurkio wrote:Each of Mick's "30th Anniversary" DSD images contains multiple games. We want to split each game out onto its own SSD.
Ah! That clarifies it. Any chance of a link to a couple of example disk images to actually see the problem?

Here's a link to Disc030.

If you LOAD and LIST the !BOOT program, you see this:
1.png


And if you do *INFO *.* on the DSD, you get this:
2.png


So the first generated SSD needs to contain the files $.CAVEY, $.CAVEY1 and $.CAVEY2 -- i.e. everything up to but excluding the next file listed in the !BOOT, which is $.MAZE. (The SSD also needs to contain a !BOOT that will CHAIN"CAVEY".)

The second SSD should contain MAZE, INT and MAZCD. (Everything up to but excluding GB-Inst.)

The third SSD: GB-Inst, GREEN, MOD2, LODCODE and BERET. (Everything up to but excluding MISSILE.)

And so on.

User avatar
richardtoohey
Posts: 3354
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand

Re: Automating the creation of SSD's

Postby richardtoohey » Sat May 16, 2015 12:34 am

Could possibly do this with a DC? :-k

But quicker on a PC.

User avatar
richardtoohey
Posts: 3354
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand

Re: Automating the creation of SSD's

Postby richardtoohey » Sat May 16, 2015 1:31 am

Got this far with Stephen's perl MMB tools.

Obviously still needs work to automate, but I'm getting there.

So I've created DSD and SSD directories. I plonk the DSD in the DSD directory. It extracts two SSDs into the SSD directory. I then extract all the files to get access to the !BOOT file (the menu, in BASIC).

So now "just" to parse the DATA statements.

1. Split the DSD into SSDs (because that's what the tool offers for DSDs)

Code: Select all

/home/richard.toohey/mmc_beeb/sweh_perl/beeb split_dsd DSD/Disc030.dsd SSD/Disc030_1.ssd SSD/Disc030_2.ssd
Disks created
2. Extract the files from side 1 (to get the !BOOT)

Code: Select all

/home/richard.toohey/mmc_beeb/sweh_perl/beeb getfile SSD/Disc030_1.ssd Disc030
Saving $.Hcode1 as Hcode1
Saving $.MANGO2 as MANGO2
Saving $.MAZE as MAZE
...
3. List the !BOOT (to get the initial file of each set)

Code: Select all

/home/richard.toohey/mmc_beeb/sweh_perl/beeb list Disc030/!BOOT
   10REM ... Games Disc 030 ...
   20REM ...... Dec 1987 ......
   30:
...
  190REM"�  ***** DRIVE 0 *****
  200DATACavey,CAVEY
  210DATAThe Maze,MAZE
  220DATAGreen Beret,GB-INST
  230DATAMissile Attack,MISSILE
  240DATAPowerboat Racing,POWERBO
  250DATADespatch Rider,BBCLOAD
  260DATAFuture Shock,LOADER
  270DATAHunkidory,HUNKY
  280DATAMango,MANGO
  290REM"�  ***** DRIVE 2 *****
  300DATAPaperboy,PAPER
  310DATAGatecrasher,GATE1
  320DATAStellar Rescue,HEADER
  330DATARaid Over Moscow,MOSCOW
  340DATA"Super Barricade�(2P)",BARCADE
  350DATAOne Last Game,ONELOAD
  360DATACrazee Rider,CRAZEE
  370DATACosmonaut,COSMO
  380DATATrench,TRENCH
So still some way to go and there may be more hurdles ahead (e.g. the extraction order from the SSD doesn't look like it is right, so might be a bit of a show-stopper here!)

poink
Posts: 963
Joined: Tue Mar 01, 2011 10:27 am

Re: Automating the creation of SSD's

Postby poink » Sat May 16, 2015 2:38 am

richardtoohey wrote:So still some way to go and there may be more hurdles ahead (e.g. the extraction order from the SSD doesn't look like it is right, so might be a bit of a show-stopper here!)

Might be as simple as removing a sort statement?

User avatar
richardtoohey
Posts: 3354
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand

Re: Automating the creation of SSD's

Postby richardtoohey » Sat May 16, 2015 4:38 am

poink wrote:
richardtoohey wrote:So still some way to go and there may be more hurdles ahead (e.g. the extraction order from the SSD doesn't look like it is right, so might be a bit of a show-stopper here!)

Might be as simple as removing a sort statement?
Yes, I removed one but it didn't help.

The raw read catalogue routine definitely reads them in the required order, but then there's at least one thing sorting them.

Definitely fixable, though, so I'm heading in the right direction. But my perl is very rusty, so might take a while.

EDIT: no need to change anything, just carry on using the tool as is:

Code: Select all

/home/richard.toohey/mmc_beeb/sweh_perl/beeb info SSD/Disc030_1.ssd
Disk title: DISC 030     (80)  Disk size: &320 - 200K
Boot Option: 2 (RUN)   File count: 31

Filename: Lck Lo.add Ex.add Length Sct
$.MANGO2    L  001900 002B9B 002200 299
$.MANGO     L  001900 008023 000D5D 28B
$.SCRDATA   L  004090 004090 00176F 273
$.Hcode2    L  001100 001100 0007FF 26B
$.Hcode1    L  000900 000900 0003FF 267
$.HUNKY2    L  001900 001900 001DFF 249
$.HUNKY     L  001900 001900 000EFF 23A
$.FUTURE    L  001347 007F88 0044B9 1F5
$.SHOCK15   L  000400 00095D 000900 1EC
$.SHOCK1    L  001100 001347 000260 1E9
$.SCREEN    L  005400 005700 002C00 1BD
$.LOADER    L  001900 001900 0009F4 1B3
$.sounds    L  0008C0 0008C0 000140 1B1
$.track     L  001100 002686 004700 16A
$.BBCload   L  001900 008023 000DFA 15C
$.POWERBO   L  001900 00801F 001DFF 13E
$.MisAtt2   L  001100 003A00 002980 114
$.MisAtt1   L  004000 004000 001600 0FE
$.MISSILE   L  001900 001900 000600 0F8
$.BERET     L  001100 001100 003B35 0BC
$.LODCODE   L  007000 007000 0000BD 0BB
$.MOD2      L  000A02 000A02 000058 0BA
$.GREEN     L  001900 008023 000225 0B7
$.GB-Inst   L  001900 008023 000900 0AE
$.MAZCD     L  001900 0041C9 004700 067
$.INT       L  001900 003A5B 0021A0 045
$.MAZE      L  001900 008023 0002BE 042
$.CAVEY2    L  003000 000000 002A00 018
$.CAVEY1    L  001900 008023 000300 015
$.CAVEY     L  001900 008023 000C3B 008
$.!BOOT     L  001900 001E00 000600 002
Now "just" :roll: to bring all these things together - for *.DSD in the DSD directory, do the above commands, parse the output and make stuff happen.

User avatar
sweh
Posts: 1833
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Automating the creation of SSD's

Postby sweh » Sat May 16, 2015 12:53 pm

FWIW, the perl utilities don't really keep "order" internally. Catalogues are stored in hash arrays and iterating over a hash can cause the results to come out in any order.

For the "info" command we explicitly sort on the starting sector to match Acorn:

Code: Select all

  foreach (sort { $files{$b}{start} <=> $files{$a}{start} } keys %files)


For the "extraction" routines we don't care about order of file extraction 'cos all the files end up on the filesystem. Filename order on the disk isn't necessarily important. I learned that when decomposing my old disks from BITD!

Remember you need to use the data in the 'inf' files to get the BBC filename; the Beeb allows characters Unix doesn't (eg "/") so the routines mangle filenames into Unix friendly format; the real Beeb filename only appears in the inf file (along with load/exec addresses, etc).
Rgds
Stephen

User avatar
sweh
Posts: 1833
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Automating the creation of SSD's

Postby sweh » Sat May 16, 2015 1:08 pm

PS: if you really do want to save files in the same order as the "info" command, then in BeebUtils.pm there's a function called "save_all_files" (around line 848). The "for" loop in that should be changed to be the same as the for loop mentioned above; that _should_ cause the save routine to work to be in the same order.
Rgds
Stephen

User avatar
richardtoohey
Posts: 3354
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand

Re: Automating the creation of SSD's

Postby richardtoohey » Sun May 17, 2015 4:03 am

Still got to actually build the SSDs, but I've got this far ...

It will scan a DSD directory for any files ending .dsd, then extract the SSD files, and decode the !BOOT BASIC loader and work out what games there are and what files. How does it look?

Code: Select all

$ php-5.5 process_mb_dsd.php 
/home/richard.toohey/mb_dsd_splitter/DSD/Disc030.dsd
Processing Cavey first file CAVEY
        Files for game: CAVEY CAVEY1 CAVEY2
Processing The Maze first file MAZE
        Files for game: MAZE INT MAZCD
Processing Green Beret first file GB-INST
        Files for game: GB-Inst GREEN MOD2 LODCODE BERET
Processing Missile Attack first file MISSILE
        Files for game: MISSILE MisAtt1 MisAtt2
Processing Powerboat Racing first file POWERBO
        Files for game: POWERBO
Processing Despatch Rider first file BBCLOAD
        Files for game: BBCload track sounds
Processing Future Shock first file LOADER
        Files for game: LOADER SCREEN SHOCK1 SHOCK15 FUTURE
Processing Hunkidory first file HUNKY
        Files for game: HUNKY HUNKY2 Hcode1 Hcode2 SCRDATA
Processing Mango first file MANGO
        Files for game: MANGO MANGO2
Processing Paperboy first file PAPER
        Files for game: PAPER LOAD PROG DATA
Processing Gatecrasher first file GATE1
        Files for game: GATE1 GATE2 GATE3
Processing Stellar Rescue first file HEADER
        Files for game: HEADER STELLAR
Processing Raid Over Moscow first file MOSCOW
        Files for game: MOSCOW MOSCOW1 RAID RAID1 RAID2
Processing "Super Barricade�(2P)" first file BARCADE
        Files for game: BARCADE BARCAD2
Processing One Last Game first file ONELOAD
        Files for game: ONELOAD ONELAST
Processing Crazee Rider first file CRAZEE
        Files for game: Crazee CrazeeR CrazScr CrazPan CrazMod CRider Game??
Processing Cosmonaut first file COSMO
        Files for game: COSMO SCORE OBJECT
Processing Trench first file TRENCH
        Files for game: TRENCH trench1 trench2
Here is (ugly) code to date:

Code: Select all

<?php

define('PERL','/usr/bin/perl');
define('BEEB','/home/richard.toohey/mmc_beeb/sweh_perl/beeb');

define('DSD_DIR','/home/richard.toohey/mb_dsd_splitter/DSD');
define('SSD_DIR','/home/richard.toohey/mb_dsd_splitter/SSD');

class Game {
        public $Name;
        public $Side=0;
        public $FirstFile;
        public $NextFile;
        public $Files=array();
}

# Grab a DSD and process it
foreach (glob(DSD_DIR.DIRECTORY_SEPARATOR.'*.dsd') as $dsd_path) {
        echo "$dsd_path\n";

        $pp=pathinfo($dsd_path);

        $fn=$pp['filename'];

        # Step 1 - split out the two SSDs
        $ssd0=SSD_DIR.DIRECTORY_SEPARATOR."{$fn}_0.ssd";
        $ssd2=SSD_DIR.DIRECTORY_SEPARATOR."{$fn}_2.ssd";
        $result=exec(PERL.' '.BEEB." split_dsd $dsd_path $ssd0 $ssd2",$output,$rc);

        # Step 2 - get all files (we need !BOOT first, but we'll need
        # all the other files anyway, to build the separate SSD files)
        $ssd0d=SSD_DIR.DIRECTORY_SEPARATOR."{$fn}_0";
        $ssd2d=SSD_DIR.DIRECTORY_SEPARATOR."{$fn}_2";
        $result=exec(PERL.' '.BEEB." getfile $ssd0 $ssd0d",$output,$rc);
        $result=exec(PERL.' '.BEEB." getfile $ssd2 $ssd2d",$output,$rc);

        # Step 3 - get the catalogues in the order we need them
        $result=exec(PERL.' '.BEEB." info $ssd0",$cat_0,$rc);
        $result=exec(PERL.' '.BEEB." info $ssd2",$cat_2,$rc);

        if ($cat_0) {
                $games=array();
                $game_list=array();
                # Step 4 - read the !BOOT (BASIC) file from side 0 - it will
                # have the menu program.  Find the DATA lines and process them
                $result=exec(PERL.' '.BEEB." list $ssd0d/!BOOT",$pling_boot,$rc);
                if ($pling_boot) {
                        $side0_data_found=false;
                        $side2_data_found=false;
                        foreach ($pling_boot as $line) {

                                if (preg_match('/.*?0DATA.*/',$line)) {
                                        if ($side0_data_found==false) {
                                                # Must be first title on side 0
                                                #echo "Side 0 data starts with $line\n";
                                                $side0_data_found=true;
                                                $games[]=make_game(0,$line);
                                        } else {
                                                if ($side2_data_found==false) {
                                                        #echo "side 0 title $line\n";
                                                        $games[]=make_game(0,$line);
                                                } else {
                                                        #echo "side 2 title $line\n";
                                                        $games[]=make_game(2,$line);
                                                }
                                        }
                                }

                                if (preg_match('/.*?0REM.*/',$line)) {
                                        if ($side0_data_found) {
                                                #echo "end of side 0? $line\n";
                                                $side2_data_found=true;
                                        }
                                }
                                       
                        }

                        # Step 5 - we have the list of games, so let's work out
                        # the files to go into the SSD
                        if ($games) {
                                for ($i=0;$i<count($games);$i++) {
                                        $j=$i+1;
                                        if ($j<count($games)) {
                                                if ($games[$i]->Side==$games[$j]->Side) {
                                                        $games[$i]->NextFile=$games[$j]->FirstFile;
                                                } else {
                                                        $games[$i]->NextFile="END-OF-DISC";
                                                }
                                        } else {
                                                $games[$i]->NextFile="END-OF-DISC";
                                        }
                                }       

                                foreach ($games as $game) {
                                        echo "Processing $game->Name first file $game->FirstFile\n";
                                        if ($game->Side==0) {
                                                $cat_to_search=array_reverse($cat_0);
                                        } else {
                                                $cat_to_search=array_reverse($cat_2);
                                        }

                                        # And walk this array for files required
                                        $gathering_files=false;
                                        $files_found=array();
                                        foreach ($cat_to_search as $cat_file) {
                                                if (substr($cat_file,0,2)=='$.') {
                                                        $cat_file=trim(substr($cat_file,2,10));
                                                        if (strtoupper($cat_file)==strtoupper($game->FirstFile)) {
                                                                $gathering_files=true;
                                                                #echo "found first, gathering\n";
                                                        }
                                                        # For END-OF-DISC games we'll get them all, anyway
                                                        if (strtoupper($cat_file)==strtoupper($game->NextFile)) {
                                                                $gathering_files=false;
                                                                #echo "encountered next, stop gathering\n";
                                                        }
                                                        if ($gathering_files) {
                                                                #echo "gathering $cat_file ";
                                                                $files_found[]=$cat_file;
                                                        }
                                                }
                                        }
                                        #echo "\n";
                                        #echo "files for game "; print_r($files_found); echo "\n";
                                        $game->Files=$files_found;
                                        echo "\tFiles for game: ";
                                        foreach ($game->Files as $f) {
                                                echo "$f ";
                                        }
                                        echo "\n";
                                }
                        }
                }
        }
}

exit;

function make_game($side,$line) {
        # Split out line parts <space><line#>DATA<title>,<first_file>
        if (preg_match('/[\s]{1,3}[0-9]{1,3}DATA(.*?),(.*)/',$line,$matches)) {
                $game=new Game();
                $game->Name=$matches[1];
                $game->Side=$side;
                $game->FirstFile=$matches[2];   
                return $game;
        }
}
?>

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

Re: Automating the creation of SSD's

Postby lurkio » Sun May 17, 2015 10:26 am

=D>

Great work, Rich! Looks to me like you're on exactly the right track (no pun intended).

User avatar
leenew
Posts: 3329
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: Automating the creation of SSD's

Postby leenew » Sun May 17, 2015 10:47 am

Cool!
I was totally unaware that this would be even doable before Mr. Lukio mentioned it.
This may save me from having to create nearly 2000 SSDs by hand. I was feeling a bit under pressure to be honest so this may prove to be a real life-saver if you can get it working Richard [-o<
**note to self: change description of RT from "bumbling" and "mostly harmless" to "deceptively clever" and potential to become "deadly", even "elite". Keep an eye on him.....

Lee.

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

Re: Automating the creation of SSD's

Postby lurkio » Sun May 17, 2015 12:29 pm

sweh wrote:if you really do want to save files in the same order as the "info" command...

That would be nice because, as Mick explained:
Michael Brown wrote:The disc image of Q-Man is fine, but the files are out of sync on the image. INTRO should be after !BOOT and before QMAN1 otherwise the disc heads would be going back and forth on a real bbc!


Also, will it be possible to write a custom !BOOT to each SSD? I think all it needs to do is this:

Code: Select all

*BASIC
CHAIN "<loader>"

Code: Select all

*BASIC
*FX21
CLOSE#0:CHAIN "<loader>"

Can sweh's DFS tools do a *OPT4,3 to auto-EXEC the !BOOT on SHIFT-BREAK?

How about *ACCESS *.* L to lock all the files?
Last edited by lurkio on Sun May 17, 2015 5:46 pm, edited 1 time in total.

User avatar
sweh
Posts: 1833
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Automating the creation of SSD's

Postby sweh » Sun May 17, 2015 2:32 pm

lurkio wrote:
sweh wrote:if you really do want to save files in the same order as the "info" command...

That would be nice because, as Mick explained:
Michael Brown wrote:The disc image of Q-Man is fine, but the files are out of sync on the image. INTRO should be after !BOOT and before QMAN1 otherwise the disc heads would be going back and forth on a real bbc!


Err, that's the order you _put_ the files onto the SSD, not the order the files are extracted from the SSD. The "putfile" command puts them in the order you list them (I was too lazy to try and find a gap large enough, so it always adds the file to the end of the SSD).
Also, will it be possible to write a custom !BOOT to each SSD?

Sure; you just create the !BOOT file on Linux and then "putfile" it the same as any other file. Without an "inf" it'll have load/exec values of 000000 which is fine for boot files. You should ensure it has BBC "end of line" characters. So if you create the file with "vi" then do

Code: Select all

tr '\012 '\015' < !BOOT.SRC > !BOOT

to change it.

e.g

Code: Select all

echo '*BASIC
CHAIN "FOOBAR"' > !BOOT.SRC
tr '\012' '\015' < !BOOT.SRC > !BOOT
beeb putfile foo.ssd !BOOT


FWIW my !BOOT file does similar to

Code: Select all

*BASIC
10CLOSE#0
20*FX21
30CHAIN "MENU"
RUN

to ensure file handles are closed. Some games (eg The Hobbit) don't like having the *EXEC filehandle open at startup.

Can sweh's DFS tools do a *OPT4,3 to auto-EXEC the !BOOT on SHIFT-BREAK?

How about *ACCESS *.* L to lock all the files?

Yup; "beeb opt4" and "beeb access" commands. Here's an extract from a SSD creation routine I wrote 3 years ago

Code: Select all

#!/bin/ksh
DSK=menudsk.ssd

rm -f $DSK
beeb blank_ssd $DSK
beeb opt4 $DSK 3
beeb title $DSK "Games Disk"
beeb putfile $DSK OBJS/*
beeb access $DSK '*.*' L


These are the "OBJS" that get put onto the disk:

Code: Select all

% ls OBJS
!BOOT  M.E00_2  M.Game1   M.Game2  M.Game4  M.Game6  M.Game8  M.Trivial  Menu0
M.E00  M.Elite  M.Game10  M.Game3  M.Game5  M.Game7  M.Game9  Menu

This the the result:

Code: Select all

% beeb info menudsk.ssd
Disk title: Games Disk (1)  Disk size: &320 - 200K
Boot Option: 3 (EXEC)   File count: 17

Filename:  Lck Lo.add Ex.add Length Sct
$.Menu0     L  000000 000000 0002F6 033
$.Menu      L  000000 000000 000482 02E
M.Trivial   L  000000 000000 000228 02B
M.Game9     L  000000 000000 0001D2 029
M.Game8     L  000000 000000 0003DA 025
M.Game7     L  000000 000000 000283 022
M.Game6     L  000000 000000 000374 01E
M.Game5     L  000000 000000 000136 01C
M.Game4     L  000000 000000 00035D 018
M.Game3     L  000000 000000 000454 013
M.Game2     L  000000 000000 00032E 00F
M.Game10    L  000000 000000 0000A7 00E
M.Game1     L  000000 000000 000329 00A
M.Elite     L  000000 000000 000320 006
M.E00_2     L  000000 000000 0000A4 005
M.E00       L  000000 000000 000162 003
$.!BOOT     L  000000 000000 00000D 002

You can see the *OPT4 and disk titles, and each file is locked.
The perl utils have lots of options; they're all documented :-)
Rgds
Stephen


User avatar
flaxcottage
Posts: 2734
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire

Re: Automating the creation of SSD's

Postby flaxcottage » Sun May 17, 2015 3:43 pm

leenew wrote:**note to self: change description of RT from "bumbling" and "mostly harmless" to "deceptively clever" and potential to become "deadly", even "elite". Keep an eye on him.....

Lee.


Richard did it just the way I should have, except I should have used BBC BASIC for Windows. :^o

Impressive. :shock:
- John

Currently running Level 4 Econet with BBC B, BBC B+ 128K, Master 128K, 4Mb A3000, 4Mb A3020, 4Mb A4000, 4Mb A5000 dual FDD; UK101; HP41CX setup; Psion 3a, 3mx and 5mx; Z88; TI-58c, TI-59 and printer

User avatar
richardtoohey
Posts: 3354
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand

Re: Automating the creation of SSD's

Postby richardtoohey » Sun May 17, 2015 7:28 pm

leenew wrote:"bumbling" and "mostly harmless"
Don't expect a Christmas card from me this year! [-(

I'll keep going, but it is not likely to be a 100% solution - it assumes files will be $.something (so any games that have files like D.LEVEL etc. won't be right), there are things like the menu file name being slightly different to the actual file GB-Inst vs GB-INST (got past that but the point is the filenames might be case-changed at the end of the process.) Also some filenames will be changed e.g. there is a Game?? file that will end up as Game__. All this would be fixable in code given endless time but I'm going to aim for get 80-90% done, then there will be some manual tidy-ups required.

And want to concentrate on the next set of tasks - actually making the SSDs, building the !BOOT, and setting the OPT 4.

What do "we" call the the generated SSD files? I'll come up with something for now, but you'll end up with a lot of fairly meaningless names. But they have to be unique.

User avatar
sweh
Posts: 1833
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Automating the creation of SSD's

Postby sweh » Sun May 17, 2015 8:19 pm

SSD filenames don't have to be limited in length. The disk title ("beeb title") is limited to 12 characters and should be descriptive and is best to be unique within an MMB (so *DIN can refer to them by name), but don't have to be.

So I have Way_Of_Exploding_Fist.ssd and the title is truncated to "Way_Of_Explo"

Code: Select all

% beeb info Way_Of_Exploding_Fist.ssd
Disk title: Way_Of_Explo (1)  Disk size: &320 - 200K
Boot Option: 3 (EXEC)   File count: 7

Filename:  Lck Lo.add Ex.add Length Sct
$.WAYSCR    L  006480 000000 001100 05A
$.WAYP2     L  001100 001100 004B00 00F
$.WAYP1     L  000400 000400 000900 006
$.WAYMOV    L  000070 000070 00001A 005
$.WAYLO1    L  006000 006000 00005D 004
$.WAYLO     L  001800 001800 00001E 003
$.!BOOT        000000 000000 000020 002
Rgds
Stephen


Return to “archive issues”

Who is online

Users browsing this forum: No registered users and 2 guests