Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research/latency and polling #124

Merged
merged 18 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Common/Common.s
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,14 @@ lwz \reg, -0x62A0(\reg)
load r3, \address
lwz r4, 0(r3) # Get branch instruction which contains offset

# Process 3rd byte and extend sign to handle negative branches
rlwinm r5, r4, 16, 0xFF
extsb r5, r5
rlwinm r5, r5, 16, 0xFFFF0000

# Extract last 2 bytes, combine with top half, and then add to base address to get result
rlwinm r4, r4, 0, 0xFFFC # Use 0xFFFC because the last bit is used for link
or r4, r4, r5
# This extracts the LI portion of the branch instruction and shifts it such
# that the sign bit is all the way left. Then it does a divide instruction to
# shift to the right 6 bits while preserving the sign. After that, add to
# branch instruction location to get result.
# Credit to taukhan for the divw improvement (saves 2 instructions)
rlwinm r5, r4, 6, 0xFFFFFF00
li r4, 64
divw r4, r5, r4
add \reg, r3, r4
.endm

Expand Down
5 changes: 5 additions & 0 deletions External/59.94Hz Engine/InGameSpeed.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# Address: 0x804DA2A8
################################################################################

.long 0x3C88AB85
5 changes: 5 additions & 0 deletions External/59.94Hz Engine/MenuSpeed.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# Address: 0x804DA9E8
################################################################################

.long 0x3C88AB85
5 changes: 5 additions & 0 deletions External/59.94Hz Engine/SetSpeedOnBoot.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# Address: 0x804D7CA0
################################################################################

.long 0x3C88AB85
27 changes: 27 additions & 0 deletions External/59.94Hz Engine/SyncPollingOnGameStart.asmtemp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
################################################################################
# Address: 0x80376a8c
################################################################################

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

# Check if VS Mode
getMinorMajor r3
cmpwi r3, 0x0202
bne EXIT

load r3, 0x80479d64
lwz r3, 0x0(r3) # 0x80479d64 - Believed to be some loading state
cmpwi r3, 0 # Loading state should be zero when game starts
bne EXIT

loadGlobalFrame r3
cmpwi r3, 1
bne EXIT

branchl r12, 0x8034f314 # VIWaitForRetrace

EXIT:
# Replaced code lines
lbz r0, 0x0002 (r31)
lbz r4, 0x0003 (r31)
5 changes: 5 additions & 0 deletions External/59.94Hz Engine/TrainingModeSpeed.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
################################################################################
# Address: 0x804DA5F8
################################################################################

.long 0x3C88AB85
53 changes: 53 additions & 0 deletions External/Debug Inputs/DebugInputs.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.ifndef HEADER_DEBUG_INPUTS

################################################################################
# Constants
################################################################################
.set INJ_InitDebugInputs, 0x8016e774

.set CIRCULAR_BUFFER_COUNT, 16

.set DIB_ACTIVE_STATE, 0 # u8. 0 = starting, 1 = active, 2 = complete
.set DIB_FETCH_INDEX, DIB_ACTIVE_STATE + 1 # u8
.set DIB_COLOR_KEY_DTEXT_ADDR, DIB_FETCH_INDEX + 1 # u32
.set DIB_LAG_DISPLAY_DTEXT_ADDR, DIB_COLOR_KEY_DTEXT_ADDR + 4 # u32
.set DIB_LAST_POLL_TIME, DIB_LAG_DISPLAY_DTEXT_ADDR + 4 # u32
.set DIB_LAST_FETCH_TIME, DIB_LAST_POLL_TIME + 4 # u32
.set DIB_CALLBACK_PTR, DIB_LAST_FETCH_TIME + 4 # u32
.set DIB_CIRCULAR_BUFFER, DIB_CALLBACK_PTR + 4 # u32 * CIRCULAR_BUFFER_COUNT
.set DIB_INPUT_TO_RENDER_US, DIB_CIRCULAR_BUFFER + (4 * CIRCULAR_BUFFER_COUNT) # u32
.set DIB_POLL_DIFF_MIN_US, DIB_INPUT_TO_RENDER_US + 4 # u32
.set DIB_POLL_DIFF_MAX_US, DIB_POLL_DIFF_MIN_US + 4 # u32
.set DIB_FETCH_DIFF_US, DIB_POLL_DIFF_MAX_US + 4 # u32
.set DIB_POLL_TO_FETCH_US, DIB_FETCH_DIFF_US + 4 # u32
.set DIB_POLL_TO_ENGINE_US, DIB_POLL_TO_FETCH_US + 4 # u32
.set DIB_POLL_COUNT, DIB_POLL_TO_ENGINE_US + 4 # u32
.set DIB_SIZE, DIB_POLL_COUNT + 4

################################################################################
# Macros
################################################################################

# Calculates us difference from two ticks
.macro calcDiffUs reg_now, reg_ref
sub r3, \reg_now, \reg_ref # This works even if ticks overflow
mulli r3, r3, 12
lis r4, 0x8000
ori r4, r4, 0x00FC
lwz r4, 0(r4) # Grab CPU speed so that this works on Nintendont (729MHz) and GC/Wii (486MHz)
li r5, 1000
divwu r4, r4, r5
divwu r4, r4, r5 # Divide by 1000 twice because I can't li 1000000
divwu r3, r3, r4
.endm

.macro calcDiffFromFetchUs reg_dib, reg_idx
branchl r12, 0x8034c408 # OSGetTick
mulli r4, \reg_idx, 4
addi r4, r4, DIB_CIRCULAR_BUFFER
lwzx r4, \reg_dib, r4
calcDiffUs r3, r4
.endm

.endif
.set HEADER_DEBUG_INPUTS, 1
Loading
Loading