Monday, October 16, 2017

NES Clones Reversed Duty Cycles - Why you should Reject them

Clones of the Famicom have been around since the mid-1980s, but clones of the Nintendo Entertainment System were very rare until Nintendo's patents expired in 2005.  Since then, clones have become quite common, all advertising such features as improved cartridge insertion mechanisms, lower cost (compared to the official NES top loader), x-in-1s with Genesis or SNES hardware and more recently built-in HDMI support.  However, the hardware in many of these clone consoles is fatally flawed and will not give a genuine experience.  The flaw comes in the reproduction of the NES's audio in the form of reversed duty cycles.  In this blog post, I will explain why this is an issue, how to detect it and why you should not buy second-rate clone consoles.




How the NES Generates Pulse Waves

The NES has five audio channels, two pulse waves, a triangle wave, a noise generator and a PCM channel.  We need to look at the pulse waves, the backbone of NES music and many of its sound effects.  In order to understand a pulse wave, we must look at the most basic waveform used in classic video games, the square wave.  A square wave is a signal that represents a nearly-instantaneous change in a logic level from high to low where the time the wave spends at both the high state and the low state is equal.  You can say that a square wave is 50% high or on and 50% low or off.  The proportion between high and low states is called the duty cycle, and because the length of time at each state is the same, the resulting wave is called a square wave.

The number of times a square wave transitions from high to low in one second is its frequency.  When a square wave is run through an amplifier, an audible sound can be heard if the frequency of the wave is within the range of human hearing.  So if a square wave is oscillating at 440Hz, you will hear a "middle C" note.

A pulse or a rectangle wave is a refinement of the square wave.  With a pulse wave, the high/low period need not be equal.  Control over the duty cycle allows for a different sound between a square wave and a rectangle wave.

The NES controls its audio through several 8-bit registers located within the CPU's memory.  The NES has two pulse wave channels and they each have a set of four registers to control their various functions.  One of those registers controls the duty cycle with two bits, giving four choices for duty cycles.

Duty Cycle Bits = 00 / Selection 0, Duty Cycle = 12.5%
 _
| |
| |
| |_______

Duty Cycle Bits = 01 / Selection 1, Duty Cycle = 25%
 __
|  |
|  |
|  |______

Duty Cycle Bits = 10 / Selection 2, Duty Cycle = 50% (aka a square wave)
 ____
|    |
|    |
|    |____

Duty Cycle Bits = 11 / Selection 3, Duty Cycle = 75% (aka 25% negated)
 ______
|      |
|      |
|      |__

Even though there are four actual choices, the 25% and 75% selections will sound identical.  So you are left with three functional choices where the sound will not be the same.

Here are recordings of how a 438.6Hz frequency will sound at each duty cycle.  First will come 12.5%, then 25%, then 50% and finally 75% and each tone will play for about 4.5 seconds.



Note how the square wave sounds more "hollow" than the rectangle waves.  The unequal waveforms sound more buzzier, especially the 12.5%, which almost sounds like a sawtooth wave.

The Differences between Proper and Reversed Duty Cycles with Samples

In clone consoles with reversed duty cycles, the pulse wave portions of the audio will often, but not always, sound incorrect.  In these consoles, duty cycle selections 1 and 2 are reversed.  When the music programmer intended select a square wave on an official console, you will hear the 25% duty cycle instead and vice-versa.  However, if the music programmer intended to use selections 0 or 3, then the music will play back as intended, so the duty cycle issue may not be instantly recognizable.

Here are recordings of how a 438.6Hz frequency will sound at each duty cycle on a clone console with reversed duty cycles.  First will come 12.5%, then 50%, then 25% and finally 75% and each tone will play for about 4.5 seconds.  This uses the same combination of bits in the same sequence as the proper tones file given above.



Famous music and sound effects are instances where you can hear reversed duty cycles.  I offer two examples.  The first is the overworld theme from Super Mario Bros.  Composer Koji Kondo intended square waves to be used, so when clone consoles use the 25% rectangle wave instead, the music may sound like its higher pitched (even though it is not).





In the next sample, Level 1-1 of Ninja Gaiden, you cannot really hear anything wrong with the music at first.  (Trust me, you will once you play through more of the game).  In this case, its the sound effects that are frequently wrong.  While the sword slash, jumping, wall climbing and enemy explosion sounds are correct, the ubiquitous item collection sounds, the pause and the timer ticks for the hourglass and fire wheel powers are not right.  The playthroughs will not be 100% in sync with each other, but you should be able to hear the differences.





In these instances, I used the Mesen emulator because it is a very accurate NES emulator and is one of the few that has an option for reversed duty cycles and I do not have a clone with reversed duty cycles.

Clone consoles with Reversed Duty Cycles

Does anyone remember the Generation NEX?  The NEX was a clone console released in 2005 by a company named Messiah Entertainment.  The NEX was the first well-known NES clone released after Nintendo's patents expired after 20 years (from 1985).  It had a 72-pin and a 60-pin slot, an enclosure that evoke the styling of the NES and controller ports that fit true Nintendo controllers.  It had its share of problems, but among its most glaring was the reversed duty cycles.  Many, but not all clones to follow would suffer from this fault. The GamerzTek 8-bit Entertainment System, the RetroN 3 and the Retro-bit Super Retro Trio v2 are more recent clone consoles with reversed duty cycles.  Bizarrely, the Super Retro Trio v1 does not have reversed duty cycles.  Some of the other 2/3-in-1s may or may not have a NOAC with reversed duty cycles, its a crapshoot because sometimes the vendors update their chip.  A chip update does not guarantee that reversed duty cycles will be fixed or prevent reversed duty cycles from appearing where they were not present in earlier hardware.  You are almost always rolling the dice unless you really do your research here.

Where did the reversed duty cycles come from?  Well, back in the 80s and early 90s, Famiclones were typically made in Taiwan.  Frequently they simply cloned the die of the official NES CPU and PPU.  At some point, the Taiwanese semiconductor fab UMC made clone chips of the Nintendo/Ricoh 2A03 CPU and 2C02 PPU.  They were called the UA6527 and UA6528, respectively.  Unfortunately, when UMC were making the CPU, they reversed the duty cycles.  This design prevailed for the most part when these chips were reduced to the single NES-on-a-Clone (NOAC) chips of the late 1990s until the present.   Not all clone consoles using a NOAC suffer from reversed duty cycles.  The ancient Game Axe portable and the Tristar/Super 8 for the SNES do not have reversed duty cycles.

Recently, there have been many NES clones with HDMI and composite video output being sold at very reasonable prices.  These include the GamerzTek 8-bit HD, the Hyperkin Retron HD, Retro-bit RES Plus and Old Skool's Classiq 2 HD.  All of them, except for the first run of the  GamerzTek 8-bit HD, have reversed duty cycles.  (The first run of the GamerzTek 8-bit HD has other audio issues).  If you want an NES HDMI solution without a problem as glaring as reversed duty cycles, you will need to ante up for the Hyperkin RetroN 5 ($150), the RetroUSB AVS ($170) or the Analogue Nt Mini ($449).

It seems that I originally noticed this issue with a clone console over twelve and a half years ago : http://atariage.com/forums/topic/67476-yabos-fc-game-console-usa-version-review/  It has not gone away in that time, it continually rears its ugly head.  As long as there is a market for cheap NES clones, it will remain with us.

6 comments:

Avi Drissman said...

"So if a square wave is oscillating at 440Hz, you will hear a "middle C" note."

440 is actually an A note, not a C.

Raifield said...

I received a Generation NEX for Christmas, probably the year it was released, I don't really remember. What I do remember is that the colors were way off, Dragon Warrior II was practically shades of neon. The cartridge slot, or the connector, was fitted weird and inserting and extracting cartridges took some arm strength.

Years later I found it in my basement and attempted to fire it up out of curiosity...but it wouldn't power on any longer. My original NES, received in 1986, is still working fine to this day.

Jonathan said...

Maybe my hearing is not as sharp as it once was -- I am well past 40 years old -- but I honestly cannot hear any difference in the sound samples between the normal and reversed duty cycles.

Is this really considered a major problem?

Great Hierophant said...

I think so, I haven't lost my hearing yet :)

Miso said...

Some of us haven't even played on a real NES, here in Slovakia it was never a thing, but many 90s kids like me played on cheap Famiclones that were available for the equivalent of 30 usd at the time. We had a LOT of great fun and we didn't give a damn about something as ridiculous as this. This page condemns something like some beep and boops sounding "wrong" as some horrible flaw. The truth is, most of the people who buy those retro clones don't care about "accurate" NES sound as that is not even what they grew up with or what they are nostalgic for. I am glad that a 32 year old console is even cloned at all. Not everyone is a spoiled kid who got the true original NES back in 1985.

Lord DoomRater said...

How crazy is it that people "don't care" that it's not accurate?! This absolutely drives me nuts and will leave me boycotting a system entirely. I own a LICENSED Sega emulator system and it gets all the sound timings wrong, meaning it never really gets used. Had I known it was a piece of junk in that regard, I never would have bought it.