RayCarrot / RayCarrot.RCP.Metro

Rayman Control Panel (4.0.0 and above)
https://raym.app/rcp
MIT License
102 stars 5 forks source link

[Feature Rquest] Add support for Rayman Origins 3DS .ipk files #27

Closed Adamillo closed 4 months ago

Adamillo commented 5 months ago

The reason is that I'm working on a (very early WIP) mod that replaces the muddy audio inside the 3DS version of Rayman Origins to higher quality audio included in the PC version of Rayman Origins, but I can't repackage the changes back to an .ipk file, since I can only extract the 3DS .ipk file using a quickbms script, not repackage it

RayCarrot commented 5 months ago

Hi! That sounds interesting! 🙂 I'll go ahead and add support for Origins 3DS support for the next update. The .ipk files are structured a bit differently, but I'm familiar with the format and it shouldn't be too hard to add. I'll comment here again once the update is out. Good luck with your mod!

RayCarrot commented 4 months ago

I've now released the beta for the next RCP update, adding support for Rayman Origins 3DS .ipk files there. I'll close the issue now, but please let me know if there are any issues with it!

Adamillo commented 4 months ago

Unfortunately when I try to load up the modified IPK as romfs the game does not boot at all. To make sure that my mod wasn't the issue I simply replaced the mus_main_menu.wav file inside the 3DS IPK with the same exact mus_main_menu.wav from the extracted 3DS IPK from quickbms and it still didn't boot. I tested it with Citra. Don't be fooled by the file name btw, the structure of the audio files on the 3DS version is quite different and cannot be easily loaded up with tools like Audacity. Internally, the audio files are Nintendo's BCWAV format and this game uses ADPCM 4-bit

RayCarrot commented 4 months ago

I don't have the tools needed to test it myself but I think I found the issue. Can you test out this (had to upload to google drive since it's too big to upload here)? If this fixes the issue then I'll release this as a new bug fix update.

Adamillo commented 4 months ago

The build from Google Drive didn't fix the issue

Adamillo commented 4 months ago

Oh nvm it does work correctly in that google drive build. I still had the broken IPK. Now to see if the mod works... Edit: The mod doesn't seem to work, it's just completely silent, hmm

Adamillo commented 4 months ago

Strange, the game refuses to output any of the replaced audio that I throw at it. Doesn't matter if it's PCM16, PCM8 or DSPADPCM, at least in the BCWAV format. Wonder if it'll maybe accept normal WAV file, probably not, but it's worth a try Edit: Nope, it doesn't accept the normal WAV file either...

RayCarrot commented 4 months ago

Great that repacking the ipk works now! I'll release this as a bug fix update then. As for replacing the audio file, how are you doing it? I'm thinking there might be some values in the file header that need to change besides just the audio data itself. At least that's the case for the texture files which have a custom header before the data itself.

Adamillo commented 4 months ago

I'm using something called cwavtool in order to convert a normal WAV file to the BCWAV file format. It's a command line tool, and here's the link to it: https://github.com/PabloMK7/cwavtool

Adamillo commented 4 months ago

Seems like it even refuses to load the replaced audio on mono, 11KHz and DSPADPCM with my audio, even though the game uses those exact audio file configurations to play. Wonder what's making it refuse to output the audio...

RayCarrot commented 4 months ago

Can you upload one of your custom wav files? I could have a quick look and see if I notice anything with the headers. (btw, I published a new beta update now with the bug fix from the build I sent you)

Adamillo commented 4 months ago

Alrighty then. Here's the custom audio. It has the same configuration as the original one, at least in theory: https://drive.google.com/file/d/1pupPxmKXJoJZxNcskUbObO9AM1V51z_H/view?usp=sharing I also recommend using DSP LLE on Citra, since the output of DSP HLE is a little messy in this game

Adamillo commented 4 months ago

DSP LLE is slower though, so keep that in mind if you don't have a powerful CPU. If you don't like the way it stretches the audio when it slows down, you can disable that too. Though it will crackle when it slows down this time, but if you strangely prefer that like I do then you can leave it turned off like it did

RayCarrot commented 4 months ago

Try this and see if it works: mus_menu_main_custom.zip

Adamillo commented 4 months ago

What changed in that audio file?

RayCarrot commented 4 months ago

The game appears to contain the CWAV file data inside of a RIFF header. So I added the RIFF header to the beginning of the file: HxD_JWuK8ERDdc I'm not sure if this will work, but this is how all the other .wav files are structured in the game.

Adamillo commented 4 months ago

Unfortunately that didn't work...

Adamillo commented 4 months ago

It seems that there is still a difference between the 2 files. Maybe the game has a checksum? image

RayCarrot commented 4 months ago

The audio data is completely different in the two files yeah. I don't really know anything about this format or how the tool works though, so not sure why.

Adamillo commented 4 months ago

Could we debug this somehow? With an emulator like Citra we could find out what the game is doing and why it refuses to load the audio, right?

RayCarrot commented 4 months ago

I have no idea how to, sorry. I've never used Citra before and am not really familiar with how 3DS games work on a technical level. It might be possible to decompile the ROM in Ghidra and analyze the audio loading code, but that would be a lot of work and I'm not too familiar with audio data either.