News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Differentiating between CPC, PCW and ZX DSK images

Started by zzarko, 14:36, 24 November 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zzarko

Hi all,

I am trying to make a (Python) code that could detect for which machine is DSK file intended for. For PCW, I search the whole image for one of names for BIOS files (J11CPM3, J12CPM3 and so on), and alternatively for text "COM" followed by 3 zeroes at the offset whose HEX address ends with digit "9" (thus searching for directory entry with COM extension). This gives a good result, except false negatives for for DSK images of games that do not use CP/M, but I can add those as exceptions, there is not many (and luckily there are no false positives so far).

I would for now ignore the fact that there is software for CPC and ZX that runs on CP/M (and thus have COM files). Does someone knows a way to distinguish between ZX+3 and CPC DSK files? How would you manually do that, if there is a way at all except trying the image in CPC and ZX emulator?

Of course, one obvious way is to just put all ZX DSK files in one directory, and CPC in another one, but I am not trying to do that.
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

pelrun

CPC disk images are trivial to unambiguously identify. They all start with either "MV - CPCEMU Disk-File" or "EXTENDED CPC DSK File".

Edit: oh blah, the other systems are using the CPC image format too, are they? You'll likely have to look at the sector ID's to identify the kind of format that's used and then guess as to the intended system.

https://www.cpcwiki.eu/index.php/Format:DSK_disk_image_file_format

pelrun

Have a look at the code for DiskImageManager, since it claims to do this identification: https://github.com/damieng/DiskImageManager

zzarko

Yes, all 3 systems use 3" disks and all 3 use the same DSK format for those (or at least that is what I have found so far). So, I am using "MV - CPC" and "EXTENDED" to differentiate Amstrad (CPC/PCW/ZX) DSK files from others (i.e. MSX). I will take a look at DiskImageManager, thanks!
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

Prodatron

Quote from: zzarko on 16:26, 24 November 24Yes, all 3 systems use 3" disks and all 3 use the same DSK format for those (or at least that is what I have found so far). So, I am using "MV - CPC" and "EXTENDED" to differentiate Amstrad (CPC/PCW/ZX) DSK files from others (i.e. MSX). I will take a look at DiskImageManager, thanks!
Systems like the MSX use plain sector dumps without any additional information, but they have the same file extension (DSK).

The DSK format created by Marco Vieth in the early/mid 90ies for his first CPC Emulator (CPCEMU) includes all the special features of the FDC765.

CPC standard discs always have sector offsets #40 (CP/M "system", 2 reserved tracks) or #c0 (CP/M "data", 0 reserved tracks).
PCW discs always have sector offsets of #00 (CP/M PCW, 1 reserved track).

I checked some Spectrum 3 disc images and it seems, that both #00 and #c0 are possible? (I am not experienced in the classic spectrums)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

andycadley

Quote from: Prodatron on 22:18, 24 November 24I checked some Spectrum 3 disc images and it seems, that both #00 and #c0 are possible? (I am not experienced in the classic spectrums)

Plus3DOS came after both AMSDOS and PCW DOS and can natively read all the different disk formats. About the only reliable way would be to look for files with a Plus3DOS header and even that might fail with bootable disks, which don't have to have anything besides a boot sector IIRC.

zzarko

Thank you all for suggestions, analyzing how DiskImageManager format analysis works was really helpful. Here are my current results (heuristics based on my previously existing code, additions of logic from DiskImageManager and additional analysis of DSK files that were wrongly recognized by combining previous two approaches):

CPC DSKs: 533
Recognized: 525
Unrecognized: 5
Wrongly recognized as PCW: 3

PCW DSKs: 332
Recognized: 316
Unrecognized: 3
Wrongly recognized as ZX: 3
Wrongly recognized as CPC System: 2
Wrongly recognized as CPC Data: 8 (all these are B sides of various games)

ZX DSKs: 205
Recognized: 172
Unrecognized: 0
Wrongly recognized as PCW: 4
Wrongly recognized as CPC System: 6
Wrongly recognized as CPC Data: 23

The results may be biased based on a collection of DSK files that I have, but I am overall satisfied with high percentage of correctly recognized DSK files and low percentage of false positives (except for ZX).
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

Prodatron

Good results!
Why were some CPC DSKs recognized as PCW? Did they have sector offsets #00?
The same for the other direction: Did some PCW discs have offsets #40/#c0?

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

robcfg

Are there any 'mixed' CPC/PCW disks, or just plain CP/M ones that can be used on both?

McArti0

CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
One chip drver for 512kB extRAM 6128
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

andycadley

Quote from: robcfg on 11:25, 04 December 24Are there any 'mixed' CPC/PCW disks, or just plain CP/M ones that can be used on both?
I believe all three machines could use an AMSDOS formatted disk, you'd obviously have to have different executables to run for each (I don't think having them autoboot is possible) and then shared data files, so a CPC/+3/PCW disk is at least theoretically possible.

Not sure if anyone ever made one, though.


Nich

Quote from: andycadley on 18:02, 04 December 24I believe all three machines could use an AMSDOS formatted disk, you'd obviously have to have different executables to run for each (I don't think having them autoboot is possible) and then shared data files, so a CPC/+3/PCW disk is at least theoretically possible.

Not sure if anyone ever made one, though.
Some of Level 9's later adventures, such as Gnome Ranger, Lancelot and Scapeghost, could run on the CPC, the PCW, and the +3, all from the same disc. The discs typically had gold stickers with the text, "TRIPLE-FORMAT DISC - This game disc really does work on the Amstrad CPC, PCW and the Spectrum +3".

zzarko

For PCW, I mostly have problems with games that do not have bootblock, but are expected to be run from machine already booted to CP/M. For those games I already have separate boot disks in my collection, so that in not a problem also.

While searching how to recognize boot block for a PCW (e.g. for games that do not use CP/M but boot directly to game itself), I have found this page:

https://www.chiark.greenend.org.uk/~jacobn/cpm/pcwboot.html

From there I have found that PCW has video and floppy control registers at I/O addresses F5, F6, F7 and F8. Dealing with those is usually with OUT (NN),A instruction, so next thing that I want to try is to simply count all OUT instructions in boot block code that deal with FDC and maybe video. Some initial tests show that this could be a good way to recognize PCW boot block code.
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

zzarko

Quote from: Nich on 19:11, 04 December 24Some of Level 9's later adventures, such as Gnome Ranger, Lancelot and Scapeghost, could run on the CPC, the PCW, and the +3, all from the same disc. The discs typically had gold stickers with the text, "TRIPLE-FORMAT DISC - This game disc really does work on the Amstrad CPC, PCW and the Spectrum +3".
WOW, I did know this, cool! No way I can recognize something like this automatically :)
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

zzarko

With a bit of corrections and with check mentioned above, now I have this:

CPC DSKs: 533
Recognized: 528
Unrecognized: 5

PCW DSKs: 332
Recognized: 280
Unrecognized: 1
Semi-wrongly recognized as PCW/ZX: 29 (all these are non-bootable sides of various games; DiskImageManager logic)
Wrongly recognized as CPC System: 6 (all these are non-bootable sides of various games)
Wrongly recognized as CPC Data: 16 (all these are non-bootable sides of various games)

ZX DSKs: 205
Recognized: 174
Unrecognized: 0
Wrongly recognized as PCW: 1
Wrongly recognized as CPC System: 6
Wrongly recognized as CPC Data: 24

So, I think I mostly solved PCW (at least bootable discs, which is most important to me). CPC is mostly good, and I still have to see what to do with ZX DSK images, as there I have most of errors in recognizing. That would be a story for another day, I will try to find something specific for them that I could use to increase accuracy. Thanks again to all of you that helped me with advice and links!
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

zzarko

After another almost-rewrite, I have finally put RunEmu to a repository:

RunEmu repository

If someone is interested, Amstrad DSK parsing resides inside parser_dsk.py. There is still a lot of work to be done, but that would be one step at the time...
464,664,6128,6128+,NC150,NC200,Joyce512,PPC512, PenPad, www.oncuponabyte.org

Powered by SMFPacks Menu Editor Mod