Adding rumble support - Printable Version

+- (
+-- Forum: PPSSPP - Playstation Portable Simulator Suitable for Playing Portably (/forumdisplay.php?fid=1)
+--- Forum: Development (/forumdisplay.php?fid=3)
+--- Thread: Adding rumble support (/showthread.php?tid=15466)

Adding rumble support - Anarky - 04-29-2015 06:36 AM


I would like to contribute to PPSSPP by adding a rumble support, at least on GNU/Linux first. I have a few ideas to implement that, but I don't have (yet) a clear idea of the project's architecture and might not go in the right direction.

My first idea was to intercept a sound effect call, and depending of its internal number (or whatever the PSP uses), call the rumble function. It seems very hacky and only offers the possibility to bind rumble with sound.

My second idea was to add a function under Core/HLE, like sceRumble; this way it becomes a function callable like any other. The problem is how to use it? I believe action replay codes are only able to overwrite a RAM address with a value, is it possible to interact with the game?
For example, in LocoRoco, how can I hook to the event when a moja is hit?

Thanks for your help Smile

RE: Adding rumble support - GamerzHell9137 - 05-01-2015 10:01 AM

I don't think so about the AR way. I think if you want to add a new function to a game you would need to ASM hack every game to support it? With AR Codes you can change lines but haven't heard nor seen that someone added a new feature/thing trough them.

RE: Adding rumble support - Bigpet - 05-01-2015 10:59 AM

Well the way you would add functions via overwriting memory is pretty simple

if you have something like this in a function that you want to trigger the rumble

0x0880B000 addi a0, 5
0x0880B004 sw a0, 0x4(s0)

then you need to find some memory that is unused first (or some memory that you can safely overwrite, like unused online functionality, padding or whatever).

Let's suppose there's some unused space in 0x0881A0C0 then you can change the code to

0x0880B000   j 0x0881A0C0
0x0880B004   addi a0, 5
0x0881A0C0   sw a0, 0x4(s0)
0x0881A0C4   jal zz_sceRumble
0x0881A0C8   j 0x0880B008  
0x0881A0CC   nop

So basically, you overwrite one instruction to jump to a place where you then do that one instruction and everything additional that you want to do

RE: Adding rumble support - Anarky - 05-04-2015 01:44 AM

Thanks a lot for your detailed answer. Is there a way to find which address (or the area) I am interested in?
I tried to play with the disassembler and the memory viewer but I don't know how to efficiently use them.

RE: Adding rumble support - [Unknown] - 05-04-2015 06:32 AM

The trouble with adding function calls is that you have to expand function sizes. Sometimes this can cause bugs in new memory usage, so it'll be a unique thing with each game.

Another idea is like debug breakpoints - when the code hits a certain PC (potentially with a register than has a certain value or etc.), trigger rumble. This is a lot more limited, but means no code changes, so a bit quicker. Still a ton of work to find the trigger points in each game.

Sound effects are sent as raw data, either PCM, VAG (ADPCM), ATRAC3/ATRAC3+, MP3, or AAC. And rather than sending files, it sends frames of the audio, so he best you could do is fingerprint it or do "mood" analysis. Which might not be awful in its own way, I guess.

Note that a game may likely use ATRAC3+ for all of: voices, background music, and sound effects. Telling them apart is difficult at best. The good news is you can at least tell movie music apart.

There is an optional channel mixer games usually use. You could potentially apply heuristics to it to see when it's playing short sequences and then stopping for a while. That might detect sound effects.