Lesson 1 the simplest type of ssubroutine and mips I know.

Makeing a one code subroutine.

Code example I will be useing:

#Infinite Stamina
;FoodFx
;Alternate
0x0015C76C 0xC48C1C0C

I will need a hook to get the subrountine working so here is a working hook
for mohh1 0x00339D78

Now I need to find a NOP area in the game im makeing the subroutine/joker for
here is a nop area in mohh1 0x00000610

so i make the commands to load the code.

here is how it will look

lui t0 $0896 // This is loading first half of code address. lui is used to load the first 16 its of a adderess/value. Note you have to add 0880. so 0895 is loaded in t0. Theres a negative rule in codeing so if its negative you have to add 1
lui t1 $C48C //This is loading the first half of the value in t1. does not need to add 0880
ori t1 t1 $1c0c //The MIP ori is loading the seconed half of code value in t1 and storeing it to t1 above. does not have to add 0880
sw t1 $c76c(t0) // stores the t1 which we loaded as the value and then storeing it back to t0
jr ra //ends our subroutine

so after your done with MIPS copy and paste in notepad

will look like this

08800610 3c080896
08800614 3c09c48c
08800618 35291c0c
0880061c ad09c76c
08800620 03e00008

now you subtract 08800000 from the addresses and add 0x to the address and value to put in NitePR format


0x00000610 0x3c080896
0x00000614 0x3c09c48c
0x00000618 0x35291c0c
0x0000061c 0xad09c76c
0x00000620 0x03e00008

Now we make a jump command to start our subroutine which would be j $08800610
because our subroutine will start at the address 08800610.
We copy the value and add it to the hook like this

0x00339D78 0x0A200184 <---Our hook with the J value
0x00000610 0x3c080896
0x00000614 0x3c09c48c
0x00000618 0x35291c0c
0x0000061c 0xad09c76c
0x00000620 0x03e00008

Now we add the code name and comments and we are done

#Infinite Stamina
;FoodFx
;Subroutine
0x00339D78 0x0A200184
0x00000610 0x3c080896
0x00000614 0x3c09c48c
0x00000618 0x35291c0c
0x0000061c 0xad09c76c
0x00000620 0x03e00008

NOTE: you will need ps2dis and a dump for your game..