Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing internal drive after un-mounting D64 image causes errors #198

Closed
johnwayner opened this issue Feb 15, 2025 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@johnwayner
Copy link

Test Environment (required)

Describe the bug
When switching back to the internal drive after having mounted a D64 image, DIR returns an "ILLEGAL TRACK OR SECTOR" error.

To Reproduce
Steps to reproduce the behavior:

  1. MOUNT <D64 image>
  2. DIR that image (important as DOS initializes things at this point)
  3. MOUNT (use internal drive with formatted disk)
  4. DIR this shows the error:
    66, ILLEGAL TRACK OR SECTOR,62,63

Expected behavior
The directory of the disk inserted in the internal drive should be shown.

Additional context
The Freezer's internal disk mount doesn't have this issue (while using HICKUP.M65 that includes $D084 -- the last track accessed). This is curious as MOUNT tries to mimic Freezer's behavior when switching to the internal drive.

I noticed that set_dimag isn't using $D68B's flags that indicate if a disk image is mounted. It only uses $D68A's flags that indicate if the mounted drive is D64 or D81. The $D68A flags don't seem to be valid if an image isn't mounted. Just fixing that isn't enough, however. I was thinking that set_dimag should also force a disk change flag if an image is mounted or its type changes (i.e. dimag changes). That should cause DOS to recalculate certain things about the disk.

However, since the Freezer works, perhaps there is a simpler solution.

I do wonder if we'll keep dancing around these types of issues and, in the end, finally bite the bullet and just re-initialize the drive when MOUNT is called (using UI drive command). The Freezer would not be able to do that directly though.

@johnwayner johnwayner added the new New report, not classified yet label Feb 15, 2025
@dansanderson
Copy link
Collaborator

Maybe re-initializing the drive should be hyppo_attach's job. @lydon42 any thoughts?

@dansanderson dansanderson added bug Something isn't working and removed new New report, not classified yet labels Feb 16, 2025
@dansanderson
Copy link
Collaborator

(MOUNT will use hyppo_attach in a future version: #197 )

@johnwayner
Copy link
Author

Using hyppo_attach won't reset the internal DOS state unless it's updating the disk change flag. That flag ($D083.0), which doesn't currently as far as I know, is probably the key to helping DOS know when to reset the state for a drive.

In https://github.com/MEGA65/mega65-rom/pull/81 I'm simulating that flag getting set when the mounted image type changes or an image is mounted/unmount (using flags in $D68A and $D68B). This seems to sufficiently simulate a working disk change flag for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants