Implement & link m_name_table.c

This commit is contained in:
Cuyler36
2023-11-10 00:42:20 -05:00
parent bc97537820
commit 34586202d8
3 changed files with 404 additions and 113 deletions
+4
View File
@@ -186,6 +186,10 @@ m_mushroom.c:
.rodata: [0x80642950, 0x80642960]
.data: [0x8065A3F8, 0x8065A430]
.bss: [0x81298B40, 0x81298F60]
m_name_table.c:
.text: [0x803C90A8, 0x803C98EC]
.rodata: [0x80642960, 0x80642978]
.data: [0x8065A430, 0x8065ABC0]
m_needlework.c:
.text: [0x803C98EC, 0x803C9F7C]
.data: [0x8065ABC0, 0x8065AE30]
+2 -1
View File
@@ -3,6 +3,7 @@
#include "types.h"
#include "m_actor_type.h"
#include "m_collision_bg.h"
/* TODO: these defintions are likely included from an auto-gen source */
@@ -1746,11 +1747,11 @@ extern mActor_name_t mNT_FishIdx2FishItemNo(int idx);
#define NPC_END (NPC_START + 236)
#define DUMMY_START 0xF000
#define DUMMY_RESERVE 0xF0EE // unsure about this, only true in DnM
#define DUMMY_HANIWA0 0xF0FB
#define DUMMY_HANIWA1 (DUMMY_HANIWA0 + 1)
#define DUMMY_HANIWA2 (DUMMY_HANIWA1 + 1)
#define DUMMY_HANIWA3 (DUMMY_HANIWA2 + 1)
#define DUMMY_RESERVE 0xF102
#define DUMMY_RADIO 0xF109
#define DUMMY_TAMA 0xF110
#define DUMMY_DOUZOU 0xF11D
+398 -112
View File
@@ -2,6 +2,7 @@
#include "m_actor.h"
#include "m_npc_personal_id.h"
#include "m_common_data.h"
s16 move_obj_profile_table[] = {
mAc_PROFILE_AIRPLANE,
@@ -54,7 +55,7 @@ s16 props_profile_table[] = {
mAc_PROFILE_NAMEPLATE
};
u8 npc_looks_table[NPC_NUM] = {
u8 npc_looks_table[NPC_NUM + 2] = {
mNpc_LOOKS_BOY,
mNpc_LOOKS_NANIWA_LADY,
mNpc_LOOKS_GIRL,
@@ -616,7 +617,22 @@ static u8 item1_F_tableNo[] = {
extern int mNT_get_itemTableNo(mActor_name_t item) {
static u8* item1_tableNo[ITEM1_CAT_NUM] = {
item1_0_tableNo,
item1_1_tableNo,
item1_2_tableNo,
item1_3_tableNo,
item1_4_tableNo,
item1_5_tableNo,
item1_6_tableNo,
item1_7_tableNo,
item1_8_tableNo,
item1_9_tableNo,
item1_A_tableNo,
item1_B_tableNo,
item1_C_tableNo,
item1_D_tableNo,
item1_E_tableNo,
item1_F_tableNo
};
switch (ITEM_NAME_GET_TYPE(item)) {
@@ -638,15 +654,19 @@ extern int mNT_get_itemTableNo(mActor_name_t item) {
case NAME_TYPE_ITEM1:
{
return item1_tableNo[ITEM_NAME_GET_CAT(item)][ITEM_NAME_GET_INDEX(item)];
int category = ITEM_NAME_GET_CAT((mActor_name_t)item);
int idx = ITEM_NAME_GET_INDEX((mActor_name_t)item);
return item1_tableNo[category][idx];
}
}
return mNT_ITEM_TYPE_NONE;
default:
return mNT_ITEM_TYPE_NONE;
}
}
extern mActor_name_t mNT_FishIdx2FishItemNo(int idx) {
if (idx >= 0 && idx < (FISH_NUM + 2)) {
if (idx >= 0 && idx <= (FISH_NUM + 1)) {
return ITM_FISH_START + idx;
}
@@ -654,7 +674,6 @@ extern mActor_name_t mNT_FishIdx2FishItemNo(int idx) {
}
extern mActor_name_t bg_item_fg_sub(mActor_name_t item, s16 flag) {
// TODO: tree type enum
static mActor_name_t cnvfg[mNT_TREE_SIZE_NUM][mNT_TREE_TYPE_NUM] = {
{ TREE_STUMP004, TREE_PALM_STUMP004, CEDAR_TREE_STUMP004, GOLD_TREE_STUMP004 },
{ TREE_STUMP003, TREE_PALM_STUMP003, CEDAR_TREE_STUMP003, GOLD_TREE_STUMP003 },
@@ -662,119 +681,278 @@ extern mActor_name_t bg_item_fg_sub(mActor_name_t item, s16 flag) {
{ TREE_STUMP001, TREE_PALM_STUMP001, CEDAR_TREE_STUMP001, GOLD_TREE_STUMP001 }
};
int tree_type = FGTreeType_check(item);
mActor_name_t conv = item;
u32 what = item;
int tree_type = FGTreeType_check(what);
mActor_name_t stump = what;
if (flag == 0) {
if (
item == TREE ||
item == TREE_1000BELLS ||
item == TREE_10000BELLS ||
item == TREE_30000BELLS ||
item == TREE_100BELLS ||
item == CEDAR_TREE ||
item == GOLD_TREE_SHOVEL ||
item == GOLD_TREE ||
item == TREE_APPLE_NOFRUIT_0 ||
item == TREE_APPLE_NOFRUIT_1 ||
item == TREE_APPLE_NOFRUIT_2 ||
item == TREE_APPLE_FRUIT ||
item == TREE_ORANGE_NOFRUIT_0 ||
item == TREE_ORANGE_NOFRUIT_1 ||
item == TREE_ORANGE_NOFRUIT_2 ||
item == TREE_ORANGE_FRUIT ||
item == TREE_PEACH_NOFRUIT_0 ||
item == TREE_PEACH_NOFRUIT_1 ||
item == TREE_PEACH_NOFRUIT_2 ||
item == TREE_PEACH_FRUIT ||
item == TREE_PEAR_NOFRUIT_0 ||
item == TREE_PEAR_NOFRUIT_1 ||
item == TREE_PEAR_NOFRUIT_2 ||
item == TREE_PEAR_FRUIT ||
item == TREE_CHERRY_NOFRUIT_0 ||
item == TREE_CHERRY_NOFRUIT_1 ||
item == TREE_CHERRY_NOFRUIT_2 ||
item == TREE_CHERRY_FRUIT ||
item == TREE_PALM_NOFRUIT_0 ||
item == TREE_PALM_NOFRUIT_1 ||
item == TREE_PALM_NOFRUIT_2 ||
item == TREE_PALM_FRUIT ||
item == TREE_BEES ||
item == TREE_FTR ||
item == TREE_LIGHTS ||
item == TREE_PRESENT ||
item == TREE_BELLS ||
item == CEDAR_TREE_BELLS ||
item == CEDAR_TREE_FTR ||
item == CEDAR_TREE_BEES ||
item == CEDAR_TREE_LIGHTS ||
item == GOLD_TREE_BELLS ||
item == GOLD_TREE_FTR ||
item == GOLD_TREE_BEES
) {
conv = cnvfg[mNT_TREE_SIZE_FULL][tree_type];
if (flag != 0) {
stump = what;
}
else if (
item == TREE ||
item == TREE_1000BELLS ||
item == TREE_10000BELLS ||
item == TREE_30000BELLS ||
item == TREE_100BELLS ||
item == CEDAR_TREE ||
item == GOLD_TREE_SHOVEL ||
item == GOLD_TREE ||
item == TREE_APPLE_NOFRUIT_0 ||
item == TREE_APPLE_NOFRUIT_1 ||
item == TREE_APPLE_NOFRUIT_2 ||
item == TREE_APPLE_FRUIT ||
item == TREE_ORANGE_NOFRUIT_0 ||
item == TREE_ORANGE_NOFRUIT_1 ||
item == TREE_ORANGE_NOFRUIT_2 ||
item == TREE_ORANGE_FRUIT ||
item == TREE_PEACH_NOFRUIT_0 ||
item == TREE_PEACH_NOFRUIT_1 ||
item == TREE_PEACH_NOFRUIT_2 ||
item == TREE_PEACH_FRUIT ||
item == TREE_PEAR_NOFRUIT_0 ||
item == TREE_PEAR_NOFRUIT_1 ||
item == TREE_PEAR_NOFRUIT_2 ||
item == TREE_PEAR_FRUIT ||
item == TREE_CHERRY_NOFRUIT_0 ||
item == TREE_CHERRY_NOFRUIT_1 ||
item == TREE_CHERRY_NOFRUIT_2 ||
item == TREE_CHERRY_FRUIT ||
item == TREE_PALM_NOFRUIT_0 ||
item == TREE_PALM_NOFRUIT_1 ||
item == TREE_PALM_NOFRUIT_2 ||
item == TREE_PALM_FRUIT ||
item == TREE_BEES ||
item == TREE_FTR ||
item == TREE_LIGHTS ||
item == TREE_PRESENT ||
item == TREE_BELLS ||
item == CEDAR_TREE_BELLS ||
item == CEDAR_TREE_FTR ||
item == CEDAR_TREE_BEES ||
item == CEDAR_TREE_LIGHTS ||
item == GOLD_TREE_BELLS ||
item == GOLD_TREE_FTR ||
item == GOLD_TREE_BEES
) {
stump = cnvfg[mNT_TREE_SIZE_FULL][tree_type];
}
else if (
item == TREE_S2 ||
item == TREE_APPLE_S2 ||
item == TREE_ORANGE_S2 ||
item == TREE_PEACH_S2 ||
item == TREE_PEAR_S2 ||
item == TREE_CHERRY_S2 ||
item == TREE_1000BELLS_S2 ||
item == TREE_10000BELLS_S2 ||
item == TREE_30000BELLS_S2 ||
item == TREE_100BELLS_S2 ||
item == TREE_PALM_S2 ||
item == CEDAR_TREE_S2 ||
item == GOLD_TREE_S2
) {
stump = cnvfg[mNT_TREE_SIZE_S2][tree_type];
}
else if (
item == TREE_S1 ||
item == TREE_APPLE_S1 ||
item == TREE_ORANGE_S1 ||
item == TREE_PEACH_S1 ||
item == TREE_PEAR_S1 ||
item == TREE_CHERRY_S1 ||
item == TREE_1000BELLS_S1 ||
item == TREE_10000BELLS_S1 ||
item == TREE_30000BELLS_S1 ||
item == TREE_100BELLS_S1 ||
item == TREE_PALM_S1 ||
item == CEDAR_TREE_S1 ||
item == GOLD_TREE_S1
) {
stump = cnvfg[mNT_TREE_SIZE_S1][tree_type];
}
else if (
item == TREE_S0 ||
item == TREE_APPLE_S0 ||
item == TREE_ORANGE_S0 ||
item == TREE_PEACH_S0 ||
item == TREE_PEAR_S0 ||
item == TREE_CHERRY_S0 ||
item == TREE_1000BELLS_S0 ||
item == TREE_10000BELLS_S0 ||
item == TREE_30000BELLS_S0 ||
item == TREE_100BELLS_S0 ||
item == TREE_PALM_S0 ||
item == CEDAR_TREE_S0 ||
item == GOLD_TREE_S0
) {
stump = cnvfg[mNT_TREE_SIZE_S0][tree_type];
}
return stump;
}
extern mActor_name_t bg_item_fg_sub_tree_grow(mActor_name_t item, int past_days, int check_plant) {
static s16 grow_check[84][2] = {
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -4, mCoBG_PLANT3 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -4, mCoBG_PLANT3 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -4, mCoBG_PLANT3 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -4, mCoBG_PLANT3 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -4, mCoBG_PLANT3 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -4, mCoBG_PLANT3 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ -1, mCoBG_PLANT0 },
{ -1, mCoBG_PLANT1 },
{ -1, mCoBG_PLANT2 },
{ -1, mCoBG_PLANT3 },
{ 0, mCoBG_PLANT4 },
{ 0, mCoBG_PLANT4 }
};
int idx;
int i;
if (
(item >= TREE_SAPLING && item <= TREE_30000BELLS) ||
(item >= TREE_100BELLS_SAPLING && item <= TREE_PALM_FRUIT) ||
(item >= CEDAR_TREE_SAPLING && item <= CEDAR_TREE) ||
(item >= GOLD_TREE_SAPLING && item <= GOLD_TREE)
) {
if (item >= TREE_PALM_SAPLING && item <= TREE_PALM_FRUIT) {
idx = item - 0x0813;
}
else if (
item == TREE_S2 ||
item == TREE_APPLE_S2 ||
item == TREE_ORANGE_S2 ||
item == TREE_PEACH_S2 ||
item == TREE_PEAR_S2 ||
item == TREE_CHERRY_S2 ||
item == TREE_1000BELLS_S2 ||
item == TREE_10000BELLS_S2 ||
item == TREE_30000BELLS_S2 ||
item == TREE_100BELLS_S2 ||
item == TREE_PALM_S2 ||
item == CEDAR_TREE_S2 ||
item == GOLD_TREE_S2
) {
conv = cnvfg[mNT_TREE_SIZE_S2][tree_type];
else if (item >= CEDAR_TREE_SAPLING && item <= CEDAR_TREE) {
idx = item - 0x0814;
}
else if (
item == TREE_S1 ||
item == TREE_APPLE_S1 ||
item == TREE_ORANGE_S1 ||
item == TREE_PEACH_S1 ||
item == TREE_PEAR_S1 ||
item == TREE_CHERRY_S1 ||
item == TREE_1000BELLS_S1 ||
item == TREE_10000BELLS_S1 ||
item == TREE_30000BELLS_S1 ||
item == TREE_100BELLS_S1 ||
item == TREE_PALM_S1 ||
item == CEDAR_TREE_S1 ||
item == GOLD_TREE_S1
) {
conv = cnvfg[mNT_TREE_SIZE_S1][tree_type];
else if (item == GOLD_TREE || (item >= GOLD_TREE_SAPLING && item <= GOLD_TREE_SHOVEL)) {
idx = item - 0x0815;
}
else if (
item == TREE_S0 ||
item == TREE_APPLE_S0 ||
item == TREE_ORANGE_S0 ||
item == TREE_PEACH_S0 ||
item == TREE_PEAR_S0 ||
item == TREE_CHERRY_S0 ||
item == TREE_1000BELLS_S0 ||
item == TREE_10000BELLS_S0 ||
item == TREE_30000BELLS_S0 ||
item == TREE_100BELLS_S0 ||
item == TREE_PALM_S0 ||
item == CEDAR_TREE_S0 ||
item == GOLD_TREE_S0
) {
conv = cnvfg[mNT_TREE_SIZE_S0][tree_type];
else if (item >= TREE_100BELLS_SAPLING) {
idx = item - 0x0813;
}
else {
idx = item - 0x0800;
}
for (i = 0; i <= past_days; i++) {
int diff = -grow_check[idx][0];
if (grow_check[idx + diff][1] > check_plant) {
break;
}
idx += diff;
item += diff;
}
}
return conv;
return item;
}
extern mActor_name_t bg_item_fg_sub_dig2take_conv(mActor_name_t item) {
mActor_name_t dig_item;
dig_item = item;
if ((item >= BURIED_PITFALL_START) && (item <= BURIED_PITFALL_END)) {
dig_item = ITM_PITFALL;
}
if (item == SHINE_SPOT) {
f32 rng_val = RANDOM_F(100.0f);
f32 money_power = mPr_GetMoneyPower();
f32 max_bells_roll = 2.0f * (money_power / 40.0f); // 30k
f32 large_bells_roll = 10.0f * (money_power / 40.0f); // 10k
if ((rng_val <= max_bells_roll) || ((int)Common_Get(now_private)->destiny.type == mPr_DESTINY_MONEY_LUCK)) {
dig_item = ITM_MONEY_30000;
}
else if (rng_val <= (large_bells_roll + max_bells_roll)) {
dig_item = ITM_MONEY_10000;
}
else {
dig_item = ITM_MONEY_1000;
}
}
return dig_item;
}
static mNT_offset_table_c height_table[3] = {
{ 0, { 100, 0, 0, 0, 0, 0, 0 } },
{ 0, { mCoBG_ATTRIBUTE_WOOD, 4, 4, 4, 4, 4, 0 } },
{ 0, { mCoBG_ATTRIBUTE_WOOD, 7, 7, 7, 7, 7, 0 } },
};
extern mNT_offset_table_c* obj_hight_table_item0_nogrow(mActor_name_t item) {
static mNT_offset_table_c height_table[3] = {
};
mNT_offset_table_c* table = &height_table[0];
if (
@@ -795,9 +973,117 @@ extern mNT_offset_table_c* obj_hight_table_item0_nogrow(mActor_name_t item) {
table = &height_table[2];
}
return height_table;
return table;
}
extern mActor_name_t bg_item_fg_sub_tree_grow(mActor_name_t item, int past_days, int check_plant) {
extern int FGTreeType_check(mActor_name_t tree) {
if (
(tree >= TREE_PALM_SAPLING && tree <= TREE_PALM_FRUIT) ||
(tree == DEAD_PALM_SAPLING) ||
(tree >= TREE_PALM_STUMP001 && tree <= TREE_PALM_STUMP004)
) {
return mNT_TREE_TYPE_PALM;
}
if (
(tree >= CEDAR_TREE_SAPLING && tree <= CEDAR_TREE) ||
(tree == DEAD_CEDAR_SAPLING) ||
(tree == CEDAR_TREE_BELLS) ||
(tree == CEDAR_TREE_FTR) ||
(tree == CEDAR_TREE_BEES) ||
(tree == CEDAR_TREE_LIGHTS) ||
(tree >= CEDAR_TREE_STUMP001 && tree <= CEDAR_TREE_STUMP004)
) {
return mNT_TREE_TYPE_CEDAR;
}
if (
(tree == GOLD_TREE) ||
(tree >= GOLD_TREE_SAPLING && tree <= GOLD_TREE_SHOVEL) ||
(tree == DEAD_GOLD_SAPLING) ||
(tree == GOLD_TREE_BELLS) ||
(tree == GOLD_TREE_FTR) ||
(tree == GOLD_TREE_BEES) ||
(tree >= GOLD_TREE_STUMP001 && tree <= GOLD_TREE_STUMP004)
) {
return mNT_TREE_TYPE_GOLD;
}
return mNT_TREE_TYPE_NORMAL;
}
extern int mNT_ItIsStump(mActor_name_t actor) {
if (
(actor >= TREE_STUMP001 && actor <= TREE_STUMP004) ||
(actor >= TREE_PALM_STUMP001 && actor <= TREE_PALM_STUMP004) ||
(actor >= CEDAR_TREE_STUMP001 && actor <= CEDAR_TREE_STUMP004) ||
(actor >= GOLD_TREE_STUMP001 && actor <= GOLD_TREE_STUMP004)
) {
return TRUE;
}
return FALSE;
}
extern int mNT_ItIsStoneCoin10(mActor_name_t actor) {
int res = FALSE;
if ((actor >= MONEY_ROCK_A) && (actor <= MONEY_FLOWER_SEED)) {
res = TRUE;
}
return res != FALSE;
}
extern int mNT_ItIsReserveDummy(mActor_name_t actor) {
return actor == DUMMY_RESERVE;
}
extern int mNT_check_unknown(mActor_name_t item_no) {
static s16 item1_kinds[ITEM1_CAT_NUM] = {
PAPER_NUM,
MONEY_NUM,
TOOL_NUM,
FISH_NUM,
CLOTH_NUM,
ETC_NUM,
CARPET_NUM,
WALL_NUM,
FRUIT_NUM,
PLANT_NUM,
MINIDISK_NUM,
DIARY_NUM,
TICKET_NUM,
INSECT_NUM,
HUKUBUKURO_NUM,
KABU_NUM
};
int index = ITEM_NAME_GET_INDEX(item_no);
int res = FALSE;
switch (ITEM_NAME_GET_TYPE(item_no)) {
case NAME_TYPE_ITEM1:
{
int category = ITEM_NAME_GET_CAT(item_no);
if (index < 0 || index >= item1_kinds[category]) {
res = TRUE;
}
break;
}
case NAME_TYPE_FTR1:
{
int FtrIdx = mRmTp_FtrItemNo2FtrIdx(item_no);
if (FtrIdx < 0 || FtrIdx >= FTR_NUM) {
res = TRUE;
}
break;
}
}
return res;
}