From b765c00d42b7252850e8428eb17506b3577bda21 Mon Sep 17 00:00:00 2001 From: Jas Laferriere Date: Fri, 6 Sep 2024 14:51:00 -0400 Subject: [PATCH] add input sync ffw codes --- AI/LoopMainEngine/IncrementPadIndex.asm | 21 ++++++++++ AI/LoopMainEngine/PadAlwaysUseMasterIndex.asm | 11 ++++++ AI/OverwriteInputs/OverwriteInputs.asm | 8 ++++ Output/AIInputs/output.txt | 39 +++++++++++++++++-- 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 AI/LoopMainEngine/IncrementPadIndex.asm create mode 100644 AI/LoopMainEngine/PadAlwaysUseMasterIndex.asm diff --git a/AI/LoopMainEngine/IncrementPadIndex.asm b/AI/LoopMainEngine/IncrementPadIndex.asm new file mode 100644 index 00000000..7824d039 --- /dev/null +++ b/AI/LoopMainEngine/IncrementPadIndex.asm @@ -0,0 +1,21 @@ +################################################################################ +# Address: 80377544 +################################################################################ + +# Credit to tauKhan + +# If we are iterating without anything in the input buffer, move the pad input +# along so that we correctly restore the x analog value used by UCF to the +# correct place. Previously, there was a possibility for desyncs when doing a +# UCF dashback while in FFW. +# +# I believe the only time this would *not* skip is when we force a FFW. +# Skip if the input buffer is larger than zero (unused inputs are present). + +bne+ SKIP + +# Add "fake" input to the queue +li r0, 1 +stb r0, 0x3(r30) + +SKIP: diff --git a/AI/LoopMainEngine/PadAlwaysUseMasterIndex.asm b/AI/LoopMainEngine/PadAlwaysUseMasterIndex.asm new file mode 100644 index 00000000..b03890ce --- /dev/null +++ b/AI/LoopMainEngine/PadAlwaysUseMasterIndex.asm @@ -0,0 +1,11 @@ +################################################################################ +# Address: 80376a88 +################################################################################ + +# Credit to tauKhan +# From tauKhan: +# make it so that the renewStatus loads masterIndex instead of its own index +# for the block where it inserts inputs +# thus it'll always put inputs to the slot the next RenewMasterStatus uses +# and will never overwrite older data +lbz r0, 0x1(r31) diff --git a/AI/OverwriteInputs/OverwriteInputs.asm b/AI/OverwriteInputs/OverwriteInputs.asm index fb711a4c..bb9ca7f0 100644 --- a/AI/OverwriteInputs/OverwriteInputs.asm +++ b/AI/OverwriteInputs/OverwriteInputs.asm @@ -83,6 +83,14 @@ stw r3, 0(r8) lwz r3, RXPB_PAD_DATA+4(r9) stw r3, 4(r8) +lbz r3, 0xA(r8) # Load status byte for pad +extsb r3, r3 +cmpwi r3, 0 +beq LOOP_CONTINUE + +lwz r5, frameIndex(r13) +logf LOG_LEVEL_NOTICE, "[Frame %d] Non 0 controller status byte: %d", "mr r6, 3" + LOOP_CONTINUE: addi r10, r10, 1 cmpwi r10, 4 diff --git a/Output/AIInputs/output.txt b/Output/AIInputs/output.txt index 8b851e84..1e2eecc1 100644 --- a/Output/AIInputs/output.txt +++ b/Output/AIInputs/output.txt @@ -1,6 +1,6 @@ $Optional: Allow Bot Input Overrides [Fizzi] *Allows bots to override inputs -C2377598 0000001F #AI/OverwriteInputs/OverwriteInputs.asm +C2377598 0000003A #AI/OverwriteInputs/OverwriteInputs.asm 48000010 4E800021 80000000 FFFFFFFF C3A2EBD0 7C0802A6 @@ -24,11 +24,38 @@ A09E0004 7C032000 4E800421 39400000 1D2A0009 7D3F4A14 88690000 2C030000 -4182001C 1D0A000C +418200F4 1D0A000C 7D194214 80690001 90680000 80690005 -90680004 394A0001 -2C0A0004 4180FFCC +90680004 8868000A +7C630774 2C030000 +418200CC 80ADB654 +48000034 4E800021 +5B467261 6D652025 +645D204E 6F6E2030 +20636F6E 74726F6C +6C657220 73746174 +75732062 7974653A +20256400 7C0802A6 +90010004 9421FF00 +BC610008 7C661B78 +60000000 60000000 +60000000 60000000 +60000000 806DAFC4 +38630003 4BFFFFA1 +7C8802A6 4CC63242 +3D808032 618C3CF4 +7D8903A6 4E800421 +806DAFC4 388000D0 +98830000 38800000 +98830001 38800001 +98830002 38800080 +38A00001 3D808000 +618C55F0 7D8903A6 +4E800421 B8610008 +80010104 38210100 +7C0803A6 394A0001 +2C0A0004 4180FEF4 BA8100B0 800100E4 382100E0 7C0803A6 60000000 00000000 @@ -58,6 +85,10 @@ C21A4DA8 00000006 #AI/LoopMainEngine/ForceStartLoop.asm 3B600001 3D80801A 618C4DE4 7D8903A6 4E800420 00000000 +C2377544 00000002 #AI/LoopMainEngine/IncrementPadIndex.asm +40A2000C 38000001 +981E0003 00000000 +04376A88 881F0001 #AI/LoopMainEngine/PadAlwaysUseMasterIndex.asm C201960C 00000008 #AI/LoopMainEngine/PreventControllerReads.asm 3C608048 80639D30 5463443E 2C030202