davidgiven / cpm65

CP/M for the 6502
BSD 2-Clause "Simplified" License
264 stars 24 forks source link

Multiple drive support #113

Open venomix666 opened 7 months ago

venomix666 commented 7 months ago

I have been experimenting with a BIOS for my homebrew computer with two drives (which in this case are two different cmpfs-files on a USB-drive), and it kind of works but I get som strange results:

Is support for multiple drives fully implemented or am I trying to do something which is not supposed to work at this point?

davidgiven commented 7 months ago

I have no devices which support this so it's never been tested.

The warmboot crash sounds suspiciously like it's trying to read the boot files from the wrong track. I bet there are several places which are failing to reselect the appropriate disk before doing an access.

venomix666 commented 7 months ago

Yes, this is likely what happens. I had a look at the BDOS code and it seems like it is assumed in entry_RESET that internal_LOGINDRIVE will select drive A: if the A register is 0, but select_active_drive is called without storing the A register to active_drive first.

I will try to store A to active_drive before the call to select_active_drive and see if that fixes the crash.

venomix666 commented 6 months ago

It works a lot better now - no more crashes at warmboot and changing drives at least changes the letter in the prompt. It still seems like the CCP always assumes that A: is the default drive though:

I have been digging a bit in both the CCP and the BDOS without finding any obvious cause for this, but perhaps the FCB is set up with A as the drive when no drive is specified?

venomix666 commented 6 months ago

I looked a bit more now and I think that the current_drive variable in the BDOS is never set to the active drive number, it is just initialized to 0 and then never updated.

This would cause bdos_GETDRIVE to always return 0 which would explain why A is always assumed to be the active drive.

venomix666 commented 6 months ago

The fix in the pull request I submitted solves the issue with A always being assumed as the active drive.

It does however introduce a behavior which I am not sure if it is expected or not - if an application accesses the second drive and does not change the active drive back before exiting, CCP will now be on the second drive. Example: A>dinfo B: (...output from dinfo...) B>

I added a small update to the CCP to the pull request to fix this, as I assume it is not the expected behavior.

The issue with only one file being detected on the first access of the second disk is still present. It is not only with DIR, the first access to the second drive after boot always finds only the first file on on the disk.

davidgiven commented 6 months ago

Thank you for the investigation! I've commented on the PR.