# Notes: SpritesMind thread 386, part 1 (posts p5485 to p6287, 2008-06-06 to 2008-09-20) Source file: `reference/scratch/t386-part1.txt` (pages t386-000.html to t386-180.html). Every line read. Only what the posts say; nothing added. "HW" = stated as measured on hardware. Nemesis's hardware where named: "PAL MD1600 MegaDrive" (discrete YM2612), oscilloscope direct on the chip, and recordings at 96 kHz. Many posts do not name the method; p5716 item 3 says his assertions are "the combined result of a lot of tests, analysis of sampled results, and a lot of math". No post in this part is by `nukeykt` or `jotego`. Nothing credited to "furrtek". ## PROVENANCE WARNINGS (read first) - **W1. The envelope tables in p5716 are MAME's, checked on hardware.** Nemesis, p5716: "Both these tables are based on information provided in MAME, but I've independently tested most of these values against the YM2612 output. I did find a few inaccuracies in the attenuation increment values provided in MAME. The entries marked with an asterisk differ from the values provided in the MAME core". Item 5 of the same post credits "Jarek Burczynski for his work on the MAME core. His implementation of the update process for the envelope generator in MAME is extremely accurate, and in the end my testing confirmed much of his implementation as being correct." So Table 1 and Table 2 below reached this thread from MAME's fm.c (GPL-headed in today's MAME), as tables in a researcher's post that he says he re-measured and corrected. The parent must decide how to treat them. - **W2. Sine and power tables.** Nemesis p5974: after "6 hours sampling data from the YM2612" he "confirmed that your [Jarek's] implementations of sin_tab and tl_tab really are 100% binary accurate". His generating algorithms in p6114 are presented as his own ("Here's my (heavily commented) algorithm"), and as producing the same result as MAME. - **W3. Detune table** (p6177) is derived by Nemesis from the YM2608 manual's table in Hz (page 26); p6205: "I know the detune table in MAME is correct". - Statements below tagged "from emulator" are posters repeating what MAME/Gens/Kega do. ## Slips and skips - p5630 (Eke): Gens lines quoted inside a [QUOTE] block, not a code block, so not withheld: three one-line statements of Gens's phase increment computation and a proposed fix. Read before recognised. Nothing taken from them. - p5639 (Nemesis): a 5-line patch to Gens's `CALC_FINC_SL` in a [QUOTE]. Read. Not used. - p5730 (Eke): two lines of modified MAME fm.c in a [QUOTE]. Read. Not used. - p6096 (Eke): prose/pseudo-lines saying how Gens and MAME compute feedback (shift amounts). Read; recorded below only as "from emulator". - p6219 (Eke): an ~10-line modified MAME key-on fragment in a [QUOTE]. Read. Not used as code; the behaviour claim is recorded as "from emulator patch". - p6225 (Nemesis): two short MAME fragments (4 and 5 lines, `advance_eg_channel`) in [CODE] blocks, presented as MAME code and his suggested change. Read before the block was recognised as emulator code (it is 3 lines). The behaviour (clamp to SL) is recorded below from his prose. - p6237 (Eke): two lines of modified MAME code in a [QUOTE]. Read. Not used. - Withheld mechanically, not seen: p5534 (Stef, Gens ENV_TAB, 370 chars), p5632 (notaz, 312 chars: by the prose a list of games checked, not code), p5644 and its re-quote in p5730 (notaz, MAME patch, 298 chars), p5691 (quote of Nemesis's timer formulae, 578 chars: the original is in p5680 and was read). ## Withheld blocks that look like measurements None. p5632's withheld block is, by its prose, a list of game names tested by ear in an emulator. --- ## 1. Chip family, documents - OPN line as listed: YM2203 (OPN), YM2608 (OPNA), YM2610 (OPNB), YM2612 (OPN2), YM3438 (OPN2C) "(CMOS implementation of the YM2612. Functionally identical)", YMF288 (OPN3). p5485 Nemesis 2008-06-06. From documents/his research. - "the YM2612 seems to just be a 'stripped down' version of the YM2608 ... the parts to get the chop were external I/O Ports, a Rhythm generator with internal ROM samples, a full ADPCM module, and the SSG module ... Apart from the addition of DAC registers at 0x2A/0x2B ... everything in the YM2612 seems to be unchanged from the YM2608 implementation". p5485. Inference from manuals. - The YM2608 manual was supplied by "Malfunction from http://www.soundshock.se"; 67 pages, Japanese. The English PDF is Nemesis's own: Acrobat OCR plus the web translator at excite.co.jp, hand-corrected (p5568, 2008-06-15); revised 2008-07-01 (p5676: corrects "numerous transcription errors ... (eg, the write wait times on page 14)"). Pages 57-67 (physical properties, bus timings) are NOT translated (p5568). - The "86 Sound Board" manual (PC-9801-86, uses a YM2608) "seems to have ... timing information on the busy flag in the status register" (p5485). Not examined in thread. - The only official YM2612 reference is "14 pages in the Genesis Sound Software Manual" (p5485). ## 2. Register map and operator numbering - Operator order in the register blocks is S1, S3, S2, S4; the algorithm charts' numbering is correct and it is the register order that is "switched". Nemesis p5495, p5597 ("The correct order of the operators is op1, op3, op2, op4 in the register blocks"). From the YM2608 manual. Eke p5599 confirms emulators agree ("S1>S3>S2>S4 for common registers"). - Key on/off register $28: "D7=op4, D6=op3, D5=op2, and D4=op1" in both the Sega and Yamaha documents. p5597 Nemesis. From manuals; Eke p5599 says emulators match. - Channel 3 per-operator frequency registers. YM2608 manual page 20 (p5592): ``` Operator 1 | A9,AD Operator 2 | AA,AE Operator 3 | A8,AC Operator 4 | A2,A6 ``` Sega's manual says otherwise and is wrong (it also lists AE twice). Shiru's hardware test with algorithm 7 and separate key-on per operator (quoted p5605): "D7 - operator, which frequency defined by A6A2 / D6 - .. ACA8 / D5 - .. AEAA / D4 - .. ADA9", i.e. D7=op4→A2/A6, D6=op3→A8/AC, D5=op2→AA/AE, D4=op1→A9/AD: "That matches the YM2608 document. At least that's confirmed then." (Nemesis p5605). HW (Shiru; which console not stated) + manual. Eke p5599: "S4>S3>S1>S2 for CH3 frequencies" (from emulator MAME, same thing). - There is no register below $30 in the second part: Shiru p5648: "My test, which tried to use special mode on second bank by setting corresponding bit in register #27 of second bank, confirmed it (both for hardware and emulators)". HW (Shiru). So special mode does not exist for channel 6. - YM2608 registers absent on the YM2612 (Nemesis p5680, HW, "After testing"): - No ID/extra status registers: "The normal status register appears to be returned from the YM2612 under all circumstances, regardless of the address the YM2612 is being read from (part 1 address/data or part 2 address/data), or the register that is latched at the time the status register is read." - Prescaler registers $2D, $2E, $2F: "This does not seem to exist in the YM2612. Latching or writing to these registers had no noticeable effect." - "I've confirmed that interrupt control flags for the YM2608 in register $29 do not exist on the YM2608" [sic: he means YM2612]. The YM2608's $29 also holds a 3/6 channel switch that defaults to 3 channels (p5569, p5592); not tested separately. - Sega manual on SSG-EG, as quoted p5504: "SSG-EG - A proprietary register whose usage is unknown. It should be set to zero." ## 3. Clocking, sample rate - "In the PAL Mega Drive, the external clock is 7610000Hz" (p5716). Eke p5719: use the exact values "53693175/7 for NTSC and 53203424/7 for PAL ... this would make 52781.17 Hz for pal". Nemesis p5692: master clocks "53.203MHz for PAL, 53.6931 for NTSC". - "In the case of the YM2612, the FM prescaler appears to be fixed at 6": FM Clock = External Clock / 6 (7610000 / 6 = 1268333.33). Output Frequency = FM Clock / 24 (= 52847.22 Hz with his 7.61 MHz). "that divider of 24 is 6*4, or 6 channels times 4 operators ... All I've done at this stage is to verify the output frequency." p5716 Nemesis 2008-07-09. HW (verified output frequency). - From the YM2608 manual's F-number formula: "each operator gets updated once every 144 clock cycles" (p6177). - p6224 Nemesis 2008-09-11 (CORRECTION of p5716): "The phase generator clock is the same as the FM clock: PG Clock = FM Clock. Since there are 6*4=24 operators to update, and a single operator is updated each clock cycle, each operator gets updated once every 24 phase clock cycles. The envelope generator clock is 1/3 of the FM clock: EG Clock = FM Clock / 3 ... each operator gets updated once every 24 envelope clock cycles, or once every 24*3=72 FM clock cycles." - The withdrawn claim (p5716): "EG Clock = External Clock / 351", ratio 1:2.4375. p6224: "All of that is wrong." Reason: he had timed total decays from the output, and "the minimum output level is actually reached before the envelope generator reaches the maximum attenuation (around 40db, instead of the full 48db)". "the envelope generator clock rate is in fact 1/3 of the FM clock, which means MAME was right all along." Note the corrected figure is "a rough adjustment" of his numbers, agreeing with MAME. - So: the envelope generator updates once every 3 output samples. - Multiplexed output: HardWareMan p5919 (oscilloscope pictures, linked below): "YM2612 has time-multiplexed output: 1 DAC and each channel in turn set its current DAC code. And timeslot #6 shared between Ch6 and DAC register (0x2A)." HW (oscilloscope; console not stated). p5717 HardWareMan: an oscilloscope measure of the per-channel rate was "close to ... but not equival" to 52847.22/2 = 26423.61 Hz, "every channel have silence gap"; left to re-measure. Nemesis p5718: his own oscilloscope numbers "matched this calculation as I recall", not recorded. - NTSC and PAL differ only through the master clock; timers, tones, CPUs scale together (p5692). ## 4. Frequency formula, F-number write order - YM2608 manual (page 24), quoted p5537 and p6177: ``` F-Number = (144 * fnote * 2^20 / M) / 2^(B-1) fnote: Frequency Data M: Master clock (Hz) B: Octave Data ``` - **Write order latch.** Nemesis p5621 2008-06-22, HW (test ROM ym2612FrequencyWriteOrder): "the YM2612 doesn't commit a write to the block/fnum register until the fnum register is written to." Example: "Set 0xA6 to 0x1E / Set 0xA2 to 0xFF / Set 0xA6 to 0x24 — The effective settings for the channel will remain as 0xA6 = 0x1E, 0xA2 = 0xFF. The second write to register 0xA6 will not be seen until 0xA2 is written to again." "If register changes were applied immediately, the result would be an A4 (440Hz). Instead, this ROM will play an A6 in the actual hardware." - "writing an fnum byte for one channel doesn't commit fnum/block writes which have been made to other channels. If you write a block/fnum byte to channel 2, then write an fnum byte to channel 3, the block/fnum byte for channel 2 will not be applied. The update will remain in limbo until the fnum register for channel 2 is written to". (Whether the high-byte latch is one per channel or shared is not stated beyond this sentence.) - Eke p5625: MAME updates frequencies "only when A0-A2, A8-AA are written" (from emulator). - Frequency changes take effect at once: Nemesis p5655 HW ("I've just tested"): "If you change the frequency for an operator, the new frequency is used for the very next sample, regardless of the current position in the output wave, or the state of the envelope generator." - Other mid-note register changes (Shiru quoted in p5719, tests by Alone Coder on a YM2203 "verified on YM2612"): "TL, MULT, DET changes sound properly and immediately"; "AR, DR, SR, RR, Feedback changes does not affects on currently playing note, but affects properly after new KEY ON"; Shiru p5720 corrects: "I was wrong about Feedback, actually it changes sound immediately too." Nemesis p5721: he "did get results that indicated rate values could be changed after key-on" but "Consider this suspect until I can re-test." Eke p5722: MAME applies rate changes immediately (from emulator). UNSETTLED in this part: when AR/DR/SR/RR changes take effect. ## 5. Phase generator (Nemesis p6177, 2008-09-03; HW unless noted) "I'm pretty sure this is everything you need to get a 100% accurate implementation of the phase generator, with the exception of phase modulation by the LFO." - Inputs: FNUM 11 bits, BLK 3 bits, DT 3 bits, MUL 4 bits. "the phase generator stores a separate 20-bit internal phase counter for each operator"; "only the upper 10 bits being output to the operator unit". - Each update: compute the phase increment, add to the 20-bit counter. Order of steps "is critically important": block shift, then detune, then multiple. Register sizes: 11-bit fnum → 17-bit after block → 17-bit after detune → 20-bit after multiple (diagram linked below). - **Step 1, block shift:** ``` ------------------------------------------------- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |-----------------------------------------------| | >>1 | - | <<1 | <<2 | <<3 | <<4 | <<5 | <<6 | ------------------------------------------------- ``` "When fnum = 0x7FF and block = 7, calculation is 0x7FF<<6=0x1FFC0. When fnum = 0x7FF and block = 0, calculation is 0x7FF>>1=0x3FF." Result is 17-bit; with block 0 "the LSB of fnum is of course discarded". - "20-bit or 21-bit?": HW: "when block is set to 0, an fnum value of 1 = 0, 3 = 2, etc. This shows that the LSB of fnum is lost when block = 0, which means the phase counter is actually 20-bit." - **Step 2, key code and detune.** Key code is 5 bits (YM2608 manual page 25): ``` --------------------- | 4 | 3 | 2 | 1 | 0 | |-------------------| | Block |N4 |N3 | --------------------- Where Block is the 3-bit block data, and N4/N3 are built from fnumber as follows: N4=F11 N3=F11&(F10|F9|F8) | !F11&F10&F9&F8 Where FXX indicates bit XX from fnumber, starting with the LSB as 1. ``` The manual's form (p5608): "N3=F11・( F10+F9+F8 ) + !F11・F10・F9・F8", with its sample rows: ``` |F11|F10|F9|F8|N3| | 0 | 1 | 0| 1| 0| | 0 | 1 | 1| 0| 0| | 0 | 1 | 1| 1| 1| | 1 | 0 | 0| 0| 0| | 1 | 0 | 0| 1| 1| ``` (TascoDLX p5610: + is OR, ・ is AND, ! is NOT.) Eke p5601: the Sega manual's key-code rule (3 block bits + 2 high frequency bits) is wrong against this. - Detune register: 3 bits, a sign bit plus 2 magnitude bits (not two's complement): "a range of -3 to +3, with both -0 and +0, which are equivalent" (manual page 26). - Detune table. Manual page 26 gives it in Hz, all multiples of 0.053 Hz at 8 MHz; "fnum = 144 * 0.053 * 2^20 / 8000000 = 1 (rounded)", so one step is 1 unit of the increment. Converted table (index: key code 0-31; column: low 2 bits of detune): ``` // Detune Key-Code // 0 1 2 3 {0, 0, 1, 2}, //0 (0x00) {0, 0, 1, 2}, //1 (0x01) {0, 0, 1, 2}, //2 (0x02) {0, 0, 1, 2}, //3 (0x03) {0, 1, 2, 2}, //4 (0x04) {0, 1, 2, 3}, //5 (0x05) {0, 1, 2, 3}, //6 (0x06) {0, 1, 2, 3}, //7 (0x07) {0, 1, 2, 4}, //8 (0x08) {0, 1, 3, 4}, //9 (0x09) {0, 1, 3, 4}, //10 (0x0A) {0, 1, 3, 5}, //11 (0x0B) {0, 2, 4, 5}, //12 (0x0C) {0, 2, 4, 6}, //13 (0x0D) {0, 2, 4, 6}, //14 (0x0E) {0, 2, 5, 7}, //15 (0x0F) {0, 2, 5, 8}, //16 (0x10) {0, 3, 6, 8}, //17 (0x11) {0, 3, 6, 9}, //18 (0x12) {0, 3, 7,10}, //19 (0x13) {0, 4, 8,11}, //20 (0x14) {0, 4, 8,12}, //21 (0x15) {0, 4, 9,13}, //22 (0x16) {0, 5,10,14}, //23 (0x17) {0, 5,11,16}, //24 (0x18) {0, 6,12,17}, //25 (0x19) {0, 6,13,19}, //26 (0x1A) {0, 7,14,20}, //27 (0x1B) {0, 8,16,22}, //28 (0x1C) {0, 8,16,22}, //29 (0x1D) {0, 8,16,22}, //30 (0x1E) {0, 8,16,22}}; //31 (0x1F) ``` "the maximum adjustment that detune will make to the increment value is 22." Provenance: manual table converted by Nemesis; "These values that are given in the detune table are accurate." - Applying: positive detune adds the table value to the 17-bit intermediate; negative adds the two's complement in 17 bits, result kept to 17 bits. Examples: fnum 0x100, block 5: "0x100 << 4 = 0x1000", key code 0x14, detune 3 → +11: "0x1000 + 0xB = 0x100B"; detune 7 (−3): "0 - 0xB = 0x1FFF5 (17-bit)", "0x1000 + 0x1FFF5 = 0xFF5 (17-bit)". - **Step 3, multiple:** the 4-bit value multiplies the increment directly, "except for the special case of 0 where it acts as a 0.5 multiplier" (manual table). Examples: fnum 0x1FF block 4: "0x1FF << 3 = 0xFF8"; MUL 8: "0xFF8 * 8 = 0x7FC0"; MUL 0: "0xFF8 * 0.5 = 0x7FC". - **Detune overflow** (first reported p5618 2008-06-21, HW: test ROM ym2612detune "generates a continuous tone on the real system (and Kega), even though all slots in all operators have a frequency number of 0"; Flashback: channel 3 operator 2 has detune −3 and frequency 0). p5633 HW: "the detune overflow bug occurs on all channels." p5629: early tests put the overflowed value "very close to the maximum frequency value you can set normally (block = 0x7, fnum = 0x7FF)". Final form, p6177: "The register size at the time the detune value is applied is 17-bit, so if detune attempted to subtract a value of 1 from an fnum of 0, the result would be 0x1FFFF." Positive detune cannot overflow: max 0x1FFC0 + 0x16 = 0x1FFD6. "The magic register size is 17-bit ... mask your increment value to a 17-bit result before applying the frequency multiplier." Used by a GEMS built-in instrument (many games). - **Multiplier overflow:** "The input to the multiplier is 17-bit, the output from the multiplier is 20-bit ... 0x1FFFF ... (15) ... 0x1DFFF1 ... This upper bit of data is lost, so an output of 0x1DFFF1 is equivalent to 0xDFFF1." - Detune also depends on key code (Eke p5601, from manual). - LFO phase modulation: not covered in this part ("at a later date"). ## 6. Envelope generator (Nemesis p5716, 2008-07-09, with corrections p5724, p6179, p6224, p6225) All "tested ... on the YM2612" per the post's preamble, with warning W1 on the tables. - Output: a 10-bit attenuation per operator, 0x000-0x3FF, linear in dB. Documented weighting (96 dB full scale): ``` EG attenuation output bit weighting = 96 / 2^10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | 48 | 24 | 12 | 6 | 3 | 1.5 | 0.75 | 0.375 | 0.1875|0.09375| ``` **Corrected in p6114 (2008-08-28):** "There's a very big lie in all of the OPN documentation ... the envelope generator can only attenuate the output by 0db to 48db ... for every table you see in any documentation that discusses decibels, you need to divide every value by 2 to get the real attenuation values. TL is actually 0-48db. SL is actually 0-12db (or 48db when all set)". Real weighting: ``` EG attenuation output bit weighting = 48 / 2^10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | 24 | 12 | 6 | 3 | 1.5 | 0.75 | 0.375 | 0.1875|0.09375|0.046875| ``` (This is a statement about power vs amplitude decibels as he computes them; see section 7, where the same 10 bits are a 4.6 fixed-point base-2 logarithm.) - Register inputs: "TL Total Level 7 bits; SL Sustain Level 4 bits; AR Attack Rate 5 bits; DR Decay Rate 5 bits; SR Sustain Rate 5 bits; RR Release Rate 4 bits; SSG-EG SSG-EG Mode 4 bits"; plus key-on/off events and "The current 4-bit key-scale value". - State per operator: current phase (Attack, Decay, Sustain, Release); "A 6-bit calculated Rate value"; "The current 10-bit attenuation value"; "A flag indicating the polarity of the output. When this is set, the attenuation output is inverted." Global: "A running cycle counter of unknown size ... at least 14 bits". - Decay, sustain and release are computed identically; only the rate register differs. - **Rate:** "Rate = (2*R) + Rks", R = the register for the current phase, Rks = "The 4-bit Rate Key-Scaling value for the operator. Refer to page 29 in the YM2608 manual." Special cases: "If R = 0, then Rate = 0, regardless of the value of Rks"; "Rate is capped at 63"; RR: "multiply it by 2, and add 1 ... the upper 4 bits of a 5-bit rate value, with the LSB fixed to 1." (Same rules from the manual via Eke p5601.) p5724: the R = 0 check is made after RR's conversion, "so Rate can never equal 0 in the release phase". "The envelope generator performs the rate calculation once, as the operator enters a new phase" (p5716; but see section 4, "UNSETTLED"). - **Table 1: counter shift values** (rate → shift), W1: ``` 11 11 11 11 0-3 (0x00-0x03) 10 10 10 10 4-7 (0x04-0x07) 9 9 9 9 8-11 (0x08-0x0B) 8 8 8 8 12-15 (0x0C-0x0F) 7 7 7 7 16-19 (0x10-0x13) 6 6 6 6 20-23 (0x14-0x17) 5 5 5 5 24-27 (0x18-0x1B) 4 4 4 4 28-31 (0x1C-0x1F) 3 3 3 3 32-35 (0x20-0x23) 2 2 2 2 36-39 (0x24-0x27) 1 1 1 1 40-43 (0x28-0x2B) 0 0 0 0 44-47 (0x2C-0x2F) 0 0 0 0 48-51 (0x30-0x33) 0 0 0 0 52-55 (0x34-0x37) 0 0 0 0 56-59 (0x38-0x3B) 0 0 0 0 60-63 (0x3C-0x3F) ``` - **Table 2: attenuation increment values** ([64][8]; asterisk = differs from MAME), W1: ``` *0,0,0,0,0,0,0,0 *0,0,0,0,0,0,0,0 *0,1,0,1,0,1,0,1 *0,1,0,1,0,1,0,1 0-3 (0x00-0x03) 0,1,0,1,0,1,0,1 *0,1,0,1,0,1,0,1 0,1,1,1,0,1,1,1 *0,1,1,1,0,1,1,1 4-7 (0x04-0x07) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 8-11 (0x08-0x0B) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 12-15 (0x0C-0x0F) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 16-19 (0x10-0x13) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 20-23 (0x14-0x17) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 24-27 (0x18-0x1B) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 28-31 (0x1C-0x1F) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 32-35 (0x20-0x23) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 36-39 (0x24-0x27) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 40-43 (0x28-0x2B) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 44-47 (0x2C-0x2F) 1,1,1,1,1,1,1,1 1,1,1,2,1,1,1,2 1,2,1,2,1,2,1,2 1,2,2,2,1,2,2,2 48-51 (0x30-0x33) 2,2,2,2,2,2,2,2 2,2,2,4,2,2,2,4 2,4,2,4,2,4,2,4 2,4,4,4,2,4,4,4 52-55 (0x34-0x37) 4,4,4,4,4,4,4,4 4,4,4,8,4,4,4,8 4,8,4,8,4,8,4,8 4,8,8,8,4,8,8,8 56-59 (0x38-0x3B) 8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8 60-63 (0x3C-0x3F) ``` "(For the record, yes, rate values of 2 and 3, 4 and 5, 6 and 7 do produce an identical output. That's not an error)". p5724: "there's no way to know what the shift value is set to when Rate = 0 ... I've got the shift value set to 11 in this case as it fits with the pattern"; "there's no way to know what increment values are used for a Rate of 1, since there's no way for this case to arise." - **Update cycle** (his pseudo-code, p5716): ``` ++globalCycleCounter For each operator //Read the shift value from Table 1 counterShiftValue = counterShiftTable[operator.rate] If (globalCycleCounter % (1 << counterShiftValue)) == 0 //Check the current cycle we're up to (0-7) updateCycle = (globalCycleCounter >> counterShiftValue) & 0x07 //Read the next attenuation increment value from Table 2 attenuationIncrement = attenuationIncrementTable[operator.rate][updateCycle] //Update the attenuation Endif Next operator ``` "At the max value of 11, the attenuation will only be updated once every 2048 cycles". Decay extremes on a PAL console: "up to 10223616 samples, or 193.5 seconds ... for a rate of 2", "as low as 312 samples for a rate of 63" (NOTE: these sample counts were computed under the withdrawn /351 clock; not restated after p6224). - The counter is global, HW (waveform screenshot "internal tables.png", rate 7, pattern 0,1,1,1,0,1,1,1 visible): "When you key-on an operator on the real system, it's possible for it to start at any point in the 8-cycle pattern of steps ... the first change in attenuation may happen at any time from the moment the note is keyed on". - **Decay phases:** `operator.attenuation += attenuationIncrement` - **Attack phase** as given in p5716: `operator.attenuation += attenuationIncrement * (((1024 - operator.attenuation) / 16) + 1)` with the inverted-output flag set during attack ("0x000 becomes 0xFFF, 0x12F becomes 0xED0" [sic, 12-bit examples for a 10-bit value]). "This formula was derived after a little experimentation." - p5724 (2008-07-11) QUALIFIES: on MAME not clearing the attenuation at key-on, "Yeah, I think they might be right about that actually. That calls into question my assertion that the YM2612 uses an output invert bit for the attack phase ... rather than resetting the contents of the attenuation register, they could be doing a binary NOT at the start of the attack phase ... That sounds most likely to me at this stage." So the attack model here is provisional in this part. - **Output:** "Take a copy of the current internal 10-bit attenuation number; If the output invert flag is set, perform a binary NOT on the number; Add TL to the number. TL is converted to a 10-bit attenuation value first. A limit is applied to prevent the result from overflowing." - **ADSR sequence** (p5716): key-on: set attack phase, calculate attack rate, "The current attenuation value is cleared" (doubted in p5724), inverted flag set. At attenuation 0: decay phase, decay rate. At SL: sustain phase, sustain rate. Then until max. Key-off at any point: release phase, release rate, "The inverted output flag is cleared". - **Maximum attack rate:** p5724: "When Rate = 62 or 63 during attack, the attack phase is skipped ... I think it far more likely that the YM2612 doesn't even enter the attack phase, and skips straight to decay when the calculated attack rate is greater than 61." p6179 (2008-09-03) says instead "When the calculated rate value for the attack phase is 60-63, I think you need to immediately switch the attenuation to minimum, and enter the decay phase. You should never generate a single sample based on the attack phase in such a case." (CONTRADICTION inside the thread: >61 vs 60-63; both "I think".) p5650 HW: in CSM, AR $1F works, and "a setting of $1E also works, and produces an identical output as $1F for this purpose". From emulator: MAME uses increment 16 instead of 8 for attack rates 62, 63 (Eke p5722). Eke p6219 (emulator patch, by ear on Mega Turrican track 3): with SL 0 and AR $1F the envelope "should directly start at the substain phase". - **Key-on timing:** p6179: "a key-on event shouldn't be processed until the start of an envelope generator update cycle" (stated as "definitely", no test described). - **Decay overshoot of SL:** p6179, p6225: untested; he thinks "the YM2612 clamps the decay phase to the sustain level" and switches to sustain then; "This is what I'm doing in my core." Speculation + emulator behaviour (Gens does it, fixes "Gynoug exploding SFX" per Eke p6226). - SL all bits set: "a max attenuation of 93dB when all bits are set" per both manuals (Eke p5615), not 45 dB. - Manual statement (p5512): "The shape of waves of the envelope changes in exponential when attacking it, and it changes in the straight line at other rates." ### SSG-EG (p5716; HW, recorded from a PAL MD1600 at 96 kHz) - Register $90-$9E, low 4 bits: ``` | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | / / / / | E |ATT|ALT|HLD| ``` "E = Enable. Unless this bit is set, SSG-EG mode is inactive, and none of the other bits have any effect. ATT = Attack. When this bit is set, the inverted output flag is initially set at the start of the first decay phase. ALT = Alternate. The inverted output flag is toggled after each repetition, alternating between 1 and 0. HLD = Hold. After the decay and sustain phases have completed one full pass, the output is held at the final level. Once hold mode begins, it doesn't end until key-off." "when you combine the ALT bit with hold, the inverted output flag is toggled before hold mode begins." - Repetition: "When the attenuation for the operator hits max, the envelope switches back to the attack phase." With AR $1F this amounts to attenuation reset to 0 and decay again. Four per-pass modes: Normal; Inverted (flag set, attenuation runs max to min); Held (max attenuation); Inverted Held (min attenuation). - "When an SSG-EG mode is applied to an operator, each time the attenuation value is being updated, the increase is multiplied by a factor of 6 ... all envelope generator decay phases, including the release phase": `operator.attenuation += 6 * attenuationIncrement`. Update timing unchanged. Attack rate "is not affected". (NOTE: the factor 6 was measured while he believed the /351 clock; not restated after p6224. AamirM p6239 guesses 4x; MAME uses 4 for decay/sustain and none for release per p5716. Treat the factor as possibly corrected in a later part.) - Key-off clears the inverted flag (MAME and Gens don't, giving "a constant tone"). - AR < $1F with SSG-EG ("officially undefined"): the attack phase is included in each repetition at its normal rate; the attack's own use of the inversion flag collides with SSG-EG's: "the results are inconsistent"; patterns 1-2 (no inversion) always work; ATT patterns "sometimes have their inversion overridden"; ALT patterns "may either be inverted or not"; "often a cross-over period of one update cycle ... creating a loud spike between each repetition." "Emulating all these quirks would require exact knowledge of when these flags are set and cleared." UNSETTLED. - SSG-EG is part of the FM module and unaffected by the removal of the SSG (p5699); "It's always behaved in a consistent fashion for me". Snake p6286 recalls "rather odd and unexpected results" but not what. - Toggling SSG-EG enable during release/decay: untested; Nemesis p6238 thinks the 6x factor could switch on/off live. Alisia Dragoon writes $FF to SSG-EG after key-off then $00 before key-on (Eke p6237). UNSETTLED. - TmEE p5723: an MD2's recording of the SSG-EG ROM "seems to work exactly like real YM2612 (but cleaner signal)". HW, MD2. ## 7. Operator unit (Nemesis p6114, 2008-08-28; HW "a lot of analysis and testing"; W2) - One operator: 10-bit EG output + 10-bit phase + 10-bit phase-modulation input → "a single 14-bit result", sent to the accumulator or used to modulate. - p5958 HW (2008-08-15): "The operator unit does output a native 14-bit value ... The internal sine table should store a 14-bit value" (MAME used 13). - Sine table (quarter wave, 256 entries, values = attenuation in 4.8 fixed point, 12-bit): ``` //sinTableBitCount = 8 //attenuationFixedBitCount = 8 for(unsigned int i = 0; i < (1 << sinTableBitCount); ++i) { double phaseNormalized = ((double)((i << 1) + 1) / (1 << (sinTableBitCount + 1))); double sinResultNormalized = sin(phaseNormalized * (M_PI / 2)); double sinResultAsAttenuation = -log(sinResultNormalized) / log(2.0); unsigned int sinResult = (unsigned int)((sinResultAsAttenuation * (1 << attenuationFixedBitCount)) + 0.5); sinTable[i] = sinResult; } ``` Comments: the phase is "a 9-bit index with the LSB fixed to 1"; "the upper two bits of the full phase are extracted by the external circuit" (quadrant: mirror and sign). - Power table (256 entries, 11-bit): ``` //powTableBitCount = 8 //powTableOutputBitCount = 11 for(unsigned int i = 0; i < (1 << powTableBitCount); ++i) { double entryNormalized = (double)(i + 1) / (double)(1 << powTableBitCount); double resultNormalized = pow(2, -entryNormalized); unsigned int result = (unsigned int)((resultNormalized * (1 << powTableOutputBitCount)) + 0.5); powTable[i] = result; } ``` ``` unsigned int YM2612::InversePow2(unsigned int num) const { unsigned int shiftCount = num >> powTableBitCount; unsigned int tableIndex = num & ((1 << powTableBitCount) - 1); unsigned int tableEntry = powTable[tableIndex]; unsigned int outputShifted = (tableEntry << 2) >> shiftCount; return outputShifted; } ``` - Combination (prose; the full data path is only in the linked diagram "ym2612 operator.png", not seen): the EG's 10 bits are a base-2 log attenuation in 4.6 fixed point (bit 6 = 1.0; weights 8, 4, 2, 1, 0.5 ... 0.015625), "so we just need to convert it to 4.8 fixed point form" (shift left 2) and add it to the sine table's 4.8 output; the sum goes through the power conversion. Yamaha approximated log10(2) = 0.30103 as 0.3, hence the "3 dB" per unit. - Precision: the 14-bit output "lacks the resolution required in order to represent numbers over around 40db attenuation ... Anything past that point just outputs 0". - "MAME already gets a 100% accurate output for this area". - The "ideal" floating-point version he gives first (sin × 10^(−att·48/1024/10), × (2^13 − 1)) is not what the chip does. - **Feedback:** NOT measured in this part ("I haven't started doing any serious testing of self-feedback"). Manual (via Eke p6096): S1(t) = E1(t) × sin(w1·t + B·S1(t)), B for feedback value 0..7 = 0, PI/16, PI/8, PI/4, PI/2, PI, 2·PI, 4·PI. From emulator (Eke p6096, Nemesis p6287): MAME and Gens feed back the sum (in effect average) of the last two outputs of operator 1; "This seems to be correct, but I can't figure out why" (Nemesis p6287, not verified on hardware). Feedback shift amounts given by Eke are from emulators. - **Operator evaluation order / delayed operand ("MEM"):** Nemesis p6090 reasons (not measured: "There's actually no way to verify what the operator unit stores from any tests on the system") that operators 1-4 are computed sequentially with one temporary store. Snake p6286 (developer of Kega, from memory, "hacking at the hardware"): "There are two [operators], running in parallel ... This is the reason for the 'odd' operator numbering (1,3,2,4) in the registers ... in most algorithms, an operator may need input from another one that's running parallel with it, and thus not ready yet. And so... it uses the previous output of that operator. This is what all the MEM stuff in Mame is all about, and it's correct." Nemesis p6287: "I haven't verified that on the hardware yet". UNSETTLED in this part: which operator inputs use the previous sample. - Algorithms: observations only (p6090): operators are only modulated by lower-numbered operators; operator 4 never modulates; algorithm 5 feeds operator 1 to the other three; algorithm 7 is four carriers (p5921, Shiru p5598 "algo #7 (all operators are slots)"). ## 8. Accumulator, DAC channel, output levels - Nemesis p5958 (2008-08-15), HW with an oscilloscope direct on the chip: - "Clipping DOES occur when operators are combined. The accumulator maps a single 14-bit operator output to the upper end of the 16-bit dynamic range of the DAC input ( operator output<<2 ). The accumulator limits the result to the 16-bit maximum, so if you were to try and combine two operators with a TL of 0, you'll get the upper half of the wave clipping. Try and combine 4 operators and you'll get the upper 3/4 of the wave clipping." - "After the DAC data is converted from unsigned to signed (DAC Data - 0x80), the result is simply mapped to the upper end of the 16-bit DAC input ( DAC data<<8 )." - p5971: unconfirmed whether operators are summed at 14 bits then shifted, or shifted then summed (whether the low 2 bits can be non-zero). p6258: "still a question in my mind about what the YM2612 sets the lower 2 bits of the 16-bit accumulator output to." - (In later parts of the thread this 16-bit picture may be revised; here it is his model as of 2008-08.) - p5917: "When the 'DAC Enable' flag in register 0x2B is set, the accumulator simply drops the 13-bit [later: 14-bit] operator output for channel 6, and maps the 8-bit 'DAC Data' register contents in register 0x2A to that channel instead." - FM vs PSG, Nemesis p5960 HW: "All 4 PSG channels at max combined is equivalent to the maximum output of a single YM2612 channel at max." With multiplexing, "the total output power at a given point in time will never exceed the maximum output of a single channel"; audible effect of multiplexing unknown. - The console's output circuit, not the chip, bends clipped/flat waveforms (p5960): at the chip pin "you get the proper waveform". - TmEE p5926: "The sine(s) are distorted at low TL values, but not clipped" (his MD2 recordings; superseded by Nemesis's oscilloscope note above). TmEE p5959: "MD1 DAC output it filled with aliasing noise, whereas MD2 DAC output is much cleaner." - Stereo and the DAC channel: TmEE p5624: on hardware you cannot play samples in stereo by switching the L/R register per sample (Kega lets you); no detail of what hardware does. - **Embedded DAC / ladder effect:** - Snake p6255 (memory, source forgotten): the output DAC "has one bit less than it would normally need ... some sort of compression/scaling which results in values close to silence being much louder"; p6260: "It's 9 bit instead of 10". - Nemesis p6258: "The YM2612 has an embedded YM3016 DAC. I know that for sure." The YM3015/YM3016 take 16-bit serial input (binary or two's complement) and convert internally to "a 3-bit exponent and 10-bit mantissa" (mantissa includes the sign, p6267). "The 'Form Select' and 'ICL' lines are also tied to bits in the test register." Not yet tested; "I've also noticed the extreme jump between low volume and silence". - HardWareMan p6259, HW (three oscilloscope/recording pictures, linked): "I confirm that! A very noticeable ladder effect is exist." ## 9. Timers, interrupts (Nemesis, HW) - YM2608 manual formulae (p5537): "tA = 72 * (1024 - NA) / M", "tB = 1152 * (256 - NB) / M" (microseconds, M in MHz). Sega manual (p5538): "18 * (1024 - TIMERA) microseconds", "288 * (256 - TIMERB) microseconds" (with its own misprinted examples). - p5680 (2008-07-01) HW: "the timer periods in the YM2612 are half the rate of the timers described in the YM2608 documentation": ``` To calculate Timer A period in microseconds: TimerA = 144 * (1024 - NA) / M NA: 0~1023 M: Master clock (MHz) Eg, where clock = 7.61Mhz TimerA(MAX) = 144 * (1024 - 0) / 7.61 = 19376.61 microseconds TimerA(MIN) = 144 * (1024 - 1023) / 7.61 = 18.92 microseconds To calculate Timer B period in microseconds: TimerB = (144*16) * (256 - NA) / M NB: 0~255 M: Master clock (MHz) Eg, where clock = 7.61Mhz TimerB(MAX) = (144*16) * (256 - 0) / 7.61 = 77506.44 microseconds TimerB(MIN) = (144*16) * (256 - 255) / 7.61 = 302.76 microseconds ``` So Timer A steps once per 144 clocks (one sample), Timer B once per 2304. - $27: bits 0, 1 = load A, B; bits 2, 3 = enable A, B (flag + interrupt on overflow); reset bits (per manual). A loaded timer "will count down at a regular rate, until it tries to count down from 0 and overflows. At this time, it will re-load the counter." With enable set, overflow sets the timer's status flag and triggers an interrupt. - Reload rules, p5687 HW: "the timer counter is only reloaded at the following times: 1. When the counter underflows 2. When the load bit is switched from 0 to 1 ... The counter does not restart from the last point it was up to when it is re-enabled. The timer counter is NOT reloaded when: 1. The load bit is already 1, and reg $27 is written to setting the load bit as 1 again 2. The reset or enable bits are changed 3. The timer counter registers are modified". - Timer A's two registers are not ganged: "Changes to either register $24 or $25 affect Timer A the next time it overflows or is loaded, regardless of the order" (p5680). - /IRQ pin (not connected in the Mega Drive), p5680 HW with oscilloscope: on overflow "The YM2612 will only generate an interrupt for that timer if the overflow bit is currently unset. If the overflow bit is unset, and the enable flag is set ... the INT line will be asserted. The INT line will remain asserted, until the reset bit for that timer is set to 1 ... or until the timer overflows again. If the reset bit for the timer is cleared at any time, the interrupt line will immediately be negated. If the timer overflows while INT is still asserted ... the interrupt line will immediately be negated. From this point on, no interrupts will be generated for that timer until the reset bit is set. Once the reset bit has been set when an interrupt has been missed, the INT line will not immediately be asserted." (His wording on "reset bit ... set / cleared" is as quoted; he calls the passage "confusing".) - Timer speeds are the same on MD1 and MD2 ("a quick check", p5697). ## 10. Channel 3 special mode and CSM (Nemesis p5650, 2008-06-29: "based entirely on tests performed on the YM2612 hardware") - $27 bits 7-6: ``` |Mode| Behaviour | | 00 | Normal | | 01 | Special | | 10 | Special + CSM | | 11 | Special | ``` "CSM mode is only active when the mode bits are set to 10, NOT when they are set to 11." (The YM2608 manual's table: 01 = CSM, 10 = effect sound; the hardware differs. Sega's manual: 01 special, 1x illegal.) - "In order for CSM mode to have any effect, Timer A must be loaded ... bit 0 of reg $27 must be set to 1. None of the other timer-related flags, including the reset and enable bits, nor the state of Timer B, have any impact". - "each time Timer A expires, the following two steps occur, in the specified order: 1. Key-on is sent to all operators in channel 3 2. Key-off is sent to all operators in channel 3 ... key on occurs, immediately followed by key-off, at the instant Timer A expires." Evaluated only at expiry; changes to the mode bits while the timer runs take effect at the next expiry. - Consequence observed: only AR $1F (and $1E, identical) gives sound; "All other settings for AR fail to produce any waveform"; TL and RR shape the envelope. - With manual key-on: "CSM mode only affects operators which are currently keyed off ... Timer A expiring will NOT key-off an operator which was manually keyed on by a write to register $28." - Works on an MD2 PAL VA1 too (TmEE p5660). Mega Turrican track 2 uses it (AamirM p6115). - Eke p5891 (emulator): to make the test ROM work he forces "attenuation level to MAX [sic] when Key ON is set and Attack rate is maximum" at once. - Snake p6255 (hearsay from Tatsuyuki Satoh's Japanese documents, 1997): "Timer A would do key ON, and you'd have to key it OFF again yourself in an interrupt"; Nemesis thinks that may be another chip. ## 11. Status, busy, write timing - Status read returns the same byte on every address (section 2). - TmEE p5704 (HW, MD2, informal): "the Busy bit doesn't last same time for all operations. Setting TL values seems to require more time than say writing to DAC ... on MD2, if you have a PCM playback loop and you wait for the Busy bit, then maximum sampling rate you get is somewhere near 33KHz." Not measured on MD1. - Hellfire's music runs at half speed "on MD2s (and other systems with Sega implementation of YM2612 in the ASIC)" vs the discrete chip (TmEE p5696; Nemesis p5697 hears it too). Cause not found: guesses are busy-flag length (TmEE, Snake p6286) or Z80 timing (Nemesis). UNSETTLED. ## 12. Test register, LFO, reset - Test register: only mentioned. Nemesis p5917 hopes to "use the test register to digitally latch the full 16-bits of data which are being sent directly to the DAC"; p6258: DAC "Form Select" and "ICL" lines "are also tied to bits in the test register". No bit map in this part. - LFO: nothing measured in this part. Eke's change list (p5871, emulator): "fixed LFO phase update for CH3 special mode (Warlock, Alladin)". - Reset: nothing. ## 13. YM2612 vs YM3438 / console revisions (this part) - "YM3438 (OPN2C) (CMOS implementation of the YM2612. Functionally identical)" (p5485). - MD2 SSG-EG output matches the discrete chip "but cleaner signal" (TmEE p5723). - MD1 DAC-channel playback has "aliasing noise"; MD2 "much cleaner" (TmEE p5959). - Hellfire half-speed on ASIC consoles (section 11). - "values below 8 [TL] should not be used" for tone on MD2 (TmEE p5660), unexplained. ## 14. Files, recordings, ROMs, images linked URLs appear truncated in the forum text ("...") exactly as below. | What | URL as posted | By | Ran on / notes | Post | |---|---|---|---|---| | YM2608 manual (Japanese, 67 pages) | http://nemesis.hacking-cult.org/MegaDri ... M2608J.PDF | Yamaha; from Malfunction (soundshock.se) | | p5485 | | YM2608 manual, English | http://nemesis.hacking-cult.org/MegaDri ... slated.PDF | Nemesis (machine translation, corrected); updated 2008-07-01 | | p5485, p5568, p5676 | | Archive: YM3016 datasheet, YM2608 ADPCM, YMF288, 86 Sound Board manual | http://nemesis.hacking-cult.org/MegaDri ... YM2608.ZIP | via Malfunction | | p5485 | | Genesis Sound Software Manual | http://nemesis.hacking-cult.org/MegaDri ... Manual.pdf | Sega | | p5485 | | operators.png, "operator registers.png" | http://nemesis.hacking-cult.org/MegaDrive/Documentation/operators.png ; .../operator%20registers.png | from YM2608 manual | | p5495 | | Manual excerpts fm_1 to fm_6 .gif | http://gxdev.wordpress.com/files/2008/06/fm_1.gif (… fm_6.gif) | Eke, from the YM2608 manual | key on/off, feedback, SSG-EG, timers, CH3, F-number | p5532 | | Detune test ROM + source | http://nemesis.hacking-cult.org/MegaDri ... detune.bin ; ... detune.asm | Nemesis | continuous tone on "the real system (and Kega)" | p5618 | | Frequency write order ROM + source | http://nemesis.hacking-cult.org/MegaDri ... eOrder.bin ; ... eOrder.asm | Nemesis | plays A6 on hardware, A4 if applied at once | p5621 | | CSM test ROM + source | http://nemesis.hacking-cult.org/MegaDri ... smmode.bin ; ... smmode.asm | Nemesis | "fading, repeating A6 tone" | p5651 | | CSM recording | http://nemesis.hacking-cult.org/MegaDri ... smmode.wav | Nemesis | "PAL MD1600 MegaDrive, recorded at 96KHz" | p5651 | | SSG-EG test ROM + source | http://nemesis.hacking-cult.org/MegaDri ... ssg-eg.bin ; ... ssg-eg.asm | Nemesis | all 8 patterns | p5716 | | SSG-EG recording | http://nemesis.hacking-cult.org/MegaDri ... md1600.rar | Nemesis | "PAL MD1600 MegaDrive, recorded at 96KHz" | p5716 | | SSG-EG recording, MD2 | http://www.fileden.com/files/2008/4/21/ ... SSG-EG.rar | TmEE | his MD2, silence cut | p5723 | | EG screenshots: "internal tables.png", "ssg-eg register.png", "ssg-eg pass1.png", "pass2.png", "ssg-eg mode1..4.png", "inverted attack.png", "ssg-eg messed up.png", "ssg-eg spike.png" | http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/… | Nemesis | waveform captures from hardware and diagrams | p5716 | | Operator diagram | http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ym2612%20operator.png | Nemesis | the operator data path | p6114 | | Phase generator diagram; "detune register.png", "detune table.png", "multiple register.png" | same directory: phase%20generator%20diagram.png etc. | Nemesis / YM2608 manual | | p6177 | | DAC block diagram | .../YM2612%20Notes/DAC.png | from YM3015 datasheet | | p6258 | | YM3016 datasheet (Japanese), YM3015 (English) | http://nemesis.hacking-cult.org/MegaDri ... M3016J.pdf ; ... YM3015.pdf | Yamaha | | p6258 | | Oscilloscope: multiplexed output | http://img49.imageshack.us/img49/2044/ym26121mv6.jpg ; http://img367.imageshack.us/img367/5593/ym26122mg1.jpg | HardWareMan | console not stated | p5717, p5919 | | Ladder-effect pictures | http://img261.imageshack.us/img261/3083/80397931gn5.th.png ; http://img522.imageshack.us/img522/5593/16493221uy4.th.png ; http://img131.imageshack.us/img131/2051/19696138zd5.th.png | HardWareMan | | p6259 | | YM2151 block diagram | http://img372.imageshack.us/img372/7429/ym2151vj3.th.gif | via Eke | 14-bit into the accumulator | p5941 | | Patents: self-feedback; FM synthesis | http://www.google.com/patents?id=IeA3AAAAEBAJ ; http://www.google.com/patents?id=GNEzAAAAEBAJ | Yamaha (per Eke) | | p6096 | | YM2151 docs | "ym2151docs.pdf here: http://msx.retro8bits.com/msxdocs.html" | | | p5615 | | Timer period thread | http://www.spritesmind.net/_GenDev//for ... .php?t=228 | Eke | theoretical | p5539 | | Channel-3/second-bank test thread | http://www.spritesmind.net/_GenDev/foru ... .php?t=231 | Shiru | hardware + emulators | p5719 | | Flashback sound thread | http://www.spritesmind.net/_GenDev/foru ... =2699#2699 | | | p5592 | | TmEE's stereo-sample demo | http://www.hot.ee/tmeeco/MD.HTM | TmEE | | p5624 | | Mega Turrican register picture; VGMs; in_vgm | http://gxdev.wordpress.com/files/2008/0 ... rrican.jpg ; http://project2612.org/details.php?id=140 ; http://www.smspower.org/maxim/forumstuf ... in_vgm.zip | Eke / Project2612 / Maxim | | p6092 | | Genesis Plus fm.c (modified MAME) | http://code.google.com/p/genplus-gx/sou ... sound/fm.c | Eke | EMULATOR SOURCE: not to be opened | p5871 | | Real-hardware clip of Mega Turrican track 3 | "Here" (link text only, URL lost) | AamirM | | p6095 | Games named as tests of behaviours: Flashback, Ariel, Comix Zone, Shaq Fu, Spiderman (detune overflow, GEMS); Mega Turrican tracks 2 (CSM), 3, 6, 9; Spider-Man Separation Anxiety stage 1 and title; Ghostbusters track 10 (SSG-EG, channel 6); Asterix sound test 0xA (sounds different each play; SSG-EG); Bubba 'n Stix track 5; Batman & Robin intro (AR refresh); Ecco 2 splash; Alisia Dragoon track 03 (SSG-EG written $FF after key-off); Gynoug explosion (SL clamp); BattleTech track 12; Hellfire (MD1 vs MD2 tempo); Dune "Ammons Advice"; Vectorman 2 "Planet Fall Dig"; Warlock, Aladdin (LFO with CH3 mode). ## 15. Open questions left by this part 1. When AR/DR/SR/RR/KS writes take effect (at phase change, at key-on, or at once). 2. Attack: exact form (formula p5716 "derived after a little experimentation"); whether attenuation is cleared, inverted or kept at key-on; the invert-flag model is doubted by its author (p5724). 3. Which calculated attack rates skip the attack: ">61" (p5724) or "60-63" (p6179). 4. Whether decay clamps to SL on overshoot (believed, untested). 5. SSG-EG: the ×6 factor's standing after the EG clock correction; behaviour with AR < $1F; effect of writing the register mid-note; exact flag timing. 6. Self-feedback: why/whether the last two outputs are summed; scaling per FB value on hardware; not measured. 7. Which modulation inputs use the previous sample ("MEM"): asserted by Snake, unverified. 8. Low 2 bits of the accumulator's 16-bit output; sum-then-shift or shift-then-sum. 9. The embedded DAC: 9-bit vs 10-bit mantissa, the "ladder" jump near silence; no numbers. 10. Busy flag duration, per register and per chip (YM2612 vs ASIC); Hellfire. 11. Test register bit map; LFO (AM and PM); reset state: all untouched here. 12. Exact per-channel multiplex timing (HardWareMan's measure did not match exactly). 13. EG clock = FM clock / 3 rests on "a rough adjustment" of earlier data plus MAME, not a fresh measurement. 14. Where in the sample the envelope is updated relative to the operator output (Eke p6219 asks; no answer). 15. The key-on being "processed at the start of an envelope generator update cycle" (asserted p6179, no test described).