Saturday, October 10, 2015

The Journey of the "PCjr./Tandy Sound Chip"

The TI SN 76496, what we today typically refer to as the PCjr./Tandy sound chip, is a long and varied one as it pertains to the IBM PC platform.  Texas Instruments originally developed this simple music chip for use in its TI/99 4 computer, where it was called the TI TMS9919.  Texas Instruments offered the core of this chip as the TI SN79426 and later the TI SN76489 as an off-the-shelf part.  The TI SN76489 found its way into the Colecovision and the Coleco Adam computer as well as many arcade machines.  Additionally, a clone of the chip is integrated into the Sega Master System and Sega Genesis and the Sega Game Gear.

The TI SN76489 can generate three square waves at different frequencies.  The input clock is typically 3,579,545MHz.  For the square wave channels, the input clock is divided by 32 and then by a 10-bit number to obtain the output frequency for the square wave.  The human ear can perceive sound waves in the range of 20KHz to 20Hz, but the lowest square wave tone the chip can produce at this input clock is about 109.24Hz.

The chip can also generate periodic or white noise for sound effects and percussion.  The channel divides the clock rate by 64, 128 or 256 or uses the rate of square wave generator 3 which drives a linear feedback 15-bit shift register (1 bit is shifted every clock cycle) to produce a pseudo-random pattern of 1s and 0s at a high rate of frequency.  The periodic noise option is output only once every 15 clock cycles compared to the white noise option.

The chip has eight registers, two for each square wave channel and two for the noise channel.  Any write to the chip will select a register and send data to the chip.  However, the frequency for each square wave channel is controlled by two registers, and if the register is not changed, the lower six bits of the frequency for a square wave channel can be updated quickly for frequency sweeps.

The chip uses a 4-bit number to attentuate the amplitude/volume of the each channel and then mixes all four channels into the single output pin on the chip.

Usage in the IBM PCjr.

The IBM PCjr. uses a discrete TI SN76496 (or TI SN76496A) at ZM26.  The TI SN76496 is the same chip as the TI SN76489A except that it has an audio in pin on pin 9 to allow for an external audio source, like a speech synthesis chip, to be mixed into the chip for a combined output.  The TI SN79494 has the audio input pin but only divides the input clock by 4 instead of 32, so it is not a drop in replacement.

IBM did not connect the audio in on pin 9 to anything in the PCjr.  Instead, all sources of audio, the PC Speaker, the TI SN76496 and the audio output pins from the cassette connector and from the sidecar bus (used for the IBM PCjr. Speech Attachment) all go to a audio multiplexer chip called the MC14529.  This chip will determine which of these four sources will be heard at the RCA audio jack, through the TV RF Modulator and through the IBM 4893 PCjr. Display.  Note that the internal speaker in the PCjr. only outputs PC Speaker audio.

IBM assigned I/O ports C0-C7 to the chip in the PCjr., even though it only needs one port.  The chip is write-only and cannot be reliably detected, the system it is part of is what gets detected.

Usage in the Tandy 1000A/HD

The Tandy 1000A/HD use a discrete TI SN76496 at U96.  The first difference in the implementation from the PCjr. is that the audio input pin is used to mix in PC Speaker sound.  This allows both the PC Speaker and SN76496 sound to be heard from the audio multiplexer chip.  The second difference is that you can hear the SN76496 through the Tandy's internal speaker as well as through its RCA audio output.  In fact, the audio selector chip is only connected to the RCA audio jack, so you will always hear the PC Speaker and SN76496 from the internal speaker, which is pretty large and loud.

Unfortunately, the default setting for the multiplexer chip will output only PC Speaker audio to the RCA jack.  Some games, like LucasArts' SCUMM games, will not touch the multiplexer chip, leaving you with only the internal speaker for music and sound effects.  You can avoid this by running a Sierra AGI game or finding a program that will let you set the multiplexer accordingly.

Usage in the Tandy 1000EX, SX, HX, TX

The Tandy 1000EX and 1000SX are similar to the earlier 1000s except now they are using NCR8496 clones of the TI SN76496 as well as the real TI SN76496s.  It is a crapshoot as to which chip you will find in any given EX or SX.  You can find the chip at U15 in the EX and U37A in the SX.

While the two chips work almost identically, there are two differences.  First, the NCR chip requires a 2K resistor instead of a 2.7K resistor for mixing in the PC Speaker audio into pin 9.  Second, the TI chip and the NCR chip behave slightly, but at times audibly differently when it comes to the noise channel.  In the TI chip, any change to the noise control register will clear the shift register.  In the NCR chip, this does not appear to happen.  (This difference in behavior also appears to be true for the registers governing the square wave channels)  The bits used for the feedback register are not the same for the TI and NCR chips.

The SX has a complex connection to the audio multiplexer chip and will require a write to hear the TI/NCR audio from the RCA jack.  This machine has the same problem with the LucasArts' SCUMM games described above. See here for more details : http://nerdlypleasures.blogspot.com/2013/06/ibm-pcjr-and-tandy-1000-sound.html

The EX has a simplified connections to the audio multiplexer chip so that by default PC Speaker and TI audio will always be heard without needing to write to the audio multiplexer chip.  The HX and TX give identical output options to the EX, except its highly likely that in these machines Tandy was exclusively using the NCR chips.  In the HX, U19 contains the chip.  In the TX, it's at U7.

While real TI SN 76496 chips can still be sourced from chip vendors, the NCR 8496 chips seem impossible to find, except in these Tandys.

Usage in the Tandy 1000 SL, SL/2, TL, TL/2, TL/3, RL, RL-HD

These machines embed the NCR version of the TI chip into a custom Tandy chip called the PSSJ (Parallel, Serial, Sound & Joystick).  The PSSJ has acquired a DMA-fed, IRQ-driven DAC/ADC, which uses ports C4-C7.  The DMA used is 1 and the IRQ used is 7, making it impossible to coexist with a Sound Blaster.

The audio multiplexer chip no longer exists in these machines.

The PSSJ chip has an option to allow an extra divisor bit (for an 11-bit divider) to be enabled for the TI/NCR chip, but it is unknown if this feature was ever used.

For some reason, the first note of Greensleeves in the opening of King's Quest I & II is not heard in these systems.

Usage in the Tandy 1000RLX & RLX-HD

The PSSJ chip in these machines is accessed identically to the other Tandy machines, but because these machines have VGA built-in instead of Tandy video, certain games will refuse to play audio through the chip.  Electronic Arts games like Skate or Die and Kings of the Beach will not work with Tandy audio in these machines.  AGI games with interpreter versions below 2.917 will show graphical glitches in the form of "trails" on these machines, but will still produce Tandy sound.

Usage in the Tandy 1000RSX & RSX-HD, 2500 and Sensation!

In addition to the VGA issue of the RLX, these systems are fully AT compatible.  This required them to relocate the PSSJ audio to I/O 1E0-1E7.  IBM decided when it made the IBM PC AT to put the second DMA controller at C0-DF.  It did not appreciate or care that its PCjr. had its TI chip there as well.  The IBM AT was a success and the PCjr. was not, so other companies followed IBM's lead.  Hence Tandy had to relocate the chip.

The result of the relocation broke Tandy music compatibility with most games because they were expecting the chip to be at C0-C7.  The TI chip was always programmed through direct register writes, neither IBM nor Tandy wrote BIOS routines to program the chip.  A few later games, mostly from Sierra, have drivers that support these machines.

The chip's presence is not advertised on the Sensation!, which contains an Adlib Gold clone.  It is there, but it sounds very muffled compared to the earlier computers.

Usage in the IBM PS/1 Model 2011 and 2121

IBM released the PS/1 Audio/Joystick Card as an upgrade for one of the proprietary sockets on the motherboards of these machines.  The PS/1 line was introduced in 1990 with the Model 2011, which uses a 10MHz 286 CPU.  The basic functionality of the TI chip is integrated into the Card, even though its musical capabilities were very unimpressive to everybody by this time.  Adding ISA slots to these machines requires an external expansion box.  It uses I/O address 205.  It can use interrupts, namely IRQ7, but does not use DMA.  Later the Model 2121 was released with support for the Card, it uses a 386SX @ 16MHz.  None of the later PS/1s support the Card.

Interestingly, while the system board supplies a 10MHz Clock signal to the Card, the integrated TI chip is based off an 8MHz signal, which means the clock rate is stepped down somewhere on the Card.  The 8MHz signal is divided by 64 and then by the 10-bit number.  Therefore, if you put the maximum value of 1,024 into the square wave generator, you will end up with a square wave being output at 122.07Hz.

The PS/1 Audio Card has a problem then if fed with pure Tandy music data, it is running the same notes at 11.74% higher frequencies!  Unfortunately, the Tandy is no master of the lower octaves, and IBM's version is even less capable of reaching the lower notes.  The Game Blaster can get all the way down to 28Hz and has three times the channels.

Now this frequency difference can be accounted for the most part if the programmers write a driver that adjusts the speed of the music playback.  However, this was not always done, as can be seen when running the special PS/1 version of Silpheed running on a real IBM PS/1.

Now for some audio comparisons :

Audio Comparison #1 - TI vs. NCR Noise Channel

IBM PCjr Maniac Mansion (low resolution version) :



Tandy 1000TL Maniac Mansion  (low resolution version) :



Audio Comparison #2 - PCjr. Discrete Chip vs. Tandy Integrated Chip

IBM PCjr. King's Quest :



Tandy 1000TL King's Quest :



Audio Comparison #3 - Tandy vs. IBM PS/1

Tandy 1000 Prince of Persia (via DOSBox SVN)



IBM PS/1 Prince of Persia (via IBMulator 0.7)



3 comments:

Anonymous said...

are you an engineer and did you work for tandy?

Cloudschatze said...

"For some reason, the first note of Greensleeves in the opening of King's Quest I & II is not heard in these systems."

Sierra's AGI games enable the external audio output, via the multiplexer, on the earlier Tandy 1000 systems. In the systems with the PSSJ, this action results in the multiplexer "resetting," with the associated delay causing the first note in KQ2 to not be heard.

Galane said...

How about an article on the hack/mod on a PCjr to make its sound Tandy 1000 compatible? The mod to make its video Tandy 1000 compatible is easy to find, IBM Canada had it on their website.