mkst / maspsx

MIT License
5 stars 4 forks source link

Possible maspsx bug in Legacy of Kain: Soul Reaver function? #105

Closed FedericoMilesi closed 4 days ago

FedericoMilesi commented 4 days ago

Hi,

I have been decompiling this function for a while, it's the third largest one from the game, so there's a lot going on in here but it's currently 99.95% matched: https://decomp.me/scratch/853nW

Only thing that is preventing from getting a 100% match is a misplaced instruction, but, I wonder if it isn't a maspsx bug because using the PsyQ 4.3 config even though the matching percent gets bogged down to 92.60% due to extra division code and such, the relevant subu instruction is correctly placed then.

Kind regards, Federico.

mkst commented 4 days ago

Let me investigate, does look like a maspsx issue, but not sure why the subu/nop is ordered that way.

This is using psyq (only $gp differences?) on mobile: https://decomp.me/scratch/vV9eT

Test case:

$L125:
    sll $2,$2,12
    div $2,$2,$7
    subu    $2,$10,$2
    mult    $2,$8

I guess because the subu reads from $2 (which the div stores to) the nop is before the subu rather than after it. Surprised this hasn't come up before.

mkst commented 4 days ago

Interestingly, the diff when using PSYQ suggests Legacy of Kain uses ASPSX 2.81 as I can :OK: this function locally using ASPSX 2.81.

mkst commented 4 days ago

Latest maspsx deployed to decomp.me (your scratch is now :ok:)

image

FedericoMilesi commented 3 days ago

Thanks for the attention, I am glad to finally be able to get this function into the project since it's the second largest function written in C and nets quite a nice amount of matching bytes.