12

For no particular reason I started reading up on the original AdLib Music Card, and it's clear that this card was little more than a stock Yamaha YM3812 music chip (aka OPL2) glued to a PC's 8-bit ISA bus slot. One thing that stood out was that the AdLib/YM3812 chip has two general purpose timers, one with a 80 µs and the other with a 320 µs resolution. However, neither the data sheet nor any documentation I could find mentioned any proposed or intended uses for these timers.

A few theories:

  1. It was included by Yamaha to support features in their digital keyboard lines such as clocking accompaniment rhythms or possibly additional downstream audio processing. In other words, it was wired in by AdLib just because, but with no intended use cases.

  2. It was used by music players or games to provide clocking for music playback (similar to generating MIDI ticks) rather than relying on beam counting or some other method for keeping musical time.

  3. It was used to provide further modulation of FM generated sounds in software.

What is interesting is that, even though the AdLib card was built with the glue logic, traces, and pin holes to wire the YM3812 timer IRQ line to a PC bus hardware IRQ line, pin headers were apparently never installed and these lines were never connected, thus AdLib was not actually capable of generating hardware interrupts.

Another curious finding was that, according to some online documentation, the AdLib "will signal a TIMER interrupt (INT 08)" when the time expires. However, with the IRQ line of the YM3812 not connected to anything, I'm not understanding how this is possible. It seems that lacking a way for the card to signal the CPU that its timer has expired would somewhat limit its usefulness.

I'm curious if there were any well-known or common uses for the AdLib's timer. If so, I'd be very curious what historically significant programs, titles, or other out-in-the-open historical source made use of it.

1
  • 1
    Keep in mind the Yamahe OPL chips were not primarily designed to be used in computers - Yamaha created those chips to be used in their range of musical instruments (mainly keyboards), where they worked in a much more restricted environment than in a typical PC. A timer is very valuable there as timing is one of the main aspects of music.
    – tofro
    Apr 10, 2021 at 7:09

2 Answers 2

11

They are just timers that can be used for any purpose anyone can think of for keeping track of time in a system. Just like any other timer.

The timers can be set to elapse after a certain period of counts, and the status of both timers being elapsed or not can be read from the OPL chip status register.

In addition to just reading the status, the timers can signal that they elapsed by triggering the interrupt output pin to go active, and this can be used to trigger an interrupt on a CPU.

It may not have much use in a PC, as there is already a 8253 or 8254 timer. And no sound card has actually connected the OPL chip interrupt output to CPU. There is a unused jumper block on the AdLib card to connect the interrupt to ISA bus signal, but it is not mounted.

Usually sound drivers use the timers for detecting if an OPL chip is present or not. One unused feature of the AdLib card is that it has another unused jumper block, which was originally intended to use for selecting four different base addresses for the card. It was simply hardwired to one address only. Then it would be necessary to detect which address the card is set to, so that is why the detection routine exists in the drivers and manuals.

I recall that some closely related OPL chip, but not necessarily the OPL-2, uses one of the timers to trigger the start of multiple operators synchronously in the rarely used Composite Synthesis Mode.

As a curiosity, the timers and the status register were cloned into Gravis Ultrasound. They were not accessed at the standard AdLib base address 388h, but at the address 228h, which is the alias port of 388h where a Sound Blaster card will have the OPL chip. By using the chip detection technique, it should be possible to detect a Sound Blaster Pro with dual OPL chips, if an OPL is found at both 228h and at 22Ah.

The mention about the card being able to trigger a timer interrupt (IRQ0 is INT8) is false information, it can be a reasonable misunderstanding on the author's part. It is not possible for a stock unmodified AdLib card to generate any interrupts.

7
  • Yeah, the operation of the timer seems pretty straightforward and I wrote some test code for it via the AdLib's registers that shows it seems to work as expected. But yeah, I'm mostly wondering if it ever had some purpose or expected use in a PC OPLx audio card above and beyond simply being a circuitous way to detect the card.
    – 640KB
    Apr 9, 2021 at 19:50
  • The chip is not specifically designed for application in a PC sound card. In many applications it would be very valuable to have on die timer interrupt sources.
    – Retrograde
    Apr 9, 2021 at 19:53
  • 3
    @640KB it was the only way to detect if an AdLib card is present or not, as the only thing you can read back from the whole card is the OPL-2 status register with the three status bits for both timers and the global interrupt. Indeed, this was a chip which was simply put on a PC add-on card with minimal glue logic to make it work.
    – Justme
    Apr 9, 2021 at 19:57
  • I have to wonder if originally AdLib designers had intended to expose the YM timer as a way to provide similar playback clocking to say an MPU-401 running in "intelligent mode" (based on the fact that IRQs were there in retail production except for the jumper pin) but ran into last minute technical problems or something...
    – 640KB
    Apr 9, 2021 at 20:29
  • 2
    @640KB It sure looks like they did think of that. But back then, IRQs were a scarce resource, and there was really no point using a hardware IRQ for another timer, because the PC already contains a timer - the 8253/8254 PIT which already generates system timer interrupts on IRQ0. And it does it with more precision and larger range, though does not allow rates slower than 18.2 Hz. And the IRQ pins on PC cannot be shared. I don't think there would be any technical problems if it did use the IRQ line, it was just found not found worth using.
    – Justme
    Apr 9, 2021 at 20:47
5

The Yamaha Applications Manual (not the Data Sheet) describes how to use the timers and IRQ output.

See https://usermanual.wiki/Document/Yamaha20YM381220Application20Manual.26216546/html Sections 3.1.2 and 3.5.

Even if the chip signal pins were not connected, one use for the timers was to check if the computer had the chip installed.

This Programming Guide for the Adlib card http://www.vgmpf.com/Wiki/images/4/48/AdLib_-_Programming_Guide.pdf gives a procedure on page (6) which sets the timers and then reads the timer registers back. This will obviously not give the expected result if there is no sound card present.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .