fork/training-mode-ce

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

AitchMerge pull request #242 from NickCondron/remove-asm96edbd1

nix
3.3 KiB130 linesraw
1    # To be inserted at 8000550c
2    .include "../../../Globals.s"
3    .include "../../../m-ex/Header.s"
4
5    .set playerdata, 31
6    .set player, 30
7
8    backup
9
10    # This static function requires before being called:
11    # - store Interrupt Bool to r3
12    # - store player to r4
13    # - store the address of a text data for OSD to r6
14    # - store the OSD kind ID to r10
15    mr player, r4
16    lwz playerdata, 0x2c(player)
17
18    # Check For Interrupt
19    cmpwi r3, 0x0
20    beq Exit
21
22    # CHECK IF ENABLED
23    li r0, OSD.ActOoAirborne
24    lwz r4, MemcardData(r13)
25    lwz r4, 0x1F24(r4)
26    li r3, 1
27    slw r0, r3, r0
28    and. r0, r0, r4
29    beq Exit
30
31CheckForFollower:
32    mr r3, playerdata
33    branchl r12, 0x80005510
34    cmpwi r3, 0x1
35    beq Exit
36
37
38CheckForPreviousActionState:
39    lhz r3, TM_OneASAgo(playerdata)
40    lhz r7, TM_FramesinOneASAgo(playerdata)
41    cmpwi r3, ASID_Pass
42    beq CheckForPreviousFrame
43    cmpwi r3, ASID_Fall
44    beq CheckForNecessarySituationForOoFall
45    cmpwi r3, ASID_JumpF
46    beq PreviousStateIsJump
47    cmpwi r3, ASID_JumpB
48    beq PreviousStateIsJump
49    cmpwi r3, ASID_JumpAerialF
50    beq PreviousStateIsDoubleJump
51    cmpwi r3, ASID_JumpAerialB
52    beq PreviousStateIsDoubleJump
53    # Aerial jump state IDs are 0x155, 0x156, 0x157, 0x158, 0x159 for fighters which have multiple jumps (Jigglypuff, Kirby)
54    lwz r4, 0x168(playerdata) # load max_jumps
55    cmpwi r4, 0x2
56    ble Exit
57    cmpwi r3, 0x155 # first aerial jump
58    blt Exit
59    cmpwi r3, 0x159 # last(5th) aerial jump
60    bgt Exit
61    b PreviousStateIsDoubleJump
62
63
64PreviousStateIsJump:
65    lfs f1, 0x150(playerdata)  # get jump_v_initial_velocity
66    b CheckForCutoffFramesForOoJump
67
68PreviousStateIsDoubleJump:
69    lfs f1, 0x150(playerdata)  # get jump_v_initial_velocity
70    lfs f2, 0x160(playerdata)  # get air_jump_v_multiplier
71    fmuls f1, f1, f2           # calculate double jump vertical initial velocity
72
73CheckForCutoffFramesForOoJump:
74    # Disable OSD if the act is after frames to reach the peak of fighter's jump (+ some additional frames)
75    lfs f2, 0x16C(playerdata)  # get gravity
76    fdivs f1, f1, f2           # calculate frames to reach the peak of fighter's jump
77    fctiwz f1, f1              # round down
78    stfd f1, 0x80(sp)
79    lwz r4, 0x84(sp)           # load the integer part
80    addi r4, r4, 0x5           # add some frames
81    cmpw r7, r4
82    bgt Exit
83    b CheckForPreviousFrame
84
85
86CheckForNecessarySituationForOoFall:
87    cmpwi r7, 10  # Cutoff by frames
88    bgt Exit
89    # Cutoff by action states before fall which don't need OSD
90    lhz r3, TM_TwoASAgo(playerdata)
91    cmpwi r3, ASID_JumpF
92    beq Exit
93    cmpwi r3, ASID_JumpB
94    beq Exit
95    cmpwi r3, ASID_AttackAirN
96    beq Exit
97    cmpwi r3, ASID_AttackAirF
98    beq Exit
99    cmpwi r3, ASID_AttackAirB
100    beq Exit
101    cmpwi r3, ASID_AttackAirHi
102    beq Exit
103    cmpwi r3, ASID_AttackAirLw
104    beq Exit
105    cmpwi r3, ASID_BarrelCannonWait  # for ignoring special moves mainly
106    bgt Exit
107    b CheckForPreviousFrame
108
109
110CheckForPreviousFrame:
111    cmpwi r7, 0x1
112    bne RedText
113
114GreenText:
115    load r5, MSGCOLOR_GREEN
116    b DisplayText
117
118RedText:
119    load r5, MSGCOLOR_RED
120
121DisplayText:
122    mr r3, r10                  # message kind
123    lbz r4, 0xC(playerdata)     # message queue
124    Message_Display
125    b Exit
126
127
128Exit:
129    restore
130    blr