Difference between revisions of "YM2612"

From MegaDrive Wiki
Jump to: navigation, search
m (Part 1: enanle --> enable)
m (19 revisions imported)
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[File:Model1MegaDriveYM2612.jpg|350px|thumb|lright|The YM2612 in a Model 1 Mega Drive. The VDP is visible near the top right, as well as the [[Zilog Z80|Z80]] RAM on the bottom right.]]
 
[[File:Model1MegaDriveYM2612.jpg|350px|thumb|lright|The YM2612 in a Model 1 Mega Drive. The VDP is visible near the top right, as well as the [[Zilog Z80|Z80]] RAM on the bottom right.]]
The YM2612 (the smaller cousin of the YM2608) is the Sega Mega Drive's main sound chip. It is capable of outputting 6 channels of FM synthesis, meaning it can re-create almost any instrument you could think of by using some algorithms, which are specified by 'voices.' The chip can output stereo sound, which means a channel can be left, right, or both. To create accurate drums, snares, and more, many games trade the YM2612's 6th FM channel in for a [[#DAC|DAC]] channel to play back these pre-recorded samples.
+
The '''YM2612''' (the smaller cousin of the YM2608) is the Sega Mega Drive's main sound chip. It is capable of outputting 6 channels of FM synthesis, allowing it to re-create almost any instrument with life-like precision by using built-in algorithms, feedback, and various other properties, which are specified by 'voices.'  
  
To access the YM2612, you write into a specific area of IO memory, which is often done by the [[Zilog Z80|Z80]] when it runs the sound driver, or the [[Motorola 68000|M68k]] when it is running the sound driver.
+
Each channel is also capable of Stereo audio, allowing it to be output on either the left or right channel, or both.
  
If distortion of a channel is required, one can utilize the chip's LFO, or Low Frequency Oscillator. As mentioned earlier, the YM2612's 6th FM channel can be used as a DAC channel by the means of the 'DAC Enable' register on the chip. DAC data is written to an 8-bit register. The YM2612 does not provide any facilities to handle buffering, mixing, or timing of this data, so any timing and mixing will need to be done in software on either the [[Zilog Z80|Z80]] or the [[Motorola 68000|M68k.]]
+
In addition to FM synthesis, the YM2612 can replace the 6th FM channel with a [[#DAC|DAC]] that can be used to re-produce accurate drums, snares, voice samples, and more. However, all timing has to be done in software, which usually limits sample quality, especially as the YM2612 requires 8-bit unsigned data. This, as well as the Z80's 'slow' bank reads often produced inferior sample quality, especially when software mixing was done by the driver to produce the illusion of having two DAC channels.
  
Yamaha removed the better 14-bit accumulator-equipped sound mixer and replaced it with an easier and presumably cheaper to manufacture time-division sound multiplexer, which first truncates the 14-bit output to 9 bits, and then rapidly loops through outputting all channels. This truncation causes a glitch as the wave form approaches zero, also known as the 'ladder effect.' To solve this, external filtering circuitry is used which distorts the sound even further. Sega used an improved YM2612 in the Model 2 Mega Drive which does not have this issue, but problems with the sound filtering circuit cause a more distorted sound. Sega also used this chip in a number of it's arcade game cabinets.
+
To access the YM2612, a program needs to write into a specific area of IO memory, which is often done by the [[Zilog Z80|Z80]] when it runs the sound driver, or the [[Motorola 68000|M68k]] when it is running the sound driver.
  
The chip is programmed through a number of 8-bit registers, some being stitched together to form longer registers, such as with the timers. In this case, the most significant byte is written first. The timers have to be constantly polled by software to yield a result, mainly due to the fact that they do not cause an interrupt for either of the two processors. The constant polling of timers may cause some inaccuracies to occur.
+
If distortion of a channel's amplitude or frequency is required, the chip's LFO, or Low Frequency Oscillator can modulate each operator's amplitude and frequency to a specifiable extent.
 +
 
 +
Yamaha removed the better 14-bit accumulator-equipped sound mixer and replaced it with an easier and presumably cheaper to manufacture time-division sound multiplexer, which first truncates the 14-bit output to 9 bits, and then rapidly loops through outputting all channels. This truncation causes a glitch as the wave form approaches zero, also known as the 'ladder effect.' To solve this, external filtering circuitry is used which distorts the sound even further. Sega used an improved YM2612 in the Model 2 Mega Drive which does not have this issue, but problems with the sound filtering circuit cause a more distorted sound. Sega also used this chip in a number of its arcade game cabinets.
 +
 
 +
The YM2612 is programmed through a number of 8-bit registers, some being stitched together to form longer registers, such as with the timers. In this case, the most significant byte is written first. The timers have to be constantly polled by software to yield a result, mainly due to the fact that they do not cause an interrupt for either of the two processors due to a design deficiency. The constant polling of timers may cause some inaccuracies to occur.
  
 
__TOC__
 
__TOC__
 
 
== Registers ==
 
== Registers ==
As stated before, the chip is programmed through a number of registers. Due to the large number of registers available, writing to the YM2612 is divided into two parts. Part 1 has it's own word-wide address, while part 2 has it's own separate word-write port.
+
As stated before, the chip is programmed through a number of registers. Due to the large number of registers available, writing to the YM2612 is divided into two parts. Part 1 has it's own data and address port, which is separate from Part 2. In general, Part 1 contains global chip control and registers for channels 1-3, whereas part 2 contains registers for channels 4-6.
  
 
=== Part 1 ===
 
=== Part 1 ===
Line 27: Line 30:
 
</th><th valign="top">D1
 
</th><th valign="top">D1
 
</th><th valign="top">D0
 
</th><th valign="top">D0
</th></tr><tr><td valign="top">22H
+
</th></tr><tr><td valign="top">$22
 
</td><td colspan="4" valign="top">
 
</td><td colspan="4" valign="top">
 
</td><td valign="top">LFO enable
 
</td><td valign="top">LFO enable
 
</td><td colspan="3" valign="top">LFO frequency
 
</td><td colspan="3" valign="top">LFO frequency
</td></tr><tr><td valign="top">24H
+
</td></tr><tr><td valign="top">$24
</td><td colspan="8" valign="top">Timer A Most Significant Bits
+
</td><td colspan="8" valign="top">Timer A MSB
</td></tr><tr><td valign="top">25H
+
</td></tr><tr><td valign="top">$25
 
</td><td colspan="6" valign="top">
 
</td><td colspan="6" valign="top">
</td><td colspan="2" valign="top">Timer A Least Significant Bits
+
</td><td colspan="2" valign="top">Timer A LSB
</td></tr><tr><td valign="top">26H
+
</td></tr><tr><td valign="top">$26
 
</td><td colspan="8" valign="top">Timer B
 
</td><td colspan="8" valign="top">Timer B
</td></tr><tr><td valign="top">27H
+
</td></tr><tr><td valign="top">$27
 
</td><td colspan="2" valign="top">Ch3 mode
 
</td><td colspan="2" valign="top">Ch3 mode
 
</td><td valign="top">Reset B
 
</td><td valign="top">Reset B
Line 46: Line 49:
 
</td><td valign="top">Load B
 
</td><td valign="top">Load B
 
</td><td valign="top">Load A
 
</td><td valign="top">Load A
</td></tr><tr><td valign="top">28H
+
</td></tr><tr><td valign="top">$28
 
</td><td colspan="4" valign="top">Operator
 
</td><td colspan="4" valign="top">Operator
 
</td><td valign="top">
 
</td><td valign="top">
 
</td><td colspan="3" valign="top">Channel
 
</td><td colspan="3" valign="top">Channel
</td></tr><tr><td valign="top">29H
+
</td></tr><tr><td valign="top">$29
 
</td><td colspan="8" valign="top">
 
</td><td colspan="8" valign="top">
</td></tr><tr><td valign="top">2AH
+
</td></tr><tr><td valign="top">$2A
 
</td><td colspan="8" valign="top">DAC
 
</td><td colspan="8" valign="top">DAC
</td></tr><tr><td valign="top">2BH
+
</td></tr><tr><td valign="top">$2B
 
</td><td valign="top">DAC enable
 
</td><td valign="top">DAC enable
 
</td><td colspan="7" valign="top">
 
</td><td colspan="7" valign="top">
 
</td></tr><tr><td colspan="9" valign="top">
 
</td></tr><tr><td colspan="9" valign="top">
</td></tr><tr><td valign="top">30H+
+
</td></tr><tr><td valign="top">$30+
 
</td><td valign="top">
 
</td><td valign="top">
 
</td><td colspan="3" valign="top">DT1
 
</td><td colspan="3" valign="top">DT1
 
</td><td colspan="4" valign="top">MUL
 
</td><td colspan="4" valign="top">MUL
</td></tr><tr><td valign="top">40H+
+
</td></tr><tr><td valign="top">$40+
 
</td><td valign="top">
 
</td><td valign="top">
 
</td><td colspan="7" valign="top">TL
 
</td><td colspan="7" valign="top">TL
</td></tr><tr><td valign="top">50H+
+
</td></tr><tr><td valign="top">$50+
 
</td><td colspan="2" valign="top">RS
 
</td><td colspan="2" valign="top">RS
 
</td><td valign="top">
 
</td><td valign="top">
 
</td><td colspan="5" valign="top">AR
 
</td><td colspan="5" valign="top">AR
</td></tr><tr><td valign="top">60H+
+
</td></tr><tr><td valign="top">$60+
 
</td><td valign="top">AM
 
</td><td valign="top">AM
 
</td><td colspan="2" valign="top">
 
</td><td colspan="2" valign="top">
 
</td><td colspan="5" valign="top">D1R
 
</td><td colspan="5" valign="top">D1R
</td></tr><tr><td valign="top">70H+
+
</td></tr><tr><td valign="top">$70+
 
</td><td colspan="3" valign="top">
 
</td><td colspan="3" valign="top">
 
</td><td colspan="5" valign="top">D2R
 
</td><td colspan="5" valign="top">D2R
</td></tr><tr><td valign="top">80H+
+
</td></tr><tr><td valign="top">$80+
 
</td><td colspan="4" valign="top">D1L
 
</td><td colspan="4" valign="top">D1L
 
</td><td colspan="4" valign="top">RR
 
</td><td colspan="4" valign="top">RR
</td></tr><tr><td valign="top">90H+
+
</td></tr><tr><td valign="top">$90+
 
</td><td colspan="4" valign="top">
 
</td><td colspan="4" valign="top">
 
</td><td colspan="4" valign="top">SSG-EG
 
</td><td colspan="4" valign="top">SSG-EG
 
</td></tr><tr><td colspan="9" valign="top">
 
</td></tr><tr><td colspan="9" valign="top">
</td></tr><tr><td valign="top">A0H+
+
</td></tr><tr><td valign="top">$A0+
</td><td colspan="8" valign="top">Frequency number LSB
+
</td><td colspan="8" valign="top">Frequency LSB
</td></tr><tr><td valign="top">A4H+
+
</td></tr><tr><td valign="top">$A4+
 
</td><td colspan="2" valign="top">
 
</td><td colspan="2" valign="top">
 
</td><td colspan="3" valign="top">Block
 
</td><td colspan="3" valign="top">Block
</td><td colspan="3" valign="top">Frequency Number MSB
+
</td><td colspan="3" valign="top">Frequency MSB
</td></tr><tr><td valign="top">A8H+
+
</td></tr><tr><td valign="top">$A8+
</td><td colspan="8" valign="top">Ch3 supplementary frequency number
+
</td><td colspan="8" valign="top">Ch3 supplementary frequency
</td></tr><tr><td valign="top">ACH+
+
</td></tr><tr><td valign="top">$AC+
 
</td><td colspan="2" valign="top">
 
</td><td colspan="2" valign="top">
 
</td><td colspan="3" valign="top">Ch3 supplementary block
 
</td><td colspan="3" valign="top">Ch3 supplementary block
</td><td colspan="3" valign="top">Ch3 supplementary frequency number
+
</td><td colspan="3" valign="top">Ch3 supplementary frequency
</td></tr><tr><td valign="top">B0H+
+
</td></tr><tr><td valign="top">$B0+
 
</td><td colspan="2" valign="top">
 
</td><td colspan="2" valign="top">
 
</td><td colspan="3" valign="top">Feedback
 
</td><td colspan="3" valign="top">Feedback
 
</td><td colspan="3" valign="top">Algorithm
 
</td><td colspan="3" valign="top">Algorithm
</td></tr><tr><td valign="top">B4H+
+
</td></tr><tr><td valign="top">$B4+
 
</td><td valign="top">L
 
</td><td valign="top">L
 
</td><td valign="top">R
 
</td><td valign="top">R
Line 109: Line 112:
  
 
=== Part 2 ===
 
=== Part 2 ===
Part 2's memory map is mostly the same as the one above - except the channels 1-3 in Part 1 are channels 4-6 in Part 2. The registers are also programmed through 4002h-4003h on the [[Zilog Z80|Z80]] side, or A04002h-A04003h from the [[Motorola 68000|M68k]] side.
+
Part 2's memory map is mostly the same as the one above - except the channels 1-3 in Part 1 are channels 4-6 in Part 2. The registers are however, differently from the first set, programmed through $4002-$4003 on the [[Zilog Z80|Z80]] side, or $A04002-$A04003 from the [[Motorola 68000|M68k]] side.
 +
 
 +
=== $22 — LFO ===
 +
The LFO can be used to distort each operator's amplitude and frequency to a certain degree at a pre-set frequency.
  
=== DAC ===
+
{| class="wikitable regtable"
The YM2612 is capable of outputting 8-bit DAC, which can be used in place of the 6th FM channel. Many games use them for drum samples, snares, and voice samples. The YM2612 does not provide any buffering of timing of samples, so this has to be done in software.
+
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" colspan="4" |
 +
| align="center" | LFO Enable
 +
| align="center" colspan="3" | LFO Frequency
 +
|}
  
== Detailed description and research ==
+
* '''LFO Enable:''' Enables the LFO if set.
 +
* '''LFO Frequency:''' Specifies the frequency that the LFO oscillates at.
 +
:* '''0:''' 3.98 Hz
 +
:* '''1:''' 5.56 Hz
 +
:* '''2:''' 6.02 Hz
 +
:* '''3:''' 6.37 Hz
 +
:* '''4:''' 6.88 Hz
 +
:* '''5:''' 9.63 Hz
 +
:* '''6:''' 48.1 Hz
 +
:* '''7:''' 72.2 Hz
  
 +
In order for the LFO to affect a channel's sound, it must not only be globally enabled, but also enabled for each channel, and each operator using the appropriate registers.
 +
=== $24 and $25 — Timer A ===
 +
{| class="wikitable regtable"
 +
 +
|-
 +
! align="center" colspan="8" | $24 — MSB
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" colspan="8" | Timer A MSB
 +
|-
 +
! align="center" colspan="8" | $25 — LSB
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| colspan="6"|
 +
| align="center" colspan="2" | Timer A LSB
 +
|}
 +
 +
Both registers are combined to hold the 10-bit value for Timer A. For the timer to function correctly, the MSBs must be written first, followed by the LSBs. To calculate the duration between the timer expiring, the following formula can be used:
 +
 +
t = 18 × (1024 - Timer A) µs
 +
 +
=== $26 — Timer B ===
 +
 +
{| class="wikitable regtable"
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" colspan="8" | Timer B
 +
|}
 +
 +
To calculate the duration between the timer expiring, the following formula can be used:
 +
 +
t = 288 × (256 - Timer B) µs
 +
 +
=== $27 — Timer Control, Channel 3 Mode ===
 +
{| class="wikitable regtable"
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" colspan="2" | Ch3 Mode
 +
| align="center" | Reset B
 +
| align="center" | Reset A
 +
| align="center" | Enable B
 +
| align="center" | Enable A
 +
| align="center" | Load B
 +
| align="center" | Load A
 +
|}
 +
 +
* '''Ch3 Mode;''' When set to <code>01</code> each of Channel 3's operators will use a separate frequency, instead of using offsets of a single integral frequency.
 +
* '''Load:''' When set, the corresponding timer (A or B) is started and begins counting.
 +
* '''Enable:''' Causes the corresponding timer to set the read register's overflow flag when set. When clear, the timer will never set this bit.
 +
* '''Reset:''' Resets the read flag when written as set.
 +
 +
=== $28 — Key on/off ===
 +
{| class="wikitable regtable"
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" colspan="4" | Operator
 +
| align="center" rowspan="2" |
 +
| align="center" colspan="3" rowspan="2" | Channel
 +
|-
 +
| align="center" | 4
 +
| align="center" | 3
 +
| align="center" | 2
 +
| align="center" | 1
 +
|}
 +
 +
This register triggers the key on and off events for a channel. In most cases, all four operators will be set to receive a key on and key off event at the same time, but the ability to give each individual operator a key on/off event can be useful when used in conjunction with the special Channel 3 mode.
 +
 +
The channel values are as follows:
 +
* Ch1: <code>000</code>
 +
* Ch2: <code>001</code>
 +
* Ch3: <code>010</code>
 +
* Ch4: <code>100</code>
 +
* Ch5: <code>101</code>
 +
* Ch6: <code>110</code>
 +
=== $2A and $2B — DAC ===
 +
The YM2612 is capable of outputting 8-bit DAC, which can be used in place of the 6th FM channel. Many games use them for drums, snares, and voice samples. The YM2612 does not provide any buffering of timing of samples, so this has to be done in software, in almost all cases by using the Z80 for this task to avoid locking up the 68k, and the main game logic.
 +
 +
{| class="wikitable regtable"
 +
|-
 +
! align="center" colspan="8" | $2A — DAC value
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" colspan="8" | DAC Value
 +
|-
 +
! align="center" colspan="8" | $2B - DAC Enable
 +
|-
 +
! 7
 +
! 6
 +
! 5
 +
! 4
 +
! 3
 +
! 2
 +
! 1
 +
! 0
 +
|-
 +
| align="center" | DAC Enable
 +
| colspan="7" |
 +
|}
 +
 +
Unsigned 8-bit DAC data is written to register <code>$2A,</code> and will be output instead of the sixth FM channel when the DAC Enable bit in register <code>$2B</code> is set.
 +
 +
== Undocumented Features ==
 
=== Register $2C ===
 
=== Register $2C ===
 
 
This undocumented register was found and researched by Oerg866 in April of 2012.  
 
This undocumented register was found and researched by Oerg866 in April of 2012.  
  
When Bit 5 of YM Register $2C is set to 1, Panning gets affected by the L/R part of the L/R/AMS/FMS reg of these channels:
+
When Bit 5 of YM Register $2C is set to 1, panning gets affected by the L/R part of the L/R/AMS/FMS reg of these channels:
  
 
* $B4 in Bank 1 of the YM2612 for Channel FM1
 
* $B4 in Bank 1 of the YM2612 for Channel FM1
Line 128: Line 305:
 
* $B6 in Bank 2 of the YM2612 for Channel FM6
 
* $B6 in Bank 2 of the YM2612 for Channel FM6
  
One bit on either side drags panning of the PCM channel in said direction. You can mix them, for example, to smooth panning (i.e. have some L and R bits enabled, but more L than R, will still have panning have priority on L)
+
One bit on either side drags panning of the PCM channel in said direction. They can be mixed, for example, to produce 'smooth' panning. (i.e. have some L and R bits enabled, but more L than R, will still have panning have priority on L)
 
 
With the following conclusions:
 
  
 +
==== Conclusion ====
 
* FM Waveform does not matter. The FM channel can be empty for all it cares.
 
* FM Waveform does not matter. The FM channel can be empty for all it cares.
 
* FM Total level does not matter (!)
 
* FM Total level does not matter (!)
Line 137: Line 313:
 
* The only thing that actually affects PCM panning is how many FM channels have either the L or R bit set to 1
 
* The only thing that actually affects PCM panning is how many FM channels have either the L or R bit set to 1
  
You can read more about the register including all research history here: http://gendev.spritesmind.net/forum/viewtopic.php?t=1118
+
More information about this undocumented register can be found [http://gendev.spritesmind.net/forum/viewtopic.php?t=1118 here.]
  
 
[[Category:Hardware]] [[Category:MegaDrive]]
 
[[Category:Hardware]] [[Category:MegaDrive]]

Latest revision as of 11:29, 16 March 2015

The YM2612 in a Model 1 Mega Drive. The VDP is visible near the top right, as well as the Z80 RAM on the bottom right.

The YM2612 (the smaller cousin of the YM2608) is the Sega Mega Drive's main sound chip. It is capable of outputting 6 channels of FM synthesis, allowing it to re-create almost any instrument with life-like precision by using built-in algorithms, feedback, and various other properties, which are specified by 'voices.'

Each channel is also capable of Stereo audio, allowing it to be output on either the left or right channel, or both.

In addition to FM synthesis, the YM2612 can replace the 6th FM channel with a DAC that can be used to re-produce accurate drums, snares, voice samples, and more. However, all timing has to be done in software, which usually limits sample quality, especially as the YM2612 requires 8-bit unsigned data. This, as well as the Z80's 'slow' bank reads often produced inferior sample quality, especially when software mixing was done by the driver to produce the illusion of having two DAC channels.

To access the YM2612, a program needs to write into a specific area of IO memory, which is often done by the Z80 when it runs the sound driver, or the M68k when it is running the sound driver.

If distortion of a channel's amplitude or frequency is required, the chip's LFO, or Low Frequency Oscillator can modulate each operator's amplitude and frequency to a specifiable extent.

Yamaha removed the better 14-bit accumulator-equipped sound mixer and replaced it with an easier and presumably cheaper to manufacture time-division sound multiplexer, which first truncates the 14-bit output to 9 bits, and then rapidly loops through outputting all channels. This truncation causes a glitch as the wave form approaches zero, also known as the 'ladder effect.' To solve this, external filtering circuitry is used which distorts the sound even further. Sega used an improved YM2612 in the Model 2 Mega Drive which does not have this issue, but problems with the sound filtering circuit cause a more distorted sound. Sega also used this chip in a number of its arcade game cabinets.

The YM2612 is programmed through a number of 8-bit registers, some being stitched together to form longer registers, such as with the timers. In this case, the most significant byte is written first. The timers have to be constantly polled by software to yield a result, mainly due to the fact that they do not cause an interrupt for either of the two processors due to a design deficiency. The constant polling of timers may cause some inaccuracies to occur.

Registers

As stated before, the chip is programmed through a number of registers. Due to the large number of registers available, writing to the YM2612 is divided into two parts. Part 1 has it's own data and address port, which is separate from Part 2. In general, Part 1 contains global chip control and registers for channels 1-3, whereas part 2 contains registers for channels 4-6.

Part 1

Below is a small map illustrating the arrangement of registers in Part 1:

D7 D6 D5 D4 D3 D2 D1 D0
$22 LFO enable LFO frequency
$24 Timer A MSB
$25 Timer A LSB
$26 Timer B
$27 Ch3 mode Reset B Reset A Enable B Enable A Load B Load A
$28 Operator Channel
$29
$2A DAC
$2B DAC enable
$30+ DT1 MUL
$40+ TL
$50+ RS AR
$60+ AM D1R
$70+ D2R
$80+ D1L RR
$90+ SSG-EG
$A0+ Frequency LSB
$A4+ Block Frequency MSB
$A8+ Ch3 supplementary frequency
$AC+ Ch3 supplementary block Ch3 supplementary frequency
$B0+ Feedback Algorithm
$B4+ L R AMS FMS

These registers are programmed through 4000h-4001h on the Z80 side, or A04000h-A04001h from the M68k side. Note that the data bus to the YM2612 is only 8 bits.

Part 2

Part 2's memory map is mostly the same as the one above - except the channels 1-3 in Part 1 are channels 4-6 in Part 2. The registers are however, differently from the first set, programmed through $4002-$4003 on the Z80 side, or $A04002-$A04003 from the M68k side.

$22 — LFO

The LFO can be used to distort each operator's amplitude and frequency to a certain degree at a pre-set frequency.

7 6 5 4 3 2 1 0
LFO Enable LFO Frequency
  • LFO Enable: Enables the LFO if set.
  • LFO Frequency: Specifies the frequency that the LFO oscillates at.
  • 0: 3.98 Hz
  • 1: 5.56 Hz
  • 2: 6.02 Hz
  • 3: 6.37 Hz
  • 4: 6.88 Hz
  • 5: 9.63 Hz
  • 6: 48.1 Hz
  • 7: 72.2 Hz

In order for the LFO to affect a channel's sound, it must not only be globally enabled, but also enabled for each channel, and each operator using the appropriate registers.

$24 and $25 — Timer A

$24 — MSB
7 6 5 4 3 2 1 0
Timer A MSB
$25 — LSB
7 6 5 4 3 2 1 0
Timer A LSB

Both registers are combined to hold the 10-bit value for Timer A. For the timer to function correctly, the MSBs must be written first, followed by the LSBs. To calculate the duration between the timer expiring, the following formula can be used:

t = 18 × (1024 - Timer A) µs

$26 — Timer B

7 6 5 4 3 2 1 0
Timer B

To calculate the duration between the timer expiring, the following formula can be used:

t = 288 × (256 - Timer B) µs

$27 — Timer Control, Channel 3 Mode

7 6 5 4 3 2 1 0
Ch3 Mode Reset B Reset A Enable B Enable A Load B Load A
  • Ch3 Mode; When set to 01 each of Channel 3's operators will use a separate frequency, instead of using offsets of a single integral frequency.
  • Load: When set, the corresponding timer (A or B) is started and begins counting.
  • Enable: Causes the corresponding timer to set the read register's overflow flag when set. When clear, the timer will never set this bit.
  • Reset: Resets the read flag when written as set.

$28 — Key on/off

7 6 5 4 3 2 1 0
Operator Channel
4 3 2 1

This register triggers the key on and off events for a channel. In most cases, all four operators will be set to receive a key on and key off event at the same time, but the ability to give each individual operator a key on/off event can be useful when used in conjunction with the special Channel 3 mode.

The channel values are as follows:

  • Ch1: 000
  • Ch2: 001
  • Ch3: 010
  • Ch4: 100
  • Ch5: 101
  • Ch6: 110

$2A and $2B — DAC

The YM2612 is capable of outputting 8-bit DAC, which can be used in place of the 6th FM channel. Many games use them for drums, snares, and voice samples. The YM2612 does not provide any buffering of timing of samples, so this has to be done in software, in almost all cases by using the Z80 for this task to avoid locking up the 68k, and the main game logic.

$2A — DAC value
7 6 5 4 3 2 1 0
DAC Value
$2B - DAC Enable
7 6 5 4 3 2 1 0
DAC Enable

Unsigned 8-bit DAC data is written to register $2A, and will be output instead of the sixth FM channel when the DAC Enable bit in register $2B is set.

Undocumented Features

Register $2C

This undocumented register was found and researched by Oerg866 in April of 2012.

When Bit 5 of YM Register $2C is set to 1, panning gets affected by the L/R part of the L/R/AMS/FMS reg of these channels:

  • $B4 in Bank 1 of the YM2612 for Channel FM1
  • $B5 in Bank 1 of the YM2612 for Channel FM2
  • $B6 in Bank 1 of the YM2612 for Channel FM3
  • $B4 in Bank 2 of the YM2612 for Channel FM4
  • $B6 in Bank 2 of the YM2612 for Channel FM6

One bit on either side drags panning of the PCM channel in said direction. They can be mixed, for example, to produce 'smooth' panning. (i.e. have some L and R bits enabled, but more L than R, will still have panning have priority on L)

Conclusion

  • FM Waveform does not matter. The FM channel can be empty for all it cares.
  • FM Total level does not matter (!)
  • FM Key on does not matter (all key on bits can be set to 0 and it will still work)
  • The only thing that actually affects PCM panning is how many FM channels have either the L or R bit set to 1

More information about this undocumented register can be found here.