fork/training-mode-ce

git clone https://git.julia.blue/fork/training-mode-ce

AitchMerge pull request #239 from NickCondron/nametagc8403fb

nix
1.8 KiB81 linesraw
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)
9    lbz r3, 7(r31)
10    cmpwi r3, 0x0
11    bne- Shake
12    lbz r4, 4(r31)
13    # Check if d-pad up or down is pressed
14    mr r23, r4
15    lwz r0, MemcardData(r13)
16    add r3, r0, r4
17    lbz r5, 7360(r3)
18    rlwinm. r0, r28, 0, 28, 28
19    bne- RumbleOn
20    rlwinm. r0, r28, 0, 29, 29
21    bne- RumbleOff
22    b Exit
23
24RumbleOn:
25    cmplwi r5, 1
26    beq- Exit
27    mr r3, r23
28    li r4, 0x0
29    li r5, 0xE
30    li r6, 0x0
31    subi r7, r13, 0x66B0
32    branchl r12, 0x80378430
33    # set r4 to 1 indicating we want to enable rumble
34    li r4, 1
35    b ToggleRumble
36
37RumbleOff:
38    cmplwi r5, 0
39    beq- Exit
40    # set r4 to 0 indicating we want to disable rumble
41    li r4, 0
42
43ToggleRumble:
44    mr r3, r23
45    branchl r12, Rumble_StoreRumbleFlag
46    li r4, 0x1
47    stb r4, 7(r31)
48    lis r4, 0xC040
49    stw r4, 20(r31)
50
51Shake:
52    # Get x position, amplitude, and decay
53    lfs f1, 0x14(r31)
54    lfs f2, -0x71F4(r2)
55    lfs f0, 0xC(r31)
56    fadds f0, f1, f0
57    stfs f0, 12(r31)
58    # Flip amplitude
59    fneg f3, f1
60    fcmpo cr0, f3, f1
61    bgt- SkipDecay
62    # If amplitude went from positive to negative, then multiply by decay
63    fmuls f3, f3, f2
64
65SkipDecay:
66    # Store new amplitude value
67    stfs f3, 0x14(r31)
68    blt- Exit
69
70    # Check if amplitude is less than .001 (approx)
71    lfs f4, -0x7DA8(r2)
72    fcmpo cr0, f3, f4
73    bgt- Exit
74
75    # If so, turn off the shake bit and set amplitude to 0
76    li r4, 0x0
77    stw r4, 0x14(r31)
78    stb r4, 7(r31)
79
80Exit:
81    lbz r4, 4(r31) # Replaced code line