mirror of
https://github.com/pret/pmd-sky.git
synced 2026-03-21 17:25:15 -05:00
Decomp GetExclusiveItemOffsetEnsureValid
This commit is contained in:
parent
d2fa771970
commit
7dd5d34966
|
|
@ -25,6 +25,7 @@
|
|||
.public CopyBitsFrom
|
||||
.public CopyBitsTo
|
||||
.public GetDungeonGroup
|
||||
.public GetExclusiveItemOffsetEnsureValid
|
||||
.public GetItemActionName
|
||||
.public GetItemBuyPrice
|
||||
.public GetItemCategory
|
||||
|
|
|
|||
|
|
@ -1889,27 +1889,3 @@ GetExclusiveItemType: ; 0x0200E760
|
|||
.align 2, 0
|
||||
_0200E778: .word ITEM_DATA_TABLE_PTRS
|
||||
arm_func_end GetExclusiveItemType
|
||||
|
||||
arm_func_start GetExclusiveItemOffsetEnsureValid
|
||||
GetExclusiveItemOffsetEnsureValid: ; 0x0200E77C
|
||||
stmdb sp!, {r4, lr}
|
||||
mov r4, r0
|
||||
cmp r4, #0x1bc
|
||||
blt _0200E798
|
||||
ldr r1, _0200E7BC ; =0x00000578
|
||||
cmp r4, r1
|
||||
blt _0200E7A0
|
||||
_0200E798:
|
||||
mov r0, #0x55
|
||||
ldmia sp!, {r4, pc}
|
||||
_0200E7A0:
|
||||
bl IsItemValid
|
||||
cmp r0, #0
|
||||
subne r0, r4, #0x1bc
|
||||
movne r0, r0, lsl #0x10
|
||||
movne r0, r0, asr #0x10
|
||||
moveq r0, #0x55
|
||||
ldmia sp!, {r4, pc}
|
||||
.align 2, 0
|
||||
_0200E7BC: .word 0x00000578
|
||||
arm_func_end GetExclusiveItemOffsetEnsureValid
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "util.h"
|
||||
|
||||
s16 GetExclusiveItemOffsetEnsureValid(s16 item_id);
|
||||
|
||||
// Checks if an item is valid given its ID.
|
||||
// In particular, checks if the "is valid" flag is set on its item_p.bin entry.
|
||||
bool8 IsItemValid(s16 item_id);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,16 @@
|
|||
|
||||
extern struct item_data_entry *ITEM_DATA_TABLE_PTRS[3];
|
||||
|
||||
s16 GetExclusiveItemOffsetEnsureValid(s16 item_id) {
|
||||
if (item_id < ITEM_PRISM_RUFF || item_id >= NUM_ITEM_IDS) {
|
||||
return ITEM_PLAIN_SEED;
|
||||
}
|
||||
if (IsItemValid(item_id)) {
|
||||
return (s16)(item_id - ITEM_PRISM_RUFF);
|
||||
}
|
||||
return ITEM_PLAIN_SEED;
|
||||
}
|
||||
|
||||
bool8 IsItemValid(s16 item_id)
|
||||
{
|
||||
if (ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].flags & ITEM_DATA_FLAG_VALID)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user