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

thunderx: simplified code of 052591 PMC emulation for clarity #11759

Merged
merged 2 commits into from
Nov 19, 2023

Conversation

jotego
Copy link
Contributor

@jotego jotego commented Nov 19, 2023

  • removed unneeded loop counters
  • removed unneeded multiplication/division operations
  • matched variable names in both functions

Played the game for 20 minutes with no issues. Collision detection works the same.

…nding

- removed unneeded loop counters
- removed unneeded multiplication/division operations
- matched variable names in both functions
src/mame/konami/thunderx.cpp Outdated Show resolved Hide resolved
src/mame/konami/thunderx.cpp Outdated Show resolved Hide resolved
src/mame/konami/thunderx.cpp Outdated Show resolved Hide resolved
src/mame/konami/thunderx.cpp Outdated Show resolved Hide resolved
@jotego
Copy link
Contributor Author

jotego commented Nov 19, 2023

I have applied the changes requested

@cuavas cuavas merged commit e4d59f2 into mamedev:master Nov 19, 2023
5 checks passed
Comment on lines -444 to +437
Y0 = m_pmcram[0];
Y0 = (Y0 << 8) + m_pmcram[1];
Y0 = (Y0 - 15) / 5;
Y1 = (m_pmcram[2] - 15) / 5;
const int e0 = (m_pmcram[0]<<8) | m_pmcram[1];
const int e1 = m_pmcram[2];
Copy link
Member

Choose a reason for hiding this comment

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

Note that this actually does change behaviour – previously it divided the Y1 value by 5 and then multiplied by 5 again later. If the actual value was not a multiple of 5, the remainder would be truncated. That’s no longer the case. It now uses the actual value from RAM directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but data is accessed in groups of 5 later on. The new code makes more sense and is more parsimonius. I have not been able to find any problem in the gameplay after the change.

I do not know why the original author ended up writting those divisions and multiplications. They might be some leftover from all the guess work needed to emulate the chip or maybe he was trying to make sense of the program bytes written by the CPU.

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.

None yet

2 participants