VOGONS

Common searches


First post, by dvwjr

User metadata
Rank Member
Rank
Member


This is for Ace from posts from the VOGONs OPL3 output problem of the Sound Blaster Pro2 (and clones) on 'faster' CPUs on DOS thread.

Star Wars X-Wing (1993 floppy version) Sound Blaster driver configuration

Problem:

On real x86 ISA based hardware the X-Wing (floppy version) sound card driver file: ADLIB_W.IMS has timer and delay problems which cause OPL FM output problems Sound Blaster sound cards which are operated on systems which are faster than the 1993 era 80386 CPUs which supported ISA bus based Sound Blaster hardware.

Background:

The Star Wars X-Wing (floppy version) released in 1993 functioned properly on 80386/80486 CPUs of the day with Sound Blaster ISA sound cards since the CPU register based timing delays functioned properly with then current CPUs. The problematic DOS sound driver for the Sound Blaster family of sound cards, ADLIB_W.IMS was a combination of the Creative CT-VOICE.DRV code and some LucasArts integration and modification to enable SoundBlaster support in X-Wing. The IMS 'driver' was actually created as a loadable MS-DOS EXE format file. The LucasArts programmers used some of their own code to support faster CPUs in the future, however their routine for creating timing delays for accessing the Sound Blaster OPL FM registers and data I/O ports was poorly coded and then never even used.

However, the problems with the LucasArts delay algorithm never mattered since the Sound Blaster port I/O delay values created were never actually used in their ADLIB_W.IMS driver code. The ADLIB_W.IMS driver for the Sound Blasters actually ignores the Sound Blaster port I/O delays and just uses the default AdLIB code for FM register and data I/O ports located at the default 0x388 and 0x389 addresses - with insufficient delays created via CPU register decrementing. Since the faster the CPU, the lower the delay time, hence the problems with the Sound Blaster sound cards on faster CPUs. This problem is not seen on emulators such as DOSBox, since the emulated Sound Blaster does not share all of the hardware timing limitations of actual Sound Blaster ISA sound card hardware.

Program configuration:

The X-Wing INSTALL.EXE program is also used to setup the supported sound card configuration via the "Set Sound Board Configuration" option by modifying the LANDRU.CFG file located in the home \XWING sub-directory. The first entry is the name of the LucasArts IMS sound card driver file to be used by the XWING.EXE game.

LANDRU.CFG
==========
adlib_w
FAST
ems
diff
==========

The following table indicates the relationship between the Sound Card choices and the LucasArts IMS driver file used:

     Selection                            Driver file
========================================================
1.) No Sound nosound
2.) AdLib and compatibles adlib
3.) Roland roland
4.) General MIDI (GMIDI) gmidi
5.) SoundBlaster adlib_w
6.) SoundBlaster Pro and compatibles adlib_w
7.) Roland with SoundBlaster roland_w
8.) General MIDI with SoundBlaster gmidi_w

All Sound Blaster ISA sound cards will use the ADLIB_W.IMS driver file.

Solution:

The default ADLIB_W.IMS driver file was modified to correct numerous timing error present in the LucasArts IMS driver code. A total of 206 of the 26,096 bytes in the driver file were modified to allow proper functionality of the modified driver on systems ranging from a DOS 6.22 Dell GXi 200MHz Pentium system with an ISA Sound Blaster Pro 2 (CT-1600) to an Intel 440BX based system with an Intel 1400Mhz Celeron SL6C6 (Tualatin) CPU with an ISA Sound Blaster AWE64 Gold (CT-4540) running directly under Win98SE and the 'native' DOS 7.1 from Win98SE.

Even with the modified ADLIB_W.IMS driver for the Sound Blaster, Sound Blaster Pro and the Sound Blaster 16, to allow the OPL FM and digital sound effects to function properly with this 1993 floppy diskette release of the Star Wars X-Wing game, the PC used must have one megabyte of EMS memory available. Lack of sufficient EMS memory will cause either no sound or distorted sound even with the modified ADLIB_W.IMS driver.

This modified ADLIB_W.IMS driver is delivered as the new driver file SBPRO_W.IMS, which is a replacement for the defective ADLIB_W.IMS driver. Delete the current ADLIB_W.IMS file and rename the SBPRO_W.IMS to ADLIB_W.IMS in the \XWING game sub-directory.

The modified SBPRO_W.IMS driver file has one potential patch byte for changing the new default delay for ISA based Sound Blaster sound cards. The default delay byte value is 0x07 which should allow more than enough delay time for proper access to the ISA Sound Blaster hardware OPL FM I/O ports. This byte is documented in the XWING_SBPRO_FIX.TXT file included in the latest attached XWING_SBPRO_FIX.ZIP file.

Ace,

If you get a chance to download and test this new replacement Star Wars X-Wing IMS driver, please be sure to test with only one Sound Blaster Pro (or clone) sound card present on the ISA bus. Dual cards, even if 'disabled' can still have an impact. Single card Sound Blaster, Sound Blaster Pro (or clone) or 16 SB16+ card testing would be appreciated. Hope this works out for you and your desire to hear OPL2 FM music and digital sound effects on real OPL hardware for this particular DOS game.

Thanks to the DOSBox team for the DOSBox 'heavy' debugger. 😁

dvwjr

Edited: 05/17/2011 - Updated with newer modified IMS driver file in a new ZIP file, changed some text to reflect update and change of original re-directed VOGONs message thread.

If you downloaded the original SBPRO_W.IMS driver, please downoad the latest SBPRO_W.IMS driver file in the XWing_SBpro_fix.zip file.

Edited: 05/27/2011 - Fixed references from XWING_FIX.ZIP to XWING_SBPRO_FIX.ZIP for attachments.

Attachments

  • Filename
    XWing_SBpro_fix.zip
    File size
    18.22 KiB
    Downloads
    604 downloads
    File comment
    The latest SBPRO_W.IMS file and documentation.
    File license
    Fair use/fair dealing exception
  • Filename
    XWing_Fix.zip
    File size
    252 Bytes
    Downloads
    360 downloads
    File comment
    Deprecated file. Please use the newer XWing_SBpro_fix.zip instead.
    File license
    Fair use/fair dealing exception
Last edited by dvwjr on 2011-05-27, 18:17. Edited 2 times in total.

Reply 2 of 9, by Ace

User metadata
Rank Oldbie
Rank
Oldbie

Here's one thing you should know: the SoundBlaster AWE64 and any other Creative sound card with CQM do not output garbage when they're used to output sound from X-Wing no matter how fast the CPU is, so on those cards, the patch is pointless. I was also unable to get X-Wing to output garbage on ESS, OPTi(those with OPTiFM rather than true OPL3) and Crystal ISA sound cards no matter how fast the CPU is.

Anyways, enough babbling, I'm going to put this patch to the test on a 400MHz Pentium II, 533MHz Celeron and 1GHz Pentium III overclocked to 1.13GHz with my SoundBlaster Pro 2.0(discrete OPL3), SoundBlaster 16 Value model CT2770(OPL3 in the CT1747 ASIC), SoundBlaster Vibra16 model CT2260(discrete OPL3), HP AZT1008(near-exact OPL3 clone), Audio Excel AV300(two exact OPL2 clones) and Avance Logic ALS4000(near-exact OPL3 clone - this is a PCI sound card unlike the others). All those cards output garbage OPL2 when used on fast computers with X-Wing.

Reply 4 of 9, by Ace

User metadata
Rank Oldbie
Rank
Oldbie

Testing has begun. I will update this post with results as I test my sound cards that have issues with X-Wing.

Intel Celeron 533MHz:

-SoundBlaster 16 Value model CT2770: FM is perfect, worked first try

Intel Pentium III 1GHz overclocked to 1.13GHz:

*nothing tested yet*

Intel Pentium II 400MHz:

-Avance Logic ALS4000: FM is now working correctly
-HP AZT1008: Black screen upon starting up the game
-Audio Excel AV300: Does not output garbage, but still hits numerous false notes. This sound card needs a delay value of 13 to output proper FM Synthesis.
-SoundBlaster Pro 2.0 model CT1600: Perfect FM with delay value 05

It seems clones of the YM3812(and maybe even the real YM3812 - this is an OPL2 FM chip) need higher delay values to work correctly on a faster computer with X-Wing. Who has a SoundBlaster with a YM3812 on it and a copy of X-Wing? Can you check to see if you get false notes(not a mess of garbage) with delay value 05?

Reply 5 of 9, by dvwjr

User metadata
Rank Member
Rank
Member

Ace,

Nice to see your many ISA and PCI audio cards are working with the Star Wars X-Wing (floppy) version of the game using the new SBPRO_W.IMS driver.

Ace wrote:

Here's one thing you should know: the SoundBlaster AWE64 and any other Creative sound card with CQM do not output garbage when they're used to output sound from X-Wing no matter how fast the CPU is, so on those cards, the patch is pointless. I was also unable to get X-Wing to output garbage on ESS, OPTi(those with OPTiFM rather than true OPL3) and Crystal ISA sound cards no matter how fast the CPU is.

Be careful, young Jedi. 😀 You are drawing a conclusion with too few data points.

I tested the original ADLIB_W.IMS driver file to failure with a Creative AWE64 Gold (CT-4540). The system used as stated above was an Intel 440BX based motherboard (AOpen AX6BC), with a PowerLeap PL-iP3/T 2.0 adapter - running an Intel Celeron SL6C6 (Tualatin) running at 1400MHz (1.4GHz). While the introductory cut-scenes did run, the was no OPL FM sound at all from the AWE64 Gold. The 1400MHz Celeron had enough CPU horsepower to outrun the flawed AdLib CPU-based delay algorithm used in the original ADLIB_W.IMS driver.

I repeated the test with the same setup except an 8-bit Sound Blaster Pro 2 (CT-1600) was swapped for the 16-bit AWE64 Gold (CT-4540). The BIOS had to modified to allow for "Legacy ISA" control of Interrupt 05h and DMA channel 01h, with the 8-bit I/O Recovery value set to "8" to allow the older Sound Blaster Pro 2 to function properly across the PCI/ISA bridge. Since the 8-bit CT-1600 needs a bit more delay in addressing the OPL FM address and data registers, it too failed to provide OPL FM sound with the original ADLIB_W.IMS driver.

Even the last ISA card that Creative issued, the AWE64 Gold, needs some delay time between OPL FM address register and data port access. Take the new SBPRO_W.IMS driver and set the delay byte from the default 0x07 to 0x00, then try that version of the driver with an AWE64 Gold. Be prepared for a very slow motion slide-show, with very slow sound - it will look like a black screen for around 45 seconds to a minute...

Both the 8-bit and 16-bit Sound Blaster ISA cards function properly with the new SBPRO_W.IMS driver file which replaces the original ADLIB_W.IMS driver file, since the new driver delay implementation is not CPU speed dependent. If sound cards based on the YM-3812 are tested, the CPU speed of the host system should have no bearing on the required delay values, only the OPL FM delay requirements of the individual sound card should have any influence on the required delay values.

Also removed was the undocumented Creative dual read-only register pair write, a byte (0xC6) write to the read-only 0x2?6 DSP Reset register, followed by a byte (0x00) write to the read-only DSP Read-Data port 0x2?A followed by various data read/writes. This undocumented register access behavior is used in certain Creative Labs diagnostic programs and is the first time I have seen it used in production code. The code path taken in the original ADLIB_W.IMS driver causes problems with the Sound Card initialization routine. So the SBPRO_W.IMS patch is not "pointless" even for the Creative SB16/SB32/AWE32/AWE64 line of ISA Sound Blaster sound cards. 😀

Ace wrote:

-HP AZT1008: Black screen upon starting up the game

You may wish to try a much higher delay byte value - say 0x90 and work your way down until it stops working. Frankly, if it need a higher delay value than 0x2A (42) then its design is worse that an actual original AdLib ISA sound card. You might wish to create in this message thread a post containing a table of the various delay values for the replacement SBPRO_W.IMS driver that you determine during the testing of your various ISA and PCI sound cards, so that others do not have to re-create the effort. Consider showing both the hex patch value and the decimal value as a rough micro-second delay number.

As to your use of a delay value of 0x05 for the Sound Blaster Pro 2 (CT-1600) as to the 'correct' delay - if it works, use it. However I based my delay numbers on the MILES AIL2 driver source code for the Sound Blaster family of ISA sound cards, which used an approximate delay of 6 uS between the OPL address registers and data sent to the data port and a delay of 8 uS for the post-data delay. Call both delays (X) and (X+2). I made the delays (X) and (X+3) so that with a delay value of 0x07 you get delays of (0x7) and (0x0A). Your delay value of 0x05 creates the values 0x05 and 0x08, just a little off from the extensively field tested MILES AIL2 drivers. You might want to go with 0x06 to be safe, the SBPRO_W.IMS modified driver used 0x07 just to be conservative. Since we are talking about micro-seconds here, the additional few micro-seconds used for I/O delays can not be detected in the iMuse created audio stream - humans detect delays in the milli-second range at best...

from thread

Ace wrote:

Before I forget, here's another issue I have with sound cards on fast computers: when using the AdLib sound option for music in the Collector's CD-ROM editions of X-Wing and TIE Fighter (this is OPL2, by the way), the music is noticeably slower and the game stutters A LOT. This happens no matter what sound card I use. Got an explanation for this?

Looking at the AdLib driver code in the X-Wing (floppy) version, there was a small section of code which performed a Sound Blaster DSP Speaker OFF, immediately followed by a DSP Speaker ON command, the pair of DSP commands which were performed on a regular basis. That DSP Speaker OFF/ON code was removed in the creation of the modified SBPRO_W.IMS driver file, since the DSP Speaker ON command requires 112 uS and the DSP Speaker OFF command requires 220 uS of delay before completion. This could be the reason for the 'stutters' and audio slowdown. Another patch was made and removed the reason for the offending code. These Sound Blaster DSP Speaker commands do not effect the audio output signal for any version 4.xx DSP (SB16+), however I do not know if the required DSP time delays are still enforced for DSP version 4.xx Sound Blasters. If these delays are still required, then these back-to-back DSP Speaker OFF/ON commands might account for the slowdown and audio 'stutters' on pre-DSP 4.xx sound blaster ISA cards, and perhaps even including DSP version 4.xx ISA sound cards.

Hope your continued sound card testing is successful,

dvwjr

Reply 7 of 9, by Ace

User metadata
Rank Oldbie
Rank
Oldbie

Here's something worth mentioning about the modified Adlib_w.ims file: the SoundBlaster Live! hates it. It works fine for the most part, but in-game, the music tends to slow down a lot and sometimes causes the game to stutter pretty badly. The SoundBlaster Live! works better with an unmodified Adlib_w.ims.

I also tried the modified Adlib_w.ims on an AOpen AW200 sound card(this contains an AOpen AS9200 chipset, which is essentially a tweaked Avance Logic ALS4000 with no SoundBlaster 16 support, better OPL3 and clearer digital sound) and that one stopped the AW200 from outputting garbage on fast computers.

So as it stands, the results are as follows:

Intel Celeron 533MHz/Intel Pentium III 500MHz:

-SoundBlaster 16 Value model CT2770: FM is perfect, worked first try

Intel Pentium III 1GHz overclocked to 1.13GHz:

*nothing tested yet*

Intel Pentium II 400MHz:

-Avance Logic ALS4000: Perfect FM
-HP AZT1008: Black screen upon starting up the game(have not tried higher delay values)
-Audio Excel AV300: Still hits false notes with delay value 07, perfect FM with delay value 13
-SoundBlaster Pro 2.0 model CT1600: Perfect FM
-SoundBlaster Live! Value model CT4830: FM plays slower at times and the game stutters a fair bit
-AOpen AW200: Perfect FM

Creator of The Many Sounds of:, a collection of various DOS games played using different sound cards.

Reply 8 of 9, by dvwjr

User metadata
Rank Member
Rank
Member
Ace wrote:

Here's something worth mentioning about the modified Adlib_w.ims file: the SoundBlaster Live! hates it. It works fine for the most part, but in-game, the music tends to slow down a lot and sometimes causes the game to stutter pretty badly. The SoundBlaster Live! works better with an unmodified Adlib_w.ims.

Ace,

On that Sound Blaster Live! 5.1 (PCI) sound card, here is something else to try to see if the in-game slowdown and 'stutter' in X-Wing can be prevented. Might work, might not - since the target sound card is a Sound Blaster Pro (ISA) device. Just make another copy of the SBPRO_W.IMS driver and patch the three bytes listed in the below table. Then copy this 'special' Live! only version of the SBPRO_W.IMS driver over the current ADLIB_W.IMS and give it a try with X-Wing using the SB Live! (PCI) sound card. Since the Live! is a PCI bus sound card from Creative, maybe their (ISA) SB-16 emulation code is not all that good. 😀

Sound Blaster Live! test patch:

 File offset         current      SB Live! Test
****************************************************
0x55F2 83 BA
0x55F3 C2 80
0x55F4 0A 00

When it comes to the PCI sound cards you have tested, it seems that the ALS4000 (PCI) is the most interesting example of DOS SB Pro 2 level support. If the DOS compatibility is good, then this card may be the way (outside of an SB-Link motherboard) to carry forward the Yamaha YMF-262 OPL 'sound' on PCI bus systems running DOS or the DOS support running under Win98SE.

dvwjr

Reply 9 of 9, by dvwjr

User metadata
Rank Member
Rank
Member

Please see the original message in this thread for an updated version of the X-Wing IMS driver file - SBPRO_W.IMS, in a new file attachment. The name of the new attachment ZIP file is XWing_SBpro_fix.zip in the above first message.

If you have already downloaded the previous driver in the now deprecated XWing_Fix.zip file, please download the newer XWing_SBpro_Fix.zip file above. Please update X-Wing (floppy) with this new IMS driver file. The documentation reflects the changes made to the SBPRO_W.IMS file.

Thank you,

dvwjr