a2stuff / a2d

Disassembly of the Apple II Desktop - ProDOS GUI
https://a2desktop.com
277 stars 20 forks source link

Issues with the new 8 drives per slot feature of ProDOS8 2.5 #168

Open LuiZ-80 opened 5 years ago

LuiZ-80 commented 5 years ago

It's not actually a bug, but one issue I've run into while testing both the A2D 1.2 pre-alpha 8 (which is incredibly awesome, BTW) and the ProDOS8 2.5 alpha 7 on my Apple //e is that A2D does not play nice with the new feature of more than 2 drives per slot of ProDOS 2.5 (https://github.com/ProDOS-8). It fails rather gracefully in that it justs duplicates the first two partitions of my CFFA card (that has 4 partitions). Although it seems to recognize that partitions 7/3 and 7/4 exist and are not currently remapped to slot 4 (as in every previous version of ProDOS, including 2.4.2), it apears to get confused and mounts partitions 1 and 2 twice on the desktop. Everything else works perfectly, and I had no issues launching any of the apps on my Selector List (they're all on the 1st and 2nd partitions), I just don't have access to any partitions beyond the first two.

ProDOS 2.5 is still in alpha, so only those users on the bleeding edge of Apple II software (a rather quaint concept in 2019) are likely to run into this issue for now, and it's not like anybody should be relying on pre-release software anyway (for the record, I only tried ProDOS 2.5 by booting from a floppy, my regular configuration boots 2.4.2, the stable release, and A2D 1.2-8 works fantastically with that).

This is more of a humble 'heads up' than a feature request or a bug report, seeing as both projects are currently in development, that perhaps it would be interesting to contemplate the new ProDOS features (2.5 also introduces support for lowercase file and volume names, and removes the 51 files limit on the root directory, though I didn't run into any issues with that in my limited testing), since it's likely that both projects share the same target audience.

inexorabletash commented 5 years ago

Are there docs on the new unit number scheme?

There is a fair bit of code in A2D that assumes the top nibble of unit numbers is 3 bits for slot and one bit for drive, as in previous versions of ProDOS, and uses this to index into the 16-entry driver entry point table. So... this will probably be a lot of work to support.

JohnMBrooks commented 5 years ago

Bit layout for P8 2.5 unitnum: 76543210 DSSS00XY

Where DSSS are Drive bit 0 and Slot bits 2:0 like previous P8 versions. X is Drive bit 2 and Y is Drive bit 1.

To calc the drive # (1-8) from a P8 2.5 unitnum in Acc: ASL AND #7 ADC #1

The internal /RAM drive in slot 3, drive 2 has a unitnum of $B0 (vs $BF in 2.4).

P8 2.5 now supports up to 37 drives stored at $BF32-$BF56, with a $00 terminator at $BF57.

All 8 drives per slot use the per-slot driver handler at $BF12-$BF1F with the 'drive 2' driver unused. However the internal /RAM driver is still called through the 'slot 3, drive 2' handler at $BF26 for compatibility with apps which disconnect /RAM in order to use aux memory.

inexorabletash commented 5 years ago

Thanks. Well... that will be a lot of work. 😬

So... good to track this, but I can't imagine getting around to it. PRs welcome, of course! And I'm happy to chat with anyone to answer details about how DeskTop works internally where it's not obvious from the code. (I can suggest starter bugs, like wiring up P8 2.5 date handling #169 ...)

JohnMBrooks commented 5 years ago

Well... that will be a lot of work. 😬

I am not surprised. Copy II Plus has needed a fair amount of rework too. My thinking so far has been to fork the app code so the P8 2.5 version can expect to have extended dates, clock drivers with second/millisecond precision, 8-drives per slot, lowercase names, '../' paths, etc. Trying to support both 2.4 & 2.5 in the same app runtime would be hard/large.

Q: 1) How does A2D use drive type? 2) Why is the device table copied? Or is it just the S3D2 entry at $BF26/27 that is copied? 3) Any other changes/fixes to P8 that would help A2D?

Apps can choose to support fewer drives. 37 is just the max space available under P8 2.5.

inexorabletash commented 5 years ago

Other unit number uses:

How does A2D use drive type?

image

Why is the device table copied? Or is it just the S3D2 entry at $BF26/27 that is copied?

S3D2 is the main reason. The table is backed up, then restored on exit:

https://github.com/a2stuff/a2d/blob/master/desktop/desktop_main.s#L15550

But additionally, if creating an icon for a device fails with DEVICE_NOT_CONNECTED it is removed:

https://github.com/a2stuff/a2d/blob/master/desktop/desktop_main.s#L16174

And, for some reason, SmartPort devices mapped to Slot 2 get special treatment:

https://github.com/a2stuff/a2d/blob/master/desktop/desktop_main.s#L15692

Any other changes/fixes to P8 that would help A2D?

Open ended question...

inexorabletash commented 4 years ago

Correctly following https://prodos8.com/docs/technote/21/ would a good initial patch here - stop using the low nibble of the unit_num at all, but continue to distinguish the common drive types (Disk II, RAM, etc).

inexorabletash commented 4 years ago

Hmm, that's actually mostly done. The low nibble appears to be used only for the Disk II case which is redundantly handled later anyway.

inexorabletash commented 4 years ago

Hmm part deux: distinguishing non-$CnXX drivers will still require heuristics, e.g. RAMdisk at $FF00 and Disk II at $D000. I guess we trust the SSS bits at that point, ignore slot 3, and use firmware bytes from that point.

inexorabletash commented 2 years ago

For posterity: updating UNIT_NUM_MASK for a P8-2.5-specific build will be necessary. This is 11110000 to mask off DSSS, for a variety of reasons:

Some of these should "just work" if the mask is changed to 11110011 or 11111111, since presumably the APIs (driver, ON_LINE, DEVNUM) will consume the new form, and DEVADR lookups can just throw away the low bits.