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

RetroAchievements CSO support, delay until identified #17699

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Jul 11, 2023

Adds support for identifying CSO files for retroachievements.

Additionally, prevents auto-loading save states in challenge mode.

Also a correctness fix: Don't start executing the game until RetroAchievement identification is done.

See #17631

@hrydgard hrydgard added the RetroAchievements RetroAchievements related work label Jul 11, 2023
@hrydgard hrydgard added this to the v1.16.0 milestone Jul 11, 2023
@hrydgard hrydgard changed the title Retroachievements CSO support, delay until identified RetroAchievements CSO support, delay until identified Jul 11, 2023
@hrydgard hrydgard merged commit 431a055 into master Jul 11, 2023
@hrydgard hrydgard deleted the retroachievements-cso-support branch July 11, 2023 23:11
@hrydgard
Copy link
Owner Author

hrydgard commented Jul 11, 2023

Oops, accidentally squash-merged, stupid github remembering what I did last. Oh well, just two commits.

int firstBlock = offset / blockSize;
int afterLastBlock = (endOffset + blockSize - 1) / blockSize;
int numBlocks = afterLastBlock - firstBlock;
// This is suboptimal, but good enough since we're not doing a lot of accesses.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Without looking super hard, it seems like it'd generally read aligned sectors:
https://github.com/RetroAchievements/rcheevos/blob/aa6324e886e12da0cf24dee1cf4e873571f39191/src/rhash/cdreader.c#L827C68-L827C81
https://github.com/RetroAchievements/rcheevos/blob/aa6324e886e12da0cf24dee1cf4e873571f39191/src/rhash/cdreader.c#L62

Overall for an entire ISO, might be worth checking if offset == firstOffset && requested_bytes == numBlocks * blockSize and just reading directly. But probably the IO will dominate anyway...

-[Unknown]

Copy link
Owner Author

@hrydgard hrydgard Jul 16, 2023

Choose a reason for hiding this comment

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

It only hashes a few files anyway, so there's no heavy pressure on this.

Also, the very first read it does is actually sector-unaligned - I first tried to assume aligned sectors but that was a no-go, so I just made a general quickfix.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, it's not reading the whole ISO? Then yeah, probably not a worry anyway.

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, it's not ideal but it's how RetroAchievements does things, and for user experience it's a good thing, of course... It hashes the eboot and paramsfo basically. Cheating through hacking other files is thus perfectly possible, but on the other hand, you can just hack the emulator instead...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RetroAchievements RetroAchievements related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants