User:Rhialto: Difference between revisions

From vice-emu
Jump to navigation Jump to search
No edit summary
No edit summary
Line 22: Line 22:
* Most of the things in ''drive_t'' (''drive_context'' points to one) are indeed per-drive, but some also belong to the unit (such as ''parallel_cable'', ''drive_ram2_enabled'', ''rom'' and some more.
* Most of the things in ''drive_t'' (''drive_context'' points to one) are indeed per-drive, but some also belong to the unit (such as ''parallel_cable'', ''drive_ram2_enabled'', ''rom'' and some more.
* Maybe ''drive_context_s'' should be renamed to ''unit_context_s'', with pointers to 2 ''drive_t''s, and some items moved from ''drive_t'' to ''unit_context''.
* Maybe ''drive_context_s'' should be renamed to ''unit_context_s'', with pointers to 2 ''drive_t''s, and some items moved from ''drive_t'' to ''unit_context''.
* But there are so many uses of ''drive'' to mean the unit / device, maybe drive in the other meaning should be renamed. But what would be a good name???

Revision as of 23:12, 16 August 2019

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. The fdc structs are accessed by number which is probably picked up from context->mynumber.
  • Should there be 2 drive_contexts for dual drives, or just one which refers to 2 disk_image_s? If there should be 2, then where are these aggregated? (drive_context_s seems to be more a unit context, or drive as in device)
  • Most of the things in drive_t (drive_context points to one) are indeed per-drive, but some also belong to the unit (such as parallel_cable, drive_ram2_enabled, rom and some more.
  • Maybe drive_context_s should be renamed to unit_context_s, with pointers to 2 drive_ts, and some items moved from drive_t to unit_context.
  • But there are so many uses of drive to mean the unit / device, maybe drive in the other meaning should be renamed. But what would be a good name???