
Originally Posted by
Jinzo
Can you make a NUB PROOF Jokering On/Off Tutorial?
Well all jokering is is this:
Check the controller address for what button we are pressing, if we are pressing the right button activate a code or codes.
Template:
Code:
Lui t0 $XXXX //Upper controller address
Lw t0 $XXXX(t0) //Lower controller address(t0)
//t0 Now holds the value in the controller address
//First line loads the upper address
//Then the LW command does this:
//t0 = VALUE AT ADDRESS {(t0) + {Lower address}}
//So t0 = the button's value currently being pressed
Addiu t1 zero $XXXX //Button Value To Activate Code
//This is saying:
//t1 = zero + 0x0000XXXX
//Or:
//t1 = 0x00000000 + 0x0000XXXX
//So now the button value for the button we want is in t1
Bne t0 t1 $XXXXXXXX //{Address of Jr ra}
Nop
//This is basically saying:
//if t0 is not = to t1 go to jr ra
//The jr ra jumps back to your hook (Two lines after to be exact)
//ending your subroutine.
//The nop is the code's delay slot, needed because
//All branches and jumps use the delay slot (Not going in depth right now)
//Now we make are code activate:
Lui t2 $XXXX //Upper code address
Lui t3 $XXXX //Upper code value
addiu t3 t3 $XXXX //Lower code value
//t3 = full value now
sw t3 $XXXX(t2) //Lower code address
//This is saying:
//Change the value at this address:
//{(t2) + {Lower address}}
//To the value in t3, making are code activate
//Now we add a jr ra to jump to the address after the hook's delay slot
Jr ra
//And we are done
Let me know if you have any questions, tried to explain it as best I could in the time I had.
EDIT:
Make sure you can write a normal working subroutine like this first:
Code:
Lui t0 $XXXX //Upper address
Lui t1 $XXXX //Upper value
Addiu t1 t1 $XXXX //Lower value
Sw t1 $XXXX(t0) //Lower address
Jr ra
Nop
EDIT TWO:
I know this isn't On/Off Like you said so here is an example of an On/Off, use the info above to know how it works:
Code:
Lui t0 $XXXX //Upper controller address
Lw t0 $XXXX(t0) //Lower controller address
Lui t1 $XXXX //Upper code address
Addiu t2 zero $XXXX //Button value to turn on
Addiu t3 zero $XXXX //Button value to turn off
Bne t0 t2 $XXXXXXXX //{Address of next bne} //If we are pressing on button
Nop
//Make code turn on
Lui t4 $XXXX //Upper on value
Addiu t4 t4 $XXXX //Lower on value
Sw t4 $XXXX(t1) //Lower address
Bne t0 t3 $XXXXXXXX //{Address of jr ra} //Else if we are pressing off button
Nop
//Make code turn off
Lui t4 $XXXX //Upper off value
Addiu t4 t4 $XXXX //Lower off value
Sw t4 $XXXX(t1) //Lower address
Jr ra
Nop
Bookmarks