diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2020-06-23 10:48:28 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2020-06-23 10:48:28 -0400 |
commit | 582fefc54bc40ffb0b00034916a3b1e1bbc35965 (patch) | |
tree | 57e6fdeacc7030b21aabd917361ccb9dcffc9db6 /arm9/src | |
parent | 0d9e2c1286db5869254783b1a3d2664298d6f872 (diff) |
Match MoveItemSlotInList
Diffstat (limited to 'arm9/src')
-rw-r--r-- | arm9/src/itemtool.c | 49 |
1 files changed, 24 insertions, 25 deletions
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) { |