Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

barcrest\mpu3.cpp: Correct 100hz signal to pia6821 ic3 #13215

Merged
merged 4 commits into from
Jan 13, 2025

Conversation

blueonesarefaster
Copy link
Contributor

@blueonesarefaster blueonesarefaster commented Jan 11, 2025

100hz signal to the pia was previously done with m_pia3->cb1_w(~m_signal_50hz);
As m_signal_50hz was an int with a value of 0 or 1 this meant cb1_w() was always being called with a non-zero value.

In addition to the above, it's supposed to be a 100hz signal, not 50hz.

This fixes software which boots and then locks with TURN-ON-DELAY 30 on the display.
Also, fixes software which use the WAI instruction and then lock.

@@ -747,14 +746,14 @@ void mpu3_state::machine_start()
}

/* generate a 50 Hz signal (some components rely on this for external sync) */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be updated to say 100 Hz.

m_signal_50hz = m_signal_50hz?0:1;
m_ptm2->set_c1(m_signal_50hz);
m_pia3->cb1_w(~m_signal_50hz);
m_signal_100hz = m_signal_100hz?0:1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, may as well clean it up a little: "m_signal_100hz ^= 1" would work to toggle it without needing the compare.

@blueonesarefaster
Copy link
Contributor Author

BTW, there are a couple of games which don't run due to a problem in the 6802 core.
The CLR instruction actually performs a read-modify-write cycle but the emulation only does a write.
Similarly, the TST instruction also does the same, although only the CLR instruction stops the games from running.

As the cpu core covers several processors I'm not going to mod it at this point.

Might be worth making a note of this somewhere for the future ?

@rb6502
Copy link
Contributor

rb6502 commented Jan 11, 2025

Those 6802 fixes seem like pretty low-risk changes, but I can check them out if you can give me more info on which MPU3 games break (and ideally the program counter of the bad CLR instruction).

@happppp
Copy link
Member

happppp commented Jan 11, 2025

I don't think 6800 TST is read-modify-write?
CLR: Yup, 6800 manual talks about it too.

Try this suggested fix in 6800ops.hxx:
line 832: INDEXED; RM(EAD); WM(EAD,0);
line 984: EXTENDED; RM(EAD); WM(EAD,0);

I see the read cycle too in Hitachi 6301Y0 manual, so Hitachi kept the dummy read in.

@blueonesarefaster
Copy link
Contributor Author

I don't think 6800 TST is read-modify-write? CLR: Yup, 6800 manual talks about it too.

Try this suggested fix in 6800ops.hxx: line 832: INDEXED; RM(EAD); WM(EAD,0); line 984: EXTENDED; RM(EAD); WM(EAD,0);

I see the read cycle too in Hitachi 6301Y0 manual, so Hitachi kept the dummy read in.

I had that change in my local copy and I know it fixes the games which don't currently start.
Just wasn't sure it applied to all variations of the chip from different manufacturers.

The 6802 datasheet lists the TST instruction together with CLR and all other RMW instructions but there is a note attached to it which I didn't spot.
So, for TST the write cycle actually happens but the valid memory address signal remains inactive so the write shouldn't actually happen.

I'm happy to do the CLR changes if everyone else is happy they're safe ?

@rb6502
Copy link
Contributor

rb6502 commented Jan 12, 2025

Yeah, go ahead and add hap's fixes. Also, for the second change, you put:

m_signal_100hz = m_signal_100hz^=1;

That's one too many assignments, which is why the auto build is complaining. Just "m_signal_100hz ^= 1;" works. And we prefer it with the spaces between the parts like I have there.

@ajrhacker
Copy link
Contributor

M6801 never performs a write cycle for TST. CLR, on the other hand, is in fact executed as a unary read-modify-write operation on M6800 and M6801, much like it is on M68HC11, M6809, MC68000 (but not its 16-bit and 32-bit successors) and most PDP-11 models.

@happppp
Copy link
Member

happppp commented Jan 12, 2025

That CLR fix is better placed in a new PR. But instead, it's faster to just add it directly, which I did: 035b34a

I think at most, a few drivers will get a spammy error.log (debug->new error log window). If it gets too bad, they can add a nopr().

@blueonesarefaster
Copy link
Contributor Author

Thanks happppp, I was just about to do that.

I've now fixed the toggle of m_signal_100hz and changed comments on some games.

@rb6502 rb6502 merged commit e0b1e23 into mamedev:master Jan 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants