From 2b9ed4a58d80024d0d9b7232e92ebf9ef6160bda Mon Sep 17 00:00:00 2001 From: emilybrooks Date: Mon, 11 Sep 2023 11:02:09 -0700 Subject: ac_toudai matched 12 functions, 2 non-equivalent (#65) * first commit * matched the gSegments thing * more progress * matched aTOU_actor_dt * matched aTOU_set_bgOffset and imported data * named everything * cleanup, work on draw functions * cleanup * review * Revert "review" This reverts commit 229788b68359cb9ff3c372639c767e4e08011d96. * format * removed change to ac_structure.h * temp changing data symbols * format * review * fix conflicts * fix season u32 thing --- src/code/game.c | 2 +- src/code/m_lights.c | 2 +- src/overlays/actors/ovl_Toudai/ac_toudai.c | 277 +++++++++++++++++++++-- src/overlays/actors/ovl_Toudai/ac_toudai.h | 20 +- src/overlays/gamestates/ovl_play/m_play.c | 2 +- src/overlays/submenu/submenu_ovl/m_submenu_ovl.c | 2 +- 6 files changed, 284 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/code/game.c b/src/code/game.c index aca7062..7767fc0 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -11,7 +11,7 @@ #include "padmgr.h" #include "69E2C0.h" #include "gfxalloc.h" -#include "6E0F50.h" +#include "m_rcp.h" #include "code_variables.h" #include "overlays/gamestates/ovl_play/m_play.h" #include "overlays/gamestates/ovl_famicom_emu/famicom_emu.h" diff --git a/src/code/m_lights.c b/src/code/m_lights.c index 172fba0..664d53b 100644 --- a/src/code/m_lights.c +++ b/src/code/m_lights.c @@ -4,7 +4,7 @@ #include "macros.h" #include "sys_matrix.h" #include "overlays/gamestates/ovl_play/m_play.h" -#include "6E0F50.h" +#include "m_rcp.h" extern Gfx D_400AA00[]; // point_light_init_model extern Gfx D_400AA40[]; // point_light_model diff --git a/src/overlays/actors/ovl_Toudai/ac_toudai.c b/src/overlays/actors/ovl_Toudai/ac_toudai.c index 93c09a6..db08c4d 100644 --- a/src/overlays/actors/ovl_Toudai/ac_toudai.c +++ b/src/overlays/actors/ovl_Toudai/ac_toudai.c @@ -2,13 +2,27 @@ #include "m_actor_dlftbls.h" #include "m_object.h" #include "overlays/gamestates/ovl_play/m_play.h" +#include "c_keyframe.h" +#include "m_field_info.h" +#include "m_collision_bg.h" +#include "m_rcp.h" +#include "m_lib.h" +#include "macros.h" +#include "code_variables.h" + +#define THIS ((Toudai*)thisx) void aTOU_actor_ct(Actor* thisx, Game_Play* game_play); void aTOU_actor_dt(Actor* thisx, Game_Play* game_play); void aTOU_actor_init(Actor* thisx, Game_Play* game_play); void aTOU_actor_draw(Actor* thisx, Game_Play* game_play); +void aTOU_set_bgOffset(Toudai* this, s32 heightTableIndex); +void aTOU_init(Toudai* this, struct Game_Play* game_play); +void aTOU_wait(Toudai* this, struct Game_Play* game_play); +void aTOU_lighting(Toudai* this, struct Game_Play* game_play); +void aTOU_lightout(Toudai* this, struct Game_Play* game_play); +void aTOU_setup_action(Toudai* this, s32 processIndex); -#if 0 ActorProfile Toudai_Profile = { /* */ ACTOR_TOUDAI, /* */ ACTOR_PART_0, @@ -22,32 +36,265 @@ ActorProfile Toudai_Profile = { /* */ aTOU_actor_draw, /* */ NULL, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/aTOU_actor_ct.s") +u8 aTOU_shadow_vtx_fix_flg_table[] = { 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00 }; + +extern Vtx obj_s_toudai_shadow_v[]; +extern Gfx obj_s_toudai_shadow_1_model[]; +ShadowData aTOU_shadow_data = { 20, aTOU_shadow_vtx_fix_flg_table, 60.0f, obj_s_toudai_shadow_v, + obj_s_toudai_shadow_1_model }; + +extern BaseSkeletonR cKF_bs_r_obj_s_toudai; +extern BaseSkeletonR cKF_bs_r_obj_w_toudai; +BaseSkeletonR* skl_324[] = { &cKF_bs_r_obj_s_toudai, &cKF_bs_r_obj_w_toudai }; + +void aTOU_actor_ct(Actor* thisx, Game_Play* game_play UNUSED) { + Toudai* this = THIS; + s32 type = (common_data.time.season == WINTER); + + gSegments[6] = OS_K0_TO_PHYSICAL(common_data.unk_10098->unk_AC(45)); + cKF_SkeletonInfo_R_ct(&this->skeletonInfo, skl_324[type], NULL, this->jointTable, this->morphTable); + aTOU_set_bgOffset(this, 1); + aTOU_setup_action(this, 0); + cKF_SkeletonInfo_R_play(&this->skeletonInfo); + this->actor.world.pos.x -= 20.0f; + this->actor.world.pos.z -= 20.0f; +} + +void aTOU_actor_dt(Actor* thisx, Game_Play* game_play UNUSED) { + Toudai* this = THIS; + + common_data.unk_10098->unk_A8(&common_data.unk_10098->unk_B0, 8, 45, thisx); + common_data.unk_10098->unk_A8(&common_data.unk_10098->unk_454, 9, 90, thisx); + common_data.unk_10098->unk_A8(&common_data.unk_10098->unk_86C, 8, 45, thisx); + cKF_SkeletonInfo_R_dt(&this->skeletonInfo); + thisx->world.pos.x += 20.0f; + thisx->world.pos.z += 20.0f; +} + +mCoBG_OffsetTable height_table_ct_360[] = { { 0x64, 16, 16, 16, 16, 16, 0 }, + { 0x64, 16, 16, 16, 16, 16, 0 }, + { 0x64, 16, 16, 16, 16, 16, 0 }, + { 0x64, 16, 16, 16, 16, 16, 0 } }; +mCoBG_OffsetTable* height_table_361[] = { height_table_ct_360, height_table_ct_360 }; +f32 addX_362[] = { -40.0f, 0.0f }; +f32 addZ_363[] = { -40.0f, 0.0f }; + +void aTOU_set_bgOffset(Toudai* this, s32 heightTableIndex) { + s32 i; + Vec3f pos; + mCoBG_OffsetTable* offsetTable = height_table_361[heightTableIndex]; + + for (i = 0; i < 2; i++) { + pos.z = addZ_363[i] + this->actor.home.pos.z; + pos.x = addX_362[0] + this->actor.home.pos.x; + mCoBG_SetPluss5PointOffset_file(pos, *offsetTable, "../ac_toudai_move.c_inc", 76); + offsetTable++; + pos.x = addX_362[1] + this->actor.home.pos.x; + mCoBG_SetPluss5PointOffset_file(pos, *offsetTable, "../ac_toudai_move.c_inc", 80); + offsetTable++; + } +} + +void aTOU_color_ctrl(Toudai* this) { + f32 var_fv0; + s32 frameTemp; + + if (this->unk2BC == 0) { + add_calc(&this->unk2C8, 0.0f, 0.3f, 100.0f, 1.0f); + add_calc(&this->unk2CC, 0.0f, 0.3f, 100.0f, 1.0f); + add_calc(&this->unk2D0, 0.0f, 0.1f, 100.0f, 1.0f); + return; + } + + frameTemp = this->unk1E8 - 51; + var_fv0 = (frameTemp < 0) ? 1.0f : -1.0f; + frameTemp = ABS(frameTemp); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/aTOU_actor_dt.s") + if (frameTemp == 0) { + this->unk2C8 = 220.0f; + this->unk2CC = 240.0f; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB488_jp.s") + } else if (frameTemp >= 40) { + add_calc(&this->unk2C8, 0.0f, 0.3f, 100.0f, 1.0f); + add_calc(&this->unk2CC, 0.0f, 0.3f, 100.0f, 1.0f); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB60C_jp.s") + } else if (frameTemp < 10) { + this->unk2C8 = this->unk2C8 + (9.0f * var_fv0); + this->unk2CC = this->unk2CC + (14.0f * var_fv0); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB81C_jp.s") + } else if (frameTemp < 30) { + this->unk2C8 = this->unk2C8 + (2.5f * var_fv0); + this->unk2CC = this->unk2CC + (4.5f * var_fv0); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB840_jp.s") + } else { + this->unk2C8 = this->unk2C8 + (8.0f * var_fv0); + this->unk2CC = this->unk2CC + var_fv0; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB894_jp.s") + add_calc(&this->unk2D0, 255.0f, 0.1f, 100.0f, 1.0f); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB8D8_jp.s") +void aTOU_init(Toudai* this, Game_Play* game_play UNUSED) { + aTOU_setup_action(this, 1); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB918_jp.s") +void aTOU_wait(Toudai* this, Game_Play* game_play UNUSED) { + if ((common_data.time.now_sec >= 0xFD20) || (common_data.time.now_sec < 0x4650)) { + this->unk2BC = 1; + this->skeletonInfo.frameControl.speed = 1.0f; + aTOU_setup_action(this, 2); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AAB9C8_jp.s") +void aTOU_lighting(Toudai* this, Game_Play* game_play UNUSED) { + if ((common_data.time.now_sec < 64800) && (common_data.time.now_sec >= 18000)) { + aTOU_setup_action(this, 3); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/aTOU_actor_init.s") +void aTOU_lightout(Toudai* this, Game_Play* game_play UNUSED) { + if (this->unk1E8 == 0x33) { + this->unk2BC = 0; + this->skeletonInfo.frameControl.speed = 0.0f; + aTOU_setup_action(this, 1); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AABAB8_jp.s") +extern BaseAnimationR cKF_ba_r_obj_s_toudai; +extern BaseAnimationR cKF_ba_r_obj_w_toudai; +BaseAnimationR* ani_484[] = { &cKF_ba_r_obj_s_toudai, &cKF_ba_r_obj_w_toudai }; +ToudaiActionFunc process_485[] = { aTOU_init, aTOU_wait, aTOU_lighting, aTOU_lightout }; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/func_80AABAD8_jp.s") +void aTOU_setup_action(Toudai* this, s32 processIndex) { + s32 type; + if (processIndex == 0) { + type = (common_data.time.season == WINTER); + cKF_SkeletonInfo_R_init(&this->skeletonInfo, this->skeletonInfo.skeleton, ani_484[type], 1.0f, 100.0f, 51.0f, + 0.0f, 0.0f, ANIMATION_REPEAT, NULL); + } + + this->unk2A0 = process_485[processIndex]; + this->unk2B4 = processIndex; +} + +void aTOU_actor_move(Actor* thisx, Game_Play* game_play) { + Toudai* this = THIS; + + gSegments[6] = OS_K0_TO_PHYSICAL(common_data.unk_10098->unk_AC(45)); + this->unk174 = cKF_SkeletonInfo_R_play(&this->skeletonInfo); + this->unk1E8 = this->skeletonInfo.frameControl.currentFrame; + this->unk2A0(this, game_play); + aTOU_color_ctrl(this); +} + +void aTOU_actor_init(Actor* thisx, Game_Play* game_play) { + Toudai* this = THIS; + + mFI_SetFG_common(61706, this->actor.home.pos, 0); + aTOU_actor_move(thisx, game_play); + this->actor.update = aTOU_actor_move; +} + +s32 aTOU_actor_draw_before(Game_Play* game_play UNUSED, SkeletonInfoR* skeletonInfo UNUSED, s32 jointIndex, + Gfx** dlist) { + // LIGHTHOUSE_JOINT_LIGHT + if (jointIndex == 4) { + *dlist = NULL; + } + return 1; +} + +extern Gfx obj_s_toudai_light_model[]; +extern Gfx obj_w_toudai_light_model[]; +Gfx* mdl_519[] = { obj_s_toudai_light_model, obj_w_toudai_light_model }; +Color_RGBA8 prmcol_520 = { 255, 255, 150, 120 }; + +#ifdef NON_EQUIVALENT +s32 aTOU_actor_draw_after(Game_Play* game_play, SkeletonInfoR* skeletonInfo, s32 jointIndex, Gfx** dlist, + u8* displayBufferFlag, Toudai* arg5, Vec3s* rotation, Vec3f* translation) { + s32 type; // sp24 + s32 object; // sp20 + s32 palette; // sp1C + GraphicsContext* temp_a3; + u8 var_a0; + Mtx* mtx; // sp18 + u32 temp_v1; + u32 temp; + Gfx* gfx; + + // LIGHTHOUSE_JOINT_LIGHT + if ((jointIndex == 4) && (arg5->unk2CC)) { + OPEN_DISPS(temp_a3); + mtx = _Matrix_to_Mtx_new(temp_a3); + if (mtx != NULL) { + type = (common_data.time.season == 3); + object = common_data.unk_10098->unk_AC(45); + palette = common_data.unk_10098->unk_450(90); + func_800BD5C0_jp(game_play->state.gfxCtx); + gfx = LIGHT_DISP; + gSPSegment(gfx++, 0x08, palette); + gSPSegment(gfx++, 0x06, object); + + temp = arg5->unk2C8; + var_a0 = arg5->unk2CC; + temp_v1 = arg5->unk2D0; + if (arg5->unk2D0 < arg5->unk2CC) { + arg5->unk2CC = temp_v1; + } + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, arg5->unk2D0, prmcol_520.r, prmcol_520.g, temp, var_a0); + gSPMatrix(gfx++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, mdl_519[type]); + if (!temp_a3) {} + } + CLOSE_DISPS(temp_a3); + } + return 1; +} +#else +#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/aTOU_actor_draw_after.s") +#endif + +#ifdef NON_EQUIVALENT +void aTOU_actor_draw(Actor* thisx, Game_Play* game_play) { + Toudai* this = THIS; + GraphicsContext* gfxCtx = game_play->state.gfxCtx; + UNK_PTR sp68; // object + u16* sp64; // palette + GraphicsContext* temp_a2; + Mtx* mtx; // temp_v1 + Gfx* gfx; + CommonData_unk_10098* ptr; + u8 t = this->skeletonInfo.skeleton->unk01; + OPEN_DISPS(gfxCtx); + ptr = common_data.unk_10098; + mtx = GRAPH_ALLOC(gfxCtx, t * sizeof(Mtx)); + if (mtx != NULL) { + sp68 = ptr->unk_AC(45); + sp64 = ptr->unk_450(90); + func_800BD5E8_jp(gfx); + gfx = POLY_OPA_DISP; + gSPSegment(gfx++, 0x08, sp64); + gSegments[6] = OS_K0_TO_PHYSICAL(sp68); + gSPSegment(gfx++, 0x06, sp68); + POLY_OPA_DISP = gfx; + func_800BD598_jp(gfx); + + gfx = POLY_XLU_DISP; + gSPSegment(gfx++, 0x08, sp64); + gSPSegment(gfx++, 0x06, sp68); + POLY_XLU_DISP = gfx; + Setpos_HiliteReflect_init(&this->actor.world.pos, game_play); + Setpos_HiliteReflect_xlu_init(&this->actor.world.pos, game_play); + cKF_Si3_draw_R_SV(game_play, &this->skeletonInfo, mtx, aTOU_actor_draw_before, aTOU_actor_draw_after, this); + common_data.unk_10080->unk_4(game_play, &aTOU_shadow_data, 45); + } + CLOSE_DISPS(gfxCtx); + if (gfxCtx) {} +} +#else #pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Toudai/ac_toudai/aTOU_actor_draw.s") +#endif diff --git a/src/overlays/actors/ovl_Toudai/ac_toudai.h b/src/overlays/actors/ovl_Toudai/ac_toudai.h index 7efe709..b77b364 100644 --- a/src/overlays/actors/ovl_Toudai/ac_toudai.h +++ b/src/overlays/actors/ovl_Toudai/ac_toudai.h @@ -4,15 +4,31 @@ #include "ultra64.h" #include "m_actor.h" #include "unk.h" +#include "z64math.h" +#include "c_keyframe.h" -struct Game_Play; struct Toudai; +struct Game_Play; typedef void (*ToudaiActionFunc)(struct Toudai*, struct Game_Play*); typedef struct Toudai { /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x164]; + /* 0x174 */ s32 unk174; + /* 0x178 */ SkeletonInfoR skeletonInfo; + /* 0x1E8 */ s32 unk1E8; + /* 0x1EC */ Vec3s jointTable[15]; + /* 0x246 */ Vec3s morphTable[15]; + /* 0x2A0 */ ToudaiActionFunc unk2A0; + /* 0x2A4 */ UNK_TYPE1 unk2A4[0x10]; + /* 0x2B4 */ UNK_TYPE unk2B4; + /* 0x2B8 */ UNK_TYPE1 unk2B8[0x4]; + /* 0x2BC */ UNK_TYPE unk2BC; + /* 0x2C0 */ UNK_TYPE1 unk2C0[0x8]; + /* 0x2C8 */ f32 unk2C8; + /* 0x2CC */ f32 unk2CC; + /* 0x2D0 */ f32 unk2D0; + /* 0x2D4 */ UNK_TYPE1 unk2D4[0x4]; } Toudai; // size = 0x2D8 #endif diff --git a/src/overlays/gamestates/ovl_play/m_play.c b/src/overlays/gamestates/ovl_play/m_play.c index 0c824c0..0f9c254 100644 --- a/src/overlays/gamestates/ovl_play/m_play.c +++ b/src/overlays/gamestates/ovl_play/m_play.c @@ -23,7 +23,7 @@ #include "libc64/qrand.h" #include "m_controller.h" #include "m_debug_display.h" -#include "6E0F50.h" +#include "m_rcp.h" #include "6D2720.h" #include "m_lights.h" #include "m_private.h" diff --git a/src/overlays/submenu/submenu_ovl/m_submenu_ovl.c b/src/overlays/submenu/submenu_ovl/m_submenu_ovl.c index 15f8f60..cbaffdf 100644 --- a/src/overlays/submenu/submenu_ovl/m_submenu_ovl.c +++ b/src/overlays/submenu/submenu_ovl/m_submenu_ovl.c @@ -7,7 +7,7 @@ #include "PreRender.h" #include "sys_matrix.h" #include "z_std_dma.h" -#include "6E0F50.h" +#include "m_rcp.h" #include "macros.h" #include "segment_symbols.h" -- cgit v1.2.3