Merge pull request #123 from Kelebek1/Fixes

Fix a couple functions
This commit is contained in:
Ethan Roseman 2020-11-17 20:23:49 -05:00 committed by GitHub
commit 0192620100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 140 deletions

View File

@ -1,36 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel add_part_decoration
/* 1959F4 80267114 27BDFFD8 */ addiu $sp, $sp, -0x28
/* 1959F8 80267118 AFB10014 */ sw $s1, 0x14($sp)
/* 1959FC 8026711C 0080882D */ daddu $s1, $a0, $zero
/* 195A00 80267120 AFB20018 */ sw $s2, 0x18($sp)
/* 195A04 80267124 00A0902D */ daddu $s2, $a1, $zero
/* 195A08 80267128 AFBF0020 */ sw $ra, 0x20($sp)
/* 195A0C 8026712C AFB3001C */ sw $s3, 0x1c($sp)
/* 195A10 80267130 AFB00010 */ sw $s0, 0x10($sp)
/* 195A14 80267134 8E220094 */ lw $v0, 0x94($s1)
/* 195A18 80267138 1040000E */ beqz $v0, .L80267174
/* 195A1C 8026713C 00C0982D */ daddu $s3, $a2, $zero
/* 195A20 80267140 8E220000 */ lw $v0, ($s1)
/* 195A24 80267144 30420002 */ andi $v0, $v0, 2
/* 195A28 80267148 1440000A */ bnez $v0, .L80267174
/* 195A2C 8026714C 00000000 */ nop
/* 195A30 80267150 8E3000C0 */ lw $s0, 0xc0($s1)
/* 195A34 80267154 0C09740F */ jal _remove_part_decoration
/* 195A38 80267158 02128021 */ addu $s0, $s0, $s2
/* 195A3C 8026715C 0220202D */ daddu $a0, $s1, $zero
/* 195A40 80267160 24020001 */ addiu $v0, $zero, 1
/* 195A44 80267164 A21308B8 */ sb $s3, 0x8b8($s0)
/* 195A48 80267168 A20208BA */ sb $v0, 0x8ba($s0)
/* 195A4C 8026716C 0C0973B2 */ jal func_8025CEC8
/* 195A50 80267170 A20008BC */ sb $zero, 0x8bc($s0)
.L80267174:
/* 195A54 80267174 8FBF0020 */ lw $ra, 0x20($sp)
/* 195A58 80267178 8FB3001C */ lw $s3, 0x1c($sp)
/* 195A5C 8026717C 8FB20018 */ lw $s2, 0x18($sp)
/* 195A60 80267180 8FB10014 */ lw $s1, 0x14($sp)
/* 195A64 80267184 8FB00010 */ lw $s0, 0x10($sp)
/* 195A68 80267188 03E00008 */ jr $ra
/* 195A6C 8026718C 27BD0028 */ addiu $sp, $sp, 0x28

View File

@ -1,29 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel lookup_defense
/* 194724 80265E44 0080182D */ daddu $v1, $a0, $zero
/* 194728 80265E48 8C620000 */ lw $v0, ($v1)
/* 19472C 80265E4C 1040000F */ beqz $v0, .L80265E8C
/* 194730 80265E50 0000302D */ daddu $a2, $zero, $zero
/* 194734 80265E54 24070001 */ addiu $a3, $zero, 1
/* 194738 80265E58 24840004 */ addiu $a0, $a0, 4
/* 19473C 80265E5C 8C620000 */ lw $v0, ($v1)
.L80265E60:
/* 194740 80265E60 14470002 */ bne $v0, $a3, .L80265E6C
/* 194744 80265E64 00000000 */ nop
/* 194748 80265E68 8C860000 */ lw $a2, ($a0)
.L80265E6C:
/* 19474C 80265E6C 14450004 */ bne $v0, $a1, .L80265E80
/* 194750 80265E70 24630008 */ addiu $v1, $v1, 8
/* 194754 80265E74 8C860000 */ lw $a2, ($a0)
/* 194758 80265E78 03E00008 */ jr $ra
/* 19475C 80265E7C 00C0102D */ daddu $v0, $a2, $zero
.L80265E80:
/* 194760 80265E80 8C620000 */ lw $v0, ($v1)
/* 194764 80265E84 1440FFF6 */ bnez $v0, .L80265E60
/* 194768 80265E88 24840008 */ addiu $a0, $a0, 8
.L80265E8C:
/* 19476C 80265E8C 00C0102D */ daddu $v0, $a2, $zero
/* 194770 80265E90 03E00008 */ jr $ra
/* 194774 80265E94 00000000 */ nop

View File

@ -1,46 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel find_script_labels
/* E7AF8 802C3148 0000182D */ daddu $v1, $zero, $zero
/* E7AFC 802C314C 2406FFFF */ addiu $a2, $zero, -1
/* E7B00 802C3150 0080282D */ daddu $a1, $a0, $zero
.L802C3154:
/* E7B04 802C3154 00831021 */ addu $v0, $a0, $v1
/* E7B08 802C3158 A0460010 */ sb $a2, 0x10($v0)
/* E7B0C 802C315C ACA00020 */ sw $zero, 0x20($a1)
/* E7B10 802C3160 24630001 */ addiu $v1, $v1, 1
/* E7B14 802C3164 28620010 */ slti $v0, $v1, 0x10
/* E7B18 802C3168 1440FFFA */ bnez $v0, .L802C3154
/* E7B1C 802C316C 24A50004 */ addiu $a1, $a1, 4
/* E7B20 802C3170 0000382D */ daddu $a3, $zero, $zero
/* E7B24 802C3174 8C830008 */ lw $v1, 8($a0)
/* E7B28 802C3178 240A0001 */ addiu $t2, $zero, 1
/* E7B2C 802C317C 24090003 */ addiu $t1, $zero, 3
/* E7B30 802C3180 0080402D */ daddu $t0, $a0, $zero
.L802C3184:
/* E7B34 802C3184 8C650000 */ lw $a1, ($v1)
/* E7B38 802C3188 24630004 */ addiu $v1, $v1, 4
/* E7B3C 802C318C 8C620000 */ lw $v0, ($v1)
/* E7B40 802C3190 24630004 */ addiu $v1, $v1, 4
/* E7B44 802C3194 8C660000 */ lw $a2, ($v1)
/* E7B48 802C3198 00021080 */ sll $v0, $v0, 2
/* E7B4C 802C319C 10AA000D */ beq $a1, $t2, .L802C31D4
/* E7B50 802C31A0 00621821 */ addu $v1, $v1, $v0
/* E7B54 802C31A4 14A90007 */ bne $a1, $t1, .L802C31C4
/* E7B58 802C31A8 28E20010 */ slti $v0, $a3, 0x10
/* E7B5C 802C31AC 00871021 */ addu $v0, $a0, $a3
/* E7B60 802C31B0 A0460010 */ sb $a2, 0x10($v0)
/* E7B64 802C31B4 AD030020 */ sw $v1, 0x20($t0)
/* E7B68 802C31B8 25080004 */ addiu $t0, $t0, 4
/* E7B6C 802C31BC 24E70001 */ addiu $a3, $a3, 1
/* E7B70 802C31C0 28E20010 */ slti $v0, $a3, 0x10
.L802C31C4:
/* E7B74 802C31C4 1440FFEF */ bnez $v0, .L802C3184
/* E7B78 802C31C8 00000000 */ nop
.L802C31CC:
/* E7B7C 802C31CC 080B0C73 */ j .L802C31CC
/* E7B80 802C31D0 00000000 */ nop
.L802C31D4:
/* E7B84 802C31D4 03E00008 */ jr $ra
/* E7B88 802C31D8 00000000 */ nop

View File

@ -1135,10 +1135,9 @@ typedef struct DecorationTable {
/* 0x8AC */ u8 effectType; /* 0 = blur, 14 = none? */
/* 0x8AD */ char unk_8AD[11];
/* 0x8B8 */ u8 decorationType[2];
/* 0x8BA */ u8 unk_8BA;
/* 0x8BB */ u8 unk_8BB;
/* 0x8BC */ u8 unk_8BC;
/* 0x8BD */ char unk_8BD[43];
/* 0x8BA */ u8 unk_8BA[2];
/* 0x8BC */ u8 unk_8BC[2];
/* 0x8BD */ char unk_8BD[42];
} DecorationTable; // size = 0x8E8
typedef struct Shop {

View File

@ -93,7 +93,6 @@ INCLUDE_ASM(s32, "code_190B20", func_80265CE8);
INCLUDE_ASM(s32, "code_190B20", func_80265D44);
#ifdef NON_MATCHING
typedef struct {
Element element;
s32 defense;
@ -103,22 +102,20 @@ s32 lookup_defense(DefenseTableEntry* defenseTable, Element elementKey) {
DefenseTableEntry* row;
s32 normalDefense = 0;
for (row = defenseTable; row->element != Element_END; row++) {
for (row = defenseTable; row->element != Element_END; row++, defenseTable++) {
if (row->element == Element_NORMAL) {
normalDefense = row->defense;
normalDefense = defenseTable->defense;
}
if (row->element == elementKey) {
return row->defense;
normalDefense = defenseTable->defense;
break;
}
}
// Fall back to normal defense if given element is not specified in table
return normalDefense;
}
#else
INCLUDE_ASM(s32, "code_190B20", lookup_defense);
#endif
INCLUDE_ASM(s32, "code_190B20", lookup_status_chance); // exactly (?) the same as lookup_defense
@ -284,23 +281,17 @@ INCLUDE_ASM(s32, "code_190B20", func_8026709C);
INCLUDE_ASM(s32, "code_190B20", func_802670C8);
#ifdef NON_MATCHING
// Register allocation issues (decorationIndex is placed in s2 for seemingly no reason?).
// Should be easy to clean up once DecorationTable is more understood
void add_part_decoration(ActorPart* part, s32 decorationIndex, DecorationId decorationType) {
if (part->idleAnimations && (part->flags & 2) == 0) {
DecorationTable* decoration = &part->decorationTable->unk_00[decorationIndex];
if ((part->idleAnimations) && !(part->flags & 2)) {
DecorationTable* decorationTable = part->decorationTable;
_remove_part_decoration(part, decorationIndex);
decoration->decorationType[0] = decorationType;
decoration->unk_8BA = 1;
decoration->unk_8BC = 0;
decorationTable->decorationType[decorationIndex] = decorationType;
decorationTable->unk_8BA[decorationIndex] = 1;
decorationTable->unk_8BC[decorationIndex] = 0;
func_8025CEC8(part);
}
}
#else
INCLUDE_ASM(void, "code_190B20", add_part_decoration, ActorPart* part, s32 decorationIndex,
DecorationId decorationType);
#endif
void add_actor_decoration(Actor* actor, s32 decorationIndex, DecorationId decorationType) {
ActorPart* part;

View File

@ -52,8 +52,6 @@ void sort_scripts(void) {
INCLUDE_ASM(s32, "code_e79b0_len_1920", sort_scripts);
#endif
#ifdef NON_MATCHING
// Very close. Reordering/branch likely issues
void find_script_labels(ScriptInstance* script) {
Bytecode* curLine;
s32 type;
@ -69,7 +67,7 @@ void find_script_labels(ScriptInstance* script) {
j = 0;
curLine = script->ptrNextLine;
for (j = 0; j < ARRAY_COUNT(script->labelIndices); j++) {
while (j < ARRAY_COUNT(script->labelIndices)) {
type = *curLine++;
numArgs = *curLine++;
label = *curLine;
@ -82,13 +80,11 @@ void find_script_labels(ScriptInstance* script) {
if (type == 3) {
script->labelIndices[j] = label;
script->labelPositions[j] = curLine;
j++;
}
}
PANIC();
}
#else
INCLUDE_ASM(void, "code_e79b0_len_1920", find_script_labels);
#endif
void clear_script_list(void) {
s32 i;