ugh, i wrote a huge reply to this, then lost it.
the basic point is this:
sulfuric acid and formaldehyde results in extremely harsh reaction conditions. sulfuric acid can do anything from hydrating double bonds to causing elimination reactions to participating as a catalyst in aldol or Mannich type condensation reactions.
I suspect that, since MDMA gives a dark blue to black color change on reaction with Marquis reagent, the product of that reaction is probably conjugated in more than one way. This could either be due to multiple reaction pathways (i.e. several differently colored compounds mixing to give black) or a multiply conjugated product (that is, conjugated at more than one place).
for those who don't know, the color of compounds arises mostly from electronic transitions from the ground state to excited states resulting from light impinging on the compound. while most organic compounds are colorless (their white color arises mostly from crystal diffraction), those with conjugated double bonds (alternating single and double bonds) tend to be more highly colored.
it's difficult to say exactly what happens when Marquis reagent reacts with MDMA, and i can't find any references to help me. the example given in the link (to the article in German) illustrates one potential reaction with resorcinol, though MDMA would by no means react in a similar manner.
I'm not even sure if the product of the Marquis reaction with MDMA would be a dimer, as it is with resorcinol. Electrophilic aromatic substitution would not ordinarily be expected to occur with formaldehyde, and probably does occur only because the reaction takes place in concentrated sulfuric acid.
The simplest possible reaction I can imagine is that formaldehyde would add between the 5-carbons of two MDMA molecules, forming a methylene-bridged dimer similar to that shown for resorcinol. I don't expect that to happen.
It is possible that ether cleavage reactions (remember, concentrated H2SO4 -- this is not, by any means, ordinary 20th century reaction conditions!) may take place, although ether cleavages are normally quite slow and I'm not sure if they could take place on the scale of several seconds as seen with the Marquis reagent.
If ether cleavages do occur, then you could see all kinds of products -- colored carbonyl compounds, even Mannich-type products from the reaction of the carbonyl groups with the amino groups of other MDMA molecules.
Clearly, if the product of the reaction is black -- there are very few black organic compounds -- there may well be several reactions taking place.
It may be easier to predict a product for a drug that gives a more definitely colored product, such as methamphetamine, which is orange. *that* product might be formed by a relatively simple reaction such as the formation of an enamine (which would have one double bond conjugated with an aromatic system).
I could explain the reaction much better if I knew what the products were; just predicting the products of the reactions of several organic compounds with formaldehyde and H2SO4 is incredibly difficult.