mirror of
https://github.com/pret/pmd-sky.git
synced 2026-03-21 17:25:15 -05:00
Merge pull request #240 from VicSevenT/more_item_funcs
Some checks failed
build / build (push) Has been cancelled
Some checks failed
build / build (push) Has been cancelled
Decomp more item funcs and item table
This commit is contained in:
commit
1f10758178
|
|
@ -13,18 +13,13 @@
|
|||
.public _02097FB8
|
||||
.public _02097FC4
|
||||
.public _02097FE4
|
||||
.public _02098038
|
||||
.public _02098054
|
||||
.public _02098070
|
||||
.public _020A18BC
|
||||
.public _020AF6C4
|
||||
.public _020AF6C8
|
||||
.public _020AFF88_EU
|
||||
.public AVAILABLE_ITEMS_IN_GROUP_TABLE
|
||||
.public BAG_ITEMS_PTR_MIRROR
|
||||
.public CopyBitsFrom
|
||||
.public CopyBitsTo
|
||||
.public GetDungeonGroup
|
||||
.public GetExclusiveItemType
|
||||
.public GetItemActionName
|
||||
.public GetItemBuyPrice
|
||||
.public GetItemCategory
|
||||
|
|
@ -32,22 +27,17 @@
|
|||
.public GetItemName
|
||||
.public GetItemPaletteId
|
||||
.public GetItemSellPrice
|
||||
.public GetLanguage
|
||||
.public GetThrownItemQuantityLimit
|
||||
.public HandleSir0Translation
|
||||
.public InitItem
|
||||
.public IsAuraBow
|
||||
.public IsItemValid
|
||||
.public IsShoppableItem
|
||||
.public IsThrownItem
|
||||
.public ITEM_DATA_TABLE_PTRS
|
||||
.public ITEM_TABLES_PTRS_1
|
||||
.public LoadFileFromRom
|
||||
.public MemAlloc
|
||||
.public MemFree
|
||||
.public MONEY_QUANTITY_TABLE
|
||||
.public MultiplyByFixedPoint
|
||||
.public PointsToZero
|
||||
.public RandRangeSafe
|
||||
.public strcpy
|
||||
.public strncpy
|
||||
|
|
@ -57,4 +47,3 @@
|
|||
.public sub_02050990
|
||||
.public sub_020509BC
|
||||
.public vsprintf
|
||||
.public ZInit8
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
#pragma once
|
||||
.public GetExclusiveItemOffsetEnsureValid
|
||||
.public ITEM_DATA_TABLE_PTRS
|
||||
|
|
@ -35,11 +35,11 @@
|
|||
.public _02092EBC
|
||||
.public _02092ED0
|
||||
.public _02094D00
|
||||
.public _020983F4
|
||||
.public _02098404
|
||||
.public _02098414
|
||||
.public _02098424
|
||||
.public _02098434
|
||||
.public ST_I2N_I_BIN
|
||||
.public ST_I2N_E_BIN
|
||||
.public ST_I2N_S_BIN
|
||||
.public ST_I2N_G_BIN
|
||||
.public ST_I2N_F_BIN
|
||||
.public _02098DAC
|
||||
.public _02098DC8
|
||||
.public _02098EB0
|
||||
|
|
|
|||
|
|
@ -1789,127 +1789,3 @@ _0200E6CC:
|
|||
blt _0200E628
|
||||
ldmia sp!, {r4, r5, r6, pc}
|
||||
arm_func_end RemoveEmptyItems
|
||||
|
||||
arm_func_start LoadItemPspi2n
|
||||
LoadItemPspi2n: ; 0x0200E6D8
|
||||
#ifdef EUROPE
|
||||
#define LOAD_ITEM_PSPI_2N_STACK_SIZE #0x108
|
||||
#else
|
||||
#define LOAD_ITEM_PSPI_2N_STACK_SIZE #8
|
||||
#endif
|
||||
stmdb sp!, {r3, lr}
|
||||
sub sp, sp, LOAD_ITEM_PSPI_2N_STACK_SIZE
|
||||
ldr r1, _0200E748 ; =_02098038
|
||||
add r0, sp, #0
|
||||
mov r2, #1
|
||||
bl LoadFileFromRom
|
||||
ldr r1, [sp]
|
||||
ldr r0, _0200E74C ; =_020AF6C4
|
||||
bl HandleSir0Translation
|
||||
ldr r1, _0200E750 ; =_02098054
|
||||
add r0, sp, #0
|
||||
mov r2, #1
|
||||
bl LoadFileFromRom
|
||||
ldr r1, [sp]
|
||||
ldr r0, _0200E754 ; =ITEM_DATA_TABLE_PTRS
|
||||
bl HandleSir0Translation
|
||||
ldr r0, _0200E758 ; =_020AF6C8
|
||||
bl PointsToZero
|
||||
cmp r0, #0
|
||||
beq _0200E740
|
||||
ldr r0, _0200E758 ; =_020AF6C8
|
||||
bl ZInit8
|
||||
#ifdef EUROPE
|
||||
bl GetLanguage
|
||||
mov r2, r0
|
||||
ldr r1, _0200E800 ; =_020AFF88_EU
|
||||
add r0, sp, #8
|
||||
ldr r2, [r1, r2, lsl #2]
|
||||
ldr r1, _0200E75C ; =_02098070
|
||||
bl SprintfStatic__0200E808_EU
|
||||
ldr r0, _0200E758 ; =_020AF6C8
|
||||
add r1, sp, #8
|
||||
#else
|
||||
ldr r0, _0200E758 ; =_020AF6C8
|
||||
ldr r1, _0200E75C ; =_02098070
|
||||
#endif
|
||||
mov r2, #1
|
||||
bl LoadFileFromRom
|
||||
_0200E740:
|
||||
add sp, sp, LOAD_ITEM_PSPI_2N_STACK_SIZE
|
||||
ldmia sp!, {r3, pc}
|
||||
.align 2, 0
|
||||
_0200E748: .word _02098038
|
||||
#ifdef EUROPE
|
||||
_0200E74C: .word ITEM_DATA_TABLE_PTRS
|
||||
#else
|
||||
_0200E74C: .word _020AF6C4
|
||||
#endif
|
||||
_0200E750: .word _02098054
|
||||
#ifdef EUROPE
|
||||
_0200E754: .word _020AF6C4
|
||||
#else
|
||||
_0200E754: .word ITEM_DATA_TABLE_PTRS
|
||||
#endif
|
||||
_0200E758: .word _020AF6C8
|
||||
#ifdef EUROPE
|
||||
_0200E800: .word _020AFF88_EU
|
||||
#endif
|
||||
_0200E75C: .word _02098070
|
||||
arm_func_end LoadItemPspi2n
|
||||
|
||||
#ifdef EUROPE
|
||||
arm_func_start SprintfStatic__0200E808_EU
|
||||
SprintfStatic__0200E808_EU: ; 0x0200E808
|
||||
stmdb sp!, {r0, r1, r2, r3}
|
||||
stmdb sp!, {r3, lr}
|
||||
add r2, sp, #0xc
|
||||
bic r2, r2, #3
|
||||
ldr r1, [sp, #0xc]
|
||||
add r2, r2, #4
|
||||
bl vsprintf
|
||||
ldmia sp!, {r3, lr}
|
||||
add sp, sp, #0x10
|
||||
bx lr
|
||||
arm_func_end SprintfStatic__0200E808_EU
|
||||
#endif
|
||||
|
||||
arm_func_start GetExclusiveItemType
|
||||
GetExclusiveItemType: ; 0x0200E760
|
||||
stmdb sp!, {r3, lr}
|
||||
bl GetExclusiveItemOffsetEnsureValid
|
||||
ldr r1, _0200E778 ; =ITEM_DATA_TABLE_PTRS
|
||||
#ifdef EUROPE
|
||||
ldr r1, [r1, #4]
|
||||
#else
|
||||
ldr r1, [r1]
|
||||
#endif
|
||||
ldrb r0, [r1, r0, lsl #2]
|
||||
ldmia sp!, {r3, pc}
|
||||
.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
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
.include "asm/macros.inc"
|
||||
.include "main_0200E7E8.inc"
|
||||
|
||||
.text
|
||||
|
||||
arm_func_start GetExclusiveItemParameter
|
||||
GetExclusiveItemParameter: ; 0x0200E7E8
|
||||
stmdb sp!, {r3, lr}
|
||||
bl GetExclusiveItemOffsetEnsureValid
|
||||
ldr r1, _0200E804 ; =ITEM_DATA_TABLE_PTRS
|
||||
#ifdef EUROPE
|
||||
ldr r1, [r1, #4]
|
||||
#else
|
||||
ldr r1, [r1]
|
||||
#endif
|
||||
add r0, r1, r0, lsl #2
|
||||
ldrsh r0, [r0, #2]
|
||||
ldmia sp!, {r3, pc}
|
||||
.align 2, 0
|
||||
_0200E804: .word ITEM_DATA_TABLE_PTRS
|
||||
arm_func_end GetExclusiveItemParameter
|
||||
|
|
@ -2886,26 +2886,26 @@ _02097FE4:
|
|||
.byte 0x25, 0x73, 0x5B, 0x43, 0x53, 0x3A, 0x31, 0x3A, 0x52, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52, 0x3A
|
||||
.byte 0x31, 0x5D, 0x00, 0x00
|
||||
#ifdef EUROPE
|
||||
.global _020983F4
|
||||
_020983F4:
|
||||
.byte 0x73, 0x74, 0x5F, 0x69, 0x32, 0x6E, 0x5F, 0x69
|
||||
.byte 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00
|
||||
.global _02098404
|
||||
_02098404:
|
||||
.byte 0x73, 0x74, 0x5F, 0x69, 0x32, 0x6E, 0x5F, 0x65
|
||||
.byte 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00
|
||||
.global _02098414
|
||||
_02098414:
|
||||
.byte 0x73, 0x74, 0x5F, 0x69, 0x32, 0x6E, 0x5F, 0x73
|
||||
.byte 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00
|
||||
.global _02098424
|
||||
_02098424:
|
||||
.byte 0x73, 0x74, 0x5F, 0x69, 0x32, 0x6E, 0x5F, 0x67
|
||||
.byte 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00
|
||||
.global _02098434
|
||||
_02098434:
|
||||
.byte 0x73, 0x74, 0x5F, 0x69, 0x32, 0x6E, 0x5F, 0x66
|
||||
.byte 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00
|
||||
.global ST_I2N_I_BIN
|
||||
ST_I2N_I_BIN:
|
||||
.string "st_i2n_i.bin"
|
||||
.align 4
|
||||
.global ST_I2N_E_BIN
|
||||
ST_I2N_E_BIN:
|
||||
.string "st_i2n_e.bin"
|
||||
.align 4
|
||||
.global ST_I2N_S_BIN
|
||||
ST_I2N_S_BIN:
|
||||
.string "st_i2n_s.bin"
|
||||
.align 4
|
||||
.global ST_I2N_G_BIN
|
||||
ST_I2N_G_BIN:
|
||||
.string "st_i2n_g.bin"
|
||||
.align 4
|
||||
.global ST_I2N_F_BIN
|
||||
ST_I2N_F_BIN:
|
||||
.string "st_i2n_f.bin"
|
||||
.align 4
|
||||
#endif
|
||||
.global BABY_EXCLUSIVE_ITEM_PAIRS
|
||||
BABY_EXCLUSIVE_ITEM_PAIRS:
|
||||
|
|
@ -2914,40 +2914,38 @@ BABY_EXCLUSIVE_ITEM_PAIRS:
|
|||
.byte 0xCF, 0x01, 0x0B, 0x01, 0xD0, 0x01, 0x46, 0x01, 0xD1, 0x01, 0x88, 0x01, 0xD2, 0x01, 0xE0, 0x01
|
||||
.byte 0xD3, 0x01, 0xE1, 0x01, 0xD4, 0x01, 0xE2, 0x01, 0xD5, 0x01, 0xE9, 0x01, 0xD6, 0x01, 0xF4, 0x01
|
||||
.byte 0xD7, 0x01, 0x13, 0x02
|
||||
.global _02098038
|
||||
_02098038:
|
||||
.byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x2F, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43
|
||||
.byte 0x45, 0x2F, 0x69, 0x74, 0x65, 0x6D, 0x5F, 0x70, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00, 0x00, 0x00
|
||||
.global _02098054
|
||||
_02098054:
|
||||
.byte 0x72, 0x6F, 0x6D, 0x30, 0x3A, 0x2F, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43, 0x45, 0x2F, 0x69, 0x74
|
||||
.byte 0x65, 0x6D, 0x5F, 0x73, 0x5F, 0x70, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00
|
||||
.global _02098070
|
||||
_02098070:
|
||||
.byte 0x72, 0x6F, 0x6D, 0x30
|
||||
.byte 0x3A, 0x2F, 0x42, 0x41, 0x4C, 0x41, 0x4E, 0x43
|
||||
.global ITEM_P_BIN
|
||||
ITEM_P_BIN:
|
||||
.string "rom0:/BALANCE/item_p.bin"
|
||||
.align 4
|
||||
.global ITEM_S_P_BIN
|
||||
ITEM_S_P_BIN:
|
||||
.string "rom0:/BALANCE/item_s_p.bin"
|
||||
.align 4
|
||||
.global ITEM_ST_I2N_BIN
|
||||
ITEM_ST_I2N_BIN:
|
||||
#ifdef EUROPE
|
||||
.byte 0x45, 0x2F, 0x25, 0x73
|
||||
.byte 0x00, 0x00, 0x00, 0x00
|
||||
.string "rom0:/BALANCE/%s"
|
||||
#else
|
||||
.byte 0x45, 0x2F, 0x73, 0x74, 0x5F, 0x69, 0x32, 0x6E
|
||||
.byte 0x5F, 0x6A, 0x2E, 0x62, 0x69, 0x6E, 0x00, 0x00
|
||||
.string "rom0:/BALANCE/st_i2n_j.bin"
|
||||
#endif
|
||||
.align 4
|
||||
.global ITEM_NAME_FORMAT_YELLOW
|
||||
ITEM_NAME_FORMAT_YELLOW: // "[CS:U]%s[CR]"
|
||||
.byte 0x5B, 0x43, 0x53, 0x3A, 0x55, 0x5D, 0x25, 0x73
|
||||
.byte 0x5B, 0x43, 0x52, 0x5D, 0x00, 0x00, 0x00, 0x00
|
||||
ITEM_NAME_FORMAT_YELLOW:
|
||||
.string "[CS:U]%s[CR]"
|
||||
.align 4
|
||||
.global ITEM_NAME_FORMAT_INDIGO
|
||||
ITEM_NAME_FORMAT_INDIGO: // "[CS:Z]%s[CR]"
|
||||
.byte 0x5B, 0x43, 0x53, 0x3A, 0x5A, 0x5D, 0x25, 0x73
|
||||
.byte 0x5B, 0x43, 0x52, 0x5D, 0x00, 0x00, 0x00, 0x00
|
||||
ITEM_NAME_FORMAT_INDIGO:
|
||||
.string "[CS:Z]%s[CR]"
|
||||
.align 4
|
||||
.global ITEM_NAME_FORMAT_PLAIN
|
||||
ITEM_NAME_FORMAT_PLAIN: // "%s"
|
||||
.byte 0x25, 0x73, 0x00, 0x00
|
||||
ITEM_NAME_FORMAT_PLAIN:
|
||||
.string "%s"
|
||||
.align 4
|
||||
.global ITEM_NAME_FORMAT_CREAM
|
||||
ITEM_NAME_FORMAT_CREAM: // "[CS:I]%s[CR]"
|
||||
.byte 0x5B, 0x43, 0x53, 0x3A
|
||||
.byte 0x49, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52, 0x5D, 0x00, 0x00, 0x00, 0x00
|
||||
ITEM_NAME_FORMAT_CREAM:
|
||||
.string "[CS:I]%s[CR]"
|
||||
.align 4
|
||||
.global KECLEON_SHOP_ITEM_TABLE_LISTS_1
|
||||
KECLEON_SHOP_ITEM_TABLE_LISTS_1:
|
||||
.byte 0x10, 0x00, 0x00, 0x00
|
||||
|
|
|
|||
|
|
@ -11664,21 +11664,18 @@ BAG_ITEMS_PTR_MIRROR:
|
|||
.word _02094D00
|
||||
.global ITEM_DATA_TABLE_PTRS
|
||||
ITEM_DATA_TABLE_PTRS:
|
||||
.byte 0x00, 0x00, 0x00, 0x00
|
||||
.global _020AF6C4
|
||||
_020AF6C4:
|
||||
.byte 0x00, 0x00, 0x00, 0x00
|
||||
.global _020AF6C8
|
||||
_020AF6C8:
|
||||
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
.word 0x00
|
||||
.word 0x00
|
||||
.word 0x00
|
||||
.word 0x00
|
||||
#ifdef EUROPE
|
||||
.global _020AFF88_EU
|
||||
_020AFF88_EU:
|
||||
.word _02098404
|
||||
.word _02098434
|
||||
.word _02098424
|
||||
.word _020983F4
|
||||
.word _02098414
|
||||
.global ITEM_LANG_FILE_ARRAY
|
||||
ITEM_LANG_FILE_ARRAY:
|
||||
.word ST_I2N_E_BIN
|
||||
.word ST_I2N_F_BIN
|
||||
.word ST_I2N_G_BIN
|
||||
.word ST_I2N_I_BIN
|
||||
.word ST_I2N_S_BIN
|
||||
#endif
|
||||
.global _020AF6D0
|
||||
_020AF6D0:
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
#ifndef PMDSKY_ITEM_H
|
||||
#define PMDSKY_ITEM_H
|
||||
|
||||
#include "file.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef EUROPE
|
||||
#define ITEM_DATA_TABLE_PTRS_INDEX 0
|
||||
#else
|
||||
#define ITEM_DATA_TABLE_PTRS_INDEX 1
|
||||
#endif
|
||||
|
||||
// Item ID
|
||||
enum item_id {
|
||||
ITEM_NOTHING = 0,
|
||||
|
|
@ -1647,7 +1642,13 @@ struct bag_items {
|
|||
/* 0x384 */ struct bag_items_inner *bag_items;
|
||||
};
|
||||
|
||||
struct item_data_entry
|
||||
struct bulk_item
|
||||
{
|
||||
/* 0x0 */ s16 id;
|
||||
/* 0x2 */ u16 quantity;
|
||||
};
|
||||
|
||||
struct item_data
|
||||
{
|
||||
/* 0x0 */ u16 buy_price;
|
||||
/* 0x2 */ u16 sell_price;
|
||||
|
|
@ -1661,10 +1662,22 @@ struct item_data_entry
|
|||
/* 0xE */ u8 flags;
|
||||
};
|
||||
|
||||
struct bulk_item
|
||||
{
|
||||
/* 0x0 */ s16 id;
|
||||
/* 0x2 */ u16 quantity;
|
||||
struct item_exclusive_data {
|
||||
u8 type;
|
||||
u16 unk2;
|
||||
};
|
||||
|
||||
struct item_tables {
|
||||
|
||||
#ifdef EUROPE
|
||||
struct item_data *data;
|
||||
struct item_exclusive_data *exclusive_data;
|
||||
#else
|
||||
struct item_exclusive_data *exclusive_data;
|
||||
struct item_data *data;
|
||||
#endif
|
||||
|
||||
struct iovec langFile;
|
||||
};
|
||||
|
||||
#endif //PMDSKY_ITEM_H
|
||||
|
|
|
|||
|
|
@ -1,10 +1,43 @@
|
|||
#ifndef PMDSKY_ITEM_UTIL_1_H
|
||||
#define PMDSKY_ITEM_UTIL_1_H
|
||||
|
||||
#include "item.h"
|
||||
#include "util.h"
|
||||
|
||||
void LoadItemPspi2n(void);
|
||||
|
||||
#ifdef EUROPE
|
||||
void SprintfStatic__0200E808_EU(char* buf, const char* fmt, ...);
|
||||
#endif
|
||||
|
||||
u8 GetExclusiveItemType(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);
|
||||
|
||||
s16 GetExclusiveItemParameter(s16 item_id);
|
||||
|
||||
// Returns the category of the specified item
|
||||
enum item_category GetItemCategory(s16 item_id);
|
||||
|
||||
u8* GetItemName(s16 item_id);
|
||||
void GetItemNameFormatted(char* name, s16 item_id, s32 arg2, s32 arg3);
|
||||
u16 GetItemBuyPrice(s16 item_id);
|
||||
u16 GetItemSellPrice(s16 item_id);
|
||||
u8 GetItemSpriteId(s16 item_id);
|
||||
u8 GetItemPaletteId(s16 item_id);
|
||||
u8 GetItemActionName(s16 item_id);
|
||||
u8 GetThrownItemQuantityLimit(s16 item_id, u8 arg1);
|
||||
s16 GetItemMoveId(s16 item_id);
|
||||
|
||||
// Returns a boolean indicating whether the item is consumable, throwable at an ally, or throwable at an enemy, depending on item_flag.
|
||||
// The table used for this is inaccessible in the code, as it is loaded from a file in the ROM at runtime.
|
||||
// Bit 7 in the table corresponds to ITEM_FLAG_CONSUMABLE, bit 6 to ITEM_FLAG_THROWABLE_AT_ALLY, and bit 5 to ITEM_FLAG_THROWABLE_AT_ENEMY.
|
||||
//
|
||||
// item_id: item_id enum
|
||||
// flag: item_flag enum. Function will test a different allowed AI action depending on the value.
|
||||
// return: bool
|
||||
bool8 TestItemAiFlag(s16 item_id, s32 flag);
|
||||
|
||||
#endif //PMDSKY_ITEM_UTIL_1_H
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef PMDSKY_ITEM_UTIL_2_H
|
||||
#define PMDSKY_ITEM_UTIL_2_H
|
||||
|
||||
#include "item.h"
|
||||
|
||||
// Returns the category of the specified item
|
||||
enum item_category GetItemCategory(s16 item_id);
|
||||
// Checks if the given item ID is valid (using IsItemValid). If so, return the given item ID. Otherwise, return ITEM_PLAIN_SEED.
|
||||
s16 EnsureValidItem(s16 item_id);
|
||||
|
||||
u8* GetItemName(s16 item_id);
|
||||
void GetItemNameFormatted(char* name, s16 item_id, s32 arg2, s32 arg3);
|
||||
u16 GetItemBuyPrice(s16 item_id);
|
||||
u16 GetItemSellPrice(s16 item_id);
|
||||
u8 GetItemSpriteId(s16 item_id);
|
||||
u8 GetItemPaletteId(s16 item_id);
|
||||
u8 GetItemActionName(s16 item_id);
|
||||
u8 GetThrownItemQuantityLimit(s16 item_id, u8 arg1);
|
||||
s16 GetItemMoveId(s16 item_id);
|
||||
|
||||
// Returns a boolean indicating whether the item is consumable, throwable at an ally, or throwable at an enemy, depending on item_flag.
|
||||
// The table used for this is inaccessible in the code, as it is loaded from a file in the ROM at runtime.
|
||||
// Bit 7 in the table corresponds to ITEM_FLAG_CONSUMABLE, bit 6 to ITEM_FLAG_THROWABLE_AT_ALLY, and bit 5 to ITEM_FLAG_THROWABLE_AT_ENEMY.
|
||||
//
|
||||
// item_id: item_id enum
|
||||
// flag: item_flag enum. Function will test a different allowed AI action depending on the value.
|
||||
// return: bool
|
||||
bool8 TestItemAiFlag(s16 item_id, s32 flag);
|
||||
|
||||
#endif //PMDSKY_ITEM_UTIL_2_H
|
||||
2
main.lsf
2
main.lsf
|
|
@ -40,8 +40,6 @@ Static main
|
|||
Object src/item_util_4.o
|
||||
Object asm/main_0200CAFC.o
|
||||
Object src/item_util_1.o
|
||||
Object asm/main_0200E7E8.o
|
||||
Object src/item_util_2.o
|
||||
Object asm/main_0200EB30.o
|
||||
Object src/main_0200ECFC.o
|
||||
Object asm/main_0200ED1C.o
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "dungeon_util_static.h"
|
||||
#include "item.h"
|
||||
#include "item_util.h"
|
||||
#include "item_util_2.h"
|
||||
#include "item_util_1.h"
|
||||
#include "overlay_29_022E1610.h"
|
||||
#include "position_util.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include "item_util.h"
|
||||
#include "item_util_2.h"
|
||||
#include "item_util_1.h"
|
||||
|
||||
enum item_category GetItemCategoryVeneer(s16 item_id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,219 @@
|
|||
#include "item_util_1.h"
|
||||
#include "debug.h"
|
||||
#include "main_0200330C.h"
|
||||
#include "main_0202593C.h"
|
||||
#include "item.h"
|
||||
#include "item_util_1.h"
|
||||
|
||||
extern struct item_data_entry *ITEM_DATA_TABLE_PTRS[3];
|
||||
#ifdef EUROPE
|
||||
#define ITEM_NAME_OFFSET 0x1A78
|
||||
#elif JAPAN
|
||||
#define ITEM_NAME_OFFSET 0x0D93
|
||||
#else
|
||||
#define ITEM_NAME_OFFSET 0x1A76
|
||||
#endif
|
||||
|
||||
extern struct item_tables ITEM_DATA_TABLE_PTRS;
|
||||
extern const char ITEM_NAME_FORMAT_YELLOW;
|
||||
extern const char ITEM_NAME_FORMAT_INDIGO;
|
||||
extern const char ITEM_NAME_FORMAT_PLAIN;
|
||||
extern const char ITEM_NAME_FORMAT_CREAM;
|
||||
extern const char ITEM_P_BIN;
|
||||
extern const char ITEM_S_P_BIN;
|
||||
extern const char ITEM_ST_I2N_BIN;
|
||||
extern char* ITEM_LANG_FILE_ARRAY[];
|
||||
|
||||
extern void LoadFileFromRom(struct iovec* iov, const char* filepath, u32 flags);
|
||||
extern void HandleSir0Translation(void*, void*);
|
||||
extern s32 GetLanguage();
|
||||
extern u8* strcpy(u8*, u8*);
|
||||
extern s32 vsprintf(u8* str, const u8* format, va_list ap);
|
||||
|
||||
static s16 GetExclusiveItemOffsetEnsureValid(s16 item_id);
|
||||
static s16 EnsureValidItem(s16 item_id);
|
||||
static void SprintfStatic(char*, const char*, ...);
|
||||
|
||||
|
||||
void LoadItemPspi2n(void) {
|
||||
struct iovec iov;
|
||||
|
||||
LoadFileFromRom(&iov, &ITEM_P_BIN, 1);
|
||||
HandleSir0Translation(&ITEM_DATA_TABLE_PTRS.data, iov.iov_base);
|
||||
LoadFileFromRom(&iov, &ITEM_S_P_BIN, 1);
|
||||
HandleSir0Translation(&ITEM_DATA_TABLE_PTRS.exclusive_data, iov.iov_base);
|
||||
if (PointsToZero(&ITEM_DATA_TABLE_PTRS.langFile) != 0) {
|
||||
ZInit8(&ITEM_DATA_TABLE_PTRS.langFile);
|
||||
#ifdef EUROPE
|
||||
char buf[256];
|
||||
SprintfStatic(buf, &ITEM_ST_I2N_BIN, ITEM_LANG_FILE_ARRAY[GetLanguage()]);
|
||||
LoadFileFromRom(&ITEM_DATA_TABLE_PTRS.langFile, buf, 1);
|
||||
#else
|
||||
LoadFileFromRom(&ITEM_DATA_TABLE_PTRS.langFile, &ITEM_ST_I2N_BIN, 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EUROPE
|
||||
static void SprintfStatic(char* buf, const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(buf, fmt, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
u8 GetExclusiveItemType(s16 item_id) {
|
||||
item_id = GetExclusiveItemOffsetEnsureValid(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.exclusive_data[item_id].type;
|
||||
}
|
||||
|
||||
static 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)
|
||||
if (ITEM_DATA_TABLE_PTRS.data[item_id].flags & ITEM_DATA_FLAG_VALID)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s16 GetExclusiveItemParameter(s16 item_id) {
|
||||
item_id = GetExclusiveItemOffsetEnsureValid(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.exclusive_data[item_id].unk2;
|
||||
}
|
||||
|
||||
enum item_category GetItemCategory(s16 item_id)
|
||||
{
|
||||
s16 valid_item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[valid_item_id].category;
|
||||
}
|
||||
|
||||
static s16 EnsureValidItem(s16 item_id)
|
||||
{
|
||||
if (item_id <= 0 || item_id >= NUM_ITEM_IDS)
|
||||
return ITEM_PLAIN_SEED;
|
||||
|
||||
if (!IsItemValid(item_id))
|
||||
return ITEM_PLAIN_SEED;
|
||||
|
||||
return item_id;
|
||||
}
|
||||
|
||||
u8* GetItemName(s16 item_id) {
|
||||
u32 valid_item_id = EnsureValidItem(item_id);
|
||||
return StringFromId((u16)(valid_item_id + ITEM_NAME_OFFSET));
|
||||
}
|
||||
|
||||
void GetItemNameFormatted(char* name, s16 item_id, s32 flag1, s32 flag2)
|
||||
{
|
||||
enum item_category category;
|
||||
|
||||
u8* raw_name = StringFromId((u16) (EnsureValidItem(item_id) + ITEM_NAME_OFFSET));
|
||||
|
||||
category = ITEM_DATA_TABLE_PTRS.data[EnsureValidItem(item_id)].category;
|
||||
if ((flag2 != 0) || ((u8)(category + 0xF4) <= 2)) {
|
||||
if (flag1 != 0) {
|
||||
SprintfStatic(name, &ITEM_NAME_FORMAT_YELLOW, raw_name);
|
||||
return;
|
||||
}
|
||||
strcpy(name, raw_name);
|
||||
return;
|
||||
}
|
||||
if (category == CATEGORY_EXCLUSIVE_ITEMS) {
|
||||
if (flag1 != 0) {
|
||||
SprintfStatic(name, &ITEM_NAME_FORMAT_INDIGO, raw_name);
|
||||
return;
|
||||
}
|
||||
SprintfStatic(name, &ITEM_NAME_FORMAT_PLAIN, raw_name);
|
||||
return;
|
||||
}
|
||||
if (flag1 != 0) {
|
||||
SprintfStatic(name, &ITEM_NAME_FORMAT_CREAM, raw_name);
|
||||
return;
|
||||
|
||||
}
|
||||
SprintfStatic(name, &ITEM_NAME_FORMAT_PLAIN, raw_name);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef EUROPE
|
||||
static void SprintfStatic(char* buf, const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(buf, fmt, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
u16 GetItemBuyPrice(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].buy_price;
|
||||
}
|
||||
|
||||
u16 GetItemSellPrice(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].sell_price;
|
||||
}
|
||||
|
||||
u8 GetItemSpriteId(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].sprite_id;
|
||||
}
|
||||
|
||||
u8 GetItemPaletteId(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].palette_id;
|
||||
}
|
||||
|
||||
u8 GetItemActionName(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].action_name;
|
||||
}
|
||||
|
||||
u8 GetThrownItemQuantityLimit(s16 item_id, u8 arg1)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].quantity_limit[arg1];
|
||||
}
|
||||
|
||||
s16 GetItemMoveId(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS.data[item_id].move_id;
|
||||
}
|
||||
|
||||
bool8 TestItemAiFlag(s16 item_id, s32 flag)
|
||||
{
|
||||
if (flag == 0)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
if (ITEM_DATA_TABLE_PTRS.data[item_id].flags & ITEM_DATA_FLAG_THROWABLE_AT_ENEMY)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flag == 1)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
if (ITEM_DATA_TABLE_PTRS.data[item_id].flags & ITEM_DATA_FLAG_THROWABLE_AT_ALLY)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
item_id = EnsureValidItem(item_id);
|
||||
if (ITEM_DATA_TABLE_PTRS.data[item_id].flags & ITEM_DATA_FLAG_CONSUMABLE)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,162 +0,0 @@
|
|||
#include "debug.h"
|
||||
#include "item_util_2.h"
|
||||
#include "item_util_1.h"
|
||||
#include "main_0202593C.h"
|
||||
|
||||
extern struct item_data_entry *ITEM_DATA_TABLE_PTRS[3];
|
||||
extern const char ITEM_NAME_FORMAT_YELLOW;
|
||||
extern const char ITEM_NAME_FORMAT_INDIGO;
|
||||
extern const char ITEM_NAME_FORMAT_PLAIN;
|
||||
extern const char ITEM_NAME_FORMAT_CREAM;
|
||||
|
||||
extern char* SprintfStatic__0200E808_EU(char*, const char*, ...);
|
||||
extern u8* strcpy(u8*, u8*);
|
||||
extern s32 vsprintf(u8* str, const u8* format, va_list ap);
|
||||
|
||||
static void SprintfStatic(char*, const char*, ...);
|
||||
|
||||
enum item_category GetItemCategory(s16 item_id)
|
||||
{
|
||||
s16 valid_item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][valid_item_id].category;
|
||||
}
|
||||
|
||||
s16 EnsureValidItem(s16 item_id)
|
||||
{
|
||||
if (item_id <= 0 || item_id >= NUM_ITEM_IDS)
|
||||
return ITEM_PLAIN_SEED;
|
||||
|
||||
if (!IsItemValid(item_id))
|
||||
return ITEM_PLAIN_SEED;
|
||||
|
||||
return item_id;
|
||||
}
|
||||
|
||||
u8* GetItemName(s16 item_id) {
|
||||
u32 valid_item_id = EnsureValidItem(item_id);
|
||||
#ifdef EUROPE
|
||||
return StringFromId((u16)(valid_item_id + 0x1A78));
|
||||
#elif JAPAN
|
||||
return StringFromId((u16)(valid_item_id + 0x0D93));
|
||||
#else
|
||||
return StringFromId((u16)(valid_item_id + 0x1A76));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef EUROPE
|
||||
#define GET_ITEM_NAME_FORMATTED_SPRINTF SprintfStatic__0200E808_EU
|
||||
#else
|
||||
#define GET_ITEM_NAME_FORMATTED_SPRINTF SprintfStatic
|
||||
#endif
|
||||
void GetItemNameFormatted(char* name, s16 item_id, s32 flag1, s32 flag2)
|
||||
{
|
||||
enum item_category category;
|
||||
|
||||
#ifdef EUROPE
|
||||
u8* raw_name = StringFromId((u16) (EnsureValidItem(item_id) + 0x1A78));
|
||||
#elif JAPAN
|
||||
u8* raw_name = StringFromId((u16) (EnsureValidItem(item_id) + 0x0D93));
|
||||
#else
|
||||
u8* raw_name = StringFromId((u16) (EnsureValidItem(item_id) + 0x1A76));
|
||||
#endif
|
||||
|
||||
category = ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][EnsureValidItem(item_id)].category;
|
||||
if ((flag2 != 0) || ((u8)(category + 0xF4) <= 2)) {
|
||||
if (flag1 != 0) {
|
||||
GET_ITEM_NAME_FORMATTED_SPRINTF(name, &ITEM_NAME_FORMAT_YELLOW, raw_name);
|
||||
return;
|
||||
}
|
||||
strcpy(name, raw_name);
|
||||
return;
|
||||
}
|
||||
if (category == CATEGORY_EXCLUSIVE_ITEMS) {
|
||||
if (flag1 != 0) {
|
||||
GET_ITEM_NAME_FORMATTED_SPRINTF(name, &ITEM_NAME_FORMAT_INDIGO, raw_name);
|
||||
return;
|
||||
}
|
||||
GET_ITEM_NAME_FORMATTED_SPRINTF(name, &ITEM_NAME_FORMAT_PLAIN, raw_name);
|
||||
return;
|
||||
}
|
||||
if (flag1 != 0) {
|
||||
GET_ITEM_NAME_FORMATTED_SPRINTF(name, &ITEM_NAME_FORMAT_CREAM, raw_name);
|
||||
return;
|
||||
|
||||
}
|
||||
GET_ITEM_NAME_FORMATTED_SPRINTF(name, &ITEM_NAME_FORMAT_PLAIN, raw_name);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef EUROPE
|
||||
static void SprintfStatic(char* buf, const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(buf, fmt, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
u16 GetItemBuyPrice(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].buy_price;
|
||||
}
|
||||
|
||||
u16 GetItemSellPrice(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].sell_price;
|
||||
}
|
||||
|
||||
u8 GetItemSpriteId(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].sprite_id;
|
||||
}
|
||||
|
||||
u8 GetItemPaletteId(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].palette_id;
|
||||
}
|
||||
|
||||
u8 GetItemActionName(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].action_name;
|
||||
}
|
||||
|
||||
u8 GetThrownItemQuantityLimit(s16 item_id, u8 arg1)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].quantity_limit[arg1];
|
||||
}
|
||||
|
||||
s16 GetItemMoveId(s16 item_id)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
return ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].move_id;
|
||||
}
|
||||
|
||||
bool8 TestItemAiFlag(s16 item_id, s32 flag)
|
||||
{
|
||||
if (flag == 0)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
if (ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].flags & ITEM_DATA_FLAG_THROWABLE_AT_ENEMY)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flag == 1)
|
||||
{
|
||||
item_id = EnsureValidItem(item_id);
|
||||
if (ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].flags & ITEM_DATA_FLAG_THROWABLE_AT_ALLY)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
item_id = EnsureValidItem(item_id);
|
||||
if (ITEM_DATA_TABLE_PTRS[ITEM_DATA_TABLE_PTRS_INDEX][item_id].flags & ITEM_DATA_FLAG_CONSUMABLE)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
#include "dungeon_util_static.h"
|
||||
#include "item.h"
|
||||
#include "item_util.h"
|
||||
#include "item_util_2.h"
|
||||
#include "item_util_1.h"
|
||||
|
||||
extern s16 RandRangeSafe(s32, s32);
|
||||
extern s16 _020A18BC[10];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user