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 by the chip and then by a 10-bit number in a register 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 reset 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)
Showing posts with label Technical Discussion. Show all posts
Showing posts with label Technical Discussion. Show all posts
Saturday, October 10, 2015
Tuesday, July 7, 2015
The First Sound Card
The Ad Lib Music Synthesizer Card may not have been the first add-on expansion board for a PC compatible computer that could generate sound, but it was undoubtedly the most important sound card ever made. In this blog entry, I will give an overview of the hardware and software that made Ad Lib synonymous with good PC sound.
Hardware
The Ad Lib came in two revisions, the 1987 version and the 1990 version. The 1987 version has a 6.35mm or 1/4" phono jack connector and the 1990 version has a 3.5mm mini-jack. The 1990 version also has two extra decoupling capacitors to reduce the effects of noise. The audio out can drive passive speakers and lower-impedance headphones.
The card itself was made entirely from off the shelf parts and a pair of specialized sound integrated circuits. All of the 1987 cards and some of the 1990 cards have he part numbers scratched off the Yamaha chips, but some 1990 cards have the part numbers on them. The larger chip is the Yamaha YM-3812 FM Operator Type-L II (OPL2). It is responsible for all audio generation. In FM Synthesis, sound is produced when one sine wave, the modulator wave, modulates another sine wave, the carrier wave. Each sine wave is called an operator and there are eighteen operators in a YM-3812. In the default mode, each pair of operators is assigned a channel, so you have 9 channels available. Each operator can have various settings assigned like Vibrato, Tremolo, ASDR and output level. The settings for each operator pair can be called an instrument. In the alternative mode, twelve pairs of operators are assigned to 6 channels and the rest are used to produce 5 percussion instruments. The smaller chip is the Yamaha YM-3014 Serial Input Floating D/A Converter (DAC-SS). It turns the digital audio output from the YM-3812 into an analog signal suitable for amplification.
Ad Lib's attempt at secrecy was short-lived. By the end of 1989, its competitor Creative Technologies was already advertising its "Killer Card" (which would become the Sound Blaster), which included full Ad Lib compatibility. Ad Lib clones appeared fairly quickly because the card was easy to clone once you figured out what the mystery chips were. Ad Lib released programming information giving the abilities and register specifications for the chips. Because the chips were not custom components (otherwise why scratch the part numbers off?), and it used FM Synthesis, it had almost certainly to come from Yamaha. The price point and chip packaging must have narrowed down Yamaha's IC line considerably. It was only a matter of time before the secret was out, and Ad Lib, a small French-Canadian company at the time, was in no position to obtain exclusive rights to use the chips from Yamaha.
When you look at either genuine board, you instantly notice the Ad Lib company logo. I do not recall seeing an earlier PC expansion card printed circuit board with so striking a design. Most PC expansion boards just have the name of the product labeled in ordinary text somewhere on the card, and many do not even have that, leaving someone to have to deduce the card's identity and function. It would be a long time until we saw something as equally stylish (even though you would only see it when you opened the computer.)
However, you will also notice two sets of solder pads. The first, with the "3 5 2" numbers above it, was to assign an IRQ to the card. The card would fire off an IRQ when after one of the timers had reached zero. None of these three pads are connected and no software would ever expect them to be connected, so this functionality was in practice never used. The timers were typically used polled to auto-detect the card.
The second set of pads, "A B C D", allowed the user to change the I/O address from 388/389H. This allowed the user to put four cards in a single system. The other addresses were 218/219H, 288/289H and 318/319H. Very little software ever supported the Ad Lib at an address other than the default. The days when hardware hackers would routinely modify their hardware with a soldering iron was rapidly coming to a close during Ad Lib's early days.
The Path to Success
When the Ad Lib was first released in 1987, it did not instantly set the PC world alight and inspire software developers with new visions of affordable music. The Ad Lib was marketed first as a music creation device using a program called Visual Composer to put notes on sheet music. It appears to have only come bundled with the Visual Composer software and cost $245.00. Music creation software was nothing new to the PC industry, Electronic Arts Music Construction Set and Mindscape's Bank Street Music Writer were already on the market and had done well. The former worked with a PC Speaker in 1-voice or 4-voice mode, the PCjr. or Tandy 3-voice chip and the latter came with a 6-voice sound board based off the Apple II Mockingboard design. IBM also had a MIDI interface based music card called the IBM Music Feature, but it was very expensive, and other companies like Roland produced MIDI interfaces to control their expensive synthesizers with computer software. Parents were far more likely to buy the cheapest Casio or Yamaha keyboard on sale at Radio Shack for their kids.
In 1988, the card and company's fortunes changed when Sierra Online was looking for good hardware to support in their latest adventure games, which were planned to support full musical scores. The Ad Lib was seen as more capable than the PSG-based solutions then available like the C64's SID chip, which simply did not sound impressive to U.S. composers. Sierra selected the Ad Lib card as its entry-level music solution and other companies followed. The first PC game to support the Ad Lib or any other external sound device (Roland MT-32 & IBM Music Feature) was Sierra's King's Quest IV: The Perils of Rosella. In fact, if you compare the boxes for the 1987 and 1990 versions, you can see that gaming had taken preference over music creation.
Once the Ad Lib became useful for games, a version of the card was released for $195.00 without the Visual Composer software. The price for the Ad Lib was now much more attractive and competitive. Often games would come with a $20 coupon for the card. The next nearest competitor was the Creative Music System/Game Blaster, which at $129.00 competed well in price but poorly in features. The Game Blaster may have had more voices (12 vs. 9 or 6/5) and stereo support, but its PSG-style music generation was not deemed by the press or the public as anywhere near the quality of the Ad Lib's FM Synthesis.
While the PSGs in the Game Blaster and the Tandy could output the same notes on the scale as the Ad Lib, the Ad Lib had sufficient capabilities to advertise to users that they could create something approximating actual instruments. It also sounded somewhat close to the music in most arcade games of the late 80s and early 90s, giving it an edge over devices that sounded like a C64 or a NES. If the Ad Lib had not gained popularity, perhaps it would have been the Game Blaster that fulfilled the PC gaming music niche, but the Ad Lib was supported in thousands of games while the Game Blaster never pushed above 100 games.
The Ad Lib had quite the appeal for people looking for a no-hassles upgrade. The Ad Lib did not require any setting up, there were no user-accessible jumpers or dipswitches on the card. It fit inside any system with a free 8-bit expansion slot. It rarely required you to load a driver before running an application or a game. PGA Tour Golf is one of the few examples I could find of a popular game that requires loading SOUND.COM before beginning the game. Even Ad Lib soon embedded its driver into its application programs. The most interaction people usually had with the card physically was with the volume control.
The Ad Lib was not designed to handle digitized sounds, but some companies were able to get around that by some careful timing writes to set up a level waveform, then feeding 6-bit values to the volume control registers. This in essence allowed the Ad Lib to function like a 6-bit DAC. Activision used it in Battle Tech : The Crescent Hawks' Revenge, Gametek in Super Jeopardy and Interplay in Out of this World. Because sending audio samples directly to the "DAC" required a lot of CPU time, it was seldom used. The rise of the Ad Lib compatible Sound Blaster, with its 8-bit DMA-assisted DAC, soon made this effectively obsolete.
From a programmer's standpoint, the Ad Lib was relatively simple to program for. Programs could automatically detect the card because it had a pair of readable timers on it. For 8088 systems, they could simply just send data to it, but faster systems required software delay loops of increasing length in order to have the card respond appropriately to address and data writes. Unfortunately, the basic Ad Lib and its clones tend to fail when older games are being run in fast 386 and 486 machines, requiring the use of slowdown utilities, cache disabling programs or turning off the turbo button. Eventually, virtually all audio would be handled by middleware drivers from companies like Miles Sound Design which would provide solid if unremarkable Ad Lib support for any system.
An Ad Lib could work with just about any PC or XT with 256KB of RAM and a CGA or better card. However, in late 1988 that combination just was not doing it anymore for the latest games. While the Ad Lib can work with most early games on an 8088 or V20 machine, the results are often unplayably slow. The Ad Lib works much better with a 286 @ 8MHz or better, an EGA graphics card and 640KB of RAM. There were exceptions like Origin's Windwalker, which was programmed before the need to add software delays for faster systems was generally known. That game is best run on an 8088 or V20 machine.
The Ad Lib had something of a love-hate relationship with musicians. Computer musicians in the U.S. in the late 80s were usually thoroughly steeped using MIDI instruments. You could compose a song on a synthesizer keyboard a lot more naturally than in a computer program of the time. The Roland MT-32 and later the Roland Sound Canvas lines of PC MIDI devices were the preeminent external audio devices for PC gaming until digitized audio took over entirely. Most composers at big-box developers like Sierra and Electronic Arts composed with MIDI devices and then transported their music to the MT-32, SC-55 and Ad Lib, but the translation was far easier from MIDI to MIDI devices with built-in samples than MIDI to Ad Lib. So too often Ad Lib music playback paled in comparison to MT-32 and SCC-1 playback.
The Ad Lib did find early advocates at the shareware development houses. The guys at ID Software and Epic MegaGames were often technologically more innovative and more willing to explore the features of their hardware than the larger publishers. Shareware titles supported Ad Lib exclusively at first, then migrated to the Ultrasound and the Sound Canvas. The music in Commander Keen 4-6 and Jill of the Jungle 1-3 (which requires a Sound Blaster) is often very good and hard to imagine being as good on an MT-32. European programmers also were able to coax good music from the Ad Lib. They already had years of experience hacking away at the SID on the C64 and Paula on the Amiga, so this came easy to them. The music for Dune by Cyro Interactive does not loose its essential character on an OPL2 even though it was composed for an OPL3. The songs in Lemmings are very impressive, even compared to the Amiga original.
From a gamer's perspective, purchasing an Ad Lib in the first years following its release was a wise purchase because virtually every game that supported an expansion sound device supported the card. Companies like Sierra, Origin, LucasArts, Microprose, Spectrum Holobyte, Interplay, and Epyx soon followed suit and began supporting the card in more and more of their products. (Airball was a very rare example of a game that supported Innovation SID and Game Blaster but not Ad Lib.) If you look at an early story such as the one published in Computer Gaming World #63 (September, 1989) you can see that every company that was considering sound cards at the time of contact was considering the Ad Lib. When the Sound Blaster came with digitized sound support in 1990, digitized sound was slower to be adopted because the samples took up so much space on floppy disks. It had other features, such as the built-in game port, and a price that was very competitive with the less-featured Ad Lib card. Ad Lib's response to the coming of the Sound Blaster was to reduce its headphone jack to use a mini-jack connector.
Even when the Ad Lib Gold released the OPL3 chip, which has support for stereo output and double the number of FM operators and 4-operator FM Synthesis, game companies rarely supported the advanced features of the newer chip. Even though the OPL3 chip quickly replaced the OPL2 chip in 1992, most music was still designed for the basic OPL2 features.
The Ad Lib was the entry level music device for an astonishing seven years, from 1988 through 1994. Until CD-ROM drives and sample-based MIDI hardware became affordable, Ad Lib FM Synthesis was still the king of PC game music. Early CD-ROM music was far superior musically but extremely inflexible. Ad Lib music occupied little space and could be adjusted instantly to suit the needs of the program. CD-ROM music changing required sending track change or track repeat commands. There would be a pause while the new song was found or the old song was being repeated. CD-ROM also did not do well with short snippets of music. The iMUSE system from LucasArts, which dynamically changed the music according to room and scenes, was feasible with the Ad Lib but impossible with CD-ROM audio. Only with the arrival of Windows 95 was the hardware sufficiently powerful to manage multiple digital streams of voice and music that made the Ad Lib totally obsolete.
Hardware
The Ad Lib came in two revisions, the 1987 version and the 1990 version. The 1987 version has a 6.35mm or 1/4" phono jack connector and the 1990 version has a 3.5mm mini-jack. The 1990 version also has two extra decoupling capacitors to reduce the effects of noise. The audio out can drive passive speakers and lower-impedance headphones.
The card itself was made entirely from off the shelf parts and a pair of specialized sound integrated circuits. All of the 1987 cards and some of the 1990 cards have he part numbers scratched off the Yamaha chips, but some 1990 cards have the part numbers on them. The larger chip is the Yamaha YM-3812 FM Operator Type-L II (OPL2). It is responsible for all audio generation. In FM Synthesis, sound is produced when one sine wave, the modulator wave, modulates another sine wave, the carrier wave. Each sine wave is called an operator and there are eighteen operators in a YM-3812. In the default mode, each pair of operators is assigned a channel, so you have 9 channels available. Each operator can have various settings assigned like Vibrato, Tremolo, ASDR and output level. The settings for each operator pair can be called an instrument. In the alternative mode, twelve pairs of operators are assigned to 6 channels and the rest are used to produce 5 percussion instruments. The smaller chip is the Yamaha YM-3014 Serial Input Floating D/A Converter (DAC-SS). It turns the digital audio output from the YM-3812 into an analog signal suitable for amplification.
Ad Lib's attempt at secrecy was short-lived. By the end of 1989, its competitor Creative Technologies was already advertising its "Killer Card" (which would become the Sound Blaster), which included full Ad Lib compatibility. Ad Lib clones appeared fairly quickly because the card was easy to clone once you figured out what the mystery chips were. Ad Lib released programming information giving the abilities and register specifications for the chips. Because the chips were not custom components (otherwise why scratch the part numbers off?), and it used FM Synthesis, it had almost certainly to come from Yamaha. The price point and chip packaging must have narrowed down Yamaha's IC line considerably. It was only a matter of time before the secret was out, and Ad Lib, a small French-Canadian company at the time, was in no position to obtain exclusive rights to use the chips from Yamaha.
When you look at either genuine board, you instantly notice the Ad Lib company logo. I do not recall seeing an earlier PC expansion card printed circuit board with so striking a design. Most PC expansion boards just have the name of the product labeled in ordinary text somewhere on the card, and many do not even have that, leaving someone to have to deduce the card's identity and function. It would be a long time until we saw something as equally stylish (even though you would only see it when you opened the computer.)
However, you will also notice two sets of solder pads. The first, with the "3 5 2" numbers above it, was to assign an IRQ to the card. The card would fire off an IRQ when after one of the timers had reached zero. None of these three pads are connected and no software would ever expect them to be connected, so this functionality was in practice never used. The timers were typically used polled to auto-detect the card.
The second set of pads, "A B C D", allowed the user to change the I/O address from 388/389H. This allowed the user to put four cards in a single system. The other addresses were 218/219H, 288/289H and 318/319H. Very little software ever supported the Ad Lib at an address other than the default. The days when hardware hackers would routinely modify their hardware with a soldering iron was rapidly coming to a close during Ad Lib's early days.
The Path to Success
When the Ad Lib was first released in 1987, it did not instantly set the PC world alight and inspire software developers with new visions of affordable music. The Ad Lib was marketed first as a music creation device using a program called Visual Composer to put notes on sheet music. It appears to have only come bundled with the Visual Composer software and cost $245.00. Music creation software was nothing new to the PC industry, Electronic Arts Music Construction Set and Mindscape's Bank Street Music Writer were already on the market and had done well. The former worked with a PC Speaker in 1-voice or 4-voice mode, the PCjr. or Tandy 3-voice chip and the latter came with a 6-voice sound board based off the Apple II Mockingboard design. IBM also had a MIDI interface based music card called the IBM Music Feature, but it was very expensive, and other companies like Roland produced MIDI interfaces to control their expensive synthesizers with computer software. Parents were far more likely to buy the cheapest Casio or Yamaha keyboard on sale at Radio Shack for their kids.
In 1988, the card and company's fortunes changed when Sierra Online was looking for good hardware to support in their latest adventure games, which were planned to support full musical scores. The Ad Lib was seen as more capable than the PSG-based solutions then available like the C64's SID chip, which simply did not sound impressive to U.S. composers. Sierra selected the Ad Lib card as its entry-level music solution and other companies followed. The first PC game to support the Ad Lib or any other external sound device (Roland MT-32 & IBM Music Feature) was Sierra's King's Quest IV: The Perils of Rosella. In fact, if you compare the boxes for the 1987 and 1990 versions, you can see that gaming had taken preference over music creation.
Once the Ad Lib became useful for games, a version of the card was released for $195.00 without the Visual Composer software. The price for the Ad Lib was now much more attractive and competitive. Often games would come with a $20 coupon for the card. The next nearest competitor was the Creative Music System/Game Blaster, which at $129.00 competed well in price but poorly in features. The Game Blaster may have had more voices (12 vs. 9 or 6/5) and stereo support, but its PSG-style music generation was not deemed by the press or the public as anywhere near the quality of the Ad Lib's FM Synthesis.
While the PSGs in the Game Blaster and the Tandy could output the same notes on the scale as the Ad Lib, the Ad Lib had sufficient capabilities to advertise to users that they could create something approximating actual instruments. It also sounded somewhat close to the music in most arcade games of the late 80s and early 90s, giving it an edge over devices that sounded like a C64 or a NES. If the Ad Lib had not gained popularity, perhaps it would have been the Game Blaster that fulfilled the PC gaming music niche, but the Ad Lib was supported in thousands of games while the Game Blaster never pushed above 100 games.
The Ad Lib had quite the appeal for people looking for a no-hassles upgrade. The Ad Lib did not require any setting up, there were no user-accessible jumpers or dipswitches on the card. It fit inside any system with a free 8-bit expansion slot. It rarely required you to load a driver before running an application or a game. PGA Tour Golf is one of the few examples I could find of a popular game that requires loading SOUND.COM before beginning the game. Even Ad Lib soon embedded its driver into its application programs. The most interaction people usually had with the card physically was with the volume control.
The Ad Lib was not designed to handle digitized sounds, but some companies were able to get around that by some careful timing writes to set up a level waveform, then feeding 6-bit values to the volume control registers. This in essence allowed the Ad Lib to function like a 6-bit DAC. Activision used it in Battle Tech : The Crescent Hawks' Revenge, Gametek in Super Jeopardy and Interplay in Out of this World. Because sending audio samples directly to the "DAC" required a lot of CPU time, it was seldom used. The rise of the Ad Lib compatible Sound Blaster, with its 8-bit DMA-assisted DAC, soon made this effectively obsolete.
From a programmer's standpoint, the Ad Lib was relatively simple to program for. Programs could automatically detect the card because it had a pair of readable timers on it. For 8088 systems, they could simply just send data to it, but faster systems required software delay loops of increasing length in order to have the card respond appropriately to address and data writes. Unfortunately, the basic Ad Lib and its clones tend to fail when older games are being run in fast 386 and 486 machines, requiring the use of slowdown utilities, cache disabling programs or turning off the turbo button. Eventually, virtually all audio would be handled by middleware drivers from companies like Miles Sound Design which would provide solid if unremarkable Ad Lib support for any system.
An Ad Lib could work with just about any PC or XT with 256KB of RAM and a CGA or better card. However, in late 1988 that combination just was not doing it anymore for the latest games. While the Ad Lib can work with most early games on an 8088 or V20 machine, the results are often unplayably slow. The Ad Lib works much better with a 286 @ 8MHz or better, an EGA graphics card and 640KB of RAM. There were exceptions like Origin's Windwalker, which was programmed before the need to add software delays for faster systems was generally known. That game is best run on an 8088 or V20 machine.
The Ad Lib had something of a love-hate relationship with musicians. Computer musicians in the U.S. in the late 80s were usually thoroughly steeped using MIDI instruments. You could compose a song on a synthesizer keyboard a lot more naturally than in a computer program of the time. The Roland MT-32 and later the Roland Sound Canvas lines of PC MIDI devices were the preeminent external audio devices for PC gaming until digitized audio took over entirely. Most composers at big-box developers like Sierra and Electronic Arts composed with MIDI devices and then transported their music to the MT-32, SC-55 and Ad Lib, but the translation was far easier from MIDI to MIDI devices with built-in samples than MIDI to Ad Lib. So too often Ad Lib music playback paled in comparison to MT-32 and SCC-1 playback.
The Ad Lib did find early advocates at the shareware development houses. The guys at ID Software and Epic MegaGames were often technologically more innovative and more willing to explore the features of their hardware than the larger publishers. Shareware titles supported Ad Lib exclusively at first, then migrated to the Ultrasound and the Sound Canvas. The music in Commander Keen 4-6 and Jill of the Jungle 1-3 (which requires a Sound Blaster) is often very good and hard to imagine being as good on an MT-32. European programmers also were able to coax good music from the Ad Lib. They already had years of experience hacking away at the SID on the C64 and Paula on the Amiga, so this came easy to them. The music for Dune by Cyro Interactive does not loose its essential character on an OPL2 even though it was composed for an OPL3. The songs in Lemmings are very impressive, even compared to the Amiga original.
From a gamer's perspective, purchasing an Ad Lib in the first years following its release was a wise purchase because virtually every game that supported an expansion sound device supported the card. Companies like Sierra, Origin, LucasArts, Microprose, Spectrum Holobyte, Interplay, and Epyx soon followed suit and began supporting the card in more and more of their products. (Airball was a very rare example of a game that supported Innovation SID and Game Blaster but not Ad Lib.) If you look at an early story such as the one published in Computer Gaming World #63 (September, 1989) you can see that every company that was considering sound cards at the time of contact was considering the Ad Lib. When the Sound Blaster came with digitized sound support in 1990, digitized sound was slower to be adopted because the samples took up so much space on floppy disks. It had other features, such as the built-in game port, and a price that was very competitive with the less-featured Ad Lib card. Ad Lib's response to the coming of the Sound Blaster was to reduce its headphone jack to use a mini-jack connector.
Even when the Ad Lib Gold released the OPL3 chip, which has support for stereo output and double the number of FM operators and 4-operator FM Synthesis, game companies rarely supported the advanced features of the newer chip. Even though the OPL3 chip quickly replaced the OPL2 chip in 1992, most music was still designed for the basic OPL2 features.
Saturday, June 27, 2015
NES Hardware Explained
Hardware :
The basic Famicom/NES consists of a 40-pin Central Processing Unit (CPU), a 40-pin Picture Processing Unit (PPU), two 2KB Static RAMs, and six standard logic chips. The front loader NES also contains a lockout chip and an extra standard logic chip, but they are not integral to the console's function except as a security measure. Every NES has 2x7pin controller ports, a power button and a reset button and an RF modulator. Front loaders also have composite video and (mono) audio outputs. A very few rare Top Loaders have a Nintendo Multi-out port instead of an RF modulator. The last top loaders with improved picture quality (RF or Nintendo Multi-out) use a newer motherboard that consolidates three of the standard logic chips into a Nintendo custom chip.
There were also rare devices that Nintendo released that used NES cartridges. These include the Sharp Nintendo Television, which was a 13 or 19" TV on top of a front loading NES. There also was the M82 Demonstration Unit that could hold 12 NES cartridges and allow for timed play in stores.
The NES power adapter is a step down converter that converts 120VAC or 240VAC into 9VAC and 1.3A. AC to DC conversion is done inside the console. A DC power adapter with a suitable plug can also be used so long as the step down specs are met. Polarity of the AC adapter's connector is irrelevant.
The RF switch is an autoswitching type, meaning that there is no TV/Game switch on it as there were with older consoles. When the NES turns on, it sends a signal of sufficient strength to automatically switch from the TV video signal to the NES video signal. You can use a TV/Game switch if that is all you have available.
Specifications :
CPU - 2A03 running at 1.79MHz (NTSC) or 2C0 7 running at 1.66MHz (PAL). The 2A03 contains a full 6502 CPU core with all unofficial opcodes but with a disabled decimal mode.
CPU Internal Memory - 19 Audio Processing Unit (APU) Registers, 2 I/O Registers, 1 Sprite DMA register
CPU External Memory - 2KB CPU RAM in the console + 32KB ROM and 8KB (optional) RAM in cartridge*
PPU - 2C02 running at 5.37MHz (NTSC) or 2C07 running at 5.32MHz (PAL). The PPU can access 2 sets of 256 tiles for background and sprite graphics. It can assign up to three distinct colors for a background or sprite tile. Each set of 16x16 background tiles displayed on the screen must share the same palette settings. The PPU is capable of scrolling horizontally and vertically by one pixel for smooth scrolling.
PPU Internal Memory - 8 Control Registers + 256 bytes + 32 bytes + 25 bytes
PPU External Memory - 2KB PPU RAM in the console + 8KB ROM and/or RAM in cartridge*
* - Limits without bankswitching hardware
PPU Resolution and Frame Rate : 256x240@60.0988fps (NTSC)/50fps (PAL), 224 lines typically viewable
Number of Colors in Palette : 54 distinct entries (out of 64) x 8 combinations of color emphasis bits = 432 colors
Number of Colors on-screen : 25 (1 Universal Background Color + 12 Background Palette Colors + 12 Sprite Colors)
Number of Sprites : 64 at 8x8 resolution or up to 32 at 8x16 resolution
Number of Sprites per Line : 8
Number of Audio Channels : 5 (2 x Pulse, Triangle, Noise, PCM)
APU Features : Variable duty-cycle rectangular waves (12.5%, 25/75%, 50%) for the two pulse channels, independent timers for all channels and length counters (automatic shut off) for first four channels, frame counter, volume envelope for pulse and noise channels, sweep unit for pulse channels, short and long noise mode (short mode only available on 2A03E or higher CPU revisions), 7-bit PCM samples or 1-bit Delta Modulation, internal mixer for the two pulse channels on one output pin and the triangle, noise and PCM on another output pin.
Standard Controller : 4-way directional pad and 4 buttons, digital latched serial bitstream interface
Cartridge Features :
Number of Games with extra Work RAM : 89
Number of Games with battery backed Work RAM : 54 (out of 89)
Number of Games with extra CHR-RAM - 3
Smallest NES Cartridge Size : 24KB
Typical Cartridge Sizes : 24KB, 32KB, 40KB, 48K, 64KB, 96KB, 128KB, 160KB, 192KB, 256KB, 320KB, 384KB, 512KB
Median Cartridge Size : 256KB
Largest NES Cartridge Size : 768KB Licensed, 2MB Unlicensed
Most Common Memory Controller hardware : MMC1
Number of games using hardwired Horizontal Mirroring - 86
Number of games using hardwired Vertical Mirroring - 209
Number of games using hardwired One Screen Mirroring - 32
Licensed Game PCB Manufacturers : Nintendo, Konami (14 games), Acclaim (15 games), Virgin Games (1 games), Sunsoft (1 games).
Graphics Basics :
The NES uses a complex scheme to draw graphics. The 2KB of internal PPU RAM holds two name tables and the attribute tables for the background graphics. Each byte entry in a 32x30 name table points to an 8x8 graphics tile in CHR ROM or CHR RAM in the cartridge and tells the PPU to display that tile at a certain place on the screen. Each byte entry in the attribute table selects the background palette entries that each set of 16x16 tiles will use. There are four sets of palette entries consisting of three colors chosen from the 54 colors the NES usually displays and the universal background color. This creates the background graphics.
The PPU RAM has space for two name tables and attribute tables. The typical use for two sets of background graphics is to aid in scrolling. One of the more impressive capabilities of the NES compared to earlier consoles is that it can scroll smoothly one column or line of pixels at a time, even though its graphics are tile based. Many NES cartridges can be wired so that the graphics pages can be mirrored horizontally or mirrored vertically. When the pages are mirrored vertically, scrolling the game horizontally becomes easier. Likewise, when the pages are mirrored horizontally, scrolling the game vertically becomes easier. Games that scroll both horizontally and vertically like Metroid or scroll diagonally like Bionic Commando typically have hardware to allow for fast mirroring changes in software. Two games add an extra 2KB of PPU RAM on the cartridge to allow for four pages of background graphics.
Sprites are controlled by a special 256 byte memory area internal to the PPU called Object Attribute Memory (OAM). Each 8x8 sprite uses 4 bytes of the memory area, and the bytes select the tile to be displayed from the cartridge's CHR ROM or CHR RAM to represent the sprite, the X and Y coordinates on the screen where the sprite is to be displayed, which of the 4 palettes of 3 color the sprite will choose for color and whether the sprite is to be flipped horizontally or vertically. Each sprite palette has a transparency color by which you can see the background graphics through clear pixels. Typically, the CPU writes the values for all 64 sprites at a time. There is also a special buffer that is not accessible by the CPU of 32 bytes which represent the data for the 8 sprites allowed on a line at a time. When there are more than 8 sprites on a line, the PPU cannot display them all, resulting in flickering.
How the CPU Controls the System :
The NES is almost unique among consoles up to that point because it uses a dual bus design. The CPU has its own address and data bus to its internal RAM and the cartridge PRG ROM and (if any) PRG RAM. The PPU has a separate address and data bus to access its internal RAM and the cartridge CHR ROM or CHR RAM. The CPU reads and writes data to memory locations in its memory map assigned to the APU and PPU. These locations correspond to the APU and PPU registers and the input from the controllers.
Even though the PPU has its own address and data bus, it is told what to do by the CPU, it does not have its own specialized instruction set like a true coprocessor. The CPU can read and write to memory anywhere in the PPU's memory addressing space. When a cartridge uses CHR RAM instead of CHR ROM, it is up to the CPU to write the graphics data to fill the CHR RAM with graphics patterns. This adds some flexibility at the cost of some speed and about 200 games use CHR RAM instead of CHR ROM (a couple use both).
Bankswitching Basics :
The NES's CPU can only handle 32KB of ROM at a time. Similarly, the NES's PPU can only handle 8KB of ROM or RAM at a time. Soon after the NES was introduced, ROM sizes on cartridges expanded beyond the combined 40KB that the NES was capable of accessing. The NES had to use extra hardware inside the cartridge to switch in and out areas of ROM outside the 32KB and 8KB addressing limits. With simple logic chips, it was possible to bankswitch additional PRG ROM, CHR ROM or both. Typically, for PRG ROM, there would be a fixed 16KB bank and a switchable 16KB bank, with the game's kernel being held in the fixed bank. Thus, for a game with a 128KB PRG ROM, there were 7 switchable banks. This allowed for larger, more complex games with more music. With CHR ROM, the simple schemes would switch the whole 8KB at a time. A game with 32KB of CHR ROM could have 8 tilesets instead of the usual 2. Games did not typically bankswitch CHR RAM or PRG RAM, but exceptions exist.
Adding extra logic chips made cartridges more difficult to manufacture and could have overwhelmed Nintendo's manufacturing capacities. Nintendo created VLSI memory mapping controller chips to consolidate the functions of many simple logic chips into one chip. The first of these was called the MMC1, and it allowed for bankswitching PRG ROM and CHR ROM, allowing for PRG ROM and PRG RAM to coexist and allowing the mirroring to be changed by the MMC1 at will. By adding a battery to the PRG RAM, games could be saved after the console had been powered off, this is how The Legend of Zelda works. Eventually more complex MMCs would be released, many of which only saw use in a handful of games. MMC1 is the most common VLSI controller and can typically handle 256KB of PRG ROM and 128KB of CHR ROM and 8KB of PRG RAM. There are NES MMC1 games that sacrifice CHR ROM bankswitching to bankswitch 512KB of PRG ROM or 16KB of PRG RAM.
The success of the NES increased the demand for more complex MMCs. Nintendo released the MMC3 chip, which was found in games like Super Mario Bros. 3 and almost as many games as the MMC1. The MMC3 could do all the MMC1 and more, it could bankswitch PRG ROM and CHR ROM in smaller memory slices, it could be accessed faster than MMC1, address more ROM and it had a scanline IRQ counter for easily splitting the screen between a main action area and a status bar. It also provides for much better memory protection so you do not have to hold in reset as you turn the power off as you would on MMC1 games. The maximum amount of memory the MMC3 can handle is 512KB of PRG ROM and 256KB of CHR ROM and 8KB of PRG RAM.
There is an extremely advanced MMC Nintendo released late in the NES's life called the MMC5. In addition to even more flexible bankswitching and more sophisticated scanline IRQ counter compared to the MMC3, it can access 1MB of PRG ROM, 64KB of PRG RAM and 1MB of CHR ROM. That was huge, the largest MMC5 NES cartridge only used 640KB. It also added two pulse and a PCM sound channel, which was never used on the NES because there was no wiring to mix the cartridge audio with the internal audio. It also could implement a vertical split screen scrolling mode, also probably never used in a NES cart. It also had an 8-bit hardware multiplier. Finally, it had 1KB embedded into its chip that could be used for a third name table and attribute table, or be used to allow each background tile to independently select its palette entries.
When NES emulation became popular, various bankswitching methods was given "mapper" numbers. As more and more games became emulated, the number kept expanding. Here is the current mapper list and number of games using each mapper for all NTSC Licensed and Unlicensed games released during the NES's lifetime in the US :
Mapper 0 - 57
Mapper 1 MMC1 - 220
Mapper 2 - 90
Mapper 3 - 63
Mapper 4 MMC3 - 187
Mapper 4 Acclaim MMC3 - 12
Mapper 4 MMC6 - 2
Mapper 5 MMC5 - 8
Mapper 7 - 32
Mapper 9 MMC2 - 2
Mapper 13 - 1
Mapper 64 RAMBO-1 - 5
Mapper 68 Sunsoft-4/Tengen 337007 - 1
Mapper 69 Sunsoft FME-7 - 1
Mapper 206 Namco 109 - 4
Mapper 206 Namco 109/MIMIC-1 - 10
Mapper 11 - 30
Mapper 34 Nintendo - 1
Mapper 34 SEI/AVE - 1
Mapper 41 - 1
Mapper 37 MMC3 - 1
Mapper 47 MMC3 - 1
Mapper 71 - 15
Mapper 79 - 15
Mapper 118 MMC3 - 3
Mapper 119 MMC3 - 2
Mapper 144 - 1
Mapper 158 RAMBO-1 - 1
Mapper 168 - 1
Mapper 228 - 2
Mapper 232 - 5
Mapper 234 - 1
The numbers may change for Europe, but no new major memory controller hardware schemes were introduced there during the NES's lifetime.
CPU/PPU Revisions :
2A03E & 2C02E-0 : Used on early NES front loaders with PCBs labeled NES-CPU-04 and maybe NES-CPU-05.
2A03G & 2C02G-0 : Used on all other NES front loaders and many top loaders, Sharp Nintendo Televisions and NES Top Loaders with the original PCB design. By far the most common combination in a NES.
2A03H & 2C02H-0 : Used on NES Top Loaders.
There are no known compatibility issues among these chips. (The same cannot be said for Famicoms with CPUs and PPUs earlier than the 2A03E/2C02E-0 or the Famicom Titler or Sharp C1 TVs using the 2C03 or 2C05 PPUs.)
Console Generic Logic Chips :
74LS139*
74LS373
74HC368 x 2*
2KBx8 SRAM 100ns x 2
74HCU04 (Front Loader only)
3913A CIC (Nintendo security chip, Front Loader only)
* - These three chips are consolidated into a Nintendo chip labeled BU3266S or BU3270S in the Top Loaders with the redesigned PCB.
Video and Audio Capabilities :
The audio output comes from two CPU pins. On one pins, there are the two square wave channels, on the other channel are the triangle, noise and PCM channels. These two signals are mixed together via resistors and then sent to the audio line output. The NES can be modded for stereo by bypassing the external mixers, but the result will usually sound unbalanced since most of the music will come from one speaker and most of the sound effects from the other speaker.
The NES's PPU generates composite video internally and outputs it on a single pin. This pin is amplified and sent to an RF modulator or RCA jacks for composite video output. S-Video, Component Video and RGB Video are not possible with a 2C02 PPU without a substantial modification.
There are two available mods to improve the NES video. First is the 2C03 PPU mod. This mod requires taking a Nintendo 2C03 PPU chip from a Playchoice-10 arcade board and replacing the 2C02 from a NES with it. This mod has been around for a very long time and for many years it was the only mod to obtain RGB from the NES. You do not have to keep the 2C02, so it is a bit easier than the later mod, which requires you to desolder the PPU without destroying it or the PCB. However, 2C03 chips are very, very expensive. You will need to build an RGB amplifier for the three signals. It also has a tendency to show jailbars in the video output. Finally, it is incompatible with at least seven NES games and will show unintended graphical anomalies in many more. Compare the NTSC palette with the RGB palette :
The newer mod is the NESRGB board, and it is much cheaper and does not have any major compatibility issues. It also allows for S-Video output and can also allow the original composite signal from the 2C02. Component video can be added with a small board.
How the NESRGB Works :
The NES has a 16 color palette for all background tiles and another 16 color palette for all sprite tiles. In simple terms, each of the 16 indexes in either palette corresponds to one of the 64 colors available on the NES. Each active picture pixel the NES outputs will have its color determined by an entry in one of those two 16 color palettes. There is also a universal background color.
There are four pins on a 2C02 PPU that are not used in a stock NES. They are called EXT0-EXT3. They can be set to input or output and are grounded on a NES or a Famicom, which is set to the input mode by default. In output mode, these pins will output the palette entry for every pixel the NES displays. The output is 4-bit and is digital, giving the nucleus of the necessary information to accurately capture the screen output digitally and losslessly.
This is where the NESRGB comes in. It sits on the PPU bus and does several things. First, it tells the PPU to put the EXT pins into output mode and prevents games from telling the PPU to do otherwise. Second, it sits on the PPU's address and data bus to discover the values the CPU is writing into the palette entries. This allows it to assign colors to the palette entries in its own output. Third, it reads the EXT pins to determine the color of the pixels by the palette indexes being output by the pins. However, because the EXT pins only output a 4-bit value, the NESRGB cannot tell whether the palette entry is from the background palettes or the sprite palettes.
In order to derive the 5th bit, which distinguishes the background from the sprite palettes, the NESRGB board will analyze the composite video output. If this did not occur, the backgrounds or the sprites would have the wrong colors because only one palette would be used.
From the composite output signal, the blanking and sync information are also derived, just like a Framemeister. NESRGB combines this with its digitized palette entries and then converts the signal into analog RGB and S-Video. NESRGB offers three palette choices, composite, RGB and improved. If no palette is selected, then the NESRGB operates merely as a passthrough for the original composite video signal. If there is a palette selected, then the original composite video is not available. This is because the NESRGB sends special palette color entries to the real PPU, all background palettes are black and all sprite palettes are white. This allows it to easily compare background and sprite pixels by analyzing the PPU's video output signal. Remember, the EXT pins are outputting palette indexes, not palette color data.
Lockout Chips :
The NES was officially released in many, many countries. One of the lockout chip's functions was to keep people from importing cartridges from another region. There were four lockout chips produced :
3193A/6113A/6113B1 - Used in US, Canada and Brazil
3195A - Used in PAL-B territories (France, Spain, Federal Republic of Germany, Norway, Sweden, Finland, Denmark, The Netherlands, Belgium, Luxembourg, Austria, Greece) and South Korea
3196A - Used in Hong Kong, Asian territories
3197A - Used in PAL-A territories (United Kingdom, Italy, Australia)
3198A - Used by the Famicom Box (a pay-to-play system Nintendo released for Japanese hotels).
The lockout chip can be disabled by removing pin 4 and connecting it to ground.
Sound Overview :
The NES uses the same basic approach to sound generation as other Programmable Sound Generator devices like the AY-3-891x/Yamaha YM-2149, the TI SN76496, the Atari POKEY and the Phillips SAA-1099. At the heart of these chips is a square wave, an electrical signal that rises and falls at equal intervals (the period) a certain number of times per second. These chips can control the frequency of the period, which is given in terms of hertz. Hertz can be equated into notes on a musical scale, so a square wave running at a frequency of 256Hz will sound like a middle C. These chips can also modify the volume of the waveform either directly and some can through an ASDR envelope.
The NES can output two square waves, but unlike any of the above sound chips, can change the period so that the time spent at the high and low ends is not equal. Thus it becomes a rectangular wave. Unlike the Commodore 64, the NES has no difficulty producing strong, distinct rectangular waves. Both of these rectangular wave channels have the same features. A rectangular wave has a high pitched but somewhat hollow sound and typically is used as the main musical instrument in the NES. All these features make it far more suitable for sound effects than the earlier chips.
The third sound channel is a triangle wave, and instead of rising nearly-instantly to the high point, it gets there in steps. The period cannot be changed. The triangle wave is usually a softer sound and is often found acting as the bass line in NES music.
The fourth sound channel is the noise channel. Noise is generated by outputting a long semi-random series of 0s and 1s at a particular frequency. The resulting waveform looks like random spikes. Noise is typically used for sound effects in the older chips, but the NES put it to good use for percussion when there was not sufficient space for samples.
The fifth and last sound channel is for playing samples. It was seldom used in the early years of NES cartridges because sound samples take up a lot of space. This channel plays sound in two different ways. First, it can accept a 7-bit value sent directly to the channel. The second is through delta modulation, whereby a single bit is sent to the channel output over a period of time. A 1 bit indicates an increase in volume, and without further 1 bits, the signal will decay and fall silent. DPCM samples take up less space but the quality is lower than the 7-bit PCM.
Unlike the Famicom, the NES does not send its internal audio to the cartridge connector for mixing with any cartridge audio hardware. Instead, audio could be mixed via the expansion port, but no product was ever released that did that. Therefore, expansion audio just does not exist on the NES unless Famicom cartridges are being used.
74HCU04 (Front Loader only)
3913A CIC (Nintendo security chip, Front Loader only)
* - These three chips are consolidated into a Nintendo chip labeled BU3266S or BU3270S in the Top Loaders with the redesigned PCB.
Video and Audio Capabilities :
The audio output comes from two CPU pins. On one pins, there are the two square wave channels, on the other channel are the triangle, noise and PCM channels. These two signals are mixed together via resistors and then sent to the audio line output. The NES can be modded for stereo by bypassing the external mixers, but the result will usually sound unbalanced since most of the music will come from one speaker and most of the sound effects from the other speaker.
The NES's PPU generates composite video internally and outputs it on a single pin. This pin is amplified and sent to an RF modulator or RCA jacks for composite video output. S-Video, Component Video and RGB Video are not possible with a 2C02 PPU without a substantial modification.
There are two available mods to improve the NES video. First is the 2C03 PPU mod. This mod requires taking a Nintendo 2C03 PPU chip from a Playchoice-10 arcade board and replacing the 2C02 from a NES with it. This mod has been around for a very long time and for many years it was the only mod to obtain RGB from the NES. You do not have to keep the 2C02, so it is a bit easier than the later mod, which requires you to desolder the PPU without destroying it or the PCB. However, 2C03 chips are very, very expensive. You will need to build an RGB amplifier for the three signals. It also has a tendency to show jailbars in the video output. Finally, it is incompatible with at least seven NES games and will show unintended graphical anomalies in many more. Compare the NTSC palette with the RGB palette :
![]() |
| NTSC 2C02 PPU Palette |
![]() |
| RGB 2C03 PPU Palette |
The newer mod is the NESRGB board, and it is much cheaper and does not have any major compatibility issues. It also allows for S-Video output and can also allow the original composite signal from the 2C02. Component video can be added with a small board.
How the NESRGB Works :
The NES has a 16 color palette for all background tiles and another 16 color palette for all sprite tiles. In simple terms, each of the 16 indexes in either palette corresponds to one of the 64 colors available on the NES. Each active picture pixel the NES outputs will have its color determined by an entry in one of those two 16 color palettes. There is also a universal background color.
There are four pins on a 2C02 PPU that are not used in a stock NES. They are called EXT0-EXT3. They can be set to input or output and are grounded on a NES or a Famicom, which is set to the input mode by default. In output mode, these pins will output the palette entry for every pixel the NES displays. The output is 4-bit and is digital, giving the nucleus of the necessary information to accurately capture the screen output digitally and losslessly.
This is where the NESRGB comes in. It sits on the PPU bus and does several things. First, it tells the PPU to put the EXT pins into output mode and prevents games from telling the PPU to do otherwise. Second, it sits on the PPU's address and data bus to discover the values the CPU is writing into the palette entries. This allows it to assign colors to the palette entries in its own output. Third, it reads the EXT pins to determine the color of the pixels by the palette indexes being output by the pins. However, because the EXT pins only output a 4-bit value, the NESRGB cannot tell whether the palette entry is from the background palettes or the sprite palettes.
In order to derive the 5th bit, which distinguishes the background from the sprite palettes, the NESRGB board will analyze the composite video output. If this did not occur, the backgrounds or the sprites would have the wrong colors because only one palette would be used.
From the composite output signal, the blanking and sync information are also derived, just like a Framemeister. NESRGB combines this with its digitized palette entries and then converts the signal into analog RGB and S-Video. NESRGB offers three palette choices, composite, RGB and improved. If no palette is selected, then the NESRGB operates merely as a passthrough for the original composite video signal. If there is a palette selected, then the original composite video is not available. This is because the NESRGB sends special palette color entries to the real PPU, all background palettes are black and all sprite palettes are white. This allows it to easily compare background and sprite pixels by analyzing the PPU's video output signal. Remember, the EXT pins are outputting palette indexes, not palette color data.
Lockout Chips :
The NES was officially released in many, many countries. One of the lockout chip's functions was to keep people from importing cartridges from another region. There were four lockout chips produced :
3193A/6113A/6113B1 - Used in US, Canada and Brazil
3195A - Used in PAL-B territories (France, Spain, Federal Republic of Germany, Norway, Sweden, Finland, Denmark, The Netherlands, Belgium, Luxembourg, Austria, Greece) and South Korea
3196A - Used in Hong Kong, Asian territories
3197A - Used in PAL-A territories (United Kingdom, Italy, Australia)
3198A - Used by the Famicom Box (a pay-to-play system Nintendo released for Japanese hotels).
The lockout chip can be disabled by removing pin 4 and connecting it to ground.
Sound Overview :
The NES uses the same basic approach to sound generation as other Programmable Sound Generator devices like the AY-3-891x/Yamaha YM-2149, the TI SN76496, the Atari POKEY and the Phillips SAA-1099. At the heart of these chips is a square wave, an electrical signal that rises and falls at equal intervals (the period) a certain number of times per second. These chips can control the frequency of the period, which is given in terms of hertz. Hertz can be equated into notes on a musical scale, so a square wave running at a frequency of 256Hz will sound like a middle C. These chips can also modify the volume of the waveform either directly and some can through an ASDR envelope.
The NES can output two square waves, but unlike any of the above sound chips, can change the period so that the time spent at the high and low ends is not equal. Thus it becomes a rectangular wave. Unlike the Commodore 64, the NES has no difficulty producing strong, distinct rectangular waves. Both of these rectangular wave channels have the same features. A rectangular wave has a high pitched but somewhat hollow sound and typically is used as the main musical instrument in the NES. All these features make it far more suitable for sound effects than the earlier chips.
The third sound channel is a triangle wave, and instead of rising nearly-instantly to the high point, it gets there in steps. The period cannot be changed. The triangle wave is usually a softer sound and is often found acting as the bass line in NES music.
The fourth sound channel is the noise channel. Noise is generated by outputting a long semi-random series of 0s and 1s at a particular frequency. The resulting waveform looks like random spikes. Noise is typically used for sound effects in the older chips, but the NES put it to good use for percussion when there was not sufficient space for samples.
The fifth and last sound channel is for playing samples. It was seldom used in the early years of NES cartridges because sound samples take up a lot of space. This channel plays sound in two different ways. First, it can accept a 7-bit value sent directly to the channel. The second is through delta modulation, whereby a single bit is sent to the channel output over a period of time. A 1 bit indicates an increase in volume, and without further 1 bits, the signal will decay and fall silent. DPCM samples take up less space but the quality is lower than the 7-bit PCM.
Unlike the Famicom, the NES does not send its internal audio to the cartridge connector for mixing with any cartridge audio hardware. Instead, audio could be mixed via the expansion port, but no product was ever released that did that. Therefore, expansion audio just does not exist on the NES unless Famicom cartridges are being used.
Thursday, June 18, 2015
Cleaning Saved Information from Famicom Disk System Game Dumps
A lot of Famicom Disk System games save some information to disk. Often this information may be custom levels designed with an in-game level editor, the top scores or the fastest times or the levels beaten. The more ambitious adventure and RPG games would typically offer three save slots to store the player's progress during the game. The use of magnetic media, the Disk Cards, allowed any Famicom Disk System game to save information to the disk. When games are dumped, any information saved will come with them. While this will not diminish the playability of a game, it still cosmetically very unappealing to see "Diskdude" all over the high score lists or hacked games on the file select screen.
Unfortunately, for most games there is no way to restore the game to a pristine, never-played state within the game itself. I have always wanted a tool or utility that could take these disk images and do just that, but since none exists I decided to investigate the images and try to fix them myself. Restoring a Famicom Disk System game to a pristine state is often times more involved than just deleting or zeroing out the last file. The resulting disk image has to work after it has been "cleansed". I used Nestopia UE 1.46 and FDSExplorer 1.63 and my favorite hex editor. A hex to decimal calculator will also come in handy.
Unfortunately, for most games there is no way to restore the game to a pristine, never-played state within the game itself. I have always wanted a tool or utility that could take these disk images and do just that, but since none exists I decided to investigate the images and try to fix them myself. Restoring a Famicom Disk System game to a pristine state is often times more involved than just deleting or zeroing out the last file. The resulting disk image has to work after it has been "cleansed". I used Nestopia UE 1.46 and FDSExplorer 1.63 and my favorite hex editor. A hex to decimal calculator will also come in handy.
Famicom Disk System games come on one or two disks. A game on a single disk can use one or both sides of the disk, two disk games always use four sides. The sides are labeled Side A and Side B. The Disk System's drive was single sided, so the user had to physically eject the disk, remove it from the drive, turn it over and insert the disk. The disk drive can automatically sense when a disk has been inserted and inform the rest of the system.
A straight dump of each side of a Famicom Disk Card will have a size of exactly 65500 bytes. Each subsequent disk side dump is appended to the previous side, so two disk side games will be 131,000 and four disk side games 262,000. Modern Famicom Disk System game dumps use an .fds file extension. They can come with an extra 16-byte header for emulators and flash carts. This header looks like this :
46 44 53 1A 0x 00 00 00 00 00 00 00 00 00 00 00
x = number of disk sides, typically 1, 2 or 4.
The first three bytes show FDS in ASCII and the fourth byte is also used as the MS-DOS End of File byte. The header is extremely basic and is designed to inform an emulator that the file loaded is a true FDS disk image and how many disk sides the game has. While this could have been discerned by the file extension and file size, the FDS image format was created in the days of Nesticle, an MS-DOS based NES emulator. MS-DOS files used 8.3 character/extension file names, so the likelihood that files could be confused was much greater.
Famicom Disk System games have a simple file system. Each file on the disk has a name using up to eight characters, a file number (0-x), an ID number (ditto), a size (up to 32KB) and a type. The three types are Nametable, CHR and PRG. CHR stores graphics tiles, PRG stores code and the Nametable is always the first file on Side A and is used for the Copyright text at the beginning. If the text is not exact, the disk will load no further. Save games are always stored in a PRG type file.
What made this much easier was the fact that Famicom Disk System games always seem to save to the last file on a disk's side. Later in the Disk System's life, (1988) Nintendo used a new drive controller chip that limited the disk drive to writing only to the last file on a disk. The earlier convention became a rule.
Sometimes the save file has an obvious name and is so small it could be nothing else, but for other games it is not so obvious. So the first thing I had to do was to observe which side was being written. Nestopia tells you when a disk is being read or written, so I just played until there was a save. Metroid was almost unique among the games I looked at because it saves information to both sides.
Once I figured out which side was being saved, I opened the disk image in FDSExplorer and looked at the file. For games with three save slots, I simply deleted two and made a third with a file name that was easy to find like ABCDEFGH. With a little deductive reasoning (i.e. looking at the hex patterns and logical reasoning) I could figure out how the file could be corrected so that no save games would be present at startup. Dr. Chaos did not follow the typical rule about writing changes to all files after starting a new game, but its save file is really simple and my image came with one unused file.
On a couple of occasions, I discovered that my image was pristine but the game actually created a file once there was saving. FDSExplorer makes it easy to delete the last file in these cases, but you have to verify that the game creates a file before you delete it. I made it a point to alter no more bytes than was necessary to make the game appear to look pristine. Whether it would actually correspond byte by byte to a pristine, error-less dump of a sealed Disk Card is an issue that may never be known for some games, but for other games the changes are so obvious and minor that it can hardly be doubted that this is how they should have appeared.
Nintendo, for its own first-party games, eventually began to store a backup of a pristine save file elsewhere on the disk. That way, if the save file became corrupted after a write, the game could try to restore the save file so the user could continue to play the game. Hikari Shinwa - Palutena no Kagami is an example of such a game.
Some games will allow you to restore the game to a pristine state via an in-game function. They are detailed below.
Here is a list of the games and what I did to make them "pure".
Akumajou Dracula (all versions) (Konami, 1986)
Information Saved - Three slots, last stage completed and number of continues
Fix : Side A - Zero out last file
NES/Famicom Port : Castlevania/Akumajou Dracula
All Night Nippon Super Mario Bros. (Nintendo 1986)
Information Saved - Number of times you have beaten the game
Fix : Side A - Zero out last file
NES/Famicom Original : Super Mario Bros.
Bubble Bobble (Taito, 1987)
Information Saved - Allows you to select a starting level up to the last level you completed
Fix : Side A - Game creates a save file when you save your level progress, delete file with FDS Explorer
NES Port : Bubble Bobble
Clu Clu Land - Welcome to New Clu Clu Land (Nintendo, 1992)
Information Saved - High scores
Fix : Side A - In the last file, this pattern must repeat ten times : 14 EF EF EF 24 00 00 00
NES/Famicom Connection : Clu Clu Land
Dr. Chaos (Pony Canon, 1987)
Information Saved - Three slots, progress through game
Fix : Side A - Zero out last file, except for the last eight bytes, should say DR.CHAOS in ASCII
NES Port : Dr. Chaos (NTSC Only)
Dracula II - Noroi no Fuuin (Konami, 1987)
Information Saved - Allows you to select a starting level up to the last level you completedtime taken in game
Fix : Side A - Zero out last file
NES Port : Castlevania II : Simon's Quest
Eggerland (HAL Laboratory, 1987)
Information Saved - Rooms completed
Fix : Side B - Start a new game, commit suicide until you see the Game Over screen, then save.
NES/Famicom Connection : Adventures of Lolo 1, 2 & 3, Eggerland - Meikyuu no Fukkatsu
Eggerland - Souzouhe no Tabidachi (HAL Laboratory, 1988)
Information Saved - Allows you to select a starting level up to the last level you completed, saves levels you build with the construction editor in the game.
Fix : Side B - Zero out the last byte in the last file and remove all tiles for all construction levels using the in-game utility, then save.
NES/Famicom Connection : Adventures of Lolo 1, 2 & 3, Eggerland - Meikyuu no Fukkatsu
Hao-Kun no Fushigina Tabi (DOG, 1987)
Information Saved - Three slots, progress through game
Fix : Side A - Delete all three save files in the main menu, then create file one. Immediately close the FDS image in Nestopia. Replace the first seven bytes in the last file with 00 5F 5F 5F 5F 5F 5F.
NES Port : Mystery Quest (NTSC Only)
Hikari Shinwa - Palutena no Kagami (Nintendo, 1986)
Information Saved - Three slots, progress through game, time taken to beat game, high scores
Fix : Side A - Copy hex from REG BACK and paste into REG.SAVE
NES Port : Kid Icarus
Kaettekita Mario Bros. (Nintendo, 1988)
Information Saved - Name, age and gender of players controlling Mario and Luigi, High Scores
Fix : Side A - Rename characters to the default, use hiragana for Mario and Luigi, set the ages to 00 and the gender to male (おとこ). Mario is まりお and Luigi is るいーじ in Nintendo's preferred hiragana spelling.
Side B - Copy over all bytes in file 9 to file 10
NES Port : Mario Bros. Classic Series (PAL Only)
NES/Famicom Connection : Mario Bros.
Knight Move (Nintendo, 1990)
Information Saved - High Scores
Fix : Side A - Save file is split into four sections of 48 bytes. The game uses the first and last section for saving the scores, so copy the second or third section to the first and fourth section.
NES/Famicom Connection : Tetris/Tetris (designed by Alexey Pajitnov)
Legend of Zelda 2, The - Link no Bouken (Nintendo, 1987)
Information Saved - Three slots, progress through game, number of deaths
Fix : Side A - Kill all save files on the file select screen, the game will reset each slot as after it is killed. The No-Intro dumps for the Legend of Zelda 2 for the FDS will not allow you to see or take any items like heart containers and magic jars for their first save slot. This can be easily fixed by entering a new name for the first save slot, then killing the the name and entering it again.
NES Port : Zelda II - The Adventure of Link
Metroid (all versions) (Nintendo, 1986)
Information Saved - Three slots, progress through game, time taken in game, ending earned for last game.
Fix : Side B - Create a new character for file one, then start the game. Immediately close the FDS image in Nestopia. Do the same for file two and three. Do NOT save the game. This causes the game to reset the save information for the world for the three files because the game will write to side B when you create a new character. Side A - Overwrite the first three bytes with 80 and the next forty eight bytes with FF. Zero out the rest of the file. This deletes character information.
NES Port : Metroid
Nazo no Kabe - Block Kuzushi (Konami, 1986)
Information Saved - Allows you to select a starting level up to the last level you completed
Fix : Side A - Delete all three save files, then create file one. Start the game, lose all your balls, then save and quit. In the last file, replace the first sixteen bytes with the second sixteen bytes. These two sets of bytes should be identical to the third set of sixteen bytes. The last sixteen bytes of the file should be 00.
NES Port : Crackout (PAL Only)
Nazo no Murasamejou (Nintendo, 1986)
Information Saved - Three slots, progress through game
Fix : Side A - Kill all save files on the file select screen, the game will reset each slot as after it is killed.
NES/Famicom Connection : The Legend of Zelda/Zelda no Densetsu 1 - The Hyrule Fantasy (engine)
Section-Z (Capcom, 1987)
Information Saved - Three slots, progress through game
Fix : Side A - Delete all three character saves in the game menu, then create file one. Start the game, get killed, then save and quit. In the last file, replace the first twenty three bytes with the second twenty three bytes. These two sets of bytes should be identical to the third set of twenty three bytes. The last four bytes of the file should be 00.
NES Port : Section Z
Super Mario Bros. 2 (Nintendo 1986)
Information Saved - Number of times you have beaten the game
Fix : Side A - Zero out last file
NES/Famicom Connection : Super Mario Bros. 1, 3
Vs. Excitebike (Nintendo, 1988)
Information Saved - Race times and data for custom tracks 4-7 designed with built in construction editor.
Fix : Side A - Delete the last file
NES/Famicom Connection : Excitebike
Winter Games (Pony Canon, 1987)
Information Saved - Records for each event
Fix : Side B - Zero out last file
NES Port : Winter Games (NTSC Only)
Wrecking Crew (Nintendo, 1989)
Information Saved - Custom level designs for phases 1-4 designed with built in construction editor.
Fix : Side A - Delete all objects on each of the four phases ofthe design part, then save.
NES/Famicom Original : Wrecking Crew
Yume Koujou Doki Doki Panic (Nintendo/Fuji Television, 1987)
Information Saved - Worlds completed by each character.
Fix : Side A - Zero out first four bytes in last file
NES/Famicom Port : Super Mario Bros. 2/Super Mario Bros. USA
Zelda no Densetsu - The Hyrule Fantasy (Prototype and final) (Nintendo, 1986)
Information Saved - Three slots, progress through game, second quest, number of deaths
Fix : Side B - Kill all save files on the file select screen, the game will reset each slot as after it is killed.
NES/Famicom Port : The Legend of Zelda/Zelda no Densetsu 1 - The Hyrule Fantasy
Further notes :
There are many, many other FDS games that save information to disk. I have only given a sample of the games which either have a NES port, are part of an NES series or substantially related to an NES game. Many Famicom Disk System games are Japanese-text heavy, which can make it more difficult to purify the image.
Nestopia does not save to the disk image by default, but can in its options menu. You should also change the option so that you can see the status Reading Disk/Writing Disk in Nestopia's status bar. Always make backups when experimenting. Nestopia saves to an image when the image is closed or the user quits Nestopia.
Unfortunately, FDSExplorer does not allow you to edit files inside a disk image directly, it is easiest to use a Hex Editor and search for the bytes you wish to alter.
This list really only scratches the surface, but I wanted to focus on games that were ported in some way or form on or related to a NES cartridge. Since my Japanese is "a little rusty", I did not want to tackle the more Japanese text-heavy games.
Monday, October 13, 2014
Battery Life in the 8-bit Game Boy Line
When the Game Boy was released in 1989, it was the first portable video game system using interchangeable cartridges. (While the Microvision had been released in 1979, the games themselves attached to the base and provided controls and CPU as well as program code). In the palms of the player's hands they had much of the power of the NES. However, its rivals the Atari Lynx, Sega Game Gear & Nomad and the NEC Turbo Express, could have easily eclipsed it with their color screens.
The Game Boy had two huge advantages over its rivals. First, it came with the killer-app pack-in, Tetris. Second, it had far superior battery life to any of its rivals. In this post, I will discuss battery life among the four members of the 8-bit Game Boy line, the original DMG Game Boy, the Game Boy Pocket, the Game Boy Light and the Game Boy Color.
1. Game Boy DMG-01
The DMG-01 takes four AA (LR6) batteries and there was an official Rechargeable Battery Pack, DMG-03, available at launch, that could provide portable or AC power. Regular Alkaline AA batteries are rated to provide a nominal 1.5 volts and 1800-2400 milli-amperes per hour (1A = 1,000mA) depending on the energy drain of the powered device.
The DMG doesn't tell you directly everything you need to know about its power requirements. On the back of the DMG, the text states that the DMG is rated for 6 volts and 0.7 watts. If you look in the Game Boy Owner's Manual, (p.12) you will see that this is not the maximum power consumption for the device, just the approximate usage. Power consumption depends on what game is used and what it is doing. The manual gives approximately 15 hours on 4xAA, but I have seen other estimates of 35 hours.
Four out of five of the launch titles for the DMG, Alleyway, Baseball, Tennis, Tetris would have required fairly little power. These small (32-64KB) games only tend to animate a small portion of the screen, leave lots of undrawn "white space", do not use extra RAM in the cartridge, are often silent or do not always have music playing and rarely scroll the screen. The fifth launch title, Super Mario Land, is a substantially more complex game and would have a greater power draw. Larger (128-512KB) and more complex games after these launch titles would almost certainly draw more.
Back to our DMG, we need to determine the amperage the device requires. Fortunately the relationship between volts, amps and watts is simple :
W = V x A
Dividing the wattage, .7, by the voltage, 6, we get .11666A, or 116.66mA. If we look at the rechargeable battery pack specs, we see that it provides 150mA, confirming the ampere requirements for the DMG.
The DMG and its successors connect its batteries in series so that the output voltage is the sum of the output voltage of each individual battery. So four 1.5v AA batteries will give a voltage of 6v. Unfortunately, the mAh available to the Game Boy does not increase with extra batteries. If the batteries were connected in parallel, it would increase but the voltage available would only be 1.5v, which is nowhere near sufficient to drive the device. Thus you get a tradeoff, either you increase the voltage or the current that can be provided, but not both.
The rechargeable battery pack also tells us that it provides 4.8v to the Game Boy. Rechargeable AA batteries like NiCd and NiMH batteries provide a nominal 1.2v per cell. NiMH was just coming on the market in 1989, and the rechargeable battery pack used NiCd batteries. However, the Game Boy is fairly tolerant of the variance between 6v and 4.8v, probably because it uses 5v logic. Besides, depending on the quality of the Alkalines being used, that 1.5v per cell may be very nominal indeed. Moreover, the voltage of an alkaline declines over time, whereas a modern NiMH battery's voltage remains much more constant until it reaches the point of discharge.
Now we come to the issue of mAh. Consider the following datasheet :
http://data.energizer.com/PDFs/E91.pdf
As we have determined, the Game Boy requires an average of 116.66mA to operate. According to the Milliamp-Hours Capacity, at that amperage requirement the battery can provide approximately 2400mAh. If we divide the mA by the mAh, we get 20.57 hours. Nintendo's estimate may have been a bit conservative here, but they could have been thinking ahead for the more complex games to come.
Nintendo was not only introducing a new video game console, it was introducing a new video game concept. It had to convince buyers that they should buy an expensive hand-held video game machine and its cartridges. It also had to show that the simple games from Tiger Electronics simply were not good enough. First impressions counted a great deal, and Nintendo could not afford to fudge the battery life figures too much. This was especially true because of how crucial battery life was to the hand-held video game market. Nintendo's success rested in no small part on its battery life. You could get 15-20 hours out of a Game Boy on a fresh 4-pack of batteries. Its competitors required 6 batteries and could give you six hours at best.
2. Game Boy Pocket MGB-001
The Pocket was the second iteration of the Game Boy line, released in 1996. This was a comparatively slimmer device, as its name implies. The Pocket takes 2xAAA (LR03) batteries and has power requirements of 3v and 0.7W. Thus, although the Pocket's logic may require fewer volts to operate, it requires double the amps, 233.33mA. Therefore the actual power to operate the Pocket is unchanged from the DMG.
The official Game Boy Pocket A/C Adapter from Nintendo, MGB-005, outputs 3v and 300mA. A similar third-party adapter from Hori outputs 350mA. The Pocket A/C Adapters are to be used with the Game Boy Light and Color. In Japan there was a rechargeable battery pack for the Pocket.
The use of AAA batteries kills the battery life of this machine. An Alkaline AAA battery has the same voltage as an AA battery, 1.5, but only provides 850-1200mAh. There is only about half the energy available to the Pocket as there is to the DMG. I have seen quotes of battery life of 8-10 hours for the Pocket.
If we take the datasheet here as a guide :
http://data.energizer.com/PDFs/E92.pdf
We can see that at 233.33mA, we are only going to get about 700mAh out of our good AAAs. This gives us a pathetic 3 hours. Perhaps Nintendo was measuring it against the titles that were available in 1994-1995, such as Kirby's Dream Land 2 and Donkey Kong. The strict approximation doesn't seem to hew to the reported battery life, which demonstrates that the Nintendo or the battery makers were treating the issue of battery life very conservatively.
3. Game Boy Light MGB-101
The Game Boy Light, released only in Japan, functions like the Game Boy Pocket with a switch to activate an electro-luminescent backlight. The Light uses 2xAA batteries and boasts 20 hours of play without the backlight and 12 hours with it on. The power requirements have also decreased slightly to 3v, 0.6w. Thus it requires an average of 200mA to run.
According to the datasheet, at 200mA we have approximately 2000mAh. If we divide the mA by the mAh, we get about 10 hours on a pair of AAs. One hopes that the stated power requirements were taking the backlight into consideration.
4. Game Boy Color CGB-001
The Color has the specs of the Light without the backlight. I have seen quotes of battery life of 20-35 hours.
Now the Color has the same power ratings as the Light, but this time it has a color screen, three times the RAM and a CPU that can run twice as fast as the Light, Pocket and DMG. The games themselves are typically larger, from 1-4MB. I suspect that the battery life is more impressive if it runs monochrome Game Boy games than if it is running Color Game Boy games because those extra features are not being used.
Compared to the original DMG, the Color seems to have less life. However, the Color can run on 2 AAs whereas the DMG requires 4. I would say that with 4 AA batteries (meaning you need to replace the batteries once), you can probably get the same amount of playtime as you would with a DMG.
The videos here may be very instructive :
https://www.youtube.com/watch?v=XsU4AcYhjy8
https://www.youtube.com/watch?v=VgKdEa06qUs
The video maker in his first video gives a battery life of 31hrs 12mins for a DMG and in the second video 35hrs 45mins for a Color. In the later video, the relatively short time for the Game Boy is because one of his children turned it off prematurely. However, both systems were running monochrome Game Boy games, and I cannot tell for certain what game was in the DMG, but it appears both videos used the same game in the DMG. I think it is Super Mario Land. (For the Color it was Top Rank(ing) Tennis). Super Mario Land has an attract mode, but Top Ranking Tennis has animation and music on its title screen, so the cartridges seem pretty fair. However, if a true Color game were being played, I would certainly think that the time would be significantly shorter.
The Game Boy had two huge advantages over its rivals. First, it came with the killer-app pack-in, Tetris. Second, it had far superior battery life to any of its rivals. In this post, I will discuss battery life among the four members of the 8-bit Game Boy line, the original DMG Game Boy, the Game Boy Pocket, the Game Boy Light and the Game Boy Color.
1. Game Boy DMG-01
The DMG-01 takes four AA (LR6) batteries and there was an official Rechargeable Battery Pack, DMG-03, available at launch, that could provide portable or AC power. Regular Alkaline AA batteries are rated to provide a nominal 1.5 volts and 1800-2400 milli-amperes per hour (1A = 1,000mA) depending on the energy drain of the powered device.
The DMG doesn't tell you directly everything you need to know about its power requirements. On the back of the DMG, the text states that the DMG is rated for 6 volts and 0.7 watts. If you look in the Game Boy Owner's Manual, (p.12) you will see that this is not the maximum power consumption for the device, just the approximate usage. Power consumption depends on what game is used and what it is doing. The manual gives approximately 15 hours on 4xAA, but I have seen other estimates of 35 hours.
Four out of five of the launch titles for the DMG, Alleyway, Baseball, Tennis, Tetris would have required fairly little power. These small (32-64KB) games only tend to animate a small portion of the screen, leave lots of undrawn "white space", do not use extra RAM in the cartridge, are often silent or do not always have music playing and rarely scroll the screen. The fifth launch title, Super Mario Land, is a substantially more complex game and would have a greater power draw. Larger (128-512KB) and more complex games after these launch titles would almost certainly draw more.
Back to our DMG, we need to determine the amperage the device requires. Fortunately the relationship between volts, amps and watts is simple :
W = V x A
Dividing the wattage, .7, by the voltage, 6, we get .11666A, or 116.66mA. If we look at the rechargeable battery pack specs, we see that it provides 150mA, confirming the ampere requirements for the DMG.
The DMG and its successors connect its batteries in series so that the output voltage is the sum of the output voltage of each individual battery. So four 1.5v AA batteries will give a voltage of 6v. Unfortunately, the mAh available to the Game Boy does not increase with extra batteries. If the batteries were connected in parallel, it would increase but the voltage available would only be 1.5v, which is nowhere near sufficient to drive the device. Thus you get a tradeoff, either you increase the voltage or the current that can be provided, but not both.
The rechargeable battery pack also tells us that it provides 4.8v to the Game Boy. Rechargeable AA batteries like NiCd and NiMH batteries provide a nominal 1.2v per cell. NiMH was just coming on the market in 1989, and the rechargeable battery pack used NiCd batteries. However, the Game Boy is fairly tolerant of the variance between 6v and 4.8v, probably because it uses 5v logic. Besides, depending on the quality of the Alkalines being used, that 1.5v per cell may be very nominal indeed. Moreover, the voltage of an alkaline declines over time, whereas a modern NiMH battery's voltage remains much more constant until it reaches the point of discharge.
Now we come to the issue of mAh. Consider the following datasheet :
http://data.energizer.com/PDFs/E91.pdf
As we have determined, the Game Boy requires an average of 116.66mA to operate. According to the Milliamp-Hours Capacity, at that amperage requirement the battery can provide approximately 2400mAh. If we divide the mA by the mAh, we get 20.57 hours. Nintendo's estimate may have been a bit conservative here, but they could have been thinking ahead for the more complex games to come.
Nintendo was not only introducing a new video game console, it was introducing a new video game concept. It had to convince buyers that they should buy an expensive hand-held video game machine and its cartridges. It also had to show that the simple games from Tiger Electronics simply were not good enough. First impressions counted a great deal, and Nintendo could not afford to fudge the battery life figures too much. This was especially true because of how crucial battery life was to the hand-held video game market. Nintendo's success rested in no small part on its battery life. You could get 15-20 hours out of a Game Boy on a fresh 4-pack of batteries. Its competitors required 6 batteries and could give you six hours at best.
2. Game Boy Pocket MGB-001
The Pocket was the second iteration of the Game Boy line, released in 1996. This was a comparatively slimmer device, as its name implies. The Pocket takes 2xAAA (LR03) batteries and has power requirements of 3v and 0.7W. Thus, although the Pocket's logic may require fewer volts to operate, it requires double the amps, 233.33mA. Therefore the actual power to operate the Pocket is unchanged from the DMG.
The official Game Boy Pocket A/C Adapter from Nintendo, MGB-005, outputs 3v and 300mA. A similar third-party adapter from Hori outputs 350mA. The Pocket A/C Adapters are to be used with the Game Boy Light and Color. In Japan there was a rechargeable battery pack for the Pocket.
The use of AAA batteries kills the battery life of this machine. An Alkaline AAA battery has the same voltage as an AA battery, 1.5, but only provides 850-1200mAh. There is only about half the energy available to the Pocket as there is to the DMG. I have seen quotes of battery life of 8-10 hours for the Pocket.
If we take the datasheet here as a guide :
http://data.energizer.com/PDFs/E92.pdf
We can see that at 233.33mA, we are only going to get about 700mAh out of our good AAAs. This gives us a pathetic 3 hours. Perhaps Nintendo was measuring it against the titles that were available in 1994-1995, such as Kirby's Dream Land 2 and Donkey Kong. The strict approximation doesn't seem to hew to the reported battery life, which demonstrates that the Nintendo or the battery makers were treating the issue of battery life very conservatively.
3. Game Boy Light MGB-101
The Game Boy Light, released only in Japan, functions like the Game Boy Pocket with a switch to activate an electro-luminescent backlight. The Light uses 2xAA batteries and boasts 20 hours of play without the backlight and 12 hours with it on. The power requirements have also decreased slightly to 3v, 0.6w. Thus it requires an average of 200mA to run.
According to the datasheet, at 200mA we have approximately 2000mAh. If we divide the mA by the mAh, we get about 10 hours on a pair of AAs. One hopes that the stated power requirements were taking the backlight into consideration.
4. Game Boy Color CGB-001
The Color has the specs of the Light without the backlight. I have seen quotes of battery life of 20-35 hours.
Now the Color has the same power ratings as the Light, but this time it has a color screen, three times the RAM and a CPU that can run twice as fast as the Light, Pocket and DMG. The games themselves are typically larger, from 1-4MB. I suspect that the battery life is more impressive if it runs monochrome Game Boy games than if it is running Color Game Boy games because those extra features are not being used.
Compared to the original DMG, the Color seems to have less life. However, the Color can run on 2 AAs whereas the DMG requires 4. I would say that with 4 AA batteries (meaning you need to replace the batteries once), you can probably get the same amount of playtime as you would with a DMG.
The videos here may be very instructive :
https://www.youtube.com/watch?v=XsU4AcYhjy8
https://www.youtube.com/watch?v=VgKdEa06qUs
The video maker in his first video gives a battery life of 31hrs 12mins for a DMG and in the second video 35hrs 45mins for a Color. In the later video, the relatively short time for the Game Boy is because one of his children turned it off prematurely. However, both systems were running monochrome Game Boy games, and I cannot tell for certain what game was in the DMG, but it appears both videos used the same game in the DMG. I think it is Super Mario Land. (For the Color it was Top Rank(ing) Tennis). Super Mario Land has an attract mode, but Top Ranking Tennis has animation and music on its title screen, so the cartridges seem pretty fair. However, if a true Color game were being played, I would certainly think that the time would be significantly shorter.
Thursday, September 25, 2014
Classic DOS Pinball Games, Mode X and What they can Teach Us about Aspect Ratios
During the early to mid 1990s, several highly regarded pinball games were released for PC compatible computers running DOS. Three prominent series of Pinball games were released during the years 1992-1995. The first, developed by Digital Illusions, includes Pinball Dreams (1992), Pinball Fantasies (1992) and Pinball Illusions (1995). All these were developed on the Commodore Amiga and ported to the PC by Frontline Designs. The second series was developed by Epic Megagames, and consists of Epic Pinball (1993), Silverball (1993) and Extreme Pinball (1995). A third series was developed by Spidersoft, and includes Pinball Dreams II (1994), Pinball Mania (1995) and Pinball World (1995). There are also a few other notable pinball games that are not distinguished by coming from a single developer or publisher around this time. These include Psycho Pinball (1995) and Absolute Pinball, which share the same style of gameplay as the other titles.
These games always supported non-standard VGA modes, sample-based music and were often heavily influenced by the demo-scene and European programmers who were still focused on the Commodore Amiga. They all used an in-game display that used the full width of the screen and most of its height, with a portion of the height reserved for a display. The tables were much taller than one screen could display. They did not use a pseudo 3-D perspective, but all supported a high frame rate for fast, exciting action. Most supported the Gravis Ultrasound as the ideal sound output device.
There has been debate over the proper aspect ratio for DOS games using the standard 320x200 resolution. That resolution, as I outlined in a previous post, was a BIOS standard resolution for no less than the five (out of seven) major DOS game graphics display adapters, CGA, TGA, EGA, MCGA and VGA. Using square pixels, the aspect ratio is 1.6:1, and this gives a letterbox effect on standard 4:3 ratio CRT monitors at the time. If you stretch the monitor vertically, you can fill the screen but the pixels become 1.2 times as tall as they are wide.
VGA BIOS Display Mode 13h, which most VGA DOS games used, used the 320x200 resolution with an ability to display 256 colors from a palette of 262,144 colors. The pixel information for the graphics is stored sequentially, with one pixel = one byte. However, in addition to the aspect ratio issue, Mode 13h had its limitations, namely the fact that it could only support one full page of graphics in RAM.
A VGA card has 256KB of RAM, so the card could support four graphics pages at this resolution. However, to do this, the card's registers had to be programmed directly. Also, the registers that made up the display resolution could also be changed, but the values had to be reasonable lest the programmer destroy his or his user's monitors. VGA, in its various official modes, supported 320, 360, 640 or 720 horizontal pixels and 200, 350 or 480 vertical pixels. 240 and 400 vertical pixels could be easily obtained by writing to a few registers.
Mode X, a custom VGA mode obtained by programming the registers, canonically has a 320x240 resolution at 256 colors. The term eventually became to be appropriated for any non-standard resolution VGA mode. 320x240 was very popular for the pinball games identified above. It is especially useful to obtain a reference for what the graphics should look like with square pixels. Other modes like 320x350, 320x400, 320x480 and 360x480 were also popular, especially with shareware games.
360x480 at 256 colors was the maximum resolution a programmer could hope to achieve with 256KB VGA and keep to some degree of compatibility. While it may have the RAM to display a 640x350 or 640x400 resolution at 256 colors, other technical limitations on the VGA prevent it from doing so. Any graphics displaying in 640x350x256, 640x400x256 or 640x480x256 is always using some kind of SVGA or VESA mode.
DOSBox will stretch certain modes horizontally and this functionality cannot be totally disabled. If no scalers in DOSBox are used, 320x200, 320x240, 360x200 and 360x240 resolutions are not scaled. Other resolutions are stretched as follows :
320x350 to 640x350
320x400 to 640x400
320x480 to 640x480
360x350 to 720x350
360x400 to 720x400
360x480 to 720x480
If a screenshot is taken of any of the horizontally-stretched modes, the stretch effect can be removed by reducing the horizontal resolution by half using nearest neighbor interpolation. This will eliminate every second column of pixels. Resizing by doubling the horizontal resolution using nearest neighbore interpolation will restore those pixels. In the screenshots below, I have eliminated any stretching by this method.
Digital Illusions' Pinball Series
Pinball Dreams and Pinball Fantasies offer two resolutions, 320x240 and 320x350. Take a look at these screens from each game :
Both modes give the same amount of screen area to the status display, only the text is off-center (in relation to the status display area), in the 320x350 mode.
The great advantages of pinball games is that they almost always have a ready supply of circles which you can judge whether the aspect ratio is correct. If a circular object looks like its diameter is the same regardless of the points of the circle measured, you are on sure ground to assume that the aspect ratio is correct. If the object looks like the diameter is shorter between certain points compared other points, looking more like an oval, then the aspect ratio is probably incorrect.
For Pinball Dreams and Fantasies, the only difference between the 320x200 and 320x350 graphics is that the 320x350 graphics show 1.75x more of the pinball table. Pinball tables, by their very nature, tend to be much taller than they are wide. This will be an important point when I go on to discuss the final game in this series, Pinball Illusions. However, this is what DOSBox displays in the 320x350 mode :
The game does not give the pixel dimensions of its high resolution mode in numbers. However, comparing the two screenshots, it is apparent that no extra detail is given in the stretched screenshot. Instead, the pixels are much more prominent and the circular objects have become ovals. It should be clear that stretching is not correct for this mode.
If any further confirmation is required, look to the original games for the Commodore Amiga. Pinball Fantasies (OCS/ECS PAL version) for that system uses an effective 320x262 resolution.
Pinball Illusions is by far the most demo-scene inspired of these three pinball games, using numerous odd-ball resolutions in its pre-game sequences. However, for VGA cards, the pattern is almost the same.
Now the ball and chutes look like spheres. Therefore, for one set of games, stretching is not desirable, but for this game, it is.
Like Psycho Pinball, the 320x400 resolution merely adds more visibility to the table and a larger dstatus display. The circular objects are circular without any stretching. For the 320x400 resolution, this is in marked contrast to Extreme Pinball, which uses the same resolution. Last, let's consider the oddball 360x270 resolution.
These games always supported non-standard VGA modes, sample-based music and were often heavily influenced by the demo-scene and European programmers who were still focused on the Commodore Amiga. They all used an in-game display that used the full width of the screen and most of its height, with a portion of the height reserved for a display. The tables were much taller than one screen could display. They did not use a pseudo 3-D perspective, but all supported a high frame rate for fast, exciting action. Most supported the Gravis Ultrasound as the ideal sound output device.
There has been debate over the proper aspect ratio for DOS games using the standard 320x200 resolution. That resolution, as I outlined in a previous post, was a BIOS standard resolution for no less than the five (out of seven) major DOS game graphics display adapters, CGA, TGA, EGA, MCGA and VGA. Using square pixels, the aspect ratio is 1.6:1, and this gives a letterbox effect on standard 4:3 ratio CRT monitors at the time. If you stretch the monitor vertically, you can fill the screen but the pixels become 1.2 times as tall as they are wide.
VGA BIOS Display Mode 13h, which most VGA DOS games used, used the 320x200 resolution with an ability to display 256 colors from a palette of 262,144 colors. The pixel information for the graphics is stored sequentially, with one pixel = one byte. However, in addition to the aspect ratio issue, Mode 13h had its limitations, namely the fact that it could only support one full page of graphics in RAM.
A VGA card has 256KB of RAM, so the card could support four graphics pages at this resolution. However, to do this, the card's registers had to be programmed directly. Also, the registers that made up the display resolution could also be changed, but the values had to be reasonable lest the programmer destroy his or his user's monitors. VGA, in its various official modes, supported 320, 360, 640 or 720 horizontal pixels and 200, 350 or 480 vertical pixels. 240 and 400 vertical pixels could be easily obtained by writing to a few registers.
Mode X, a custom VGA mode obtained by programming the registers, canonically has a 320x240 resolution at 256 colors. The term eventually became to be appropriated for any non-standard resolution VGA mode. 320x240 was very popular for the pinball games identified above. It is especially useful to obtain a reference for what the graphics should look like with square pixels. Other modes like 320x350, 320x400, 320x480 and 360x480 were also popular, especially with shareware games.
360x480 at 256 colors was the maximum resolution a programmer could hope to achieve with 256KB VGA and keep to some degree of compatibility. While it may have the RAM to display a 640x350 or 640x400 resolution at 256 colors, other technical limitations on the VGA prevent it from doing so. Any graphics displaying in 640x350x256, 640x400x256 or 640x480x256 is always using some kind of SVGA or VESA mode.
DOSBox will stretch certain modes horizontally and this functionality cannot be totally disabled. If no scalers in DOSBox are used, 320x200, 320x240, 360x200 and 360x240 resolutions are not scaled. Other resolutions are stretched as follows :
320x350 to 640x350
320x400 to 640x400
320x480 to 640x480
360x350 to 720x350
360x400 to 720x400
360x480 to 720x480
If a screenshot is taken of any of the horizontally-stretched modes, the stretch effect can be removed by reducing the horizontal resolution by half using nearest neighbor interpolation. This will eliminate every second column of pixels. Resizing by doubling the horizontal resolution using nearest neighbore interpolation will restore those pixels. In the screenshots below, I have eliminated any stretching by this method.
Digital Illusions' Pinball Series
Pinball Dreams and Pinball Fantasies offer two resolutions, 320x240 and 320x350. Take a look at these screens from each game :
![]() |
| Pinball Dreams 320x200 |
![]() |
| Pinball Dreams 320x350 |
![]() |
| Pinball Fantasies 320x200 |
![]() |
| Pinball Fantasies 320x350 |
The great advantages of pinball games is that they almost always have a ready supply of circles which you can judge whether the aspect ratio is correct. If a circular object looks like its diameter is the same regardless of the points of the circle measured, you are on sure ground to assume that the aspect ratio is correct. If the object looks like the diameter is shorter between certain points compared other points, looking more like an oval, then the aspect ratio is probably incorrect.
For Pinball Dreams and Fantasies, the only difference between the 320x200 and 320x350 graphics is that the 320x350 graphics show 1.75x more of the pinball table. Pinball tables, by their very nature, tend to be much taller than they are wide. This will be an important point when I go on to discuss the final game in this series, Pinball Illusions. However, this is what DOSBox displays in the 320x350 mode :
![]() |
| Pinball Fantasies Stretched |
If any further confirmation is required, look to the original games for the Commodore Amiga. Pinball Fantasies (OCS/ECS PAL version) for that system uses an effective 320x262 resolution.
![]() |
| Pinball Fantasies Amiga OCS/ECS |
![]() |
| Pinball Fantasies Amiga OCS/ECS |
![]() |
| Pinball Illusions 320x240 |
![]() |
| Pinball Illusions "360"x350 (only 336 horizontal pixels used) |
If you look carefully, you can see that the right side of the screen is slightly cropped in the 320x240 mode compared to the "360"x350 mode. The SVGA/VESA Modes follow the 360x350 mode, but only the vertical resolution is increased :
![]() |
| Pinball Illusions "640"x480 (only 336 horizontal pixels used) |
![]() |
| Pinball Illusions "800"x600 (only 336 horizontal pixels used) |
By the time you get to 800x600 pixels, the screen barely needs to scroll, you can see almost the whole table. On a real CRT monitor, these tables will appear centered in a narrow portion of the middle of the screen with large black borders on either side. For all these pinball games, no stretching should be done. If necessary, you should decrease the horizontal size on your CRT monitor until the circular objects look like circles.
Epic Megagames Pinball Series
For the first two games in Epic's series, Epic Pinball and Silverball, they are easy to deal with because they each only use a 320x240 resolution for their tables.
![]() |
| Epic Pinball 320x240 |
![]() |
| Silverball 320x240 |
For the final game, Extreme Pinball, it only uses a 320x400 resolution, and the situation is quite different.
![]() |
| Extreme Pinball 320x400 |
As you may have noticed, the ball and the chutes do not look like spheres. If we stretch this resolution, we get the following :
![]() |
| Extreme Pinball "640"x400 |
Now the ball and chutes look like spheres. Therefore, for one set of games, stretching is not desirable, but for this game, it is.
Spidersoft Pinball Series
Pinball Dreams II was intended as the sequel for Pinball Dreams even though Spidersoft had no connection to Digital Illusions. Since it was built using the same engine, the same graphical issues appear in it. Pinball Mania uses the same graphics modes as Pinball Fantasies, and the same comments apply. In short, they all look correct at their native aspect ratios, no adjustments or stretching required :
![]() |
| Pinball Dreams II 320x200 |
![]() |
| Pinball Dreams II 320x350 |
![]() |
| Pinball Mania 320x240 |
![]() |
| Pinball Mania 320x350 |
Pinball World uses a standard 320x200 mode or a 320x240 mode. However, the ball is perfectly "circular" in the 320x200 and 320x240 modes (15x15 pixels) without any aspect ratio correction. Unlike the earlier pinball games, Pinball World uses huge tables that are wider and taller than the screen resolution. The ball is the same size in both modes, so the higher resolution just shows more of the table :
![]() |
| Pinball World 320x200 |
![]() |
| Pinball World 320x240 |
Other Pinball Games
Although Psycho Pinball uses a 320x240 or an odd 320x368 resolution, it follows the same pattern as Pinball Dreams. The extra resolution merely shows more of the table, although this time more of the status bar is displayed. No stretching should be done to its graphics.
For the final game to be detailed in this blog post, Absolute Pinball, the comments made for Psycho Pinball apply. It offers three modes, 320x240, an odd 360x270 mode and a 320x400 mode. First, the usual modes :
![]() |
| Absolute Pinball 320x240 |
![]() |
| Absolute Pinball 320x"400" (only 384 vertical pixels are used) |
![]() |
| Absolute Pinball "360"x270 (only 320 horizontal pixels are used) |
First, despite the larger number of horizontal pixels offered by the mode, only the middle 320 pixels are used. The status display uses a 320x62 pixel box. This is essentially the size of the status display in the 320x400 mode. The purpose of this mode was to allow for the same status display as enjoyed by users of the highest display resolution with more modest system requirements instead of the smaller status display. Again, no particular stretching is required for this mode.
Subscribe to:
Posts (Atom)

































