Wednesday, March 11, 2015

Cajoling Sierra and LucasArts Games to Play Tandy Sound on a Non-Tandy System

Sierra's AGI engine games, which formed the bulk of their mid 80s PC offerings, supported Tandy graphics and sound.  LucasArts' early SCUMM engine games also supported Tandy graphics and sound.  As far as sound went, the Tandy 3-voice chip was the only alternative to the PC Speaker.  However, Tandy sound chips were almost exclusively found in Tandy 1000s and PCjrs.  They were not generally available in PCs and never available to the general public as a sound card.

The main reason why no one put the 3-voice TI SN76496 sound chip inside their PCs was because it utilized the same address space (C0-C7) as the 2nd DMA controller in the IBM PC AT and clones.  The blame for this was on IBM, which had designed both the PCjr. and AT.  Although the 2nd DMA controller was not really important until the mid 90s, PC clones that wanted to manufacture AT compatibles had to include it.  While this was not the only reason why the sound chip was not generally available, it was a daunting hurdle when every game that used it had to write directly to the registers located at the contested I/O location(s).

Games cannot detect the Tandy sound chip because it can be written to but not read.  They can detect a Tandy 1000 or an IBM PCjr. by reading identifier bytes in the BIOS area of these machines.  For the PCjr. it is FD at F000:FFFE and 21 for the Tandy 1000s at FC00:0000.  When the programmers have their programs search for these bytes, then they know that Tandy or PCjr. graphics and sound are present in the machine.  However, Tandy allowed its machines, starting with the SX, to use other graphics cards, complicating matters.

Graphics cards can be detected by software.  A MDA adapter can be identified by reading from a status port at 3BA and a CGA by a status port at 3DA.  Hercules cards can be detected by some unused (by IBM) bits in the status port.  An EGA, MCGA or VGA can be detected via BIOS extensions and readable registers, particularly at 3C0-3CF.  MGCA can additionally be assumed if the system returns the ID byte for an IBM PS/2 Model 25 or 30, FA at F000:FFFE

Distinguishing CGA from Tandy video is tricky because Tandy video (almost) perfectly emulates the latter from a hardware perspective.  There are generally two ways a programmer can distinguish CGA from Tandy video.  First, Tandys use IRQ5 for vertical retrace, CGAs do not.  However, often this functionality is disabled because hard drive adapters also tend to use IRQ5 in 8-bit slots.  The other way is through the amount of video memory available.  Tandy video can use 32KB while CGA video only uses 16KB, so if a program writes a value to a memory location in the lower 16KB and a different value to the memory location exactly 16KB above the first memory location written, if the first memory location is the same as the second memory location, you have a CGA, and if the locations are different, you have Tandy.  This only works for CGA cards with access only to 16KB of RAM.

Despite these issues, an ISA card is being developed that will put Tandy sound on a non-Tandy PC.  If it is completed, you will be able to run virtually any DOS game that allows you to specify the audio in an install or setup program of via the command line.  Some games are a bit difficult when asked to do this, and here are instructions on how to coerce some games to work in this (for now) hypothetical scenario.

Sierra's Adventure Game Interpreter

Games affected :

King's Quest I, II, III, Space Quest I, II, Mixed Up Mother Goose, Police Quest, Leisure Suit Larry, The Black Cauldron, Donald Duck's Playground

Solution :

Any of these games released with an AGI Interpreter version of 2.917 or later can support Tandy sound with an EGA or VGA adapter present.  The latest interpreters are also required to avoid having graphical garbage be left on the screen from animation due to some self-modifying code in the graphics card drivers the game uses in earlier interpreters.  You will need the command line argument -t if you are not running the game on a Tandy 1000.  This tells the executable to use Tandy graphics and sound, but the program conducts checks for an EGA or VGA adapter and will use them if present.  It will still give you Tandy sound.

However, if you have a version of the game that uses an AGI Interpreter below 2.917, you will need to copy over the interpreter files from another game with that interpreter.  Here are the interpreter files :

AGI or SIERRA.EXE
AGIDATA.OVL
CGA_GRAF.OVL
EGA_GRAF.OVL
HGC_FONT
HGC_GRAF.OVL
HGC_OBJS.OVL
IBM_OBJS.OVL
JR_GRAF.OVL
SIERRA.COM or KQ[1].COM, KQ2.COM, KQ3.COM, LL[LSL1].COM, PQ[1].COM, SQ[1].COM, SQ2.COM, BC.COM
VG_GRAF.OVL

The real executable is the AGI file, the .COM file is a loader which implemented the key disk copy protection.  (The .COM file is also necessary to set up these games to work correctly on the PCjr., otherwise it is not needed).  To keep people from using these files interchangeably, Sierra included the initials of the game in the encrypted AGI file.  If that name does not match the game files, then the program will refuse to run.  You will need a cracked .COM file and a program called AGI Decryptor to decrypt the AGI file into an executable AGI.EXE.  Then you must hex edit the AGI.EXE file to change the name of the game.  Then it will run.

Games using AGI Interpreters with 3.xx work without any intervention required.

This will not work with any booter game, as Tandy video is the best video adapter they support, without major hacking.

LucasArts SCUMM

Games Affected :

Maniac Mansion (both non-Enhanced and Enhanced), Zak McKracken and the Alien Mindbenders (both non-Enhanced and Enhanced), Indiana Jones and the Last Crusade : The Adventure Game (both 16-color and 256-color versions).

Solution :

These games autodetect Tandy 1000s and will use Tandy graphics and sound.  If they are not being run in a Tandy 1000, they will use PC Speaker sound.  They support an EGA or VGA card in a Tandy 1000.  With a little bit of hex editing, you can force the executable to always use Tandy sound (but nothing else).  The instructions can be found here : http://www.vogons.org/viewtopic.php?t=31657#p260253

It is not impossible that the executable may be compressed because it was necessary to fit it on the floppy disks.  In that case, you will need an EXE unpacker like UNP or LZEXE before you can hex edit the files.

Indy 3 will always use Adlib sound if an Adlib or Sound Blaster is in the system, even in a Tandy 1000. If you use the above method, you will need to remove the sound card to hear Tandy music.  It will never autodetect a Game Blaster, which is supported in the 256-color versions and 16-color version 3.14.

While typically DOSBox's Tandy mode obviates the need for these patches, in the non-Enhanced versions of Maniac and Zak, you will be able to enjoy the crisper text of the EGA and VGA modes with this patch.

Notes :

Neither series of games will show the correct graphics with a CGA or Hercules card when these methods to force Tandy sound are used.

8 comments:

Anonymous said...

Looks like there is an easy way to decrypt AGI now without needing the keydisk:
http://www.sierrahelp.com/forums/viewtopic.php?f=86&t=4212

Maki Mahoney said...

http://sierrahelp.com/Utilities/SoundUtilities/AGI-MIDI.html
I've been meaning to try this patch for a couple of months and reading this made me think of it. It lets you play Tandy 3 Voice AGI Sierra games with MIDI instead, specifically it seems only to work with a MT-32 compatible synth. I feel like he could have gone for a wider choice but I'm grateful all the same. Is this something you'd be interested in trying?

Anonymous said...

Hello,

Not sure if you are still reading comments for these old posts, but I wrote a small tool that can upgrade interpreters 2.411,2.435,2.439,2.440 and 2.915 to 2.917, along with patching AGI with the correct game id. The tool uses the interpreter files from an old AGI demo (i.e. AGI is unencrypted), and has them compiled straight into the code as byte arrays in order to allow the program to be distributed as only a single .exe.

I did this so I can play pre 2.917 AGI games using Tandy sound on my Covox using Temu. Certainly it's possible to find versions of these games with later interpreters, but I had the original disks for some games that were pre 2.917.

Would distributing this program be considered in any way a violation of copyright, or are these old AGI demo files now in a grey area?

Great Hierophant said...

That is the AGI Disk Free! Decryptor 1.1 I believe? That is a great program. There is probably a good argument that the tool is copyright infringing, but no one is going to care if you distribute a tool to cracking older versions of these ancient AGI games.

Anonymous said...

While I did write AGI Disk Free! Decryptor (and released it on Sierrahelp.com a few years back), that program just decrypts the AGI file into an executable and does not change the interpreter version.

This program is different in that it is not a decryption engine. It just writes the .OVL, .COM and AGI files for interpreter 2.917 into the game directory (backing up the originals), and then patches AGI with the correct game ID instead of having to manually use a hex editor. Since the Sierra demo packs use a decrypted AGI already, decryption wasn't required.

It was actually this article that inspired me to write the tool, as I couldn't figure out why some of my AGI games were messed up when I forced Tandy sound with "-t" while running on a VGA based system. After manually upgrading the interpreter and hex editing AGI, I decided to write a tool to automate the process.

Based on your comments, I'll probably release this to the public. Thanks again for the amazing blog!

Anonymous said...

Just to close the loop, the AGI Interpreter Upgrader is now available on the Sierrahelp Wiki:
http://agiwiki.sierrahelp.com/index.php?title=AGI_Interpreter_Upgrader

Great Hierophant said...

Great work. An increasing number of vintage computing enthusiasts now use real Tandy 1000s, and this program will allow them to play the AGI games even if they have an EGA or VGA card installed in their systems without graphics corruption.

Anonymous said...

Found a bug in 1.0 of AGI Interpreter Upgrader which detects 2.43x games as newer than 2.917. The link above now contains version 1.1 which fixes this bug.