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

Device-based removable media replacement problem #45

Closed
Eugeny1 opened this issue Apr 7, 2020 · 4 comments
Closed

Device-based removable media replacement problem #45

Eugeny1 opened this issue Apr 7, 2020 · 4 comments
Assignees
Labels
bug Something isn't working fixplemented This bug has already been fixed/this feature has already been implemented in a released version

Comments

@Eugeny1
Copy link

Eugeny1 commented Apr 7, 2020

I am developing device-based driver for floppies. Performing DIR in DOS2 after diskette replacement lists directory properly, but if I go to Nextor disk-BASIC and perform FILES in there, I see part of previous disk's directory just after floppy disk is replaced. Second time I perform FILES it may give better results (more files listed from new media), and if performing FILES 3rd time directory listing from new media seems to be correct.
Driver reports disk change properly (it performs diagnostic output to the screen).
I am afraid that on first FILES run after disk replacement I do not see required sectors being read to display new media properly.
I report 0 sectors for floppies in LUN_INFO (expecting kernel to read boot sector when needed to find out media geometry). When reading changed disk, kernel reads boot sector at least 3 times (why does it do this as it must be enough to read it once...)
Same problem happens with 720k and 1.44 disks. Tried kernel in openMSX with drive-based disk-basic 1.0 and FILES seems to work properly after virtual diskette change.

@Eugeny1
Copy link
Author

Eugeny1 commented Apr 8, 2020

Update: after I change 720k floppy with 1.44M floppy, then following actions are performed by FILES:

  • boot sector is read 7 times
  • sector 0x07 (directory location for 720k floppy) is read.

FILES displayed garbage, because new diskette is 1.44M and has directory at sector 0x13.

Next time FILES is invoked, without changing the disk, it performs the following action:

  • only one sector is read, 0x13, which is a correct location for 1.44M diskette.

FILES displays proper directory listing.

Seems that kernel updates DPB after reading the sector of location of the directory for previous diskette format. This problem will never be noticed in 720k-diskette-only environment, as its directory sector is always located at sector 7 (in standard format). As I said before DIR in DOS2 always lists directory properly, thus issue is in algorithm of FILES execution.

@Eugeny1
Copy link
Author

Eugeny1 commented Jul 6, 2020

Further investigation shows that kernel seems being losing disk change flag after if performs first call to DEV_STAT. The interesting thing is that it does not happen all the times. Sometimes DEV_STAT returning A=2 is followed by the boot sector and other sectors' read, and causing correct FILES output, but most of the times kernel does not call DEV_RW, calling DEV_STAT several times, and of course on second and all further calls DEV_STAT returns 1 (not changed).

@Eugeny1
Copy link
Author

Eugeny1 commented Jul 6, 2020

Here's the test kernel for you. It uses two disk images: first is Nextor DOS2 one of 720k size (so that kernel boots into DOS2 mode), and second is DOS1 360k size. Disk switching is performed by putting zero (first image) or non-zero (second image) value into FFFD using POKE&HFFFD,x. Put breakpoints to the kernel JP addresses, and perform switching images using POKE and doing FILES afterwards seeing what routines are being invoked. I see that most of the times DEV_STAT loses A=2 at its first call after issuing FILES (it must actually lose 0ffh in B as you translate A=2 -> B=FF and then flags NZ/NC), and of course displays wrong contents afterwards.
I have changed bootable file names in the images, thus do not think these are corrupt outputs, these are correct names so that kernel does not try to boot without proper file content (images do only contains boot, FAT and directory, no file contents).

issue-45

The problem is here at address 348F at kernel page 0: you operate bit 5 at (ix+05), current value is 035h. If it is in this value, kernel skips all further reading. However if I manually reset the value to 015h (resetting bit 5) then kernel performs correctly, reading structures of the diskette and displaying proper directory listing.

What is this flag for, and why it is set wrongly?

@Konamiman Konamiman added bug Something isn't working due in next version This will be fixed/implemented in the next version labels Jul 11, 2020
@Konamiman Konamiman self-assigned this Jul 11, 2020
Konamiman added a commit that referenced this issue Jul 26, 2020
- Fix: broken RAM disk (introduced in RC1).
- Fix: disk errors for old MSX-DOS 1 file functions in BASIC crash the computer (#59).
- Add: new flag returned by LUN_INFO allows to instruct Nextor to ignore devices when searching devices for automatic device to drive mapping (#54).
- Fix: files can't have 3 or 4 in their names in DOS 1 mode (#55).
- Fix: after booting directly yo BASIC by pressing 3, CALL SYSTEM doesn't work.
- Fix: slot disable keys don't work on real MSX computers (#49).
- Add: new boot key, pressing N at boot time disables all the Nextor kernels present.
- Add: default DPB gets a fixed address of 7BAAh in banks 0 and 3, so it can be customized reliably.
- Add: PROMPT routine made available to drivers at address 41E8h (#42).
- Fix: the DOS 1 variables "data buffer changed" and "redirect console output to printer" were not zeroed when switching to DOS 1 mode at boot time.
- Fix: can't change volume name when there are long filename entries in the root directory (#57).
- Fix: absolute sector read/write functions not working properly when a file is mounted to a drive (#43).
- Fix: bad sector buffer management when writing to a mounted file causing data corruption on the mounted file (#58).
- Fix: drive parameters not updated on first access to a drive after a media change if the driver provides drive mapping via DRV_CONFIG, causing bad data read (#45).
@Konamiman Konamiman added fixplemented This bug has already been fixed/this feature has already been implemented in a released version and removed due in next version This will be fixed/implemented in the next version labels Aug 1, 2020
@Konamiman
Copy link
Owner

Fixed in v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixplemented This bug has already been fixed/this feature has already been implemented in a released version
Projects
None yet
Development

No branches or pull requests

2 participants