Dolphin, the GameCube and Wii emulator - Forums

Full Version: [Patch] dspHLE Mario galaxy 1 music
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
ok guys, all the credits is for nexus, almost all is based on his modifications on patch v1, v2 and v3 for zelda, and his patch for intro music, thanks to him and xtreme2damax too.

Ive decided to create a thread apart, couse this problems are different for each game; copy paste myself:

i feel that the solution for mario galaxy is near, i can't wait xD.

Ok guys, finally i managed to reproduce the music without cuting off. Now, this is the weird thing, this patch only fix sounds from the begining to the first planet or second, don't remember, aaaHH, yes, when you meet the other princes (the mother of stars?), then the sound start to loop weird again (it must be couse i use last fixv3 from Nexus). Ok that is all, i wish people can help me with this, couse practically, i didn't do alomst anithing to the code, only a few modifications.

To reproduce the same experiencie, this is what i have: Windows 7 x64, with ati hd 5770 and phenom II x2 555 @ X4 @3,8ghz and 4 gb of ram. The main config is dual core, idle skip, lock on theards, lle on single thread eneabled. OpenCL eneabled.

Audio plugin audio throttle is disable.
Video plugin is dx9 all default but eneable efb copy to texture.

Greets and sorry for my poor english, i wish you understand me. CYA

------------------------

Oo the most important thing i forgot to mention, i'm using my compiled version with opencl x64 of the emu at rev 5807M (M is becouse of Opencl?)
---------------------------
mmmm this may cause loop problems on zelda tp, i can't verify that couse i don't have that game. Plz, somebody check it
also posted this patch on my "no so issue" : http://code.google.com/p/dolphin-emu/iss...il?id=2875
-----------------------------------
guys, i need people to test this patch, couse xtreme told me that killed his audio completely on wind waker. But after that, i've managed to aquire wind waker, and i don't have any glitches (only one, that i think i know how to fix it. It is a glitchy sound that u can hear time to time, but notheing more). Cheers

----------------------------------------------------------------------------------
Last update:

Ok, this is what i got so far:

I'm doing things with RE (yep, read the manual of menanings like clrc or subax and that stuff). I think i've got something interesting while doing this reverse engineering. This is the thing, i've looked into UC_MarioGalaxy_wii.txt or smething like that xD, and found that it's kinda wrong how SizeForResampling and ConvertRatio wroks, or maybe i didn't understand the RE, here it goes:

Code:
// Prepare regs for format 0x10                                \/                                             |
0b2e 0092 0004 lri         $CR, #0x0004                // $CR = 0x0004                                     |
0b30 2002      lrs         $AX0.L, @0x0002             // $AX0.L = RatioInt                             |
0b31 8100      clr         $ACC0                       // $ACC0 = 0                                     |
0b32 8900      clr         $ACC1                       // $ACC1 = 0                                     |
0b33 2430      lrs         $AC0.L, @0x0030             // $AC0.L = CurSampleFrac                         |
0b34 8d00      set15                                   // doo?                                             |
0b35 0950      lris        $AX1.L, #0x50               // $AX1.L = 0x50                                 |
0b36 a000      mulx        $AX0.L, $AX1.L              // product = CurSampleFrac * 0x50                 |
0b37 a400      mulxac      $AX0.L, $AX1.L, $ACC0       // $ACC0 = product -> (RatioInt * 0x50)          |
0b38 1404      lsl         $ACC0, #4                    // ACC0 = (RatioInt * 0x50) << 4;                 |
0b39 8c00      clr15                                   // doo? = 0                                         |
0b3a 1ffe      mrr         $AC1.M, $AC0.M                // AC1.M = AC0.M;                                 |
0b3b 0083 0580 lri         $AR3, #0x0580               // $AR3 = 0x0580                                 |
0b3d 02df      ret                                     // return

Resulting in what i think, that this part of code from UCode_Zelda_voice.cpp:

Code:
int CUCode_Zelda::SizeForResampling(ZeldaVoicePB &PB, int size, int ratio) {
    // This is the little calculation at the start of every sample decoder
    // in the ucode.
    return (PB.CurSampleFrac + size * ConvertRatio(PB.RatioInt)) >> 16;

Is wrong. As i stated before with the RE, the return should be something like this:

Code:
return (size * ConvertRatio(PB.RatioInt)) >> 16;

And the PB.CurSampleFrac should be gone, and so, adapt the size to 0x50, when i reched this, i though that i should read the UC_Zelda.txt, and the surprise is this:

Code:
    // 0a1b 0950      lris        $AX1.L, #0x50
    // 0a1c a000      mulx        $AX0.L, $AX1.L
    // 0a1d a400      mulxac      $AX0.L, $AX1.L, $ACC0
    // 0a1e 1404      lsl         $ACC0, #4
    // 0a1f 8c00      clr15      

    // Compute how much data we need to read, to get 0x50 samples after resampling.
    // AC0.L is cursamplefrac, AX0.L is ratio.
    $ACC0 = (PB.CurrentSampleFrac + 0x50 * PB.Ratio) << 4;

They look similar, only that this have the PB.CurentSampleFrac added to mulxac, and mulxac only multiplies the others ac. So i tried this, erasing the currentsamplefrac, and i obtained a very long time music, but after 4 or 5 repeats, don't remember well, it cut off and i got fifo error. The strange thing is that i think that the samples are being calculated wrong, so with each looping, the adress copied to mem is also wrong, so i think the factor for convertraio should be changed ( to 0x50 ? ). Greets
I would just like to inform you that your last patch killed the intro music on Windwaker, kept skipping, looping, and crackling like crazy.
One thing for another xD jocking, maybe i have to do this with and IF function, so changes only work for this game if it is present
btw, i'm trying to get zelda tp from a friend of mine, so i cand check what is the influence of the patch. cheers
oops it was wind waker, not tp xD have to search for it again
(06-29-2010, 11:30 AM)Xtreme2damax Wrote: [ -> ]I would just like to inform you that your last patch killed the intro music on Windwaker, kept skipping, looping, and crackling like crazy.

Are you shure xtreme? couse iv'e tested both zeldas (tp for wii and wind waker gb), and i don't have any glitches, well one that seems i have a little, very little, skip, but nothing more (i think i know how to fix it anyway), it didn't kill music at all. May i ask what version are u using?
guys, i need people to test this patch, couse xtreme told me that killed his audio completely on wind waker. But after that, i've managed to aquire wind waker, and i don't have any glitches (only one, that i think i know how to fix it. It is a glitchy sound that u can hear time to time, but notheing more). Cheers
Awesome news if true...
You could try to compile a version with the patch included to make it easy to a wider range of testers to check it out.
So cool someone is tinkering on this! Where are the DSP devs to give this guy a hand?
@ Torin: Does it work the same for SMG 1 and 2?
ok, since this thread is about smg1 music fix i will only comment on that

changes regarding PCM16:

- PB.CurAddr = PB.StartAddr + (PB.RestartPos << 1);
+ PB.CurAddr = ((((((PB.LoopStartPos >> 4) & 0xffff0000)*PB.Format)<<16)+ (((PB.LoopStartPos >> 4) & 0xffff)*PB.Format))+PB.StartAddr) & 0xffffffff;;

This is plain wrong, code as it was can be verified in dissasm. And you replaced it with this formula i reversed long ago when i tried to fix Zelda TP music (AFC).

+ // for debugging only (has to be put into corresponding methods)
+ if (((pb.Format == 16) || (pb.Format == 0x0008)))
+ {
+ if (pb.LoopStartPos != 0)
+ pb.ReachedEnd = 1;
+
+ if (pb.IsBlank == 1) {
+ // Don't know what to do...
+ // if pb.IsBlank == 1 music stops dead and only sound effects are present
+ // even if part of a game is finished and new stuff is loaded
+ pb.IsBlank = 0; // this does not work... (music either stops or loops in short circles)
+ }
+ }

This again is a hack that will not cure the problem and it will cause SMG1 music to play in very short loops sooner or later.

Btw... music is not stoping under LLE, so if someone is bored enough he can use that to improve hle (or wait for LLE
to be faster).
yeap, i think the same, but that formula prooved that the loop of pcm16 is right, and the thing is wrong is how the pcm16 decoder update it counter samples. Today when i return home, i'll work on this. Cheers
(06-29-2010, 05:46 PM)StripTheSoul Wrote: [ -> ]So cool someone is tinkering on this! Where are the DSP devs to give this guy a hand?
@ Torin: Does it work the same for SMG 1 and 2?

Haven't tried for mario galaxy 2, but i think it will work at a certain parte like in mario galaxy 1, and then it will loop wrong. As i said before, i think we need to check and rewrite how pcm16 update its counter samples
(06-30-2010, 12:34 AM)Torin Wrote: [ -> ]yeap, i think the same, but that formula prooved that the loop of pcm16 is right, and the thing is wrong is how the pcm16 decoder update it counter samples. Today when i return home, i'll work on this. Cheers
(06-29-2010, 05:46 PM)StripTheSoul Wrote: [ -> ]So cool someone is tinkering on this! Where are the DSP devs to give this guy a hand?
@ Torin: Does it work the same for SMG 1 and 2?

Haven't tried for mario galaxy 2, but i think it will work at a certain parte like in mario galaxy 1, and then it will loop wrong. As i said before, i think we need to check and rewrite how pcm16 update its counter samples

i tried in smg 1 , and the music last more time. For example i enter the library in SMG 1 and i heard music the entire book with 5 chapters, but than i get out and go to engine room and star the water level that has a shark in it, and you have to follow him tru circles and the music stops when i enter the water. Undecided


but keep the GOOD WORK guys
You have to remove the following lines:

+ // for debugging only (has to be put into corresponding methods)
+ if (((pb.Format == 16) || (pb.Format == 0x0008)))
+ {
+ if (pb.LoopStartPos != 0)
+ pb.ReachedEnd = 1;
+
+ if (pb.IsBlank == 1) {
+ // Don't know what to do...
+ // if pb.IsBlank == 1 music stops dead and only sound effects are present
+ // even if part of a game is finished and new stuff is loaded
+ pb.IsBlank = 0; // this does not work... (music either stops or loops in short circles)
+ }
+ }

Otherwise you cannot test if your changes cure the problem. As I stated earlier, this hack sometimes works too good Wink
I usually test my changes in SMG in a normal level. Just stand still on a place where there is no special sound effects (only background music).
Another good test is Mario Kart Double Dash because the music almost always stops after 1 minute and 20 seconds.

Torin, what is the purpose of the changes in Decoder21_ReadAudio? Is this code ever called while playing SMG?

Greetz,
neXus

P.S.: This code part kills music (at least in Mario Kart Double Dash)
in RenderVoice_AFC method:

56 PB.RestartPos = PB.LoopStartPos;
57 - PB.RemLength = PB.Length - PB.RestartPos;
58 + UpdateSampleCounters59(PB);
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18