diff --git a/config/GAFE01_00/config.yml b/config/GAFE01_00/config.yml index 065ec811..61ea385a 100644 --- a/config/GAFE01_00/config.yml +++ b/config/GAFE01_00/config.yml @@ -417,6 +417,16 @@ modules: header: assets/aBTD_island_ldr.inc header_type: raw + - symbol: aNNW_client_prg + binary: assets/aNNW_client_prg.bin + header: assets/aNNW_client_prg.inc + header_type: raw + + - symbol: aNNW_client_ldr + binary: assets/aNNW_client_ldr.bin + header: assets/aNNW_client_ldr.inc + header_type: raw + - symbol: mbg_v binary: assets/mbg_v.bin header: assets/mbg_v.inc diff --git a/include/ac_npc_needlework.h b/include/ac_npc_needlework.h index c8659069..b05feb84 100644 --- a/include/ac_npc_needlework.h +++ b/include/ac_npc_needlework.h @@ -3,11 +3,56 @@ #include "types.h" #include "m_actor.h" +#include "ac_npc.h" #ifdef __cplusplus extern "C" { #endif +#define aNNW_GBA_STATE_NOT_CONNECTED -1 +#define aNNW_GBA_STATE_TRANSMITTING 0 +#define aNNW_GBA_STATE_READY 1 +#define aNNW_GBA_STATE_EDITOR_READY 2 + +#define aNNW_DESIGN_PRICE 350 +#define aNNW_TALK_DAYS_MAX 10 + +enum { + aNNW_SISTER0, + aNNW_SISTER1, + + aNNW_SISTER_NUM +}; + +typedef struct npc_needlework_actor_s NPC_NEEDLEWORK_ACTOR; + +typedef void (*aNNW_THINK_PROC)(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play); + +struct npc_needlework_actor_s { + NPC_ACTOR npc_class; + aNNW_THINK_PROC think_proc; + f32 saved_keyframe_current; + u8 design_name[mNW_ORIGINAL_DESIGN_NAME_LEN]; + u8 proc_delay_frames; + u8 delay_frames; + u8 _9AE; + u8 think_idx; + u8 think_idx_after_talk; + u8 _9B1; + u8 talk_idx; + u8 _9B3; + u8 _9B4; + u8 buy_ut_idx; + u8 _9B5; + u8 my_proc_idx; + u8 pl_area; + u8 now_area; + u8 sister_state; + u8 _9BB; + u8 gba_ready; + u8 gba_wait_frames; +}; + extern ACTOR_PROFILE Npc_Needlework_Profile; #ifdef __cplusplus @@ -15,4 +60,3 @@ extern ACTOR_PROFILE Npc_Needlework_Profile; #endif #endif - diff --git a/src/actor/npc/ac_npc_needlework.c b/src/actor/npc/ac_npc_needlework.c new file mode 100644 index 00000000..60e68999 --- /dev/null +++ b/src/actor/npc/ac_npc_needlework.c @@ -0,0 +1,219 @@ +#include "ac_npc_needlework.h" + +#include "m_needlework.h" +#include "m_needlework_ovl.h" +#include "libultra/libultra.h" +#include "m_common_data.h" +#include "m_msg.h" +#include "m_font.h" +#include "m_eappli.h" +#include "m_player_lib.h" +#include "m_string.h" +#include "m_ledit_ovl.h" +#include "GBA2/gba2.h" + +enum { + aNNW_TALK_WHAT_HAPPEN_FIRST, + aNNW_TALK_WHAT_HAPPEN, + aNNW_TALK_OTHER_HAPPEN, + aNNW_TALK_OTHER_HAPPEN2, + aNNW_TALK_CHECK_LISTEN, + aNNW_TALK_LISTEN_SISTER, + aNNW_TALK_LISTEN_SISTER2, + aNNW_TALK_LISTEN_SISTER3, + aNNW_TALK_LISTEN_SISTER4, + aNNW_TALK_ANE_0, + aNNW_TALK_ANE_1, + aNNW_TALK_ANE_2, + aNNW_TALK_DESIGN_CHECK, + aNNW_TALK_DESIGN_WHICH, + aNNW_TALK_DESIGN_OPEN, + aNNW_TALK_DESIGN_CLOSE, + aNNW_TALK_DESIGN_CLOSE2, + aNNW_TALK_DESIGN_CLOSE2_END, + aNNW_TALK_DESIGN_WHICH2, + aNNW_TALK_DESIGN_OPEN3, + aNNW_TALK_DESIGN_CLOSE3, + aNNW_TALK_TRADE_CHECK, + aNNW_TALK_TRADE_WHICH, + aNNW_TALK_TRADE_OPEN, + aNNW_TALK_TRADE_CLOSE, + aNNW_TALK_GIVE_ADMISSION, + aNNW_TALK_TRADE_WHICH2, + aNNW_TALK_TRADE_OPEN2, + aNNW_TALK_TRADE_CLOSE2, + aNNW_TALK_GIVE_ADMISSION2, + aNNW_TALK_TRADE_WHICH3, + aNNW_TALK_TRADE_OPEN3, + aNNW_TALK_TRADE_CLOSE3, + aNNW_TALK_GBA_WHICH, + aNNW_TALK_GBA_TOOL_BF, + aNNW_TALK_GBA_TOOL, + aNNW_TALK_GBA_TOOL_0, + aNNW_TALK_GBA_TOOL_AF, + aNNW_TALK_GBA_TOOL_AF2, + aNNW_TALK_GBA_TOOL_AF3, + aNNW_TALK_GBA_LOAD_BF, + aNNW_TALK_GBA_LOAD, + aNNW_TALK_GBA_LOAD_CHECK, + aNNW_TALK_GBA_LOAD_AF, + aNNW_TALK_TREND_CLOTH, + aNNW_TALK_BYEBYE, + aNNW_TALK_EXIT, + aNNW_TALK_CLOTH_CHANGE, + aNNW_TALK_CLOTH_WAIT, + aNNW_TALK_CLOTH_CHANGE2, + aNNW_TALK_CLOTH_WAIT2, + aNNW_TALK_CLOTH_CHANGE3, + aNNW_TALK_CLOTH_WAIT3, + aNNW_TALK_CLOTH_CHANGE4, + aNNW_TALK_CLOTH_WAIT4, + aNNW_TALK_CPORIGINAL0, + aNNW_TALK_CPORIGINAL1, + aNNW_TALK_CPORIGINAL2, + aNNW_TALK_GBA_MENU0, + aNNW_TALK_GBA_MENU1, + aNNW_TALK_ANE_3, + aNNW_TALK_GBA_OVER_SAVE, + aNNW_TALK_GBA_TOOL_BF_2, + aNNW_TALK_GBA_TOOL_2, + aNNW_TALK_GBA_TOOL_AF3_2, + aNNW_TALK_END_WAIT, + aNNW_TALK_CARD_E_LOAD_BF_0_0, + aNNW_TALK_CARD_E_LOAD_BF_0, + aNNW_TALK_CARD_E_LOAD_BF_1, + aNNW_TALK_CARD_E_LOAD, + aNNW_TALK_CARD_E_MENU0, + aNNW_TALK_CARD_E_MENU1, + aNNW_TALK_CARD_E_MENU2, + aNNW_TALK_CARD_E_LOAD_PRG_BF_0, + aNNW_TALK_CARD_E_LOAD_PRG_BF_1, + aNNW_TALK_CARD_E_LOAD_PRG_0, + aNNW_TALK_CARD_E_LOAD_PRG_AF, + + aNNW_TALK_NUM +}; + +enum { + aNNW_THINK_NORMAL_WAIT, + aNNW_THINK_OMATIKUDASI, + aNNW_THINK_OMATIKUDASI2, + aNNW_THINK_MISIN_WAIT, + aNNW_THINK_AINOTE, + aNNW_THINK_AINOTE3, + aNNW_THINK_TURN, + + aNNW_THINK_NUM +}; + +enum { + aNNW_THINK_INIT_NONE, + aNNW_THINK_INIT_NORMAL_WAIT, + aNNW_THINK_INIT_MISIN_WAIT, + aNNW_THINK_INIT_AINOTE, + aNNW_THINK_INIT_NEXT, + aNNW_THINK_INIT_TURN, + + aNNW_THINK_INIT_NUM +}; + +static void aNNW_actor_ct(ACTOR* actorx, GAME* game); +static void aNNW_actor_dt(ACTOR* actorx, GAME* game); +static void aNNW_actor_init(ACTOR* actorx, GAME* game); +static void aNNW_actor_save(ACTOR* actorx, GAME* game); +static void aNNW_actor_move(ACTOR* actorx, GAME* game); +static void aNNW_actor_draw(ACTOR* actorx, GAME* game); +static BOOL aNNW_talk_init(ACTOR* actorx, GAME* game); +static BOOL aNNW_talk_end_chk(ACTOR* actorx, GAME* game); +static void aNNW_schedule_proc(NPC_ACTOR*, GAME_PLAY*, int); +static void aNNW_talk_request(ACTOR* actorx, GAME* game); +static void aNNW_change_talk_proc(NPC_NEEDLEWORK_ACTOR*, u8); +static void aNNW_change_talk_proc_next(NPC_NEEDLEWORK_ACTOR*); + +// clang-format off +ACTOR_PROFILE Npc_Needlework_Profile = { + mAc_PROFILE_NPC_NEEDLEWORK, + ACTOR_PART_NPC, + ACTOR_STATE_NONE, + SP_NPC_NEEDLEWORK0, + ACTOR_OBJ_BANK_KEEP, + sizeof(NPC_NEEDLEWORK_ACTOR), + aNNW_actor_ct, + aNNW_actor_dt, + aNNW_actor_init, + mActor_NONE_PROC1, + aNNW_actor_save +}; +// clang-format on + +static void aNNW_actor_ct(ACTOR* actorx, GAME* game) { + // clang-format off + static aNPC_ct_data_c ct_data = { + aNNW_actor_move, + aNNW_actor_draw, + aNPC_CT_SCHED_TYPE_SPECIAL, + (aNPC_TALK_REQUEST_PROC)none_proc1, + aNNW_talk_init, + aNNW_talk_end_chk, + 0 + }; + // clang-format on + + if (NPC_CLIP->birth_check_proc(actorx, game) == TRUE) { + NPC_NEEDLEWORK_ACTOR* actor = (NPC_NEEDLEWORK_ACTOR*)actorx; + + actor->npc_class.schedule.schedule_proc = aNNW_schedule_proc; + NPC_CLIP->ct_proc(actorx, game, &ct_data); + actor->npc_class.palActorIgnoreTimer = -1; + actor->_9B3 = 0; + actor->_9B4 = 0; + actor->proc_delay_frames = 0; + actor->delay_frames = 0; + actor->gba_ready = FALSE; + } +} + +static void aNNW_actor_save(ACTOR* actorx, GAME* game) { + mNpc_RenewalSetNpc(actorx); +} + +static void aNNW_actor_dt(ACTOR* actorx, GAME* game) { + NPC_CLIP->dt_proc(actorx, game); +} + +static void aNNW_actor_init(ACTOR* actorx, GAME* game) { + NPC_CLIP->init_proc(actorx, game); +} + +static int aNNW_set_request_act(NPC_NEEDLEWORK_ACTOR* actor, u8 priority, u8 act_idx, u8 act_type, u16 act_obj, s16 move_x, s16 move_z) { + int ret = FALSE; + + if (priority >= actor->npc_class.request.act_priority) { + u16 arg_data[aNPC_REQUEST_ARG_NUM]; + + bzero(arg_data, sizeof(arg_data)); + arg_data[0] = act_obj; + arg_data[2] = move_x; + arg_data[3] = move_z; + + actor->npc_class.request.act_priority = priority; + actor->npc_class.request.act_idx = act_idx; + actor->npc_class.request.act_type = act_type; + mem_copy((u8*)actor->npc_class.request.act_args, (u8*)arg_data, sizeof(arg_data)); + ret = TRUE; + } + + return ret; +} + +static void aNNW_actor_move(ACTOR* actorx, GAME* game) { + NPC_CLIP->move_proc(actorx, game); +} + +static void aNNW_actor_draw(ACTOR* actorx, GAME* game) { + NPC_CLIP->draw_proc(actorx, game); +} + +#include "../src/actor/npc/ac_npc_needlework_gba.c_inc" +#include "../src/actor/npc/ac_npc_needlework_talk.c_inc" +#include "../src/actor/npc/ac_npc_needlework_schedule.c_inc" diff --git a/src/actor/npc/ac_npc_needlework_gba.c_inc b/src/actor/npc/ac_npc_needlework_gba.c_inc new file mode 100644 index 00000000..25f50270 --- /dev/null +++ b/src/actor/npc/ac_npc_needlework_gba.c_inc @@ -0,0 +1,218 @@ +#define aNNW_CLIENT_PRG_SIZE 0xACC0 +#define aNNW_CLIENT_LDR_SIZE 0x8D20 + +#ifndef __INTELLISENSE__ +static u8 aNNW_client_prg[] = { +#include "assets/aNNW_client_prg.inc" +}; + +static u8 aNNW_client_ldr[] = { +#include "assets/aNNW_client_ldr.inc" +}; +#else +extern u8 aNNW_client_prg[]; +extern u8 aNNW_client_ldr[]; +#endif + +static u8 aNNW_trance_data[0x1100] ATTRIBUTE_ALIGN(32); + +static void aNNW_gba_init(void) { + mGcgba_Init(); +} + +static void aNNW_gba_trance_data_init(Submenu* submenu) { + mNW_original_design_c* design_p = Now_Private->my_org; + u8* my_org_no_table_p = Now_Private->my_org_no_table; + mNW_original_design_c* dst_p = (mNW_original_design_c*)aNNW_trance_data; + int i; + + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + int idx = mNW_get_image_no(submenu, i); + + bcopy(&design_p[idx], &dst_p[i], sizeof(mNW_original_design_c)); + mNW_GC_to_Agb_texture(design_p[idx].design.data, dst_p[i].design.data); + } +} + +static void aNNW_gba_trance_data_clear(void) { + mem_clear(aNNW_trance_data, sizeof(aNNW_trance_data), 0); +} + +static void aNNW_gba_open_submenu(Submenu* submenu) { + mSM_open_submenu_new(submenu, mSM_OVL_NEEDLEWORK, mNW_OPEN_GBA, 0, aNNW_trance_data); +} + +static void aNNW_gba_trance_data_end(void) { + u8 design[mNW_DESIGN_TEX_SIZE]; + mNW_original_design_c* design_p = (mNW_original_design_c*)aNNW_trance_data; + int i; + + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + mNW_AGB_to_GC_texture(design_p[i].design.data, design); + mNW_OverWriteOriginalTexture(&design_p[i], design); + } +} + +static int aNNW_check_GBA(u8* gba_connected_p) { + int status; + + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + status = mGcgba_ConnectEnabled(); + if (status == GBA2_GBA_STATE_SUCCESS) { + *gba_connected_p = FALSE; + return aNNW_GBA_STATE_READY; + } else if (status == GBA2_GBA_STATE_TRANSMITTING) { + return aNNW_GBA_STATE_TRANSMITTING; + } + + *gba_connected_p = FALSE; + return aNNW_GBA_STATE_NOT_CONNECTED; +} + +static int aNNW_mGcgba_boot(u8* gba_connected_p) { + int status; + + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + status = mGcgba_Boot(aNNW_client_ldr, aNNW_CLIENT_LDR_SIZE); + if (status != GBA2_GBA_STATE_TRANSMITTING) { + *gba_connected_p = FALSE; + } + + if (status == GBA2_GBA_STATE_TRANSMITTING) { + return aNNW_GBA_STATE_TRANSMITTING; + } else if (status == GBA2_GBA_STATE_SUCCESS) { + return aNNW_GBA_STATE_READY; + } else { + return aNNW_GBA_STATE_NOT_CONNECTED; + } +} + +static int aNNW_SendPrg(u8* gba_connected_p) { + int status; + + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + status = mGcgba_Send(aNNW_client_prg, aNNW_CLIENT_PRG_SIZE); + if (status != GBA2_GBA_STATE_TRANSMITTING) { + *gba_connected_p = FALSE; + } + + if (status == GBA2_GBA_STATE_SUCCESS) { + return aNNW_GBA_STATE_READY; + } else if (status == GBA2_GBA_STATE_TRANSMITTING) { + return aNNW_GBA_STATE_TRANSMITTING; + } else { + return aNNW_GBA_STATE_NOT_CONNECTED; + } +} + +static int aNNW_SendData(u8* gba_connected_p) { + int status; + + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + status = mGcgba_Send(aNNW_trance_data, sizeof(aNNW_trance_data)); + if (status != GBA2_GBA_STATE_TRANSMITTING) { + *gba_connected_p = FALSE; + } + + if (status == GBA2_GBA_STATE_SUCCESS) { + return aNNW_GBA_STATE_READY; + } else if (status == GBA2_GBA_STATE_TRANSMITTING) { + return aNNW_GBA_STATE_TRANSMITTING; + } else { + return aNNW_GBA_STATE_NOT_CONNECTED; + } +} + +static int aNNW_RecvData(u8* gba_connected_p) { + int status; + + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + status = mGcgba_Recv(aNNW_trance_data, sizeof(aNNW_trance_data)); + if (status != GBA2_GBA_STATE_TRANSMITTING) { + *gba_connected_p = FALSE; + } + + if (status == GBA2_GBA_STATE_SUCCESS) { + return aNNW_GBA_STATE_READY; + } else if (status == GBA2_GBA_STATE_TRANSMITTING) { + return aNNW_GBA_STATE_TRANSMITTING; + } else { + return aNNW_GBA_STATE_NOT_CONNECTED; + } +} + +static int aNNW_IsEditor(u8* gba_connected_p) { + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + switch (mGcgba_IsEditor()) { + case GBA2_GBA_STATE_SUCCESS: + *gba_connected_p = FALSE; + return aNNW_GBA_STATE_READY; + case GBA2_GBA_STATE_ALREADY_EXIST: + *gba_connected_p = FALSE; + return aNNW_GBA_STATE_EDITOR_READY; + case GBA2_GBA_STATE_ERROR: + *gba_connected_p = FALSE; + return aNNW_GBA_STATE_NOT_CONNECTED; + } + + return aNNW_GBA_STATE_TRANSMITTING; +} + +static void aNNW_gba_open_submenu_card_e(Submenu* submenu) { + mSM_open_submenu_new(submenu, mSM_OVL_NEEDLEWORK, mNW_OPEN_CARD, 0, aNNW_trance_data); +} + +static void aNNW_Send_card_e(u8* gba_connected_p) { + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + mGcgba_send_eAppri(mEA_dl_carde_program_p(), mEA_dl_carde_program_size()); +} + +static int aNNW_RecvData_card_e(u8* gba_connected_p) { + int status; + + if (*gba_connected_p == FALSE) { + mGcgba_InitVar(); + *gba_connected_p = TRUE; + } + + status = mGcgba_Read(aNNW_trance_data, sizeof(mNW_original_design_c), GBA2_EAPPLI_TYPE_NEEDLEWORK); + if (status != GBA2_GBA_STATE_TRANSMITTING) { + *gba_connected_p = FALSE; + } + + if (status == GBA2_GBA_STATE_SUCCESS) { + return aNNW_GBA_STATE_READY; + } else if (status == GBA2_GBA_STATE_TRANSMITTING) { + return aNNW_GBA_STATE_TRANSMITTING; + } else { + return aNNW_GBA_STATE_NOT_CONNECTED; + } +} diff --git a/src/actor/npc/ac_npc_needlework_schedule.c_inc b/src/actor/npc/ac_npc_needlework_schedule.c_inc new file mode 100644 index 00000000..e69de29b diff --git a/src/actor/npc/ac_npc_needlework_talk.c_inc b/src/actor/npc/ac_npc_needlework_talk.c_inc new file mode 100644 index 00000000..c4910cde --- /dev/null +++ b/src/actor/npc/ac_npc_needlework_talk.c_inc @@ -0,0 +1,781 @@ +#define aNNW_SISTER_STORY_NOW_NUM 3 + +static u8 sister_story = 0; +static u8 sister_now = 0; + +// clang-format off +static u8 aNNW_message_table[24 * aNNW_SISTER_STORY_NOW_NUM] = { + 0x00, 0xFF, 0xFF, + 0x01, 0xFF, 0xFF, + 0x02, 0x20, 0x21, + 0x03, 0x22, 0x23, + 0x04, 0xFF, 0xFF, + 0x05, 0xFF, 0xFF, + 0x06, 0xFF, 0xFF, + 0x07, 0x24, 0xFF, + 0x08, 0xFF, 0xFF, + 0x09, 0x25, 0x26, + 0x0A, 0xFF, 0xFF, + 0x0B, 0xFF, 0xFF, + 0x0C, 0xFF, 0xFF, + 0x0D, 0x27, 0x28, + 0x0E, 0xFF, 0xFF, + 0x0F, 0x29, 0x2A, + 0x10, 0xFF, 0xFF, + 0x11, 0x2B, 0x2C, + 0x13, 0xFF, 0xFF, + 0x14, 0xFF, 0xFF, + 0x15, 0xFF, 0xFF, + 0x16, 0xFF, 0xFF, + 0x17, 0xFF, 0xFF, + 0x18, 0xFF, 0xFF, +}; +// clang-format on + +static u8 aNNW_story_first_table[4] = { 5, 9, 13, 17 }; +static u8 aNNW_story_other_table[4] = { 6, 10, 14, 18 }; +static int aNNW_string_table[4] = { 0x06CC, 0x06CB, 0x06CA, 0x06C9 }; + +static int aNNW_get_sister_message(void) { + int msg_no; + + if (sister_now >= aNNW_SISTER_STORY_NOW_NUM) { + msg_no = -1; + } else { + msg_no = 0x3012 + aNNW_message_table[sister_story * aNNW_SISTER_STORY_NOW_NUM + sister_now]; + } + + return msg_no; +} + +static void aNNW_day_day(void) { + lbRTC_time_c* time_p = Common_GetPointer(time.rtc_time); + mPr_day_day_c* day_day = &Now_Private->nw_visitor; + + if (Common_Get(player_no) != mPr_FOREIGNER && (time_p->year != day_day->last_date.year || time_p->month != day_day->last_date.month || time_p->day != day_day->last_date.day)) { + day_day->last_date.year = time_p->year; + day_day->last_date.month = time_p->month; + day_day->last_date.day = time_p->day; + + if (day_day->days < aNNW_TALK_DAYS_MAX) { + day_day->days++; + } + } +} + +static void aNNW_get_make_sister_message(void) { + int days; + int add_day; + lbRTC_time_c* time_p = Common_GetPointer(time.rtc_time); + mPr_day_day_c* day_day = &Now_Private->nw_visitor; + + sister_now = 0; + add_day = 0; + if (time_p->year != day_day->last_date.year || time_p->month != day_day->last_date.month || time_p->day != day_day->last_date.day) { + add_day = 1; + } + + days = day_day->days + add_day; + if (Common_Get(player_no) == mPr_FOREIGNER) { + days = 0; + } + + if (days < 4) { + sister_story = RANDOM(5); + } else if (days >= 8) { + sister_story = 21 + RANDOM(3); + } else if (add_day == 1) { + sister_story = aNNW_story_other_table[days - 4]; + } else { + sister_story = aNNW_story_other_table[days - 4] + RANDOM(3); + } +} + +static int aNNW_get_next_sister_message(void) { + if (sister_now >= (aNNW_SISTER_STORY_NOW_NUM - 1) || aNNW_message_table[sister_story * aNNW_SISTER_STORY_NOW_NUM + sister_now + 1] == 0xFF) { + return FALSE; + } + + return TRUE; +} + +static mActor_name_t aNNW_get_sister_name(mActor_name_t name) { + if (name == SP_NPC_NEEDLEWORK0) { + return SP_NPC_NEEDLEWORK1; + } else { + return SP_NPC_NEEDLEWORK0; + } +} + +static ACTOR* aNNW_search_sister(GAME_PLAY* play, NPC_NEEDLEWORK_ACTOR* actor) { + ACTOR* actorx = (ACTOR*)actor; + ACTOR* search; + + for (search = play->actor_info.list[ACTOR_PART_NPC].actor; search != NULL; search = search->next_actor) { + if (search->id == mAc_PROFILE_NPC_NEEDLEWORK && search != actorx) { + break; + } + } + + return search; +} + +static void aNNW_turn_player(NPC_NEEDLEWORK_ACTOR* actor) { + ACTOR* playerx = GET_PLAYER_ACTOR_NOW_ACTOR(); + + NPC_CLIP->set_dst_pos_proc((NPC_ACTOR*)actor, playerx->world.position.x, playerx->world.position.z); +} + +static int aNNW_trend_check_cloth(int cloth_idx) { + Animal_c* animals; + Animal_c* animal; + int i; + int count; + + for (i = 0, animals = Save_Get(animals), count = 0; i < ANIMAL_NUM_MAX; i++) { + animal = &animals[i]; + if (!mNpc_CheckFreeAnimalPersonalID(&animal->id) && animal->cloth == RSV_CLOTH) { + int idx = (animal->cloth_original_id & 3); + + if (idx == cloth_idx) { + count++; + } + } + } + + return count; +} + +static void aNNW_trend_delete_cloth(int cloth_idx) { + Animal_c* animals; + Animal_c* animal; + int i; + + for (i = 0, animals = Save_Get(animals); i < ANIMAL_NUM_MAX; i++) { + animal = &animals[i]; + if (!mNpc_CheckFreeAnimalPersonalID(&animal->id) && animal->cloth == RSV_CLOTH) { + int idx = (animal->cloth_original_id & 3); + + if (idx == cloth_idx) { + mNpc_SetDefAnimalCloth(animal); + } + } + } +} + +static int aNNW_trend_check_umbrella(int umbrella_idx) { + int idx; + Animal_c* animals; + Animal_c* animal; + int i; + int count; + + animals = Save_Get(animals); + i = 0; + count = 0; + idx = (umbrella_idx & 3) + UMBRELLA_NUM; + umbrella_idx += UMBRELLA_NUM; + + for (i; i < ANIMAL_NUM_MAX; i++) { + animal = &animals[i]; + if (!mNpc_CheckFreeAnimalPersonalID(&animal->id)) { + if (animal->umbrella_id == umbrella_idx || animal->umbrella_id == idx) { + count++; + } + } + } + + return count; +} + +static void aNNW_trend_delete_umbrella(int umbrella_idx) { + int idx; + Animal_c* animals; + Animal_c* animal; + int i; + + animals = Save_Get(animals); + i = 0; + idx = (umbrella_idx & 3) + UMBRELLA_NUM; + umbrella_idx += UMBRELLA_NUM; + + for (i; i < ANIMAL_NUM_MAX; i++) { + animal = &animals[i]; + if (!mNpc_CheckFreeAnimalPersonalID(&animal->id)) { + if (animal->umbrella_id == umbrella_idx || animal->umbrella_id == idx) { + mNpc_SetDefAnimalUmbrella(animal); + } + } + } +} + +static int aNNW_first_talk_check(u8 flag) { + return Common_Get(needlework_first_talk_flags) & flag; +} + +static void aNNW_first_talk_end(u8 flag) { + if (aNNW_first_talk_check(flag) == 0) { + Common_Get(needlework_first_talk_flags) |= flag; + } +} + +static void aNNW_set_trend_set_string(int trend_idx, int str_no) { + u8 str[mString_DEFAULT_STR_SIZE]; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + mString_Load_StringFromRom(str, sizeof(str), aNNW_string_table[trend_idx & 3]); + mMsg_Set_item_str(msg_p, mMsg_ITEM_STR2 + str_no, str, sizeof(str)); + mMsg_Set_item_str(msg_p, str_no, Save_Get(needlework).original_design[trend_idx & 7].name, sizeof(Save_Get(needlework).original_design[trend_idx & 7].name)); +} + +static void aNNW_set_trend_cloth_message(void) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int trend_count; + int trend; + int i; + + trend = RANDOM(mNW_CLOTH_DESIGN_NUM); + trend_count = 0; + for (i = 0; i < mNW_CLOTH_DESIGN_NUM; i++) { + int count = aNNW_trend_check_cloth(i); + + if (count > trend_count) { + trend_count = count; + trend = i; + } + } + + aNNW_set_trend_set_string(trend, mMsg_ITEM_STR0); + if (trend_count == 0) { + mMsg_Set_continue_msg_num(msg_p, 0x2FDC); + } else if (trend_count == 1) { + mMsg_Set_continue_msg_num(msg_p, 0x2FDB); + } else if (trend_count < 5) { + mMsg_Set_continue_msg_num(msg_p, 0x2FDA); + } else { + mMsg_Set_continue_msg_num(msg_p, 0x2FD9); + } +} + +static void aNNW_set_trend_umbrella_message(void) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int trend_count; + int trend; + int i; + + trend = mNW_CLOTH_DESIGN_NUM + RANDOM(mNW_UMBRELLA_DESIGN_NUM); + trend_count = 0; + for (i = mNW_CLOTH_DESIGN_NUM; i < (mNW_CLOTH_DESIGN_NUM + mNW_UMBRELLA_DESIGN_NUM); i++) { + int count = aNNW_trend_check_cloth(i); + + if (count > trend_count) { + trend_count = count; + trend = i; + } + } + + aNNW_set_trend_set_string(trend, mMsg_ITEM_STR1); + if (trend_count == 0) { + mMsg_Set_continue_msg_num(msg_p, 0x2FE0); + } else if (trend_count == 1) { + mMsg_Set_continue_msg_num(msg_p, 0x2FDF); + } else if (trend_count < 5) { + mMsg_Set_continue_msg_num(msg_p, 0x2FDE); + } else { + mMsg_Set_continue_msg_num(msg_p, 0x2FDD); + } +} + +static void aNNW_change_camera_priority_demo(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + ACTOR* sister_actor = aNNW_search_sister(play, actor); + ACTOR* actorx = (ACTOR*)actor; + + Camera2_request_main_needlework_talk(play, sister_actor, actorx, 6); + if (actorx->npc_id == SP_NPC_NEEDLEWORK0) { + NPC_CLIP->set_dst_pos_proc((NPC_ACTOR*)actor, sister_actor->world.position.x, sister_actor->world.position.z); + } +} + +static void aNNW_change_camera_return_demo(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + ACTOR* actorx = (ACTOR*)actor; + + Camera2_request_main_talk(play, GET_PLAYER_ACTOR_ACTOR(play), actorx, 6); + if (actorx->npc_id == SP_NPC_NEEDLEWORK0) { + aNNW_turn_player(actor); + } +} + +static void aNNW_set_6_ways(NPC_NEEDLEWORK_ACTOR* actor, mMsg_Window_c* msg_p, int chose_num) { + switch (chose_num) { + case mChoice_CHOICE0: + aNNW_change_talk_proc(actor, aNNW_TALK_DESIGN_CHECK); + break; + case mChoice_CHOICE1: + if (Common_Get(player_no) != mPr_FOREIGNER) { + aNNW_change_talk_proc(actor, aNNW_TALK_CPORIGINAL0); + } else { + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + mMsg_Set_continue_msg_num(msg_p, 0x2FEE); + } + break; + case mChoice_CHOICE2: + aNNW_set_trend_cloth_message(); + aNNW_change_talk_proc(actor, aNNW_TALK_TREND_CLOTH); + break; + case mChoice_CHOICE3: + aNNW_change_talk_proc(actor, aNNW_TALK_CHECK_LISTEN); + aNNW_first_talk_end(0x40); + break; + case mChoice_CHOICE4: + aNNW_change_talk_proc(actor, aNNW_TALK_OTHER_HAPPEN); + break; + case mChoice_CHOICE5: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } +} + +static void aNNW_set_5_ways(NPC_NEEDLEWORK_ACTOR* actor, int chose_num) { + switch (chose_num) { + case mChoice_CHOICE0: + aNNW_change_talk_proc(actor, aNNW_TALK_GBA_TOOL_BF); + break; + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_GBA_LOAD_BF); + break; + case mChoice_CHOICE2: + aNNW_change_talk_proc(actor, aNNW_TALK_CARD_E_LOAD_BF_0); + break; + case mChoice_CHOICE3: + aNNW_change_talk_proc(actor, aNNW_TALK_CARD_E_LOAD_PRG_BF_0); + break; + case mChoice_CHOICE4: + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + break; + default: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } +} + +static void aNNW_talk_what_happen_first(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + aNNW_set_6_ways(actor, msg_p, mChoice_GET_CHOSENUM()); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aNNW_talk_what_happen(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + aNNW_set_6_ways(actor, msg_p, mChoice_GET_CHOSENUM()); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aNNW_talk_other_happen(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + aNNW_set_5_ways(actor, mChoice_GET_CHOSENUM()); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aNNW_talk_other_happen2(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + switch (mChoice_GET_CHOSENUM()) { + case mChoice_CHOICE0: + if (Common_Get(player_no) != mPr_FOREIGNER) { + aNNW_change_talk_proc(actor, aNNW_TALK_CPORIGINAL0); + } else { + aNNW_change_talk_proc(actor, aNNW_TALK_OTHER_HAPPEN); + mMsg_Set_continue_msg_num(msg_p, 0x2FEE); + } + break; + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_GBA_WHICH); + break; + case mChoice_CHOICE2: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } + + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aNNW_talk_check_listen(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + switch (mChoice_GET_CHOSENUM()) { + case mChoice_CHOICE0: + aNNW_change_talk_proc(actor, aNNW_TALK_LISTEN_SISTER); + break; + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } + + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aNNW_talk_listen_sister(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + + if (order != 0) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aNNW_change_talk_proc_next(actor); + aNNW_change_camera_priority_demo(actor, play); + } +} + +static void aNNW_talk_listen_sister2(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + + if (order != 0) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + actor->npc_class.actor_class.npc_id = aNNW_get_sister_name(actor->npc_class.actor_class.npc_id); + aNNW_change_talk_proc_next(actor); + } +} + +static void aNNW_talk_listen_sister3(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + + if (order != 0) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + actor->npc_class.actor_class.npc_id = aNNW_get_sister_name(actor->npc_class.actor_class.npc_id); + aNNW_change_talk_proc_next(actor); + } +} + +static void aNNW_talk_listen_sister4(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + + if (order != 0) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + aNNW_change_camera_return_demo(actor, play); + } +} + +static void aNNW_talk_design_check(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + switch (mChoice_GET_CHOSENUM()) { + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + break; + case mChoice_CHOICE0: + if (mSP_money_check(aNNW_DESIGN_PRICE)) { + aNNW_change_talk_proc(actor, aNNW_TALK_DESIGN_WHICH); + } else { + mMsg_Set_continue_msg_num(msg_p, 0x2FE7); + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + } + break; + } + + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + } +} + +static void aNNW_talk_design_which(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + + if (order != 0 && mMsg_CHECK_MAINNORMALCONTINUE() == TRUE) { + mMsg_REQUEST_MAIN_DISAPPEAR_WAIT_TYPE1(); + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + aNNW_change_talk_proc(actor, actor->talk_idx + 1); + } +} + +static void aNNW_talk_design_open(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + if (mMsg_CHECK_MAIN_WAIT() == TRUE) { + Submenu* submenu = &play->submenu; + int open_type = mNW_OPEN_DESIGN; + + switch (actor->talk_idx) { + case aNNW_TALK_TRADE_OPEN: + open_type = mNW_OPEN_INV; + break; + case aNNW_TALK_TRADE_OPEN3: + open_type = mNW_OPEN_CPORIGINAL; + break; + } + + mSM_open_submenu_new2(submenu, mSM_OVL_NEEDLEWORK, 0, Common_Get(player_no), NULL, open_type); + aNNW_change_talk_proc(actor, actor->talk_idx + 1); + } +} + +static void aNNW_talk_design_close(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + Submenu* submenu = &play->submenu; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (!submenu->open_flag) { + Submenu_Item_c* sm_item_p = submenu->item_p; + + if (sm_item_p->item == RSV_NO) { + int slot = sm_item_p->slot_no; + + actor->_9AE = mNW_get_image_no(submenu, slot); + mSM_open_submenu(submenu, mSM_OVL_DESIGN, slot, 0); + aNNW_change_talk_proc(actor, aNNW_TALK_DESIGN_CLOSE2); + } else { + mMsg_ChangeMsgData(msg_p, 0x2FE9); + mMsg_Set_ForceNext(msg_p); + mMsg_request_main_appear_wait_type1(msg_p); + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + } + } +} + +static void aNNW_talk_design_close2(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + Submenu* submenu = &play->submenu; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (!submenu->open_flag) { + Submenu_Item_c* sm_item_p = submenu->item_p; + + if (sm_item_p->slot_no == 1) { + mMsg_ChangeMsgData(msg_p, 0x2FEA); + mMsg_Set_ForceNext(msg_p); + mMsg_request_main_appear_wait_type1(msg_p); + aNNW_change_talk_proc(actor, aNNW_TALK_DESIGN_CLOSE2_END); + } else { + mMsg_ChangeMsgData(msg_p, 0x2FE9); + mMsg_Set_ForceNext(msg_p); + mMsg_request_main_appear_wait_type1(msg_p); + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + } + } +} + +static void aNNW_talk_design_close2_end(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + if (mMsg_CHECK_NOT_SERIES_MAIN_WAIT() == TRUE) { + aNNW_change_talk_proc(actor, actor->talk_idx + 1); + } +} + +static void aNNW_talk_design_open3(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + if (mMsg_CHECK_MAIN_WAIT() == TRUE) { + Submenu* submenu = &play->submenu; + + mSM_open_submenu_new(submenu, mSM_OVL_LEDIT, mLE_TYPE_MYORIGINAL_NAME, 0, actor->design_name); + aNNW_change_talk_proc(actor, aNNW_TALK_DESIGN_CLOSE3); + } +} + +static void aNNW_talk_design_close3(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + Submenu* submenu = &play->submenu; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (!submenu->open_flag) { + u16 org_cloth_idx; + + mSP_get_sell_price(aNNW_DESIGN_PRICE); + mNW_OverWriteOriginalName(&Now_Private->my_org[actor->_9AE & 7], actor->design_name); + org_cloth_idx = (CLOTH_NUM + 1) + actor->_9AE; + if (org_cloth_idx == Now_Private->cloth.idx) { + aNNW_change_talk_proc(actor, aNNW_TALK_CLOTH_CHANGE2); + } else { + mMsg_ChangeMsgData(msg_p, 0x2FEB); + mMsg_Set_ForceNext(msg_p); + mMsg_request_main_appear_wait_type1(msg_p); + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + } + } +} + +static void aNNW_talk_trade_check(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + + switch (mChoice_GET_CHOSENUM()) { + case mChoice_CHOICE0: + aNNW_change_talk_proc(actor, aNNW_TALK_GIVE_ADMISSION); + break; + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_GIVE_ADMISSION2); + break; + case mChoice_CHOICE2: + aNNW_change_talk_proc(actor, aNNW_TALK_TRADE_WHICH); + break; + case mChoice_CHOICE3: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } + } +} + +static void aNNW_talk_trade_which(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + if (mMsg_CHECK_MAINNORMALCONTINUE() == TRUE) { + mMsg_REQUEST_MAIN_DISAPPEAR_WAIT_TYPE1(); + aNNW_change_talk_proc(actor, actor->talk_idx + 1); + } +} + +static void aNNW_talk_trade_close(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + Submenu* submenu = &play->submenu; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (!submenu->open_flag) { + Submenu_Item_c* sm_item_p = submenu->item_p; + + if (sm_item_p->item == RSV_NO) { + u16 org_idx; + u32 change_idx; + + actor->_9AE = mNW_get_image_no(submenu, sm_item_p->slot_no); + org_idx = (CLOTH_NUM + 1) + actor->_9AE; + switch (actor->talk_idx) { + case aNNW_TALK_TRADE_CLOSE: + mMsg_ChangeMsgData(msg_p, 0x2FFA); + change_idx = actor->buy_ut_idx; + if (change_idx < mNW_CLOTH_DESIGN_NUM) { + CLIP(needlework_indoor_clip)->request_exchange_cloth_data_proc(change_idx, actor->_9AE); + aNNW_trend_delete_cloth(actor->buy_ut_idx); + } else { + change_idx -= mNW_CLOTH_DESIGN_NUM; + CLIP(needlework_indoor_clip)->request_exchange_umb_data_proc(change_idx, actor->_9AE); + aNNW_trend_delete_umbrella(actor->buy_ut_idx - mNW_CLOTH_DESIGN_NUM); + } + break; + case aNNW_TALK_TRADE_CLOSE2: + mMsg_ChangeMsgData(msg_p, 0x2FF8); + change_idx = actor->buy_ut_idx; + if (change_idx < mNW_CLOTH_DESIGN_NUM) { + CLIP(needlework_indoor_clip)->request_copy_cloth_data_proc(change_idx & 3, &Now_Private->my_org[actor->_9AE & 7]); + aNNW_trend_delete_cloth(actor->buy_ut_idx); + } else { + change_idx -= mNW_CLOTH_DESIGN_NUM; + CLIP(needlework_indoor_clip)->request_copy_umb_data_proc(change_idx & 3, &Now_Private->my_org[actor->_9AE & 7]); + aNNW_trend_delete_umbrella(actor->buy_ut_idx - mNW_CLOTH_DESIGN_NUM); + } + break; + case aNNW_TALK_TRADE_CLOSE3: + mMsg_ChangeMsgData(msg_p, 0x2FF9); + bcopy(&Save_Get(needlework).original_design[actor->buy_ut_idx & 7], &Now_Private->my_org[actor->_9AE & 7], sizeof(mNW_original_design_c)); + break; + } + + if (actor->talk_idx != aNNW_TALK_TRADE_CLOSE2 && org_idx == Now_Private->cloth.idx) { + aNNW_change_talk_proc(actor, aNNW_TALK_CLOTH_CHANGE); + return; + } + } else { + mMsg_ChangeMsgData(msg_p, 0x2FF5); + } + mMsg_Set_ForceNext(msg_p); + mMsg_request_main_appear_wait_type1(msg_p); + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + } +} + +static void aNNW_talk_give_admission(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + + switch (mChoice_GET_CHOSENUM()) { + case mChoice_CHOICE0: + aNNW_change_talk_proc(actor, actor->talk_idx + 1); + break; + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_TRADE_WHICH); + break; + case mChoice_CHOICE2: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } + } +} + +static void aNNW_talk_gba_which(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + if (order != 0 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + + switch (mChoice_GET_CHOSENUM()) { + case mChoice_CHOICE0: + aNNW_change_talk_proc(actor, aNNW_TALK_GBA_TOOL_BF); + break; + case mChoice_CHOICE1: + aNNW_change_talk_proc(actor, aNNW_TALK_GBA_LOAD_BF); + break; + case mChoice_CHOICE2: + aNNW_change_talk_proc(actor, aNNW_TALK_CARD_E_LOAD_BF_0_0); + break; + case mChoice_CHOICE3: + aNNW_change_talk_proc(actor, aNNW_TALK_END_WAIT); + break; + } + } +} + +static void aNNW_talk_gba_tool_bf(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); // @unused + + if (order != 0 && mMsg_CHECK_MAINNORMALCONTINUE() == TRUE) { + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); + sAdo_SysLevStart(NA_SE_47); + mMsg_SET_LOCKCONTINUE(); + aNNW_change_talk_proc_next(actor); + aNNW_gba_init(); + aNNW_gba_trance_data_init(&play->submenu); + } +} + +static void aNNW_talk_gba_tool(NPC_NEEDLEWORK_ACTOR* actor, GAME_PLAY* play) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + + switch (aNNW_check_GBA(&actor->gba_ready)) { + case aNNW_GBA_STATE_TRANSMITTING: + break; + case aNNW_GBA_STATE_READY: + switch (actor->talk_idx) { + case aNNW_TALK_GBA_TOOL: + aNNW_change_talk_proc_next(actor); + break; + default: + aNNW_change_talk_proc_next(actor); + break; + } + break; + case aNNW_GBA_STATE_NOT_CONNECTED: + if (actor->gba_wait_frames < 5) { + actor->gba_wait_frames++; + } else { + sAdo_SysLevStop(NA_SE_47); + mMsg_UNSET_LOCKCONTINUE(); + mMsg_Set_continue_msg_num(msg_p, 0x3008); + aNNW_change_talk_proc(actor, aNNW_TALK_WHAT_HAPPEN); + mGcgba_EndComm(); + } + break; + } +}