diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 58dfe84e..1023603e 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -559,6 +559,10 @@ ac_npc_curator.c: .text: [0x8054B06C, 0x8054CF28] .rodata: [0x806495B0, 0x806495B8] .data: [0x806A4FB0, 0x806A5530] +ac_npc_rtc.c: + .text: [0x80573044, 0x80574134] + .rodata: [0x80649A08, 0x80649A40] + .data: [0x806BF648,0x806BF788] ac_douzou.c: .text: [0x805AD6D8, 0x805AE704] .rodata: [0x8064A7C0, 0x8064A7E8] diff --git a/include/ac_nameplate.h b/include/ac_nameplate.h index 60908453..03796e5c 100644 --- a/include/ac_nameplate.h +++ b/include/ac_nameplate.h @@ -12,7 +12,7 @@ extern ACTOR_PROFILE Nameplate_Profile; typedef struct nameplate_actor_s{ ACTOR actor_class; - u8 pad[0x2D8 - 0x170]; + u8 pad[0x2D8 - 0x170]; }NAMEPLATE_ACTOR; #ifdef __cplusplus diff --git a/include/ac_npc.h b/include/ac_npc.h index 7e1405df..4b057324 100644 --- a/include/ac_npc.h +++ b/include/ac_npc.h @@ -35,7 +35,7 @@ enum { aNPC_ATTENTION_TYPE_NUM }; - + enum { aNPC_THINK_WAIT, aNPC_THINK_WANDER, @@ -136,12 +136,25 @@ typedef struct npc_info_s { /* TODO: draw data */ typedef struct npc_draw_info_s { - /* 0x000 */ u8 _000[0x584 - 0x000]; + /* 0x000 */ u8 _000[0x20 - 0]; + /* 0x020 */ f32 _20; + /* 0x024 */ f32 _24; + /* 0x024 */ u8 _028[0x534 - 0x028]; + /* 0x538 */ u8 _534; + /* 0x538 */ u8 _535; + /* 0x538 */ u8 _536; + /* 0x538 */ u8 _537; + /* 0x538 */ u8 _538; + /* 0x538 */ u8 _539; + /* 0x540 */ u8 _53A[0x580 - 0x53A]; + /* 0x580 */ int _580; /* 0x584 */ int texture_bank_idx; - /* 0x588 */ u8 _588[0x5BD - 0x588]; + /* 0x588 */ u8 _588[0x5BD - 0x588]; /* 0x5BD */ u8 _5BD; - /* 0x5BE */ u8 _5BE[0x630 - 0x5BE]; -} aNPC_draw_info_c; + /* 0x5BE */ u8 _5BE; + /* 0x5BE */ u8 _5BF[0x630 - 0x5BF]; +} aNPC_draw_info_c; + typedef void (*aNPC_THINK_PROC)(NPC_ACTOR*, GAME_PLAY*, int); diff --git a/include/ac_npc_rtc.h b/include/ac_npc_rtc.h index 258df63f..5f19b3eb 100644 --- a/include/ac_npc_rtc.h +++ b/include/ac_npc_rtc.h @@ -3,11 +3,30 @@ #include "types.h" #include "m_actor.h" +#include "ac_npc.h" #ifdef __cplusplus extern "C" { #endif +typedef struct actor_npc_rtc_s NPCRTC_ACTOR; + +typedef void (*aNPCRTC_SUB_PROC)(NPCRTC_ACTOR* rtc, GAME_PLAY* play); + +struct actor_npc_rtc_s{ + NPC_ACTOR npc_class; + int unk994; + int unk998; + aNPCRTC_SUB_PROC unk99C; + int unk9A0; + int unk9A4; + int unk9A8; + int unk9AC; + int unk9B0; + int unk9B4; + int unk9B8; +}; + extern ACTOR_PROFILE Npc_Rtc_Profile; #ifdef __cplusplus diff --git a/include/jaudio_NES/staff.h b/include/jaudio_NES/staff.h index dc78073b..d03ddaeb 100644 --- a/include/jaudio_NES/staff.h +++ b/include/jaudio_NES/staff.h @@ -7,6 +7,12 @@ extern "C" { #endif +typedef struct staff_roll_info_s{ + s16 unk0; + int unk4; + f64 unk8; +}StaffRoll; + extern void Na_GetStaffRollInfo(void*); #ifdef __cplusplus diff --git a/include/m_card.h b/include/m_card.h index 21860def..55b8403f 100644 --- a/include/m_card.h +++ b/include/m_card.h @@ -26,6 +26,8 @@ extern void mCD_InitAll(); extern void mCD_LoadLand(); extern void mCD_toNextLand(); +extern int mCD_EraseBrokenLand_bg(void*); +extern int mCD_card_format_bg(u8); #ifdef __cplusplus } #endif diff --git a/include/m_common_data.h b/include/m_common_data.h index e3c2a622..753c3505 100644 --- a/include/m_common_data.h +++ b/include/m_common_data.h @@ -296,7 +296,8 @@ typedef struct common_data_s { /* 0x02DB46 */ mCD_persistent_data_c travel_persistent_data; /* used for checking if travelling back to town */ /* 0x02DBA2 */ s16 island_weather; /* 0x02DBA4 */ s16 island_weather_intensity; - /* 0x02DBA6 */ u8 _2DBA6[0x2DBAC - 0x2DBA6]; + /* 0x02DBA6 */ s16 _2DBA6; + /* 0x02DBA8 */ u8 _2DBA8; /* 0X02DBAC */ int famicom_2DBAC; /* 0x02DBB0 */ s16 can_look_goki_count; /* 0x02DBB4 */ f32 rainbow_opacity; /* current opacity of rainbow (0.0f - 1.0f) */ diff --git a/include/m_play.h b/include/m_play.h index 2cb233e6..bef0a01b 100644 --- a/include/m_play.h +++ b/include/m_play.h @@ -70,7 +70,7 @@ struct game_play_s { /* 0x2318 */ fbdemo_fade color_fade; /* 0x2328 */ CollisionCheck_c collision_check; /* 0x23F8 */ DRAW_CHK_PROC draw_chk_proc; // only used by mikanbox actor - /* 0x23FC */ u32 fade_color_value; + /* 0x23FC */ rgba8888 fade_color_value; /* 0x2400 */ Scene_data_status_c* scene_data_status; /* 0x2404 */ u8 _2400[0x2600 - 0x2404]; }; diff --git a/m2ctx.py b/m2ctx.py new file mode 100755 index 00000000..43dd35e9 --- /dev/null +++ b/m2ctx.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 + +import argparse +import os +import sys +import subprocess +import tempfile + +script_dir = os.path.dirname(os.path.realpath(__file__)) +root_dir = os.path.abspath(os.path.join(script_dir, "..")) + +# Project-specific +CPP_FLAGS = [ + "-I.", + "-I include", + "-I /home/samalv/ac-decomp/headers/ultra/usr/include", + + "-D_LANGUAGE_C", + "-DF3DEX_GBI_2", + "-D__USE_ISOC99", + "-DNDEBUG", + "-D_FINALROM", + "-D_MIPS_SZLONG=32", + "-D__USE_ISOC99", + + "-DM2CTX", + "-DCC_CHECK=1" + "-DNON_MATCHING", + + "-ffreestanding", + "-std=gnu89", +] + +def import_c_file(in_file, version: str) -> str: + in_file = os.path.relpath(in_file, root_dir) + + cpp_command = ["gcc", "-E", "-P", "-undef", "-dM", *CPP_FLAGS, in_file] + cpp_command2 = ["gcc", "-E", "-P", "-undef", *CPP_FLAGS, in_file] + + with tempfile.NamedTemporaryFile(suffix=".c") as tmp: + stock_macros = subprocess.check_output(["gcc", "-E", "-P", "-undef", "-dM", tmp.name], cwd=root_dir, encoding="utf-8") + + out_text = "" + try: + out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") + out_text += subprocess.check_output(cpp_command2, cwd=root_dir, encoding="utf-8") + except subprocess.CalledProcessError: + print( + "Failed to preprocess input file, when running command:\n" + + " ".join(cpp_command), + file=sys.stderr, + ) + sys.exit(1) + + if not out_text: + print("Output is empty - aborting") + sys.exit(1) + + for line in stock_macros.strip().splitlines(): + out_text = out_text.replace(line + "\n", "") + return out_text + +def main(): + parser = argparse.ArgumentParser( + description="""Create a context file which can be used for m2c""" + ) + parser.add_argument( + "c_file", + help="""File from which to create context""", + ) + parser.add_argument("-v", "--version", help="Which version should be processed", default="us", choices=["us", "cn"]) + args = parser.parse_args() + + output = import_c_file(args.c_file, args.version) + + with open(os.path.join(root_dir, "ctx.c"), "w", encoding="UTF-8") as f: + f.write(output) + + +if __name__ == "__main__": + main() diff --git a/src/ac_nameplate.c b/src/ac_nameplate.c index 2849461e..381f8726 100644 --- a/src/ac_nameplate.c +++ b/src/ac_nameplate.c @@ -19,7 +19,7 @@ ACTOR_PROFILE Nameplate_Profile = { NONE_ACTOR_PROC, aNP_actor_init, NULL, - NULL, + NULL, }; static void aNP_set_talk_info(ACTOR* actor) { @@ -41,7 +41,7 @@ static void aNP_set_talk_info(ACTOR* actor) { } static void aNP_actor_move(ACTOR* actor, GAME_PLAY* play) { - PLAYER_ACTOR* player; + PLAYER_ACTOR* player; s16 player_angle; int angle; @@ -58,7 +58,7 @@ static void aNP_actor_move(ACTOR* actor, GAME_PLAY* play) { } extern void aNP_actor_init(ACTOR* actor, GAME* game) { - GAME_PLAY* play = (GAME_PLAY*)game; + GAME_PLAY* play = (GAME_PLAY*)game; mFI_SetFG_common(DUMMY_NAMEPLATE, actor->home.position, 0); aNP_actor_move(actor, play); diff --git a/src/ac_npc_rtc.c b/src/ac_npc_rtc.c new file mode 100644 index 00000000..cd19d9ff --- /dev/null +++ b/src/ac_npc_rtc.c @@ -0,0 +1,133 @@ +#include "ac_npc_rtc.h" +#include "m_name_table.h" +#include "m_common_data.h" +#include "m_player_lib.h" +#include "jaudio_NES/staff.h" +#include "m_msg.h" +#include "m_bgm.h" +#include "m_soncho.h" +#include "m_card.h" + +extern void aNRTC_actor_ct(ACTOR*, GAME*); +extern void aNRTC_actor_dt(ACTOR*, GAME*); +extern void aNRTC_actor_init(ACTOR*, GAME*); +extern void aNRTC_actor_save(ACTOR*, GAME*); + +ACTOR_PROFILE Npc_Rtc_Profile = { + mAc_PROFILE_NPC_RTC, + ACTOR_PART_NPC, + ACTOR_STATE_NONE, + SP_NPC_RTC, + ACTOR_OBJ_BANK_KEEP, + sizeof(NPCRTC_ACTOR), + aNRTC_actor_ct, + aNRTC_actor_dt, + aNRTC_actor_init, + mActor_NONE_PROC1, + aNRTC_actor_save, +}; + +extern void aNRTC_actor_move(ACTOR*, GAME*); +extern void aNRTC_actor_draw(ACTOR*, GAME*); + +extern int aNRTC_talk_init(ACTOR*, GAME*); +extern int aNRTC_talk_end_chk(ACTOR*, GAME*); + +extern void aNRTC_schedule_proc(NPC_ACTOR*, GAME_PLAY*, int); + +extern void aNRTC_talk_request(ACTOR* actor,GAME*); + +extern void aNRTC_change_talk_proc(NPCRTC_ACTOR* rtc, int idx); + +u8 aNRTC_sound_mode[] = {0x00,0x01,0x02,0x00}; +u8 aNRTC_voice_mode[] = {0x00,0x01,0x02,0x00}; + +void aNRTC_actor_ct(ACTOR* actor, GAME* game){ + static aNPC_ct_data_c ct_data = { + &aNRTC_actor_move, + &aNRTC_actor_draw, + 5, + mActor_NONE_PROC1, + &aNRTC_talk_init, + &aNRTC_talk_end_chk, + 0 + }; + + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + PLAYER_ACTOR* player; + xyz_t center; + xyz_t eye; + if(Common_Get(clip.npc_clip)->birth_check_proc(actor,game) == TRUE){ + rtc->npc_class.schedule.schedule_proc = aNRTC_schedule_proc; + Common_Get(clip.npc_clip)->ct_proc(actor,game,&ct_data); + actor->status_data.weight = MASSTYPE_IMMOVABLE; + mPlib_request_main_demo_wait_type1(play,0,NULL); + player = GET_PLAYER_ACTOR(play); + if(player != NULL){ + player->actor_class.state_bitfield |= 0x80; + } + + center.x = 100.0f; + center.y = 60.0f; + center.z = 60.0f; + + eye.x = 100.0f; + eye.y = 130.0f; + eye.z = 210.0f; + + Camera2_change_priority(play,0); + Camera2_request_main_lock(play, ¢er, &eye, 40.0f, 0, 100.0f, 400.0f, 5); + sAdo_SetOutMode(aNRTC_sound_mode[Save_Get(config.sound_mode)]); + sAdo_SetVoiceMode(aNRTC_voice_mode[Save_Get(config.voice_mode)]); + rtc->npc_class.condition_info.hide_request = 0; + rtc->npc_class.talk_info.default_act = 9; + rtc->npc_class.talk_info.melody_inst = 0; + rtc->unk9A0 = 0; + } +} + + +void aNRTC_actor_save(ACTOR* actor, GAME* game) { + Common_Get(clip.npc_clip)->save_proc(actor,game); +} + +void aNRTC_actor_dt(ACTOR* actor, GAME* game) { + Common_Get(clip.npc_clip)->dt_proc(actor,game); +} + +void aNRTC_actor_init(ACTOR* actor, GAME* game) { + Common_Get(clip.npc_clip)->init_proc(actor,game); +} + +void aNRTC_actor_move(ACTOR* actor, GAME* game){ + StaffRoll info; + f32 val = 0.5f; + u8 arm_flag = TRUE; + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + + + if(rtc->npc_class.draw._580 == 0x76){ + sAdos_GetStaffRollInfo(&info); + if(info.unk0 != 4){ + val = 0.0f; + arm_flag = FALSE; + rtc->npc_class.draw._24 = 1.0f + (64.0f * (f32)info.unk8); + } + } + + rtc->npc_class.draw._20 = val; + sAdos_TTKK_ARM(arm_flag); + Common_Get(clip.npc_clip)->move_proc(actor,game); + mSC_change_player_freeze(play); +} + + +void aNRTC_actor_draw(ACTOR* actor, GAME* game) { + Common_Get(clip.npc_clip)->draw_proc(actor,game); +} + +#include "../src/ac_npc_rtc_think.c.inc" + +#include "../src/ac_npc_rtc_talk.c.inc" \ No newline at end of file diff --git a/src/ac_npc_rtc_talk.c.inc b/src/ac_npc_rtc_talk.c.inc new file mode 100644 index 00000000..f5a40a98 --- /dev/null +++ b/src/ac_npc_rtc_talk.c.inc @@ -0,0 +1,340 @@ + +void aNRTC_set_slot_name(NPC_ACTOR* actor, int str_no) { + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + u8 name[16]; + + mString_Load_StringFromRom(name, sizeof(name), &rtc->npc_class.draw._539); + + mMsg_Set_free_str(mMsg_Get_base_window_p(),str_no, name, sizeof(name)); +} + + +void aNRTC_rtc_err(NPCRTC_ACTOR* rtc, GAME_PLAY*) { + int num; + + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == 1) { + num = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + switch (num) { + case 0: + aNRTC_change_talk_proc(rtc, 3); + break; + case 1: + rtc->unk9A8 = 1; + aNRTC_change_talk_proc(rtc, 10); + break; + } + } +} + + +void aNRTC_timer_open_msg_wait(NPCRTC_ACTOR* rtc, GAME_PLAY*) { + int order = mDemo_Get_OrderValue(4, 9); + + if (order == 1) { + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == 1) { + mDemo_Set_OrderValue(4, 9, 0); + aNRTC_change_talk_proc(rtc, 4); + mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); + } + } +} + +void aNRTC_timer_open_wait(NPCRTC_ACTOR* rtc, GAME_PLAY* play){ + Submenu* submenu = &play->submenu; + if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == 1) { + aNRTC_change_talk_proc(rtc, 5); + mSM_open_submenu(submenu, 3, 1, 0); + mMsg_request_main_appear_wait_type1(mMsg_Get_base_window_p()); + } +} + + +void aNRTC_timer_close_wait(NPCRTC_ACTOR* rtc, GAME_PLAY* play) { + if (play->submenu.flag == 0) { + if (mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == 1) { + mMsg_Set_ForceNext(mMsg_Get_base_window_p()); + rtc->unk9A8 = 2; + aNRTC_change_talk_proc(rtc, 0xA); + } + } +} + + +void aNRTC_delete_bf(NPCRTC_ACTOR* rtc, GAME_PLAY* play) { + int order = mDemo_Get_OrderValue(4, 9); + + if ((mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == 1) && (order != 0)) { + + mMsg_Set_LockContinue(mMsg_Get_base_window_p()); + aNRTC_change_talk_proc(rtc, 7); + } +} + + +void aNRTC_delete(NPCRTC_ACTOR* rtc, GAME_PLAY* play){ + mMsg_Window_c* window; + int card; + int card_ret; + + window = mMsg_Get_base_window_p(); + card_ret = mCD_EraseBrokenLand_bg(&card); + + switch(card_ret){ + case 0: + rtc->unk9A8 = 3; + mMsg_Set_continue_msg_num(window, 0x9DE); + break; + case 22: + case 2: + rtc->unk9A8 = 1; + mMsg_Set_continue_msg_num(window, 0x9DF); + break; + case 25: + return; + case 15: + rtc->unk9A8 = 3; + mMsg_Set_continue_msg_num(window, 0x9E1); + break; + default: + rtc->unk9A8 = 1; + mMsg_Set_continue_msg_num(window, 0x9DF); + break; + } + + if(card_ret != 0x19){ + mMsg_Unset_LockContinue(window); + aNRTC_change_talk_proc(rtc,10); + } +} + + +void aNRTC_format_chk(NPCRTC_ACTOR* rtc, GAME_PLAY* play) { + int num; + + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == 1) { + aNRTC_change_talk_proc(rtc, 0xA); + num = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + switch (num) { + case 0: + rtc->unk9A8 = 3; + break; + case 1: + rtc->unk9A8 = 2; + break; + case 2: + rtc->unk9A8 = 1; + break; + case 3: + rtc->unk9A8 = 3; + aNRTC_change_talk_proc(rtc, 9); + break; + } + } +} + +void aNRTC_format(NPCRTC_ACTOR* rtc, GAME_PLAY* play) { + int order; + mMsg_Window_c* window; + int card_ret; + + window = mMsg_Get_base_window_p(); + order = mDemo_Get_OrderValue(4, 9); + switch (order) { + case 1: + mDemo_Set_OrderValue(4, 9, 2); + mMsg_Set_LockContinue(window); + break; + case 2: + card_ret = mCD_card_format_bg(Common_Get(_2DBA8)); + switch (card_ret) { + case 1: + mMsg_Set_continue_msg_num(window, 0x9E9); + mMsg_Unset_LockContinue(window); + aNRTC_change_talk_proc(rtc, 0xA); + rtc->unk9A8 = 3; + mDemo_Set_OrderValue(4, 9, 0); + break; + case -1: + mMsg_Unset_LockContinue(window); + aNRTC_change_talk_proc(rtc, 0xA); + rtc->unk9A8 = 1; + mMsg_Set_continue_msg_num(window, 0x9E7); + mDemo_Set_OrderValue(4, 9, 0); + case 0: + break; + } + break; + } +} + + +void aNRTC_break_data(NPCRTC_ACTOR* rtc, GAME_PLAY* play) { + int num; + + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == 1) { + aNRTC_change_talk_proc(rtc, 0xA); + num = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + switch (num) { + case 0: + rtc->unk9A8 = 3; + break; + case 1: + aNRTC_change_talk_proc(rtc, 6); + break; + } + } +} + +void aNRTC_break_data_2(NPCRTC_ACTOR* rtc, GAME_PLAY* play) { + int num; + + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == 1) { + aNRTC_change_talk_proc(rtc, 0xA); + num = mChoice_Get_ChoseNum(mChoice_Get_base_window_p()); + switch (num) { + case 0: + rtc->unk9A8 = 3; + break; + case 1: + rtc->unk9A8 = 2; + break; + case 2: + rtc->unk9A8 = 1; + break; + case 3: + rtc->unk9A8 = 4; + break; + } + } +} + + + +void aNRTC_change_talk_proc(NPCRTC_ACTOR* rtc, int idx) { + static aNPCRTC_SUB_PROC process[] = { + aNRTC_break_data, aNRTC_break_data_2, aNRTC_rtc_err, aNRTC_timer_open_msg_wait, + aNRTC_timer_open_wait, aNRTC_timer_close_wait, aNRTC_delete_bf, aNRTC_delete, + aNRTC_format_chk, aNRTC_format, (aNPCRTC_SUB_PROC)none_proc1, + }; + rtc->unk994 = idx; + rtc->unk99C = process[idx]; +} + + +void aNRTC_set_talk_info_talk_request(){ + int msg; + + switch(Common_Get(save_error_type)){ + case 0: + msg = 0x9CC; + break; + case 2: + msg = 0x9D1; + break; + case 6: + msg = 0x9DA; + break; + case 7: + msg = 0x9D8; + break; + case 9: + msg = 0x9D4; + break; + case 1: + msg = 0x9E2; + break; + case 4: + msg = 0x9E4; + break; + case 3: + msg = 0x9E3; + break; + case 5: + msg = 0x9E5; + break; + case 8: + msg = 0x9E6; + break; + default: + msg = 0x9D4; + break; + } + mDemo_Set_msg_num(msg); + mDemo_Set_camera(1); +} + + +void aNRTC_talk_request(ACTOR* actor,GAME*) { + mDemo_Request(8, actor, aNRTC_set_talk_info_talk_request); +} + + +int aNRTC_talk_init(ACTOR* actor, GAME* game) { + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + + mDemo_Set_ListenAble(); + aNRTC_set_slot_name((NPC_ACTOR*)Common_Get(_2DBA8), 4); + switch (Common_Get(save_error_type)) { + case 0: + aNRTC_change_talk_proc(rtc, 2); + break; + case 2: + aNRTC_change_talk_proc(rtc, 0); + break; + case 5: + aNRTC_change_talk_proc(rtc, 8); + break; + default: + aNRTC_change_talk_proc(rtc, 1); + break; + } + rtc->npc_class.talk_info.talk_request_proc = mActor_NONE_PROC1; + mMsg_Get_base_window_p(); + mMsg_Set_idling_req(); + return 1; +} + + +int aNRTC_talk_end_chk(ACTOR* actor,GAME* game){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + int res = 0; + mMsg_Window_c* window; + + window = mMsg_Get_base_window_p(); + rtc->unk99C(rtc,play); + + if(mMsg_Check_idling_now(window) == 1){ + mMsg_request_main_disappear_wait_type1(window); + aNRTC_think_init_proc(&rtc->npc_class,play); + rtc->unk9A0 = 0; + res = 1; + rtc->unk9B4 = 0x32; + rtc->unk9B0 = 0x4B; + bzero(&play->fade_color_value, sizeof(rgba8888_t)); + } + else{ + int unk9AC; + unk9AC = rtc->unk9AC; + if ((mMsg_Check_MainNormal(mMsg_Get_base_window_p()) == 1) || (((mChoice_check_main_normal(mChoice_Get_base_window_p()) == 1) != 0))) { + unk9AC++; + if (unk9AC > 0x258) { + unk9AC = 0x258; + } + } else { + unk9AC = 0; + } + if (mDemo_Get_OrderValue(4, 0) == 0) { + if (unk9AC >= 0x258) { + if ( rtc->npc_class.draw._580 != 0x76) { + mDemo_Set_OrderValue(4, 0, 0xFF); + } + } else if (rtc->npc_class.draw._580 == 0x76) { + mDemo_Set_OrderValue(4, 0, 0xFD); + } + } + rtc->unk9AC = unk9AC; + } + return res; +} + diff --git a/src/ac_npc_rtc_think.c.inc b/src/ac_npc_rtc_think.c.inc new file mode 100644 index 00000000..6c75d8c2 --- /dev/null +++ b/src/ac_npc_rtc_think.c.inc @@ -0,0 +1,137 @@ + +void aNRTC_talk_request(ACTOR* actor,GAME*); + +void aNRTC_think_start(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + if(rtc->unk9B8 > 0){ + rtc->unk9B8--; + } + else{ + rtc->unk9A0 = 1; + rtc->npc_class.talk_info.talk_request_proc = aNRTC_talk_request; + rtc->npc_class.condition_info.demo_flg = 0x100; + } +} + +void aNRTC_think_title(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + + play->fb_wipe_type = 3; + play->fb_fade_type = 4; + mPlib_request_main_invade_type1(play); + Actor_info_save_actor(play); + rtc->unk9A8 = 5; +} +Door_data_c door_data = { + SCENE_PLAYERSELECT, + 4, + FALSE, + 0, + {100,0,120}, + EMPTY_NO, + 3, + {0,0,0} +}; + +void aNRTC_think_door(NPC_ACTOR* actor, GAME_PLAY* play) { + + if (sAdo_BgmFadeoutCheck() != 0) { + goto_other_scene(play, &door_data, 1); + Common_Set(transition.wipe_type,3); + } +} + +void aNRTC_think_check(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + if (sAdo_BgmFadeoutCheck() != 0) { + goto_other_scene(play, &door_data, 1); + mCD_ReCheckLoadLand(play); + Common_Set(transition.wipe_type,3); + rtc->unk9A8 = 5; + } +} + +void aNRTC_think_ipmenu(NPC_ACTOR* actor, GAME_PLAY* play) { + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + if (sAdo_BgmFadeoutCheck() != 0) { + HotResetIplMenu(); + rtc->unk9A8 = 5; + } +} + + +aNPC_SUB_PROC aNRTC_proc_table[] = { + aNRTC_think_start, + aNRTC_think_title, + aNRTC_think_door, + aNRTC_think_check, + aNRTC_think_ipmenu, + (aNPC_SUB_PROC)mActor_NONE_PROC1, +}; + +void aNRTC_think_main_proc(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + if(rtc->unk9B0 > 0){ + rtc->unk9B0--; + if(rtc->unk9B0 == 0){ + play->fade_color_value.c.a = -1; + } + else if(rtc->unk9B0 < 25){ + play->fade_color_value.c.a = 255.0f * (1.0f - (0.04f * rtc->unk9B0)); + } + } + else if(rtc->unk9A0 == 0){ + aNRTC_proc_table[rtc->unk9A8](actor,play); + } + if(rtc->unk9B4 == 0){ + if(rtc->unk9A8 == 1){ + mBGMPsComp_make_ps_wipe(0x21C2); + } else { + mBGMPsComp_make_ps_wipe(0x621C); + } + rtc->unk9B4 = -2; + } + else if(rtc->unk9B4 > 0){ + rtc->unk9B4--; + } +} + +void aNRTC_think_init_proc(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + rtc->npc_class.request.act_priority = 4; + rtc->npc_class.request.act_idx = 8; + rtc->npc_class.request.act_type = 0; +} + +void aNRTC_think_proc(NPC_ACTOR* actor, GAME_PLAY* play,int idx){ + static aNPC_SUB_PROC think_proc[] = { aNRTC_think_init_proc, aNRTC_think_main_proc,}; + + think_proc[idx](actor,play); +} + + +void aNRTC_schedule_init_proc(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + rtc->npc_class.draw._5BE = 1; + rtc->npc_class.talk_info.default_animation = 0x76; + rtc->unk9B4 = -1; + rtc->unk9B0 = 0; + rtc->unk9B8 = 0x5A; + rtc->npc_class.think.think_proc = aNRTC_think_proc; + rtc->unk9A8 = 0; + Common_Get(clip.npc_clip)->think_proc(actor,play,6,0); +} + +void aNRTC_schedule_main_proc(NPC_ACTOR* actor, GAME_PLAY* play){ + NPCRTC_ACTOR* rtc = (NPCRTC_ACTOR*)actor; + if(Common_Get(clip.npc_clip)->think_proc(actor,play,-1,1) == 0){ + Common_Get(clip.npc_clip)->think_proc(actor,play,-1,2); + } +} + + +void aNRTC_schedule_proc(NPC_ACTOR* actor, GAME_PLAY* play, int idx){ + static aNPC_SUB_PROC sche_proc[] = {aNRTC_schedule_init_proc,aNRTC_schedule_main_proc}; + + sche_proc[idx](actor,play); +} diff --git a/src/m_play.c b/src/m_play.c index b0265770..18913bf1 100644 --- a/src/m_play.c +++ b/src/m_play.c @@ -497,7 +497,7 @@ void play_init(GAME* game){ fbdemo_fade_setcolor_rgba8888(fade, 0xA0A0A0FF); fbdemo_fade_startup(fade); - play->fade_color_value = 0; + play->fade_color_value.rgba8888 = 0; freebytes = game_getFreeBytes(&play->game); alloc = (u32)THA_alloc16(&play->game.tha, freebytes); @@ -731,7 +731,7 @@ int makeBumpTexture(GAME_PLAY* play, GRAPH* graph1, GRAPH* graph2){ } fbdemo_fade_draw(&play->color_fade, &polydisp); - fade_rgba8888_draw(&polydisp, play->fade_color_value); + fade_rgba8888_draw(&polydisp, play->fade_color_value.rgba8888); gSPEndDisplayList(polydisp++); diff --git a/src/m_rcp.c b/src/m_rcp.c index 6e905fd2..a8dee82e 100644 --- a/src/m_rcp.c +++ b/src/m_rcp.c @@ -1,6 +1,7 @@ #include "m_rcp.h" #include "gfxalloc.h" +#include "libu64/u64types.h" #define G_CC_POLY_Z_LIGHT_PRIM PRIMITIVE, 0, SHADE, 0, 0, 0, 0, PRIMITIVE #define G_CC_MODULATEIDECALA_PRIM2 PRIMITIVE, 0, COMBINED, 0, 0, 0, 0, COMBINED