Fix nonmatching PutItemOnSlot

This commit is contained in:
Tal Hayon 2021-12-27 17:06:51 +02:00
parent 60e74d1ba9
commit 167fe1122e
2 changed files with 6 additions and 80 deletions

View File

@ -1,73 +0,0 @@
.syntax unified
.text
push {r4, r5, lr}
adds r5, r0, #0
cmp r5, #0x46
bhi _080543A8
movs r0, #0
movs r1, #1
bl sub_0807CAA0
_080543A8:
subs r0, r5, #1
cmp r0, #0x1e
bhi _08054410
movs r1, #2
ldr r2, _080543C0 @ =gSave
adds r0, r2, #0
adds r0, #0xb4
ldrb r0, [r0]
cmp r0, #0
bne _080543C4
movs r1, #0
b _080543D0
.align 2, 0
_080543C0: .4byte gSave
_080543C4:
adds r0, r2, #0
adds r0, #0xb5
ldrb r0, [r0]
cmp r0, #0
bne _080543D0
movs r1, #1
_080543D0:
cmp r1, #2
bne _0805440A
ldr r3, _080543F0 @ =gUnk_080FD5B4
lsls r0, r5, #3
adds r0, r0, r3
ldrb r4, [r0]
adds r0, r2, #0
adds r0, #0xb4
ldrb r0, [r0]
lsls r0, r0, #3
adds r0, r0, r3
ldrb r0, [r0]
cmp r4, r0
bne _080543F4
movs r1, #0
b _08054406
.align 2, 0
_080543F0: .4byte gUnk_080FD5B4
_080543F4:
adds r0, r2, #0
adds r0, #0xb5
ldrb r0, [r0]
lsls r0, r0, #3
adds r0, r0, r3
ldrb r0, [r0]
cmp r4, r0
bne _08054406
movs r1, #1
_08054406:
cmp r1, #2
beq _08054410
_0805440A:
adds r0, r5, #0
bl ForceEquipItem
_08054410:
pop {r4, r5, pc}
.align 2, 0
.syntax divided

View File

@ -44,13 +44,13 @@ u32 IsItemEquipped(u32 itemID) {
return itemSlot;
}
NONMATCH("asm/non_matching/PutItemOnSlot.inc", void PutItemOnSlot(u32 itemID)) {
// reg-alloc
void PutItemOnSlot(u32 itemID) {
u32 itemSlot;
if (itemID < 0x47) {
register u32 itemID2 asm ("r5") = itemID;
if (itemID2 < 0x47) {
sub_0807CAA0(0, 1);
}
if (itemID - 1 < 0x1f) {
if (itemID2 - 1 < 0x1f) {
itemSlot = 2;
if (gSave.stats.itemOnA == 0) {
itemSlot = 0;
@ -58,7 +58,7 @@ NONMATCH("asm/non_matching/PutItemOnSlot.inc", void PutItemOnSlot(u32 itemID)) {
itemSlot = 1;
}
if (itemSlot == 2) {
u8 temp = gUnk_080FD5B4[itemID].unk;
u8 temp = gUnk_080FD5B4[itemID2].unk;
if (temp == gUnk_080FD5B4[gSave.stats.itemOnA].unk) {
itemSlot = 0;
} else {
@ -70,10 +70,9 @@ NONMATCH("asm/non_matching/PutItemOnSlot.inc", void PutItemOnSlot(u32 itemID)) {
return;
}
}
ForceEquipItem(itemID, itemSlot);
ForceEquipItem(itemID2, itemSlot);
}
}
END_NONMATCH
ASM_FUNC("asm/non_matching/ForceEquipItem.inc", void ForceEquipItem(u32 itemID, u8 itemSlot))