summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2020-06-23 10:48:28 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2020-06-23 10:48:28 -0400
commit582fefc54bc40ffb0b00034916a3b1e1bbc35965 (patch)
tree57e6fdeacc7030b21aabd917361ccb9dcffc9db6
parent0d9e2c1286db5869254783b1a3d2664298d6f872 (diff)
Match MoveItemSlotInList
-rw-r--r--arm9/arm9.lcf2
-rw-r--r--arm9/asm/unk_0206E5B4.s82
-rw-r--r--arm9/src/itemtool.c49
3 files changed, 24 insertions, 109 deletions
diff --git a/arm9/arm9.lcf b/arm9/arm9.lcf
index a6f59e57..46c4b318 100644
--- a/arm9/arm9.lcf
+++ b/arm9/arm9.lcf
@@ -374,7 +374,6 @@ SECTIONS {
unk_0206DE24.o (.text)
unk_0206E0F0.o (.text)
unk_0206E2F0.o (.text)
- unk_0206E5B4.o (.text)
itemtool.o (.text)
unk_0206EB80.o (.text)
unk_0206F1F0.o (.text)
@@ -696,7 +695,6 @@ SECTIONS {
unk_0206BF90.o (.rodata)
unk_0206C700.o (.rodata)
unk_0206E0F0.o (.rodata)
- unk_0206E5B4.o (.rodata)
itemtool.o (.rodata)
unk_0206F1F0.o (.rodata)
unk_0206F3FC.o (.rodata)
diff --git a/arm9/asm/unk_0206E5B4.s b/arm9/asm/unk_0206E5B4.s
deleted file mode 100644
index a40749bc..00000000
--- a/arm9/asm/unk_0206E5B4.s
+++ /dev/null
@@ -1,82 +0,0 @@
- .include "asm/macros.inc"
- .include "global.inc"
-
- .text
-
- thumb_func_start MoveItemSlotInList
-MoveItemSlotInList: ; 0x0206E5B4
- push {r3-r6}
- add r3, r0, #0x0
- add r0, r2, #0x0
- cmp r1, r0
- beq _0206E63A
- lsl r2, r1, #0x2
- ldrh r4, [r3, r2]
- add r5, r3, r2
- add r2, sp, #0x0
- strh r4, [r2, #0x0]
- ldrh r4, [r5, #0x2]
- strh r4, [r2, #0x2]
- cmp r0, r1
- bls _0206E600
- sub r0, r0, #0x1
- lsl r0, r0, #0x10
- lsr r0, r0, #0x10
- lsl r1, r1, #0x10
- lsl r2, r0, #0x10
- asr r1, r1, #0x10
- asr r5, r2, #0x10
- cmp r1, r5
- bge _0206E62C
- lsl r2, r1, #0x2
- add r2, r3, r2
- add r4, r2, #0x0
-_0206E5E8:
- ldrh r6, [r2, #0x4]
- add r1, r1, #0x1
- lsl r1, r1, #0x10
- strh r6, [r4, #0x0]
- ldrh r6, [r2, #0x6]
- asr r1, r1, #0x10
- add r2, r2, #0x4
- strh r6, [r4, #0x2]
- add r4, r4, #0x4
- cmp r1, r5
- blt _0206E5E8
- b _0206E62C
-_0206E600:
- lsl r1, r1, #0x10
- asr r5, r1, #0x10
- lsl r1, r0, #0x10
- asr r4, r1, #0x10
- cmp r5, r4
- ble _0206E62C
- lsl r1, r5, #0x2
- add r1, r3, r1
- add r2, r1, #0x0
-_0206E612:
- sub r6, r1, #0x4
- ldrh r6, [r6, #0x0]
- sub r5, r5, #0x1
- lsl r5, r5, #0x10
- strh r6, [r2, #0x0]
- sub r6, r1, #0x2
- ldrh r6, [r6, #0x0]
- asr r5, r5, #0x10
- sub r1, r1, #0x4
- strh r6, [r2, #0x2]
- sub r2, r2, #0x4
- cmp r5, r4
- bgt _0206E612
-_0206E62C:
- lsl r4, r0, #0x2
- add r0, sp, #0x0
- ldrh r1, [r0, #0x0]
- add r2, r3, r4
- strh r1, [r3, r4]
- ldrh r0, [r0, #0x2]
- strh r0, [r2, #0x2]
-_0206E63A:
- pop {r3-r6}
- bx lr
- .balign 4
diff --git a/arm9/src/itemtool.c b/arm9/src/itemtool.c
index 14167844..9cd7552d 100644
--- a/arm9/src/itemtool.c
+++ b/arm9/src/itemtool.c
@@ -664,31 +664,30 @@ static const u16 sItemIndexMappings[][4] = {
{ 441, 600, 601, 0 },
};
-//static inline void ShiftItemSlots(struct ItemSlot * itemSlots, s16 from, s16 to, s32 direction)
-//{
-// for (; direction > 0 ? from < to : from > to; from += direction)
-// {
-// itemSlots[from] = itemSlots[from + direction];
-// }
-//}
-//
-//void MoveItemSlotInList(struct ItemSlot * itemSlots, u16 from, u16 to)
-//{
-// if (from != to)
-// {
-// struct ItemSlot firstSlot = itemSlots[from];
-// if (to > from)
-// {
-// to--;
-// ShiftItemSlots(itemSlots, from, to, 1);
-// }
-// else
-// {
-// ShiftItemSlots(itemSlots, from, to, -1);
-// }
-// itemSlots[to] = firstSlot;
-// }
-//}
+void MoveItemSlotInList(struct ItemSlot * itemSlots, u16 from, u16 to)
+{
+ if (from != to)
+ {
+ s16 i;
+ struct ItemSlot firstSlot = itemSlots[from];
+ if (to > from)
+ {
+ to--;
+ for (i = (s16)from; i < (s16)to; i++)
+ {
+ itemSlots[i] = itemSlots[i + 1];
+ }
+ }
+ else
+ {
+ for (i = (s16)from; i > (s16)to; i--)
+ {
+ itemSlots[i] = itemSlots[i - 1];
+ }
+ }
+ itemSlots[to] = firstSlot;
+ }
+}
u16 GetItemIndexMapping(u16 a0, u16 a1)
{