jessaskey / mhavocpe

Major Havoc - The Promised End
18 stars 2 forks source link

Boot up in test mode and Quad Pokey is labeled bad. #204

Open bakerhillpins opened 2 years ago

bakerhillpins commented 2 years ago

0.85

If you boot up in test mode (Self Test switch on) the Quad Pokey will be labeled as bad with a red X in the ST screen. If you boot up into the game and flip the ST switch the POKEY passes.

jessaskey commented 2 years ago

This is sort of a weird one and I wonder how consistent it is on your hardware? The way that the POKEY is 'tested' is really not very reliable because all the routine does is read the random number generator from the POKEY and then it reads it 24 more times and looks for a result that is different than the first read... if any of subsequent results are different from the original read, then the POKEY will pass.... so what this means is that somehow your POKEY (and for the QUAD Pokey it just uses the random generator from ONE POKEY) is sending back 24 random numbers which are the same value. So, either your POKEY is weird OR there is indeed a strange bug that is showing this error for a totally different issue.

bakerhillpins commented 2 years ago

Happened every time I tried. Probably tried 6 times.

bakerhillpins commented 2 years ago

Just did it again. Seems to happen every time on HW.

IMG_9845

jessaskey commented 1 year ago

Im still investigating this one... (in v1.01).... the Pokey is a challenge to troubleshoot in MAME because of the way MAME runs emulations, it sorta assigns PC CPU time in chucks to the various 'devices' that are emulated in MAME. The major devices in this issue are the Alpha CPU, the Gamma CPU and the Quad Pokey. Between the Alpha and the Gamma, MAME lets each CPU run for about 500 cycles and then switches over to the Gamma and runs it for 500 cycles, similarly, with the POKEY, it seems that after about 100 cycles, the Pokey updates. So both the Alpha and Gamma may need to wait a bit before the POKEY gets any attention in the emulator. Long story short, this affects the random number generator in the POKEY and when the GAMMA reads the POKEY random number register, the results will be the same number for up to 100 cycles of the GAMMA CPU. This specifically causes issues during Self Test because the way that Atari tests if a POKEY is good, is by reading the random number generator of each POKEY (4 in the QUAD)... if it reads the same random number from the POKEY 5 times (in about 25 cycles of GAMMA CPU time), then it assumes that the POKEY is bad.

In MAME I am able to get POKEY's to pass if I increase the testing iterations up to about 40 cycles (instead of 5)... unfortunately, this makes the self test run longer enough that it confuses the Alpha sometimes on the state of the GAMMA and it can cause the GAMMA CPU to be reset. So, there is a cascade of issues that happen.

I left the test cycles to 5, which is what Atari set it at and came to peace with the fact that the POKEY will always show as BAD in MAME, but it should be fine on the actual hardware since there is no 'time sharing' between devices.

So... to your point... on actual hardware, the POKEY should be testing okay, but it is challenging to troubleshoot this in MAME because of the differences. The only real addition that I could do here is to somehow specify WHICH POKEY the random number generator failed on or allow some sort of test to show the random numbers that are being generated by the POKEY's (which would be sorta cool to show on a test screen, but I don't have the time for that! :-) )

bakerhillpins commented 1 year ago

The POKEY tests bad when you power up with the self test switch ON. If you boot up into the game and flip the ST switch the POKEY passes. I wasn't clear in that distinction in the description so I added this. Sorry as it appears I sent you off into the weeds a bit.

This occurs on the last ROMs you sent as I remember seeing it while I was looking at the input issue.

jessaskey commented 1 year ago

Okay, I will check that specific issue. I have a feeling that several issues that come up in regards to Alpha <-> Gamma communcation are all based upon some timing and deeper bugs that only manifest in certain situations. I found a bug in the EEROM WRITE code that was causing #208 and that was sorta throwing the Gamma into a bit of a fit. I also found strange 'zero' commands coming to the Gamma from Alpha which should never be happening and also sends the Gamma into odd work tasks. All this feedback is good tho and getting things ironed out as I find root causes to more complex issues.

One note about this particular bug, I feel like something might be happening where when the EEROM tests bad (or has a bad checksum), that the GAMMA is also getting stuck or sending back data that the Alpha is interpreting as a bad POKEY. The Gamma code that runs on a fresh reboot and to enter Self Test is exactly the same (including a full memory reset and init both times on the Gamma).

bakerhillpins commented 1 year ago

This is NOT fixed on my 1.01 PE ROMs. Flip test switch, power cycle and then advance to the 2nd screen. POKEY has red X.

jessaskey commented 1 year ago

I saw this on mine too, there might not be much I can do about this but I will def take a look again.