Login  •  Register


The time is now: Tue Jul 23, 2019 5:41 am

Emaculation wiki  •  Delete all board cookies



Post new topic  Reply to topic Page 1 of 1 [ 6 posts ]
Print view Previous topic  |  Next topic
Author Message
PostPosted: Sun Jun 16, 2019 8:49 pm 
Offline
Tinkerer

Joined: Wed Mar 21, 2012 12:35 am
Posts: 43
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 or variants 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!


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Wed Jun 19, 2019 4:32 am 
Offline
Tinkerer

Joined: Mon Jul 18, 2005 5:42 am
Posts: 80
Location: Australia
That is awesome news, thanks for revisiting this issue and making such quick progress.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Wed Jun 19, 2019 12:03 pm 
Offline
Tinkerer

Joined: Mon Jul 18, 2005 5:42 am
Posts: 80
Location: Australia
I will definitely do some testing and report back.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sat Jun 29, 2019 6:17 am 
Offline
Tinkerer

Joined: Mon Jul 18, 2005 5:42 am
Posts: 80
Location: Australia
I have tested Decent II. When I start the game I can get the CD music working in the main menu. I have swapped between MIDI and redbook audio and the difference is obvious.

However, when the introduction movie for the first level finishes, the game crashes with "Error locking sound 76". I have not been able to find a away around that yet. Enabling MIDI music results in the same error.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sat Jun 29, 2019 6:37 am 
Offline
Tinkerer

Joined: Mon Jul 18, 2005 5:42 am
Posts: 80
Location: Australia
I also tested Warcraft II.

When I launch the game, I go to the advanced tab under Startup Options and next to "CD Audio Source" the menu has "none" selected and there are no other options. When the game starts, there is no background music.

However, when I go to the CD Audio Player, the CD tracks will play in there.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Jul 08, 2019 3:54 am 
Offline
Tinkerer

Joined: Wed Mar 21, 2012 12:35 am
Posts: 43
Thanks for testing, almeath!

It looks like Warcraft II is the same as Warcraft I, using the CD player as a Sound Input device and passing through audio. Unfortunately, I still haven't found better documentation on the Sound Input Manager.

For Descent, I wonder if the lack of CD scanning is the problem. Error -76 is "tk0BadErr: track 0 detect doesn't change", so maybe it's related. Descent I doesn't have videos and doesn't crash, so I'll need to download Descent II and try to reproduce the crash.

Another issue with these mixed-mode games is timing. For some reason, in Warcraft and Descent, gameplay is too fast and controls are too slow. Maybe it can be fixed in settings, but some adjustment will be necessary to make them play correctly.


Top
 Profile  
Reply with quote Post a reply  
Display posts from previous:  Sort by  
Post new topic  Reply to topic Page 1 of 1 [ 6 posts ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
 

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group