It's been almost 9 years since Geoffrey Brown kindly contributed BII code for limited bin/cue support
(partly inspired by the excellent DosBox team's bin/cue reader
). Sadly, the feature never made it into standard builds of either BasiliskII or SheepShaver. I suppose this was due to a number of restrictions: audio output must match CD quality to play, Core Audio in Mac OS X led to a second output device for Mac OS to mix with the emulator output, and a reliance on Posix functions for reading the BIN files. Regardless, with so much of the logic in place and the lack of bin/cue files remaining a notable constraint on SheepShaver (e.g. inability to mount mixed-mode CDs), it seemed worth revisiting Dr. Brown's code.
I've been fiddling off and on for a while and finally made some headway this week. Originally, I focused on Core Audio. Some of the Core Audio calls have changed in the last few years, and while it now compiles, I still hear static with this approach. SDL is actually the better option for cross-compatibility, and since we're using SDL2 in both BII and SheepShaver now, I moved to SDL's new AudioStream API for reading and converting the CD audio. Not only should this remove limitations on matching sound output since SDL can convert to the appropriate format before mixing, but more importantly, CD audio works again!
The volume slider is now operational, and I tweaked the data partition reader to support redbook (MODE1/2352), yellowbook (MODE2/2352), and pure data (MODE1/2048) type discs, although I've not been able to get yellowbook discs to mount yet.
I've put a test build on GitHub for Mac OS X: https://github.com/spolsley/macemu/releases/tag/2.5_20190616
. The source code is available in the cdaudio_test branch
. Uncertain, but it will probably build on Linux with USE_SDL_AUDIO=1. The build should swap out with an existing SheepShaver setup.
To use it, add a .cue file to the volumes list as a cdrom. My testing has been pretty limited so far, so I'm curious if it works for others.
Here's the list of limitations and issues that I know so far:
- The code is still very messy; comments and unused snippets are strewn about. Also, the way it does things should be improved; it's not really best practice. For instance, the hook in audio_sdl.cpp to play CD sound checks if a CD is playing every time the audio buffer tries to refill. This wastes CPU cycles the vast majority of times. My focus has been on functionality, but I would still like to clean the code and improve performance soon.
- Using SDL will enable CD audio in Windows, but the code continues to use lseek() and read() for handling BIN files. Looks like there might be equivalencies
available in Windows, but I don't have a current setup to test that.
- BasiliskII runs and recognizes the data and audio partitions. However, I'm still hearing static when playing the audio. It sounds like the format or rate isn't matching, but I haven't been able to determine the cause or find a fix yet.
- A few driver-level features remain unimplemented for the CD player: Shuffle, Scan, and Program.
- Some games, like Descent, will play CD audio in-game, but others, like Warcraft: Orcs and Humans, will not. It depends on how the game developers handled CD audio. Warcraft tries to open the Internal CD drive as a recording device and uses playthrough to simulate output. This is problematic, because it requires extending driver support to the Sound Input Manager. A skeleton of useful code exists in audio.cpp
, but the 68k assembly for icon loading is indecipherable to me. It crashes SheepShaver and fails to build in BasiliskII.
Does anybody have a good reference for Sound Input Manager? I've been pouring over Inside Macintosh's Sound chapters
, various documentation archived at Macintosh Garden
, and a slew of technical notes
. Maybe my eyes have glazed over, but I can't seem to find details on the expected arguments and responses to register a sound input device. It's all beyond my knowledge. I'm hoping someone here will have an idea. If this is enough of a start that others are interested or able to help, we might be able to get stable, cross-platform bin/cue support in all Sheep and BII builds soon!