fork/training-mode-ce
git clone https://git.julia.blue/fork/training-mode-ce
c8403fb
techchase-camera
1# To be inserted at 802608D8 2.include "../../Globals.s" 3 4# CREDIT: Dan Salvato 5# https://smashboards.com/threads/d-pad-up-down-on-css-to-toggle-rumble-with-cursor-shake-effect.417382/ 6# https://web.archive.org/web/20151121044233/https://www.20xx.me/blog/toggling-rumble-the-te-way 7 8# If shake bit is on, skip d-pad checks (we're still shaking) 9lbz r3 , 7 ( r31 ) 10cmpwi r3 , 0x0 11bne - Shake 12lbz r4 , 4 ( r31 ) 13# Check if d-pad up or down is pressed 14mr r23 , r4 15lwz r0 , MemcardData ( r13 ) 16add r3 , r0 , r4 17lbz r5 , 7360 ( r3 ) 18rlwinm. r0 , r28 , 0 , 28 , 28 19bne - RumbleOn 20rlwinm. r0 , r28 , 0 , 29 , 29 21bne - RumbleOff 22b Exit 23 24RumbleOn : 25cmplwi r5 , 1 26beq - Exit 27mr r3 , r23 28li r4 , 0x0 29li r5 , 0xE 30li r6 , 0x0 31subi r7 , r13 , 0x66B0 32branchl r12 , 0x80378430 33# set r4 to 1 indicating we want to enable rumble 34li r4 , 1 35b ToggleRumble 36 37RumbleOff : 38cmplwi r5 , 0 39beq - Exit 40# set r4 to 0 indicating we want to disable rumble 41li r4 , 0 42 43ToggleRumble : 44mr r3 , r23 45branchl r12 , Rumble_StoreRumbleFlag 46li r4 , 0x1 47stb r4 , 7 ( r31 ) 48lis r4 , 0xC040 49stw r4 , 20 ( r31 ) 50 51Shake : 52# Get x position, amplitude, and decay 53lfs f1 , 0x14 ( r31 ) 54lfs f2 , -0x71F4 ( r2 ) 55lfs f0 , 0xC ( r31 ) 56fadds f0 , f1 , f0 57stfs f0 , 12 ( r31 ) 58# Flip amplitude 59fneg f3 , f1 60fcmpo cr0 , f3 , f1 61bgt - SkipDecay 62# If amplitude went from positive to negative, then multiply by decay 63fmuls f3 , f3 , f2 64 65SkipDecay : 66# Store new amplitude value 67stfs f3 , 0x14 ( r31 ) 68blt - Exit 69 70# Check if amplitude is less than .001 (approx) 71lfs f4 , -0x7DA8 ( r2 ) 72fcmpo cr0 , f3 , f4 73bgt - Exit 74 75# If so, turn off the shake bit and set amplitude to 0 76li r4 , 0x0 77stw r4 , 0x14 ( r31 ) 78stb r4 , 7 ( r31 ) 79 80Exit : 81lbz r4 , 4 ( r31 ) # Replaced code line