### Mario gets a Divine Hand: creating a new collision routine (Gameshark code)

 Code on the bottom of the page.This is an ASM hack which replaces the 0x0A (death at the bottom routine) with a custom function.Here is it in Pseudo-c so you can understand better the ASM. First it calculates the distance between Mario and the ground.If Mario is near enough, it will set the variable going_up = 1, so Mario will start floating.Whenever he steps out of the collision triangle 0x0A, the going_up variable is set to 0.void MarioGoesUp{mario.y = mario.y + 85;             /* gravity = about 75 */}int MarioGetsaDivineHand{  if ( ! (going_up) )   {                if (mario.y < ground.y + 2048)    {                              going_up = 1;               MarioGoesUp();               }         }        else  {        MarioGoesUp();        }} void ResetsGoingUp           /*  Called from the collision processing routine */{  if ( ! (collision == 0x0A) )     {      going_up = 0;     }}In MIPS ASM:.ORG 802505D8802505D8: LUI AT, 0x803F802505DC: LW T1, 0x7FFC (AT)802505E0: BNE T1, R0, 0x80250618 # if ( (going_up) )802505E4: NOP# check if Mario is near the Ground:802505E8: LUI AT, 0x4500 802505EC: MTC1 AT, F8802505F0: LWC1 F6, 0x0070 (T6)802505F4: LWC1 F4, 0x0040 (T6)802505F8: ADD.S F10, F6, F8802505FC: C.LT.S F4, F1080250600: NOP80250604: BC1F 0x8025063480250608: NOP# sets going_up = 1;8025060C: LUI AT, 0x803F80250610: ADDIU T1, R0, 0x000180250614: SB T1, 0x7FFF (AT)# MarioGoesUp80250618: LUI AT, 0x42AA8025061C: MTC1 AT, F680250620: LWC1 F4, 0x0040 (T6)80250624: ADD.S F4, F4, F680250628: SWC1 F4, 0x0040 (T6)8025062C: BEQ R0, R0, 0x8025063480250630: NOP#End80250634: LW RA, 0x0014 (SP)80250638: ADDIU SP, SP, 0x00188025063C: JR RA80250640: NOP# Resets going_up byte (called from collision processor)80250644:  LUI AT, 0x803F80250648: SW R0, 0x7FFC (AT)8025064C: LUI AT, 0x8025  # Not a good option. Better was a simple "J 0x8025085C"80250650: ORI AT, AT, 0x085C80250654: JR AT80250658: NOP# Patches collision processing rountine.ORG 80250850ADDIU AT, R0, 0x000ABNE S0, AT, 0x80250644 # if (collision != 0x0A)  NOPADDIU AT, R0, 0x000ABEQ S0, AT, 0x80250894 # if (collision = 0x0A)NOP ADDIU AT, R0, 0x0032BEQ S0, AT, 0x802508A4 # if (collision = 0x32)NOPADDIU AT, R0, 0x0033BEQ S0, AT, 0x802508B8 # if (collision = 0x33)NOPADDIU AT, R0, 0x0034BEQ S0, AT, 0x802508C8 # if (collision = 0x34)NOP# Gameshark code (part 1)812505D8 3C01812505DA 803F812505DC 8C29812505DE 7FFC812505E0 1409812505E2 000D812505E4 2400812505E6 0000812505E8 3C01812505EA 4500812505EC 4481812505EE 4000812505F0 C5C6812505F2 0070812505F4 C5C4812505F6 0040812505F8 4608812505FA 3280812505FC 460A812505FE 203C81250600 240081250602 000081250604 450081250606 000B81250608 24008125060A 00008125060C 3C018125060E 803F81250610 240981250612 000181250614 A02981250616 7FFF81250618 3C018125061A 42AA8125061C 44818125061E 300081250620 C5C481250622 004081250624 460681250626 210081250628 E5C48125062A 00408125062C 10008125062E 000181250630 240081250632 000081250634 8FBF81250636 001481250638 27BD8125063A 0018# Gameshark code (part2)8125063C 03E08125063E 000881250640 240081250642 000081250644 3C0181250646 803F81250648 AC208125064A 7FFC8125064C 3C1F8125064E 802581250650 37FF81250652 085C81250654 03E081250656 000881250658 24008125065A 000081250850 240181250852 000A81250854 143081250856 FF7B81250858 24008125085A 00008125085C 24018125085E 000A81250860 103081250862 000C81250864 240081250866 000081250868 24018125086A 00328125086C 10308125086E 000D81250870 240081250872 000081250874 240181250876 003381250878 10308125087A 000F8125087C 24008125087E 000081250880 240181250882 003481250884 103081250886 001081250888 24008125088A 0000