Python module to create Acorn DFS .ssd images?

Development tools discussion area.
SteveF
Posts: 429
Joined: Fri Aug 28, 2015 8:34 pm

Python module to create Acorn DFS .ssd images?

Postby SteveF » Mon Jul 31, 2017 9:38 pm

What I'm looking for is something I could use roughly as follows:

Code: Select all

import dfs
image = dfs.ssd()
image.set_title('Cool stuff')
image.add_file('$.!BOOT', "*BASIC\rCHAIN "MENU"\r", load=0x0000, exec=0x0000, locked=False)
image.add_file("$.MENU", open("menu.bas", "rb").read(), load=0x0000, exec=0x0000, locked=False)
open('myprog.ssd', 'wb').write(image.get())

I started knocking my own up, then realised how much I hated doing it. :-)

I found https://github.com/rcook/ssdtools which looks as though I could turn it into what I want, but it's not directly applicable as it's more of a command line tool. So before I start with that, I thought I'd ask if anyone has already done this.

I really need this to be under some kind of open source licence as well, I'm afraid. I'm building a command line driver for PLASMA and I'd like it to be able to take PLASMA source as input and emit an emulator-ready SSD at the other end, so I'd want to put the code in the PLASMA repository on github.

Sorry if this already exists and my searching powers were weak...

ETA: Not sure if this should be in the "utilities" forum instead, I'll leave it up to the moderators to advise...
Last edited by SteveF on Mon Jul 31, 2017 9:47 pm, edited 1 time in total.

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

Re: Python module to create Acorn DFS .ssd images?

Postby jgharston » Mon Jul 31, 2017 9:41 pm

I've never used Python, are you able to shell out and call another program, like system() or OSCLI? Then you could do something like system(path_to_mkimg$+"mkimg "+outfile$+" "+inlist$);

Code: Select all

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

SteveF
Posts: 429
Joined: Fri Aug 28, 2015 8:34 pm

Re: Python module to create Acorn DFS .ssd images?

Postby SteveF » Mon Jul 31, 2017 9:44 pm

Python can do that, but I'm really looking for something self-contained if possible. Otherwise I guess I can use Richard's ssdtools directly by invoking them as you suggest.

User avatar
davidb
Posts: 1824
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Python module to create Acorn DFS .ssd images?

Postby davidb » Mon Jul 31, 2017 10:11 pm

I have a couple of modules that do fairly limited things with DFS images, basically just to make it easier to create them and fill them with files. One place they can be found is in my UEF2ROM repository, though they could be broken out into a separate repository along with one or two tools I have that use them.

The API could be improved a bit. Here's a code snippet that puts a file in a disk image:

Code: Select all

import makedfs

disk = makedfs.Disk()
disk.new()

catalogue = disk.catalogue()
catalogue.boot_option = 3

disk_files = []
data, load, exec_ = "Some data", 0x1900, 0x1900
disk_files.append(makedfs.File("$.FILE", data, load, exec_, len(data)))

catalogue.write("Title", disk_files)

disk.file.seek(0, 0)
disk_data = disk.file.read()
open(out_file, "w").write(disk_data)

SteveF
Posts: 429
Joined: Fri Aug 28, 2015 8:34 pm

Re: Python module to create Acorn DFS .ssd images?

Postby SteveF » Mon Jul 31, 2017 10:16 pm

Thanks David, that looks great! I'll give it a go and let you know how I get on.

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

Re: Python module to create Acorn DFS .ssd images?

Postby jgharston » Mon Jul 31, 2017 11:29 pm

SteveF wrote:Python can do that, but I'm really looking for something self-contained if possible. Otherwise I guess I can use Richard's ssdtools directly by invoking them as you suggest.

That reads really oddly. Surely something like mkimg or ssdtools *is* self-contained. It is a single simple tool that does a single specific task, without you having to give it anything else. Changing to 'looking *to* *write* *something* self-contained...' makes it work. :)

I'm reminded of a discussion with a colleague at work yonks ago when he said "we need to use something proprietary, like HTML". Err, no... that's *non*-proprietary.

Code: Select all

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

User avatar
simonm
Posts: 164
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: Python module to create Acorn DFS .ssd images?

Postby simonm » Tue Aug 01, 2017 1:27 am

Maybe you could use BeebAsm? Just assemble a sourcefile containing a bunch of PUTFILE commands and no source and have it write the output SSD. Only snafu there is you can't set the title. Just a thought anyways.

SteveF
Posts: 429
Joined: Fri Aug 28, 2015 8:34 pm

Re: Python module to create Acorn DFS .ssd images?

Postby SteveF » Tue Aug 01, 2017 3:11 pm

Ha, I didn't express that very well, did I? What I was trying to say was that I'd like to avoid adding external dependencies to my Python program if I can help it. Ultimately I'd like to make it easy for someone to download a ready-to-go PLASMA development environment and the fewer external components I have to bundle or tell them to install separately the better.

@simonm Ta, that would work - I am in fact (mis)using beebasm for exactly this elsewhere in PLASMA at the moment, but I'd like to get away from that dependency if I can help it, so it looks like David's Python module will be perfect.


Return to “development tools”

Who is online

Users browsing this forum: No registered users and 2 guests