User:Rhialto

From vice-emu
Revision as of 22:49, 16 August 2019 by Rhialto (talk | contribs)
Jump to navigation Jump to search

Stub page to show I exist.

Improving dual disk drive handling

Currently, dual disk drives live a strange half / double life. Drive 1 of unit 8 (using the terminology of Basic 4 and fortunately also mostly of the code) is using most of the data structures that would otherwise be used by device 9. So if you want 2 dual drives, they will have device numbers 8 and 10.

This madness is clearly visible in source file src/drive/ieee/fdc.c.

There are 4 fdc_t structures, each of which corresponds to a drive. (Despite the name that suggests floppy disk controller). When using unit 9 or 11, or num_drives is 2, weird stuff happens in functions like fdc_reset().

My proposal here is to change all functions here that take a unit number (in particular those that also do something with a disk_image_t), and change them to take a drive number too.. static fdc_t fdc[NUM_FDC]; will become static fdc_t fdc[NUM_FDC][2]; and the drive number will be the second index.

This change will flow outwards like an oil spill, since many functions are used via pointers and need to have the same signature...

For dual drives, there must be some code to reset both drives, if the unit is reset, for instance. I'm not sure where such things currently happen, but it may need to be moved.

Other weird things: - struct drive_context_s refers to struct drive_s which refers to a struct disk_image_s, but fdc also refers to such a thing, and so does (for 2 types of disk controllers) context->wd1770->fdd->image, and context->pc4877->fdds[0]->fdd->image and context->pc4877->fdd->image and context->pc4877->current->fdd->image - but there is no context->fdc.