######## POST p8557 | TmEE co.(TM) | 2009-04-20 | t386-450.html I believe you wanted BTST #7, (A0) instead of BTST D7, (A0) in your files... or if you did meant D7, you forgot to put #7 in it... on MD2, I was unable to do any tests until I "fixed" YM write routine (ASIC YM2612 is slower...). Here's a small shot from my audio modded MD2 : http://www.fileden.com/files/2008/4/21/ ... 1000Hz.jpg The lines are very thick because the sine is very distorted on low TL values, the cause is either my sound mod (which is unlikely...) or ASIC YM2612 just not being able to output high volume stuff too well...... anyway, the harmonics are different from your MD1 recording. Here's a 48KHz (my card could do 500KHz according to datasheet, but the old and apparently best drivers don't allow more than 48KHz)... http://www.fileden.com/files/2008/4/21/1876835/YM77.jpg I'll try to do some recording from my gaming machines onboard crap later... it should be able to do 192KHz and 24bit (though I believe its more like 96Kz and 16bit that's made "big" in software)... PS: I would love to have a screen capable of 2048x1536 [IMG ./images/smilies/icon_razz.gif] ######## POST p8558 | GManiac | 2009-04-20 | t386-450.html [QUOTE] TmEE co.(TM) wrote:I believe you wanted BTST #7, (A0) instead of BTST D7, (A0) in your files... [/QUOTE] No, I put #7 to D7 and then used BTST D7,(A0) because this command is shorter then BTST #7,(A0) and takes less cycles. I used short commands deliberately (like bsr.s and bne.s) to make more free cycles remain for other purposes. [QUOTE] TmEE co.(TM) wrote:or if you did meant D7, you forgot to put #7 in it... [/QUOTE] Really! In older versions I put #7 to D7 and later I erased that lines and forgot about it. Thanks, I will correct this. [QUOTE] TmEE co.(TM) wrote:Here's a small shot from my audio modded MD2 : http://www.fileden.com/files/2008/4/21/ ... 1000Hz.jpg The lines are very thick because the sine is very distorted on low TL values, the cause is either my sound mod (which is unlikely...) or ASIC YM2612 just not being able to output high volume stuff too well...... anyway, the harmonics are different from your MD1 recording. [/QUOTE] No, no, thickness of lines is caused by small divisor. You should go to Settings of your program (it looks like Cool Edit 2 or higher or Adobe Audition, right?), then to "Display" or "Spectral" and choose resolution of 512..2048 bands - then lines will be thin. Also there you can increase brightness of spectrum, for 1024-2048 bands the good value is 130-140 dB. [QUOTE] TmEE co.(TM) wrote:Here's a 48KHz (my card could do 500KHz according to datasheet, but the old and apparently best drivers don't allow more than 48KHz)... http://www.fileden.com/files/2008/4/21/1876835/YM77.jpg [/QUOTE] You mentioned Yamaha card and it's rather old, right? How can it handle 500 kHz??? while hi-end cards handle only 384 kHz with SNR 120 dB? [QUOTE] TmEE co.(TM) wrote:PS: I would love to have a screen capable of 2048x1536 [IMG ./images/smilies/icon_razz.gif] [/QUOTE] My screen is 9 years old [IMG ./images/smilies/icon_smile.gif] and it can't handle (could not) so high resolution, but for some reason it handle this res. And what about AFC? Please show your oscillogram, I wonder if high frequencies are filtered or not [IMG ./images/smilies/icon_wink.gif] Anyhow, as you use 48 kHz ADC, frequencies higher than 22-24 kHz will be absent on your oscillo and AFC won't be a straight horizontal line - it will sag mostly at 26 kHz. ######## POST p8560 | GManiac | 2009-04-20 | t386-450.html I corrected files in that archive: http://shedevr.org.ru/ghost/ym2612/sweep_1000.rar and added another demo, "mirror.asm". I'll explain its meaning. As I mentioned it doesn't matter for YM to play frequency X or 52781-X. We know these formulas: F-Number = 144 * freq * (2^20 / MCLOCK) / 2^(Oct - 1) / multiplier freq = multiplier * F-Number * 2^(Oct - 1) * (MCLOCK / 2^20) / 144 MCLOCK/144 = 52781 Octave 7 gives multiplying by 64, maximum note + 1 = 2047+1 = 2048, so 2^20 / 64 / 2048 = 1048576 / 64 / 2048 = 8, so multiplier 8, octave 7 give us frequencies up to 52781, excluding last value (it corresponds to note 2048, but highest note is 2047). Okay, we want to see mirroring and multiplying effects and to hear low frequencies caused by these effects while our main frequencies will be high, so we won't mess "main" and "side" harmonics. So errors of low-res ADC or discrete spectrogram won't influence on our experiment and we'll hear these harmonics right in headphones. As MASTER_FREQ corresponds to note 2048, we can operate with integer numbers. If our freq is x, then it's multiple freqs are n*x and its mirrors are 2048-n*x. The lowest mirror will be 2048-n*x = 2048 mod x. I want x to be multiple of some first integers (2,3,5,7...), the lowest multiple of 2..7 is 420, but 2048 mod 420 = 368, it corresponds 9 khz, it's not a good choice If we exclude 5 then we get 84 (420/5) and this is very good number: 2048 mod 84 = 32 = 825 Hz Mirror of 32 is 2016 and it is multiple of 2,3,4,6,7,8,9! So I wrote this demo with dividing note 2016 by numbers from 1 to 9. And firstly it plays note 32. Here's spectrogram (Cool Edit 1, Blackman's algorithm, 2048 bands, Range 140 dB): [IMG http://shedevr.org.ru/ghost/ym2612/mirror_2048_140.jpg] As you can see, notes 32 and 2016 (first two columns) are identical. All divisors give phantom of note 32 (825 Hz at the bottom of spectrogram), except 5 - it makes phantom of 33 (850 Hz). And, starting from divisor 4 there is some sort of ladder steps proportionally between main and mirrored harmonics. Divisor 4 has 1 "pair of steps", divisor 5 has 2 "pairs", etc., last divisor (9) has 6 pairs. Listening to HW we can hear the same note (excluding divisor 5) in various octaves - that prooves presenting of 825 Hz freq and its multiples. ######## POST p8561 | TmEE co.(TM) | 2009-04-20 | t386-450.html [QUOTE] GManiac wrote:No, no, thickness of lines is caused by small divisor. You should go to Settings of your program (it looks like Cool Edit 2 or higher or Adobe Audition, right?), then to "Display" or "Spectral" and choose resolution of 512..2048 bands - then lines will be thin. Also there you can increase brightness of spectrum, for 1024-2048 bands the good value is 130-140 dB. [/QUOTE] ok, done, looks good [IMG ./images/smilies/icon_biggrin.gif] I have Cool Edit Pro 2 http://www.fileden.com/files/2008/4/21/ ... /YM672.jpg (some stuff looks like its missing because of noise reduction which I forgot to undo). http://www.fileden.com/files/2008/4/21/ ... /YM772.jpg [QUOTE] GManiac wrote:You mentioned Yamaha card and it's rather old, right? How can it handle 500 kHz??? while hi-end cards handle only 384 kHz with SNR 120 dB? [/QUOTE] The datasheet of the chipset says the card can process 2MBytes worth of data per second... so 2000000 / 2(16bits) / 2(stereo) = 500000 The card has 18bit ADC and DAC (16bits seen by outside world though). Its a ISA DMA based card so it can very well be true... [QUOTE] GManiac wrote:And what about AFC? Please show your oscillogram, I wonder if high frequencies are filtered or not [IMG ./images/smilies/icon_wink.gif] Anyhow, as you use 48 kHz ADC, frequencies higher than 22-24 kHz will be absent on your oscillo and AFC won't be a straight horizontal line - it will sag mostly at 26 kHz. [/QUOTE] Here it is, things start getting attenuated after ~15...16KHz. http://www.fileden.com/files/2008/4/21/ ... /YM672.png I don't quite know why DC offset changes... its probably because of transistors not biased optimally in the sound mod... ######## POST p8619 | Lord Nightmare | 2009-05-01 | t386-450.html Ok, even if I don't understand the exact importance of them, those images look DAMN cool! Wouldn't they look identical between MD1 and MD2 if both were sampled at the same rate? Does the samplerate have a large effect on those images? Does anyone have a ym3438/opn2c to compare to the opn2 in the md1? (the fmtowns system has an opn2c in it iirc) LN ######## POST p8620 | TmEE co.(TM) | 2009-05-01 | t386-450.html I somehow think that YM3438 will generate things close to ASIC YM2612... the ASIC should be in CMOS (because the rest of the MD2 is CMOS) ######## POST p8642 | GManiac | 2009-05-07 | t386-450.html Hm, is there any way to make Yamaha chip slower? I know two ways: 1) change quartz of MD from 53 MHz to more slow 2) change frequency divider of YM2612 to more large (originally it's 7, so YM's freq is 53/7=7.6 MHz). I don't think this is absolutely impossible, but can't say is it easy or difficult. If I could I made this by myself, but I'm strongly unfamiliar with electronics [IMG ./images/smilies/icon_sad.gif] Of course it's better to make experiments on original frequency with very powerful ADC capable of 3GHz at 16 bits, but this method will give us some advantages: - usual sound card can replace fast ADCs (and oscilloscopes) which are pretty expensive and are often 8 bit resolution. 16 bit ones are more expensive, but it's not main problem - 16 bit ADC must provide SNR of about 100 dB, but I don't believe that they do it. At the same time sound cards provide this SNR. ######## POST p8643 | HardWareMan | 2009-05-07 | t386-450.html I'll try to divide VCLK for YM2612 by 10. That must all YM2612 output frequences down by 10 too. But, I'll take a record from YM2612 directly, becouse analog filter part will become useless. Why I had not guessed this before? ######## POST p8645 | TmEE co.(TM) | 2009-05-07 | t386-450.html I have had nice results running YM2612 on 3.5MHz and 17MHz [IMG ./images/smilies/icon_razz.gif] I should have done some recordings... ######## POST p8646 | GManiac | 2009-05-07 | t386-450.html The main target is to record single wavefronts from YM, we know that their frequency is 317 kHz (7.67 MHz/24) and duration of 1 wavefront is 6 cycles (look at screenshots by Nemesis) and of zero point - 18 cycles. So if you want to take several samples per 1 wavefront (including silence) of YM, you should slow YM at least by 20-50 times. The good value is 158-160 times (7.60-7.67 MHz / 48 kHz) - then recording at 48 kHz speed will give us 24 "cycles" per one channel, so oscillogram from sound card will look just like in screenshots by Nemesis. ######## POST p8647 | TmEE co.(TM) | 2009-05-07 | t386-450.html if the chip gets too slow, it will probably start experiencing trouble when its being written/read by much faster chip.... underclokcing controlling CPU would become necessary too I guess ######## POST p8649 | HardWareMan | 2009-05-07 | t386-450.html [QUOTE] TmEE co.(TM) wrote:if the chip gets too slow, it will probably start experiencing trouble when its being written/read by much faster chip.... underclokcing controlling CPU would become necessary too I guess [/QUOTE] I think, access to register file is asynchronous and CPU will not have any trouble. Timers and "BUSY" flag will slow down too, so timer controlled software will slow down and software wich do not use those timers - not. Using the "BUSY" flag and timers in test ROM IMHO will works fine. ######## POST p8652 | TmEE co.(TM) | 2009-05-07 | t386-450.html the chip probably has certain timing requirements and if the chip is made very slow, it may start missing the faster bus operations done to it..... ######## POST p8653 | Shiru | 2009-05-07 | t386-465.html Old chips has requirements for minimal operational frequency and don't work at lower frequencies, because their internal registers are dynamic memory-based. ######## POST p8750 | Lord Nightmare | 2009-05-19 | t386-465.html BTW, could the differences on those graphs on the prior page, between the ym2612 and the sega asic version, be because the sega asic one has the 'off by one' error on the descending portion of the sine wave fixed? LN ######## POST p8751 | GManiac | 2009-05-19 | t386-465.html When I set AR=$FF and looked at growing amplitude of sine from 0 to MAX, I noticed that multiple harmonics have the same level at all levels of sine. And figured out that they are result of "ladder effect" - it is irregular meander, it contains all multiples of main frequency, not only odd ones, but odd multiples (especially "4*n+3" ones) are stronger. But I don't know why harmonics are also reflected from level of 52781 Hz - is it result of irregularity of "ladder"? And eventually what causes this "ladder effect"? And what about slowing YM down? I don't see any reports [IMG ./images/smilies/icon_smile.gif] upd: TA-07 in my chinese MD2 also showed same "ladder", and spectrogram made by TmEE from his MD2 contained it too. ######## POST p8753 | TmEE co.(TM) | 2009-05-19 | t386-465.html some interesting info : AamirM asked me to record the into music of Ariel the Little Mermaid (or whatever the title was), and when you just listen it, hihats are "Tss Tss", but when I recorded the sound they went "Blau Blau" like broken emulators [IMG ./images/smilies/icon_eek.gif] I am gonna try to see if recording the output of my sound card (the card has internal loopback setup) or microphone makes a difference.... this is fun [IMG ./images/smilies/icon_razz.gif] ######## POST p8763 | TmEE co.(TM) | 2009-05-20 | t386-465.html http://www.fileden.com/files/2008/4/21/ ... /ARIEL.RAR a recording of the effect, first 10 seconds is with mic, and that's how things would sound, last part is line-in or loopback and it sounds like broken emulator... ######## POST p8767 | HardWareMan | 2009-05-21 | t386-465.html Very interesting. I think the thing in the very high frequencies that are filtered and aliased when sampling. ######## POST p8772 | notaz | 2009-05-21 | t386-465.html Doesn't it also happen with BGMs like Battletech, Comix Zone BGM5, etc? ######## POST p8773 | TmEE co.(TM) | 2009-05-21 | t386-465.html Last time I did this, they did not, but then my sound mod was in different state (I'm improving it right now and it does not propose filtering on high frequencies that much over long cables than it did before). what HWM said is probably the cause, aliasing+reflections of the freqs that can't be handled by the ADC at given sample rate cause it. ######## POST p8783 | HardWareMan | 2009-05-22 | t386-465.html [QUOTE] TmEE co.(TM) wrote:what HWM said is probably the cause, aliasing+reflections of the freqs that can't be handled by the ADC at given sample rate cause it. [/QUOTE] Exactly. ######## POST p8811 | TmEE co.(TM) | 2009-05-28 | t386-465.html Some fun stuff : I did major undercloking in my MD2... the lowest master clock I used was 3.6MHz (NTSC color carrier or something close), that means YM and 68K ran off ~500KHz and Z80 ~200KHz... YM output is nicely ~4000Hz then [IMG ./images/smilies/icon_smile.gif] I would like to try lower speeds but I have no smaller crystals. I recorded some music off my sound system and when speeding it up 14 times, I get correct speed and pitch for the song so thigns work. due to HW nuances in analog area, of course things won't sound exactly same when sped up [IMG ./images/smilies/icon_smile.gif] The file is too big for me to upload (it would upload forever.....). I'll see how small I can get it, if it becomes small enough I'll put it up. ######## POST p8842 | Christuserloeser | 2009-06-01 | t386-465.html [QUOTE] Nemesis wrote:The next info I post will be on the LFO. The current LFO implementation in MAME is mostly correct, but there is an error in the phase modulation implementation which I'll detail. I've also figured out the cause of the different sound in Battletech track 12, which was discussed awhile back in this thread. I'll post a detailed description on what causes the difference in sound, but it's actually a fairly complex explanation, so it'll be quite a long post. Apart from that, I've got some more testing to perform on the operator unit relating to the way algorithms are implemented, the DAC needs some attention, and I'm going to publish my own notes on the YM2612 test register, but after that, I'll be pretty much done with the YM2612. [/QUOTE] Did you ever post the info on LFO / phase modulation ? (I am asking because I might have overlooked something) ######## POST p8905 | Nemesis | 2009-06-15 | t386-465.html [QUOTE] Did you ever post the info on LFO / phase modulation ? (I am asking because I might have overlooked something) [/QUOTE] Not yet. Sorry, I've been really short on free time lately, so I've had to dial back on this stuff for a while. If you've got a specific question, I should be able to answer it. In terms of writing up a full description of the LFO, I just don't think I've got the time right now. What I will do is try and briefly describe what's wrong in the MAME implementation of frequency modulation. Actually, I think I'll just cut and paste from my raw testing notes: [QUOTE] -We have confirmed that MAME implements phase modulation incorrectly. Phase modulation is applied to the 11-bit fnum value before it is combined with the block data, or any other operations are carried out using it. This is done using the same process implemented in the MAME core, but without the apparent extra bit of precision which was added, which is also what breaks the precision loss when block data is 0. The incorrect calculations most likely originated from confusion over the sign extension of the phase modulation value when it was in the negative oscillation, which would create an apparent extra bit of precision, even when all significant bits had been discarded. By repeatedly disabling the LFO before it entered into the negative oscillation phase, and carefully measuring and monitoring the output from the YM2612, we were able to observe that frequency modulation values do indeed cut off after the 11th bit, not the phantom 12th bit which MAME creates. [/QUOTE] (Never mind all the "we" references. That means I'm in agreement with myself over what I'm writing. I write all my notes as if I have some kind of multiple personality disorder, that way I can disagree or debate with myself in note form if I'm not entirely convinced of something.) In a nutshell, when the author of frequency modulation in the MAME core was doing hardware tests, he made a mistake in his analysis which made him think frequency modulation had one more bit of precision than it really did. He made this mistake because frequency modulation applies a signed displacement value to the base frequency, and being a signed value, that displacement value is sign-extended. As a result of the sign-extension, the frequency modulation value always has at least one bit of precision, even if all the "real" bits have been lost. This error is the source of this (erroneous) statement in the MAME core: [QUOTE] /* there are 2048 FNUMs that can be generated using FNUM/BLK registers but LFO works with one more bit of a precision so we really need 4096 elements */ [/QUOTE] There is no extra bit of precision with frequency modulation. Frequency modulation is applied directly to the base fnum value, which is an 11-bit number, and this is the very first step in the phase generator, before block data is even applied to fnum. I conducted a whole battery of tests using observable overflow conditions and precision limitations during the phase generator update cycle to prove this is the case, and the current implementation in MAME (and, IIRC, in Kega as well?) is measurably incorrect. The good news is, the correct implementation of frequency modulation simplifies the whole process greatly. The frequency modulation stage just "slots in" at the beginning of the update cycle for the phase modulator, without requiring any changes to the existing pipeline. For MAME, this means all changes which have been made to treat fnum as a 12-bit value should be stripped out. ######## POST p8907 | Eke | 2009-06-15 | t386-465.html [QUOTE] (Never mind all the "we" references. That means I'm in agreement with myself over what I'm writing. I write all my notes as if I have some kind of multiple personality disorder, that way I can disagree or debate with myself in note form if I'm not entirely convinced of something.) [/QUOTE] [IMG ./images/smilies/icon_lol.gif] Thanks to "all of you" anyway, makes everything easier to understand [QUOTE] Frequency modulation is applied directly to the base fnum value, which is an 11-bit number [/QUOTE] ok, so you mean that the value from "lfo_pm_table" (in the MAME core) should be added to the fnum value (11 bits), NOT to the block+fnum value (14 bits, identified by block_fnum in the MAME core) like it's done actually (well it's actuallty done on block_fnum << 1 because of this increased precision thing) ? I mean, the "block" value is not affected by the modulation, is it ? I don't really understand that part of the MAME implementation, because fnum AND block value are recalculated after the addition of the phase modulation [IMG ./images/smilies/icon_confused.gif] Also in that case, I would think the result should be masked as a 11 bits value (by 0x7ff) ? but what if the resulted fnum becomes negative, does it have the sign bit extension or is it simply masked like with detune overflow ? ######## POST p8908 | Nemesis | 2009-06-18 | t386-465.html [QUOTE] ok, so you mean that the value from "lfo_pm_table" (in the MAME core) should be added to the fnum value (11 bits), NOT to the block+fnum value (14 bits, identified by block_fnum in the MAME core) like it's done actually (well it's actuallty done on block_fnum << 1 because of this increased precision thing) ? I mean, the "block" value is not affected by the modulation, is it ? I don't really understand that part of the MAME implementation, because fnum AND block value are recalculated after the addition of the phase modulation [/QUOTE] The MAME core is pretty messy, and I've forgotten most of what I knew about exactly how MAME implemented the phase generator, so I'm hesitant to try and give specific advice on exactly how to modify the MAME core to fix is up. MAME crams the block and fnum data into a single variable, it uses a large lookup table to calculate frequency modulation, it tries to cache the final phase increment value and only recalculate it when it changes, and it has multiple update functions for the phase generator which are called at different times under different circumstances. All of these decisions are designed to try and get more speed out of the core, but they also mean making changes is a lot more painful than it should be. What I can tell you is the frequency modulation adjustment is applied directly to fnum, before block data is applied, and this is an 11-bit calculation. In a pure implementation, your phase generator update function should be a series of six discrete steps: 1. Get the current value of fnum (11-bit result) 2. Apply frequency modulation to the fnum value (11-bit result) 3. Shift fnum by the block data to obtain the initial phase increment value (17-bit result) 4. Apply detune to the phase increment value (17-bit result) 5. Apply the frequency multiplier to the phase increment value (20-bit result) 6. Add the final phase increment value to the phase counter (20-bit result) It's a lot more complicated than this in the MAME core, but this is how the phase generator is updated each cycle in the YM2612. [QUOTE] Also in that case, I would think the result should be masked as a 11 bits value (by 0x7ff) ? but what if the resulted fnum becomes negative, does it have the sign bit extension or is it simply masked like with detune overflow ? [/QUOTE] Phase modulation can't cause a negative overflow like with detune, since the "amplitude" of the phase modulation is dependent on the initial fnum data itself, specifically, the upper 6 bits of fnum. If all upper six bits of fnum are 0, phase modulation won't adjust fnum at all. Due to the way phase modulation is applied to fnum, fnum will always be larger than the amount that would be subtracted from fnum during the peak of the negative oscillation of the phase modulation. Phase modulation can cause a positive overflow with fnum however. If all bits of fnum are set for example, the positive oscillation of phase modulation will cause an overflow. In this case, the upper bits are lost. The result is an 11-bit result, so a positive overflow will cause fnum to wrap around from a very large value to a very small value. In other words, just mask the result of the addition between fnum and the phase modulation value with an 11-bit mask, and you'll get the correct result. Or at least, that's how it would be without the extra bit of precision that's been added into the MAME core. ######## POST p8909 | Eke | 2009-06-18 | t386-465.html [QUOTE] It's a lot more complicated than this in the MAME core, but this is how the phase generator is updated each cycle in the YM2612. [/QUOTE] Not really that much, just that the phase increment value is only recalculated when needed (i.e some registers changed) and that the fnum value is shifted by the block value immediately when the block/fnum register is updated, again on optimization purpose. The reason why the block/fnum value is also stored is because of LFO: when LFO is active, the phase increment value is indeed recalculated on each update cycle instead and frequency modulation is applied before block shifting (yes, in that case, this means that some redundant calculation has been done so it's less efficient when LFO is active !) Anyway, here's how I modified the phase update function in that case: [CODE BLOCK WITHHELD: 877 chars] lfo_fn_table_index_offset is a value from the LFO table, which indeed depends on the FNUM higher 7 bits, LFO depth (0~7) and LFO current step (0~31). It is negative value for steps above 16. I assume the MAME base LFO table is correct: [CODE BLOCK WITHHELD: 3395 chars] ######## POST p8911 | Nemesis | 2009-06-18 | t386-480.html That table is correct, but mostly redundant. I use the following table in my core: [CODE] const unsigned int YM2612::phaseModIncrementTable[1 << pmsBitCount][1 << (phaseModIndexBitCount - 2)] = { {0, 0, 0, 0, 0, 0, 0, 0}, //0 {0, 0, 0, 0, 1, 1, 1, 1}, //1 {0, 0, 0, 1, 1, 1, 2, 2}, //2 {0, 0, 1, 1, 2, 2, 3, 3}, //3 {0, 0, 1, 2, 2, 2, 3, 4}, //4 {0, 0, 2, 3, 4, 4, 5, 6}, //5 {0, 0, 4, 6, 8, 8,10,12}, //6 {0, 0, 8,12,16,16,20,24}}; //7 [/CODE] This corresponds with the lookup table for fnum bit 9. You'll note that the lookup table for every other bit is simply a shift of this table. For fnum bit 10, shift the values up by 1. For fnum bit 8, shift the values down by 1. For fnum bit 7, shift the values down by 2, etc. Note that I say the table above corresponds with fnum bit 9, but in MAME, since they're giving the values for use with a 12-bit fnum calculation instead of an 11-bit calculation, the MAME table for fnum bit 9 will be shifted up by 1. Looking back on my notes, I've realised there's some testing I still haven't completed for frequency modulation. I've talked about the upper six bits being relevant for frequency modulation, and the lower bits not having an effect. That's not entirely true however. According to my notes, I measured sign-extension taking effect in the negative portion of the frequency modulation wave, even when the only fnum bits set were below the upper six bits, all the way down to fnum bit 0, which suggests that the frequency modulation value may be calculated at full precision, then the lower bits discarded when it is combined with fnum, eg: [CODE] // --------------------------------------------- // | Fnum (11-bit) | // |-------------------------------------------| // |10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | // --------------------------------------------- // --------------------------------------------------------------------------------- // | Frequency Modulation Value (20-bit) | // |-------------------------------------------------------------------------------| // |19 |18 |17 |16 |15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | // --------------------------------------------------------------------------------- //10 | 4 | 3 | 2 | 1 | 0 | // 9 | 4 | 3 | 2 | 1 | 0 | // 8 | 4 | 3 | 2 | 1 | 0 | // 7 | 4 | 3 | 2 | 1 | 0 | // 6 | 4 | 3 | 2 | 1 | 0 | // 5 | 4 | 3 | 2 | 1 | 0 | // 4 | 4 | 3 | 2 | 1 | 0 | // 3 | 4 | 3 | 2 | 1 | 0 | // 2 | 4 | 3 | 2 | 1 | 0 | // 1 | 4 | 3 | 2 | 1 | 0 | // 0 | 4 | 3 | 2 | 1 | 0 | [/CODE] In this case, the lookup table I've given above would correspond with fnum bit 0, and you would shift up from that for each place above bit 0, then negate the value if we're in the negative half of the wave, and finally you'd shift down 9 places and add the result to fnum. I don't do this in my core currently however. Like MAME, I'm just grabbing the upper bits of fnum and calculating the frequency modulation value directly in the 11-bit target. If the real hardware calculates the frequency modulation adjustment at full precision based on all the bits of fnum however, this may not be accurate, since a carry could be generated from bit 8 of the frequency modulation value for example. I was going to perform a set of tests to confirm whether this was the case, and then make adjustments to my core as necessary, but I lost time to work on it, and I didn't end up completing the test. I'll try and find some time to carry out this test, so we know for sure how the frequency modulation value needs to be calculated. Personally, I think it's likely the value is calculated at full precision. MAME would also effectively generate a carry from bit 8 currently, due to the extra bit of precision they added to the pipeline. I'll have to do some math and see if I can construct a test where I can measure a carry taking place from bit 7 or lower. ######## POST p8913 | Eke | 2009-06-19 | t386-480.html [QUOTE] This corresponds with the lookup table for fnum bit 9. You'll note that the lookup table for every other bit is simply a shift of this table. For fnum bit 10, shift the values up by 1. For fnum bit 8, shift the values down by 1. For fnum bit 7, shift the values down by 2, etc. Note that I say the table above corresponds with fnum bit 9, but in MAME, since they're giving the values for use with a 12-bit fnum calculation instead of an 11-bit calculation, the MAME table for fnum bit 9 will be shifted up by 1. [/QUOTE] oh, thanks for clarifying that. That means that I also need to divide all the values in the MAME table by 2, right ? I was not sure if I should do that :-/ This also means that FNUM bit 4 is not taken in consideration as it is currently done in MAME core and only the 6 higher bits should be used, which would involve some table size reduction and additional modifications when calcultating the current phase modulation. Do you have some kind of test ROM for this LFO thing or did you tested audio output directly ? [QUOTE] In this case, the lookup table I've given above would correspond with fnum bit 0, and you would shift up from that for each place above bit 0, then negate the value if we're in the negative half of the wave, and finally you'd shift down 9 places and add the result to fnum. I don't do this in my core currently however. Like MAME, I'm just grabbing the upper bits of fnum and calculating the frequency modulation value directly in the 11-bit target. If the real hardware calculates the frequency modulation adjustment at full precision based on all the bits of fnum however, this may not be accurate, since a carry could be generated from bit 8 of the frequency modulation value for example. I was going to perform a set of tests to confirm whether this was the case, and then make adjustments to my core as necessary, but I lost time to work on it, and I didn't end up completing the test. I'll try and find some time to carry out this test, so we know for sure how the frequency modulation value needs to be calculated. Personally, I think it's likely the value is calculated at full precision. MAME would also effectively generate a carry from bit 8 currently, due to the extra bit of precision they added to the pipeline. I'll have to do some math and see if I can construct a test where I can measure a carry taking place from bit 7 or lower. [/QUOTE] hum, I not sure to follow anymore... wouldn't this mean that MAME was already somehow quite correct (at least more than your implementation currently is) by adding this bit of precision and taking bit 4 in consideration ? I mean, the only thing that the MAME core was doing was shifting the FNUM value by 1 (x2) then adding the phase modulation value from the LFO table (which was also shifted by 1 compared to your values). The way the frequency table is initially computed make the frequency increment being also correctly computed (the table is set for a block value of 7 but use a multiplier of 2^5 instead 2^6, taking the later bit shifting in account). To me, this seems very similar to the process you describe (except it's limited to bit 4 and do not take all bits in account). This certainly need some confirmation before I keep modifying the current code [IMG ./images/smilies/icon_wink.gif] ######## POST p8992 | Lord Nightmare | 2009-07-16 | t386-480.html What happened with this? Did the weird stuff get documented? Eke, did you manage to fix the core? LN ######## POST p9005 | Eke | 2009-07-20 | t386-480.html No, I didn't have much time for coding lastly and I prefer waiting for Nemesis definitive documentation anyway. From memory, here are the few things that still need to be covered: (1) How LFO amplitude and phase modulation work (see above posts) ? In this thread, Nemesis once mentionned that even when LFO was disabled, significant AM (and PM ?) values could still be applied depending on which step the LFO was stopped. Is that correct ? One game (Spiderman Separation Anxiety) seems to rely on this feature (intro track). It seems also that the LFO is reseted when switched from OFF to ON. For the record, in MAME implementation, LFO AM and PM values are reseted as soon as LFO is disabled. MAME gets this track wrong anyway and seems to update LFO too early (should be done AFTER output calculation I think, like EG and PG updates) (2) How operators outputs are combined together to form a channel output ? - Accumulator: is there an accumulator or not ? If not, what does combine operator outputs together and how are channels ouputs to the DAC ? It seems to be acknowledged now that channels are indeed multiplexed (interleaved ?) and that the "real" ouput samplerate should therefore not be VCLK/144 (~53kHz) but VCLK/24 (~320 kHz) with each 6 channels being sampled succesively. I wonder how that matters in term of emulation: doesn't that means that clipping can not occurs and that adding channel ouputs then applying a limit could be wrong ? How can we accurately emulate channel multiplexing without multiplying the output samplerate by 6 ? -Operator 1 Self Feedback: the MAME core sums up the two last samples to calculate the Self-feedback phase modulation. Steve Snake confirmed it was a common way for Yamaha synthetisers to implement feedback. It's probably correct but still need confirmation. Another thing that needs clarification is how the 14-bits operator 1 output is transformed into 10-bits Phase input, in relation with the feedback level (in MAME, this is NOT done the same way as other output modulation, described by Nemesis here ) -Chained Operators delayed samples: again, Steve Snake explained that there were in fact 2 operators running in parallel which would explain why some operators outputs were delayed by one cycle before being output to chained operators. The MAME core indeed implements that for algorithms 0,1,2 & 3 when either M2 or C2 needs inputs from M1 or C1, which seems quite logical (two modulator/carrier pair running in parallel). Strangely M1 (Operator 1) output is also always delayed by one sample clock, I'm not sure to understand why though (maybe because of self-feedback) and if this is correct or not. -Slots (carriers) outputs combination: algorithm 4 sums two carriers to get the channel output, algorithms 5&6 sum 3 carriers and algorithm 7 sums 4 carriers . We know that an operator ouput is 14 bits but what happen when you sum up multiple operator ouputs ? MAME implementations use 32 bits integer to hold the result so there isn't any possible overflow but what happen on real hardware ? Various possibilities: (*) final output (DAC input) is 16 bits so that a maximal sum of four 14-bits operators ouputs can fit without overflow. This is how MAME implementation works. (*) operator outputs (14 bits) are shifted left by 2 bits to form a 16 bits output. This results in some kind of precision loss at lower volumes and clipping (or overflow ???) is possible when multiple operators ouputs are combined. This was once described by Nemesis but never really confirmed. For the record, clipping each channel output to 14-bits fixes a bug in Sonic 3 (the boss ship area where bombs are dropped) where the sound appears very distorded when not cliped. (*) operators are added inside the DAC with an unknown process (3) How is the unsigned 8 bits Channel 6 DAC value handled and mapped to a (16 bits ?) signed channel output ? Current MAME implementation simply transforms the unsigned 8bits value into a signed one (data -0x80) then shift this value by 6. Shifting by 8 results in too high volume relatively to other channels. (4) Internal DAC precision: it is said to be 9 bits but how do you emulate this accurately (emulators generally need to output 16 bits signed samples) ? Well, that's all I could remember (not counting analog filtering effects and differences between several ym2612 chip variations) [IMG ./images/smilies/icon_wink.gif] ######## POST p9019 | GManiac | 2009-07-25 | t386-480.html So whats news about slowing of YM2612? [QUOTE] TmEE co.(TM) wrote: I recorded some music off my sound system and when speeding it up 14 times, I get correct speed and pitch for the song so thigns work. due to HW nuances in analog area, of course things won't sound exactly same when sped up The file is too big for me to upload (it would upload forever.....). I'll see how small I can get it, if it becomes small enough I'll put it up. [/QUOTE] Can you record pure sine, one second or even less (in original)? Then it will be equal to 15 seconds or less with slowing. Frequency of 1 Hz will be enough to get whole period of wave, actually we need only quarter of period. Then 50000 samples of YM emissions (25000 samples from -1 to +1 of sine) (15 seconds or 1 second in original) will show us resolution of DAC. And file won't be too large: 15 * 48000 samples per second * 2 bytes * 1 channel = 720 kbytes. And can you make such recording from MD1 too? ######## POST p9020 | HardWareMan | 2009-07-26 | t386-480.html My turn. First, I was trying to divide VCLK by 2 for YM2612 source CLK. I had make 2 records: from "Comix Zone" and "Batman & Robin". Why? Becouse "Comix Zone" uses GEMS, wich use VBlank interrupt based timings (but DAC is still analyzing BUSY flag, so PCM tempo slowing down too). But "Batman & Robin" uses YM2612 timers timing, so melody is slowing down with tempo proportionally, like tape, and you can just increase playing speed (just set 96000Hz as discretization frequency instead of 48000Hz) and get right result (with some "features": hardware low pass filter will equivalent pass twice higher frequences, than at normal speed). You can download this records: Comix Zone (5,3MB) , Batman & Robin (29MB sample, full - 170MB!) (all in lossless WAV ofcourse). It is huge, but it very interesting. Unfortunately, I can't make YM2612 work at VCLK/4 and more. Maybe some synchronization was broken. In future, I will try to slowdown whole system with didve MCLK and test this. So, make your own test PD ROMs and I will test it on my hardware. [IMG ./images/smilies/icon_wink.gif] ######## POST p9164 | neologix | 2009-08-26 | t386-480.html been a while since i read this topic. awesome to see that the ym2612 is one step closer to being spec complete thanks to the ym3438 sheets! now who has an updated open-source ym2612 core i can use to make a preset previewer? [IMG ./images/smilies/icon_wink.gif] it would be primarily for the vgm-to-midi converter i'd be implementing into vgmtool, which i'm currently testing in a javascript version. ######## POST p9166 | Eke | 2009-08-26 | t386-480.html http://code.google.com/p/genplus-gx/sou ... d/ym2612.c should be up-to-date with Nemesis last findings regarding CSM and SSG-EG modes (verified with his test ROM), also include modified behavior for LFO (instead of being reseted, current modulation level is held when LFO is disabled, and is reseted when LFO is enabled) there are a few stuff that are related to the FIR resampler I'm using or were modified for the emulator but otherwise it should be straight to use it in other project with limited changes ######## POST p9175 | neologix | 2009-08-28 | t386-480.html awesome stuff, eke. will DL & have it ready for vgmtool soon enough [IMG ./images/smilies/icon_smile.gif] ######## POST p9213 | Paul Jensen | 2009-09-08 | t386-480.html Any new discoveries? I've got some questions in case anybody can answer them for me. After reading this thread I started working on VGM2MID (now tentatively called VGM Studio as it can also output other types of files now). I've already updated my Midi converter code, and now I'm working on adding PCM audio output. The core of the Midi code in my program is based on getting an FNote (i.e. frequency in Hz) based on an FNum, Block, and the frequency of the sample clock (FSam): FNote = FNum * FSam * (2 ^ Block - 21) Also, the code for volume changes uses decibels for its calculations. I'm thinking of going the same route for generating PCM output. That is, using "real" frequencies and decibel values instead of counters and lookup tables. I'm not necessarily concerned with producing binary accurate output, I just want to get output that sounds good. So here are my questions: 1) For the Envelope Generator, is there any good method for calculating real time values for AR, SR, DR, and RR (in ms or FM clock cycles)? That is, is there any formula to determine how long it will take for a note to decay, etc, based on the rate value parameter? 2) Also, what's a good method for converting a dB value to a linear value? Unless I'm wrong, you're supposed to be able to calculate linear amplitude by using the equation: A1 = 10 ^ (dB / 20) * A0 where A1 = amplitude; dB = decibel value; A0 = reference amplitude But I can't figure out how to make that work. Right now I'm using the following formula to calculate output level: outputLevel = 1 / (2 ^ (attenuationIndB / 6)) The formula seems to work well. I'm using it in my SN76489AN output code, and the output sounds almost identical to Kega and other emulators. Anyway, this post is getting longer that I thought it would, and I've gotta go to work now. But I'd be really grateful if anyone could help me with those two questions. Thanks. ETA one more question: 3) I've noticed in my Midi output that some games seem to have missing channels. This seems to happen with games that make a lot of "illegal" writes. Super Hydlide is a prime example of this (the bass line is missing in a lot of tracks). Also, a lot of Namco games seem to do it too. Most of the games also seem to rely on keying on/of operators individually rather than all at the same time. I remember that old versions of Dega exhibited the same behavior. Has anybody encountered this issue while writing a YM2612 core? ETA another question (related to (3)): 4) What's the best way to handle "illegal" channel settings. On the YM2612, register $28 is used for setting KeyOn/Off, and the lowest three bits are used to select the channel to be Keyed On/Off. The manual lists the following channel select values: 0 0 0 CH1 0 0 1 CH2 0 1 0 CH3 1 0 0 CH4 1 0 1 CH5 1 1 0 CH6 But what about the following undefined values: 0 1 1 ? 1 1 1 ? Some games (like Super Hydlide) try to set these values. Does anybody know what effect these two settings have on a real YM2612? ######## POST p9214 | GManiac | 2009-09-08 | t386-480.html [QUOTE] Paul Jensen wrote:Any new discoveries? [/QUOTE] I have mathematical proof of "mirroring" effect on spectrogram. [IMG ./images/smilies/icon_biggrin.gif] I'll post it later. ...but maybe it's common fact? [IMG ./images/smilies/icon_confused.gif] [QUOTE] FNote = FNum * FSam * (2 ^ Block - 21) [/QUOTE] * F-Number = 144 * freq * (2^20 / MCLOCK) / 2^(Oct - 1) / multiplier * freq = multiplier * F-Number * 2^(Oct - 1) * (MCLOCK / 2^20) / 144 With your identfiers formula will look like: FNote = FNum * FSam * Multiplier * 2^(Block - 21) / 144 You only need to keep in mind that last note (2047, but we'll use 2048) of last octave (7) with multiplier=8 will give you base channel frequency (53 kHz). [QUOTE] A1 = 10 ^ (dB / 20) * A0 where A1 = amplitude; dB = decibel value; A0 = reference amplitude But I can't figure out how to make that work. Right now I'm using the following formula to calculate output level: outputLevel = 1 / (2 ^ (attenuationIndB / 6)) [/QUOTE] 10 ^ (dB/20) should be equal to 2^(db/6). But in second case you divide original amplitude by this value (because it's attenuation, not apmlification) and in first case you mulitiply by it. Maybe here is mistake? Remember that both YM and PSG use attenuation. ######## POST p9457 | Eke | 2009-10-23 | t386-480.html [QUOTE] Nemesis wrote:I just encountered another quirk with the YM2612 which I wasn't fully aware of. This may be common knowledge for people who've worked with the hardware, but I noticed this isn't emulated in Gens, and I wasn't aware of it until I was running these tests either, so I think it should be mentioned. There's repeated warnings in numerous places throughout both the Sega documentation and the documentation from Yamaha, regarding how the registers which set the frequency and octave for a channel should be written to. What they say is that you should always write the Block/Fnum ($A4-$A6) byte first, then write the Fnum ($A0-$A2) byte second. What they don't say is what happens when you ignore this advice. [IMG ./images/smilies/icon_biggrin.gif] It appears that the YM2612 doesn't commit a write to the block/fnum register until the fnum register is written to. If you were for example to perform the following writes: -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. Here's a test ROM which demonstrates this behaviour: http://nemesis.hacking-cult.org/MegaDri ... eOrder.bin And here's the source: http://nemesis.hacking-cult.org/MegaDri ... eOrder.asm If register changes were applied immediately, the result would be an A4 (440Hz). Instead, this ROM will play an A6 in the actual hardware. For the sake of completeness, it's also worth noting that 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, regardless of how many writes are made to the registers for other channels. Once again, this behaviour is emulated correctly in Kega. Does anyone know of something Kega doesn't get right? [/QUOTE] For the record, I didn't noticed until yet but I'm not sure if those register quirks are emulated correctly by the MAME implementation. There is indeed a common block/fnum value that is used for all channels: [CODE BLOCK WITHHELD: 687 chars] This indeed means that if you write a block/fnum byte to channel 2 (0xa5), then write a fnum byte to channel 3 (0xa2): (1) block/fnum value for channel 2 will not be changed until the next write to fnum for channel 2 BUT (2) block/fnum value for channel 3 will be applied with the block/fnum byte previously written for channel 2 and the fnum byte written for channel 3 I wonder if this is correct ? Also, in the case of CH3 special mode registers, I'm curious to know how this works ? Does it use the same latched fnum/block byte for ALL operators (incl. 0xa6), does it use an additional latched value only for 0xac-0xae (this is what MAME is doing) or does it latch the fnum/block byte for each operator separately ? Again, I doubt any games try to access these registers in such uncommon way and the MAME implementation is probably (again) right but it would be nice to be sure, again "for the sake of completness" [IMG ./images/smilies/icon_wink.gif] ######## POST p10441 | blargg | 2010-02-20 | t386-480.html I was doing some testing today on a YM2612 emulator of the number of bits in the DAC. I believe it's a 7- or 8-bit DAC, that's time-division multiplexed (as the YM2612 Wikipedia page says). This means that the DAC really operates at 6 times the normal rate, or 1/24 the clock input. So for the Sega Genesis where the YM2612 operates at 7.6704545... MHz, the DAC operates at 319.6022727... kHz. For an emulator, this just means you clear the lower bits of each channel before mixing them together, not after. The result can then be played at 1/6 that rate, 53.26704545... kHz. Making this change finally brings the proper sound to music from games like Wonder Boy in Monster World and Target Earth. In my listening tests, it seems that a 7-bit DAC sounded closer to my recordings, but I can't be really sure so take this with a grain of salt. Someone needs to run some hardware tests. ######## POST p10442 | Eke | 2010-02-20 | t386-480.html [QUOTE] blargg wrote:I was doing some testing today on a YM2612 emulator of the number of bits in the DAC. I believe it's a 7- or 8-bit DAC, that's time-division multiplexed (as the YM2612 Wikipedia page says). This means that the DAC really operates at 6 times the normal rate, or 1/24 the clock input. So for the Sega Genesis where the YM2612 operates at 7.6704545... MHz, the DAC operates at 319.6022727... kHz. For an emulator, this just means you clear the lower bits of each channel before mixing them together, not after. The result can then be played at 1/6 that rate, 53.26704545... kHz. Making this change finally brings the proper sound to music from games like Wonder Boy in Monster World and Target Earth. In my listening tests, it seems that a 7-bit DAC sounded closer to my recordings, but I can't be really sure so take this with a grain of salt. Someone needs to run some hardware tests. [/QUOTE] the thing is; how much of the lower bits need to be cleared ? It is not totally clear what's the width of channel output before going to the DAC: operator output is 14 bits (incl. sign bit) but what happen with "algorithms" that sum up multiple operators (up to 4) ? In my emulator, limiting the channel output to 14 bits then summing up channels seems to fix some music but I have no confirmation it's actually correct. In this case, you mean that "emulating" 8-bit DAC precision is simply clearing the lowest 6-bits, right (you need to keep sign bit somehow though) ? I remember Steve Snake explaining it was not exactly like that (something related to "floating-point DAC", that is if the sample value fits in the DAC precision width, there are not shift/mask and you lose nothing, i.e you lose more precision at higher volumes) Regarding DAC, I think it was established previously in the topic that channels were indeed time-multiplexed (in a strange order like 1,4,3,2,5,6 i think, must look back) and that DAC precision was 9-bit (apparently higher on MD2 ASIC) with some strange behaviour with negative values. [QUOTE] Making this change finally brings the proper sound to music from games like Wonder Boy in Monster World and Target Earth [/QUOTE] Do you have some recording that I could compare with ? ######## POST p10446 | blargg | 2010-02-20 | t386-480.html Here are some recordings (sorry for mp3, as I lack FLAC or anything modern): genesis_recordings.zip (2.6 MB; let me know if you have problems, as this host sucks) These are from the original Sega Genesis model, not a later one where sound is really crappy (on those, getting rings in Sonic for example sounds all distorted). [QUOTE] In this case, you mean that "emulating" 8-bit DAC precision is simply clearing the lowest 6-bits, right (you need to keep sign bit somehow though)? [/QUOTE] Yeah. I just modified the channel muting mask from ~0 to ~((1 << 7) - 1). This preserves the sign bit. This was in the MAME version, where it applies this mask to each channel, sums them, divides by 2, then outputs that. [QUOTE] I remember Steve Snake explaining it was not exactly like that (something related to "floating-point DAC", that is if the sample value fits in the DAC precision width, there are not shift/mask and you lose nothing, i.e you lose more precision at higher volumes) [/QUOTE] I don't think it could be that, because some of the example tracks above have a tone fading out, yet it's still grossly quantized by the DAC. If it were floating, those would fade out smoothly as on most YM2612 emulators. [QUOTE] Regarding DAC, I think it was established previously in the topic that channels were indeed time-multiplexed (in a strange order like 1,4,3,2,5,6 i think, must look back) [/QUOTE] Fortunately the order doesn't really matter, since the effects are all well above what is filtered out. That's why you can just mask the channels, add them together, then output at the usual ~53 kHz rate. [QUOTE] and that DAC precision was 9-bit (apparently higher on MD2 ASIC) with some strange behaviour with negative values. [/QUOTE] I tried higher precision, but I couldn't get anything close to the distortion in the example recordings. ######## POST p10458 | Eke | 2010-02-22 | t386-495.html [QUOTE] blargg wrote:Here are some recordings (sorry for mp3, as I lack FLAC or anything modern): genesis_recordings.zip (2.6 MB; let me know if you have problems, as this host sucks) [/QUOTE] yeah, it seems I can't download them [IMG ./images/smilies/icon_wink.gif] [QUOTE] Yeah. I just modified the channel muting mask from ~0 to ~((1 << 7) - 1). This preserves the sign bit. This was in the MAME version, where it applies this mask to each channel, sums them, divides by 2, then outputs that. [/QUOTE] divide by 2 ? [QUOTE] I don't think it could be that, because some of the example tracks above have a tone fading out, yet it's still grossly quantized by the DAC. If it were floating, those would fade out smoothly as on most YM2612 emulators. [/QUOTE] Where do you take your recording from btw ? I don't know, there is circuitry filtering coming in account too, and differences between MD1 & MD2 (I had a look at schematics some time ago and, while MD1 seemed to have only a low pass filter @~26.7 khz and a DC removal capacity before the stereo mixing chip, MD2 had slightly more "destructive" high-pass and low-pass filters, something like 7Khz for LP if I recall correctly) ######## POST p10459 | blargg | 2010-02-22 | t386-495.html [QUOTE] Eke wrote:yeah, it seems I can't download them [IMG ./images/smilies/icon_wink.gif] [/QUOTE] OK, try this mirror: genesis_recordings.zip [QUOTE] blargg wrote:Yeah. I just modified the channel muting mask from ~0 to ~((1 << 7) - 1). This preserves the sign bit. This was in the MAME version, where it applies this mask to each channel, sums them, divides by 2, then outputs that. [/QUOTE] [QUOTE] Eke wrote:divide by 2 ? [/QUOTE] 6 channels, each in the range -8192 to +8191, totals -49152 to +49146. Dividing by 2 reduces the range to -24576 to +24573, so it'll fit within a 16-bit sample without any chance of overflow. I was able to modify your YM2612 as described above: [CODE BLOCK WITHHELD: 121 chars] [QUOTE] Where do you take your recording from btw ? I don't know, there is circuitry filtering coming in account too, and differences between MD1 & MD2 [/QUOTE] US MD1 (the revision that shows the "licensed by sega" at the beginning no matter what cartridge you insert). ######## POST p10460 | Eke | 2010-02-22 | t386-495.html [QUOTE] OK, try this mirror: genesis_recordings.zip [/QUOTE] ok, that one works. [QUOTE] 6 channels, each in the range -8192 to +8191, totals -49152 to +49146. Dividing by 2 reduces the range to -24576 to +24573, so it'll fit within a 16-bit sample without any chance of overflow. [/QUOTE] Well, shouldn't we just apply a limit like it was done in the original core ? By doing this, you are reducing FM output level (relative to PSG)... I think it's not very common that all channels are set to max, hence why a limiter was used but I wonder which solution is best. (and this remind me I removed the limiter and forgot that clipping/overflow could still occur when adding channels, thanks) [QUOTE] I was able to modify your YM2612 as described above: Code: ym2612.OPN.pan[ c*2 ] = (v & 0x80) ? ~((1 << 7) - 1) : 0; ym2612.OPN.pan[ c*2+1 ] = (v & 0x40) ? ~((1 << 7) - 1) : 0; [/QUOTE] edit: i tested similar modification quickly (WB5 intro tune) and it indeed "seems" that emulating DAC precision affects the sound output similar to your recording. There is some channel in background at the beginning of the track ((buzzing static sound) that is not so much audible on emulator but starts to be audible when lowering DAC precision. However, I found out that lowering below 9-bits precision make the buzzing noise too loud and affect other channels as well, in a very different way than real hardware on therecording: 9-bits (~((1 << 5) - 1)) seemed the most accurate to me. Still, I 'm not sure if that's the exact way to emulate it: Steve Snake was somehow referring to a DAC issue with negative values, where low values were being output much more louder than they should (much more than if it was simply lower bits precision loss), it seems it's the same issue here. I guess the only way to be sure would be to write a program that output a range of possible sample value (from -256 to 255 for example) on a channel and measuring chip output directly. Anyway, can you point me to particular effects to listen in your recordings that sound completely differently in an emulator ? ######## POST p10462 | blargg | 2010-02-22 | t386-495.html [QUOTE] Eke wrote:Well, shouldn't we just apply a limit like it was done in the original core ? By doing this, you are reducing FM output level (relative to PSG)... I think it's not very common that all channels are set to max, hence why a limiter was used but I wonder which solution is best. [/QUOTE] It's definitely rare, or maybe absent from anything real (even that crazy Castlevania stage end doesn't overflow when you remove the divide by two). But doing the clamping there is wasteful since you have to clamp again when you're mixing the PSG in later. And it's conceptually better to avoid clamping here because that's not what the chip does, and dividing by two fully solves the problem (obviously you'd have to halve your PSG volume later, and then apply some gain to the final mix). [QUOTE] Steve Snake was somehow referring to a DAC issue with negative values, where low values were being output much more louder than they should (much more than if it was simply lower bits precision loss), it seems it's the same issue here. [/QUOTE] Hmmm, since the DAC is most likely unsigned, the values must be converted to offset binary before being sent to it (toggle the top bit). Maybe they're converting wrong in the chip. [QUOTE] Anyway, can you point me to particular effects to listen in your recordings that sound completely differently in an emulator ? [/QUOTE] Those are the most prominent. It's really noticeable with headphones, where current emulators sound way too clean, and the hardware has these distortions and a kind of background noise due to this (you can head this even in Sonic - Green Hill Zone, as a faint background static). Considering how close emulation is, this for me is one of the most noticeable inaccuracies, and makes the output sound damn close to the recordings. It's true that the distortions introduced by the above masking are NOT exactly the same. I'm thinking that if we can figure out this DAC issue, it will go a long way to ensuring other things are correct, because the distortion effect depends critically on the internal amplitudes, due to the non-linearity of clearing low bits. So I think the reason the distortion differs currently might be because the emulator's amplitude is slightly off (I'm not very familiar with the internals). Anyway, I just wanted to mention my finding, and am very impressed with the changes I hear when upgrading from my old modified Gens core to your current one. I'm excited to get a new version of Game_Music_Emu out with this new one. ######## POST p10466 | Eke | 2010-02-23 | t386-495.html [QUOTE] So I think the reason the distortion differs currently might be because the emulator's amplitude is slightly off (I'm not very familiar with the internals). [/QUOTE] Amplitude depends on the power and sinus tables (TL_TAB & SIN_TAB in the core you use), which have been verified by Nemesis on real chip (and Jarek as well on chip of the same family) , which outputs a 14-bits signed value for each operator (also verified on real chip). The process used to output a 14-bit operator output and generate phase & enveloppe inputs (10-bits) has also been reverse-engineered and is binary accurate in the MAME core, so I don't think it could be that. It's more likely the DAC is not exactly working as you expect it should, or there are tiny timings differences (maybe the fact channels are time-multiplexed also makes some differences). Here are some extracted text from the previously posted YM3438 manual that is mentionning the DAC, it would be nice if someone could translate them: [IMG http://www.monsterup.com/upload/1266919197124.gif] [IMG http://www.monsterup.com/upload/1266919197314.gif] [IMG http://www.monsterup.com/upload/1266919198568.gif] [IMG http://www.monsterup.com/upload/1266919246689.gif] ######## POST p10467 | Eke | 2010-02-23 | t386-495.html On that topic, some other part of the YM3438 manual I would be curious to have translated (i.e info that are not already covered by YM2608 translated manual): Something about the read mode (when reading FM address 1,2,3): [IMG http://www.monsterup.com/upload/1266919560215.gif] [IMG http://www.monsterup.com/upload/1266919560405.gif] An article about differences between Yamaha OPN chips: [IMG http://www.monsterup.com/upload/1266919560196.gif] ######## POST p10471 | Ketsuban | 2010-02-24 | t386-495.html A friend of mine does freelance translation work to make some extra cash (due to disability he's not able to get a job) and I've passed those on to him. I'll let you know what he comes up with. ######## POST p10473 | Eke | 2010-02-24 | t386-495.html Thank you, that's what I was hoping for by posting these here [IMG ./images/smilies/icon_wink.gif] ######## POST p11125 | dtech | 2010-06-13 | t386-495.html Hey, Nemesis, may I ask - how far are you with 2612 decapping? I think interest in details about the chip has not faded in any way. [QUOTE] $90? Is that all a professional decap costs? Hmm, for $90 I might pay to get the YM2612 decapped myself. In fact, I think I will. I'll need to pick myself up a good digitial microscope to take my own pics. It'll make a valuble addition to my collection of equipment. I'll have to do some research. As soon as I've got a microscope picked out, I'll send away a chip to be decapped. I've got a few chips sitting around here already desoldered and ready to go. I'm not really sure how much immediately useful info a decap will give us, but it'll be fun. [/QUOTE] I am one of those who are impatiently waiting for any nude pictures of our beloved chips. Cannot decap anything myself as I can't ham any f those few 2612 I have, I'm from europe and don't have any high quality microscope as well. By the way, it would be nice to decap VDP as well. A curiosity peek with awe at another beloved chip [IMG ./images/smilies/icon_smile.gif] ######## POST p11132 | Nemesis | 2010-06-14 | t386-495.html I agree it would be very interesting. I was always planning to do the VDP and YM2612 together, but that never eventuated. I got in touch with MEFAS, but the catch was they would only ship back to a US address. I tried to arrange with another person in the US to have the decapped chips sent to them, and then back to me, but I never made a concrete arrangement, and then I had doubts that the microscope I had would actually be up to the task of taking the images, so I was weighing up whether to pay more money to MEFAS for images, or shell out for a more professional microscope, and then I wasn't sure which one, and I was questioning whether decapping would show anything useful anyway, so it just kind of faded away. As things stand today, I don't have the money anyway. I'm now married with a mortgage and a baby on the way. $90 sounds like a fortune now. lol ######## POST p11135 | dtech | 2010-06-15 | t386-495.html [QUOTE] Nemesis wrote:As things stand today, I don't have the money anyway. I'm now married with a mortgage and a baby on the way. $90 sounds like a fortune now. lol [/QUOTE] Ohh, you poor guy, I feel sorry for you [IMG ./images/smilies/icon_smile.gif] Good luck! [IMG ./images/smilies/icon_smile.gif]) Well first I thought that MEFAS is in UK or somewhere near, yet then I found out they are in US, so I knew that postage will be a mess (and so I moaned about being in europe). I thought you are in US, but ok whatever. There's also a post-soviet (but enough advanced) chip decapping facility here in baltic states, yet I cannot find any info on them any more. Don't remember name of the company and it doesn't google up in any way. Also have no idea about prices there, I think it might be 1000$ instead of 90$ and using more destructive methods. Ok, anyways then the idea from what we have there is getting pretty clear: 1. We have to decap YM2612 and VDP (and could also add the other PQ packaged chip from megadrive1 that has the ROM and logic) 2. We have to do the decapping where we know it's cheap and high quality (decapped chips will remain functional!) - in MEFAS, so we have to arrange a guy in US via a team effort (there is likely to be somebody from US in this forum..?) 3. We have to get chip photos from MEFAS tools, that is - order high resolution images from them. When we get the decapped chips back, we have to keep them in excellent conditions (controlled moisture, no UV, no mechanical stress) and might someday try to do our own pictures as well, whoever will get the most suitable tools for that. 4. We could try to arrange the money for this great cause via some donations or just somebody (or maybe me) will get 5. Maybe Nemesis could provide the chips for decapping, I can smoothlly desolder the large PQ-s from some megadrive mainboard if provided with one. 6. If money is provided from one person, that person becomes the holder of the saint decapped chips as well as gets credited on all images. (a bonus or something) 7. We don't know what we would get from the images, but at least these images are likely to be a tremendously delicious food for brain for a prolonged period of time, as well as an object for aestetical pleasure. 8. If nobody else will want to capture various rom contents from images, I will do it. At least we've got a plan of some kind [IMG ./images/smilies/icon_smile.gif] ######## POST p11136 | Chilly Willy | 2010-06-15 | t386-495.html I'm in the US and willing to handling all the shipping, but I can't provide the chips or take photos. ######## POST p11139 | Nemesis | 2010-06-15 | t386-495.html I can easily provide the chips as I've got no shortage of hardware that can be "sacrificed" in the interests of science. [IMG ./images/smilies/icon_smile.gif] ######## POST p11141 | dtech | 2010-06-15 | t386-495.html Well, nice to see that the rock starts to move [IMG ./images/smilies/icon_wink.gif] This far we see, that on point No.1 we have a common view; No.2 might be solved thanks to Chilly Willy; No.5 is clear thanks to Nemesis; No.7 seems to be acceptable to everyone as well. So the things we need to figure out are the rest of points - mainly getting to know how much money do we need for this to be done (YM2612 and VDP decapped and photographed in very high resolution in MEFAS), and getting the money for this to happen. Nemesis - maybe you could ask your contact in MEFAS on prices at the current moment and on making photos? If things are in reasonable range, we could trow in the other megadrive1 chip as well. Logistics then are likely to be something like Australia(Nemesis)->US(MEFAS)->US(Chilly Willy)->Whateverland(Whoeverpaysmost) ######## POST p11147 | Chilly Willy | 2010-06-15 | t386-495.html Hmm - would it go Nemesis -> MEFAS -> Chilly or Nemesis -> Chilly -> MEFAS -> Chilly The first would be less expensive. Nemesis - do you have PayPal? It would be easiest to PayPal you money for shipping from your end (when I said I'd cover the shipping, I meant ALL the shipping). Probably best to discuss any explicit PayPal or shipping info via PMs. ######## POST p11154 | dtech | 2010-06-16 | t386-510.html I assumed "Nemesis -> MEFAS -> Chilly" path because as far as I know, MEFAS doesn't care about receiving things from other countries - it's only about sending. Anyways this should be cleared out along with the price on all of this. I think I will myself cover some significant part of the price the MEFAS will want. Yet don't know how much spare pennies I'll have, but I feel comfortable on spending them on such research. ######## POST p11155 | Chilly Willy | 2010-06-16 | t386-510.html We should probably find out what it would be for just the YM2612, and for both the YM2612 and VDP. That would give us an idea of whether we can scrape up enough to do both or to just do the YM2612 for now. ######## POST p11156 | dtech | 2010-06-16 | t386-510.html Unfortunately, MEFAS has no email address mentioned in their website, so it's up to somebody located in US to call them up to avoid international call fee hell burden. http://www.mefas.com/contact.html From them we should get: - price on decapping DIP24 package - price on decapping PQ type packages - deal on many chips sent them at once (possible discount on each additional) - explicitly reask if it is ok for them to receive chips from outside us if sending "back" will be to a us location. - price on photography in suggested resolution for die sizes and integration scale of chips circa 1989. ######## POST p11157 | TascoDLX | 2010-06-16 | t386-510.html [QUOTE] dtech wrote:Unfortunately, MEFAS has no email address mentioned in their website, so it's up to somebody located in US to call them up to avoid international call fee hell burden. [/QUOTE] You should know that MEFAS is owned by EAG (apparently since November 2007!), so I suggest you check http://www.eaglabs.com/ . EAG also has labs in Europe and Asia, so you might be able to get this done without the overseas shipping hassles. ######## POST p11158 | dtech | 2010-06-16 | t386-510.html Ok then it might simplify things. Europaen one is in France - so, anybody from France there? http://www.eaglabs.com/contact/france.php Or UK: http://www.eaglabs.com/contact/uk.php (Is there anybody from UK or even better - Wokingham?) There is, however, no information about what they can do in this particular lab. Probably the same stuff that they do elsewhere. Anyways this should be cleared out, to avoid possibility that they shuddenly send chips around world and then ask a lot of additional bucks for that. ######## POST p11159 | Eke | 2010-06-16 | t386-510.html I work very nearby (~10 km) from the first location so let me know if i can help in the case they don't ship back worldwide. ######## POST p11160 | dtech | 2010-06-16 | t386-510.html [QUOTE] I work very nearby (~10 km) from the first location [/QUOTE] Woow, that's excellent! I think it further changes planned logistics to: Nemesis(Australia)--postal-->Eke(France)--driving-->EAG EAG--pickup-->Eke(France)--postage-->whoeverpays(whereverpays) That's if EAG can hangle everything within lab in France. And if prices are reasonable. Eke, could you please someday give them a call and ask those questions I mentioned above? That is: - price on decapping DIP24 package - price on decapping PQ type packages - deal on many chips given them at once (possible discount on each additional) - price on photography in suggested highest resolution, adequate for die sizes and integration scale of chips circa 1989. ######## POST p11161 | Eke | 2010-06-16 | t386-510.html The problem is that I have no full idea about what you are trying to achieve, neither technical background so I'm pretty stuck if they start asking me more technical details by phone, which they probably would do since it depends on a lot of factor. It would be pretty better if you directly discuss with them via email or via the website form, seems the right thing to do according to the website . I can eventually help if payment/shipping is not possible worldwide but that's all, I really not feel comfortable discussing hardware details with them [IMG ./images/smilies/icon_wink.gif] ######## POST p11162 | Chilly Willy | 2010-06-16 | t386-510.html Uh, MEFAS has an email address: lab@mefas.com It's on their profile page. If necessary, I could call them, but we want to do what we can by email since that will avoid unneeded expense. While calling would not be an international charge for me, it would still be a long distance charge. ######## POST p11166 | dtech | 2010-06-16 | t386-510.html Drums roll now. Ok I contaced EAG, which forwarded me to MEFAS, because chip decapsulation and photography cannot be carried out in other labs. So it was unnecessary fuss around EAG, yet we now at least know that there are no such simple ouside-us options. So yes, Chilly Willy, we will need your help in this regard! [IMG ./images/smilies/icon_smile.gif] All is very good and doesn't cost too much. In fact, chip decap costs slightly less then we know, and photography costs are exactly twice the amount (that we know about chip decap) an hour, and two hours are expected time for full analisys for all works for every chip. Discount offers kick in only when working with >10piece volumes of the same chip (not for us for now). From the two hours of inspection time we will get large volume of pictures that we can edit together and have fun. (yay! a puzzle assembly!) I was realy surprised that service there, at least in communication level, is truly awesome. So we have now a fallback to the initial logistics plan: Nemesis(Australia)-->maybe Chilly Willy(US)-->MEFAS(US)-->Chilly Willy(US)-->Whoeverpays(Wherever) The second is a "maybe" point because I am currently clearing out the issue with them - wether they can receive and/or send packages from outside US (maybe something has changed to one side or another). PM me for exact numbers and info I've got from them. ######## POST p11180 | notaz | 2010-06-18 | t386-510.html I can donate a bit for this too. For great justice! (and maybe for some raw pics too) ######## POST p11184 | Stef | 2010-06-18 | t386-510.html I can donate a bit too [IMG ./images/smilies/icon_smile.gif] ######## POST p11185 | dtech | 2010-06-18 | t386-510.html Nice, me and Chilly Willy (we chatted thru PM about the matter) are highly likely to donate, too. At the moment I have no spare resources, yet I plan to have them by next month and so for this great cause I might put maybe a half/whole buck for a kilobyte of genesis memory (both dram and sram) [IMG ./images/smilies/icon_smile.gif] Genny is definitely worth it even in 2010. As we seem to need around 400 bucks total, there have to be at least 4-8 donators to keep donations within reasonable/possible range. Current idea is that most trustable guy of us could gather the money and then send it to the company along with chips (yes, Nemesis). Seems that we actually might get this done around the fall of this year, unless someone set up us the bomb. ######## POST p11187 | Chilly Willy | 2010-06-19 | t386-510.html This is a tech site, and if we stick to those of us who have been here and contributed to handle the task that require a bit more trust (like collecting the donations), I think we'll be fine. No picking someone with one post who joined just to say he'll collect the donations. [IMG ./images/smilies/icon_lol.gif] ######## POST p11188 | koilazka | 2010-06-19 | t386-510.html dtech, what would 400 be for, decap and pictures for one chip, or 2 or? Ive never heard of this before, would the pictures be pictures of the silicon slide? If so, can you guys here translate them into schematics? Sorry for silly questions, sounds like an awesome thing to do. ######## POST p11194 | AamirM | 2010-06-19 | t386-525.html I wish I could donate some money. But I am totally broke right now [IMG ./images/smilies/icon_cry.gif] . If the donations are accepted for a month or two, I may throw something in. ######## POST p11205 | dtech | 2010-06-19 | t386-525.html koilazka: it's a sum for one chips to be decapped and throughoutly photographed by a professional using a microscope. Check pages 20-22 of this very thread to read on what and how could be done thanks to such an operation. (viewtopic.php?t=386&postdays=0&postorder=asc&start=300 ) Here's original doc from the guys who decapped OPL2 and OPL3 YMFs and extracted rom table contents from the images, and that way cleared/confirmed out a lot of things for the emulation community. http://docs.google.com/View?docid=dd8kqn9f_13cqjkf4gp AamirM: I think that donation gathering will not happen rapidly and instantly - it will likely stretch for several months, so no need to worry [IMG ./images/smilies/icon_smile.gif] ######## POST p11206 | dtech | 2010-06-19 | t386-525.html For more appetising fun, here are three versions of beloved SID decapped and micrographed: http://www.digital-circuits.org/sid/CSG%20Micrographs/ Guys even reversed some analog circuits (you can dig up there somewhere some sketches reversed from the layers) ######## POST p11209 | koilazka | 2010-06-20 | t386-525.html [IMG http://img130.imageshack.us/img130/7330/01101010.png] That is awesome. ######## POST p11268 | Eke | 2010-07-01 | t386-525.html I was told about this company, located in US also which seems to do some good quality decapping and provide good quality photos, could be a cheaper alternative: http://www.flylogic.net/ ######## POST p11269 | TmEE co.(TM) | 2010-07-01 | t386-525.html The Flylogic guys seem good. I looked at their blog and how they crack different security measures etc. in chips, lol ######## POST p11276 | HardWareMan | 2010-07-02 | t386-525.html [QUOTE] TmEE co.(TM) wrote:The Flylogic guys seem good. I looked at their blog and how they crack different security measures etc. in chips, lol [/QUOTE] I saw the result of Chinese crackers. They make decap of chip, find the position security fuse bit and clear it with laser. Then just read the firmware by programmer. Simply brilliant. ######## POST p11286 | Charles MacDonald | 2010-07-03 | t386-525.html Could somebody explain exactly what the goal with decapping is? What thing(s) are we trying to get? 1.) I know the YM2612 has an internal ROM with a sine wave. This has been read out with other FM chips using the test mode, and the YM2612 has a test mode too. Couldn't we use that or at least attempt to? 2.) Are there other tables in the YM2612 we need to read? If so, what? 3.) What ROM data is in the VDP that we intend to recover by decapping? One concern is that typically ROM data is not stored in an obvious way so it could be very difficult to find the ordering of the binary data. If you know what the data should be, it's easier to find the ordering. If the contents of a table are completely unknown then it is very difficult. E.g. If you think of the ROM as a matrix of bits the rows and columns are all interleaved and transposed and shuffled around, nothing is in linear order on the die. Another concern is that simply having a photograph of the chip will not (in an obvious way) reveal anything about how it works, to the point that we can solve (say) FM or VDP emulation issues that still persist. For example the NES PPU has been around since the 80s, and nobody has copied it. There have been reverse-engineered implementations, but in terms of figuring out how it works at the gate level, it has never been done based on die photographs. That's one of the reasons the Famiclones are so terrible. Now in comparison the Genesis VDP is several orders of magnitude more complex. Not trying to rain on the parade, just trying to be realistic about what the goals are and if we can accomplish them. ######## POST p11386 | Nemesis | 2010-07-16 | t386-525.html [QUOTE] 1.) I know the YM2612 has an internal ROM with a sine wave. This has been read out with other FM chips using the test mode, and the YM2612 has a test mode too. Couldn't we use that or at least attempt to? [/QUOTE] Already done. That's how I derived the algorithm I provided in this thread to re-create the bit-accurate sine table. [QUOTE] 2.) Are there other tables in the YM2612 we need to read? If so, what? [/QUOTE] Well, none I know of that we need to read. The tables I know about are: -Sine table -Pow table -Detune table -Phase modulation increment table -Attenuation increment table (may be largely "generated" rather than stored. -Envelope generator counter shift table (may be entirely generated) -LFO increment table (probably part of the circuit path) -Amplitude modulation shift table (probably part of the circuit path) I've already reverse engineered the contents of all these tables to my satisfaction, as in, I'm confident I have them 100% correct, perhaps with the exception of the attenuation increment table for which I haven't directly verified every single entry, so maybe 95% confident for that one. [QUOTE] 3.) What ROM data is in the VDP that we intend to recover by decapping? [/QUOTE] I don't think there's any data of note in there other than the tables. I suppose the interest in decapping the YM2612 is more of a curiosity thing for me than anything else. It would be interesting to get a look at the inner workings of the chip, and perhaps try and reverse some of the more curious logic pathways of the YM2612 by analysing the real implementation on the die, if such a thing is actually possible. We might also be able to gather some more information on the embedded DAC, in particular on now many bits of input it accepts, and any precision issues it might have, which it is very difficult to perform accurate tests on due to the fact the only output we get from it is analog. Technically speaking though, we don't really need to decap the YM2612. It might lead to some improvements in emulation, but probably not any that anyone is going to actually hear a difference from. The VDP would be an interesting project though, I'd love to take a peek inside that chip. As you say though, staring at shots of the die might not yeild any useful information in and of itself. I think it would help to direct reverse-engineering attempts on the right path though. I think it should be possible to at least block out what parts of the die manage what "units" of functionality. Simply getting a look at what units connect to what can help to better understand how the device operates internally. At any rate, a die shot is just another form of documentation, and hey, the more documentation the better. Payoffs from this kind of thing are probably going to be very long term though. Maybe in 10 years time they'll attract the interest of some guru who's got a background in failure analysis or design/reverse engineering of hardware devices, and he'll be able to look at these shots and read them like code. If I can stare at a random binary and make sense out of it (IE, what's code, what's data, whether its little endian or big endian, CISC or RISC, register width, etc) and then start reversing it, I don't see why someone can't do the same with a die shot. It doesn't have to hold all the answers, just enough to get someone started, or compliment the documentation we already have. ######## POST p11689 | Richter X | 2010-08-16 | t386-525.html Would be nice for someone to reverse engineer the chips from the 32X and SegaCD as well, just to be able to finally make something like the unreleased Sega Neptune. ######## POST p11810 | Oliver_A | 2010-08-31 | t386-525.html [QUOTE] HardWareMan wrote: [QUOTE] Nemesis wrote:I was going to look at the DAC last, once I've finished examining the other components of the YM2612. I've also noticed the extreme jump between low volume and silence though. I'm sure the answer to that behaviour lies in the DAC. [/QUOTE] I confirm that! A very noticeable ladder effect is exist. [IMG http://img261.imageshack.us/img261/3083/80397931gn5.th.png] [IMG http://img522.imageshack.us/img522/5593/16493221uy4.th.png] [IMG http://img131.imageshack.us/img131/2051/19696138zd5.th.png] [/QUOTE] I think this is still the biggest, unresolved issue concerning correct YM2612 emulation. When I got my first Mega Drive (which was after I used Genecyst and KGEN), I immediately noticed this strange bias in the audio output in quiet passages. To me, it looks like an offset is somehow added to the digital data before the sign conversion takes place, which results in a noticeable gap in the positive and negative interval around the zero mark. When I first heard this effect on the real hardware, I thought it was due to the lower precision of the YM2612 DAC. But after seeing these waveforms, I agree with Steve Snake that the there seems to be a bug before the digital data reaches the DAC. What might shed some light onto the nature of this bug would be the question if the DAC mode of channel 6 exposes the same kind of distortion than the native FM data. For example, when generating a sawtooth by writing incrementing values into the DAC, is there the same gap around the zero mark? If yes, is it a flaw of the DAC itself, and can the results be used to reverse-engineer what range of values is affected? If no, is this a confirmation that the DAC is fine and that the bug seems to occur only during the 14 Bit-> 9 Bit conversion of the FM data? Anyway, I think no YM2612 emulator can be considered complete unless this characteristic of the real chip is emulated. It has quite some effect on the way how the original Mega Drive/Genesis sounds. ######## POST p11811 | TmEE co.(TM) | 2010-08-31 | t386-525.html Here's some fragments of a recording form my MD2 I took long ago, Only PCM here, the gap is the point where my sound engine is doing something else than playing PCM samples : http://www.fileden.com/files/2008/4/21/ ... CM_MD2.png Here's a FM waveform in action too with samples. Gap is same as before. http://www.fileden.com/files/2008/4/21/ ... FM_MD2.png I cannot see that sudden jump. You can see a bit of "staircase" on the FM in the gap though... if one could count all the gaps, one could get to know the real output res of the MD2 YM implementation... I don't have precise enough equipment for that. EDIT: I'm not very zoomed in there... ######## POST p11813 | Oliver_A | 2010-09-01 | t386-525.html [QUOTE] TmEE co.(TM) wrote:Here's some fragments of a recording form my MD2 I took long ago, [/QUOTE] Thank you, but... isn't the "ladder effect" supposed to occur on the real YM2612 only? Does your MD2 have the external YM2612 and not the integrated one? I guess we need a recording from an early MD1. I have one, but no possibility to run code. ######## POST p11814 | TmEE co.(TM) | 2010-09-01 | t386-525.html This was just for comparsion. MD2 is different form MD1. I have several MD1s around, I need to get some time to do some recording... ######## POST p11859 | Christuserloeser | 2010-09-13 | t386-525.html @Eke: I posted a request at romhacking.net and Paul Jensen replied with a basic translation of these: http://www.romhacking.net/forum/index.p ... 422.0.html [QUOTE] Eke wrote:Here are some extracted text from the previously posted YM3438 manual that is mentionning the DAC, it would be nice if someone could translate them: [IMG http://www.monsterup.com/upload/1266919197124.gif] [IMG http://www.monsterup.com/upload/1266919197314.gif] [IMG http://www.monsterup.com/upload/1266919198568.gif] [IMG http://www.monsterup.com/upload/1266919246689.gif] [/QUOTE] [QUOTE] Eke wrote:On that topic, some other part of the YM3438 manual I would be curious to have translated (i.e info that are not already covered by YM2608 translated manual): Something about the read mode (when reading FM address 1,2,3): [IMG http://www.monsterup.com/upload/1266919560215.gif] [IMG http://www.monsterup.com/upload/1266919560405.gif] An article about differences between Yamaha OPN chips: [IMG http://www.monsterup.com/upload/1266919560196.gif] [/QUOTE] [QUOTE] Paul Jensen wrote: Didn't I already post translations for some of this stuff in the Spritesmind forums? I can post a more thorough translation later, but here are some basics: 1. Each slot/carrier is output as a 9-bit value. 2.The DAC is 9-bit. 3. The chip has a 96 dB dynamic range internally/theoretically, but the DAC is only 9-bit, so the effective dynamic range is 54 dB. 4. Due to the lower dynamic range of the DAC, overflows can occur if you set attenuation (TL) too low. 5. The minimum wait time between writes to addresses $21 through $B6 is 17 clock cycles. HTH [/QUOTE] ######## POST p11860 | Christuserloeser | 2010-09-14 | t386-540.html [QUOTE] BRPXQZME wrote: [IMG http://www.monsterup.com/upload/1266919197124.gif] Audio output: Two (2) channels, L and R. Nine (9)-bit stereo DAC included. [IMG http://www.monsterup.com/upload/1266919197314.gif] 6. Accumulator The accumulator adds together and accumulates for each channel the output (9-bit) of each slot for each channel sent from the operator, and sends it to the D/A converter. Therefore, not only does it perform sound construction, there is nothing in particular to look out for. 7. D/A converter and output selection 7-1. D/A converter The D/A converter converts the result calculated in the accumulator into analog voltages. Also, the OPN2C can perform D/A conversion on the data written in the address $2A registers. This encodes analog sound into eight (8)-bit data and does this by writing these in order to the $2A registers. The sampling rate for this is 55.5 kHz. →cf. 1-2. Registers for D/A use [IMG http://www.monsterup.com/upload/1266919198568.gif] [in figure: レベル = “level”, 時間 = “time”] Fig. 2.3: Envelope waveform and each parameter * The envelope’s waveform changes exponentially during attack; at the rest of the rates, it changes linearly. Also, in the internal calculations, it has a zero (0) to negative ninety-six (-96) dB range, but due to the precision of the DAC, the actual dynamic range ends up being zero (0) dB to negative fifty-four (-54) dB. [IMG http://www.monsterup.com/upload/1266919246689.gif] ◻ TL (Total Level): $40–$4E The setting of the output level is performed through the total level. The weight of each bit indicates the attenuation value. Therefore, “00” means attenuation of zero (0) dB (the maximum level), and “7F” is ninety-six (96) dB (the minimum level). However, in the case of the OPN2C, the internal D/A converter is nine (9)-bit, so the actual analog audio output becomes equivalent to fifty-four (54) dB. Therefore, compared to the OPN, even if the exact same parameters are set, there are cases where the analog sound output will overflow entirely. [/QUOTE] ######## POST p11861 | TmEE co.(TM) | 2010-09-14 | t386-540.html Regarding the PCM/DAC register, it is said the sample rate is 55.5KHz(for 8MHz master clock), but whenever I go past half it, I start getting missed writes which result in distortion/cracking/etc. on high freqs (i.e if you got 26KHz waveform and you skip a write every once in a while, you'll get shitty sound, especially if the write carried a peak value). ######## POST p11862 | GManiac | 2010-09-14 | t386-540.html I confirm that DAC and accumulator are 9 bits, and carriers are shifted BEFORE going to accumulator. With this we lose precision and get spare calculations: 4 shifts and 4 sums instead of 4 sums and 1 shift (algorithm 7). I don't know why they used this method. [QUOTE] Regarding the PCM/DAC register, it is said the sample rate is 55.5KHz(for 8MHz master clock), but whenever I go past half it, I start getting missed writes which result in distortion/cracking/etc. on high freqs (i.e if you got 26KHz waveform and you skip a write every once in a while, you'll get shitty sound, especially if the write carried a peak value). [/QUOTE] It's sample rate of every channel and thus, rate of getting output of 6th channel or byte $2A and sending it to DAC. I think THIS is what they meant. How fast you can write to $2A is quite another story, and it strongly depends on specific console. One console let me writings at 32 kHz, while other - at 24 kHz. ######## POST p11863 | Eke | 2010-09-14 | t386-540.html Thanks a lot ! This [QUOTE] The accumulator adds together and accumulates for each channel the output (9-bit) of each slot for each channel sent from the operator, and sends it to the D/A converter. [/QUOTE] and this [QUOTE] However, in the case of the OPN2C, the internal D/A converter is nine (9)-bit, so the actual analog audio output becomes equivalent to fifty-four (54) dB. Therefore, compared to the OPN, even if the exact same parameters are set, there are cases where the analog sound output will overflow entirely. [/QUOTE] are interesting. This would mean that not only the output of channel is limited from 14 to 9 bits but also the output of each of the 4 slots that makes a channel... and that overflow can occur is surprising: as I understand it, it means that in case of algorithm 7 for example, the sum of the four 9-bit operators output is masked and a large attenuation can become a lower attenuation ? I'm not sure how they ended with the 54dB value though. ######## POST p11864 | TmEE co.(TM) | 2010-09-14 | t386-540.html 9 * 6 = 54 [IMG ./images/smilies/icon_razz.gif] each bit is 6db [QUOTE] GManiac wrote:How fast you can write to $2A is quite another story, and it strongly depends on specific console. One console let me writings at 32 kHz, while other - at 24 kHz. [/QUOTE] You get those rates when you wait for the ready bit ? I have so far got only ~33KHz form MD2 and my MD1s by doing the busy wait before sending in a sample ######## POST p11865 | GManiac | 2010-09-14 | t386-540.html [QUOTE] This would mean that not only the output of channel is limited from 14 to 9 bits but also the output of each of the 4 slots that makes a channel... and that overflow can occur is surprising: as I understand it, it means that in case of algorithm 7 for example, the sum of the four 9-bit operators output is masked and a large attenuation can become a lower attenuation ? [/QUOTE] Operator is arithmetically shifted by 5 bits, result sums with accumulator. One operator can give you values from -256 to +255. Using one more operator you can get +256, I know it sounds strange. Range of accumulator or DAC is -256..+256 and you cannnot get values out of this range. There is no "overflow", high values won't become small values. [QUOTE] You get those rates when you wait for the ready bit ? [/QUOTE] Yes. In other case I should lose samples. ######## POST p11867 | TmEE co.(TM) | 2010-09-14 | t386-540.html So there's some different kind of YM chips around..... When I wait for the flag, I get 33KHz, with lot of missed writes, just boost up highs in some test tune and you'll hear how crappy stuff close to 13KHz and above gets... and its no way caused by playback code or analog stages after the YM. ######## POST p11873 | Eke | 2010-09-19 | t386-540.html Some additional notes from the romhacking board (huge thanks to the translators there) [QUOTE] Points of note on OPN2C data conversion-time The YM3438 (OPN2C), due to the use of YM2203 (OPN) and YM2608 (OPNA) software, can drive 3ch or even 6ch audio output. However, due to the characteristics of the OPN2C, there are also cases in which it cannot drive audio, like the OPN2. However, even though the the OPN2 and OPN2C can drive software made for OPN and OPNA, there are cases in which they cannot attain the same tone [i.e. sound characteristics] as the OPN and OPNA. Because the D/A converter’s dynamic range is limited to nine (9) bits, this can cause the output waveform to overflow unintentionally depending on the values set for tone parameters. In order to avoid this, it is necessary to adjust the “total level” in the tone parameters so as to not distort the output waveform. Also, even when performing sound production using the OPN or OPN2C, it is necessary to take caution. In this manner, the tone data between the OPN2/OPN2C and OPN/OPNA are not 100% compatible. Accordingly, the standards when creating OPN2 or OPN2C tone data based on that of the OPN, OPNA, and YM2610 (OPNB) are listed below. This is the same even when using the OPN2/OPN2C to perform sound production. ① Confirm the connection (algorithm) data. If these data are zero (0) through three (3), then the waveform does not distort, even at TL=0. ② When con. = 4, set the TL of the second individual carrier so that it will be negative six (-6) [dB] or more. ③ When con. = 5 or 6, set the TL of the third individual carrier so that it will be negative nine and one half (-9.5) [dB] or more. ④ When con. = 7, set all TL’s to negative twelve (-12) or more. [/QUOTE] It is related to how channel's slots are summed to compute 9-bits DAC input, not sure how to interpret that though. ######## POST p11874 | Stef | 2010-09-21 | t386-540.html The guy said "this can cause the output waveform to overflow unintentionally ...", well i guess he meant the waveform can be limited. I think there is a limiter after the sum so it can fit in 9 bits (without limiter it would sound completly trashy in case of overflow). ######## POST p11875 | Eke | 2010-09-22 | t386-540.html [QUOTE] Gmaniac wrote:Operator is arithmetically shifted by 5 bits, result sums with accumulator. One operator can give you values from -256 to +255. Using one more operator you can get +256, I know it sounds strange. Range of accumulator or DAC is -256..+256 and you cannnot get values out of this range. There is no "overflow", high values won't become small values. [/QUOTE] [QUOTE] Stef wrote:The guy said "this can cause the output waveform to overflow unintentionally ...", well i guess he meant the waveform can be limited. I think there is a limiter after the sum so it can fit in 9 bits (without limiter it would sound completly trashy in case of overflow). [/QUOTE] so basically, the process would be, for each channel: 1/ convert 14-bit slot output to 9-bit using simple 5-bit shifter (maybe it's more complicate, seeing how 14-bit output is converted to 10-bit modulation input) 2/ add each slot output (up to four slots per channel) 3/ limits the result to -256;+256 ? @GManiac: may I ask you how you ended up to that conclusions ? ######## POST p11876 | GManiac | 2010-09-22 | t386-540.html I made a tons of tests on real MD to get understanding for myself how YM really works. Information which I could read (MAME's source, YM2608 manual, posts by Nemesis) didn't give me the "whole picture" of understanding. And of course oscillograms will tell more than cold numbers and C source. All of these tests I made 1 year ago and even wrote emulator, but then leaved all this job and it is still in unfinished state [IMG ./images/smilies/icon_sad.gif] Now I'm trying to write an articles about PSG and YM (in Russian), they will fully explain how chips work (info is based on my tests of course) and will consist of some "layers": entry level, detailed description, full description with tests and examples. Back to DAC. I made such test: algo 7, all operators are at +1 of sinus, all TL = $7f, freq = 0, so we have silence. Having prevoius knowledge: - operator's output is -8168..+8168 - each 8 steps of TL are equal to 6 dB (division by 2) and adjusting separate TL I realized that: - operators are shifted first, then are summed - operators are shifted arithmetically (not logically) by 5 bits - levels -1 and -2 of DAC are the same. I mean that if you change output from -1 to -2 you won't notice difference on oscillogram. I know it's very strange, but it's true. - AFAIR, there is level +256, and you can get it summing 2 or more operators, you can't reach it using only 1 operator. Calculations: +8168 asr 5 = +255 -8168 asr 5 = -256 Setting one operator to +255 and adjusting TL of other operator I found that maximum is +256. So we have 513 levels, but maybe here is how equality of -1 and -2 affects final output and we have only 512 uniqie levels? I don't know. I need to revive my work on YM. ######## POST p12972 | HardWareMan | 2011-03-18 | t386-540.html New records from Yamaha. Even Regen is not capable of such accuracy of emulation. Note the abundant presence of the ladder effect in all of decaying sounds. ######## POST p12973 | TmEE co.(TM) | 2011-03-18 | t386-540.html ASIC YM has this effect definitely not present in its output. A while ago l_oliveira put a YM3438 into his MD1 (output is lower impedance on it so analog things had to be adjusted on MD side) and it has same problem in its output, which means ASIC YM is not based on it. ######## POST p12980 | GManiac | 2011-03-18 | t386-540.html Question. Has MD2 REALLY higher precision DAC (>9 bits ) or not? TmEE co.(TM), can you make a test? Algo 7, TL about $3F, sine wave of any operator. Explanation: TL $40 = attenuation of 256 times. So, output of operator will be from -31 to +31. -31 asr 5 = -1 31 asr 5 = 0 Playing this sine wave on YM you'll see: -1 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 0 0 TL $3F = attenuation of 2^7.875 = 234.75 times, output of operator will be from -34 to +34 and output of DAC will be from -2 to +1 and you'll see -2 -1 0 +1 0 -1 -2 -1 0 +1 In fact you won't see -2 because of glitch in DAC, I wrote earlier about it. These calculations are fro 9-bit DAC. I made them "in mind", so there can be mistake. If MD2's DAC is more prceise, you'll see more precise ladder of sine wave. ######## POST p12981 | TmEE co.(TM) | 2011-03-18 | t386-540.html This is what I got with the settings you provided : [IMG http://www.hot.ee/tmeeco/PICS/MD2YMtest.png] There seems to be -2, -1, 0 and +1 here. So even if there is none of higher percision DAC, there's no glitch that eats up few values. I'd do more tests but right now my girl waits me to come to bed... [IMG ./images/smilies/icon_wink.gif] Need to remove the caps from my sound card input... EDIT: Tried TL of 71 this morning and there seems to be 2 values left, alternating rapidly. No 9-bit DAC, but no glitch either... ######## POST p12991 | GManiac | 2011-03-19 | t386-555.html Okay, I understand. And if you run this test on MD1 you should see only 2 steps: from -1 to 0 and from 0 to +1. You won't see step from -2 from -1 because of glitch, so level "-1" will be last longer on X axis. And step -1 to 0 will be HUGE (that is ladder effect). Also, I noticed another glitch in MD1 DAC. Some larger levels have really less voltage. For example, +35 is higher than +36. I don't know concrete values. But you can record sine wave at 0.50 Hz, TL 0 and see this glitch. ######## POST p12994 | HardWareMan | 2011-03-19 | t386-555.html Wrong value at sine table? ######## POST p12995 | GManiac | 2011-03-19 | t386-555.html No, we've discussed this. Glitch in DAC. Sine table is normal, I tested it using phase modulation. ######## POST p13067 | TmEE co.(TM) | 2011-03-30 | t386-555.html I have confirmed that MD2 uses an YM3438. I got a bunch of Yamaha chips today and YM3438 were among them. I did some tests as I did on my MD2 and to my surprise everything matched [IMG ./images/smilies/icon_biggrin.gif] downside of YM3438 is that it has very high impedance output that picks up lot of digital noise. Also the output is significantly louder than YM2612, and this all matches with MD2 output aswell. ######## POST p13441 | TmEE co.(TM) | 2011-06-03 | t386-555.html Does anyone have any info on how to program YMF288 ? It should be YM2608 without ADPCM and GPIO, ADPCM being replaced with a noise generator. I've been searching for quite a while and have not been able to find any programming info. AY and FM side should be identical to YM2608, but noise generator I know nothing about. I have found pinouts of SOP and QFP version and it seems to use regular I2S DAC interface aswell so you don't need any Yamaha DACs. http://sue.niko.to/ps98 http://sue.niko.to/ps98/ps98@ymf288-s_sch.png http://www.kurusugawa-ele.jp http://www.kurusugawa-ele.jp/product/pc ... _v1p42.pdf It was also used on PC-9801-118 and someone has to know how it works. Some people have tried to get datasheets etc. form Yamaha and other places but without luck.... I am building a music making computer and for sound quality reasons I don't want to use YM2612/3438 (only 9bit internal DAC), so I thought I will use YM2151 but it seems this is a very whiny and slow chip, I am having very hard time making right sound with it over LPT (I still have not succeeded yet). YM2203, YM2608 and YM2610 all have external DACs but also very huge chip packages and things I don't need (ADPCM, GPIO). YMF288 would be ideal, but I'd like to get a bit more info about it (the noise generator in particular). EDIT: YM2610 is described having a controllable noise channel... is it AY noise or something else ? Search continues... EDIT2: I found a japanese text that tells about differences, and there is no special noise channel. So YMF288 is YM2608 with these changes : *ADPCM is removed *GPIO is removed *Writes can be done much faster *No CSM mode *Added Standby mode *Regular I2C audio output, so no need for Yamaha floating point DAC ######## POST p13442 | Nemesis | 2011-06-04 | t386-555.html The only programming documentation I've seen for that chip is what I assume is the japanese document you've already come across, from this site: http://www.ylw.mmtr.or.jp/~hosino/ma-ne ... ymf288.txt It's comparing the differences between the YMF288 and the YM2608. Since we have complete documentation for the YM2608, hopefully that document gives enough info to figure out what it does. Actually, looking at it, that same document is in the zip archive I gave in the very first post in this thread. There's some other documentation in that same archive on the PC-9801-86. Maybe something else in there is of use to you? I tend to collect documentation whenever I come across it, whether it's useful to me at the time or not, just in case I need it later. Here's everything I've "harvested" about various sound chips over the years (warning, 140MB file!): http://nemesis.hacking-cult.org/MegaDri ... /FMDocs.7z It's a bit of a mess, lots of random stuff not really organized, but some of it might be useful to someone. ######## POST p13444 | TmEE co.(TM) | 2011-06-04 | t386-555.html That archive is a gold mine [IMG ./images/smilies/icon_biggrin.gif] It will take a while to go through it, but form first glance all I got is already in the archive. Also I can provide better pics of YMF262-F, YM3812, YM2151, YM3438, YM2612, YM3012, YAC512, YAC513 and YMF278B. ######## POST p13445 | HardWareMan | 2011-06-04 | t386-555.html [QUOTE] TmEE co.(TM) wrote:Also I can provide better pics of YMF262-F, YM3812, YM2151, YM3438, YM2612, YM3012, YAC512, YAC513 and YMF278B. [/QUOTE] [IMG http://img821.imageshack.us/img821/8641/dsc0592oc.th.jpg] ######## POST p13446 | Nemesis | 2011-06-05 | t386-555.html Cool, thanks for those images HardWareMan. It would be good to get more pictures of those chips too TmEE, some of those chips really don't have good images online. I've always thought an online wiki, specifically around collecting and sharing documentation for various chips and systems, would be really good for the emulation community. You know, something specifically about the technical info you'd need to learn how to emulate or program for a device. Right now, everything is scattered everywhere, and it often takes a long time to find the "best" version of a document, simply because we have a dozen different versions of the same document floating around (case in point: The Genesis Software Manual). Most of the time you have to crawl old forum threads from various places in order to find info. Websites which are maintained by individuals, where other people can't contribute or maintain the information, always end up out of date. A wiki would be really great for allowing all the versions of a doucment to be hosted, but indicating which is the best of all of them, allowing users to submit more documents and write a community "errata", etc. We could also have a "most wanted" section, to try and get users to notice when they have things which other people want. All in all, I think it'd be a great idea. I might actually try and set something like that up. I've got unlimited download/upload and a static IP with my ISP now, so I could try and host a server. ######## POST p13447 | TmEE co.(TM) | 2011-06-06 | t386-555.html I also foundo ne other very interesting FM chip that was used in FM Towns II, the YMF276, which is YM2612/3438 with i2s DAC interface... FM Towns did have a separate PCM chip in it so the DAC channel may be cut in YMF276... I am unable to find any definitive info though. In any case I will order some YMF288 and YMF276 in nearer future. ######## POST p13448 | HardWareMan | 2011-06-06 | t386-555.html I got an opportunity to make decap of YM2612. Should I? It will cost, but I think I can handle it. PS Hi-res photos ofcourse will be shared. :3 ######## POST p13449 | GreenLine | 2011-06-06 | t386-555.html [QUOTE] HardWareMan wrote:I got an opportunity to make decap of YM2612. Should I? It will cost, but I think I can handle it. PS Hi-res photos ofcourse will be shared. :3 [/QUOTE] I think it contains the same tables as the "OPLx decapsulated" document, but if you decide to do the decap I'd like to contribute to the cost. ######## POST p13453 | King Of Chaos | 2011-06-09 | t386-555.html Go for it if you want to, never know it may yield something useful. ######## POST p14069 | andlabs | 2011-10-12 | t386-555.html These have probably been answered here before and this may not be the right topic for the latter question but :/ I'm trying to figure out how the YM2612 works by reading the MAME code... 1) I understand that "int ksr = kc >> SLOT->KSR" (in refresh_fc_eg_slot) gets what the YM2608 translated doc calls "key-scaling value of the rate", which is shown calculated for a block number and a two-bit note value (same as YM2151, apparently, though that uses a two-bit note value and cents instead of freqnum). The MAME code calculates that two-bit note value by indexing into an array opn_fktable. Where did this calculation come from? 2) What is ((SLOT->ar + SLOT->ksr) < 32+62) checking? I've seen it sprinkled throughout the code... Thanks. ######## POST p14071 | Eke | 2011-10-12 | t386-555.html [QUOTE] I understand that "int ksr = kc >> SLOT->KSR" (in refresh_fc_eg_slot) gets what the YM2608 translated doc calls "key-scaling value of the rate", which is shown calculated for a block number and a two-bit note value (same as YM2151, apparently, though that uses a two-bit note value and cents instead of freqnum). The MAME code calculates that two-bit note value by indexing into an array opn_fktable. Where did this calculation come from? [/QUOTE] opn_fktable is used to calculate the key-code value for detune (see post below about phase generator) [QUOTE] What is ((SLOT->ar + SLOT->ksr) < 32+62) checking? I've seen it sprinkled throughout the code... [/QUOTE] This limit is the maximal RATE value, which is capped at 63 (see post below about envelope generator). When the rate is maximal, envelope directly switches to the next "phase". Everything should be better explainable by these posts from Nemesis: viewtopic.php?t=386&postdays=0&postorder=asc&start=106 viewtopic.php?t=386&postdays=0&postorder=asc&start=167 There is a third one explaining operator unit in between... ######## POST p14072 | andlabs | 2011-10-12 | t386-570.html Thanks; I'll take a look into these since they look like they would be more effective in understand the chip =P However I think I misstated my first question: I meant what was the calculation for the array itself? EDIT wait I see, it's the "Where Block is the 3-bit block data, and N4/N3 are built from fnumber as follows: " part. Thanks anyway =P ######## POST p14104 | andlabs | 2011-10-19 | t386-570.html This is what I can gather/guess about what happens on each YM2612 cycle, am I correct? [CODE BLOCK WITHHELD: 666 chars] with post 7516 being this one ? Thanks. ######## POST p14105 | Chilly Willy | 2011-10-19 | t386-570.html [QUOTE] andlabs wrote:This is what I can gather/guess about what happens on each YM2612 cycle, am I correct? [CODE BLOCK WITHHELD: 666 chars] with post 7516 being this one ? Thanks. [/QUOTE] Hmm - does the FM channel still update even if it is set to PCM? It seems to me that the PCM enable would only effect whether the FM out or the PCM out gets added to the sum. It's POSSIBLE some game might rely on the channel being updated even if it's not enabled for output. ######## POST p14109 | GManiac | 2011-10-21 | t386-570.html [QUOTE] Chilly Willy wrote:Hmm - does the FM channel still update even if it is set to PCM? [/QUOTE] Yes, it does. FM Channel 6 and Reg $2A are independent of each other. "DAC mode" (Reg $2B) only chose output of one of them. If it is in "FM Mode" it outputs Channel 6 output. If it is in "DAC Mode", it outputs value stored in Reg $2A and normalized to scale of DAC (-512 to + 512). Normalization formula is (v - $80) * 4 where v = ($2A). I tested in on HW. ######## POST p14115 | andlabs | 2011-10-22 | t386-570.html Good to know, thanks. Thinking about it some more, wouldn't the EG also run independently of the phase and output generators? The MAME source code implies that the global cycle counter is global to all channels, is this really the case? If so there's really no other way to have the EG work... as far as I can tell anyway :/ ######## POST p14187 | andlabs | 2011-11-11 | t386-570.html In addition to the questions I asked above, I have a few others: With regards to the SSG-EG register, the YM2149 datasheet and Neo-Geo manual (YM2610) all list inverted normal output for any combination 01xx (that is, 01xx behaves like 1111), but that's not what we have down for YM2612, and the YM3438 APL doesn't list any 0xxx values. Is the YM2612 a special case or does it work just like the YM2149 and YM2610? In Nemesis's SSG-EG implementation, key off has "state->attenuation = Data(attenuationBitCount, 0x200) - state->attenuation; ". What is the Data call? The MAME code just subtracts from 0x200... When does the EG first run — on the first cycle, the second cycle, or the third cycle of the entire system execution? I probably will have more questions but I don't remember them now... Thanks anyway! ######## POST p14196 | Nemesis | 2011-11-13 | t386-570.html [QUOTE] With regards to the SSG-EG register, the YM2149 datasheet and Neo-Geo manual (YM2610) all list inverted normal output for any combination 01xx (that is, 01xx behaves like 1111), but that's not what we have down for YM2612, and the YM3438 APL doesn't list any 0xxx values. Is the YM2612 a special case or does it work just like the YM2149 and YM2610? [/QUOTE] A setting of 0xxx appears to have no effect on the YM2612. When figuring out SSG-EG, I ran a test on all 256 possible values for the SSG-EG register. The upper 4 bits had no observable effect, and unless bit 3 was set to 1, there was also no observable effect either. [QUOTE] In Nemesis's SSG-EG implementation, key off has "state->attenuation = Data(attenuationBitCount, 0x200) - state->attenuation; ". What is the Data call? The MAME code just subtracts from 0x200... [/QUOTE] Nothing too important. "Data" is a container class in my emulator I use to simplify otherwise messy operations. It gives me handy function calls to do things like get/set individual bits or segments of a data value, rather than having to use things like masks and shifts everywhere in my code, which I found were very difficult to read, too easy to make a typo or error in, and hard to spot when there was an error. In this case, the fact I'm using the "Data" class to perform the subtraction means that the result will be masked to the size of "attenuationBitCount", or in other words, 10 bits. Equivalent code without the Data class would be something like this: "state->attenuation = ((unsigned int)0x200 - state->attenuation) & ((1 << attenuationBitCount) - 1);" [QUOTE] When does the EG first run — on the first cycle, the second cycle, or the third cycle of the entire system execution? [/QUOTE] Good question. I have absolutely no idea, and no real idea how I could test that either. If the YM2612 uses some kind of volatile internal register to track what cycle it's on, it might not bother initializing it, since it's not really that important. It will power up outputting silence due to the way the other registers are initialized, so it might not care what internal cycle it starts at on power-up. I've seen other devices which behave in this way. The VDP for example can start rendering from any point in a frame, it doesn't begin at any particular point when it is first powered on. The YM2612 might be the same. If this is the case, there isn't really a concept of a "first" cycle. ######## POST p14859 | HardWareMan | 2012-03-31 | t386-570.html Boom! Shake-shake-shake the room! Hallelujah! I started a project of decap those chips! Let me introduce to you: YM2612 [IMG http://savepic.net/2658093m.jpg] And it's clone: TA-07 [IMG http://savepic.net/2641709m.jpg] These chips have different technology, but it still shows that the clone is made almost by copy-paste technique. For example, you may look at it here . So, very soon we can know almost all about YM2612 and it's clones. Soon I will provide you photos with enough quality. Feel free to use it as you wish. Wish me luck to finish this project. You can start to search peoples, which can read these photos, or learn it yourself. Tic-tic-tic-tic Boom! ######## POST p14868 | TmEE co.(TM) | 2012-03-31 | t386-570.html That is really awesome [IMG ./images/smilies/icon_biggrin.gif] Nice to see the clones are close to original, and probably work exactly like originals ######## POST p14871 | HardWareMan | 2012-04-01 | t386-570.html I already get YM2612 photos at 400x zoom, now I must stitch them together. All 268 of them. :3 Check this out! [IMG http://savepic.net/2670220m.jpg] ######## POST p14872 | Stef | 2012-04-01 | t386-570.html Hehe excellent ! ######## POST p14886 | Nemesis | 2012-04-03 | t386-570.html Haha! This is beyond awesome, I'm looking forward to taking a close look at these die shots! We have such a good understanding of the main internal pipeline for this chip already, that we might be able to make some real discoveries from looking at the die in the less well known areas, in particular from examining the DAC implementation. HardWareMan, do you have any plans to decap other Mega Drive related chips? I think it would be very beneficial to get the VDP in particular decapped, with the bus arbiter and I/O controller being next on the list. Once the decapped shots are out there for anyone to see, I think they'll be a source of new information for a long time into the future. I've been amazed at the work that's been done with the 6502 recently ( http://www.visual6502.org ), where they've managed to build a full transistor-level emulation of the chip from analysis of the die shots. This may never happen for the Mega Drive, but it just goes to show how much information these images can yeild. ######## POST p14890 | HardWareMan | 2012-04-03 | t386-570.html [QUOTE] Nemesis wrote:HardWareMan, do you have any plans to decap other Mega Drive related chips? [/QUOTE] It may very well be. I recently discovered this opportunity decapsulation with a good zoom and good speed of get the result and I don't intend to throw in the near future. While I do stitch Yamaha pics, I have already started to recieve pics TA-07. [IMG ./images/smilies/icon_wink.gif] ######## POST p14898 | Chilly Willy | 2012-04-03 | t386-570.html One of the things I'm hopeful about is that each new bit of info about these old FM chips show how simple the design is when you actually know what is it is. Emulations of the FM chips have always consumed a lot more power than they need because they work in a more idealized manner rather than how the chips actually work. Once the 2612 is understood, an exact emulation should work on lesser systems, like the GBA or PSP or NDS, without consuming so much time that it slows the rest of the emulation. Then you won't need to cut back on the FM emulation to run games full speed on such systems. ######## POST p14906 | Nemesis | 2012-04-03 | t386-570.html That would be nice. You can tell when you're missing something when writing an emulation core, if it takes a massive number of calculations to perform some trivial operation. That said, I think one of the big problems with emulating hardware devices like the YM2612, VDP, etc, is that something can be extremely simple to build using transistor logic, and run extremely fast, but extremely difficult and slow to write code to emulate. There are two main issues: bit manipulation, and parallellism. You've got to remember, these raw circuits can just take a 16-bit input, and break it up into half a dozen peices purely by where the data lines are connected, which then get sent to half a dozen different circuits, in parallel. Each circuit can then work with its own bit of data to produce some result, and often, this can happen in a single clock cycle for that chip. Emulating that in code often requires a lot of AND's, OR's, and bitshifts just to break apart the data, and then you've usually got to run each operation in series, since you can't parallellize in software for a 50-cycle peice of code and get a performance win. Here's a good example of some of these difficulties, from my VDP core: [CODE] unsigned int screenSizeModeV = ((vszState & 0x1) & ((~hszState & 0x02) >> 1)) | ((vszState & 0x02) & ((~hszState & 0x01) << 1)); [/CODE] This code correctly limits the vertical screen playfield size, based on the specified horizontal and vertical screen modes. I know exactly what that is in hardware: it's two NAND gates. In my code, I need a big comment above it just to explain what it's doing. Of course, this kind of stuff can often be made faster using pre-calculated conversion tables and the like, but on the whole, you're still a lot slower than the real hardware. This can all mean what was a trivial circuit taking some data, splitting it up, running bits of it through a few logic operations, and outputting a few other numbers at the end, can end up taking hundreds of cycles to emulate, while the hardware device did it in one cycle. That's just the nature of emulation sometimes. ######## POST p14976 | HardWareMan | 2012-04-09 | t386-585.html OK, I've finished it. This is my first experience of gluing pictures, so do not kick me. :3 So, this picture 24516x21770 pixels and 116MBytes. It's too big for FileDen, and all pichostings, so I placed it on filesharing service. Someone of you can rehost it to better place. [IMG http://savepic.su/1692466.jpg] 1. DAC is 8bit, not 9bit. 2. DAC seems to be one not only for 6 channels, but for left/right output too. But I don't get it: oscilloscope shows channel synchronization: [IMG http://savepic.su/1700658.png] Perhaps they used the capacitance to store the current signal level. DAC place at upper right corner on picture. All analog pins can easily be traced to him. The first step is to identify all the blocks in the picture. Interestingly, below the center at right side there are some matrixes, perhaps this is the operator unit and the calculation tables for the level of the envelope and sine. And they're seems 14-bit. On the left side above the middle is likely array of registers. Learning, thinking and posting here. PS Any part of picture can be recaptured with better quality. Source PSD file was 1,5GB. :3 ######## POST p14982 | TmEE co.(TM) | 2012-04-09 | t386-585.html I'm not very sure but I think the 2 big zig zags (capacitors ?) right next to each other under DAC part are part of channel switching. Final analog lines end up in the circuitry connected to them and there's some digital lines coming into the circuitry too... There are 6 of something (triggers ?) that could hold panning settings for each channel... ? It could also explain that when you overload one channel it affects the other. ######## POST p14985 | HardWareMan | 2012-04-09 | t386-585.html [QUOTE] TmEE co.(TM) wrote:I'm not very sure but I think the 2 big zig zags (capacitors ?) right next to each other under DAC part are part of channel switching. [/QUOTE] Yeah, it could be capacitors. Or it could be power current amplifier. I'm not sure for now. But, there are lot of capacitors, that interconnect some power rails on die. Look at bidirectional pin: [IMG http://savepic.su/1643350.png] And analog output pin: [IMG http://savepic.su/1699689.png] Analog output has only one transistor, wich connected to AVCC. Thus, analog output can only source current, not sink. External resistor required. And here those "zig-zags". Definitely this is a two transistors with some control circuit. [IMG http://savepic.su/1684328.png] ######## POST p14988 | TmEE co.(TM) | 2012-04-09 | t386-585.html I was just thinking... there not needs to be 2x DACs for both sides, only a switch that turns off sides. [CODE BLOCK WITHHELD: 193 chars] ######## POST p14990 | HardWareMan | 2012-04-09 | t386-585.html Interesting idea. This chip can't do smooth L/R panorama, you can simply enable or disable the output to the L/R channel, right? ######## POST p14991 | TmEE co.(TM) | 2012-04-09 | t386-585.html This is exactly what got me thinking this, especially since output is muxed not summed. If it was summed you'd need 2x DAC or have no sync between 2 sides with single DAC. ######## POST p14998 | Nemesis | 2012-04-09 | t386-585.html Great work HardWareMan! Permanent mirror: http://nemesis.hacking-cult.org/MegaDri ... tiched.jpg ######## POST p15000 | Nemesis | 2012-04-09 | t386-585.html I haven't had too much time to look at the die shot so far, but one thing I can add is the function of pin 10. It was mentioned earlier in this thread that pin 10 is actually the "TEST" pin. So far, the only known function of this pin is that it returns the realtime "busy" state of the YM2612, the same as what can be read from the status register. I've confirmed this through hardware tests. See this post: viewtopic.php?p=7409#7409 Pin 10 is also formally identified as the TEST pin in the official YM3438 manual. It's likely that this pin can perform other functions, depending on the state of the test register. I don't know of any at this stage, but I haven't investigated it too thoroughly. Looking at the die shot however, it does appear that this pin can act as an input line as well as an output line... [IMG ./images/smilies/icon_smile.gif] ######## POST p15006 | HardWareMan | 2012-04-10 | t386-585.html [QUOTE] Nemesis wrote:Great work HardWareMan! Permanent mirror: http://nemesis.hacking-cult.org/MegaDri ... tiched.jpg [/QUOTE] OK, applied to my post. ######## POST p15018 | Nemesis | 2012-04-10 | t386-585.html HardWareMan was kind enough to supply the original psd, so I've uploaded it to my webspace: http://nemesis.hacking-cult.org/MegaDri ... hed_PSD.7z The file is massive, almost 700MB compressed. To be honest though, after comparing it with the jpg file, the two images are virtually indistinguishable. I don't think anyone will find any extra details revealed in the psd file that can't be seen in the jpg version, but here it is for the sake of posterity. ######## POST p15021 | HardWareMan | 2012-04-11 | t386-585.html Exactly. JPEG compression was set above 10. Any thoughts about crystal? ######## POST p15024 | TmEE co.(TM) | 2012-04-11 | t386-585.html I'd need a crash course in IC topology so I would know what kind of components am I looking at... ######## POST p15026 | HardWareMan | 2012-04-11 | t386-585.html Go for it! And I can proceed to SN76489AN (someone not sure about noise channel). :3 ######## POST p15027 | TmEE co.(TM) | 2012-04-11 | t386-585.html What I want to see is 315-5478 / 5660 / 5700 / 5708 to finally settle why it has the least noisy output, plus the other tidbits that fix trailing noises and other oddities that only happen on YM2612 and not on YM3438... ######## POST p15031 | Nemesis | 2012-04-12 | t386-585.html Yeah, it would definitely be interesting to see the embedded version of the YM2612/YM3438 on the Mega Drive 2, if nothing else just to see how "custom" it is, or if it is literally a "YM3438 in a box" if you will. Getting a good look at the DAC will also be quite useful, since we know it's a completely different DAC than in the discrete YM2612. ######## POST p15032 | HardWareMan | 2012-04-12 | t386-600.html [QUOTE] TmEE co.(TM) wrote:What I want to see is 315-5478 / 5660 / 5700 / 5708 to finally settle why it has the least noisy output, plus the other tidbits that fix trailing noises and other oddities that only happen on YM2612 and not on YM3438... [/QUOTE] I don't have this chips. Sorry. I'm waiting for the completion of photography clones YM2612: TA-07 and SE-95. ######## POST p15033 | Huge | 2012-04-12 | t386-600.html ... could you decap other chips if we sent them to you? ######## POST p15034 | TmEE co.(TM) | 2012-04-12 | t386-600.html I can donate : 315-5750 (SVP, failed due to static electricity) 315-5960 (MD2 VA4, Genny3 VA0/VA1 ASIC) YM3438 (a fake chip, made in 2000something but works perfectly) 315-5660 (MD2 VA0/1/3) ######## POST p15035 | Huge | 2012-04-12 | t386-600.html Now, let's not open the floodgates just yet. As I understand it, decapping takes significant work, very expensive hardware, and it is a dangerous process. I too have a few Sega chips I want to see decapped, that I am willing to send for zero charge, but they are only borderline related to the Megadrive. So first I must ask if it is even possible, how much would it cost, how many do you have the capacity and time to do, would the chips still work after decapping & photographing, and such things. ######## POST p15057 | TmEE co.(TM) | 2012-04-14 | t386-600.html There is one thing I am wondering... perhaps the DAC is a simplified Yamaha floating point DAC ? Normal format for them is 3 bit exponent and 10 bit mantissa. The DAC seems to be made of 2 parts, and one of the parts does have 3 lines coming into it... ? ######## POST p15075 | Nemesis | 2012-04-16 | t386-600.html I don't think so. With what little I understand of IC design logic at this stage, it seems to me that what's happening is that they're splitting the upper 3 bits and the lower 5 bits of the value so that they can construct an array. You'll see there are three separate parts to that circuit, with an upper section that has 3 lines going into it and 8 lines going out, and a lower part with 5 lines going into it and 32 lines going out. I'm guessing these sections are "decoders" of sorts, which will take in effectively a binary value, and assert only a single output line indicating the decoded value. IE, 2^3=8, and 2^5=32, which is why there are 8 output lines for the upper part, and 32 output lines for the lower part, one for each value respectively. Those output lines then get fed into some kind of logic array which is 8x32, with 256 entries. A single entry gets triggered, which is the point at which the two asserted lines intersect. If I was to guess, I'd say this is effectively an array of resistors, each one having a different resistance, so that each entry on the table produces a different output current based on the 8-bit digital input. A very simple, neat DAC. All that said, this array is just an array of entries. I don't know if there's any way to tell from looking at this 8x32 array what the "value" of each entry is. If there isn't, there's no way to know how the 8-bit input data is encoded without tracing it back further up the circuit. Since the operator unit produces a simple binary output though, I don't think they would have encoded it as floating point to pass to the DAC, since the DAC decode table could just as easily work with floating point or raw binary data, depending on the resistance values for each entry. ######## POST p15076 | Nemesis | 2012-04-16 | t386-600.html I should add, I'm not really sure from looking at the circuit if the DAC really is 9-bit or 8-bit. It looks like 9 data lines come up to the DAC, but one of them gets whisked away and I can't quite figure out what happens to it. At a guess, I'd say it's really a 9-bit DAC, but one of those is the sign bit, so it gets applied later on, after the remaining 8 bits have been run through the ADC conversion table. ######## POST p15077 | HardWareMan | 2012-04-16 | t386-600.html You totally right! Analog value matrix is 8x32 (256 levels). 9th bit is a sign. [IMG http://savepic.su/1714262.png] Sign bit conect DAC matrix to AVCC or AGND via Source/Sink power switches. That is why between two samples on MOL/MOR are 1/2 of AVCC. Thus, 8bit DAC pulls up to the AVCC or pulls down to the AGND which depends on 9th sign bit. Whoah. ######## POST p15080 | TmEE co.(TM) | 2012-04-16 | t386-600.html That is very neat ! ######## POST p15081 | HardWareMan | 2012-04-16 | t386-600.html OK. Look here: [IMG http://savepic.su/1723272.jpg] Very interesting: all 9 bits routed to control unit. Upper 8 are goes from 8-bit register 9above control block) and rest one bit goes (by another route) somewhere inside control block. So, are we able to whole 9 bit DAC programming? ######## POST p15082 | Nemesis | 2012-04-16 | t386-600.html Actually, since reading this topic: viewtopic.php?t=1118 I've been thinking the upper 2 bits in the DAC test register at $2C could very well be the same as the upper 2 bits in the FM test register, namely, they might allow the digital data being fed into the DAC to be read from the status register, so maybe that circuit is for reading the internal 9-bit DAC value out? It's also possible one of the other bits in that test register allows a full 9-bit DAC value for channel 6 to be set somehow, IE, maybe bit 0 is the LSB of the 9-bit DAC value? ######## POST p15083 | Nemesis | 2012-04-16 | t386-600.html By the way, thanks for that picture! It's extremely helpful for getting an idea of how the DAC is connected. ######## POST p15093 | Eke | 2012-04-16 | t386-600.html I am quite impressed by the way you guys are able to follow those "tracks" and figure what kind of component they are connected to [IMG ./images/smilies/icon_eek.gif] Has this already been figured how the 9-bit DAC source was generated from 14-bit operator output ? What is the 9-bit DAC source register purpose ? EDIT: well, I can answer the latter myself at least, it seems to be a "temporary" storage for the DAC source, I noticed that there were "inputs" and "outputs" connected through those registers (one per bit and per stereo channel,, 18 in total). I'd never have thought that a "simple" register would have been so much complex electronic though ! ######## POST p15097 | HardWareMan | 2012-04-17 | t386-600.html DAC is 9 bit mono. "Stereo" is just enabling selected channel to left or right output. Next, those area, which I marked as DAC register is seems to be an multiplexor, which selects program sample or accumulator sample. Accumulator lies below this area. ######## POST p15104 | Paul Jensen | 2012-04-18 | t386-600.html I don't really have any insights to contribute here, but I'd just like to say thanks to you guys for going through all the effort to decap and analyze the circuitry of the YM2612. I've had a weird interest in this chip ever since I started working on vgm2mid (anyone here remember that program?), and it makes me happy to know that I'm not the only one curious to find out what makes it tick. [IMG ./images/smilies/icon_smile.gif] Also, does anybody have any links to good resources for learning how to read IC schematics? Looking at all the photos of the YM2612 has made me want to be able to analyze these circuits for myself. ######## POST p15105 | Huge | 2012-04-18 | t386-615.html I have vgm2mid, a version that dates to 2001. Also a copy of gym2mid somewhere, and a handful of midis converted by either of them. (too lazy to clean them up) Damn, the vgm format is 10+ year old already... ######## POST p15109 | Nemesis | 2012-04-18 | t386-615.html [QUOTE] Also, does anybody have any links to good resources for learning how to read IC schematics? Looking at all the photos of the YM2612 has made me want to be able to analyze these circuits for myself. [/QUOTE] I'm interested in this too. I've got some old IC design books from the 1970's and 1980's which seem to be a good resource. I think at the end of the day, you need to learn as much about how to design these circuits as possible. If you understand what the principles of the design are, you should be able to more easily recognize what individial elements on the circuit are. ######## POST p15118 | King Of Chaos | 2012-04-19 | t386-615.html I didn't see it mentioned on any of the last few pages, but this topic might be of interest: http://forums.sonicretro.org/index.php?showtopic=28589 ######## POST p15120 | andlabs | 2012-04-19 | t386-615.html There's a topic on that elsewhere here. Nemesis: which books do you have? I guess it's time to actually learn computer engineering =P ######## POST p15122 | Mamizou | 2012-04-19 | t386-615.html Hi there! I've been monitoring this thread for awhile now and updating the Wikipedia article on the YM2612 as this has progressed. Seeing the OPN2 finally decapped is really amazing, and it's interesting comparing the full die image to those of the decapped OPL2 and OPL3. Seeing a decapped VDP would be amazing as well, even one from a Model 2 Genesis/MD. Anyway, I'm curious if it's possible to get a good clean image of the decapped OPN2 for use on the Wikipedia article, like this ? That way I can include it on the YM2612 article. (It'd be even more awesome if, at some point in the future, a YM2608 and YM2203 get decapped, just to see the progression of development of the OPN family in general. I wish I had the hardware/money to donate. T-T Wishful thinking, hahaha.) Anyway, thanks for all of the amazing decapping and photographing work, and I can't wait for more info to surface on my favorite FM synth chip family. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p15123 | Huge | 2012-04-19 | t386-615.html You should send a PM to HardwareMan if you want to see any more chips decapped and have the cash to pay for it. ######## POST p15147 | ICEknight | 2012-04-23 | t386-615.html As long as it's not illegal or anything, how about creating a Kickstarter for decapping as many Mega Drive chips as possible, from every motherboard revision? If many people show interest and the initial goal is met, more systems could be added, even (Mega CD, Mega 32X, SEGA Nomad, Laseractive SEGA pac, SEGA Pico, or anything related). Oh, and hi. ######## POST p15152 | Huge | 2012-04-23 | t386-615.html Finances are the main problem I think. I'd chip in if we are talking about decapping Saturn stuff, by the way. I think that's the one that needs it the most. The Mame team was supposedly trying to decap the SH1, but nothing came out of that but a partial, low-res die shot. ######## POST p15153 | sega16 | 2012-04-23 | t386-615.html Why would there even be a chance that decapping an old ic chip be illegal I don't understand were that would have came from. ######## POST p15157 | Nemesis | 2012-04-25 | t386-615.html There's no legality issue, in fact, reverse engineering itself isn't illegal, and we aren't even doing that, just "modifying" a physical device we legally own. I two would love to see the Saturn chips decapped. I don't know if I've ever mentioned this publically before, but once my Mega Drive emulator is finally complete and released, with MegaCD and 32x support, I'll be turning my sights on the Saturn in a major way. [IMG ./images/smilies/icon_smile.gif] All that said, my ability to contribute financially to this effort at this point is virtually nill. Mortgage + kids, plus all the financial stress in the world today, well, I'm sure a lot of other people are in the same situation. It would be good to know just how much a decap like this costed all up, for the decap plus the photos, that way we would know the kind of money that needs to be raised. I mean, $50 for a chip is probably doable. $150 kind of puts it a lot further out of reach... ######## POST p15160 | sigMate | 2012-04-25 | t386-615.html Hi guys, I think I made a nice hardware implementation which could be used to experiment a little (undocumented registers, etc...). I just posted this : viewtopic.php?t=1122 Please tell me what you think [IMG ./images/smilies/icon_smile.gif] Thanks a lot ! sig ######## POST p15164 | Huge | 2012-04-25 | t386-615.html [QUOTE] Nemesis wrote:I two would love to see the Saturn chips decapped. I don't know if I've ever mentioned this publically before, but once my Mega Drive emulator is finally complete and released, with MegaCD and 32x support, I'll be turning my sights on the Saturn in a major way. [IMG ./images/smilies/icon_smile.gif] [/QUOTE] Don't know if I mentioned this (only to AamirM, I think), but if anyone is doing anything Saturn related work, I'd be glad to help in any way I can - I've a full library of games to test in emulators (all full quality bin/cue dumps), and an almost full library of hardware revisions to test applications on (the evolution of the hardware is mighty interesting & actually breaks some games). I want to write down all documentations, but I still need to properly photo the machines I have with the lightbox I built - oh, and I want to write a CMS behind this too (not gonna cave in and use wordpress, oh no). edit: perhaps soon it will be time to open a Saturn board here. And here's the partial SH1 die shot: http://decap.mameworld.info/2010/06/29/the-big-picture/ It's the Hitachi HDS6437097F CDB106 from the saturn... there are actually multiple revisions of this too... an earlier one: HD6437097F20 CDB105, and a later one, 315-5932 YGR022, which is basically that chip and the otherwise separate YGR019 disc controller under one ASIC. ######## POST p15168 | Chilly Willy | 2012-04-25 | t386-615.html Decapping the SH1 or SH2 is a waste of time and money. Both chips are fully documented by Hitachi/Renesas, and it's not like the Saturn use "undocumented" features of the chips like older systems did on older CPUs (like the undocumented opcodes on the 6502). Put that money into decapping the chips that matter, like the VDP1 and VDP2! ######## POST p15169 | Huge | 2012-04-25 | t386-615.html The Saturn uses a custom "SH1 + other things" though, and it's supposed to hold the details over the copy protection, which remains poorly understood even today (there is talk about not one but 3 security rings, two being red herrings). And the entire CD Block is a black box that you cannot interface with, only with BIOS calls, last time I checked. The copy protection details may be in the YGR chip though. Thing is, no one knows anything about either of them, AND there is no way to access or work with any of them. Compared to that, the VDP1/2 is almost fully documented. If we'd skip the cd block, I'd put my money on the SCU. The DSP part has poor to missing documentation. Even if it only used by a few dozen games, it is the biggest unknown. Plus the SCU itself is responsible for a lot of timing related things. Anyway, this is going off topic. ######## POST p15175 | Mamizou | 2012-04-25 | t386-615.html [QUOTE] Huge wrote:If we'd skip the cd block, I'd put my money on the SCU. The DSP part has poor to missing documentation. [/QUOTE] On the topic of sound chips, the SCSP would be very interesting since it does both FM and PCM (I guess an operator would just read from a PCM buffer instead of the quarter-sine ROM). I think the Sonic Jam games used it directly instead of emulating a YM2612, although I could be totally wrong. ######## POST p15176 | Huge | 2012-04-25 | t386-630.html I meant the SCU DSP not the SCSP DSP. It was meant to be a vector coprocessor apparently, but it was woefully inadequate in many ways - including, but not limited to, documentation. Sonic Jam used streaming ADPCM for the music, and normal PCM for most of the sound effects. One or two sound effects MAY have used FM in them, it was used in a scarce way like that in many, many games. ######## POST p15183 | TmEE co.(TM) | 2012-04-26 | t386-630.html SCU has maaany of pages of documentation. I went through my saturn docs to find some SCSP info and I came accross with at least 10x PDFs full of SCU stuff. Only few that dealth with SCSP, and from those few, SCSP DSP had no meaningful info. ######## POST p15185 | Stef | 2012-04-26 | t386-630.html Maybe things changed with time because indeed the SCU DSP documentation was the most undocumented part sometime ago. Hopefully that was not a big deal for emulation as only a bunch of game actually use it (i did some work on SSE emulator but it was quickly discontinued by lack of time and because of the messy internal structure). ######## POST p15352 | neologix | 2012-05-14 | t386-630.html may this topic be stickied? ######## POST p15640 | Mamizou | 2012-05-31 | t386-630.html Just wondering, is anyone else trying to parse through the parts of the chip scan? I've been trying working through them, but my poor computer can't open the full scan without abusing the hard drive. So far I've identified the EG, PG, sine and exponential ROMs, sine/exp. output adder, etc., but actually figuring out the detailed functional parts and what goes specifically where is a lot more difficult, especially at lower resolution. Anyway, I have to say, Nemesis' functional diagrams of the PG and the output section seem to be pretty spot on so far from what I've been seeing. One thing may need to be done is to strip off the metal layer, to expose any hidden vias on the chip. It'll definitely make the chip itself nonfunctional, but the chip's guts will be completely scanned and could allow full vectorizing of the chip (and maybe even eventually a graphical simulation, like the 6502 and 6800 visual sims). ######## POST p15657 | Nemesis | 2012-05-31 | t386-630.html I haven't done any more analysis on it in quite awhile, I found it hard to identify elements from the die shot. It's good to hear you're making more progress. When you're able, maybe you could post an image of some of what you've identified, IE, a basic overlay identifying the main functional areas of the chip. I found it hard just figuring out the basics. I don't think I was even certain where the phase generator and envelope generator circuits were. Stripping off the metal layer sounds interesting, I've seen some other die shots where that's been done, and it certainly seems to reveal more. I couldn't tell exactly from looking at the die shot what parts make up the metal layer. Do you believe doing that alone will be enough to reveal the entire internal structure of the chip? ######## POST p15663 | Mamizou | 2012-06-01 | t386-630.html Here's the chip parts so far . (~500KB) All of the sections in the top-left (not marked with a red box) are the various registers; I haven't yet figured which are which, but I'm going to assume the large and wide part in the middle-left are the main channel registers, and the smaller part in the very top-left are the misc registers (PCM data to Ch.6, LFO control, etc.). I've boxed off some of the other stuff elsewhere but I'm not completely sure what they are yet. Basically, all the light yellow traces are metal (either aluminum or copper, depending on the chip). It's light yellow because the chip has a protective layer of silicon on the very top covering everything (it's also why some things may look wavy, distorted, or unclear). The metal layers may also reveal some of those hidden silicon features, since the metal is deposited over those features, the top of the chip will end up with valleys and hills everywhere. You may see some of those underlying features by the valleys and hills they form on the upper layers (in the big featureless metal areas), but usually they're concealed by the features above. Compare the various images of the 6502's layers here . ######## POST p15664 | Ricky | 2012-06-01 | t386-630.html [QUOTE] Momiji wrote:Here's the chip parts so far . (~500KB) All of the sections in the top-left (not marked with a red box) are the various registers; I haven't yet figured which are which, but I'm going to assume the large and wide part in the middle-left are the main channel registers, and the smaller part in the very top-left are the misc registers (PCM data to Ch.6, LFO control, etc.). I've boxed off some of the other stuff elsewhere but I'm not completely sure what they are yet. Basically, all the light yellow traces are metal (either aluminum or copper, depending on the chip). It's light yellow because the chip has a protective layer of silicon on the very top covering everything (it's also why some things may look wavy, distorted, or unclear). The metal layers may also reveal some of those hidden silicon features, since the metal is deposited over those features, the top of the chip will end up with valleys and hills everywhere. You may see some of those underlying features by the valleys and hills they form on the upper layers (in the big featureless metal areas), but usually they're concealed by the features above. Compare the various images of the 6502's layers here . [/QUOTE] This is so cool. I got a noob question.. How do you know which part does what? How does one go about doing this? ######## POST p15665 | Mamizou | 2012-06-01 | t386-630.html [QUOTE] Ricky wrote:This is so cool. I got a noob question.. How do you know which part does what? How does one go about doing this? [/QUOTE] Mainly by looking at how many bits wide it is. For example, you can see the 10.10 bit wide registers in the PG, the 10 bit registers in the EG, the 14 bit output of the PG leading to the sine ROM, etc. Nemesis' PG-to-output and operator unit diagrams also helped figure out what goes where. ######## POST p16391 | Eke | 2012-07-29 | t386-630.html viewtopic.php?t=386&postdays=0&postorder=asc&start=476 [QUOTE] Nemesis wrote: [QUOTE] Did you ever post the info on LFO / phase modulation ? (I am asking because I might have overlooked something) [/QUOTE] Not yet. Sorry, I've been really short on free time lately, so I've had to dial back on this stuff for a while. If you've got a specific question, I should be able to answer it. In terms of writing up a full description of the LFO, I just don't think I've got the time right now. What I will do is try and briefly describe what's wrong in the MAME implementation of frequency modulation. Actually, I think I'll just cut and paste from my raw testing notes: [QUOTE] -We have confirmed that MAME implements phase modulation incorrectly. Phase modulation is applied to the 11-bit fnum value before it is combined with the block data, or any other operations are carried out using it. This is done using the same process implemented in the MAME core, but without the apparent extra bit of precision which was added, which is also what breaks the precision loss when block data is 0. The incorrect calculations most likely originated from confusion over the sign extension of the phase modulation value when it was in the negative oscillation, which would create an apparent extra bit of precision, even when all significant bits had been discarded. By repeatedly disabling the LFO before it entered into the negative oscillation phase, and carefully measuring and monitoring the output from the YM2612, we were able to observe that frequency modulation values do indeed cut off after the 11th bit, not the phantom 12th bit which MAME creates. [/QUOTE] (Never mind all the "we" references. That means I'm in agreement with myself over what I'm writing. I write all my notes as if I have some kind of multiple personality disorder, that way I can disagree or debate with myself in note form if I'm not entirely convinced of something.) In a nutshell, when the author of frequency modulation in the MAME core was doing hardware tests, he made a mistake in his analysis which made him think frequency modulation had one more bit of precision than it really did. He made this mistake because frequency modulation applies a signed displacement value to the base frequency, and being a signed value, that displacement value is sign-extended. As a result of the sign-extension, the frequency modulation value always has at least one bit of precision, even if all the "real" bits have been lost. This error is the source of this (erroneous) statement in the MAME core: [QUOTE] /* there are 2048 FNUMs that can be generated using FNUM/BLK registers but LFO works with one more bit of a precision so we really need 4096 elements */ [/QUOTE] There is no extra bit of precision with frequency modulation. Frequency modulation is applied directly to the base fnum value, which is an 11-bit number, and this is the very first step in the phase generator, before block data is even applied to fnum. I conducted a whole battery of tests using observable overflow conditions and precision limitations during the phase generator update cycle to prove this is the case, and the current implementation in MAME (and, IIRC, in Kega as well?) is measurably incorrect. The good news is, the correct implementation of frequency modulation simplifies the whole process greatly. The frequency modulation stage just "slots in" at the beginning of the update cycle for the phase modulator, without requiring any changes to the existing pipeline. For MAME, this means all changes which have been made to treat fnum as a 12-bit value should be stripped out. [/QUOTE] I was thinking more about this recently and think I figured where the error in MAME core came from. It's not about the size of the table or added bit of precision for LFO (it's actually taken care of when calculating phase increment from 11-bit FNUM value, see below) but from the fixed point (16.16) precision that was added to make the chip run at other frequencies than the original one (i.e directly at the desired samplerate, without having to resample the output). Indeed, if we take a look at how the phase increment table is calculated: [CODE BLOCK WITHHELD: 89 chars] and how the 17-bit phase increment value is calculated from FNUM and BLOCK values: [CODE BLOCK WITHHELD: 56 chars] we can see that: 1) the value is shifted for non-integer input/output samplerate ratio using 16.16 (FREQ_SH = 16) fixed point precision 2) the 10-bit right shift done by the chip on phase value (remember the size of phase counter is 20-bit, with lower 10-bit being dropped when calcultating the output) is actually "pre-included" in the returned increment value (the phase counter is later shifted by 16-bit instead to keep the needed precision samplerate ratio until then) 3) the BLOCK shifting done by the chip on FNUM value is taken account by returning a value already left-shifted by 6 (FNUM is multiplied by 2 to get an index between 2048-4095 in the table then by 32 out of the table) and then by righ-shifting the value returned by the table by 0-7, depending on BLOCK value. Now, the flaws I potentially see with this design (please someone correct me if I'm wrong): 1) the 10-bit right-shift is done on the increment value instead of being done on the phase counter value itself -> actually, this is not really a problem because of the 6-bit (16-10) shifting added anyway so you don't lose the original 20-bit precision. 2) the added precision (6-bit) actually prevents the lowest FNUM bit to be dropped in case the BLOCK value is 0 -> this indeed actually increase the phase increment precision by one bit, for example if FNUM=0x01 and BLOCK=0, the phase counter will still be incremented on each cycle by (1 * 2 * 32 * (1 << 6)) >> 7 i.e 2048 (in MAME's core 16.16 fixed point precision) on each cycle while it should NOT have been updated. I would appreciate any comment on this as I might indeed have missed something in the implementation. Another unanswered question I have is about how LFO really works, how the phase and envelope modulation values are exactly calculated from PMS/AMS register values then evolving off course, but also how LFO unit works when it's being stopped or restarted. The reason I ask is that an user reported me a sound issue with one track in California Games (the "Surfing event" track) and I kinda figured the problem was that the sound engine was continuously stopping/starting LFO to update each channel parameters and that it resulted in some channel (channel 3 specifically) to sound lower and differently pitched than it should. I was initially resetting LFO modulation counter/values each time it was restarted and somehow got it to sound louder by leaving LFO state untouched when stopped/started but that's still not exactly pitched how it should and also inconsistent (got different result depending on when the track is restarted using the sound test). ######## POST p16431 | Eke | 2012-07-30 | t386-630.html Well, I actually got it to sound correctly (like real hardware or Kega, other emulators don't get it right either) if I somehow invert the LFO AM, doing: [CODE BLOCK WITHHELD: 332 chars] instead of doing [CODE BLOCK WITHHELD: 333 chars] It seems like the AM value is expected to be max (i.e = 126) for this channel operators (it affects volume and tone because both carrier and modulator slots are affected), otherwise it does not sound as it should. An alternate fix is to reset the LFO counter to 64 instead of 0 when LFO is enabled (so it starts with maximum AM value when restarted) I wonder what is the correct behavior [IMG ./images/smilies/icon_rolleyes.gif] ######## POST p16436 | Nemesis | 2012-07-31 | t386-630.html It's been awhile since I've done any work on the YM2612, so I don't know if I can give a definitive answer to your question off the top of my head, but I have this commented section of code in my YM2612 core which may be relevant: [CODE] //Apply amplitude modulation to the output attenuation value if(GetAmplitudeModulationEnabled(channelNo, operatorNo, accessTarget)) { // --------------------------------- // | LFO Counter | // |-------------------------------| // |...| 6 | 5 | 4 | 3 | 2 | 1 | 0 | // ----============================= // | Amplitude Modulation | // | Index (7-bit) | // |---------------------------| // | 6 | 5 | 4 | 3 | 2 | 1 | 0 | // ----------------------------- //Calculate the current attenuation value from the LFO. Note that the amplitude //modulation wave starts off inverted. An index of 0 corresponds with the maximum //attenuation value that amplitude modulation can apply, according to the current //amplitude modulation sensitivity. This is of particular importance when the LFO //is set to the disabled state. In this state, the LFO counter is held at 0, but //since an amplitude modulation index of 0 represents the "peak" of the wave, the //operator will be attenuated by a fixed amount through amplitude modulation while //the LFO counter is being held at 0. bool inverted = (currentLFOCounter & 0x40) == 0; unsigned int amValue = currentLFOCounter & 0x3F; if(inverted) { amValue = ~amValue & 0x3F; } //Adjust the attenuation value by the amplitude modulation sensitivity const unsigned int amShiftValues[4] = {8, 3, 1, 0}; unsigned int amSensitivity = GetAMSData(channelNo, accessTarget); amValue = (amValue << 1) >> amShiftValues[amSensitivity]; //Attenuate the operator output by the current amplitude modulation value attenuation += amValue; } [/CODE] It seems to me you might not be following this, so in your code, maybe an LFO counter value of 0 represents no AM attenuation, when it is in fact supposed to be maximum attenuation? ######## POST p16438 | Eke | 2012-07-31 | t386-630.html Thank you for confirming this ! Yes the initial code was starting with minimal attenuation (AM=0) when LFO counter = 0 and my change indeed inverted it. It's basically a sawtooth that starts from peak (AM = $3f x 2) insteaf of zero level. Not sure about the shifting by 8 though that is also used by the MAME code when AM depth is minimal, since the max value is $7e, a shifting by 7 would be enough. Did you get these values by your own testings or simply used MAME values ? Another interrogation i have is about LFO phase modulation: the manual says it affects BLOCK/FNUM data, does it mean that for high FNUM value (like $3ff), the block bits can be affected by the modulation ? What about keycode (which is later used for detune), can the value be modified if phase increment value high bits got modified by LFO modulation ? Or is always calculated with orihinal FNUM register value ? ######## POST p16459 | Nemesis | 2012-08-02 | t386-630.html [QUOTE] Not sure about the shifting by 8 though that is also used by the MAME code when AM depth is minimal, since the max value is $7e, a shifting by 7 would be enough. Did you get these values by your own testings or simply used MAME values ? [/QUOTE] I've looked back on my notes, and I'm sorry to say I didn't record enough detail to be sure if I confirmed those shift values through my own tests or not. I presume I did, since I tried to do that for everything, but I never fully finished testing the phase modulation implementation to my satisfaction. I have some unanswered questions about the precision and implementation of phase modulation which I eventually plan to go back and find the full answers to through hardware tests. [QUOTE] Another interrogation i have is about LFO phase modulation: the manual says it affects BLOCK/FNUM data, does it mean that for high FNUM value (like $3ff), the block bits can be affected by the modulation ? What about keycode (which is later used for detune), can the value be modified if phase increment value high bits got modified by LFO modulation ? Or is always calculated with orihinal FNUM register value ? [/QUOTE] I think what the manual means is that phase modulation is affected by BLOCK/FNUM, that is to say, that the frequency of the note affects how extreme the phase modulation will be. In reality, I don't think BLOCK data has any effect (at least, I don't recall being able to find any), but FNUM of course affects the phase modulation in the way that has already been described. I don't believe that phase modulation impacts the way any other part of the phase generator operates, such as detune or the normal way BLOCK/FNUM data is used, all it does is to add a small adjustment to FNUM before the BLOCK data is applied. The rest of the phase generator pipeline proceeds as normal. ######## POST p16567 | TmEE co.(TM) | 2012-08-10 | t386-630.html I have been messing around with YMF276 like that : http://www.fileden.com/files/2008/4/21/ ... undMod.jpg That thing is awesome, and really has 16 bit sound output. So smooth and nice : http://www.fileden.com/files/2008/4/21/ ... vs276.flac http://www.fileden.com/files/2008/4/21/ ... oreVs.flac One side is MD2 ASIC, other side is 276 through a DAC you can find in SNES. You can guess which side is which [IMG ./images/smilies/icon_razz.gif] There is one thing about 276 though, the test register $2C has different functions, and few tracks in Shinobi III write garbage to that reg, and cause the chip to go silent (and it is luck it does not happen on 2612/3438). There is no "loud PCM mode" but instead 2 bits that turn off FM in different ways (different as in the bits make different kind of pop sound) and one bit that seems to halt EG, all volumes and states get stuck, key ons do nothing and such. TL changes do work, ADSR seems stuck. Any thoughts ? ######## POST p16574 | Huge | 2012-08-11 | t386-645.html Do any games work with that? ######## POST p16577 | TmEE co.(TM) | 2012-08-11 | t386-645.html All games except few "broken" tracks in Shinobi III that write junk to test register. The cihp is Write-Only in my MD2, so all timer values etc. come from original YM, and because I cannot turn off onboard YM without damaging something. ######## POST p16578 | Huge | 2012-08-11 | t386-645.html So, record some games then! I vote Streets of Rage 2, level 3, 4, 8 and the boss tune. ######## POST p17324 | sigMate | 2012-10-14 | t386-645.html [IMG ./images/smilies/icon_eek.gif] Wait... Shall I understand that, except for the $2C register, the YMF276 is register-map and feature-set compatible with the YM2612 ??? I couldn't find any datasheet for the YMF276, but it sounds really good !!! ######## POST p17325 | TmEE co.(TM) | 2012-10-14 | t386-645.html It is a low power OPN2 chip, OPN2L. Apart from the test register it is compatible and does such a naiss sound ! I got to do some real recordings. ######## POST p17327 | sigMate | 2012-10-14 | t386-645.html Does it operate in 5V or 3.3V ? Where did you got any schematics or pin assignments ? Any doc or so ? Thanks man ! ######## POST p17330 | TmEE co.(TM) | 2012-10-14 | t386-645.html 5V, with power off modes in that test reg (at least so I think). I got wiring info from a Japanese site. The chip was used in the last FM Towns models and possibly some arcade machines. ######## POST p17339 | andlabs | 2012-10-15 | t386-645.html Just out of curiosity, who made the two YM2612 clones HardWareMan mentioned (TA-07 and SE-95) and are they recent chips? Thanks. ######## POST p18698 | TmEE co.(TM) | 2013-02-02 | t386-645.html ^ Chinese [IMG ./images/smilies/icon_razz.gif] I started writing my own FM emulation code, and this thread is really great ! I am right now slowly writing the EG code. There are still a lot of things I don't yet fully understand and looking at Genesis Plus GX and other's FM code has not helped much, the MAME implementation that is quite popular is nearly impossible for me to follow... Also, how are the decapping related things going on ? It has been quite silent around it. ######## POST p18699 | Mamizou | 2013-02-02 | t386-645.html [QUOTE] TmEE co.(TM) wrote:Also, how are the decapping related things going on ? It has been quite silent around it. [/QUOTE] I had to wait for a laptop upgrade before continuing to identify the chip parts and whatnot, my machine was swapping itself to death trying to load the massive die image. I started going over it again though, making some progress on the PG. I guess at some point once I get even more ram in this machine I can try tracing everything out, but HardWareMan will need to fully delayer his OPN2 to get pictures of the underlying layers (like such ). Then maybe eventually we can have a visual6502-style visual simulator. ######## POST p18715 | TmEE co.(TM) | 2013-02-03 | t386-645.html Now time for questions... [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ym2612%20operator.png] Where do the Algos/Connections come in ? I would think I got to store the PG outputs in some way and combine them during each operator updates according to algo setting ? Also, does this mean each operator is output sequentially, so I get 1 value per operator shifted out the sine table to be processed by PG output and then converted to output, then summed up.....? I have EG and PG implemented already. LFO and SSG-EG I'll leave for a bit later time. Any pointers and corrections are greatly appreciated [IMG ./images/smilies/icon_smile.gif] Ginormous thänk you te Nemesis for this awesome information ! ######## POST p18717 | sega16 | 2013-02-03 | t386-645.html [QUOTE] Momiji wrote: I had to wait for a laptop upgrade before continuing to identify the chip parts and whatnot, my machine was swapping itself to death trying to load the massive die image. I started going over it again though, making some progress on the PG [/QUOTE] Are you using windows if so that is your problem not your computer. When I boot my computer into windows 7 already after it finishes starting up it is using over 1gb of ram but on Debian GNU/Linux on start up it takes about 190mb of ram or less and it never uses that swap on my computer but windows 7 uses the swap even when there is a-lot of ram free. ######## POST p18721 | TmEE co.(TM) | 2013-02-04 | t386-645.html When you deal with a program that on its own uses couple of hundred MB of RAM and then use it to process an image that is over several Gbytes in size with its layers, then I am afraid it is not going to be limited to just windows. ######## POST p18722 | Mamizou | 2013-02-04 | t386-645.html [QUOTE] sega16 wrote:Are you using windows if so that is your problem not your computer. When I boot my computer into windows 7 already after it finishes starting up it is using over 1gb of ram but on Debian GNU/Linux on start up it takes about 190mb of ram or less and it never uses that swap on my computer but windows 7 uses the swap even when there is a-lot of ram free. [/QUOTE] I'm on a 64-bit Gentoo Linux setup. I previously only had a C2D w\ 4GB RAM, now I have an i7 with 6GB. The image itself is only ~1GB but it adds up when you add layers to the image (which is necessary for tracing stuff without modifying the original image). Right now I was able to crop out a separate image of just the PG at original resolution, and it fully fits within my RAM without swapping. Also having faster graphics hardware helps, since GIMP offloads some processing to it now (I believe Photoshop does as well). [QUOTE] TmEE co.(TM) wrote: Where do the Algos/Connections come in ? [/QUOTE] If you look at my first chip image , that happens in the Sine + EG Adder, just above the Sine and Exponential ROMs. While the major details of that image are probably still correct, I'd take the smaller details with a grain of salt as I figure things out deeper. [QUOTE] TmEE co.(TM) wrote:Ginormous thänk you te Nemesis for this awesome information ! [/QUOTE] I second that! Your information helped me make sense of quite a lot on the chip (and I've learned quite a bit about chip layout and FM audio synthesis [IMG ./images/smilies/icon_biggrin.gif]). ######## POST p18723 | TmEE co.(TM) | 2013-02-04 | t386-645.html I read more about the subject and it is all starting to come together. It happening in the Sine+EG adder makes sense. The output from PG multiplication calculator is 20 bit, lower 10 bits are dropped and the data exits the PG and enters "Operator Unit". I now see a 10 bit modulation input. That must be input from the output Operator unit, but that output is 14 bits. Now my next question : Are the lower 4 bits dropped of the 14bit output or something else happens ? What about algos that got 2 operator outputs go into one operator ? Are those 2 outputs just summed together and fed into the next Op or there is more to it ? EDIT: seems just summed together. 2 ops at one modulation level sounds same as 1 op at twice modulation level. Also, the sine ROM is exponentiated so they could just use an adder and no multiplier unit... How is the PG freq multiplication with MUL parameter handled ? A real multiplier unit ...? Sequential adder would take many cycles before it can give out a proper output... EDIT: When operators are all summed together (like in case of Algo7) the output is clamped to 14bits range ? ######## POST p18725 | Mamizou | 2013-02-04 | t386-660.html [QUOTE] TmEE co.(TM) wrote:Are the lower 4 bits dropped of the 14bit output or something else happens ? [/QUOTE] Yeah, they're just dropped. If you look where I have the truncation labelled, you'll see 14 bits coming out of the Sine+EG adder, but 4 of those traces just end. It's too bad they couldn't add a serial output pin so you could just serialize that 14-bit data and send it to an external DAC like other OPN series chips, although you wouldn't get the PCM data. And I guess you'd just use an OPNA or OPM anyway. [QUOTE] TmEE co.(TM) wrote:Also, the sine ROM is exponentiated so they could just use an adder and no multiplier unit... How is the PG freq multiplication with MUL parameter handled ? [/QUOTE] MUL is still handled in the PG. I haven't figured out the techniques for that yet. ######## POST p18734 | TmEE co.(TM) | 2013-02-06 | t386-660.html I report that my FM core is modulating, PG and OP work great ! My EG is still not quite right, the attack part behaves wrong but I am getting it fixed up soon ! Then I will add LFO and SSG-EG... latter will ruin my pretty code haha ######## POST p18736 | GManiac | 2013-02-06 | t386-660.html Here's my very old and abandoned YM emu in Delphi, if you are interested, with some comments in Russian. http://shedevr.org.ru/ghost/ym2612/YM_Emu.rar What is not implemented: SSG-EG, special 3ch mode. ######## POST p18738 | TmEE co.(TM) | 2013-02-06 | t386-660.html Your algos are implemented in a very close way to mine hehe ######## POST p18777 | Nemesis | 2013-02-09 | t386-660.html I'll actually be finally releasing my emulator soon. I'm currently targeting the end of March for the first release. I'm going to be releasing the sourcecode very soon afterwards. I built the YM2612 core in my emulator while I was doing these tests, and each aspect of its implementation was tested in hardware, so the sourcecode for it should be a good reference for anyone trying to build a YM2612 core in the future. There are a lot of comments in there clearly stating what's been backed up by hardware tests, and why particular areas are implemented in certain ways. ######## POST p18784 | neologix | 2013-02-09 | t386-660.html [QUOTE] Nemesis wrote:I built the YM2612 core in my emulator while I was doing these tests, and each aspect of its implementation was tested in hardware, so the sourcecode for it should be a good reference for anyone trying to build a YM2612 core in the future. [/QUOTE] AWESOME SAUCE. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p18801 | TmEE co.(TM) | 2013-02-10 | t386-660.html My envelopes look perfect now, real chip progresses same way and Kega Fusion too. I also had operator order problem but I fixed that hoping it also fixes the modulation problem I had but that did not happen. Unmodulated outputs are perfect though. I take the final 14 bit output of an operator, shift it right 4 places and add to other operator's 10bit phase output value. I tried several bit positions but that really did not help make right sound... Maybe I am missing something simple ...? ######## POST p18814 | GManiac | 2013-02-11 | t386-660.html 14-bit operator output sums with other operators's output, if it is present (algos 1-3), then their sum shifts RIGHT for ONE bit and this value is added to input phase of modulated operator. No exceptions. For feedback fb1 and fb2 are summed, then value shifted for various amount of bits, it depends on feedback depth. Yes, there are really two feedback registers, I made it sure by special tests. ######## POST p18817 | andlabs | 2013-02-11 | t386-660.html Here's my question. I am trying to write a concurrent emulator (rather than a sequential one like existing emulators) that tries to mimic the chip operation on some level. I'm confused as to how the EG is supposed to work if it runs at 1/3 the clock rate of the rest of the chip, since each operator is updated on each clock cycle, not every 3 clock cycles. Is there some value caching going on? Thanks. http://github.com/andlabs/ym2612 is the code I have so far btw; I never bothered to ask if I could use Nemesis's algorithms so I guess I'll ask now =P I only put this up because I thought I was going to change OSs and didn't want to lose anything, but didn't at the time ######## POST p18818 | TmEE co.(TM) | 2013-02-12 | t386-660.html YM chip IS sequential for the most part. The EG has an output and it is used 3 times by other parts while it is not updated. Updates happen every 3 cycles. ######## POST p18820 | andlabs | 2013-02-12 | t386-660.html Right, sequential isn't exactlyt he right word, but componentized/concurrent rather than singlethreaded and linear? Whatever it may be I'm trying to imitate the chip as much as possible given the limited knowledge I have (how do you read a die shot?) So let me get this straight: there are 24 outputs (one for each operator) and the operator unit just picks the appropriate one for the current channel? ######## POST p18822 | TmEE co.(TM) | 2013-02-12 | t386-660.html These 24 outputs are also the "accumulators" of all envelope calculations. ######## POST p18823 | andlabs | 2013-02-12 | t386-660.html Ok. So in that case (and this may have been answered already but just to be sure), are all EG outputs updated at once on the three-cycle mark, or does it update each operator EG in a three cycle loop? Or to put it in code terms, is the EG unit loop [CODE BLOCK WITHHELD: 199 chars] or [CODE BLOCK WITHHELD: 280 chars] Thanks. ######## POST p18836 | TmEE co.(TM) | 2013-02-13 | t386-660.html I wait for 3 cycles to pass (or for a special SSG-EG condition) and then update all operators and channels at once. I don't think the chip behaves any different, it makes no sense to have a counter for each channel separately, the effect of that would be inaudible. I found one new problem in my FM core - I was adjusting feedback and then I saw that my sawtooth looked like this : [CODE BLOCK WITHHELD: 39 chars] instead of this : [CODE BLOCK WITHHELD: 39 chars] Bottom halves of my waveform are horizontally flipped. I never saw it as sines are all really symmetrical [IMG ./images/smilies/icon_razz.gif] Fixing this problem should fix all my modulation related issues. EDIT : I forgot to add sign to the modulation value [IMG ./images/smilies/icon_redface.gif] ######## POST p18838 | GManiac | 2013-02-13 | t386-660.html Somewhere was an opinion that envelopes of different channels of one block (block = 3 channels) are updated in different cycles of 3-cycle phase. I think it's true because update requires time. I mean: Global cycle 1: channels 1 and 4 updated Global cycle 2: channels 2 and 5 updated Global cycle 3: channels 3 and 6 updated Global cycle 4: channels 1 and 4 updated ... Also note that global EG counter max value is 4095, not 4096, so full EG "cycle" lasts 12285 internal cycles. ######## POST p18861 | TmEE co.(TM) | 2013-02-15 | t386-675.html I have made some good progress and comparing my output with real chip and I am getting correct EG updates and envelope shapes and lengths, and operators 4 to 7 produce correct spectrum ! I have been having some difficulties with Algo3. I get correct output when I have all but first op enabled, whet I have that in play the spectra goes completely wrong... but I will investigate it more tomorrow, it is very early in the morning here hehe EDIT: When I have Op1 > Op2 all is fine, but when I got Op1 > Op2 > Op3 then the spectrum goes all wrong compared to real chip... (Op1 + Op2) > Op3 works out perfectly though, spectrum is much like real chip and of course sounds like so too... ######## POST p18884 | neologix | 2013-02-16 | t386-675.html Do you clip or otherwise limit the output in any way before you feed to Op3? ######## POST p18903 | TmEE co.(TM) | 2013-02-18 | t386-675.html Only thing I do is shift the 14bit output right 1 time and then add to 10bit output of PG. This I am not too sure of being right. And I now identified a problem in my EG, my attacks last a lot less that they should. I still have to find out if they reach max too soon or something else... 10 bit EG output + 10 bits of TL I clamp to 10 bits, changing it makes everything go completely wrong so I believe this part is right. EDIT : My SL level was not handled right, so far 3 ops work perfectly and produce correct spectrum. 4 ops should work too, I'll test in a moment [IMG ./images/smilies/icon_biggrin.gif] ...and 4ops work correctly too, producing correct spectrum ! ......I can start adding LFO and SSG-EG now. ######## POST p19059 | andlabs | 2013-03-03 | t386-675.html I guess I could just update everything at once for now, though knowing how the hardware times updates would be best, and in retrospect GManiac's suggestion makes the most sense =P Also, are the various EG register values sent to the EG on every cycle and then stored, or on every EG cycle and used immediately? And how wide is the globalCycleCounter, 11 bits? (I think this might have been answered elsewhere in this thread; I don't remember right now... it's been a while =P ) Thanks. ######## POST p19163 | Mamizou | 2013-03-15 | t386-675.html So after struggling with Gimp like crazy for most of the day yesterday, I started tracing out the components on my sliced up version of the OPN2 chip die shot. I started with the DAC because the layers there were the clearest. A lot of it is still unclear, and I don't think it'll get better unless the metal layers are also removed. Anyway, take a look at my progress: https://www.dropbox.com/s/kbsocon4v6v14 ... g-wip2.png (Higher resolution available too, if requested) Color legend Blue: Metal Green: Diffusion Red: Polysilicon Cyan: Analog voltage supply (A VCC) Orange: Analog ground (A GND) ######## POST p19743 | Eke | 2013-05-18 | t386-675.html [QUOTE] HardWareMan wrote:You totally right! Analog value matrix is 8x32 (256 levels). 9th bit is a sign. Sign bit conect DAC matrix to AVCC or AGND via Source/Sink power switches. That is why between two samples on MOL/MOR are 1/2 of AVCC. Thus, 8bit DAC pulls up to the AVCC or pulls down to the AGND which depends on 9th sign bit. Whoah. [/QUOTE] Looking a bit more into this, I was wondering: the way sign bit is handled means that the DAC voltage references are basically inverted when sign bit is set (V+ is GND and V- is Vcc) and so resistor array analog output is simply inverted (ideally, 0 1111 1111 would output 255Vcc/256 and therefore 1 1111 111 would be -255Vcc/256), right ? However, since the 9-bit input value is a two's complement binary (-256 = 1 0000 0000, -255 = 1 0000 0001, ..., -1 = 1 1111 1111), an offset therefore needs to be applied on the analog outputs when sign bit is set. "ideal" offsets would be: [CODE BLOCK WITHHELD: 232 chars] I have no idea how this could be implemented (reusing the existing resistor array ?), sign bit seems to do more than basic voltage source switching (it goes to a complex control unit below the 5-to-32 line decoder) but I think that the bug on negative values (what you call "ladder effect" ?) is directly related to this conversion and offsets calculation. There might be additional imprecision which affects both positive and negative values because of non-ideal resistors. Does that make sense ? maybe it is known stuff and only pointing the obvious without really explaining it but I figured it would be worth mentioning. ######## POST p19744 | HardWareMan | 2013-05-18 | t386-675.html Look at DIE shot, where source multiplexer. Sign bit goes to output piece of schematic each other bits and seems to somehow affect to it. Maybe it just makes the necessary inversion of the other bits of data. ######## POST p19769 | Aly James | 2013-05-21 | t386-675.html Regarding the "ladder effect emulation" Something that might help on my last post on this page.. [IMG ./images/smilies/icon_smile.gif] viewtopic.php?t=1402&start=21 ######## POST p19771 | TechnoZealot | 2013-05-21 | t386-675.html That .wav sample you gave sounded like something that used to happen occasionally when I would use the Tone function on my Arduino with a speaker I have, and that was just outputting a raw, digital square wave with PWM. It seems like there's some sort of an output logic reversal going on, but I might be completely incorrect. ######## POST p19907 | Aly James | 2013-05-31 | t386-675.html About the LADDER effect... As previously stated in the FMDrive Vst thread, a simple way to implement the ladder effect is to add the clean output with the following... (same behavior is observed on the hardware when you mute a channel, you still ear the distorted part at lower volume..) This will produce an almost similar signal, spectrum and sound wise. WAV recordings: Megadrive PAL model 1 recording FMDrive MD1 mode recording and for the sake of comparison here is a clean signal from a YM2164 (from a FB01 unit) We will do something when the output is negative... -------------------------------------------------------------------------------------- Ladder output: -Let's consider the pure clean sine wave signal is going from max +1 to -1 as "sineout" -Make a condition: If sineout goes down past -0.009 then output a negative voltage almost 50 times lower then the clean maximum signal. Else output 0.0 (and this will also prevent audio clicks) Now let's see what happens to the "Ladder output"... As you can see on the graphic, as the amplitude of the sine goes much lower, the period where the condition is true will also reduce..and this is what we clearly ear at the end. green is our "Ladder output". [IMG http://www.alyjameslab.com/tutorials/YM2612LADDER.jpg] Note that you will also need to filter a bit (lp filter) the ladder output before adding to the clean signal. Code snippet from FMDrive.. If you make any use of this, credit would be nice [IMG ./images/smilies/icon_wink.gif] [CODE BLOCK WITHHELD: 526 chars] Here you can see a very fast decay envelope that kind of shows the process [IMG ./images/smilies/icon_smile.gif] [IMG http://www.alyjameslab.com/tutorials/YM2612_Ladder_waveform.png] ######## POST p21109 | trap15 | 2013-09-28 | t386-675.html I know this was asked earlier, but the answer wasn't exactly clear. I've been working on a YM2203 emulator (yes, not quite a YM2612, but most everything else here has been extremely helpful and accurate, so I have no reason to believe that this is different), and I've run into an interesting concern. If I update the EG counter on every "output cycle", the EG is too fast. Here's what that update process looks like: Cycle 0: Update output latch, increment EG counter, Update Op0 of Chan0 Cycles 1-3: Update Op[2,1,3] of Chan0 Cycles 4-7: Update Op[0,2,1,3] of Chan1 Cycles 8-11: Update Op[0,2,1,3] of Chan2 Now, if I modify my code to update the EG every 3 "output cycles", the EG seems to be updating at the proper rate. Here's what that looks like: Cycle 0: Update output latch, increment EG counter, Update Op0 of Chan0 Cycles 1-3: Update Op[2,1,3] of Chan0 Cycles 4-7: Update Op[0,2,1,3] of Chan1 Cycles 8-11: Update Op[0,2,1,3] of Chan2 Cycle 12: Update output latch, Update Op0 of Chan0 Cycles 13-15: Update Op[2,1,3] of Chan0 Cycles 16-19: Update Op[0,2,1,3] of Chan1 Cycles 20-23: Update Op[0,2,1,3] of Chan2 Cycle 24: Update output latch, Update Op0 of Chan0 Cycles 25-27: Update Op[2,1,3] of Chan0 Cycles 28-31: Update Op[0,2,1,3] of Chan1 Cycles 32-35: Update Op[0,2,1,3] of Chan2 Considering that this works and sounds correct, I'm willing to bet it's the correct (or at least similar to the correct) functionality. However, I'm not quite sure how or why, and I doubt the accuracy of it as well. I'd really appreciate any insight or information for this. A little side question as well, and not nearly as important, is what order the updates occur in. As in, is the output latch updated on cycle 0, or cycle 11? Is the EG counter updated on cycle 0, or cycle 11 (or 35 or whatever)? ######## POST p21132 | Aly James | 2013-10-01 | t386-675.html IIRC EG updates every 3 FM update cycles.. ######## POST p21338 | Mamizou | 2013-11-03 | t386-675.html Just a heads up, someone at siliconpr0n.org decapsulated a YM3438 and did high-res scans of the metal layer. It's definitely a different layout than the YM2612, although the typical YM chip functional blocks are still recognizable. Looks like the EG was shifted to being 'below' the ROMs instead of off to the opposite side of the PG (assuming 'top' is to the left on the scan, so it's comparable to the YM2612 scan). Probably so there's less trace distance between those functional blocks. The DAC is still in the 'upper-right' (upper-left of the scan). ######## POST p21339 | TmEE co.(TM) | 2013-11-03 | t386-675.html That is awesome ! It looks quite a bit different from 2612. I have been adding SSG-EG to my YM core, that is going somewhat well. I'll likely have questions about it later on. LFO info never really appeared here, so, will it appear here ? ######## POST p21355 | Nemesis | 2013-11-03 | t386-675.html I just don't have time to write up info on it right now, and I've probably forgotten half of it anyway, but I'm working towards the source release of my emulator Exodus, which has my heavily commented YM2612 core in it, so you'll be able to refer to that soon as a working reference model. I wrote that core in tandem with my testing and findings, verifying the output to the chip on many points, including the LFO. That said, I think there were one or two questions I had remaining about the LFO I never got back to testing. If so, those questions should appear as comments in my source marked with //##TODO## or //##FIX##. ######## POST p21357 | TmEE co.(TM) | 2013-11-04 | t386-690.html OK, I shall wait for that time then. It is very hard for me to get any info from the existing implementations, they are written is totally different way than I have done with like 3x more code... (2K vs ~600 lines) ######## POST p24774 | HardWareMan | 2014-10-25 | t386-690.html New osc - new pictures. [IMG http://savepic.org/6325557.png] [IMG http://savepic.org/6330677.png] [IMG http://savepic.org/6331701.png] [IMG http://savepic.org/6328629.png] [IMG http://savepic.org/6318389.png] Yellow - phones left Cyan - phones right Magenta - YM2612 output That's what I'm talking about from beginning. You can clearly see how filtering works. Battletech, music 12 (that sound): [IMG http://savepic.org/6355272.png] [IMG http://savepic.org/6353224.png] [IMG http://savepic.org/6342984.png] [IMG http://savepic.org/6344008.png] [IMG http://savepic.org/6321482.png] [IMG http://savepic.org/6310218.png] [IMG http://savepic.org/6311242.png] [IMG http://savepic.org/6308170.png] ######## POST p24776 | MintyTheCat | 2014-10-25 | t386-690.html A question: What are the RIGOL Scopes like? I had some reservations personally but are they any good? Which Scope are you using? ######## POST p24783 | HardWareMan | 2014-10-26 | t386-690.html [QUOTE] MintyTheCat wrote:A question: What are the RIGOL Scopes like? I had some reservations personally but are they any good? Which Scope are you using? [/QUOTE] Previously, I used this one: http://www.rigol.com/prodserv/DS1000E/ Now I use this one: DS1074Z-S http://www.rigol.com/prodserv/DS1000Z/ ######## POST p24784 | MintyTheCat | 2014-10-26 | t386-690.html [QUOTE] HardWareMan wrote: [QUOTE] MintyTheCat wrote:A question: What are the RIGOL Scopes like? I had some reservations personally but are they any good? Which Scope are you using? [/QUOTE] Previously, I used this one: http://www.rigol.com/prodserv/DS1000E/ Now I use this one: DS1074Z-S http://www.rigol.com/prodserv/DS1000Z/ [/QUOTE] Thanks for the information. ######## POST p25362 | Mamizou | 2014-12-19 | t386-690.html Hi again; I just noticed that a couple more things were posted to siliconpr0n. The YM2203 and YM2413 . I definitely see a lot of the same func. blocks in the YM2203 compared to the YM2612, but they're laid out in a weird way (PG on the opposite side as the sine/exponential roms?). In the lower-right is the SSG unit (compare to the functional blocks on the AY-3-8910 ). The three units on the far-right lined up with the pads are the DACs for each SSG channel. Also to note, the DAC-SS used with the YM2203. ######## POST p25392 | Stef | 2014-12-22 | t386-690.html I don't know if this has been already verified but i can confirm that the BUSY bit of the YM2612 can be read only on port 0 and not from any port as we can read in many documentations. I just fixed a small issue in my XGM driver which was caused by that (trying to read busy bit on port 1) ######## POST p25400 | Nemesis | 2014-12-26 | t386-690.html I had no idea about that Stef, thanks for sharing that information! I really want to go back to the YM2612 at some point and confirm the timing of the busy flag. No emulators emulate access delays to the YM2612 ports right now, Exodus included. ######## POST p25406 | Stef | 2014-12-26 | t386-690.html When i started to wrote the driver i read somewhere that 4 or 5 NOP from Z80 between 2 YM writes is enough to ensure you won't miss any of them so i initially designed the driver with these values in mind. Unfortunately it's much more than that. From my observations, the busy cycle after writing port 0 or port 2 is quite short (28 Z80 cycles is enough) but it can much longer after a write to port 1 or 3, it can take up to 75/80 Z80 cycles ! I think some registers has longer busy cycle than other but i can't confirm that, at least i can say the "Key on/off" register requires more than 60 cycles for instance. ######## POST p25408 | HardWareMan | 2014-12-27 | t386-690.html Internal state synchronization before update? ######## POST p25409 | sigMate | 2014-12-27 | t386-690.html Would be very interesting to know how many cycles are needed for each type of register changes. I guess there'd be no other option than polling the state of the BUSY flag while counting cycles, right ? ######## POST p25412 | neologix | 2014-12-27 | t386-690.html [QUOTE] sigMate wrote:Would be very interesting to know how many cycles are needed for each type of register changes. I guess there'd be no other option than polling the state of the BUSY flag while counting cycles, right ? [/QUOTE] If I have to start counting cycles, then if byuu's higan and Nemesis's Exodus are any indication the JavaScript YM2612 will end up running at 1FPS if I want to keep it as accurate as possible. Any way we can avoid cycle counting on emulation but still keep it accurate? I'm already having enough trouble as it is keeping FM AND PCM generation steady without stutter (and boy-howdy there's stutter). ######## POST p25443 | Eke | 2015-01-02 | t386-690.html [QUOTE] neologix wrote: If I have to start counting cycles, then if byuu's higan and Nemesis's Exodus are any indication the JavaScript YM2612 will end up running at 1FPS if I want to keep it as accurate as possible. Any way we can avoid cycle counting on emulation but still keep it accurate? I'm already having enough trouble as it is keeping FM AND PCM generation steady without stutter (and boy-howdy there's stutter). [/QUOTE] Emulating the BUSY flag would not necessarely be CPU intensive, counting cycles would just be updating a "ready" cycle counter each time a write is done to YM2612 registers and checking against that cycle counter when a read is made to return flag status. You could even easily use that "ready" cycle counter to ignore writes done while the chip is still supposely busy, which would partially emulates the internal busy behavior ( I think there was one test ROM with very fast PCM writes that would sound wrong on emultors because of that). The most difficult is actually to figure the busy cycle counts for each registers: the numbers given in official manuals seem indeed a bit off (at least for data registers) and, as said already, differ depending on the register ( I suspect registers affecting all channels have different timing than registers affecting a specific channel, same for registers affecting a specific operator). Current granularity in Genesis Plus GX core is at the "sample" level (all 6 channels mixed together in one sample) and the emulated ym2612 is resynchronized with emulated CPU every time the latter attempts to write or read the chip: this is what slowdowns most of emulation since you have to render a various number of samples many times per frame (instead of just only one time at the end of frame). Synchronizing at lower level (internal chip cycle, operator cycle or channel cycle) would indeed but a bit more costly since it multiplies the number of times you have to update the emulated chip but I doubt you would be able to really tell the difference in sound output(after resampling, etc). The internal timings below channel level are also still undocumented so it would need to be figured somehow. ######## POST p26964 | Sauraen | 2015-09-19 | t386-690.html Hi everyone, this is Sauraen from the MIDIbox forums . I'm the one who made MIDIbox FM V2.1 /V2.0 , and the 32-bit OPL3 driver for MIOS32 (the MIDIbox operating system). I'm now working on MIDIbox Quad Genesis , a similar synth with four YM2612s and four SN76489/SN76494/SN76496es. But that is a topic for another thread... In planning the synth engine I did research on the YM2612, found this thread, and devoured it--I really love this kind of detailed analysis work. Thanks especially to Nemesis for all the stunning detail and thorough explanations, and also HardWareMan for the invaluable die shots. I'm currently taking a course on VLSI, so I started trying to read the die... and I got excited when I started to discover new things, never before known! Let me report my findings so far. Memory Map / Test Registers This is the complete memory map of the chip-level control registers of the YM2612. I can confirm that all the bits listed here are present and connect to other things in the chip (affect its state in some way). I can further confirm that no other "undocumented" registers exist at the chip level (have not confirmed this for channel or operator registers yet though). First, all these control registers are only accessible from bank 0 (A1 = 0, $4000, or whatever you want to call it). (For curiosity's sake, I will mention that this is not a global design decision--each register individually is specified as having that address bit at zero, it would have been less chip area if they allowed the registers to be accessible from both banks. However an inverted bank line is not run, they would have had to add a wire to the I/O bus internally if they wanted to have some control registers only in bank 1.) (Key: - no bit, X bit present) [CODE] 20|-------- 21|XXXXXXXX (LSI Test Register) 22|----XXXX (LFO Register) 23|-------- 24|XXXXXXXX (Timer A MSBs) 25|------XX (Timer A LSBs) 26|XXXXXXXX (Timer B) 27|XXXXXXXX (Ch3 mode, timer controls) 28|XXXX-XXX (Key-ons) 29|-------- 2A|XXXXXXXX (Ch6 DAC data) 2B|X------- (Ch6 DAC enable) 2C|XXXXX--- (Test Register 2) 2D|-------- 2E|-------- 2F|-------- [/CODE] That's right, the LSI Test Register indeed has all 8 bits, and the test register at $2C ("DAC Test Register") has bits 7:3! As far as I know this is new information, previously it was thought that the LSI Test Register only had bits 7:2 and the DAC Test Register only had bit 5. Here is what I have figured out so far about where the wires from the bits in the two test registers go. References to testing are other people's testing I've seen here or elsewhere, I have not done any hardware testing yet. 21:D7 Goes to parallel data output unit. From testing, selects MSB or LSB of output. *** Actual output data unknown (probably channel accumulator to DAC, unknown how it selects which channel). (*** EDIT: output data is described a few posts down) 21:D6 Goes to parallel data output unit, and status flags output unit. From testing, 0 is read status flags, 1 is read parallel data output. 21:D5 Goes to EG control unit. From testing, 1 disables EG clock. 21:D4 Goes to MSB of channel accumulator unit (probably sign bit). From testing, “inverts output” (changes sign bit without changing other bits?) 21:D3 Goes to PG control unit. From testing, 1 disables PG clock. 21:D2 Goes to timer unit. From testing, 1 makes timers run off FM clock (24x faster) instead of sample clock. 21:D1 Goes to unknown control unit (large block above PG). 21:D0 Goes to parallel data output unit. Function unknown—maybe selects which channel to read output of? All of the bits from the control register 2C go to *** a small circuit which I think has to do with reading the data value specifically off the I/O bus. My guess is this circuit has to do with synchronization to which operator is being processed. The only possible exception is bit 6, which goes through that same circuit, but unless I'm reading it wrong comes back out and goes down to the EG. (***EDIT: This paragraph is incorrect, they are in that area but don't affect the data bits at all. They're five separate test signals that go to various units in the chip, see a few posts after this.) Some notes about chip architecture Note: I will state these things as certain (rather than saying "probably" everywhere), but I am happy to be proven wrong. This is a screenshot from my drawings on the die: [IMG http://i.imgur.com/lbLtEJs.jpg] The unit on the left is the synchronizer for the input data bus--it takes in the 8-bit input pins' values and the current A1 bit, and outputs normal (green) and inverted (red) copies of the signals. They go through the bus you see, with the units in the middle being the timers and probably the LFO. The table on the right is probably for address decoding, I have yet to confirm this. The magenta lines are positive and negative latch enables for each of the registers. They come from a vertical unit (decoder) that has connections (vias) to eight address/data lines, and then the vertical units next to them are each connected to one bit from the bus (latches for those bits in the register). Thus, the purple lines define registers. Further, which lines are being sampled for the decoder tells what the address is. (I left gaps in the buses where there are vias, so they can be seen.) For instance, the top-left register, reading from bottom to top, connects to Green Green Red Green Green Red Green Green, which translates to 00100100 or 0x24 (with the final green wire at the top meaning this is bank 0). Thus this is the decoder for register 0x24, and the latches connected by purple wires are the bits for that register. All of them are used (albeit in the order 75106432, though that is probably because of other layout considerations). Reading registers this way, on the top bus are registers 24, 25, 27, 2B, 2A, and a final unit connected to that table (more on this later). On the bottom bus again from left to right are registers 21, 28, 26, 22, 2C, and a final unit with all 8 bits. I've labeled the two test registers and where their wires go to--you can see for yourself that all the bits I mentioned above are functional. Now for that last unit on each side. My guess is the one at the top, which connects to the table, is where the chip reads off the address for all the channel/operator registers; and the bottom one is where the data is read off. The interesting part is that the top one is based on a register of similar form to the other ones, and it's gated by a decoder whose value would be 0000XXXX (the four dots in the four green lines). But since obviously the chip doesn't respond only to address writes $00-0F, my guess is this decoder's output is inverted--that is, the register will only latch the address if the address is not 0000XXXX. Why would they ever put this in? Because if the chip had an AY-3-8910 core in it, this is a perfect way to ensure the two didn't interfere! Isn't this an interesting holdover? The other thing to mention is that the unit on the bottom, which probably reads the data byte off the bus into the main interconnect, is connected to a number of bits from test register $2C. Here's why I think this is important. When I first saw the description of register $2C , I immediately thought that bit 5 must simply cause the DAC value to be output on all 6 channels' cycles, instead of only on the cycle of channel 6. This would explain why it got louder and why all channels' LR bits affected it, while no other registers did. The next thing I noticed along this train of thought is that there are not nearly enough wires in the YM2612. Take a look at the big register array in the middle (probably operator parameters, but not important right now). There's a decent number of wires going in and out the top and bottom, but ZERO going in or out the left and right. Compare this to the DAC or the sine/exponential tables, where there are wires (decoders in the latter cases) on both sides of the tables. This led me to conclude that the register arrays in this chip are not RAM, but SHIFT REGISTERS! The chip doesn't address one channel or one operator and read/write parameters and values from/to it, it scrolls through all the sets of parameters for all the channels or operators, and processes whichever one is currently at the end, writing back the result to the other end of the array! This explains the chaotic behavior of the BUSY signal. Other than the chip global registers that I talked about before, when it's told to write a register it has to wait for that value to come around in the sequence before it can modify it. I don't think it stops its processing and scrolls the register file to the right place, I think it just waits until that operator/channel would be processed, and then writes the value and clears the BUSY flag. (EDIT: turns out this is true, but the BUSY flag is just a timer, not actually related to when the data is stored into the shift registers.) This means that critical elements like these test bits probably work very differently to how we think. My guess is that the bits in register $2C don't have anything to do with the Ch6 DAC in particular, but control how the chip progresses through the channels and operators, possibly stopping, resetting, or forcing that counter to a particular value. (EDIT: not true, they're just other test bits) I also suspect that the bits in $21 that "pause" the PG or EG--which I previously thought simply stopped the clock to that module--actually just prevent writes of the recalculated phase or attenuation value back to the list. Finally, one last thing. Steve Snake has said there are two operator units running in parallel. There aren't. I am not questioning that his implementation produces a sample-accurate result, it probably does and I haven't tested; but there aren't two operator units on the die. (The operator unit is the two lookup tables, the register array above that, and the control unit above and below the register array, all on the right side.) My guess is that the chip's use of previous values for certain operators has to do with it pipelining calculation of one operator across two steps, so the one before is not done when the next one needs the value. (EDIT: this is true, see later) Conclusion From this long post, it looks like I'm following in Nemesis's footsteps! Other than that, the only thing to say is that probably we still won't be able to figure out exact logic from the die shots. (EDIT: using the YM2203 die shot as well, I can figure out exact logic in most cases.) I can't even figure out on the Test pin which of the three wires is the pin direction signal and which is the output value (the input is clear). (EDIT: figured this out) So some of this will have to be good old hardware testing. I'm in the process of building a prototype of the MIDIbox Genesis module that I've designed, and once I get notes out of it I will of course start messing with the test bits. [IMG ./images/smilies/icon_smile.gif] ######## POST p26966 | Sik | 2015-09-20 | t386-690.html [QUOTE] Sauraen wrote:But since obviously the chip doesn't respond only to address writes $00-0F, my guess is this decoder's output is inverted--that is, the register will only latch the address if the address is not 0000XXXX. Why would they ever put this in? Because if the chip had an AY-3-8910 core in it, this is a perfect way to ensure the two didn't interfere! Isn't this an interesting holdover? [/QUOTE] Note that the YM2608 uses that register range (and $10-$1F as well). The YM2612 is pretty much the YM2608 with a lot of features removed (and the DAC slapped in). ######## POST p26974 | HardWareMan | 2015-09-21 | t386-705.html [QUOTE] Sauraen wrote:Thanks especially to Nemesis for all the stunning detail and thorough explanations, and also HardWareMan for the invaluable die shots. I'm currently taking a course on VLSI, so I started trying to read the die... and I got excited when I started to discover new things, never before known! [/QUOTE] Soon I'll provide die shots of YM2612 with more quality and even with polysilicon separation. And I want to decap VDP, arbiter and IO. [IMG ./images/smilies/icon_wink.gif] I need more time for this. ######## POST p26977 | Stef | 2015-09-21 | t386-705.html Thanks Sauraen for the precious and detailed informations ! The internal organization in shift register explain indeed the volatile BUSY time. I guess it will be complicated to find a good formula to calculate a perfect timing. Anyway because of this unpredictable aspect almost sound driver always pool the busy flag because writing the YM registers. ######## POST p26978 | Eke | 2015-09-21 | t386-705.html @Sauraen: Thanks a lot for your contribution, it's always interesting to have people knowledgable about circuit design taking a loot at those de shots. Do you think it's possible to figure what happen with the 14-bit operator output, where algorithm connections are made to produce the final channel output, then the conversion to 9-bit DAC input ? I am still wondering if the YM2612 "ladder effect" could take place during the 14-bit -> 9-bit conversion or if there is nothing special with it and it is just something done wrong within the DAC array of resistors. ######## POST p26980 | HardWareMan | 2015-09-21 | t386-705.html [QUOTE] Eke wrote:Do you think it's possible to figure what happen with the 14-bit operator output, where algorithm connections are made to produce the final channel output, then the conversion to 9-bit DAC input ? I am still wondering if the YM2612 "ladder effect" could take place during the 14-bit -> 9-bit conversion or if there is nothing special with it and it is just something done wrong within the DAC array of resistors. [/QUOTE] Do you remember this picture? [IMG http://savepic.ru/7837847.jpg] I think I got how it works: [IMG http://savepic.ru/7821463.png] The "sign" bit push resistor chain to AVcc or pull it to GND. The matrix of switches connect to right step of R-chain acording to X-Y code (8 bit code). And there is also 1/2 AVcc generator by 2 resistors. The on/off schematic connect analog output to 1/2AVcc or Ux. That what I thought. But it turned out that there is additional resistance. I don't know why, maybe as current protection fuse if source/sink switches opened simultaneously, but it obviously affected to Ux possibly making some unbalancing between positive and negative part of DAC values. ######## POST p26981 | Eke | 2015-09-21 | t386-705.html [QUOTE] HardWareMan wrote: [QUOTE] Eke wrote:Do you think it's possible to figure what happen with the 14-bit operator output, where algorithm connections are made to produce the final channel output, then the conversion to 9-bit DAC input ? I am still wondering if the YM2612 "ladder effect" could take place during the 14-bit -> 9-bit conversion or if there is nothing special with it and it is just something done wrong within the DAC array of resistors. [/QUOTE] Do you remember this picture? [IMG http://savepic.ru/7837847.jpg] I think I got how it works: [IMG http://savepic.ru/7821463.png] The "sign" bit push resistor chain to AVcc or pull it to GND. The matrix of switches connect to right step of R-chain acording to X-Y code (8 bit code). And there is also 1/2 AVcc generator by 2 resistors. The on/off schematic connect analog output to 1/2AVcc or Ux. That what I thought. But it turned out that there is additional resistance. I don't know why, maybe as current protection fuse if source/sink switches opened simultaneously, but it obviously affected to Ux possibly making some unbalancing between positive and negative part of DAC values. [/QUOTE] Yes, I remember, it 's a good explanation of how the 9-bit DAC works. Problem is that the "effect" afaik does not affect all negative values, only "small" ones. Hence why I thought it could have something to do with how 14-bit output is converted to 9-bit DAC input (as it is likely not something as simple as just dropping the 5 lowest bits but a little bit more evolved). I could not determine in the picture where this conversion takes place though. The way I see it : if it was a problem within the DAC R-ladder, it would affect positive and negative values equally since the sign bit is handled separately as you figured. And if it was something related to the analog reference used for negative values, this would affect all negative values equally too. I may be wrong though, I'm really not much knowledgeable in analog electronic. ######## POST p26985 | Sauraen | 2015-09-21 | t386-705.html [QUOTE] Sik wrote:Note that the YM2608 uses that register range (and $10-$1F as well). The YM2612 is pretty much the YM2608 with a lot of features removed (and the DAC slapped in). [/QUOTE] I started working on the die shot of the YM2203, since it's clearer and easier to read than the one of the YM2612. I'm not quite done with the register analysis, but that same decoder in this chip is wired as ~(000-----), that is any address other than $00 or $10. So the YM2612 must have been made based on the assumption that something else might be at $00, but not at $10. Edit: Finished the registers in the YM2203, these are the only addresses present in the FM register set: [CODE] AD|76543210 --+-------- 21|XX-XXXX- (Test Register) 24|XXXXXXXX (Timer A MSBs) 25|------XX (Timer A LSBs) 26|XXXXXXXX (Timer B) 27|XXXXXXXX (Flags and Ch3 mode) 28|XXXX--XX (Key Ons) 2D|[address decoder, but no data bits] 2E|[address decoder, but no data bits] 2F|[address decoder, but no data bits] [/CODE] [QUOTE] HardWareMan wrote:Soon I'll provide die shots of YM2612 with more quality and even with polysilicon separation. [/QUOTE] That would be great, thanks! If we get versions that are as clear as the YM2203, and better yet a version without the aluminum layer as well, we might be able to start reading individual logic circuits. Even on the YM2203 I can figure out what some of the circuits are at the gate level, but there's still a lot of "components" I don't understand yet (not being far enough in the course on VLSI). [QUOTE] Stef wrote:Thanks Sauraen for the precious and detailed informations ! [/QUOTE] [QUOTE] Eke wrote:@Sauraen: Thanks a lot for your contribution, it's always interesting to have people knowledgable about circuit design taking a loot at those de shots. [/QUOTE] My pleasure! [QUOTE] Stef wrote:I guess it will be complicated to find a good formula to calculate a perfect timing. Anyway because of this unpredictable aspect almost sound driver always pool the busy flag because writing the YM registers. [/QUOTE] It depends on what timing resolution the chip is being emulated at. It should just be that whenever the chip is in the cycle in which it outputs the channel sound whose register was written, the BUSY flag is cleared. One other thing to mention, this may be incorrect so take it with a grain of salt--but it looks to me like the BUSY flag should not affect writes to the chip-level registers. That is, if you write to $52 and it goes BUSY, you should be able to write to $2A (DAC data) and it will accept that data even though it is still busy with $52. But if you write to $62 it will drop that write if it's still busy. Can someone with some Z80 ASM skillz test this on hardware? [QUOTE] Eke wrote:Do you think it's possible to figure what happen with the 14-bit operator output, where algorithm connections are made to produce the final channel output, then the conversion to 9-bit DAC input ? I am still wondering if the YM2612 "ladder effect" could take place during the 14-bit -> 9-bit conversion or if there is nothing special with it and it is just something done wrong within the DAC array of resistors. [/QUOTE] I will take a look. Still trying to understand and confirm a lot of things at the higher level. My intuition is that the logic is 100% correct, and it's an analog effect. My guess--again, just a guess--is that the "ladder effect" is this. Using a resistive voltage divider to make voltages like this will always be imprecise. And especially if for signals above half, the voltage is being pulled down in some way from AVCC, and below half it is being pulled up from AGND, there's no guarantee that these will meet in the middle, with the same voltage step between the adjacent points on both halves as between all the points within each half. Worse, this step won't be constant--it'll depend on the analog characteristics of what's going on with the chip at that time, including what previous values the DAC has been outputting and therefore what currents have been flowing where. Something to try for someone with the aforementioned Z80 ASM skillz as well as a nice scope (plus a thorough knowledge of the YM2612 to be able to get it to do this): Get the DAC to output values close to AVCC (255) for a long time (1 second or so), then get it to output values 4, 3, 2, 1, 0, -1, -2, -3, -4 (that is, the values immediately around the halfway point switching halves). Check the relative sizes of those steps. Then do the same thing but start from a very low value (-256 for a long time, then -4, -3, -2, -1, 0, 1, 2, 3, 4). Then also just output a triangle or sine wave near zero (4, 3, 2, 1, 0, -1, -2, -3, -4, -3, -2, -1, 0, 1, 2, 3, 4) and see what the steps are like. I'll bet that the steps at zero will be different in each case. Of course this has to be sampling at the analog output pin, not after the filtering circuitry. I should be able to do some of these tests myself in the coming weeks on my sound chip board for the Genesis synthesizer, if nobody gets to them first. But for now my main focus is on the test registers--I want to actually use them in the synthesizer. ######## POST p26987 | Sauraen | 2015-09-22 | t386-705.html More info! [IMG http://i.imgur.com/yt0p3IV.jpg] [IMG http://i.imgur.com/J5lfNGM.jpg] This is, as I had expected, the address decoder table of the YM2612. Note that bits 0, 1, and A1 from the bus (they're in order 0-7 then A1) go directly to the control unit on the left; bits 2 and 3 go to the control unit as well as the table; and bits 4-7 go to the table. At the top of the table there are 6 inputs (2-7); each of those goes down through the polysilicon wire, goes through an inverter at the bottom (marked in cyan in one case), and comes back up as the next column wire to the left. Thus 12 of the 14 columns are bits 2-7 of the address. The rightmost two lines are not simple inverted copies of each other; they come from the control unit, and are (probably) enable signals for the channel registers and the operator registers respectively. Here's how to read the table contents. Yellow wires are the aluminum layer; green is polysilicon; brown with black lines around it is diffusion. In this table the green polysilicon column wires are the inputs, and the 13 yellow aluminum wires are the outputs. Each of the output wires has a pull-up resistor to Vdd (the structure on the left of each one in the table); on the right side is an inverter (buffer), and the output. So any output wire that gets pulled down in the table anywhere will be a zero, and if it is never pulled down it's a 1 because of the resistor. The critical element is the interaction between the green polysilicon and the diffusion. As you can see, some places it looks like the diffusion is cut out around the polysilicon. At those places, the two conductors (semiconductors) form a diode (it would be anode=diffusion, cathode=polysilicon column wire). In addition, wherever there is one of these, there's a via from the aluminum to the diffusion (can be shared by two diodes on opposite sides of the via). The way this works is that if there's no column wire that's at 0 that has a diode to the row wire, the row wire is 1 (this is the active state). If any of the column wires is wrong, its diode will pull down the row wire and make it zero. Of course you don't know whether the incoming column wires were inverted or not, or which state is active on the outputs; but basically I just put red dots on each diode, and then knowing what the column wires represented I wrote those in binary, and I happened to get the polarity doubly wrong (hence correct). The results are labeled next to the output row wires. This proves that there are no undocumented channel or operator registers (though there still could be undocumented bits in existing registers, though probably they would have been discovered by now since everyone is always writing to those registers). I suspect that the control unit to the left of the table is the sequencer that keeps track of which operator/channel is at the end of the shift registers, and it sends the two enable signals (right two column wires) appropriately to time the write when the correct item is up. ######## POST p26996 | Sauraen | 2015-09-26 | t386-705.html Okay, I got Test Register $2C! $2C:7 - Selects whether the TEST pin is an output or input. (Presumably 0 = output, 1 = input, since power-up state is output.) $2C:6 - Goes to the same unit as the TEST pin's input wire, which is a small control unit at the upper right of the EG. I will try to figure out whether this unit actually has to do with the EG or not. (It's also worth mentioning that it looks like BUSY is permanently wired to the TEST pin output--you can't switch it to output some other signal on this pin.) $2C:5 - Goes to a few places (probably some sort of control) around the DAC output register block. (By others' testing, causes the Ch6 DAC output value to be used in place of all channels except Ch5, or something like this.) $2C:4 - Goes to the control unit for the accumulator-to-DAC parallel output (which can be read from the data bus). Same control unit as $21:7, $21:6, and $21:0 go to. $2C:3 - Ch6 DAC ninth (least significant) bit. Yup, I remember reading about this in this thread, someone theorized this bit's existence, and here it is! It goes into the ninth bit of the DAC output register block, in an exactly corresponding place as where the eight signals from $2A go into the first eight bits. Even better, since it doesn't look like BUSY affects the chip-global registers ($2X) at all, you should be able to write the eight MSBs into $2A and write the LSB into $2C:3 as soon as the Z80 will let you. As long as you get them both in before the YM2612 gets around to the Ch6 cycle again, you should be able to get full-precision 9-bit output without missing samples. ######## POST p27002 | HardWareMan | 2015-09-27 | t386-705.html [QUOTE] Sauraen wrote:[*]$2C:3 - Ch6 DAC ninth (least significant) bit. Yup, I remember reading about this in this thread, someone theorized this bit's existence, and here it is! It goes into the ninth bit of the DAC output register block, in an exactly corresponding place as where the eight signals from $2A go into the first eight bits. Even better, since it doesn't look like BUSY affects the chip-global registers ($2X) at all, you should be able to write the eight MSBs into $2A and write the LSB into $2C:3 as soon as the Z80 will let you. As long as you get them both in before the YM2612 gets around to the Ch6 cycle again, you should be able to get full-precision 9-bit output without missing samples.[/list] [/QUOTE] It's was me, lol. ######## POST p27032 | Sauraen | 2015-09-29 | t386-705.html Two things to mention. First I figured out the unit which allows the Z80 to read data from the YM2612: [IMG http://i.imgur.com/QvnRFS9.jpg] The unit which outputs the BUSY signal and the two timer overflow flags is elsewhere and not pictured, though there's nothing more to it. (EDIT: it also contains the logic, just an AND, which produces the IRQ output from the two overflow signals.) The red horizontal bus here is the 8-bit output bus. Orange are control signals from the Test registers (with their bits labeled). Blue on the left is the external address/control bus (A1, A0, /CS, etc.) Blue in the middle is the 14-bit output from the current operator (actually comes from the bottom of the operator register block, I only bothered finishing the leftmost 5 wires, but the remaining 9 do go down to the corresponding place). Green is the output of the operator accumulator register unit, actually from the top of that unit right by where the output goes to the DAC. The unit right in the middle (16+ wide) is where values are gated onto the 8-bit data bus. There's a MSB and an LSB, fortunately in the picture it's in order, bits 15 downto 0. Whether the MSB or LSB is read is selected by $21:7 (polarity unknown, but based on the following information, it should be very easy to figure out with some testing). In addition, whether the green wires or the blue wires are being read is selected by $2C:4. (From others' work with the test registers and reading data, I'm assuming that 0 means read 9-bit channel output and 1 means read 14-bit operator output.) As you can see, the top five bits of the green wires are connected together and pulled-up or pulled-down (can't quite tell which). Bit 14 (cyan wire) comes from a unit on the left which has two cyan wires feeding it, and $21:0 as another input signal. I assume this means that the value of bit 14 is one of those bits if $21:0 = 0 and the other if $21:0 = 1. Both cyan wires come from the top of the EG; one comes from near the end of a 10-bit structure (possibly overflow or sign?), and the other comes from a complex logic unit I haven't looked at yet. Bit 15 (light blue wire) comes from the very lower right corner of the PG, seemingly a signal that would otherwise be continued to the next block (probably carry/overflow bit). It's a pity these things weren't known about earlier--they're Test registers for a reason, they allowed Yamaha to confirm the internal functionality of their chip... and they could also allow us to confirm it. [IMG ./images/smilies/icon_smile.gif] Since we can read the output of each operator individually from the chip using this, we can implement the same thing in an emulator and compare the two at bit accuracy. One more thing to mention from this information. Only the top 9 bits of the operator output are passed to the channel accumulator unit. As you can see the remainder go to the read-output unit, but they don't continue to the unit above. There's no other data bus wires going to that unit. So I think it's pretty clear that the full 14-bit operator output value is used (and stored) for modulation, but it's reduced to 9 bits before being added to other operators' values that are being sent to the audio output. (This obviously effects the sound in a very minor way, if two operators had their lower bits high they won't add and carry over into low bits of the 9 bit output.) Second I'm working on the operator unit, and I'll just say that things aren't quite as Nemesis and everyone else described. I don't have enough information yet to comment on the accuracy of the results, but at the very least things aren't implemented in hardware quite that way. For instance, the sine table is actually 7 -> 19 bit and the exponential table is 7 -> 13 bit, but in both cases several output bits are later gated by the input LSB, so the result of each table plus the logic near them is actually 8 -> 11 bit for the sine table and 8 -> 10 bit for the exponential table. The 11-bit output of the sine table is added to the 10-bit EG attenuation value, but it looks like it adds it to the upper 10 bits, not just 10+10 bits = 11 bits with a carry. In any case, the four top bits of the resulting value go to a small unit and become eight bits which go to the lower part of the operator register unit; the remaining 7 bits address the exponential table, which with its associated logic produces a 10-bit output for the LSBs of the operator register unit. (I know I said 8 bits before; it looks like the gating bit for the exponential table outputs, as well as one of the inputs to the table, come from the same column--don't know what's up with that.) ######## POST p27060 | Sauraen | 2015-10-01 | t386-705.html I've been bashing my head against the operator unit for the last couple days, and here's some results. Some of these things were figured out from the YM2203 die, just because it's easier to read; but I've been confirming critical elements against the YM2612. 1. The YM2612 uses dynamic memory (DRAM) throughout. This means it can't operate below a minimum clock frequency, because data is stored as charge on small capacitors, and it slowly leaks out. My guess is that the chip would start losing stability at about 1/4 to 1/10 its rated clock speed, but this is not confirmed. 2. The operator unit, and probably the whole chip, makes heavy use of pipelining. In the operator unit I've counted five pipeline registers, plus the circular shift register array which probably counts as a sixth one: a) At the adder between the 10-bit FM value and the 10-bit PG value b) At the adder between the 11-bit logsin output and the 10-bit attenuation value c) At the 10-bit mantissa value, immediately before the exponent shifter d) At the two's compliment unit (this is where the output is taken from) e) Circular shift register array (stores outputs of previously computed operators) f) At the unit which adds two previously-computed operator values to make the new FM value This has two direct results: a) Figuring out the timing of any control unit will be a pain in the ass. b) Exactly what bits go where is easier to see. For instance, bit 9 of the FM+PG value goes through two sequential shift register cells before going to the two's compliment unit, which is correct--it has to be delayed with the data in registers b and c above. Also, the top four bits of the 12-bit logsin+attenuation value, which don't go through the exponential table, each go through a single shift register cell before they go to a decoder and then the shifter unit; they have to be delayed to match the rest of the data waiting in register c. c) Anyone who's trying to implement this chip in VHDL will have massive timing/complexity issues unless they get this right. [IMG ./images/smilies/icon_razz.gif] 3. The chip--or at least the operator unit--doesn't process all four operators of one channel, then go to the next channel. It processes one operator from each channel before it goes to the next operator. I don't have enough information to tell the order, that is whether it processes operator 1 from all six channels in a row, or different operators on each channel--but definitely each next clock cycle (this is the main internal clock, which is the external clock divided by 6) a different channel is being processed, and only after they're all done is the first channel processed again. I don't know how this affects the outputting, but the channel accumulator unit definitely has at least six stages of circular shift registers, so there's no reason it can't add up the right operators from the right channels and spit them out at its leisure. 4. The circular shift register array which stores the outputs of previous operators has three entries. Based on Steve Snake's info, I think I understand exactly how they work--but the timing is kind of insane. The three entries store op 2, op "old 1", and op 1. Remember, 6 cycles between an operator being started and it finishing: 0) Op 1's FM value is fed into the pipeline from stored "old 1" and stored 1. Op 2 just finishing, sent to accumulator and stored as 2. 3) Op 3's FM value is fed into the pipeline from stored 1 and stored 2. Op 4 just finishing, sent to accumulator. 6) Op 2's FM value is fed into the pipeline from new Op 1 result, which is also stored as 1 and sent to the accumulator. The old value from "stored 1" is stored as "old 1". 9) Op 4's FM value is fed into the pipeline from new Op 3 result (which is also sent to the accumulator), Op 1 stored, and Op 2 stored. Of course the accumulator doesn't always accept the values sent to it, and neither does the adder which produces the new FM value (it only has two inputs, but those could be hooked up to stored op 2, stored op 1, stored old 1, or new result). Edit: After I posted this I remembered that all this was from the YM2203, which has only three channels. So on the YM2612 the cycles indicated should be 0, 6, 12, and 18. And then I remembered that the YM2612 has a six-stage shift register added to the pipeline between the calculated 10-bit FM value and adding that to the 10-bit phase value. They purposely lengthened the pipeline by 6 cycles so each operator takes 12 cycles now to compute, so all the timing stays in sync (but with 6 voices instead of 3)! Other than that, I believe it's exactly the same in both chips. One more thing to add, it's a pity Yamaha didn't give us more detailed control over the chip. Just by modifying the control units (and adding some more externally-visible registers), we could have had programmable FM algorithms, and we could have also had independent modulation depths for each voice. The shifter unit that implements the "feedback amount" is in the datapath for all operators, but it's just set to a constant for all but op 1. ######## POST p27062 | mikejmoffitt | 2015-10-01 | t386-705.html I played with clocking the YM2612 with a function generator. At a VERY low frequency it seemed to lose its internal state, and it may have been around 1/4. The use of DRAM would explain that. Naturally a high speed clock caused issues as well, though it went remarkably high before issues appeared. ######## POST p27069 | Sauraen | 2015-10-01 | t386-705.html [QUOTE] mikejmoffitt wrote:I played with clocking the YM2612 with a function generator. At a VERY low frequency it seemed to lose its internal state, and it may have been around 1/4. The use of DRAM would explain that. Naturally a high speed clock caused issues as well, though it went remarkably high before issues appeared. [/QUOTE] If you wanna have some fun, clock it at just above the minimum frequency that it works, and then introduce noise into the supply rails. Hopefully you'll get it to start glitching out. This should not damage the chip (assuming the peaks of the supply noise are not above +5V), though you do so at your own risk. [IMG ./images/smilies/icon_smile.gif] ######## POST p27081 | TmEE co.(TM) | 2015-10-02 | t386-705.html I have ran the YM at 500KHz (only DAC worked then lol) and at around 16MHz (it got hot but still worked right). This is some excellent infor you're digging up here [IMG ./images/smilies/icon_biggrin.gif] ######## POST p27098 | Sauraen | 2015-10-03 | t386-705.html I'm writing a VHDL equivalent description of the operator unit. This is the only way to express in detail how it works, other than the die shot itself. I drew out some diagrams and these are the final results. There's no concept of a complete cycle for updating a channel, but if such a concept is artificially introduced, the four operators use the following values for their modulation in "Cycle 1": Op 1: Op 1 Cycle 0, Op 1 Cycle -1 Op 2: Op 1 Cycle 1 Op 3: Op 1 Cycle 0, Op 2 Cycle 0 Op 4: Op 1 Cycle 1, Op 2 Cycle 0, Op 3 Cycle 1 There is at least one algorithm in each case that uses each of these sources, though usually most are unusued (i.e. there's no algorithm where ops 1, 2, and 3 all modulate 4). This can also be replicated simply by processing the operators in the order 3, 1, 4, 2, and in every case using the most recent output of the needed operator. (So that when you process op 3, you're using the results of ops 1 and 2 from the previous cycle; and when you process op 4, you're using the most recent 1 and 3 but old 2.) To be clear, the operator numbering I'm using is such that in Algorithm 0 (chain of operators), they are in the order 1-2-3-4. The "two operator units in parallel" claim that Steve Snake made--that the chip processes operators 1 and 3 at the same time, then it processes 2 and 4 at the same time--is functionally correct, in so far as it produces the same relationships between operators, though it's not strictly how the chip behaves. ######## POST p27104 | Stef | 2015-10-03 | t386-720.html Definitely very precious informations you're revealing here Sauraen !! The 9th bit of the DAC which is actually present in the test register, wonderful finding [IMG ./images/smilies/icon_smile.gif] Something i'm really wondering, you said it would be pretty difficult to predict the behavior of the BUSY flag, but from what i understood it seems that only registers linked to OPN / FM states requires sort of processing time. Does it mean that writing to port 0 and port 2 (register index value) can be done at any time ? or at least that we can immediately write to port 1 or port 3 just after writing them ? if i do something as : [CODE BLOCK WITHHELD: 114 chars] Does it should always work ?