Drive Emulation Type Cleanup

From vice-emu
Jump to: navigation, search

goals:

  • have a "emulation type" option rather than seperate options for various features
    • prevent non working combinations
  • fix the Autostart logic to always work, regardless of options

files

src/attach.c ("FileSystemDeviceX"/"-device8")
src/traps.c ("VirtualDeviceX"/"-virtualdevX")
src/machine-bus.c
src/drive/drive-resources.c ("DriveXType", "DriveXTrueEmulation")
src/iecbus/iecbus.c
src/serial/serial-iec-device.c ("IECDeviceX"/"-iecdeviceX")
src/c64/c64bus.c
src/vic20/vic20bus.c
src/plus4/plus4bus.c
src/pet/petbus.c
src/cbm2/cbm2bus.c

related options

First we need to collect all related options and how they relate to each other

emulation related options

Drives

  • Virtual Device Traps ("VirtualDeviceX" = 0,1)
    • Host Filesystem ("FileSystemDeviceX" = ATTACH_DEVICE_FS)
    • Disk Images ("FileSystemDeviceX" = ATTACH_DEVICE_VIRT)
    • Real Device (opencbm) ("FileSystemDeviceX" = ATTACH_DEVICE_REAL)
  • IEC Device ("IECDeviceX" = 0,1)
    • Host Filesystem ("FileSystemDeviceX" = ATTACH_DEVICE_FS)
    • Disk Images ("FileSystemDeviceX" = ATTACH_DEVICE_VIRT)
    • Real Device (opencbm) (opencbm) ("FileSystemDeviceX" = ATTACH_DEVICE_REAL)
  • True Drive Emulation ("DriveXTrueEmulation" = 0,1)
    • Disk Images
      • Drive Type ("DriveXType")
what does "none" mean exactly?
found in attach.c:
   /*
    * FIXME: Note about ATTACH_DEVICE_FS and ATTACH_DEVICE_VIRT:
    * Attaching a disk image also uses _FS even though you would expect _VIRT.
    * The value _VIRT seems to be unused in practice.
    * One would expect _FS for the fsdevice, and _VIRT for vdrive images.
    */

"FileSystemDeviceX" = ATTACH_DEVICE_FS apparently means that we will either get "host system" or "virtual device with disk image" depending on wether an image is attached or not

when "FileSystemDeviceX" = ATTACH_DEVICE_NONE using a disk image still appears to work

Printer

  • Virtual Device ("VirtualDeviceX" = 0,1)
    • None ("PrinterX" = PRINTER_DEVICE_NONE)
    • Host Filesystem ("PrinterX" = PRINTER_DEVICE_FS)
    • Real Device (opencbm) ("PrinterX" = PRINTER_DEVICE_REAL)
  • IEC Device ("IECDeviceX" = 0,1)
    • None ("PrinterX" = PRINTER_DEVICE_NONE)
    • Host Filesystem ("PrinterX" = PRINTER_DEVICE_FS)
    • Real Device (opencbm) ("PrinterX" = PRINTER_DEVICE_REAL)

Printer #7 is kindof special, there appears no actual printer emulation attached to it, only the options exist that are required to redirect device #7 to opencbm

  • Virtual Device ("VirtualDevice7" = 0,1)
    • None ("Printer7" = PRINTER_DEVICE_NONE)
    • Real Device (opencbm) ("Printer7" = PRINTER_DEVICE_REAL)
  • IEC Device ("IECDevice7" = 0,1)
    • None ("Printer7" = PRINTER_DEVICE_NONE)
    • Real Device (opencbm) ("Printer7" = PRINTER_DEVICE_REAL)

Tape

Tape Emulation generally requires neither Traps nor IEC bus things. The exception is .t64 support, which is implemented via device traps, and requires "VirtualDevice1" = 1

other options

  • handle TDE at autostart
  • warpmode
  • Host Filesystem
    • use long filenames
    • create P00 files
    • only show P00 files

odd stuff

  • for the PET and CBM2, the "VirtualDevices" resource is not related to ROM traps, but to "IEC devices"? wth? (see traps.c)
  • for xcbm2 and xcbm5x0 the TAPE device traps (nor the DISK device traps) are not implemented
also tape in general only works in the first (old) kernal+basic, it was removed later

remaining bugs

  • on xplus4 - only when using 1551 - when a .prg is autostarted with only TDE on and "handle tde at autostart", the prg starts as expected via traps, but then the drive is not working afterwards.
  • it looks like "IECDrive" and "Device Traps" somehow collide with each other, when both are enabled random errors in the transmitted data occur
  • xpet/xcbm2/xcbm5x0 with -drive8type 0 -device8 1 -drive8truedrive +virtualdev8 -autostartprgmode 0 +autostart-handle-tde NO drive is detected. this seems correct (fix the testscript?)
  • xpet with -drive8type 8250 or 0 -device8 1 +drive8truedrive +virtualdev1 when autostarting t64 detects vfs
  • xpet with -drive8type 0 -device8 1 _drive8truedrive +virtualdev1 when autostarting t64 detects tde

not bugs

  • it looks like "IECDrive" does generally not work with vic20
-> it does not use src/iecbus/iecbus.c, see https://sourceforge.net/p/vice-emu/bugs/1501/
  • xpet and xcbm2/xcbm5x0 systematically fail when both TDE and virtual device is disabled - this is probabably fine since it has no IECDrive
  • in xpet and xcbm2/xcbm5x0 the default drive should perhaps be 8250 instead. for some reason 2040 causes problems

Precedence

iecbus.c contains this table:

iecbus_status_set() sets IEC bus devices according to the following table:

     TDE ID VD DE                                       iecbus_device
none 0  0  0  0  nothing enabled                       IECBUS_DEVICE_NONE
     0  0  0  1  nothing enabled                       IECBUS_DEVICE_NONE
VD   0  0  1  0  trap device enabled                   IECBUS_DEVICE_NONE
VD   0  0  1  1  trap device enabled                   IECBUS_DEVICE_NONE
IEC  0  1  0  0  IEC device enabled                    IECBUS_DEVICE_IECDEVICE
IEC  0  1  0  1  IEC device enabled                    IECBUS_DEVICE_IECDEVICE
     0  1  1  0  IEC device enabled+trap dev. enabled  IECBUS_DEVICE_IECDEVICE
     0  1  1  1  IEC device enabled+trap dev. enabled  IECBUS_DEVICE_IECDEVICE
     --------------------------------------------------------------------------
     1  0  0  0  nothing enabled                       IECBUS_DEVICE_NONE
TDE  1  0  0  1  TDE drive enabled                     IECBUS_DEVICE_TRUEDRIVE
     1  0  1  0  nothing enabled                       IECBUS_DEVICE_NONE
     1  0  1  1  TDE drive enabled                     IECBUS_DEVICE_TRUEDRIVE
     1  1  0  0  IEC device enabled                    IECBUS_DEVICE_IECDEVICE
     1  1  0  1  IEC device enabled                    IECBUS_DEVICE_IECDEVICE
     1  1  1  0  IEC device enabled                    IECBUS_DEVICE_IECDEVICE
     1  1  1  1  IEC device enabled                    IECBUS_DEVICE_IECDEVICE

TDE = true drive emulation ("DriveXTrueEmulation")
ID = IEC devices ("IECDriveX")
VD = virtual devices ("VirtualDeviceX")
DE = device enable ("DriveXType")

conclusion

The following is a proposal on how the UI could look like to be less confusing.

THIS IS WORK IN PROGRESS - CURRENT UI CHANGES WILL USE THE EXISTING SWITCHES/OPTIONS PER DRIVE and it should stay this way for a while, until we worked out everything and debugged/tested all cases.

Drives

For Drives, the UI should have a Dropdown box or Radio Button group to select the emulation mode:

  • None ("VirtualDeviceX" = 0, "IECDeviceX" = 0, "DriveXTrueEmulation" = 0)
  • Virtual Device Traps ("VirtualDeviceX" = 1, "IECDeviceX" = 0, "DriveXTrueEmulation" = 0)
  • IEC Device ("IECDeviceX" = 1, "VirtualDeviceX" = 0, "DriveXTrueEmulation" = 0)
  • True Drive Emulation ("DriveXTrueEmulation" = 1, "VirtualDeviceX" = 0, "IECDeviceX" = 0)

only when the above is not "none" it should enable another Dropdown box or Radio Button group to select the device type that is emulated:

  • Host Filesystem ("FileSystemDeviceX" = ATTACH_DEVICE_FS, "DriveXType = DRIVE_TYPE_NONE")
  • Disk Images ("FileSystemDeviceX" = ATTACH_DEVICE_VIRT, "DriveXType != DRIVE_TYPE_NONE")
  • Real Device (opencbm) (opencbm) ("FileSystemDeviceX" = ATTACH_DEVICE_REAL)

FIXME: find out if we really need to set "DriveXType = DRIVE_TYPE_NONE", it would be more intuitive if we leave it alone.

when "True Drive Emulation" is enabled, the device type selection should be "greyed out"

when "True Drive Emulation" is NOT enabled, the drive type selection should be "greyed out"

Kludges

  • in xvic "IEC Device" does not work (yet) - so the respective options should be removed (greyed out)

Printers

For Printers, the UI should have a Dropdown box or Radio Button group to select the emulation mode:

  • None ("PrinterX" = PRINTER_DEVICE_NONE, "VirtualDeviceX" = 0, "IECDeviceX" = 0)
  • Virtual Device ("VirtualDeviceX" = 1, "IECDeviceX" = 0)
  • IEC Device ("IECDeviceX" = 1, "VirtualDeviceX" = 0)

only when "PrinterX" is not PRINTER_DEVICE_NONE it should enable another Dropdown box or Radio Button group to select the device type that is emulated:

FIXME: find out if we really need to set "PrinterX = PRINTER_DEVICE_NONE", it would be more intuitive if we leave it alone.

  • Host Filesystem ("PrinterX" = PRINTER_DEVICE_FS)
  • Real Device (opencbm) ("PrinterX" = PRINTER_DEVICE_REAL)

for Device #7, the second selection should "grey out" the "Host Filesystem" item (Printer #7 only exists so you can redirect it to opencbm)

Tape

no UI changes required, the only option is "VirtualDevice1" = 0,1