Ricoh 2A03: Difference between revisions

Content deleted Content added
FME-7 (talk | contribs)
→‎Triangle Wave Generator: Removed the Famitracker info, FT's emulation is outdated and should not be a baseline for a real console's behaviour.
FME-7 (talk | contribs)
Rewrote the sound hardware section; the previous information provided was inaccurate, overly technical, and severely lacked cited sources.
Line 18:
== Technical details ==
The Ricoh 2A03<ref name="visual6502">{{cite web|url=http://visual6502.org/images/pages/Nintendo_RP2A_die_shots.html|title=Nintendo RP2A03 and RP2A07 - an high quality picture of the die|last=Sattler|first=Christian|website=visual6502.org|access-date=2020-08-12}}.</ref> contained a [[second source]]d [[MOS Technology 6502]] core, modified to disable the 6502's [[binary-coded decimal]] mode (possibly to avoid a MOS Technology patent<ref>[https://patents.google.com/patent/US3991307 Patent US3991307]</ref>). It also integrated a [[programmable sound generator]] (also known as APU, featuring twenty two [[memory-mapped I/O]] registers),<ref>{{Cite web|url=http://www.atkinsoft.com/soundgenerators.html|title=Sound generators of the 1980s home computers|website=www.atkinsoft.com|access-date=2019-12-02}}</ref> rudimentary [[Direct memory access|DMA]], and game controller polling.<ref name="2A03techref">{{cite web|url=https://www.nesdev.com/2A03%20technical%20reference.txt|title=2A03 technical reference|last=Taylor|first=Brad|date=April 23, 2004|website=NesDev.com|archive-url=https://web.archive.org/web/20181017163239/https://www.nesdev.com/2A03%20technical%20reference.txt|archive-date=October 17, 2018|url-status=live|access-date=June 6, 2008}}</ref>
== Sound Hardware ==
The Ricoh 2A03's sound hardware has 5 channels, separated into two APUs (Audio Processing Unit). The first APU contains two general purpose pulse channels with 4 duty cycles, and the second APU contains a Triangle wave generator, a [[Linear-feedback shift register|LFSR]]-based Noise generator, and one Delta-Modulated PCM (DPCM) channel. While a majority of the NES library used only 4 channels, more games later into the NES's life span used the 5th DPCM channel, as memory mappers became more common and prices of ROM chips became cheaper. For example, [[Super Mario Bros. 3]] uses it for simple drum sounds, while other games like [[Journey to Silius]] use it for sampled basslines. An interesting quirk of the DPCM channel is that the bit order is reversed compared to what is normally expected for input, as a result, many games often ignore this quirk, which results in distorted sounding samples.<ref>{{cite web |url=https://tcrf.net/Ufouria:_The_Saga#Sound_Design_Quirks |website=The Cutting Room Floor |access-date=9 October 2021}}</ref>
 
The sound output by the Ricoh 2A03 is present on two pins, which are then mixed using a non-linear mixing circuit. On Famicom and Dendy systems, this is then output to the cartridge slot, where an expansion sound chip may add its own mixed sound into the resulting output, which is then fed back into the console. International NES systems instead output the 2A03's sound directly to the TV, but expansion sound functionality can be restored by a simple pin mod on the expansion port, allowing the internal mixer to add the cartridge's expansion sound output from the expansion port.<ref>{{cite web |last1=Burke |first1=Kevin |title=NES Expanded Audio: 100k Pot Mod |url=https://curriculumcrasher.com/2017/01/24/nes-expanded-audio-100k-pot-mod/ |website=The Curriculum Crasher |access-date=9 October 2021}}</ref>
The [[programmable sound generator]] in the 2A03/2A07 contains 5 channels: 2 Pulse Wave channels, which have 4 different sound modes, a Triangle Wave generator, a Noise generator with 16 pitches, and a DPCM ([[Delta modulation|Delta Pulse Code Modulation]]) channel with 16 pitches.
 
== Detailed Sound Specifications ==
 
=== Pulse Channels ===
The 2 Pulse channels of the 2A03 support pitches A-0 to B-7, and have 4 pulse modes:
 
12.5%(‾|_ _ _ _ _ _ _), 25%(‾ ‾|_ _ _ _ _ _), 50% (‾ ‾ ‾ ‾|_ _ _ _) and 75% (‾ ‾ ‾ ‾ ‾ ‾|_ _), with the % value referring to how long the generator is on per cycle.
 
Because 75% is an inverted version of 25%, they both sound identical.
 
=== Triangle Wave Generator ===
The Triangle Wave Generator generates a triangle wave, and supports pitches A--1 to B-6. Because it uses the volume register to create the wave, it has no volume control.
 
=== White Noise Generator ===
The Noise Generator creates a random stream of either 7 or 15 bits, depending on which sound mode it's set to, and plays it back. The generator supports pitches $0 to $F.
 
==== SOUND MODES ====
Mode 0 generates percussion. Pitches after $3 will start to repeat their waveform and become quieter, due to the generator not being able to keep up with demand.
 
Mode 1 generates a metallic sound and is similar to mode 0, however the waveform is shorter.
 
=== Sample Playback (PCM Channel) ===
The DPCM channel is a 7-bit PCM channel which is controlled by the 8th bit in the register, which is used to generate the samples. Similar to the Triangle wave Generator, it has no volume control, but for a different reason. Samples are played back using a single bit, ON increases the 7-bit Delta Counter by 1 while OFF decreases it by 1. this makes Pulse Wave playback impossible, as the channel has to work its way to the value. This adds support for up to 4kb of samples, starting at memory location $C000 to be stored in up to 4080 byte long samples.
 
Raw PCM can be played through this channel, however it requires heavy use of the CPU, so it isn't often used during gameplay.
 
The DPCM channel has 16 pitches. If you were to use a sample playing at the note C-4, this is the pitches you would get in order:
{| class="wikitable"
|+DPCM Pitch Table
!Pitch
!Output
|-
|$F
|C-4
|-
|$E
|G-3
|-
|$D
|E-3
|-
|$C
|C-3
|-
|$B
|A-2
|-
|$A
|G-2
|-
|$9
|F-2
|-
|$8
|D-2
|-
|$7
|C-2
|-
|$6
|B-1
|-
|$5
|A-1
|-
|$4
|G-1
|-
|$3
|F-1
|-
|$2
|E-1
|-
|$1
|D-1
|-
|$0
|C-1
|}
 
== Regional variations ==
PAL versions of the NES (sold in Europe, Asia, and [[Video gaming in Australia|Australia]]) used the '''Ricoh 2A07''' or '''RP2A07''' processor, which was identical to the 2A03 except for a different [[Frequency divider|clock divider]] and the 50&nbsp;[[Hertz|Hz]] [[Refresh rate|vertical refresh rate]] used in the PAL television standard, with the exception of the 16 hard-coded sampling rates for the [[Delta modulation]]-encoded sample playback unit. The changes were made in order for sampled sounds to maintain the original pitch of the RP2A03 with the new clock divider. Most developers however, usually lacked the resources to properly convert their games to the 2A07, leading to most games often sounding out of tune or off-tempo.
 
==See also==