RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Discussion about old sound cards, MIDI devices and sound related accessories.

RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-08 @ 00:17

Hello, I developed a small utility to help owners of CMI8x38-based cards to run DOS software.
Based on the information from this thread: viewtopic.php?f=62&t=36445
You specify PCI base port of the card and it redirects standard 220h, 388h, 330h port accesses to their proper locations relative to that base port.

It uses the same method that is used by SoftMPU & ADLiPT, but is written from scratch in assembly. Same requirements, needs EMM386 3.46+ running.
It remaps hardcoded port ranges and doesn't pass the data through to whatever may live on those ports. This may be later improved in the future, or made configurable.

Thanks to pdw for opensourcing his projects and to Kamerat for coming up with the idea and testing with plenty of DOS software.

Current version is 1.11
Redirects SB, Adlib, MPU401 port ranges, but digital audio support is not yet confirmed. Relative to unreleased 1.1 only has internal code refactorings and text changes. AdLib ports are redirected to SB OPL3 base port, seem to work ok.
Attachments
RECMI111.ZIP
(1.04 KiB) Downloaded 37 times
Last edited by noop on 2018-3-08 @ 02:21, edited 4 times in total.
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Kamerat » 2018-3-08 @ 00:52

Thanks again noop!
This is very useful for accsessing the card when it's behind a PCI-PCIe bridge or used in a virtual machine where you can't accsess the legacy ports directly. In my initial testing I found it to be very compatible when using FM synth or MPU401.
User avatar
Kamerat
Oldbie
 
Posts: 725
Joined: 2014-3-14 @ 19:09
Location: Oslo, Norway

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Scali » 2018-3-14 @ 11:30

noop wrote:AdLib ports are redirected to SB OPL3 base port, seem to work ok.


Yes, that is fine.
OPL3 has two sets of registers, so it more or less looks like a dual OPL2 setup.
The first set of registers is also the OPL2-compatible set. SB Pro 2 mapped the OPL3's register sets to base-address and base-address + 2.
It also mirrored the first register set at 388h for AdLib-compatibility.

I believe the earlier SB Pro, with dual OPL2, actually made writes to 388h go to both OPL2 chips at the same time. The first OPL2 chip is at base-address, and the second is at base-address + 2.
So in that case, it will be different... but those cards are not your target anyway.
Scali
l33t
 
Posts: 3395
Joined: 2014-12-13 @ 14:24

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-14 @ 17:37

Scali wrote:
noop wrote:AdLib ports are redirected to SB OPL3 base port, seem to work ok.

I believe the earlier SB Pro, with dual OPL2, actually made writes to 388h go to both OPL2 chips at the same time.

Thanks, I know all that, having already programmed detection and port virtualization utils.
You also forgot address 228h, which is also supposed to be OPL2 emulation base port for compatibility with older SoundBlasters.
Thing is, it is a bit mysterious to me, if OPL3 takes 2 or 4 ports at 388 on many SB and SB-compatible cards and also on Adlib Gold, PAS etc.
OPL3 or 2x OPL2s are guaranteed to take 4 ports at 220, guaranteed to only take 2 ports at 228, but on 388, even official Creative documentation says about 2 ports taken on SB16, while some people tell me that the whole of OPL3 4 ports are actually available there on most/all cards.
For Adlib emulation this is unimportant, but, obviously, important for games that try to use OPL3 on Adlib base port, which obviously exist, because this is how it works on Adlib Gold at least.

Without having an actual CMI card to test, I decided to reliably support presence of OPL3 at 388 by redirecting it to the base port corresponding to 220.

There is also an issue of partial address decoding. Older hardware may actually not bother with decoding all address lines, leading to their regs being mirrored all over the address space and possibly conflicting (noticed this in earlier MPU401). Also, IIRC, port address space on earlier PCs is 12 bits. Dunno if there is an important software that depends on that.
Last edited by noop on 2018-3-14 @ 18:04, edited 2 times in total.
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Scali » 2018-3-14 @ 17:46

noop wrote:You also forgot address 228h, which is also supposed to be OPL2 emulation base port for compatibility with older SoundBlasters.


Yes, that is another alias, but I don't think anyone ever used it.
Technically it's base-address+8, because it changes with the base address selection (388h is always fixed).

noop wrote:Thing is, it is a bit mysterious to me, if OPL3 takes 2 or 4 ports at 388 on many SB and SB-compatible cards and also on Adlib Gold, PAS etc.


I have an SB Pro 2 myself, and it only has 2 ports at 388h.
As you say, the AdLib Gold is the one that has 4 ports at 388h (but I don't think it has them at 220h).
With other cards, I don't know. Perhaps some do, some don't.
DOSBox seems to emulate it (even when you select SBPro2, which is wrong).
Scali
l33t
 
Posts: 3395
Joined: 2014-12-13 @ 14:24

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-14 @ 17:54

Scali wrote:DOSBox seems to emulate it (even when you select SBPro2, which is wrong).

Yeah, one of many cases where you can't rely on DOSbox. BTW, if there an easy way to set it up with support for port virtialization APIs?.

I won't be surprised even if different revisions of Creative SB cards support 388 differently. After all, they use DSP for emulating MPU401 UART on SB16+ with varying bugs depending on DSP microcode version, they have different implementations of OPL3 itself: real OPL3 with Yamaha DAC, CQM, real OPL3 with digital connection to emu8000..

Correction about base port and 220 not being fixed in stone is accepted, but obviously the text is easier to write and read if the default base port is assumed. Also, the utility can't change SB base port. I'm only planning to add that is somebody requests it, and improve my asm code meanwhile to make arbitrary changes easier.
Last edited by noop on 2018-3-14 @ 18:01, edited 2 times in total.
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Scali » 2018-3-14 @ 17:58

noop wrote:BTW, if there an easy way to set it up with support for port virtialization APIs?.


Yea, I added support for inpout32.dll to my own custom version.
I wanted to add configuration for it, but haven't done so yet.
Currently I use it for printer port support, so I can test the OPL2LPT and other devices from Windows.
Scali
l33t
 
Posts: 3395
Joined: 2014-12-13 @ 14:24

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby 640K!enough » 2018-3-14 @ 18:12

Scali wrote:As you say, the AdLib Gold is the one that has 4 ports at 388h (but I don't think it has them at 220h).

Just for some additional context, the Ad Lib Gold used 388 to 38F by default for audio features. If I remember correctly, most of these were passed through the main control chip, so that not every write to the typical OPL port range will end up going to the on-board OPL3. This was used to detect the level of compliance with the Gold Sound Standard, for instance. GSS cards ignored 220 altogether, except when used with the (beta) SB emulation TSR.
640K!enough
Member
 
Posts: 310
Joined: 2017-5-11 @ 17:52
Location: Canada

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-14 @ 18:21

640K!enough wrote:detect the level of compliance with the Gold Sound Standard, for instance.

So, it may be worthwhile to emulate, for games that only play OPL3 FM on Adlib Gold and try detecting it, instead of running generic OPL3 detection?
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby 640K!enough » 2018-3-14 @ 18:37

noop wrote:So, it may be worthwhile to emulate, for games that only play OPL3 FM on Adlib Gold and try detecting it, instead of running generic OPL3 detection?

I'm not sure that would be worth the effort. There were very few titles that even tried to use any of the features that would make this relevant. Most titles probably had generic support for OPL3 via 388 and used that. A notable exception, I think, was Dune (EDIT: Dune, not Dune II; my mistake), which could also make use of the reverb module.
Last edited by 640K!enough on 2018-3-14 @ 19:34, edited 1 time in total.
640K!enough
Member
 
Posts: 310
Joined: 2017-5-11 @ 17:52
Location: Canada

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby hard1k » 2018-3-14 @ 19:11

A small correction - it was Dune, not Dune II.
Please have a look at my wishlist (hosted at Amibay)
User avatar
hard1k
Oldbie
 
Posts: 576
Joined: 2014-4-22 @ 11:28
Location: Buenos Aires, Argentina

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby 640K!enough » 2018-3-14 @ 19:29

hard1k wrote:A small correction - it was Dune, not Dune II.

So it was; I stand corrected. :blush:
640K!enough
Member
 
Posts: 310
Joined: 2017-5-11 @ 17:52
Location: Canada

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby cyclone3d » 2018-3-14 @ 19:39

Cool project. Watching this thread now.
User avatar
cyclone3d
Oldbie
 
Posts: 1726
Joined: 2015-4-08 @ 06:06
Location: Huntsville, AL USA

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Scali » 2018-3-14 @ 20:24

Yea, Dune is a bit of a shame... It's one of very few games with OPL3 music, arguably the best OPL3 music ever made for a game... and it has a very strict AdLib Gold detection routine, so it really doesn't run on any other OPL3 hardware.
It's as if Dune was meant as a promotion for AdLib Gold.
Scali
l33t
 
Posts: 3395
Joined: 2014-12-13 @ 14:24

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby 640K!enough » 2018-3-14 @ 22:47

Scali wrote:Yea, Dune is a bit of a shame... It's one of very few games with OPL3 music, arguably the best OPL3 music ever made for a game... and it has a very strict AdLib Gold detection routine, so it really doesn't run on any other OPL3 hardware.
It's as if Dune was meant as a promotion for AdLib Gold.

I guess it could be that, as one of the earliest OPL3 cards, Ad Lib provided an early prototype for development. From what I've read, Ad Lib had a certain amount of input in the development of the OPL3, so maybe with early access, and maybe some arm-twisting (and money?), Ad Lib was able to secure exclusive support.

Still, for a few titles, would it be worth the development time to implement emulation features to fake the presence of the remaining hardware, while re-directing the music to an OPL3 equivalent? I don't own a copy of Dune, did it require a whole Gold 1000, or could other hardware be used for digital audio playback? What might Dune sound like without the reverb module?
640K!enough
Member
 
Posts: 310
Joined: 2017-5-11 @ 17:52
Location: Canada

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Scali » 2018-3-14 @ 22:57

640K!enough wrote:Still, for a few titles, would it be worth the development time to implement emulation features to fake the presence of the remaining hardware, while re-directing the music to an OPL3 equivalent?


That depends on how easy it is to fake it, I suppose.
It seems there is already a DOSBox patch for AdLib Gold support:
https://www.youtube.com/watch?v=YMAeteGRjuU

640K!enough wrote:I don't own a copy of Dune, did it require a whole Gold 1000, or could other hardware be used for digital audio playback?


It doesn't have any digital audio afaik. You can only select one audio device anyway, so it's AdLib Gold or nothing.

640K!enough wrote:What might Dune sound like without the reverb module?


Well, see the above video...
It basically sounds like the OPL2 version with stereo and slightly fancier instruments (which imho doesn't always make it sound better).

Dune is very picky anyway... if you just try to force it to use an 'AdLib Gold' at address 220h, on an SB Pro 2 or compatible card, the game just locks up.
So whatever detection and other stuff they do, it's not very forgiving.
Scali
l33t
 
Posts: 3395
Joined: 2014-12-13 @ 14:24

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-14 @ 23:16

640K!enough wrote:What might Dune sound like without the reverb module?

Somebody said previously there is a patch already here on vogons. Apparently, this one: viewtopic.php?p=258707
Didn't try. youtube clips seem to be deleted.

Scali wrote:It's one of very few games with OPL3 music

I thought many newer games support OPL3, if found, without advertising it too much. Descent, for example, sounds much nicer if OPL3 is enabled in dosbox vs opl2 or stereo opl2.
Last edited by noop on 2018-3-14 @ 23:19, edited 1 time in total.
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby Falcosoft » 2018-3-15 @ 06:54

It doesn't have any digital audio afaik. You can only select one audio device anyway, so it's AdLib Gold or nothing.

If you select Sound Blaster as audio device Dune uses digital audio samples but you can count them on 1 hand :)
As far as I remember: 1. In the intro when the worm appears 2. When you visit a sietch during fight.
User avatar
Falcosoft
Oldbie
 
Posts: 611
Joined: 2016-5-21 @ 13:46
Location: Pécs, Hungary

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-15 @ 17:41

640K!enough wrote:I guess it could be that, as one of the earliest OPL3 cards, Ad Lib provided an early prototype for development. From what I've read, Ad Lib had a certain amount of input in the development of the OPL3

From what I've read it looks to me that Adlib spent some effort helping with development of OPL3 and MMA, while Creative just stole the result, putting it into SB Pro2 and later "borrowed" several other advertised features of Adlib Gold into SB16 (12-bit DAC that accepts 16 bits, samplerate-dependent digital antialiasing filter) while killing it with unfair competition practices.
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Re: RemapCMI - Tool for emulating DOS audio ports on C-Media CMI8x38 soundcards

Postby noop » 2018-3-15 @ 18:11

640K!enough wrote:If I remember correctly, most of these were passed through the main control chip

AFAIK MMA only serves as bus address decoder for OPL3. For all purposes it can be considered transparent if we are only concerned with OPL3 (and if mixer is alreadty set up properly).
4 MMA chip regs follow 4 OPL3 regs and the method of accessing its state mirrors OPL3.
User avatar
noop
Newbie
 
Posts: 86
Joined: 2015-7-20 @ 15:42
Location: Minsk, Belarus

Next

Return to Sound

Who is online

Users browsing this forum: No registered users and 2 guests