Add Y distance check to business Deku Scrub talk#2552
Conversation
|
If the code doesn't make sense in ASM but makes sense in C, I think you should create a C function for it instead. You're already successfully recompiling the C which isn't necessary for ASM only hacks, so you have already finished the hard part of getting a toolchain setup. Instead of creating a label |
Thanks, I think I will do this with more advanced hacks. |
|
I agree with flagrama that, if possible, readable C code is preferable to ASM magic no one can explain. We had issues last year with old ASM hacks that no one really understood anymore and that we had to fix anyway. |
|
Now a few days later I am more experienced with floats and updated the asm with comments. This is how it looks with breakpoint at |
GSKirox
left a comment
There was a problem hiding this comment.
Aside from this question, i understand the rest of the fix, and i did also test it and everything seems to work fine.
| c.lt.s $f0,$f4 ; Y distance < 100.0f? | ||
| bc1tl @@EnDns_YReturn ; If yes, continue function | ||
| nop ; Else... | ||
| addi ra,ra,0x8c ; Go to 0x80a7550c (EnDns_Idle function return) |
There was a problem hiding this comment.
I'm assuming this forces an early return but i've never seen this syntax before.
This adds some value to the return register?
There was a problem hiding this comment.
Yes, increase the return address by 0x8c to return to the end of calling function
There was a problem hiding this comment.
Sorry for the late answer, I was asking around because i remembered some warning about the ra register.
Turns out we did have issues before when trying to do this sort of thing on VC :
https://github.com/OoTRandomizer/OoT-Randomizer/pull/2345/changes
This kokiri actor hack previously added a value to the ra register and this caused inconsistent crashes on VC.
There was a big discussion about it on the discord and the conclusion was that we should never assume the state of the RA register and basically just avoid ever touching it other than with jr ra.
Feel free to bring this up more in the #dev-public-talk channel, mracsys and flagrama who poked around this issue last time should be able to have more elements.
|
Updated with no |

ASM fix to add Y distance check to business Deku Scrub talking, which includes selling items. Fixes #2285.
Deku Scrubs have a Y distance check for giving the item, but not for selling it. In MQ Deku Tree player can buy the item from the water (is within XZ distance), but cannot receive it (is outside Y distance), potentially losing the check. This adds Y distance check of 100.0f to talking, which is the same as receiving item.
The float distance checking is 100% a product of disassembly of C code and I cannot explain how it works at all, but it does. I used matching decomp NTSC 1.0 as base, added check, took the disassembly and modified it to fit with jumps.
Testing
Works in Ares 1.47, Project64 3.0.1 and Mupen64plus 2.8. https://www.youtube.com/watch?v=qhhwmbkHhbo
Tested with adult as well.
I have not tested any scrubs beyond MQ Deku Tree and Lost Woods bridge. If the added check somehow would mess with a scrub I'll look into how that could be solved. A scene id check could be added to make this change only apply to the MQ Deku Tree scrub etc.