12-21-2021, 06:53 PM
Been under the weather (still am), so apologies for the late reply and if my foggy brain misunderstood any part of your post.
To modify this instruction to not subtract anything else, you can could just use an 04 RAM Write to rewrite the default instruction... (obviously this won't work out the player vs enemy issue, just showing you some options for running into a sub instruction)
In fact, you don't even need this (nor do you need something such as 'li r28, 0x12C'). Since r28 is part of the source and destination register, we just want r28 to keep its previous value. Therefore we don't need any default instruction, just 'nop' it. (04xxxxxx 60000000)
--
In regards to player vs enemy, try checking the GVR's in that index method I explained awhile ago if you haven't already.
There's no need for this, because nowhere earlier in you source did you rewrite the default instruction itself. But let's say this was the case, this would still be incorrect. Broadway (like all other modern microprocessors) utilizes cache. To keep things really simple, what you see in Memory isn't exactly what is occurring on the 'physical level' of the CPU.
Either way it's pretty neat to see how you did come up with the idea of rewriting instructions on your own.
Before I became ill, I had a few tutorials (one being about cache and rewriting executable instructions) that I was wrapping up and planning on posting. Maybe it's time to get some motivation and finish those up.
--
Another issue I can see in your source is that the default instruction has a record feature which includes the modification of the Condition Register (cr0). This could cause a slew of problems because the game is obviously running some sort of branch route after the default instruction based on the result of the CR (cr0). When you execute a basic 'cmpwi' instruction, you are modifying cr0 based on the results from said cmpwi instruction. And any typical conditional branch instruction (i.e. beq) will check the bits of cr0 and execute accordingly.
I would find a slightly diff place to hook the C2 to instead at that default instruction. If not, you're gonna wanna run comparisons & conditional branches in your source using cr7. But even if you did, then cr0 still might not be in a proper state, because the default instruction always has it updated before the branch route. So this better concludes to hook the C2 somewhere else. More info on the CR -> https://mariokartwii.com/showthread.php?tid=1743
Code:
sub. r28, r28, r5 #r28 minus r5. Place result in r28. Do cmpwi r28, 0.
To modify this instruction to not subtract anything else, you can could just use an 04 RAM Write to rewrite the default instruction... (obviously this won't work out the player vs enemy issue, just showing you some options for running into a sub instruction)
Code:
subi r28, r28, 0
In fact, you don't even need this (nor do you need something such as 'li r28, 0x12C'). Since r28 is part of the source and destination register, we just want r28 to keep its previous value. Therefore we don't need any default instruction, just 'nop' it. (04xxxxxx 60000000)
--
In regards to player vs enemy, try checking the GVR's in that index method I explained awhile ago if you haven't already.
Code:
lis r12, 0x7F85 #ASM Loads r12 with upper half-word of default code 0x7F85E051
ori r12, r12, 0xE051 #ASM Loads r12 with lower half-word of default code 0x7F85E051
lis r11, 0x8007 #ASM Loads r11 with upper half-word of address default code to be stored at 0x8007673C
ori r11, r11, 0x673C #ASM Loads r11 with lower half-word of address default code to be stored at 0x8007673C
stw r12, 0x0 (r11) #ASM restores original code when not taking damage or during cutscenes/intros
There's no need for this, because nowhere earlier in you source did you rewrite the default instruction itself. But let's say this was the case, this would still be incorrect. Broadway (like all other modern microprocessors) utilizes cache. To keep things really simple, what you see in Memory isn't exactly what is occurring on the 'physical level' of the CPU.
Either way it's pretty neat to see how you did come up with the idea of rewriting instructions on your own.
Before I became ill, I had a few tutorials (one being about cache and rewriting executable instructions) that I was wrapping up and planning on posting. Maybe it's time to get some motivation and finish those up.
--
Another issue I can see in your source is that the default instruction has a record feature which includes the modification of the Condition Register (cr0). This could cause a slew of problems because the game is obviously running some sort of branch route after the default instruction based on the result of the CR (cr0). When you execute a basic 'cmpwi' instruction, you are modifying cr0 based on the results from said cmpwi instruction. And any typical conditional branch instruction (i.e. beq) will check the bits of cr0 and execute accordingly.
I would find a slightly diff place to hook the C2 to instead at that default instruction. If not, you're gonna wanna run comparisons & conditional branches in your source using cr7. But even if you did, then cr0 still might not be in a proper state, because the default instruction always has it updated before the branch route. So this better concludes to hook the C2 somewhere else. More info on the CR -> https://mariokartwii.com/showthread.php?tid=1743