whscullin / apple2js

An Apple II emulator originally written in Javascript, now being converted to TypeScript
http://www.scullinsteel.com/apple2/
MIT License
438 stars 57 forks source link

CATALOG Bug on Floppy Disk #149

Closed wyatt-wong closed 2 years ago

wyatt-wong commented 2 years ago

I use Apple 2 Emulator to boot up Apple DOS 3.3 Master Disk in Drive 1, then I insert a Blank DOS 3.3 disk in Drive 2 and initialize the disk with "INIT HELLO". After that, I type in an Applesoft BASIC program and save to Drive 2. I perform a CATALOG and it looks like this.

image

I download the disk from Drive 2 and rename the DSK as "B GREET.DSK". Then I reset the Apple 2 Emulator and this time I load up the "B GREET.DSK". After boot up, I perform a CATALOG and the disk contents look like this. All the files shown are called HELLO but I only have one HELLO and one B.GREET file in the disk.

image

whscullin commented 2 years ago

Interesting, it looks like DOS is getting corrupted when the disk is getting initialized, it looks like possibly the first few tracks are either being over or under written when being formatted. There's some logic that tries to compensate for how formatting writes out different sync byte patterns for inner vs outer tracks that I should reinvestigate, I guess.

wyatt-wong commented 2 years ago

Interesting, it looks like DOS is getting corrupted when the disk is getting initialized, it looks like possibly the first few tracks are either being over or under written when being formatted. There's some logic that tries to compensate for how formatting writes out different sync byte patterns for inner vs outer tracks that I should reinvestigate, I guess.

When the "B GREET.DSK" is loaded in Drive 2, the CATALOG works properly.

whscullin commented 2 years ago

When I factored out finding a sector from reading a sector, I introduced a bug reading sectors that crossed the track "seam". These don't normally exist for tracks created from images, but when you INIT a disk, it can happen.

Fixed by https://github.com/whscullin/apple2js/commit/fec0e1446508fe1399b99e0701fc6db21344c35f

whscullin commented 2 years ago

Great find, btw.

wyatt-wong commented 2 years ago

Is the CATALOG bug fixed ?