From 396bc5ffc8a4d86dd215d9533b906819d5e3ed69 Mon Sep 17 00:00:00 2001 From: Jas Laferriere Date: Tue, 3 Sep 2024 20:41:43 -0400 Subject: [PATCH] fix char/stage dependent crash --- AI/LoopMainEngine/ForceContinueLoop.asm | 8 +++ AI/OverwriteInputs/OverwriteInputs.asm | 12 +++- Common/FastForward/FunctionMacros.s | 5 ++ Output/AIInputs/output.txt | 76 +++++++++++++++++++++++++ Output/Netplay/GALE01r2.ini | 75 ------------------------ Output/Netplay/GALJ01r2.ini | 75 ------------------------ ai_inputs.json | 41 +++++++++++++ build-aiinputs.bat | 6 ++ netplay.json | 32 ----------- 9 files changed, 145 insertions(+), 185 deletions(-) create mode 100644 Output/AIInputs/output.txt create mode 100644 ai_inputs.json create mode 100644 build-aiinputs.bat diff --git a/AI/LoopMainEngine/ForceContinueLoop.asm b/AI/LoopMainEngine/ForceContinueLoop.asm index 3e0239c2..86e1dd17 100644 --- a/AI/LoopMainEngine/ForceContinueLoop.asm +++ b/AI/LoopMainEngine/ForceContinueLoop.asm @@ -3,6 +3,7 @@ ################################################################################ .include "Common/Common.s" +.include "Common/FastForward/FunctionMacros.s" getMinorMajor r3 cmpwi r3, 0x0202 @@ -25,6 +26,10 @@ beq CONTINUE_LOOPING branch r12, 0x801a508c CONTINUE_LOOPING: +# Exec camera tasks to prevent desyncs. This might not be needed for AI training so I'll keep it +# commented out for now. If this is uncommented the line lower in the file must be as well. +# bl FN_ExecCameraTasks + # Fake that there is an input ready load r4, 0x804c1f78 li r3, 1 @@ -33,5 +38,8 @@ stb r3, 0x3(r4) addi r26, r26, 1 branch r12, 0x801a4de4 # back to start of loop +# Camera tasks function body +# FunctionBody_ExecCameraTasks # Adds FN_ExecCameraTasks + EXIT: lwz r0, 0x000C(r25) # replaced code line \ No newline at end of file diff --git a/AI/OverwriteInputs/OverwriteInputs.asm b/AI/OverwriteInputs/OverwriteInputs.asm index 7cc2ab2b..fb711a4c 100644 --- a/AI/OverwriteInputs/OverwriteInputs.asm +++ b/AI/OverwriteInputs/OverwriteInputs.asm @@ -8,6 +8,7 @@ b CODE_START STATIC_MEMORY_TABLE_BLRL: blrl .long 0x80000000 # Placeholder for allocated memory pointer +.long 0xFFFFFFFF # Placeholder for last scene CODE_START: lfs f29, -0x1430 (rtoc) # replaced code line @@ -29,9 +30,14 @@ backup bl STATIC_MEMORY_TABLE_BLRL mflr REG_STATIC_MEM -loadGlobalFrame r3 -cmpwi r3, 0 -bne SKIP_ALLOC +# Allocate a new buffer on a scene change because the old one will have been cleaned up +getMinorMajor r3 +lhz r4, 0x4(REG_STATIC_MEM) +cmpw r3, r4 +beq SKIP_ALLOC + +# Write current scene to memory +sth r3, 0x4(REG_STATIC_MEM) # Prepare buffer for EXI transfer li r3, RXB_SIZE diff --git a/Common/FastForward/FunctionMacros.s b/Common/FastForward/FunctionMacros.s index 130c3b05..56d3fc11 100644 --- a/Common/FastForward/FunctionMacros.s +++ b/Common/FastForward/FunctionMacros.s @@ -1,3 +1,5 @@ +.ifndef HEADER_FFW_FUNCTION_MACROS + .macro FunctionBody_ExecCameraTasks FN_ExecCameraTasks: backup @@ -56,3 +58,6 @@ bne FNPGX_Loop restore blr .endm + +.endif +.set HEADER_FFW_FUNCTION_MACROS, 1 diff --git a/Output/AIInputs/output.txt b/Output/AIInputs/output.txt new file mode 100644 index 00000000..8b851e84 --- /dev/null +++ b/Output/AIInputs/output.txt @@ -0,0 +1,76 @@ +$Optional: Allow Bot Input Overrides [Fizzi] +*Allows bots to override inputs +C2377598 0000001F #AI/OverwriteInputs/OverwriteInputs.asm +48000010 4E800021 +80000000 FFFFFFFF +C3A2EBD0 7C0802A6 +90010004 9421FF20 +BE8100B0 4BFFFFE1 +7FC802A6 3C608048 +80639D30 5463443E +A09E0004 7C032000 +41820020 B07E0004 +38600024 3D808037 +618CF1E4 7D8903A6 +4E800421 907E0000 +83FE0000 386000D9 +987F0000 7FE3FB78 +38800001 38A00001 +3D808000 618C55F0 +7D8903A6 4E800421 +7FE3FB78 38800024 +38A00000 3D808000 +618C55F0 7D8903A6 +4E800421 39400000 +1D2A0009 7D3F4A14 +88690000 2C030000 +4182001C 1D0A000C +7D194214 80690001 +90680000 80690005 +90680004 394A0001 +2C0A0004 4180FFCC +BA8100B0 800100E4 +382100E0 7C0803A6 +60000000 00000000 + +$Optional: FFW VS Mode [Fizzi] +*To be used by bots, simulates vs mode gameplay +C21A500C 0000000F #AI/LoopMainEngine/ForceContinueLoop.asm +3C608048 80639D30 +5463443E 2C030202 +4082005C 3C608048 +80639D60 2C030001 +4081004C 3C608046 +6063B6A0 88630008 +2C030000 41820014 +3D80801A 618C508C +7D8903A6 4E800420 +3C80804C 60841F78 +38600001 98640003 +3B5A0001 3D80801A +618C4DE4 7D8903A6 +4E800420 8019000C +60000000 00000000 +C21A4DA8 00000006 #AI/LoopMainEngine/ForceStartLoop.asm +3C608048 80639D30 +5463443E 2C030202 +4082001C 3B400000 +3B600001 3D80801A +618C4DE4 7D8903A6 +4E800420 00000000 +C201960C 00000008 #AI/LoopMainEngine/PreventControllerReads.asm +3C608048 80639D30 +5463443E 2C030202 +40820014 3D808001 +618C9618 7D8903A6 +4E800420 38600000 +3D808037 618C69FC +7D8903A6 4E800421 +60000000 00000000 +C238D00C 00000006 #AI/LoopMainEngine/SkipSounds.asm +3AE30000 3C608048 +80639D30 5463443E +2C030202 40820014 +3D808038 618CD29C +7D8903A6 4E800420 +60000000 00000000 diff --git a/Output/Netplay/GALE01r2.ini b/Output/Netplay/GALE01r2.ini index 27196433..04d1892c 100644 --- a/Output/Netplay/GALE01r2.ini +++ b/Output/Netplay/GALE01r2.ini @@ -7149,78 +7149,3 @@ C0230064 BA810008 BA810008 800100B4 382100B0 7C0803A6 60000000 00000000 - -$Optional: Allow Bot Input Overrides [Fizzi] -*Allows bots to override inputs -C2377598 0000001D #AI/OverwriteInputs/OverwriteInputs.asm -4800000C 4E800021 -80000000 C3A2EBD0 -7C0802A6 90010004 -9421FF50 BE810008 -4BFFFFE5 7FC802A6 -3C608048 80639D60 -2C030000 4082001C -38600024 3D808037 -618CF1E4 7D8903A6 -4E800421 907E0000 -83FE0000 386000D6 -987F0000 7FE3FB78 -38800001 38A00001 -3D808000 618C55F0 -7D8903A6 4E800421 -7FE3FB78 38800024 -38A00000 3D808000 -618C55F0 7D8903A6 -4E800421 39400000 -1D2A0009 7D3F4A14 -88690000 2C030000 -4182001C 1D0A000C -7D194214 80690001 -90680000 80690005 -90680004 394A0001 -2C0A0004 4180FFCC -BA810008 800100B4 -382100B0 7C0803A6 -60000000 00000000 - -$Optional: FFW VS Mode [Fizzi] -*To be used by bots, simulates vs mode gameplay -C21A500C 0000000F #AI/LoopMainEngine/ForceContinueLoop.asm -3C608048 80639D30 -5463443E 2C030202 -4082005C 3C608048 -80639D60 2C030001 -4081004C 3C608046 -6063B6A0 88630008 -2C030000 41820014 -3D80801A 618C508C -7D8903A6 4E800420 -3C80804C 60841F78 -38600001 98640003 -3B5A0001 3D80801A -618C4DE4 7D8903A6 -4E800420 8019000C -60000000 00000000 -C21A4DA8 00000006 #AI/LoopMainEngine/ForceStartLoop.asm -3C608048 80639D30 -5463443E 2C030202 -4082001C 3B400000 -3B600001 3D80801A -618C4DE4 7D8903A6 -4E800420 00000000 -C201960C 00000008 #AI/LoopMainEngine/PreventControllerReads.asm -3C608048 80639D30 -5463443E 2C030202 -40820014 3D808001 -618C9618 7D8903A6 -4E800420 38600000 -3D808037 618C69FC -7D8903A6 4E800421 -60000000 00000000 -C238D00C 00000006 #AI/LoopMainEngine/SkipSounds.asm -3AE30000 3C608048 -80639D30 5463443E -2C030202 40820014 -3D808038 618CD29C -7D8903A6 4E800420 -60000000 00000000 diff --git a/Output/Netplay/GALJ01r2.ini b/Output/Netplay/GALJ01r2.ini index 4d36ac78..6ccc116a 100644 --- a/Output/Netplay/GALJ01r2.ini +++ b/Output/Netplay/GALJ01r2.ini @@ -7148,78 +7148,3 @@ C0230064 BA810008 BA810008 800100B4 382100B0 7C0803A6 60000000 00000000 - -$Optional: Allow Bot Input Overrides [Fizzi] -*Allows bots to override inputs -C2377598 0000001D #AI/OverwriteInputs/OverwriteInputs.asm -4800000C 4E800021 -80000000 C3A2EBD0 -7C0802A6 90010004 -9421FF50 BE810008 -4BFFFFE5 7FC802A6 -3C608048 80639D60 -2C030000 4082001C -38600024 3D808037 -618CF1E4 7D8903A6 -4E800421 907E0000 -83FE0000 386000D6 -987F0000 7FE3FB78 -38800001 38A00001 -3D808000 618C55F0 -7D8903A6 4E800421 -7FE3FB78 38800024 -38A00000 3D808000 -618C55F0 7D8903A6 -4E800421 39400000 -1D2A0009 7D3F4A14 -88690000 2C030000 -4182001C 1D0A000C -7D194214 80690001 -90680000 80690005 -90680004 394A0001 -2C0A0004 4180FFCC -BA810008 800100B4 -382100B0 7C0803A6 -60000000 00000000 - -$Optional: FFW VS Mode [Fizzi] -*To be used by bots, simulates vs mode gameplay -C21A500C 0000000F #AI/LoopMainEngine/ForceContinueLoop.asm -3C608048 80639D30 -5463443E 2C030202 -4082005C 3C608048 -80639D60 2C030001 -4081004C 3C608046 -6063B6A0 88630008 -2C030000 41820014 -3D80801A 618C508C -7D8903A6 4E800420 -3C80804C 60841F78 -38600001 98640003 -3B5A0001 3D80801A -618C4DE4 7D8903A6 -4E800420 8019000C -60000000 00000000 -C21A4DA8 00000006 #AI/LoopMainEngine/ForceStartLoop.asm -3C608048 80639D30 -5463443E 2C030202 -4082001C 3B400000 -3B600001 3D80801A -618C4DE4 7D8903A6 -4E800420 00000000 -C201960C 00000008 #AI/LoopMainEngine/PreventControllerReads.asm -3C608048 80639D30 -5463443E 2C030202 -40820014 3D808001 -618C9618 7D8903A6 -4E800420 38600000 -3D808037 618C69FC -7D8903A6 4E800421 -60000000 00000000 -C238D00C 00000006 #AI/LoopMainEngine/SkipSounds.asm -3AE30000 3C608048 -80639D30 5463443E -2C030202 40820014 -3D808038 618CD29C -7D8903A6 4E800420 -60000000 00000000 diff --git a/ai_inputs.json b/ai_inputs.json new file mode 100644 index 00000000..f1c669ff --- /dev/null +++ b/ai_inputs.json @@ -0,0 +1,41 @@ +{ + "outputFiles": [ + { + "file": "Output/AIInputs/output.txt" + } + ], + "codes": [ + { + "name": "Optional: Allow Bot Input Overrides", + "authors": [ + "Fizzi" + ], + "description": [ + "Allows bots to override inputs" + ], + "build": [ + { + "type": "injectFolder", + "sourceFolder": "AI/OverwriteInputs", + "isRecursive": true + } + ] + }, + { + "name": "Optional: FFW VS Mode", + "authors": [ + "Fizzi" + ], + "description": [ + "To be used by bots, simulates vs mode gameplay" + ], + "build": [ + { + "type": "injectFolder", + "sourceFolder": "AI/LoopMainEngine", + "isRecursive": true + } + ] + } + ] +} \ No newline at end of file diff --git a/build-aiinputs.bat b/build-aiinputs.bat new file mode 100644 index 00000000..da7cb114 --- /dev/null +++ b/build-aiinputs.bat @@ -0,0 +1,6 @@ +@echo off +echo Building ai_inputs.json... +gecko build -c ai_inputs.json -defsym "STG_EXIIndex=1" -batched +echo. + +pause \ No newline at end of file diff --git a/netplay.json b/netplay.json index 6e14806b..4eb35eb3 100644 --- a/netplay.json +++ b/netplay.json @@ -521,38 +521,6 @@ "isRecursive": true } ] - }, - { - "name": "Optional: Allow Bot Input Overrides", - "authors": [ - "Fizzi" - ], - "description": [ - "Allows bots to override inputs" - ], - "build": [ - { - "type": "injectFolder", - "sourceFolder": "AI/OverwriteInputs", - "isRecursive": true - } - ] - }, - { - "name": "Optional: FFW VS Mode", - "authors": [ - "Fizzi" - ], - "description": [ - "To be used by bots, simulates vs mode gameplay" - ], - "build": [ - { - "type": "injectFolder", - "sourceFolder": "AI/LoopMainEngine", - "isRecursive": true - } - ] } ] } \ No newline at end of file