mamedev / mame

MAME
https://www.mamedev.org/
Other
8.05k stars 2.01k forks source link

Apple IIgs floppy motor noises at inappropriate times #7852

Open ksherlock opened 3 years ago

ksherlock commented 3 years ago

using the apple2gs machine, running GS/OS, the floppy 5.25" motor sound is continuously triggered.

The Apple IIgs firmware 3.5" driver stores a 0 to DISKREG (eg, $ff/3fc0) to cancel the drive timer. That should not start up the 5.25" drive motor.

rb6502 commented 3 years ago

This only happens in the Finder in my testing. And I remember something very much like this happening on real hardware in the Finder, because it's the only way they can poll the status of 5.25 drives. @galibert and I can take a look to make sure we're not doing anything weird, but I'm fairly certain this is more a case of the sound effects being a bit aggressive as opposed to any issues with the actual drive emulation.

ksherlock commented 3 years ago

It also happens with System 6 Teach, Archiver, and Advanced Disk Utilities. Poking some more, I believe it's triggered by the HandleDiskInsert tool call (added in system 6, so rarely used.)

Scanning only occurs if flag bit 15 (hdiScan) is set. Once an insertion is detected it is either handled as described in the next section or the device number is returned directly to the application (depending on flag bit 14, hdiHandle).

  • When scanning, 5.25" devices are ignored, as are character devices.
  • Block devices with non-removable media are still scanned, since it’s important for some applications to get a “first time” insertion for those devices.
  • If 60 ticks have not elapsed since the last time HandleDiskInsert scanned devices, no scanning is performed. You can bypass this check by setting flag bit 11, hdiNoDelay.
  • HandleDiskInsert keeps an internal table recording its idea of the on-line/off-line status of each device. When a device’s status differs from the value recorded in this table, an insertion or ejection has occurred. This table is owned by the current application, not by desk accessories or other system components. At WindStartUp time, the table is initialized tos how the current status of every device.
rb6502 commented 3 years ago

The reported issue was addressed in 4171bba and some additional knock-on problems were fixed in https://github.com/mamedev/mame/commit/2e749cdd86e43bfb8435566c7ec2496a16426547 .

ksherlock commented 3 years ago

apple2gs is better but apple2gsr1 still grinds my gears.

rb6502 commented 3 years ago

On ROM 01, Finder really is flipping the motor on on the first 5.25" drive constantly. It doesn't do that on ROM 03. I have no idea what the difference is.

ksherlock commented 3 years ago

Here's a minimal 8-bit example, which makes a smartport status call for the 2nd 3.5" drive.

300: 20 0d c5 00 08 03 60 ea 03 02 0d 03 00
300G

With the ROM 1 3.5" smartport firmware (significantly changed in ROM 3), if I'm following it correctly,

$5DDC enables the motor

 FF:5DD9  LDA $c0ec                                           AD EC C0
 FF:5DDC  LDA $c0e9                                           AD E9 C0

later $5970 clears the diskreg and selects drive 0 but since the motor is still enabled, it triggers 5.25" motor sound

 FF:596E  LDY #$00                                            A0 00
 FF:5970  STY $c031                                           8C 31 C0
 FF:5973  STY $c0ea                                           8C EA C0

$F644 disables the motor soon thereafter

 FF:5644  BIT $c0e8                                           2C E8 C0
 FF:5647  stz DISKREG                                         9C 31 C0
rb6502 commented 3 years ago

Yeah, that fits my observations. Unfortunately the ROM 1 firmware also relies on the motor turning on if it's already on when they zero DISKREG. If I remove that behavior the Finder noise goes away but 5.25" disks don't boot.