-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New implementation of sceAtrac (the Atrac3+ module) #20098
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
Conversation
Guess what? This now fixes Flatout! (Well, behavior at the end of the songs / looping is still not implemented....) |
Thanks for pre-testing! I'll add a comment here when it's actually ready to be fully tested. Known errors are "halfway" buffers and looping/resetting. |
GTA Vice City now plays music/speech, although testing some more games I find a lot of issues remaining, plus looping and seeking isn't implemented yet. But progress! Quite a lot of games actually play music now without crashing, so that's nice. It might make sense to start testing previously problematic games now... |
Hello, 10 years since the first issue report about this bug! Glad to see the light at the end of the tunnel :). Do you have a list of the problematic titles? Thanks for your amazing work. P.S.: Do you any build for testing? |
Fixed a bunch more issues, now Burnout Legends is solid, and Flatout still works ;) Well, I was right in my prediction that a total rewrite of I'll collect a list of games that have Atrac issues from around the issue tracker, I expect this to fix most of them once done (added list in the top post) Looping while streaming still remains to be implemented, and it's pretty complex. As for testing builds, you can grab builds from CI right here on github if you know where to look, or build your own from this branch. Or just wait for this to hit master, I'd estimate a few more days to a week before I'm fully done with it. I have to hold off on actually merging this until I have savestate handling for this implemented correctly, and I want it pretty solid first. |
Added a link to the new sceAtrac documentation I've written. Next up I'll be working on the trickiest case, looping+streaming. |
Is there any precompiled android build to download and test? Checked github actions but android build seems to be absent there. |
you can use the manual generate android apk workflow and select the branch used by this PR (ie. atrac3-new-impl) to generate the apk. |
Hm, getting further (more commits are coming soon), but I'm facing a slightly odd issue.
It seems the contexts are actually simply located in the data segment of sceAtrac. Where that will be will depend on whether the module is fake-loaded through sceUtilityLoadModule or if an sceAtrac.prx is loaded from disk (and then unused since we HLE it). Some games use sceUtilityLoadModule, others supply their own. But in the latter case, at least in the first case I tried, the bss section is too small.. 0x5c0 instead of the required 0x600 bytes for six contexts. Though almost nothing uses that many.. Anyway I guess we'll need two cases here. I could just allocate contexts in fake "kernel space" and avoid the problem entirely, but I don't like that since it'll have games doing accesses that "should" be illegal, if they call _sceAtracGetContextAddress. Another thing I noticed is that digging a bit deeper into how Atrac3+ works, it itself uses sceAudiocodec, so maybe we can just run the native sceAtrac when it's supplied by games on disk and only HLE sceAudiocodec instead in those cases.. |
Btw, in your documentation, on GTA Vice City, there is "Atrac2" being mentioned, was it a typo? |
That's just the (current) name of my new implemementation. I'll clarify it later (and probably rename the current one to AtracLegacy and the new one to Atrac, internally). |
Hoping it's not late, but i can report that FIFA 07 doesn't crash with the current sceAtrac implementation in the branch build. |
Fix #5564 with "experiment sceAtrac" in option |
f8f27c9
to
a142d81
Compare
Alright, implemented proper support for looping while streaming, including with trailer, and full savestate support with backwards compatibility. Things seem to work pretty well, and my new set of detailed tests all pass (they will be updated soon). Please re-test things that weren't previously working (don't forget to enable the Experimental Atrac3+ setting in developer options) Note that if you load old savestates, the old implementation will be used - you need to restart and load from a proper in-game save. Oh yeah, Sol Trigger is probably not gonna work, I'll have to write a test for the sceSas + sceAtrac interaction. |
re-tested FIFA 07, still good, no bad memory execution crash whatsoever. |
By using thr above method, I tested this with FlatOut on Android and it works both in the menu and in game with 60 fps patch enabled as well. Happy times! Thank you for the huge effort, @hrydgard! |
v1.19 milestone |
Re-implementation and documentation of sceAtrac
IT FIXES FLATOUT!
The new documentation page, trying to document sceAtrac in detail:
https://www.ppsspp.org/docs/development/ppsspp-internals/atrac/
You guys can start testing some problematic cases now. NOTE: To test it, go into developer setting (on a build from this branch) and enable Experimental Atrac.
Atrac3+ is Sony's proprietary format used for music playback (similar to MP3). sceAtrac is the Sony library used to parse the streams, handle buffering and decode them. It's very complex.
This is a new approach to sceAtrac emulation. Instead of trying to simulate the surface behavior, we now go deep and exactly replicate everything including using the Atrac context state directly, instead of having a lot of extra state variables.
To do this, I've written a new hardware test, and more are coming: hrydgard/pspautotests#235
Luckily, sceAtrac exposes a pointer to its inner state using the
_sceAtracGetContextAddress
function, so my hardware test can read all the variables from the state, and we can compare. I've uncovered which variable represents the buffer read pointer while streaming, which wasn't known before.Unluckily, there's still a ton of complexity here, especially around looping etc which has always been a pain. But it seems to be managable.
This will stay behind the "Experimental Atrac3+" setting until it starts getting reliable across a lot of games. But the hope is that soon we'll be able to default to this for all games, and that it will fix a lot of the more mysterious Atrac bugs.
Remaining work:
To test
Moved all the checkboxes to #20125