Supported disk image formats and detection logic.
Disclaimer: this is absolutely useless and I am doing all of this due to the excessive amount of free time I had during the long weekend
I am not quite good at reading VHDL/Verilog so I'd appreciate any help here. Could someone point me to the code handling various disk images, please? Is it done in the core or in the main MiSTer programme? Specifically, I am wondering how IMG and MGT detected as they have no any kind of magic bytes.
Here is the full story. I was playing with different Plus D configurations and found a curious thing. Knowing how boot.rom is configured, I decided to try BetaDOS and Uni-DOS. BetaDOS worked as expected (yeah, I can see those familiar with BetaDOS chuckling here), but with Uni-DOS I stumbled on a weird issue. No matter what I did I was getting "Sector Missing" error. For G+DOS and BetaDOS I was using MGT images built with FUSE. However I had downloaded Uni-Dos.img, which was an IMG file. And down the rabbit hole I went, exploring IMG, MGT, (E)DSK and TRD image formats. Even wrote my own converter from MGT to IMG because I could not find one.
Both G+DOS and BetaDOS were working fine with both IMG and MGT images. Any combination works, e.g. I can boot G+DOS/BetaDOS from and MGT image, mount an IMG and successfully launch an app. However, a few evenings later, when I was desperately trying all permutations of ROMs and disk image formats, I found a combination which sort of enabled Uni-DOS boot. And I do not understand how it works. So Uni-DOS boots ONLY if I use CPC ESDK format. IMG or MGT, known to work as "tested with FUSE", they do not work with Uni-DOS ROM. But if I use Uni-DOS as an image with (E)DSK format, it boots and at least it reads the root catalogue. It still fails to run programmes accessing disk via the (BASIC) API or using subdirectories, though. My guess is that Spectrum core somehow "misunderstands" that specific image format (because of the Uni-DOS directory structure?) and applies different sector/track reading logic.
Hence, the question: how does the image format detection work? Does it actually try reading G+DOS filesystem (and, thus, incompatible with any other filesystems)?