How do you change what CP/M programs are on a disk image file?
If you are running CP/M within an emulator, you can copy (PIP) files from one disk to another. But, you have to have them within a disk image to start with. If you need to get a file from a Windows computer into a disk image for a CP/M computer, that presents problems. Hey, the CP/M disks were 128 bytes per sector and Windows computers use 512 bytes per sector. This means even writing a physical disk (if you still have a floppy disk drive) is ruled out too.
Some emulators might have the ability to copy a file in. If you’re using one like that, this won’t be a problem for you. If not, here’s a solution …
The emulators I’m currently using access a disk image file. It’s one file that contains all of the sectors of a disk. It’s a good match to the old days: you put a single floppy disk in the drive and you got access to the files on it. This is the same principle. One disk image and a set of files. It makes a lot of sense to do it that way. CP/M wants to maintain the disk by writing new files to it, deleting existing ones and so on. It has its own style for directories. It has its way of filing things. CP/M needs a disk to read and write from. Using disk image files just makes a lot of sense for emulators.
What was needed was a way I could get a file onto any “disk” (into any disk image). Then it becomes possible to set up disks for any emulator with any combination of programs. I needed something simple that understood CP/M format disks and that would copy files from Windows to a CP/M disk image or back out again.
I ended up writing one.
The program is cpmfs.exe. It is free and open source. The source code is cpmfs.c.
In line with the desire for it to be really simple: it is a single source code file, it just uses plain C so you don’t need a C++ compiler or C++ DLLs, it just compiles and runs. I used the GNU C Compiler, gcc.
It runs on Windows and doesn’t require any special access, permissions or drivers. It just treats the disk image as a normal, user data file.
If you want to use it on other platforms, it should be simple to compile. The only obvious “gotcha” is the need to open the disk image in binary mode on Windows. There is an extra “b” in the fopen() function calls to stop Windows automatically converting CR LFs to newline characters. You don’t need the “b” bit on unix / linux. Other than that, it is pretty standard C for console-mode on Windows or anything else.
Here’s what it looks like:
Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\test>cpmfs CP/M File System Utility Ver 0.01 Copyright 2017 Sydneysmith.com Usage: cpmfs [-t type] imagefile cmd [fn1 [fn2]] cmd: make : create imagefile init : reset imagefile to empty rsys fn1 : read system tracks -> win fn1 wsys fn1 : write system tracks <- win fn1 dir : list cpm files in imagefile era fn1 : erase cpm file fn1 r fn1 [fn2] : read cpm fn1 -> win fn2 w fn1 [fn2] : write cpm fn1 <- win fn2 Default fn2 is same name as fn1 C:\test>cpmfs cpma.cpm dir DUMP.COM SDIR.COM SUBMIT.COM ED.COM (etc) ASM.COM LOAD.COM XSUB.COM C:\test>cpmfs cpma.cpm r ddt.com OK. C:\test>dir ddt.com Volume in drive C is OS Volume Serial Number is C2B8-A798 Directory of C:\test 30-Oct-17 16:37 4,864 ddt.com 1 File(s) 4,864 bytes 0 Dir(s) 84,479,627,264 bytes free C:\test>cpmfs cpma.cpm w szp.c OK. C:\test>cpmfs cpma.cpm dir DUMP.COM SDIR.COM SUBMIT.COM ED.COM (etc) SZP.C ASM.COM LOAD.COM XSUB.COM C:\test>cpmfs cpma.cpm era szp.c OK. C:\test>
That’s running under Windows 8.1.
Limitations
The program looks for an E5 at the start of a CP/M File Control Block (FCB) for deleted files. It uses these to find an empty slot when copying a new file into the disk image. That is pretty robust. However, the reverse looks for a 00 in that position when looking for existing files. I think some of the updates to CP/M set bits in that part of the FCB to cover things like: different user areas and flags for (maybe) R/O, Hidden and System files.
As the program currently is, copies are only to or from USER area 0 (which isn’t much of a problem) but; if you have files with special attributes, and if you copy a file with the same name onto the disk image, you could end up with two files with the same name on the image. Don’t do that. I’ll protect against that in a later version.
At present, it works for 8 inch, SSSD (standard) disk images. It doesn’t work for other disk types yet (but you can see from the source code, and usage message, I plan to add others).
I hope you find it useful.
Licensing is as per the text in the source code (see the link above).