emustudio / emuStudio

Universal emulation platform and framework.
https://www.emustudio.net/
GNU General Public License v3.0
40 stars 9 forks source link

Transferring files from the host file system to the emulated CP/M file system #209

Closed pamoroso closed 2 years ago

pamoroso commented 2 years ago

What is your question? Is it possible to transfer files from the host file system to the emulated CP/M file system?

What environment do you have? OpenJDK 11 JRE, Crostini Linux (Debian Buster) under Chrome OS.

What computer configuration do you use? MITS Altair 8800.

How you run emuStudio? GUI.

Additional context I checked the issue archive and did some experimentation but it looks like it's currently not possible to transfer files.

For example, I used the mkfs.cpm Linux tool to create a CP/M disk image and copied a file to that image with cpmcp. Then, from emuStudio, I booted CP/M (disk A:) on the Altair 8800 and mounted as B: the disk image containing the file to transfer. But, when changing to the B: drive, CP/M issued the error Bdos Err On B: Bad Sector on the ADM-3A terminal.

vbmacher commented 2 years ago

Hi @pamoroso , thank you for raising this issue, it's always good to see that emuStudio is used. The CP/M filesystem does not include very importand metadata, crucial for locating files and file data in the image. For example: sector length, sectors per track, sector skew, ... Various versions of CP/M used different values of such. To use mkfs.cpm, you must use the same disk format as the image you use. The tool has some options to alter disk "format", but I wasn't digging so deep into it yet.

Still, there are at least two tickets with this feature request altready to support this inside emuStudio:

But I agree it would be very useful if tools like mkfs.com, cpmls, etc. work too. Please let me know if you were successful with altering disk format.

pamoroso commented 2 years ago

Thanks, I actually didn't experiment with mkfs.cpm further as I have no idea what disk format emuStudio expects.

vbmacher commented 2 years ago

Hey @pamoroso I've implemented very basic support for reading/writing files to Altair 8" disks running CP/M 2.2. Other CP/M versions are not supported yet, as well as other disk formats. This corresponds to a file altcpm.dsk I am attaching here. The implementation is buggy, but it seems to be working with this file only, hahaha.

I'll continue working on this. You can track the proggress also in #176 altcpm.zip

How to use it (it's undocumented now):

$ bin/88-dcdd --help
MITS 88-DCDD emuStudio plug-in, version 0.41-SNAPSHOT
 --help           : output this message (default: true)
 --image fileName : use given disk image
 --sectors X      : sectors per track (default 32) (default: 32)
 --sectorsize X   : sector size in bytes (default 128) (default: 128)
 --sectorskew X   : sector skew in bytes (default 17) (default: 17)

For the file I attached let's leave it as it is by default. Then command cpmfs supports few basic sub-commands:

$ bin/88-dcdd --image altcpm.dsk cpmfs 
Argument "CPMFS command (cat, ls, volinfo, download, upload)" is required

list files

For example, list files:

$ bin/88-dcdd --image altcpm.dsk cpmfs ls
STAT.COM
PIP.COM
ED.COM
DDT.COM
ASM.COM
LOAD.COM
SUBMIT.COM
XSUB.COM
MOVCPM.COM
COPY.COM
FORMAT.COM
DUMP.COM
SYSGEN.SUB
DUMP.ASM
CBIOS.ASM
PTD.ASM
LS.COM
CPM62.COM
SURVEY.COM
ABOOT62.ASM

upload file

Upload file "hello" with content:

$ cat hello 
ahoj all!

The upload command:

$ bin/88-dcdd --image altcpm.dsk cpmfs upload hello

it prints nothing if success.

show file content

$ bin/88-dcdd --image altcpm.dsk cpmfs cat hello 
ahoj all!

0

(I think the 0 at the end is the EOF char, or I have bug :))

pamoroso commented 2 years ago

@vbmacher This is awesome, thank you very much. I'm watching the repo and I see you're doing great work!

vbmacher commented 2 years ago

Thanks @pamoroso , you're very kind. I hope it won't be hard to support more disk formats and CP/M versions. The documentation is not really awesome, and unfortunately disk parameters are not stored in the disk itself, so it depend's on how particular CP/M was compiled...

It would be great - and this is a goal I'd like to achieve - if a user could compile a source file directly in the disk image (or upload it there with a simple click) so real CP/M programming can be done in emuStudio directly. This would involve some library file for BDOS calls.

pamoroso commented 2 years ago

I don't know whether it's useful but the file diskdefs that comes with cpmtools lists lots of disk parameters.

vbmacher commented 2 years ago

Thanks, yes I am aware if cpmtools and diskdefs, this will be definitely my inspiration :)

To list an example - eg. 88-DCDD - the Altair disk floppy drive puts some control codes around data in the sector. Like the sector is 137 bytes long (you can find it in the diskdef file). But first 3 bytes are control ones (track number, then sector number or boot file lenght depending on the track number) then goes data then another 6 bytes of control codes (stop byte and checksum). But this is not like this on most of drives, also cpmtools dont work properly with this format.

CP/M 3 or other operating systems bring in filesystem changes, like file creation/modification dates, user number per file, and even passwords :) Thats why Im hoping it won't be hard.

I'll test it one by one on some existing images. Thanks for your support!

vbmacher commented 2 years ago

@pamoroso I now consider this experimental feature as implemented. Currently, only 88-dcdd disk images are supported (*.dsk files I have mostly from simh emulator), with some (= experimental) support of other drives. The feature is accessible via command line (bin/88-dcdd --help), and in the future it might be extended.

In examples/altair8800/cpm-formats.toml you can find definition of few disk and cp/m formats. I discovered that the most correct information about particular CP/M is to read it's BIOS.ASM source code. There are usually variables defining so-called disk-parameter block and other useful information..

Also, some features like Datestamper time-stamps and CP/M Plus passwords decoding/encoding are not implemented. It's just because I don't have any disk images which I can use for playing/testing. If you know about some, I'd be grateful. Maybe there are some, but remember I'm looking for images in 88-dcdd format, not e.g. altair minidisk, or harddisk, etc.

In order to support more disk drive formats, emuStudio would need be able to emulate those, which seems to me as separate project. Few examples are:

It doesn't make sense in my opinion to implement pure read/write for any drive formats above when the emulation of such devices is unsupported.

pamoroso commented 2 years ago

This is excellent work, thank you very much. I look forward to trying the new features.