Skip to content

Conversation

@Domppari
Copy link
Contributor

@Domppari Domppari commented Sep 14, 2025

Summary

Floppy disk sound emulation prototype for review. Emulates 3.5" 300RPM 1,44MB FDD and 5.25 300 RPM 1.2MB spindle motor sound, spin-up, spin-down and spinning. Emulates single seek sounds during disk read/write and multitrack seek. Supports concurrent sound emulation for all active FDDs.

Fixes issue with FDC where, when seeking, the drive status was immediately released from "busy" state, which caused BIOS to fire next commands for the drive, even when the seek was not done. The fix can be observed in POST FDD test, as it will take longer for testing drives than before (if enabled in BIOS). This is a fix for FDC emulation and not purely related to the FDD sound emulation. This fix isn't disabled by the -DDISABLE_FDD_AUDIO flag (mentioned later).

Added checkbox to enable Floppy disk drive sounds for all drives in floppy disk settings, and loading and saving for the selection. This is a shared setting for all drives and is not drive specific.

Feature is on by default in the cmake build, but can be disabled with flag -DDISABLE_FDD_AUDIO, which will disable the feature code and hide the selection from UI settings.

Notes:

  • Some simple audio mixing is done in the fdd_audio.c but the basic function is to add audio samples for playback and then similar audio thread that cd audio uses will callback the sampled data. Should not be too taxing for the CPU, as it is mostly just data transferring for the audio buffers.
  • Emulation assumes currently maximum track seek length to be 80 tracks, this is incorrect and over 80 track seeks only plays 80 tracks of seek sound sample.
  • Sound emulation samples are 48kHz, 16bit mono PCM WAVE-samples and will be send to audio system without any resampling to different sample rate. If the audio system uses different playback sampling rate, this should be fixed to do resampling, or edit separate samples for different sample rates.
  • Tested only on mingw64 Windows build.
  • Sound emulation currently detects only 3.5" and 5.25" drives for emulating,.

Known Issues:

  • If floppy disk sound emulation setting is changed when VM is running, restart does not recognize the setting changes. The VM needs to be shutdown and cold started.

Checklist

  • I have discussed this with core contributors already
  • Pull request comes with required audio samples currently in the same directory with the 86box executable

References

Used sound samples have been editor from http://shiru.untergrund.net/files/flopster.zip
Original samples can edited and used separately from the Flopster VSTi under the
Creative Commons Attribution (CC-BY) license terms.

Toni Riikonen and others added 26 commits September 6, 2025 17:35
Updated README to reflect the new project name and added details about the Immersive86Box features and future plans.
Added instructions for audio emulation installation.
…e operation and when it's finished at call fdc to set the appropriate fdc flags.

Also added time logic to fdd to calculate seek duration and a callback function for it.
DISABLE_FDD_AUDIO definition added, to disable the feature via cmake/build.
@Domppari Domppari marked this pull request as ready for review September 14, 2025 07:40
@OBattler
Copy link
Member

OBattler commented Sep 14, 2025

Emulation assumes currently maximum track seek length to be 80 tracks, this is incorrect and over 80 track seeks only plays 80 tracks of seek sound sample.

That's corroborated by the FDC datasheets - any seek beyond 80 tracks needs a second seek.

Also, you added a seek complete interrupt but that's wrong - seeks do NOT interrupts, that's why the SENSE INTERRUPT STATUS command exists.

Edit: I may be wrong about the 80 tracks (one byte would indicate up to 255 tracks, though the PC87306 supports an extended mode with up to 4095 tracks), though that's for seek, recalibrate is limited though, to 77 or 80, depending on the controller.

@Domppari
Copy link
Contributor Author

PCJr required longer seek-times. All systems working correctly now.

Domppari and others added 3 commits September 19, 2025 23:24
…even_when_it_gets_no_more_accesses

Fixed second drive motor keeps running when first drive is only accessed
@Domppari
Copy link
Contributor Author

Fixed the second FDD motor kept running, when only first drive was accessed.

PCJr still has odd timing issues. Usually it works fine, but sometimes at failes to load disk. I need to tweak the timings more for it.

@OBattler
Copy link
Member

The motor always runs when the relevant motor ON bit in the DOR register is enabled, at least from what I understand.

@OBattler
Copy link
Member

This is from the Winbond W83877TF datasheet:
imagem

@OBattler
Copy link
Member

And as I said, Microsoft DMFWRITE.EXE actually relies on that - it turns on both drives' motors at the same time and then switches between them.

@Domppari
Copy link
Contributor Author

Domppari commented Sep 20, 2025

I'm not sure if you understand the problem here correctly. Each drive's motor can run separately and individually and can be commanded to do so, as stated by the documentation provided. The issue here is that, when I access drive B: and it starts the motor, then I access the drive A: before the drive B: motor is commanded off, the A: motor starts. At this point both drive's motors are running. If I then keep accessing ONLY the drive A: like for 1 minute, the drive A: motor keeps spinning for that minute, but so keeps drive B: motor. That is incorrect. This is what is fixed now. The problem could be observed in BIOS POST test routine, which caused incorrect spinning behavior in vanillla 86box implementation when using two drives. Also this could be observed in DOS, by accessing drive B: then back to drive a: and then just pressing enter on drive a: prompt would keep drive A: motor running, but it did also keep B: drive motor running.

Without audio cues, you wouldn't notice this at all, unless you'd look in the FDD/FDC logs very closely. It did not affect the technical behavior of the drive but was apparently wrong when sound was added.

Of course, could be that I'm missing the point here.

@OBattler
Copy link
Member

I just looed at the code changes and... the new DOR behavior seems to be basically the same as before, except for the indexes, and the motor not being disabled if it was already disabled before.

@Domppari
Copy link
Contributor Author

Domppari commented Sep 20, 2025

I think the issue was with drive swapping. We were using wrong index at some situations, which would leave some drive motor bit as not cleared.

This or that, based on my tests it functions as expected and the drive motor shutdowns work correctly when there is no accessing the drive for a second or two - this is controlled by the BIOS, the drive index was incorrectly used / determined.

@Domppari
Copy link
Contributor Author

I just looed at the code changes and... the new DOR behavior seems to be basically the same as before, except for the indexes, and the motor not being disabled if it was already disabled before.

My bad. Don't know what happened before, but both drives still seem to spin during boot, even when B-drive is not accessed during that time.

@OBattler
Copy link
Member

I suspect that this behavior varies from BIOS to BIOS - some switch drive motors on and off when probing different drives, some have them all spinning at the same time.

@jriwanek
Copy link
Member

@Domppari So, for my notes, what's left to be done before this is ready for merger?

@Domppari
Copy link
Contributor Author

I'll add TeacFD 5.25" drive sound samples. Make UI changes to FDD settings, so that you can select what sounds do you want for each drive separately. The selection would include three drives: Generic Mitsumi 3.5" 1.44MB drive, Panasonic 5.25" 1.2MB drive and Teac 5.25" 1.2MB drive. Some small timing tweaking still do be done and additional system testing.

I'll tell you when I think it's ready for merge from my side.

@Domppari
Copy link
Contributor Author

Teac 5.25" drive samples added and implemented drive specific audio selection to FDD settings. Changed the audio sample path to look into roms/samples/fdd instead of '/samples' and root folder.

So for me, the PR is ready to merge at your will. But the samples should be moved to the roms repository and removed from 86box source - if that's ok. Should be do it now, or?

@jriwanek
Copy link
Member

Better now than later imo

@OBattler
Copy link
Member

CodeQL found a problem here: #6166 (comment) .

@OBattler
Copy link
Member

I tried this but I can't hear the sounds - how do I enable them?

@OBattler OBattler merged commit 1859e7c into 86Box:master Sep 21, 2025
47 checks passed
@Domppari
Copy link
Contributor Author

I tried this but I can't hear the sounds - how do I enable them?

Copy samples to roms/samples/fdd folder and set audio for drive in the fdd settings.

@Domppari Domppari deleted the feature/fdd_sound_emulation_proto branch September 22, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants