######## POST p5485 | Nemesis | 2008-06-06 | t386-000.html As anyone who's tried to emulate it will know, there's a significant lack of solid information on the YM2612. The only official reference we have comes from 14 pages in the Genesis Sound Software Manual ( http://nemesis.hacking-cult.org/MegaDri ... Manual.pdf ), and they're a little light on the details. There are some manuals out there for other Yamaha FM chipsets, but the problem is there are a LOT of different "lines" of FM chips that Yamaha released, such as the OPL, OPN, OPM, OPZ, etc. The YM2612 is an OPN chip, and all the documents which are publicly available are for chips from entirely different lines. Thanks to Malfunction from http://www.soundshock.se , we've now got something which could fill this gap. Here's a link to an official document from Yamaha describing the YM2608: http://nemesis.hacking-cult.org/MegaDri ... M2608J.PDF This is the first time this document has been publicly posted on the internet. This isn't just a datasheet, it's a complete Programming/Technical Reference Manual, weighing in at 67 pages. It's full of hard numbers, tables, and equations. There is a catch however: The manual is in Japanese. I wouldn't hold out for an official version in English. There's a good chance this document was never fully translated from Japanese, even by Yamaha. We've got the information now though. The language barrier can be solved with time and the help of the right people. The language issue aside, as you'll note, this document is for the YM2608 not the YM2612. This leads to the question, what are the differences between the YM2608 and the YM2612? I've been doing a fair bit of research on this, and the news is good. Here's a list of the all the known Yamaha OPN chips: -YM2203 (OPN) -YM2608 (OPNA) -YM2610 (OPNB) -YM2612 (OPN2) -YM3438 (OPN2C) (CMOS implementation of the YM2612. Functionally identical) -YMF288 (OPN3) As you can see, both the YM2612 (OPN2) and YM2608 (OPNA) are part of this line. More significantly, after comparing information about all these OPN chips, and particularly after looking through this new manual, it seems that the YM2608 is the direct and immediate ancestor of the YM2612. More than that, the YM2612 seems to just be a "stripped down" version of the YM2608. The documentation for the YM2608 may in fact be better than an official YM2612 reference, as it contains a description of all the features they removed, while still containing all the information on the features provided by the YM2612. The YM2608 came in a 64-pin package, and required a separate DAC (YM3016) in order to actually produce an analog sound output. The goal of the YM2612 seems to have been to provide a lower cost single-chip solution for systems which didn't require all the features of the YM2608. It seems the parts to get the chop were external I/O Ports, a Rhythm generator with internal ROM samples, a full ADPCM module, and the SSG module (well, most of it anyway [IMG ./images/smilies/icon_smile.gif]). Apart from the addition of DAC registers at 0x2A/0x2B to provide some basic PCM without the ADPCM module, everything in the YM2612 seems to be unchanged from the YM2608 implementation, meaning the YM2608 manual above should be extremely relevant. I was sent a number of other documents along with this one. There's a datasheet and some info on the YM3016 DAC, the ADPCM module in the YM2608, a short document on the YMF288, and a full manual on the "86 Sound Board" for the PC-9801-86, which uses a YM2608. One tidbit the 86 Sound Board manual seems to have which I didn't see in the doc from Yamaha is timing information on the busy flag in the status register. Here's the full archive I got sent: http://nemesis.hacking-cult.org/MegaDri ... YM2608.ZIP Hopefully some of you will find this info useful. I know I will. ...So, anyone read Japanese? [IMG ./images/smilies/icon_biggrin.gif] EDIT: Here's a transcribed and translated version using an online translator: http://nemesis.hacking-cult.org/MegaDri ... slated.PDF ######## POST p5486 | TmEE co.(TM) | 2008-06-06 | t386-000.html This is incredible [IMG ./images/smilies/icon_biggrin.gif] And now I've got another reason to learn Japanese [IMG ./images/smilies/icon_smile.gif] I hope this gets translated someday, I somehow feel it contains all the answers to the issues I've encountered while writing my sound engine (and I think Steve Snake knows a lot, since he's emulator does emulate ALL the quirks I've encountered 1:1 to real HW). ######## POST p5488 | Oerg866 | 2008-06-06 | t386-000.html I think that's not quite correct, if you check out the ending sound of MicroMachine96's SuperSonic intro screen, that is totally messed. ######## POST p5490 | TmEE co.(TM) | 2008-06-06 | t386-000.html Gimme a link... so far, all has been 1:1 to my audio-modded MD2 sound. ######## POST p5495 | Nemesis | 2008-06-07 | t386-000.html One interesting thing to note about this document is the numbering of the operators. In the Genesis document, we know they've got operators 2 and 3 switched somewhere, either in the register map or in the operator connection charts. Generally, we switch operators 2 and 3 in the connection charts to fix the problem. It's interesting to note from this document however, that the operator numbering in the chart is correct. According to this document, it's the register order numbers which are switched. [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/operators.png] [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/operator%20registers.png] Notice that the register order is S1, S3, S2, S4. Of course, the two numbering systems are functionally equivalent, it's just interesting to note the "official" order numbers they use. ######## POST p5496 | 1magus | 2008-06-07 | t386-000.html People have problems emulating this or writing games while using it? ######## POST p5497 | AamirM | 2008-06-07 | t386-000.html Hi, Thanks a lot Nemesis! You just made my day. I can try to get some of my japanese friends to translate it. I've been trying to get some sound problems in my core fixed without any success but I guess this will help me. This is a huge find. Thanks again. stay safe, AamirM ######## POST p5498 | Stef | 2008-06-07 | t386-000.html Of course i don't read japanese but from schems i don't see anything news compared to the sega manual. Maybe japanese comments are importants though [IMG ./images/smilies/icon_wink.gif] ######## POST p5499 | Nemesis | 2008-06-07 | t386-000.html There's quite a bit of stuff in there which isn't covered in the Sega documentation, like self-feedback, conversion to real frequencies, the actual way sounds are generated and operators are combined, etc. And of course there's lots of misc stuff like SSG-EG and the test register which aren't included in the Sega documentation. Just have a close look at pages 15 and 16. I really wish I could read those pages. ######## POST p5500 | Eke | 2008-06-07 | t386-000.html yes, but doesn't every chip differ in term of frequencies value, internal conversion tables, etc... I think I've seen the YM2413 and YM2149 programmer manuals somewhere with lot of value tables but they can not be used for the YM2612 for example About the SSG, the interesting part is that it uses the same register location and envellope shape is pretty well explained, but this does not mean that YM2612 has SSG working the same way, same thing about CHM mode, why didn't they even mentionned these features in the YM2612 "short" manual if it was working ? probably because it was only partially working and "broken" in some way... anyway, this is really exciting news, big thanks to everyone who participated in releasing it, I'm definitely waiting for a translation PS: about operator combination, I don't think there is something new or different from the way it is actually emulated, we already discussed about that somewhere on this board and this is only a matter of naming convention (M1,C1,M2,C2 or OP1, OP3, OP2, Op4 or S1, S2, S3, S4) ######## POST p5504 | Nemesis | 2008-06-07 | t386-000.html [QUOTE] yes, but doesn't every chip differ in term of frequencies value, internal conversion tables, etc... I think I've seen the YM2413 and YM2149 programmer manuals somewhere with lot of value tables but they can not be used for the YM2612 for example [/QUOTE] That's the reason this manual is so significant: The FM process seems to be identical between the two chips. As I said, the YM2612 is a "stripped down" version of the YM2608. They cut out extra self-contained modules like ADPCM and simplified its external connections, but it seems they left the FM module untouched. The YM2612 is little more than the YM2608 FM module in a different box. By all means, prove me wrong, but I've looked into this enough now to be convinced of this point, and nothing I've seen in the documentation so far suggests otherwise. [QUOTE] About the SSG, the interesting part is that it uses the same register location and envellope shape is pretty well explained, but this does not mean that YM2612 has SSG working the same way, same thing about CHM mode, why didn't they even mentionned these features in the YM2612 "short" manual if it was working ? probably because it was only partially working and "broken" in some way... [/QUOTE] There could be a number of reasons for this. The Genesis sound manual is written by Sega, not Yamaha. The Genesis sound manual is based on the Japanese "Mega Drive" sound manual. The Japanese sound manual was written based on the information Yamaha provided to Sega. You've got three organizations involved there, plus the language barrier, plus the fact that we know that Sega of America and Sega of Japan had very poor communication with each other. All we know is what is written in the Genesis sound manual, which is this: [QUOTE] SSG-EG - A proprietary register whose usage is unknown. It should be set to zero. [/QUOTE] That seems to say to me quite clearly that the people writing this manual simply didn't know what it was for. I'd say that information either wasn't passed on from SOJ to SOA, or it wasn't passed on from Yamaha to SOJ in the first place. This idea of SSG-EG being "buggy" in the YM2612 seems unfounded to me. I don't know where that rumor came from, but I've certainly never seen a case presented, or even a case mentioned, where SSG-EG has been seen to play up. It's quite possible they were officially "unsupported" features of the chip (IE, they were only included because it wasn't worth removing them), but in terms of being buggy, I'm not convinced of that at all. [QUOTE] PS: about operator combination, I don't think there is something new or different from the way it is actually emulated, we already discussed about that somewhere on this board and this is only a matter of naming convention (M1,C1,M2,C2 or OP1, OP3, OP2, Op4 or S1, S2, S3, S4) [/QUOTE] Yes, it really doesn't make a difference what they're called or how they're numbered. I just find it interesting to know how they designated them. I like to use the "official" names and designations for things where possible. ######## POST p5505 | Shiru | 2008-06-07 | t386-000.html [QUOTE] Eke wrote:I think I've seen the YM2413 and YM2149 programmer manuals somewhere with lot of value tables but they can not be used for the YM2612 for example [/QUOTE] YM2413 is a OPLL, cut-down and very limited version of OPL1. It's different family, so of course information about this chip can't be used for YM2612. YM2149 is a slightly enhanced clone of AY-3-8910, it's not FM synth. It's quite simple and very well documented PSG chip. YM2203 has it as addition to FM part. FM part of OPN family chips is compatible in general (at least between YM2203, YM2610, YM2612), so documentation for any of chips of this family can be useful. ######## POST p5509 | AamirM | 2008-06-07 | t386-000.html Hi, Shiru is right. You can't use YM2413 info for YM2612 as it is different. I hope this manual contains those little details that I am looking for. First of all SSG-EG sounds different on all emulators so there is something that needs to be corrected here. Secondly there is the CSM key control which nobody seems to have a clue about. Thirdly I recently discovered (by listening to real hardware recordings and emulated sound) that in 3 slot mode, channel 6's envelope generator seems to speed up. I maybe wrong but this fixes sound in some games. BTW, I was told that Dune's soundtrack called 'Ammons Advice' doesn't sound correct in Kega either. Can't confirm it though. stay safe, AamirM ######## POST p5511 | Nemesis | 2008-06-08 | t386-000.html Well, there's a section in this manual about CSM on page 36. Here's what OCR + web-based Japanese to English translator has to say: [CODE] 2-8-4 Setting of mode of CH3 Channel 3 can set the mode by $27 “D7,D6". Table 2-1C CH3 mode ------------------------------------------------------------------------ |D7|D6|Mode | Ki E | |--|--|------------|---------------------------------------------------| | 0| 0|Normality |It pronounces normally as well as other CH. | |--|--|------------|---------------------------------------------------| | 0| 1|CSM |It becomes CSM voice synthesis mode, and F-Number | | | | |can be set each every of the four slots. Key-on/off| | | | |at the CSM mode is done with timer A. | |--|--|------------|---------------------------------------------------| | 1| 0|Effect sound|Separate F-Number can be set to each slot as well | | 1| 0| |as CSM. | ------------------------------------------------------------------------ [/CODE] That last row is probably suppost to be for bit patterns 10 and 11, but I've written it exactly as it appears in the document. ######## POST p5512 | Nemesis | 2008-06-08 | t386-000.html Hah, here's something I didn't know about the envelope generator: [QUOTE] *The shape of waves of the envelope changes in exponential when attacking it, and it changes in the straight line at other rates. [/QUOTE] Does anyone emulate this correctly? ######## POST p5516 | AamirM | 2008-06-08 | t386-015.html Hi, No. At least not in Regen. But I think the current linear approximation is good enough. stay safe, AamirM ######## POST p5524 | Stef | 2008-06-08 | t386-015.html [QUOTE] AamirM wrote:Hi, No. At least not in Regen. But I think the current linear approximation is good enough. stay safe, AamirM [/QUOTE] Correctly emulated in Gens as far i remember. ######## POST p5527 | AamirM | 2008-06-09 | t386-015.html Hi, Nice. I'll have a look at that. With what exponential relation does it rise? Do you have a formula? stay safe, AamirM ######## POST p5532 | Eke | 2008-06-09 | t386-015.html I'm curious, what is the SSG part mapped in registers 00-0Fh (which does not exist on YM2612). Otherwise, for keeping some record of it, I tried to list some of the new informations that we don't have in the first doc and that might applied to Ym2612 also: .Key OFF/ON register and operator assignation: [IMG http://gxdev.wordpress.com/files/2008/06/fm_1.gif] .Feedback values: [IMG http://gxdev.wordpress.com/files/2008/06/fm_5.gif] .SSG-EG register: [IMG http://gxdev.wordpress.com/files/2008/06/fm_2.gif] I imagine this could be quickly tested in a modified emu ? .Timer exact periods: [IMG http://gxdev.wordpress.com/files/2008/06/fm_3.gif] This confirms what we were initially thinking, internal clock is VCLK/144 and timerA period is half the internal period. We retrieve this value in FNUM calculation: [IMG http://gxdev.wordpress.com/files/2008/06/fm_6.gif] . CH3 special mode and "illegal" CSM mode: [IMG http://gxdev.wordpress.com/files/2008/06/fm_4.gif] we need some translation for this one [IMG ./images/smilies/icon_wink.gif] ######## POST p5534 | Stef | 2008-06-09 | t386-015.html [QUOTE] AamirM wrote:Hi, Nice. I'll have a look at that. With what exponential relation does it rise? Do you have a formula? stay safe, AamirM [/QUOTE] Enveloppe is defined in the "ENV_TAB", first part is for attack and i defined it as follow : [CODE] for(i = 0; i < ENV_LENGHT; i++) { // Attack curve (x^8 - music level 2 Vectorman 2) x = pow(((double) ((ENV_LENGHT - 1) - i) / (double) (ENV_LENGHT)), 8); x *= ENV_LENGHT; ENV_TAB[i] = (int) x; // Decay curve (just linear) x = pow(((double) (i) / (double) (ENV_LENGHT)), 1); x *= ENV_LENGHT; ENV_TAB[ENV_LENGHT + i] = (int) x; } [/CODE] As you can see i used x^8, i guess level 2 in vectorman was very sensitive to that (see the comment i left) [IMG ./images/smilies/icon_wink.gif] ######## POST p5535 | Shiru | 2008-06-09 | t386-015.html [QUOTE] Eke wrote:I'm curious, what is the SSG part mapped in registers 00-0Fh (which does not exist on YM2612). [/QUOTE] It is not related to FM synth or SSG-EG register. It's AY-3-8910/YM2149 part, same as in YM2203. I think, SSG-EG register named so just because it controls envelope in similar way like AY-3-8910 does. ######## POST p5536 | TmEE co.(TM) | 2008-06-09 | t386-015.html YM2612 timers in MD manual are all wrong. They're based on 8MHz not 7.6MHz and the Freq numbers for one octave's notes they had are all whipped off form this datasheet it seems, all wrong for MD. I had so much trouble getting the the value of the timer when I tried to have MD tracker and TMSE running at same speed... according to PC's PIT, the speed I got would be 49.4Hz, but the correct YM2612 calculation says its 49.9Hz... the PC runs faster with its 49.4 than MD with its 49.9 which makes no sense... ######## POST p5537 | Nemesis | 2008-06-10 | t386-015.html Fortunately, they do provide clock-independent formulas for calculating frequency values and timer intervals in this manual: [CODE] F-Number = (144 * fnote * 2^20 / M) / 2^(B-1) fnote: Frequency Data M: Master clock (Hz) B: Octave Data tA = 72 * (1024 - NA) / M NA: 0~1023 M: Master clock (MHz) tB = 1152 * (256 - NA) / M NB: 0~255 M: Master clock (MHz) [/CODE] EDIT: Note that the frequency calculation uses the clock frequency in Hz, while the timer calculations use the clock frequency in MHz. Also note the timer calculations are returning the timer interval in microseconds. You can see from the formulae that timer A counts down once every 72 clock pulses, and timer B counts down once every 1152 clock pulses (72 * 16). ######## POST p5538 | Nemesis | 2008-06-10 | t386-015.html Looking again at the Sega documentation, the formulae they provide for timer calculation are very different to the numbers from the YM2608 manual. [CODE] Timer A: 18 * (1024 - TIMERA) microseconds TIMER A = all 1's -> 18usec = 0.108ms TIMER A = all 0's -> 8400usec = 18.4ms Timer B: 288 * (256 - TIMERB) microseconds TIMER B = all 1's -> 0.288ms TIMER B = all 0's -> 73.44ms [/CODE] Comparing those simplified formulae to the ones in the YM2608 manual, Sega have either calculated these assuming a clock speed of 4MHz, or the dividers for the timers are different. It's quite possible the YM2612 has timers which have half the rate (144 clock pulses for Timer A, 144*16=2304 clock pulses for Timer B), and they've calculated for 8MHz. Can anyone confirm this? ######## POST p5539 | Eke | 2008-06-10 | t386-015.html here's the calculation I once made to find the exact timer period, however this is purely theorical: http://www.spritesmind.net/_GenDev//for ... .php?t=228 YM2612 is probably dividing input clock by 2: [QUOTE] 72/(VCLK/2/1000000) = 18.77 microseconds 1152/(VCLK/2/1000000) = 300.37 microseconds [/QUOTE] ######## POST p5540 | AamirM | 2008-06-10 | t386-015.html Hi, @ Stef Thanks a lot. @ Eke Nemesis has given a translation of CSM mode on the previous page. @ TmEE Could you please tell what quirks are you talking about besides the DAC? stay safe, AamirM ######## POST p5541 | TmEE co.(TM) | 2008-06-10 | t386-015.html Quirks are setting the "ganged" together registers backwards, previous instruments' settings affecting next instrument to some extent... It is very possible that YM2612 divides input clock by 2, as when I calculated the timer period, I got double result, ~100Hz instead of ~50Hz. ######## POST p5542 | AamirM | 2008-06-10 | t386-015.html Hi, Do you have some examples (audible) containing those quirks? I only have your DAC test program. stay safe, AamirM ######## POST p5544 | TmEE co.(TM) | 2008-06-10 | t386-015.html just make a small test proggy for MD, and listen in Fusion, it does ALL sound as real HW, all the various noises and such. ######## POST p5568 | Nemesis | 2008-06-15 | t386-015.html Ok, I've just completed a translation of this document, using the OCR function in Adobe Acrobat Professional, and a web-based Japanese translator at http://www.excite.co.jp/world/english which was recommended to me. I've been manually correcting OCR errors along the way, which in some cases meant looking through tables of several thousand Kanji, and bashing away at problem portions of the text until they made sense. I've preserved the page numbers of the original document, and largely preserved the original formatting. Yes, it took a lot of work. Here's the translated PDF: http://nemesis.hacking-cult.org/MegaDri ... slated.PDF The results are surprisingly good. The scans are clear enough and high resolution enough for the OCR to clean up. There was probably around a 99% success rate for the OCR, with most of the errors being simple accent problems. The web-based translator is also probably the best one I've seen. It's on a Japanese site, it only deals with English and Japanese, and it beats the Google translator into the ground. I haven't rewritten or restructured the output of the web translator, so some of it is a little backwards, but if you have a good grasp of English, the meaning should be clear in most cases. I'm not going to reword the output from the online translator, as I can't read Japanese, so I can't proof-check my translation against the original meaning of the text, and I don't want to risk losing any more information in the translation process. Note that pages 57-67 are not included in this translation. These pages aren't actually part of the main document, they're part of a separate document which is all about the physical properties of the chip, and the bus timings. Unfortunately, the quality of the scan is worse than the main document, and the font is different. The OCR doesn't cope nearly as well with it, so it would be slow and painful to translate, and I don't feel the urge to do it. These are probably different for the YM2612 anyway. You won't find anything important in this section though if you're just trying to emulate or use the YM2612. Anyway, hopefully this will open the document up for some more people to make use of. ######## POST p5569 | Eke | 2008-06-15 | t386-030.html thanks for the hard work [IMG ./images/smilies/icon_exclaim.gif] PS: just finished reading it, this is quite understandable or explain some nice stuff about FM synthethis, definitely what the official YM2612 manual should have been [IMG ./images/smilies/icon_wink.gif] I notice there was a register to disable CH4-CH6 and only process 3 channels, maybe someone could test it to see how the YM2612 behaves ######## POST p5592 | Nemesis | 2008-06-18 | t386-030.html Yeah, I noticed that. I have a feeling that register may not exist on the YM2612, as according to this documentation, the register defaults to 0, which would mean the chip would power up in 3 channel mode. It's definitely worth testing though. They might have just changed the default. There's also the interrupt control bits in that same register which I'd be interested in testing, even though the interrupt line of the YM2612 isn't connected in the Mega Drive. Another thing which is very interesting is the "Priscarar function" (phonetic for something?). It appears that writing to registers 0x2D, 0x2E, and 0x2F in the YM2608 adjusts the clock divider for the FM and SSG sound generation units. I'd be interested in testing whethter these registers have any effect on the YM2612. The thing I'm most interesting in solving once and for all with this new documentation is the cause of the unusual sound in Flashback, and several other Mega Drive games. There's some discussion about it in the following thread on this forum: http://www.spritesmind.net/_GenDev/foru ... =2699#2699 What we know is that this problematic instrument uses the channel 3 "special" mode, where a separate frequency is specified for each operator in the channel. I've been going through the documentation trying to get my head around all the implications of this mode, and here's what I've got so far. Here's what the new YM2608 manual says about this mode: [CODE] 2-8-4 Setting of mode of CH3 Channel 3 can set the mode by $27 “D7,D6". Table 2-1C CH3 mode ------------------------------------------------------------------------ |D7|D6|Mode | Function | |--|--|------------|---------------------------------------------------| | 0| 0|Normality |It pronounces normally as well as other CH. | |--|--|------------|---------------------------------------------------| | 0| 1|CSM |It becomes CSM voice synthesis mode, and F-Number | | | | |can be set each every of the four slots. Key-on/off| | | | |at the CSM mode is done with timer A. | |--|--|------------|---------------------------------------------------| | 1| 0|Effect sound|Separate F-Number can be set to each slot as well | | 1| 0| |as CSM. | ------------------------------------------------------------------------ [/CODE] Several things about this table: 1. My reading is that the last entry should apply to bit patterns 10 and 11. I think the fact they list 10 twice for the last entry is an obvious typo. 2. My understanding of the description is that the CSM and "Effect Sound" modes both enable the use of the extra channel 3 registers to specify the frequency/block data for each operator separately. The difference between the two seems to be that in the CSM mode, Timer A is somehow used to automatically toggle key on/off. The text seems to suggest that this does not happen in "Effect sound" mode, it simply activates the separate frequency numbers for each operator. What I don't know from reading this documentation is how exactly this "key on/off" on Timer A works. Obviously something happens when Timer A expires, but there's a few different ways I could imagine this being implemented. Does it always simply set key on for each Timer A, and never send a key-off? Does it alternate between key on/key off as the timer expires? I'd want to confirm exactly what the behaviour is. Comparing the table in the YM2608 manual with the one in the Genesis Software Sound Manual, here's what Sega says about this mode: [CODE] ------------------------------------------------------------- |CH 3 Mode |D7|D6| | |----------|--|--|------------------------------------------| |NORMAL | 0| 0|Channel 3 is the same as the others. | |----------|--|--|------------------------------------------| |SPECIAL | 0| 1|Channel 3 has four separate frequencies. | |----------|--|--|------------------------------------------| |ILLEGAL | 1| X| | ------------------------------------------------------------- [/CODE] This would suggest that what we currently call channel 3 "special" mode is in fact CSM mode, and that in order to emulate it, we should be doing the key on/off on Timer A. Perhaps the sound error is due to this feature not being emulated? Another thing of note, is that the Sega documentation and the YM2608 documentation disagree about which frequency values affect which operators. Here's what it says in the Genesis Software Sound Manual, page 12: [QUOTE] "Channel 3 operator 1's frequency is in Registers A2 and A6. Operators 2 and 4 are in Registers A8 and AC, A9 and AE, and AA and AE, respectively." [/QUOTE] Well, for one thing, I assume they meant to say "Operators 2, 3, and 4", and there's the glaring error that they listed register AE twice. The third pair should have been A9, AD. Even if you account for those errors though, that doesn't match up with the register assignments given in the YM2608 manual. The table on page 20 of the YM2608 Application Manual gives the following register allocation: [CODE] ------------------ |Operator 1|A9,AD| |Operator 2|AA,AE| |Operator 3|A8,AC| |Operator 4|A2,A6| ------------------ [/CODE] Compared with the numbers they were trying to give in Sega's documentation: [CODE] ------------------ |Operator 1|A2,A6| |Operator 2|A8,AC| |Operator 3|A9,AD| |Operator 4|AA,AE| ------------------ [/CODE] We know that the registers for operators 2 and 3 are switched in the Sega documentation, so if you use the same operator numbers as are given in the register list in the Sega documentation, you should reverse operators 2 and 3 in that table. Even if you do that however, the Sega documentation clearly says that the frequency for operator 1 is in A2,A6, while the YM2608 manual says that's the frequency for operator 4. Can anyone who's worked with the YM2612 in hardware, or written a working YM2612 core, confirm which register numbers match up to which operators? ######## POST p5593 | TascoDLX | 2008-06-18 | t386-030.html [QUOTE] Nemesis wrote:"Priscarar function" (phonetic for something?) [/QUOTE] Prescaler. ######## POST p5594 | Nemesis | 2008-06-18 | t386-030.html Yeah, that's probably it. I found another phonetic entry in the ADPCM section of "Priscal" which is known to definitely mean prescale. It's the part at the end which is throwing me a bit. It almost seems like it's another word tacked on. I was thinking "priscarar" might mean something along the lines of "Prescale rate", but that doesn't match "Sastenrat" which means "Sustain rate". Maybe it is just supposed to be "prescaler". ######## POST p5596 | Shiru | 2008-06-18 | t386-030.html [QUOTE] Nemesis wrote:Another thing which is very interesting is the "Priscarar function" (phonetic for something?). It appears that writing to registers 0x2D, 0x2E, and 0x2F in the YM2608 adjusts the clock divider for the FM and SSG sound generation units. [/QUOTE] Prescaler, also works on YM2203. Don't know about YM2612. [QUOTE] Nemesis wrote:Well, for one thing, I assume they meant to say "Operators 2, 3, and 4", and there's the glaring error that they listed register AE twice. The third pair should have been A9, AD. Even if you account for those errors though, that doesn't match up with the register assignments given in the YM2608 manual. [/QUOTE] In MAME OPN emulation code register pairs for multi-frequency mode are A6A2, ACA8, AEAA, ADA9. When I did test of that mode, it worked same in all emulators and on real hardware. ######## POST p5597 | Nemesis | 2008-06-18 | t386-030.html Ok, so those register pairs are different again. If that's the correct allocation, that would mean both the documents are wrong. In your testing on the hardware, did you specifically test and confirm the register allocation, or were you just listening to the sound output for the channel as a whole? It's possible swapped register pairs could have little audible effect on the sound output, depending on how the sound is being created. It seems the best way to test this would be to set algorithm 8 (each operator as a slot), and key-on each individual operator separately, with separate frequencies in each register. By stepping one operator at a time, you could tell which registers were being used for that operator by the tone it creates. I might run this test for my own piece of mind if nothing else. It would seem odd to me that neither document would have the correct info. And speaking of key on/off, I've noticed something that's either wrong in the Yamaha documentation, or a lot of emulators probably get wrong. Both the Sega and Yamaha documentation agree that when it comes to setting key on/off for individual operators in reg $28, D7=op4, D6=op3, D5=op2, and D4=op1. When it comes to all the other registers however, the Sega documentation has operators 2 and 3 switched. I'm pretty sure in the past with only the Sega document as a reference, most people have switched the operator numbers in the algorithm table, assuming that's where the error was. We can see in this document from Yamaha however that the numbers in the algorithm tables were correct, and that it was the register locations which were switched. The correct order of the operators is op1, op3, op2, op4 in the register blocks. The Yamaha docs agree that the operator numbers come sequentially in the key on/off register however. If the Yamaha docs are correct, and an emulator has been written assuming the registers came sequentially in the register block, then the bits for operator 2 and 3 would have to be switched in the key on/off register, otherwise the wrong operator would be affected. This might not be easily noticed either, as operators aren't usually controlled separately. ######## POST p5598 | Shiru | 2008-06-18 | t386-030.html [QUOTE] Nemesis wrote:Ok, so those register pairs are different again. If that's the correct allocation, that would mean both the documents are wrong. [/QUOTE] Actually, order which I said is same as in YM2608 doc, just reversed by some reason. [QUOTE] Nemesis wrote:In your testing on the hardware, did you specifically test and confirm the register allocation, or were you just listening to the sound output for the channel as a whole? [/QUOTE] Main goal of test was to check if second bank of YM2612 has multi-frequency mode (it does not). But I used algo #7 (all operators are slots) and separate Key On/Off for each operator in that test. You can check it by yourself . [QUOTE] Nemesis wrote:If the Yamaha docs are correct, and an emulator has been written assuming.. [/QUOTE] I highly doubt that any of YM2612 emulators was written with info from docs only, without very many tests on real hardware. ######## POST p5599 | Eke | 2008-06-18 | t386-030.html The emulators are correct regarding operator order and register addresses, even for CH3 special mode, it's just that the YM2612 doc is wrong... but this new doc seems correct for me, this is exactly the same order as in MAME emu (S1>S3>S2>S4 for common registers and S4>S3>S1>S2 for CH3 frequencies) the operator bits in KEYON/OFF register is also the same [QUOTE] What I don't know from reading this documentation is how exactly this "key on/off" on Timer A works. Obviously something happens when Timer A expires, but there's a few different ways I could imagine this being implemented. Does it always simply set key on for each Timer A, and never send a key-off? Does it alternate between key on/key off as the timer expires? I'd want to confirm exactly what the behaviour is. [/QUOTE] in emulators (MAME for example), it only set KEY ON for all operators while reading the new doc, it seems to me it could be that the first time it occurs, key ON is set than the next time, Key OFF is set (and so on...) still, I 'm not sure to understand the difference between the 2 special mode, is that only the Timer A behaviour ? Also note that in emulators, the TimerA Key ON (CSMKeyControll in MAME core) only happen when the last bit is set, which is in contradiction with this doc... ######## POST p5600 | AamirM | 2008-06-18 | t386-030.html Hi, [QUOTE] Nemesis wrote:The thing I'm most interesting in solving once and for all with this new documentation is the cause of the unusual sound in Flashback, and several other Mega Drive games. [/QUOTE] I have spent many tens of hours trying to figure out this one but unable to do so. I've looked into (and tried) every possible reasoning there is. I remember that I once changed operator order and it sounded very close Kega (but not exact, I don't have MD anymore to test real hardware recording) but it broke sound in Todd's Slime World. But if we have gotten the operator order wrong and Steve Snake has it right then why does it is only corrected in SuperHQ mode? I also tried various things with Key On/Off using Timer A but no success there either. Game Music Emu by Blargg has a modified Gens core in which this is fixed (possibly using FIR filtering which it has) but I haven't gotten any time to figure out how its done. If anybody else could use that core in some emu to see if it is in fact the FIR filtering or something in that pirticular version of Gens core, then that would be awesome. Also, this blip sound doesn't only happen in one pirticular setting which Eke described in another topic. This blip sound is also present in Vector Man 2 in music called 'Planet Fall Dig' using a slightly different setting. I think its the FIR filtering which will fix this. stay safe, AamirM ######## POST p5601 | Eke | 2008-06-18 | t386-030.html Also, did you notice that the Key-Code calculation is also wrong in YM2612 doc ? it said it was made from the 3 bits of BLOCK and from the 2 high frequency bits which is not what this new doc tells us: KEY CODE is made of BLOCK data 3 bits (OK) but then with N3 and N4 bits where: N4 = last bit of frequency (OK) N3 is a strange combination of the 4 last frequency bits Some other stuff different from the original doc: - DETUNE varies with KEY CODE value also - when using KEYSCALE formula (FINAL RATE = 2*RATE + KS_RATE): FINAL RATE will be 0 if RATE is 0, regardless of KS_RATE value the maximal RATE value is bounded to 63 RR is different from the others (normal, it's one bit less), RATE=2*RR+1 I didn't looked into emulator to see if they emulate this correctly (probably yes) ######## POST p5605 | Nemesis | 2008-06-19 | t386-030.html [QUOTE] Shiru wrote: [QUOTE] Nemesis wrote:Ok, so those register pairs are different again. If that's the correct allocation, that would mean both the documents are wrong. [/QUOTE] Actually, order which I said is same as in YM2608 doc, just reversed by some reason. [/QUOTE] Actually, after checking again, the order of the registers you confirmed in your hardware tests, and the order currently used in MAME, both match the YM2608 documentation. It is just the Sega documentation that's wrong. You might have read the operator bits backwards in the key on/off register. From a post of yours in the thread you linked to: [QUOTE] D7 - operator, which frequency defined by A6A2 D6 - .. ACA8 D5 - .. AEAA D4 - .. ADA9 [/QUOTE] Where D7=op4, D6=op3, D5=op2, and D4=op1. That matches the YM2608 document. At least that's confirmed then. [QUOTE] I highly doubt that any of YM2612 emulators was written with info from docs only, without very many tests on real hardware. [/QUOTE] I must say, I didn't expect to find this many errors and omissions in the Sega documentation, and there are some big ones in there. No wonder YM2612 emulation is the last thing Mega Drive emulators tend to get right, if ever. You're probably right, I don't think it would have been possible to get a YM2612 core off the ground at all without tests in hardware, and only the Sega document as a reference. [QUOTE] still, I 'm not sure to understand the difference between the 2 special mode, is that only the Timer A behaviour ? Also note that in emulators, the TimerA Key ON (CSMKeyControll in MAME core) only happen when the last bit is set, which is in contradiction with this doc... [/QUOTE] I must say, I'm a bit unclear on the distinction between the two as well. It seems to me to be saying that the "Effect Sound" mode is just the separate frequency part of the CSM mode, without key on/off on timer A. There is a bit of ambiguity in the translated text however. I might get the text in this particular section professionally translated, just to be sure of the meaning. It would have been nice to have at least a good paragraph describing the channel 3 modes though. A few sentences in a table really isn't enough to sum up all the details of these modes. It does sound a bit sus that MAME only enables CSM mode when D7 is set. The Sega documentation certainly doesn't mention anything about key on/off on timer A, they simply describe the separate frequency values for each slot. I would be surprised if every Mega Drive game has been using CSM mode without having the information about the timer A key on/off control. It's possible the Yamaha documentation has these bits switched. This definitely needs to be tested in hardware. [QUOTE] Game Music Emu by Blargg has a modified Gens core in which this is fixed (possibly using FIR filtering which it has) but I haven't gotten any time to figure out how its done. If anybody else could use that core in some emu to see if it is in fact the FIR filtering or something in that pirticular version of Gens core, then that would be awesome. [/QUOTE] I might look into that. I'm at the stage of planning the YM2612 core for my emulator, and it would be good to know the answer to this mystery before I repeat the same mistakes. [QUOTE] Also, did you notice that the Key-Code calculation is also wrong in YM2612 doc ? [/QUOTE] I actually hadn't spotted that. It's a subtle difference, which means it's probably wrong in a few different emulators. [QUOTE] Some other stuff different from the original doc: - DETUNE varies with KEY CODE value also - when using KEYSCALE formula (FINAL RATE = 2*RATE + KS_RATE): FINAL RATE will be 0 if RATE is 0, regardless of KS_RATE value the maximal RATE value is bounded to 63 RR is different from the others (normal, it's one bit less), RATE=2*RR+1 [/QUOTE] Good finds. I'd noticed all those special case rules for the keyscale formula, but I hadn't compared to the Sega documentation to see if it covered them. Seems it doesn't. I actually thought the Sega documentation had mentioned detune being affected by rate scaling, but looking back over it, it seems I was wrong about that. ######## POST p5607 | bobthebuilder | 2008-06-19 | t386-030.html I think it would be a great idea if the manual was submitted to romhacking.net. Nemesis, you can have the guys at romhacking.net help translate any parts that need clarification (several of them are professionals). Here is a link to the forum that can help: http://www.romhacking.net/forum/index.p ... d,9.0.html ######## POST p5608 | Nemesis | 2008-06-19 | t386-030.html Am I the only one who finds the formula for the N3 bit of the keycode confusing? Here's how the YM2608 manual says the N3 bit is calculated, on page 25: N3=F11・( F10+F9+F8 ) + !F11・F10・F9・F8 This is a boolean calculation, so their operator symbols are confusing me a bit. I don't see how addition has any place in this operation, and I haven't seen that dot symbol used in this context before. I somehow doubt they're talking about vector dot product. Fortunately they've given us some sample data above. [CODE] ------------------ |F11|F10|F9|F8|N3| |----------------| | 0 | 1 | 0| 1| 0| | 0 | 1 | 1| 0| 0| | 0 | 1 | 1| 1| 1| | 1 | 0 | 0| 0| 0| | 1 | 0 | 0| 1| 1| ------------------ [/CODE] So given those combinations of F11, F10, F9, and F8, that's the resulting N3 bit they're somehow getting using that above equation. Can anyone figure out how to actually interpret that formula to get these results? ######## POST p5609 | Nemesis | 2008-06-19 | t386-030.html [QUOTE] bobthebuilder wrote:I think it would be a great idea if the manual was submitted to romhacking.net. Nemesis, you can have the guys at romhacking.net help translate any parts that need clarification (several of them are professionals). Here is a link to the forum that can help: http://www.romhacking.net/forum/index.p ... d,9.0.html [/QUOTE] Looks good to me. I might submit the original. I won't enter my transcription just yet though. Now that I've finished the transcription and I actually have time to read the document, I've found a number of errors in the transcription and the OCR that I missed in my initial checks. I've also been translating phonetic words into their proper English equivalents as I confirm them. In a week or so once the corrections settle down, I'll release an updated document and submit it to romhacking.net. ######## POST p5610 | TascoDLX | 2008-06-19 | t386-030.html [QUOTE] Nemesis wrote:Am I the only one who finds the formula for the N3 bit of the keycode confusing? Here's how the YM2608 manual says the N3 bit is calculated, on page 25: N3=F11・( F10+F9+F8 ) + !F11・F10・F9・F8 This is a boolean calculation, so their operator symbols are confusing me a bit. I don't see how addition has any place in this operation, and I haven't seen that dot symbol used in this context before. I somehow doubt they're talking about vector dot product. Fortunately they've given us some sample data above. [/QUOTE] It's boolean algebra: + is OR, ・ is AND, ! is NOT. Order of operations (ignoring parentheses) is NOT then AND then OR. This formula can be split into two cases: * If F11 is set (1), then only one of the other three ( F10, F9, F8 ) need be set (1). [1001, 1010, 1011, 1100, 1101, 1110, 1111] * If F11 is not set (0), then the other three ( F10, F9, F8 ) must all be set (1). [0111] The formula can be rewritten thusly: N3 = F11・( F10+F9+F8 ) + !F11・( F10・F9・F8 ) ######## POST p5611 | Nemesis | 2008-06-19 | t386-045.html Thanks, that makes sense now. I've never seen those symbols for boolean operators before. I think I must have tried every combination of operators except the right one. ######## POST p5614 | AamirM | 2008-06-19 | t386-045.html Hi, [QUOTE] I might look into that. I'm at the stage of planning the YM2612 core for my emulator, and it would be good to know the answer to this mystery before I repeat the same mistakes. [/QUOTE] It is also interesting to note that the blip sound only disappears when you use the Gens' core with game music emu. Game Music emu also has the option to use MAME FM core in which case the blip sound is present (which gives the indication that it might not be the FIR filtering). I tried exchanging the operator 2 & 3 order (which is incorrect) in that pirticular Gens' FM core and the blip sound came again. I wasn't able to find any differences between that Gens FM core (which is a modified from Gens 2.10) and the current one (in Gens 2.14) although blargg has modified it very much (mostly for optimization and simplification). I would recommend others to look there for answer to this mystery. I don't have any time right now otherwise I would've looked at that myself in detail. stay safe, AamirM ######## POST p5615 | Eke | 2008-06-19 | t386-045.html [QUOTE] It does sound a bit sus that MAME only enables CSM mode when D7 is set. The Sega documentation certainly doesn't mention anything about key on/off on timer A, they simply describe the separate frequency values for each slot. I would be surprised if every Mega Drive game has been using CSM mode without having the information about the timer A key on/off control. It's possible the Yamaha documentation has these bits switched. This definitely needs to be tested in hardware. [/QUOTE] look at ym2151docs.pdf here:http://msx.retro8bits.com/msxdocs.html I know it is not the same chip family but there is a lot of similarities in hardware design and technical concepts, this is a good complement to this doc too, just to doublecheck some calculations also, see that bit D7 is defined as CSM mode activation, where Timer A generate a Key-ON on all CH3 operators, this is probably where the MAME code is coming from (btw, this is commented as "actually wrong" in the code, so they probably just copy what was on similar YM chips) PS: another thing I noticed in those two docs in that SL (substain level, T1L in YM2612 doc) will have a max attenuation of 93dB when all bits are set, even if it would seem more logical to just add the value of each bit : 24+12+6+3 = 45dB max, I still need to check in emulator codes how they handle this one (I'm first trying to make a synthethis of all new or corrected features that are specified in this doc, comparing to original ym2612 doc) finally, what we are still missing and are probably the most important stuff are the AR/DR& RR timings, according to the register values. There are fully described at the end of the YM2151 doc but they are probably not compatible... EDIT: I just looked into the MAME ym2612 core source and it appears that every ambiguous things I mentionned is handled as described in the doc (excepting the auto key feature which is still not clearly understood), even the SSG-EG shapes (there are even devs comment about that ones suggesting they had access to a similar documentation [IMG ./images/smilies/icon_wink.gif] ) that's why I fear that this doc, even if still being a great reference , will not be any help to fix the remaining inaccuracies in current ym2612 implementations, which are SSG-EG handling and the special instrument that produce the so called "blip-blip" sound about SSG-EG, could it be possible that it is somehow relying on the SSG part of this chip, which would result in a broken or only partially working feature on ym2612 ? ######## POST p5618 | Nemesis | 2008-06-21 | t386-045.html I've cracked it. I know the cause of the mysterious blip sound in Flashback. I had a thorough play with Gens and the "Game Music Emu" thingamajigy, and based on the modifications made to the Gens core, I was able to trace back the differences between the two, and figure out the cause. The sound created by this instrument is the result of a bug in the YM2612 hardware, as some people had suspected. Based on the specs, it shouldn't happen, but it does. The culprit is the detune setting. Specifically, the case arises when you have: 1. A negative detune value 2. A frequency value for an operator very close to or equal to 0 The offender in the case of Flashback is Channel 3, operator 2. It has a detune value of -3, and a frequency value of 0. The negative detune attempts to subtract a small frequency value from the specified frequency. When the frequency value is smaller than the value being subtracted, the result overflows, producing a very large (high) frequency number instead. I've tested and confirmed this on the real hardware. Here's a simple test ROM: http://nemesis.hacking-cult.org/MegaDri ... detune.bin And here's the source: http://nemesis.hacking-cult.org/MegaDri ... detune.asm This ROM generates a continuous tone on the real system (and Kega), even though all slots in all operators have a frequency number of 0. Emulating this is possible. By using the same number system and register sizes during the frequency calculation, this overflow case can be accurately emulated. This requires information on the register sizes used within the Phase Generator, and the numbers which are used to represent frequency values internally. It's possible to determine this information by measuring the frequency of the waves produced by this overflow bug on the real hardware, and varying the octave and detune parameters as required. The Gens core does in fact already cause an overflow with detune values. It just so happens that because of the numbers Gens uses to represent intermediate frequency values, and because of the size of the datatypes used, Gens outputs a much higher frequency than the real system would in the case of an overflow, which is beyond the range of human hearing. The modified core in the "Game Music Emu" program uses a different scheme which results in a wave which is closer, but not the same, as the one produced by the real system. I don't believe this bug was deliberately emulated in this "Game Music Emu" player. Rather, it's an accidental side-effect of some changes in the way frequency values are dealt with, which differs from the stock Gens core. The result is close to correct in the case of the Flashback ROM, but not quite right. The same may be true of Kega, but it seems to be a lot more accurate, if not exactly the same as the real system. It's quite possible Steve figured out this bug a long time ago. ######## POST p5620 | Stef | 2008-06-21 | t386-045.html Kudos for your discover ! I searched about this "bug" for a long time, i guess now we just need to figure internal table/reg size for accurate emulation [IMG ./images/smilies/icon_smile.gif] ######## POST p5621 | Nemesis | 2008-06-22 | t386-045.html 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? ######## POST p5622 | HardWareMan | 2008-06-22 | t386-045.html So, you trying to say what whole block&fnum register triggers by write low fnum byte? I always thought that warning is for write rough tune first, then write fine tune, so less error will notice between writes. But now all different. For 8-bit systems it is helpfull for change 16-bit register. ######## POST p5623 | Eke | 2008-06-22 | t386-045.html great found, finally the big secret has been revealed [IMG ./images/smilies/icon_wink.gif] thank for taking the time to do test on real HW and for sharing ! btw, is this a bug with ch3 only or did you reproduce it on other channels ? ######## POST p5624 | TmEE co.(TM) | 2008-06-22 | t386-045.html [QUOTE] Nemesis wrote:Once again, this behaviour is emulated correctly in Kega. Does anyone know of something Kega doesn't get right? [/QUOTE] In Kega you are able to play samples in Stereo, but you can't do it in other emulators and real hardware... Kega won't play the currently played sample on the channel in next one when you change Left/Right reg so you can get nice and clean stereo sample playback. I made a demo which is on my OUTDATED site's MD section : http://www.hot.ee/tmeeco/MD.HTM Great work on figuring out what the writing of freq to YM2612 in a wrong way causes. I had all kinds of trouble with it when writing my sound engine, as it didn't work on MD and Kega but worked on all other emulators... now I know that you must write high part first. I wonder if Timer A behaves in a same manner if writes are done backwards ? ######## POST p5625 | Eke | 2008-06-22 | t386-045.html [QUOTE] TmEE co.(TM) wrote: Great work on figuring out what the writing of freq to YM2612 in a wrong way causes. I had all kinds of trouble with it when writing my sound engine, as it didn't work on MD and Kega but worked on all other emulators... now I know that you must write high part first. I wonder if Timer A behaves in a same manner if writes are done backwards ? [/QUOTE] well, this is handled correctly by the MAME emu (frequencies are updated only when A0-A2, A8-AA are written) but not by GENS (frequencies are updated every time you modify any registers) none of them care about Timer A write order: counter are reinitialized each time the Timers values are changed (this is needed to fix Outrun music I think) but Timer writes behaviour when Timer is started is not really known... I also wonder how they really work: is the order important ? does the counter reset when the START bit flag is changed ? ######## POST p5626 | Chilly Willy | 2008-06-22 | t386-045.html If you've never set a timer before, the proper way to do so (assuming you have to do two writes to a hi and lo reg without latching) is to write the largest possible value (usually 0xff) to the low reg first, then write the hi value, then finally the correct lo value. The idea is that by writing the largest possible value allowed to lo reg first, you have time to set hi and then the proper lo without the register underflowing. If the timer latches the values, then of course none of that matters. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p5628 | notaz | 2008-06-23 | t386-045.html I just want to add my thanks for your work, Nem! ######## POST p5629 | Nemesis | 2008-06-23 | t386-045.html [QUOTE] Stef wrote:Kudos for your discover ! I searched about this "bug" for a long time, i guess now we just need to figure internal table/reg size for accurate emulation [/QUOTE] I can tell you right now from initial tests, that the value it overflows to is very close to the maximum frequency value you can set normally (block = 0x7, fnum = 0x7FF). I've got a whole series of tests planned to narrow down the exact numbers though. [QUOTE] HardWareMan wrote:So, you trying to say what whole block&fnum register triggers by write low fnum byte? I always thought that warning is for write rough tune first, then write fine tune, so less error will notice between writes. But now all different. For 8-bit systems it is helpfull for change 16-bit register. [/QUOTE] Yeah, I'd assumed the same thing. I only found out about this behaviour because I was setting the registers the wrong way around for some of my tests, and was a little puzzled when all I got was silence. [QUOTE] Eke wrote:btw, is this a bug with ch3 only or did you reproduce it on other channels ? [/QUOTE] I'm pretty sure I tested on other channels, but now that you've asked, I can't remember for sure. I'll repeat the tests on a few other channels just to be certain. [QUOTE] TmEE co.(TM) wrote:Great work on figuring out what the writing of freq to YM2612 in a wrong way causes. I had all kinds of trouble with it when writing my sound engine, as it didn't work on MD and Kega but worked on all other emulators... now I know that you must write high part first. I wonder if Timer A behaves in a same manner if writes are done backwards ? [/QUOTE] That's a good question. I'll add that to my list of things to test about the timers. [QUOTE] notaz wrote:I just want to add my thanks for your work, Nem! [/QUOTE] Thanks [IMG ./images/smilies/icon_biggrin.gif]. It's nice to be able to share this information with other people who can make use of it. There's a lot more tests I'm going to be running on the YM2612 in the next little while. I don't have much time free right now, but I've got 2 weeks holidays starting at the end of this week, and I plan to spend a fair portion of that tinkering with the YM2612, and maybe even get my own FM core off the ground. I'll make sure to post my findings here. I've already got a list of things to test, but are there any special requests? I'm going to be running a whole battery of tests on the hardware, so if there's some point of behaviour for the YM2612 that you've always wanted to get an answer on, let me know and I'll check it out. ######## POST p5630 | Eke | 2008-06-23 | t386-045.html [QUOTE] I can tell you right now from initial tests, that the value it overflows to is very close to the maximum frequency value you can set normally (block = 0x7, fnum = 0x7FF). I've got a whole series of tests planned to narrow down the exact numbers though. [/QUOTE] do you mean that the maximal frequency the ym2612 can achieve is given by these max values ? or is the max frequency the max NUM value multiplied by the max FNUM/BLOCK value which have been added to the MAX Detune value ? this would be a little like enveloppe rates, they can be increased with the key scale but the maximal values is still limited to the maximal rate value well, I have some thought for a quick fix in the Gens core but didn't have the mean to test it for now: in Gens (Stef, please correct me if I'm wrong), phase increment are used, and phase is updated like this for example: [QUOTE] (1) CH->SLOT[S0].Fcnt += CH->SLOT[S0].Finc; [/QUOTE] the incremented value is calculated each time that parameters are changed by this formula: [QUOTE] (2) SL->Finc = (finc + SL->DT[kc]) * SL->MUL; [/QUOTE] where finc is derivated from FNUM and BLOCK values: [QUOTE] (3) finc = FINC_TAB[CH->FNUM[0]] >> (7 - CH->FOCT[0]); [/QUOTE] as you can see, in formula (2), if finc < -DT , the Phase Increment will become negative, which is no good (SL->Finc is indeed declared as signed int so it does not underflow, the only time it is negative should be when it need to be recalculated, i.e forced to -1) so the idea would be to calculate the maximal increment value and to add this test after (2): [QUOTE] if (SL->Finc < 0) SL->Finc += FInc_MAX + 1; [/QUOTE] ######## POST p5631 | Stef | 2008-06-23 | t386-045.html Yep, that should do it in theory. As you said the YM2612 is probably using internally a non signed fixed size register and in some case it underflows. Your fix should emulate it correctly =) ######## POST p5632 | notaz | 2008-06-23 | t386-060.html Tried to add handling for this into MAME core. It took a while to figure out that the behavior Nemesis described is not what actually causes the 'blip' sound, the blip comes from operator1, and the described operator2 behavior eliminates the 'blip' [IMG ./images/smilies/icon_smile.gif] For some reason I'm getting the best results when I use fnum=7ff and blk=5 settings as a maximum. I've checked as many games as I could: [CODE] +- Ariel - The Little Mermaid (intro, 1st level) +- Battletech (music 03, 07, 12) +- Berenstain Bears', The - Camping Adventure (music 1, 4, ...) +- Comix Zone (tracks 5, 10) +- Flashback (bgm3) +- Shaq Fu (most of the music) +- Spider-Man - The Animated Series (intro music) +- Vectorman 2 ("fall dig" track) [/CODE] They sound fine, but they all seem to use the same settings (blk=4, mul=12, ...), probably because they all use GEMS. ######## POST p5633 | Nemesis | 2008-06-24 | t386-060.html I've confirmed the presence of the CSM mode in the YM2612, and whatsmore, Kega doesn't emulate it. Hooray, I've found something new! [IMG ./images/smilies/icon_lol.gif] I've still got more tests to run before I can post a full description of how the CSM mode works, and I'm not going to have time to complete them all tonight, but I'll post the details as soon as I've confirmed the behaviour. [QUOTE] Eke wrote:btw, is this a bug with ch3 only or did you reproduce it on other channels ? [/QUOTE] I've now confirmed that the detune overflow bug occurs on all channels. ######## POST p5634 | Eke | 2008-06-24 | t386-060.html cool, did you found any games using this ? Btw, you already made a great discovery by explaining the Detune bug, I still can not understand how this could have remained like a dirty secret so long [IMG ./images/smilies/icon_rolleyes.gif] sharing informations is the way to move on, especially when some people don't have a way or enough knowledge to make test on real hardware themselves... thanks a lot Nemesis ######## POST p5635 | Nemesis | 2008-06-24 | t386-060.html I haven't looked for games that use this feature, I've just been experimenting with my own code. If anybody wants to hunt for games which might make use of it, CSM mode is active when the channel 3 mode bits are set to "10", or in other words, when register $27 is set to 10******. CSM mode is not active when the upper bits are set to 11. ######## POST p5636 | notaz | 2008-06-24 | t386-060.html Looking forward to "Undocumented YM2612 features" doc [IMG ./images/smilies/icon_smile.gif] ######## POST p5637 | Eke | 2008-06-26 | t386-060.html [QUOTE] Stef wrote:Yep, that should do it in theory. As you said the YM2612 is probably using internally a non signed fixed size register and in some case it underflows. Your fix should emulate it correctly =) [/QUOTE] well, it doesn't [IMG ./images/smilies/icon_sad.gif] I'm probably missing something with this phase increment stuff (this is definitely one of the thing I'm still not sure to understand in the emulator code) notaz: what did you do exactly to fix the MAME core ? ######## POST p5638 | TmEE co.(TM) | 2008-06-26 | t386-060.html What is this CSM mode ? ######## POST p5639 | Nemesis | 2008-06-26 | t386-060.html [QUOTE] Eke wrote: [QUOTE] Stef wrote:Yep, that should do it in theory. As you said the YM2612 is probably using internally a non signed fixed size register and in some case it underflows. Your fix should emulate it correctly =) [/QUOTE] well, it doesn't [IMG ./images/smilies/icon_sad.gif] I'm probably missing something with this phase increment stuff (this is definitely one of the thing I'm still not sure to understand in the emulator code) [/QUOTE] I added the following lines to CALC_FINC_SL in Gens to approximate the effect when I was doing testing: [QUOTE] if(SL->Finc < 0) { finc = FINC_TAB[0x7FF] >> (7 - 0x7); SL->Finc = (finc + SL->DT[kc]) * SL->MUL; } [/QUOTE] Based on what notaz said, you might find the result sounds closer if you set block to 5 instead of 7. [QUOTE] TmEE co.(TM) wrote:What is this CSM mode ? [/QUOTE] CSM mode is another special mode for channel 3, where Timer A automatically does key on/off for the channel. ######## POST p5640 | TmEE co.(TM) | 2008-06-26 | t386-060.html I can't make use of CSM mode in my sound engine then... Timer A is used for SFX, Timer B for BGM, VBLs are not touched. ######## POST p5641 | Chilly Willy | 2008-06-26 | t386-060.html [QUOTE] TmEE co.(TM) wrote:What is this CSM mode ? [/QUOTE] It's a mode meant for formant speech synthesis. One of the better methods of synthesizing speech is to break it into the addition of resonant frequencies that last a specific time. These are called formants and if you add the correct ones, you get a phoneme. You might want to check the proper wiki pages for more info. http://en.wikipedia.org/wiki/Speech_syn ... _synthesis http://en.wikipedia.org/wiki/Formant ######## POST p5642 | TmEE co.(TM) | 2008-06-26 | t386-060.html For speech synthesis I use samples... 50K of samples are enough for well understandable text [IMG ./images/smilies/icon_smile.gif] only limitation of my synth : you need to be Estonian to make it talk (all languages that have "say what you read" and no pronounciation stuff will do. in Estonian "a" is spelled exactly the same in any word you encounter not like in English where the pronounciation depends on word). ######## POST p5643 | TulioAdriano | 2008-06-26 | t386-060.html It would work well for Portuguese, though, and most romance languages, except for French which has lots of irregularities... interesting, very nice. Btw, I haven't seen any concrete report on the famous channel 3 special mode which would allow individual operators to be set on different frequencies. As far as I know most tests on that feature failed to succeed, maybe wrong documentation again? ######## POST p5644 | notaz | 2008-06-26 | t386-060.html [QUOTE] Eke wrote:what did you do exactly to fix the MAME core ? [/QUOTE] I changed the start of refresh_fc_eg_slot() to this: [CODE] INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) { int ksr, fdt; /* (frequency) phase increment counter */ fdt = fc+SLOT->DT[kc]; /* detect overflow */ if (fdt < 0) fdt += fn_table[0x7ff*2] >> 2; SLOT->Incr = fdt*SLOT->mul >> 1; ... [/CODE] Note that this only works when sampling @ 44.1hHz, so it's probably wrong. Multiplier may have something to do with all this too. ######## POST p5645 | Shiru | 2008-06-26 | t386-060.html [QUOTE] TulioAdriano wrote:Btw, I haven't seen any concrete report on the famous channel 3 special mode which would allow individual operators to be set on different frequencies. As far as I know most tests on that feature failed to succeed, maybe wrong documentation again? [/QUOTE] What you mean 'failed'? This mode works well both in emulators and on real hardware, some games use it. I even added basic support for this mode in TFM MM long ago. ######## POST p5646 | Mask of Destiny | 2008-06-26 | t386-060.html [QUOTE] Shiru wrote: [QUOTE] TulioAdriano wrote:Btw, I haven't seen any concrete report on the famous channel 3 special mode which would allow individual operators to be set on different frequencies. As far as I know most tests on that feature failed to succeed, maybe wrong documentation again? [/QUOTE] What you mean 'failed'? This mode works well both in emulators and on real hardware, some games use it. I even added basic support for this mode in TFM MM long ago. [/QUOTE] My guess is he's thinking of the tests as to whether or not Channel 3 special mode also worked on Channel 6. ######## POST p5647 | TulioAdriano | 2008-06-26 | t386-075.html [QUOTE] Shiru wrote: [QUOTE] TulioAdriano wrote:Btw, I haven't seen any concrete report on the famous channel 3 special mode which would allow individual operators to be set on different frequencies. As far as I know most tests on that feature failed to succeed, maybe wrong documentation again? [/QUOTE] What you mean 'failed'? This mode works well both in emulators and on real hardware, some games use it. I even added basic support for this mode in TFM MM long ago. [/QUOTE] Ok dude, it was just a question. You don't need to get angry... [IMG ./images/smilies/icon_eek.gif] ######## POST p5648 | Shiru | 2008-06-26 | t386-075.html [QUOTE] Mask of Destiny wrote:My guess is he's thinking of the tests as to whether or not Channel 3 special mode also worked on Channel 6. [/QUOTE] Documentation has no mentions that second bank has any registers below #30. My test, which tried to use special mode on second bank by setting corresponding bit in register #27 of second bank, confirmed it (both for hardware and emulators). We also know that register #27 of first bank has two bits for special mode and CSM control and no free bits. So, I think, this information enough for 'concrete report'. ######## POST p5650 | Nemesis | 2008-06-29 | t386-075.html Ok, here's everything I know about CSM mode. The operation is quite simple in the end, but I did a lot of tests searching for unusual behaviour along the way. All this information is based entirely on tests performed on the YM2612 hardware. Enabling CSM mode: CSM mode is a special mode of operation for channel 3 only. First of all, here's a complete description of the effects of the channel 3 mode flags in register $27: [CODE] ---------------------- |Mode| Behaviour | |----|---------------| | 00 | Normal | | 01 | Special | | 10 | Special + CSM | | 11 | Special | ---------------------- [/CODE] Normal mode is of course when no special mode is in effect for channel 3, and it behaves like any other channel. Special mode is when a separate frequency/octave can be assigned to each operator within the channel, which we already have documentation on. CSM mode is where Timer A performs automatic key on/off for channel 3. As you can see from the table above, Special mode is always active when CSM mode is active. CSM mode is only active when the mode bits are set to 10, NOT when they are set to 11. In order for CSM mode to have any effect, Timer A must be loaded. In other words, bit 0 of reg $27 must be set to 1. None of the other timer-related flags, including the reset and enable bits, nor the state of Timer B, have any impact on CSM mode whatsoever, and the act of changing the state of these settings at any time have no impact on the operation of the CSM mode, as long as the channel 3 mode, and Timer A load flag remain unchanged. The effects of CSM mode: When CSM mode is correctly enabled, each time Timer A expires, the following two steps occur, in the specified order: 1. Key-on is sent to all operators in channel 3 2. Key-off is sent to all operators in channel 3 In other words, key on occurs, immediately followed by key-off, at the instant Timer A expires. CSM mode is only evaluated when Timer A expires. The YM2612 does not evaluate the CSM mode when Timer A is loaded, only when it expires, and any changes to the CSM mode while Timer A is running will take effect immediately. If Timer A is currently running and CSM mode is enabled, key on/off will occur when the timer next expires. If Timer A is currently running and CSM mode is disabled, key on/off will not occur when the timer next expires. There is a big implication related to the instant key on/off behaviour of CSM mode. As described in the documentation on the envelope generator, there are several phases the envelope passes through once key-on is triggered, which determine the overall volume of the operator over time. The first phase is the Attack Phase, where the volume of the operator rises from 0 towards TL, the Total Level, at a rate governed by AR, the Attack Rate. When key off occurs, the volume of the operator immediately starts to drop at a rate governed by RR, the Release Rate. If an operator is keyed off during the attack phase and it has not reached TL yet, the volume of the operator will stop rising, and will immedaitely start to fall according to the release rate. Since the key-on and key-off occur at the same time in CSM mode, the only way a sound can be produced is if the volume level starts at something greater than 0. This means the only supported value for the Attack Rate in CSM mode is $1F, which is described as "infinity" in the documentation, meaning the volume of the channel starts at the level specified by TL. Testing has shown that a setting of $1E also works, and produces an identical output as $1F for this purpose (and possibly is identical under all circumstances. Would need further testing). All other settings for AR fail to produce any waveform, since they start with a volume level of 0. Since you can only use an AR value of infinity, and key-off occurs instantly, TL and RR are the two parameters which govern the envelope under CSM mode. DR, SR, and SL will have no impact. The interaction of CSM and manual key on/off: One subtle point about CSM mode is how it interacts with manual key on/off events triggered through register $28. CSM mode doesn't trigger a "real" key-on or key-off event. Timer A expiring will NOT key-off an operator which was manually keyed on by a write to register $28. CSM mode cannot trigger a key-on or key-off for any operator which has been manually sent a key-on event to register $28, until that operator is keyed off manually by a write to register $28. In other words, CSM mode only affects operators which are currently keyed off. If you were to manually key-on all operators in channel 3, then enable CSM mode, the CSM mode would have no effect until you sent a manual key-off event. If you never send a manual key-off, CSM mode will never take effect, even when the output of the operators decay to 0. ######## POST p5651 | Nemesis | 2008-06-29 | t386-075.html Here's a test ROM which uses CSM to generate a fading, repeating A6 tone: http://nemesis.hacking-cult.org/MegaDri ... smmode.bin Here's the source: http://nemesis.hacking-cult.org/MegaDri ... smmode.asm And here's a sample of the output you get on a PAL MD1600 MegaDrive, recorded at 96KHz: http://nemesis.hacking-cult.org/MegaDri ... smmode.wav In an emulator that doesn't support CSM, you'll only get silence if you run this ROM. I haven't come across any Mega Drive emulator which emulates CSM mode as of yet. ######## POST p5652 | notaz | 2008-06-29 | t386-075.html [QUOTE] Nemesis wrote:I haven't come across any Mega Drive emulator which emulates CSM mode as of yet. [/QUOTE] It works in MESS, as MAME YM2612 core supports CSM mode. ######## POST p5653 | Nemesis | 2008-06-29 | t386-075.html Ok then, no emulator that emulates it correctly. [IMG ./images/smilies/icon_smile.gif] MAME has an attempt at CSM support implemented, but it doesn't work properly, as is noted in the sourcecode. I've just tried the CSM test ROM in HazeMD, and it just plays a solid tone, which isn't silence, but it isn't correct. I haven't tried MESS, but it's based on the MAME core as I understand it, so it's probably in the same boat. EDIT: Yep, tried in MESS. Same as MAME. ######## POST p5654 | Chilly Willy | 2008-06-29 | t386-075.html Does changing the frequency during the release period take affect, or does it wait for the next KEY_ON? If the frequency only changes when you KEY_ON, it makes sense why they made CSM work this way. CSM is meant for speech synthesis, so here's what you'd do: Set frequency of all ch3 ops for your formants. Set TIMERA and enable CSM. loop: Wait for TIMERA overflow. Set TIMERA for the period of the phoneme. Set ops for the next phoneme's formants. goto loop This would give you properly timed phonemes while allowing you to set up for the next one ahead of time. Many phonemes are sensitive to how long they last. This form of speech synthesis usually has a table with the formant center frequencies, and the length of the phoneme. ######## POST p5655 | Nemesis | 2008-06-30 | t386-075.html I've just tested, and frequency changes take effect immediately. If you change the frequency for an operator, the new frequency is used for the very next sample, regardless of the current position in the output wave, or the state of the envelope generator. This is consistent with how frequency changes occur without CSM mode active. Even without the ability to setup the freqencies ahead of time, it wouldn't change the length of time each frequency is active for, it would just introduce some minor latency after each Timer A overflow before the frequencies are updated, and create a slight offset between the frequency changes of each operator. This would occur both leading into and out of each Timer A period, so the length wouldn't be affected, merely the timing of the changes. It would be most noticeable if the decay phase of the envelope was extreme, as the initial "attack" for each new key-on would be using the frequency of the previous phoneme. If there was virtually no decay for each key-on, which it sounds like is probably how it's intended to be used, there would be no noticeable effect whatsoever, apart from the minor offset between each operator receiving frequency changes. In a way it could be a good thing. If you set a very short Timer A period, there might not be time to update all 4 frequency values before the timer overflows. If you were leading into a very long Timer A period, and the frequency was latched at key-on only, it could result in a very long phoneme being played with one or more operators set to the wrong frequency, as the new frequency values couldn't be written in time. ######## POST p5656 | Chilly Willy | 2008-06-30 | t386-075.html Well, in the terms of the YM2612 clock or the Z80, phonemes are LONG. I don't think there would be one so short that you couldn't set the operators before the timer overflowed. Perhaps in SEGA's arcade systems where they used this for speech synthesis, they actually had the int line tied to the processor so that TIMERA actually generated an int. Then the behavior would work even with the frequency changing immediately. You'd just change three or four operators during the int handler. I would guess the point of the CSM mode is to eliminate the envelop almost completely. If you set the decay to be long, you have virtually no attack, just a waveform that starts at max and stays very close. The only thing that would change is the frequencies. ######## POST p5660 | TmEE co.(TM) | 2008-06-30 | t386-075.html CSM mode works on MD2 (PAL VA1 board). There is tonal difference, but that is because you used too low TL value (values below 8 should not be used). ######## POST p5676 | Nemesis | 2008-07-01 | t386-075.html I've just uploaded a new version of the YM2608 manual translation. It includes too many fixes to detail. Suffice to say, it corrects numerous transcription errors in the previous document (eg, the write wait times on page 14), a bucketload of OCR corrections I missed the first time around which greatly improves the translation in several sections, adds some entire sentences I somehow skipped when I was doing the initial translation, includes proper equivalents for words that were spelt phonetically, lots of improvements to the overall formatting, etc etc. If you downloaded the first translation, you should update it with the new version. I don't expect to change this document again in the near future, unless I find some whopping big error, or I get someone who actually reads Japanese to check the translation. You can download the latest version from the following link: http://nemesis.hacking-cult.org/MegaDri ... slated.PDF ######## POST p5680 | Nemesis | 2008-07-01 | t386-075.html Here are a few more things I've found out about the YM2612 over the last few days: 1. Status registers The YM2608 manual describes 3 separate status registers that can be read. Significantly, one of them reportedly returns an ID number for the chip, when the status register is read while register location $FF is latched. After testing, I can confirm that this does not apply to the YM2612. The normal status register appears to be returned from the YM2612 under all circumstances, regardless of the address the YM2612 is being read from (part 1 address/data or part 2 address/data), or the register that is latched at the time the status register is read. 2. Prescaler registers The YM2608 manual describes registers $2D, $2E, and $2F as prescaler register addresses, which reportedly simply latching will adjust the multipliers used to calculate the internal clock for the FM generator. This does not seem to exist in the YM2612. Latching or writing to these registers had no noticeable effect. 3. Interrupts I've conducted a full set of tests on the behaviour of the interrupt (INT) line of the YM2612. Even though it's not connected in the Mega Drive, it's still a functional part of the YM2612, and for the sake of completeness if nothing else, I wanted to confirm how it operated. Emulators like MAME could make use of this info too. First and foremost, I've confirmed that interrupt control flags for the YM2608 in register $29 do not exist on the YM2608. The interrupt line can be triggered by either Timer A or Timer B. Using the terms applied in the YM2608 manual, when a timer is "loaded" (bits 0 and 1 of reg $27), it starts with a number loaded into it as specified in the counter registers for each timer, and will count down at a regular rate, until it tries to count down from 0 and overflows. At this time, it will re-load the counter. What else happens as a result of a timer overflowing depends on the setting of the "enable" flag (bits 2 and 3 of reg $27). As described in the documentation, when the enable bit is set and the timer overflows, it will set the overflow flag for that timer in the status register, and trigger an interrupt. And now for the new stuff. Although not mentioned in the documentation, the reset flag directly affects interrupt generation. When a timer overflows, the YM2612 checks the current state of the timer overflow bit for that timer in the status register. The YM2612 will only generate an interrupt for that timer if the overflow bit is currently unset. If the overflow bit is unset, and the enable flag is set in the timer control register, the INT line will be asserted. The INT line will remain asserted, until the reset bit for that timer is set to 1 in the timer control register, or until the timer overflows again. If the reset bit for the timer is cleared at any time, the interrupt line will immediately be negated. If the timer overflows while INT is still asserted, that is, without reset being written to, the interrupt line will immediately be negated. From this point on, no interrupts will be generated for that timer until the reset bit is set. Once the reset bit has been set when an interrupt has been missed, the INT line will not immediately be asserted. The INT line will remain negated until the timer overflows again. This means in order to use the YM2612 interrupt line, the interrupt handler must always write the reset bit for that timer before exiting the interrupt handler. This tells the YM2612 to stop asserting the INT line for that timer, and prepares the YM2612 to trigger another interrupt when the timer overflows again. Additionally, in periods where the YM2612 interrupt is masked, it may be possible for a YM2612 interrupt to be missed, requiring the reset bit to be written in order to resume interrupt generation. The overflow bit in the status register would allow missed interrupts to be detected. The overflow bit should only be asserted in the interrupt handler where YM2612 interrupts are being used, as the overflow bit is set at the same time as the interrupt is generated, and the reset operation when leaving the interrupt handler clears this flag. Sorry if that's confusing. It's easier to understand when you're just looking at the oscilloscope. I might put some pictures up for this later on. I'm not sure that I explained this very well. 4. Timers Two things here. First of all, I've tested the timer A registers, and confirmed that they are NOT "ganged together" like the frequency registers are. Changes to either register $24 or $25 affect Timer A the next time it overflows or is loaded, regardless of the order the registers are written to. Secondly, I've confirmed the timer periods in the YM2612 are half the rate of the timers described in the YM2608 documentation, or in other words, the YM2612 timers take twice as long to count down as the timers in the YM2608. Here are the formulae to calculate the correct timer periods for the YM2612: [CODE] To calculate Timer A period in microseconds: TimerA = 144 * (1024 - NA) / M NA: 0~1023 M: Master clock (MHz) Eg, where clock = 7.61Mhz TimerA(MAX) = 144 * (1024 - 0) / 7.61 = 19376.61 microseconds TimerA(MIN) = 144 * (1024 - 1023) / 7.61 = 18.92 microseconds To calculate Timer B period in microseconds: TimerB = (144*16) * (256 - NA) / M NB: 0~255 M: Master clock (MHz) Eg, where clock = 7.61Mhz TimerB(MAX) = (144*16) * (256 - 0) / 7.61 = 77506.44 microseconds TimerB(MIN) = (144*16) * (256 - 255) / 7.61 = 302.76 microseconds [/CODE] I think that's about it so far. I'm finding so many bits out about this chip that I probably will end up compiling it all into a "YM2612 Undocumented" reference of some kind, at some point in the future. As for what's still to come, I'm making very significant progress on SSG-EG. I hope to have a full description of SSG-EG completed within the next few days, so that should be of interest to some people. I also plan to revisit the detune overflow bug as well, as I haven't got all the needed info in order to emulate that correctly yet. ######## POST p5684 | Eke | 2008-07-01 | t386-075.html very nice... about the timers, could you precise in which condition a timer counter is reloaded: what has been verified: 1/ when the counter underflows what's still unsure: 2/ each time the LOAD bit is set (unlikely) 3/ each time the LOAD bit switch from 1 to 0 or from 0 to 1 (or does the counter restart from the last point where it was stopped ?) 4/ when the timer base value is modified ######## POST p5687 | Nemesis | 2008-07-02 | t386-075.html After some testing, it appears that the timer counter is only reloaded at the following times: 1. When the counter underflows 2. When the load bit is switched from 0 to 1 (IE, the counter is changed from the stopped state to the running state). The counter does not restart from the last point it was up to when it is re-enabled. The timer counter is NOT reloaded when: 1. The load bit is already 1, and reg $27 is written to setting the load bit as 1 again 2. The reset or enable bits are changed 3. The timer counter registers are modified ######## POST p5690 | Eke | 2008-07-02 | t386-075.html Thanks for the clarification again [IMG ./images/smilies/icon_smile.gif] at least , this was not correctly emulated in emulators (counter was reloaded every time the timer load value was changed), this should not affect any games but it's still better to know ######## POST p5691 | TulioAdriano | 2008-07-02 | t386-090.html [QUOTE] Nemesis wrote:4. Timers Two things here. First of all, I've tested the timer A registers, and confirmed that they are NOT "ganged together" like the frequency registers are. Changes to either register $24 or $25 affect Timer A the next time it overflows or is loaded, regardless of the order the registers are written to. Secondly, I've confirmed the timer periods in the YM2612 are half the rate of the timers described in the YM2608 documentation, or in other words, the YM2612 timers take twice as long to count down as the timers in the YM2608. Here are the formulae to calculate the correct timer periods for the YM2612: [CODE] To calculate Timer A period in microseconds: TimerA = 144 * (1024 - NA) / M NA: 0~1023 M: Master clock (MHz) Eg, where clock = 7.61Mhz TimerA(MAX) = 144 * (1024 - 0) / 7.61 = 19376.61 microseconds TimerA(MIN) = 144 * (1024 - 1023) / 7.61 = 18.92 microseconds To calculate Timer B period in microseconds: TimerB = (144*16) * (256 - NA) / M NB: 0~255 M: Master clock (MHz) Eg, where clock = 7.61Mhz TimerB(MAX) = (144*16) * (256 - 0) / 7.61 = 77506.44 microseconds TimerB(MIN) = (144*16) * (256 - 255) / 7.61 = 302.76 microseconds [/CODE] [/QUOTE] So, based on the formula above is it correct to state that NTSC MD would have slightly faster timers? For a 7.67 MHz Clock we'd have the Min values for TimerA = 18.77 ms and for TimerB = 300.39 ms. I'd like very much to confirm the precision of this information to update my SFX Editor for Pier Solar. ######## POST p5692 | Nemesis | 2008-07-02 | t386-090.html There would definitely be a slight difference in the timing between an NTSC and PAL system, as the master clock for the system as a whole is slightly different (53.203MHz for PAL, 53.6931 for NTSC), and every operation any of these chips perform, including tracking the YM2612 timers, is ultimately based on the timing pulse. This will also be affecting the frequency of the tones produced by the YM2612, as well as the PSG. A given note will actually produce a very slightly different frequency between an NTSC and PAL system, although the variation would be undetetable to the human ear. You've got to remember though that the difference in the timer periods are still "in time" with the rest of the system. Every device in the system runs slightly faster in the NTSC system, and slightly slower in the PAL system. Code running on the system won't perceive any difference in timer periods between PAL and NTSC units, as while the timers do run a bit faster, the Z80 and M68000 also run faster, in the same proportions. As a result, the code running on the system won't notice these variations. Only the user can percieve them by comparing the output with an independent timing source. ######## POST p5693 | AamirM | 2008-07-02 | t386-090.html Hi, I see the ch3 instrument mystery is solved. Nemesis, your a genius [IMG ./images/smilies/icon_smile.gif] . I have something for you to test out. Ghostbuster track 10 is not emulated correctly by any other emulator except Kega and it would be nice to find out what is it doing too. stay safe, AamirM ######## POST p5695 | Nemesis | 2008-07-02 | t386-090.html Hmmm. On first impressions it could be something to do with the LFO, but I'll need to do a lot more testing to narrow it down. I'll definitely look into it. ######## POST p5696 | TmEE co.(TM) | 2008-07-03 | t386-090.html One interesting thing : Hellfire, on MD2s (and other systems with Sega implementation of YM2612 in the ASIC) the music plays half as slow as it would on Yamaha discrete YM2612 chip (MD1, certain MD2 model). This behaviour is not evident in any emulators I've tried. ######## POST p5697 | Nemesis | 2008-07-03 | t386-090.html Don't tell me that. =P I was hoping to get away with a single standard core for either the Sega integrated or Yamaha discrete YM2612. I've had a brief look, and you're right of course, the music is clearly running at half the rate on the MD2. Personally, I doubt it will turn out to be a difference in the YM2612 that's responsible for this. It's probably a variation in the timing for the integrated Z80 vs the discrete Z80 in the Model 1. I've done a quick check of the YM2612 timers, and they seem to be running at the same rate on the MD1 and MD2. The only other way the YM2612 could affect the speed at which the music progresses would be differences in the delay times between writes on the integrated vs the discrete chip, but my money is on the Z80. It's highly likely there are differences in instruction execution times between the integrated Z80 in the MD2, and the discrete chip in the MD1. Ok, so far there are two remaining sound emulation mysteries: -Ghostbusters track 10 lead sounds wrong -Hellfire music runs twice as slow on MD2 vs MD1 Any other unemulated/only emulated by Kega sound quirks that anyone knows of? ######## POST p5698 | Eke | 2008-07-03 | t386-090.html the SSG-EG part ? The MAME core is emulating it like described in the YM2618 manual, but still get it wrong for some games (try BGM and SFX in Asterix, Bubba 'n Stix... ) according to Steve Snake, SSG-EG is patially broken in YM2612, maybe it is related to the missing SSG part ######## POST p5699 | Nemesis | 2008-07-03 | t386-090.html I'm a fair way along in my testing of SSG-EG mode. Gens, Kega Fusion, and MAME all have attempted support for SSG-EG, but all of the implementations are broken in different ways. I know Steve Snake mentioned once that SSG-EG "doesn't always behave like it should" in the YM2612, but I haven't found any indication of that so far. It's always behaved in a consistent fashion for me, and everything it does matches with the documentation I've seen, once I understood what the documentation was saying. The problem is making sense of what little documentation there is, and figuring out how that relates to what it actually does. The SSG-EG mode wouldn't have been impacted in any way by the removal of the SSG module, as they're logically separate, discrete units, with no direct connection between each other. The SSG-EG envelope generation is handled by the FM module, it just happens to be an implementation of the envelope generator that is used in the SSG module, but it is a separate implementation. Where I'm currently up to with SSG-EG is that it's become clear from analysing the SSG-EG mode that it would be impossible to accurately emulate without first having accurate information on how to calculate the rates of each part of the ASDR envelope, and apply them to calculate the actual attenuation value over time. Minor inaccuracies in this area would be unnoticeable in normal use, but it's critical to get this right in order to emulate the SSG-EG. I'm currently focusing on calculating this information. Hopefully I'll be able to post some comprehesive information on SSG-EG, and the envelope generator as a whole, sometime in the very near future. ######## POST p5700 | AamirM | 2008-07-03 | t386-090.html [QUOTE] Nemesis wrote:Hmmm. On first impressions it could be something to do with the LFO, but I'll need to do a lot more testing to narrow it down. I'll definitely look into it. [/QUOTE] Hi, Last time when looked into it, I found if I ran envelope generator at twice the speed then the sound would get correct (to some extent, since it uses SSG-EG I think that made a bit of difference). One thing to note is that Ghostbusters tries to use channel 6 in special mode. stay safe, AamirM ######## POST p5701 | Nemesis | 2008-07-03 | t386-090.html [QUOTE] ....since it uses SSG-EG I think that made a bit of difference.... [/QUOTE] Doh! That was the first thing I looked for, but it turns out the SSG-EG registers weren't being displayed correctly in my emulator's debugger, so I thought SSG-EG wasn't being used. Yes, it is just bad SSG-EG support which is responsible for the incorrect sound in Gens. I've extracted the culprit instrument (channel 6) and run it through by itself, and Gens is definitely calculating the SSG-EG envelope incorrectly for this channel. Kega gets this particular case correct. There are other cases Kega gets wrong which Gens gets right. ######## POST p5702 | Shiru | 2008-07-03 | t386-090.html About SSG-EG. MAME emulates it incorrectly too. Alone Coder did some fixes which I use in TFM MM. They not fix emulation completely, but makes sound more closer to real chip (YM2203) in some cases. His version of MAME code is included into TFM MM package, replayers/pc/mame/ folder. All changes in code can be found by search for 'Alone Coder' string. ######## POST p5703 | Eke | 2008-07-03 | t386-090.html thanks for the tip and apparently, kode54 (foogep developper) also have made some modifications to the MAME core regarding SSG-EG, someone shoudl ask him about that too ######## POST p5704 | TmEE co.(TM) | 2008-07-03 | t386-090.html [QUOTE] Nemesis wrote:I've had a brief look, and you're right of course, the music is clearly running at half the rate on the MD2. Personally, I doubt it will turn out to be a difference in the YM2612 that's responsible for this. It's probably a variation in the timing for the integrated Z80 vs the discrete Z80 in the Model 1. I've done a quick check of the YM2612 timers, and they seem to be running at the same rate on the MD1 and MD2. The only other way the YM2612 could affect the speed at which the music progresses would be differences in the delay times between writes on the integrated vs the discrete chip, but my money is on the Z80. It's highly likely there are differences in instruction execution times between the integrated Z80 in the MD2, and the discrete chip in the MD1. [/QUOTE] If Z80 would the the trouble maker, then overclocking should help... and I just tried and it did help, but very little. I used 4.5MHz. Also, my MD2 has a discrete Z80, a clone by Toshiba, but this should not cause the slowdown as then my sound engine must sound wrong (slower for example, the poor Z80 is moving incredible amounts of data constantly). The game uses Timers, and the Timers run at same speed, and if there would be a Timer bug, overclocking would not have helped. So only possible cause would be the Busy bit of Sega YM2612 lasting longer... my sound engine completely ignores that bit, and so do many others. One thing I know is that the Busy bit doesn't last same time for all operations. Setting TL values seems to require more time than say writing to DAC. If it helps, on MD2, if you have a PCM playback loop and you wait for the Busy bit, then maximum sampling rate you get is somewhere near 33KHz. I have not done any tests on MD1 as I got my hands on some MD1s only recently. ######## POST p5706 | AamirM | 2008-07-04 | t386-090.html [QUOTE] Shiru wrote:About SSG-EG. MAME emulates it incorrectly too. Alone Coder did some fixes which I use in TFM MM. They not fix emulation completely, but makes sound more closer to real chip (YM2203) in some cases. His version of MAME code is included into TFM MM package, replayers/pc/mame/ folder. All changes in code can be found by search for 'Alone Coder' string. [/QUOTE] Hi, Thanks Shiru. I took some time to make some of those changes in my core and they seem to work pretty well. Didn't tested it heavily though. I'll be doing some more testing (means comparing to Kega [IMG ./images/smilies/icon_smile.gif] ) on this. BTW Nemesis, someone told me that the track 'Ammune Advice' in Dune is not emulated correctly by any emu (including Kega). Although I can't confirm this. Another thing to test out would be whether the behaviour of SSG-EG changes in ch3 special mode. I am thinking of putting up a new 'private' build of Regen with updates to FM core. stay safe, AamirM ######## POST p5707 | King Of Chaos | 2008-07-04 | t386-090.html Wow, glad to see all the progress so far. [IMG ./images/smilies/icon_smile.gif] Aamir, if you need a tester with good ears, I'm your man. [IMG ./images/smilies/icon_wink.gif] Good work Nemesis. [IMG ./images/smilies/icon_smile.gif] ######## POST p5711 | AamirM | 2008-07-05 | t386-105.html Hi, I was doing some SSG-EG stuff in Regen and just noted another thing that only Kega emulates. The sound test number 0xA in Asterix will sound different every time you play it. The difference is in the speed and amplitude of it. It seems these two factors depend on something. [QUOTE] King Of Chaos wrote:Aamir, if you need a tester with good ears, I'm your man. [IMG ./images/smilies/icon_wink.gif] [/QUOTE] Sure, I am still testing a few thing to make sure nothing is broken. I will put it up when I am done. stay safe, AamirM ######## POST p5716 | Nemesis | 2008-07-09 | t386-105.html Several things first up: 1. This is going to be a VERY long post 2. All this information relates specifically to tests I have performed on the YM2612. Although I may not always name the YM2612 specifically, it is implied that all this information has only been tested and verified on the YM2612. I'm going to make a number of references to the way things are implemented in MAME along the way, and specifically, some areas where the behaviour of MAME differs to the way the YM2612 behaves. The implementation in MAME is based on tests done on the YM2203 and YM2151. Note that where I point out that MAME emulates something incorrectly, that simply means the emulation in MAME doesn't match the behaviour of the YM2612. Someone with access to the YM2203 or YM2151 hardware would need to cross-check my findings with those chips to determine whether the MAME implementation is incorrect for all these chips, or whether the YM2612 differs from these chips on these points of behaviour. 3. I'm going to make a LOT of assertions in the following article about how the YM2612 carries out certain operations. I'm not always going to explain how I know these assertions to be true, or the tests I carried out to gather this information. In most cases, it is the combined result of a lot of tests, analysis of sampled results, and a lot of math. Providing a full description of all the tests I carried out would detract from the purpose of this article. Suffice to say, if I make an assertion, it is only because I have specifically tested and proven this aspect to be correct to my satisfaction, even if the information is available in the official documentation, or has been implemented a certain way by another emulator. If there is something I haven't tested and verified for myself, I will note it along the way. If you want to query a specific assertion I make, or you want more info about how I obtained certain results, just ask. 4. I'm going to be pointing out flaws in other people's emulators in this document. Please don't take it personally. Existing emulators are a reference for behaviour on the YM2612 as much as a document is, and I think it's important to be clear what is emulated accurately, and what is not. 5. Credit to Jarek Burczynski for his work on the MAME core. His implementation of the update process for the envelope generator in MAME is extremely accurate, and in the end my testing confirmed much of his implementation as being correct. And now without further ado, here's the result of the last 2 weeks of my life. What you're about to see is a full breakdown of how the YM2612 envelope generator works, including a comprehensive look at the SSG-EG mode. There is not a single emulator in existence at this point in time that implements everything from the following article correctly, so emulator authors should find it informative. YM2612: Clock sources First of all, an overview of the clock. The YM2612 is fed by an external clock source. The clock governs the speed at which the YM2612 performs all of its operations. In order to correctly emulate the YM2612, all aspects of its emulation must ultimately be tied back to the external clock. In the PAL Mega Drive, the external clock is 7610000Hz. Documentation tells us that Yamaha FM chips divide the external clock by the FM prescaler, to get the FM clock. In the case of the YM2612, the FM prescaler appears to be fixed at 6. Here's how you calculate the FM clock: FM Clock = External Clock / FM Prescaler FM Clock = External Clock / 6 FM Clock = 7610000 / 6 = 1268333.33r The FM Clock ultimately determines the sample rate of the YM2612 output, or in other words, the number of actual changes to the output that occur in a given period of time. Here's how you calculate the output frequency of the YM2612: Output Frequency = FM Clock / 24 Output Frequency = 1268333.33r / 24 = 52847.22Hz Interestingly, that divider of 24 is 6*4, or 6 channels times 4 operators. Maybe that's significant, maybe it isn't. All I've done at this stage is to verify the output frequency. This is where things get a little more interesting. The Envelope Generator does NOT update once for each sample the YM2612 produces, as you might initially expect it would. More than that, the envelope generator isn't even tied to the FM clock source. Testing has shown that the clock for the envelope generator is independent of the FM clock. Here is the formula for the rate at which the envelope generator updates: EG Clock = External Clock / 351 This may seem a little odd. I agree. I have tested and re-tested my results however, and the numbers come back the same. The ratio of the frequency output to the envelope generator clock is 1:2.4375. This directly contradicts MAME, which has the output cycle at a ratio of 1:3, or in other words, the envelope generator updates once for every 3 FM clock pulses. Comparing the output from MAME with the output from the YM2612 shows that MAME is incorrect however. Getting this update cycle for the envelope generator correct is important, and SSG-EG mode in particular is very sensitive to this. YM2612: Overview of the Envelope Generator The only purpose of the envelope generator is to generate a single number for each operator. That number is the attenuation value, or in simple terms, the amount to reduce the volume of an operator by. As an attenuation value, a high number produces a low volume, and a low number produces a high volume. The envelope generator outputs its attenuation value as a 10-bit number, giving a range of 0x000-0x3FF/0-1024. This output number is a simple linear progression from 0db to 96db. Here is the weighting for each bit in the 10-bit output of the envelope generator: [CODE] EG attenuation output bit weighting = 96 / 2^10 --------------------------------------------------------------------------------- | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |-------------------------------------------------------------------------------| | 48 | 24 | 12 | 6 | 3 | 1.5 | 0.75 | 0.375 | 0.1875|0.09375| --------------------------------------------------------------------------------- [/CODE] IE, a value of 0x20 is 3db, a value of 0x40 is 6db. Ultimately, the value of the envelope generator comes in its ability to automatically adjust this 10-bit attenuation value over time, based on a set of parameters. Under normal operation (no SSG-EG), the envelope generator creates a basic ADSR envelope. For the sake of brevity, I'm going to assume everyone reading this knows the basics of how the ADSR envelope in the YM2612 works, as it's sufficiently explained in the available documentation. YM2612: Decibels to samples The 10-bit attenuation output of the envelope generator is a linear scale in decibels. The decibel scale itself is logarithmic. If the envelope generator produces a linear increase in values, IE, incrementing the 10-bit output value by 1 for each clock pulse, the final curve that is produced by the YM2612 would be an exponential curve, not a straight line. This conversion from db to sample values is handled by the DAC for the FM module, not the envelope generator. Don't confuse the FM module DAC with the DAC registers at 0x2A/0x2B in the YM2612, that's a different thing entirely. The envelope generator doesn't know what a decibel is, or how it relates to the final samples the YM2612 produces. The only job of the envelope generator is to produce this 10-bit attenuation output. After all calculations have been performed by the envelope generator, and the final attenuation value is handed off to the DAC, it is only then that the conversion from decibels to actual sample values is performed, and it is at this point an otherwise linear progression becomes an exponential progression. This means when you're looking at sampled data and comparing it to the output of the envelope generator, you must always be comparing on the basis of decibels. This is probably obvious to anyone who has a bit of a background in audio, but I'm mentioning this because this confused me initially when I started looking at sampled output. YM2612: Inputs and internal data The envelope generator receives the following register data: [CODE] TL Total Level 7 bits SL Sustain Level 4 bits AR Attack Rate 5 bits DR Decay Rate 5 bits SR Sustain Rate 5 bits RR Release Rate 4 bits SSG-EG SSG-EG Mode 4 bits [/CODE] In addition, the YM2612 receives the following data for each operator, which will be discussed further later on: -Notification about key-on and key-off events -The current 4-bit key-scale value For each operator, the envelope generator stores the following data: -A register indicating the current phase being run in the ADSR envelope (Attack, Decay, Sustain, or Release) -A 6-bit calculated Rate value -The current 10-bit attenuation value -A flag indicating the polarity of the output. When this is set, the attenuation output is inverted. The envelope generator also keeps the following global data which is shared by all operators: -A running cycle counter of unknown size (not really important), which has enough storage for at least 14 bits of data. YM2612: Attack and Decay The ASDR envelope fundamentally only has two states: Attack and Decay. In the Attack phase, the attenuation value decreases exponentially, until it reaches 0. In the decay phase, the attenuation increases in a linear fashion until the attenuation reaches max, at which time no sound is produced for that channel. Decay, Sustain, and Release are all components of the decay phase, and for calculation purposes, they are all identical. With comparable settings, the same output will be produced from all three phases. When it comes to calculating envelopes, the only thing that makes the Decay, Sustain, and Release phases different from each other is that they calculate their decay rates using values from different registers, so the user can provide a different rate of decay for each state. When they are all set with comparable settings, the final waveform will be the same, regardless of what SL is set to or when key-off occurs. YM2612: Calculating Attenuation Values So we know the envelope generator maintains a 10-bit attenuation value for each operator. This is increased in a linear fashion during the decay phase, and decreased in an exponential fashion during the attack phase, but how and when are these adjustments made? This is the core of the envelope generator. The process occurs in several key steps. 1. The Rate Calculation The rate calculation is the first step in calculating attenuation values. The envelope generator performs the rate calculation once, as the operator enters a new phase of the ADSR envelope. It requires two pieces of data first: R: The rate value supplied in the register for the state currently running (AR,DR,SR,RR) Rks: The 4-bit Rate Key-Scaling value for the operator. Refer to page 29 in the YM2608 manual. With those two pieces of data, you then use the following formula to calculate the 6-bit internal rate number: Rate = (2*R) + Rks Special cases: -If R = 0, then Rate = 0, regardless of the value of Rks. -Rate is capped at 63. If the calculation result is greater than 63, Rate=63. -Note that the source registers for AR, DR, and SR are 5-bit, but RR is only 4-bit. In order to convert RR into a 5-bit value for use in this calculation, multiply it by 2, and add 1. In other words, you can think of RR as the upper 4 bits of a 5-bit rate value, with the LSB fixed to 1. This Rate number doesn't give you anything directly, just another number, but it is used in the following stages to adjust the attenuation. 2. The Update Cycle And here's the bit that's not documented. The rate calculation gives you a 6-bit rate value, but how is that actually applied to vary the 10-bit attenuation value over time? First of all, I'm going to throw a few tables at you: [CODE] Table 1: Counter shift values 11 11 11 11 0-3 (0x00-0x03) 10 10 10 10 4-7 (0x04-0x07) 9 9 9 9 8-11 (0x08-0x0B) 8 8 8 8 12-15 (0x0C-0x0F) 7 7 7 7 16-19 (0x10-0x13) 6 6 6 6 20-23 (0x14-0x17) 5 5 5 5 24-27 (0x18-0x1B) 4 4 4 4 28-31 (0x1C-0x1F) 3 3 3 3 32-35 (0x20-0x23) 2 2 2 2 36-39 (0x24-0x27) 1 1 1 1 40-43 (0x28-0x2B) 0 0 0 0 44-47 (0x2C-0x2F) 0 0 0 0 48-51 (0x30-0x33) 0 0 0 0 52-55 (0x34-0x37) 0 0 0 0 56-59 (0x38-0x3B) 0 0 0 0 60-63 (0x3C-0x3F) [/CODE] [CODE] Table 2: Attenuation increment values *0,0,0,0,0,0,0,0 *0,0,0,0,0,0,0,0 *0,1,0,1,0,1,0,1 *0,1,0,1,0,1,0,1 0-3 (0x00-0x03) 0,1,0,1,0,1,0,1 *0,1,0,1,0,1,0,1 0,1,1,1,0,1,1,1 *0,1,1,1,0,1,1,1 4-7 (0x04-0x07) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 8-11 (0x08-0x0B) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 12-15 (0x0C-0x0F) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 16-19 (0x10-0x13) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 20-23 (0x14-0x17) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 24-27 (0x18-0x1B) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 28-31 (0x1C-0x1F) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 32-35 (0x20-0x23) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 36-39 (0x24-0x27) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 40-43 (0x28-0x2B) 0,1,0,1,0,1,0,1 0,1,0,1,1,1,0,1 0,1,1,1,0,1,1,1 0,1,1,1,1,1,1,1 44-47 (0x2C-0x2F) 1,1,1,1,1,1,1,1 1,1,1,2,1,1,1,2 1,2,1,2,1,2,1,2 1,2,2,2,1,2,2,2 48-51 (0x30-0x33) 2,2,2,2,2,2,2,2 2,2,2,4,2,2,2,4 2,4,2,4,2,4,2,4 2,4,4,4,2,4,4,4 52-55 (0x34-0x37) 4,4,4,4,4,4,4,4 4,4,4,8,4,4,4,8 4,8,4,8,4,8,4,8 4,8,8,8,4,8,8,8 56-59 (0x38-0x3B) 8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8 8,8,8,8,8,8,8,8 60-63 (0x3C-0x3F) [/CODE] Think of this as a multidimentional array of [64][8]. For each of the possible 64 rate values, there are 8 integer values. Both these tables are based on information provided in MAME, but I've independently tested most of these values against the YM2612 output. I did find a few inaccuracies in the attenuation increment values provided in MAME. The entries marked with an asterisk differ from the values provided in the MAME core (For the record, yes, rate values of 2 and 3, 4 and 5, 6 and 7 do produce an identical output. That's not an error). Ok, so what do these tables do? The following pseudo C-like algorithm describes the basic process the envelope generator carries out each cycle. [CODE] ++globalCycleCounter For each operator //Read the shift value from Table 1 counterShiftValue = counterShiftTable[operator.rate] If (globalCycleCounter % (1 << counterShiftValue)) == 0 //Check the current cycle we're up to (0-7) updateCycle = (globalCycleCounter >> counterShiftValue) & 0x07 //Read the next attenuation increment value from Table 2 attenuationIncrement = attenuationIncrementTable[operator.rate][updateCycle] //Update the attenuation //The attenuation update process happens here. More on that in the next section. Endif Next operator [/CODE] The use of the global cycle counter makes this seem a little more complex than it really is. Basically, the Rate calculation determines two things: 1. How many envelope generator cycles will pass between updates Table 1 lists "Counter shift values" for each possible rate. If the value is 0, the attenuation will be updated every cycle of the envelope generator. If the value is 1, the attenuation will be updated every second cycle. If it's 2, updates will occur every 4 cycles, if it's 3, every 8, etc. At the max value of 11, the attenuation will only be updated once every 2048 cycles of the envelope generator. This allows extremely slow attack and decay. 2. How large the adjustments to the attenuation will be at each update Table 2 gives an 8-cycle loop of adjustment values for the attenuation, for each possible rate. The YM2612 works through these 8 values in a continuous loop. Each time the attenuation value for an envelope is updated, it will use the next sequential value in that loop to adjust the attenuation. In some cases, the value is 0, meaning even though an update cycle is triggered, no adjustments are made to the envelope on that cycle. For the larger rate values, the adjustments are more extreme. The way the attenuation update cycle has been setup allows the envelope generator to create envelopes that have an extremely long decay (up to 10223616 samples, or 193.5 seconds on a PAL Mega Drive, for a rate of 2), while still allowing high-resolution updates to envelopes that have an extremely short decay (as low as 312 samples for a rate of 63). The same is of course true of the attack phase. I think it's important to show how the contents of these two internal tables can be determined by measuring the external output of the YM2612, so allow me to show you a screencap: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/internal%20tables.png] You can clearly see the steps in the attenuation here, including the pattern of cycles where the attenuation is and is not modified. This wave was created in SSG-EG mode, so the changes in amplitude are larger than normal (more on that later), but you can observe the same effect without SSG-EG active. This particular wave was produced with a calculated rate value of 7. Looking at the table above, that gives it an update cycle pattern of 0,1,1,1,0,1,1,1. You can see that pattern coming through in the output. The counter shift values increase the length between the steps. This waveform also demonstrates the fact that the update cycle is based on a global clock. You can see at the start of this wave that there is a short period where the wave is held at 0db, before the first drop occurs. This drop does not occur at the same spacing as the rest of the changes that follow it. This demonstrates that each operator doesn't have its own running cycle counter. When you key-on an operator on the real system, it's possible for it to start at any point in the 8-cycle pattern of steps, and regardless of how large the spacing between steps, the first change in attenuation may happen at any time from the moment the note is keyed on, depending on what the global counter was up to when key-on occurred. YM2612: Updating and outputting attenuation values In the previous section, some pseudocode was presented showing the update cycle for attenuation values in the envelope generator. The part on actually adjusting the attenuation was left out. The update process is different between attack and decay. The decay phase is simpler, so I'll present that one first. The decay phase: [CODE] operator.attenuation += attenuationIncrement [/CODE] The decay phase is a simple linear progression. You add the increment value to the attenuation on each update. The attack phase: [CODE] operator.attenuation += attenuationIncrement * (((1024 - operator.attenuation) / 16) + 1) [/CODE] The attack phase is a little more complex. The attack phase produces an inverted exponential curve in attenuation, from maximum to minimum. This formula was derived after a little experimentation. This formula is only half the implementation however. In an earlier section, I mentioned that the envelope generator stores a flag for each operator indicating whether the output is inverted. During the attack phase, this flag is set. This effectively does a binary not of the attenuation when it is output, so 0x000 becomes 0xFFF, 0x12F becomes 0xED0, etc. For the output of attenuation values, here's the basic process: -Take a copy of the current internal 10-bit attenuation number -If the output invert flag is set, perform a binary NOT on the number -Add TL to the number. TL is converted to a 10-bit attenuation value first. A limit is applied to prevent the result from overflowing. YM2612: The ASDR envelope This is a quick summary of how the envelope generator manages the ASDR envelope. 1. Key-on occurs. -The envelope generator sets the operator to the attack phase -The rate parameter for the attack phase is calculated -The current attenuation value is cleared -The inverted output flag is set 2. The attenuation is continually adjusted, until attenuation reaches 0 -The envelope generator switches the operator to the decay phase -The rate parameter for the decay phase is calculated 3. The attenuation is continually adjusted, until the attenuation value reaches SL -The envelope generator switches the operator to the sustain phase -The rate parameter for the sustain phase is calculated 4. The attenuation is continually adjusted until it hits max At any point, key-off may occur. If it does, the following immediately occurs. -The envelope generator sets the operator to the release phase -The rate parameter for the release phase is calculated -The inverted output flag is cleared YM2612: SSG-EG mode Ahh yes, now we've reached that part that every emulator gets wrong: SSG-EG mode. Well, right into it. The key feature SSG-EG provides is the ability to repeat the decay and sustain phases of the ASDR envelope over and over again. First of all, here's the SSG-EG register, as it's presented in the YM2608 documentation: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20register.png] You'll see there are 8 patterns presented here, but there isn't any real indication given in the documentation of what these patterns mean, or how they affect the output waveform. What these patterns actually represent is a series of repetitions of the decay and sustain phases of the ASDR envelope, like so: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20pass1.png] [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20pass2.png] When the attenuation for the operator hits max, the envelope switches back to the attack phase. If you've got the attack rate set to 0x1F like the Yamaha documentation says you need to, you can effectively say the attenuation is reset to 0, and the envelope mode switches back to the decay phase. The next section will cover the interaction of SSG-EG with the attack phase. Each repetition within these patterns is selected from one of 4 basic modes. These modes affect the way the decay and sustain phases proceed. Each mode shows how the amplitude changes in the decay phase over time. Here are what each of the 4 modes do: 1. Normal [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20mode1.png] This mode represents the normal progression of the decay and sustain phases. The amplitude starts at the maximum level, and proceeds to the minimum level, or in other words, the attenuation increases from 0 to max. This is the way the decay and sustain phases would proceed without SSG-EG mode active. 2. Inverted [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20mode2.png] The inverted output flag is set for the operator during this repetition. The calculation remains the same, but due to the inverted output, the 10-bit attenuation value will proceed from maximum to minimum, or in other words, rather than "decaying", the output will be increasing in volume. 3. Held [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20mode3.png] The output is simply held at maximum attenuation (minimum volume). 4. Inverted Held [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20mode4.png] An inverted version of the above. The output is held at minimum attenuation (maximum volume). There's a better description of the 4 bits that set the SSG-EG mode than the one provided in the YM2608 manual. [CODE] SSG-EG: $90-$9E --------------------------------- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |---------------|---|---|---|---| | / / / / | E |ATT|ALT|HLD| --------------------------------- [/CODE] E = Enable. Unless this bit is set, SSG-EG mode is inactive, and none of the other bits have any effect. ATT = Attack. When this bit is set, the inverted output flag is initially set at the start of the first decay phase. ALT = Alternate. The inverted output flag is toggled after each repetition, alternating between 1 and 0. HLD = Hold. After the decay and sustain phases have completed one full pass, the output is held at the final level. Once hold mode begins, it doesn't end until key-off. If you look at the 8 patterns shown above, you'll see how these bits combine to create the patterns. Note that when you combine the ALT bit with hold, the inverted output flag is toggled before hold mode begins. There is a second effect that SSG-EG has on all envelope generator decay phases, including the release phase. When an SSG-EG mode is applied to an operator, each time the attenuation value is being updated, the increase is multiplied by a factor of 6. Note that the envelope generator does not update any quicker in SSG-EG mode. The update cycles remain the same, but the amount that is added to the attenuation value is increased by a factor of 6 in the YM2612. So, for the sake of completeness, as per the update formulae for the attack and decay phases given above, the following is the update formula for all decay phases under SSG-EG mode. [CODE] operator.attenuation += 6 * attenuationIncrement [/CODE] Note that the rate of change for the attack phase is not affected by SSG-EG mode, so the calculation previously given for the attack phase still stands. There are however a lot of other quirks to mention regarding the attack phase and SSG-EG mode. The interaction of the attack phase and SSG-EG is the topic of the next section. YM2612: SSG-EG and the Attack Phase Officially, Yamaha say the attack rate must be set to 0x1F in order to use SSG-EG mode. You can consider all behaviour of the YM2612 to be officially undefined and unsupported when you combine SSG-EG mode with an attack rate less than 0x1F. The effect of having an attack value less than 0x1F with SSG-EG enabled is that the attack phase will also be included in each repetition of the envelope. SSG-EG does a loop of the attack, decay, and sustain phases. Although the rate of change in the decay phases are increased by a factor of 6 when SSG-EG is applied, the rate of change for the attack phase is unaffected, and is evaluated in its normal fashion. Each repetition of the envelope triggered by SSG-EG will repeat the attack, decay, and sustain modes. The reason Yamaha say not to use the attack phase when SSG-EG is enabled, is because it really does mess things up. There are two issues it creates. The first issue relates to the nature of the calculation being performed to create the attack phase. The attack phase is an inverted exponential curve. The attenuation starts at maximum, and advances very quickly at first, but gradually slows as it approaches minimum attenuation. SSG-EG allows the output to be inverted. This doesn't change the actual calculation that is being performed in order to calculate the attack curve however, it literally just inverts the bits being output. This creates an attack curve which makes several extremely large, obvious steps from 0db, which are the most audible changes, while all the slower gradual changes occur at the other end of the scale, where the change in attenuation is much less noticeable. Here's a screenshot of what you get with an inverted attack curve: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/inverted%20attack.png] The second issue with combining an attack phase with SSG-EG mode is a little more subtle, and a lot more serious. If you look in an earlier section where I present pseudocode for the update process for the attack phase, you'll see that I mention the attack phase uses the output inversion bit to invert the output. Both the decay and attack phases use an incrementing value to represent the attenuation value, but the attack phase uses this output inversion setting to negate the output, which creates a falling attenuation (rising volume), instead of a rising attenuation (falling volume). The problem is, SSG-EG mode uses the output inversion bit too, and they end up interfering with each other. Sometimes the beginning of the attack phase will override the changes made by SSG-EG mode, and sometimes it will be the other way around. The worst thing is, because the update timing of the attack cycle, like all envelope update cycles, is tied to the global cycle count for the envelope generator, the results are inconsistent. If you repeat a key-on for the operator without changing any settings, you might get quite a different result. With a real attack phase and SSG-EG mode both active, the first two SSG-EG patterns always work correctly, as they don't affect the output inversion bit. Patterns which use the ATT bit to start the output inverted sometimes have their inversion overridden by the attack phase, so they will start non-inverted. Patterns which use the ALT bit are severely affected, as at the start of each repetition, including the first, there's a chance that it could go either way, so each successive repetition may either be inverted or not inverted. There's also often a cross-over period of one update cycle for the envelope phase, where the output inversion bit is set by SSG-EG, then overridden by the attack phase, creating a loud spike between each repetition. Here's a screenshot showing the messed up stuff you can get with the ALT bit set: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20messed%20up.png] And here's a screenshot showing the noise spike you get between each cycle even when it behaves: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ssg-eg%20spike.png] Emulating all these quirks would require exact knowledge of when these flags are set and cleared. I may do more work in this area at a later date. YM2612: Current emulator support for SSG-EG mode I haven't checked what emulators do about emulating SSG-EG mode with an attack phase, but here are some notes about current emulator support for SSG-EG mode in the YM2612. -MAME doesn't clear the inverted output flag on release, so release during an inverted output creates a constant tone. MAME also only multiplies the attenuation increase by a factor of 4 in the decay and sustain phases, not 6. Interestingly, MAME also does not adjust the rate of the release phase, which it should. -Kega doesn't do the release phase at all when SSG-EG is active, and messes up held notes. It does get the timing of the decay phase almost perfect however. -Gens doesn't clear the inverted output flag on release, so it has a constant tone problem like MAME does. Gens doesn't seem to increase the decay phase increment at all, so each repetition of the decay phase runs 6 times too slow. YM2612: SSG-EG Test ROM Finally, here's a quick test rom which uses all 8 SSG-EG patterns: http://nemesis.hacking-cult.org/MegaDri ... ssg-eg.bin Here's the source: http://nemesis.hacking-cult.org/MegaDri ... ssg-eg.asm And here's a sample of the output you get on a PAL MD1600 MegaDrive, recorded at 96KHz: http://nemesis.hacking-cult.org/MegaDri ... md1600.rar And on that note, I'm going to get some sleep. ######## POST p5717 | HardWareMan | 2008-07-10 | t386-105.html So, if we return to previous test with oscilloscope: [IMG http://img49.imageshack.us/img49/2044/ym26121mv6.jpg] we get that real single channel sample rate is: [QUOTE] Nemesis wrote:Output Frequency = FM Clock / 24 Output Frequency = 1268333.33r / 24 = 52847.22Hz [/QUOTE] And every channel have silence gap, that is mean 52847,22Hz / 2 = 26423,61Hz. That is close to measured with oscilloscope, but not equival. We need to re-measure that very carefully.... ######## POST p5718 | Nemesis | 2008-07-10 | t386-105.html I don't have access to any equipment right now, but I did my own measurements of the output with an oscilloscope during this process, and the numbers I got back matched this calculation as I recall. I didn't record any of the results though. I'll be able to test this again in a day or two, so I'll measure the output frequency again and snag some results. ######## POST p5719 | Eke | 2008-07-10 | t386-105.html wow, this is great and definitively the technical doc I was waiting for since long long time [IMG ./images/smilies/icon_eek.gif] It describes the internal mechanism pretty well ,and also help me a lot to better understand the MAME emulator implementation just to clarify something, Shiru mentionned this in another thread http://www.spritesmind.net/_GenDev/foru ... .php?t=231 [QUOTE] Shiru wrote:Alone Coder already did some tests on YM2203, which was verified on YM2612 - so we already knew about most of other registers, but not about special mode on/off. So, if we change registers after KEY ON but before KEY OFF: - TL, MULT, DET changes sound properly and immediately - AR, DR, SR, RR, Feedback changes does not affects on currently playing note, but affects properly after new KEY ON I forgot about SL, RS, but generally seems like changing of any registers, which controls amplitude and frequency is affects immediately, and changing of any registers, which controls envelope parameters and algorithm is affects after new KEY ON. Alone Coder did used fact about AR/DR/etc in his compiler of TFM music to preload some values by frame before corresponding KEY ON, that allow to reduce number of register writes per frame (by moving some of writes to prev. frames). That works fine both on TFM device and SMD. [/QUOTE] So, according to you, as the env rates are calculated at the start of each phase, would this mean that register values are also latched at the same time and not all together on Key ON as mentionned above ? btw, just a minor suggestion but, in your frequency calculation and approximations, you should use the the exact clock values:53693175/7 for NTSC and 53203424/7 for PAL [IMG ./images/smilies/icon_wink.gif] this would make 52781.17 Hz for pal ######## POST p5720 | Shiru | 2008-07-10 | t386-105.html [QUOTE] Shiru wrote:- AR, DR, SR, RR, Feedback changes does not affects on currently playing note, but affects properly after new KEY ON [/QUOTE] I was wrong about Feedback, actually it changes sound immediately too. ######## POST p5721 | Nemesis | 2008-07-10 | t386-105.html [QUOTE] So, according to you, as the env rates are calculated at the start of each phase, would this mean that register values are also latched at the same time and not all together on Key ON as mentionned above ? [/QUOTE] Hmmm. To be honest, I didn't thoroughly test this particular aspect. I meant to double-check this point before I made this post, but I ran out of time. I was going to be doing far more extensive tests on when various register changes are applied at a later date. I did get results that indicated rate values could be changed after key-on, but I can't recall if this was combined with CSM or SSG-EG mode at the time, which could potentially have affected the result. Consider this suspect until I can re-test. ######## POST p5722 | Eke | 2008-07-10 | t386-105.html For the record, the MAME core resets the shift & increment values immediately after that: 1) the register values for the according rates (AR,DR,SR,RR) are modified 2)Rks is modified (either KSR register is modified or frequency/block is modified) I think the introduction of Batman&Robin is pretty sensitive to that: I needed to modify the set_ar_ksr function to make it sound correctly PS: some other differences I notice between MAME core and your tests around enveloppe shift & increments: 1/ the MAME implementation use a dedicated enveloppe increment value when calculated Attack Rate is 62 or 63: it uses +16 instead of +8 in this special case. 2/ shift values are wrong when R = 0 (in the formula Rate = 2xR +Rks, Rate should be 0 when R=0), shift value of 0 is usead instead of 11. 3/ in the case of RR, Rate is not forced to 0 if RR = 0 4/ the current attenuation value is NOT cleared at KEY ON ######## POST p5723 | TmEE co.(TM) | 2008-07-10 | t386-105.html http://www.fileden.com/files/2008/4/21/ ... SSG-EG.rar This is the recording of the SSG-EG test ROM from my MD2. I cut out the silence to get smaller file... it seems to work exactly like real YM2612 (but cleaner signal). ######## POST p5724 | Nemesis | 2008-07-11 | t386-105.html [QUOTE] For the record, the MAME core resets the shift & increment values immediately after that: 1) the register values for the according rates (AR,DR,SR,RR) are modified 2)Rks is modified (either KSR register is modified or frequency/block is modified) I think the introduction of Batman&Robin is pretty sensitive to that: I needed to modify the set_ar_ksr function to make it sound correctly [/QUOTE] So that means rate changes are applied immediately in MAME? That could be correct. I'll run some tests on this ASAP. [QUOTE] 1/ the MAME implementation use a dedicated enveloppe increment value when calculated Attack Rate is 62 or 63: it uses +16 instead of +8 in this special case. [/QUOTE] That's their way of eliminating the attack phase. When Rate = 62 or 63 during attack, the attack phase is skipped. MAME use this calculation to immediately force the result to TL, but based on the behaviour I've observed with CSM and SSG-EG, I think it far more likely that the YM2612 doesn't even enter the attack phase, and skips straight to decay when the calculated attack rate is greater than 61. I probably should have written that in as a special case. [QUOTE] 2/ shift values are wrong when R = 0 (in the formula Rate = 2xR +Rks, Rate should be 0 when R=0), shift value of 0 is usead instead of 11. [/QUOTE] There's actually no way to know what the shift value is set to when Rate = 0, and it doesn't make a difference in the end, since no updates are made even when the counter does expire. I've got the shift value set to 11 in this case as it fits with the pattern, but it wouldn't make any difference if they set the shift counter to 0. Likewise, there's no way to know what increment values are used for a Rate of 1, since there's no way for this case to arise. [QUOTE] 3/ in the case of RR, Rate is not forced to 0 if RR = 0 [/QUOTE] That's because RR is a 4-bit value. For the rate calculation, RR is treated as a 5-bit value with the LSB set to 1, and it's after this conversion that the check is made, so Rate can never equal 0 in the release phase. [QUOTE] 4/ the current attenuation value is NOT cleared at KEY ON [/QUOTE] Yeah, I think they might be right about that actually. That calls into question my assertion that the YM2612 uses an output invert bit for the attack phase. Some behaviour in SSG-EG mode suggests it does, but this suggests it doesn't. Well, rather than resetting the contents of the attenuation register, they could be doing a binary NOT at the start of the attack phase, to adjust the attenuation into a compatible number. That sounds most likely to me at this stage. ######## POST p5728 | Stef | 2008-07-11 | t386-105.html Very interesting technicals informations ! Thanks for spending that much time in testing then writing your founds. It's exactly that type of informations we need for accurate emulation, i'm really motived to rewrite a new YM2612 core now :p ######## POST p5729 | TmEE co.(TM) | 2008-07-11 | t386-105.html Go Stef !!! I like Gens, and it desperately needs better sound (with good DAC support so my sound engine would sound NICE) [IMG ./images/smilies/icon_smile.gif] Now that I know how SSG-EG works, I could have some cool instruments [IMG ./images/smilies/icon_smile.gif] ######## POST p5730 | Eke | 2008-07-11 | t386-105.html [QUOTE] notaz wrote: [QUOTE] Eke wrote:what did you do exactly to fix the MAME core ? [/QUOTE] I changed the start of refresh_fc_eg_slot() to this: [CODE] INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT, int fc, int kc) { int ksr, fdt; /* (frequency) phase increment counter */ fdt = fc+SLOT->DT[kc]; /* detect overflow */ if (fdt < 0) fdt += fn_table[0x7ff*2] >> 2; SLOT->Incr = fdt*SLOT->mul >> 1; ... [/CODE] Note that this only works when sampling @ 44.1hHz, so it's probably wrong. Multiplier may have something to do with all this too. [/QUOTE] side note: this requires the YM2612 to be emulated at the original frequency (i.e HQ YM2612 mode) to work properly I implemented the Gens interpolation method (anyone know about other resampling algorithm ?) in MAME to get it working but doing this: [QUOTE] fc += SLOT->DT[kc]; if (fc < 0) fc = (UINT32)((double)ym2612.OPN.fn_table[0x7ff*2] / ym2612.OPN.ST.freqbase) + SLOT->DT[kc]; [/QUOTE] apparently make it work is both case (tested @48kHz) ######## POST p5765 | AamirM | 2008-07-18 | t386-105.html Hi, Great work once again Nemesis! Thanks for all the work your doing. stay safe, AamirM ######## POST p5870 | Arbee | 2008-08-02 | t386-105.html Hi. I'm looking to fold all of these fixes into official MAME. I see TFM/MM has a modified MAME core with some fixes and the Flashback fix was posted here. If anyone else has been tinkering with a MAME-derived FM core based on these findings or other tests against real h/w I'd love to see your changes. Please PM me if you'd rather not post them inline. Thanks in advance! ######## POST p5871 | Eke | 2008-08-02 | t386-120.html [QUOTE] Hi. I'm looking to fold all of these fixes into official MAME. I see TFM/MM has a modified MAME core with some fixes and the Flashback fix was posted here. If anyone else has been tinkering with a MAME-derived FM core based on these findings or other tests against real h/w I'd love to see your changes. Please PM me if you'd rather not post them inline. Thanks in advance! [/QUOTE] here is my modified MAME fm.c in genesis plus: http://code.google.com/p/genplus-gx/sou ... sound/fm.c [QUOTE] - added DAC filtering - fixed internal FM timer emulation - removed unused multichip support and YMxxx support - fixed CH3 CSM mode (credits to Nemesis) - implemented PG overflow, aka "detune bug" (Ariel, Comix Zone, Shaq Fu, Spiderman,...), credits to Nemesis - implemented sample interpolation, highly based on GENS code (HQ YM2612) - fixed SSG-EG support, credits to Nemesis and additional fixes from Alone Coder - modified EG rates and frequency, tested by Nemesis on real hardware - fixed EG attenuation level on KEY ON (Ecco 2 splash sound) - fixed LFO phase update for CH3 special mode (Warlock, Alladin), thanks to AamirM [/QUOTE] ######## POST p5873 | Arbee | 2008-08-02 | t386-120.html Thank you VERY much! I appreciate it [IMG ./images/smilies/icon_smile.gif] ######## POST p5885 | Nemesis | 2008-08-06 | t386-120.html For the record, I haven't finished working on this chip. Not by a long shot. Since I last posted I've written my own YM2612 core from scratch, and I'm using that as a testing ground to verify my model of the YM2612 internal structure, based on tests and observed behaviour on the hardware. The next info I post will be a complete description of the phase generator, operator unit, accumulator, and DAC. It might take awhile to complete however. I don't have as much spare time right now as I'd like, and I need to make sure I've got all my facts straight. ######## POST p5886 | HardWareMan | 2008-08-06 | t386-120.html I will wait for this look! ######## POST p5887 | Eke | 2008-08-08 | t386-120.html [QUOTE] Arbee wrote:Thank you VERY much! I appreciate it [IMG ./images/smilies/icon_smile.gif] [/QUOTE] I saw that you have updated fm.c in MAME, that's cool [IMG ./images/smilies/icon_smile.gif] anyway, I forgot to notify about this also [QUOTE] ** - fixed Attack rate refresh (fix Batman&Robin introduction) [/QUOTE] the change is in set_ar_ksr() function: the code assume that if the KSR value is changed, AR will be refreshed during Phase recalculation but even if it is often the case, it seems that under specific condition (if AR and KSR values are changed but kc >> KSR does not change), AR is not refreshed that's why Attack Rate should ALWAYS be refreshed in set_ar_ksr(), as soon as AR is modified. This fixes intro sound in Batman&Robin. ######## POST p5888 | Arbee | 2008-08-08 | t386-120.html Thanks for the tip, Eke. I'll pick that fix up. Incidentally, submitting those changes woke up Jarek B. I pointed him to this thread so hopefully he'll decide to work with you guys and we can get OPN totally perfect. In the meantime at least it sounds like Haze is going to work on HazeMD again now that he can do it without people whining that GEMS games sound wrong, so there's some positive results [IMG ./images/smilies/icon_smile.gif] ######## POST p5890 | Nemesis | 2008-08-09 | t386-120.html Nice! I'll have to give the new core a spin. [IMG ./images/smilies/icon_biggrin.gif] BTW, I notice that CSM support wasn't implemented in the official source, and you note in your development copy that it wasn't working correctly. Is that an implementation issue, or have you found cases where my description doesn't match the expected behaviour? Let me know if you come across any cases that call my results into question. I'm happy to be proven wrong on something, I just want to make sure the right information is out in the public domain. Feel free to ask me any questions you might have as well, either publically or via IM. The same goes for anyone else trying to apply this information. ######## POST p5891 | Eke | 2008-08-09 | t386-120.html no, it works correctly (at least, your test ROM works) initially it didn't work because setting KEY ON then key OFF without updating the enveloppe attenuation level obviously did not work I fixed that by immediately forcing attenuation level to MAX when Key ON is set and Attack rate is maximum (this was usually done on the next enveloppe update) I should fix the commentary asap ######## POST p5898 | Arbee | 2008-08-11 | t386-120.html Has anyone looked into the proper FM/DAC balance yet? In current MAME the DAC seems to be too loud (I think we just mix the written sample value directly into the chip's output) but I'd love to have a tested value to attenuate it by. ######## POST p5917 | Nemesis | 2008-08-13 | t386-120.html I'm partway through that process now. The key to getting the levels right lies in the accumulator. The accumulator takes an (almost certainly) 13-bit input from the operator unit, and definitely produces a 16-bit output for the embedded YM3015/YM3016 DAC for each channel. When the "DAC Enable" flag in register 0x2B is set, the accumulator simply drops the 13-bit operator output for channel 6, and maps the 8-bit "DAC Data" register contents in register 0x2A to that channel instead. In order to get the levels right, we simply need to know: 1. How the 13-bit operator output from one or more operators are combined into the 16-bit output for that channel. This will include any clipping operations which may or may not occur. 2. How the 8-bit DAC Data is converted into a 16-bit value. The accumulator may directly convert the 8-bit data to 16-bit (probably just by using it as the MSBs of the output), or it might convert the DAC data to a 13-bit input, and latch it several times, as if it was latching the output from several operators. I haven't done any specific tests yet to determine how the accumulator maps its inputs to the 16-bit DAC output, but I'll be doing them soon. I'm hoping I can use the test register to digitally latch the full 16-bits of data which are being sent directly to the DAC, which would allow a precise calculation to be made. The notes that are out there describing the test register indicate this should be possible, but I haven't attempted it yet. ######## POST p5919 | HardWareMan | 2008-08-13 | t386-120.html As I already said , YM2612 has time-multiplexed output: 1 DAC and each channel in turn set its current DAC code. And timeslot #6 shared between Ch6 and DAC register (0x2A). [IMG http://img367.imageshack.us/img367/5593/ym26122mg1.jpg] So, IMHO, there are no clipping may occur. ######## POST p5921 | Nemesis | 2008-08-13 | t386-120.html I'm aware of the multiplexed output for the channels themselves. The clipping I was referring to was in relation to the operators. Depending on the algorithm selected for the channel, there may be multiple operators being combined into a single channel, eg, in the case of algorithm 7, you've got 4 13-bit operator outputs being combined into a single 16-bit output. The accumulator might clip the output if you were to try and combine all 4 operators at max volume, depending on how it operates. It should be easy enough to determine how the accumulator is calculating its output, which will answer this question. ######## POST p5926 | TmEE co.(TM) | 2008-08-13 | t386-120.html The sine(s) are distorted at low TL values, but not clipped... at least that is what my recordings showed. ######## POST p5934 | Chilly Willy | 2008-08-13 | t386-120.html [QUOTE] Nemesis wrote:I'm aware of the multiplexed output for the channels themselves. The clipping I was referring to was in relation to the operators. Depending on the algorithm selected for the channel, there may be multiple operators being combined into a single channel, eg, in the case of algorithm 7, you've got 4 13-bit operator outputs being combined into a single 16-bit output. The accumulator might clip the output if you were to try and combine all 4 operators at max volume, depending on how it operates. It should be easy enough to determine how the accumulator is calculating its output, which will answer this question. [/QUOTE] Four 13 bit values cannot clip when combined into a 16 bit value. In fact, a 16 bit value can be the sum of eight 13 bit values w/o clipping. Any more than that might clip. ######## POST p5939 | Nemesis | 2008-08-13 | t386-120.html If they're simply being added, yeah. That might not be the case however. I personally suspect the 13-bit output is being shifted up by 1 to make each operator a 14-bit output (or the operator unit actually does use 14-bit resolution internally. I'll be testing for that), and then they are simply being added, which would mean there would be no clipping. I'll know for sure once I run some tests though. ######## POST p5941 | Eke | 2008-08-14 | t386-135.html If I refer to the YM2151 diagram (this is I know a whole different chip but the data bus width for EG and PG seem to be the same as in YM2612), it is indeed a 14-bit input into ACCumulator [IMG http://img372.imageshack.us/img372/7429/ym2151vj3.th.gif] PS: Arbee, if you read this, I found another little "bug" in SSG-EG implementation for MAME: in function advance_eg_channel, the variable swap_flag is used for all 4 operators but is not reseted between operators. This variable is used to swap (or not) the "invert output" flag at the end of the decay phases. the result is that if two operators use different SSG-EG settings, this will interfere between each other also, as the flag ssgn is modified several time during SSG-EG enveloppe, it should be reinitialized with the initial SSG register value when a KEY ON occurs ######## POST p5958 | Nemesis | 2008-08-15 | t386-135.html Heh, so much for assumptions. -The operator unit does output a native 14-bit value. There's no shifting or other such voodoo. The operator unit calculates a true 14-bit value internally. MAME currently calculates this as a 13-bit value, probably because the way modulation has been implemented suggests a 13-bit value, and I'd made the same assumption in the first build of my core. Turns out we're both wrong. The internal sine table should store a 14-bit value. That's the second time I've thought that YM2151 diagram was wrong about something, and the second time it's turned out to be correct. -Clipping DOES occur when operators are combined. The accumulator maps a single 14-bit operator output to the upper end of the 16-bit dynamic range of the DAC input ( operator output<<2 ). The accumulator limits the result to the 16-bit maximum, so if you were to try and combine two operators with a TL of 0, you'll get the upper half of the wave clipping. Try and combine 4 operators and you'll get the upper 3/4 of the wave clipping. You've got to have the right equipment to measure this properly. If you record from a sound card, you'll see what appears to be a "distorted" wave, as when the wave clips, the soundcard will try and balance the input back to 0, so you'll see a logarithmic decay even though the voltage is holding steady. Use an oscilloscope and the result is clear. -After the DAC data is converted from unsigned to signed (DAC Data - 0x80), the result is simply mapped to the upper end of the 16-bit DAC input ( DAC data<<8 ). Since the lower bits are set to 0, the maximum DAC output is slightly lower than that of an fm channel, due to 6 less bits of significant data. That should be everything required to get the FM and DAC levels right. ######## POST p5959 | TmEE co.(TM) | 2008-08-15 | t386-135.html Guess I have to get rid of couple of parts from my sound card then... Can you test the MD2 DAC output ? MD1 DAC output it filled with aliasing noise, whereas MD2 DAC output is much cleaner. ######## POST p5960 | Nemesis | 2008-08-15 | t386-135.html It occurred to me that the next thing someone's going to want to know is how to balance the YM2612 output against the PSG, so I did some tests on that. All 4 PSG channels at max combined is equivalent to the maximum output of a single YM2612 channel at max. Remember however that the YM2612 multiplexes the channel outputs, as shown by HardWareMan, which means the total output power at a given point in time will never exceed the maximum output of a single channel. It also means that each channel is not actually playing constantly. I'm unsure of the audible effects of multiplexing. It may create an apparent drop in volume for the YM2612, but that's not one you can measure digitally. A minor correction to what I wrote above as well. The output circuitry for the Mega Drive is responsible for the "distorted" waveform when the YM2612 clips, it wasn't my soundcard. If you sample direct from the chip (like I did with my oscilloscope) you get the proper waveform. When I repeat the same process sampling the final output, I get the same waveform on my oscilloscope as I recorded on my PC. The output circuitry has the same effect on the PSG output signal, which being a square wave generator always flatlines, so that's the primary cause of the distorted PSG waveform outlined by Maxim in SN76489.txt. The actual decay when sampling direct from the chip is barely measurable, even at the minimum frequency. ######## POST p5961 | Nemesis | 2008-08-15 | t386-135.html [QUOTE] Can you test the MD2 DAC output ? MD1 DAC output it filled with aliasing noise, whereas MD2 DAC output is much cleaner. [/QUOTE] There's a bit of noise on all the output signals, but I've taken that into account. It wouldn't affect the results of these tests. It might make the DAC sound worse, but I've got enough data to be confident in how the output is generated, before it's affected by analog interference. I probably will do some tests on a MD2 at some point in the future anyway, but right now I haven't got any "modded" MD2's to perform easy tests on. ######## POST p5964 | TmEE co.(TM) | 2008-08-15 | t386-135.html My MD2 is having its audio part completely replaced with something much much better... only noise there is, is the VDP activity noise in the PSG line. ######## POST p5969 | HardWareMan | 2008-08-16 | t386-135.html [QUOTE] Nemesis wrote:-After the DAC data is converted from unsigned to signed (DAC Data - 0x80), the result is simply mapped to the upper end of the 16-bit DAC input ( DAC data<<8 ). Since the lower bits are set to 0, the maximum DAC output is slightly lower than that of an fm channel, due to 6 less bits of significant data. [/QUOTE] I think, you mean "8 bits" not "6 bits", becouse DAC is 16 bit and DAC register is 8 bits. And to convert usigned 8 bit value to signed 8 bit value you need just do "XOR" by 0x80 (or just invert most significant bit). ######## POST p5971 | Nemesis | 2008-08-16 | t386-135.html [QUOTE] I think, you mean "8 bits" not "6 bits", becouse DAC is 16 bit and DAC register is 8 bits. [/QUOTE] No, I meant 6 bits. The output from the operator unit is a 14-bit value. This is shifted up by 2 to create the 16-bit output to the DAC. The DAC register gives an 8-bit value. This is shifted up by 8 to create the 16-bit output to the DAC. Comparing the maximum and minimum possible values from the DAC register (8-bit) with the output from the operator unit (14-bit), there's 6 less bits the DAC register is able to populate with significant data. OTOH, it might be 8-bits afterall, depending on whether the operators are summed before they're converted to 16-bit values, or after. If the operator output is converted to a 16-bit value before each operator is summed, it would be possible for the lower 2 bits to be populated with meaningful data. If the operators were summed as 14-bit values, then the final value was shifted up by 2 when it's output to the DAC, the lower two bits would always be unset. I have yet to confirm which one is correct. [QUOTE] And to convert usigned 8 bit value to signed 8 bit value you need just do "XOR" by 0x80 (or just invert most significant bit). [/QUOTE] You could, but I prefer to do the subtraction, as the processor will then perform sign extension and give a valid 2's compliment value even if you're using a datatype larger than 8-bit. ######## POST p5974 | Nemesis | 2008-08-16 | t386-135.html Wow. Jarek, if you're reading this, you're a genius. I thought the MAME implementation of the operator unit was inaccurate. I just spent the last 6 hours sampling data from the YM2612, and the end result is, I've just confirmed that your implementations of sin_tab and tl_tab really are 100% binary accurate. You've even figured out algorithms to generate the exact datasets [IMG ./images/smilies/icon_eek.gif]. I'm not sure that MAME is going to benefit much from the next batch of info I publish. Everything I've tested so far seems to be emulated perfectly, with the possible exception of the accumulator which I simply haven't checked in MAME. Still, it should be a useful resource for anyone else writing their own core, or who simply wants to better understand the MAME implementation. ######## POST p5975 | Eke | 2008-08-16 | t386-135.html I'm sure he is, just look how his enveloppe generator implementation quite exactly matches your results However, the work you are doing here and the way you document it is still priceless for me, at least to finally understand the MAME implementation ######## POST p6021 | Arbee | 2008-08-19 | t386-135.html Honestly, one of the big problems with MAME's FM has been that it's not well documented. If you'd like to add comments explaining how it works we'd be more than happy to include them. ######## POST p6040 | Nemesis | 2008-08-20 | t386-135.html I might take you up on that. Once I've finished running tests and I've got everything documented, I'll consider going through the MAME core and commenting the implementation. The operator unit in particular needs a lot more info given. I'll get in touch with you when I'm thinking about starting. ######## POST p6089 | Eke | 2008-08-23 | t386-135.html Nemesis, I have a question for you: the MAME core implement some kind of delayed sample operator (MEM) for some algorithms, did you verify this happen on a real YM2612 ? ######## POST p6090 | Nemesis | 2008-08-23 | t386-135.html It's clear that the operator unit does have an internal temporary storage location which can hold the output of at least one operator. There's actually no way to verify what the operator unit stores from any tests on the system, but you can determine a lot from just looking at the way the algorithms are arranged. If you look at all of the algorithms, it seems clear that the YM2612 always calculates operators 1-4 sequentially for each algorithm. You'll notice if you look at each arrangement that in every case, operators are only modulated by operators with a lower number. This is the reason operator 4 never modulates another operator for example. Also, in cases where an operator is only being modulated by a single operator, that operator is always the operator immediately before it in the sequence. We know carriers have their output sent directly to the accumulator and that's the end of it. Operators which directly modulate another operator can simply have their output fed directly into the input for the next operator and they never need to be stored. Some of the algorithms in the YM2612 however involve the output from multiple operators being summed together to modulate another. The only way the operator unit can achieve this is if it has a temporary storage location where it can save the output from one of these operators into, so that it is then free to evaluate the other operator, then sum the result of the two. There's also algorithm 5, which involves the output of operator 1 being fed into all 3 other operators, which again requires the result to be stored. Looking at the algorithms, none of the patterns would ever require more than one result to be stored when the operators are evalulated sequentially. It makes sense that there's a single "mem" slot inside the operator unit which can buffer a single result, which is used as this storage location. The only other option would be that the output of all 4 operators are saved along the way, but seeing as Yamaha designed their algorithms to allow them to get away with only one, and storing the output makes the device more complex, it's almost a given that there is simply a single cached storage location where an operator output can be stored. ######## POST p6092 | Eke | 2008-08-23 | t386-135.html [QUOTE] Operators which directly modulate another operator can simply have their output fed directly into the input for the next operator and they never need to be stored. [/QUOTE] So, with this in mind, would you think Algorithm #0 (all operators chained) would require MEM ? I'm asking this because I got some musics in Mega Turrican (track 3,6,9...) playing wrong with the MAME core: for each of this track, the channel that is wrong always use algorithm #0 with the same configuration (feedback =7,... see attached picture here: http://gxdev.files.wordpress.com/2008/0 ... rrican.jpg ) If I switch to the GENS core, musics are fine If I modify the MAME core to make C1 outputs directly to M2 without using MEM, it seems to fix also the problem You can easily listen the difference using the current in_vgm for winamp which can switch between the two cores http://www.smspower.org/maxim/forumstuf ... in_vgm.zip . vgm files are here: http://project2612.org/details.php?id=140 . incriminated tracks are "Stage 1-2" & "Stage 1 Boss" tracks GENS does not use delayed sample operator btw ######## POST p6093 | Nemesis | 2008-08-24 | t386-150.html Ahh, I hadn't looked into the algorithm implementation in MAME. The MEM storage in MAME has nothing to do with what I was just talking about. They've implemented this MEM storage as something which actually holds over the output of a particular operator for each channel between samples. In MAME, portions of most of the algorithms are actually fed with the calculated MEM value from the previous sample. I'm definitely suspicious about that. I see no reason for this to occur, especially as the operator unit still has to calculate all 4 operators each sample anyway. It's making the device more complicated and less accurate for no good reason as far as I can see. I can't confirm or deny this behaviour until I test for it. I was going to be doing smiliar tests on channel 1 self-feedback. I'll make sure I expand those tests to look for any "delayed sample" behviour from any of the operators. If you modified MAME to remove the MEM storage and it fixed the problem though, that's pretty strong evidence this delayed sample storage doesn't exist for algorithm 0 at least. ######## POST p6094 | Eke | 2008-08-24 | t386-150.html well, I should modify my statement: removing the MEM in algorithm #0 does not solve the problem, I had to modify the self-feedback too so maybe this is more something wrong with self-feedback implementation ######## POST p6095 | AamirM | 2008-08-24 | t386-150.html Hi, I think the delayed sample actually does exists (and its emulated in Regen). The reason? Well it will sound fine in Gens but if you listen very closely to the track 3 of Mega Turrican in Gens some instruments will come a bit early then they should be. Again, you should listen very carefully other wise you won't notice the difference.Here is a recording from the real hardware for the relevant part. I've only seen Regen and Kega that emulate it perfectly. I think its not related to delayed sample. I think it some kind of inaccuracy in envelope generator. stay safe, AamirM ######## POST p6096 | Eke | 2008-08-24 | t386-150.html The problem in MAME core with those tracks seems to be more related to feedback implementation, especially when the feedback value is 7... I re-tested and the MEM delayed sample has nothing to do with that, my bad... About self-feedback, here is how I understand how it works according to the documentation: for slot 1 only, the phase input of the sin tab can be added by a factor of the slot ouput : S1(t) = E1(t) x sin (w1.t + B.S1(t)) The factor B is given by the following table, depending of the feedback register value: [QUOTE] v=0 -> B = 0 v=1 -> B = PI/16 v=2 -> B = PI/8 v=3 -> B = PI/4 v=4 -> B = PI/2 v=5 -> B = PI v=6 -> B = 2.PI v=7 -> B = 4.PI [/QUOTE] In an emulator, I initially thought a straight implementation was doing something like that, for each sample: [QUOTE] PHASE += OUT x feedback_factor OUT = SIN_TABLE[PHASE][ENV] [/QUOTE] but both MAME and GENS implementation use something more like : [QUOTE] PHASE + (OLD_OUT + OUT) x feedfack_factor OUT = OLD_OUT OLD_OUT = SIN_TABLE[PHASE][ENV] [/QUOTE] probably it is more correct, I'm still not sure why About the feedback factor (or shift value), here is how I understand it: the relation between frequency and phase is: w =2xPIxfreq this would mean the B factors (shifts) would be, in term of frequency (calculations in emulators are based on frequencies increment): 0, 1/32 (>>5), 1/16 (>>4), 1/8 (>>3), 1/4 (>>2), 1/2 (>>1), 1 (>>0) and 2 (<<1) Now each core are dealing with this differently: - gens core is doing PHASE += (OUT + OLD_OUT) >> FB where FB = 9 - v - Mame core is doing (only if v !=0) PHASE += (OUT + OLD_OUT) << FB with FB = 6 + v I guess the Gens core is translating the 13-bits OUT value is in a 10-bits phase value (>>3) then applying the feedback factor (see above) I still don't understand the MAME implementation yet ps: for the record, here is the US patent describing self-feedback: http://www.google.com/patents?id=IeA3AAAAEBAJ another one describing FM synth in detail: http://www.google.com/patents?id=GNEzAAAAEBAJ ######## POST p6114 | Nemesis | 2008-08-28 | t386-150.html Well, I can't answer the questions about self-feedback yet. I haven't started doing any serious testing of self-feedback, but when I do, I'll definitely investigate these issues and see if I can track down the cause. I can post a lot of info about other aspects of the operator unit however. They should be an interesting read for someone. I've also finished my testing on the phase generator and accumulator. I'll write up my findings in those areas once I've got some time free. Until then, here's the OPN operator unit in a nutshell. The core of the operator unit is the process involved in evaluating a single operator. That process involves taking a 10-bit output from the envelope generator, a 10-bit output from the phase generator, a 10-bit phase modulation input (generated by the operator unit itself from either self-feedback or modulation by another operator), and producing a single 14-bit result, which is then either output to the accumulator or used to modulate another operator. The steps involved in generating this 14-bit output are IMO the most poorly expressed and documented parts of the MAME core, and you'd be hard pressed to figure out what was going on by looking at the MAME implementation alone. There's one very important thing to note before I say anything more about the operator unit. There's a very big lie in all of the OPN documentation. You will read time and time again that the envelope generator has the power to attenuate the output by between 0db and 96db. This is incorrect. In fact, the envelope generator can only attenuate the output by 0db to 48db. This doesn't change anything about how you implement the envelope generator itself, but for every table you see in any documentation that discusses decibels, you need to divide every value by 2 to get the real attenuation values. TL is actually 0-48db. SL is actually 0-12db (or 48db when all set), and the 10-bit output of the envelope generator itself is of course 0 to 48db. There wouldn't be much point in giving the envelope generator a 96db range. The output of the OPN operator unit is only 14-bit, and lacks the resolution required in order to represent numbers over around 40db attenuation anyway. Anything past that point just outputs 0, so they couldn't have implemented a 96db effective range without a significant increase in the precision of the operator unit. On paper, the calculations the operator unit performs are simple. The operator unit simply has to calculate the sine value for the phase, and attenuate it by the output from the envelope generator. That's it. You could implement the operator unit like this: [CODE] //attenuationBitCount = 10 //phaseBitCount = 10 //operatorOutBitCount = 14 //phase = the output from the phase generator //attenuation = the output from the envelope generator //Calculate the sine value double phaseNormalized = ((double)phase / ((1 << phaseBitCount) - 1)) double sinResult = sin(phaseNormalized * M_PI * 2); //Convert the attenuation to a linear representation of power double attenuationIndividualBitWeighting = 48.0 / (1 << attenuationBitCount); double attenuationInBels = (((double)attenuation * attenuationIndividualBitWeighting) / 10.0); double powerLinear = pow(10.0, -attenuationInBels); //Attenuate the result double resultNormalized = sinResult * powerLinear; //Calculate the 14-bit operator output unsigned int maxOperatorOutput = ((1 << (operatorOutBitCount - 1)) - 1); int result = (int)(resultNormalized * maxOperatorOutput); [/CODE] This was actually my first implementation. It works, and if the YM2612 was a "perfect" device, this would actually be a very accurate implementation. In reality, Yamaha had to actually build the operator unit as a physical device, and they had to do it as cheaply and efficiently as possible, within the boundaries of what was possible with the technology of the time. The end-result is that the operator unit is not as precise as the calculation which is performed above. I doubt you'll hear any audible difference, but if you want to build an accurate emulator, it is possible to perfectly emulate the operator unit calculations performed by the YM2612, but the implementation is a little more complex than the algorithm I've just presented. I've done a lot of analysis and testing, and I've figured out what I believe are the exact steps the real operator unit performs. I can guarantee if you follow the information I'm about to show, you will be able to create a 100% binary exact implementation of the YM2612 operator unit. I've implemented all of this in my YM2612 core, and it works a treat. It is worth noting that MAME already gets a 100% accurate output for this area, though the implementation is a little hard to understand. I found the easiest way to document the core of the operator unit was using a diagram. They say a picture says a thousand words, so hopefully this will save me some typing: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/ym2612%20operator.png] Here's my (heavily commented) algorithm to build the perfect contents for the sine table: [CODE] //sinTableBitCount = 8 //attenuationFixedBitCount = 8 for(unsigned int i = 0; i < (1 << sinTableBitCount); ++i) { //Calculate the normalized phase value for the input into the sine table. Note //that this is calculated as a normalized result from 0.0-1.0 where 0 is not //reached, because the phase is calculated as if it was a 9-bit index with the //LSB fixed to 1. This was done so that the sine table would be more accurate //when it was "mirrored" to create the negative oscillation of the wave. It's //also convenient we don't have to worry about a phase of 0, because 0 is an //invalid input for a log function, which we need to use below. double phaseNormalized = ((double)((i << 1) + 1) / (1 << (sinTableBitCount + 1))); //Calculate the pure sine value for the input. Note that we only build a sine //table for a quarter of the full oscillation (0-PI/2), since the upper two bits //of the full phase are extracted by the external circuit. double sinResultNormalized = sin(phaseNormalized * (M_PI / 2)); //Convert the sine result from a linear representation of volume, to a //logarithmic representation of attenuation. The YM2612 stores values in the sine //table in this form because logarithms simplify multiplication down to addition, //and this allowed them to attenuate the sine result by the envelope generator //output simply by adding the two numbers together. double sinResultAsAttenuation = -log(sinResultNormalized) / log(2.0); //The division by log(2) is required because the log function is base 10, but the //YM2612 uses a base 2 logarithmic value. Dividing the base 10 log result by //log10(2) will convert the result to a base 2 logarithmic value, which can then //be converted back to a linear value by a pow2 function. In other words: //2^(log10(x)/log10(2)) = 2^log2(x) = x //If there was a native log2() function provided we could use that instead. //Convert the attenuation value to a rounded 12-bit result in 4.8 fixed point //format. unsigned int sinResult = (unsigned int)((sinResultAsAttenuation * (1 << attenuationFixedBitCount)) + 0.5); //Write the result to the table sinTable[i] = sinResult; } [/CODE] And here's my algorithm to build the perfect contents for the power table: [CODE] //powTableBitCount = 8 //powTableOutputBitCount = 11 for(unsigned int i = 0; i < (1 << powTableBitCount); ++i) { //Normalize the current index to the range 0.0-1.0. Note that in this case, 0.0 //is a value which is never actually reached, since we start from i+1. They only //did this to keep the result to an 11-bit output. It probably would have been //better to simply subtract 1 from every final number and have 1.0 as the input //limit instead when building the table, so an input of 0 would output 0x7FF, //but they didn't. double entryNormalized = (double)(i + 1) / (double)(1 << powTableBitCount); //Calculate 2^-entryNormalized double resultNormalized = pow(2, -entryNormalized); //Convert the normalized result to an 11-bit rounded result unsigned int result = (unsigned int)((resultNormalized * (1 << powTableOutputBitCount)) + 0.5); //Write the result to the table powTable[i] = result; } [/CODE] I'd also suggest you wrap the entire power conversion into a function like this: [CODE] unsigned int YM2612::InversePow2(unsigned int num) const { unsigned int shiftCount = num >> powTableBitCount; unsigned int tableIndex = num & ((1 << powTableBitCount) - 1); unsigned int tableEntry = powTable[tableIndex]; unsigned int outputShifted = (tableEntry << 2) >> shiftCount; return outputShifted; } [/CODE] A quick note about fixed point, in case you've never encountered that term before. What "fixed point" means is that a number is an integer value, but one or more of the bits in the number are treated as if they were after the decimal place, so you could represent non-whole numbers like 3.6 or 1.5. In the case of a 4.8 fixed point number, the upper 4 bits are used to represent the whole number portion, while the lower 8 bits are used to represent the "fractional" portion below the decimal place, meaning 1.5 would be represented by 0x180 for example. You'll see that the operator unit uses fixed point math when handling attenuation values. Everything you should need to implement a perfect operator unit is shown above. What I'm going to do now is simply talk about how the actual implementation created by Yamaha relates to the "perfect" algorithm shown right at the start, so you can understand why the Yamaha implmentation works. You'll need to be clear on logarithms first of all. I find it easiest to think of a logarithm as the "reverse" of a power function, so: 10^log10(num)=log10(10^num)=num The envelope generator output is represented in decibels. Decibels are a 10th of a "bel", so a value of 48 decibels is 4.8 bels. Bels are a value on the base 10 logarithmic scale. This means in order to convert back to a linear value, we would need to use a pow10 function, or 10^num, where num is a base 10 number representing a value in bels. In the case of attenuation, you could calculate 10^-num to get a normalized representation of the attenuation in the linear scale. In the first algorithm I presented, this is exactly what we did. The 10-bit attenuation output from the envelope generator was scaled to a floating point value between 0 and 4.8, and converted to a linear normalized result. Yamaha don't do this in the YM2612. Instead, they use a useful property of logarithms to reduce the work the operator unit has to do. Logarithms reduce multiplication down to addition. As you'll find right near the top of the wiki article, log(x * y) = logx + logy. Yamaha took advantage of this fact when designing the OPN operator unit. Rather than convert the attenuation from the envelope generator into a linear scale and multiply it with the output from the sine table, they converted the sine table itself to return values which are also a logarithmic representation of attenuation. This allowed them to simply add the two numbers together, then convert the whole thing back to a linear scale to get the final output, doing away with the need for multiplication. This is the reason the sine table in the YM2612 is built in a non-standard way, it's the reason the power conversion happens after the sine value is attenuated by the envelope generator output, and it's the reason the attenuation from the envelope generator and the output from the sine table are simply added together. There's one remaining quirk about the implementation which needs explanation, and that's all about bases. In the algorithm I presented at the start, we convert the envelope generator output to an expression of attenuation in bels, then use a base 10 power function to convert from bels, which is a base 10 logarithmic scale, to a linear value. You'll see the Yamaha implementation uses a base 2 power function to convert back to a linear value however. That's not a problem for the sine table, as you'll see in the comments for building the sine table that we (effectively) use a base 2 log function to build the table, so the base 2 power function is the valid conversion to turn those back to linear values. What about the envelope generator output though? We talk about the attenuation of the envelope generator in decibels, and doesn't that require a base 10 power function to convert back to a linear scale? First of all, here's the weighting table I gave previously for the 10-bit envelope generator output: [CODE] EG attenuation output bit weighting = 96 / 2^10 --------------------------------------------------------------------------------- | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |-------------------------------------------------------------------------------| | 48 | 24 | 12 | 6 | 3 | 1.5 | 0.75 | 0.375 | 0.1875|0.09375| --------------------------------------------------------------------------------- [/CODE] Given that the official documentation is incorrect, and that the output of the envelope generator is 0-48db, this is the actual weighting of each bit of the output: [CODE] EG attenuation output bit weighting = 48 / 2^10 ---------------------------------------------------------------------------------- | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |--------------------------------------------------------------------------------| | 24 | 12 | 6 | 3 | 1.5 | 0.75 | 0.375 | 0.1875|0.09375|0.046875| ---------------------------------------------------------------------------------- [/CODE] You can see from the diagram above that I indicate this 10-bit output is also actually a 4.6 fixed point value, like so: [CODE] |------Whole number portion-----|---------------Fractional portion---------------| ---------------------------------------------------------------------------------- | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |--------------------------------------------------------------------------------| | 24 | 12 | 6 | 3 | 1.5 | 0.75 | 0.375 | 0.1875|0.09375|0.046875| ---------------------------------------------------------------------------------- [/CODE] First of all, you'll note that these numbers are not in base 10 at all. Bit 6, which is the first "whole number" bit of the output, actually has a reported weighting of 3db. If this was a base 10 number, 3db would be represented by a whole number value of 0x03, not 0x01, and 24db would be represented by a whole number value of 0x18, whereas here it's 0x08. To understand what's going on here, have a look at the code to build the sine table. We need to calculate a log2 value, but there's only a log10 function available. We can in fact convert a log10 value into a log2 value using a useful identity however. As presented in the comments, that identity as it applies to this case is as follows: 2^(log10(x)/log10(2))=2^log2(x)=x In more general terms, if you divide the result of logx(num) value by logx(y), where x and y are two arbitrary bases, you convert bases, giving you the same result as logy(num). What that means is that if we wanted to convert from base 10 logarithmic values, that being the attenuation in bels in this case, into base 2 logarithmic values, we would have to divide the base 10 logarithmic value by log10(2). So, what is the value of log10(2)? Well, it's approximately 0.30103. That's fairly close to 0.3. The guys at Yamaha decided it was close enough. First of all, let's convert our attenuation values from decibels to bels, by simply dividing all the numbers by 10: [CODE] |------Whole number portion-----|----------------Fractional portion----------------| ------------------------------------------------------------------------------------ | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |----------------------------------------------------------------------------------| | 2.4 | 1.2 | 0.6 | 0.3 | 0.15 | 0.075 | 0.0375|0.01875|0.009375|0.0046875| ------------------------------------------------------------------------------------ [/CODE] Now look what happens when we divide all those numbers in our weighting table by 0.3: [CODE] |------Whole number portion-----|---------------Fractional portion---------------| ---------------------------------------------------------------------------------- | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |--------------------------------------------------------------------------------| | 8 | 4 | 2 | 1 | 0.5 | 0.25 | 0.125 | 0.0625|0.03125|0.015625| ---------------------------------------------------------------------------------- [/CODE] Now we see what we've actually got is straight values in powers of 2. This shows the output from the envelope generator is in fact a base 2 logarithmic expression of attenuation, and we can see from the table above it is in fact in 4.6 fixed point form, so we just need to convert it to 4.8 fixed point form, and it's ready to be combined with the output from the sine table. And I think that's everything there is to know about how an operator is calculated. The only other parts of the operator unit which remain relate to how the phase modulation input is calculated for self-feedback and modulation. ######## POST p6115 | AamirM | 2008-08-28 | t386-150.html Hi, Interestingly, track 2 of Mega Turrican uses the so-called "Illegal" CSM mode (with key-on using Timer A) which Nemesis documented. stay safe, AamirM ######## POST p6117 | Nemesis | 2008-08-28 | t386-150.html Awesome. That means everyone can implement CSM support and say they have more accurate YM2612 emulation than Kega. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p6119 | King Of Chaos | 2008-08-28 | t386-150.html Haha, has anyone contacted Steve Snake and informed him of these new developments yet? I'm sure he'd be quite interested to know. [IMG ./images/smilies/icon_smile.gif] ######## POST p6121 | TulioAdriano | 2008-08-28 | t386-150.html I find it quite hard to undestand why he doesn't post here... [IMG ./images/smilies/icon_sad.gif] [IMG ./images/smilies/icon_question.gif] ######## POST p6122 | King Of Chaos | 2008-08-29 | t386-150.html Steve Snake? It's because of his job and real life getting in the way. I'm sure he'd love conversing with everyone and stuff, but he doesn't have the time at all. ######## POST p6124 | Stef | 2008-08-29 | t386-150.html Thanks a tons nemesis, your awesome work and research on YM2612 is very appreciated ! ######## POST p6142 | AamirM | 2008-08-31 | t386-150.html Hi, Nemesis, thanks a lot for the detailed description on operator unit. I have now fixed all the tables in my YM2612 core according to your tests and it has fixed a lot of sound issues in my core. As you said, MAME implementation wasn't clear (though it itself was 100% correct) so I was doing some wrong calculations which resulted in incorrect sound in many games (Urban Strike intro, Sonic 1/2/3/Knuckles special stages etc..) had a pop/crackle. I was thinking I had done them right (as MAME/docs say) but I didn't. Now thanks to you, I have just fixed it [IMG ./images/smilies/icon_smile.gif] . The bug is most apparent in Sonic 3 (Angel Island Zone Act 2) when plane drops the bombs. Listen to it in the latest beta 3, the sound is distorted a lot. Thanks again. AamirM ######## POST p6151 | AamirM | 2008-09-01 | t386-150.html Hi, Although I cannot confirm this but a Regen user has reported that track 12 in BattleTech does not sound like real hardware. And guess what, that track is reproducing GEMS bug but yet it does not goes into high frequency in the real hardware. Again, this needs to be confirmed. Only Gens plays this track correctly according to his recordings because it does not handle the GEMS bug. stay safe, AamirM ######## POST p6155 | AamirM | 2008-09-01 | t386-150.html Hi, The same user has also sent in another interesting thing. He has reported that the sound in the first stage of "Spider-Man and Venom - Separation Anxiety" doesn't sound correct in any emu except Kega (and later I found out that it was correct in the same VGM plugin by blargg [IMG ./images/smilies/icon_eek.gif] ). So I guess there is an overflow again somewhere but I couldn't find any myself after a quick look. stay safe, AamirM ######## POST p6156 | Nemesis | 2008-09-02 | t386-150.html The sound issue in the first level of Separation Anxiety seems to be a self-feedback related issue, or at least it has similar symptoms to track 3 in Mega Turrican. I don't think it's related to detune. I'll be carrying out some tests to try and isolate this problem, and track down the cause. The title screen music has a separate issue however, one that is related to detune overflow. If you compare Kega and Regen, you'll hear the differences. As for Battletech, I'll try it out on the actual hardware this afternoon. I can hear that Regen and Kega are getting a different result though. It's probably just an accuracy issue with how the overflow has been implemented in Regen, Kega, or both. I should buckle down and write up my notes on the phase generator. There's no reason we can't get detune overflow perfect, and it seems like a lot of games rely it. ######## POST p6162 | AamirM | 2008-09-02 | t386-165.html Hi, Updating envelope generator (just the attenuation level) on key-on has completely fixed the spiderman problem for me [IMG ./images/smilies/icon_smile.gif] . It decrease the attenuation level which then results in the correct sound. Although I don't know if its correct or not. I tried doing the same in MAME but it didn't fixed the problem. Must be some other problem with it then or I didn't do it correctly. Although I can tell that MAME's envelope generator is not handling certain cases correctly. I'll dig up some more on this and hopefully can fix those problems with MAME as well. Someone more knowlegeable (Nemesis, Eke) with MAME core should try and look into that. EDIT: Possibly found the cause of MAME problems. Notice how high is the sustain level while sustain rate is low. MAME is surely not handling this right. stay safe, AamirM ######## POST p6166 | King Of Chaos | 2008-09-02 | t386-165.html Great work! I can notice the issue in Separation Anxiety now, might have to test Maximum Carnage soon as well. The only sound issue left I know of is the Robocop issue. [IMG ./images/smilies/icon_wink.gif] ######## POST p6177 | Nemesis | 2008-09-03 | t386-165.html Here's my description of the phase generator. I'm pretty sure this is everything you need to get a 100% accurate implementation of the phase generator, with the exception of phase modulation by the LFO. I'll cover LFO phase and amplitude modulation in a full description of the low frequency oscillator at a later date. Overview of the phase generator: The purpose of the phase generator is to generate a phase value for the operator unit. The phase represents the current progress through a single oscillation of a sine wave. The 10-bit phase output is mapped to a value between 0 and 2PI by the operator unit (or you can think of it as a value between 0 and 360 if you prefer degrees to radians), and is used as the input for a sine function. In practical terms, the phase generator is just a counter. The current value of this counter is output as a 10-bit value, and it increases in a linear fashion, counting from 0x000 to 0x3FF, then overflowing and looping again and again. The rate at which this counter advances is what determines frequencies in the YM2612. If the phase counter overflows exactly once every second, the frequency of the output wave will be 1Hz. If the phase counter overflows exactly 440 times every second, the frequency of the output wave will be 440Hz. Inputs and internal data: The phase generator receives the following register data: [CODE] FNUM Frequency 11 bits BLK Block 3 bits DT Detune 3 bits MUL Multiple 4 bits [/CODE] In addition, the phase generator stores a separate 20-bit internal phase counter for each operator. Inside the phase generator: Even though the phase generator only outputs a 10-bit value for the phase counter, internally, the counter is actually 20-bit, with only the upper 10 bits being output to the operator unit. MAME refers to this as 10.10 fixed point. I wouldn't really call this fixed point format. I prefer to think of it more like the operator unit only accepts the phase with 10 bits of precision, while the phase generator calculates and stores the phase with 20 bits of precision. This extra precision is necessary in order to accurately calculate the phase, particularly with low frequencies. There's an extremely important formula on page 24 of the YM2608 manual relating to the phase generator update cycle. It is as follows: F-Number = (144 * fnote * 2^20 / M) / 2^(B-1) fnote: Pronunciation frequency M: Master clock B: Block data This actually gives away quite a bit of vital information about the phase generator. What this formula is doing is calculating the increment value you would need to provide to cause a 20-bit register (2^20) to overflow the specified number of times each second, if the counter was advanced 144*clock times each second. This tells us each operator gets updated once every 144 clock cycles, it confirms that the phase generator is a counter which is increased in a linear fashion, it tells us that counter is 20-bit, and it shows us the relationship between block and fnum to form the increment value for this counter. There are a few things this formula doesn't explain however. No indication is given as to how the detune or multiple registers are applied for example. A full description of the update cycle is given in the next section. Phase generator update cycle: The phase generator only has to perform one task each cycle, which is simply to advance the phase counter. It does this by calculating the current phase increment value, and adding it to the phase counter. The addition with the phase counter is trivial, so all the real work goes into calculating the current phase increment value. The phase increment is built by starting with the 11-bit fnum register data for the current operator. That fnum value is then adjusted through a series of steps to apply block, detune, and multiple data. Please note that the order is critically important. If you perform the detune adjustment out of order in particular, you will introduce errors into your phase calculation which may be subtle and hard to track down. An overview of these steps, and the register sizes at each stage of the process, are shown in the basic diagram below: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/phase%20generator%20diagram.png] Here's an in-depth look at each of the three key steps in calculating the phase increment: 1. Shift fnum by block The block data acts as a shift counter for fnum, but it isn't as straight forward as it might initially appear. The block data is a number between 0-7, but if you look at the frequency calculation shown above, you'll see that the calculation applies block data by multiplying by 2^(B-1). That formula does treat the block data starting at 0, meaning when block = 0, you've got 2^-1=0.5, or in other words, when block is 0, the number is shifted down by 1, when it's 1, no shift occurs, when it's 2, the number is shifted up by 1, etc. Just so there's no ambiguity, here's a table showing the relative shift operations each possible value of the block register applies to the fnum data. [CODE] ------------------------------------------------- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |-----------------------------------------------| | >>1 | - | <<1 | <<2 | <<3 | <<4 | <<5 | <<6 | ------------------------------------------------- [/CODE] Eg: When fnum = 0x7FF and block = 7, calculation is 0x7FF<<6=0x1FFC0. When fnum = 0x7FF and block = 0, calculation is 0x7FF>>1=0x3FF. As shown on the diagram above, the intermediate result of fnum after the block data is applied is a 17-bit number, allowing for a shift up by 6 with no overflow or limiting of any kind. When shifting down by 1 however, the LSB of fnum is of course discarded, so you do loose precision with a block value of 0. 2. Calculating and applying detune Detune allows a very small offset to be applied to the phase increment value. The implementation of detune is a little more complex, and there are several stages to the calculation. The first step is to calculate the current key-code value for the operator. The key-code is a 5-bit number build from the block and fnum data. The calculation is outlined in the YM2608 documentation, page 25. To add a bit more info on top of what's given in the documentation, here's how I've described it in the comments for my YM2612 core, building on what's written in the YM2608 docs: [CODE] --------------------- | 4 | 3 | 2 | 1 | 0 | |-------------------| | Block |N4 |N3 | --------------------- Where Block is the 3-bit block data, and N4/N3 are built from fnumber as follows: N4=F11 N3=F11&(F10|F9|F8) | !F11&F10&F9&F8 Where FXX indicates bit XX from fnumber, starting with the LSB as 1. [/CODE] The N3 bit obviously requires a bit of work to build, but the other bits are simple. The info above should be all you need to calculate the key-code. Now that we've got the key-code value, just put it to the side for a moment, since there's another step we need to carry out before we're ready to use it. There's a detune register in the YM2612 which we of course need in order to calculate the detune value. The detune register stores a 3-bit value, which determines how extreme the detune adjustment will be, and whether the detune adjustment is positive or negative. The weighting of each bit is shown in the following table from the YM2608 manual, page 26: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/detune%20register.png] As you can see, this isn't a normal 2's compliment signed value. The detune register uses a primitive sign bit, so you've got a range of -3 to +3, with both -0 and +0, which are equivalent. In order to use the detune data, we need to separate the sign bit, leaving us with just the lower 2 bits of the register value, and a flag indicating whether the detune is positive or negative. With both the key-code calculated, and the detune data interpreted, we now need to calculate the detune adjustment itself. For that, we need to use a table. The YM2608 manual also lists a detune table on page 26, which looks a little something like this: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/detune%20table.png] Note that where this table lists "block" and "note" down the side, what those really correspond with is the key-code we just calculated. "Block" is of course the upper 3 bits of the key-code, while "Note" is the lower 2 bits of the key code, so essentially the table is listing detune values in order for a key-code from 0 to 0x1F. The other index used here is the lower 2 bits of the detune register data, which we separated above, so we've got a multi-dimensional array of [32][4]. These values that are given in the detune table are accurate. Unfortunately, they're given in Hz. We need to convert these values into actual numbers we can add to our frequency increment value in order to apply them. In fact, that's not too tricky. Looking at the detune table, we can see that every value detune value is given as a multiple of 0.053Hz. There's a little but of rounding coming into play for the higher values, but basically they're all a common factor of 0.053. This tells us that the resolution of the detune table only allows minimum adjustments to the increment value by steps of 0.053Hz, and we can break each value in the table down into a multiple of this adjustment. Now we just need to calculate what fnum value corresponds with a single step in the detune table. For that, we can use the frequency formula given earlier, to calculate the fnum value needed to produce an output of the specified frequency. Taking out the block adjustment which doesn't apply here, the fnum calculation for a frequency of 0.053Hz is as follows: fnum = 144 * 0.053 * 2^20 / 8000000 = 1 (rounded) So basically, we've just confirmed a single step in the detune corresponds with a single number adjustment to the frequency increment value. Note that we used a clock frequency of 8MHz in this calculation, as all the values given in the YM2608 manual have been calculated assuming a clock rate of 8MHz. After converting all those numbers in the detune table from Hz to fnum values, you get something a little like this: [CODE] // Detune Key-Code // 0 1 2 3 {0, 0, 1, 2}, //0 (0x00) {0, 0, 1, 2}, //1 (0x01) {0, 0, 1, 2}, //2 (0x02) {0, 0, 1, 2}, //3 (0x03) {0, 1, 2, 2}, //4 (0x04) {0, 1, 2, 3}, //5 (0x05) {0, 1, 2, 3}, //6 (0x06) {0, 1, 2, 3}, //7 (0x07) {0, 1, 2, 4}, //8 (0x08) {0, 1, 3, 4}, //9 (0x09) {0, 1, 3, 4}, //10 (0x0A) {0, 1, 3, 5}, //11 (0x0B) {0, 2, 4, 5}, //12 (0x0C) {0, 2, 4, 6}, //13 (0x0D) {0, 2, 4, 6}, //14 (0x0E) {0, 2, 5, 7}, //15 (0x0F) {0, 2, 5, 8}, //16 (0x10) {0, 3, 6, 8}, //17 (0x11) {0, 3, 6, 9}, //18 (0x12) {0, 3, 7,10}, //19 (0x13) {0, 4, 8,11}, //20 (0x14) {0, 4, 8,12}, //21 (0x15) {0, 4, 9,13}, //22 (0x16) {0, 5,10,14}, //23 (0x17) {0, 5,11,16}, //24 (0x18) {0, 6,12,17}, //25 (0x19) {0, 6,13,19}, //26 (0x1A) {0, 7,14,20}, //27 (0x1B) {0, 8,16,22}, //28 (0x1C) {0, 8,16,22}, //29 (0x1D) {0, 8,16,22}, //30 (0x1E) {0, 8,16,22}}; //31 (0x1F) [/CODE] So we can see the maximum adjustment that detune will make to the increment value is 22. Using the lookup table above, we're able to calculate phase adjustment values for detune, but we still have to factor in the sign bit from the detune register. For positive detune adjustments, the numbers from the table can be directly added to the intermediate fnum result. When the sign bit is set however, we have to calculate the 2's compliment of the detune value before we can add it to fnum, and this 2's compliment value needs to be sign-extended to a 17-bit value. To give some examples about how detune is applied, consider a case where fnum is 0x100 and block is 5. In this case, we perform the following operation: 0x100 << 4 = 0x1000 So, our intermediate 17-bit fnum result before applying detune is 0x1000. The next step is to calculate the key-code value, which from a block of 5 and fnum of 0x100, is 0x14. Let's say the detune register data is 0x3. When we look at the table above, a detune value of 3 and a key-code of 0x14 gives a detune adjustment value of 11(0xB). So, to apply detune, we simply add that detune adjustment value to the intermediate fnum result: 0x1000 + 0xB = 0x100B And that's fnum adjusted for detune. Now consider the case where the detune data is 0x7. In this case, the detune adjustment is -3. First of all, we read the detune adjustment value for +3 from the table, which is of course still 11(0xB). We need to calculate the 2's compliment of this number now, in a register size of 17-bit, like so: 0 - 0xB = 0x1FFF5 (17-bit) We now add that inverted detune value to the intermediate fnum result, and cap the result to 17-bits: 0x1000 + 0x1FFF5 = 0xFF5 (17-bit) Since 0x1000 - 0xB = 0xFF5, we can see we've obtained the correct result. It's up to you how you want to implement this in code, whether you use 2's compliment and addition, or just use subtraction for negative values, what you represent using signed and unsigned types, etc, but these are the results you need to get at the end. There's some further discussion of detune in the next section. 3. Applying the frequency multiplier This step is fairly simple. The multiple register provides a 4-bit value to the phase generator. This 4-bit value specifies a multiplier for the frequency, which in real terms means it's a multiplier for the frequency increment value. There's another good table in the YM2608 manual which shows the multiplier each possible value of the multiple register applies to the frequency increment value: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/multiple%20register.png] You can see from this table that the multiple register data is simply directly multiplied with the frequency increment value, except for the special case of 0 where it acts as a 0.5 multiplier, or in other words, it halves the frequency increment. For an example of how the multiplier is applied, consider a case where fnum is 0x1FF and block is 4. From the first stage of the process, we perform the following operation: 0x1FF << 3 = 0xFF8 So, the intermediate 17-bit frequency increment value is 0xFF8. Skipping past detune, let's say the multiple register is loaded with the value 0x8. Looking at the table above, that means the multiplier is 8, so: 0xFF8 * 8 = 0x7FC0 So, our final frequency increment value in this case is 0x7FC0, after the multiplier has been applied. If the multiple data was 0, our multiplier would be 0.5 instead, so: 0xFF8 * 0.5 = 0x7FC In code, you'll probably want to implement the 0.5 multiplier special case as a simple shift down by 1. If you correctly apply these main frequency calculation steps, you'll be able to calculate the correct phase increment values for each update. All you've got to do now is add this phase increment value to the stored 20-bit phase value for each operator on each update cycle, and you've got a working phase generator. There is a special case to consider when implementing the phase generator however, which is covered in the next section. Detune overflow: The detune setting allows a negative detune value to be applied, which will subtract a small frequency adjustment from the supplied fnum. This begs the question, what happens when fnum is smaller than the number the detune setting is subtracting? The answer is, you get an overflow. The register size at the time the detune value is applied is 17-bit, so if detune attempted to subtract a value of 1 from an fnum of 0, the result would be 0x1FFFF. You can't get an overflow when detune is positive, as the max output from the shift step is 0x1FFC0 (0x7FF<<6), and the max value we add through detune is 0x16(22), giving a combined total of 0x1FFD6. As you can see, you can actually slightly exceed the maximum intermediate frequency you could normally obtain with fnum and block using detune overflow. The GEMS sound driver for the Mega Drive has an inbuilt instrument which makes use of detune overflow. A large number of Mega Drive games use the GEMS sound driver, and a significant number of those use this instrument, so if you're working on a Mega Drive emulator, you'll get bad sound in a lot of games unless detune overflow is implemented correctly. There's actually a second point in the frequency increment calculation where an overflow can occur, and that's when the frequency multiplier is applied. The input to the multiplier is 17-bit, the output from the multiplier is 20-bit, but when you multiply the maximum 17-bit input (0x1FFFF) by the maximum multiplier value (15), you get a result of 0x1DFFF1, which is well over the maximum 20-bit output of 0xFFFFF. This upper bit of data is lost, so an output of 0x1DFFF1 is equivalent to 0xDFFF1. You shouldn't have to do anything special to handle multiplier overflow however, as the phase counter itself is only 20-bit, so this upper bit is going to be discarded anyway when you add the final frequency increment value to the phase counter. 20-bit or 21-bit?: After reading the information above, you may wonder if the internal phase counter is really 21-bit. It wouldn't have any radical impact at all if the phase counter was actually 21-bit, and the block register actually only shifted up, rather than shifting down one place when the block data was 0. This is certainly a simpler system to emulate. If you test this on the hardware however, you'll find this is not the case. If the register was really 21-bit, you would still have 11 bits of precision in fnum when block = 0. As it turns out, when block is set to 0, an fnum value of 1 = 0, 3 = 2, etc. This shows that the LSB of fnum is lost when block = 0, which means the phase counter is actually 20-bit. A small sidenote really, but you might be left wondering about this like I was, so I thought I'd mention it. So yeah, I think that just about covers it. Anyone who worked on adding support for the detune overflow bug might want to doublecheck their implementation. The magic register size is 17-bit. If you're representing frequency numbers properly, all you should have to do is mask your increment value to a 17-bit result before applying the frequency multiplier. ######## POST p6179 | Nemesis | 2008-09-03 | t386-165.html [QUOTE] AamirM wrote:Updating envelope generator (just the attenuation level) on key-on has completely fixed the spiderman problem for me [IMG ./images/smilies/icon_smile.gif] . It decrease the attenuation level which then results in the correct sound. Although I don't know if its correct or not. [/QUOTE] Well, an envelope generator update should definitely occur at the same time as the key-on event is processed, or rather, a key-on event shouldn't be processed until the start of an envelope generator update cycle. I must say though, I'm not entirely clear on exactly what you did to fix the problem. Can you provide a bit more info? Unfortunately, Separation Anxiety doesn't want to run properly in my emulator right now (Z80 bug somewhere), so I don't know if my core has the same problem. From what you said, one thought about a possible cause of this problem jumped to mind though, which is in how maximum attack rates are handled. When the calculated rate value for the attack phase is 60-63, I think you need to immediately switch the attenuation to minimum, and enter the decay phase. You should never generate a single sample based on the attack phase in such a case. The very first sample you output for that operator after the envelope generator has processed the key-on event should be starting from TL and decaying from there. Perhaps something relating to this is the cause of the problem? [QUOTE] Possibly found the cause of MAME problems. Notice how high is the sustain level while sustain rate is low. MAME is surely not handling this right. [/QUOTE] There's a number of things about the envelope generator I didn't think about when I was doing my tests in that area, and one of them was what happens when, in a single update cycle during the decay phase, the envelope generator moves past the sustain level. In most cases the attenuation isn't going to fall perfectly on the sustain level when the decay phase is completed. There's only two possibilities I can see. One possibility is that if the decay phase moves past the specified sustain level, the decay phase begins from that level instead of the sustain level. This would mean if you have a very fast decay and a slow sustain, the decay phase might jump significantly past the sustain level, and the decay may begin at a significantly higher attenuation level than intended. I think it's more likely that the YM2612 clamps the decay phase to the sustain level, so if the last update cycle for the decay phase tries to move past the sustain level, the envelope generator forces the result to SL, and changes to the sustain phase at that point in time, in preparation for the next update cycle. Perhaps MAME is doing the first, and jumping past SL? I'm going to go back and do more testing on the envelope generator at some point, and these little remaining ambiguities are things I'll be targeting. ######## POST p6181 | AamirM | 2008-09-03 | t386-165.html Hi, [QUOTE] I think it's more likely that the YM2612 clamps the decay phase to the sustain level, so if the last update cycle for the decay phase tries to move past the sustain level, the envelope generator forces the result to SL, and changes to the sustain phase at that point in time, in preparation for the next update cycle. Perhaps MAME is doing the first, and jumping past SL? [/QUOTE] Yes, exactly. And in fact, forcing the envelope to sustain phase instead of decay on key-on or envelope update in MAME seems to fix the wrong sound in mega turrican. But sound in other channels get broken but its expected of course. stay safe, AamirM ######## POST p6204 | Eke | 2008-09-07 | t386-165.html Nemesis, this is awesome. I already figured some stuff by reading/analysing the MAME implementation but I never figured where they get the bits width for fixed point calculation. The fact you double-checked everything from testing is just great [IMG ./images/smilies/icon_biggrin.gif] now, did you find any mistakes in Operator (sin table, db to linear conversion, ...) or Phase generator (bit width) operations in the MAME implementation ? ######## POST p6205 | Nemesis | 2008-09-08 | t386-165.html The MAME operator unit gets a perfect result (mainly implemented through sin_tab and tl_tab), so there are no mistakes to fix there, although personally if it was my core, I'd rewrite some of it to make it simpler if nothing else (at the cost of a little extra overhead most likely). I know the detune table in MAME is correct, but I haven't checked the actual phase increment calculation. We know the MAME core didn't handle detune overflow, so it obviously wasn't perfect before, but I haven't compared my test results to the MAME implementation in this case. ######## POST p6219 | Eke | 2008-09-10 | t386-165.html Ok, I fixed the problem in Mega Turrican track #3 (and some others) COntrary to what I was saying, this is indeesd an Envelope Update issue: the game set Operator #2 with a SL value of 0 and a maximal Attack Rate (0x1F), and the enveloppe generator should directly start at the substain phase Modifying the Key ON function this way fixed it: [QUOTE] if ((SLOT->ar + SLOT->ksr) < 94 /*32+62*/) { SLOT->state = EG_ATT; /* phase -> Attack */ SLOT->volume = MAX_ATT_INDEX; /* fix Ecco 2 splash sound */ } else { /* directly switch to Decay (or Substain)*/ SLOT->volume = MIN_ATT_INDEX; SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC; } [/QUOTE] similar thing should be done in "advance_eg_channel" function, at the end of the attack phase and, in SSG-EG mode, at the end of the substain phase EDIT: another way to fix it is, as aamir said, to always call advance_eg_channel when a KEY ON occurs to adjust the state & level correctly also, I'm wondering, contrary to the GENS core, the MAME core is updating the enveloppe BEFORE calculating the operator output, shouldn't that be the contrary as for PHASE calculation (output a sample then update the counters).. the only difficulty being that Enveloppe Counter is updated between each 2nd and 3rd samples (352/144) ######## POST p6220 | AamirM | 2008-09-10 | t386-165.html Hi, [QUOTE] COntrary to what I was saying, this is indeesd an Envelope Update issue: the game set Operator #2 with a SL value of 0 and a maximal Attack Rate (0x1F), and the enveloppe generator should directly start at the substain phase [/QUOTE] Haha, told ya [IMG ./images/smilies/icon_wink.gif] . By the way, did it fix Spider Man issue too? stay safe, AamirM ######## POST p6221 | Eke | 2008-09-10 | t386-165.html which issue in which Spiderman game ? the mega turrican one was the only one I was still looking for but there are certainly other ######## POST p6222 | AamirM | 2008-09-10 | t386-165.html Hi, Listen to the first stage of Spiderman - Separation Anxiety. Has same sort of problems like in Mega Turrican. I have fixed it in Regen by updating envelope on key on but couldn't fix it in MAME. stay safe, AamirM ######## POST p6224 | Nemesis | 2008-09-11 | t386-165.html [QUOTE] the only difficulty being that Enveloppe Counter is updated between each 2nd and 3rd samples (352/144) [/QUOTE] .... umm, yeah, about that..... [IMG ./images/smilies/icon_smile.gif] When I was doing my tests on the envelope generator and calculating the update cycle, I had assumed the minimum output level was reached when the envelope generator hit max attenuation. As I discovered when I was doing my tests on the operator unit, due to precision limitations, the minimum output level is actually reached before the envelope generator reaches the maximum attenuation (around 40db, instead of the full 48db). My calculations to determine the envelope generator clock rate were based on total decay times, but since I was measuring the final output, and the final output was hitting minimum before the envelope generator output was hitting maximum, this invalidates my findings. The envelope generator update cycle is actually slower than I had calculated. Going back to my numbers and making a rough adjustment for the point at which I now know precision cut off the output, the envelope generator clock rate is in fact 1/3 of the FM clock, which means MAME was right all along. Just so there's no confusion, here's what I said previously in the "Clock Sources" section of my discussion on the envelope generator: [QUOTE] This is where things get a little more interesting. The Envelope Generator does NOT update once for each sample the YM2612 produces, as you might initially expect it would. More than that, the envelope generator isn't even tied to the FM clock source. Testing has shown that the clock for the envelope generator is independent of the FM clock. Here is the formula for the rate at which the envelope generator updates: EG Clock = External Clock / 351 This may seem a little odd. I agree. I have tested and re-tested my results however, and the numbers come back the same. The ratio of the frequency output to the envelope generator clock is 1:2.4375. This directly contradicts MAME, which has the output cycle at a ratio of 1:3, or in other words, the envelope generator updates once for every 3 FM clock pulses. Comparing the output from MAME with the output from the YM2612 shows that MAME is incorrect however. Getting this update cycle for the envelope generator correct is important, and SSG-EG mode in particular is very sensitive to this. [/QUOTE] All of that is wrong. The phase generator clock is the same as the FM clock: PG Clock = FM Clock Since there are 6*4=24 operators to update, and a single operator is updated each clock cycle, each operator gets updated once every 24 phase clock cycles. The envelope generator clock is 1/3 of the FM clock: EG Clock = FM Clock / 3 Since there are 6*4=24 operators to update, and a single operator is updated each clock cycle, each operator gets updated once every 24 envelope clock cycles, or once every 24*3=72 FM clock cycles. ######## POST p6225 | Nemesis | 2008-09-11 | t386-165.html Looking at the envelope generator update process in the MAME core, specifically in the advance_eg_channel function, I suspect you need to change this: [CODE] if ( SLOT->volume >= SLOT->sl ) SLOT->state = EG_SUS; [/CODE] into something like this: [CODE] if ( SLOT->volume >= SLOT->sl ) { SLOT->volume = SLOT->sl; SLOT->state = EG_SUS; } [/CODE] for both the SSG-EG and normal update steps. This will ensure that the decay phase doesn't move past SL, which will prevent over-attenuated output when you have a high SL (low attenuation), a fast decay, and a slow sustain. I think you'll find the YM2612 is performing the exact same operation to prevent the decay phase from eating into sustain. This is what I'm doing in my core. ######## POST p6226 | Eke | 2008-09-11 | t386-165.html [QUOTE] AamirM wrote:Hi, Listen to the first stage of Spiderman - Separation Anxiety. Has same sort of problems like in Mega Turrican. I have fixed it in Regen by updating envelope on key on but couldn't fix it in MAME. stay safe, AamirM [/QUOTE] did not find any problem with this game at first listening, maybe it's due to my implementation I however got a new problem with Alisia Dragon, the track of the first level now starts with a bigg buzz sound, this can also be reproduced in sound test (track 03). Strangely, if I play track 00 then switch to track 03; it plays fine, maybe it has something related to key on/enveloppe update [QUOTE] Looking at the envelope generator update process in the MAME core, specifically in the advance_eg_channel function, I suspect you need to change this: [/QUOTE] yes, I recently changed this also. According to Gens sourcecode, it fixes Gynoug exploding SFX thanks for you precision about EG clock anyway ######## POST p6233 | AamirM | 2008-09-11 | t386-165.html Hi, [QUOTE] My calculations to determine the envelope generator clock rate were based on total decay times, but since I was measuring the final output, and the final output was hitting minimum before the envelope generator output was hitting maximum, this invalidates my findings. The envelope generator update cycle is actually slower than I had calculated. Going back to my numbers and making a rough adjustment for the point at which I now know precision cut off the output, the envelope generator clock rate is in fact 1/3 of the FM clock, which means MAME was right all along. [/QUOTE] And here was I thinking why SSG-EG was going so wrong [IMG ./images/smilies/icon_smile.gif] . I've been working for the past 4 hours or so trying to revert back the changes in my core. Now after these changes, SSG-EG in Regen sounds very close to the SSG-EG recording you posted. And Buba 'n' Stix track 5 seems to have been fixed too (it doesn't produce any crackling anymore). Good thing this mistake has been caught early. Nice work again, Nemesis. I am feeling very happy right now [IMG ./images/smilies/icon_smile.gif] . [QUOTE] did not find any problem with this game at first listening, maybe it's due to my implementation [/QUOTE] Maybe it is somehow fixed in your implementation. Did you compare with Kega? [QUOTE] I however got a new problem with Alisia Dragon, the track of the first level now starts with a bigg buzz sound, this can also be reproduced in sound test (track 03). Strangely, if I play track 00 then switch to track 03; it plays fine, maybe it has something related to key on/enveloppe update [/QUOTE] Ahh..I remember I had this problem as well when I used MAME core in Regen (you can still hear it in 0.77, the last version to use MAME core). I remember that it was related to SSG-EG. You should look there. stay safe, AamirM ######## POST p6237 | Eke | 2008-09-11 | t386-180.html [QUOTE] Ahh..I remember I had this problem as well when I used MAME core in Regen (you can still hear it in 0.77, the last version to use MAME core). I remember that it was related to SSG-EG. You should look there. [/QUOTE] thanks, indeed it was a problem with the SSG-EG invert flag: I reseted it when key-off occurs at Nemesis explained but the game will set it again after KEY OFF by writing 0xFF into the SSG-EG register before later setting it back to 0x00 before next KEY ON), which will activate SSG-EG enveloppe type during this time. Also, the write will mess up the invert flag status which should not be set during Release Phase. I fixed it by checking we are not in Release Phase before eventually inverting the output in SSG-EG mode [QUOTE] if ((SLOT->ssg&0x08) && (SLOT->ssgn&2) && (SLOT->state > EG_REL)) out ^= MAX_ATT_INDEX; [/QUOTE] but I'm wondering if this write to SSG-EG register is intentional and should really affect the Release Phase ? Maybe SSG-EG register state is latched on Key ON only and can not be affected during Enveloppe update ? Also, what would happen if you write the register during Decay or Substain phase ? Anyway, I don't think this game use SSG-EG intentionnaly in any way, it just has no sense in setting it to 0xff then to 0x00 ######## POST p6238 | Nemesis | 2008-09-11 | t386-180.html I still need to do tests to determine when various register changes take effect. I think you'll find most of the decisions about SSG-EG are only made when changing between envelope generator states, but I think it's quite possible that toggling the SSG-EG enabled state during the release phase (or the sustain and decay phases) could cause the 6x multiplier effect on the attenuation increment to be toggled on or off as the phase progresses. Perhaps this is what they are trying to do in Alisia Dragoon? They'd have to control the timing in software, but if it was done correctly, you could effectively achieve two stages of release, with the second stage being 6 times slower than the first. ######## POST p6239 | AamirM | 2008-09-11 | t386-180.html Hi, My guess would be that it toggles between 4x and 6x multiplier rather than off. stay safe, AamirM ######## POST p6255 | Snake | 2008-09-13 | t386-180.html [QUOTE] TulioAdriano wrote:I find it quite hard to undestand why he doesn't post here... [IMG ./images/smilies/icon_sad.gif] [IMG ./images/smilies/icon_question.gif] [/QUOTE] Well one reason would be that I didn't know of it's existance [IMG ./images/smilies/icon_wink.gif] I've spent the best part of the last 4 years being almost completely absent from the internet. And, yeah, life is more than a bit evil right now. I won't go into it here. Interesting stuff. I think I have most of it correct, but I've forgotten more about the YM2612 than I remember. There were a few things I knew weren't correct but I think I've already fixed most of them. Really should release a new build at some point. And cross reference with these documents. For the record I've not been intentionally hiding any findings, Stef will tell you I sent him the source for an early Kega implementation, but he likes to try to figure things out on his own [IMG ./images/smilies/icon_smile.gif] It's only more recently that people have been asking, and I've been not very good at remembering to look things up. But if there's anything I can add to the discussion I shall do so. Yes, most of what I found was done via hacking at the hardware rather than documentation. It also helped that I already understood how FM synthesis worked. But I'd kill for a YM2612 on a PC card. The CSM stuff is news to me, though. I haven't really looked at this since 1997, when I was talking to Tatsuyuki Satoh (original MAME core, and the one I think Stef based his on) - he has some japanese documents which suggested CSM mode was useless without the timer interrupts. Timer A would do key ON, and you'd have to key it OFF again yourself in an interrupt. We tried to figure it out but I eventually decided it'd be pretty useless on the Genesis. The only thing (as far as I remember) that I still want to know is this: The YM2612 (apparently, and I don't remember where I found this) output DAC has one bit less than it would normally need. Something is done to remove one bit before it goes into the DAC. It appears to be some sort of compression/scaling which results in values close to silence being much louder. If you can figure that out I'd be very interested. I no longer have access to my hardware so I can't do tests anymore [IMG ./images/smilies/icon_sad.gif] ######## POST p6256 | King Of Chaos | 2008-09-13 | t386-180.html Welcome to the party Snakey. [IMG ./images/smilies/icon_wink.gif] The circle is now complete... ######## POST p6258 | Nemesis | 2008-09-13 | t386-180.html Hi Snake, I was hoping you'd drop by at some point. Welcome to the forum. [IMG ./images/smilies/icon_smile.gif] [QUOTE] The CSM stuff is news to me, though. I haven't really looked at this since 1997, when I was talking to Tatsuyuki Satoh (original MAME core, and the one I think Stef based his on) - he has some japanese documents which suggested CSM mode was useless without the timer interrupts. Timer A would do key ON, and you'd have to key it OFF again yourself in an interrupt. We tried to figure it out but I eventually decided it'd be pretty useless on the Genesis. [/QUOTE] I get the feeling CSM is one of those functions that's probably implemented a little differently across a variety of chips, possibly even within the OPN line. Those documents he had may have been correct for another Yamaha chip. It would be nice to have a look at them, but I guess he never scanned them in. [QUOTE] The only thing (as far as I remember) that I still want to know is this: The YM2612 (apparently, and I don't remember where I found this) output DAC has one bit less than it would normally need. Something is done to remove one bit before it goes into the DAC. It appears to be some sort of compression/scaling which results in values close to silence being much louder. If you can figure that out I'd be very interested. [/QUOTE] I think I know the answer to that one. [IMG ./images/smilies/icon_smile.gif] The YM2612 has an embedded YM3016 DAC. I know that for sure. I also obtained a datasheet for the YM3016 DAC when I got the YM2608 documentation, but unfortunately, the YM3016 datasheet is also in Japanese, and I haven't found an English version. Fortunately, that doesn't matter one bit, as I've noticed the YM3015 is identical to the YM3016, with the exception that it takes a 12V input rather than the 5V input the YM3016 uses, and there's a YM3015 datasheet publically available in English. If you look at the datasheets, they contain the exact same information, with only the operating voltages differing. Here's the YM3016 datasheet in Japanese: http://nemesis.hacking-cult.org/MegaDri ... M3016J.pdf and here's the YM3015 datasheet in English: http://nemesis.hacking-cult.org/MegaDri ... YM3015.pdf Many other DAC's in the YM301X line like the YM3012 and YM3014 take the input to the DAC in a floating point format, with a 3-bit exponent and a 10-bit mantissa. The YM3015 and YM3016 are different in that they take their input as a 16-bit integer value in either binary or 2's compliment form. Internally, the DAC still converts that 16-bit input into a 3-bit exponent and 10-bit mantissa before using it however. Looking at the YM3015 datasheet, here's a block diagram of the internal operations the DAC performs: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/YM2612%20Notes/DAC.png] SD is the 16-bit serial data input, which comes from the accumulator in the case of the YM2612. The "Form Select" line switches between binary and 2's compliment mode. The "Form Select" and "ICL" lines are also tied to bits in the test register. This internal conversion process means that although the output from the accumulator is 16-bit (with 14-bits of meaningful data from the operator unit), internally, the DAC converts it back to a 10-bit mantissa and 3-bit exponent before generating the analog output, so there is the potential for some loss of precision within the DAC unit. I haven't had a good look yet at the effects of the internal floating point conversion in the DAC on the precision of the signal output. There's also still a question in my mind about what the YM2612 sets the lower 2 bits of the 16-bit accumulator output to. They might not simply be 0. 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. ######## POST p6259 | HardWareMan | 2008-09-13 | t386-180.html [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] ######## POST p6260 | Snake | 2008-09-13 | t386-180.html [QUOTE] Nemesis wrote:The YM2612 has an embedded YM3016 DAC. I know that for sure. [/QUOTE] Ok, from what I know, *most* chips that have an embedded DAC do indeed use that one. But in the YM2612? It's 9 bit instead of 10... Unfortunately I can't remember where I got this info. ######## POST p6267 | Nemesis | 2008-09-14 | t386-180.html Well, looking at the YM3016 datasheet, the 10-bit mantissa actually includes the sign bit. Traditionally when taking about floating point formats, the sign bit would be counted separately from the mantissa, so maybe that's where that came from. If the embedded DAC in the YM2612 did use a different floating point format, it would have to be an unknown variant. Every Yamaha YM301X DAC I've heard of uses the same floating point representation. I'll do tests on the DAC later on to see if I can confirm the mantissa size. I'm pretty confident in the assertion that the YM2612 has an embedded YM3016 though. ######## POST p6275 | AamirM | 2008-09-17 | t386-180.html Hi, @Snake I've been busy lately myself but I noticed that Kega has lower level in some places than all other emu and I was wondering why was that (if you remember of course). It noticeable in Spiderman - Spearation Anxiety intro music. Also the first stage sound of Sonic And Knuckles sounds a bit different from other emus. stay safe, AamirM ######## POST p6286 | Snake | 2008-09-19 | t386-180.html [QUOTE] AamirM wrote:I was wondering why was that (if you remember of course). [/QUOTE] Hmm, I have no idea, I'd have to see exactly what those games are doing, and even then that might only give me an *idea* why. When I get the chance I'll check it out and see if I can hear what you're reporting. Ok, quick postage of some interesting bits I missed earlier. [QUOTE] TmEE wrote:Kega won't play the currently played sample on the channel in next one when you change Left/Right reg so you can get nice and clean stereo sample playback [/QUOTE] Heh, that's interesting [IMG ./images/smilies/icon_smile.gif] I guess the hardware doesn't allow you to switch channels that fast. Admittedly something I never tested, because I didn't expect anybody to ever do that. What happens on the real hardware? Do you have a recording? [QUOTE] Eke wrote:at least , this was not correctly emulated in emulators (counter was reloaded every time the timer load value was changed) [/QUOTE] It's right in Kega. Or if it isn't, it should be, because I knew this [IMG ./images/smilies/icon_smile.gif] [QUOTE] TmEE wrote:One interesting thing : Hellfire, on MD2s (and other systems with Sega implementation of YM2612 in the ASIC) the music plays half as slow as it would on Yamaha discrete YM2612 chip [/QUOTE] Also interesting. I remember this game giving me trouble back in the very early days of KGen. One thing it does is spam the living hell out of the YM2612, repeatedly writing registers that haven't changed. I don't remember if it checks the status to see if the chip is busy between writes - but maybe it does, and those writes take a bit longer on the different chip? (or, maybe the newer chip forces a delay if you write to quick?) It's possible it wastes so much time with all this spamming that it misses an interrupt or timer interval. That'd explain why it runs at half speed. [QUOTE] Nemesis wrote:I know Steve Snake mentioned once that SSG-EG "doesn't always behave like it should" in the YM2612, but I haven't found any indication of that so far. [/QUOTE] Yes, I can't remember now what that was. But I was definitely doing some tests on it and getting rather odd and unexpected results back. At the time I couldn't make any sense of it, and I meant to look at it again later. I don't know if it's actually important, i.e. if any games try to do what I was doing. [QUOTE] Nemesis wrote:For the record, I haven't finished working on this chip. Not by a long shot. [/QUOTE] Heh, eight years on and off for me, and I'm not done yet either [IMG ./images/smilies/icon_smile.gif] [QUOTE] Nemesis wrote:Operators which directly modulate another operator can simply have their output fed directly into the input for the next operator and they never need to be stored. [/QUOTE] Aha. The document you found mentions there is only one operator. Incorrect. There are two, running in parallel. It simplifies the hardware design. This is the reason for the 'odd' operator numbering (1,3,2,4) in the registers. It also means that in most algorithms, an operator may need input from another one that's running parallel with it, and thus not ready yet. And so... it uses the previous output of that operator. This is what all the MEM stuff in Mame is all about, and it's correct. ######## POST p6287 | Nemesis | 2008-09-20 | t386-180.html [QUOTE] Aha. The document you found mentions there is only one operator. Incorrect. There are two, running in parallel. It simplifies the hardware design. This is the reason for the 'odd' operator numbering (1,3,2,4) in the registers. It also means that in most algorithms, an operator may need input from another one that's running parallel with it, and thus not ready yet. And so... it uses the previous output of that operator. This is what all the MEM stuff in Mame is all about, and it's correct. [/QUOTE] Yeah, once I had a closer look at the MAME implementation, I guessed that's what they were emulating. I haven't verified that on the hardware yet, but I expect I'll find it's correct once I test for it. I must say however, the self-feedback implementation still baffles me. MAME adds the last two samples together to build the self-feedback modulation value. This seems to be correct, but I can't figure out why it's correct, or rather, why the guys at Yamaha chose to implement it this way. Of course, there's no rule that says self-feedback has to be implemented in any particular way. Maybe they found this method "sounded better". It does produce a better saw-tooth when FB=5. I should probably stop wasting time on it and look at something else. ######## POST p6288 | Nemesis | 2008-09-20 | t386-180.html [QUOTE] Also interesting. I remember this game giving me trouble back in the very early days of KGen. One thing it does is spam the living hell out of the YM2612, repeatedly writing registers that haven't changed. I don't remember if it checks the status to see if the chip is busy between writes - but maybe it does, and those writes take a bit longer on the different chip? (or, maybe the newer chip forces a delay if you write to quick?) It's possible it wastes so much time with all this spamming that it misses an interrupt or timer interval. That'd explain why it runs at half speed. [/QUOTE] I've got a way to sample cycle-accurate measurements for the busy flag on the separate YM2612 BTW. I saw on a pinout somewhere that the supposed "unused" pin 10 is really a "TEST" pin. I've confirmed this is correct, and that what this pin actually does is indicate the current "busy" status of the chip. Yamaha could have used this pin to drive their tests on the chip, without having to read the status register to know when they could send each successive write. I'm getting a logic analyzer in the coming months, which will make it easy to measure the number of cycles the chip remains in a busy state. It wouldn't be as easy to test the busy status of the embedded YM2612, but once I've got the exact numbers for the real chip, it shouldn't be too hard to determine whether the embedded chip is different at the very least. ######## POST p6289 | Eke | 2008-09-20 | t386-180.html [QUOTE] Aha. The document you found mentions there is only one operator. Incorrect. There are two, running in parallel. It simplifies the hardware design. This is the reason for the 'odd' operator numbering (1,3,2,4) in the registers. It also means that in most algorithms, an operator may need input from another one that's running parallel with it, and thus not ready yet. And so... it uses the previous output of that operator. This is what all the MEM stuff in Mame is all about, and it's correct. [/QUOTE] aha, thanks for clearing that: another mystery of the MAME implemenation is finally solved [IMG ./images/smilies/icon_wink.gif] [QUOTE] I must say however, the self-feedback implementation still baffles me. MAME adds the last two samples together to build the self-feedback modulation value. This seems to be correct, but I can't figure out why it's correct, or rather, why the guys at Yamaha chose to implement it this way. Of course, there's no rule that says self-feedback has to be implemented in any particular way. Maybe they found this method "sounded better". It does produce a better saw-tooth when FB=5. I should probably stop wasting time on it and look at something else. [/QUOTE] Couldt it be some kind of linear interpolation and a way to solve the equation: y = x + B.sin(y) ? [QUOTE] I'm getting a logic analyzer in the coming months, which will make it easy to measure the number of cycles the chip remains in a busy state. It wouldn't be as easy to test the busy status of the embedded YM2612, but once I've got the exact numbers for the real chip, it shouldn't be too hard to determine whether the embedded chip is different at the very least. [/QUOTE] nice... this is Out Topic but do you plan to analyze the VDP also (or maybe did you already) ? I always wanted to know the exact timings of the different VDP events (interrupts and HV blanking periods) related to the main clocks as well as the exact video signal timings (VSYNC/HSYNC) and pixel clocks, which will give us the exact total number of pixels ######## POST p6290 | Nemesis | 2008-09-20 | t386-180.html [QUOTE] nice... this is Out Topic but do you plan to analyze the VDP also (or maybe did you already) ? I always wanted to know the exact timings of the different VDP events (interrupts and HV blanking periods) related to the main clocks as well as the exact video signal timings (VSYNC/HSYNC) and pixel clocks, which will give us the exact total number of pixels [/QUOTE] That's the first thing on the list. [IMG ./images/smilies/icon_smile.gif] ######## POST p6298 | TmEE co.(TM) | 2008-09-21 | t386-195.html [QUOTE] Snake wrote:Heh, that's interesting [IMG ./images/smilies/icon_smile.gif] I guess the hardware doesn't allow you to switch channels that fast. Admittedly something I never tested, because I didn't expect anybody to ever do that. What happens on the real hardware? Do you have a recording? [/QUOTE] http://www.hot.ee/tmeeco/MD.HTM - You can get the ROM I will use for the recording here... Warning : the site is VERY outdated. [QUOTE] Snake wrote:Also interesting. I remember this game giving me trouble back in the very early days of KGen. One thing it does is spam the living hell out of the YM2612, repeatedly writing registers that haven't changed. I don't remember if it checks the status to see if the chip is busy between writes - but maybe it does, and those writes take a bit longer on the different chip? (or, maybe the newer chip forces a delay if you write to quick?) It's possible it wastes so much time with all this spamming that it misses an interrupt or timer interval. That'd explain why it runs at half speed. [/QUOTE] Only thing I can suspect is the busy flag timings to be different on the two implementations as when I overclocked the Z80 to 4.5MHz the music got a little bit faster, but not as fast as it should. Some things that require longer waits are TL operators and KeyOn/Off. Having too short delays when writing to these registers will have weird sound, possibly because the write got missed or corrupt or notes left playing (Note ONs seem to have no problems). L/R reg seems to require long wait aswell. When TEST signal of YM2612 would have been used for hardware based delays, my sound engine will probably not be what it is now. Time would get wasted in CPU wait while you could have few more instructions executed... I'm raping YM2612, pushing ~50KB of data through it per second [IMG ./images/smilies/icon_razz.gif] EDIT: Recording of "stereo" PCM and the ROM I used : http://www.fileden.com/files/2008/4/21/ ... STEREO.RAR System used for recording http://www.hot.ee/tmeeco/MYSMD2.JPG (all new image now [IMG ./images/smilies/icon_smile.gif] ) ######## POST p6333 | Snake | 2008-09-23 | t386-195.html [QUOTE] Nemesis wrote:I must say however, the self-feedback implementation still baffles me. MAME adds the last two samples together to build the self-feedback modulation value. This seems to be correct, but I can't figure out why it's correct, or rather, why the guys at Yamaha chose to implement it this way. [/QUOTE] Two answers (well, three.) One - it's correct. Two - it's the way Yamaha have always done it (ah, I do miss my old yamaha synths...) Three - because its a very sensible thing to do. If you modulate a wave by itself, with no modification, you can very easily end up with a wave that oscillates from positive to negative every other sample, or other undesirable patterns, none of which are very useful. It's always a good idea to modify something before you feed it back in, in any application, not just audio. [QUOTE] Nemesis wrote:I should probably stop wasting time on it and look at something else. [/QUOTE] Yep, move along, nothing to see here [IMG ./images/smilies/icon_smile.gif] ######## POST p6334 | Snake | 2008-09-23 | t386-195.html [QUOTE] TmEE co.(TM) wrote:Recording of "stereo" PCM and the ROM I used : http://www.fileden.com/files/2008/4/21/ ... STEREO.RAR [/QUOTE] Thanks for that. Shame it doesn't work, but I can see why. [QUOTE] TmEE co.(TM) wrote:System used for recording http://www.hot.ee/tmeeco/MYSMD2.JPG (all new image now [IMG ./images/smilies/icon_smile.gif] ) [/QUOTE] That's... insane. Respect [IMG ./images/smilies/icon_smile.gif] ######## POST p6337 | TmEE co.(TM) | 2008-09-24 | t386-195.html I've tried many ways, writing more than 1 sample and then switching channel... no go, it will still sound poor [IMG ./images/smilies/icon_sad.gif] ######## POST p6339 | Stef | 2008-09-24 | t386-195.html [QUOTE] TmEE co.(TM) wrote:I've tried many ways, writing more than 1 sample and then switching channel... no go, it will still sound poor [IMG ./images/smilies/icon_sad.gif] [/QUOTE] I also wrote a stereo sample player some time ago (i probably kept the source somewhere) but it worked only on Kega Fusion. It acted as simple mono sample player on real hardware and produced some bad noises on Gens... very disapointing. I tried severals ways to get the thing working on hardware but all them failed. I was thinking about playing sample with YM channels by modifying quickly the output slot TL value but that requires more work with the Z80 and i'm not sure it can actually work. That also requires a log conversion on sample with some quality loss... ######## POST p6343 | Snake | 2008-09-24 | t386-195.html Yeah, I don't think you can update those registers fast enough anyway. ######## POST p6448 | AamirM | 2008-10-04 | t386-195.html Hi, Has anyone been able to fix Battletech track 12 problem yet? I have made changes to make phase increment value 17-bit but it doesn't work. stay safe, AamirM ######## POST p6518 | Snake | 2008-10-10 | t386-195.html [QUOTE] Eke wrote:no, it works correctly (at least, your test ROM works) initially it didn't work because setting KEY ON then key OFF without updating the enveloppe attenuation level obviously did not work I fixed that by immediately forcing attenuation level to MAX when Key ON is set and Attack rate is maximum (this was usually done on the next enveloppe update) I should fix the commentary asap [/QUOTE] Yeah, I'm pretty sure this is wrong. It seems too 'hacky'. What probably happens is that the KEY OFF happens immediately after the next envelope update, rather than immediately after the KEY ON. Note that this won't make any difference to the sound, because the previous KEY ON won't have any effect until the update happens anyway. ######## POST p6519 | Eke | 2008-10-10 | t386-195.html [QUOTE] AamirM wrote:Hi, Has anyone been able to fix Battletech track 12 problem yet? I have made changes to make phase increment value 17-bit but it doesn't work. stay safe, AamirM [/QUOTE] how is it supposed to sound like btw ? In kega, even with SuperHQ enabled, I can still hear the noisy & high-frequency cymbal, and in Regen, it sounds more like a "tic tic" ... In my Genesis Plus implementation, I got it differently from both, the sound seems less noticeable... Currently I got best results using 48000hz and SINC_FAST setting as the libsamplerate conversion algorithm (iLINEAR has less quality and it's quite noticeable in that specific track) ALso, regarding MAME implementation, I'm calculating the max value to add when Finc<0 like this: [QUOTE] ym2612.OPN.fn_max = (UINT32)( (double)0x20000 * ym2612.OPN.ST.freqbase * (1<<(FREQ_SH-10)) ); [/QUOTE] [QUOTE] if (finc < 0) finc += ym2612.OPN.fn_max; [/QUOTE] this way, and according to what Nemesis found, we indeed got: -1 = 0x1FFFF ######## POST p6520 | AamirM | 2008-10-11 | t386-195.html Hi, [QUOTE] how is it supposed to sound like btw ? [/QUOTE] It is supposed to sound like this . You will notice that the detune bug doesn't seems to be happening at all. [QUOTE] Currently I got best results using 48000hz and SINC_FAST setting as the libsamplerate conversion algorithm (iLINEAR has less quality and it's quite noticeable in that specific track) [/QUOTE] You are using SRC? Nice [IMG ./images/smilies/icon_smile.gif] . Is it fast enough? [QUOTE] Yeah, I'm pretty sure this is wrong. It seems too 'hacky'. [/QUOTE] Yep it was. I think he has since removed it. stay safe, AamirM ######## POST p6521 | Snake | 2008-10-11 | t386-195.html [QUOTE] AamirM wrote:It is supposed to sound like this [/QUOTE] No it isn't. Where did that come from? ######## POST p6522 | Eke | 2008-10-11 | t386-195.html [QUOTE] You are using SRC? Nice Smile . Is it fast enough? [/QUOTE] anything better than SINC_FAST is too slow but SINC_FAST gives good results at fullspeed on both Wii (729Mhz PPC) & Gamecube (485Mhz PPC) Sadly, to obtain fullspeed with Virtua Racing or NTSC filters enabled, I have to lower the quality (LINEAR) or even disabled HQ mode Never thought I would have to optimize the code someday [IMG ./images/smilies/icon_wink.gif] [QUOTE] Snake wrote: [QUOTE] Eke wrote:no, it works correctly (at least, your test ROM works) initially it didn't work because setting KEY ON then key OFF without updating the enveloppe attenuation level obviously did not work I fixed that by immediately forcing attenuation level to MAX when Key ON is set and Attack rate is maximum (this was usually done on the next enveloppe update) I should fix the commentary asap [/QUOTE] Yeah, I'm pretty sure this is wrong. It seems too 'hacky'. What probably happens is that the KEY OFF happens immediately after the next envelope update, rather than immediately after the KEY ON. Note that this won't make any difference to the sound, because the previous KEY ON won't have any effect until the update happens anyway. [/QUOTE] well, according to Nemesis [QUOTE] That's their way of eliminating the attack phase. When Rate = 62 or 63 during attack, the attack phase is skipped. MAME use this calculation to immediately force the result to TL, but based on the behaviour I've observed with CSM and SSG-EG, I think it far more likely that the YM2612 doesn't even enter the attack phase, and skips straight to decay when the calculated attack rate is greater than 61. I probably should have written that in as a special case. [/QUOTE] but I'm very interested to know how exactly the chip behave is such extreme case, when Key ON/OFF are exactly taken in account (after a new EG cycle or after an enveloppe update ? but what happen in the case of very slow update rates ?) , what happens internally (attenuation level reseted or not ? phase counter reseted ?) [QUOTE] No it isn't. Where did that come from? [/QUOTE] I'm curious also, this definitively sound too weird, no programmers could have leave this that way [IMG ./images/smilies/icon_eek.gif] ######## POST p6523 | AamirM | 2008-10-11 | t386-195.html Hi, [QUOTE] Snake wrote: No it isn't. Where did that come from? [/QUOTE] Thats a recording from the real hardware sent by a user. He also sent some other recordings which have pointed out bugs in my core. Some recording which are related to SSG-EG aren't emulated correctly by any emulator so he couldn't have made this up. So until and unless someone has some other real proof I am going to believe it sounds like that. stay safe, AamirM ######## POST p6524 | Snake | 2008-10-11 | t386-195.html [QUOTE] Eke wrote:Never thought I would have to optimize the code someday [IMG ./images/smilies/icon_wink.gif] [/QUOTE] I'd offer, but I don't much like PPC [IMG ./images/smilies/icon_wink.gif] [QUOTE] Eke wrote:well, according to Nemesis [QUOTE] That's their way of eliminating the attack phase. When Rate = 62 or 63 during attack, the attack phase is skipped. MAME use this calculation to immediately force the result to TL, but based on the behaviour I've observed with CSM and SSG-EG, I think it far more likely that the YM2612 doesn't even enter the attack phase, and skips straight to decay when the calculated attack rate is greater than 61. I probably should have written that in as a special case. [/QUOTE] [/QUOTE] Nah. Only thing that touches the envelope is the envelope generator. And that doesn't update every cycle. [QUOTE] Eke wrote:I'm curious also, this definitively sound too weird, no programmers could have leave this that way [IMG ./images/smilies/icon_eek.gif] [/QUOTE] Well, I've heard this plenty of times, so I know it doesn't sound like that. But yeah, I'm curious as to where this came from. [QUOTE] Aamir wrote:So until and unless someone has some other real proof I am going to believe it sounds like that. [/QUOTE] Ok. But it doesn't [IMG ./images/smilies/icon_wink.gif] ######## POST p6525 | AamirM | 2008-10-11 | t386-195.html Hi, [QUOTE] Snake wrote:I'd offer, but I don't much like PPC Wink [/QUOTE] I always wanted to know how Kega resamples. Are you using linear interpolation? stay safe, AamirM ######## POST p6526 | TmEE co.(TM) | 2008-10-11 | t386-210.html Seems I've got do some hardware recording... Battletech track 12, right ? ######## POST p6527 | AamirM | 2008-10-11 | t386-210.html Yes thats it. ######## POST p6529 | Snake | 2008-10-12 | t386-210.html [QUOTE] TmEE co.(TM) wrote:Seems I've got do some hardware recording... Battletech track 12, right ? [/QUOTE] Well It'd be interesting. Your machine(s) are heavily modified, right? If you can get something that sounds as bad as what Aamir posted, please do tell... I can tell you that it was not meant to sound like that. All GEMS stuff was created on very early model 1 consoles (it required the EXT port on the back) and that track does not sound like that on such consoles. Given that this sound is way out of spec, its possible it sounds completely wrong on some later model console that doesnt use a real YM2612. Doesn't change the fact that it's not supposed to sound like that. I have a sample somewhere, I'm trying to find it. [edit]Here we go. But, yes. There is a lot more to this bug. ######## POST p6531 | Eke | 2008-10-12 | t386-210.html cool, I got it sounding exactly like your sample [IMG ./images/smilies/icon_wink.gif] I don't want to imagine the moment when we would be emulating specific Mega Drive & Genesis revisions [IMG ./images/smilies/icon_rolleyes.gif] ######## POST p6532 | TmEE co.(TM) | 2008-10-12 | t386-210.html http://www.fileden.com/files/2008/4/21/ ... Tech12.ogg My unmodded MD1 sounds same, except it has more noise because of the stonger "ladder effect". Regen sounds way off, Fusion is not quite correct either, and Gens, well it blips [IMG ./images/smilies/icon_razz.gif] Didn't try other emulators... ######## POST p6533 | AamirM | 2008-10-12 | t386-210.html Hi, [QUOTE] TmEE co.(TM) wrote: Regen sounds way off, Fusion is not quite correct either, and Gens, well it blips Razz Didn't try other emulators... [/QUOTE] Hah [IMG ./images/smilies/icon_smile.gif] . Now I can safetly say that it doesn't sound weird to me without me being getting called a wierdo [IMG ./images/smilies/icon_biggrin.gif] . Now I wonder whats causing that. [QUOTE] TmEE co.(TM) wrote: Regen sounds way off, Fusion is not quite correct either, [/QUOTE] Thats because they both are producing the detune bug. At least thats what the real thing should do. Can you also listen to ComixZone track 5 on the same machine and see if it produces this bug there as well because it uses pretty much the same settings on channel 3. Now I 100% know that comixzone shouldn't produce this thing and which will make things more interesting [IMG ./images/smilies/icon_wink.gif] . stay safe, AamirM ######## POST p6536 | Eke | 2008-10-12 | t386-210.html What is interesting is that we got two samples from hardware that sounds VERY differently: could it be that one is running on a PAL Mega Drive and the other one on a NTSC Genesis ? Or could the output circuitry from one or another filters frequency in a different way ? ######## POST p6537 | AamirM | 2008-10-12 | t386-210.html Hi, [QUOTE] What is interesting is that we got two samples from hardware that sounds VERY differently: could it be that one is running on a PAL Mega Drive and the other one on a NTSC Genesis ? Or could the output circuitry from one or another filters frequency in a different way ? [/QUOTE] Yeah, could be it. I think Battletech was only meant to be run on NTSC machines. stay safe, AamirM ######## POST p6538 | TmEE co.(TM) | 2008-10-12 | t386-210.html My MD2 was with NTSC master clock and 50Hz setting, I tried other combinations and there's no difference in sound (except speed). Also my Nomads and Christuserloeser's X'eye and Wondermega sound same (as all are MD2 basically). Unmodified MD2 that's same model as my primary use one sounds same. I'll do a recording of the MD1 aswell... and while at it, I have a SE-95 YM2612 clone chip, I've socketed my MD1s YM2612, and do a recording of that aswell then. I'll make a record of the Comix Zone track 5... I don't recall it well anymore, but if you expect it to do the blip sound, it won't... same goes for Flashback, Bloodshot (nothing more coming to mind). The bug is very specific I think. ######## POST p6539 | Christuserloeser | 2008-10-12 | t386-210.html I think it's the early Yamaha 2612s that do sound correctly with GEMS - like Steve Snake said. The SEGA developed 2612 clones used in later MD1s and all MD2 based hardware will sound similar to what TmEE recorded. [QUOTE] TmEE co.(TM) wrote:I'll do a recording of the MD1 aswell... and while at it, I have a SE-95 YM2612 clone chip, I've socketed my MD1s YM2612, and do a recording of that aswell then. [/QUOTE] Is that the one from the Scorpion/AITO ? I would love to hear some recordings done with this chip! [IMG ./images/smilies/icon_biggrin.gif] ######## POST p6540 | TmEE co.(TM) | 2008-10-12 | t386-210.html My MD1 is the early kind without TMSS, same as what HardWareMan has, except not so modded [IMG ./images/smilies/icon_smile.gif] It has regular Yamaha YM2612 chip in it... And the SE-95 is from the AITO (which seems to have a dead functional part in it.....). SE-95 has higher output levels compared to real YM2612 and its sound seemed cleaner... I'll do some recordings soon. ######## POST p6541 | AamirM | 2008-10-12 | t386-210.html Hi, [QUOTE] I think it's the early Yamaha 2612s that do sound correctly with GEMS - like Steve Snake said. The SEGA developed 2612 clones used in later MD1s and all MD2 based hardware will sound similar to what TmEE recorded. [/QUOTE] No. Its just this game. I had a PAL MD and I know that ComixZone track 5 doesn't sound like that. I also have ran ComixZone on a chinese clone MD (one with the 132-in-1 logo, there seem to be like hundred types of them [IMG ./images/smilies/icon_smile.gif] ) and that sounds correct as well. So I am guessing this game is doing something different. Too bad both systems are busted now [IMG ./images/smilies/icon_sad.gif] (chinese one was expected). stay safe, AamirM ######## POST p6545 | TmEE co.(TM) | 2008-10-12 | t386-210.html http://www.fileden.com/files/2008/4/21/ ... CRDNGS.RAR CCAM MD2, MD1 with YM2612 and MD1 with SE-95 clone chip... seems MD2 YM2612 implementation does sound different with BattleTech... I still prefer MD2 over anything. ######## POST p6546 | AamirM | 2008-10-12 | t386-210.html Hi, [QUOTE] CCAM MD2, MD1 with YM2612 and MD1 with SE-95 clone chip... seems MD2 YM2612 implementation does sound different with BattleTech... I still prefer MD2 over anything. [/QUOTE] Thanks man [IMG ./images/smilies/icon_wink.gif] . I'd say Regen sounds closer to MD1 w/ YM2612. stay safe, AamirM ######## POST p6549 | Eke | 2008-10-12 | t386-210.html So, much probably, those various ym2612 chips have different internal register width good to know, now we need Nemesis to do ALL his tests again [IMG ./images/smilies/icon_wink.gif] ######## POST p6553 | Christuserloeser | 2008-10-12 | t386-225.html [QUOTE] TmEE co.(TM) wrote:http://www.fileden.com/files/2008/4/21/ ... CRDNGS.RAR CCAM MD2, MD1 with YM2612 and MD1 with SE-95 clone chip... seems MD2 YM2612 implementation does sound different with BattleTech... I still prefer MD2 over anything. [/QUOTE] Wow, I am quire impressed by the SE-95! Sounds great! A bit like a mix between MD1 and MD2, but with low volume for the PSG channels. I would love to hear a recording of Bare Knuckle 2's Go Straight Beatmix and Never Return Alive... ######## POST p6554 | Snake | 2008-10-12 | t386-225.html [QUOTE] AamirM wrote:No. Its just this game. [/QUOTE] Well as you can clearly hear from the samples now provided, the later chips are quite different to the original. And as I pointed out, this stuff was all created on the earlier models. Kega has this right, based on a real YM2612, which is, after all, what I'm trying to emulate [IMG ./images/smilies/icon_wink.gif] The only reason it sounds different to the YM2612 sample is because my filter is a bit off. It's *very* hard to get this exact and I haven't spent anywhere near enough time on it. But back to the bug for a second... Why did somebody create sounds that used this? All of them are on channel 3, using special mode, where they could very easily have set the operator to the same high frequency legitimately. Unless doing this does something different... [QUOTE] I don't want to imagine the moment when we would be emulating specific Mega Drive & Genesis revisions [/QUOTE] Pretty much all dev hardware was based on early models, so I would just stick to those, personally. [QUOTE] I'd say Regen sounds closer to MD1 w/ YM2612. [/QUOTE] Regen makes a 'tick' sound instead of a quiet 'beep'. This is because you're outputting way higher than the real chip does. You should filter and downsample. ######## POST p6558 | HardWareMan | 2008-10-13 | t386-225.html I think this is a philosophical question - whats sounds correct? YM2612 - is original. PCS95 - YM2612 hardware clone. Seen under this angle, it seems like inaccurate simulation. So the main question is: Whats sounds correct? Original YM2612 or its clone PCS95? ######## POST p6559 | Snake | 2008-10-13 | t386-225.html As I said, these sounds will have been created on an original NTSC Genesis 1. Therefore however it sounds on one of those is how it was intended to sound. This particular story gets even more interesting. I had someone test it on an NTSC Genesis 2. Guess what? It sounds pretty much exactly the same as an NTSC Genesis 1. So it would seem its got something to do with PAL consoles, but what, I'm not exactly sure. It doesn't seem to be a timing issue, it's something else. Maybe this is why the game didn't get released outside the US - they couldn't figure out what the hell was going on [IMG ./images/smilies/icon_smile.gif] ######## POST p6562 | Eke | 2008-10-13 | t386-225.html What is funny is that we were looking for months how to get ride of this "blip-blip" awful sound and now we try to figure how to make it reappear [IMG ./images/smilies/icon_lol.gif] Anyway, I agree and, for the time being, I will restrict my definition of "accurate" to "how it was designed to sound" [QUOTE] Regen makes a 'tick' sound instead of a quiet 'beep'. This is because you're outputting way higher than the real chip does. You should filter and downsample. [/QUOTE] downsample to how much ? in my case, I'm stuck to 32khz or 48Khz and which kind of filter to we exactlly need ? I'm currently using a very simple low-pass filter but that does not "muffle" the sound so much [QUOTE] The only reason it sounds different to the YM2612 sample is because my filter is a bit off. It's *very* hard to get this exact and I haven't spent anywhere near enough time on it. [/QUOTE] Could it be possible to implement a filter based on the exact values of the RC composants from a real machine ? or would it be a completely wrong approach ? ######## POST p6563 | TmEE co.(TM) | 2008-10-13 | t386-225.html Have a filter which gets rid on anything above 10KHz or so would be what's in MD2, plus a great deal of distortion... for MD1, you can omit the distortion... downsample the output to 22KHz and you get what real HW does after its crappy mixer circuits... not my idea of good sound... Its odd that NTSC MD2 would sound like MD1... I have some Nomads and Christuserloeser's X'eye and Wondermega, which are all true NTSC systems with variations of main components used in all MDs.... this is getting interesting here. X'eye and my MD2 uses 315-5660 chipset, Nomad uses 315-5700, Wondermega uses the earliest 315-4xxx chipset... These are the 3 I've encountered, and I don't think there's more of the same kind. One thing about MD2 is the REALLY shitty mixer, just listen the before and after : http://www.sega-16.com/forum/showpost.p ... stcount=60 I think if I'd record the BattleTech tune from original MD2, it would sound so different its sounds like what's coming from MD1... I'm gonna do more recordings... more games please [IMG ./images/smilies/icon_smile.gif] ######## POST p6564 | HardWareMan | 2008-10-13 | t386-225.html OffTop: [QUOTE] TmEE co.(TM) wrote:http://www.sega-16.com/forum/showpost.p ... stcount=60 [/QUOTE] I can tell you how to get PAL color even in 60Hz mode (PAL60) without RGB cable. You need this: 1 20..40 pF capacitor and PAL quartz 4.43MHz. You have to cut off color subcarrier frequency from VDP and PAL/NTSC mode pin. Then solder quartz series with a capacitor to PAL encoders and set PAL/NTSC pin always to PAL mode. ######## POST p6565 | AamirM | 2008-10-13 | t386-225.html Hi, [QUOTE] Snake wrote: Regen makes a 'tick' sound instead of a quiet 'beep'. This is because you're outputting way higher than the real chip does. You should filter and downsample. [/QUOTE] Yeah, I am not doing any sort of filtering. I will probably write a new resampler/filter when I get the time which will resample using filtering with more better quality. But as Eke asked already, downsample to how much? Its my experience that MD's output is bassed quite a bit meaning one will need more heavy lowpass filtering. stay safe, AamirM ######## POST p6567 | TmEE co.(TM) | 2008-10-13 | t386-225.html [QUOTE] HardWareMan wrote:I can tell you how to get PAL color even in 60Hz mode (PAL60) without RGB cable. You need this: 1 20..40 pF capacitor and PAL quartz 4.43MHz. You have to cut off color subcarrier frequency from VDP and PAL/NTSC mode pin. Then solder quartz series with a capacitor to PAL encoders and set PAL/NTSC pin always to PAL mode. [/QUOTE] I know that already, its that I don't use Composhit at all and don't bother with it. Its RGB all the way at my place [IMG ./images/smilies/icon_smile.gif] I don't have original RGB cables for MD2 or any adaptors (9-pin mini DINs are hard to find) so I had to use composhit for example... ######## POST p6570 | SmartOne | 2008-10-13 | t386-225.html AamirM, I like the idea of "sound plugins" for various types of filtering and sampling options. [QUOTE] TmEE co.(TM) wrote:Composhit [/QUOTE] I really wish RGB was used in the US. [IMG ./images/smilies/icon_sad.gif] ######## POST p6574 | Lord Nightmare | 2008-10-13 | t386-225.html We're trying to document the YM2612 here, correct? Wouldn't it be a better idea then to simply document the real YM2612 when run in a pal or ntsc machine, and also consequently document the two sega-made ym2612 clones when run at ntsc and pal clock rates, and just ignore the output mixing for the time being, as that is a somewhat unrelated topic? It would be interesting to document the mixer cutoffs/lowpass/downsampling etc for all the different sega (and 3rd party clone) chipsets, but thats a job for another thread, IMHO. Just my $.02 LN ######## POST p6575 | Eke | 2008-10-13 | t386-225.html at the time being, only a few people have the knowledge/ability to test and document their findings, what we are doing are only discussion and asking technical questions Well, that is also what I like about this board: you never know about what a thread will end talking about [IMG ./images/smilies/icon_biggrin.gif] ######## POST p6576 | Lord Nightmare | 2008-10-13 | t386-225.html Eke: this is true, but here comes a problem: Unless we document each chip separately from all the others, we're going to have errors in the documentation caused by 'it sounds correct' cases where due to the fact that a real ym2612 and an old type sega ic, or a real ym2151 and a middle type sega ic, or a clone ym2612 and an old type ic or... etc interact in a way that either hides some chip output that IS present or has output which is really not from the ym2612 at all. This is why I think for all ym2612 tests on real hardware, data should be captured as soon as it exits the dac on the ym2612 chip, as opposed to capturing it at the megadrive/genesis audio output pins, post-mixing. This way, instead of having to juggle a whole lot of variables (ym2612 type (real or one of the two clones), ym2612 clock rate, MD/genesis cpu clock rate, MD/genesis cpu chipset/mixer type, MD/genesis console revision (since the output filters after the mixer may change), we're down to only three: ym2612 type, ym2612 clock rate (pal vs ntsc), and MD/genesis cpu clock rate (pal vs ntsc), and we can ignore the rest of the mixer stuff. Once the three ym2612-and-clones chips are documented, then we can go back and do sine wave sweeps, etc on the mixer and different hardware revisions and messing with the VDP/sn76494 sound, to properly characterize different hardware revisions. The ym2612 is separate. Again, this is just my opinion, based on other stuff I've worked on. LN ######## POST p6577 | Eke | 2008-10-13 | t386-225.html [IMG ./images/smilies/icon_lol.gif] As I said, we were only discussing way to improve the accuracy of emulator outputs and this end up discussing hardware filtering and mixing, nothing more Don't worry, I'm sure Nemesis (or other technical people willing to do the same thing) knows well what they need to test and how exactly they have to test it [IMG ./images/smilies/icon_wink.gif] ######## POST p6578 | Arbee | 2008-10-13 | t386-225.html LN: well, this board is about the Genesis/MD, so the filters on the back end do matter. (If schematics exist, they'd probably be fairly easy to hook up in MAME with the discrete audio subsystem). I can't think of any cases where the filter would somehow give Nemesis false results anyway. I do agree 100% with Snake regarding 2612 knockoffs: the real 2612 and other bits of a model 1 Genesis/MD should always be the default setting. It's of course fun to discover and emulate how the clones and ASICs differ, but they're not what the composers intended the games to sound like. ######## POST p6579 | Lord Nightmare | 2008-10-13 | t386-240.html Arbee: Indeed they do matter, but I was wondering whether it would be better to discuss them in a separate thread or not. I defer to the people already in the discussion though, since everyone else here knows a lot more about this stuff than I do. However the discussion has piqued my interest in trying to do an fpga implementation of the ym2612... LN ######## POST p6580 | King Of Chaos | 2008-10-13 | t386-240.html I agree with Snake too. By default it should sound like the model 1 Genesis/MD since that's what the games were developed on. Now, that doesn't mean there can't be several modes where you can sound like the other ASICs or knock off YM2612s. [IMG ./images/smilies/icon_smile.gif] ######## POST p6581 | TmEE co.(TM) | 2008-10-13 | t386-240.html Emulators sound like MD2 mostly, with the nice and clean sound. Real YM2612 has quite bit of the "ladder effect" noise in the sound, where as MD2 ASIC YM2612 does have it much less. Also, real YM2612 has its sine a bit shifted on half periods... one half its 1 step up, other half not... I have a sample somewhere on this forum. Slight tonal change happens because of it. MD2 ASIC has perfect sine to say so. I don't know about the clone chip SE-95... I presume its a slightly modified YM2612 (a decapped one...) [QUOTE] http://www.epicgaming.us/tiido/MD_Sine.rar Kindly done by Epicenter [IMG ./images/smilies/icon_smile.gif] [IMG http://www.epicgaming.us/tiido/waveform_analysis.png] I hope this sheds some light on YM2612's internals Each WAV has 5 or 6 samples in it, First with Total Level at 00h, and each following has it incremented. 0, 1, 2... notice how the wave gets better with lower TLs... and they should be 27.5Hz... [/QUOTE] ######## POST p6582 | Snake | 2008-10-13 | t386-240.html [QUOTE] Lord Nightmare wrote:This is why I think for all ym2612 tests on real hardware, data should be captured as soon as it exits the dac on the ym2612 chip [/QUOTE] Indeed. But most YM chips output digitally to an external DAC. The YM2612 has the DAC and other things internally. There is some filtering that goes on BEFORE the signal exits the chip, and that's what I was really talking about. ######## POST p6583 | SmartOne | 2008-10-13 | t386-240.html What is it called again where you crack open an integrated circuit and >>dye<< the bits to obtain a 100% accurate representation of what goes on? Expensive, but intriguing? ######## POST p6584 | Snake | 2008-10-13 | t386-240.html [QUOTE] SmartOne wrote:What is it called again where you crack open an integrated circuit and die the bits to obtain a 100% accurate representation of what goes on? Expensive, but intriguing? [/QUOTE] Murder. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p6585 | SmartOne | 2008-10-14 | t386-240.html Awww, *expletive.* I knew I was spelling that wrong! DYE. ######## POST p6588 | HardWareMan | 2008-10-14 | t386-240.html [QUOTE] Snake wrote: [QUOTE] SmartOne wrote:What is it called again where you crack open an integrated circuit and die the bits to obtain a 100% accurate representation of what goes on? Expensive, but intriguing? [/QUOTE] Murder. [IMG ./images/smilies/icon_biggrin.gif] [/QUOTE] Not quite. The Chinese often do. When the chip must be protected in reading, they whittle away the shell and read under a microscope. [IMG ./images/smilies/icon_wink.gif] And there are real benefits of this technique. So the method is technically and feasible. And the Chinese are 100% did so. But who would do so now for us? ######## POST p6590 | ElBarto | 2008-10-14 | t386-240.html That's the goal of the "Decapping Project" for MAME. ######## POST p6592 | Shiru | 2008-10-14 | t386-240.html [QUOTE] ElBarto wrote:That's the goal of the "Decapping Project" for MAME. [/QUOTE] Isn't goal of this project is to only 'dump' masked ROMs which is undumpable otherwise? Reading masked ROM data from scanned chip surface is much simpler than reconstructing chip logic from same source (if it possible at all). ######## POST p6593 | Nemesis | 2008-10-14 | t386-240.html [QUOTE] Not quite. The Chinese often do. When the chip must be protected in reading, they whittle away the shell and read under a microscope. And there are real benefits of this technique. So the method is technically and feasible. And the Chinese are 100% did so. But who would do so now for us? [/QUOTE] It wouldn't be too hard to do decapping at home, but it is a little dangerous. I had a good look at it awhile back. In order to do it properly, you need to use concentrated fuming nitric acid, which is nasty stuff. The method is simple though, it's just the acid that's dangerous. You'd want a proper fume cabinet to use, but it's the kind of thing you could easily do with the equipment you'd find in a highschool science lab. I had a go at decapping a chip just using a hand-held dremel recently, and the results were surprisingly good on the chips I tried, but you need a really steady hand, and you always end up damaging some parts of the die. Decapping is mainly useful for reading embedded ROM data though. I'm not sure how much the untrained eye could figure out in terms of how an IC actually performs various operations from pictures of the die. Never know until you try though I guess. Anyway, I've been away on holidays and then working on other areas of my emulator, so I haven't done much on the YM2612 in the last few weeks. Some SSG-EG issues came up in the Regen thread which I need to do some tests for, and I'm definitely going to have to get to the bottom of this track 12 issue in BattleTech. I was hoping that there weren't any YM2612 differences between the various mainstream Mega Drive systems. Looks like we're not quite so lucky. I agree with Snake that the focus should be on emulating the "real" YM2612, but I will do tests on the other models now to figure out what's responsible for this difference at least. I own just about every Mega Drive model, variant, and spinoff ever made, so I can run tests on all the different PAL and NTSC models with what I have on hand. ######## POST p6594 | Eke | 2008-10-14 | t386-240.html Still the question is, about the Model2 chip: why the "blip blip" sound is clearly more audible in battetech track 12 but sounds not so different from a Model 1 chip in Comix ZOne track 05 ? Both use the exact same instrument settings, the only difference being the incriminated operator RR & TL values(0x00 in Battletech, 0x0e in Comix Zone) I did not succeed in emulating both accurately by simply increasing the former 17-bits register width, this must be something else going on [QUOTE] Indeed. But most YM chips output digitally to an external DAC. The YM2612 has the DAC and other things internally. There is some filtering that goes on BEFORE the signal exits the chip, and that's what I was really talking about [/QUOTE] . I would love to know more about that and no, I'm not tired of asking [IMG ./images/smilies/icon_lol.gif] One example I think could result from bad filtering is the Konami Logo jingle in some games that sound crackly on emulators but perfectly clear in Kega ######## POST p6595 | TmEE co.(TM) | 2008-10-14 | t386-240.html http://www.fileden.com/files/2008/4/21/ ... GMPLAY.ogg Here's Konami logo along with some other things from my MD2. Mike-Stamp's VGMplay is used. ######## POST p6596 | zack | 2008-10-14 | t386-240.html http://d.hatena.ne.jp/video/niconico/sm3495564 This is the only one video i know which compare sound of jp md1 and md2. I will say md1 better than md2 in this video. u could easily hear noise in md2's sound. ######## POST p6601 | SmartOne | 2008-10-14 | t386-240.html Are you sure that's the correct Konami logo in the recording? The only one I know that has the crackling issue is the one from Zombies Ate My Neighbors. Castlevania Bloodlines BGM 26 distorts similarly. ######## POST p6602 | Snake | 2008-10-14 | t386-255.html [QUOTE] HardWareMan wrote:Not quite. The Chinese often do. [/QUOTE] Yeah, I know. I just love these chips and the thought of even one being destroyed, for any reason... *shudder* [QUOTE] Eke wrote:this must be something else going on [/QUOTE] Yep. Doesn't make any sense at all, does it? I'd like to hear this particular sound from a known completely unmodified PAL MD2 before I think about it too much, though [IMG ./images/smilies/icon_wink.gif] I have no idea on what the sample Aamir provided came from but the sound is even louder than TmEE's CCAM MD2. I really think that must have been modified in some way. Or is just broken [IMG ./images/smilies/icon_wink.gif] ######## POST p6603 | YM2612fan | 2008-10-15 | t386-255.html [QUOTE] TmEE co.(TM) wrote:I'm gonna do more recordings... more games please [IMG ./images/smilies/icon_smile.gif] [/QUOTE] Can you post recordings from your modified MD2 of these tracks...I'd really like to hear them using your audio mod. Blaster Master - TUNE 3 Heavy Nova - BGM 10 Hellfire - BGM 07 Subterrania - ENEMY MINES (LEVEL IV) Combat Cars - BGM 03 ######## POST p6604 | HardWareMan | 2008-10-15 | t386-255.html [QUOTE] Snake wrote: [QUOTE] HardWareMan wrote:Not quite. The Chinese often do. [/QUOTE] Yeah, I know. I just love these chips and the thought of even one being destroyed, for any reason... *shudder* [/QUOTE] Oh yeah? So you need just do brute force attack with all combinations all parameters and record the result. And see what happend. If somebody starts do this, say, in 2000, it will be already done, I think. ######## POST p6606 | Snake | 2008-10-15 | t386-255.html That's what I've been doing since 1997 [IMG ./images/smilies/icon_smile.gif] Little bugger still has secrets. ######## POST p6607 | TmEE co.(TM) | 2008-10-15 | t386-255.html [QUOTE] YM2612fan wrote: [QUOTE] TmEE co.(TM) wrote:I'm gonna do more recordings... more games please [IMG ./images/smilies/icon_smile.gif] [/QUOTE] Can you post recordings from your modified MD2 of these tracks...I'd really like to hear them using your audio mod. Blaster Master - TUNE 3 Heavy Nova - BGM 10 Hellfire - BGM 07 Subterrania - ENEMY MINES (LEVEL IV) Combat Cars - BGM 03 [/QUOTE] One thing with Hellfire, the music will be 2x slower... that is so on all MD2 based systems... mr. Snake can tell more about it I think... Heavy Nova is much likely to suffer from heavy clipping (on many tunes) as MD2 YM2612 seems to start clipping at lower amplitudes that real YM2612. And Wondermega sounds exactly like MD2, despite having the earliest MD2 ASIC in it. ######## POST p6609 | AamirM | 2008-10-16 | t386-255.html Hi, [QUOTE] I'm gonna do more recordings... more games please [/QUOTE] Busy at the moment but I was just reading this and wanted to request a recodring of Spiderman Separation Anxiety intro music. stay safe, AamirM ######## POST p6610 | TmEE co.(TM) | 2008-10-16 | t386-255.html Recordings are done, and slowly being uploaded... my connection sucks today :/ ######## POST p6611 | Eke | 2008-10-16 | t386-255.html sorry, I forget to ask: could you do a recording of Ecco: the Tide of Time 's splash sound (first level, do some jump out of the water, Gens is reproducing the sound more realistic than other emulators though I don't know if realistic=reality) thanks again ######## POST p6612 | TmEE co.(TM) | 2008-10-17 | t386-255.html http://www.fileden.com/files/2008/4/21/ ... vyNova.ogg http://www.fileden.com/files/2008/4/21/ ... D2CCAM.ogg http://www.fileden.com/files/2008/4/21/ ... ermega.ogg http://www.fileden.com/files/2008/4/21/ ... rrania.ogg http://www.fileden.com/files/2008/4/21/ ... derMan.ogg http://www.fileden.com/files/2008/4/21/ ... llfire.ogg These are the first recordings, other ones come soon. All except Hellfire come from Mike-Stamp's magnificent VGM player. ######## POST p6613 | Lord Nightmare | 2008-10-17 | t386-255.html I have a question (this is a big one too): what asics are used in all the versions of the MD/genesis, and what is the label of each YM2612 or 2612-clone chip in each one? And how do wondermega and the Amstrad mega-pc and mega-pc plus fit in to all this? Also, what is the chronological order of the system revision releases? (This data is needed to clean up the MD/genesis driver in MESS) LN ######## POST p6614 | HardWareMan | 2008-10-17 | t386-255.html [QUOTE] TmEE co.(TM) wrote:http://www.fileden.com/files/2008/4/21/ ... rrania.ogg [/QUOTE] My turn. Same track (MD1, YM2612), but not VGM - true PD ROM (for more details see this page ). [IMG ./images/smilies/icon_wink.gif] ######## POST p6615 | TmEE co.(TM) | 2008-10-17 | t386-255.html [QUOTE] HardWareMan wrote:My turn. Same track (MD1, YM2612), but not VGM - true PD ROM (for more details see this page). [/QUOTE] Someone have been busy [IMG ./images/smilies/icon_smile.gif] Mike-Stamp made one impressive ripping work too. EDIT: How is your track recorded, is there any post processing done ? Now for ASICs, I've come accross 3 compatible variants, 315-5487 (used in MD1 VA7, Wondermega, MD2 VA0), 315-5660 (MD2 VA1 and VA3, X'eye) and 513-7000 (Nomad). All have same pinout and seem to be working same (though I have no idea how same, no good equipment to do detail testing...). And Hellfire plays at correct speed in VGM ######## POST p6616 | Snake | 2008-10-17 | t386-255.html [QUOTE] Eke wrote:sorry, I forget to ask: could you do a recording of Ecco: the Tide of Time 's splash sound (first level, do some jump out of the water, Gens is reproducing the sound more realistic than other emulators though I don't know if realistic=reality) thanks again [/QUOTE] Kega has this game 100% correct. In fact, there are two different sounds, and it seems like Gens is only playing one of them. ######## POST p6617 | Eke | 2008-10-17 | t386-255.html [QUOTE] [QUOTE] sorry, I forget to ask: could you do a recording of Ecco: the Tide of Time 's splash sound (first level, do some jump out of the water, Gens is reproducing the sound more realistic than other emulators though I don't know if realistic=reality) thanks again [/QUOTE] Kega has this game 100% correct. In fact, there are two different sounds, and it seems like Gens is only playing one of them. [/QUOTE] exactly what I noticed the second sound seemed weird into my hear but if you can confirm it happens on real hw also, that's fine ######## POST p6621 | Snake | 2008-10-17 | t386-255.html [QUOTE] Eke wrote:exactly what I noticed the second sound seemed weird into my hear but if you can confirm it happens on real hw also, that's fine [/QUOTE] Yeah. It seems you're meant to hear a 'splash' when you are out of the water, and that other slightly odd sound when you're under it. ######## POST p6623 | AamirM | 2008-10-18 | t386-270.html Hi, @ TmEE Thanks a bunch for posting that recording. Now.... @ Snake In that Spiderman recording, notice that a intrument is played using channel 3 (alternating between left and right channels) has quite low level compared to all other emulators (except Kega) and I would like to know how do you do that? stay safe, AamirM ######## POST p6630 | Lord Nightmare | 2008-10-19 | t386-270.html In response to ym2612 versions, there appear to be 7 variants of the MD system *in terms of ym2612 and VDP*: MD1 VA0 thru VA6: use a real yamaha ym2612 and a real 315-5313 VDP (note that va0 and va4 (and likely the intervening models, but please correct me) have 3 asics, while at least va5 and va6 have only two, one of which is the vdp) MD1 VA7 thru MD2 VA1, plus MD2 VA3: use a FC1004 ASIC with ym2612 and VDP functionality integrated. The amstrad mega-pc also uses this same ASIC. MD2 VA2: need more info on this MD2 VA4/MD3 VA1: uses 315-5960 asic, need more info on where the ym2612 is hiding MD3 VA0: need more info on this MD3 VA2: uses 315-6123 "FQ8007" asic, need more info Nomad(and megajet?): uses a 315(or is this 513?)-7000(or is it 5700?) ASIC with ym2612 and VDP integrated (as well as the z80?) So for sound analysis, we need to consider all of these 7 (and there are likely more) as separate. Most emulators probably should try to emulate the original MD1 config with the separate ym2612, alternately choosing the FC1004 asic which has a 'cleaner' ym2612. Edited 10/20/2008, thanks to Tmee for corrections LN ######## POST p6631 | SmartOne | 2008-10-19 | t386-270.html Wow, but do those four really sound that different? ######## POST p6632 | TmEE co.(TM) | 2008-10-19 | t386-270.html Real YM2612 sounds one way (poorer), and ASIC variants all sound same. I have systems with all 3 in them, and no difference whatsoever. My VA1 MD2 ( http://www.hot.ee/tmeeco/MYSMD2.JPG ) has 315-5660, the VA1.x plays no role to what's in the machine, 5487 is old, 5660 is newer, and 5700 is newest from these types of ASICs. MD2 VA2 uses discrete YM2612, and different ASIC, MD2 VA4 uses same setup as one of the 2 known Genny3 setups. I know nothing about MD2 VA4 nor Genny3s. The last Genny3 setup, or maybe the one also used in MD2 VA4, has some things altered in them which causes incompatibilities with few games, and around around 10% US SMS games have some glitches (so I've been told). ######## POST p6633 | Snake | 2008-10-19 | t386-270.html [QUOTE] TmEE co.(TM) wrote:Real YM2612 sounds one way (poorer) [/QUOTE] Blasphemy! [IMG ./images/smilies/icon_wink.gif] Certainly, with your audio mod, an MD2 sounds better - but without it - ugh. But with a similar audio mod I think you'd find a real YM2612 doesn't sound much different, if it all. ######## POST p6635 | TmEE co.(TM) | 2008-10-19 | t386-270.html It makes things nice and clear, but the sheer amount of the "ladder effect" noise which is otherwise filtered out ruins all experience for me... it sounds like a damn 6-bit WAV (not as bad, but you get the idea...). ######## POST p6636 | HardWareMan | 2008-10-19 | t386-270.html [QUOTE] TmEE co.(TM) wrote:It makes things nice and clear, but the sheer amount of the "ladder effect" noise which is otherwise filtered out ruins all experience for me... it sounds like a damn 6-bit WAV (not as bad, but you get the idea...). [/QUOTE] Indeed. YM2612 "ladder" effect was clearly hear at very low volume on every FM channel (did not tested it for DAC). But I had MD2 with integrated YM2612+Z80+M68000+Arbiter+IOPort in one big chip. It did not produce this "ladder" effect but it did mute some very low volume sounds! Very noticeable cut off some weak sounds. ######## POST p6637 | TmEE co.(TM) | 2008-10-19 | t386-270.html Some cutting happens, but at these volumes, its hard to make out what you're listening anyway... My MD2 has 68K, Z80 and all RAMs separate... also, PSG carries VDP activity noise [IMG ./images/smilies/icon_razz.gif] ######## POST p6638 | Lord Nightmare | 2008-10-20 | t386-270.html I've updated the post above with the systems list with tmee's corrections, and to include late MD2 and MD3. Please add comments. Also, which MD2 has the z80 inside the giant asic? VA4? Thanks to tmee's correction, I know all the va1.x ssytems are really 'VA1' systems regardless of the second number, but I'm still missing a couple of md2 systems: FC1004 ASIC chips: (208 pins) 315-5487, 315-5487-01, 315-5487-10, 315-5660, 315-5660-02, 315-5700, all are supposedly interchangable MD2 VA0: FC1004, separate? z80 MD2 VA1(.x) (and x'eye and multimega): FC1004, separate zilog z80 or 315-5676/315-5619 which seems to be a z80 MD2 VA2: NEED INFO on this system, preferably a pcb picture. tmee says it has a separate ym2612, a non-yamaha version? MD2 VA3: FC1004, ? z80 MD2 VA4: 315-5960 asic (160 pins), may have z80 on it? do these systems have separate yamaha chips or is that inside an asic? MD3 VA0: NEED INFO on this system, preferably a pcb picture MD3 VA1: 315-5960 asic (160 pins), may have z80 on it? do these systems have separate yamaha chips or is that inside an asic? MD3 VA2: 315-6123 FQ8007 (208 pins, not compatible with FC1004, contains z80?) LN ######## POST p6639 | TmEE co.(TM) | 2008-10-20 | t386-270.html 315-5487, -5660, -5700 all are VDP+I/O+YM2612+PSG. 68K, Z80 and RAMs are separate on these systems. 5660 and 5700 are definitely pin compatible, 5487 uses same VRAM chips as what are in MD1 and I have no idea if they're compatible with the single VRAM chip used in later designs. All should be considered same. MD1 VA0...VA4, all have no TMSS, all have 2 part I/O controller, everything is with discrete chips. VA3 has one small extra digital chip in it, which function is unknown to me, possibly related to clock signals... earlier models possibly too. MD1 VA5 and VA6 are same as previous models, but have single chip I/O controller and also have TMSS. VA2 MD2 has discrete YM2612, which is made by Yamaha. Goes under MD1 category. 315-5950 has everything but VRAM and 68K RAM integrated in it. http://www.sega-16.com/forum/showthread.php?t=5079 All newer designs should be like that chip, with everything integrated... ######## POST p6641 | YM2612_fan | 2008-10-21 | t386-270.html [QUOTE] TmEE co.(TM) wrote:315-5487, -5660, -5700 all are VDP+I/O+YM2612+PSG. 68K, Z80 and RAMs are separate on these systems. [/QUOTE] What about the 315-5708 ASIC? I don't see a separate Z80 on my board (MD2 - VA1,) unless the KM428C64J-10 is a clone. ######## POST p6643 | TmEE co.(TM) | 2008-10-21 | t386-270.html VA1 boards have to have Z80 (I've only seen clone chips on all units I've had access to), 68K and RAMs... The Z80 is a small square chip near reset switch. I think it had 40 or 44 pins. 5708 is a 5660 and 5700 compatible then... how many variants Sega has !? ######## POST p6644 | Eke | 2008-10-22 | t386-270.html I've fallen accross this picture recently and made me think about this topic: http://img523.imageshack.us/img523/4518 ... ordhf9.jpg apparently, the Amstrad MegaPC had a YM3812 inside (instead of YM2612 ?) and 315-5487 (bus arbitrer + VDP/PSG ?) ######## POST p6645 | Shiru | 2008-10-22 | t386-270.html [QUOTE] Eke wrote:Amstrad MegaPC had a YM3812 inside (instead of YM2612 ?) [/QUOTE] YM3812 is OPL2, it's not compatible with YM2612. ######## POST p6646 | TmEE co.(TM) | 2008-10-22 | t386-270.html 315-5487 is the first VDP+I/O+PSG+YM2612. The OPL2 was in the MegaPC for Adlib compatibility. ######## POST p6647 | Eke | 2008-10-22 | t386-285.html thanks for clarifying, that seemed odd indeed ######## POST p6648 | Lord Nightmare | 2008-10-23 | t386-285.html ouch. whoever owned that megapc snapped capacitor c113 off of the MD isa card. SOMETHING is gonna work completely wrong until that is replaced. EDIT: nope, once again I'm wrong. C113 is NOT SUPPOSED to be populated. see a later megapc plus card here: http://aycu14.webshots.com/image/27693/ ... 198_rs.jpg It may have only been populated on some early cards. LN ######## POST p6649 | kode54 | 2008-10-25 | t386-285.html Commenting this line in the MAME fm.c source: [CODE] //SLOT->volume = MAX_ATT_INDEX; /* fix Ecco 2 splash sound */ [/CODE] seems to fix dropped or cut notes in the following VGM tracks, at least: Dynamite Headdy - Geisha Robot Bubba 'n' Stix - The Spaceport Maybe something needs further testing? ######## POST p6651 | Eke | 2008-10-26 | t386-285.html yeah, I was wrong with this one (broke some other sound effects too) and reverted it some time ago in my implementation .... unfortunately, MAME used an older version as reference and there is still some mistakes (also probably in the new one) and Steve Snake confimed the Ecco 2's sound "bug" was not a bug so... ######## POST p6659 | Arbee | 2008-10-27 | t386-285.html MAME 0.128u2 will be up to date with r157 of GenPlus-GX, including removing that "fix". Any ideas on the Battletech thing? ######## POST p6660 | Eke | 2008-10-27 | t386-285.html for me, battletech track 12 sounds like Model 1 recording, probably not exactly (kega sound a little more accurate) because it requires better filtering but close enough to me at the moment or were you talking of something else ? ######## POST p6666 | Arbee | 2008-10-27 | t386-285.html That's fine. I wasn't clear if it was a problem in the MAME code or not. ######## POST p6668 | AamirM | 2008-10-27 | t386-285.html Hi, [QUOTE] Eke wrote:for me, battletech track 12 sounds like Model 1 recording, probably not exactly (kega sound a little more accurate) because it requires better filtering but close enough to me at the moment or were you talking of something else ? [/QUOTE] Did you tried changing fn_max to something more suitable for 48000/44100 or whatever you run at? Although I am not an expert on MAME but it seems MAME will resample everything to 44100...even if you set sample rate to something higher (like 48000). stay safe, AamirM ######## POST p6669 | Eke | 2008-10-27 | t386-285.html what do you mean by "more suitable" ? I emulate the chip at his original frequency internally so I dont think I need to change the max value this should be the job of the resampler/filter (and indeed, the gc/wii output samplerate is 48Khz) ######## POST p6674 | Arbee | 2008-10-27 | t386-285.html [QUOTE] MAME will resample everything to 44100...even if you set sample rate to something higher (like 48000). [/QUOTE] No, it resamples to whatever rate you set it to. I run MAME at 48 kHz (since that's the native rate of my Audigy 2) and it works fine. ######## POST p6679 | AamirM | 2008-10-28 | t386-285.html Hi, [QUOTE] Eke wrote: what do you mean by "more suitable" ? I emulate the chip at his original frequency internally so I dont think I need to change the max value this should be the job of the resampler/filter (and indeed, the gc/wii output samplerate is 48Khz) [/QUOTE] Sorry, I forgot you used a resampler now [IMG ./images/smilies/icon_redface.gif] . [QUOTE] Arbee wrote: No, it resamples to whatever rate you set it to. I run MAME at 48 kHz (since that's the native rate of my Audigy 2) and it works fine. [/QUOTE] Thanks for clarifying that up. stay safe, AamirM ######## POST p6725 | Shiru | 2008-11-01 | t386-285.html About decapping and FM chips emulation: http://docs.google.com/View?docid=dd8kqn9f_13cqjkf4gp (OPL2 and OPL3). ######## POST p6726 | HardWareMan | 2008-11-01 | t386-285.html [QUOTE] Shiru wrote:About decapping and FM chips emulation: http://docs.google.com/View?docid=dd8kqn9f_13cqjkf4gp (OPL2 and OPL3). [/QUOTE] I wonder what they used for dissolve chip shell? I've heard, there is an liquid wich dissolve only plastic shell and did not touch the chip crystal. I would like to look at chip under a microscope... ######## POST p6727 | Shiru | 2008-11-01 | t386-285.html [QUOTE] HardWareMan wrote:they used for dissolve chip shell? [/QUOTE] They used MEFAS service . You can find list of equipment of that company on their page. Part of this list: [QUOTE] Package Decapsulation Nisene D cap system B&G 250 system [/QUOTE] I think, you can ask Matthew or Olli about hi-res photos. ######## POST p6729 | HardWareMan | 2008-11-01 | t386-285.html [QUOTE] Shiru wrote:I think, you can ask Matthew or Olli about hi-res photos. [/QUOTE] I mean I want to look at YM2612 crystal not YM3812. ######## POST p6730 | Shiru | 2008-11-01 | t386-300.html [QUOTE] HardWareMan wrote:I mean I want to look at YM2612 crystal not YM3812. [/QUOTE] Well, then you already know how much it will cost (~$90 decap without postage). I don't think it's possible to get near quality of photos at home, if you don't have good equipment and you never did it before. ######## POST p6731 | Jorge Nuno | 2008-11-01 | t386-300.html I think it is the fumic nitric acid you are looking for... (The "normal" nitric acid won't do). It's super corrosive and it's vapours can change the the skin color to yellow [IMG ./images/smilies/icon_eek.gif] ######## POST p6741 | Nemesis | 2008-11-03 | t386-300.html [QUOTE] Shiru wrote:About decapping and FM chips emulation: http://docs.google.com/View?docid=dd8kqn9f_13cqjkf4gp (OPL2 and OPL3). [/QUOTE] Thanks for posting that, I hadn't come across that info. Those tables they provided confirm a lot about how I believed the operator unit worked internally. Both the sin and pow tables have 256 entries, and the sin table is a perfect match for the data my algorithm generates. The power table is a little different however. Since the entries in the power table effectively run from 0x7FA-0x400, they didn't need to include bit 10, since it's always fixed to 1, so the entries in the real physical table run from 0x3FA-0x0. It's also interesting that they listed the entries in their power table in reverse, from 0x0-0x3FA. Did they read the table backwards, or does the index get inverted before a lookup to the power table for some reason? The result will be equivalent, but once again, it's interesting to see exactly how the real YM2612 performed its operations internally. [QUOTE] Well, then you already know how much it will cost (~$90 decap without postage). [/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. Anyone got any suggestions on a particular model? What kind of magnification do you think I'd need to get a good shot of the die? 1000x? The microscope will also need to have its own lighting built in obviously. I think I could afford to spend a reasonable sum on a decent scope. 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. ######## POST p6742 | Shiru | 2008-11-03 | t386-300.html [QUOTE] Nemesis wrote:$90? Is that all a professional decap costs? [/QUOTE] That said in the article. [QUOTE] Nemesis wrote:What kind of magnification do you think I'd need to get a good shot of the die? 1000x? [/QUOTE] This (copy-paste this link, does not work otherwise) is 100x, so probably 1000x will be overkill. ######## POST p6743 | Oliver_A | 2008-11-04 | t386-300.html [QUOTE] Nemesis wrote: I'm not really sure how much immediately useful info a decap will give us, but it'll be fun. [/QUOTE] The first component I would examine is the DAC. ######## POST p6757 | Lord Nightmare | 2008-11-06 | t386-300.html I got the high-res opl2 pics from Olli (he goes by 'yehar' on ircnet), and unfortunately, not all the chip is imaged at high res. There is also at least one smaller rom on it (roughly 16x7 bits), which could be key-shift or other LUT tables which are not imaged at a high enough resolution yet to be fully visible and decodable. I'll see if I can prod Olli to join the conversation here. LN ######## POST p6758 | Nemesis | 2008-11-06 | t386-300.html I'd be interested in taking a look at those images. Any chance of putting the archive up on a file dumping site? (if Olli is ok with that of course) I'd also be interested in hearing what kind of equipment was used to take the pictures. Did MEFAS take the pics, or did they use their own equipment, and if so, what equipment did they use? ######## POST p6767 | yehar | 2008-11-06 | t386-300.html Hi, it's Olli writing... [QUOTE] Nemesis wrote:I'd be interested in taking a look at those images. Any chance of putting the archive up on a file dumping site? (if Olli is ok with that of course) [/QUOTE] Here's one "dump": http://yehar.com/adlib [QUOTE] Nemesis wrote:I'd also be interested in hearing what kind of equipment was used to take the pictures. Did MEFAS take the pics, or did they use their own equipment, and if so, what equipment did they use? [/QUOTE] We only paid MEFAS to do the decapsulation. They were willing to do more, but presumably at a much higher cost. I went to the material technology lab (or something to that effect) at Oulu university here in Finland, and they were kind enough to let me use their microscope that was used there to inspect materials. It had its own built-in color digital camera, which however didn't have enough resolution for reading the bits from the memory. The microscopy system was from mid-90's probably, I cannot remember details like magnification. I got better results by using my pocket digicam through the eyepiece, but it was quite cumbersome, so I didn't shoot the whole die. If someone has access to a better microscope with a built-in camera and is willing to take pictures of the whole die of YM3812 (OPL2) and YMF262 (OPL3), I will gladly mail the decapsulated chips to them (drop me an e-mail at o@iki.fi ). You will need an optical microscope that has a lighting system available that does not try to beam light through the sample (typically on a glass slide), but illuminates it from above. Older chips are easier to photograph because the line width is broader. The circuit on YMF262 was already significantly more dense than on YM3812, and I don't think we would have succeeded in reading the ROM's from it alone. Nemesis, I got the impression that the sine table was sign-inverted, and that the exp table was as expected, the opposite of your analysis. :-) ######## POST p6775 | bobthebuilder | 2008-11-08 | t386-300.html How many pictures would that be and at what magnification? ######## POST p6779 | yehar | 2008-11-09 | t386-300.html [QUOTE] bobthebuilder wrote:How many pictures would that be and at what magnification? [/QUOTE] Hmm maybe 300 pictures per die and 100X magnification. ######## POST p6784 | Lord Nightmare | 2008-11-10 | t386-300.html opl2 rom3: This decoding is based on http://yehar.com/adlib/ym3812_rom3_1.jpg Legend: 0 = dark/absent gate, 1 = light/present gate C = clear/correct for this address, C? = probably correct. X = a pullup or perhaps pulldown between every 2nd rom line, only present on bits which need it. This was useful for checking to be sure if the bits present are sane or not, as such: The X will only appear if one of the bit gates immediately above or below it is present. Note that all bits may be inverted, and the bit order may be backwards as compared to the usual MSB-at-left notation. [CODE] 0000000 C 1000000 C X X 1010000 C 1011010 C XXXX X 1100000 C 1100110 C XX XXX 1101010 C 1101110 C XXXXXX 1110000 (unclear bits ...ooo.) 1110100 C XXX XX 1110110 C? 1111000 (unclear bit .....o.) XXXX X 1111010 C? 1111100 C? XXXXXX 1111110 C? 0000001 C? X [/CODE] Thats what I BELIEVE the contents of ROM3 on the opl2 are. I'm not sure what it is used for yet. 4 bits address in, 7 bits data out. LN ######## POST p6785 | Nemesis | 2008-11-11 | t386-300.html I've purchased some gear which should do the job of capturing images of the die. I'll give it a test run once it all arrives. I'm happy to take full die snaps of the YM3812 and YMF262 once I've got a process in place. I'm planning to take full coverage snaps of the entire die in a grid, at a suitable zoom level. Once I've got all the pics, I'll stitch them together into one large psd image or the like, so you'll be able to download a full die shot of the device, and zoom in on the parts you want to examine. If nothing else, it'll make a good poster. [IMG ./images/smilies/icon_biggrin.gif] I've also contacted MEFAS and got the ball rolling with getting the YM2612 decapped. ######## POST p6787 | yehar | 2008-11-11 | t386-300.html Nemesis, Nice! :-) I also just ordered a microscope, so I will delay sending you the chips until I have tried taking the pictures myself, before end of this month I hope. I bought this Aigo GE-5: http://cgi.ebay.de/ws/eBayISAPI.dll?Vie ... AQ:DE:1123 Manual: http://www.analogtechnologies.com/Aidep ... ual_EN.pdf I'll let you know if it's any good. The 1/2 " size 1280 x 1024 pixel sensor and 60X, 180X and 540X all optical magnification should give a resolution of something like 90 nm, 30 nm and 10 nm per pixel. The price of the microscope was 350 EUR including postage. ######## POST p6788 | yehar | 2008-11-11 | t386-300.html Lord Nightmare, I get exactly the same decoding. If you look at a pullup, the stuff just above and below the dark dot, that will already tell you to which ROM line the pullup is connected. ######## POST p6849 | yehar | 2008-11-20 | t386-300.html [QUOTE] yehar wrote:I also just ordered a microscope, so I will delay sending you the chips until I have tried taking the pictures myself, before end of this month I hope. I bought this Aigo GE-5 [/QUOTE] OK, having played with it an hour, it is not as good as I hoped. The 540x zoom will only give a resolution of 500 nm / pixel. The magnification ratio is probably calculated for a typical computer screen, and is NOT the ratio of enlargement to the sensor as I had thought. Currently it is not possible to read bits from memory with this setup, or even to follow the traces on the die. Now I have to use a lamp from the sides and that gives nasty highlights and not a smooth lighting. Perhaps a modification would help. The sample could be illuminated from above through a beamsplitter. Dunno. ######## POST p6854 | Lord Nightmare | 2008-11-21 | t386-315.html I did top-illumination using a 1940's binocular scope (my mom used it in medical school in the 1970s) by taking one eyepiece lens out and sticking a flashlight in the hole (being sure it didn't fall in and scratch something). It DOES work, but only so-so; you get a lot of light from the second eye directly back up the remaining one without hitting the die at all. I don't know what the maximum magnification possible is, but it is probably somewhere around 400x-500x, or maybe more with oil immersion. LN ######## POST p7393 | Jorge Nuno | 2009-01-27 | t386-315.html bump! [IMG ./images/smilies/icon_biggrin.gif] I'm quite interested to know what pin #10 on the 2612 is..., It says in wikipedia that it's a not connected pin, the genesis1 VA0 schematics don't mention it, but! It has internal resistance to both +V e Gnd (around 90kOhm, depends slightly on the measure polarity when it's powered off). Powered on and playing stuff gives 4.85V (not sure if it's steady, or if has some AC on top) ######## POST p7398 | TmEE co.(TM) | 2009-01-27 | t386-315.html IIRC, this pin is tied to the ReadyBit of chip, useful for hardware based timings (which I would not like, as I can do something useful while I wait for the chip to become ready). ######## POST p7402 | Jorge Nuno | 2009-01-27 | t386-315.html Humm? Maybe you are talking about the IRQ pin. That is #13. Pin #10 is nowhere mentioned about. It could be apparently the not-so-important /Test pin, like the one in the 2608 translated pdf, (It says it has an internal pullup). ######## POST p7409 | Nemesis | 2009-01-28 | t386-315.html I've seen some references which do in fact refer to pin 10 as the "Test" pin. I think I mentioned it in passing somewhere in this thread. TmEE is right about its function. What it does is return the real-time state of the "busy" flag from the status register. It's an output line which is asserted when the YM2612 is busy, and negated when the YM2612 is ready to receive a write. You could use it in a circuit to detect when the YM2612 is ready to receive the next write, without having to read and decode the status register. ######## POST p7410 | Nemesis | 2009-01-28 | t386-315.html Oh, and seeing as I was going to bump this thread myself soon, I might as well mention that I've got another round of info coming up, including a lot of fixes for the envelope generator. I'm very close to completing some extremely comprehensive testing which I'm using to build a binary-accurate envelope generator. When I carried out my original tests on the envelope generator, I didn't know enough about the rest of the chip to digitally sample the output from the envelope generator, but the process of fully breaking down the operator unit and the phase generator, as well as more experimentation with the test register, now allow me to perform tests where I can determine the exact digital output from the envelope generator easily. As a result, I've started from scratch with the envelope generator and re-tested everything, plus gone much further and tested a lot of stuff I wasn't able to test before. I've spent the last few weeks running an extremely comprehensive tests designed to determine exactly how, where, and when the envelope generator carries out all of its operations, and as a result, I'm very close to building a perfect YM2612 envelope generator. By that, I mean an envelope generator which perfectly emulates the YM2612 envelope generator output under every operating condition, including when any register change occurs at any point, and when those register changes are combined with all the 1001 strange cases that can occur in SSG-EG mode, including when an attack phase is used. And yeah, the MAME core will require a lot of fixes to incorporate these changes. I had to rewrite my own envelope generator from scratch to accomodate them. Virtually everything about my SSG-EG implementation was wrong, and the way a lot of it is implemented is surprising. The payoff is worth it though. I know enough about the envelope generator now to contruct some truly evil tests, and I know how to make them all pass. You won't have to worry about any games having envelope-related issues after this. In fact, when I release my core, I dare anyone to find any case in which my YM2612 doesn't produce a binary accurate output. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p7418 | Eke | 2009-01-28 | t386-315.html [QUOTE] Nemesis wrote: And yeah, the MAME core will require a lot of fixes to incorporate these changes. [/QUOTE] can't wait for it [IMG ./images/smilies/icon_wink.gif] everything seems very promising, huge thanks for your effort Nemesis ######## POST p7419 | Christuserloeser | 2009-01-28 | t386-315.html I would like to thank you as well, your work means a lot to me. ######## POST p7427 | dr. apocalipsis | 2009-01-28 | t386-315.html Can't wait to see it fully implemented in current emus ^^ ######## POST p7429 | Snake | 2009-01-29 | t386-315.html [QUOTE] Nemesis wrote:Virtually everything about my SSG-EG implementation was wrong, and the way a lot of it is implemented is surprising. [/QUOTE] It's definitely the strangest part of the chip, and as I said before, doesn't do what you'd expect in a lot of situations. You've nailed all cases now though? That's pretty cool. I ended up testing just the ones I knew were used because the only way I had of testing was (convert rom to SMD, copy to floppy, load floppy in SMD device) and it was taking me DAYS to get through all this stuff [IMG ./images/smilies/icon_sad.gif] But I don't even have that anymore so I'm looking forward to your findings. AFAIK it's the last bit of the chip that I don't have 100%. Well, ignoring the DAC distortion. ######## POST p7430 | GManiac | 2009-01-29 | t386-315.html Hi all. I hope next information will be useful. Many years ago I noticed that music of After Burner sounds poorly in emulators. I didn't know about this great research on YM2612. It seems that the latest versions of Fusion or Regen are made with a glance of new info from this research, but it didn't affect sound in After Burner. There is some instrument(s) that doesn't play in emulators. Simply listen to song "Super Stripe" on real hardware and you'll feel the difference. ######## POST p7434 | Snake | 2009-01-29 | t386-315.html [QUOTE] GManiac wrote:It seems that the latest versions of Fusion or Regen are made with a glance of new info from this research [/QUOTE] No, in fact I was going to suggest that this topic gets renamed once Nemesis is ready to post his new info, because as he has now stated, most of the stuff in here is completely wrong. [QUOTE] GManiac wrote:There is some instrument(s) that doesn't play in emulators. Simply listen to song "Super Stripe" on real hardware and you'll feel the difference. [/QUOTE] If true this is very odd. ######## POST p7435 | GManiac | 2009-01-29 | t386-315.html Here is the recording from my chinese MD2 clone (for some reason it sounds better than even MD1 HD). http://shedevr.org.ru/ghost/After_Burner_II_-_SS.ogg ######## POST p7437 | Snake | 2009-01-29 | t386-315.html Thanks - I know this tune very well (second cart I bought [IMG ./images/smilies/icon_smile.gif]) and briefly listened to it in Fusion last night. The sounds are all there, but yes, one or two of them are barely audible. The music in this game is mixed at a very low volume so that the PSG samples can be heard at a decent volume. At first glance it looks like some of these sounds are louder on the real thing simply because of the distortion that occurs in the real chip. That really does need to be figured out... ######## POST p7439 | GManiac | 2009-01-29 | t386-315.html I noticed that those "instruments" are very quiet too, and I listened to only them, turning off other channels in Winamp plugin. But when I listened to hardware, its sound was more wealthy, that's why I thought that something is not playing in emulators. Although all channels are present in emulators and some of them are quiet, the main reason of poorness is not in their loudness. At this time I cut PSG (drums) and channels 1, 2 from VGM file and recorded its playback. Here's the files: http://shedevr.org.ru/ghost/After_Burner_SS_Cut.zip Seconds from 2 to 16 in Kega's playback were amplified by 3 to normalize loudness. As you see, these seconds differ sufficiently from hardware playback. Even if this all is tricks of incorrect loudnesses [IMG ./images/smilies/icon_lol.gif] (of course, no, sounds are too different) it should be corrected. ######## POST p7440 | Snake | 2009-01-30 | t386-330.html Yes, that makes perfect sense. The distortion effect makes the sounds louder as well as making them sound quite different. I think this is probably the culprit here. Good find, by the way, I can't believe I didn't spot that one myself. ######## POST p7441 | AamirM | 2009-01-30 | t386-330.html [QUOTE] No, in fact I was going to suggest that this topic gets renamed once Nemesis is ready to post his new info, because as he has now stated, most of the stuff in here is completely wrong. [/QUOTE] Wait, I thought Nemesis said only SSG-EG stuff was wrong. If you think some other things are wrong as well, then please state the corrections. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p7443 | Nemesis | 2009-01-30 | t386-330.html All the stuff I've posted about the phase generator and operator unit stands. The latest information I provided about those areas is all correct to the best of my knowledge. There are some significant errors in the information I posted on the envelope generator, some of which I've already corrected, but a lot of which I have yet to correct. Most of the errors relate to SSG-EG mode. Apart from that, there's one error in my description of the interrupt line for the YM2612, which I'll post along with the envelope generator info, but I'm not aware of any other errors apart from that, so far at least. Feel free to share any corrections you might have about what's been posted in this thread so far, or any further info you might have about the YM2612. Also let me know if there are things you suspect might be incorrect, and I'll re-test. ######## POST p7445 | Snake | 2009-01-30 | t386-330.html I probably should have worded that differently [IMG ./images/smilies/icon_smile.gif] [QUOTE] Nemesis wrote:All the stuff I've posted about the phase generator and operator unit stands. The latest information I provided about those areas is all correct to the best of my knowledge. [/QUOTE] Yes, I haven't gone back and read over it, but from what I remember that part is all correct. However, this stuff is pretty straight forward, and as far as I'm aware, was already correct in the MAME core. In other words, it wasn't new information. [QUOTE] Nemesis wrote:There are some significant errors in the information I posted on the envelope generator [/QUOTE] This is where I feel the problem is with this thread. Yes, I note that you'd made corrections before I'd even read it all, but its fairly difficult to find all the bits and pieces of correct info among the non correct info, which isn't really what the title of the thread states [IMG ./images/smilies/icon_wink.gif] It could do with cleaning up, but it'd probably be better in a new thread, because the discussion in here has still been interesting. It really has been way too long since I really looked at this stuff, and I can't think of anything specific off the top of my head. But top of my list of things to try and determine right now, if I had the hardware to do it, would be this distortion stuff. We need to find out what gets fed into the DAC, i.e. the conversion from integer to 'floating point'. I'm fairly certain this is done very cheaply, is bugged, and thats where the error comes from. To me, this is much more important than some stuff already discussed in this thread. It affects all sounds in some way, whereas a lot of the things discussed aren't even used, or in some cases, such as the interrupt lines, can't be used. Have you looked into this at all? ######## POST p7446 | Snake | 2009-01-30 | t386-330.html Sorry to quote myself but: [QUOTE] Snake wrote:Yes, that makes perfect sense. The distortion effect makes the sounds louder as well as making them sound quite different. I think this is probably the culprit here. [/QUOTE] CONFIRMED: on a Genesis 2, it sounds just like Kega. ######## POST p7448 | Nemesis | 2009-01-30 | t386-330.html [QUOTE] This is where I feel the problem is with this thread. Yes, I note that you'd made corrections before I'd even read it all, but its fairly difficult to find all the bits and pieces of correct info among the non correct info, which isn't really what the title of the thread states It could do with cleaning up, but it'd probably be better in a new thread, because the discussion in here has still been interesting. [/QUOTE] I think what I'll probably do once I'm finished testing stuff on the YM2612 is actually what someone suggested ages back, and compile everything into a "YM2612 Undocumented" article or the like. Once that's done, it can basically replace this thread as a reference for information on the YM2612. For the time being, I think it's better that I just continue to post new information in this thread as I go. [QUOTE] It really has been way too long since I really looked at this stuff, and I can't think of anything specific off the top of my head. But top of my list of things to try and determine right now, if I had the hardware to do it, would be this distortion stuff. We need to find out what gets fed into the DAC, i.e. the conversion from integer to 'floating point'. I'm fairly certain this is done very cheaply, is bugged, and thats where the error comes from. To me, this is much more important than some stuff already discussed in this thread. It affects all sounds in some way, whereas a lot of the things discussed aren't even used, or in some cases, such as the interrupt lines, can't be used. Have you looked into this at all? [/QUOTE] It's on the to-do list. I'll probably cover the LFO first, then test the DAC. The good news is, I have a studio mastery grade audio card with a 120dB signal to noise ratio, so I can obtain some very accurate samples from the hardware at extremely low volume. I don't think the distortion from the DAC itself is that bad though. I've observed a minor loss in precision, which is either due to the DAC or the accumulator, and of course there's the obvious jump between low volume and off, but I honestly think that by far the biggest factor is the external amplification/mixing circuitry that the YM2612 feeds into. ######## POST p7449 | Snake | 2009-01-30 | t386-330.html [QUOTE] Nemesis wrote:I don't think the distortion from the DAC itself is that bad though. [/QUOTE] Oh, it is... (or rather, to be clear, the DAC itself should only have minor inaccuracies - its the data that's fed INTO it thats hideously innacurate.) [QUOTE] Nemesis wrote:and of course there's the obvious jump between low volume and off [/QUOTE] Yes. But not only that, 'off' should happen way earlier than it actually does. The difference between what's supposed to happen and what actually happens is HUGE, and as I've just had confirmed, makes the difference between instruments in afterburner being heard very clearly, and not at all... ######## POST p7451 | Eke | 2009-01-30 | t386-330.html [QUOTE] Snake wrote:Yes, that makes perfect sense. The distortion effect makes the sounds louder as well as making them sound quite different. I think this is probably the culprit here. Good find, by the way, I can't believe I didn't spot that one myself. [/QUOTE] I guess I learn something new every day is there an accurate way to emulate that "distortion" and, more generally, any side effects/filtering introduced by the sound output circuitry ? ######## POST p7452 | TmEE co.(TM) | 2009-01-30 | t386-330.html What Afterburner BGM are we talking about ? I've got to do a recording... ######## POST p7455 | Snake | 2009-01-30 | t386-330.html [QUOTE] Eke wrote:is there an accurate way to emulate that "distortion" [/QUOTE] There will be, yeah, but first we need to know exactly what happens. That's what I'm trying to convince Mr. Nemesis to test next [IMG ./images/smilies/icon_wink.gif] TmEE - the track is 'super stripe'. I was hoping you'd turn up to provide a CCAM version [IMG ./images/smilies/icon_smile.gif] ######## POST p7460 | Nemesis | 2009-01-30 | t386-330.html Man, this After Burner II music goes nuts. I honestly spent 10 minutes thinking I was listening to an entirely different tune. You know what, I think I know what causes this, and the answer has already been posted in this thread by someone else. HardWareMan discovered awhile back that the output from the YM2612 is multiplexed. Based on experiments I carried out on my emulator with multiplexed output, this DOES cause an audible difference in some sounds, and I don't even want to think about what the audio output circuitry in the Mega Drive would do to that multiplexed signal. It would probably compress everything together a little, amplifying the low volume channels, and softening the high volume channels. The greater the variance, the greater the effect. It's the same kind of problem as with the PSG when it hits super-high frequencies. Speaking of the PSG, I've noticed previously that After Burner II runs every channel of the PSG at maximum frequency, around half volume constantly. This PSG signal is also getting mixed with the YM2612 output, and it's possible that the PSG is introducing some destructive interference, cancelling out some of the output from the YM2612. I've just run some tests on this After Burner II track in my emulator using experimental multiplexed output. I generated wave logs for both combined and multiplexed outputs at their native bitrate, and ran them through Adobe Audition (to take advantage of their groovy output resampling), and there's no doubt that the multiplexed output not only sounds very different to the combined output, but it also sounds much closer to the real hardware. I've got a feeling that the only way to get this "output distortion" to sound right all the time is to generate a true multiplexed output for the YM2612, correctly generate the full high frequency output from the PSG, faithfully emulate the mixing hardware in the Mega Drive to mix and distort the output, and use some sort of killer resampling algorithm to step down from the super high frequency output we've just generated (over 220KHz for the PSG, and over 310KHz for the multiplexed YM2612) to something the average computer can actually output (around 48Khz), without altering the tone. Ouch. ######## POST p7463 | TmEE co.(TM) | 2009-01-30 | t386-330.html The answer to your problem is in accuracy, current emulators are doing the sound too accurately compared to real HW... the After Burner uses very attenuated FM to get it around same levels to PSG which is used for samples so that FM would not overpower PSG... however, YM2612 is not having too great resolution output, and quiet sounds are quite hard to hear as they're very aliased (especially on real YM2612, MD2 ASIC is a bit more accurate). The sounds you hear in emulators are present on real HW, but they're quite aliased and are hard to notice in the sea of aliasing noise. When you mess with 8-bit WAVs, you always try to record in highest possible volume so you would hear less of the aliasing noise. Here's the recording (a shitty medley with all tunes) : http://www.fileden.com/files/2008/4/21/ ... TRBRN2.ogg And 22KHz WAV sounds better on MD than on anything else [IMG ./images/smilies/icon_razz.gif] http://www.fileden.com/files/2008/4/21/ ... KOZMOZ.RAR (to get original WAV, rip it off the BIN, I've clearly marked the point) ######## POST p7467 | GManiac | 2009-01-30 | t386-330.html Why are you both talking about PSG and that PSG at high volume muffles/damps YM2612 or cancelling some of YM2612's output? I said that in 2nd test I CUT OUT all writings to PSG and tones 1, 2 from VGM file and played this VGM on hardware and you can see that emulator still playing the same as with all tones and PSG. ...Hmmm, I listened to "Super Stripe" from CCAM'ed MD2 and... I don't like it [IMG ./images/smilies/icon_sad.gif] But, though those instruments play quietly, right as in emulator, they still sound closer to my MD2, not to emulator (you say they are "distorted"). Okay, here's my vgm: http://shedevr.org.ru/ghost/SS_PSG.7z Don't pay attention to incorrect loop offset, I'm too lazy to correct it. Also, in this huge recording of After Burner tunes there are strange clicks in "Final Take Off" tune (seconds 28-40). It's wrong of course. Though in this topic someone named various chipsets and YM2612 variations, it seems that there's no any etalon [IMG ./images/smilies/icon_sad.gif] In one cases one console sounds better, in other it sounds worse. It seems, the only way is to allow to choose chipset and other factors in emulator, but user still WILL HAVE to choose the best factors. TmEE, can you desribe in detail what model did you use? I used Asian PAL MD2 (Chinese clone) MK 1631-07 and European MD1 PAL 1600-05 and they sound identical (MD2 sounds a bit clearer). upd: to make sure that I provided right playing of tune (with loud "instruments") you can listen to other versions of After Burner (NES, 32X and others) - they are loud there too. ######## POST p7470 | Snake | 2009-01-30 | t386-330.html [QUOTE] Nemesis wrote:You know what, I think I know what causes this, and the answer has already been posted in this thread by someone else. HardWareMan discovered awhile back that the output from the YM2612 is multiplexed. [/QUOTE] Yeah, thats one of those things thats completely incorrect. What do you think the accumulator does? I thought you'd covered this already. It's the DAC distortion, I'm telling you. This stuff is exactly in the range where the distortion is most noticable. But if that's not convincing, there's nothing else that explains why this does not happen on an MD2. [QUOTE] TmEE wrote:however, YM2612 is not having too great resolution output [/QUOTE] Well, this is the point. It does - or - it's supposed to. The DAC is designed to lose accuracy at higher volumes and retain it at lower volumes. But I'm convinced there's a bug there that causes it to lose accuracy all the time, under the right conditions. This bug is probably fixed in the later models so all you are left with is the fairly minor distortion caused by the fact it does this at all. [QUOTE] GManiac wrote:you can listen to other versions of After Burner (NES, 32X and others) - they are loud there too. [/QUOTE] Indeed, I don't think anybody is saying that the tune isn't supposed to sound like the file you posted. It definitely should, and when you pointed this out, I noticed you were correct right away. I listened to this stuff for hours with headphones back when it was released [IMG ./images/smilies/icon_smile.gif] But, It, like most other Genesis/MD music, was created on an MD1. The official MD2 does not have the same level of distortion, so it will sound very different, which you can now hear for yourself. I guess your clone is closer to a real MD1. [QUOTE] GManiac wrote:I don't like it [/QUOTE] No, me neither [IMG ./images/smilies/icon_wink.gif] [QUOTE] GManiac wrote:In one cases one console sounds better, in other it sounds worse [/QUOTE] I wouldn't worry about it. How it sounds on an original MD1 is how its supposed to sound, and this is going to be true for everything. That's the one to focus on. ######## POST p7480 | Nemesis | 2009-01-31 | t386-330.html [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:You know what, I think I know what causes this, and the answer has already been posted in this thread by someone else. HardWareMan discovered awhile back that the output from the YM2612 is multiplexed. [/QUOTE] Yeah, thats one of those things thats completely incorrect. What do you think the accumulator does? I thought you'd covered this already. [/QUOTE] Sorry, but the output from the YM2612 is definitely multiplexed. The accumulator combines the output from operators, it does not combine the output from channels. The output from the YM2612 is multiplexed. Hook up an oscilloscope to the output and you can see it. I can also see it (although not enough to get a complete sample of each individual channel) when I record at 192KHz. [QUOTE] It's the DAC distortion, I'm telling you. This stuff is exactly in the range where the distortion is most noticable. But if that's not convincing, there's nothing else that explains why this does not happen on an MD2. [/QUOTE] Maybe you're right. I will run tests on the DAC. There are other things I want to test first however. It makes sence to figure out things "higher up the chain" first. The DAC is also crossing into the analog domain, so it's going to be much harder to obtain precise results. ######## POST p7484 | AamirM | 2009-01-31 | t386-345.html Another thing to test would be the Spiderman intro sound I've been bugging everyone about for a while [IMG ./images/smilies/icon_smile.gif] . I don't know if its a problem with the envelope generator or whether Genesis does something special when output reaches a certain level. I found a fix for it using a hack by messing with the TL writes (if I add a certain fixed value, 0xF, to TL of the operators). It makes it sound like the recording by TmEE/Kega. Steve, would you take a look? plz plz plz ######## POST p7486 | Huge | 2009-01-31 | t386-345.html [QUOTE] AamirM wrote:Another thing to test would be the Spiderman intro sound I've been bugging everyone about for a while [IMG ./images/smilies/icon_smile.gif] . I don't know if its a problem with the envelope generator or whether Genesis does something special when output reaches a certain level. I found a fix for it using a hack by messing with the TL writes (if I add a certain fixed value, 0xF, to TL of the operators). It makes it sound like the recording by TmEE/Kega. Steve, would you take a look? plz plz plz [/QUOTE] Which Spiderman, the Animated Series one? I thought it just uses the channel 3 glitch, like Comix Zone. ######## POST p7487 | AamirM | 2009-01-31 | t386-345.html Spiderman Separation Anxiety. There is a problem in the intro, on channel 3 and 6. ######## POST p7489 | HardWareMan | 2009-01-31 | t386-345.html [QUOTE] GManiac wrote:...Hmmm, I listened to "Super Stripe" from CCAM'ed MD2 and... I don't like it [IMG ./images/smilies/icon_sad.gif] [/QUOTE] Me too. But we can not compare the taste? My turn to share some records. http://rapidshare.com/files/192035241/AftBrn2.rar.html http://rapidshare.com/files/192021501/WavPlay.rar.html Record takes from unmodded MD1 (YM2612+SEGA 315-5313, board IC BD M5 PAL VA4) in 60Hz mode. [IMG http://img216.imageshack.us/img216/1151/dscn2670bk6.th.jpg] As the saying goes - feel the difference. ######## POST p7490 | Nemesis | 2009-01-31 | t386-345.html [QUOTE] AamirM wrote:Spiderman Separation Anxiety. There is a problem in the intro, on channel 3 and 6. [/QUOTE] Ahh yes, I think I know the instruments you're talking about. I looked into that a bit. Little known fact: Even when the LFO is disabled, amplitude (and frequency?) modulation are still applied, but the LFO waveform itself is locked. In the problem track on Spiderman, the instruments on channels 3 and 6 have AM sensitivity set to max, with amplitude modulation enabled on all operators. Whatever value the LFO is frozen at, it applies a large amount of attenuation to the instrument, making it much softer. Phase modulation may also be affecting the pitch. I haven't done full tests on this behaviour, as I haven't started work on the LFO yet. ######## POST p7492 | Nemesis | 2009-01-31 | t386-345.html [QUOTE] Record takes from unmodded MD1 (YM2612+SEGA 315-5313, board IC BD M5 PAL VA4) in 60Hz mode. [/QUOTE] Ahh, that's more like it. [IMG ./images/smilies/icon_smile.gif] That's the exact model I do most of my testing on. ######## POST p7493 | HardWareMan | 2009-01-31 | t386-345.html [QUOTE] Nemesis wrote: [QUOTE] Record takes from unmodded MD1 (YM2612+SEGA 315-5313, board IC BD M5 PAL VA4) in 60Hz mode. [/QUOTE] Ahh, that's more like it. [IMG ./images/smilies/icon_smile.gif] That's the exact model I do most of my testing on. [/QUOTE] Cool! That mean we have same result in audio because we have same analog part. I can do more audio tests if anybody need this. [IMG ./images/smilies/icon_wink.gif] After Burner 2 used PSG as DAC sets highest possible frequency and controls it amplitude (16 levels). And this frequency can be heared in headphones. But, when I try to record it by soundcart this high frequency seems to cut-off by filter in soundcart. Or something like that. That frequency very close to channel change frequency (that was I showed at oscillograph screen). And YM2612 output mixes with PSG output before preamp, which do filtering of high frequences. So that to high frequences can affect to each other and produce many harmonic frequences, wich make sound much complex, then we can imagine. ######## POST p7494 | TmEE co.(TM) | 2009-01-31 | t386-345.html [QUOTE] GManiac wrote:Why are you both talking about PSG and that PSG at high volume muffles/damps YM2612 or cancelling some of YM2612's output? I said that in 2nd test I CUT OUT all writings to PSG and tones 1, 2 from VGM file and played this VGM on hardware and you can see that emulator still playing the same as with all tones and PSG. [/QUOTE] PSG is not causing any distortions, its that PSG is used to play samples, and the result is failrly silent... now FM has to be made silent aswell so you could actually hear the samples from PSG... BUT not having too high accuracy, things become quite aliased at lower volume levels. I can disable PSG from my MD2 (by disconneting PSG input from the audio mod) and things will be exactly like they are, just without samples... [QUOTE] TmEE, can you desribe in detail what model did you use? I used Asian PAL MD2 (Chinese clone) MK 1631-07 and European MD1 PAL 1600-05 and they sound identical (MD2 sounds a bit clearer). [/QUOTE] Its an European MD2 model MK-1631-50 with IC BD VA1 PAL board, and 315-5660-02 system ASIC. http://www.fileden.com/files/2008/4/21/1876835/5E6A.jpg http://www.hot.ee/tmeeco/MYSMD2.JPG [QUOTE] HardWareMan wrote:Me too. But we can not compare the taste? My turn to share some records. http://rapidshare.com/files/192035241/AftBrn2.rar.html http://rapidshare.com/files/192021501/WavPlay.rar.html Record takes from unmodded MD1 (YM2612+SEGA 315-5313, board IC BD M5 PAL VA4) in 60Hz mode. As the saying goes - feel the difference. [/QUOTE] I also have exact same model MD1 that HardWareMan has, but without some of the mods he has in his MD1 [IMG ./images/smilies/icon_wink.gif] Your recordings sound quite bright, my anything from my MD1 sounds much darker (more filtered)... Maybe my very long cables have something to do with it (6 meter shielded cable...) ######## POST p7496 | HardWareMan | 2009-01-31 | t386-345.html [QUOTE] TmEE co.(TM) wrote:I also have exact same model MD1 that HardWareMan has, but without some of the mods he has in his MD1 [IMG ./images/smilies/icon_wink.gif] [/QUOTE] Wich mods you mean? Adding region selector, PAL/NTSC selector and hardware pause? Nothing was change with analog audio part. [IMG ./images/smilies/icon_wink.gif] [QUOTE] TmEE co.(TM) wrote:Your recordings sound quite bright, my anything from my MD1 sounds much darker (more filtered)... [/QUOTE] Very interesting. Why so? [QUOTE] TmEE co.(TM) wrote:Maybe my very long cables have something to do with it (6 meter shielded cable...) [/QUOTE] I think capacitance of 6m qualitative cable can't spoil quality of sound. I used 10m of such cable and have no problems even in video quality. Or you used some cheap of one? ######## POST p7497 | GManiac | 2009-01-31 | t386-345.html [QUOTE] HardWareMan wrote:As the saying goes - feel the difference. [/QUOTE] [QUOTE] HardWareMan wrote:Cool! That mean we have same result in audio because we have same analog part. I can do more audio tests if anybody need this. [IMG ./images/smilies/icon_wink.gif] [/QUOTE] It's strange because I have the same MD1 as you, its date is 05 May 92 (but Chinese assembly), and yours - 20 May. But your one sounds clearer [IMG ./images/smilies/icon_eek.gif] Probably you know about this link http://arcade.ym2149.com/megadrive/index.html His MD1 is dated on 04 June 92. I recorded "Datarum" on my MD1 and it sounded just like his recording. Also someone provided recording BGM 02 from SoR2 and the result was the same. Here are comparisons: http://shedevr.org.ru/ghost/Datarum_Super_Stripe.rar HardWareMan, can you provide the whole recording or only these seconds from Datarum recording: part 1: from nearly 19.58 to 29.36 (length = 9.78) part 2: from nearly 4:38.67 to 4:41.13 (length = 2.46) Differences between models are most noticeable on this sections. [QUOTE] TmEE co.(TM) wrote:I can disable PSG from my MD2 (by disconneting PSG input from the audio mod) and things will be exactly like they are, just without samples... [/QUOTE] Do you mean those things will sound loudly or not? I think there's no necessity to disable PSG, you could playback my VGM on console (link is in previous post). [QUOTE] TmEE co.(TM) wrote:Your recordings sound quite bright, my anything from my MD1 sounds much darker (more filtered)... [/QUOTE] I said the same [IMG ./images/smilies/icon_razz.gif] and problem is not in cable. Maybe he is concealing something? [IMG ./images/smilies/icon_wink.gif] ######## POST p7498 | HardWareMan | 2009-01-31 | t386-345.html [QUOTE] GManiac wrote: [QUOTE] HardWareMan wrote:As the saying goes - feel the difference. [/QUOTE] [QUOTE] HardWareMan wrote:Cool! That mean we have same result in audio because we have same analog part. I can do more audio tests if anybody need this. [IMG ./images/smilies/icon_wink.gif] [/QUOTE] It's strange because I have the same MD1 as you, its date is 05 May 92 (but Chinese assembly), and yours - 20 May. But your one sounds clearer [IMG ./images/smilies/icon_eek.gif] Probably you know about this link http://arcade.ym2149.com/megadrive/index.html His MD1 is dated on 04 June 92. I recorded "Datarum" on my MD1 and it sounded just like his recording. Also someone provided recording BGM 02 from SoR2 and the result was the same. Here are comparisons: http://shedevr.org.ru/ghost/Datarum_Super_Stripe.rar HardWareMan, can you provide the whole recording or only these seconds from Datarum recording: part 1: from nearly 19.58 to 29.36 (length = 9.78) part 2: from nearly 4:38.67 to 4:41.13 (length = 2.46) Differences between models are most noticeable on this sections. [/QUOTE] Done. There no problem do it with my "Super 3in1 Trax" PD ROM . [IMG ./images/smilies/icon_wink.gif] http://rapidshare.com/files/192104633/Datarum.rar While recording Datarum noticed an interesting feature: record sounds different from the direct signal. Such a scheme: MD1 is connected to the line input, and listening to headphones with pre-amplifier connected to the output of a sound card. Sound card is Creative Audigy model SB0090. I try to record at 44kHz and at 48kHz - no difference, but still different than direct signal. And matter is not in the frequency range, the upper of which cut-off at ADC sampling. There is something else... The truth is out there (C) Cris Carter [IMG ./images/smilies/icon_wink.gif] ######## POST p7499 | TmEE co.(TM) | 2009-01-31 | t386-345.html My MD1 is 08 May 1992... I'll do some recordings and provide a pic or two... ######## POST p7500 | GManiac | 2009-01-31 | t386-345.html [QUOTE] HardWareMan wrote: Done. There no problem do it with my "Super 3in1 Trax" PD ROM . [IMG ./images/smilies/icon_wink.gif] http://rapidshare.com/files/192104633/Datarum.rar [/QUOTE] It's awesome! [IMG ./images/smilies/icon_eek.gif] Your playback is the best, it's better than CCAMed MD2's and still doesn't sound too sharply or poignantly. Maybe I have bad specimen of MD1? I intend to purchase first Japanese model and I hope it'll be as good as yours. [QUOTE] HardWareMan wrote:Sound card is Creative Audigy model SB0090. I try to record at 44kHz and at 48kHz - no difference, but still different than direct signal. [/QUOTE] As Nemesis said, he notices something on oscillogram at 192 kHz rate. It seems the best option is to use sound card with 384 kHz ADC, but it's very high grade of sound cards. Also when I recorded James Bond tracks at 96 kHz, I noticed some strange lines on spectrogram. Later I'll show them. ######## POST p7501 | TmEE co.(TM) | 2009-01-31 | t386-345.html My Yamaha YMF71x type card could do 500KHz 16bit stereo (or perhaps 1MHz 16bit mono) sampling according to datasheet where its said that the DAC and ADC can handle 2MBytes of data per second... Windows(95) drivers don't allow me to use rates above 64KHz... And the Datarum recording of HWM does not sound as bright as the recordings of the AfterBurner songs.... ######## POST p7502 | HardWareMan | 2009-01-31 | t386-345.html [QUOTE] GManiac wrote: [QUOTE] HardWareMan wrote: Done. There no problem do it with my "Super 3in1 Trax" PD ROM . [IMG ./images/smilies/icon_wink.gif] http://rapidshare.com/files/192104633/Datarum.rar [/QUOTE] It's awesome! [IMG ./images/smilies/icon_eek.gif] Your playback is the best, it's better than CCAMed MD2's and still doesn't sound too sharply or poignantly. Maybe I have bad specimen of MD1? I intend to purchase first Japanese model and I hope it'll be as good as yours. [/QUOTE] Everything can be corrected. If your MD have same sound chips, then there can be preamp filtering error. Some of passive elements may have allowed more than +-20%. And for amplifier frequency loopback it is enough to cut-off something more, than need. [QUOTE] GManiac wrote: [QUOTE] HardWareMan wrote:Sound card is Creative Audigy model SB0090. I try to record at 44kHz and at 48kHz - no difference, but still different than direct signal. [/QUOTE] As Nemesis said, he notices something on oscillogram at 192 kHz rate. It seems the best option is to use sound card with 384 kHz ADC, but it's very high grade of sound cards. Also when I recorded James Bond tracks at 96 kHz, I noticed some strange lines on spectrogram. Later I'll show them. [/QUOTE] Well, I always said that. Even at that dead russian forum "emu-russia", remember that? ######## POST p7503 | TmEE co.(TM) | 2009-01-31 | t386-360.html http://www.fileden.com/files/2008/4/21/1876835/MD11.jpg http://www.fileden.com/files/2008/4/21/1876835/MD12.jpg My MD1... socketed YM2612 and 2 jumpers for region are all what's done... ######## POST p7504 | HardWareMan | 2009-01-31 | t386-360.html [QUOTE] TmEE co.(TM) wrote:http://www.fileden.com/files/2008/4/21/1876835/MD11.jpg http://www.fileden.com/files/2008/4/21/1876835/MD12.jpg My MD1... socketed YM2612 and 2 jumpers for region are all what's done... [/QUOTE] LED wire hinders see wich "VA" your board. Is it "VA4" as mine? ######## POST p7505 | TmEE co.(TM) | 2009-01-31 | t386-360.html Yes, VA4, just like yours. ######## POST p7506 | Snake | 2009-01-31 | t386-360.html [QUOTE] Nemesis wrote:The accumulator combines the output from operators, it does not combine the output from channels. [/QUOTE] That doesn't even make sense. ######## POST p7509 | Chilly Willy | 2009-01-31 | t386-360.html [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:The accumulator combines the output from operators, it does not combine the output from channels. [/QUOTE] That doesn't even make sense. [/QUOTE] If I remember the discussion right, there are six channels with four operators each. Instead of summing all twenty four operators and outputting the result as one value, instead the four operators for each channel are summed and output as one value during one of eight time slots - one time slot for each channel plus one slot for DAC and one for ? didn't catch the last one. Putting out six distinct analog values at different times is NOT going to sound the same as adding six values together and presenting it once. ######## POST p7511 | Snake | 2009-02-01 | t386-360.html [QUOTE] Chilly Willy wrote: [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:The accumulator combines the output from operators, it does not combine the output from channels. [/QUOTE] That doesn't even make sense. [/QUOTE] If I remember the discussion right, there are six channels with four operators each. Instead of summing all twenty four operators and outputting the result as one value, instead the four operators for each channel are summed and output as one value during one of eight time slots - one time slot for each channel plus one slot for DAC and one for ? didn't catch the last one. Putting out six distinct analog values at different times is NOT going to sound the same as adding six values together and presenting it once. [/QUOTE] For gods sake. No. Operators have inputs. They take care of this stuff. If they didn't, there would BE no 'FM'. It. Does. Not. Make. Sense. The 6 outputs go to the accumulator and then to the DAC. Other chips in the YM range don't have an internal DAC. The data that goes out to the DAC has been intercepted and interpreted by others many times. This is already well documented and I can't believe I'm even wasting my time discussing it. In fact, I'm going to stop now. ######## POST p7512 | Nemesis | 2009-02-01 | t386-360.html [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:The accumulator combines the output from operators, it does not combine the output from channels. [/QUOTE] That doesn't even make sense. [/QUOTE] [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/operators.png] Algorithms 0, 1, 2, and 3 have 1 carrier. Algorithm 4 has 2. Algorithms 5 and 6 have 3. Algorithm 7 has 4. The accumulator sums the output from all these carriers within a channel, and presents each channel as a single output to the DAC. It also handles the DAC signal for channel 6, and the left/right channel outputs. The accumulator has the job of taking a possible 24 carrier outputs from the operator unit (when each channel is running in algorithm 7), and presenting it to the DAC as 12 distinct output streams, 6 going to the left speaker, and 6 going to the right speaker. Both speaker outputs use multiplexing to interleave the 6 operator output streams directed at that speaker. Sure, the accumulator could have summed each channel and presented it to the DAC as two combined output streams, one to the left speaker, and one to the right speaker. Why didn't they? Maybe they figured they get a better effective output bitrate this way. The audible output sounds pretty much the same, and they didn't have to lose precision by combining the 6 channels into 1 while the output was still in digital form, which would have cut the effective bitrate of each channel. Maybe this was just easier. Hell, I don't know. All I can tell you is, it's obvious the output stream is multiplexed when you hook up any equipment which can sample fast enough to notice it. Anything that's sampling at around 96KHz or less is just going to be combining all those outputs into one during the capture process, so it'll just look like a continuous, combined signal. Your ears are doing the same. My oscilloscope isn't lying though. It's digital, I can post some screenshots if you'd like. ######## POST p7514 | Snake | 2009-02-01 | t386-360.html Ok, one last time. [QUOTE] Nemesis wrote:The accumulator has the job of taking a possible 24 carrier outputs from the operator unit (when each channel is running in algorithm 7), and presenting it to the DAC as 12 distinct output streams, 6 going to the left speaker, and 6 going to the right speaker. [/QUOTE] This isn't the job of the accumulator. Do you have any idea what speed the DAC would have to operate at if if was receiving 12 seperate streams? Remember this thing is SERIAL. Doing things this way makes zero sense at all when an adder is one of the simplest things to implement. [QUOTE] Nemesis wrote:All I can tell you is, it's obvious the output stream is multiplexed when you hook up any equipment which can sample fast enough to notice it. [/QUOTE] Why, because you can see gaps between samples? Yeah, that's how a DAC works. You're looking at multiple samples, not multiple channels. The MAME team discovered, and documented, a very long time ago, that a YM2610 divides the output by two after adding all channels together, because the addition of the extra ADPCM channels would have caused clipping otherwise. They did this by examining the output to the DAC, not by just sampling the output. ######## POST p7515 | Nemesis | 2009-02-01 | t386-360.html *facepalm* http://nemesis.hacking-cult.org/MegaDri ... lexing.asm http://nemesis.hacking-cult.org/MegaDri ... lexing.bin [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/multiplexing.png] Do the test yourself. I'm not going to argue this point any longer. ######## POST p7516 | Nemesis | 2009-02-01 | t386-360.html Ehh, for posterity, I'm going to elaborate anyway. The test I just posted uses a single operator from each channel. The phase generator is frozen, with the phase generator outputting a maximum positive value each cycle. The envelope generator for the selected operator in each channel is locked in an infinite decay phase, at an effective internal attenuation value of 0. A different TL value is used for the selected operator in each channel. The overall effect of this is that each channel has a constant output. The attenuation level that each channel sits at is controlled by TL. The screenshot I posted shows the output from the YM2612, sampled directly from the chip with an oscilloscope. If all the channels were summed, and the gaps were gaps between successive samples, every sample would be the same value. As you can see, the levels between each successive sample differ, with each sample clearly representing a different channel with a different attenuation value, as set by TL. Here's another screenshot I've just taken: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/multiplexing2.png] This one shows both the left and right channels, and this time, I've used unique values for TL in each channel, moving from 0x0 to 0xA with a step of 2 from channel 1 to channel 6. Channel 1 is the one mostly visible on the lefthand side. You can see how the channels are actually output out of order. The apparent output order is 1,5,3,2,6,4. Also, according to this, the left and right output streams are actually output at the same time, which I find a little surprising. In terms of the frequency the DAC would have to run at, if we assume the YM2612 does use an embedded YM3016, if it was only doing a single channel, the YM3016 would need to be running at a minimum clock rate of around 5.07MHz, which is above its reported maximum clock input of 5MHz. This does suggest the YM2612 may be using a different DAC. It's also possible it uses two DAC's, one for the left channel, and one for the right channel, and controls them both in parallel. At any rate, it does appear that the YM2612 does its DAC conversion quite differently than the known OPN chips that have an external DAC, like the YM2608. ######## POST p7518 | HardWareMan | 2009-02-01 | t386-360.html Whoa... Channel order is not "123456"? As for multiplexing output, I had already say: 6 timeslots per one channel (left and right). That's is why DAC function replace one of channel (number 6). Nemesis, please make measurement of time (frequency) between start of every timeslot and time of width of one timeslot. ######## POST p7519 | Snake | 2009-02-01 | t386-360.html ARGH pictures too big, lots of scrolling... Ok, your pictures are interesting. I did do similar tests many years ago, using equipment owned by a guy I worked with. I didn't see the same results. Maybe his equipment wasn't good enough. Maybe this was changed in later chips. I don't know now. Still... The operators/channels take care of themselves. The function of the accumulator is, absolutely, to sum the channels. If it's not doing that it actually suggests they REMOVED the accumulator. They did exactly this (and it's documented) in some simpler chips, but the YM2612 sounds much cleaner. [QUOTE] Nemesis wrote:the left and right output streams are actually output at the same time, which I find a little surprising. [/QUOTE] They will be, it's a stereo DAC. [QUOTE] Nemesis wrote:In terms of the frequency the DAC would have to run at, if we assume the YM2612 does use an embedded YM3016, if it was only doing a single channel, the YM3016 would need to be running at a minimum clock rate of around 5.07MHz [/QUOTE] I make it 5.11MHz (and twice that if, as you originally suggested, it did 12 passes) - but it's probably more than that because the chip requires some time to do the actual conversion and settle. [QUOTE] Nemesis wrote:This does suggest the YM2612 may be using a different DAC. [/QUOTE] Yes, I mentioned this before. I knew it was a different DAC, but it seems very odd that they would put a faster DAC in there instead of an accumulator. In any case, I still say this isn't the reason for the distortion we are hearing. Just as well, because any way you try to downsample that it's just going to sound pretty much the same as if they were mixed. Only playing it at the same frequency is going to sound the same. ######## POST p7520 | Nemesis | 2009-02-01 | t386-360.html [QUOTE] Whoa... Channel order is not "123456"? As for multiplexing output, I had already say: 6 timeslots per one channel (left and right). That's is why DAC function replace one of channel (number 6). Nemesis, please make measurement of time (frequency) between start of every timeslot and time of width of one timeslot. [/QUOTE] I can go one better than that: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/multiplexing3.png] This is the analog output from the YM2612 next to the master clock (7.61MHz or there abouts). As you can see, there are 24 master clock cycles between each timeslot. The silence gap is most likely at the start of the timeslot, and represents the period in which the accumulator is sending the serial data stream to the DAC. Looking at the bus communication diagram in the YM3016 datasheet, with 16 bits of data to stream, that's 16 cycles used for the data transfer, plus an extra 2 cycles, one before the start of the stream, and one after the end of the stream, for the data latch input, plus an extra 1 cycle before the final latch input, where the SMP1/2 lines are negated. That gives 19 cycles for the serial communication, which is the observed gap of silence between each output, leaving only 5 cycles for the output to remain asserted across a full clock cycle, which is exactly what we see on the image above. Tying this back into the clock rates used in the YM2612, the DAC has one timeslot per channel, or 7610000/6/4=317083, where 6 is the fm prescaler, and 4 is the number of operators per channel. The actual DAC runs at the full input clock rate. Oh, and based on the datasheet for the YM3016, it looks like both channels can be programmed at once on that device (IE, the DAC can latch a single output stream and send it to both channels), and seeing as the communication between the accumulator and the DAC seems to match the communication pattern of the YM3016, it seems the embedded DAC is most likely a YM3016 derivitive. Since this embedded DAC is obviously running at 7.61MHz however, it must support a higher clock input. The YM3016 was only rated for a max of 6MHz (not 5MHz like I said earlier, that was the YM3015. Perhaps this would make the DAC model a YM3018?). EDIT: Some googling seems to confirm that the YM3018 does exist, but there seems to be absolutely no information on it. ######## POST p7521 | Snake | 2009-02-01 | t386-360.html [QUOTE] Nemesis wrote:it seems the embedded DAC is most likely a YM3016 derivitive. [/QUOTE] Well, as I mentioned before, I read somewhere (fucking wish I could remember where) that it's only 9 bit. That would seem to make more sense now, wouldn't it? No point in putting a full 16-bit capable DAC in there if it's not going to get used. That channel order is fucking strange, though. ######## POST p7522 | HardWareMan | 2009-02-01 | t386-360.html Whoa! This is a very accurate data. So, one timeslot takes 24 of VCLK. So, all 6 channel takes VCLK/24/6. In case of VCLK=7.61MHz it will be 7600KHz/24/6=52kHz... Mmmm... That is more than twice faster, than I thought... ######## POST p7523 | Nemesis | 2009-02-01 | t386-375.html [QUOTE] Well, as I mentioned before, I read somewhere (fucking wish I could remember where) that it's only 9 bit. That would seem to make more sense now, wouldn't it? No point in putting anything better in there if it's not going to get used. [/QUOTE] Anything's possible. I must admit, I thought the YM2612 wasn't doing too much differently in terms of the DAC, despite the fact this one is embedded. Guess I was wrong. Different precision on the input is certainly possible. The circuitry of the DAC itself could also be very different, and there could well be errors in it as you suspect, or they might have taken some shortcuts to reduce complexity or power requirements. It's a fair bet this DAC was built, or at the very least customized, for the YM2612. [QUOTE] That channel order is fucking strange, though. [/QUOTE] Yeah, I don't get that either. ######## POST p7524 | Snake | 2009-02-01 | t386-375.html It might be interesting to try this on an MD2 and see if theres any differences. Not that it probably makes much difference in emulation, but still... ######## POST p7525 | Nemesis | 2009-02-01 | t386-375.html I haven't modded a MD2 to sample direct from the YM2612 output. Let me grab one off the stack and see what I can rig up. ######## POST p7526 | Snake | 2009-02-01 | t386-375.html Oh, and incase it's of interest - the YM2413 is the chip that has no accumulator... and also an embedded 9 bit DAC. Isn't that interesting. [QUOTE] Nemesis wrote:Let me grab one off the stack [/QUOTE] Heh, how many have you got? ######## POST p7527 | Nemesis | 2009-02-01 | t386-375.html [QUOTE] Snake wrote:Oh, and incase it's of interest - the YM2413 is the chip that has no accumulator... and also an embedded 9 bit DAC. Isn't that interesting. [/QUOTE] Hmm, maybe I can get my hands on one a run some tests on that. Comparing the two might help answer some questions. Hell, maybe I can put one in the Mega Drive in place of the YM2612. [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:Let me grab one off the stack [/QUOTE] Heh, how many have you got? [/QUOTE] I honestly don't know. It seems like every time I move something or look in a box I haven't opened in awhile, I find another one hiding. O_o I bought too much Mega Drive stuff on ebay. ######## POST p7528 | Snake | 2009-02-01 | t386-375.html [QUOTE] Nemesis wrote:Hmm, maybe I can get my hands on one a run some tests on that. Comparing the two might help answer some questions. Hell, maybe I can put one in the Mega Drive in place of the YM2612. [/QUOTE] Doubtful, the chip is very different. But it's the chip used in the Japanese SMS. Go on, now tell me you've already got one [IMG ./images/smilies/icon_wink.gif] Just done some googling and found: [QUOTE] - OPLL: Budget version of the OPL2. It's quite cut down, and can only have 1 fm patch at the same time - the other sounds must come from a ROM that has 15 different FM sounds. Also lacks an accumulator (channels are summed together with an analog filter instead). [/QUOTE] from http://www.soundshock.se/phpBB2/viewtop ... f8d5c#2280 OPLL=YM2413. ######## POST p7529 | TmEE co.(TM) | 2009-02-01 | t386-375.html YM2413 will not start working in place of YM2612 unless you make code exactly for the YM2413... the pinout is very different aswell. I'm looking forward to seeing some more info about MD2 sound [IMG ./images/smilies/icon_smile.gif] And by judging from aliasing noise, things do sound like the DAC is 9 or 10 bits... ######## POST p7530 | Snake | 2009-02-01 | t386-375.html While we're waiting for Nemesis to do the tests, thought I'd post my thoughts on the distortion. If you've ever looked at the waves produced, it seems as though one side performs exactly as it should, and hits silence when it should. But the other side doesn't, producing a non-sinewave. it takes much longer to get to zero, and it distorts on the way there. It's been a long time since I've done any tests on this at all (5 years probably), but I've been thinking about it a fair bit recently. I *think* it's the negative side that has the problem (I'm sure somebody here can confirm), and if so, it would seem to indicate the chip handles negative samples incorrectly, OR that the values are scaled before hitting the DAC, and there is a problem with scaling negative values. The standard yamaha DACs, as far as I remember, don't use 2s compliment, but I'm pretty sure the operators do, so theres another possible conversion that could go wrong. It's also possible it's just a problem with the DAC itself, but that doesn't seem as likely, because the error is actually quite a large one. With a decent scope and a bit of time, it should be possible to figure out exactly what's going on here. I have neither anymore, nor the capacity to run test code anymore, or I'd have done it already [IMG ./images/smilies/icon_wink.gif] ######## POST p7531 | HardWareMan | 2009-02-01 | t386-375.html Snake, you talking about "ladder" effect? Wich present in every channel separatly. ######## POST p7532 | Snake | 2009-02-01 | t386-375.html Yes, indeed, the effect you refer to as the "ladder effect". It's more than that, though, if you look at samples. ######## POST p7537 | Nemesis | 2009-02-01 | t386-375.html Ok, now that the final between Federer and Nadal is over (dammit!), here's some readings from an MD2, board PC BD MD2 VA1.8 PAL, with an embedded YM2612 in the 315-5660: [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/multiplexingmd2-1.png] [IMG http://nemesis.hacking-cult.org/MegaDrive/Documentation/multiplexingmd2-2.png] Very different to the MD1 with the "real" YM2612. The output is still multiplexed, and the strange channel order from the output is the same, but that's about it. Clearly this is a totally different DAC. ######## POST p7538 | HardWareMan | 2009-02-01 | t386-375.html Whoa... For complete picture, you should post recording from YM2612 clones: TA-07 and PCS-95. Mmm... Square waveform consist from many harmonic frequences. To infinite high frequences. So, result output can be more complex, specially at high frequences. But saw waveform consist much less of high frequences, than square frequences. So, result output can be much clearer from harmonic frequences. ######## POST p7541 | AamirM | 2009-02-01 | t386-375.html [QUOTE] Nemesis wrote: [QUOTE] AamirM wrote:Spiderman Separation Anxiety. There is a problem in the intro, on channel 3 and 6. [/QUOTE] Ahh yes, I think I know the instruments you're talking about. I looked into that a bit. Little known fact: Even when the LFO is disabled, amplitude (and frequency?) modulation are still applied, but the LFO waveform itself is locked. In the problem track on Spiderman, the instruments on channels 3 and 6 have AM sensitivity set to max, with amplitude modulation enabled on all operators. Whatever value the LFO is frozen at, it applies a large amount of attenuation to the instrument, making it much softer. Phase modulation may also be affecting the pitch. I haven't done full tests on this behaviour, as I haven't started work on the LFO yet. [/QUOTE] Yeah, that seems to be it. Shame on me for not noticing it myself. [IMG ./images/smilies/icon_redface.gif] Btw, I would like to thank you again for all your work. [IMG ./images/smilies/icon_wink.gif] ######## POST p7548 | Snake | 2009-02-01 | t386-375.html I had a feeling this would look very different. From the pics it seems the MD2 DAC takes a lot longer to do the conversion, but isn't serial, which allows it the time it needs. The original YM2612 probably uses the exact same DAC as the YM2413. Thinking about this some more, the much simpler straight 9 bit DAC and no accumulator will be much cheaper, because you can get away with a mono DAC. The left/right output will always be identical, so you can simply route the mono output to left/right or both. ######## POST p7551 | Shiru | 2009-02-02 | t386-375.html One interesting thing about YM2413: it has not single mono output, but two separate outputs for melodic and drum channels. ######## POST p7553 | Snake | 2009-02-02 | t386-390.html [QUOTE] Shiru wrote:One interesting thing about YM2413: it has not single mono output, but two separate outputs for melodic and drum channels. [/QUOTE] Indeed. There's no logical reason for that, though, the 'drum' channels, if enabled, take over some of the other channels. I think they just did this so you can choose to mix them at different volumes. What I find even stranger is that some chips have an internal DAC for their PSG-type waves, but not for the FM stuff. You'd think it would have been easier to just mix the PSG stuff with the FM stuff. ######## POST p7554 | Shiru | 2009-02-02 | t386-390.html You must learn how those built-in PSG works (AY-3-8910/YM2149), it's much harder to mix than use as-is. ######## POST p7555 | Snake | 2009-02-02 | t386-390.html [QUOTE] Shiru wrote:You must learn how those built-in PSG works (AY-3-8910/YM2149), it's much harder to mix than use as-is. [/QUOTE] Well, what I meant was, digital signal comes out of PSG, goes through DAC, and to output pin. Why not send that digital signal out the same way as the other output? Or why not use a DAC that can handle both outputs? Of course the answer is probably 'its cheaper', but then if you've got to use an external DAC anyway... ######## POST p7556 | Shiru | 2009-02-02 | t386-390.html PSG uses three separate 4-bit DAC's (5-bit in Yamaha's version), one per channel. They are apply volume or envelope to the output. To get digital output which can be mixed with FM output you'll need adders instead of those DAC's. ######## POST p7558 | Snake | 2009-02-02 | t386-390.html Well, yes, but an adder that could handle exactly that is already there. Then again, volume levelling would be an issue again. I guess it was just easier to basically throw a full YM2149 in there. [QUOTE] Shiru wrote:4-bit DAC's (5-bit in Yamaha's version) [/QUOTE] Going way off topic here, but do you have info to back that up? As far as I remember, they're both 4 bit, except the Yamaha version is actually accurate, and the AY version very much isn't [IMG ./images/smilies/icon_smile.gif] In either case I've emulated both of these and compared the outputs with original chips. [QUOTE] HardWareMan wrote:Mmm... Square waveform consist from many harmonic frequences. To infinite high frequences. So, result output can be more complex, specially at high frequences. But saw waveform consist much less of high frequences, than square frequences. So, result output can be much clearer from harmonic frequences. [/QUOTE] Well, the filtering effectively downsamples the whole thing to around 40KHz, so it *shouldn't* sound any different (the MD2 may sound a bit louder, though). The filters are far from perfect, though. ######## POST p7566 | Shiru | 2009-02-02 | t386-390.html [QUOTE] Snake wrote:Going way off topic here, but do you have info to back that up? As far as I remember, they're both 4 bit, except the Yamaha version is actually accurate, and the AY version very much isn't :) In either case I've emulated both of these and compared the outputs with original chips. [/QUOTE] Well, try to read at least first page of the YM2149F datasheet. This is officially documented fact, and is confirmed long ago by few independent enthusiasts who did measurements of the real chips, and implemented in many emulators. ######## POST p7567 | TmEE co.(TM) | 2009-02-02 | t386-390.html http://www.epicgaming.us/tiido/MD_Sine.rar Can this be any help ? There's recordings of the sine of single operator of MD2 and MD1, going from TL0 to higher values. MD1 has a shift in each half period...... ######## POST p7575 | Snake | 2009-02-02 | t386-390.html [QUOTE] Shiru wrote:Well, try to read at least first page of the YM2149F datasheet. [/QUOTE] Ah, ok, I'm probably just misremembering, then. [edit] - doh - yeah - without even looking I remember now it IS twice the resolution. I'm probably thinking of some other chips. Done way too much of this stuff [IMG ./images/smilies/icon_wink.gif] [QUOTE] TmEE co.(TM) wrote:MD1 has a shift in each half period...... [/QUOTE] That's probably relevant, yeah. What's odd is that I have some recordings from an MD1 - they were taken at final output (I was trying to measure the filter effects at the time) and they don't show this at all. Which is both odd and annoying. ######## POST p7578 | Stef | 2009-02-02 | t386-390.html [QUOTE] TmEE co.(TM) wrote:http://www.epicgaming.us/tiido/MD_Sine.rar Can this be any help ? There's recordings of the sine of single operator of MD2 and MD1, going from TL0 to higher values. MD1 has a shift in each half period...... [/QUOTE] The MD2 sin curve is really... weird ! Looks like a bad approximation of real one, the MD1 does a lot better here. ######## POST p7579 | TmEE co.(TM) | 2009-02-02 | t386-390.html it looks weird because of the low TL value... higher values show good sine... ######## POST p7581 | HardWareMan | 2009-02-03 | t386-390.html [QUOTE] TmEE co.(TM) wrote:it looks weird because of the low TL value... higher values show good sine... [/QUOTE] I don't see a good sine there. ######## POST p7582 | Jorge Nuno | 2009-02-03 | t386-390.html A FFT would show the harmonic distortion better [IMG ./images/smilies/icon_cool.gif] ######## POST p7583 | Snake | 2009-02-03 | t386-390.html One thing I did notice about the MD2 many years ago, is that when it goes from playing silence, to playing a loud tone, it seems to be overdriven for a brief period. But that may have more to do with the mixer, or may even have just been my console. But yes, I always thought the sinewave was a bit off too. ######## POST p7585 | Richter X | 2009-02-03 | t386-390.html There's something that's still bothering me. I keep playing "Good Job, Headdy" from Dynamite Headdy using TmEE's recording of it, The OST's recording of it, and foo_gep with the newest 2612 core. In foo_gep the pitch of the orchestra hit at the end has a higher pitch than it should sound. Anyone care to look into it? ######## POST p7590 | TmEE co.(TM) | 2009-02-03 | t386-390.html Fusion had a small bug which caused PCM to be played faster, and this affects all VGMs... the VGM recording I did of that tune SHOULD sound like Fusion does... I should do another recording using real game... ######## POST p7605 | AamirM | 2009-02-03 | t386-405.html Before I forget, another "test case" for your SSG-EG implementation would be the Water Diving practice mode in Barcelona Olympics. When you dive into the water, the splash sound isn't emulated correctly by any emulator. And yeah, it uses SSG-EG there. Nemesis, I think that your suspicion that SSG-EG switches between 4x and 6x multiplication is true. That would be one thing to test for sure. ######## POST p7623 | Snake | 2009-02-04 | t386-405.html [QUOTE] AamirM wrote:Nemesis, I think that your suspicion that SSG-EG switches between 4x and 6x multiplication is true. That would be one thing to test for sure. [/QUOTE] Hmm, that sounds completely illogical, unless it does so because of a bug. It's more likely it's down to one of the weird cases that Nemesis has since discovered, so he probably has the answer already. I'm surprised so many games use this at all given the complete lack of documentation on it at the time. ######## POST p7650 | AamirM | 2009-02-04 | t386-405.html [QUOTE] Hmm, that sounds completely illogical, unless it does so because of a bug. [/QUOTE] Since you said yourself that SSG-EG is strangest part of YM2612, I wouldn't be really surprised if it really switched between 4x and 6x. EDIT: I forgot to mention, when I was testing this in Regen last time, I remember that splash sound got fixed if multiplication factor was set to 4. Go figure. [QUOTE] I'm surprised so many games use this at all given the complete lack of documentation on it at the time. [/QUOTE] Me too. ######## POST p7654 | Shiru | 2009-02-04 | t386-405.html [QUOTE] Snake wrote:I'm surprised so many games use this at all given the complete lack of documentation on it at the time. [/QUOTE] Documentation isn't needed at all to make weird patches. All that needed is very simple program which allows user to change all the parameters of the patch and test it on real chip (console). So patch designer simply edit the parameters until he get interesting sound, and he is not need to understand how this actually works. ######## POST p7672 | Nemesis | 2009-02-04 | t386-405.html [QUOTE] [QUOTE] Hmm, maybe I can get my hands on one a run some tests on that. Comparing the two might help answer some questions. Hell, maybe I can put one in the Mega Drive in place of the YM2612. [/QUOTE] Doubtful, the chip is very different. But it's the chip used in the Japanese SMS. Go on, now tell me you've already got one [IMG ./images/smilies/icon_wink.gif] [/QUOTE] Not that one I'm afraid. I might try and pick one up. [QUOTE] Whoa... For complete picture, you should post recording from YM2612 clones: TA-07 and PCS-95. [/QUOTE] Hmm, I don't actually know that I have any Mega Drive systems that use a clone chip. I haven't opened all my model 1 units however. I'll hunt around and see if I can locate one. What kind of systems did they appear in? Did they appear in normal European Mega Drive units, or should I be looking at the asian systems? [QUOTE] Before I forget, another "test case" for your SSG-EG implementation would be the Water Diving practice mode in Barcelona Olympics. When you dive into the water, the splash sound isn't emulated correctly by any emulator. And yeah, it uses SSG-EG there. [/QUOTE] Yep, this sound relies heavily on SSG-EG with an attack phase. Actually, the only real tricky case that needs to be emulated here is pattern 0xF with attack. I'll be posting all the info necessary to emulate this. This sound does play correctly in my emulator. [QUOTE] Nemesis, I think that your suspicion that SSG-EG switches between 4x and 6x multiplication is true. That would be one thing to test for sure. [/QUOTE] Well the 6x figure I gave is completely wrong anyway, but what I said was, I suspect that toggling SSG-EG on or off during the release phase would immediately switch between the normal decay sequence, and the accelerated SSG-EG decay sequence, IE, the SSG-EG enable bit is checked each update cycle to determine whether the attenuation increment value is multiplied. This'll all be covered when I post my updated info. ######## POST p7673 | Nemesis | 2009-02-04 | t386-405.html I might share a little quirk I discovered a few days ago, while I was working through a list of random tests unrelated to the envelope generator. I was running a test to check whether parts 1 and 2 had a separate address register, IE, whether you could write one address to $A00000 and another to $A00002, then write to each data port, and have the two writes go to two different register addresses in each part. What I found was that not only do parts 1 and 2 not have a separate address register, they don't even have a separate data port. It turns out that writing to an address register stores both the written address, and the part number of the address register you wrote to. You can then write to either the data port at $A00001, or the data port at $A00003, and the write will go to the register number you wrote, within the part of the address register you wrote to. This means you can, for example, write an address to $A00000, then write the data to $A00003, and the data will in fact be written to the part 1 register block, not the part 2 register block. The simpler implementation would seem to be only storing the 8-bit address data that was written, and use the data port that received the write to determine which part to write to, but it isn't implemented this way. Writing to the address register stores 9 bits of data, indicating both the target register address, and the part number. I don't think any emulator does this correctly right now. ######## POST p7674 | TmEE co.(TM) | 2009-02-04 | t386-405.html This gives me some ideas [IMG ./images/smilies/icon_biggrin.gif] Great find [IMG ./images/smilies/icon_biggrin.gif] ######## POST p7680 | notaz | 2009-02-05 | t386-405.html Nice find, time to do some quick patching [IMG ./images/smilies/icon_smile.gif] ######## POST p7696 | Snake | 2009-02-06 | t386-405.html [QUOTE] Nemesis wrote:Well the 6x figure I gave is completely wrong anyway, but what I said was, I suspect that toggling SSG-EG on or off during the release phase would immediately switch between the normal decay sequence, and the accelerated SSG-EG decay sequence, IE, the SSG-EG enable bit is checked each update cycle to determine whether the attenuation increment value is multiplied. This'll all be covered when I post my updated info. [/QUOTE] Ah, that makes more sense. It's been a while but if I remember correctly, most SSG-EG register writes while keyed on completely break things. I fully intended to do more tests here, but life sucks. [QUOTE] Nemesis wrote:What I found was that not only do parts 1 and 2 not have a separate address register, they don't even have a separate data port [/QUOTE] Heh. I knew the address register thing, but I never tried the data port thing. Did you test this on MD1 and MD2? ######## POST p7704 | HardWareMan | 2009-02-07 | t386-405.html You saying about YM2612 registers (address/data potrs)? Is it should be $A04000..$A04003? ######## POST p7719 | Snake | 2009-02-08 | t386-405.html [QUOTE] HardWareMan wrote:You saying about YM2612 registers (address/data potrs)? Is it should be $A04000..$A04003? [/QUOTE] Yes, that's what he's talking about. [QUOTE] TmEE wrote:This gives me some ideas [/QUOTE] You're evil [IMG ./images/smilies/icon_twisted.gif] Seriously, though, I'm not seeing any benefits of making use of this, and I'd suggest you don't. As is probably well known, reading any of the ports will give you the YM status - but there was a 32X bulletin that warned you not to do that because it causes weird bus timing problems. In short, don't do naughty things [IMG ./images/smilies/icon_wink.gif] ######## POST p7733 | Nemesis | 2009-02-09 | t386-405.html [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:What I found was that not only do parts 1 and 2 not have a separate address register, they don't even have a separate data port [/QUOTE] Heh. I knew the address register thing, but I never tried the data port thing. Did you test this on MD1 and MD2? [/QUOTE] I have now. The behaviour is the same on both. ######## POST p7967 | Nemesis | 2009-02-22 | t386-405.html Ok, here's another batch of info. When I conducted my previous tests on the envelope generator, I had to extrapolate the output from the envelope generator based on the analog output from the chip. This severely limited the accuracy and precision of the tests I could perform. Increased understanding of the phase generator, operator unit, and the test register, now allows me to obtain pure, digital samples of the output data from the envelope generator. With this new information, I decided a complete re-test of the envelope generator was required, as several clear errors had been identified, and there was a lot more testing I still wanted to carry out which I was unable to perform with sufficient accuracy before. I've now done a thorough re-test of the envelope generator as a whole, and as a result, I've got a lot of corrections for the information I provided before, as well as bunch of new information to share. This post is going to cover details of the envelope generator, but unlike the information I posted previously, this is mainly going to be a list of corrections and additions to previous information I have provided. I am going to break it into points arbitrarily arranged and numbered, and it is going to primarily focus on what is different to my previous description of the envelope generator. Unless I specifically amend or correct a piece of information I provided in my previous description, the previous information still stands. The previous description I gave of the envelope generator is at the following location: viewtopic.php?p=5716#5716 General info: 1. Envelope Generator update clock rate I've posted this correction previously, but I'm going to mention it again briefly here. I previously stated that the envelope generator was updated according to the following clock rate: "EG Clock = External Clock / 351" Or that "The ratio of the frequency output to the envelope generator clock is 1:2.4375". This information was incorrect. In fact, the envelope generator is updated once every 3 fm update cycles, which was the existing behaviour in the MAME core. Refer to the following post for the information I previously gave on this correction: viewtopic.php?p=6224#6224 2. Envelope generator output inversion I previously stated that the envelope generator had an output inversion flag which was used by both SSG-EG mode and the attack phase. This is incorrect. SSG-EG has an output inversion flag, but it is not shared by the attack phase. The attack phase does not use output inversion, nor does any function of the envelope generator outside of SSG-EG mode. 3. Calculating the attack curve The previously given information for calculating the attack curve stated that while the attack phase was active, the output inversion bit was set, and the following formula was used to advance the attack curve: [CODE] operator.attenuation += attenuationIncrement * (((1024 - operator.attenuation) / 16) + 1) [/CODE] This is incorrect on both points. The attack phase does not use output inversion, and the provided update calculation is incorrect. The correct update formula is as follows: [CODE] newAttenuation += (~newAttenuation * attenuationIncrement) >> 4 [/CODE] This is the same as the existing update calculation used in the MAME core. 4. Restart of phase generator on key-on I forgot to mention in my original post that when key-on occurs, the internal phase counter in the phase generator is reset to 0. This of course also includes key-on events triggered by CSM mode. The phase counter is also reset in SSG-EG mode at the beginning of each repetition of the waveform in cases where both the HLD and ALT bits are unset, but the implementation is a little different than you might expect. The SSG-EG section will cover this fully. 5. When register changes are applied I didn't provide much information on this before, because I hadn't performed many tests on it before. I did state previously that the rate value for the current phase of the envelope generator was calculated and stored when entering each phase of the envelope, and that updates within each envelope phase were based on this stored value. This is incorrect. The rate value is calculated each update cycle of the envelope generator. As such, changes to the various rate parameters for an operator, as well as changes to the rate key-scale value, can cause an immediate change in the effective rate for the current phase of the ADSR envelope. Regarding other register values, changes to all other parameters for an operator or channel, including TL, Detune, Multiple, Key Scale, AMS, PMS, Left/Right, Block, Fnum, etc, also all take effect immediately. One important note however relates to SL, the sustain level. Changes to SL do take effect immediately, including during the decay phase, but note that once the decay phase of the envelope reaches SL, the transition from decay to sustain is a one-way operation. If the ADSR envelope was in the decay phase, and the attenuation level reached SL, the ADSR envelope would switch to the sustain phase. If you were to then modify SL to move it past the current attenuation level (eg, so the operator was now in the sustain phase above SL), the operator does NOT re-enter the decay phase. All emulators probably do this correctly anyway, but it was possible that the decision of whether the operator was in the decay phase or the sustain phase was made each update cycle based on the relative position of the current attenuation value to the sustain level. This is not the case. Once the transition is made from the decay phase to the sustain phase, changes to SL will not have any effect. Note that changes to the SSG-EG register also take effect immediately, but there's a lot to cover about this behaviour, which will be addressed separately in the SSG-EG section. 6. Clamping of attenuation values when changing states I posted a comment somewhere around here about the possibility of the current attenuation level being "clamped" to SL when moving from the decay phase to the sustain phase. I suspected that if, for example, SL was 0x200, and the decay phase was to cause the current attenuation value to jump from, say, 0x1FC to 0x204, the attenuation value would be clamped to 0x200, preventing the attenuation level from moving past SL during the decay phase. This is incorrect, and the premise itself is also incorrect. The sustain level can only be set in 16 increments of 0x20, from 0x0 to 0x1E0, with the special case that when it is set to max, it is forced to the maximum attenuation level (0x3FF). The decay phase always begins from an attenuation value of 0, since the attack phase does not terminate until this value is reached. Without SSG-EG mode active, the largest increment value which can be applied to the attenuation value in a single update cycle is 8. Since all the levels SL can reach are multiples of 8, without making changes to the effective rate of the decay phase during the decay sequence, the attenuation level would always finish perfectly on SL anyway, without SSG-EG active. With SSG-EG, the increment value is multiplied, however the 6x figure I gave previously is incorrect, as will be elaborated on below. The correct multiplier is 4x. With a 4x multiplier, the maximum increment value for a single step in the decay phase is 8*4=0x20, which is the same interval as the minimum step we can specify with SL, so again, unless changes are made to the effective rate of the decay phase during decay, we will always finish perfectly on SL, so no clamping is required. When we do change the decay rate during the decay phase, we have confirmed that the decay phase can be forced to "skip over" SL in both normal and SSG-EG modes. In the case where the decay phase moves past SL, the sustain phase begins on the next cycle, but the attenuation value is not clamped to SL. 7. When key on/off events are applied In my implementation, I thought changes to the key-on state were applied according to the envelope generator update cycle, so only once every 3 fm update cycles would a key-on state change take effect. This is incorrect. In fact, key-on changes are processed every fm update cycle. This becomes important when CSM mode is in use, since timer A overflows every fm update cycle. 8. Attack phase with rate values 62 and 63 I was vague on this point before. I've got a bit more info to add now. When an attack phase has a rate value greater than or equal to 62 (0x3E or 0x3F), it is treated differently. With no special case handling, rate values of 62 and 63 would be the same as rate values 60 and 61, namely, there would be an 8x increment value applied to the attack curve update process, and from a starting attenuation level of 0x3FF, it would take 10 update steps to achieve minimum attenuation. In fact, for the attack phase, there is special case handling to force the attenuation level directly to 0 when the attack phase is entered, if the calculated rate value is 62 or 63. Note that this happens immediately when the key-on event is processed, so it doesn't even have to wait for the next full envelope generator update cycle. This behaviour also occurs when the SSG-EG envelope loops, so it isn't just actual key-on events which trigger this behaviour. Since this special case handling appears to be triggered when the attack phase is entered, there's an interesting quirk that occurs when you change the attack rate during the attack phase. If you begin an attack phase with a slow rate value (to give you enough time to change it again before it finishes), then change the attack rate settings to switch to an effective rate value of 62 or 63 during the attack phase, the attack phase will NOT finish in the next update cycle. In fact, it won't advance at all. Switching to an effective rate value of 62 or 63 after the attack phase has already begun causes the attack phase to stall. The attenuation value will be locked at its current value, and will no longer advance until the attack rate is modified again to something less than 62, at which time, it will resume advancing from its current position, or until key-off occurs. I don't think MAME emulates this currently. I haven't found a neat way to emulate all this behaviour. I currently calculate the effective attack rate immediately when switching to the attack phase, and if the rate is greater than or equal to 62, I force the attenuation level directly to 0. I also have an exclusion in the normal envelope generator update cycle when updating the attack curve. If the attack rate is greater than or equal to 62, I don't advance the attack curve. This emulates the behaviour of the YM2612, but it probably isn't emulating the exact way this special case behaviour is implemented. I'm open to any suggestions about a neater way to emulate this. SSG-EG corrections: The information I gave previously about SSG-EG mode is mostly correct, but there are a lot of critical implementation details which I didn't have at the time. These details are vital in order to emulate the multitude of quirks which can arise with SSG-EG mode when using an attack rate less than 0x1F, or when making changes to various register values, in particular the SSG-EG mode flags, during output. I'm going to cover corrections for clear errors in my previous description of SSG-EG in this section, and cover new information regarding SSG-EG in the following section. 1. SSG-EG decay phase update formula I previously stated that during SSG-EG mode, for the decay, sustain, and release phases, the envelope generator attenuation value was updated as follows: [CODE] operator.attenuation += 6 * attenuationIncrement [/CODE] This is incorrect. The increment value is in fact only multiplied by a factor of 4 during SSG-EG mode, making the correct update formula the following: [CODE] operator.attenuation += 4 * attenuationIncrement [/CODE] This was the existing update behaviour in MAME, with the exception that MAME did not apply any multiplication factor in the release phase under SSG-EG mode. While MAME had the multiplication factor correct, this 4x multiplication factor should indeed be applied during the release phase under SSG-EG mode, as per the information I gave previously. 2. Attenuation limits under sustain, decay, and release When I wrote my previous information, I believed that the decay, sustain, and release phases under SSG-EG decayed the entire way to the maximum attenuation level of 0x3FF. In particular, I believed that an SSG-EG pattern without the hold bit set would loop only when the attenuation level had progressed the entire length from 0x0 to 0x3FF. This is actually not the case. When the internal attenuation level reaches 0x200 under SSG-EG mode, a variety of special operations are performed, which will be elaborated on later. 3. Output inversion I mentioned previously that SSG-EG "inverts" the attenuation output, but I really didn't provide any information on exactly how the non-inverted data was converted to the inverted data, because I wasn't able to sample the digital output. The attenuation data is inverted on the output from the envelope generator through the following operation: [CODE] attenuation = 0x200 - attenuation; attenuation &= 0x3FF; [/CODE] Basically, it's a full, proper two's compliment inversion. The inversion is actually "centered" at 0x200. MAME does the output inversion by performing a simple XOR operation with 0x1FF, which is incorrect. This produces an output which is off by 1. The result needs to be adjusted for normal two's compliment math. 0x001 should invert to 0x1FF, 0x110 should invert to 0xF0, 0x250 should invert to 0x3B0, etc. SSG-EG new info: SSG-EG is dangerous to emulate. It's dangerous because many of its functions could be implemented in a dozen different ways to achieve the intended result. Consider the implementation of output inversion. Based on the information I previously gave describing how the inverted output works, if you were to think about emulating it, you would probably create a boolean flag, to indicate whether the output is currently inverted or not. In the case of the attack bit, you would probably use the attack bit to determine the initial state of this inversion flag, so when key-on occurs, you would load the value of the attack bit into the inversion flag. It seems simple and logical, it's what I did at first, and it's what MAME currently does. It's also wrong. Similar pitfalls exist with things like hold mode and the alternate bit. Initially it may appear it doesn't matter how the YM2612 hardware performs a particular task compared with how it is emulated, as long as the two implementations produce an identical result. This is true, but unfortunately, there are a lot of ways to abuse SSG-EG mode. When you start changing things on the fly, and pushing SSG-EG into corners it's not supposed to deal with, you can expose lots of little quirks. These aren't bugs, simply areas of undefined behaviour where the result is not specified, because "you're not supposed to do that". These quirks betray information about how SSG-EG is really implemented. If your implementation differs from the YM2612 implementation, your SSG-EG implementation will not function correctly when pushing into these undefined areas. Unfortunately, simply using an attack rate less than 0x1F runs into a multitude of quirks, and we now know of several games which do in fact make use of this (Beavis & Butthead chainsaw sound effect, Barcelona Olympics water diving splash sound), so it's now important to emulate all these quirks, not just as an academic exercise, but in order to get correct sound in retail games. The good news is, after a solid month of testing involving hundreds of tests on dozens of strange pieces of aberrant behaviour, I have managed to derive an accurate implementation of SSG-EG which fully implements all the quirks of the real hardware. This isn't a hackaround, it makes perfect sense, and the implementation is fairly straightforward in the end, but it is almost completely different to what I started with. MAME will also require its SSG-EG implementation to be rewritten from scratch, and significant modifications to the envelope generator implementation in general, in order to incorporate these changes, so it should keep someone busy. [IMG ./images/smilies/icon_smile.gif] 1. Where SSG-EG is updated: Envelope generator output cycle vs envelope generator update cycle As previously mentioned, the envelope generator is updated once for every 3 times the phase generator is updated, and once for every 3 times the output of each operator is calculated. While the envelope generator may only update once every 3 FM output cycles however, its output is used every cycle. This means that internally, the envelope generator has a separate output process which runs at the same clock rate as the operator unit, to feed the current output for each operator to the operator unit as it is required. As it turns out, this output cycle is not an idle process. In fact, this output cycle is where virtually all the SSG-EG processing steps are implemented. Accurate emulation of SSG-EG mode requires that there be a series of active steps performed each time the output of the envelope generator is fed into the operator unit. More than this, there is an order to the way the SSG-EG update steps during this output cycle interact with the normal envelope generator update cycle. For one of every three output samples, the envelope generator update cycle will occur along with the envelope generator update cycle. When that happens, the operations are performed in the following order: 1. The SSG-EG output cycle update steps are performed 2. The envelope generator update cycle runs 3. The output from the envelope generator is calculated So, first the SSG-EG update steps occur, followed by the envelope generator update cycle, followed by the output calculation from the envelope generator, which includes applying SSG-EG output inversion if it is active. Where an envelope generator update cycle doesn't occur on the current output cycle, only steps 1 and 3 occur. This order of operations is a relatively minor point, but it does have a measurable effect. In the case where the attenuation level reaches 0x200 in SSG-EG mode, a single output sample is generated at this attenuation level before the envelope loops back to the attack phase. 2. How SSG-EG is updated I've already explained the basic theory and principles of SSG-EG, and they pretty well cover what SSG-EG mode does, but what they don't cover is exactly how the YM2612 implements them. I think the only way I can adequately explain the implementation of SSG-EG is by providing some sourcecode. This is taken directly from my core, so it's going to have some extra fluff which is specific to my emulator, but it's commented to the point of excess, so it should be easy enough to follow. I've taken great care to try and explain why each step of the SSG-EG update process is implemented the way it is, and what test cases on the hardware validate each step. This is an example of the steps that need to be carried out for SSG-EG on each envelope generator output cycle, IE, each time the output from the envelope generator is used by the operator unit: [CODE] //If SSG-EG is enabled, and the current internal attenuation level of the //envelope generator is greater than or equal to 0x200, we need to run some //special SSG-EG update steps. Note that hardware tests have proven that //these operations occur each time the output of the envelope generator is //calculated (IE, each sample), not just each time the envelope generator //is updated. The output inversion and phase counter reset steps in particular //are easily measurable, and have been shown to occur each sample. Note that //hardware tests have also shown that this update process occurs before the //normal envelope generator update steps in the case where both run on the //same cycle. This can allow a single sample to be output at an attenuation //level of 0x200 before these update steps are applied. OperatorData* state = &operatorData[channelNo][operatorNo]; if(GetSSGEnabled(channelNo, operatorNo, accessTarget) //SSG-EG mode is enabled && (state->attenuation >= 0x200)) //The internal attenuation value has reached the magic 0x200 threshold { if(GetSSGAlternate(channelNo, operatorNo, accessTarget) //SSG-EG is set to an alternating pattern && (!GetSSGHold(channelNo, operatorNo, accessTarget) || !state->ssgOutputInverted)) //Hold mode is disabled, or the current inversion state matches the initial inversion state at key-on { //Toggle the current inversion state of the envelope generator //output. Note that extensive hardware tests have been performed //on SSG-EG output inversion. This implementation has been shown //to always produce the correct output, even under unusual //circumstances such as when an attack phase is present, and/or //changes are made to the SSG-EG mode at critical points. state->ssgOutputInverted = !state->ssgOutputInverted; //Note that if the hold bit is set, the inversion state is //only toggled if the current inversion state matches the //initial inversion state. Under normal circumstances, this //prevents the inversion state from being toggled more than //once when the hold bit is set. This matches the confirmed //behaviour of the real chip. This behaviour is vital, as the //internal attenuation value finishes on 0x200 after each //decay phase. Without this test, once hold mode begins, the //inversion state would be toggled each sample. Note that the //envelope generator does not maintain a separate flag which //tracks whether the output has been inverted since key-on, //as changes to the SSG-EG mode after key-on can cause the //output to be inverted more than once under hold mode. } if(!GetSSGAlternate(channelNo, operatorNo, accessTarget) && !GetSSGHold(channelNo, operatorNo, accessTarget)) { //Hardware tests have shown that the phase counter is held at 0 //in cases where SSG-EG is enabled, both the hold bit and //alternate bit are unset, and the internal envelope generator //attenuation value is greater than or equal to 0x200. Once any //of these conditions change, the phase counter will resume //counting up from 0. This causes the phase of the output wave //to restart on each repetition of patterns 08 and 0C, which //occurs on the real hardware. Note that the phase counter //really is held at 0, not simply set to 0 at a particular point //in time. This can create silence gaps between repetitions of //the SSG-EG envelope where an attack phase exists. state->phaseCounter = 0; } if(state->phase != OperatorData::ADSR_ATTACK) { if((state->phase != OperatorData::ADSR_RELEASE) && !GetSSGHold(channelNo, operatorNo, accessTarget)) { //If SSG-EG is enabled, we're in either the decay or sustain phase, //and the hold bit is not set, now that we've reached an attenuation //level of 0x200, we need to loop back to the attack phase and begin //the ADSR envelope again. //Switch back to the attack phase SetADSRPhase(channelNo, operatorNo, OperatorData::ADSR_ATTACK); //Note that we've confirmed that the attenuation is not clamped //to 0x200 in SSG-EG mode when the ADSR envelope loops. By //toggling DR during the decay phase, we've proven that the final //attenuation value is allowed to move past 0x200 before looping. //If an attack curve follows, it begins its decay from this final //attenuation value. Don't uncomment the line below, it is //incorrect. It is only provided as an example of what NOT to do. //state->attenuation = 0x200; } else if((state->phase == OperatorData::ADSR_RELEASE) || !(state->ssgOutputInverted ^ GetSSGAttack(channelNo, operatorNo, accessTarget))) //If the output is not currently inverted { //If the output is not currently inverted, and we've reached an //internal attenuation level of 0x200 in one of the decay phases //(either the decay, sustain, or release phase), but the envelope //is not looping back to the attack phase, we need to force the //internal attenuation value to 0x3FF. This emulates the behaviour //of the YM2612 when entering a low-hold state in SSG-EG mode, and //when the release phase reaches 0x200. In both cases, the internal //attenuation value is forced directly to 0x3FF. This has been //confirmed through hardware tests. Note that this step occurs after //the inversion state has been toggled. Performing these steps the //wrong way around would break SSG-EG pattern 0xB, where both the //hold and alternate bits are set, and the attack bit is clear. //Force the internal attenuation value to 0x3FF state->attenuation = 0x3FF; //Note that this behaviour can be observed when switching from an //inverted hold pattern to a low-hold pattern, then back again after //the hold sequence has begun. When the inverted hold pattern resumes, //the digital output will be 0x001F instead of 0x1FE8, as the internal //attenuation value has been forced from 0x200 to 0x3FF, which becomes //0x201 when it is inverted, outputting a value of 0x001F. This effect //can also be observed when reading the decay sequence under the //release phase when SSG-EG mode is active. With an increment value of //1, the digital output from the operator unit can be observed to jump //directly from 0x0021 to 0, indicating the output attenuation value //from the envelope generator skipped from a known value of 0x1FC from //the decay sequence, to a value greater than 0x33F. } } } [/CODE] And this is an example of the steps you need to carry out when actually calculating the output from the envelope generator: [CODE] //If SSG-EG is enabled and the output is inverted, invert the output data. Note that //extensive testing has been performed on the hardware to build this implementation. //This test is performed exactly as shown each time the attenuation value is used. //Note the way the attack bit is combined with the inversion state. This is known //to be correct, and is essential in order to deal with cases where the SSG-EG state //is changed after key-on. A change in the state of the attack bit will result in an //immediate inversion of the output. Also note the calculation performed to derive //the "inverted" data. This calculation has been proven to be binary-accurate. if(GetSSGEnabled(channelNo, operatorNo, accessTarget) && (state->phase != OperatorData::ADSR_RELEASE) && (state->ssgOutputInverted ^ GetSSGAttack(channelNo, operatorNo, accessTarget))) { attenuation = 0x200 - attenuation; attenuation &= 0x3FF; } [/CODE] Note that this code snippet is being performed on a copy of the attenuation value, not the internal attenuation value itself. IE, this code isn't actually modifying the real attenuation value, just the value which is being output. This inversion of the output also occurs before TL is added to the output attenuation, and before amplitude modulation is applied. This is an example of the update calculation for the attenuation value in the decay, sustain, and release phase: [CODE] //Advance the linear decay for the decay, sustain, or release phase. Note //that if SSG-EG is enabled for this operator, the decay phase runs at 4x //the normal speed. if(GetSSGEnabled(channelNo, operatorNo, accessTarget)) { //If the current internal attenuation value is below 0x200, advance the //decay phase. In most cases when the attenuation level reaches 0x200, //the envelope will move back to the attack phase, or the attenuation //level will be forced to 0x3FF anyway. One case where neither of these //changes occur, and we need this check here to ensure the attenuation //level isn't permitted to advance any further, is when we enter an //inverted hold phase. Hardware tests have conclusively shown that in //these cases, if the internal attenuation level is greater than or equal //to 0x200, the attenuation level remains unchanged. This is true even in //cases where the internal attenuation level has been offset from a //multiple of 4, and the precise value of 0x200 is skipped over by an //SSG-EG increment. if(newAttenuation < 0x200) { newAttenuation += (int)(4 * attenuationIncrement); } } else { newAttenuation += (int)attenuationIncrement; } [/CODE] This is what you need to do when a key-off event occurs: [CODE] //If SSG-EG is enabled and the output is currently inverted, convert the //current attenuation value into an equivalent non-inverted value. This //emulates the release mode behaviour when SSG-EG is active. Note that we do //not alter the output inversion flag here. Output inversion is ignored //during the release phase. The output inversion flag is cleared when key-on //occurs. if(GetSSGEnabled(channelNo, operatorNo, accessTarget) && (state->ssgOutputInverted ^ GetSSGAttack(channelNo, operatorNo, accessTarget))) { state->attenuation = Data(attenuationBitCount, 0x200) - state->attenuation; } [/CODE] And finally, this little command needs to be run each time a key-on event occurs: [CODE] //Reset the SSG-EG output inversion flag state->ssgOutputInverted = false; [/CODE] That's my entire SSG-EG implementation. Note that existing emulators, including MAME and Kega, get a lot of the above implementation wrong. In fact, I'm pretty sure every aspect of the SSG-EG implementation in MAME is incorrect, including the calculation to invert the output, so the SSG-EG implementation in MAME really does need to be redone from scratch. 3. SSG-EG test rom With all this extra information about SSG-EG mode, I think I should post another SSG-EG test ROM to check the behaviour of SSG-EG under some of these undefined circumstances. Here's a test ROM which runs through each of the SSG-EG patterns with an attack phase: http://nemesis.hacking-cult.org/MegaDri ... elease.bin Here's the source: http://nemesis.hacking-cult.org/MegaDri ... elease.asm Here's the output you get on a PAL MD1600 (WARNING, huge file): http://nemesis.hacking-cult.org/MegaDri ... elease.rar And here's the output I currently get from my emulator using the SSG-EG implementation I detailed above: http://nemesis.hacking-cult.org/MegaDri ... elease.rar Note that patterns 0x0A and 0x0E alter each time they run. The inversion state may toggle between repetitions of the wave. In the "noise spike" between each repetition, the inversion state is actually being toggled each sample, since the internal attenuation level during the slow attack phase remains above 0x200 for an extended period of time, and the output inversion state is toggled each sample where the alternate bit is set, and the hold bit is unset. The exact sample on which the attenuation level drops below 0x200 determines what the inversion state is set to for the remainder of that repetition. Interrupt line corrections: I've got one correction to make regarding the info I posted ages back about the operation of the INT line on the YM2612. I had previously stated this: "Although not mentioned in the documentation, the reset flag directly affects interrupt generation. When a timer overflows, the YM2612 checks the current state of the timer overflow bit for that timer in the status register. The YM2612 will only generate an interrupt for that timer if the overflow bit is currently unset. If the overflow bit is unset, and the enable flag is set in the timer control register, the INT line will be asserted. The INT line will remain asserted, until the reset bit for that timer is set to 1 in the timer control register, or until the timer overflows again. If the reset bit for the timer is cleared at any time, the interrupt line will immediately be negated. If the timer overflows while INT is still asserted, that is, without reset being written to, the interrupt line will immediately be negated. From this point on, no interrupts will be generated for that timer until the reset bit is set. Once the reset bit has been set when an interrupt has been missed, the INT line will not immediately be asserted. The INT line will remain negated until the timer overflows again." Everything about the interrupt line not being asserted while the overflow bit is set, or the INT line being negated if the overflow bit hasn't been cleared, is incorrect. There was an error in my testing procedures which caused bad readings. The INT line is asserted whenever a timer overflows, and will remain asserted until the reset bit is flagged for the timer. This makes more sense, and is consistent with how other interrupt devices operate. The INT line is generated in real-time by a logical OR operation between the overflow bits of the two timers. CSM corrections: The information I gave previously about CSM mode is basically correct, but there are some points which require clarification. I didn't feel I did enough testing on the interaction between CSM key on/off and manual key on/off events, so I went back and did some more testing. These tests revealed some important details about how CSM mode is implemented in the YM2612. 1. When CSM key-on and key-off occur I stated previously that CSM key-on and key-off events occurred "at the same time". Obviously this isn't exactly correct, since the key-on event needs to be processed first. Originally, I believed that CSM key-on and key-off occurred during a single envelope generator update cycle, however while implementing CSM support in my core, I came to doubt the accuracy of this. I did some more testing in an attempt to verify whether CSM key-on and key-off occurred on the same update cycle, or whether CSM key-on occurred on one cycle with key-off occurring at the start of the next cycle. What I found is that not only does CSM key-off occur on a separate cycle to key-on, it is possible for a CSM key-on event to be lengthened to any number of update cycles, allowing the note to proceed through the attack, decay, and sustain phases, with CSM key-off not occurring until a register change is made. The way CSM key on/off events are triggered is simple. First of all, there is a dedicated internal flag which indicates the current "CSM key-on" state. When timer A overflows, if CSM mode is enabled, this "CSM key-on" flag is set. This flag remains set until the next phase generator update cycle, when key-on events are again evaluated. Note that this does occur based on the phase generator update cycle, not the envelope generator update cycle, as elaborated on above regarding when key on/off events are processed. After the key-on state of the operator has been evaluated during the next update cycle, the CSM key-on flag is cleared. If timer A does not overflow again before the next update, the CSM key-on flag will appear negated, which would key-off the operator on the next update cycle after it had been keyed on by CSM mode. If timer A overflows before every update cycle however, the CSM key-on flag appears to be permanently set, since it is always being re-asserted before it is sampled again. The effect of this is that CSM key-off does not occur, and the key-on event generated by CSM mode allows the operator to proceed through the normal ADSR envelope. Since timer A runs at the same rate as the phase generator update cycle, setting the timer A period to the shortest possible value (0x3FF) will cause this behaviour. Note that if the channel 3 mode doesn't equal 10 (upper bits of register 0x27 set to 10), the CSM key-on is masked, and the CSM key-on state is forced to 0. This causes a CSM key-off event to occur if CSM mode is disabled while CSM key-on is currently being held on. Note that as I stated in my previous description of CSM mode, CSM mode is only active when the channel 3 mode status bits are set to 10, not when they are set to 11. 2. How CSM key-on is tracked vs manual key-on There are two separate key-on flags. There is a normal key-on flag, which is updated by sending manual key on/off writes to register $28. There is also a separate CSM key-on flag, which is constantly and automatically updated when CSM mode is enabled, even when an operator has been manually keyed on. The way these two separate key-on flags interact is really simple. They are OR'd together. An operator is in a state of key-on if either of these flags is asserted. An operator is in a state of key-off if both these flags are cleared. With this implementation, if an operator is manually keyed on, the CSM key-on event is effectively "masked". Since the lines are OR'd together, if the manual key-on line is asserted, it will hold the operator in a keyed on state, regardless of the state of the CSM key-on flag. Once the manual key-on event is cleared, the CSM key-on state is able to have an effect, and change the effective key-on state of the operator. The YM2612 itself only considers that a key on/off event has occurred if the combined OR state of these two flags is different at the beginning of an update cycle than it was at the beginning of the last update cycle. You should be aware that some unusual combinations of manual key on/off events and CSM mode do require the above details to be implemented correctly. It is possible, for example, to "hand over" a key-on event between CSM mode and manual key on/off events. Eg, you can key on an operator manually, trigger a CSM key-on event in a "held" state (timer A at max rate), key-off the operator manually, and find that the operator does not actually key-off, since the CSM key-on state keeps the operator keyed on. The same rule applies in reverse. And I think that's all the corrections I'm aware of for the info I've previously posted. 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. Then I can turn my attention entirely to the VDP. ######## POST p7969 | TmEE co.(TM) | 2009-02-22 | t386-405.html Awesome work [IMG ./images/smilies/icon_biggrin.gif] And some relevant stuff, I messed with DAC a little... Seems that YM2612 misses DAC writes or does not output them when the sample rate is too high... it is odd that when you wait for the chip to be ready, things will not sound too good.... 32KHz sounds bad (and its around the rate you get when you wait for the chip). 26KHz (~half the YM2612 sample rate) sounds great though [IMG ./images/smilies/icon_smile.gif] http://www.fileden.com/files/2008/4/21/ ... CTESTS.RAR ######## POST p7995 | Eke | 2009-02-23 | t386-405.html Thanks for the corrections Nemesis, the CSM mode is now more clear (and appears to be a vey useful feature for programmers) and the SSG-EG support indeed requires some additional work [IMG ./images/smilies/icon_wink.gif] Though, there is still something about EG that is not clear to me: when does EG phase change occurs ? at the start of a new enveloppe cycle by checking the current attenuation level or at the end, after the attenuation level has been updated. This also determine the behaviour of the next enveloppe update in the 2 following case: 1/ attack rate is set to 62 or 63: you say that the attenuation level is set to 0 but is the next enveloppe update done with Attack or Decay parameters ? 2/ SL is set to 0: does EG enter the susbtain phase once or does it directly jump to release ? 3/ what happen when both conditions are met: AR = 62/63 and SL = 0 ? Some other questions: how is attenuation level generally handled when Key ON occurs , for example, if the "volume" has not reached 0 yet ? what are default values (internals and registers ) on chip reset ? ######## POST p7998 | Snake | 2009-02-23 | t386-420.html Wow, huge post [IMG ./images/smilies/icon_smile.gif] Kind of odd that you would post this right now. I have a ton of SSG-EG samples I did years ago, but I lost the test ROMs that created them, so I didn't know what I was looking at. This weekend I found them and spent most of it looking into this again. I'll read your post properly later and see if it matches what I came up with, a brief look says that some of it does, but there's stuff I didn't get around to yet that you've probably covered. So, all in all, I probably just wasted a weekend [IMG ./images/smilies/icon_smile.gif] All the other stuff seems to be correct, at first glance anyway. [edit] ok, so the bits I hadn't gotten to yet seem to be the bits that make the least sense. "Surprising" isn't the word. Given what the thing is supposed to do, you'd have to be on crack to implement it this way. I don't doubt that what you posted does indeed match the output of the real chip - it does seem to explain exactly what I'm seeing (all except one case which I won't be able to confirm without testing). But I do wonder if there is another way of getting the same results from some of this, just because - well - it's pretty insane [IMG ./images/smilies/icon_smile.gif] I'd be interested to hear more about how you came to some of these conclusions and the tests you did to verify. [QUOTE] Nemesis wrote:These aren't bugs, simply areas of undefined behaviour where the result is not specified, because "you're not supposed to do that". [/QUOTE] Not that it's important, but I would agree with you that writing to registers while the envelope generator is running is really something you're not supposed to do, and the odd things that can happen when you do this can't really be considered 'bugs'. But I disagree on the oddness that happens when AR!=0x1F. The fact that the documentation tells you to do that just strikes me as a "oops, we didn't test this" from Yamaha. Any sensible implementation of SSG-EG wouldn't have this problem, there should be no reason it's needed, and there's plenty of places where they could have, should have, and probably would have (if they'd thought of it) just forced the attenuation to zero - IF that was how it was originally intended to work. "You must use 0x1F" is a workaround, definitely a bug imo. [QUOTE] Nemesis wrote:Note that existing emulators, including MAME and Kega, get a lot of the above implementation wrong. [/QUOTE] Yeah, I thought I'd covered every case that was actually used, and planned to go further later, but then lost the ability to do so. Didn't know about that damn olympics game... [QUOTE] Nemesis wrote:In fact, the envelope generator is updated once every 3 fm update cycles, which was the existing behaviour in the MAME core. [/QUOTE] There's something that you could test. Fairly unimportant, but I believe the reason why it's 3 cycles is that the YM2203 updates the envelopes for channel 1 on the first cycle, channel 2 on the second cycle... The YM2612 probably does one channel from each 'half' every cycle. [edit again] I missed this... [QUOTE] Nemesis wrote:I've also figured out the cause of the different sound in Battletech track 12 [/QUOTE] I think there are a number of things that cause the difference, but this is I believe the main one. [IMG http://www.reptilia-design.co.uk/gen1-gen2.png] This is a sample I produced long ago while investigating the detune bug, and the filters. Top is a Genesis model 1, bottom is a Genesis model 2. Throughout the entire test, everything is played at max volume. The large bars you see are a normal note which is in a range which does not get filtered at all, showing you what the actual output volume is supposed to be. Everything else is a note played utilising the detune bug. All of the frequencies produced are the same on both consoles. But the filter in the Genesis 2 has a fair amount of ripple, whereas the Genesis 1 filter flattens out nicely. As you can see, most of the time the Genesis 2 filters out more than the Genesis 1. But the 4th, 5th and 9th note in this picture show the Genesis 2 letting through significantly more than the Genesis 1 does. The 5th note played is, I believe, the one used by Battletech. The Genesis 1 cuts out most of the high frequency created by using this note as a modulator, the Genesis 2 lets a lot of it through. As a side note, this would be much softer than it actually is on a Genesis 1 if it wasn't for the distortion created at this low volume. ######## POST p7999 | Snake | 2009-02-23 | t386-420.html [QUOTE] Eke wrote:1/ attack rate is set to 62 or 63: you say that the attenuation level is set to 0 but is the next enveloppe update done with Attack or Decay parameters ? [/QUOTE] Decay. Attack is skipped immediately in this case. [QUOTE] Eke wrote:2/ SL is set to 0: does EG enter the susbtain phase once or does it directly jump to release ? [/QUOTE] I believe you mean 'decay' and 'sustain' here... Again, one phase (decay) is skipped and it goes immediately to sustain. [QUOTE] Eke wrote:3/ what happen when both conditions are met: AR = 62/63 and SL = 0 ? [/QUOTE] level set to zero, followed by sustain. [QUOTE] Eke wrote:how is attenuation level generally handled when Key ON occurs , for example, if the "volume" has not reached 0 yet ? [/QUOTE] Nothing happens, the level continues from where it was. This is true of all 'real' synth chips, including the good old SID chip. It's closer to how a real instrument works - softly tap a key on a piano and it will get louder each time. [QUOTE] Eke wrote:what are default values (internals and registers ) on chip reset ? [/QUOTE] I did a bit of testing on that many, many years ago. I don't recall fully, but I believe they are mostly undefined (if you reset the chip while it's playing, I believe the note continues unaffected), with the exception of the registers that control stereo, which seem to be set to allow left and right output for all channels, at least at power on. It's a good question, though... ######## POST p8004 | Eke | 2009-02-24 | t386-420.html again, thanks for the clarifications this helps a lot ######## POST p8007 | HardWareMan | 2009-02-24 | t386-420.html I made a record Battletech Track 12 from my Model 1 for compare. Here is it . I keep it in original WAV, so you get lossless. That high frequences is very interesting. [IMG http://img7.imageshack.us/img7/5615/hifreq1.th.gif] [IMG http://img7.imageshack.us/img7/5498/hifreq2.th.gif] The amplitude can be distort becouse very small difference with sampling frequency (wich is 48kHz) and frequency of signal. But this signal still interesting. Next, we have seen good old "ladder" effect on bass: [IMG http://img7.imageshack.us/img7/5692/ladder.th.gif] ######## POST p8008 | Snake | 2009-02-24 | t386-420.html That's a really good capture of the effect, better than I've seen so far. How did you capture that? ######## POST p8009 | HardWareMan | 2009-02-24 | t386-420.html [QUOTE] Snake wrote:That's a really good capture of the effect, better than I've seen so far. How did you capture that? [/QUOTE] Easy. Just connect earphone jack on MD1 to line in of my Audigy. Then set maximum volume on MD1 (to get maximal signal-to-noise ratio) and attenuate it on Audigy mixer. BTW, volume of this track not so loud, so I set all to maximum. ######## POST p8010 | Eke | 2009-02-24 | t386-420.html some more bits [QUOTE] I haven't found a neat way to emulate all this behaviour. I currently calculate the effective attack rate immediately when switching to the attack phase, and if the rate is greater than or equal to 62, I force the attenuation level directly to 0. I also have an exclusion in the normal envelope generator update cycle when updating the attack curve. If the attack rate is greater than or equal to 62, I don't advance the attack curve. This emulates the behaviour of the YM2612, but it probably isn't emulating the exact way this special case behaviour is implemented. I'm open to any suggestions about a neater way to emulate this. [/QUOTE] What I did is to use the same increment values as when Rate is 0 (infinite rate), in the case Atttack Rate is 62 or 63 when rate values (increment and shift) need to be recalculated. And to immediately jump into Decay phase on Key ON (or SSG-EG loop restart) when Attack Rate is 62 or 63. [QUOTE] More than this, there is an order to the way the SSG-EG update steps during this output cycle interact with the normal envelope generator update cycle. For one of every three output samples, the envelope generator update cycle will occur along with the envelope generator update cycle. When that happens, the operations are performed in the following order: 1. The SSG-EG output cycle update steps are performed 2. The envelope generator update cycle runs 3. The output from the envelope generator is calculated [/QUOTE] Can you confirm that output calculation also happen the same way with normal enveloppe ? Meaning that any change to internal attenuation level (for example on Key ON with AR=62,63) or to TL (on register write) will apply to the EG output calculation used for the next sample, even if no EG update was planned ... [CODE] else if((state->phase == OperatorData::ADSR_RELEASE) || !(state->ssgOutputInverted ^ GetSSGAttack(channelNo, operatorNo, accessTarget))) //If the output is not currently inverted { //If the output is not currently inverted, and we've reached an //internal attenuation level of 0x200 in one of the decay phases //(either the decay, sustain, or release phase), but the envelope //is not looping back to the attack phase, we need to force the //internal attenuation value to 0x3FF. This emulates the behaviour //of the YM2612 when entering a low-hold state in SSG-EG mode, and //when the release phase reaches 0x200. In both cases, the internal //attenuation value is forced directly to 0x3FF. This has been //confirmed through hardware tests. Note that this step occurs after //the inversion state has been toggled. Performing these steps the //wrong way around would break SSG-EG pattern 0xB, where both the //hold and alternate bits are set, and the attack bit is clear. //Force the internal attenuation value to 0x3FF state->attenuation = 0x3FF; [/CODE] what happen in this case and more generally during the RELEASE phase for next samples update ? according to your algo, as attenuation level will remain higher than 0x200, this would mean the Invert flag could be swapped (even if output is not inverted during release) or the Phase counter could be reseted for each samples under some conditions... isn't there a OFF state when attenuation reaches 0x3FF which turn the Enveloppe Generator off ? Or does the SSG-EG update process continue anyway ? ######## POST p8017 | SmartOne | 2009-02-24 | t386-420.html [QUOTE] HardWareMan wrote:Then set maximum volume on MD1 (to get maximal signal-to-noise ratio) and attenuate it on Audigy mixer. BTW, volume of this track not so loud, so I set all to maximum. [/QUOTE] Does the Genesis 1 HD max volume really produce the greatest signal-to-noise ratio? I thought about 75% was the most distortion-free... ######## POST p8018 | TmEE co.(TM) | 2009-02-24 | t386-420.html Its model dependant, some models have different headphone amp which starts distorting sound at over ~7. The model he has, has no trouble at max. The VA7 MD1 is one model which is very bad at higher volumes. ######## POST p8019 | Snake | 2009-02-24 | t386-420.html [QUOTE] Eke wrote:What I did is to use the same increment values as when Rate is 0 (infinite rate) [/QUOTE] Indeed, it makes perfect sense. [QUOTE] Eke wrote:Can you confirm that output calculation also happen the same way with normal enveloppe ? Meaning that any change to internal attenuation level (for example on Key ON with AR=62,63) [/QUOTE] If what Nemesis says is 100% correct, then it follows that this must indeed be the case, or certain things would get broken. [QUOTE] Eke wrote:or to TL (on register write) [/QUOTE] TL is done independantly of the env anyway, so, yes, this will happen immediately. [QUOTE] Eke wrote:according to your algo, as attenuation level will remain higher than 0x200, this would mean the Invert flag could be swapped [/QUOTE] This is one of the parts I'm not yet convinced of. I can see where the thinking comes from because it solves a number of problems - then again, I've got a ton of samples that don't look like that is happening. It's possible that it is but I'd need to write some tests before I can say either way. [QUOTE] Eke wrote:isn't there a OFF state when attenuation reaches 0x3FF which turn the Enveloppe Generator off ? Or does the SSG-EG update process continue anyway ? [/QUOTE] It's highly probable nothing ever really 'stops'. There'd be no benefit in doing so. ######## POST p8020 | Nemesis | 2009-02-25 | t386-420.html Gah, more to say, not enough time. I'll reply to some more comments later. [QUOTE] Seems that YM2612 misses DAC writes or does not output them when the sample rate is too high... it is odd that when you wait for the chip to be ready, things will not sound too good.... 32KHz sounds bad (and its around the rate you get when you wait for the chip). 26KHz (~half the YM2612 sample rate) sounds great though [/QUOTE] Hmm, that is strange. It looks like the one running at the higher frequency has some additional noise on the output signal. I'll take a look. [QUOTE] what are default values (internals and registers ) on chip reset ? [/QUOTE] I can't say I've done very thorough tests on this. I generally ran on the assumption that the registers were initialized to 0 on power-on. I found documentation stating this is the case for other Yamaha FM chips, and the same seems to be true on the YM2612, with the exception of the Left/Right flags, which are initially set as Steve mentioned (and would be on the YM2608 as well, presumably for OPN compatibility reasons). I didn't do any tests with triggering a reset after initializing the registers or anything like that however. [QUOTE] Not that it's important, but I would agree with you that writing to registers while the envelope generator is running is really something you're not supposed to do, and the odd things that can happen when you do this can't really be considered 'bugs'. But I disagree on the oddness that happens when AR!=0x1F. The fact that the documentation tells you to do that just strikes me as a "oops, we didn't test this" from Yamaha. Any sensible implementation of SSG-EG wouldn't have this problem, there should be no reason it's needed, and there's plenty of places where they could have, should have, and probably would have (if they'd thought of it) just forced the attenuation to zero - IF that was how it was originally intended to work. "You must use 0x1F" is a workaround, definitely a bug imo. [/QUOTE] That depends on what you think their objectives were. You could say that having the attack phase officially supported and usable with the SSG-EG modes would have been a useful addition, and you're right, it shouldn't have taken a lot of work to do. I honestly don't think they ever planned on allowing the attack phase to be used with SSG-EG modes however, and there is reason behind that line of thinking. It is important to remember that the SSG-EG mode is only provided in order to emulate the behaviour of the SSG envelope generator. The SSG module itself is based on the older AY-3-8910 produced by General Instruments. From the get-go, the purpose of SSG-EG wasn't to add new functionality, it was to emulate old functionality, and it was approached in that manner. The AY-3-8910 effectively only had a linear decay cycle. It had a counter which was set to advance at a specified rate, and it progressed in a linear fashion. That was the spec. In this context, the attack phase is superfluous. Allowing an attack phase to be combined with SSG-EG mode was simply not required, and from some points of view, pointless. The designers would have been given the specs saying "we want the FM envelope generator to be able to mimic the behaviour of this chip", and they went off and designed a function that allowed just that, but the designers obviously didn't feel the need to go beyond that spec. In this context, I would disagree with the statement that the strange behaviour we see when combining an attack phase with SSG-EG should be considered a bug. SSG-EG was built for a purpose, and the attack phase simply wasn't a part of it. They didn't want the attack phase getting in the way of the SSG-EG emulation, so the mandate was to set the attack rate to 0x1F, causing the attack phase to be instantly skipped, getting it out of the way and allowing the decay/sustain phase to emulate the linear counter of the SSG envelope generator without interference. I don't think this was an "oops" at the end, I think it was a conscious decision made early on in the planning stages, and as such, SSG-EG was built without regard for how it would interact with an attack phase. [QUOTE] There's something that you could test. Fairly unimportant, but I believe the reason why it's 3 cycles is that the YM2203 updates the envelopes for channel 1 on the first cycle, channel 2 on the second cycle... The YM2612 probably does one channel from each 'half' every cycle. [/QUOTE] Heh, I hadn't thought of that. You're probably right. I'll do some tests for this. [QUOTE] [QUOTE] I've also figured out the cause of the different sound in Battletech track 12 [/QUOTE] I think there are a number of things that cause the difference, but this is I believe the main one. ... [/QUOTE] Yep, that's along the right line. The cause of the difference is in the analog domain, and it is triggered by high frequency tones. In the case of Battletech track 12, it's specifically the effect of volume changes on a high frequency tone that cause the problem. The tone effectively becomes a carrier wave for another wave which is generated by the volume changes. The MD2 has an imperfect output which causes these volume changes to produce an audible waveform, when they should in fact not be audible at all. I really need to post pictures and samples in order to explain it properly. [QUOTE] [QUOTE] More than this, there is an order to the way the SSG-EG update steps during this output cycle interact with the normal envelope generator update cycle. For one of every three output samples, the envelope generator update cycle will occur along with the envelope generator update cycle. When that happens, the operations are performed in the following order: 1. The SSG-EG output cycle update steps are performed 2. The envelope generator update cycle runs 3. The output from the envelope generator is calculated [/QUOTE] Can you confirm that output calculation also happen the same way with normal enveloppe ? Meaning that any change to internal attenuation level (for example on Key ON with AR=62,63) or to TL (on register write) will apply to the EG output calculation used for the next sample, even if no EG update was planned ... [/QUOTE] Yes. Try using CSM mode with really quick timer periods (IE, one less than minimum) and you'll see this is true for key on/off changes. I can't say I've tested this for TL changes specifically, but I can say it is true for TL anyway, since TL is applied after output inversion, and I confirmed that output inversion happens every sample, so the envelope generator has to read TL each sample to apply it to the output. ######## POST p8023 | Snake | 2009-02-25 | t386-420.html [QUOTE] Nemesis wrote:Hmm, that is strange. It looks like the one running at the higher frequency has some additional noise on the output signal. I'll take a look. [/QUOTE] It's probably writing to the DAC at around the same time the chip is trying to read it. [QUOTE] Nemesis wrote:I can't say I've done very thorough tests on this. I generally ran on the assumption that the registers were initialized to 0 on power-on. I found documentation stating this is the case for other Yamaha FM chips [/QUOTE] Yes, me too, and it's probably correct, at least on power on. I seem to recall hitting the reset line didn't clear things though (maybe it keyed all channels off?) - then again I've done so much of this stuff on different hardware over the last few years I could be thinking of an entirely different system [IMG ./images/smilies/icon_wink.gif] [QUOTE] Nemesis wrote:From the get-go, the purpose of SSG-EG wasn't to add new functionality, it was to emulate old functionality [/QUOTE] Absolutely, and it definitely seems like it was tacked on at the end rather than built into the design from the start. [QUOTE] Nemesis wrote:They didn't want the attack phase getting in the way of the SSG-EG emulation, so the mandate was to set the attack rate to 0x1F [/QUOTE] Yes, but my point is that if they're already forcing the attenuation to zero when AR is above 62, why didn't they just force that all the time in SSG-EG mode? Or in plenty of other places where they could have done so? Leaving this up to the programmer in this way isn't something you'd usually expect to see. In any case, the entire chip seems very well designed and logical - except for this bit, which is all a bit "WTF?" [IMG ./images/smilies/icon_wink.gif] ######## POST p8025 | Nemesis | 2009-02-26 | t386-420.html [QUOTE] Snake wrote:[edit] ok, so the bits I hadn't gotten to yet seem to be the bits that make the least sense. "Surprising" isn't the word. Given what the thing is supposed to do, you'd have to be on crack to implement it this way. I don't doubt that what you posted does indeed match the output of the real chip - it does seem to explain exactly what I'm seeing (all except one case which I won't be able to confirm without testing). But I do wonder if there is another way of getting the same results from some of this, just because - well - it's pretty insane I'd be interested to hear more about how you came to some of these conclusions and the tests you did to verify. [/QUOTE] Notes on a lot of the important hardware test cases are included in the source I posted. There are a few points which could be implemented differently to get the same result, but not a lot. I simply can't think of another way to implement some of the weirdest stuff. Consider the way output inversion is tracked for example. A change to the attack bit always causes an immediate inversion of the output, and believe me when I say I tested this under every conceivable circumstance. The YM2612 doesn't reset the inversion state to the attack state on the write, since if you had a wave where ATT=0 and ALT=1, and it had toggled the output inversion state once since the wave began (so the output was currently inverted), and you then changed the ATT bit to set, the wave output would immediately switch to a non-inverted state. With that ruled out, the observed behaviour says to me that the attack bit is being combined with the output inversion state each cycle through an XOR operation, and the internal flag tracks whether the output has been inverted from the starting value, rather than representing the true output inversion state by itself. A slightly unusual choice perhaps, but that's what the evidence indicates, and it's a fairly simple operation by itself. That has a few flow-on effects however. It simplifies the inversion exclusion for hold mode, since we now only have to test the boolean flag to determine whether the output has been inverted yet (since hold mode only ever allows the ALT bit to toggle the inversion state once), however it now means we have to combine the ALT bit with the inversion bit in 3 places in order to calculate the true, effective inversion state. There are more impacts as well. Now we have to consider release mode. Output inversion is always disabled during the release phase, regardless of what the current state of the output inversion bit was, and the state of the ATT bit, when the release phase was entered. Ok, so output inversion is disabled during release, but how is it disabled? Since the output inversion flag now represents whether the output inversion state has been toggled from the base value given by the ATT bit, it's not as simple as clearing the output inversion flag when entering the release phase. If you clear the output inversion flag and the ATT bit is set, you still get an inverted output. Do you then load the state of the ATT bit into the output inversion state when entering the release phase? Wrong, since toggling the ATT bit during the release phase doesn't cause output inversion to kick in. This means we now need an extra test where we check the output inversion state. If we're in the release phase, the effective output inversion state is forced to false, so our test for output inversion is now something like this: (phase != release) && (ATT ^ inversionBit) Some other interesting choices are having the SSG-EG state updated on the output cycle rather than the update cycle. Perhaps this made the SSG-EG mode easier to integrate with the existing design. All the voodoo with 0x200 makes sense from the point of view of least effort, since they needed some way to hook their SSG-EG update process with the existing envelope generator. Sacrificing one bit of resolution from the attenuation value and using the upper bit of the attenuation as a flag for the SSG-EG update steps in the output cycle was the easiest way to achieve it, and a 9-bit resolution for attenuation was enough for what they were emulating anyway. [QUOTE] Eke wrote:what happen in this case and more generally during the RELEASE phase for next samples update ? according to your algo, as attenuation level will remain higher than 0x200, this would mean the Invert flag could be swapped (even if output is not inverted during release) or the Phase counter could be reseted for each samples under some conditions... [/QUOTE] There's no way to verify, at least that I can think of. Since the effective output inversion state is always forced to false when the release phase is active, there's no way to sample the current value of the invert flag. All we can say with certainty is that when key-on occurs, the note begins with the invert flag cleared. In my implementation, I only clear it during key-on, and simply allow it to be constantly toggled when the release phase reaches 0x200. Instead of this, you could clear it when key-off occurs, and add an exclusion to the SSG-EG update steps to prevent the invert flag being toggled during the release phase. As for the phase counter restart, again there's no way to verify, since the internal attenuation level is always forced to 0x3FF when the release phase hits 0x200. The phase counter is theoretically restarted on the same sample as the attenuation is forced to max, but I have no way to sample the output from the phase generator when the attenuation is at max, and the only way to lower the attenuation from a release phase is to trigger a key-on event, which restarts the phase counter anyway. Of course, seeing as there's no way to verify what the real chip does, it also doesn't matter, since there's no way any of this can have any effect on the output. [QUOTE] Eke wrote:isn't there a OFF state when attenuation reaches 0x3FF which turn the Enveloppe Generator off ? Or does the SSG-EG update process continue anyway ? [/QUOTE] I'd say there isn't an "off" state, simply because there would be absolutely no point to include one. The decay phases include a limiter on the update step to clamp the maximum attenuation at 0x3FF. This prevents the decay phase from advancing once it reaches maximum attenuation anyway, and since the output during any "off" mode is just going to be 0x3FF, adding an "off" state wouldn't serve any purpose. [QUOTE] Snake wrote: [QUOTE] Eke wrote:according to your algo, as attenuation level will remain higher than 0x200, this would mean the Invert flag could be swapped [/QUOTE] This is one of the parts I'm not yet convinced of. I can see where the thinking comes from because it solves a number of problems - then again, I've got a ton of samples that don't look like that is happening. It's possible that it is but I'd need to write some tests before I can say either way. [/QUOTE] Do you mean in general, or during the release phase (the source of the quote)? During the release phase it doesn't matter. During the attack/decay/sustain phases, I'm quite confident the invert flag gets toggled each sample once the attenuation reaches 0x200. If you're looking at the recorded output of the chip, remember that high frequency waves (which is what a constantly toggling inversion bit gives you) get pulverized by the output circuitry. [QUOTE] Snake wrote: [QUOTE] Nemesis wrote:They didn't want the attack phase getting in the way of the SSG-EG emulation, so the mandate was to set the attack rate to 0x1F [/QUOTE] Yes, but my point is that if they're already forcing the attenuation to zero when AR is above 62, why didn't they just force that all the time in SSG-EG mode? Or in plenty of other places where they could have done so? Leaving this up to the programmer in this way isn't something you'd usually expect to see. In any case, the entire chip seems very well designed and logical - except for this bit, which is all a bit "WTF? [IMG ./images/smilies/icon_wink.gif] [/QUOTE] Yeah, that's true. Ok, we can agree then that SSG-EG was clearly an afterthought, done quickly, with the least effort possible, requiring the least changes to the existing core, and certainly using some questionable design approaches. In other words, it's dodgy, but they knew it was dodgy. [IMG ./images/smilies/icon_smile.gif] ######## POST p8026 | Nemesis | 2009-02-26 | t386-420.html Missed this: [QUOTE] Snake wrote:I don't doubt that what you posted does indeed match the output of the real chip - it does seem to explain exactly what I'm seeing (all except one case which I won't be able to confirm without testing). [/QUOTE] Care to share? If there are errors in my implementation, I'd like to track them down quickly before I forget all this stuff. [IMG ./images/smilies/icon_smile.gif] In six months time I'm not going to remember a damn thing about this. ######## POST p8027 | Snake | 2009-02-26 | t386-420.html [QUOTE] Nemesis wrote:Care to share? [/QUOTE] Absolutely, happy to. It's to do with the inverting every cycle thing. I believe my tests were done with AR=0x0A, and one of the inverting patterns. I was looking at what I assume is an inverted attack, and it looks like a perfect sine wave at a constant volume. The samples you provided don't look like that at all. As I said, I can't rule out it is in fact doing what you suggest without testing. If it matters I think the sample came from an MD2, but I'd be surprised if SSG-EG works any differently there. I'll look through my samples and post this one when I find it, but you can probably repro it fairly easily. [edit]Here we go. As you can see it looks like a sine wave at the same frequency as the rest of the wave. I'm not sure your data explains this, or the volume level, but if you can explain it, please do - I've been stupidly busy and haven't had much sleep these last few days, so my brain may just be misfiring [IMG ./images/smilies/icon_wink.gif] Actually, looking at it now, you can see where the wave switches from decay to sustain - and the level of the 'spike' is suspiciously similar to the sustain level. Hmm. ######## POST p8028 | AamirM | 2009-02-26 | t386-435.html Damn, I've got no free time time to read all that [IMG ./images/smilies/icon_cry.gif] . But thanks to everyone who is contributing to these new discoveries [IMG ./images/smilies/icon_smile.gif] . ######## POST p8030 | Eke | 2009-02-26 | t386-435.html ok, I've finished the new SSG-EG implementation in the MAME core.(as well as some other stuff you mentionned, like correct CSM mode) Seems fine so far with the test programs... Nemesis, if you want to have a look and doublecheck it (I tried to optimize it a little bit and avoid unecessary recalculation as most as I could), please check here for fm.c... any advice/corrections appreciated [IMG ./images/smilies/icon_wink.gif] ######## POST p8032 | Nemesis | 2009-02-26 | t386-435.html [QUOTE] Snake wrote:[edit]Here we go. As you can see it looks like a sine wave at the same frequency as the rest of the wave. I'm not sure your data explains this, or the volume level, but if you can explain it, please do - I've been stupidly busy and haven't had much sleep these last few days, so my brain may just be misfiring [IMG ./images/smilies/icon_wink.gif] [/QUOTE] Yep, I can explain what's happening. The recording you've taken is at 44100Hz. The native output of the YM2612 in the Mega Drive is around 52847Hz. With the output being inverted each sample, that creates a wave with a frequency of around 26423.5Hz, but since you need to be able to capture at least two full samples in order to record a wave at that frequency, the sampling rate you're recording at simply isn't high enough to capture the inversion. The samples are averaging together, which is why you're being left with a regular sine wave at mid-level. You'll also note the strange distortion on the sine waves you posted as the phase of the output causes the output to approach 0. That's because the difference between the normal and inverted output samples is being reduced by the attenuation from the phase generator, so your sound card is able to more accurately observe the true slope of the carrier wave as the output approaches 0. If you check the massive sampled recording I made on the hardware (which is recorded at 96KHz), you'll see the inversion occurring. Measure the frequency of the generated wave (spectral view is good for that) and you'll see that it matches the expected output frequency caused by the inversion state toggling each sample. You'll also note in the recording I took that there is still some sample averaging taking place. The only way to get a true, clean sampling of the output with such a high frequency wave would be to run at a multiple of the native output sample rate from the YM2612. Running at 192KHz doesn't make things clearer, since the multiplexed output from the YM2612 becomes visible at that sample rate. [QUOTE] Eke wrote:Nemesis, if you want to have a look and doublecheck it (I tried to optimize it a little bit and avoid unecessary recalculation as most as I could), please check here for fm.c... any advice/corrections appreciated [IMG ./images/smilies/icon_wink.gif] [/QUOTE] I can see one thing that might be a problem, if I'm following your code correctly. When SSG-EG is active and the envelope is in the release phase, the attenuation level is still forced directly to 0x3FF when the release phase reaches 0x200. It looks like you're excluding all SSG-EG update steps when release phase is active, which would also exclude this behaviour. And this is nitpicking, but there are also some old comments under the heading "SSG-EG envelope shapes" which should be looked at. Some of the info under this comment block will no longer match what the code actually does, eg, the bit about a restart of the phase generator. ######## POST p8034 | Snake | 2009-02-26 | t386-435.html [QUOTE] Nemesis wrote:The samples are averaging together, which is why you're being left with a regular sine wave at mid-level. [/QUOTE] I did consider that, but since the sample rate is not divisible by the hardware output rate, I would have expected to see some clear distortion rather than an almost perfect wave - I can see this in other samples. Also - granted, inverted 0x200 will give you 0x000, but every value above 0x200 will also give you a value above 0x200 - I would have expected something much quieter than mid level if the two were just being averaged. But as I said, it's not clear from this sample alone and I'd have to do more tests. I do know that a lot of the info you posted is correct, because I confirmed some of it myself a long time ago. But back then 44KHz was "the business", and I knew it wasn't good enough. I paid a lot of money for a true 96KHz card right before I lost all my equipment anyway :-/ I'd love to be able to confirm all this stuff for myself, and see it we can't come up with a simpler or more logical way of implementing it. Not that it's complicated, just... odd. In my experience, odd usually means wrong, but I'm prepared to accept that in this case, it is probably just a strange piece of hardware hackery. Would like to be sure, though, because that's just "how I roll" [IMG ./images/smilies/icon_wink.gif] [edit] oh - while I'm here - a lot of games write to the upper 4 bits of the SSG-EG registers. I'm not sure what the programmers think they were doing this for, and I didn't test extensively, but I believe they don't do anything. Did you test this? ######## POST p8037 | Nemesis | 2009-02-27 | t386-435.html [QUOTE] Snake wrote:Also - granted, inverted 0x200 will give you 0x000, but every value above 0x200 will also give you a value above 0x200 - I would have expected something much quieter than mid level if the two were just being averaged. [/QUOTE] Ahh, but remember that the attenuation isn't moving past 0x200 during a repeating SSG-EG wave. In the pattern you posted, the attenuation decays until it reaches 0x200. When this happens, if AR was 0x1F, the attenuation would be forced back to 0. Since this isn't the case, what happens is the attenuation sits on 0x200 until the attack phase advances. When it does advance, it will drop the attenuation to 0x1DF. From this point on, you get a valid, advancing attack phase, but all the samples that were generated while the attenuation value was sitting on 0x200 will be inverting each sample. One point where you do get an attenuation level over 0x200 being toggled each sample is when you first key-on an SSG-EG envelope with an attack rate less than 0x1F, if the current attenuation level is over 0x200 that is. Examine the hardware recording I made at the start of patterns 0xA and 0xE. You want to zoom in on the vertical axis a lot and have a really good look at the low-volume lead-in for the attack curve. The DAC starts doing horrible things with this much attenuation, but you'll be able to see the same high-frequency oscillation occurring on this wave. You'll also be able to see a "dead patch" a little before half-way along this block, where the attenuation level is around 0x300, and 0x300 inverted is still 0x300, so the high frequency oscillation reduces as the attenuation approaches 0x300, then increases again as it approaches 0x200. This constantly toggling inversion state just after the key-on event is what causes the initial state of the ATT bit to be overridden. [QUOTE] But as I said, it's not clear from this sample alone and I'd have to do more tests. I do know that a lot of the info you posted is correct, because I confirmed some of it myself a long time ago. But back then 44KHz was "the business", and I knew it wasn't good enough. I paid a lot of money for a true 96KHz card right before I lost all my equipment anyway :-/ [/QUOTE] If you're in the market for a new sound card, this is the one I use for my tests: http://www.emu.com/products/product.asp?product=9872 It's got the best ADC of any card on the market, at least that I've seen. You can pick this card up on ebay for under $200USD. For my hardware tests, I do everything with a Tototek flash cart. When I need to sample digital data, I use test roms to dump data to RAM, and I use a Pro Action Replay to read the contents of the RAM on demand (use the trainer feature, "Slow but sure" mode, then "List possibilities"). [QUOTE] I'd love to be able to confirm all this stuff for myself, and see it we can't come up with a simpler or more logical way of implementing it. Not that it's complicated, just... odd. In my experience, odd usually means wrong, but I'm prepared to accept that in this case, it is probably just a strange piece of hardware hackery. Would like to be sure, though, because that's just "how I roll" [IMG ./images/smilies/icon_wink.gif] [/QUOTE] I understand exactly what you mean. I'm definitely interested in hearing about any simplified, more logical implementations. Personally, the think that irks me the most is the behaviour when the effective attack rate is 62 or 63. If it was just a matter of forcing the attenuation directly to 0 when the attack phase is entered with these rate values, well, that's one thing, but the "stalling" behaviour when changing to this rate during the attack phase bothers me. It just doesn't make any sense for that to occur. When I did the test, I expected to find that the attack curve would proceed with an increment value of 8. I'm sure I'm missing something there. [QUOTE] [edit] oh - while I'm here - a lot of games write to the upper 4 bits of the SSG-EG registers. I'm not sure what the programmers think they were doing this for, and I didn't test extensively, but I believe they don't do anything. Did you test this? [/QUOTE] I can quite confidently say they do absolutely nothing. Most of my test roms that iterated through patterns, including the test ROM I just posted, use an incrementing counter which allows the upper bits of the SSG-EG mode register to be set. I left some of these roms recording for a very long time (over a day once) to generate large blocks of reference data, and I never saw any change in behaviour based on what these upper bits would have been set to. I also did do some specific tests awhile back on forcing all the upper bits of the SSG-EG mode register to set, and it had no effect. ######## POST p8038 | Snake | 2009-02-27 | t386-435.html [QUOTE] Nemesis wrote:Ahh, but remember that the attenuation isn't moving past 0x200 during a repeating SSG-EG wave. [/QUOTE] Ah, this is what I meant, but I didn't explain it very well [IMG ./images/smilies/icon_smile.gif] I was assuming the attenuation starts at 0x3FF, and is decremented until it hits 0x200 - at which point it will immediately switch to decay, then immediately to sustain (provided the sustain level doesn't prevent that) - and then (almost) immediately back to attack. In this case, during the attack it inverts every sample. Values in the 0x201-0x3FF range inverted are still in the 0x201-0x3FF range, which is why I found it a bit odd to see what I was seeing, and for it to have no apparent change in amplitude. Also I was half asleep and can see the errors in this thinking now. [QUOTE] Nemesis wrote:what happens is the attenuation sits on 0x200 until the attack phase advances. [/QUOTE] Right. So the very first time after key on, it should look different. I'll check that again. [QUOTE] Nemesis wrote:One point where you do get an attenuation level over 0x200 being toggled each sample is when you first key-on an SSG-EG envelope with an attack rate less than 0x1F, if the current attenuation level is over 0x200 that is. [/QUOTE] Ah, I see we are actually on the same page [IMG ./images/smilies/icon_smile.gif] As for sound cards and tototek flash cards - I'm pretty stuck at the moment. Don't have anything with PCI slots nor anything with a parallel port, so I need to find something decent in USB flavour. [QUOTE] Nemesis wrote:I can quite confidently say they do absolutely nothing. [/QUOTE] Exactly what I thought, thanks. ######## POST p8040 | Nemesis | 2009-02-27 | t386-435.html [QUOTE] As for sound cards and tototek flash cards - I'm pretty stuck at the moment. Don't have anything with PCI slots nor anything with a parallel port, so I need to find something decent in USB flavour. [/QUOTE] Ouch. Yeah, that cuts down the options somewhat. Personally, I use an old crappy P4 box for all this stuff. I do most of my work on my laptop, and just use the test rig to transfer ROM data to the flashcart, or capture audio/video from the console. I think that's the best way to go. If you don't have an old PC lying around, you could pick one up really cheap if you look in the right place. ######## POST p8045 | Eke | 2009-02-27 | t386-435.html [QUOTE] I can see one thing that might be a problem, if I'm following your code correctly. When SSG-EG is active and the envelope is in the release phase, the attenuation level is still forced directly to 0x3FF when the release phase reaches 0x200. It looks like you're excluding all SSG-EG update steps when release phase is active, which would also exclude this behaviour. [/QUOTE] well, the attenuation level is forced to max during EG update and I considered that, in RELEASE phase, once the attenuation level has reached 0x200 and been forced to max, there is no need to check for SSG-EG update anymore until next KEY ON event... see, in advance_eg_channel, I have this: [CODE] if (SLOT->volume >= 0x200) { SLOT->volume = MAX_ATT_INDEX; SLOT->state = EG_OFF; } [/CODE] The use of EG_OFF state permits to avoid unecessary EG updates checking since the only way the EG output could change anymore after that is to issue a KEY ON. However, to be more corect, I should also force the attenuation level as soon as KEY OFF occurs, in case the attenuation level is already above 0x200... there are some cases where this could happen, especially when an attack phase is programmed. thanks for looking PS: that's make me think to another "extreme" case What would happen if a fast KEY-OFF / KEY ON occurs at the very start of the Decay phase(or Substain Phase with SL=0) , before any EG update have occur, so attenuation level is still 0 ? Doesn't that mean that the EG will immediately restart in the decay phase (or substain if SL =0) ? ######## POST p8049 | Snake | 2009-02-27 | t386-435.html [QUOTE] Nemesis wrote:Personally, the think that irks me the most is the behaviour when the effective attack rate is 62 or 63. If it was just a matter of forcing the attenuation directly to 0 when the attack phase is entered with these rate values, well, that's one thing, but the "stalling" behaviour when changing to this rate during the attack phase bothers me. It just doesn't make any sense for that to occur. [/QUOTE] I think that the attack phase simply doesn't happen at all when the rate is >=62, it's just skipped over. So when you force it to stay inside the attack state with a rate of 62, by modifying registers afterwards, it just does nothing, and has no way of getting out of the attack state. The table used for the envelope timings is undoubtedly stored in a small 4-bit ROM, and will be shared for A/D/S/R. But it never goes higher than 8, which means an immediate attack is impossible. An immediate attack is also desirable, even forgetting for a moment SSG-EG and CSM. It would have been awkward to implement for a few reasons - you'd need a seperate attack table to do this without also changing the D/S/R settings, and you'd need an extra bit in the table. Much easier to just special case it. ######## POST p8403 | vedge | 2009-04-02 | t386-435.html Hi Guys New here (but not new to FM hardware hacking). Ive been doing lots of research, and maybe this is new to you http://www7.plala.or.jp/kikekike/fm/YM3438_APL.pdf Now, this is another PDF that requires translation [IMG ./images/smilies/icon_smile.gif] Kind of awesome since thats the CMOS version of the 2612! Even in Japanese, this will help me finish up my HW 2612 VGM/MIDI synth with amplifyer output setting. ######## POST p8406 | Nemesis | 2009-04-02 | t386-435.html Holy crap! How long has that been online? I looked really hard for documentation on these chips, including the YM3438, and never came across this file. Thank you for posting this link, it's a major find. Well, this is quite simply exactly what I was after at the start. The YM3438 is the YM2612 for all intensive purposes. I've just taken a look through the file, and most of what this document contains is also covered in the YM2608 document (as expected), but this document still contains valuble information which we haven't got. For one thing, it confirms what Steve suspected; they've removed the accumulator. It also formally identifies pin 10 as the TEST pin, shows the difference in the CH3 mode flags between the YM2608 and the YM3438, gives us busy flag timing information, and gives us a description of the CH6 DAC mode. I'll start a translation of this document the same way I did the YM2608 document. Thank you again for sharing this. ######## POST p8407 | Snake | 2009-04-02 | t386-435.html [QUOTE] vedge wrote:Now, this is another PDF that requires translation [IMG ./images/smilies/icon_smile.gif] Kind of awesome since thats the CMOS version of the 2612! [/QUOTE] I don't know if this document will tell us anything we didn't already know, but it does indeed appear to be hardware and software 100% identical to the YM2612. So this is a very nice thing to have, regardless. Thanks [IMG ./images/smilies/icon_smile.gif] It does confirm the 9 bit DAC which I've been saying since the dawn of time, though. [edit] heh - Nemesis beat me to reply and seems to have noticed other nice little bits of info. Get to that translation, kind sir [IMG ./images/smilies/icon_smile.gif] ######## POST p8408 | vedge | 2009-04-03 | t386-435.html Hi Guys Was quite lucky and surprised to find it.. Just google imaged "ym3438" and that pdf was at the bottom of a page that contained a nice picture of a 3438 on a board. Just a few days ago i read through this whole thread with great interest. Cant wait for your translation magic. Cheers EDIT, btw for completeness, theres another document (hidden in the underneath directory structure) http://www7.plala.or.jp/kikekike/fm/YM3438_Cat.pdf ######## POST p8447 | Paul Jensen | 2009-04-06 | t386-435.html Hi everybody. Some of you might remember me as the author of (the not updated for a long, long time) GYM2MID and VGM2MID. Anyway, I'm very interested in this new documentation about the YM3438. I've skimmed through the latest PDF, and have a little input on the matter, mostly in the way of translation. It's too bad the scan quality isn't higher. Makes OCR pretty difficult. [IMG ./images/smilies/icon_wink.gif] [QUOTE] Nemesis wrote:For one thing, it confirms what Steve suspected; they've removed the accumulator. [/QUOTE] Are you sure about this? An accumulator is mentioned on page 33 (page 35 of the PDF): "The accumulator totals up the (9-bit) output sent to each slot of each channel one at a time and sends it to the D/A converter. Therefore, no special attention is required in terms of sound creation." I don't know if this is already common knowledge, but the document also mentions some sort of overflow protection for rate calculation (page 28 of the document, page 30 of the PDF): "'Rate' has a maximum value of 63. When a calculated value is higher than 63, the value becomes 63." "Rate" = 2R (for example, the attack rate) * Rks (the key-scaling value). Cool stuff, everybody. This thread is satisfying a lot of my long-standing curiosity with the YM2612. [IMG ./images/smilies/icon_smile.gif] ######## POST p8469 | Snake | 2009-04-07 | t386-435.html This is probably an error copied over from some other document. A lot of the documentation was probably copied then edited where necessary, same is probably true of most of Yamaha documentation, given the huge similarities with a lot of their chips. But we know this stuff in the YM2612 works differently from other Yamaha chips. The Rate thing was mentioned early on in the thread, and was well known way before that [IMG ./images/smilies/icon_smile.gif] ######## POST p8494 | Lord Nightmare | 2009-04-12 | t386-450.html YM2612/YM3438 are not the only chips which do time-multiplexing of the output channels rather than using a 'real' accumulator to mix them (the 3438 DOES use multiplexing, right?): The YM2413 OPLL and the Konami VRC7 (which is a reduced-ym2413-on-a-famicom-mapper-chip, almost certainly manufactured by yamaha for konami) both do it too. Other 'internal use only' chips such as the YM3427 (a vastly-reduced-pin-count SSG-plus-extras, possibly AY-3-8930 (yes, 8930, not 8910) compatible, chip used on the PSS-80 keyboard) may do so as well. LN ######## POST p8556 | GManiac | 2009-04-19 | t386-450.html I made some tests to get amplitude-frequency characteristic of console's sound and then I remember one strange thing (see below) and made one more test. Here are sources and binaries (2.5 kb) For getting AFC I firstly wrote demo ym_67.asm (octave 6, multiplier 7), which makes frequencies up to 23080 Hz, but AFC looked unnaturaly in 48 kHz oscillogram (because it can't handle 23 kHz sinus and more high frequencies absent), then I made ym_77.asm (octave 7, multiplier 7) - for 46161 Hz. This is 96 kHz oscillogram from my European MD1: [IMG http://shedevr.org.ru/ghost/ym2612/md1_eur_46160_osci_6621.png] You can see that the more high frequency the more it's filtered. But that's not all. Long ago I noticed that YM doesn't produce pure sinus, it produces multiple harmonics of it. If you play frequency F, you will also get frequencies 2F, 3F and so on. Maybe you noticed this fact too. Also when I recorded tunes from HW at 96 kHz I noticed that the high part of spectrum (40+ kHz) is sort of mirror of its low part. It's not bug of my ADC because it records high freqs correctly (for example, 37 kHz from PSG). Here's spectrogram of previous sweep: [IMG http://shedevr.org.ru/ghost/ym2612/md1_eur_46160_spec.jpg] This is interesting sight [IMG ./images/smilies/icon_smile.gif] You see multiple harmonics of every frequencies (they look like the web) and you see freqs' reflection. Our main harmonic and its reflection cross at point of 26390 Hz. On the left side at the top there is corner made by two lines. Its frequency is 48 kHz and its reflection is at 4780 Hz. And on the right side main harmonic is 46160 Hz (our program produced it) and its reflection is 6620 Hz. If we sum main and "mirror" frequencies, we will get 52780 Hz - it's base frequency of YM. To the left of that "corner" there is phantom of low frequencies. It starts from 43220 Hz, that is 96000 - 52780. I dunno what causes this phantom, but it's present. This reflection certainly is not result of my ADC, you may see that after 26390 Hz (point of crossing) "main harmonic" become more weak than its reflection and sound sweeps to low freqs. It can be heard right in headphones. So, for YM it doesn't matter, do you generate freq X or (MAX-X) (MAX = 52781 or 53267), result will be the same. At first pic you can see red line showing one volume level. At the right there is 46160 Hz (final freq of our program) and at the left is... 6620 Hz! One more pic to show multiple harmonics: [IMG http://shedevr.org.ru/ghost/ym2612/1000Hz_96.png] You see that after 5th repetition even harmonics are more weak than odd ones. And then, 13 is weaker than 11 and 15, 19 is weaker than 17 and 21 and so on. At the right side you may see 3 kHz and low reflections of its repetitions: 1780 (52780 - 3000*17), 7780, 13780, 19780... Why YM can't generate pure sinus, what's the reason of multiple harmonics and what causes this reflection? Can anyone provide recording at 192+ kHz or its spectrogram? ######## 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] UINT32 fnum_lfo = ((block_fnum & 0x7f0) >> 4) * 32 * 8; INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + pms + LFO_PM ]; if (lfo_fn_table_index_offset) /* LFO phase modulation active */ { /* retrieve BLOCK register value */ UINT8 blk = (block_fnum >> 11) & 7; /* apply phase modulation to FNUM register value */ UINT32 fn = (block_fnum + (UINT32)lfo_fn_table_index_offset) & 0x7ff; /* recalculate keyscale code */ int kc = (blk<<2) | opn_fktable[fn >> 7]; /* recalculate (frequency) phase increment counter */ int fc = (ym2612.OPN.fn_table[fn]>>(7-blk)) + SLOT->DT[kc]; /* (frequency) phase overflow (max. 17 bits) */ if (fc < 0) fc += ym2612.OPN.fn_max; /* update phase */ SLOT->phase += (fc * SLOT->mul) >> 1; } else /* LFO phase modulation = zero */ { SLOT->phase += SLOT->Incr; } [/CODE] 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] static const UINT8 lfo_pm_output[7*8][8]={ /* 7 bits meaningful (of F-NUMBER), 8 LFO output levels per one depth (out of 32), 8 LFO depths */ /* FNUM BIT 4: 000 0001xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 2 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 3 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 4 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 5 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 6 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 7 */ {0, 0, 0, 0, 1, 1, 1, 1}, /* FNUM BIT 5: 000 0010xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 2 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 3 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 4 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 5 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 6 */ {0, 0, 0, 0, 1, 1, 1, 1}, /* DEPTH 7 */ {0, 0, 1, 1, 2, 2, 2, 3}, /* FNUM BIT 6: 000 0100xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 2 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 3 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 4 */ {0, 0, 0, 0, 0, 0, 0, 1}, /* DEPTH 5 */ {0, 0, 0, 0, 1, 1, 1, 1}, /* DEPTH 6 */ {0, 0, 1, 1, 2, 2, 2, 3}, /* DEPTH 7 */ {0, 0, 2, 3, 4, 4, 5, 6}, /* FNUM BIT 7: 000 1000xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 2 */ {0, 0, 0, 0, 0, 0, 1, 1}, /* DEPTH 3 */ {0, 0, 0, 0, 1, 1, 1, 1}, /* DEPTH 4 */ {0, 0, 0, 1, 1, 1, 1, 2}, /* DEPTH 5 */ {0, 0, 1, 1, 2, 2, 2, 3}, /* DEPTH 6 */ {0, 0, 2, 3, 4, 4, 5, 6}, /* DEPTH 7 */ {0, 0, 4, 6, 8, 8, 0xa, 0xc}, /* FNUM BIT 8: 001 0000xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 1, 1, 1, 1}, /* DEPTH 2 */ {0, 0, 0, 1, 1, 1, 2, 2}, /* DEPTH 3 */ {0, 0, 1, 1, 2, 2, 3, 3}, /* DEPTH 4 */ {0, 0, 1, 2, 2, 2, 3, 4}, /* DEPTH 5 */ {0, 0, 2, 3, 4, 4, 5, 6}, /* DEPTH 6 */ {0, 0, 4, 6, 8, 8, 0xa, 0xc}, /* DEPTH 7 */ {0, 0, 8, 0xc,0x10,0x10,0x14,0x18}, /* FNUM BIT 9: 010 0000xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 2, 2, 2, 2}, /* DEPTH 2 */ {0, 0, 0, 2, 2, 2, 4, 4}, /* DEPTH 3 */ {0, 0, 2, 2, 4, 4, 6, 6}, /* DEPTH 4 */ {0, 0, 2, 4, 4, 4, 6, 8}, /* DEPTH 5 */ {0, 0, 4, 6, 8, 8, 0xa, 0xc}, /* DEPTH 6 */ {0, 0, 8, 0xc,0x10,0x10,0x14,0x18}, /* DEPTH 7 */ {0, 0,0x10,0x18,0x20,0x20,0x28,0x30}, /* FNUM BIT10: 100 0000xxxx */ /* DEPTH 0 */ {0, 0, 0, 0, 0, 0, 0, 0}, /* DEPTH 1 */ {0, 0, 0, 0, 4, 4, 4, 4}, /* DEPTH 2 */ {0, 0, 0, 4, 4, 4, 8, 8}, /* DEPTH 3 */ {0, 0, 4, 4, 8, 8, 0xc, 0xc}, /* DEPTH 4 */ {0, 0, 4, 8, 8, 8, 0xc,0x10}, /* DEPTH 5 */ {0, 0, 8, 0xc,0x10,0x10,0x14,0x18}, /* DEPTH 6 */ {0, 0,0x10,0x18,0x20,0x20,0x28,0x30}, /* DEPTH 7 */ {0, 0,0x20,0x30,0x40,0x40,0x50,0x60}, }; [/CODE] ######## 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] case 0: /* 0xa0-0xa2 : FNUM1 */ { UINT32 fn = (((UINT32)((ym2612.OPN.ST.fn_h)&7))<<8) + v; UINT8 blk = ym2612.OPN.ST.fn_h>>3; /* keyscale code */ CH->kcode = (blk<<2) | opn_fktable[fn >> 7]; /* phase increment value (17 bits) */ CH->fc = ym2612.OPN.fn_table[fn*2]>>(7-blk); /* store fnum in clear form for LFO PM calculations */ CH->block_fnum = (blk<<11) | fn; /* phase increment value (20 bits) should be updated */ CH->SLOT[SLOT1].Incr=-1; break; } case 1: /* 0xa4-0xa6 : FNUM2,BLK */ ym2612.OPN.ST.fn_h = v&0x3f; break; [/CODE] 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] ym2612.OPN.pan[ c*2 ] = (v & 0x80) ? ~((1 << 7) - 1) : 0; ym2612.OPN.pan[ c*2+1 ] = (v & 0x40) ? ~((1 << 7) - 1) : 0; [/CODE] [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] if current channel is channel 6 in PCM mode output PCM byte to DAC if 4*NCYCLES_PER_OPERATOR cycles passed move to next channel else run SSG-EG for current channel if NCYCLES_PER_EGUPDATE cycles passed update EG for current channel output EG for current channel run phase generator for current operator run LFO for current operator run output generator for current operator if current operator is output send current operator output to DAC else send silence (is that what the low outputs shown in the image in post 7516 means?) if NCYCLES_PER_OPERATOR cycles passed move to next operator if finished with this channel move to next channel [/CODE] 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] if current channel is channel 6 in PCM mode output PCM byte to DAC if 4*NCYCLES_PER_OPERATOR cycles passed move to next channel else run SSG-EG for current channel if NCYCLES_PER_EGUPDATE cycles passed update EG for current channel output EG for current channel run phase generator for current operator run LFO for current operator run output generator for current operator if current operator is output send current operator output to DAC else send silence (is that what the low outputs shown in the image in post 7516 means?) if NCYCLES_PER_OPERATOR cycles passed move to next operator if finished with this channel move to next channel [/CODE] 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] digital data -> DAC -+-> Switch -> L Output | ^ | +--LR registers | V +-> Switch -> R Output [/CODE] ######## 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] ym2612.OPN.fn_table[i] = (UINT32)( (double)i * 32 * freqbase * (1<<(FREQ_SH-10)) ); [/CODE] and how the 17-bit phase increment value is calculated from FNUM and BLOCK values: [CODE] CH->fc = ym2612.OPN.fn_table[fn*2]>>(7-blk); [/CODE] 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] /* There are 128 LFO steps */ ym2612.OPN.lfo_cnt = ( ym2612.OPN.lfo_cnt + 1 ) & 127; /* triangle */ /* AM: 126 to 0 step -2, 0 to 126 step +2 */ if (ym2612.OPN.lfo_cnt<64) ym2612.OPN.LFO_AM = 126 - ((ym2612.OPN.lfo_cnt&63) * 2); else ym2612.OPN.LFO_AM = ym2612.OPN.lfo_cnt * 2; [/CODE] instead of doing [CODE] /* There are 128 LFO steps */ ym2612.OPN.lfo_cnt = ( ym2612.OPN.lfo_cnt + 1 ) & 127; /* triangle */ /* AM: 0 to 126 step +2, 126 to 0 step -2 */ if (ym2612.OPN.lfo_cnt<64) ym2612.OPN.LFO_AM = ym2612.OPN.lfo_cnt * 2; else ym2612.OPN.LFO_AM = 126 - ((ym2612.OPN.lfo_cnt&63) * 2); [/CODE] 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] for each clock pulse { send out current operator's EG output // I know this isn't literally what the hardware does but eh if three cycles passed { recalculate all EG outputs } } [/CODE] or [CODE] for each clock pulse { send out current operator's EG output do 1/3 of the operation for the current EG output being calculated // oversimplification of what actually is going on but you get what I mean if done calculating this EG output { go to next } } [/CODE] 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] |\ |\ | \ | \ | / | / |/ |/ [/CODE] instead of this : [CODE] |\ |\ | \ | \ | \ | \ | \| \ [/CODE] 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] -256Vcc/256 for -256 ($100) -254Vcc/256 for -255 ($101) ... -2Vcc/256 for -129 ($17F) 0Vcc/256 for -128 ($180) +2Vcc/256 for -127 ($181) ... +250Vcc/256 for -3 ($1FD) +252Vcc/256 for -2 ($1FE) +254Vcc/256 for -1 ($1FF) [/CODE] 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] //Start of very fast ladder code while( --sampleFrames >= 0 ) // sampleFrames = how many samples to process (may change). repeat (loop) that many times { sineout = *in; // max -1 +1 //ladder condition, VCC or GROUND if (sineout<-0.009f) {ladder=-0.02f; // output is almost 50 times lower than the clean signal, can be adjusted or optionally controlled.. } else ladder=0.0f; // grounded no signal *ladder_out = ladder; //then filter this before adding to sineout ladder_out++; in++; } [/CODE] 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] - wait while BUSY become 0 - write register index in port 0/2 then immediately write register value in port 1/3 [/CODE] Does it should always work ? ######## POST p27124 | Sauraen | 2015-10-05 | t386-720.html [QUOTE] Stef wrote: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] [/QUOTE] Thanks! I'm having a lot of fun with this too. [IMG ./images/smilies/icon_smile.gif] [QUOTE] 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 ? [/QUOTE] I took a look at the BUSY signal and associated stuff, and this is what I've found so far. -- The signal that appears in bit 7 of the default read register is NOT the same as the signal that appears on the Test pin when it's configured as an output (by $2C:7 = 0). -- Neither signal affects any logic between the external I/O bus and the chip-level registers. This includes all the $2X registers, and also the address register and data register that all other addresses use. (I.e. when you write $78 to $52, it immediately stores $52 in the address register and $78 in the data register, and then when that operator--determined by the current address register--comes around in the circular buffers, it actually changes the value to whatever's in the data register.) This has the following results: The only limit on how fast you can write to the $2X registers is the YM2612's internal clock. Certainly it would need to have one cycle (6x 68000 clock cycles) for it to catch anything; I'd give it at least 2 (12) or maybe 3 (18), but hardware testing on this point would be great. Writing the address and writing the data should take the same amount of time. Writing data doesn't unlatch the address, you can keep writing data over and over to the last address. (I'm assuming this might be useful for the DAC.) Of course writing to the DAC faster than the YM2612's sample rate (external clock / (6*24)) will be useless. You can write to a $2X register while you're waiting for the channel/operator register write to complete. (EDIT: this is unfortunately not true) If you write to another channel/operator register while the last one is still pending, the previous write will be lost--it won't block the new write. The one exception is that if you write one address and data, and then you write a new address and data, but between writing the new address and writing the new data the new address's register comes along, it will write the old data in the new address (and then 24 cycles later the new data at that address, assuming the address didn't change before this). I'm just being specific here because someone might think "for any write, EITHER the chip misses it completely OR it gets it"--but this is a circumstance in which it gets the write wrong. -- The signal that appears on the Test pin originates from a "master sequencer" control unit (other outputs of which, for example, are the control signals for the algorithm in the operator unit, and a bunch more which I haven't traced yet). This control unit is located at the upper right of the PG and has a sizable decoder "table" and a couple smaller tables. (Sorry, Nemesis--this is a table you're not going to have worked out every bit of in your source code already! [IMG ./images/smilies/icon_wink.gif] ) Some of the outputs go directly into the interconnect, others go into push-pull buffers and then are routed throughout the chip. The Test pin output signal is one of these--it also ends up going to the PG, one of the timers, the channel register file, and probably a couple other places. I haven't traced the rest yet--hopefully more info coming soon. -- I hope I'm wrong about this, but this is what it looks like as best I can tell: the signal that appears on the default read register bit 7 (i.e. "BUSY") comes from a small timer/counter whose only inputs are the two clocks [the chip has clocks of both polarities throughout], system reset, and the "please read data off bus into registers" signal. The counter has 5 or 6 stages and is probably an asynchronous counter rather than a shift register, meaning it counts 32 or 64 cycles (of the internal clock, which is divided by 6 from the external clock). Since there's no other inputs, this means the timer starts when you write data and BUSY goes high, counts a certain number of cycles, and then clears BUSY. I'm guessing it's 5-bit and 32 cycles, because 24 cycles would be enough to ensure that all the operator registers have been updated. (Of course these are internal clock cycles, which is the external [68000] clock divided by 6.) I say I hope I'm wrong because if this is true, it means: The BUSY bit doesn't actually tell you any useful information about the chip's internal state, it's just a dumb timer for a fixed interval after a write. You might as well do timing in software. It implies that "the chip is busy", but in fact there's a lot you can do with the chip during that time (most importantly DAC writes). It overestimates the amount of time needed by 33% (32 instead of 24 cycles). 32x6=192 68000 cycles (about 90 Z80 cycles) is a lot of wasted time! I really hope it's not 64 internal cycles for some dumb reason! It makes the sound driver wait more than one sample between writes (assuming the sound driver does wait for it). This means the sound driver could never play a sample at the full YM2612 sampling rate, let alone do that and play other music at the same time. Can someone please test writing to various registers and counting Z80 cycles until the BUSY bit (bit 7 of the read register) goes low? Your counting doesn't have to be very accurate, one count every few Z80 cycles is plenty. Just check and see whether it's the same for a chip register, a channel register, and an operator register; and do the test a few times each, to make sure it's constant in each case. ######## POST p27127 | TmEE co.(TM) | 2015-10-05 | t386-720.html From my tests if you write to DAC faster than half the YM sample rate you get missed writes, sound gets noticably worse at that point. When you wait for busy you get roughly 22KHz sample rate when waiting for the DAC on some chips and roughly 32KHz on others (that is what i recall someone saying, I no longer remember results from my own tests). Some writes such as TLs seem to take longer to process than other stuff, I do full software timing in my old sound driver and I always had to have longer delays on TL writes or the data got mangled and I got wrong output. Same deal with the LR flags register. Others seemed to work faster. It doesn't make too much sense on hardware level though, at least if I designed the thing it wouldn't work like that [IMG ./images/smilies/icon_razz.gif] From what I have observed if you write too fast to the chip the new write will overwrite the old data messing up previous operation. Your research seems to confirm it. The busy flag SHOULD tell you when the chip is ready to grab new data. I would have thought the busy flag is cleared every sample or so. I guess it isn't the case... ######## POST p27133 | Stef | 2015-10-05 | t386-720.html Strangely in my case i never test the BUSY flag for DAC write and writing above 22 Khz does seems possible. Actually i logged output between 22 Khz DAC output and 32 Khz DAC output and i observed a real difference. Still it's quite difficult to say how much was actually played by the YM2612 DAC as my notebook microphone jack is pure shit but i can definitely saw the 32 Khz signal was better and more defined than the 22 Khz. You can easily do the test by yourself by using the "sound" sample given in SGDK, the first driver test allow you to play the same sample at different output rate (from 8Khz to 32Khz). About the BUSY flag itself, well in my case i never measured how much time it stay up but if it counts one sample for each write (even after address register write ?) then that is a pure waste of time :-/ What i can say is that the effective process time by the YM2612 is dependent from the register you are actually writing (as TmEE said). I observed than some registers requires no more than ~25 Z80 cycles to be processed but others can take a long than ~70-80 Z80 cycles... so now to be safe i am always testing the busy flag. I would say that a good practice to write YM register is to always check BUSY flag to be 0 first. Then if you need to write severals 2x registers you can write them really quickly with maybe 2 NOP to be safe between each write. When you write a specific register you write its address then you can immediately write its value, no need to check the BUSY flag between the address and value write... If that work then that is already a good thing to know [IMG ./images/smilies/icon_smile.gif] You said that : <> But if you do that, you can change the address register before the write to channel/operator occurred so the value is lost (or happen in the 2X register) ? Oh and by the way, internal clock of YM is not Z80 clock but 68000 clock (i just said that in regard of the Z80 cycle informations i gave) =) ######## POST p27138 | Sauraen | 2015-10-05 | t386-720.html [QUOTE] TmEE co.(TM) wrote:Some writes such as TLs seem to take longer to process than other stuff, I do full software timing in my old sound driver and I always had to have longer delays on TL writes or the data got mangled and I got wrong output. Same deal with the LR flags register. Others seemed to work faster. It doesn't make too much sense on hardware level though, at least if I designed the thing it wouldn't work like that [/QUOTE] [QUOTE] The busy flag SHOULD tell you when the chip is ready to grab new data. I would have thought the busy flag is cleared every sample or so. I guess it isn't the case... [/QUOTE] Haven't checked yet, but this is how I think it is: - All $2X registers will update within one internal clock. - All operator registers update once every 24 internal clocks. But you never know where in the cycle you're going to be, so you have to wait at least 24 clocks in all cases to be sure. - Some channel registers are like the operator registers and only update once every 24 clocks. Others update every 6 clocks. Hopefully I'll figure this out soon. The BUSY flag/bit does indeed tell you that the chip is ready--it just waits longer than the maximum necessary, so if you wait for it you're guaranteed to not mess anything up. [QUOTE] Stef wrote:About the BUSY flag itself, well in my case i never measured how much time it stay up but if it counts one sample for each write (even after address register write ?) then that is a pure waste of time :-/ [/QUOTE] No, it's triggered by data write, you can write addresses all day and the BUSY flag won't be affected. But yes, it waits more than one sample, since one sample is 24 clocks and it waits 32. One other thing to mention: it's possible they might have changed the BUSY flag in the YM3438 to actually only wait 24 clocks--I took a quick look at the die of that chip, and it's completely different, almost unrecognizable. The YM2612 is not only similar to the YM2203, they actually copied-and-pasted blocks from the YM2203 to the YM2612--in fact the position of some of the control units in the operator unit of the YM2612 matches where they were in the YM2203, even though this positioning doesn't make sense anymore in the YM2612. But anyway, both of these chips are built in NMOS, not CMOS (there's no P-channel FETs, and they vary transistor lengths rather than widths to control current and timing--breaking all the rules I'm learning in VLSI class!), so when the chip was redesigned in CMOS, it had to be completely redone from the ground up, they couldn't keep a single register. If they indeed changed the BUSY flag timing, this might explain how that one track in that one game plays faster on one system than another. [QUOTE] I would say that a good practice to write YM register is to always check BUSY flag to be 0 first. Then if you need to write severals 2x registers you can write them really quickly with maybe 2 NOP to be safe between each write. When you write a specific register you write its address then you can immediately write its value, no need to check the BUSY flag between the address and value write... If that work then that is already a good thing to know [/QUOTE] I would say this: Always give at least 1 YM2612 internal cycle (about 4 Z80 cycles) between any writes to the chip. Don't ever check the BUSY flag between writing address and data, it'll never be set anyway (unless it was already set before you wrote the address). Don't check the BUSY flag if the last address written was a $2X register. For all other writes, do software timing of just over 24 YM2612 internal cycles (about 70 Z80 cycles); this will save you about 25% from waiting for BUSY (about 90 Z80 cycles). Could someone please check this on hardware? I especially want to see what the minimum timing is for $2X writes and between address and data for all writes. [QUOTE] You said that : <> But if you do that, you can change the address register before the write to channel/operator occurred so the value is lost (or happen in the 2X register) ? [/QUOTE] I did mean that, but after thinking about it I take it back. The address register and data register for all other chip writes are at the same "level" as the $2X registers. So the access time for any of them is the same, and there ordinarily would be no reason you couldn't put an address and data in the operator/channel address register and data register, and then write to another $2X register immediately afterward. However, unfortunately, the operator/channel address register is enabled by any address which is not $0X. If I was designing it, I would have made it enabled by any address not $0X or $2X (would have taken slightly less logic than they actually have)--but the way it is, if you write another $2X register the operator/channel address register will get overwritten with that value as well. Sorry! [QUOTE] Oh and by the way, internal clock of YM is not Z80 clock but 68000 clock (i just said that in regard of the Z80 cycle informations i gave) =) [/QUOTE] Fixed, thanks! Dumb mistake, I've been playing with hardware clock circuits for these chips for the past few days, I know their frequencies. [IMG ./images/smilies/icon_smile.gif] ######## POST p27145 | Stef | 2015-10-05 | t386-720.html [QUOTE] Sauraen wrote: Haven't checked yet, but this is how I think it is: - All $2X registers will update within one internal clock. - All operator registers update once every 24 internal clocks. But you never know where in the cycle you're going to be, so you have to wait at least 24 clocks in all cases to be sure. - Some channel registers are like the operator registers and only update once every 24 clocks. Others update every 6 clocks. Hopefully I'll figure this out soon. ... No, it's triggered by data write, you can write addresses all day and the BUSY flag won't be affected. But yes, it waits more than one sample, since one sample is 24 clocks and it waits 32. I would say this: ... Always give at least 1 YM2612 internal cycle (about 4 Z80 cycles) between any writes to the chip. Don't ever check the BUSY flag between writing address and data, it'll never be set anyway (unless it was already set before you wrote the address). Don't check the BUSY flag if the last address written was a $2X register. For all other writes, do software timing of just over 24 YM2612 internal cycles (about 70 Z80 cycles); this will save you about 25% from waiting for BUSY (about 90 Z80 cycles). [/QUOTE] Thanks, definitely gold informations for anyone developing Z80 driver [IMG ./images/smilies/icon_wink.gif] You sometime need to write a lot of data to the YM2612 so saving cycles for write is important ! [QUOTE] One other thing to mention: it's possible they might have changed the BUSY flag in the YM3438 to actually only wait 24 clocks--I took a quick look at the die of that chip, and it's completely different, almost unrecognizable. The YM2612 is not only similar to the YM2203, they actually copied-and-pasted blocks from the YM2203 to the YM2612--in fact the position of some of the control units in the operator unit of the YM2612 matches where they were in the YM2203, even though this positioning doesn't make sense anymore in the YM2612. But anyway, both of these chips are built in NMOS, not CMOS (there's no P-channel FETs, and they vary transistor lengths rather than widths to control current and timing--breaking all the rules I'm learning in VLSI class!), so when the chip was redesigned in CMOS, it had to be completely redone from the ground up, they couldn't keep a single register. If they indeed changed the BUSY flag timing, this might explain how that one track in that one game plays faster on one system than another. [/QUOTE] I observed than write processing time on YM3438 is actually *slower* than YM2612 ! I got some issues on my MD2 with my initial driver implementation because i only tested it on MD1 for a long time :-/ ######## POST p27153 | TmEE co.(TM) | 2015-10-06 | t386-720.html 26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. The game Hellfire has 2x slower music on MD2 than on MD1. The game spams YM with unnecessary writes and is being polite about it (waits for busy). Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). ######## POST p27154 | Sik | 2015-10-06 | t386-720.html Suddenly using blind cycle counting instead of BUSY in Echo is looking like a scaringly good decision. Also this reminds me, isn't it possible for the 68000 to read BUSY before it gets the chance to get set, at least on the YM2612? ######## POST p27155 | Sauraen | 2015-10-06 | t386-720.html [QUOTE] Stef wrote: Thanks, definitely gold informations for anyone developing Z80 driver [IMG ./images/smilies/icon_wink.gif] You sometime need to write a lot of data to the YM2612 so saving cycles for write is important ! [/QUOTE] Thanks, but I hope it's right! This is why I keep asking for someone to write some tests and run them on real hardware. I will be able to do so soon with a discrete YM2612 in a prototype board for my synth, but I don't have a Genesis flash cart nor do I know Z80 or 68000 ASM. [QUOTE] I observed than write processing time on YM3438 is actually *slower* than YM2612 ! I got some issues on my MD2 with my initial driver implementation because i only tested it on MD1 for a long time :-/ [/QUOTE] [QUOTE] The game Hellfire has 2x slower music on MD2 than on MD1. The game spams YM with unnecessary writes and is being polite about it (waits for busy). Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). [/QUOTE] Interesting. I have two different revision Genesis 2's (US models), and I will probably end up with a model 1 at some point. I also plan to throw a discrete YM3438 into the synth board at some point and see what happens. Also, that seems to answer the question at least in a general way. YM3438 has a longer BUSY delay because it has a longer internal register write delay as well. So the sound driver waits for BUSY, ends up waiting longer (maybe missing every other timer rollover or something?), and ends up slower. [QUOTE] TmEE co.(TM) wrote:26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. [/QUOTE] That may not be entirely true. While it may be that there's some weirdness with the chip that causes the DAC value to be outputted only once every other sample (haven't seen this yet), I think what's more likely is that since this is roughly half the sampling rate, if you play music between this and the full sampling rate, it will play some samples once and some twice, which will introduce a whole bunch of aliasing at basically random frequencies. However, it should be that if you play samples at the full sampling rate, exactly (68000 clock) / (24*6), or exactly 144x 68000 instructions per sample, it will sound crystal clear. (Well maybe that's a stretch--it's still 8-bit, or 9-bit if you use the extra bit from $2C...) [QUOTE] Sik wrote:Suddenly using blind cycle counting instead of BUSY in Echo is looking like a scaringly good decision. [/QUOTE] As long as the BUSY delay is indeed longer than it needs to be, then yes. [QUOTE] Also this reminds me, isn't it possible for the 68000 to read BUSY before it gets the chance to get set, at least on the YM2612? [/QUOTE] Yes, if you violate the address/data timing requirements for the YM2612! Remember the internal clock is divided by 6 from the 68000 clock, so it takes at least 6 cycles if not 12 or so for the YM2612 to respond to its I/O bus. If you write a data byte and manage to "read" the data bus again in 3 or 4 68000 cycles, whatever data you read will be completely invalid. But as far as its internal clock, BUSY should get set on the same cycle as the data register gets loaded internally (which is probably the cycle after the I/O bus was written), and it should be externally readable on the cycle after that. So that could be up to 18 68000 cycles--so I could easily see how the status register could be read before BUSY was set. ######## POST p27159 | Eke | 2015-10-06 | t386-720.html From what I remember, Hellfire sometimes reads the FM status (timers and busy flags) from $4001-$4003 instead of just $4000 as recommended so maybe some (or all) of those flags can only be read correctly when A0 is low ? ######## POST p27161 | Stef | 2015-10-06 | t386-720.html [QUOTE] Sik wrote: Also this reminds me, isn't it possible for the 68000 to read BUSY before it gets the chance to get set, at least on the YM2612? [/QUOTE] When i designed my sound driver i first though it was possible but then i realized i was trying to read the busy flag from port 1/2/3 instead of port 0. Even from the 68000 i am not sure you can go that fast so you can read the busy flag before it actually turns to 1, also i never saw any Sega technical information about it and i believe that an issue like this one would have been probably notified by Sega engineers back in time. [QUOTE] 26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. [/QUOTE] I don't know how you achieved to obtain these result as myself i never experienced worse sound by going higher... i have to admit i never tried going above 32 Khz anyway, 32 Khz is already quite high and eat rom very quickly :p [QUOTE] Also, that seems to answer the question at least in a general way. YM3438 has a longer BUSY delay because it has a longer internal register write delay as well. So the sound driver waits for BUSY, ends up waiting longer (maybe missing every other timer rollover or something?), and ends up slower. [/QUOTE] That is the problem, if we want to maintain compatibility with the MD2 we still have to wait for that BUSY flags as we don't know how slow is the YM3438 :-/ And maybe that unlike the YM2612, it does even requires a small wait between the address write and the value write (i hope that is not the case !) ######## POST p27178 | Sik | 2015-10-07 | t386-720.html Echo just assumes 19 Z80 cycles is enough. It seems to work for the most part (the only problematic part is instrument loading where it bangs 29 writes in a row, but moving 1 or 2 more instructions in the loop does the job). [QUOTE] Stef wrote:also i never saw any Sega technical information about it and i believe that an issue like this one would have been probably notified by Sega engineers back in time. [/QUOTE] That means nothing, most addenums are still missing. Also the fact we're still missing the documentation for the 3 button controller should say something. ######## POST p27181 | Stef | 2015-10-07 | t386-720.html [QUOTE] Sik wrote:Echo just assumes 19 Z80 cycles is enough. It seems to work for the most part (the only problematic part is instrument loading where it bangs 29 writes in a row, but moving 1 or 2 more instructions in the loop does the job). [/QUOTE] 19 cycles is enough for what ? Depending the register wrote on YM2612 you actually need to wait *a lot more* than 19 Z80 cycles. ######## POST p27188 | mikejmoffitt | 2015-10-07 | t386-720.html [QUOTE] TmEE co.(TM) wrote: Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). [/QUOTE] Given that the discrete YM3438 has different behavior than the ASIC one, and the ASIC one is further different from the YM3438 design, are we sure the ASIC one isn't actually a Sega fixed-and-improved YM2612 core? ######## POST p27193 | TmEE co.(TM) | 2015-10-07 | t386-720.html Service manuals say "YM3438" in the ASIC diagram. ######## POST p27197 | Sauraen | 2015-10-08 | t386-735.html [QUOTE] mikejmoffit wrote:Given that the discrete YM3438 has different behavior than the ASIC one, and the ASIC one is further different from the YM3438 design, are we sure the ASIC one isn't actually a Sega fixed-and-improved YM2612 core? [/QUOTE] The YM2612 is implemented in depletion-mode NMOS ratioed logic with dynamic gates. It's an old process that is cheaper to fabricate (though more difficult to design), but it has a static power consumption--if the chip is running and you stop the clock, it will still draw a significant amount of power. I haven't checked myself, but based on others' info the YM3438 is probably implemented in CMOS with dynamic gates, which is roughly the same process used in modern digital logic (CPUs, etc.). It has extremely low static power consumption, and hence a lower overall power consumption. I would be extremely surprised if the VDP was implemented in the power-hungry NMOS process, simply because it would get too hot. So unless Sega designed a custom YMXXXX chip that emulated the two Yamaha chips--instead of licensing the YM3438 design--what's in the VDP is basically a YM3438. However, there's no reason Sega couldn't have modified it, especially "outer" things like the way the address/data bus works. I will be testing discrete YM2612 and discrete YM3438 in my synth. ######## POST p27198 | Sik | 2015-10-08 | t386-735.html I thought the ASIC variant was somewhere between the YM2612 and YM3438 (since it has quirks from both). ######## POST p27199 | mikejmoffitt | 2015-10-08 | t386-735.html Well, given the nature of NMOS devices and static power consumption, that's actually what led me to wonder if it was a 2612 in the VDP in the first place. My CDX's VDP gets pretty warm just from regular use. Nothing wrong with the 5V rail, it's steady at 5V. Even still, if Sega's diagrams say it's a YM3438 then I'd be inclined to believe it's a 3438, or a Sega variant. It is very strange that the Sega-YM3438 would behave so differently compared to the discrete one. It's not impossible for Sega to have re-implemented the YM2612 in a CMOS process, realize that they've made something much like the YM3438, and call it the YM3438 in a logic diagram as a result. That's a bit outlandish, but it's just so weird to have it not be quite one chip and not quite the other. ######## POST p27202 | TmEE co.(TM) | 2015-10-08 | t386-735.html The VDP should be NMOS, and it does get hot, hotter than the NMOS 68K CPU in the machine. I even put a heatsink on it. The ASIC in MD only gets warm, and it has a bunch of stuff packed in. ######## POST p27204 | Sauraen | 2015-10-09 | t386-735.html [QUOTE] mikejmoffitt wrote:Well, given the nature of NMOS devices and static power consumption, that's actually what led me to wonder if it was a 2612 in the VDP in the first place. [/QUOTE] [QUOTE] TmEE co.(TM) wrote:The VDP should be NMOS, and it does get hot, hotter than the NMOS 68K CPU in the machine. [/QUOTE] Well then... Maybe what's going on is that they put a YM2612 in there, but messed with the I/O bus to integrate it with the bus arbiter and everything else in that chip. And of course then they slightly changed some timing thing, and voila. But if someone would just decap the VDP already, we would know for sure! We wouldn't even need ultra-high-res photography--just enough to pick out the OPN2 block and match it to one or the other. ######## POST p27306 | Sauraen | 2015-10-15 | t386-735.html Potentially good news! As a graduate student in electrical engineering at a major research university in the US, I know people with access to some pretty good equipment. I'm actually getting independent study research credit for my work with the YM2612, so I can get access to a micron-level optical microscope used by the semiconductor light source group. I asked about decapsulation and the professor who'd give me access said I can use the microscope, but there's no way I'll be able to get access to the chemicals needed to eat away the plastic. However, I have a buddy in the department who has a lot of cool toys, including a CO2 laser which he says can be theoretically used for decapsulation (especially if the chip doesn't have to work afterwards). He's going to test this on a few other chips, and then we'll test this on a VDP ASIC (I have a broken US Genesis II VA1.8 with the chip 315-5660-02). If this works well and we get some nice pictures, I'd be happy to decap chips for other people for free if they send them to me. Of course the chips will be destroyed and you won't get them back. ######## POST p27310 | Nemesis | 2015-10-16 | t386-735.html Wow, seriously awesome work Sauraen! I'm especially excited by the work you did figuring out the test register, being able to read the digital output of individual operators is absolutely golden. I'm going to be spending hours going over your notes and pictures with interpreting the die shots too, this is something I seriously want to learn how to do. If you can find it somewhere on the die, see if you can figure out what data tables/process is involved in the FM modulation feature. There are still unknowns in that process. In terms of the decapping, yes please! I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it. I had some success and was working out the right process (and trying to take it slow so I didn't kill myself), but in the end I had to shelve it due to lack of time, but if you have access to professional gear, the work you could do on this could open up a lot of possibilities. I'm happy to supply hardware, and the VDP would be on the top of the list, followed closely by the I/O and bus arbiter chips. There's a few extra chips for other systems I'd like to slip your way too if you get this working [IMG ./images/smilies/icon_smile.gif]. The SVP processor in Virtua Racing is a must, but so are the DSP chips on the Sega Model 1 arcade hardware, which to this day have critical, undumped embedded ROM data. And there's the MegaCD, and the Sega Saturn.... I know I know, that's a lot of chips and a year of photography work, but one can dream. [IMG ./images/smilies/icon_biggrin.gif] ######## POST p27317 | Eke | 2015-10-16 | t386-735.html [QUOTE] Nemesis wrote:I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it [/QUOTE] [IMG ./images/smilies/icon_eek.gif] ######## POST p27318 | Stef | 2015-10-16 | t386-735.html Haha, when i read this i internally had the same reaction / feeling, crazy guy ! But that is how we progress [IMG ./images/smilies/icon_smile.gif] ######## POST p27319 | Sauraen | 2015-10-16 | t386-735.html [QUOTE] Nemesis wrote:Wow, seriously awesome work Sauraen! [/QUOTE] Thanks! I was hoping to see you here at some point! And I will thank you in return for the years of work on this chip--I wouldn't have known where to begin with the die, nor frankly would have had the interest, without your wonderful details. [QUOTE] Nemesis wrote:I'm especially excited by the work you did figuring out the test register, being able to read the digital output of individual operators is absolutely golden. [/QUOTE] I thought you'd be excited by some of this stuff! But there's still bits I haven't fully explained; some of them are going to take quite a while. [QUOTE] Nemesis wrote:I'm going to be spending hours going over your notes and pictures with interpreting the die shots too, this is something I seriously want to learn how to do. [/QUOTE] I can write a little tutorial, but the biggest help while I've been doing the operator unit recently is that I'm actually reading the YM2203 die, and cross-checking things with the YM2612. I can actually read all the layers off the former, but in the latter I really can't see the diffusion when there's metal and poly on top of it. As I mentioned above, blocks from the YM2203 were copied-and-pasted onto the YM2612; other chips, for instance the YM3438, are a complete reimplementation (in that case, in a different technology). [QUOTE] Nemesis wrote:If you can find it somewhere on the die, see if you can figure out what data tables/process is involved in the FM modulation feature. There are still unknowns in that process. [/QUOTE] You mean how the outputs of operators are summed and fed back to modulate the phase of another operator in the operator unit? Or the LFO modulating the frequency of a voice (which is actually the only true FM the chip can do)? If you're talking about the operator unit, I'm in the process of making a complete VHDL equivalent description of the unit, that will work in YM2203 or YM2612 depending on a generic value (number of voices, which just changes the length of the shift registers). This will directly correspond with the chip at the sub-module level, including all internal I/O lines from other modules. This is the best way to document the chip at this level. The only thing that's different between what I'm doing and what's in the original chip is that in the chip, they use latches gated by both clock phases, rather than edge-triggered flip-flops in FPGAs. For instance, what I was working on last night: the circuit taking the outputs of the operator previous-value registers and summing two of them to produce the feedback value (before the shifter controlled by the FEEDBACK register). This is done in two stages. The values that go into the section (from the registers or current operator output) are gated by one phase of the clock (let's call this "low"). There's logic to select among them and produce two values which are going to be added; the two results here are gated by the "high" phase. The results of that go through a standard adder, and the result is gated by the "low" phase. Instead, what I'm doing in VHDL is that both the selection logic and the adder are in one "section" with no latch between them, but there's a flip-flop that stores the output of the whole thing once per clock cycle (on the rising edge). These two approaches are equivalent ASSUMING there's no timing stuff that depends on one phase or the other; if I find that there is, I'll have to change my approach in the VHDL. One tidbit I've found so far here: the two selection outputs are sign-extended to 15 (from 14) bits before being added (just means the MSB is copied to the new MSB); the 15-bit result is sent to the shifter; and the carry-out of the last bit is discarded. The carry-in is fixed to zero. The shifter is next on my list to do. [QUOTE] Eke wrote: [QUOTE] Nemesis wrote:I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it [/QUOTE] [IMG ./images/smilies/icon_eek.gif] [/QUOTE] Yeah, basically. The professor told me access to those chemicals was severely restricted due to safety concerns, and I shouldn't even try to get some. We'll see how the laser method goes. Let me see how it goes with this chip before you get too excited about future ones! But if all goes well, that won't be a year of work; the laser should be quick, and the photography shouldn't be that bad. If some of these chips are in unusual packages, what would help to maximize the chances of success would be if you could also send a random different chip that happens to be in the same package--that way we would get two chances to get the laser depth right. Keep in mind that reading this logic takes a long time, and reading ROMs isn't terribly easy either, depending on the photo quality and lighting as well as the chip process. ######## POST p27320 | mikejmoffitt | 2015-10-16 | t386-735.html If you can read the digital output of an operator, it would be very productive to dump with a logic analyzer the output of the carrier with TL at max, with all modulators silenced, to get a decent dump of the sine table used internally. ######## POST p27321 | Sauraen | 2015-10-17 | t386-735.html [QUOTE] mikejmoffitt wrote:If you can read the digital output of an operator, it would be very productive to dump with a logic analyzer the output of the carrier with TL at max, with all modulators silenced, to get a decent dump of the sine table used internally. [/QUOTE] That won't be necessary. Nemesis probably already has it 100% correct, and I can read it from the die shot just fine. When I release the VHDL equivalent description of the operator unit, that will include the table exactly as it is in the chip, with the additional logic that modifies its output to produce the value that an emulator would likely have. ######## POST p27332 | Nemesis | 2015-10-19 | t386-735.html [QUOTE] Sauraen wrote: [QUOTE] Eke wrote: [QUOTE] Nemesis wrote:I was actually starting up my own "at home" decapping lab, and I've got the fuming nitric acid in the garage which can attest to it [/QUOTE] [IMG ./images/smilies/icon_eek.gif] [/QUOTE] Yeah, basically. The professor told me access to those chemicals was severely restricted due to safety concerns, and I shouldn't even try to get some. [/QUOTE] [QUOTE] Stef wrote:Haha, when i read this i internally had the same reaction / feeling, crazy guy ! But that is how we progress [IMG ./images/smilies/icon_smile.gif] [/QUOTE] Yeah, you need the right balance of crazy and cautious to attempt this I think. Hopefully I've got that balance right [IMG ./images/smilies/icon_smile.gif]. I actually exaggerate slightly, because technically my nitric acid isn't "fuming" nitric acid, it's reagent grade 70%, and Wikipedia tells me that in order to be classified as "fuming" nitric acid, it needs to be 90%. I still call it fuming though, because call me silly, but my definition of fuming is "gives off fumes", and I can tell you, 70% nitric acid does that plenty well at room temperature thank you very much. I could of course distill this 70% solution to increase the concentration, but I actually don't see the need. The reactivity of the nitric acid can be increased by raising the temperature. Rather than heating the acid, I got myself an old electric fry pan, and placed a block of offcut marble from a benchtop in it, to give me a good thermal mass and something I could chemically abuse without worry. This is all wired up to a temperature controller to keep a stable temperature, and I then just stick the chip on the marble block to heat it up. I was experimenting with 70-80 degrees celcius. I then use one drop of acid at a time directly on to the chip package. With the chip so hot, it heats the acid on contact and causes a strong reaction, and after a second or two, I flush with a little acetone and repeat. This seems to work well. It's much better to have the slightly less nasty 70% nitric in storage than true fuming nitric too. I still get paranoid about this acid, and check on the bottles from time to time, just in case. They're stored in an old, thick wooden cabinet at ground level, with a magnetic lock that can only be opened by placing a magnet at the right magic place on the front door. The acid bottles are in tern surrounded by several large plastic containers of deionized water, with the theory that if it somehow escapes and starts eating away at anything, the plastic bottles will break and flood the area, diluting the acid to a harmless concentration. I'm actually not just using nitric acid through, I'm using a nitric+sulpheric acid mix. I came across a paper that talked about mixing sulpheric acid with nitric acid, to create a "buffer" which should apparently protect the metal layer, for the first few seconds of contact anyway, which I want to do at least for the initial decapping, so I'm trying a mix of 3 parts nitric (70%) to 1 part sulpheric (98%). The original paper called for 2 parts nitric to 1 part sulpheric, but they were using fuming nitric, so I've adjusted the quantities. Still yet to verify the results. Finding nitric acid was hard though, and laws vary between countries. I live in Australia, and while it's not illegal to buy or possess nitric acid in high concentrations, it's still tough to find any companies which will supply it retail to an individual, and just as tough to ship it. With how good it is at building things that go boom, and how hazardous it is to transport and store, this isn't surprising. I found a single supplier in the country where I could get it, and had it personally couriered to my door by a chemical courier company. I'm probably on some kind of terrorist watchlist now after making the purchase, but so be it. Fortunately the prices weren't too bad. In the end, this was the smallest cost though, the cash starts adding up quick when you realize all the other equipment you need in order to, you know, not die. Storing this mix is a real pain. Nitric+sulpheric acid reacts with just about everything. A lot of standard lab equipment, and basically all the standard lab safety gear, can't handle this kind of acid. You can't use any plastic, it's glassware throughout, and the fact it fumes means you can't keep it in anything with a rubber dropper or the like very long, because it'll rise up and start eating it. Made that mistake with my first attempt. Came back in the shed and found it had eaten its way out of my vials and started stripping the paint off the workbench. Makes very good paintstripper. For storage, you're basically limited to glass and teflon. Protective gear also needs to be neoprene. And then there's the fumes. That's the last barrier I had to properly address. I could mix the acids safely enough in open air, but when it comes to the actual decapping, the fumes are simply to hazardous, even with my kit that makes me look like I walked off the set of breaking bad. The vapour from this stuff can turn your lungs to soup, and outdoors is simply too uncontrolled an environment to work in for long. I ended up getting an old industrial fume cabinet off ebay for $1, just needed to set it up in an area and have another go. Haven't had a chance to get back to it since then though, and right now my garage is full of parts from my truck, the engine for which I'm rebuilding, so that's the project that needs to be finished first before I get back to this again. Still, I managed to get about halfway to the die of the chip I was testing on last time before I had to stop due to the fumes, and that only took a minute or so, so I'm hopeful with the fume cabinet, I can decap chips quickly and easily. Then it'd be on to the photography issue. I've picked up a really high-end Nikon 20x Plan microscope objective (http://www.nikoninstruments.com/index.p ... -VC-Series ), and under tests with an adapter for a telephoto lens on a digital camera, I believe it will work well. I was inspired by examples I've seen of this online, such as here: http://www.photomacrography.net/forum/v ... php?t=9664 . I still need to pick up the actual camera I'm planning to use (waiting on the right price), but with the complete setup, I should be able to capture 18 megapixel (or whatever the camera I get supports) pictures at 20x zoom, which based on research, I believe will be enough detail. My lighting solution should work, and I've got an X/Y table thingy from an old microscope to address the stability issue for taking the pictures, which is critical, because the focal depth of a microscope objective is insanely small. Apart from the camera, I'm pretty sure I have everything now to make this work, just need the time to work on it again. [QUOTE] Sauraen wrote:We'll see how the laser method goes. Let me see how it goes with this chip before you get too excited about future ones! But if all goes well, that won't be a year of work; the laser should be quick, and the photography shouldn't be that bad. If some of these chips are in unusual packages, what would help to maximize the chances of success would be if you could also send a random different chip that happens to be in the same package--that way we would get two chances to get the laser depth right. [/QUOTE] Cool, can't wait to hear how it goes! My backyard setup would be handy for the long term, and hell it's just plain fun to try, but I have a feeling you'll be able to turn around a result quicker than I'll be able to get my rig up and running, especially with how little time I've had this last year. [QUOTE] Keep in mind that reading this logic takes a long time, and reading ROMs isn't terribly easy either, depending on the photo quality and lighting as well as the chip process. [/QUOTE] Yep, no illusions about that, but even without much analysis, some things can be determined very quickly that otherwise are very hard to know. IE, is that unused pin actually connected to something internally? What might those "test" lines be wired up to? Longer term, it also serves as an indisputable, absolute reference on what's really inside a chip. After research, like the kind you're doing, we can know for certain what the internal operation of the chip is. Combining decap analysis with physical system tests, everything should be possible to reveal. The problem with system tests alone is you've still essentially got a black box, so you don't know for sure if you're missing something. Decapping can highlight things that have been missed in system testing. Into the future, a delayered die-shot will be the most important resource for emulating old hardware. Things need to start with logical documentation, either official or reverse engineered, but they can't truly be completed for any reasonably complex chip without decapping IMO. ######## POST p27333 | Sauraen | 2015-10-19 | t386-735.html [QUOTE] Nemesis wrote:Cool, can't wait to hear how it goes! My backyard setup would be handy for the long term, and hell it's just plain fun to try, but I have a feeling you'll be able to turn around a result quicker than I'll be able to get my rig up and running, especially with how little time I've had this last year. [/QUOTE] Well, we did get results quickly, but they weren't good ones. Turns out the "plastic" packages are actually glass-epoxy; the laser vaporizes the epoxy and fuses the glass, so you get a nice ugly layer of SiO2 over the chip and it's impossible to see. [IMG ./images/smilies/icon_sad.gif] My buddy is going to try a few more techniques with the laser before giving up, but it's not looking good. This is a dumb question, but wouldn't less-concentrated acid still work, just take longer? I'm sure I can get ahold of some 10% nitric acid, what if I leave that on the chip overnight? I know there was talk of getting photos of the chips with and without the metal layer, but if you can only choose one, with the metal is MUCH more helpful. For these old chips there's only one metal layer; for chips with several, you'd have to selectively eat away one at a time and take pictures between each one. Would it be possible for you to decap some of these chips, take some initial photos, and then ship them to me and I'll use the university's microscope to take the final ones? The equipment here is for looking at experimental LEDs at micron resolution, so it should be better than any consumer camera jerryrigged to a microscope. ######## POST p27343 | Nemesis | 2015-10-19 | t386-735.html [QUOTE] Well, we did get results quickly, but they weren't good ones. Turns out the "plastic" packages are actually glass-epoxy; the laser vaporizes the epoxy and fuses the glass, so you get a nice ugly layer of SiO2 over the chip and it's impossible to see. [IMG ./images/smilies/icon_sad.gif] My buddy is going to try a few more techniques with the laser before giving up, but it's not looking good. [/QUOTE] Yep, these packages are nasty little things. Not much works well for them. I'm only aware of two methods that are known to work reliably, with the right setup. The first one is of course nitric acid decapsulation. The second approach is manual drilling of the package down to the die. With xray equipment to work out the precise depth and size of the embedded die, and with an extremely precise milling machine setup, you can drill down to the die surface, or a fraction of a mm above it, then gently split the remaining tiny layer from the die surface. That said, acid decapsulation seems easier and less error prone, if not a little more risky to your health. There is a simpler, more brutal decapsulation method I've seen used. I've seen lots of examples, but there's a good description here: http://www.t4f.org/articles/ultra-low-c ... psulation/ The method is basically to heat up a beaker of nitric acid and dunk an IC in, and let it totally eat away everything but the die. I believe this is slightly safer on average in the sense that you actually handle and deal with the acid less. You don't need to actually dropper it bit by bit on the chip and stand next to it while it's fuming, but at the same time, you have to use a larger quantity of acid, and you have to heat that entire volume of acid at once, which in my mind means the "worst case" scenarios are a bit worse with this method. 100ml of boiling nitric acid sitting on a hotplate in a glass beaker? Yeah, not fun. It's much cheaper to setup and simpler on the whole though. I didn't go with this method however, because I wanted to preserve the outer package as much as possible, and more significantly, this approach doesn't give you any option to preserve the metal layer, which I wanted to be able to do. Still, I'll throw it out there as an option. [QUOTE] This is a dumb question, but wouldn't less-concentrated acid still work, just take longer? I'm sure I can get ahold of some 10% nitric acid, what if I leave that on the chip overnight? [/QUOTE] I am by no means a chemist (in fact, I hated chemistry), but my understanding is that without concentrated enough acid, or sufficient temperature, the reaction won't even begin. A 10% solution is so weak, I don't think it'll do anything. The article I linked above says as much for the 60% acid they used, so 10% would certainly be much, much worse than that. You might have to check what you can easily source in your area. The guy who wrote that article is obviously in Europe, but it seems he could buy 1 litre of 60% nitric in a bottle locally for around 30 euro. You can't buy anything like that here in Australia, no stores I found even stock nitric acid in any concentration. Maybe you can find something like that in the US though? Still I totally understand if you don't want to even investigate this option yourself. If you have access to a proper chemistry lab, or a friend who does, with all the right lab equipment and a proper fume cabinet, it should be really easy to make an attempt yourself. Pretty much all you're doing is mixing two acids together (in the right order! Pour the strong into the weak), heating up the chip, and droppering the acid mix onto the chip until you reach the die. That part is easy. 90% of the difficulty is in setting up the environment properly with the right equipment, but a proper lab should have everything ready to go. If you don't have any of that though, it's a long, expensive, hazardous road to get setup, I can tell you. [QUOTE] Would it be possible for you to decap some of these chips, take some initial photos, and then ship them to me and I'll use the university's microscope to take the final ones? The equipment here is for looking at experimental LEDs at micron resolution, so it should be better than any consumer camera jerryrigged to a microscope. [/QUOTE] What's the timeframe here? I'm really, really busy with work and life right now. I'm flying over to Denver this Saturday for a couple of weeks for work, then Adelaide shortly after I get back. I've got kids and a pregnant wife back home, and we've been moving house, with all my gear in storage. What's not in storage is in the old garage, as I said with a disassembled engine taking up most of my work area. It's really unlikely I'll be able to do anything more on this stuff until next year. I will get back to it, but obviously you won't have access to that gear forever. It's very hard for me to predict when I'll have enough time to work on this again, so you might need another option rather than waiting for me. If you can put a couple of dollars into this, it might be worth looking at commercial decapping labs. There was a place in the US called MEFAS that would do decapping for very good prices. I made an inquiry back in 2008, at that time it was $75 per chip, but unfortunately they would only FedEx post out of the US, which was $150 and made it too expensive for me. Still, you're US based, so the postage will be cheap. MEFAS would even guarantee the chip would still be operational after decapping. They were happy to deal with individuals, and didn't care what they were decapping (IE, you didn't have to be a company, or the creator of the IC). Google tells me they've since been bought out by a place called "Evans Analytical Group". Here's the page: http://www.eag.com/mte/failure-analysis-services.html You'll have to make an inquiry to find out about price, but hopefully they're still reasonable. Since you wouldn't need any photography, they should be able to offer a really cheap price. All they need to do is stick your chip in their automated decapping machine for 5 minutes. This should be a very cost effective option for a few chips. I was looking at my own at-home decapping lab because I wanted to be able to do a LOT of chips, but for a small number, this could actually be the cheapest, simplest option, and the turnaround time should be really quick. ######## POST p27344 | Nemesis | 2015-10-19 | t386-750.html I did some research on laser decapping, and found some very interesting info. http://hackaday.com/2015/08/24/using-a- ... decap-ics/ Seems this is an up and coming method. You might want to read it over and follow the links, and show it to your buddy. Looks like laser decapping is possible, might just be a matter of getting the technique and power levels right? EDIT: Just noticed this article is actually dealing with a die covered in a blob of epoxy, not a typical plastic package. I think this is a very different beast, so maybe none of this applies. ######## POST p27345 | Sauraen | 2015-10-19 | t386-750.html I've done a little more research since my last post, and I'm pretty much on the same page. The wiki at siliconpr0n lists a technique using concentrated sulfuric acid only, and it looks like this may be possible with the facilities I have access to. I will have more information in the coming weeks. Would it be helpful to everyone if a single VDP/IO/arbiter/OPN2/PSG ASIC was decapped and photographed, even if this meant multiple revisions were not documented? If so, I'll just forget about the manual method and go to EAG/MEFAS. As far as the laser, that's exactly the article my buddy saw and got him going--but those "glop tops" are epoxy only, no glass. He's going to try something with the laser and a powerful air jet next, to see if he can do something about the glass. ######## POST p27349 | mikejmoffitt | 2015-10-19 | t386-750.html I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. ######## POST p27353 | Sauraen | 2015-10-20 | t386-750.html [QUOTE] mikejmoffitt wrote:I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. [/QUOTE] You want to donate one? ######## POST p27357 | mikejmoffitt | 2015-10-20 | t386-750.html [QUOTE] Sauraen wrote: [QUOTE] mikejmoffitt wrote:I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. [/QUOTE] You want to donate one? [/QUOTE] I would, but mine isn't available since I'm not anywhere near it. If you can give me a few months, then yeah, that should be possible. ######## POST p27368 | Nemesis | 2015-10-22 | t386-750.html [QUOTE] Sauraen wrote:Would it be helpful to everyone if a single VDP/IO/arbiter/OPN2/PSG ASIC was decapped and photographed, even if this meant multiple revisions were not documented? If so, I'll just forget about the manual method and go to EAG/MEFAS. [/QUOTE] Eventually we'd want both, but only one chip could be done right now, doing the all-in-one would be a pretty good idea. That at least gives us a peek into all the chips in one hit. Most likely the ASIC is little more than each of the original discrete chips glued together on the one die. Although we do know there are some internal differences with some of the components like the VDP, it's a great starting place, and we can always decap the discrete versions later on. The other advantage is that if we decap the discrete versions later, we'll get the first revisions of them done, while the ASIC effectively has the last revisions of them, so it'll be able to highlight internal differences that have occurred between the versions. [QUOTE] Sauraen wrote: [QUOTE] mikejmoffitt wrote:I'd actually love to see a decapping of the Genesis 3 all-in-1 ASIC, if that's available. [/QUOTE] You want to donate one? [/QUOTE] They're actually pretty easy to get, any VA2 Genesis 3, which you can identify by a serial number beginning with "AG82", has the very last revision of that chip. The system isn't really considered a collector's item, so they're usually cheap as chips. Here's one on ebay right now for $16: http://www.ebay.com/itm/252116959245 Pretty hard to beat that price. EDIT: Since that one is sold as untested, and you're going to invest quite a bit of time and effort into this, you may only want to go ahead with the decapping of that system if you're able to test it before you proceed. Almost certainly there's absolutely nothing wrong with it (after all, this is the board: http://segaretro.org/File:PC_BD_MD3_VA2_USA.jpg ), but better to check before proceeding IMO. If you just want to buy one that's listed as working, there are plenty of other systems going, but unfortunately a lot of ebay sellers don't show the serial numbers in their pictures. This was the cheapest one I could find listed as known working which showed an AG82 serial: http://www.ebay.com/itm/161864280729 There are other cheaper systems (and even a cheaper bundle of 3 systems) you could look at If you're willing to message the sellers to check the serial numbers. I'd strongly suggest sticking to the VA2 board, since we already know it contains some important internal changes in this chip revision that have been noticed in software. ######## POST p27370 | Sik | 2015-10-22 | t386-750.html If we go with requests for decaps we could try the TCT-6705 as well. Yes, it's a clone, but I checked it against Overdrive and the whole demo behaves as expected so I imagine it's some sort of superclone. The thing that catches my attention is that the Mega 3 (the clone I tested with) has 48* of the pins unconnected (out of 128), and I don't think there are that many connections under the chip since there really isn't much room (there's nothing on the other side of the board so there's no way to dodge crosses). With that many pins unconnected I imagine there must be something going on. *Actually 49, but one has a trace going nowhere, so I assume it's just some toggle e.g. Master System or TMSS. We should probably discuss which chips to decap in another thread though (so we can keep discussion about the YM2612 separate from the rest of the stuff, and make it easier to go back and see what we want to decap =P). ######## POST p27387 | Sauraen | 2015-10-23 | t386-750.html Okay, here's a thread about the decapping: viewtopic.php?f=13&t=2191 ######## POST p28045 | SeregaZ | 2015-12-13 | t386-750.html maybe you have some dll of YM2612 for using in another programm languages? i mean send command like: SendToYM2612(register, value) like OPN.dll, that give me ValleyBell... i see full code, but i think i cant to port this to my language... ######## POST p28067 | r57shell | 2015-12-14 | t386-750.html [QUOTE] SeregaZ wrote:maybe you have some dll of YM2612 for using in another programm languages? i mean send command like: SendToYM2612(register, value) like OPN.dll, that give me ValleyBell... i see full code, but i think i cant to port this to my language... [/QUOTE] checkout any opensource emulator, then separate its YM2612 into external DLL for example here is genplus-gx YM2612 and SN76489 (PSG): https://github.com/ekeeke/Genesis-Plus- ... core/sound here is gens-rerecording YM2612: https://github.com/TASVideos/gens-rerec ... c/ym2612.c and here is YM2612 from MESS: http://git.redump.net/mame/tree/src/dev ... fm2612.cpp Don't forget to check license for compatibility ######## POST p28075 | Sik | 2015-12-14 | t386-750.html [QUOTE] r57shell wrote:Don't forget to check license for compatibility [/QUOTE] Yeah that tends to be quite the issue, either it's something based on the MAME core which has an explicit "no commercial use" clause (this can become an issue for composing music for homebrew which would be otherwise legal) or it's based on the Gens core which is not exactly the greatest out there (although at least it allows commercial use since it's GPL... or is that part of the emulator not covered by it?). ######## POST p28077 | MetalliC | 2015-12-14 | t386-750.html [QUOTE] Sik wrote:either it's something based on the MAME core which has an explicit "no commercial use" clause [/QUOTE] currently MAME in process of relicensing, so in most parts it is BSD-3 or/and GPL already. but not in the case of FM OPL/OPN cores, its commercial usage was explicit forbidden by its author (Jarek Burczynski). ######## POST p28080 | Sik | 2015-12-14 | t386-750.html And that wouldn't have helped with the derivative code either (see: Genesis Plus GX), since you can't change licenses retroactively. Nice to see that there's an attempt to relicense MAME's code though. I can see where they come from with "no commercial use" but technically the way copyright works already would forbid it anyway for starters (having permission to use MAME commercially doesn't mean you have permission to run the games =P) ######## POST p28094 | r57shell | 2015-12-15 | t386-750.html [QUOTE] Sik wrote: [QUOTE] r57shell wrote:Don't forget to check license for compatibility [/QUOTE] Yeah that tends to be quite the issue, either it's something based on the MAME core which has an explicit "no commercial use" clause (this can become an issue for composing music for homebrew which would be otherwise legal) or it's based on the Gens core which is not exactly the greatest out there (although at least it allows commercial use since it's GPL... or is that part of the emulator not covered by it?). [/QUOTE] I don't see trouble here. If you testing commercial song playback for example in MESS, does it violate its license? If no, then obviously you can make other freeware composer thing based on its source and test songs there again. Or you can't? I'm not familar with law so close [IMG ./images/smilies/icon_confused.gif] But you made me confused. But obviously you can't use its core as sound engine for commercial PC game for example. That's true. And, in the end. It's always better to test music straightforward on console itself (sega genesis I mean), via JOYPAD port or stuff like UMDK etc... ######## POST p28105 | Sik | 2015-12-16 | t386-750.html The problem being most licenses just say "non-commercial use" without giving any specifics on what counts as commercial use so in practice it's up to how angry is the lawyer =P ######## POST p28109 | SeregaZ | 2015-12-16 | t386-765.html commercial? [IMG ./images/smilies/icon_smile.gif])) this software will be used by 5-10 mans... what commercial you talking? [IMG ./images/smilies/icon_smile.gif] it is just for romhackers comunity. ######## POST p28110 | MetalliC | 2015-12-16 | t386-765.html its going off topic but... you are wrong, here is a lot of old games was released recent times, mostly from DotEmu company. all of them emulated, for example Raiden Legacy in Steam and GoG is MAME-based. so I'm not surprised some people like Jarek doesn't want to see their's code and research research results used by someone else for making money. ######## POST p28111 | Eke | 2015-12-16 | t386-765.html [QUOTE] MetalliC wrote: so I'm not surprised some people like Jarek doesn't want to see their's code and research research results used by someone else for making money. [/QUOTE] I am not sure if he is aware that his code is being used commercially in Genesis Plus GX ripoffs that have a lot of exposure and likely make huge profits out of it: - MD.emu on Google Play (https://github.com/Rakashazi/emu-ex-plu ... /ym2612.cc ) - Hyperkin's Retron 5 (http://retron5.in/node/9 ) - Cybergadget's Retrofreak (http://www.cybergadget.co.jp/support/re ... tware.html ) That's the only part they use (with ym2413 implementation) that is still not licensed under GPL, yet they don't have any issue with that. Sadly we could not claim anything since we are not copyright holders for this code. ######## POST p28114 | r57shell | 2015-12-17 | t386-765.html [QUOTE] Eke wrote:Sadly we could not claim anything since we are not copyright holders for this code. [/QUOTE] Really? I thought all contributers considered as holders, except if in license noted something different. For example you can't even change license, until you have approve from all contributers, that's why some people using BSD and other no-restrictive at all licenses to avoid any troubles, if for example too many contributers already, and you can't change politics and direction of project... Again, I'm not sure, but that what I thought. ######## POST p28164 | Sauraen | 2015-12-19 | t386-765.html I apologize for my absence from this thread for the last couple months, I've been very busy towards the end of this semester with several things (including making a complete 8-bit microprocessor at the transistor level for a VLSI class--46 instructions, 50 MHz!) I've finally finished my VHDL equivalent description of the YM2203 / YM2612 operator unit. The code is available at https://github.com/sauraen/YM2612 . As I explain in the file header as well, this is an untested implementation. Obviously I tried to get everything right, but it is very likely there will be a couple bit errors in the logsin and exponential tables, and also it's possible a signal should be inverted from how I have it. But I am confident that this matches the chip architecture at a high level--that is, the pipelining and register positions. This should also clear up questions about bit widths, when carry-outs are used and when discarded, etc. Also the exact use of Test Register $21 bit 4 is included. I'm taking requests for what to reverse engineer next. (Please don't say the EG!) I would go with the LFO, but honestly I haven't found it yet. I will tell you this, it is absolutely not a sine wave LFO, it must be a triangle wave--there's no other logic interfacing to the operator unit's sine table for the LFO, and there's no other table that would be large enough to hold any decent approximation of a sine wave. Also, in the OPL2/OPL3 which have an "exponential" waveform available, it is thought to be a "readout of the exponential table"--I doubt this, it probably just skips the logsin table completely. ######## POST p29435 | Count SymphoniC | 2016-04-08 | t386-765.html I've been puzzled over the math involved in determining the number of cycles to wait in between register writes. The number is 24 internal cycles * 6 = 144 68000 cycles? If a 68k nop is 4 cycles, does that mean it would take 36 68k nop's in between writes? I swear that doesn't sound right, that seems like a lot.... Where am I wrong? ######## POST p29436 | Sik | 2016-04-08 | t386-765.html In assuming the YM2612 is fast, it's actually way too slow, even for the Z80 it is (in Echo I have to get around this by intentionally using a slow instruction to burn cycles, without that I need to resort to adding explicit delays every time which would make code more convulted). So yes, your math is correct. ######## POST p29437 | Count SymphoniC | 2016-04-08 | t386-765.html Wouldn't that mean you'd need about 18 z80 nop instructions then? Why does this sound like too many... ######## POST p29438 | Sik | 2016-04-08 | t386-765.html You need to wait 33.6 Z80 cycles after you write to $4001/3 (the second write). You'd need about 9 NOPs for that (or be clever and waste just enough cycles as you do any other operations ;P). Note that you don't need any delay after $4000/2 (the first write), if you did then yes it would be indeed 18 NOPs as you said. This loop in Echo barely meets the limit by 3 cycles. There isn't much you can optimize without breaking it. EDIT: and let me stress it, yes the YM2612 is really that slow. ######## POST p29439 | Count SymphoniC | 2016-04-09 | t386-765.html Thank you for the clarity, I never was very sure about the best way to do this. I meant to test the wait times on hardware but wasn't sure of a good reliable method for doing so. I'm still open to doing so and posting results if someone has any accessible ideas. ######## POST p29440 | Stef | 2016-04-09 | t386-765.html The main problem for me is that ym2612 (MD1) and ym3438 (MD2) does not have same busy cycles and if you test your cycles on a MD1, you might be greatly disappointed when you will test then on a MD2 as the ym3438 seems to require more time after some register writes. In my case I preferred to test the busy flag when I require to do many ym writes in a short period of time. ######## POST p29442 | Sik | 2016-04-09 | t386-765.html Well, Echo works with both so I assume that part of the timing stands. I guess the YM3438 is just less lenient about not respecting it =P The biggest problem with checking the busy flag is that when it comes to the Z80, a busy wait loop may very well take longer than it takes for the busy flag to clear in the first place (whoops!), at which point you may as well just insert a delay instead. A wait loop may make more sense with the 68000 which is much faster. EDIT: by the way if you're using the Z80, using the IX and IY registers is a good way to burn extra cycles and reduce the amount of clobber needed to meet the timing requirements (also you can just keep $4000 always there, which frees up other registers for more important purposes). ######## POST p29443 | Sauraen | 2016-04-09 | t386-765.html FWIW here's the timing in MIDIbox Quad Genesis : http://svnmios.midibox.org/filedetails. ... gmplayer.h http://svnmios.midibox.org/filedetails. ... gmplayer.c This driver was developed on the first MIDIbox Quad Genesis synth I finished the hardware of, which contains four YM2612s (and four SN76489s). However, that synth is now in the possession of my client, and I've finished the hardware of a second copy for myself, which instead contains four hardware YM3438s. The driver worked immediately with no changes, so I left it alone. But because I don't have the YM2612 version, any experimentation with reducing the wait times can only directly be confirmed on the YM3438. Right now I'm using a wait time of 2100 ticks at 84 MHz/tick (a total of 25us or 200 external OPN2 cycles at 8 MHz [which the chip is clocked at, not at 7.67MHz] or 33.3 internal cycles). This works on both YM2612 and YM3438 with no audible dropped commands, and the performance is high enough that I can play four VGM files at the same time, one on each OPN2/PSG . So I haven't tried to push it, but I can do so and let everyone know the results. ######## POST p29448 | Count SymphoniC | 2016-04-11 | t386-765.html Whoa [IMG ./images/smilies/icon_eek.gif] talk about a show of technical prowess. Very nice. Actually, lately I've been having a wild itch for building a YM synth, I've seen posts here and there with schematics, but are these completed? I have the software programming knowledge but my electronic engineering skills are at a very basic level. I'd really like to chip away on a side project like this while developing my Sega Genesis tracker. Quad Genesis... Wow. ######## POST p29450 | Sauraen | 2016-04-12 | t386-765.html @CountSymphoniC Thanks! Not to derail the thread or shamelessly self-promote, but here's the current state of the MIDIbox Quad Genesis project. The MBHP_Genesis boards which I designed, each of which holds one YM2612/YM3438 and one SN76489 and provides appropriate glue logic for a parallel interface to your MCU of choice, are finished, fully documented (at the above link), and available for $5 each on the MIDIbox Shop . (Disclaimer: I profit from the sale of these boards.) To interface to the STM32F4 microcontroller from the MIDIbox hardware platform, a simple level shifter board is also required, which you can build by hand. The remaining hardware you need is all from the MIDIbox platform, and all the required PCBs are available on the MIDIbox Shop. Three software applications for the MBHP_CORE_STM32F4 are in progress. (All three support up to four MBHP_Genesis modules, i.e. four of each sound chip.) The first project is MIDIbox VGM Player , which just allows you to play VGM files from a SD card on the MBHP_Genesis boards. This application is completed (though I will update it as I continue to develop the VGM driver), and information is available at the link above that should be sufficient for you to build one. The second application is MIDIbox Genesis Tracker, which is currently in progress and should be released soon. This application controls the pairs of sound chips exclusively via MIDI commands, according to the GENMDM spec . Finally the third application is the entire application layer for MIDIbox Quad Genesis, the full-featured synth with the large front panel whose hardware is shown in the videos above. The software for this will probably not be anywhere near completed before the end of the summer, although when it is, I intend to sell a few sets of custom parts for constructing the front panel (finished aluminum, front panel PCB, and 3D printed button caps--it won't be cheap though, expect around $400-$500, plus you'll have to buy the hundreds of LEDs yourself, not to mention solder them all!) I'd love to have some people build some VGM Players or Trackers and give feedback to help improve the design and documentation. If you have issues building the hardware or using the software, I offer technical support on the MIDIbox Forums . ######## POST p29458 | neozeed | 2016-04-15 | t386-780.html I'm sure everyone's seen this, but the ym2151.c in mame is now GPL! Commits on Jan 21, 2016 @mmicko Setting GPL license for Jarek Burczynski, by his request (nw) https://github.com/mamedev/mame/commit/ ... 4663ba3ba9 [CODE] // license:GPL-2.0+ // copyright-holders:Jarek Burczynski /***************************************************************************** * * Yamaha YM2151 driver (version 2.150 final beta) * ******************************************************************************/ [/CODE] ######## POST p29470 | Eke | 2016-04-18 | t386-780.html [QUOTE] Sauraen wrote:I 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. [/QUOTE] I didn't noticed it initially but it seems MAME implementation is a little bit different. If you look at current channel algorithm calculation code: https://bitbucket.org/eke/genesis-plus- ... 2612.c-843 [CODE] INLINE void setup_connection( FM_CH *CH, int ch ) { INT32 *carrier = &out_fm[ch]; INT32 **om1 = &CH->connect1; INT32 **om2 = &CH->connect3; INT32 **oc1 = &CH->connect2; INT32 **memc = &CH->mem_connect; switch( CH->ALGO ){ case 0: /* M1---C1---MEM---M2---C2---OUT */ *om1 = &c1; *oc1 = &mem; *om2 = &c2; *memc= &m2; break; case 1: /* M1------+-MEM---M2---C2---OUT */ /* C1-+ */ *om1 = &mem; *oc1 = &mem; *om2 = &c2; *memc= &m2; break; case 2: /* M1-----------------+-C2---OUT */ /* C1---MEM---M2-+ */ *om1 = &c2; *oc1 = &mem; *om2 = &c2; *memc= &m2; break; case 3: /* M1---C1---MEM------+-C2---OUT */ /* M2-+ */ *om1 = &c1; *oc1 = &mem; *om2 = &c2; *memc= &c2; break; case 4: /* M1---C1-+-OUT */ /* M2---C2-+ */ /* MEM: not used */ *om1 = &c1; *oc1 = carrier; *om2 = &c2; *memc= &mem; /* store it anywhere where it will not be used */ break; case 5: /* +----C1----+ */ /* M1-+-MEM---M2-+-OUT */ /* +----C2----+ */ *om1 = 0; /* special mark */ *oc1 = carrier; *om2 = carrier; *memc= &m2; break; case 6: /* M1---C1-+ */ /* M2-+-OUT */ /* C2-+ */ /* MEM: not used */ *om1 = &c1; *oc1 = carrier; *om2 = carrier; *memc= &mem; /* store it anywhere where it will not be used */ break; case 7: /* M1-+ */ /* C1-+-OUT */ /* M2-+ */ /* C2-+ */ /* MEM: not used*/ *om1 = carrier; *oc1 = carrier; *om2 = carrier; *memc= &mem; /* store it anywhere where it will not be used */ break; } CH->connect4 = carrier; } [/CODE] & https://bitbucket.org/eke/genesis-plus- ... 612.c-1423 [CODE] unsigned int eg_out = volume_calc(&CH->SLOT[SLOT1]); m2 = c1 = c2 = mem = 0; *CH->mem_connect = CH->mem_value; /* restore delayed sample (MEM) value to m2 or c2 */ { INT32 out = CH->op1_out[0] + CH->op1_out[1]; CH->op1_out[0] = CH->op1_out[1]; if( !CH->connect1 ){ /* algorithm 5 */ mem = c1 = c2 = CH->op1_out[0]; }else{ /* other algorithms */ *CH->connect1 += CH->op1_out[0]; } CH->op1_out[1] = 0; if( eg_out < ENV_QUIET ) /* SLOT 1 */ { if (!CH->FB) out=0; CH->op1_out[1] = op_calc1(CH->SLOT[SLOT1].phase, eg_out, (out<FB) ); } } eg_out = volume_calc(&CH->SLOT[SLOT3]); if( eg_out < ENV_QUIET ) /* SLOT 3 */ *CH->connect3 += op_calc(CH->SLOT[SLOT3].phase, eg_out, m2); eg_out = volume_calc(&CH->SLOT[SLOT2]); if( eg_out < ENV_QUIET ) /* SLOT 2 */ *CH->connect2 += op_calc(CH->SLOT[SLOT2].phase, eg_out, c1); eg_out = volume_calc(&CH->SLOT[SLOT4]); if( eg_out < ENV_QUIET ) /* SLOT 4 */ *CH->connect4 += op_calc(CH->SLOT[SLOT4].phase, eg_out, c2); /* store current MEM */ CH->mem_value = mem; [/CODE] I am not sure how much you can read C code but, for algorithm 0, modulators being used by each operator (OP1,OP2,OP3,OP4) at cycle n will be : OP1 (n-2) + OP1(n-1)) modulating OP1 (n) OP1 (n-1) modulating OP2 (n) OP2 (n-1) modulating OP3 (n) OP3 (n) modulating OP4 (n) The one in bold in particular contradicts your observations. More generally, the way it is implemented, OP1 will never directly modulate OP2 or OP4 on the same cycle but always modulate them with one cycle (sample) delay. More over, in case of algo 1 or algo5, OP3(n) is actually modulated by OP1(n-2) ! I am not sure if this is an error in MAME implementation when they introduced the MEM register (used to emulate the cycle delay you observed for OP3 modulator/s) in regard to OP1 feedback registers or if this is correct behavior but it seems a little weird... What do you think? ######## POST p29471 | Sauraen | 2016-04-19 | t386-780.html I took the bait and started an analysis of the control unit that generates the signals specifying which values are added during which cycles (the op_algorithm_ctl signal in my VHDL version of the operator unit ). Here's the results so far: All these observations are directly from the YM2203, not the YM2612, but the results should be equivalent. We already know that the chip processes one operator from each channel per cycle. We don't yet know the relative phase between the operators, that is whether the chip processes operator 1 from all channels before moving on to the next operator, or whether it interleaves them in some fashion (for various reasons I think the latter is much more likely). But within one channel, it definitely processes one operator, than operators from two other channels, than the next operator from the first channel again. (Remember this is on the YM2203 with three channels.) Also remember that this is from the point of view of any point in the pipeline, and that each operator takes 6 cycles to go through the whole pipeline. The result is that the operators are evaluated in the order 1-3-2-4 OR 1-4-2-3 (don't know yet which one) [EDIT: later confirmed to be 1324]. For this next bit, keep in mind that I'm considering the "first" step of evaluation to be the step of summing up to 2 operator output values to produce the feedback/feedforward phase for the next operator. Therefore: when operator 1 begins evaluation, the result from operator 2 is ready (op_result_internal is the result of the most recent evaluation of operator 2) when operator 3 begins evaluation, op_result_internal is from operator 4 when operator 2 begins evaluation, op_result_internal is from operator 1 when operator 4 begins evaluation, op_result_internal is from operator 3 So from the control unit that I've analyzed, I've made a handwritten table of the values of x and y (the operator values being added) in the case of each algorithm and each operator phase. I won't reproduce it here because it basically amounts to the same information as the diagrams of the operator connections in the algorithms, but here's the key points. Remember the operator unit stores 3 values, "Old 1" (two evaluations ago), "1" (most recent evaluation of operator 1), and "2" (most recent evaluation of operator 2). In the phase where op_result_internal is 2 (and we're beginning to evaluate operator 1), X is always "Old 1" and Y is always "1". This matches all previous results. In the phase where op_result_internal is 4 (and we're beginning to evaluate operator 3), sometimes X is "2" and sometimes Y is "1", for the appropriate algorithms. That is, operator 3 is always calculated from the most recent results of operators 1 and 2, but those will be the results received 1 and 3 phases ago and therefore BEGUN 3 and 5 phases ago. (Which is which depends on whether the overall order is 1324 or 1423. [EDIT: later confirmed to be 1324]) In the phase where op_result_internal is 1 (and we're beginning to evaluate operator 2), sometimes Y is op_result_internal (for the appropriate algorithms). This is the most recently evaluated result from operator 1, just finishing now; also available (about to be overwritten) are the previous two results from operator 1, but these are not used (consider this confirmed). That is, operator 2 is always calculated from the most recent result of operator 1, the one whose calculation was begun 2 phases ago. Finally, in the phase where op_result_internal is 3 (and we're beginning to evaluate operator 4), "1", "2", and op_result_internal (i.e. 3) are all used as necessary. The overall conclusion is that, yes, in all cases an operator's value is calculated from the most recent result of the required operator (except of course for the feedback, which intentionally uses the last two values of operator 1). However, this most recent result could have been received up to 3 phases ago and therefore begun evaluating up to 5 phases ago. Therefore, I retract my previous statement that evaluating the operators in some other order (3142 or something) will produce the correct result--it won't. If every operator is evaluated all at once (how it would normally be done in code rather than in VLSI), there has to be storage for up to 5 phases. This is how I would organize the code, assuming that the evaluation order is actually 1324 [EDIT: later confirmed]. It's based on exactly what the chip does in the same order: Each operator has a variable for its most recent output, op[n].output. (n is 1-indexed here for consistency with the above) Three other variables are available: outOld1, out1, out2 (probably not named these things!) Evaluate operator 1 using outOld1 and out1. Also copy op[2].output to out2. Evaluate operator 3 using out1 and out2. Evaluate operator 2 using op[1].output. Also copy out1 to outOld1 and op[1].output to out1. Evaluate operator 4 using out1, out2, and op[3].output. If it turns out that the actual order is 1423, simply switch the steps for evaluating operators 3 and 4. THEREFORE, I think the MEM thing is wrong, or at least your description of it is. (I certainly can read C, but that's about the least readable C I've ever seen!) No matter how you cut it, operator 2 gets evaluated with the most recent output from operator 1, and similarly operator 4 uses the most recent output from operator 3. Those are clear. The tricky part is that assuming it's 1324 [EDIT: later confirmed], operator 4 is evaluated with the result of operator 2 which was calculated 5 phases ago, not the one from last phase (on the chip it's still not done yet). Similarly, operator 3 is evaluated with the 5-phase-old operator 1 value, not the one from 1 phase ago. ######## POST p29476 | Eke | 2016-04-19 | t386-780.html Ouch, I've read your post multiple time but this is quite confusing, I guess because I'm not familiar with some terms you are using or that I am missing some basic concepts you figured about how the operator unit is functioning in hardware. [QUOTE] Sauraen wrote: The result is that the operators are evaluated in the order 1-3-2-4 OR 1-4-2-3 (don't know yet which one). For this next bit, keep in mind that I'm considering the "first" step of evaluation to be the step of summing up to 2 operator output values to produce the feedback/feedforward phase for the next operator. Therefore: when operator 1 begins evaluation, the result from operator 2 is ready (op_result_internal is the result of the most recent evaluation of operator 2) when operator 3 begins evaluation, op_result_internal is from operator 4 when operator 2 begins evaluation, op_result_internal is from operator 1 when operator 4 begins evaluation, op_result_internal is from operator 3 [/QUOTE] What do you mean by "evaluation of operator X " exactly ? Operator output calculation or its use as modulation input for another operator? And what exactly is "op_result_internal"? operator output or modulation input? It's not very clear to me what you mean by "when operator X begins evaluation", "op_result is from operator Y" and I don't quite follow what this is implying. Is that related to operator execution order or something else? [QUOTE] Sauraen wrote:So from the control unit that I've analyzed, I've made a handwritten table of the values of x and y (the operator values being added) in the case of each algorithm and each operator phase. I won't reproduce it here because it basically amounts to the same information as the diagrams of the operator connections in the algorithms, but here's the key points. Remember the operator unit stores 3 values, "Old 1" (two evaluations ago), "1" (most recent evaluation of operator 1), and "2" (most recent evaluation of operator 2). In the phase where op_result_internal is 2 (and we're beginning to evaluate operator 1), X is always "Old 1" and Y is always "1". This matches all previous results. In the phase where op_result_internal is 4 (and we're beginning to evaluate operator 3), sometimes X is "2" and sometimes Y is "1", for the appropriate algorithms. That is, operator 3 is always calculated from the most recent results of operators 1 and 2, but those will be the results received 1 and 3 phases ago and therefore BEGUN 3 and 5 phases ago. (Which is which depends on whether the overall order is 1324 or 1423.) In the phase where op_result_internal is 1 (and we're beginning to evaluate operator 2), sometimes Y is op_result_internal (for the appropriate algorithms). This is the most recently evaluated result from operator 1, just finishing now; also available (about to be overwritten) are the previous two results from operator 1, but these are not used (consider this confirmed). That is, operator 2 is always calculated from the most recent result of operator 1, the one whose calculation was begun 2 phases ago. Finally, in the phase where op_result_internal is 3 (and we're beginning to evaluate operator 4), "1", "2", and op_result_internal (i.e. 3) are all used as necessary. [/QUOTE] Again, I don't get what you mean by "op_result_internal is X / we're beginning to evaluate operator Y) ", seems like 1/2 and 3/4 go in pair for some reason I don't understand. Also, what is that "phase" you are talking about? [QUOTE] Sauraen wrote:The overall conclusion is that, yes, in all cases an operator's value is calculated from the most recent result of the required operator (except of course for the feedback, which intentionally uses the last two values of operator 1). However, this most recent result could have been received up to 3 phases ago and therefore begun evaluating up to 5 phases ago. [/QUOTE] What do you mean by "received'"? I don't understand what that last sentence is implying either. [QUOTE] Sauraen wrote:Therefore, I retract my previous statement that evaluating the operators in some other order (3142 or something) will produce the correct result--it won't. If every operator is evaluated all at once (how it would normally be done in code rather than in VLSI), there has to be storage for up to 5 phases. This is how I would organize the code, assuming that the evaluation order is actually 1324. It's based on exactly what the chip does in the same order: Each operator has a variable for its most recent output, op[n].output. (n is 1-indexed here for consistency with the above) Three other variables are available: outOld1, out1, out2 (probably not named these things!) Evaluate operator 1 using outOld1 and out1. Also copy op[2].output to out2. Evaluate operator 3 using out1 and out2. Evaluate operator 2 using op[1].output. Also copy out1 to outOld1 and op[1].output to out1. Evaluate operator 4 using out1, out2, and op[3].output. If it turns out that the actual order is 1423, simply switch the steps for evaluating operators 3 and 4. [/QUOTE] I don't understand, evaluating operators in order 3142 could give the exact same result as above , with: [*] op3 using out1 and out2 [*] op1 using outOld1 and out1 then copy out1 to outOld1 and op[1].output to out1. [*] op4 using out1 (same as op[1].output at this stage), out2 and op[3].output [*] op2 using out1 (same as op[1].output at this stage), then copy op[2].output to out2. It could even be 1342 with: [*] op1 using outOld1 and out1 then copy out1 to outOld1 and op output to out1. [*] op3 using outOld1 and out2 [*] op4 using out1 (same as op[1].output at this stage), out2 and previous op ouput (corresponding to op[3].output at this stage) [*] op2 using out1 (same as op[1].output at this stage), then copy op output to out2. with the benefit of not needing to store the output of each operator but only the last calculated output, by cleverly using the other three existing registers keeping old op1 / op2 outputs. In any case, unless I'm missing something, I don't see the difference with what you described in your initial post. [QUOTE] Sauraen wrote:THEREFORE, I think the MEM thing is wrong, or at least your description of it is. (I certainly can read C, but that's about the least readable C I've ever seen!) [/QUOTE] I agree Jarek's implementation can be quite complex to read, it took me quite some time to get familiarized with it but I can assure you the MEM thing does exactly what you are describing (i.e it corresponds to the modulation input used for op3, which is either out1, out2 or the addition of both). I can explain it if you (or anyone) are interested. Basically, in "setup_connection" function, memory pointers are used to connect (depending on algorithm): - the output of op1 (CH->connect1) to either intermediate register (mem), modulation inputs of op2 (c1) and op4 (c2) or accumulator (out_fm). - the output of op2 (CH->connect2) to either intermediate register (mem) or accumulator (out_fm). - the output of the intermediate register (CH->mem_connect) to modulation input of op3 (m2) or op4 (c2) - the output of op3 (CH->connect3) to either modulation inputs of op4 (c2) or accumulator (out_fm). NB: the output of op4 (CH->connect4) is always connected to accumulator (out_fm) by default Next, in "chan_calc" function, the intermediate register output (CH->mem_connect) is updated with saved mem value and operator outputs are calculated sequentially and added o to their respective CH->connect, with the exception of op1. For some reason, the output of op1 (CH->connect1) is updated with out1 value (previous op1 output) BEFORE op1 output is effectively calculated and copied to out1. The result is that it works the same as what you describe with the exception that: - op2 & op4 are using out1 instead of op[1].output - op3 is using outOld1 instead of out1 As I said, I'm not sure if this is intended or a mistake made when dealing with out1 and outOld1 (CH->op1_out[1] and CH->op1_out[0] in MAME code) . [QUOTE] Sauraen wrote:No matter how you cut it, operator 2 gets evaluated with the most recent output from operator 1, and similarly operator 4 uses the most recent output from operator 3. Those are clear. The tricky part is that assuming it's 1324, operator 4 is evaluated with the result of operator 2 which was calculated 5 phases ago, not the one from last phase (on the chip it's still not done yet). Similarly, operator 3 is evaluated with the 5-phase-old operator 1 value, not the one from 1 phase ago. (If it's actually 1423, the only difference is that now operator 4 uses the old operator 1, and operator 3 uses the old operator 2.) [/QUOTE] From what you said before, in both cases, op3 uses the old op2 output. Or you mean that with 1423, it would use new op2 output? ######## POST p29477 | Sauraen | 2016-04-19 | t386-780.html [QUOTE] Eke wrote:Ouch [/QUOTE] I don't have time right now for a giant answer, but I think this is what you're missing. Please also refer to my operator unit VHDL code I linked in the previous post. The operator unit, like all the other units in the YM2203, is pipelined. It takes six internal clock cycles to compute the output of an operator. But at any given moment, the six pipeline stages are all working on a different operator's data. So for instance, at one instant in the operator unit: Pipeline stage 1, the creation of the feedback/modulation signal, is processing channel 1 operator 2 Pipeline stage 2, the feedback shifter and adder of the PG phase, is processing channel 3 operator 3 Pipeline stage 3, the logsin table and adder of the EG attenuation, is processing channel 2 operator 3 Pipeline stage 4, the exponential table, is processing channel 1 operator 3 Pipeline stage 5, the floating-point-to-integer conversion, is processing channel 3 operator 1 Pipeline stage 6, which doesn't do any processing, is holding channel 2 operator 1 This example is under two assumptions, first that the operator order is 1324 [EDIT: later confirmed], and second that the chip processes the same operator from each channel before going to the next operator (it processes operator 1 of all three channels, then operator 3 of all three channels, etc.--[EDIT: later confirmed]). Because of this pipeline, in any given stage, every 3 clock cycles an operator from our chosen channel is being processed. But the previous and next stages are at the same time processing different operators from different channels. So therefore, at stage 1 above (which produces the feedback/modulation signal and is critical for answering the question of which cycle's value is used), in clock cycle 0, channel 1 operator 1 is being processed in clock cycle 3, channel 1 operator 3 is being processed in clock cycle 6, channel 1 operator 2 is being processed in clock cycle 9, channel 1 operator 4 is being processed with the other channels' operators being processed in the intervening clock cycles. This is the origin of my term "phase"--we can ignore the other channels for now and say there are 4 phases, during each one a different operator is being processed. Since it takes 6 cycles (2 phases) for an operator's value to finish being processed, in the above example operator 1 was begun on cycle 0, which means it's done and its result is available on cycle 6, which is also when operator 2 is being processed (again just by this one pipeline stage). So the question was whether at that time, the unit takes the just-finished value of operator 1, or uses the previously-stored value of operator 1, when calculating the modulation value which will be used for operator 2. And the answer, which I confirmed from the control unit, is that it takes the just-finished value of operator 1, not the old (and definitely not the oldold) value. ######## POST p29478 | Sik | 2016-04-20 | t386-780.html Is it me or are you all overcomplicating things? Can't you just do it like the YM2612 and just process one operator at a time? (whether a new or an old value gets used will be implicitly handled by just doing that) ######## POST p29479 | Mask of Destiny | 2016-04-20 | t386-780.html [QUOTE] Sik wrote:Is it me or are you all overcomplicating things? Can't you just do it like the YM2612 and just process one operator at a time? (whether a new or an old value gets used will be implicitly handled by just doing that) [/QUOTE] So the point that Sauraen is making is that the YM2612 doesn't exactly process one operator at a time (well assuming that it behaves like the YM2203 that it is based on anyway). Any given stage in the operator pipeline evaluates a single operator at a time, but the stages are operating in parallel and won't be processing the same operator. Depending on the order of evaluation it's possible that an "old" value is used when modulating due to the pipeline latency. That said, if it iterates through an operator for all the channels first (a big assumption at the moment) then it's not going to be an issue on the YM2612, regardless of operator evaluation order, since there are as many channels as there are pipeline stages. Of course, it's conceivable that it processes all the operators for part 1 before moving on to the part 2 operators in which case the behavior would be the same as the YM2203. ######## POST p29480 | Sauraen | 2016-04-20 | t386-780.html [QUOTE] Sik wrote:Is it me or are you all overcomplicating things? [/QUOTE] Yes, we are, in so far as I can't even think of a test sound that would sound audibly different whether modulators were delayed by a cycle or not. [QUOTE] Sik wrote:Can't you just do it like the YM2612 and just process one operator at a time? [/QUOTE] [QUOTE] Mask of Destiny wrote:the YM2612 doesn't exactly process one operator at a time [/QUOTE] Exactly. However... [QUOTE] Mask of Destiny wrote:if it iterates through an operator for all the channels first (a big assumption at the moment) then it's not going to be an issue on the YM2612, regardless of operator evaluation order, since there are as many channels as there are pipeline stages. [/QUOTE] Nope. I purposely didn't include any discussion of the YM2612 in the last post (though I have in past posts, plus it's covered in the VHDL model), because it's in fact MORE complicated than the YM2203, not less. For starters, the YM2612 pipeline contains a 6-stage-long shift register with the sole purpose of delaying the operator evaluation so that it's actually 12 cycles, not 6. This makes sense, because if we double the number of channels and also double the number of pipeline stages, the algorithm will be the same as in the YM2203. [EDIT: the following is not true] I am guessing, though I have not confirmed this in any way, that the chip evaluates the channels in the order 1-4-2-5-3-6; that is, it evaluates channel 1, then channel 1 in the high bank, then channel 2, etc.[EDIT: later confirmed to be 123456] So if you want to consider this all from the YM2612, in my last post make the cycles listed 0-6-12-18 instead of 0-3-6-9. Still, the result from operator 2 is available when operator 1 is being calculated, and so on--the logic is exactly the same. ######## POST p29490 | r57shell | 2016-04-21 | t386-780.html Anyway you overcomplicating things. Sorry if I'm being captian obvious [IMG ./images/smilies/icon_biggrin.gif] Let say 1) We have 3 workers. 2) Each has different profession. So, he can do only single type of job. 3) They can't do several jobs at once. 4) They do only single type product. 5) Time to make any kind of job are equal between. So, making this product, requires steps: First worker (A) don't need anything, and can create, starting product = completion state 1 Starting product can be updated to next completion state only by second worker (B) = completion state 2 And last completion state is made by last worker (C) = finished product = completion state 3 In time zero - we don't have any product. All workers free, but only A can do his job. [CODE] A B C 1 X X [/CODE] where A B C - workers, 1 - id of product, X is - slacking (does nothing) Next time, A can start make next, B has to do... so whole table will looks like this: [CODE] A B C 1 X X 2 1 X 3 2 1 4 3 2 5 4 3 .... 500 499 498 ... [/CODE] Idea simple: all workers "update" product to next completion state. And, you don't need to have 6 workers for each kind of job (6*3), to make 6 products. Here is same, difference is, products are remade. Channels results remade. I'll use term Channel, for 6 FM channels, and Operators, for 4 operators. (just to make it strict, at least for myself, because I was struggling to remember this stuff) So, from scratch I suppose it should look like: [CODE] A B C 1 3 2 2 1 3 3 2 1 1 3 2 2 1 3 ..... [/CODE] But taking into consideration, that there is 6 channels, 4 operators. So, we call "product" as channel output. Number of workers = number of steps to update one operator. One important addition in this case, that each worker must do his job 4 times (must do his job for each operator) Let say, workers again 3, then sequence will look like [CODE] A B C 11 64 54 21 11 64 31 21 11 12 31 21 22 12 31 32 22 12 13 32 22 23 13 32 33 23 13 14 33 23 24 14 33 34 24 14 41 34 24 21 41 34 ... 54 34 24 64 54 34 ...repeat... [/CODE] where first digit is - channel id, second is operator id processed. They can place it in other order... For example... whole cycle of channels first, then operators. Anyway, each channel update time will take only 6*4 steps, and will do all jobs at once (all workers are busy). But what I consider, should be taken from this example, is that result is not dependent to order of channels. So, you can think as about processing single channel. and only order of updating operators, and completion steps (you may say phase), does matter. Summary, I think, process should be well explainable by defining N steps. (jobs in previous examples), and their order for operators. For previous example, it is representable as array: A1 B1 C1 A2 B2 C2 A3 B3 C3 A4 B4 C4 (job, operator) To verify that, you may replace all numbers starting not from 1, to XX, and see, that processing of single channel does exactly in this way. So, in my theory, all chanels should be indpendent. ######## POST p29498 | Sauraen | 2016-04-21 | t386-780.html [QUOTE] r57shell wrote:all chanels should be indpendent [/QUOTE] Yes, I wasn't saying they weren't. Obviously parameters of one channel don't affect the others (at least not until we get to the DAC...). The order of evaluation of the channels won't make any difference to whether a software implementation produces a sample-accurate result or not. It does make a difference to my VHDL code, though--otherwise the channels will all work, but which channel's registers and values are being used by which units on what cycles will be all mixed up. (E.g. I might have ch3 op4 getting its envelope attenuation value from ch6 op4 or from ch3 op3.) ######## POST p29499 | r57shell | 2016-04-21 | t386-780.html [QUOTE] Sauraen wrote:It does make a difference to my VHDL code, though--otherwise the channels will all work, but which channel's registers and values are being used by which units on what cycles will be all mixed up. (E.g. I might have ch3 op4 getting its envelope attenuation value from ch6 op4 or from ch3 op3.) [/QUOTE] But it does not happen in YM2612? So, it may happen to your VHDL due to your bug? [IMG ./images/smilies/icon_smile.gif] I guess you can make automatic tests, that will test, that each phase access to variables only same channel, no? ######## POST p29501 | Sauraen | 2016-04-22 | t386-780.html What I mean is that behind all this crazy pipelining in the YM2612 is a number of control units which each have exactly the correct number of delays in each signal so that all the signals used in each channel are correct. There's no question that this is implemented correctly in the YM2612, and the particular order doesn't affect the sounds, so it's not relevant for a software implementation. However, my VHDL version (of which right now only the operator unit exists) attempts to match the original chip structure in every detail, not just the resulting functionality. So if I have a mistake in any of the control units--which is very likely because I don't actually map every gate one at a time, I learn as much as I need to from the die and make up the rest--the output will be all mixed up and obviously wrong. At this point I'm not even trying to make the VHDL version into a working implementation, I'm more using it to describe my findings in the chip. ######## POST p29508 | Eke | 2016-04-22 | t386-780.html [QUOTE] Sauraen wrote: I don't have time right now for a giant answer, but I think this is what you're missing. [/QUOTE] Thanks, it's a lot more clearer now, I totally missed the pipeline stuff. I also made a sheet (with configurable channel / operator order) which helped me figuring what you were referring to (see zipped file attached) [IMG ./download/file.php?id=48&sid=450ef40075b16b98a546345d13036eef] ym2612_pipeline.png (100.89 KiB) Viewed 125109 times This also helps to understand what you meant when you said it could be either 1324 or 1423. [QUOTE] Sauraen wrote: This example is under two assumptions, first that the operator order is 1324 (it might be 1423), and second that the chip processes the same operator from each channel before going to the next operator (it processes operator 1 of all three channels, then operator 3 of all three channels, etc.--this is probably not correct, it's probably in an interleaved order, but that wouldn't change the discussion below). [/QUOTE] I think 1324 makes more sense because of the operator register address order (lower address is Op1, then Op3, Op2, Op4) and the fact operators are designed to work paired initially (a modulator then a carrier). I guess that the strange channel order and the spacing (4 FM cycles between each channel output, with output remaining available during 1 FM cycle) observed by Nemesis could possibly help figuring the exact channel order as well as how operators are interleaved for each channels by tring different combinations. cf.this post: viewtopic.php?f=24&t=386&start=369 [QUOTE] Sauraen wrote:So the question was whether at that time, the unit takes the just-finished value of operator 1, or uses the previously-stored value of operator 1, when calculating the modulation value which will be used for operator 2. And the answer, which I confirmed from the control unit, is that it takes the just-finished value of operator 1, not the old (and definitely not the oldold) value. [/QUOTE] So this confirms there is an error in MAME implementation regarding Op1 output calculation as both Op2 & Op4 always use Op1 output from previous sample (one sample delay) and Op3 always use Op1 output from two samples ago (one sample delay + MEM register delay). This also causes Algorithm7 to output to accumulator/DAC the previous output of Op1 combined with current output of Op2/Op3/Op4, which definitively seems wrong. So the code below [CODE] INT32 out = CH->op1_out[0] + CH->op1_out[1]; CH->op1_out[0] = CH->op1_out[1]; if( !CH->connect1 ){ /* algorithm 5 */ mem = c1 = c2 = CH->op1_out[0]; }else{ /* other algorithms */ *CH->connect1 += CH->op1_out[0]; } CH->op1_out[1] = 0; if( eg_out < ENV_QUIET ) /* SLOT 1 */ { if (!CH->FB) out=0; CH->op1_out[1] = op_calc1(CH->SLOT[SLOT1].phase, eg_out, (out<FB) ); } [/CODE] should be corrected to [CODE] INT32 out = CH->op1_out[0] + CH->op1_out[1]; CH->op1_out[0] = CH->op1_out[1]; CH->op1_out[1] = 0; if( eg_out < ENV_QUIET ) /* SLOT 1 */ { if (!CH->FB) out=0; CH->op1_out[1] = op_calc1(CH->SLOT[SLOT1].phase, eg_out, (out<FB) ); } if( !CH->connect1 ){ /* algorithm 5 */ mem = c1 = c2 = CH->op1_out[1]; }else{ /* other algorithms */ *CH->connect1 += CH->op1_out[1]; } [/CODE] [QUOTE] Sauraen wrote: [QUOTE] Sik wrote:Is it me or are you all overcomplicating things? [/QUOTE] Yes, we are, in so far as I can't even think of a test sound that would sound audibly different whether modulators were delayed by a cycle or not. [/QUOTE] I am not sure, the fact that the delay was implemented in MAME (through the use of MEM value) likely means Jarek was able to notice it while testing the hardware. He wouldn't have used that complicated implementation if it wasn't worth it. By the way, it's one of the missing thing not emulated in Exodus because Nemesis was not 100% sure how this worked so I believe this is still an interesting thing to understand correctly. Anyway, my initial question was more to figure if there was an error in MAME implementation or not. Attachments YM2612-pipeline.zip (19.81 KiB) Downloaded 3397 times ######## POST p29512 | Mask of Destiny | 2016-04-22 | t386-780.html [QUOTE] Eke wrote:I am not sure, the fact that the delay was implemented in MAME (through the use of MEM value) likely means Jarek was able to notice it while testing the hardware. He wouldn't have used that complicated implementation if it wasn't worth it. [/QUOTE] Wasn't the MAME implementation originally somewhat generic in that could emulate multiple members of the OPN family? Is it possible it's only observable on certain chips it supported? [QUOTE] Eke wrote:By the way, it's one of the missing thing not emulated in Exodus because Nemesis was not 100% sure how this worked so I believe this is still an interesting thing to understand correctly. [/QUOTE] I've avoided any emulation of the MEM stuff in BlastEm for similar reasons (though there are still other unrelated things I'm missing). I'd certainly be interested in the actual behavior too. There's something I'm a bit unclear on here with regards to overall timing. On the YM-2612 it's known that it takes 144 cycles of its input clock to process all the operators for all 6 channels. Previously, my assumption was that operators were processed in a relatively linear fashion and that processing an operator took 6 cycles. 6 cycles * 6 channels * 4 operators per channel does indeed get you 144 cycles. With a pipelined design, while the execution time of a single operator would indeed be 6 cycles (or 12 in the YM-2612 as you mentioned before due to the extra dummy stages), the overlap in execution means that it only takes 24 cycles to process all the operators (ignoring the 12 cycle overlap with the next runthrough anyway). Is there in fact an internal /6 divider on the clock line or do these pipeline stages take 6 cycles to execute? Alternatively, is there something else I'm missing? ######## POST p29513 | Sauraen | 2016-04-22 | t386-780.html [QUOTE] Mask of Destiny wrote:Is there in fact an internal /6 divider on the clock line [/QUOTE] Yup, this has been known for a while. It takes 24 INTERNAL clock cycles to evaluate everything, which is 144 external clock cycles. [QUOTE] Mask of Destiny wrote:Wasn't the MAME implementation originally somewhat generic in that could emulate multiple members of the OPN family? Is it possible it's only observable on certain chips it supported? [/QUOTE] All my work so far has been from the YM2203 die because it's clearer, and then cross-checking things with the YM2612 die when necessary. They're similar enough that my VHDL operator unit covers both of them, and there's no reason MAME couldn't. But if there is a difference, it might have to do with the DAC versus the shift register output section. By the way, the difference in channel order in the YM2612 may be observable, in so far as the YM2612 outputs the channel values sequentially. That's actually where I got the 1-4-2-5-3-6 order from, I think it was Nemesis or someone who posted those findings years ago. Now, just because the chip outputs the channels in that order doesn't necessarily mean it processes them in that order, but it's a strong hint. The reason I say it's not guaranteed is that if the chip processes all the channels of one operator before going to the next operator, and then just outputs the results after operator 4 finishes, it'll have no results for 18 cycles (while operators 1, 3, and 2 were being processed) and then spit out 6 results in quick succession. Instead we know that the results are uniformly spaced, implying that there's more going on here. [EDIT: this is wrong. For any operator, channels are processed in the order 123456. But at the same time, channels are output in the order 153264, with each channel value held for four cycles. Disregard the below also.] Edit: Actually Eke linked us back to Nemesis's post about this, evidently it's 4 internal clocks of zero and then 1 of a value... Hmm. And if he got 1-5-3-2-6-4, that would mean: 1 X X X X 5 X X X X 3 X X X X 2 X X X X 6 X X X X 4 X X X X which adds up to 30 cycles, nah that's not right. It's gotta be 3 internal clocks of zero and 1 of a value. 1 X X X 5 X X X 3 X X X 2 X X X 6 X X X 4 X X X Let's fill in some blanks... 1 2 3 4 5 6 1 2 3 4 5 6 1 ut-oh! That still doesn't quite work out, simply because we know that 12 cycles after a particular channel is being evaluated (at a particular unit), a different operator from the same channel is being evaluated at the same unit. However, it clearly is 3 internal clocks of zero and 1 of a value--a couple posts down from that one of Nemesis it shows the output along with the master clock. It's clearly 18 master clocks (3 internal) between the beginning of the falling edge and the rising edge, and 6 master clocks (1 internal) between the beginning of the rising edge and the falling edge. Of course the text there is meaningless, because they're talking about an embedded serial DAC which has long since been disproven. ######## POST p29515 | Mask of Destiny | 2016-04-22 | t386-795.html [QUOTE] Sauraen wrote: [QUOTE] Mask of Destiny wrote:Is there in fact an internal /6 divider on the clock line [/QUOTE] Yup, this has been known for a while. [/QUOTE] You know, now that you mention that I'm sure I had read as much, but I must have discounted it since there was way too much going on for it to finish in a cycle. I just failed to take into account the possibility of pipelining. Oh well. [QUOTE] Sauraen wrote:By the way, the difference in channel order in the YM2612 may be observable, in so far as the YM2612 outputs the channel values sequentially. [/QUOTE] Observable if you bypass all the analog filtering circuitry anyway. From an emulation perspective, the only way it probably matters involves how the order of processing interacts with the funky register file and register write timing. [QUOTE] Sauraen wrote:It's gotta be 3 internal clocks of zero and 1 of a value. 1 X X X 5 X X X 3 X X X 2 X X X 6 X X X 4 X X X Let's fill in some blanks... 1 2 3 4 5 6 1 2 3 4 5 6 1 ut-oh! That still doesn't quite work out, simply because we know that 12 cycles after a particular channel is being evaluated (at a particular unit), a different operator from the same channel is being evaluated at the same unit. However, it clearly is 3 internal clocks of zero and 1 of a value--a couple posts down from that one of Nemesis it shows the output along with the master clock. It's clearly 18 master clocks (3 internal) between the beginning of the falling edge and the rising edge, and 6 master clocks (1 internal) between the beginning of the rising edge and the falling edge. [/QUOTE] I think I know why it's 3 clocks of zero and 1 of value: Algorithms 5-7. Those algorithms require adding together more than 2 operators for the output. I bet those zeros become the output of operators 1-3. I wonder if we can exploit that to observe the operator update order. ######## POST p29516 | Sauraen | 2016-04-23 | t386-795.html [QUOTE] Mask of Destiny wrote:From an emulation perspective, the only way it probably matters involves how the order of processing interacts with the funky register file and register write timing. [/QUOTE] And that only matters for emulators that actually care about write timings, i.e. Exodus. [QUOTE] Mask of Destiny wrote:I think I know why it's 3 clocks of zero and 1 of value: Algorithms 5-7. Those algorithms require adding together more than 2 operators for the output. I bet those zeros become the output of operators 1-3. I wonder if we can exploit that to observe the operator update order. [/QUOTE] In the YM2612 (not in the YM2203) there is, after the operator unit and before the DAC, a unit that looks at first glance like it contains 2 sets of 6-stage shift registers, plus some other stuff, all 9 bits wide. This is also where the DAC value bits and some relevant control wires enter. So obviously this unit is adding up operator values and giving them to the DAC. (Worth mentioning that the 14-bit operator outputs are lopped off to 9 bits before this unit, no rounding or anything, and the adder which adds the operator input to the stored value also must be only 9 bits.) If I do a thorough reverse engineering of this unit, we'll have our answers about the output timing. But it's hard to read actual logic from the YM2612 die shot--that's why I mostly stick to tracing wires in that die, and actually reading gates from the YM2203. (But of course this unit is not present in the YM2203.) I doubt it's as simple as the 3 zeros are for the three silent operators. Otherwise, when using algorithm 7, we'd get the four operator values out one at a time. And also that would mean that the chip was processing the four operators in consecutive cycles, which is not true (or storing them to emulate this behavior, which would be silly). ######## POST p29523 | r57shell | 2016-04-23 | t386-795.html [QUOTE] Sauraen wrote: [QUOTE] Mask of Destiny wrote:Is there in fact an internal /6 divider on the clock line [/QUOTE] Yup, this has been known for a while. It takes 24 INTERNAL clock cycles to evaluate everything, which is 144 external clock cycles. [/QUOTE] Hmm, if /6 then 24 cycles for whole processing? We have 6 channels 4 operators = 24 operators in total. Also, we have X "jobs" (stages / steps). 6*4*X = total things to do. One of X takes T time. Y pipes. Summary, total time is: 6*4*X*T/Y = 144. X*T/Y = 144/(6*4) = 6 X*T/Y = 6 So, one of possible implementation is: X = Y, and T = 6. So, pipes (workers) Y = X (stages / steps). Other possible solution: T = 3. It's if you trigger both: CLK rising, and CLK fall. Same as in M68k. Then X*3/Y = 6. X/Y = 2. Stages in twice more than wokers. Anyway, equation X*T/Y = 6. [IMG ./images/smilies/icon_smile.gif] We know, that period of output is 24. Ley say, X = Y. Then all is doable in straight forward way. [CODE] A B C D E F 1 2 3 4 5 6 11 44 64 24 34 54 0 1 0 0 0 0 0 out 1 from previous 24 cycle 51 11 44 64 24 34 1 1 0 0 0 1 0 31 51 11 44 64 24 2 1 0 1 0 1 0 21 31 51 11 44 64 3 1 1 1 0 1 0 61 21 31 51 11 44 0 1 1 1 0 1 1 out 2 from previous 24 cycle 41 61 21 31 51 11 1 1 1 1 1 1 1 12 41 61 21 31 51 2 1 1 1 1 1 1 52 12 41 61 21 31 3 1 1 1 1 1 1 32 52 12 41 61 21 0 1 1 1 1 1 1 out 3 from previous 24 cycle 22 32 52 12 41 61 1 1 1 1 1 1 1 62 22 32 52 12 41 2 1 1 1 1 1 1 42 62 22 32 52 12 3 1 1 1 1 1 1 13 42 62 22 32 52 0 1 1 1 1 1 1 out 4 from previous 24 cycle 53 13 42 62 22 32 1 1 1 1 1 1 1 33 53 13 42 62 22 2 1 1 1 1 1 1 23 33 53 13 42 62 3 1 1 1 1 1 1 63 23 33 53 13 42 0 1 1 1 1 1 1 out 5 from previous 24 cycle 43 63 23 33 53 13 1 1 1 1 1 1 1 14 43 63 23 33 53 2 1 1 1 1 1 1 54 14 43 63 23 33 3 1 1 1 1 1 1 34 54 14 43 63 23 0 1 1 1 1 1 1 out 6 from previous 24 cycle 24 34 54 14 43 63 1 1 1 1 1 1 1 64 24 34 54 14 43 2 1 1 1 1 1 1 44 64 24 34 54 14 3 1 1 1 1 1 1 [/CODE] Last 6 columns is "up to date from last 24 cycle". So channel output always store value from 24 (144) cycles back. Nothing bad in this delay, because anyway you can't do faster, except if you calculate faster. Anyway you need 24 cycles to make 6*4 operators. Ah... to make it easier to understand. In any way... there is last Stage (in this example stage F), and there is last operator (in this example operator 4). So, time for certain chanell from update to update is equal to delay from appearing this channel in last Stage with last operator. So, channel 4 is updating when last operator of channel 4 appearing in last stage (in example 44 at stage F). As far, as whole sequention has period of 24, thus sequention of operators appearint at last stage (F) has period 24 too, so update time is equal to 24, and during whole that time, it has previous value. It does not matter when we output this value, anyway it's same during 24 period. Ok, now I shut up, because... I can't help with figuring out die. I can't even open it. (: But, it would be nice, if someone would crop its units in separate images and mark all input wires. And known ones, named somehow, so we could look at it as several more small units with pins. like as some blackbox with pins. If someone made it already, then I'm slowpoke [IMG ./images/smilies/icon_sad.gif] ######## POST p29525 | Sauraen | 2016-04-23 | t386-795.html I'm not sure why you're trying to figure out the pipeline stages, I've already finished that, the information is in my VHDL operator unit at https://github.com/sauraen/YM2612/blob/ ... erator.vhd . There are five stages that actually do work, one that just stores the value, and an additional six-stage delay unit in the YM2612 only which lengthens the pipeline to 12 stages. The PG and EG have their own pipelines. The image I have of the YM2612 die with several layers of drawings on it is 1.6 GB on disk and 5.7 GB loaded into RAM. Probably at some point I should actually label things better, but it will take a huge amount of effort to label every interconnect wire. Here's the overall picture: [IMG http://i.imgur.com/jQnlY70.jpg] ######## POST p29544 | r57shell | 2016-04-24 | t386-795.html [QUOTE] Sauraen wrote:I'm not sure why you're trying to figure out the pipeline stages, I've already finished that, the information is in my VHDL operator unit at https://github.com/sauraen/YM2612/blob/ ... erator.vhd . There are five stages that actually do work, one that just stores the value, and an additional six-stage delay unit in the YM2612 only which lengthens the pipeline to 12 stages. The PG and EG have their own pipelines. [/QUOTE] Trouble that it's hard to verify. I did look at that vhd. What is suspicious for me, that all stages implemented as "process" in your code. I thought, it should be concurent, and what actually process is shift buffer that does shift. I'm not sure, but that is one of my questions around YM2612. [QUOTE] Sauraen wrote:The image I have of the YM2612 die with several layers of drawings on it is 1.6 GB on disk and 5.7 GB loaded into RAM. Probably at some point I should actually label things better, but it will take a huge amount of effort to label every interconnect wire. [/QUOTE] Thanks for brief view of YM2612 internals. I did write app to read it by parts, so I was able to look at it [IMG ./images/smilies/icon_biggrin.gif] I have new question: there is working NES emulator with visualisation of gates in action. I'm wondering what tools did they use to make it in vector graphics. Maybe they have tools suitable to make some represetnation of internal connections, to be able to use it with software processing. With raster images you can verify it only with your own eyes. Better would be have some vector representation, where you can process it and do stuff, like simulation. IDK really. But they made NES, so they did it somehow, maybe they still have all tools available. I can write my own tool for drawing vectors over schematics, and labeling + tracking them. But I guess it's repeating what already done. ######## POST p29553 | Sauraen | 2016-04-25 | t386-795.html [QUOTE] r57shell wrote:What is suspicious for me, that all stages implemented as "process" in your code. I thought, it should be concurent, and what actually process is shift buffer that does shift. [/QUOTE] Keep in mind that in VHDL, all statements in a process are executed sequentially, but in zero time. In reality, the statements in the process represent signals flowing through gates, which do happen sequentially. But all the things in a process are what happens between clock edges, which is why the process is triggered on that clock edge. So basically, I tried to have the statements in the process match the flow of data within one cycle, and the processes themselves match the pipeline stages. Actually, in the chip, any one of these processes is divided into two halves--one with high level-triggered latches, and the other with low-level triggered latches, instead of a single edge-triggered flip-flop. I decided that this would be crazy to try to implement, and also would take much more space on most FPGAs if someone actually tried to compile it. But the only way this would lead to a problem is if there was a timing issue where data had to arrive on the correct half-cycle. ######## POST p30063 | Sauraen | 2016-07-29 | t386-795.html New info! Using MIDIbox Quad Genesis and the test modes, I have confirmed the internal order of calculation of operators and channels. These tests were performed on hardware (DIP) YM3438s, which is what I have in my synth. You may say this isn't helpful, as this is neither YM2612 nor whatever's in the VDP. But I haven't found any differences between the YM3438 and what's described here for the YM2612, even on undocumented features like the test bits and SSG-EG mode. The tests were performed as follows: Turn on read data mode ($21:6 = 1). Select MSB or LSB of read data ($21:7 = 0 for MSB, 1 for LSB--this may be new information) Select the signal that appears on bit 14 of the output ($21:0, and it does seem to make a difference, but I still don't know what the two signals are) Select whether to read operator or channel outputs ($2C:4 = 0 for operators, 1 for channels) Set up to read data from the OPN2 (as if checking whether it's busy). Every OPN2 internal clock cycle, capture a new byte from the bus, for 24 cycles. Print the 24 bytes from the synth to a terminal. The data format is: [CODE] Channel output: (MSB) SX00000C CCCCCCCC (LSB) Operator output: (MSB) SXPPPPPP PPPPPPPP (LSB) where S is the SYNC signal (see below), X is the unknown signal selected with $21:0, C is the 9-bit channel output, P is the 14-bit operator output [/CODE] (I just stuck with reading the MSB all the time, since the LSB doesn't have any timing information so you just get random values. In the case of channel outputs, at least you get one bit of it, so the value is negative half the time and you can see where the 1s are.) I was hoping/expecting that bit 15 (S) would be some sort of sync pulse so I could see where the beginning of the cycle was (and therefore be able to identify every byte subsequently). The results were close to this, but a little confusing. [CODE] Operator output: 111111111100000000000000 Channel output: 111110111000000000000000 [/CODE] Just resetting the chip and setting up the test mode results in each of those patterns on the S signal for the 24 cycles. (Of course, in testing the pattern starts at an arbitrary place in the 24 captured bytes, and wraps around, since I have no idea when in the cycle I start capturing). In addition, during or after playing a note on any channel but channel 4, these patterns are maintained. However, as soon as a single operator of channel 4 starts playing, the S signal changes, and it doesn't change back to this pattern even after the note is keyed off and dies out completely. The new S signal looks like the old one, but with random bits among the first 10 bits, and then all zeros for the remaining 14. Frequently there's only three or four 1s, and they're often spaced out, but they never span more than 10 bits. So it looks like there's some sort of internal sync signal here, which is getting logical-ANDed with some other signal dependent on channel 4. I have NO idea what this is all about--I will do my best to trace this signal on the die. So the S signal can be used as a sync pulse assuming you never played anything on channel 4. Based on that, I could always align the results, and so I measured all the other operators on the other channels, and filled in the blanks according to the pattern for where channel 4 must be (since I couldn't measure it). (For clarity, operator numbers are the ones from the OPNA datasheet, not the Sega docs. The numbering is such that in algorithm 0, the four operators modulate each other in the order 1->2->3->4, and the registers are in the order 1-3-2-4.) [CODE] Operator output: S 111111111100000000000000 Ch 456123456123456123456123 Op 444111111333333222222444 Channel output: S 111110111000000000000000 Ch 226666444411115555333322 or if the S signal should actually be one more step right S 011111011100000000000000 Ch 222666644441111555533332 (though from some attempts at measuring channel 4 output, I believe it's probably the first one) [/CODE] So, in English: for operator processing, it's in the order 1324, with all channels' same operator processed next to each other, and the channels in the order 123456. This makes the most sense, and matches the registers, but it had to be confirmed. For channel output, it's in the order 153264 (which was found earlier by someone else by measuring the output with a scope). There's more work for me to do here, but I figured I'd post what I've found so far. ######## POST p30065 | Sauraen | 2016-07-31 | t386-795.html I should have known. The SYNC signal I was looking for isn't bit 15 of the test read data. It's much simpler than that. It's on the TEST pin. *facepalm.jpg* Bit $2C:7 indeed selects whether the TEST pin is an input or an output. But it's the opposite of what I initially thought (since it was "common knowledge" that the BUSY signal was output from the TEST pin in normal operation). In fact, $2C:7 being 0 means the TEST pin is an input, and 1 means it's an output. The signal it outputs is always the SYNC signal: a pulse that is high for one of the 24 internal cycles, always the same one of course. The state of $2C:6 doesn't affect the SYNC signal being output. (Since I could tell from the die that $2C:6 has something to do with what the TEST input signal does, my guess is it's an enable--if $2C:6 is 0, as in the normal chip, the input is ignored, and if it's 1 the input is used for something. Don't know what it does yet though.) Since the MBHP_Genesis boards I designed support reading back the TEST pin (as well as the IRQ pin and the PSG's DONE signal), I immediately changed the software in my synth to synchronize to the TEST pin instead of bit 15 of the read data. After some experimentation, this is what I'm using: Set $21 to $40 (output data mode) and $2C to $80 (test pin outputs SYNC). Wait for TEST to go high. Wait for TEST to go low (falling edge). Change the parallel interface to read from the OPN2's data output instead of the TEST pin and stuff. Wait 5-and-a-half OPN2 internal cycles. Capture the OPN2 data output, wait an OPN2 internal cycle. Repeat 23 more times. With this 5-and-a-half cycle delay between the falling edge of SYNC and the first data capture, the first data captured is Ch 1 Op 1. And then the remaining operator values captured are each of the channels in order, and then the operators in the order 1324. Voila! So now, whenever it has a little extra time between VGM commands, my synth captures the state of all the operators, calculates the channels' values based on which operators are being output, and displays all the results as VU meters on the front panel. It's quite a light show! And it's the real operators' states, read back from the chip, not an emulation of them. For instance if I turn on SSG-EG mode and push the chip into undocumented waters, the visualization always matches the sound without me having to understand what's actually going on in the EG. Shot a quick video for you all: [IMG http://i.imgur.com/BKdqEXa.jpg] ######## POST p30067 | TmEE co.(TM) | 2016-07-31 | t386-795.html Very awesome ! ######## POST p30069 | Stef | 2016-07-31 | t386-795.html That is really a awesome discover indeed ! Great work again Sauraen ! I really wish i could have used it for my XGM player instead of trying to emulate it :p ######## POST p30080 | foobat | 2016-08-06 | t386-795.html I'd buy one of these if you feel like making 2 instead of 1, Sauraen. Wish I had time to assemble the kit myself, but alas. Hit me up if you feel like making another. I'm flexible on the price. (serious offer btw, I'm fully aware of how much time and effort goes into a project like this) ######## POST p30083 | Sauraen | 2016-08-08 | t386-795.html [QUOTE] foobat wrote:I'd buy one of these if you feel like making 2 instead of 1, Sauraen. Wish I had time to assemble the kit myself, but alas. Hit me up if you feel like making another. I'm flexible on the price. (serious offer btw, I'm fully aware of how much time and effort goes into a project like this) [/QUOTE] I appreciate the offer, but I don't have the time. However, all the parts you would need to make it yourself are either already available for sale (including the sound chip boards, the processor board, and the MIDI board from the MIDIbox Shop , the sound chips from eBay, and all the components from Mouser), or will be for sale once I have more of the software done (the front panel board will be for sale on the same shop, and I will provide the design files for the aluminum front panel so anyone can order one). It took 10 hours for me to solder all the parts in the front panel board, by the way--there's 638 LEDs! But you don't have to build a giant flashy box to get your VGM files playing on hardware Genesises. MIDIbox VGM Player is the stripped-down version with only a few buttons and a screen, which plays VGM files from the SD card on the hardware YM2612 and SN76489. The total cost should be under $100 and while you still need soldering experience, it's much tamer. There's also another project, MIDIbox Genesis Tracker, which is just the processor board and the Genesis board with no interface, and it lets you control the chip by MIDI using the same protocol as Littlescale's GENMDM. This is in beta, so if anyone's interested let me know and I can help you build one! Also I would like to mention that this already is the second unit. The project was commissioned by an indie game composer, Josh Whelchel ; as part of the deal, he paid for two units and I got to keep one, which I'm also developing the software on. ######## POST p30087 | Eke | 2016-08-10 | t386-795.html Yes, that's really a nice synth you have done [IMG ./images/smilies/icon_cool.gif] Thanks for confirming the operator and channel order. I have some questions regarding channel and operator output seen in read data mode, not sure if you were able to figure those: 1) is the format for channel output really 9-bit signed (i.e with sign bit in MSB) or are the values similar to the 8-bit value written to Ch6 DAC register (i.e unsigned value where 0x00 is min and 0xFF is max) ? 2) same for operators, can you confirm the format being output is 14-bit signed (-8192;+8191)? 3) it was reported earlier in this this thread (viewtopic.php?f=24&t=386&start=550 ) that by summing at least two operators, it was possible to have [-256;+256] range in channel output i.e 513 distinct DAC levels while it was normally limited to [-256;+255] with a single operator as carrier. Did you see anything in the channel "accumulator" (or 9-bit "adder", not sure of the right terminology) that could explain this? ######## POST p30088 | Sauraen | 2016-08-10 | t386-795.html 1) It looks like 9-bit signed, but it's a little hard to tell since you have to read the lower 8 bits and the upper 1 bit separately. But it does appear that if there's nothing playing (or after power-up), the values is 0--it would be 0x100 if it was unsigned like you say, and that's definitely not what I'm seeing. So yes, basically confirmed. 2) Yes, definitely 14-bit signed. In my synth I'm just reading the MSB and treating it as a 6-bit signed integer (throwing out bits 14 and 15 which do other things). That's the basis for the VU meters, and as you can see they seem to work. 3) I don't know at this point. I haven't reverse engineered the accumulator unit yet. I can tell you it's 9 bits wide, but it's very possible there's a feature where if the sum clips (which we know it does rather than overflowing), it sets the output to +256. ######## POST p30097 | GManiac | 2016-08-13 | t386-795.html Hi all! I haven't read this topic for many years. Maybe, this info was discussed earlier, maybe I'm repeating myself, if so, pardon me. The subject is "ladder effect". Eke gave link to my old post about DAC output, where I say [QUOTE] operators are shifted arithmetically (not logically) by 5 bits [/QUOTE] Ladder effect is a large step between DAC levels -1 and 0. AFAIR, It is 3-4x times larger than usual step between other levels, for example, between 0 and +1. Arithmetic shift logic and large step makes sound more volumetric and in case of quiet sound makes a big sense (e.g., After Burner, track Super Stripe). Arithmetic shift is important. Why? Let's compare: -1 asr 5 = -1 -1 lsr 5 = 0 -31 asr 5 = -1 -31 lsr 5 = 0 -32 asr 5 = -1 -32 lsr 5 = -1 If our output operator is oscillating between -1 and +1, DAC digital output will be: - in case of arithmetic shift: -1; 0; -1; 0; -1; 0 - in case of logical shift: 0; 0; 0; 0; Because of ladder effect DAC analogue output will be: -3.5; 0; -3.5; 0 If emulator uses 14-bit DAC, it's "analogue output" equivalent will be: -0.03125; +0.03125; -0.03125; +0.03125 (0.03125 = 1.0/32.0). Range between maximum and minimum (0.0625) is 50 times more silent than on hardware! We will here almost nothing. So low bitness of DAC plus arithemtic shift plus large step ladder effect is NOT a bug, but feature! [IMG ./images/smilies/icon_biggrin.gif] When I was writing my YM emulator, i've simulated ladder and can confirm that After Burner sounded correctly. Can anyone add this "feature" to existing emulators / players plugins? Usually I listen music via Maxim's plugin. ######## POST p30098 | Sauraen | 2016-08-14 | t386-810.html [QUOTE] GManiac wrote: [QUOTE] operators are shifted arithmetically (not logically) by 5 bits [/QUOTE] [/QUOTE] The top 9 bits of the 14-bit operator output are sent to the accumulator, which adds the operators within one voice. So there's no question of shifting--it just takes the top 9 bits and discards the bottom 5. Only on PC where you are actually running these calculations in a 32-bit register does it matter which kind of shift you're using. The correct one here would indeed be an arithmetic shift, though depending on your implementation of the saturation (clipping) when operators are added, it may not matter. Remember, these are signed numbers, not unsigned numbers with an extra sign bit. Any emulator which is outputting 14-bit audio is not authentic, simply because the YM2612 DAC is 9 bit. The ladder effect is a result of the resistor string DAC--when the MSB is 0 and the string is between VDD and the midpoint, it pulls up the midpoint voltage slightly, and vice versa when the MSB is 1 and the string is between GND and the midpoint. Basically, the two halves of the range have decent linearity in themselves, but they don't quite meet in the middle. A decent way of emulating this would be to offset negative values by a constant amount (which it sounds like you're doing). Determining what that amount is has probably already been done quite well by someone with a good scope, but I can't do an effective job of that just by reading the die. [IMG ./images/smilies/icon_smile.gif] ######## POST p30102 | Eke | 2016-08-15 | t386-810.html [QUOTE] GManiac wrote: Can anyone add this "feature" to existing emulators / players plugins? Usually I listen music via Maxim's plugin. [/QUOTE] I am emulating the 9-bit DAC (although not 100% accurately for all algorithms since bits 0-4 masking is done after the operator 14-bit outputs have been eventually summed while it should be done on each operator carrier). Problem with emulating the "ladder effect" is that no precise measures/tests have been made on DAC output to actually emulate it accurately, we just know that an "offset" must be added for negative values but I'm still not sure how large it should be and to which levels it should be applied. So I was actually waiting to be able to accurately measure the voltage on MOL/MOR for each 512 DAC levels before implementing something. I guess that we could use the recently discovered 9th bit for Ch6 DAC mode in test register $2C (bit 3) to write a test ROM that outputs all 512 levels by muting all channels except Ch6 and writing directly to DAC register. ######## POST p30919 | jotego | 2017-02-26 | t386-810.html Hi all, I have finished reading the full thread and I have enjoyed every bit of it. Let me add to it now. First, I am working on a verilog module that replicates in hardware the YM2612/YM3438 to a very precise level. The internal operation is likely to be pretty much the same as the original. Everything runs in parallel, with pipelines, circular shift registers and stuff. I had actually developed this architecture when I did the YM2151 clone (the JT51). Then I was asked to do the YM2612, found Sauraen's and Nemesis' findings and was just very glad to see the convergence between JT51 architecture and actual hardware. On this new clone, the JT12, I am getting even closer. BTW, I also want to say thank you to HardWareMan for taking the die pictures. I have seen contributions on this thread of many others, thank to all of you. JT12 is GPL. You can have a look here . The folder hdl contains actual verilog files. Note that the work is not complete yet, though it is probably just a couple of weeks away from completition. You can check the issues page to see then pending tasks. You can also see it working with the current status here . It is running on a MiST FPGA board. Many of the things discussed in the thread make a lot of sense when you take a look at the hardware implementation in the verilog files. Aspects such as the duration of the BUSY signal, or EG behaviour are much clearer when look at from the eyes of a digital design, rather than software. By the way, the operator implementation (jt12_op.v) is pretty much a copy of Sauraen's VHDL file. Although converted to verilog and with style modifications, in essence, it is the same thing. Second, I have a blunt offer to people working on emulators. I think it might make sense to use Verilator in order to obtain a C++ model of the Verilog files, which is cycle-clock accurate. With that model you do not need an emulator, you just get the actual chip running inside your software! Although this might sound like a slow solution, I have seen some YM2612 emulator work which is so high level in terms of objects, abstraction layers, interfaces and stuff that it cannot be fast either! Third, let me make a couple of comments to things that were said at some point in the thread: [QUOTE] HardWareMan wrote: [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] [/QUOTE] I am almost certain that these zig-zags are ESD protection structures. These are compulsory protection circuits that must be placed next to the pads of a silicon die. [QUOTE] Eke wrote: ① 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] This tells about the accumulator behaviour and lack of clamping and resolution. In some aspects, these chips were too cheap [IMG ./images/smilies/icon_sad.gif] [QUOTE] Stef wrote: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. [/QUOTE] The YM3438 application notes PDF does contain a table with the length of BUSY time depending on the register. I have to compare it to my implementation (jt12_reg.v) but at the end we are doing the same thing: we have a circular shift register and we have to wait for the selected register to come out of it so we can insert the new value in its place. Note that in my implementation, the old value comes out and the new value in, so it takes a full 24-operator cycle to get the new value take effect. It is possible to discard the old value but it requires more logic, and if they were mean on the DAC, which is more important, I do not think they will extra logic for this. Well, thanks for reading this long post. I will keep working on JT12 and let you know when completed. ######## POST p30920 | HardWareMan | 2017-02-27 | t386-810.html Hi and welcome! [QUOTE] jotego wrote:I am almost certain that these zig-zags are ESD protection structures. These are compulsory protection circuits that must be placed next to the pads of a silicon die. [/QUOTE] [IMG http://savepic.su/1699689.png] A lot of time is passed. Now I sure that analog output have only one transistor that can only source current. You may clearly see it. [IMG http://savepic.su/1684328.png] As for about this one's, it is strong buffer for clock. It feeds from input logic of CLK pin and have some kind divider or counter (notice: with 6 steps). Also there is some kind shift register right below it. I believe this is main sync circuit, that set starts of any process inside (such start of channel and operator in it). Anyway, I can't be 100% sure until I make better die shots. ######## POST p30921 | Sauraen | 2017-02-27 | t386-810.html HardWareMan is correct, those are large drive transistors, not ESD protection devices. The one between OUT and AVCC is the driver for the output pin, and the two in a pair near the "Control" label are indeed for driving the positive and negative clock lines throughout the chip. These are labeled in my annotated die shot with the blocks labeled. The only sort of protection I've seen on the chip is some sort of resistor on the digital input pins. The YM2612 isn't CMOS so large protection transistors (really diodes) weren't required. ######## POST p30923 | jotego | 2017-03-01 | t386-810.html [QUOTE] Sauraen wrote:The only sort of protection I've seen on the chip is some sort of resistor on the digital input pins. The YM2612 isn't CMOS so large protection transistors (really diodes) weren't required. [/QUOTE] I see. ESD really became popular with CMOS processes. ######## POST p30935 | Eke | 2017-03-14 | t386-810.html [QUOTE] Sauraen wrote: I would go with the LFO, but honestly I haven't found it yet. [/QUOTE] Hi, Recently doing some correction in YM2612 core, I was wondering if you ever figured out the LFO and how it works exactly, especially regarding Phase Modulation. Some questions I have (based on current implementations): 1) how is LFO PM value calculated ? MAME implementation uses an offset table which takes LFO step (0-31) and LFO depth (0-7) as X/Y then use the seven upper bits of the FNUM value as weights to compute an offset value : for (i = 4 to 10) LFO_PM += (FNUM & (1<> (10 - i)) : 0 Exodus use similar table but uses the whole FNUM range (bits 0-10) to calculate LFO PM value and does the bitweight shifting differently: for (i = 0 to 10) LFO_PM += (FNUM & (1<> 9 See also this discussion: viewtopic.php?f=24&t=386&start=480 The difference is that MAME implementation right-shifts LFO table value for each weighted bit BEFORE adding them while Exodus first left-shift all table value, add them and THEN performs right-shift on the final sum. Result is similar but MAME implementation therefore limits itself to 7 upper bits (since right-shifted table values will always be 0 starting from bit3) while Exodus implementation provides additional bits of precision. From hardware point of view, both implementations seem plausible so it's hard to figure which one is correct. 2) how and where exactly is LFO PM value applied ? MAME applies the offset value on the whole BLOCK+FNUM register value, then recalculate BLOCK (which has been possibly impacted by LFO PM), Key-Code (which depends on FNUM and BLOCK) and Detune (which depends on Key Code) values before doing normal PG process on modified FNUM value (BLOCK shift, DETUNE add, etc). It's also notable that there is an additional bit of precision introduced here for some unknown reason (offset value is twice the one used in Exodus but bit0 is not used when adding to BLOCK/FNUM value and is instead injected during BLOCK shift). Exodus directly applies the offset value on the FNUM value then recalculate Key-Code and Detune values before doing normal PG process. Note that, while Key Code is recalculated in both implementations (and is therefore impacted by LFO PM) , Key Scale and EG rates (which depend on Key code value) are never recalculated and therefore not impacted by LFO PM. From an hardware point of view, it seems odd that BLOCK shift value would be impacted, same goes for Key Code if Key Scale is not (unless key code is recalculated by both EG and PG blocks !). I guess it would be a matter of figuring where the LFO PM adder takes place, what it takes as inputs, if it is internal or external to PM block and where its output goes). ######## POST p30937 | Sauraen | 2017-03-14 | t386-810.html [QUOTE] Eke wrote:I was wondering if you ever figured out the LFO and how it works exactly, especially regarding Phase Modulation. [/QUOTE] I never did a full reverse engineering of it, but here's what I have (from private messages to jotego): [QUOTE] Sauraen wrote:The LFO seems to have 3 sections: [*] 7-bit linear prescaler. The test bit 0x21:1 goes into what looks like the carry-in or something similar; it could go into the reset, I can't quite tell with more detailed analysis. The 7-bit output (plus maybe carry-out) gets logiced together into 8 lines (evidently perform "== N" with N hardcoded for each line), and these go into a little selector unit which is also fed by the LFO Speed and LFO Enable bits. I can't quite see the output of this, but I do see there's some sort of feedback to the prescaler's reset. So this clearly seems like a divide-by-N prescaler. I can try to read the eight N's for you if you want, but you should be able to reverse engineer them from knowing what the LFO speeds are. [*] 7-bit linear counter, with an 8-bit unit after the output (possibly inverts the output after each cycle to make a triangle wave?). Bits 1:6 of the output of this go to the EG, and stick into its pipeline at the same place where the LFO->Amplitude two bits go. (Elsewhere the operator LFO enable flag simply forces these two bits to zero for operators not affected by the LFO.) Some modified version of the 8-bit signal between the counter and the inverter unit thing goes to the third unit of the LFO. [*] Highly complex unit which modifies the frequency data as it goes from the channel registers to the PG. The block bits bypass this, but all the frequency bits get modified by it. There's a bitslice portion corresponding to bits 0:6, and then what appears to be the same logic folded over to process bits 7:A. But the interesting part is that bits 4:A of the frequency data go into the bitslices 0:6. That is, the bitslice unit for bit 0 has bit 0 enter at the middle and leave (to the PG) at the bottom. But it also has bit 4 enter at the top. And so on through bit 6 having bit A enter at the top. It looks like the top portion is some sort of shifter for bits 4:A--the wires go diagonally so that bit 4 only gets used once, bit 5 gets used in bitslice 1 and 0, bit 6 gets used in bitslices 2:0, and so on so that bit A gets used in all of them. I'm guessing this whole unit is basically a multiplier, multiplying bits 4:A of the frequency value by bits 0:7 of the LFO state, and then adding the result to bits 0:6 of the frequency value (with carry up to the higher bits). It looks like, between the multiplied output and the adder, there's another shifter whose value is based on the the LFO->Frequency bits. But it looks like it's a bit more complex than I'm describing. [/QUOTE] The upshot is that the LFO is definitely doing frequency modulation, not phase modulation. ######## POST p30938 | Eke | 2017-03-15 | t386-810.html [QUOTE] Sauraen wrote: I never did a full reverse engineering of it, but here's what I have (from private messages to jotego): [/QUOTE] Thanks, it still helps confirming a few stuff [QUOTE] [*] 7-bit linear prescaler. The test bit 0x21:1 goes into what looks like the carry-in or something similar; it could go into the reset, I can't quite tell with more detailed analysis. The 7-bit output (plus maybe carry-out) gets logiced together into 8 lines (evidently perform "== N" with N hardcoded for each line), and these go into a little selector unit which is also fed by the LFO Speed and LFO Enable bits. I can't quite see the output of this, but I do see there's some sort of feedback to the prescaler's reset. So this clearly seems like a divide-by-N prescaler. [/QUOTE] This would be LFO clock generator which is divided from internal clock based on LFO speed bits. Presumably, LFO enable bit halts the LFO clock generator as well as Test register 0x21 bit1 (similarly to YM2151 test register described here: to http://www.msxarchive.nl/pub/msx/mirror ... ym2151.txt ) [QUOTE] I can try to read the eight N's for you if you want, but you should be able to reverse engineer them from knowing what the LFO speeds are. [/QUOTE] According to MAME implementation, values are {108, 77, 71, 67, 62, 44, 8, 5} "sample clocks" where sample clock is internal clock / 24. From the value specified in YM2612 doc, assuming a 8Mhz input clock and 128 LFO clocks per period, 3.98 hz for speed 0 would give 8000000/6/24/3.98/128 = 109 samples between each LFO clock, which is one above MAME specified value. All other speed values give also one additional sample value (72.2 for speed 7 gives 8000000/6/24/72.2/128 = 6 samples) [QUOTE] [*] 7-bit linear counter, with an 8-bit unit after the output (possibly inverts the output after each cycle to make a triangle wave?). Bits 1:6 of the output of this go to the EG, and stick into its pipeline at the same place where the LFO->Amplitude two bits go. (Elsewhere the operator LFO enable flag simply forces these two bits to zero for operators not affected by the LFO.) [/QUOTE] That would be 7-bit LFO step counter (which is incremented on each LFO clock and reset when LFO enable bit is cleared). LFO AM value indeed corresponds to LFO step counter bits 0:5 shifted left by one and XORed with inversion of bit 6 (to generate an inverted triangle waveform) LFO AM sensitivity (2 bits) indicates to EG how much LFO AM value is shifted before adding to EG output [QUOTE] Some modified version of the 8-bit signal between the counter and the inverter unit thing goes to the third unit of the LFO. [/QUOTE] This would be LFO PM step (0-31), which takes bits 2:6 of LFO step counter (0-127) and goes to LFO PM calcuation unit you describe below [QUOTE] [*] Highly complex unit which modifies the frequency data as it goes from the channel registers to the PG. The block bits bypass this, but all the frequency bits get modified by it. [/QUOTE] This would be LFO PM calculation unit and this would confirm BLOCK calculation is not affected by LFO PM. Any chance you have located the "Key Code" calculation unit ? This would be a simple unit with a few OR/AND/NOT gates, taking highest 4 bits of FNUM value as inputs and outputting a 2-bit value (LSB of 5-bit Key Code value, MSB being BLOCK bits). Since this value is used by both EG and PG unit, it's more likely to be external to these units. Whether it interfaces with original frequency bits or the output of LFO PM calculation would indicate if LFO PM really has an impact on Detune value (since it depends on Key code value) as it is currently done in emulator implementations and if EG rates should be impacted as well. [QUOTE] There's a bitslice portion corresponding to bits 0:6, and then what appears to be the same logic folded over to process bits 7:A. But the interesting part is that bits 4:A of the frequency data go into the bitslices 0:6. That is, the bitslice unit for bit 0 has bit 0 enter at the middle and leave (to the PG) at the bottom. But it also has bit 4 enter at the top. And so on through bit 6 having bit A enter at the top. It looks like the top portion is some sort of shifter for bits 4:A--the wires go diagonally so that bit 4 only gets used once, bit 5 gets used in bitslice 1 and 0, bit 6 gets used in bitslices 2:0, and so on so that bit A gets used in all of them. I'm guessing this whole unit is basically a multiplier, multiplying bits 4:A of the frequency value by bits 0:7 of the LFO state, and then adding the result to bits 0:6 of the frequency value (with carry up to the higher bits). It looks like, between the multiplied output and the adder, there's another shifter whose value is based on the the LFO->Frequency bits. But it looks like it's a bit more complex than I'm describing. [/QUOTE] This seems to match with MAME implementation (more than Exodus implementation). If we look at LFO PM offset table used in MAME we can see the max offset value per FNUM bit is 96 (0x60) for when bit 10 is set so this would only require 7-bit addition/substraction (hence bitslices 0 to 6) with carry propagating on higher bits. For following FNUM bits, LFO PM offset are shifted by one, so max value would be : 0x30 (6-bits i.e bitslices 0 to 5) for bit 9 , 0x18 (5-bits i.e bitslices 0 to 4) for bit 8, ... , 0x03 (2-bits i.e bitslices 0 & 1) for bit 5 and finally 0x01 (1-bit i.e bitslice 0 only) for bit 4. I just don't understand the extra bit precision added in MAME implementation: from the chip hardware point of view, this would mean that this unit would takes 11 bits of original Frequency (FNUM) value but output 12 bits and that frequency input of PG unit is actually 12 bit or more, not 11 (with MSBs corresponding to original FNUM and LSB being forced to zero when no LFO modulation is applied) . Another solution is that LFO offset value is calculated as 7 bit (6.1 fixed point) value and the lowest bit is discarded when adding to FNUM value. Would it be possible to confirm or deny this from looking at the die shot ? ######## POST p31026 | Eke | 2017-04-02 | t386-810.html [QUOTE] TmEE co.(TM) wrote:26KHz is the effective max for the YM DAC register from my tests, going higher makes the sound worse. I haven't done any actual investigation but there cannot be anything else happening than missed writes. I played some real music and all the higher freq stuff was getting garbled when you went beyond 26KHz. The game Hellfire has 2x slower music on MD2 than on MD1. The game spams YM with unnecessary writes and is being polite about it (waits for busy). Discrete YM3438 didn't seem to run 2x slower (I no longer remember the result...), but it has issues in other games (I recall Sonic Spinball being one). [/QUOTE] About this one, I've run a few tests on VA4 MD1 (with discrete YM2612) and VA0 MD2 (with 315-5660 ASIC) regarding the BUSY flag and here is what I figured or confirmed from Sauraen die shot analysis : 1) BUSY flag can only be read from port 0 (A0=A1=0) on discrete YM2612 while it can be read from any port on ASIC-integrated version 2) BUSY flag is only set on DATA port writes (A0=1) 2) BUSY flag duration is constant and does not depend on the written register 3) BUSY flag duration seems to be 32 internal clocks (32*6 68k clocks): this was tested with my emulator against real hardware using a test program that counts number of status read with BUSY flag being set. Results were identical to real hardware on emulator with busy wait set to 32*6 68k cycles, other values (like 24, 48 or even 30) give too much different values than real hardware 4) BUSY flag duration is the same on discrete YM2612 and ASIC-integrated chip Now, this also explains why Hellfire music is slower on MD2 with ASIC-integrated FM: as mentioned before, the game spams the FM chip with writes while waiting for BUSY flag to be cleared between each of them. The problem is that they made a mistake in the sound engine as they are reading FM status from the same port they write the data to (i.e port 1 or port 2) so the result is that when run on MD1 (which is likely the model it was developed for), the BUSY flag always appears to be cleared and there isn't enough delay between each writes. This is the reason there is a lot of unnecessary writes being done as they likely noticed there was a problem with their code and they "fixed" it by repeating the same writes multiple times. When run on MD2, the BUSY flag is read correctly and the code this time waits correctly between each write. But since there are a lot of repeated writes because of the workaround implemented for MD1 hardware, it results in slower music. ######## POST p31027 | TmEE co.(TM) | 2017-04-02 | t386-810.html I'd like to add that it is possible to write stuff to YM at sample rate (1 write every 144 YM clocks). I made YM run at same clock as Z80 and made code write one sample every 144 cycles and I got all writes intact. It is not possible to get perfect synchronity to YM like that in normal condition, when 68K accesses Z80 side there are always penalty cycles, aswell as when Z80 accesses 68K side. I'll do more tests around it later on to determine what are the minimum delays per register before data gets missed. ######## POST p31049 | Sauraen | 2017-04-06 | t386-810.html [QUOTE] Eke wrote:Any chance you have located the "Key Code" calculation unit ? This would be a simple unit with a few OR/AND/NOT gates, taking highest 4 bits of FNUM value as inputs and outputting a 2-bit value (LSB of 5-bit Key Code value, MSB being BLOCK bits). Since this value is used by both EG and PG unit, it's more likely to be external to these units. Whether it interfaces with original frequency bits or the output of LFO PM calculation would indicate if LFO PM really has an impact on Detune value (since it depends on Key code value) as it is currently done in emulator implementations and if EG rates should be impacted as well. [/QUOTE] Your intuition seems to be correct. There's a unit at the beginning of the PG which takes the 3 bits of BLOCK, plus two bits from an "unknown source" (I'll call them "pink bits" because I happened to color their wires pink on my annotated chip image), delays them by 1 or 2 cycles, sends the BLOCK bits into the PG, and sends the delayed 5 bits into the PG and the EG. I traced these two pink bits back to a beginning somewhere in the logic for the channel parameter shift registers, and with a little more tracing they are definitely being computed from the top 4 bits of the raw FNUM value, pre-LFO. (By the way, this value is the FNUM for the current operator, including the cases of the operators of voice 3 with their own frequencies.) So unless the key code value is modified later (i.e. the PG's copy of the key code is modified before being used, but I don't think this is happening), it's not affected by the LFO at all. [QUOTE] Eke wrote:I just don't understand the extra bit precision added in MAME implementation: from the chip hardware point of view, this would mean that this unit would takes 11 bits of original Frequency (FNUM) value but output 12 bits and that frequency input of PG unit is actually 12 bit or more, not 11 (with MSBs corresponding to original FNUM and LSB being forced to zero when no LFO modulation is applied) . Another solution is that LFO offset value is calculated as 7 bit (6.1 fixed point) value and the lowest bit is discarded when adding to FNUM value. Would it be possible to confirm or deny this from looking at the die shot ? [/QUOTE] Not so lucky here. 11 bits enter the LFO multiplier thing, 12 bits leave and go to the PG. In fact, the first unit in the PG (unknown function) where these 12 bits enter is actually 16 bits wide: the three LSBs are zero, then the 12 bits from the LFO, then the MSB is also zero. This is followed by another unit which actually has a 17-bit output. These two units are extremely compact custom logic and I can't quite tell their function, but they appear to be shifters; the second one appears to shift right four bits depending on bit 2 of BLOCK, and I think the first one shifts one or two bits based on bits 0 or 1 of BLOCK. The unit after this, which looks like it's adding something (Detune?), is also 17 bits, with no carry-out as far as I can tell. The unit after that is 18 bits and the unit after that is 20 bits, both of which look like more elaborate shifters. Then comes what appears to be the PG state shift register addition and control unit. ######## POST p31050 | Eke | 2017-04-06 | t386-810.html [QUOTE] Sauraen wrote: Your intuition seems to be correct. There's a unit at the beginning of the PG which takes the 3 bits of BLOCK, plus two bits from an "unknown source" (I'll call them "pink bits" because I happened to color their wires pink on my annotated chip image), delays them by 1 or 2 cycles, sends the BLOCK bits into the PG, and sends the delayed 5 bits into the PG and the EG. I traced these two pink bits back to a beginning somewhere in the logic for the channel parameter shift registers, and with a little more tracing they are definitely being computed from the top 4 bits of the raw FNUM value, pre-LFO. (By the way, this value is the FNUM for the current operator, including the cases of the operators of voice 3 with their own frequencies.) So unless the key code value is modified later (i.e. the PG's copy of the key code is modified before being used, but I don't think this is happening), it's not affected by the LFO at all. [/QUOTE] Thanks a lot for confirming that. As said previously, this wasn't very logical to have key code impacted by LFO when calculating detune but not when calculating EG rates. Seems much more logical this way. On a side note, do you happen to have this annotated chip image available somewhere, I couldn't find it back in the thread? [QUOTE] Sauraen wrote:Not so lucky here. 11 bits enter the LFO multiplier thing, 12 bits leave and go to the PG. [/QUOTE] At least, it seems to confirm LFO adds a bit of precision to FNUM 11-bit input, just like Jarek's implementation in MAME is doing. [QUOTE] Sauraen wrote:In fact, the first unit in the PG (unknown function) where these 12 bits enter is actually 16 bits wide: the three LSBs are zero, then the 12 bits from the LFO, then the MSB is also zero. This is followed by another unit which actually has a 17-bit output. These two units are extremely compact custom logic and I can't quite tell their function, but they appear to be shifters; the second one appears to shift right four bits depending on bit 2 of BLOCK, and I think the first one shifts one or two bits based on bits 0 or 1 of BLOCK. [/QUOTE] Yes, I was able to see that as well on the die shot, 16-bit input with only 12-bit in the middle holding value, then converted to 17-bit but I couldn't tell where these 12-bit were coming from so thanks for confirming it comes directly out of LFO PM unit. I guess this is a way of preshifting frequency value before doing BLOCK right-shifting. In MAME implementation, this is done like that: (freqnum << 5) >> (7 - BLOCK) where freqnum = (FNUM<<1) + lfo_offset (12-bit adjusted FNUM value after LFO). Here it seems like it first does something equivalent to doing (freqnum << 3) then does BLOCK shifting in multiple passes To get equivalent formula as above implementation, it would be something like that: 1) 1-bit right-shifting if BLOCK bit 0 is cleared 2) 2-bit left-shifting if BLOCK bit 1 is set 3) 4-bit right-shifting if BLOCK bit 2 is cleared [QUOTE] The unit after this, which looks like it's adding something (Detune?), is also 17 bits, with no carry-out as far as I can tell. [/QUOTE] Yes, quite likely. Detune addition result can indeed overflow and output is 17 bit [QUOTE] The unit after that is 18 bits and the unit after that is 20 bits, both of which look like more elaborate shifters. [/QUOTE] This would be the multiplication unit, not sure why it is 18-bit but it has to handle the case where MUL=0 ( x 1/2) so there must be some pre-shifthing or post-shifting involved. ######## POST p31053 | Sauraen | 2017-04-06 | t386-810.html [QUOTE] Eke wrote:On a side note, do you happen to have this annotated chip image available somewhere, I couldn't find it back in the thread? [/QUOTE] I've posted small segments from it on occasion, but no. It's a 1.6 GB GIMP image with 6 layers or so (just different types of signals, not broken out into the actual chip layers), and it uses 6 GB of RAM to be loaded for editing. Maybe when I'm "done" (whatever that means) I can upload the flattened result somewhere, but even exporting it as a JPG would be ~200 MB. [QUOTE] Eke wrote:I guess this is a way of preshifting frequency value before doing BLOCK right-shifting. [/QUOTE] As you know, hardware doesn't care how a value is aligned, just how many bits it contains. [QUOTE] Eke wrote:This would be the multiplication unit, not sure why it is 18-bit but it has to handle the case where MUL=0 ( x 1/2) so there must be some pre-shifthing or post-shifting involved. [/QUOTE] I think both of the units I mentioned together are the multiplication unit, though I'm still not quite sure--it doesn't look like it has the adders, just the shifters, though maybe the adders are present in the subsequent unit. ######## POST p31153 | jotego | 2017-04-17 | t386-810.html I am glad to see the thread still alive. We do not know everything about the YM2612 yet! [QUOTE] Eke wrote: About this one, I've run a few tests on VA4 MD1 (with discrete YM2612) and VA0 MD2 (with 315-5660 ASIC) regarding the BUSY flag and here is what I figured or confirmed from Sauraen die shot analysis : 1) BUSY flag can only be read from port 0 (A0=A1=0) on discrete YM2612 while it can be read from any port on ASIC-integrated version 2) BUSY flag is only set on DATA port writes (A0=1) 2) BUSY flag duration is constant and does not depend on the written register 3) BUSY flag duration seems to be 32 internal clocks (32*6 68k clocks): this was tested with my emulator against real hardware using a test program that counts number of status read with BUSY flag being set. Results were identical to real hardware on emulator with busy wait set to 32*6 68k cycles, other values (like 24, 48 or even 30) give too much different values than real hardware 4) BUSY flag duration is the same on discrete YM2612 and ASIC-integrated chip [/QUOTE] I actually entered the forum today to talk about this. I didn't expect to find this post. Well, what I am going to say kind of contradicts this information. I spent the last 5 days working on JT51 , adding lessons learnt from the JT12 experience. One tool I made when developing JT51 was a sample accurate operator in C. With some parameters about the operator configuration, the tool produces an output on screen with the exact same sequence as the real YM2151. It is verified against literally thousands of chip measurements as I automated the measurement process to take samples for each set of register values. The YM2151 has digital output, which YM2612 doesn't, so that work is rather easy. (In my case it wasn't because the PCB I made for this was a disaster!) Anyway, on my v1.0 implementation of JT51 I had to make a lot of tricks to get the exact output from the Verilog RTL code. The problem is that one operator, which is called M2 in YM2151 and is equivalent to S3 in YM2612 seems to be getting output in the middle of two samples. Suppose you use algorithm 7 (all operators are just summed at the output. It is supposed to be good for organ sound emulation). Then you would expect samples to have the sum of S1,S3,S2,S4 (or M1,M2,C1,C2 in YM2151 documentation). However, as the keyon is set for all operator on a channel, M2 (S3) gets output one sample ahead of time. This is issue #1. Then, if you go for an algorithm where one operator modulates another, like S1->S2 in alg. 6 (called M1->C1 in YM2151) then if keyon did not occur first on S1 and then on S2, the modulation effect of S1 over S2 would be lost for the first sample. However, in all my measurements I found consistently that modulation was present from the very first sample. I took measurements primarily on channel 0 but I did take many measurements on the other channels to verify whether they were equal or not. They were. (NB: I could not measure channel 7. Only verified 0-6). So keyon order on the operators is important. This is issue #2. So these two issues seem to point at two hardware blocks: Issue #1 -> related to when the accumulator unit resets the output sum, produces and output and starts to sum up the next sample. Issue #2 -> related to when they keyon information gets processed. I fixed these issues on v1.0 with ugly verilog. A hack. I wanted to take Sauraen's work on the operator of YM2612 and take it to substitute my operator unit in JT51. Although the YM2151 had 8 channels instead of the 6 of YM2612 so I had to make some arrangements. As expected, -after many hours of work- the operator did actually work. When comparing outputs from Verilog to outputs from my C emulator -which is exact in value and sample time to the original- I found that issue #1 was manifesting for some algorithms (but not all). So M2 being off by one sample was creating an error in my regression tests. When I look at the waveforms the error signals are virtually identical and the difference is likely not to be hearable at all. But you know what happens to engineers, we want it perfect so eventually I will go back to issue #1 in the future. But as for issue #2, I found that a way to fix it that did not call for a complex implementation was to run the operator update not as a constant time, but at a variable. This is where the busy signal comes in. Let me explain: When the user writes to a register, the internal circular shift registers may be at any point. The easy way to get the new data in is to wait for the shift register to output the old and then feed in the new one. If the user writes data when register 2/5 (operator 2, channel 5) is being output then it just waits (busy on) until the same register 2/5 gets output again. During that time the required register has been traversed too and so the data has been written. I made it that way in JT51 and then in JT12 too. But I think my JT12 implementation may take only 24 cycles instead of 32... I should check. The problem with this is the keyon register. That register must be another circular shift register that holds the key-on state of each operator. But if it was updated as explained on the previous paragraph then sometimes S2 would get the keyon before S1 does and then the first sample of S2 would not contain modulation from S1 as S1 is still in the keyoff state. This is the key aspect here: keyon must occur in order for the operators. At least in YM2151 the keyon for M1 (S1) always occurs before that of C1 (S2) and the modulation is always present. Was it the same for YM2612? I wonder. Note that in order to make S1 keyon happen ahead of time of S2 the register update strategy cannot take a fixed number of cycles. Not at least for keyon writes. This is something I would be very grateful to Eke if he could verify on the real part. Eke has shown that it takes 32 cycles to get the busy signal cleared. But... Does it take 32 cycles too for keyon writes? By the way, you may be thinking that it is not a big deal to update the keyon register in a different way. But when dealing with actual logic gates, the design can get very complex and large easily. The update way I propose is very economical in terms of circuit area and gate count so I bet the original one is like that. I hope I have not lost you with this long post. I know it is hard to follow. Probably even with illustrations it would be hard! ######## POST p31154 | Sauraen | 2017-04-18 | t386-825.html [QUOTE] jotego wrote:I hope I have not lost you with this long post. [/QUOTE] A bit, but one thing I can say from an initial read-through: I am quite confident from viewing the die shots, and it seems to be sufficiently confirmed from testing, that whenever you write a data value, BUSY gets set, and gets cleared exactly 32 cycles later. On the die shot it's just a 5-stage counter, not connected to anything else. Of course the chip actually "consumes" the written data value at some point within the first 24 (or possibly a couple more) cycles of it being written, when its value comes around in whatever circular shift register. (They're all 24 stages or less.) I see that what you're saying is that, as far as you can see, if you write the key on register just after op 1's key on bit came around, it waits until it comes around again so that the key on bits are always updated in the order 1, 3, 2, 4. This is possible--I haven't worked out any of the control units in detail--but this is easily testible. Write all four operators key-on on one cycle. Exactly 24 cycles later, write all of them key-off. On the naive implementation, you will get each operator to output a nonzero value exactly one sample (possibly not all on the same sample, but one each). On your implementation, one of two things will happen: either the new key-on value will overwrite the old, and some of the operators will have never received a key-on; or the new value will be discarded, and some of the operators will remain keyed on afterwards. Both of these conditions should be observable even on one sample (if release is set to a long value, you can notice any operator which was keyed on for only one sample; and as long as decay level is not zero, you can also tell it apart if the operator was never keyed off). The thing is that, if your implementation is correct, it would take a maximum of 18+23=41 cycles to update the keyon states of all four operators. Which means, you could write a certain keyon value, wait the 32 cycles the dumb BUSY timer (and the datasheet) told you to, and then write a different keyon value, and have the output be blatantly incorrect (compared to what the datasheet specified), i.e. have some operators still on or never turned on. I am a bit doubtful that Yamaha would have added the additional logic to make sure the operators got keyed on in the correct order, when this could lead to strictly incorrect performance, while the only penalty for not adding this logic would be modulation being wrong for a single sample. ######## POST p31156 | jotego | 2017-04-18 | t386-825.html Very interesting. Let me comment: [QUOTE] Sauraen wrote: The thing is that, if your implementation is correct, it would take a maximum of 18+23=41 cycles to update the keyon states of all four operators. Which means, you could write a certain keyon value, wait the 32 cycles the dumb BUSY timer (and the datasheet) told you to, and then write a different keyon value, and have the output be blatantly incorrect (compared to what the datasheet specified), i.e. have some operators still on or never turned on. [/QUOTE] The chip could have a different logic to generate the BUSY for the keyon. In JT51 v1.0 I had a fixed 32 bit counter for busy_reg and then an independent busy_keyon signal. And the final busy was the OR of both of them. This means a bit more of logic, yes and: [QUOTE] Sauraen wrote: I am a bit doubtful that Yamaha would have added the additional logic to make sure the operators got keyed on in the correct order, when this could lead to strictly incorrect performance, while the only penalty for not adding this logic would be modulation being wrong for a single sample. [/QUOTE] So I think they added the extra logic to have a longer BUSY but I do not have a PCB setup to verify it at the moment. The alternative to update the keyon within a 32 bit count and still get the operator order right doesn't sound easy either. And I insist, I took literally hundreds of measurements and it is not possible that all of them just by mere chance got the same operator order for all channels... is it? I do not think my testbench was so deterministic as the PC was driving it and relied on an UART... so there are plenty of chances to get information delayed by several clock cycles even when running the same test bench. ######## POST p31160 | TmEE co.(TM) | 2017-04-18 | t386-825.html You get clicks and whatnot on note ons, they didn't try to do anything about it whatsoever (easiest thing would have been allowing te select if phase generator is reset by note on or not) and having a wrong sample or two at a noteon wasn't gonna be a problem because it is gonna be masked by the click or even be source of it. I don't see any reason they tried to handle things specially here. ######## POST p31240 | Sauraen | 2017-04-21 | t386-825.html [QUOTE] jotego wrote:The chip could have a different logic to generate the BUSY for the keyon [/QUOTE] I looked again, and as far as I can tell this is not the case. The BUSY timer's only inputs are chip reset and a signal indicating a data address was written, and it has one output. This output goes to a unit which puts values on the output bus. The connections to this unit are: the two timer overflow signals, the BUSY signal, test register 21:6 (which disables this unit and enables another unit to put test data on the output bus), a signal to teh actual /IRQ pin, a Bus Write timing control signal, and bits 7, 0, and 1 of the output bus. There's no other "mystery control signal" from the keyon logic. ######## POST p31283 | jotego | 2017-04-26 | t386-825.html [QUOTE] Sauraen wrote: [QUOTE] jotego wrote:The chip could have a different logic to generate the BUSY for the keyon [/QUOTE] I looked again, and as far as I can tell this is not the case. The BUSY timer's only inputs are chip reset and a signal indicating a data address was written, and it has one output. This output goes to a unit which puts values on the output bus. The connections to this unit are: the two timer overflow signals, the BUSY signal, test register 21:6 (which disables this unit and enables another unit to put test data on the output bus), a signal to teh actual /IRQ pin, a Bus Write timing control signal, and bits 7, 0, and 1 of the output bus. There's no other "mystery control signal" from the keyon logic. [/QUOTE] Very interesting, thanks a lot! So it is very unlikely that they could manage to have a specific sort order for operator keyon. I will try to verify it on the actual part, using the test output. I have a question about parallel data: [QUOTE] Sauraen wrote:Turn on read data mode (21:D6 = 1). Select MSB or LSB of read data (21:D7 = 0 for MSB, 1 for LSB--this may be new information) Select the signal that appears on bit 14 of the output (1:0, and it does seem to make a difference, but I still don't know what the two signals are) Select whether to read operator or channel outputs (2C:D4 = 0 for operators, 1 for channels) Set up to read data from the OPN2 (as if checking whether it's busy). Every OPN2 internal clock cycle, capture a new byte from the bus, for 24 cycles. Print the 24 bytes from the synth to a terminal. [/QUOTE] I do not understand what the interaction with the clock is. If I set to read LSB data and then read for 24 cycles, I am getting the LSB of all the 24 operators... but I am losing the MSB! If then I set to read MSB the operators are already at a different value (different clock) so I cannot get to read both the MSB and the LSB of an operator at a specific clock cycle. Is that correct? It seems odd that MSB+LSB cannot be read. Then about the test pin, when it is set to input, (2C:D7 = 1), I wonder if that input is actually a clock. Maybe when the PG and EG clocks are stopped using test modes (21:D5=1, stops EG clock and 21:D3, stops PG clock) the clock is actually handed to the test pin. However, note that even stopping the PG clock is not enough to read MSB+LSB of the same operator. Because if we have to read MSB for 24 cycles and then set to read LSB for another 24 cycles, even if PG and EG are stopped, the internal modulation shift registers and signals will make operator values shift away. So there must be another bit that stops the modulation control signals (the ones you called op_algorithm_ctl, voice_fb and op_fb_enable). If the modulation, PG and EG are stopped then we can alternate between MSB and LSB read and get all the information. Then we can advance one clock cycle using the test pin or one of the other unknown test pins: [QUOTE] Sauraen wrote: 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? 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.) [/QUOTE] ######## POST p31285 | Sauraen | 2017-04-26 | t386-825.html [QUOTE] jotego wrote:I do not understand what the interaction with the clock is. If I set to read LSB data and then read for 24 cycles, I am getting the LSB of all the 24 operators... but I am losing the MSB! If then I set to read MSB the operators are already at a different value (different clock) so I cannot get to read both the MSB and the LSB of an operator at a specific clock cycle. Is that correct? It seems odd that MSB+LSB cannot be read. [/QUOTE] You are correct, MSB+LSB cannot be read. The info you quoted from me about the unknown test bits is obsolete. The most up-to-date information is as follows: Test Bit Functions $21:0: Select which of two unknown signals is read as bit 14 of the test read output. $21:1: Some LFO control, unknown function. $21:2: Timers increment once every internal clock rather than once every sample. (Untested by me) $21:3: Freezes PG. Presumably disables writebacks to the phase register. $21:4: Ugly bit. Inverts MSB of operators. $21:5: Freezes EG. Presumably disables writebacks to the envelope counter register. Unknown whether this affects the other EG state bits. $21:6: Enable reading test data from OPN2 rather than status flags. $21:7: Select LSB (1) or MSB (0) of read test data. (Yes, it's backwards.) $2C:2 downto 0: Ignored by OPN2, confirmed by die shot. $2C:3: Bit 0 of Channel 6 DAC value $2C:4: Read 9-bit channel output (1) instead of 14-bit operator output (0) $2C:5: Play DAC output over all channels (possibly except for Channel 5--in my testing the DAC is the only thing you hear and it's much louder, you do not get any output from Channel 5; but someone else supposedly found that the pan flags for Channel 5 don't affect the panning of this sound, which is only possible if it's not being output during that time slot for some reason. I don't have any other reason to believe this is true though). $2C:6: Select function of TEST pin input--both unknown functions. $2C:7: Set the TEST pin to be an output (1) instead of input (0). Test Read Data Format ABPPPPPP PPPPPPPP (if $2C:4 is 0) AB00000C CCCCCCCC (if $2C:4 is 1) A: Unknown signal. B: One of two unknown signals; which one is read is selected by $21:0. C: 9-bit channel output. P: 14-bit operator output. Test Bit Functions When the test bit is configured as an output ($2C:7 is 1), it outputs the SYNC signal (NOT BUSY as stated in old posts of mine). This signal goes high for one internal cycle every sample (24 cycles). Its falling edge occurs just after an internal clock pulse, so wait half an internal cycle before sampling the OPN2's output. Then, four cycles after that, the data on the output will be for Ch 1 Op 1. (Presumably, the SYNC signal is when it begins calculation of Ch 1 Op 1, and the output is available after four cycles.) Sample on each internal cycle to receive the data for channels 1-6 operator 1, then 1-6 op 3, then 1-6 op 2, then 1-6 op 4. I implemented this in my synth MIDIbox Quad Genesis to read back operator states (just the MSB) at about 500 Hz and create a VU meter display on the front panel ; the code for the routine is in this file . When the test bit is configured as an input, I have no idea what it does. So to answer your question @jotego, there is no bit which stops calculation of the operators. When I transcribed the operator unit I found no such functionality. The operator pipeline does calculation as part of the pipeline, and there's no way to skip it. Unlike the PG and EG which can essentially pop out a value, modify it, and put it back in the circular shift registers, in the OP the shift registers are throughout the pipeline. There's also no "mystery" test bit (input) which is unaccounted for which could do this, and yes I'm sure I saw them all. As I don't know what the TEST pin input does, I can't rule out that it would behave like you're saying; but there's two things which lead me to believe it's not. First, the two functions the test bit has don't seem to be linked to logic related to the PG and EG writeback disable signals, so I think the TEST pin input is active regardless of what kind of test mode the chip is in. Second, you need the TEST pin configured as an output in order to synchronize your data capture to it; and while you might be able to synchronize and then not need to look at the TEST pin anymore, to change it back to an input would require writing to $2C, which might interrupt your data collection. I guess you could keep careful timing throughout the process and still get good results--after all you have to write to $21 anyway to switch between LSB and MSB. ######## POST p31304 | jotego | 2017-04-27 | t386-825.html Very informative. I have updated the wiki on the JT12 repository with the information. I am setting up a board to take direct measurements so expect news in the coming weeks about the latest topics we have discussed. ######## POST p32605 | Eke | 2017-10-24 | t386-825.html Some more news about YM2612 DAC "ladder" effect: a guy named Nuked who analyzed YM3438 die shots recently wrote a cycle-accurate implementation in C and figured the effect was actually caused by two things: 1 ) the fact that the resistor array would not exactly reach Vcc/2 on either negative or positive side (already explained by Sauraen in a previous post) which causes a gap 2x larger than expected between 0 and -1 steps: 0 and -1 actually corresponds to same amount of resistance in DAC array i.e they are like opposed values symmetrical on each side of Vcc/2 => a way to emulate this is to add a +1 offset on positive or zero channel output (so 0 corresponds to +1 and so on). 2 ) the fact that the sign bit also has an impact when the DAC output is silenced, which can happen on one of the stereo analog output when muted but also between channels output as seen in early Nemesis captures (channel output is active for one chip internal cycle then kept "low" for 3 internal cycles) : when "silence" is needed, the output is actually forced to either +1 or -1 (max resistance output of DAC array) => a way to emulate this is to add a +3/-3 offset (+4/-4 when channel is muted) on channel output depending on sign bit This actually makes low volume instruments sounds much louder (see After Burner 2 " Super Stripe") but also cause that distinctive background noise when channel output is faded out (see Konami logo sound for example) Also see https://github.com/ekeeke/Genesis-Plus-GX/pull/179 for more details on Nuked2 YM3438 implementation (which also emulates test registers, status bit, etc) ######## POST p32647 | Kabuto | 2017-11-09 | t386-825.html I can confirm this large ladder gap from measurements of DAC output levels: https://docs.google.com/document/d/e/2P ... cbCvlG/pub (scroll down to YM2612 and zoom in on those 2 diagrams). Also, further discontinuities exist, especially for test bit $2C:3=0, where when DAC register bits 0 to 3 are 0 and register value is > 128. I tested multiple MD1s, all of them had this odd behaviour. I did not spot this on MD2, too bad that the seemingly better DAC performance is crippled by a poor amplifier circuit. Regarding $2C:5: I noticed that on a MD1 I tested this resulted in a roughly 30-fold increase of DAC levels when all channels are on. This causes distortions as the amplifier does not expect to see anything louder than all 6 channels played at once at maximum levels (which is unlikely since phases would need to match as well so there is a bit of head room left for PSG). Maybe this does not only output DAC on multiple channels but also output DAC for much longer than it does normally. ######## POST p32648 | Sauraen | 2017-11-09 | t386-825.html My understanding with the DAC "loud" test bit is that normally, channel values are output in an "impulse-like" fashion, for a fraction of their time slot (I think it should be 1/4, since there are 24 clock cycles per complete computation cycle and there are 6 channel values to output during that time, so output for 1 clock cycle would be 1/4 of a slot). Whereas, with the test bit set, the output is just constantly the DAC value. So it would be 24x as loud. ######## POST p34243 | jotego | 2018-11-21 | t386-825.html [QUOTE] Sauraen wrote: Tue Apr 18, 2017 3:04 am I am quite confident from viewing the die shots, and it seems to be sufficiently confirmed from testing, that whenever you write a data value, BUSY gets set, and gets cleared exactly 32 cycles later. On the die shot it's just a 5-stage counter, not connected to anything else. Of course the chip actually "consumes" the written data value at some point within the first 24 (or possibly a couple more) cycles of it being written, when its value comes around in whatever circular shift register. (They're all 24 stages or less.) [/QUOTE] Kabuto's Titan 2 Overdrive demo does not work well with a 24-stage circular shift register. His experimentation tells him that 12 FM cycles are enough to get a good write. He also reported that Sik, the author of echo, found that it was possible to get good writes while waiting less than 24 FM cycles. After thinking about it, I do not think that there is any other thing but a 24-stage circular shift register. But, maybe it was built out of the original 12-stage circular shift register from YM2203. We know, thanks to Sauraen, that the operator unit is pretty much a copy-paste exercise (with a difference in the number of stages) from that of YM2203. So I wonder if the original YM2203 structure of an input multiplexer, fed by the external data input on one side and the output of the shift register, followed by a 12-stage shift register was actually used twice in series. Thus having a total of 24 stages, where feedback goes from stage 24 to stage 1 but there are two multiplexers, one in front of stage 1 and another one in front of stage 13. This means that you can update operators 0 and 2 using the first multiplexer and operators 1 and 3 using the second one, within a 12-FM clock cycle period. This double-mux structure is compatible with the structural need for 24 stages and the observation from the demo scene that 12-FM clock cycles should work and makes sense historically and would have saved layout work to YM2612 designers. I wonder if Sauraen would still care to have a look at the die shot to confirm this, please. ######## POST p34246 | Sauraen | 2018-11-21 | t386-825.html [QUOTE] jotego wrote: Wed Nov 21, 2018 9:21 am So I wonder if the original YM2203 structure of an input multiplexer, fed by the external data input on one side and the output of the shift register, followed by a 12-stage shift register was actually used twice in series. Thus having a total of 24 stages, where feedback goes from stage 24 to stage 1 but there are two multiplexers, one in front of stage 1 and another one in front of stage 13. This means that you can update operators 0 and 2 using the first multiplexer and operators 1 and 3 using the second one, within a 12-FM clock cycle period. [/QUOTE] The pipeline for YM2612 is indeed 12 stages long: 6 of these are the same as YM2203, and then YM2612 has an additional 6-layer shift register stuck in the middle. Unlike PG and EG which have an important state variable to store (and so have logic to compute its new value from the old one and then enough shift registers to delay it for the remainder of 24 cycles), OP doesn't *normally* (leaving aside feedback for the moment) use the old value of an operator to compute the new one. What it does have is three additional buffers for modulation that store the last value of op 0, the last value of op 1, and the last-last value of op 0. (These are only 6 layers deep, because there are 6 voices.) At any given point in the pipeline, if you're looking at the data there, it's for (say) op 0; six cycles later it will be the same voice op 2; six cycles later the same voice op 1; and finally six cycles later the same voice op 3. In the intermediate six cycles, the other six voices are being computed. Please take a look at my VHDL model of the operator unit. I do not claim that every single logical element in this is correct, but I am confident that the overall structure of this in terms of what registers are where and how the pipeline works is correct. https://github.com/sauraen/YM2612/blob/ ... erator.vhd The operator parameters (for all units: EG, PG, OP) are stored in 24-deep circular shift registers whose outputs are basically just the control signals for all the units in the chip. There's no way to write to the middle of these--they can only be written to when that particular operator's data comes around. [EDIT: this is wrong] So, there is control logic (which I haven't analyzed in detail) which, based on which voice and operator you're writing to, waits to write your new data to these until the proper cycle. If you write one address and data at a given time and then 12 cycles later write another address and data, you might get lucky and both get captured, or the first one might get lost if it didn't come around in time. I can't see how it would be possible to make a sound engine that wrote new data every 12 clocks, consistently, without problems. ######## POST p34247 | Sik | 2018-11-21 | t386-825.html Reminds me, the other day I got reports that it's possible for a write to register $28 to go missing and you need to do key-on twice as a workaround. Now I wonder if that particular register does indeed need double the delay, seeing as it messes with the ADSR mechanism (・~・) ######## POST p34249 | jotego | 2018-11-22 | t386-825.html [QUOTE] Sauraen wrote: Wed Nov 21, 2018 5:53 pm The operator parameters (for all units: EG, PG, OP) are stored in 24-deep circular shift registers whose outputs are basically just the control signals for all the units in the chip. There's no way to write to the middle of these--they can only be written to when that particular operator's data comes around. So, there is control logic (which I haven't analyzed in detail) which, based on which voice and operator you're writing to, waits to write your new data to these until the proper cycle. If you write one address and data at a given time and then 12 cycles later write another address and data, you might get lucky and both get captured, or the first one might get lost if it didn't come around in time. I can't see how it would be possible to make a sound engine that wrote new data every 12 clocks, consistently, without problems. [/QUOTE] Thanks for your detailed account. I totally agree with it and JT12 implementation follows those lines as you know. However, in view of this new evidence from Kabuto, I remembered having seen some actual wait times in some Yamaha document, so I dug for it. It is the application notes for YM3438 , a CMOS version of YM2612 -which is NMOS logic. It is in Japanese so you may have to take my word for it. On page 10 it shows these wait times: Address register: 17 master clock cycles -> equivalent to -> 2.8=1+1.8 FM clock cycles Data on global or operator register: 83 master clock cycles -> 13.8=12+1.8 FM clock cycles Data on channel-wide register: 47 master clock cycles -> 7.8=6+1.8 FM clock cycles Now, this is how I explain it: There is a delay through the input/output latches equivalent to 2 master clock cycles. This is fixed. It might be because these are actually flip flops clocked with the master clock or just an equivalent delay through an asynchronous latch. Once that delay is taken away we are left with very interesting numbers: 12 FM clock cycles for global (0x2? registers) and operator registers. And 6 FM clock cycles for channel-wide registers. Remember than one FM clock cycles is six master clock cycles because of the internal divider. It takes 24 FM ticks for the pipeline operators to process everything and data must be poured into the pipeline one operator at a time, as Sauren also explained. My implementation -so far as v0.61 of JT12- was assuming that a 24 CSR (circular shift register) only had an update point, so it would take 24 FM ticks to get new data in. That also made sense in view of the length of the BUSY counter, which Sauren had reported to count for 32 FM ticks. However, the evidence from Kabuto and from YM3438 document tells us that the CSR can be updated in just 12 FM ticks. Thinking of different ways to accomplish this on silicon, I think that an update point just in the middle of it is economical and makes sense if they were reusing layout work from YM2203. As I explained before. Now, if someone looks at the die shots (YM33438 or YM2612 ) and checks the CSR and outputs from each flip flop just go straight to the next FF's input without any mux anywhere, then we will have to consider other implementation options. [QUOTE] Sik wrote: Wed Nov 21, 2018 7:46 pm Reminds me, the other day I got reports that it's possible for a write to register $28 to go missing and you need to do key-on twice as a workaround. Now I wonder if that particular register does indeed need double the delay, seeing as it messes with the ADSR mechanism (・~・) [/QUOTE] That makes sense. Keyon register $28 is an operator-level register because the key-on signal has to go through the pipeline. In my implementation I use another CSR to hold the key-on values and feed them to the pipeline. Original implementation must be like this too. I think I should change this CSR to have an update point in the middle too so it can get updated in 12 FM ticks rather than 24. More importantly, PCM data gets taken into account in the accumulator and the accumulator will exactly add each operator once every 24 FM ticks. So even if YM3438 says that 12 FM ticks is enough for $2? registers, I don't think you can get PCM data out of the chip at the suggested time of 13.8 FM ticks because the accumulator is only processing data at 24 FM ticks. You can write the data in the PCM register, and it will get in, but you will not get it out to the DAC. In summary, in the $2? space we have some registers that take rather immediate effect -like the frequency of the LFOSC- and others that go through the pipeline and have either a 12 or 24 FM tick time frame to become effective. ######## POST p34253 | Sik | 2018-11-22 | t386-825.html PCM data straight up can't be faster than ~26KHz (i.e. half the sample rate at which FM updates), writing faster than that outright results in missed samples. It may be slower than you think. In fact it'd be probably a good idea seeing how fast each of the $2x registers is. They by-pass the shifter (as they're global) which at first may make it look like they may work faster, but after some issues I've had some time ago and the key-on thing (not to mention the well known slowness of the PCM output) I'm starting to think they may be slower in general (probably depends on each particular register, so that's gonna need a lot more of testing). ######## POST p34255 | Sauraen | 2018-11-22 | t386-840.html [QUOTE] jotego wrote: Thu Nov 22, 2018 12:35 pm My implementation -so far as v0.61 of JT12- was assuming that a 24 CSR (circular shift register) only had an update point, so it would take 24 FM ticks to get new data in. That also made sense in view of the length of the BUSY counter, which Sauraen had reported to count for 32 FM ticks. However, the evidence from Kabuto and from YM3438 document tells us that the CSR can be updated in just 12 FM ticks. Thinking of different ways to accomplish this on silicon, I think that an update point just in the middle of it is economical and makes sense if they were reusing layout work from YM2203. As I explained before. Now, if someone looks at the die shots (YM3438 or YM2612 ) and checks the CSR and outputs from each flip flop just go straight to the next FF's input without any mux anywhere, then we will have to consider other implementation options. [/QUOTE] Surprise surprise, I was wrong. I thought I remembered them being 24 units/layers deep, and they are, but they're broken up to two groups of 12, with logic in between and at the beginning and the end. I don't have time right now to fully transcribe it, but given the other findings here, it seems reasonable that this allows a write to be made to the end or the middle. This would take more control logic, since at any given time there's two different operator's values which could be updated, but it's not that bad because the two values that could be updated would be subsequent operators in the same voice (e.g. voice 5 operator 3 is in the middle and operator 2 is at the end). The voice-level circular shift registers are 5-6 units/layers deep as expected. If I remember correctly for the YM2612, the register holding the DAC (PCM) value should update immediately (as soon as the data is in the internal data register), it just only gets used once per complete FM cycle (unless you have the DAC Loud bit turned on). ######## POST p34259 | Stef | 2018-11-22 | t386-840.html I can confirm DAC can be updated at more than 26 Khz, i don't know why people keep repeating that... maybe it depends from the system version but at least i was able to do 32 Khz on both MD1 and the MD2 and i'm confident we can get as high than 53 Khz. I think the 26 Khz mistake come from a driver using the busy bit to test the PCM write register speed, today we know we can't realy on this bit to correctly evaluate "busy" time. ######## POST p34262 | TmEE co.(TM) | 2018-11-23 | t386-840.html It is possible to update DAC once every sample if you have cycle synchronity to the YM. I did some tests where YM and Z80 were made to share the clock in MD and I could get unique samples out every 144 cycles. Doing rates between full and half sample rate are very ugly though due to the "resampling" effect, leading to pretty nasty sound (which is why I originally thought samples get missed). Unfortunately YM and Z80 don't share clock in YM and it is not possible to maintain any cycle level synchronity with the YM, especially when any ROM access is being done which adds uncertain amount of latency to the operation. ######## POST p34263 | jotego | 2018-11-23 | t386-840.html [QUOTE] Sauraen wrote: Thu Nov 22, 2018 5:57 pm Surprise surprise, I was wrong. I thought I remembered them being 24 units/layers deep, and they are, but they're broken up to two groups of 12, with logic in between and at the beginning and the end. I don't have time right now to fully transcribe it, but given the other findings here, it seems reasonable that this allows a write to be made to the end or the middle. [/QUOTE] Awesome news. So we have this piece of information confirmed. It is funny how they went for breaking up the CSR. As I said before, I think they were reusing layout from YM2203. Because the break is made at stage 12, it just happens that in comparison with the next data at the head, the difference is only in the operator MSB, let me explain. You have data flowing this way: Operator (binary) .........00...........01.........10............11..... Channel (decimal) 0-1-2-3-4-5-0-1-2-3-4-5-0-1-2-3-4-5-0-1-2-3-4-5 So from one location in the CSR to another 12 stages away the only difference in the operator-channel identification is the MSB of the operator, where in one location is 00b, in the other it will be 10b. So the logic to decide whether to update or not can be partly shared. Not sure if they actually shared it. Anyway, another mistery solved! [QUOTE] TmEE co.(TM) wrote: Fri Nov 23, 2018 4:06 am It is possible to update DAC once every sample if you have cycle synchronity to the YM. I did some tests where YM and Z80 were made to share the clock in MD and I could get unique samples out every 144 cycles. Doing rates between full and half sample rate are very ugly though due to the "resampling" effect, leading to pretty nasty sound (which is why I originally thought samples get missed). Unfortunately YM and Z80 don't share clock in YM and it is not possible to maintain any cycle level synchronity with the YM, especially when any ROM access is being done which adds uncertain amount of latency to the operation. [/QUOTE] I agree. An update of exactly 144 cycles (that is to say 24 FM ticks) will work. By the way, any PCM rate that is not an integer multiple of 24 FM ticks will eventually have sound artifacts. I don't know if software developers were aware of this. Probably not. For instance, if you update at 36 FM ticks half your samples will take two output slots (48 ticks) and the other half only one (24 ticks) so on average you do have (48+24)/2 = 36 ticks per sample but they will not be evenly output to the DAC so there will be very noticeable distortion. ######## POST p34265 | Sauraen | 2018-11-23 | t386-840.html [QUOTE] jotego wrote: Fri Nov 23, 2018 10:49 am Anyway, another mystery solved! [/QUOTE] Yeah! I was wondering why it wasn't just uniformly 24 layers... [QUOTE] jotego wrote: Fri Nov 23, 2018 10:49 am By the way, any PCM rate that is not an integer multiple of 24 FM ticks will eventually have sound artifacts. I don't know if software developers were aware of this. Probably not. [/QUOTE] Anyone who has rudimentary knowledge of DSP should realize this. But, if you sample at a much lower rate like 4 kHz used in common games (is it 8 kHz?), the effect is less noticeable since there are many samples which are the same. Plus, there is additional aliasing between the actual rate of writing to the DAC register and the mandatory 44.1kHz sampling rate of the VGM file--this was obviously not an issue when making games, but it is an issue now. Also, if my hypothesis that the DAC Loud test bit just makes the DAC value outputted all the time instead of a fraction of 1/6th of the time, you should be able to push audio out at an even higher sampling rate, since the 24 FM ticks no longer has any bearing on the output. ######## POST p34268 | nukeykt | 2018-11-24 | t386-840.html Probably my cycle accurate YM3438 emulator (which is basically translation of YM3438 schematic to C code) can give some insight about YM2612/YM3438 internals. ######## POST p34269 | jotego | 2018-11-24 | t386-840.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 7:10 am Probably my cycle accurate YM3438 emulator (which is basically translation of YM3438 schematic to C code) can give some insight about YM2612/YM3438 internals. [/QUOTE] That's an impressive piece of work. I will look at it carefully. Particularly I want to learn more about the undocumented bits. I do not see any schematic in Github, though. Only a very nice SVG file but that is very little information about the chip. Do you have something else? Apologies for saying it but It is not cycle accurate! For instance, you are not using a circular shift register for the pipeline data so you are not sensitive to inconsistency in writes. Indeed, if you do not have a clock input, I don't see how you can be cycle accurate. ######## POST p34270 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] jotego wrote: Sat Nov 24, 2018 8:15 am That's an impressive piece of work. I will look at it carefully. Particularly I want to learn more about the undocumented bits. I do not see any schematic in Github, though. Only a very nice SVG file but that is very little information about the chip. Do you have something else? Apologies for saying it but It is not cycle accurate! For instance, you are not using a circular shift register for the pipeline data so you are not sensitive to inconsistency in writes. Indeed, if you do not have a clock input, I don't see how you can be cycle accurate. [/QUOTE] Thanks! [IMG ./images/smilies/icon_smile.gif] I have no any other documentation unfortnately. YM3438 die shot is pretty clean, so just labeling certain bits was enough to understand it's logic. Vectorizing entire chip is overkill i think. About cycle accuracy: Emulation core runs at YM2612's internal FM rate(i.e 24x of YM2612's sampling rate). Calling OPN_Clock will advace chip state by one FM cycle and return one stereo sample. Shift registers were replaced by arrays for performance reasons. This change doesn't affect accuracy. ######## POST p34271 | Sik | 2018-11-24 | t386-840.html On the topic of DAC output: how do DAC bits map to the actual channel output? Because DAC seems to sound too quiet compared to what FM channels can do and I always have to make samples louder to compensate (and that's considering I already make FM channels to be TL = 8 or quieter). ######## POST p34272 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] Sik wrote: Sat Nov 24, 2018 2:38 pm On the topic of DAC output: how do DAC bits map to the actual channel output? Because DAC seems to sound too quiet compared to what FM channels can do and I always have to make samples louder to compensate (and that's considering I already make FM channels to be TL = 8 or quieter). [/QUOTE] 9 bits of PCM data are directly fed to YM2612's 9-bit DAC just like FM channels. ######## POST p34273 | Sik | 2018-11-24 | t386-840.html But register $2A only has 8 bits... ######## POST p34274 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] Sik wrote: Sat Nov 24, 2018 4:33 pm But register $2A only has 8 bits... [/QUOTE] LSB bit of PCM is mapped to $2C:3. ######## POST p34275 | jotego | 2018-11-24 | t386-840.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 4:47 pm [QUOTE] Sik wrote: Sat Nov 24, 2018 4:33 pm But register $2A only has 8 bits... [/QUOTE] LSB bit of PCM is mapped to $2C:3. [/QUOTE] Exactly, and MSB is inverted in order to get correct sign for addition with other channels: [CODE] pcm_data = { ~pcm[8], pcm[7:0] } ; [/CODE] (Verilog code) ######## POST p34276 | jotego | 2018-11-24 | t386-840.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 8:43 am I have no any other documentation unfortnately. YM3438 die shot is pretty clean, so just labeling certain bits was enough to understand it's logic. Vectorizing entire chip is overkill i think. About cycle accuracy: Emulation core runs at YM2612's internal FM rate(i.e 24x of YM2612's sampling rate). Calling OPN_Clock will advace chip state by one FM cycle and return one stereo sample. Shift registers were replaced by arrays for performance reasons. This change doesn't affect accuracy. [/QUOTE] I agree that it doesn't affect accuracy for well behaved software. What you called one FM cycle, is what I have been calling 24 FM clock ticks, and from the discussion above we have determined that register updates happen in a 12-FM-clock-tick frame. Thus when software changes dynamically register values while sound is still played, there will be a 12-FM tick delay between your solution and real hardware. Nothing major, unless someone writes software to actually exploit this difference. For instance, if software updates PCM at 36-FM-tick pace, as I explained before. Indeed, when a value is updated within the 24 FM tick cycle will make a difference if software is not nice behaved (which means updating register values only while key-off, using PCM update in integer multiples of 24FM ticks and reading BUSY bit). By the way, there is still one question about how the register selection works pending there: when is the part selection bit (i.e. A1 pin) latched? For instance, if user writes to address 2'b00 the value $30, and then to address $b11 the value $FF, where does $FF go to? What happens when there is inconsistency between the A1 pin value for write address and write data operations? Have you got any insight about this? [CODE] case 0xa0: chip->fnum[channel] = (chip->data & 0xff) | ((chip->reg_a4 & 0x07) << 8); chip->block[channel] = (chip->reg_a4 >> 3) & 0x07; chip->kcode[channel] = (chip->block[channel] << 2) | fn_note[chip->fnum[channel] >> 7]; break; case 0xa4: chip->reg_a4 = chip->data & 0xff; break; case 0xa8: chip->fnum_3ch[channel] = (chip->data & 0xff) | ((chip->reg_ac & 0x07) << 8); chip->block_3ch[channel] = (chip->reg_ac >> 3) & 0x07; chip->kcode_3ch[channel] = (chip->block_3ch[channel] << 2) | fn_note[chip->fnum_3ch[channel] >> 7]; break; case 0xac: chip->reg_ac = chip->data & 0xff; break; [/CODE] I see that you got different latch for MSB of FNUM of channel 3 special values and the rest. That is very interesting. Have you confirmed that by inspecting the die shot? It looks like you got all test bits implemented to! That's awesome. I think I might be missing some. I will probably add all for completeness. Another question from your code: [CODE] if (chip->eg_kon_csm[slot]) { nextlevel |= chip->eg_tl[1] << 3; } [/CODE] I thought CSM would just trigger key-on for a cycle, and after that key-off. But you seem to be altering the value in a strange way. Why TL[1]? Is that a value of TL inside the envelope pipeline? I am not sure if your implementation actually tries to replicate the pipeline, but in order to do that you should operate at the FM clock rate and not the 24*FM clock rate (i.e. sample rate) you said. And what does that line do? An OR there can only make sound quieter but why make it quieter for a key on? How confident are you about the chip actually doing this? By the way, I love your simple API and neat implementation. I have seen many and they make everything very software-ish complicating everything a lot. ######## POST p34277 | nukeykt | 2018-11-24 | t386-840.html [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm I agree that it doesn't affect accuracy for well behaved software. What you called one FM cycle, is what I have been calling 24 FM clock ticks, and from the discussion above we have determined that register updates happen in a 12-FM-clock-tick frame. Thus when software changes dynamically register values while sound is still played, there will be a 12-FM tick delay between your solution and real hardware. Nothing major, unless someone writes software to actually exploit this difference. For instance, if software updates PCM at 36-FM-tick pace, as I explained before. Indeed, when a value is updated within the 24 FM tick cycle will make a difference if software is not nice behaved (which means updating register values only while key-off, using PCM update in integer multiples of 24FM ticks and reading BUSY bit). [/QUOTE] One FM clock in my code is 6 master clocks. For example in Genesis Plus GX emulator OPN2_Clock is called 1.27(7.67/6) million times per second(for comparison MAME code works at 53.267 KHz). Like real hardware my implementation updates registers within 12 FM ticks. Look carefully to OPN2_DoRegWrite function. [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm By the way, there is still one question about how the register selection works pending there: when is the part selection bit (i.e. A1 pin) latched? For instance, if user writes to address 2'b00 the value $30, and then to address $b11 the value $FF, where does $FF go to? What happens when there is inconsistency between the A1 pin value for write address and write data operations? Have you got any insight about this? [/QUOTE] It's a bit weird i think. I'm not 100% sure, but looking at my code it's behaves like this. For global registers(0x21-0x2C) A1 of data write matters, but for register and channel registers A1 from address write matters instead. Would be cool if someone could perform hardware tests. EDIT: Looks like for global registers both address and data writes must have zero A1 pin state in order to work properly. [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm [CODE] case 0xa0: chip->fnum[channel] = (chip->data & 0xff) | ((chip->reg_a4 & 0x07) << 8); chip->block[channel] = (chip->reg_a4 >> 3) & 0x07; chip->kcode[channel] = (chip->block[channel] << 2) | fn_note[chip->fnum[channel] >> 7]; break; case 0xa4: chip->reg_a4 = chip->data & 0xff; break; case 0xa8: chip->fnum_3ch[channel] = (chip->data & 0xff) | ((chip->reg_ac & 0x07) << 8); chip->block_3ch[channel] = (chip->reg_ac >> 3) & 0x07; chip->kcode_3ch[channel] = (chip->block_3ch[channel] << 2) | fn_note[chip->fnum_3ch[channel] >> 7]; break; case 0xac: chip->reg_ac = chip->data & 0xff; break; [/CODE] I see that you got different latch for MSB of FNUM of channel 3 special values and the rest. That is very interesting. Have you confirmed that by inspecting the die shot? [/QUOTE] Yes [QUOTE] jotego wrote: Sat Nov 24, 2018 6:27 pm It looks like you got all test bits implemented to! That's awesome. I think I might be missing some. I will probably add all for completeness. Another question from your code: [CODE] if (chip->eg_kon_csm[slot]) { nextlevel |= chip->eg_tl[1] << 3; } [/CODE] I thought CSM would just trigger key-on for a cycle, and after that key-off. But you seem to be altering the value in a strange way. Why TL[1]? Is that a value of TL inside the envelope pipeline? I am not sure if your implementation actually tries to replicate the pipeline, but in order to do that you should operate at the FM clock rate and not the 24*FM clock rate (i.e. sample rate) you said. And what does that line do? An OR there can only make sound quieter but why make it quieter for a key on? How confident are you about the chip actually doing this? By the way, I love your simple API and neat implementation. I have seen many and they make everything very software-ish complicating everything a lot. [/QUOTE] This behavior should be consistent with real hardware. Not sure why Yamaha implemented it in that way though. In theory my code should be 1:1 to real hardware. But in practice i could make some mistakes in implementation. ######## POST p34279 | Eke | 2018-11-25 | t386-855.html Nemesis tested the address/data ports relation some years ago viewtopic.php?f=24&t=386&start=410 [QUOTE] It turns out that writing to an address register stores both the written address, and the part number of the address register you wrote to. You can then write to either the data port at $A00001, or the data port at $A00003, and the write will go to the register number you wrote, within the part of the address register you wrote to. This means you can, for example, write an address to $A00000, then write the data to $A00003, and the data will in fact be written to the part 1 register block, not the part 2 register block. [/QUOTE] Not sure if he tested also with global registers ($2x) though ######## POST p34281 | jotego | 2018-11-25 | t386-855.html [QUOTE] nukeykt wrote: Sat Nov 24, 2018 7:36 pm One FM clock in my code is 6 master clocks. For example in Genesis Plus GX emulator OPN2_Clock is called 1.27(7.67/6) million times per second(for comparison MAME code works at 53.267 KHz). Like real hardware my implementation updates registers within 12 FM ticks. Look carefully to OPN2_DoRegWrite function. [/QUOTE] I see, I agree with that approach. However, I have another question. Are you really implementing the pipeline? For instance, in function OPN2_PhaseCalcIncrement you perform a lot operations for the data of the current slot, without holding any intermmediate value in a latch. Can that be real? Of course the chip has a lot of parallel things going on that speed up things but it still looks like a lot to be done in a clock cycle. Then you have the result stored in pg_inc[slot], but data couldn't be actually stored in the same "slot" as it was passing through. You use pg_inc in the OPN2_PhaseGenerate but you calculate slot as [CODE] slot = (chip->cycles + 20) % 24; [/CODE] My interpretation of this is that the previous function actually had 20 pipeline stages (20 latches) in hardware. Your writing to the same slot you were using as input does not affect accuracy of emulation because that position will not be read until 20 cycles later. So, in general, it looks like you are respecting the pipeline delays but just not writting a function (latch) for each pipeline stage. Is my interpretation correct? Another question is about your function OPN2_DoRegWrite. chip->write_fm_data is read at the beginning of the function (in the if statement) but it is modified at the end of the function. Are you representing a latch operation in this way? Because the data written at the end will not be read until the next call to the function. ######## POST p34283 | nukeykt | 2018-11-25 | t386-855.html [QUOTE] jotego wrote: Sun Nov 25, 2018 5:29 pm [QUOTE] nukeykt wrote: Sat Nov 24, 2018 7:36 pm One FM clock in my code is 6 master clocks. For example in Genesis Plus GX emulator OPN2_Clock is called 1.27(7.67/6) million times per second(for comparison MAME code works at 53.267 KHz). Like real hardware my implementation updates registers within 12 FM ticks. Look carefully to OPN2_DoRegWrite function. [/QUOTE] I see, I agree with that approach. However, I have another question. Are you really implementing the pipeline? For instance, in function OPN2_PhaseCalcIncrement you perform a lot operations for the data of the current slot, without holding any intermmediate value in a latch. Can that be real? Of course the chip has a lot of parallel things going on that speed up things but it still looks like a lot to be done in a clock cycle. Then you have the result stored in pg_inc[slot], but data couldn't be actually stored in the same "slot" as it was passing through. You use pg_inc in the OPN2_PhaseGenerate but you calculate slot as [CODE] slot = (chip->cycles + 20) % 24; [/CODE] My interpretation of this is that the previous function actually had 20 pipeline stages (20 latches) in hardware. Your writing to the same slot you were using as input does not affect accuracy of emulation because that position will not be read until 20 cycles later. So, in general, it looks like you are respecting the pipeline delays but just not writting a function (latch) for each pipeline stage. Is my interpretation correct? [/QUOTE] All calculations performed in OPN2_PhaseCalcIncrement function actually take 4 cycles on real hardware. I've simplified it as all data used in this function enter to the PG block at the same time. Replicating all latches would be big headache for linear C emulator. Probably there are some other optimizations like this in my code that should not screw up core accuracy. [QUOTE] jotego wrote: Sun Nov 25, 2018 5:29 pm Another question is about your function OPN2_DoRegWrite. chip->write_fm_data is read at the beginning of the function (in the if statement) but it is modified at the end of the function. Are you representing a latch operation in this way? Because the data written at the end will not be read until the next call to the function. [/QUOTE] Yes. write_fm_data actually is register and it does exist on YM3438. So it should be consistent with real hardware. ######## POST p34289 | jotego | 2018-11-26 | t386-855.html [QUOTE] nukeykt wrote: Sun Nov 25, 2018 6:24 pm All calculations performed in OPN2_PhaseCalcIncrement function actually take 4 cycles on real hardware. I've simplified it as all data used in this function enter to the PG block at the same time. Replicating all latches would be big headache for linear C emulator. Probably there are some other optimizations like this in my code that should not screw up core accuracy. [/QUOTE] I have started to translate your code to Verilog so we can have this level of accuracy in FPGA too. I don't know whether it will make an audible difference to current JT12 or not, but once the knowledge of the real implementation is published, I think we ought to use it. I understand the original chip well because I wrote a clone so I may be able to spot a bug in your code -if there is one. Thus, this exercise of mine may also be useful to you as you get a second pair of eyes going through your code. If you have information about how many cycles -pipeline length- took each function, could you share it? That would help me as in digital design these things have more implications than in software. By the way, I see the timers do operations in cycles 1 and 2. I wonder, how do timers know the cycle in real hardware? In my implementation, I did find it useful to have a signal indicating the first stage of the pipeline. I called it zero and it goes to many places. However, your code suggests that there are signals to indicate other cycles, not only the first one. Was there another circular shift register (CSR) to indicate the current cycle in hardware? Something like a one-bit CSR feeding different circuits so Yamaha designers could have more freedom to decide when things happened? This would be a departure from YM2203 as if the timer counts on cycle 1 as in your code, it would count at twice the speed in YM2203 because there are half the number of operators (i.e. total cycles per output) ######## POST p34290 | nukeykt | 2018-11-26 | t386-855.html [QUOTE] jotego wrote: Mon Nov 26, 2018 12:03 pm I have started to translate your code to Verilog so we can have this level of accuracy in FPGA too. I don't know whether it will make an audible difference to current JT12 or not, but once the knowledge of the real implementation is published, I think we ought to use it. I understand the original chip well because I wrote a clone so I may be able to spot a bug in your code -if there is one. Thus, this exercise of mine may also be useful to you as you get a second pair of eyes going through your code. [/QUOTE] Nice to hear it. Good luck with it [IMG ./images/smilies/icon_smile.gif] [QUOTE] jotego wrote: Mon Nov 26, 2018 12:03 pm If you have information about how many cycles -pipeline length- took each function, could you share it? That would help me as in digital design these things have more implications than in software. [/QUOTE] I think i can't help much here. More than one year has passed since i worked on it. [QUOTE] jotego wrote: Mon Nov 26, 2018 12:03 pm By the way, I see the timers do operations in cycles 1 and 2. I wonder, how do timers know the cycle in real hardware? In my implementation, I did find it useful to have a signal indicating the first stage of the pipeline. I called it zero and it goes to many places. However, your code suggests that there are signals to indicate other cycles, not only the first one. Was there another circular shift register (CSR) to indicate the current cycle in hardware? Something like a one-bit CSR feeding different circuits so Yamaha designers could have more freedom to decide when things happened? This would be a departure from YM2203 as if the timer counts on cycle 1 as in your code, it would count at twice the speed in YM2203 because there are half the number of operators (i.e. total cycles per output) [/QUOTE] YM3438 actually has internal cycle counter which outputs 24 signals for each cycle value. Cycle counter is actively used throughout entire chip. For example operator unit uses it to determine channel's operator number which further used for FM algorithm control. ######## POST p37832 | Stef | 2023-01-17 | t386-855.html I finally took sometime to make some tests about the minimum safe write timings for the YM2612 / YM3438 chip. I made a lot of tests but still I couldn't test every cases and every registers but hopefully that is enough to confirm (or not) data we got from official documents. I made all my tests using the 68K CPU (I initially tried with the Z80 but it was really too painful honestly) and i assumed there is no extra delay cycle in writing the YM2612 chip from it (to be honest I had no idea but it definitely seems that this is not the case). I tested both on YM2612 (MD1 VA0) and the ASIC YM3438 (Nomad and MD3 clone) and so far the write timing seems roughly identical between the 2 (contrary to my initial belief) but I still need to do some tests with the key register on YM2612 to confirm that. Edit: I just completed my tests on the YM2612 and I can confirm that timings are identical. So far here are the timing given in official docs: - 17 YM cycles (8 Z80 cycles) between writing the address and data - no wait between writes to addresses $21-$2F - 83 YM cycles (39 Z80 cycles) between writes to addresses $30-$9E - 47 YM cycles (22 Z80 cycles) between writes to addresses $A0-$B6 The good news is that I can confirm almost all these numbers [IMG ./images/smilies/icon_smile.gif] Still there is some minor but important differences in some parts: - The documentation said 17 cycles between address / data write. That really seems pessimist and I couldn't got any problems using 12 cycles (5-6 Z80 cycles). With 10 cycles or less you indeed got some missed or corrupted writes quickly though. This is interesting to know as it means we can chain 2 fast Z80 writes (7 cycles + 7 cycles) to write a register. - The documentation said there is no wait for all $2x registers, and so far that is true except for the $28 register (key on/off) ! As i though this register really need some delay between writes otherwise you will got some unwanted results as completely missed writes or even altered envelop phase (!?!) when you chain key operations too quickly on the same channel (note play but quieter than expected). The minimum delay for safe operation is about 112-116 cycles (52-54 Z80 cycles) which is quite a lot (but I expected even more here). That is more than the 83 cycles required for writing $30-$9E registers. - The 83 cycles / 47 cycles for $30-$9E / $A0-$B6 registers seems to perfectly matches what i measured. There is some quirks about the ASIC YM3438 to be aware of as it makes it behave a bit differently when we read the status and the busy flag in particular : - unlike the YM2612 the status can only be read on the port #0. - the busy bit isn't immediately set to 1 when writing register. I dunno how much time it takes exactly to be set but waiting 20 YM cycles after the register write is enough to avoid any problem with that. ######## POST p37833 | TmEE co.(TM) | 2023-01-17 | t386-855.html I remember needing a larger than normal delay on key on/off registers when I made my sound driver many years ago, the envelope thing you mention is because the 4bits react differently and sometimes one or more won't do same as others and this can dramatically alter the sound. I also remember getting away with a little shorter address delay, but in the end it got wrapped into using convenient but slow IX and IY instructions lol ######## POST p37836 | Stef | 2023-01-17 | t386-855.html Yeah the address / register write delay seems quite short, still not short enough to use a Z80 16 bit write as LD (YMPORT), HL (16 cycles) or LD (YMPORT), DE (20 cycles) I really wanted to use it as even if high byte is written first (at addr + 1), it's not much of an issue as both address ports share the same register (it doesn't make any difference writing the address to $4001 or $4003). Unfortunately it's too fast as you have only 3 Z80 cycles between the address / register write.. At best you can do the following sequence: LD (BC), A // write address (7 cycles) LD (HL), E // write value (7 cycles) but it's unlikely to happen as you need to waste / initialize both BC and HL registers for that.. In the end myself I often use something as: LD (HL), D // write address (7 cycles) INC L // (4 cycles) LD (HL), E // write value (7 cycles) About the key registers, indeed the envelop alteration with too short delay maybe caused by only having part of the operators key ON/OFF state being properly updated. That make some sense after all.. ######## POST p37837 | TmEE co.(TM) | 2023-01-17 | t386-855.html One thing is that the write itself happens at the end of instruction so the delay really starts then and what happens next depends on what comes after. In the end I gave up trying to optimize access speeds and use IX/IY with YMPORT in them permanently, since I don't use them for anything else due to their slowness. ######## POST p38014 | HardWareMan | 2023-06-21 | t386-855.html As I already said here we opened the MD decapping project. One of it branch is was YM2612/YM3438 FM chip. Now the new dedicated to FM chip project is started and almost die perfect verilog model is available here . Testbench: [IMG https://github.com/nukeykt/Nuked-OPN2-FPGA/raw/main/imgstore/testbench.jpg] Resource usage on DE10-nano: [IMG https://github.com/nukeykt/Nuked-OPN2-FPGA/raw/main/imgstore/usage.png] Some WIP recordings. YM only (no PSG). https://soundcloud.com/user-656259515/test11 https://soundcloud.com/user-656259515/test14 https://soundcloud.com/user-656259515/test13 ######## POST p38015 | jotego | 2023-06-22 | t386-855.html Congratulations on such a feat! I’ll be comparing your implementation to mine for fine details. Thanks for sharing it.