Skip to content

Commit

Permalink
add success / failure game end on LGL
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Jul 5, 2024
1 parent 2ff76fb commit ccb5923
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Online/Core/CustomizeMessageLRAS.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ PLAY_SOUND:
branchl r12, SFX_Menu_CommonSound
SKIP_PLAY_SOUND:

# 0: Time, 1: Sudden Death, 2: Success, 3: Ready, 4: GO!, 5: Game!, 6: Failure, 7: Complete, 8: Nothing, 9: Crash
# branch r12, 0x802f70c0 # Time
# branch r12, 0x802f70e8 # Complete
# branch r12, 0x802f70fc # Failure
# branch r12, 0x802f7110 # Game!
branch r12, 0x802f7120 # Exit function, shows nothing and plays no sound
Expand Down
140 changes: 140 additions & 0 deletions Online/Core/LGLExceededGameEnd.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
################################################################################
# Address: 0x802f70c4 # HUD_DisplayEndingExclaimationGraphic
################################################################################

.include "Common/Common.s"
.include "Online/Online.s"

.set REG_P1_LEDGE_GRABS, 28
.set REG_P2_LEDGE_GRABS, 27
.set REG_LGL_LOSER, 26
.set REG_DISPLAY_MESSAGE_ID, 25
.set REG_DO, 24
.set REG_LGL_LOSER_GRAB_COUNT, 23
.set REG_FILL_COLOR, 22
.set REG_FIRST_STRING, 21

# This function's main goal is to overwrite the message displayed on an LGL timeout. Here are the options:
# 0: Time, 1: Sudden Death, 2: Success, 3: Ready, 4: GO!, 5: Game!, 6: Failure, 7: Complete, 8: Nothing, 9: Crash

b CODE_START

DATA_BLRL:
blrl
.set DO_SCALE, 0
.float 0.7
.set DO_POS_X, DO_SCALE + 4
.float 0
.set DO_POS_Y, DO_POS_X + 4
.float 70
.set DO_STROKE_OFFSET, DO_POS_Y + 4
.float 1
.set DO_COLOR_OUTLINE, DO_STROKE_OFFSET + 4
.byte 0,0,0,255
.set DO_COLOR_FILL_LOSS, DO_COLOR_OUTLINE + 4
.byte 215,165,255,255
.set DO_COLOR_FILL_WIN, DO_COLOR_FILL_LOSS + 4
.byte 250,250,120,255
.set DO_STRING_YOU, DO_COLOR_FILL_WIN + 4
.string "You"
.set DO_STRING_OPP, DO_STRING_YOU + 4
.string "Opp"
.set DO_STRING, DO_STRING_OPP + 4
.string "%s Exceeded Ledge Grab Limit of %d: %d"
.align 2


CODE_START:
backup

# Store values of r4-r6 so we can restore on exit. They are args to the function that will be called.
# The other args, r3, r7, and r8 are about to be set so we don't need to worry about those
mr r31, r4
mr r30, r5
mr r29, r6
li REG_DISPLAY_MESSAGE_ID, 0

# Grab data address
bl DATA_BLRL
mflr REG_DO

# Ensure that this is an online match
getMinorMajor r3
cmpwi r3, SCENE_ONLINE_IN_GAME
bne EXIT

# Don't run this code for teams
lbz r3, OFST_R13_ONLINE_MODE(r13)
cmpwi r3, ONLINE_MODE_TEAMS
beq EXIT

# Check to see if this is an LGL victory

# Fetch ledge grab amounts
li r3, 0
branchl r12, 0x80040af0 # PlayerBlock_GetCliffhangerStat
mr REG_P1_LEDGE_GRABS, r3
li r3, 1
branchl r12, 0x80040af0 # PlayerBlock_GetCliffhangerStat
mr REG_P2_LEDGE_GRABS, r3

# First handle condition where both players are over LGL
cmpwi REG_P1_LEDGE_GRABS, LGL_LIMIT
ble CHECK_LGL_LOSS
cmpwi REG_P2_LEDGE_GRABS, LGL_LIMIT
bgt EXIT # If we branch here both players have more than 45 so ignore LGL

CHECK_LGL_LOSS:
cmpwi REG_P1_LEDGE_GRABS, LGL_LIMIT
li REG_LGL_LOSER, 0
mr REG_LGL_LOSER_GRAB_COUNT, REG_P1_LEDGE_GRABS
bgt SET_MODIFIED_MESSAGE # If P1 has more than 45 ledge grabs, P2 wins
cmpwi REG_P2_LEDGE_GRABS, LGL_LIMIT
li REG_LGL_LOSER, 1
mr REG_LGL_LOSER_GRAB_COUNT, REG_P2_LEDGE_GRABS
bgt SET_MODIFIED_MESSAGE # If P2 has more than 45 ledge grabs, P1 wins
b EXIT # If neither player has more than 45 ledge grabs, exit

SET_MODIFIED_MESSAGE:
# Check if we won or lost via LGL
lwz r3, OFST_R13_ODB_ADDR(r13) # data buffer address
lbz r3, ODB_LOCAL_PLAYER_INDEX(r3)
cmpw r3, REG_LGL_LOSER # Compare local player index of winner
li REG_DISPLAY_MESSAGE_ID, 2 # Set message to "Success" if we won
addi REG_FILL_COLOR, REG_DO, DO_COLOR_FILL_WIN
addi REG_FIRST_STRING, REG_DO, DO_STRING_OPP
bne DISPLAY_LGL_MESSAGE
li REG_DISPLAY_MESSAGE_ID, 6 # Set message to "Failure" if we lost
addi REG_FILL_COLOR, REG_DO, DO_COLOR_FILL_LOSS
addi REG_FIRST_STRING, REG_DO, DO_STRING_YOU

# Make game exit transition longer
load r3, 0x8046b6a0 # Some static match state struct
li r4, 0xFD # Default value for this is 0x6e
stb r4, 0x24D5(r3) # Overwrite the GAME! think max time to make it longer

DISPLAY_LGL_MESSAGE:

lwz r3, OFST_R13_ODB_ADDR(r13) # data buffer address
lwz r3, ODB_HUD_TEXT_STRUCT(r3)
mr r4, REG_FILL_COLOR
li r5, 1
addi r6, REG_DO, DO_COLOR_OUTLINE # Outline Color
addi r7, REG_DO, DO_STRING # String
mr r8, REG_FIRST_STRING
li r9, LGL_LIMIT # LGL Limit
mr r10, REG_LGL_LOSER_GRAB_COUNT # Grab Count
lfs f1, DO_SCALE(REG_DO)
lfs f2, DO_POS_X(REG_DO)
lfs f3, DO_POS_Y(REG_DO)
lfs f6, DO_STROKE_OFFSET(REG_DO)
branchl r12, FG_CreateSubtext

EXIT:
# Restore r4-r6
mr r4, r31
mr r5, r30
mr r6, r29
mr r3, REG_DISPLAY_MESSAGE_ID # Use the message ID we set earlier. 0 if no LGL which is replaced codeline
restore
addi r7, r31, 0 # Line 802f70c0 may have been clobbered, set it again
11 changes: 5 additions & 6 deletions Online/Static/SubtextFunctions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
# r6 = outline color pointer
# r7... = string pointers

# f1 = scale size x
# f2 = scale size y
# f3 = x pos
# f4 = y pos
# f5 = inner text y-scale
# f1 = scale size
# f2 = x pos
# f3 = y pos
# f5 = inner text y-scale (unused?)
# f6 = outline offset/size
################################################################################
# Output:
Expand All @@ -42,7 +41,7 @@
.set REG_X, REG_SCALE-1
.set REG_Y, REG_X-1
.set REG_Z, REG_Y-1
.set REG_OUTLINE_SIZE, REG_Z-1
.set REG_OUTLINE_SIZE, REG_Z-1 # looks unused?
.set REG_OUTLINE_OFFSET, REG_OUTLINE_SIZE-1 # outlines offsets to create size

.set REG_LOOP_INDEX, 15
Expand Down
7 changes: 7 additions & 0 deletions Output/InjectionLists/list_netplay.json
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,13 @@
"Annotation": "Online/Core/InitPause.asm",
"Tags": ""
},
{
"InjectionAddress": "802F70C4",
"Name": "Required: Slippi Online",
"Codetype": "Auto",
"Annotation": "Online/Core/LGLExceededGameEnd.asm",
"Tags": ""
},
{
"InjectionAddress": "801A5014",
"Name": "Required: Slippi Online",
Expand Down
54 changes: 54 additions & 0 deletions Output/Netplay/GALE01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,60 @@ C216E904 0000004C #Online/Core/InitPause.asm
800100E4 382100E0
7C0803A6 4E800020
881F0001 00000000
C22F70C4 00000035 #Online/Core/LGLExceededGameEnd.asm
48000054 4E800021
3F333333 00000000
428C0000 3F800000
000000FF D7A5FFFF
FAFA78FF 596F7500
4F707000 25732045
78636565 64656420
4C656467 65204772
6162204C 696D6974
206F6620 25643A20
25640000 7C0802A6
90010004 9421FF20
BE8100B0 7C9F2378
7CBE2B78 7CDD3378
3B200000 4BFFFF91
7F0802A6 3C608048
80639D30 5463443E
2C030208 408200F0
886DAFA0 2C030003
418200E4 38600000
3D808004 618C0AF0
7D8903A6 4E800421
7C7C1B78 38600001
3D808004 618C0AF0
7D8903A6 4E800421
7C7B1B78 2C1C002D
4081000C 2C1B002D
418100A4 2C1C002D
3B400000 7F97E378
41810018 2C1B002D
3B400001 7F77DB78
41810008 48000080
806DB61C 88630000
7C03D000 3B200002
3AD80018 3AB80020
40820020 3B200006
3AD80014 3AB8001C
3C608046 6063B6A0
388000FD 988324D5
806DB61C 80630912
7EC4B378 38A00001
38D80010 38F80024
7EA8AB78 3920002D
7EEABB78 C0380000
C0580004 C0780008
C0D8000C 3D808000
618C56B4 7D8903A6
4E800421 7FE4FB78
7FC5F378 7FA6EB78
7F23CB78 BA8100B0
800100E4 382100E0
7C0803A6 38FF0000
60000000 00000000
C21A5014 0000005C #Online/Core/LoopEngineForRollback.asm
41A20014 3D80801A
618C5024 7D8903A6
Expand Down
54 changes: 54 additions & 0 deletions Output/Netplay/GALJ01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,60 @@ C216E904 0000004C #Online/Core/InitPause.asm
800100E4 382100E0
7C0803A6 4E800020
881F0001 00000000
C22F70C4 00000035 #Online/Core/LGLExceededGameEnd.asm
48000054 4E800021
3F333333 00000000
428C0000 3F800000
000000FF D7A5FFFF
FAFA78FF 596F7500
4F707000 25732045
78636565 64656420
4C656467 65204772
6162204C 696D6974
206F6620 25643A20
25640000 7C0802A6
90010004 9421FF20
BE8100B0 7C9F2378
7CBE2B78 7CDD3378
3B200000 4BFFFF91
7F0802A6 3C608048
80639D30 5463443E
2C030208 408200F0
886DAFA0 2C030003
418200E4 38600000
3D808004 618C0AF0
7D8903A6 4E800421
7C7C1B78 38600001
3D808004 618C0AF0
7D8903A6 4E800421
7C7B1B78 2C1C002D
4081000C 2C1B002D
418100A4 2C1C002D
3B400000 7F97E378
41810018 2C1B002D
3B400001 7F77DB78
41810008 48000080
806DB61C 88630000
7C03D000 3B200002
3AD80018 3AB80020
40820020 3B200006
3AD80014 3AB8001C
3C608046 6063B6A0
388000FD 988324D5
806DB61C 80630912
7EC4B378 38A00001
38D80010 38F80024
7EA8AB78 3920002D
7EEABB78 C0380000
C0580004 C0780008
C0D8000C 3D808000
618C56B4 7D8903A6
4E800421 7FE4FB78
7FC5F378 7FA6EB78
7F23CB78 BA8100B0
800100E4 382100E0
7C0803A6 38FF0000
60000000 00000000
C21A5014 0000005C #Online/Core/LoopEngineForRollback.asm
41A20014 3D80801A
618C5024 7D8903A6
Expand Down

0 comments on commit ccb5923

Please sign in to comment.