(:title YM2413:) !!!Overview The [=YM2413=], also known as OPLL, is a FM sound generator produced by Yamaha. It was used in the FM Sound Unit add-on to the Sega Mark III and later built into the japanese Sega Master System. It was also featured in some MSX2 systems and the NES mapper VRC7 from Konami uses a derivative of the YM2413 for extended sound. [[http://www.smspower.org/Development/MusicEngineControl-FM|List of SMS games with FM sound support]] !!![=YM3812 / OPL-2 comparisons=] The [=YM3812=] has 9 channels each with its own set of registers for defining the type of sound coming from it. The [=YM2413=] simplifies the design: each channel has a 4-bit instrument number, the instrument being a group of predefined register settings stored in an internal ROM. Of the 16 available instrument types the first one is a user defined instrument that is controlled by a set of programmable registers. There is no limit on the allocation of instruments; the user instrument or any of the fixed ones can be used by multiple channels. !!!Sound generation A slot (also known as 'operator') generates a waveform that has several attributes: * Waveform type (full or rectified sine wave) * Volume (called total level) * Feedback (input from the same slot's output) * Envelope (ADSR type) * Other characteristics (vibrato, LFO) The [=YM2413=] allocates two slots per channel, called the carrier and modulator. The output of the carrier is combined with the modulator, and the resulting sound is output on a given channel. Each channel has its own attributes as well: * Frequency * Volume * Instrument type (as explained earlier) !!!Rhythm mode Rhythm mode is used to create percussion type sounds which cannot be made normally by FM sound generation. Several slots are used for this purpose, which changes the distribution of slots per channel: * Six melodic channels (can use any of instruments 0-15) * Five rhythm channels (bass drum, snare drum, tom-tom, top cymbal, high hat) The allocation of slots for the rhythm instruments are: * Bass drum: slots 13, 16 * Snare drum: slot 17 * Tom-tom: slot 15 * Top cymbal: slot 18 * High hat: slot 14 The rhythm channels have their own dedicated volume control and key-on bits. The normally used frequency and volume settings for the channels that share these operators need to be set up in a fixed way as advised by Yamaha: || border=0 width=70% ||!Reg. ||!Setting ||!Purpose || ||$16 ||$20 ||F-Num LSB for channel 7 (slots 13,16) || ||$17 ||$50 ||F-Num LSB for channel 8 (slots 14,17) || ||$18 ||$C0 ||F-Num LSB for channel 9 (slots 15,19) || ||$26 ||$05 ||Block/F-Num MSB for channel 7 || ||$27 ||$05 ||Block/F-Num MSB for channel 8 || ||$28 ||$01 ||Block/F-Num MSB for channel 9 || Notice that the key-on bits are reset so that the dedicated ones in register $0E can be used. Because of the way rhythm mode works, it isn't possible to disable some rhythm channels to "free up" the operators so the channel can be used in melodic mode. !!!Reverse engineering of the YM2413 Extensive reverse engineering of the chip has been performed by andete and is available on GitHub: [[https://github.com/andete/ym2413]]. The notes are also linked below chronologically with embedded images: (:include YM2413ReverseEngineeringNotes:) Note that the die shots referred to in the above notes are actually from a FHB013 which is a YM2413 derivative with a different instrument set. There are no actual YM2413 die shots available.