List of every detectable difference in Mega Drive revisions?

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

List of every detectable difference in Mega Drive revisions?

Post by Sik » Sat Aug 15, 2020 8:41 am

I was thinking that about looking to make some test code that pokes different parts of the hardware to help narrow down which board revision it may be (in order to take an educated guess without having to have people open up the consoles), but uuuh while I remember some of the things that may change I don't remember exactly on which board revisions did they change (or how), and I'm probably missing stuff.

Can anybody help by posting here whatever stuff can be detected by the 68000 and on which board revisions? (don't bother with things that can't be detected through software) The more stuff can be poked the more it can be narrowed down.
Sik is pronounced as "seek", not as "sick".

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by TmEE co.(TM) » Sat Aug 15, 2020 1:40 pm

There is some small difference in timing of Z80 bus crossings between MD1 VA0...MD2 VA3 (MD1 chipsets, 315-5487/5660/5700/5708), MD1 VA4/Genny3 VA1(515-5960) and Genny3 VA2(315-6123). No clue about MD2 VA2.x with 315-5685/5786, I have none to play with.
I was exploring what happens when DMA was done with two writes and there was spacing between the writes, and Z80 was doing stuff at close to video line rate and I was able to make DMAs *cancel* between those writes with nearly full stability on first group hardware (All MD1 and most MD2 models), with much less stability with 315-5960 chipset hardware and another different result with final 315-6123 based hardware.
I never turned it into a full hardware identifier though but it would definitely be possible, I might have the code still left somewhere and I planned to revisit it one day...

It should also be possible to differentiate NMOS and CMOS Z80 in software which would allow to roughly differentiate MD1 from MD2 since latter always use CMOS parts. I first discovered that something is up when I changed NMOS part with CMOS one in Amstrad CPC, one software always locked up and after some investigation by a friend this was uncovered :
http://www.cpcwiki.eu/forum/amstrad-cpc ... s-or-cmos/
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by Sik » Sun Aug 16, 2020 3:53 pm

The DMA thing sounds like the bus clash bug (where if both Z80 and DMA try to get to the 68000 bus at the same time the DMA transfer fails and loads garbage). All revisions suffer from it but some boards seem more susceptible than others at exposing issues (in particular early ones, but not necessarily limited to them), cartridge speed also seems to influence it (faster cartridges will likely just glitch occasionally while slower ones will be a complete glitchfest). Ultimately this is why the docs insist that you have to halt the Z80 when doing a DMA transfer and there's no workaround other than telling the sound driver to stay off the 68000 bus.

The Z80 CMOS bugs are honestly unfeasible to test for, the OUT instruction is effectively a no-op in Mega Drive mode and the other bug can take many frames to expose itself (you can't execute LD A, I or LD A, R non-stop, eventually you need to branch in a loop and the interrupt could happen when the jump is executing) and even then it may not be 100% reliable depending how unlucky you are. It may be worth checking if any of the undocumented instructions changes, however.


Uh, anything else to try? I know model 3 has a good bunch of stuff to try, and Teradrive could be probably detected through its VRAM (assuming nothing gets modded, but presumably somebody who mods a console will know what's inside anyway). Also of course VDP version to see if TMSS register is present, but I have no idea what versions are exposed for every board revision.
Sik is pronounced as "seek", not as "sick".

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by TmEE co.(TM) » Sun Aug 16, 2020 4:16 pm

DMA doesn't fail and load garbage, it is outright cancelled, the transfer does not happen and you can measure the time won from that and determine if DMA happened or not, or read VRAM instead.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by Stef » Mon Aug 17, 2020 8:31 am

TmEE co.(TM) wrote:
Sun Aug 16, 2020 4:16 pm
DMA doesn't fail and load garbage, it is outright cancelled, the transfer does not happen and you can measure the time won from that and determine if DMA happened or not, or read VRAM instead.
Are you sure of that ? From what i observed it looks like the VRAM was always filled with a fixed value (sometime 0) when DMA failed, exactly as a DMA fill occurred instead of the wanted data transfer.
We really need to make deep tests to figure out exactly what happen about that BUS clash stuff :D

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by Sik » Mon Aug 17, 2020 9:15 am

Yeah the DMA transfer definitely still happens because the data in VRAM gets overwritten, it seems to act as if it was reading all ones (0xFFFF) as if the VDP couldn't access the 68000 bus. Maybe VDP is leaving the 68000 bus too early?
Sik is pronounced as "seek", not as "sick".

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by TmEE co.(TM) » Mon Aug 17, 2020 9:12 pm

Originally I saw it when I was doing very precise raster effects, where DMA triggering was in two writes to win time, but with Z80 running I noticed that I had failing DMAs every once in a while (in that case palettes didn't get updated).

Then I made a specially crafted thing, where I deliberately split the DMA trigger into two halves, and put enough space between the two halves that Z80 could do something in that span, and I could see DMAs that simply didn't happen since I used backdrop color change between and after DMA and when DMA happens there's a block of pixels between that show time clearly passed where as no DMA and the color change happened pretty much right after the point where DMA normally would have begun.
And I noticed diffecence in behavious between the 3 machine classes I mentioned. By adjusting timings it is possible to target every one of the three types.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by Stef » Tue Aug 18, 2020 7:53 am

So you were testing using CRAM DMA right ? in my case i was always testing using VRAM DMA and just doing some tile data update while the Z80 was running and using the 68k BUS. In that case it seems the DMA break and instead of the wanted data the VRAM is filled with fixed color (and often something like 0xEEEE or 0xFFFF as Sik said as i could see my tiles as flat plain color instead of expected data).
I also observed that the bug occurs much less when i quickly do take/release Z80 bus sequence right before triggering the DMA, but unfortunately it does still happen (i was hoping the delay about the Z80 request/release would be enough to avoid the clash on DMA start but that is not always the case).

Anyway, it's why we really need to investigate in depth this DMA bug, i would really like to find a solution to avoid it without halting completely the Z80 but i'm afraid the only solution is just to avoid having Z80 touching 68k at all during DMA and if it cannot be guarantee then halt it :-/

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by TmEE co.(TM) » Tue Aug 18, 2020 2:56 pm

Originally I saw it with CRAM yeah, but dedicated test used VRAM DMA. I will dig up the stuff hopefully in not so far future, there's currently bunc hof work stuff getting in the way (retro PC sound hardware stuff)...

I haven't actually ever experienced the DMA bug you describe.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by Sik » Wed Aug 19, 2020 6:48 am

I can confirm it's 0xFFFF because one of the reports was water flashing red in Miniplanets and red is the last color in its palette.

The DMA bug where it loads garbage has been happening so often lately it's not funny, I guess it's starting to rear its head now because homebrew is way more widespread and that means a lot more of people testing on a wide variety of revisions (also more people finding out that they need to recap their consoles urgently, but that's another topic). That's also why I decided to do the Z80 guard against I/O accesses just in case, because even though we haven't seen it yet I have the feeling that there's some revision out there that hits it hard and the diagram in the addenum seems to imply that it's prefectly possible for the Z80 to completely miss the read at all no matter how fast is the memory (depending on the alignment).

Bus arbitrer is a buggy piece of shit :​P

In the BlastEm server it was brought up that apparently Red Zone doesn't work on model 1 VA0 and that changing the work RAM for a faster one fixes it (?). That revision was exclusive to Japan and Red Zone didn't come out in Japan, so maybe it didn't get caught because it was never tested on Japanese consoles. Anybody know what Red Zone could be doing?


…also uh, hey? What about the known differences? Do we need to start testing absolutely everything again to know what differences apply on each revision or what? Because I'm pretty sure that there are more obvious places to look at than DMA glitches (TMSS (exposed through $A10001), YM2612 vs integrated YM3438 vs discrete YM3438 (exposed through status register), whether $A11000 has any impact on performance, just about everything from model 3 VA2…)
Sik is pronounced as "seek", not as "sick".

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Re: List of every detectable difference in Mega Drive revisions?

Post by Mask of Destiny » Thu Aug 20, 2020 5:26 am

These are the detectable differences I am personally aware of
* Open bus behavior of the Z80 bus (MD1 VA3 and later always return FF, earlier consoles will return last value read)
* Discrete YM2612 vs Integrated YM3438 (the latter allows status to be properly read on all addresses)
* Open bus behavior of the 68K bus (MD1 VA6 and possibly VA5 have some bits stuck or biased in one direction or the other)
* Amount of VSRAM present (MD2 VA4 and later have 64 words instead of 40)
* Whether TAS works right or not (MD3 VA2 only)
* How addresses are mapped in 128KB mode (MD3 VA2 is different here again)
* Whether work RAM has refresh delays or not (MD3 VA2 is once again the outlier)
* Amount of Z80 RAM (Teradrive has 16KB)
* Amount of VRAM (Teradrive has 128KB)
* Version register value

MD1 VA2 definitely fixes some bus arbitration bug of some sort present in VA0 and VA1, but I don't understand the bug well enough to know out how to detect it.

I have a test ROM that tests most of these.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by Sik » Fri Aug 21, 2020 3:26 pm

OK my notes so far (feel free to correct mistakes):

Code: Select all

???
- TMSS (hardware version 0 vs 1)
- YM2612 vs YM3438

MD1 VA3 onwards
- Z80 open bus returns $FF instead of last value read

MD1 VA5? and VA6 (only)
- bits stuck when open bus with 68000?

MD2 VA4 onwards
- VSRAM is 64 words instead of 40

MD3 VA2 onwards
- TAS instruction works
- VRAM 128K mapping changes
- RAM refresh changes

Teradrive
- has 128K VRAM
- has 16K Z80 RAM


Notes:
MD1 VA7 == MD2 VA0
MD2 VA4 == MD3 VA1
Knowing from which revisions Sega started to use the YM3438 would be nice, as well as when TMSS started being included. I think that should help narrow some gaps above. Also the part about bits stuck could use some detail (which bits are stuck and with which values).

Even then I think some board revisions are not accounted for, though if two revisions are practically identical in behavior it may not really matter… The main goal here is to detect board revision so when somebody comes in reporting that a game breaks there's an easy way to tell what the revision is without having to open up the console (so far the reports I've been getting include the serial number, which kinda give a ballpark of what revision it could be due to including the year but don't give enough detail).
Sik is pronounced as "seek", not as "sick".

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by TmEE co.(TM) » Fri Aug 21, 2020 5:30 pm

YM3438 only appeared as a block integrated in the MD2 ASIC, which first appeared in MD1 VA7 (the awful sounding MD1s lol).
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Re: List of every detectable difference in Mega Drive revisions?

Post by Mask of Destiny » Sat Aug 22, 2020 2:50 am

TmEE co.(TM) wrote:
Fri Aug 21, 2020 5:30 pm
YM3438 only appeared as a block integrated in the MD2 ASIC, which first appeared in MD1 VA7 (the awful sounding MD1s lol).
The Teradrive has a discrete YM3438 and in the other direction there are the MD2 VA2/VA2.3 which have a discrete YM2612.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Re: List of every detectable difference in Mega Drive revisions?

Post by TmEE co.(TM) » Sat Aug 22, 2020 5:02 am

That's something I didn't know, I mainly only commented among the actual consoles (except MD2 VA2, which I would like to get and a VA0 MD1). Discrete YM3438 has longer busy bit cycle from what I remember reading from nukeYKT core notes, compared to 2612 and ASIC which would be another way to detect things.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Post Reply