Skip to content

Commit

Permalink
separate out bones file, untested
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Apr 3, 2024
1 parent 07dc94a commit 47ba904
Show file tree
Hide file tree
Showing 11 changed files with 1,513 additions and 1,158 deletions.
481 changes: 268 additions & 213 deletions Output/Console/GALE01r2.ini

Large diffs are not rendered by default.

Binary file modified Output/Console/g_core.bin
Binary file not shown.
Binary file modified Output/Console/g_core_porta.bin
Binary file not shown.
481 changes: 268 additions & 213 deletions Output/Netplay/GALE01r2.ini

Large diffs are not rendered by default.

481 changes: 268 additions & 213 deletions Output/Netplay/GALJ01r2.ini

Large diffs are not rendered by default.

481 changes: 268 additions & 213 deletions Output/Playback/GALE01r2.ini

Large diffs are not rendered by default.

481 changes: 268 additions & 213 deletions Output/Playback/GALJ01r2.ini

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions Recording/Recording.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
.set CMD_ITEM, 0x3B
.set CMD_FRAME_BOOKEND, 0x3C
.set CMD_GAME_END, 0x39
.set COMMAND_COUNT, 10 # number of possible commands
# I realized after being mostly done with this that there's another bones extract branch... I'll leave this one here
# regardless because I think it might include rotation and stuff? This branch is untested atm
# Other branch: https://github.com/project-slippi/slippi-ssbm-asm/commit/e88025b6269714f12d1190beec4f228ee15fe099#diff-933ee24f9d76cf3111e644da95574259e7d4f8f8c40964dbf9a7db35e433e8fdR40
.set CMD_BONES_EXTRACT, 0x21
.set COMMAND_COUNT, 11 # number of possible commands

.set BONE_BYTES, 4 * 9 # float for each R/S/T, X/Y/Z
.set BONE_MAX, 118 # Zelda has the most bones at 118
Expand All @@ -35,6 +39,7 @@
.set GAME_FRAME_START_PAYLOAD_LENGTH, 12 #byte count
.set GAME_PRE_FRAME_PAYLOAD_LENGTH, 64 # byte count
.set GAME_POST_FRAME_PAYLOAD_LENGTH, 84 # byte count
.set GAME_BONES_EXTRACT_PAYLOAD_LENGTH, 9 + (BONE_BYTES * BONE_MAX) # byte count
.set GAME_ITEM_INFO_PAYLOAD_LENGTH, 44 # byte count
.set GAME_FRAME_BOOKEND_PAYLOAD_LENGTH, 8 # byte count
.set GAME_END_PAYLOAD_LENGTH, GAME_END_TXB_SIZE - 1 # byte count
Expand All @@ -60,7 +65,7 @@
.set SUPPORTED_PORTS, 4
.set MAX_CHARACTERS, SUPPORTED_PORTS * 2 # ICs
.set TOTAL_FRAME_START_LEN, GAME_FRAME_START_PAYLOAD_LENGTH + 1
.set TOTAL_CHAR_FRAME_LEN, MAX_CHARACTERS * (GAME_PRE_FRAME_PAYLOAD_LENGTH + 1) + MAX_CHARACTERS * (GAME_POST_FRAME_PAYLOAD_LENGTH + 1)
.set TOTAL_CHAR_FRAME_LEN, MAX_CHARACTERS * (GAME_PRE_FRAME_PAYLOAD_LENGTH + 1) + MAX_CHARACTERS * (GAME_POST_FRAME_PAYLOAD_LENGTH + 1) + MAX_CHARACTERS * (GAME_BONES_EXTRACT_PAYLOAD_LENGTH + 1)
.set TOTAL_ITEM_LEN, MAX_ITEMS * (GAME_ITEM_INFO_PAYLOAD_LENGTH + 1)
.set TOTAL_FRAME_BOOKEND_LEN, GAME_FRAME_BOOKEND_PAYLOAD_LENGTH + 1
.set TOTAL_GAME_END_LEN, GAME_END_PAYLOAD_LENGTH + 1
Expand Down
159 changes: 159 additions & 0 deletions Recording/SendGameBones.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
################################################################################
# Address: 8006da38
################################################################################
.include "Common/Common.s"
.include "Recording/Recording.s"

################################################################################
# Routine: SendGameBones
# ------------------------------------------------------------------------------
# Description: Sends bone data to be stored in replay
################################################################################

.set REG_PlayerData,31
.set REG_FighterGobj,30
.set REG_Buffer,29
.set REG_BufferOffset,28
.set REG_PlayerSlot,27

backup

# Check if VS Mode
branchl r12,FN_ShouldRecord
cmpwi r3,0x0
beq Injection_Exit

# check if this character is in sleep
lbz r3,0x221F(REG_PlayerData)
rlwinm. r3,r3,0,27,27
bne Injection_Exit

#------------- INITIALIZE -------------
# here we want to initalize some variables we plan on using throughout
lbz REG_PlayerSlot,0xC(REG_PlayerData) #loads this player slot
# get current offset in buffer
lwz r3, primaryDataBuffer(r13)
lwz REG_Buffer, RDB_TXB_ADDRESS(r3)
lwz REG_BufferOffset,bufferOffset(r13)
add REG_Buffer,REG_Buffer,REG_BufferOffset

#------------- Start bones extract -------------

# send bones extract code
li r3, CMD_BONES_EXTRACT
stb r3,0x0(REG_Buffer)

# send frame count
lwz r3,frameIndex(r13)
stw r3,0x1(REG_Buffer)

# send playerslot
stb REG_PlayerSlot,0x5(REG_Buffer)

# send isFollowerBool
mr r3,REG_PlayerData
branchl r12,FN_GetIsFollower
stb r3,0x6(REG_Buffer)

# send char id
lwz r3,0x04(REG_PlayerData) #load internal char ID
stb r3,0x07(REG_Buffer)

# Extract bone information
lwz r3, 0x28(REG_FighterGobj) # Get JObj
li r4, 0
addi r5, REG_Buffer, 0xA
bl JOBJ_ExtractBones

# Store bone count
sth r3, 0x8(REG_Buffer)

#------------- Increment Buffer Offset ------------
lwz REG_BufferOffset,bufferOffset(r13)
addi REG_BufferOffset,REG_BufferOffset,(GAME_BONES_EXTRACT_PAYLOAD_LENGTH+1)
stw REG_BufferOffset,bufferOffset(r13)

b Injection_Exit

##############################

JOBJ_ExtractBones:
# r3 = jobj
# r4 = count
# r5 = buffer_addr

.set REG_JObj, 31
.set REG_Count, 30
.set REG_BufAddr, 29

# backup jobj
mflr r0
stw r0, 0x0004 (sp)
stwu sp, -0x001C (sp)
stw REG_JObj, 0x0014 (sp)
stw REG_Count, 0x10(sp)
stw REG_BufAddr, 0x0C(sp)
mr REG_JObj,r3
mr REG_Count,r4
mr REG_BufAddr,r5

# output all jobj values
lwz r3, 0x44(REG_JObj)
stw r3, 0x0(REG_BufAddr) # RX
lwz r3, 0x54(REG_JObj)
stw r3, 0x4(REG_BufAddr) # RY
lwz r3, 0x64(REG_JObj)
stw r3, 0x8(REG_BufAddr) # RZ
lwz r3, 0x2C(REG_JObj)
stw r3, 0xC(REG_BufAddr) # SX
lwz r3, 0x30(REG_JObj)
stw r3, 0x10(REG_BufAddr) # SY
lwz r3, 0x34(REG_JObj)
stw r3, 0x14(REG_BufAddr) # SZ
lwz r3, 0x38(REG_JObj)
stw r3, 0x18(REG_BufAddr) # TX
lwz r3, 0x3C(REG_JObj)
stw r3, 0x1C(REG_BufAddr) # TY
lwz r3, 0x40(REG_JObj)
stw r3, 0x20(REG_BufAddr) # TZ

addi REG_Count, REG_Count, 1
addi REG_BufAddr, REG_BufAddr, 9 * 4

# run on child
lwz r3,0x10(REG_JObj)
mr r4, REG_Count
mr r5, REG_BufAddr
cmpwi r3,0
beq 0x10
bl JOBJ_ExtractBones
mr REG_Count, r3
mr REG_BufAddr, r4

# run on sibling
lwz r3,0x8(REG_JObj)
mr r4, REG_Count
mr r5, REG_BufAddr
cmpwi r3,0
beq 0x10
bl JOBJ_ExtractBones
mr REG_Count, r3
mr REG_BufAddr, r4

# Return values and exit function
mr r3, REG_Count
mr r4, REG_BufAddr
lwz REG_JObj, 0x0014 (sp)
lwz REG_Count, 0x10(sp)
lwz REG_BufAddr, 0x0C(sp)
lwz r0,0x20(sp)
addi sp, sp, 0x001C
mtlr r0
blr

##############################

Injection_Exit:
restore
lwz r0, 0x001C (sp)
lwz r31, 0x0014 (sp)
6 changes: 6 additions & 0 deletions Recording/SendGameInfo.asm
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ backup
li r3, SPLIT_MESSAGE_PAYLOAD_LENGTH
sth r3, CommandSizesStart+0x1B(REG_Buffer)

# bones extract command
li r3, CMD_BONES_EXTRACT
stb r3, CommandSizesStart+0x1D(REG_Buffer)
li r3, BONES_EXTRACT_PAYLOAD_LENGTH
sth r3, CommandSizesStart+0x1E(REG_Buffer)

#------------- BEGIN GAME INFO COMMAND -------------
# game information message type
.set GameInfoCommandStart, (CommandSizesStart + CommandSizesLength)
Expand Down
92 changes: 1 addition & 91 deletions Recording/SendGamePostFrame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
################################################################################

.set REG_PlayerData,31
.set REG_FighterGobj,30
.set REG_Buffer,29
.set REG_BufferOffset,28
.set REG_PlayerSlot,27
Expand Down Expand Up @@ -161,100 +160,11 @@ backup
lhz r3,0x2088(REG_PlayerData)
sth r3,0x53(REG_Buffer)

# Extract bone information
lwz r3, 0x28(REG_FighterGobj) # Get JObj
li r4, 0
addi r5, REG_Buffer, 0x4F
bl JOBJ_ExtractBones

# Store bone count
sth r3, 0x4D(REG_Buffer)
#------------- Increment Buffer Offset ------------
lwz REG_BufferOffset,bufferOffset(r13)
addi REG_BufferOffset,REG_BufferOffset,(GAME_POST_FRAME_PAYLOAD_LENGTH+1)
stw REG_BufferOffset,bufferOffset(r13)

b Injection_Exit

##############################

JOBJ_ExtractBones:
# r3 = jobj
# r4 = count
# r5 = buffer_addr

.set REG_JObj, 31
.set REG_Count, 30
.set REG_BufAddr, 29

# backup jobj
mflr r0
stw r0, 0x0004 (sp)
stwu sp, -0x001C (sp)
stw REG_JObj, 0x0014 (sp)
stw REG_Count, 0x10(sp)
stw REG_BufAddr, 0x0C(sp)
mr REG_JObj,r3
mr REG_Count,r4
mr REG_BufAddr,r5

# output all jobj values
lwz r3, 0x44(REG_JObj)
stw r3, 0x0(REG_BufAddr) # RX
lwz r3, 0x54(REG_JObj)
stw r3, 0x4(REG_BufAddr) # RY
lwz r3, 0x64(REG_JObj)
stw r3, 0x8(REG_BufAddr) # RZ
lwz r3, 0x2C(REG_JObj)
stw r3, 0xC(REG_BufAddr) # SX
lwz r3, 0x30(REG_JObj)
stw r3, 0x10(REG_BufAddr) # SY
lwz r3, 0x34(REG_JObj)
stw r3, 0x14(REG_BufAddr) # SZ
lwz r3, 0x38(REG_JObj)
stw r3, 0x18(REG_BufAddr) # TX
lwz r3, 0x3C(REG_JObj)
stw r3, 0x1C(REG_BufAddr) # TY
lwz r3, 0x40(REG_JObj)
stw r3, 0x20(REG_BufAddr) # TZ

addi REG_Count, REG_Count, 1
addi REG_BufAddr, REG_BufAddr, 9 * 4

# run on child
lwz r3,0x10(REG_JObj)
mr r4, REG_Count
mr r5, REG_BufAddr
cmpwi r3,0
beq 0x10
bl JOBJ_ExtractBones
mr REG_Count, r3
mr REG_BufAddr, r4

# run on sibling
lwz r3,0x8(REG_JObj)
mr r4, REG_Count
mr r5, REG_BufAddr
cmpwi r3,0
beq 0x10
bl JOBJ_ExtractBones
mr REG_Count, r3
mr REG_BufAddr, r4

# Return values and exit function
mr r3, REG_Count
mr r4, REG_BufAddr
lwz REG_JObj, 0x0014 (sp)
lwz REG_Count, 0x10(sp)
lwz REG_BufAddr, 0x0C(sp)
lwz r0,0x20(sp)
addi sp, sp, 0x001C
mtlr r0
blr

##############################

Injection_Exit:
restore
lwz r0, 0x001C (sp)
lwz r0, 0x001C (sp)

0 comments on commit 47ba904

Please sign in to comment.