Skip to content

Commit

Permalink
fix char/stage dependent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Sep 4, 2024
1 parent b5de4b1 commit 396bc5f
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 185 deletions.
8 changes: 8 additions & 0 deletions AI/LoopMainEngine/ForceContinueLoop.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
################################################################################

.include "Common/Common.s"
.include "Common/FastForward/FunctionMacros.s"

getMinorMajor r3
cmpwi r3, 0x0202
Expand All @@ -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
Expand All @@ -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
12 changes: 9 additions & 3 deletions AI/OverwriteInputs/OverwriteInputs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Common/FastForward/FunctionMacros.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.ifndef HEADER_FFW_FUNCTION_MACROS

.macro FunctionBody_ExecCameraTasks
FN_ExecCameraTasks:
backup
Expand Down Expand Up @@ -56,3 +58,6 @@ bne FNPGX_Loop
restore
blr
.endm

.endif
.set HEADER_FFW_FUNCTION_MACROS, 1
76 changes: 76 additions & 0 deletions Output/AIInputs/output.txt
Original file line number Diff line number Diff line change
@@ -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
75 changes: 0 additions & 75 deletions Output/Netplay/GALE01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
75 changes: 0 additions & 75 deletions Output/Netplay/GALJ01r2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 41 additions & 0 deletions ai_inputs.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
6 changes: 6 additions & 0 deletions build-aiinputs.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
echo Building ai_inputs.json...
gecko build -c ai_inputs.json -defsym "STG_EXIIndex=1" -batched
echo.

pause
32 changes: 0 additions & 32 deletions netplay.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
]
}

0 comments on commit 396bc5f

Please sign in to comment.