diff options
| author | inspectredc <78732756+inspectredc@users.noreply.github.com> | 2024-04-24 01:37:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-23 17:37:47 -0700 |
| commit | 7ae1401111806ddb483756e544b050d5f35b7c42 (patch) | |
| tree | 90111faf3459fa38613264fceb53a69af8432039 | |
| parent | 99081d5a7ec723e439e352f00d14fa2bb569e69b (diff) | |
ac_airplane OK and documented (#178)
* ac_airplane OK and documented
* player lib funcs
* include object
* remove statics
| -rw-r--r-- | include/m_player_lib.h | 4 | ||||
| -rw-r--r-- | include/macros.h | 2 | ||||
| -rw-r--r-- | include/sys_math.h | 2 | ||||
| -rw-r--r-- | include/tables/dmatables/dmadata_table_jp.h | 2 | ||||
| -rw-r--r-- | include/tables/object_table.h | 2 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_assets.txt | 3 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_code.txt | 4 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_overlays.txt | 50 | ||||
| -rw-r--r-- | linker_scripts/jp/undefined_syms.ld | 4 | ||||
| -rw-r--r-- | src/objects/glider/glider.c | 4 | ||||
| -rw-r--r-- | src/objects/glider/glider.h | 9 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Airplane/ac_airplane.c | 316 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Airplane/ac_airplane.h | 32 | ||||
| -rw-r--r-- | yamls/jp/assets.yaml | 16 | ||||
| -rw-r--r-- | yamls/jp/overlays.yaml | 2 |
15 files changed, 386 insertions, 66 deletions
diff --git a/include/m_player_lib.h b/include/m_player_lib.h index 057ea84..315bdd3 100644 --- a/include/m_player_lib.h +++ b/include/m_player_lib.h @@ -70,8 +70,8 @@ void mPlib_Load_PlayerTexAndPallet(u8*, u8*, s32); // void func_800B22FC_jp(); // void func_800B2350_jp(); void mPlib_request_main_invade_type1(struct Game_Play*); -// void func_800B23DC_jp(); -// void func_800B2414_jp(); +void mPlib_request_main_refuse_type1(Game_Play*); +void mPlib_request_main_wait_type3(Game_Play*); // void func_800B2450_jp(); // void func_800B24A0_jp(); // void func_800B24F8_jp(); diff --git a/include/macros.h b/include/macros.h index 05c5990..9a196ef 100644 --- a/include/macros.h +++ b/include/macros.h @@ -22,7 +22,7 @@ #define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr)) #define ABS(x) (((x) >= 0) ? (x): -(x)) -#define ABS_F(x) ((x) >= 0.0f) ? (x) : -(x) +#define ABS_F(x) (((x) >= 0.0f) ? (x) : -(x)) #define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) diff --git a/include/sys_math.h b/include/sys_math.h index bccf335..599e94f 100644 --- a/include/sys_math.h +++ b/include/sys_math.h @@ -18,7 +18,7 @@ // void ifact(); // void powi(); f32 sinf_table(f32); -// void cosf_table(); +f32 cosf_table(f32); // void tanf_table(); #endif diff --git a/include/tables/dmatables/dmadata_table_jp.h b/include/tables/dmatables/dmadata_table_jp.h index a461b89..5519a9d 100644 --- a/include/tables/dmatables/dmadata_table_jp.h +++ b/include/tables/dmatables/dmadata_table_jp.h @@ -2281,7 +2281,7 @@ DEFINE_DMA_ENTRY(object_01131000, "object_01131000") DEFINE_DMA_ENTRY(object_01134000, "object_01134000") DEFINE_DMA_ENTRY(object_01135000, "object_01135000") DEFINE_DMA_ENTRY(segment_01136000, "segment_01136000") -DEFINE_DMA_ENTRY(object_0113C000, "object_0113C000") +DEFINE_DMA_ENTRY(glider, "glider") DEFINE_DMA_ENTRY(object_0113D000, "object_0113D000") DEFINE_DMA_ENTRY(object_01147000, "object_01147000") DEFINE_DMA_ENTRY(segment_01148000, "segment_01148000") diff --git a/include/tables/object_table.h b/include/tables/object_table.h index c091d92..75ed685 100644 --- a/include/tables/object_table.h +++ b/include/tables/object_table.h @@ -17,7 +17,7 @@ /* 0x004 */ DEFINE_OBJECT(object_00D2D000, OBJECT_4) /* 0x005 */ DEFINE_OBJECT(object_013A4000, OBJECT_5) /* 0x006 */ DEFINE_OBJECT(tol_hata_01, OBJECT_TOL_HATA_01) -/* 0x007 */ DEFINE_OBJECT(object_0113C000, OBJECT_7) +/* 0x007 */ DEFINE_OBJECT(glider, OBJECT_GLIDER) /* 0x008 */ DEFINE_OBJECT(object_00D25000, OBJECT_8) /* 0x009 */ DEFINE_OBJECT(object_00B36000, OBJECT_9) /* 0x00A */ DEFINE_OBJECT_UNSET(OBJECT_UNSET_10) diff --git a/linker_scripts/jp/symbol_addrs_assets.txt b/linker_scripts/jp/symbol_addrs_assets.txt index d092978..e48eed9 100644 --- a/linker_scripts/jp/symbol_addrs_assets.txt +++ b/linker_scripts/jp/symbol_addrs_assets.txt @@ -1210,6 +1210,9 @@ tol_hata_01_evw_anime_1 = 0x60003D8; // segment:tol_hata_01 rom:0x11303D8 tol_hata_01_evw_anime_2 = 0x60003E8; // segment:tol_hata_01 rom:0x11303E8 tol_hata_01_evw_anime = 0x60003F0; // segment:tol_hata_01 rom:0x11303F0 +glider_v = 0x6000000; // segment:glider rom:0x113C000 size:0xB0 +glider_model = 0x60000B0; // segment:glider rom:0x113C0B0 + act_bee_v = 0x6000000; // segment:act_bee rom:0x11F4000 size:0x3A0 act_bee_C_model = 0x60003A0; // segment:act_bee rom:0x11F43A0 act_bee_B_model = 0x60004B8; // segment:act_bee rom:0x11F44B8 diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index f03c268..c5fa8f6 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -2565,8 +2565,8 @@ func_800B22D0_jp = 0x800B22D0; // type:func func_800B22FC_jp = 0x800B22FC; // type:func func_800B2350_jp = 0x800B2350; // type:func mPlib_request_main_invade_type1 = 0x800B23A4; // type:func -func_800B23DC_jp = 0x800B23DC; // type:func -func_800B2414_jp = 0x800B2414; // type:func +mPlib_request_main_refuse_type1 = 0x800B23DC; // type:func +mPlib_request_main_wait_type3 = 0x800B2414; // type:func func_800B2450_jp = 0x800B2450; // type:func func_800B24A0_jp = 0x800B24A0; // type:func func_800B24F8_jp = 0x800B24F8; // type:func diff --git a/linker_scripts/jp/symbol_addrs_overlays.txt b/linker_scripts/jp/symbol_addrs_overlays.txt index 0449321..5ce6dea 100644 --- a/linker_scripts/jp/symbol_addrs_overlays.txt +++ b/linker_scripts/jp/symbol_addrs_overlays.txt @@ -8615,37 +8615,37 @@ D_809678AC_jp = 0x809678AC; // Airplane_Actor_ct = 0x80967920; // type:func Airplane_Actor_dt = 0x80967A10; // type:func Airplane_Actor_draw = 0x80967A20; // type:func -func_80967B50_jp = 0x80967B50; // type:func -func_80967B78_jp = 0x80967B78; // type:func -func_80967B9C_jp = 0x80967B9C; // type:func -func_80967C8C_jp = 0x80967C8C; // type:func -func_80967D04_jp = 0x80967D04; // type:func -func_80967E1C_jp = 0x80967E1C; // type:func -func_80967E98_jp = 0x80967E98; // type:func -func_80968058_jp = 0x80968058; // type:func -func_80968068_jp = 0x80968068; // type:func -func_809680C8_jp = 0x809680C8; // type:func -func_809681A4_jp = 0x809681A4; // type:func -func_80968280_jp = 0x80968280; // type:func -func_80968304_jp = 0x80968304; // type:func -func_80968464_jp = 0x80968464; // type:func -func_809685B8_jp = 0x809685B8; // type:func -func_80968638_jp = 0x80968638; // type:func +aAp_RubberMove = 0x80967B50; // type:func +aAp_FallByWall = 0x80967B78; // type:func +aAp_GroundFriction = 0x80967B9C; // type:func +aAp_FreeFlyMove = 0x80967C8C; // type:func +aAp_SomerFlyMove = 0x80967D04; // type:func +aAp_SelectFly = 0x80967E1C; // type:func +aAp_StartFlyMove = 0x80967E98; // type:func +aAp_PlayerCatch = 0x80968058; // type:func +aAp_StopFlyMove = 0x80968068; // type:func +aAp_FallFlyMove = 0x809680C8; // type:func +aAp_FallFlyMove2 = 0x809681A4; // type:func +aAp_LeanAirplane = 0x80968280; // type:func +aAp_WindSystem = 0x80968304; // type:func +aAp_CommonHandle = 0x80968464; // type:func +aAp_ZbuttonChangeStatus = 0x809685B8; // type:func +aAp_GetBgCheckOffsetY = 0x80968638; // type:func Airplane_Actor_move = 0x80968674; // type:func // .data Airplane_Profile = 0x80968710; // -D_80968734_jp = 0x80968734; // type:s16 -D_80968744_jp = 0x80968744; // type:s16 -D_80968754_jp = 0x80968754; // -D_80968760_jp = 0x80968760; // -D_8096876C_jp = 0x8096876C; // -D_80968778_jp = 0x80968778; // -D_80968784_jp = 0x80968784; // -D_80968794_jp = 0x80968794; // +goal_angle_random = 0x80968734; // type:s16 +goal_angle_random2 = 0x80968744; // type:s16 +wind1 = 0x80968754; // +wind2 = 0x80968760; // +wind3 = 0x8096876C; // +wind4 = 0x80968778; // +wind_table = 0x80968784; // +wind_change_frame_table = 0x80968794; // D_809687BC_jp = 0x809687BC; // -D_809687C8_jp = 0x809687C8; // +AirplaneMove = 0x809687C8; // // .rodata diff --git a/linker_scripts/jp/undefined_syms.ld b/linker_scripts/jp/undefined_syms.ld index 17a206a..50fca18 100644 --- a/linker_scripts/jp/undefined_syms.ld +++ b/linker_scripts/jp/undefined_syms.ld @@ -1133,10 +1133,6 @@ D_60000F0 = 0x060000F0; D_60000C0 = 0x060000C0; -// ovl_Airplane - -D_60000B0 = 0x060000B0; - // ovl_Haniwa D_60018AC = 0x060018AC; diff --git a/src/objects/glider/glider.c b/src/objects/glider/glider.c new file mode 100644 index 0000000..e431ce8 --- /dev/null +++ b/src/objects/glider/glider.c @@ -0,0 +1,4 @@ +#include "glider.h" + +#include "assets/jp/objects/glider/glider_v.vtx.inc.c" +#include "assets/jp/objects/glider/glider_model.gfx.inc.c" diff --git a/src/objects/glider/glider.h b/src/objects/glider/glider.h new file mode 100644 index 0000000..b559703 --- /dev/null +++ b/src/objects/glider/glider.h @@ -0,0 +1,9 @@ +#ifndef OBJECT_GLIDER_H +#define OBJECT_GLIDER_H + +#include "gbi.h" + +extern Vtx glider_v[]; +extern Gfx glider_model[]; + +#endif diff --git a/src/overlays/actors/ovl_Airplane/ac_airplane.c b/src/overlays/actors/ovl_Airplane/ac_airplane.c index c39ff01..69f2b1b 100644 --- a/src/overlays/actors/ovl_Airplane/ac_airplane.c +++ b/src/overlays/actors/ovl_Airplane/ac_airplane.c @@ -2,19 +2,27 @@ #include "m_actor_dlftbls.h" #include "m_object.h" #include "overlays/gamestates/ovl_play/m_play.h" +#include "overlays/actors/player_actor/m_player.h" +#include "m_player_lib.h" +#include "m_actor_shadow.h" +#include "macros.h" +#include "m_rcp.h" + +#include "objects/glider/glider.h" + +#define THIS ((Airplane*)thisx) void Airplane_Actor_ct(Actor* thisx, Game_Play* game_play); void Airplane_Actor_dt(Actor* thisx, Game_Play* game_play); void Airplane_Actor_move(Actor* thisx, Game_Play* game_play); void Airplane_Actor_draw(Actor* thisx, Game_Play* game_play); -#if 0 ActorProfile Airplane_Profile = { /* */ ACTOR_AIRPLANE, /* */ ACTOR_PART_4, /* */ ACTOR_FLAG_10 | ACTOR_FLAG_20, /* */ 0x8000, - /* */ OBJECT_7, + /* */ OBJECT_GLIDER, /* */ sizeof(Airplane), /* */ Airplane_Actor_ct, /* */ Airplane_Actor_dt, @@ -22,44 +30,306 @@ ActorProfile Airplane_Profile = { /* */ Airplane_Actor_draw, /* */ NULL, }; -#endif -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/Airplane_Actor_ct.s") +void Airplane_Actor_ct(Actor* thisx, UNUSED Game_Play* game_play) { + Airplane* this = THIS; + + Shape_Info_init(thisx, 0.0f, mAc_ActorShadowEllipse, 6.5f, 6.5f); + + this->state = Ap_STATE_STOP_FLY_MOVE; + this->speed = 6.2f; + this->actor.speed = 6.2f; + this->ySpeed = 0.0f; + this->yRot = RAD_TO_DEG(BINANG_TO_RAD(thisx->world.rot.y)); + this->groundTimer = 0; + this->windFrame = 0; + this->windChangeFrame = 0; + this->wind = NULL; + this->zRot = 0.0f; + this->xRot = 0.0f; + this->targetYRot = this->yRot; + this->startYRot = this->yRot; + + this->actor.world.pos.y = mCoBG_GetBgY_AngleS_FromWpos(0, this->actor.world.pos, -5.5f); +} + +void Airplane_Actor_dt(Actor* thisx, UNUSED Game_Play* game_play) { + UNUSED Airplane* this = THIS; +} + +void Airplane_Actor_draw(Actor* thisx, Game_Play* game_play) { + Airplane* this = THIS; + + if ((this->state != Ap_STATE_PLAYER_CATCH) && (this->state != Ap_STATE_START_FLY_MOVE)) { + OPEN_DISPS(game_play->state.gfxCtx); + _texture_z_light_fog_prim(game_play->state.gfxCtx); + Matrix_RotateX(RAD_TO_BINANG(DEG_TO_RAD(this->xRot)), MTXMODE_APPLY); + Matrix_RotateZ(RAD_TO_BINANG(DEG_TO_RAD(this->zRot)), MTXMODE_APPLY); + Matrix_scale(50.0f, 50.0f, 50.0f, 1); + gSPMatrix(POLY_OPA_DISP++, _Matrix_to_Mtx_new(game_play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, glider_model); + CLOSE_DISPS(game_play->state.gfxCtx); + } +} + +void aAp_RubberMove(f32* pValue, f32 target, f32 step) { + *pValue = *pValue + ((target - *pValue) * step); +} + +void aAp_FallByWall(Airplane* this) { + if (this->actor.colResult.hitWall != 0) { + this->state = Ap_STATE_FALL_FLY_MOVE; + } +} + +void aAp_GroundFriction(Airplane* this, Game_Play* game_play) { + + if (this->actor.colResult.onGround) { + aAp_RubberMove(&this->speed, 0.0f, 0.6f); + if (this->speed < 1.0f) { + this->state = Ap_STATE_STOP_FLY_MOVE; + this->speed = 0.0f; + if (this->groundTimer >= 5) { + this->groundTimer = 0; + common_data.clip.unk_090->unk_00(1, this->actor.world.pos, 1, this->actor.world.rot.y, game_play, + this->actor.fgName, 0, 8); + } + this->groundTimer++; + } + } +} + +void aAp_FreeFlyMove(Airplane* this, Game_Play* game_play) { -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/Airplane_Actor_dt.s") + aAp_RubberMove(&this->speed, 3.0f, 0.01f); + aAp_RubberMove(&this->xRot, 19.0f, 0.045f); + aAp_RubberMove(&this->zRot, 0.0f, 0.05f); + aAp_GroundFriction(this, game_play); + aAp_FallByWall(this); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/Airplane_Actor_draw.s") +void aAp_SomerFlyMove(Airplane* this, Game_Play* game_play) { + f32 xAngle; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967B50_jp.s") + switch (this->tiltState) { + case Ap_TILT_DOWN: + aAp_RubberMove(&this->xRot, -89.0f, 0.2f); + aAp_RubberMove(&this->speed, 9.0f, 0.1f); + if (this->xRot < -87.0f) { + this->tiltState = Ap_TILT_UP; + this->xRot = 60.0f; + } + break; + case Ap_TILT_UP: + aAp_RubberMove(&this->xRot, 0.0f, 0.04f); + aAp_RubberMove(&this->speed, 10.0f, 0.1f); + xAngle = ABS(this->xRot); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967B78_jp.s") + if (xAngle < 3.0f) { + this->state = Ap_STATE_FREE_FLY_MOVE; + this->tiltState = Ap_TILT_DOWN; + } + aAp_GroundFriction(this, game_play); + break; + default: + break; + } + aAp_FallByWall(this); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967B9C_jp.s") +s32 aAp_SelectFly(Airplane* this, s32 joystickY) { + u32 rand = RANDOM(7); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967C8C_jp.s") + if (joystickY > 67) { + if (rand % 2) { + this->state = Ap_STATE_FALL_FLY_MOVE2; + } else { + this->state = Ap_STATE_SOMER_FLY_MOVE; + this->tiltState = Ap_TILT_DOWN; + } + } else { + this->state = Ap_STATE_FREE_FLY_MOVE; + } + return 1; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967D04_jp.s") +void aAp_StartFlyMove(Airplane* this, Game_Play* game_play) { + static s16 goal_angle_random[8] = { + 0x093E, 0x07D2, 0xFBBC, 0xF6C2, 0x0000, 0x1110, 0xEFA6, 0x105A, + }; + static s16 goal_angle_random2[8] = { + 0x31C4, 0x1FFE, 0xDC74, 0xE002, 0xD558, 0x2AA8, 0x238C, 0x0000, + }; + UNUSED UNK_TYPE1 pad[0x4]; + s32 joystickY = getJoystick_Y(); + Player* player = get_player_actor_withoutCheck(game_play); + s32 randIndex = RANDOM_F(8); + s16* goalAngle; + UNUSED UNK_TYPE1 pad2[0x4]; + s32 joystickYMagnitude; + + if ((joystickY - this->joystickY) > 30) { + joystickYMagnitude = ABS(this->joystickY); + this->speed = ABS_F((f32)this->joystickY) * (7.0f / 80.0f) + 3.0f; + + aAp_SelectFly(this, joystickYMagnitude); + goalAngle = (joystickYMagnitude > 50) ? goal_angle_random2 : goal_angle_random; + this->actor.world.pos.y = player->actor.world.pos.y + 25.0f; + this->actor.world.pos.x = player->actor.world.pos.x; + this->actor.world.pos.z = player->actor.world.pos.z; + this->yRot = RAD_TO_DEG(BINANG_TO_RAD(player->actor.shape.rot.y)); + this->targetYRot = RAD_TO_DEG(BINANG_TO_RAD(goalAngle[randIndex])) + this->yRot; + this->xRot = this->speed * -(60.0f / 7.0f) + 30.0f; + this->zRot = 0.0f; + this->ySpeed = 0.0f; + mPlib_request_main_wait_type3(game_play); + } +} + +void aAp_PlayerCatch(UNUSED Airplane* this, UNUSED Game_Play* game_play) { +} + +void aAp_StopFlyMove(Airplane* this, UNUSED Game_Play* game_play) { + this->speed = 0.0f; + if ((this->actor.xzDistToPlayer <= 30.0f) && chkTrigger(A_BUTTON)) { + this->state = Ap_STATE_PLAYER_CATCH; + } +} + +void aAp_FallFlyMove(Airplane* this, Game_Play* game_play) { + aAp_RubberMove(&this->xRot, 60.0f, 0.04f); + aAp_RubberMove(&this->speed, 5.0f, 0.02f); + this->actor.world.pos.y -= 0.15f; + if (this->actor.colResult.onGround) { + common_data.clip.unk_090->unk_00(1, this->actor.world.pos, 1, this->actor.world.rot.y, game_play, + this->actor.fgName, 0, 8); + this->state = Ap_STATE_STOP_FLY_MOVE; + } +} + +void aAp_FallFlyMove2(Airplane* this, Game_Play* game_play) { + aAp_RubberMove(&this->xRot, 70.0f, 0.15f); + aAp_RubberMove(&this->speed, 10.0f, 0.02f); + this->actor.world.pos.y -= 0.15f; + if (this->actor.colResult.onGround) { + common_data.clip.unk_090->unk_00(1, this->actor.world.pos, 1, this->actor.world.rot.y, game_play, + this->actor.fgName, 0, 8); + this->state = Ap_STATE_STOP_FLY_MOVE; + } +} + +void aAp_LeanAirplane(Airplane* this) { + if (this->state == Ap_STATE_FREE_FLY_MOVE) { + aAp_RubberMove(&this->zRot, 0.0f, 0.05f); + } else if (this->yRot < this->startYRot) { + aAp_RubberMove(&this->zRot, 50.0f, 0.05f); + } else { + aAp_RubberMove(&this->zRot, -50.0f, 0.05f); + } +} + +xyz_t wind1 = { 2.0f, 1.0f, 4.0f }; +xyz_t wind2 = { -3.0f, -4.0f, -7.0f }; +xyz_t wind3 = { 4.0f, -3.0f, 1.0f }; +xyz_t wind4 = { -1.0f, 3.0f, -4.0f }; + +xyz_t* wind_table[4] = { + &wind1, + &wind2, + &wind3, + &wind4, +}; + +s32 wind_change_frame_table[10] = { + 300, 20, 500, 1000, 100, 700, 20, 200, 80, 70, +}; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967E1C_jp.s") +void aAp_WindSystem(Actor* thisx, UNUSED Game_Play* game_play) { + Airplane* this = THIS; + xyz_t direction = { 0.0f, 1.0f, 0.0f }; + s32 randWindTableIndex; + s32 randWindFrameIndex; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80967E98_jp.s") + this->windFrame++; + if (this->windFrame > this->windChangeFrame) { + randWindTableIndex = RANDOM_F(4); + randWindFrameIndex = RANDOM_F(10); + this->windFrame = 0; + this->windChangeFrame = wind_change_frame_table[randWindFrameIndex]; + this->wind = wind_table[randWindTableIndex]; + } -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80968058_jp.s") + if (this->state != Ap_STATE_STOP_FLY_MOVE && this->state != Ap_STATE_START_FLY_MOVE && + this->state != Ap_STATE_PLAYER_CATCH && this->wind) { + sMath_RotateX(&direction, DEG_TO_RAD(this->xRot)); + sMath_RotateZ(&direction, DEG_TO_RAD(this->zRot)); + sMath_RotateY(&direction, DEG_TO_RAD(this->yRot)); + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80968068_jp.s") +void aAp_CommonHandle(Actor* actor, Airplane* this, Game_Play* game_play) { -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_809680C8_jp.s") + aAp_LeanAirplane(this); + actor->speed = cosf_table(DEG_TO_RAD(this->xRot)) * this->speed; + this->ySpeed = sinf_table(DEG_TO_RAD(this->xRot)) * this->speed; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_809681A4_jp.s") + actor->world.pos.y -= this->ySpeed; + actor->world.rot.y = RAD_TO_BINANG(DEG_TO_RAD(this->yRot)); + actor->shape.rot.y = RAD_TO_BINANG(DEG_TO_RAD(this->yRot)); + Actor_position_moveF(actor); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80968280_jp.s") + this->joystickX = getJoystick_X(); + this->joystickY = getJoystick_Y(); -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80968304_jp.s") + switch (this->state) { + case Ap_STATE_START_FLY_MOVE: + case Ap_STATE_PLAYER_CATCH: + actor->shape.drawShadow = 0; + break; + case Ap_STATE_FREE_FLY_MOVE: + case Ap_STATE_FALL_FLY_MOVE: + case Ap_STATE_FALL_FLY_MOVE2: + case Ap_STATE_SOMER_FLY_MOVE: + aAp_RubberMove(&this->yRot, this->targetYRot, 0.07f); + actor->shape.drawShadow = 1; + break; + default: + actor->shape.drawShadow = 1; + break; + } + aAp_WindSystem(actor, game_play); +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80968464_jp.s") +void aAp_ZbuttonChangeStatus(Airplane* this, Game_Play* game_play) { + if (chkButton(Z_TRIG)) { + if (this->state == Ap_STATE_PLAYER_CATCH) { + mPlib_request_main_refuse_type1(game_play); + this->state = Ap_STATE_START_FLY_MOVE; + } + } else if (this->state == Ap_STATE_START_FLY_MOVE) { + mPlib_request_main_wait_type3(game_play); + this->state = Ap_STATE_PLAYER_CATCH; + } +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_809685B8_jp.s") +f32 aAp_GetBgCheckOffsetY(s16 state) { + if ((state == Ap_STATE_FALL_FLY_MOVE) || (state == Ap_STATE_STOP_FLY_MOVE)) { + return -5.5f; + } + return 0.0f; +} -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/func_80968638_jp.s") +void Airplane_Actor_move(Actor* thisx, Game_Play* game_play) { + static AirplaneActionFunc AirplaneMove[] = { + aAp_FreeFlyMove, aAp_FallFlyMove, aAp_FallFlyMove2, aAp_SomerFlyMove, + aAp_StartFlyMove, aAp_StopFlyMove, aAp_PlayerCatch, + }; + Airplane* this = THIS; -#pragma GLOBAL_ASM("asm/jp/nonmatchings/overlays/actors/ovl_Airplane/ac_airplane/Airplane_Actor_move.s") + this->startYRot = this->yRot; + AirplaneMove[this->state](this, game_play); + aAp_ZbuttonChangeStatus(this, game_play); + aAp_CommonHandle(&this->actor, this, game_play); + mCoBG_BgCheckControll(0, &this->actor, 15.0f, aAp_GetBgCheckOffsetY(this->state), 0, 0, 0); +} diff --git a/src/overlays/actors/ovl_Airplane/ac_airplane.h b/src/overlays/actors/ovl_Airplane/ac_airplane.h index dfa8209..0c90400 100644 --- a/src/overlays/actors/ovl_Airplane/ac_airplane.h +++ b/src/overlays/actors/ovl_Airplane/ac_airplane.h @@ -8,11 +8,41 @@ struct Game_Play; struct Airplane; +typedef enum AirplaneState { + /* 0 */ Ap_STATE_FREE_FLY_MOVE, + /* 1 */ Ap_STATE_FALL_FLY_MOVE, + /* 2 */ Ap_STATE_FALL_FLY_MOVE2, + /* 3 */ Ap_STATE_SOMER_FLY_MOVE, + /* 4 */ Ap_STATE_START_FLY_MOVE, + /* 5 */ Ap_STATE_STOP_FLY_MOVE, + /* 6 */ Ap_STATE_PLAYER_CATCH, +} AirplaneState; + +typedef enum AirplaneTiltState { + /* 0 */ Ap_TILT_DOWN, + /* 1 */ Ap_TILT_UP, +} AirplaneTiltState; + typedef void (*AirplaneActionFunc)(struct Airplane*, struct Game_Play*); typedef struct Airplane { /* 0x000 */ Actor actor; - /* 0x174 */ UNK_TYPE1 unk_174[0x54]; + /* 0x174 */ s16 state; + /* 0x176 */ s16 tiltState; + /* 0x178 */ f32 speed; + /* 0x17C */ f32 ySpeed; + /* 0x180 */ f32 targetYRot; + /* 0x184 */ f32 startYRot; + /* 0x188 */ f32 yRot; + /* 0x18C */ f32 xRot; + /* 0x190 */ f32 zRot; + /* 0x194 */ s32 joystickY; + /* 0x198 */ s32 joystickX; + /* 0x19C */ s16 groundTimer; + /* 0x1A0 */ s32 windFrame; + /* 0x1A4 */ s32 windChangeFrame; + /* 0x1A8 */ xyz_t* wind; + /* 0x1AC */ UNK_TYPE1 unk_1AC[0x1C]; } Airplane; // size = 0x1C8 #endif diff --git a/yamls/jp/assets.yaml b/yamls/jp/assets.yaml index 8689e4d..1a7af61 100644 --- a/yamls/jp/assets.yaml +++ b/yamls/jp/assets.yaml @@ -6541,15 +6541,23 @@ align: 0x1000 - [0x113BCD0] - - name: object_0113C000 - type: bin # code + - name: glider + dir: objects/glider + type: code start: 0x113C000 vram: 0x06000000 exclusive_ram_id: segment_06 compress: True align: 0x1000 - # subsegments: - # - [0x113C000, data, assets/objects/object_0113C000/object_0113C000] + symbol_name_format: $VRAM_$ROM + subsegments: + - [auto, c, glider] + - start: 0x113C000 + type: .data + name: glider + subsegments: + - [0x113C000, vtx, glider_v] + - [0x113C0B0, af_gfx, glider_model] - [0x113C100] - name: object_0113D000 diff --git a/yamls/jp/overlays.yaml b/yamls/jp/overlays.yaml index ef5b267..1278e2c 100644 --- a/yamls/jp/overlays.yaml +++ b/yamls/jp/overlays.yaml @@ -1703,7 +1703,7 @@ bss_size: 0x0 subsegments: - [0x85C570, c, overlays/actors/ovl_Airplane/ac_airplane] - - [0x85D360, data, overlays/actors/ovl_Airplane/ac_airplane] + - [0x85D360, .data, overlays/actors/ovl_Airplane/ac_airplane] - [0x85D440, .rodata, overlays/actors/ovl_Airplane/ac_airplane] - name: ovl_Airplane_reloc type: code |
