Skip to content

Commit

Permalink
Merge branch 'master' into feature/extract-bones
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Apr 3, 2024
2 parents 9d7f992 + 7cd7e77 commit 07dc94a
Show file tree
Hide file tree
Showing 329 changed files with 32,434 additions and 7,227 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build Check

on:
push:
branches:
- "**"
pull_request:
branches:
- "**"

jobs:
ubuntu64:
name: "Build Check"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
submodules: recursive
- name: "Build"
if: success()
working-directory: ${{ github.workspace }}
run: |
sudo docker run --volume=${PWD}:/work --workdir=/work nikhilnarayana/devkitpro-slippi:latest make ini list
- uses: numtide/clean-git-action@v1
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,14 @@ pip-log.txt

.idea/

.vscode

Output/Console/install.bat
Output/Console/install-core-only.bat
Output/Netplay/install.bat
Output/Netplay/build-netplay.bat - Shortcut.lnk
Output/Playback/install.bat
Output/Playback/build-playback.bat - Shortcut.lnk
Output/Bootloader/build-bootloader.bat - Shortcut.lnk
./build-netplay0.sh
./netplay0.json
Binary file modified Binary/FasterMeleeSettings/UnlockAll.bin
Binary file not shown.
Binary file removed Binary/FasterMeleeSettings/UnlockAllTrophies.bin
Binary file not shown.
Binary file removed Binary/Force2PCenterHud.bin
Binary file not shown.
Binary file added Binary/LagReduction/PD+HalfVB.bin
Binary file not shown.
Binary file added Binary/LedgeGrabLimit.bin
Binary file not shown.
Binary file added Binary/UCF_0.84.bin
Binary file not shown.
Binary file added Binary/m-ex.bin
Binary file not shown.
10 changes: 10 additions & 0 deletions Bootloader/AddHeap.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
################################################################################
# Address: 8015ff60
################################################################################

################################################################################
# Description: adjusts the number of heaps from 4 to 6.
# Slippi uses heap 5 and m-ex uses heap 6.
################################################################################

li r4, 6
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
################################################################################
# Address: 8025d22c
# Address: 80346314
################################################################################
li r29,0

b 0x58
196 changes: 196 additions & 0 deletions Bootloader/main.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
################################################################################
# Address: 80375380
################################################################################

################################################################################
# Function: Bootloader
# ------------------------------------------------------------------------------
# Description: Requests codeset length and receives codeset file. Permanently
# allocates memory for the codeset in the heap.
# ------------------------------------------------------------------------------
# In: r3 = pointer to buffer
# r4 = buffer length
# r5 = read (0x0) or write (0x1)
################################################################################
.include "Common/Common.s"
.include "Online/Online.s"

.set REG_HeapLo,31
.set REG_FileSize,28
.set REG_File,27
.set REG_HeapID,26
.set REG_Buffer,25

# Original codeline
branchl r12,0x803444e0

backup

#Create a temp heap for getting the codeset size
addi r4,REG_HeapLo,32 + 32 #heap hi, 32 bytes padding?
mr r3,REG_HeapLo #heap lo = start
branchl r12,0x803440e8
mr REG_HeapID,r3

# Alloc temp buffer
mr r3,REG_HeapID
li r4,32
branchl r12,0x80343ef0
mr REG_Buffer,r3

# request gct size from slippi
li r3, CONST_SlippiCmdGctLength # store gct length request ID
stb r3,0x0(REG_Buffer)
# Transfer buffer over DMA
mr r3,REG_Buffer #Buffer Pointer
li r4,1 #Buffer Length = command
li r5,CONST_ExiWrite
branchl r12,FN_EXITransferBuffer
# Receive response
mr r3,REG_Buffer
li r4,4 #Buffer Length
li r5,CONST_ExiRead
branchl r12,FN_EXITransferBuffer
# Read file size off buffer
lwz REG_FileSize,0x0(REG_Buffer)

# Destroy the temp heap
mr r3,REG_HeapID
branchl r12,0x80344154

#Align
addi REG_FileSize,REG_FileSize,31
rlwinm REG_FileSize, REG_FileSize, 0, 0, 26
#Create heap of this size
add r4,REG_HeapLo,REG_FileSize #heap hi = start + filesize
addi r4,r4,32+32+128 #heap hi, 32 bytes per allocation? Also add space for file buffer
mr r3,REG_HeapLo #heap lo = start
mr REG_HeapLo,r4 #new start = heap hi
branchl r12,0x803440e8
mr REG_HeapID,r3
#Alloc from this heap
mr r3,REG_HeapID
mr r4,REG_FileSize
branchl r12,0x80343ef0
mr REG_Buffer,r3

#Load file here
li r3, CONST_SlippiCmdGctLoad # store gct length request ID
stb r3,0x0(REG_Buffer)
stw REG_Buffer,0x1(REG_Buffer) # store buffer address to buffer
# Transfer buffer over DMA
mr r3,REG_Buffer #Buffer Pointer
li r4,5 #Buffer Length = command + address
li r5,CONST_ExiWrite
branchl r12,FN_EXITransferBuffer
# Receive response
mr r3,REG_Buffer
mr r4,REG_FileSize #Buffer Length
li r5,CONST_ExiRead
branchl r12,FN_EXITransferBuffer

stw REG_HeapLo, -0x3FE8 (r13) # store new heap low

# Save pointer to gecko codes
load r3,GeckoHeapPtr
stw REG_Buffer, 0 (r3)

# Process gecko codes
addi r3, REG_Buffer, 8 # Gecko code list start
bl Callback_ProcessGeckoCode # Callback function to process codes
mflr r4
branchl r12, FN_ProcessGecko

#Alloc from this heap
mr r3,REG_HeapID
li r4,128
branchl r12,0x80343ef0
stw r3,OFST_R13_SB_ADDR(r13)

b Exit

Callback_ProcessGeckoCode:
blrl

.set REG_CodeAddress, 30
.set REG_TargetDataPtr, 29
.set REG_SourceDataPtr, 28
.set REG_ReplaceSize, 27

# r5 is input to this function, it contains the size of the replaced data
cmpwi r5, 0 # If size is 0, either we don't support this codetype or theres nothing to replace
beq Callback_ProcessGeckoCode_End

backup # TODO: Consider being more efficient about backup and restore?

mr REG_CodeAddress, r4
mr REG_ReplaceSize, r5

lwz r5, 0(REG_CodeAddress)
rlwinm r5, r5, 0, 0x01FFFFFF
oris REG_TargetDataPtr, r5, 0x8000 # Injection Address

# r3 contains the codetype, do a switch statement on it to prepare for memcpys
cmpwi r3, 0x04
beq HANDLE_04

cmpwi r3, 0x06
beq HANDLE_06

cmpwi r3, 0xC2
beq HANDLE_C2

# TODO: Assert? It should not be possible to get here. Obviously we could skip
# TODO: one of the above compares but I'd rather do an assert or something
# TODO: here to make sure that we haven't made a code error

HANDLE_04:
addi REG_SourceDataPtr, REG_CodeAddress, 4
b EXEC_COPY

HANDLE_06:
addi REG_SourceDataPtr, REG_CodeAddress, 8
b EXEC_COPY

HANDLE_C2:
# C2 Step 1: Copy the branch instruction that will overwrite data to buffer.
addi r4, REG_CodeAddress, 0x8
sub r3, r4, REG_TargetDataPtr
rlwinm r3, r3, 0, 6, 29
oris r3, r3, 0x4800
stw r3, BKP_FREE_SPACE_OFFSET(sp)
addi REG_SourceDataPtr, sp, BKP_FREE_SPACE_OFFSET

# C2 Step 2: Replace branch instruction in gecko code to return to correct loc
lwz r3, 0x4(REG_CodeAddress)
mulli r3, r3, 0x8
add r4, r3, REG_CodeAddress # get branch back site
addi r3, REG_TargetDataPtr, 0x4 # get branch back destination
sub r3, r3, r4
rlwinm r3, r3, 0, 6, 29 # extract bits for offset
oris r3, r3, 0x4800 # Create branch instruction from it
subi r3, r3, 0x4 # subtract 4 i guess
stw r3, 0x4(r4) # place branch instruction

EXEC_COPY:
# Replace data
mr r3, REG_TargetDataPtr # destination
mr r4, REG_SourceDataPtr # source
mr r5, REG_ReplaceSize
branchl r12, memcpy

mr r3, REG_TargetDataPtr
mr r4, REG_ReplaceSize
branchl r12, TRK_flush_cache

restore

Callback_ProcessGeckoCode_End:
blr

Exit:
restore

# overwrite r31 which stores the low bound. A few upcoming instructions rely
# on this to initialize the heap
lwz r31, -0x3FE8(r13)
File renamed without changes.
Loading

0 comments on commit 07dc94a

Please sign in to comment.