diff --git a/Online/Core/EXIFileLoad/AllocBuffer.asm b/Common/AllocBuffer.asm similarity index 100% rename from Online/Core/EXIFileLoad/AllocBuffer.asm rename to Common/AllocBuffer.asm diff --git a/Common/Common.s b/Common/Common.s index 6ee37439..e679ea0f 100644 --- a/Common/Common.s +++ b/Common/Common.s @@ -549,6 +549,9 @@ add \reg, r3, r4 # Misc .set CONST_SlippiCmdGetDelay, 0xD5 +.set CONST_SlippiPlayMusic, 0xD6 +.set CONST_SlippiStopMusic, 0xD7 +.set CONST_SlippiChangeMusicVolume, 0xD8 # For Slippi Premade Texts .set CONST_SlippiCmdGetPremadeTextLength, 0xE1 @@ -606,6 +609,7 @@ add \reg, r3, r4 .set frameIndex,-0x49ac .set textStructDescriptorBuffer,-0x3D24 .set isWidescreen,-0x5020 +.set OFST_R13_SB_ADDR,-0x503C # Scene buffer, persists throughout scenes ################################################################################ # Log levels diff --git a/Online/Core/Music/StartSong.asm b/Online/Core/Music/StartSong.asm new file mode 100644 index 00000000..268cc658 --- /dev/null +++ b/Online/Core/Music/StartSong.asm @@ -0,0 +1,79 @@ +################################################################################ +# Address: 0x8038e910 # fileLoad_HPS, after entry num is fetched +################################################################################ + +.include "Common/Common.s" + +.set REG_PMQ, 31 +.set REG_ENTRYNUM, 30 +.set REG_INTERRUPT_IDX, 29 + +# This will contain the DVDFileInfo struct which has length 0x40 +.set SPO_STRUCT_START, BKP_FREE_SPACE_OFFSET +.set SPO_FILE_OFFSET, SPO_STRUCT_START + 0x30 +.set SPO_FILE_SIZE, SPO_FILE_OFFSET + 4 + +# This space will be used to transfer over EXI. EXI buffers must be 32 byte aligned though +# so we don't know exactly where the buffer will start +.set SPO_EXI_SPACE_START, SPO_STRUCT_START + 0x40 + +# PlayMusicQuery args +.set PMQ_COMMAND, 0 +.set PMQ_FILE_OFFSET, PMQ_COMMAND + 1 +.set PMQ_FILE_SIZE, PMQ_FILE_OFFSET + 4 +.set PMQ_SIZE, PMQ_FILE_SIZE + 4 # Confusing but this is the size of the buffer + +# Grab enough space that no matter where we are, we can byteAlign32 and still fit the PMQ data +.set SPACE_NEEDED, SPO_EXI_SPACE_START + PMQ_SIZE + 32 + +backup SPACE_NEEDED + +mr REG_ENTRYNUM, r3 + +branchl r12, OSDisableInterrupts +mr REG_INTERRUPT_IDX, r3 + +mr r3, REG_ENTRYNUM +addi r4, sp, SPO_STRUCT_START +branchl r12, 0x80337c60 # DVDFastOpen + +# TODO: File_GetLength asserts when result = 0, hopefully just ignoring it and doing nothing is fine +cmpwi r3, 0 +beq CLEANUP_AND_EXIT + +# Log +# lwz r5, SPO_FILE_OFFSET(sp) +# lwz r6, SPO_FILE_SIZE(sp) +# logf LOG_LEVEL_WARN, "[Music] Starting song at 0x%x with size %d" + +addi REG_PMQ, sp, SPO_EXI_SPACE_START +byteAlign32 REG_PMQ + +# Write command +li r3, CONST_SlippiPlayMusic +stb r3, PMQ_COMMAND(REG_PMQ) + +# Write file offset and size +lwz r3, SPO_FILE_OFFSET(sp) +stw r3, PMQ_FILE_OFFSET(REG_PMQ) +lwz r3, SPO_FILE_SIZE(sp) +stw r3, PMQ_FILE_SIZE(REG_PMQ) + +# Exec EXI transfer +mr r3, REG_PMQ +li r4, PMQ_SIZE +li r5, CONST_ExiWrite +branchl r12, FN_EXITransferBuffer + +CLEANUP_AND_EXIT: +addi r3, sp, SPO_STRUCT_START +branchl r12, 0x80337cd4 # DVDClose + +mr r3, REG_INTERRUPT_IDX +branchl r12, OSRestoreInterrupts + +mr r3, REG_ENTRYNUM + +restore SPACE_NEEDED + +lwz r0, -0x5668(r13) # replaced code line \ No newline at end of file diff --git a/Online/Core/Music/Stop.asm b/Online/Core/Music/Stop.asm new file mode 100644 index 00000000..fa226879 --- /dev/null +++ b/Online/Core/Music/Stop.asm @@ -0,0 +1,40 @@ +################################################################################ +# Address: 0x800236ec # Music_StopMusic, after function call +################################################################################ + +.include "Common/Common.s" + +.set REG_SMQ, 31 + +# This space will be used to transfer over EXI. EXI buffers must be 32 byte aligned though +# so we don't know exactly where the buffer will start +.set SPO_EXI_SPACE_START, BKP_FREE_SPACE_OFFSET + +# PlayMusicQuery args +.set SMQ_COMMAND, 0 +.set SMQ_SIZE, SMQ_COMMAND + 1 + +# Grab enough space that no matter where we are, we can byteAlign32 and still fit the SMQ data +.set SPACE_NEEDED, SPO_EXI_SPACE_START + SMQ_SIZE + 32 + +backup SPACE_NEEDED + +# logf LOG_LEVEL_WARN, "[Music] Stopping music" + +addi REG_SMQ, sp, SPO_EXI_SPACE_START +byteAlign32 REG_SMQ + +# Write command +li r3, CONST_SlippiStopMusic +stb r3, SMQ_COMMAND(REG_SMQ) + +# Exec EXI transfer +mr r3, REG_SMQ +li r4, SMQ_SIZE +li r5, CONST_ExiWrite +branchl r12, FN_EXITransferBuffer + +CLEANUP_AND_EXIT: +restore SPACE_NEEDED + +li r0, 0 # replaced code line \ No newline at end of file diff --git a/Online/Core/Music/VolumeChange.asm b/Online/Core/Music/VolumeChange.asm new file mode 100644 index 00000000..2726b0f0 --- /dev/null +++ b/Online/Core/Music/VolumeChange.asm @@ -0,0 +1,66 @@ +################################################################################ +# Address: 0x800249f0 # DSP_Process, where volume is written +################################################################################ + +.include "Common/Common.s" + +.set REG_CMVQ, 31 +.set REG_DATA, 30 + +# This space will be used to transfer over EXI. EXI buffers must be 32 byte aligned though +# so we don't know exactly where the buffer will start +.set SPO_EXI_SPACE_START, BKP_FREE_SPACE_OFFSET + +# PlayMusicQuery args +.set CMVQ_COMMAND, 0 +.set CMVQ_VOLUME, CMVQ_COMMAND + 1 +.set CMVQ_SIZE, CMVQ_VOLUME + 1 + +# Grab enough space that no matter where we are, we can byteAlign32 and still fit the CMVQ data +.set SPACE_NEEDED, SPO_EXI_SPACE_START + CMVQ_SIZE + 32 + +b CODE_START + +DATA_BLRL: +blrl +.set DO_PREV_VOLUME, 0 +.long 0x00000000 + +CODE_START: +stw r0, -0x7E18(r13) # replaced code line + +backup SPACE_NEEDED + +bl DATA_BLRL +mflr REG_DATA + +lwz r4, -0x7E18(r13) # load new value +lwz r3, DO_PREV_VOLUME(REG_DATA) # load old value +cmpw r3, r4 +beq CLEANUP_AND_EXIT + +# Update prev value to current +stw r4, DO_PREV_VOLUME(REG_DATA) + +# Here the volume differs from the previous. Let's send the new volume to Dolphin +# mr r5, r4 +# logf LOG_LEVEL_WARN, "[Music] Volume changed: %d" + +addi REG_CMVQ, sp, SPO_EXI_SPACE_START +byteAlign32 REG_CMVQ + +# Write command +li r3, CONST_SlippiChangeMusicVolume +stb r3, CMVQ_COMMAND(REG_CMVQ) + +# Write new volume +stb r4, CMVQ_VOLUME(REG_CMVQ) + +# Exec EXI transfer +mr r3, REG_CMVQ +li r4, CMVQ_SIZE +li r5, CONST_ExiWrite +branchl r12, FN_EXITransferBuffer + +CLEANUP_AND_EXIT: +restore SPACE_NEEDED \ No newline at end of file diff --git a/Online/Online.s b/Online/Online.s index 350917d5..a2eeb0d4 100644 --- a/Online/Online.s +++ b/Online/Online.s @@ -10,7 +10,6 @@ # Offsets from r13 ################################################################################ .set OFST_R13_ODB_ADDR,-0x49e4 # Online data buffer -.set OFST_R13_SB_ADDR,-0x503C # Scene buffer, persists throughout scenes .set OFST_R13_ONLINE_MODE,-0x5060 # Byte, Selected online mode .set OFST_R13_APP_STATE,-0x505F # Byte, App state / online status .set OFST_R13_FORCE_MENU_CLEAR,-0x505E # Byte, Force menu clear diff --git a/Output/Console/GALE01r2.ini b/Output/Console/GALE01r2.ini index 114336f9..98d69bac 100644 --- a/Output/Console/GALE01r2.ini +++ b/Output/Console/GALE01r2.ini @@ -518,6 +518,11 @@ C208D698 00000005 #Recording/GetLCancelStatus/GetLCancelStatus.asm C206C324 00000002 #Recording/GetLCancelStatus/ResetLCancelStatus.asm 38600000 987E25FF 807E00B0 00000000 +C21A4CB4 00000004 #Common/AllocBuffer.asm +38600080 3D808037 +618CF1E4 7D8903A6 +4E800421 906DAFC4 +38000000 00000000 C20055F8 0000000F #Common/GetIsFollower.asm 7C0802A6 90010004 9421FF20 BE8100B0 diff --git a/Output/Console/g_core.bin b/Output/Console/g_core.bin index 4008e916..b01d8c0a 100644 Binary files a/Output/Console/g_core.bin and b/Output/Console/g_core.bin differ diff --git a/Output/Console/g_core_porta.bin b/Output/Console/g_core_porta.bin index ef17deb7..b9b03399 100644 Binary files a/Output/Console/g_core_porta.bin and b/Output/Console/g_core_porta.bin differ diff --git a/Output/InjectionLists/list_console_core.json b/Output/InjectionLists/list_console_core.json index ba1abf03..63bc27d9 100644 --- a/Output/InjectionLists/list_console_core.json +++ b/Output/InjectionLists/list_console_core.json @@ -266,6 +266,13 @@ "Annotation": "Recording/GetLCancelStatus/ResetLCancelStatus.asm", "Tags": "" }, + { + "InjectionAddress": "801A4CB4", + "Name": "Slippi Recording", + "Codetype": "Auto", + "Annotation": "Common/AllocBuffer.asm", + "Tags": "" + }, { "InjectionAddress": "800055F8", "Name": "Slippi Recording", diff --git a/Output/InjectionLists/list_netplay.json b/Output/InjectionLists/list_netplay.json index 732af658..47651a01 100644 --- a/Output/InjectionLists/list_netplay.json +++ b/Output/InjectionLists/list_netplay.json @@ -462,6 +462,13 @@ "Annotation": "Recording/GetLCancelStatus/ResetLCancelStatus.asm", "Tags": "" }, + { + "InjectionAddress": "801A4CB4", + "Name": "Required: Slippi Recording", + "Codetype": "Auto", + "Annotation": "Common/AllocBuffer.asm", + "Tags": "" + }, { "InjectionAddress": "800055F8", "Name": "Required: Slippi Recording", @@ -651,13 +658,6 @@ "Annotation": "Online/Core/TriggerSendInput.asm", "Tags": "" }, - { - "InjectionAddress": "801A4CB4", - "Name": "Required: Slippi Online", - "Codetype": "Auto", - "Annotation": "Online/Core/EXIFileLoad/AllocBuffer.asm", - "Tags": "" - }, { "InjectionAddress": "800163FC", "Name": "Required: Slippi Online", @@ -728,6 +728,27 @@ "Annotation": "Online/Core/Hacks/PreventPadAlarmDuringRollback.asm", "Tags": "" }, + { + "InjectionAddress": "8038E910", + "Name": "Required: Slippi Online", + "Codetype": "Auto", + "Annotation": "Online/Core/Music/StartSong.asm", + "Tags": "" + }, + { + "InjectionAddress": "800236EC", + "Name": "Required: Slippi Online", + "Codetype": "Auto", + "Annotation": "Online/Core/Music/Stop.asm", + "Tags": "" + }, + { + "InjectionAddress": "800249F0", + "Name": "Required: Slippi Online", + "Codetype": "Auto", + "Annotation": "Online/Core/Music/VolumeChange.asm", + "Tags": "" + }, { "InjectionAddress": "801D4578", "Name": "Required: Slippi Online", diff --git a/Output/Netplay/GALE01r2.ini b/Output/Netplay/GALE01r2.ini index 582eefce..d377db37 100644 --- a/Output/Netplay/GALE01r2.ini +++ b/Output/Netplay/GALE01r2.ini @@ -1021,6 +1021,11 @@ C208D698 00000005 #Recording/GetLCancelStatus/GetLCancelStatus.asm C206C324 00000002 #Recording/GetLCancelStatus/ResetLCancelStatus.asm 38600000 987E25FF 807E00B0 00000000 +C21A4CB4 00000004 #Common/AllocBuffer.asm +38600080 3D808037 +618CF1E4 7D8903A6 +4E800421 906DAFC4 +38000000 00000000 C20055F8 0000000F #Common/GetIsFollower.asm 7C0802A6 90010004 9421FF20 BE8100B0 @@ -2040,11 +2045,6 @@ BA8100B0 800100E4 800100E4 382100E0 7C0803A6 2C1E0000 60000000 00000000 -C21A4CB4 00000004 #Online/Core/EXIFileLoad/AllocBuffer.asm -38600080 3D808037 -618CF1E4 7D8903A6 -4E800421 906DAFC4 -38000000 00000000 C20163FC 0000001B #Online/Core/EXIFileLoad/GetFileSize.asm 7C7E1B78 7C0802A6 90010004 9421FF20 @@ -2194,6 +2194,63 @@ C2019608 0000000F #Online/Core/Hacks/PreventPadAlarmDuringRollback.asm 618C9618 7D8903A6 4E800420 38600000 60000000 00000000 +C238E910 0000001A #Online/Core/Music/StartSong.asm +7C0802A6 90010004 +9421FF54 BE81007C +7C7E1B78 3D808034 +618C7364 7D8903A6 +4E800421 7C7D1B78 +7FC3F378 38810008 +3D808033 618C7C60 +7D8903A6 4E800421 +2C030000 41820044 +3BE10048 3BFF001F +57FF0034 386000D6 +987F0000 80610038 +907F0001 8061003C +907F0005 7FE3FB78 +38800009 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +38610008 3D808033 +618C7CD4 7D8903A6 +4E800421 7FA3EB78 +3D808034 618C738C +7D8903A6 4E800421 +7FC3F378 BA81007C +800100B0 382100AC +7C0803A6 800DA998 +60000000 00000000 +C20236EC 0000000B #Online/Core/Music/Stop.asm +7C0802A6 90010004 +9421FF9C BE810034 +3BE10008 3BFF001F +57FF0034 386000D7 +987F0000 7FE3FB78 +38800001 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +BA810034 80010068 +38210064 7C0803A6 +38000000 00000000 +C20249F0 00000011 #Online/Core/Music/VolumeChange.asm +4800000C 4E800021 +00000000 900D81E8 +7C0802A6 90010004 +9421FF9C BE810034 +4BFFFFE5 7FC802A6 +808D81E8 807E0000 +7C032000 4182003C +909E0000 3BE10008 +3BFF001F 57FF0034 +386000D8 987F0000 +989F0001 7FE3FB78 +38800002 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +BA810034 80010068 +38210064 7C0803A6 +60000000 00000000 C21D4578 00000003 #Online/Core/PreventFileAlarms/FreezeStadium.asm FFE00890 3D80801D 618C4FD8 7D8903A6 diff --git a/Output/Netplay/GALJ01r2.ini b/Output/Netplay/GALJ01r2.ini index d42febc6..7cfef3f3 100644 --- a/Output/Netplay/GALJ01r2.ini +++ b/Output/Netplay/GALJ01r2.ini @@ -1020,6 +1020,11 @@ C208D698 00000005 #Recording/GetLCancelStatus/GetLCancelStatus.asm C206C324 00000002 #Recording/GetLCancelStatus/ResetLCancelStatus.asm 38600000 987E25FF 807E00B0 00000000 +C21A4CB4 00000004 #Common/AllocBuffer.asm +38600080 3D808037 +618CF1E4 7D8903A6 +4E800421 906DAFC4 +38000000 00000000 C20055F8 0000000F #Common/GetIsFollower.asm 7C0802A6 90010004 9421FF20 BE8100B0 @@ -2039,11 +2044,6 @@ BA8100B0 800100E4 800100E4 382100E0 7C0803A6 2C1E0000 60000000 00000000 -C21A4CB4 00000004 #Online/Core/EXIFileLoad/AllocBuffer.asm -38600080 3D808037 -618CF1E4 7D8903A6 -4E800421 906DAFC4 -38000000 00000000 C20163FC 0000001B #Online/Core/EXIFileLoad/GetFileSize.asm 7C7E1B78 7C0802A6 90010004 9421FF20 @@ -2193,6 +2193,63 @@ C2019608 0000000F #Online/Core/Hacks/PreventPadAlarmDuringRollback.asm 618C9618 7D8903A6 4E800420 38600000 60000000 00000000 +C238E910 0000001A #Online/Core/Music/StartSong.asm +7C0802A6 90010004 +9421FF54 BE81007C +7C7E1B78 3D808034 +618C7364 7D8903A6 +4E800421 7C7D1B78 +7FC3F378 38810008 +3D808033 618C7C60 +7D8903A6 4E800421 +2C030000 41820044 +3BE10048 3BFF001F +57FF0034 386000D6 +987F0000 80610038 +907F0001 8061003C +907F0005 7FE3FB78 +38800009 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +38610008 3D808033 +618C7CD4 7D8903A6 +4E800421 7FA3EB78 +3D808034 618C738C +7D8903A6 4E800421 +7FC3F378 BA81007C +800100B0 382100AC +7C0803A6 800DA998 +60000000 00000000 +C20236EC 0000000B #Online/Core/Music/Stop.asm +7C0802A6 90010004 +9421FF9C BE810034 +3BE10008 3BFF001F +57FF0034 386000D7 +987F0000 7FE3FB78 +38800001 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +BA810034 80010068 +38210064 7C0803A6 +38000000 00000000 +C20249F0 00000011 #Online/Core/Music/VolumeChange.asm +4800000C 4E800021 +00000000 900D81E8 +7C0802A6 90010004 +9421FF9C BE810034 +4BFFFFE5 7FC802A6 +808D81E8 807E0000 +7C032000 4182003C +909E0000 3BE10008 +3BFF001F 57FF0034 +386000D8 987F0000 +989F0001 7FE3FB78 +38800002 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +BA810034 80010068 +38210064 7C0803A6 +60000000 00000000 C21D4578 00000003 #Online/Core/PreventFileAlarms/FreezeStadium.asm FFE00890 3D80801D 618C4FD8 7D8903A6 diff --git a/Output/Playback/GALE01r2.ini b/Output/Playback/GALE01r2.ini index fa373578..bad30343 100644 --- a/Output/Playback/GALE01r2.ini +++ b/Output/Playback/GALE01r2.ini @@ -846,6 +846,11 @@ C216E8C8 00000005 #Playback/Core/Stadium/Enable Home Run Contest Distance.asm 4182000C 819F0044 4800000C 3D808018 618C1998 00000000 +C21A4CB4 00000004 #Common/AllocBuffer.asm +38600080 3D808037 +618CF1E4 7D8903A6 +4E800421 906DAFC4 +38000000 00000000 C20055F8 0000000F #Common/GetIsFollower.asm 7C0802A6 90010004 9421FF20 BE8100B0 diff --git a/Output/Playback/GALJ01r2.ini b/Output/Playback/GALJ01r2.ini index 335d5ef7..d3d3f783 100644 --- a/Output/Playback/GALJ01r2.ini +++ b/Output/Playback/GALJ01r2.ini @@ -845,6 +845,11 @@ C216E8C8 00000005 #Playback/Core/Stadium/Enable Home Run Contest Distance.asm 4182000C 819F0044 4800000C 3D808018 618C1998 00000000 +C21A4CB4 00000004 #Common/AllocBuffer.asm +38600080 3D808037 +618CF1E4 7D8903A6 +4E800421 906DAFC4 +38000000 00000000 C20055F8 0000000F #Common/GetIsFollower.asm 7C0802A6 90010004 9421FF20 BE8100B0