This routine is something that Ive came up wit when, I wanted to call on my different stack routines w/o making one joker routine that only calls on one routine!
If you understand the 1st Joker tut that Ive posted then you will pretty much understand this one...
We are going to be using some new registers that you may not have used or seen before!
- a0
- s4
- s5
- s6
- s7
Those are the registers that we're going to be using in our stack multi joker routine!
- addiu sp, sp, -20 <--- // This sets aside 20 bit that way we can save to the stack
- sw a0, $0000(sp) <--- // Saved a0 to the stack at offset 0000
- sw s4, $0004(sp) <--- // Saved s4 to the stack at offset 0004
- sw s5, $0008(sp) <--- // Saved s5 to the stack at offset 0008
- sw s6, $000C(sp) <--- // Saved s6 to the stack at offset 000C
- sw s7, $0010(sp) <--- // Saved s7 to the stack at offset 0010
- sw ra, $0014(sp) <--- // #1 rule, You always got to save ra before a jal if not you will freeze
- lui a0, $09A8 <--- // Load our 1st four controller address
- lh a0, $E1E4(a0) <--- // Load our last four controller address back to a0
- addiu s4, zero, $8000 <--- // Load our button value which is []
- addiu s5, zero, $4000 <--- // Load our button value which is X
- addiu s6, zero, $2000 <--- // Load our button value which is O
- addiu s7, zero, $1000 <--- // Load our button value which is /\
- and a0, a0, s4 <--- // When we got [] press held in we can stil press other buttons and your joker will work
- and a0, a0, s5 <--- // When we got X press held in we can stil press other buttons and your joker will work
- and a0, a0, s6 <--- // When we got O press held in we can stil press other buttons and your joker will work
- and a0, a0, s7 <--- // When we got /\ press held in we can stil press other buttons and your joker will work
- bne s4, a0, $00001 <-- // We branch if [] isnt pressed in
- nop
- jal <--- // Whatever routine you have will be call on by []
- bne s5, a0, $00001 <-- // We branch if X isnt pressed in
- nop
- jal <--- // Whatever Routine you have will be call on by X
- bne s6, a0, $00001 <-- // We branch if O isnt pressed in
- nop
- jal <--- // Whatever Routine you have will be call on by O
- bne s7, a0, $00002 <-- // We branch if /\ isnt pressed in
- nop
- jal <--- // Whatever Routine you have will be call on by /\
- lw a0, $0000(sp) <--- // Restore a0 back to how it was before we used it
- lw s4, $0004(sp) <--- // Restore s4 back to how it was before we used it
- lw s5, $0008(sp) <--- // Restore s5 back to how it was before we used it
- lw s6, $000C(sp) <--- // Restore s6 back to how it was before we used it
- lw s7, $0010(sp) <--- // Restore s7 back to how it was before we used it
- lw ra, $0014(sp) <--- // We do this to load back to normal if not you will cause a inf loop causing a crash
- jr ra <--- // This returns back to the routine
- addiu sp, sp, 20 <--- // Adds 20 bits back to the stack when you jr ra their is a one line delay that picks this up
The last thing you need of course is a hook!
NOTE: This joker routine will only work if your going to write out four different routines and calling on them by different buttons!
- // The JAL'S Acts as the hooks for your routine!