Separate ac_structure clip into sub TU, fix aSTR_PROC types

This commit is contained in:
Cuyler36
2024-02-19 10:13:58 -05:00
parent 64eb115a2b
commit c8c1e34c60
8 changed files with 725 additions and 759 deletions
+196 -195
View File
@@ -5,6 +5,7 @@
#include "m_actor.h"
#include "m_actor_dlftbls.h"
#include "c_keyframe.h"
#include "m_play_h.h"
#ifdef __cplusplus
extern "C" {
@@ -14,167 +15,167 @@ extern "C" {
#define aSTR_OVERLAY_SIZE 0x2400
enum structure_type {
aSTR_TYPE_HOUSE1,
aSTR_TYPE_HOUSE2,
aSTR_TYPE_HOUSE3,
aSTR_TYPE_HOUSE4,
aSTR_TYPE_HOUSE5,
aSTR_TYPE_MYHOME,
aSTR_TYPE_6,
aSTR_TYPE_7,
aSTR_TYPE_SHOP1,
aSTR_TYPE_SHOP2,
aSTR_TYPE_SHOP3,
aSTR_TYPE_SHOP4,
aSTR_TYPE_POST_OFFICE,
aSTR_TYPE_STATION1,
aSTR_TYPE_STATION2,
aSTR_TYPE_STATION3,
aSTR_TYPE_TRAIN0,
aSTR_TYPE_TRAIN1,
aSTR_TYPE_POLICE_BOX,
aSTR_TYPE_FALLS,
aSTR_TYPE_FALLSESW,
aSTR_TYPE_RESERVE,
aSTR_TYPE_SHRINE,
aSTR_TYPE_BRSHOP,
aSTR_TYPE_BUGGY,
aSTR_TYPE_S_CAR,
aSTR_TYPE_KAMAKURA, // also used for camping tent
aSTR_TYPE_GOZA,
aSTR_TYPE_RADIO,
aSTR_TYPE_YATAI,
aSTR_TYPE_TUKIMI,
aSTR_TYPE_TUKIMI2,
aSTR_TYPE_MIKUJI,
aSTR_TYPE_COUNT,
aSTR_TYPE_COUNT02,
aSTR_TYPE_SPORTSFAIR_A,
aSTR_TYPE_SPORTSFAIR_B,
aSTR_TYPE_TURI,
aSTR_TYPE_TURI2,
aSTR_TYPE_KOINOBORI,
aSTR_TYPE_DUMP,
aSTR_TYPE_WINDMILL,
aSTR_TYPE_LOTUS,
aSTR_TYPE_MIKAN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LS,
aSTR_PAL_FALLSESW,
aSTR_PAL_RESERVE,
aSTR_PAL_SHRINE,
aSTR_PAL_BR_SHOP,
aSTR_PAL_BUGGY,
aSTR_PAL_S_CAR,
aSTR_PAL_KAMAKURA,
aSTR_PAL_GOZA,
aSTR_PAL_RADIO,
aSTR_PAL_YATAI,
aSTR_PAL_TUKIMI,
aSTR_PAL_TUKIMI2,
aSTR_PAL_MIKUJI,
aSTR_PAL_COUNT,
aSTR_PAL_COUNT02,
aSTR_PAL_KAGO_R,
aSTR_PAL_KAGO_W,
aSTR_PAL_TURI,
aSTR_PAL_TURI2,
aSTR_PAL_KOINOBORI_A,
aSTR_PAL_DUMP,
aSTR_PAL_WINDMILL_A,
aSTR_PAL_WINDMILL_B,
aSTR_PAL_WINDMILL_C,
aSTR_PAL_WINDMILL_D,
aSTR_PAL_WINDMILL_E,
aSTR_PAL_01_LOTUS,
aSTR_PAL_MIKANBOX,
aSTR_PAL_DOUZOU_DAI,
aSTR_PAL_TOUDAI,
aSTR_PAL_MUSEUM,
aSTR_PAL_BRIDGE_A,
aSTR_PAL_TAILOR,
aSTR_PAL_FLAG,
aSTR_PAL_BOAT,
aSTR_PAL_MYHOME_ISLAND,
aSTR_PAL_HOUSE_I,
aSTR_PAL_NUM
aSTR_PAL_NUM
};
typedef struct actor_structure_control_s STRUCTURE_CONTROL_ACTOR;
@@ -187,63 +188,63 @@ typedef STRUCTURE_ACTOR* (*aSTR_GET_ACTOR_AREA_PROC)();
typedef void (*aSTR_FREE_ACTOR_AREA_PROC)(STRUCTURE_ACTOR*);
typedef u16* (*aSTR_GET_PAL_SEGMENT_PROC)(s16);
typedef void (*aSTR_MOVE_PROC)(ACTOR*, GAME*);
typedef void (*aSTR_MOVE_PROC)(STRUCTURE_ACTOR*, GAME_PLAY*);
// sizeof(actor_structure_s) == 0x2DC
struct actor_structure_s {
/* 0x000*/ ACTOR actor_class;
/* 0x174*/ int keyframe_state;
/* 0x178*/ cKF_SkeletonInfo_R_c keyframe;
/* 0x1E8*/ int keyframe_saved_keyframe;
/* 0x1EC*/ s_xyz work_area[15];
/* 0x246*/ s_xyz morph_area[15];
/* 0x2A0*/ aSTR_MOVE_PROC action_proc;
/* 0x2A4*/ int _2A4;
/* 0x2A8*/ int structure_type; /* aSTR_TYPE_* */
/* 0x2AC*/ int structure_pal; /* aSTR_PAL_* */
/* 0x2B0*/ int request_type;
/* 0x2B4*/ int action;
/* 0x000*/ ACTOR actor_class;
/* 0x174*/ int keyframe_state;
/* 0x178*/ cKF_SkeletonInfo_R_c keyframe;
/* 0x1E8*/ int keyframe_saved_keyframe;
/* 0x1EC*/ s_xyz work_area[15];
/* 0x246*/ s_xyz morph_area[15];
/* 0x2A0*/ aSTR_MOVE_PROC action_proc;
/* 0x2A4*/ int _2A4;
/* 0x2A8*/ int structure_type; /* aSTR_TYPE_* */
/* 0x2AC*/ int structure_pal; /* aSTR_PAL_* */
/* 0x2B0*/ int request_type;
/* 0x2B4*/ int action;
/* general purpose members with unique usage between structure actors */
/* 0x2B8*/ int arg0;
/* 0x2BC*/ int arg1;
/* 0x2C0*/ int arg2;
/* 0x2C4*/ int arg3;
/* general purpose members with unique usage between structure actors */
/* 0x2B8*/ int arg0;
/* 0x2BC*/ int arg1;
/* 0x2C0*/ int arg2;
/* 0x2C4*/ int arg3;
/* general purpose float members with unique usage between structure actors*/
/* 0x2C8*/ f32 arg0_f;
/* 0x2CC*/ f32 arg1_f;
/* 0x2D0*/ f32 arg2_f;
/* 0x2D4*/ f32 arg3_f;
/* general purpose float members with unique usage between structure actors*/
/* 0x2C8*/ f32 arg0_f;
/* 0x2CC*/ f32 arg1_f;
/* 0x2D0*/ f32 arg2_f;
/* 0x2D4*/ f32 arg3_f;
/* 0x2D8*/ u32 season;
/* 0x2D8*/ u32 season;
};
typedef struct actor_overlay_info_s {
u8* overlay_p;
int used;
u8* overlay_p;
int used;
} aSTR_Overlay_info_c;
typedef struct actor_structure_clip_s {
aSTR_SETUP_ACTOR_PROC setup_actor_proc;
aSTR_GET_OVERLAY_AREA_PROC get_overlay_area_proc;
aSTR_FREE_OVERLAY_AREA_PROC free_overlay_area_proc;
aSTR_GET_ACTOR_AREA_PROC get_actor_area_proc;
aSTR_FREE_ACTOR_AREA_PROC free_actor_area_proc;
aSTR_SETUP_ACTOR_PROC setup_actor_proc;
aSTR_GET_OVERLAY_AREA_PROC get_overlay_area_proc;
aSTR_FREE_OVERLAY_AREA_PROC free_overlay_area_proc;
aSTR_GET_ACTOR_AREA_PROC get_actor_area_proc;
aSTR_FREE_ACTOR_AREA_PROC free_actor_area_proc;
STRUCTURE_ACTOR* structure_actor_tbl[aSTR_ACTOR_TBL_COUNT];
int structure_actor_used_tbl[aSTR_ACTOR_TBL_COUNT];
STRUCTURE_ACTOR* structure_actor_tbl[aSTR_ACTOR_TBL_COUNT];
int structure_actor_used_tbl[aSTR_ACTOR_TBL_COUNT];
aSTR_Overlay_info_c overlay_area[aSTR_ACTOR_TBL_COUNT];
aSTR_Overlay_info_c overlay_area[aSTR_ACTOR_TBL_COUNT];
aSTR_GET_PAL_SEGMENT_PROC get_pal_segment_proc;
aSTR_GET_PAL_SEGMENT_PROC get_pal_segment_proc;
} aSTR_Clip_c;
struct actor_structure_control_s {
ACTOR actor_class;
int _174;
mActor_name_t str_door_name;
u8 reset;
ACTOR actor_class;
int _174;
mActor_name_t str_door_name;
u8 reset;
};
extern ACTOR_PROFILE Structure_Profile;
+190 -201
View File
@@ -14,283 +14,272 @@
#include "m_player_lib.h"
static int aDOU_set_check(int house_no) {
int player_no = mHS_get_pl_no(house_no);
Private_c* priv = Save_GetPointer(private[player_no]);
mHm_hs_c* house = Save_GetPointer(homes[house_no]);
int player_no = mHS_get_pl_no(house_no);
Private_c* priv = Save_GetPointer(private[player_no]);
mHm_hs_c* house = Save_GetPointer(homes[house_no]);
if (mEv_CheckTitleDemo() != 0 && mEv_CheckTitleDemo() != -1 && mEv_CheckTitleDemo() != -9) {
return FALSE;
}
else if (mLd_PlayerManKindCheckNo(player_no) || mPr_CheckPrivate(priv) == FALSE) {
return FALSE;
}
else if (mPr_NullCheckPersonalID(&house->ownerID) == FALSE && house->size_info.next_size == mHm_HOMESIZE_STATUE) {
return TRUE;
}
else {
return FALSE;
}
if (mEv_CheckTitleDemo() != 0 && mEv_CheckTitleDemo() != -1 && mEv_CheckTitleDemo() != -9) {
return FALSE;
} else if (mLd_PlayerManKindCheckNo(player_no) || mPr_CheckPrivate(priv) == FALSE) {
return FALSE;
} else if (mPr_NullCheckPersonalID(&house->ownerID) == FALSE && house->size_info.next_size == mHm_HOMESIZE_STATUE) {
return TRUE;
} else {
return FALSE;
}
}
static int aDOU_get_color(int house_no) {
return Save_Get(homes[house_no]).size_info.statue_rank;
return Save_Get(homes[house_no]).size_info.statue_rank;
}
static int aDOU_get_douzou_type(int house_no) {
int player_no = mHS_get_pl_no(house_no);
Private_c* priv = Save_GetPointer(private[player_no]);
s8 sex = mPr_SEX_MALE;
s8 face = mPr_FACE_TYPE0;
int player_no = mHS_get_pl_no(house_no);
Private_c* priv = Save_GetPointer(private[player_no]);
s8 sex = mPr_SEX_MALE;
s8 face = mPr_FACE_TYPE0;
if (mLd_PlayerManKindCheckNo(player_no) == FALSE && mPr_CheckPrivate(priv)) {
sex = priv->gender;
face = priv->face;
}
if (mLd_PlayerManKindCheckNo(player_no) == FALSE && mPr_CheckPrivate(priv)) {
sex = priv->gender;
face = priv->face;
}
return sex * mPr_FACE_TYPE_NUM + face;
return sex * mPr_FACE_TYPE_NUM + face;
}
static void KeepItem(xyz_t pos) {
mActor_name_t* unit_fg = mFI_GetUnitFG(pos);
if (unit_fg != NULL) {
mFI_Wpos2DepositOFF(pos);
mPB_keep_item(*unit_fg);
mFI_SetFG_common(EMPTY_NO, pos, TRUE);
}
mActor_name_t* unit_fg = mFI_GetUnitFG(pos);
if (unit_fg != NULL) {
mFI_Wpos2DepositOFF(pos);
mPB_keep_item(*unit_fg);
mFI_SetFG_common(EMPTY_NO, pos, TRUE);
}
}
static void aDOU_keep_item(ACTOR* actor) {
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
xyz_t wpos;
int i;
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
xyz_t wpos;
int i;
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
xyz_t_move(&wpos, &actor->world.position);
wpos.x += xpostbl[i];
wpos.z += zpostbl[i];
KeepItem(wpos);
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
xyz_t_move(&wpos, &actor->world.position);
wpos.x += xpostbl[i];
wpos.z += zpostbl[i];
KeepItem(wpos);
}
}
}
}
static int aDOU_setEffect_sub(ACTOR* actor, GAME* game, int house_no, int color) {
static xyz_t offset_tbl[mHS_HOUSE_NUM] = {
{ 1.0f, 68.0f, 14.0f },
{ 1.0f, 62.0f, 12.0f },
{ 1.0f, 56.0f, 10.0f },
{ 1.0f, 50.0f, 8.0f }
};
static xyz_t offset_tbl[mHS_HOUSE_NUM] = {
{ 1.0f, 68.0f, 14.0f }, { 1.0f, 62.0f, 12.0f }, { 1.0f, 56.0f, 10.0f }, { 1.0f, 50.0f, 8.0f }
};
static xyz_t mult_p_tbl[mHS_HOUSE_NUM] = {
{ 26.0f, 42.0f, 0.0f },
{ 23.0f, 38.0f, 0.0f },
{ 20.0f, 34.0f, 0.0f },
{ 17.0f, 30.0f, 0.0f }
};
static xyz_t mult_p_tbl[mHS_HOUSE_NUM] = {
{ 26.0f, 42.0f, 0.0f }, { 23.0f, 38.0f, 0.0f }, { 20.0f, 34.0f, 0.0f }, { 17.0f, 30.0f, 0.0f }
};
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
xyz_t ofs;
xyz_t eff_pos;
xyz_t wpos;
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
xyz_t ofs;
xyz_t eff_pos;
xyz_t wpos;
Matrix_push();
Matrix_push();
/* Initialize base position */
xyz_t_move(&wpos, &actor->world.position);
wpos.x += xpostbl[house_no];
wpos.z += zpostbl[house_no];
Matrix_translate(wpos.x, wpos.y, wpos.z, 0);
/* Initialize effect offset */
xyz_t_move(&ofs, &offset_tbl[color]);
/* Initialize base position */
xyz_t_move(&wpos, &actor->world.position);
wpos.x += xpostbl[house_no];
wpos.z += zpostbl[house_no];
Matrix_translate(wpos.x, wpos.y, wpos.z, 0);
/* Randomize effect offset */
ofs.x += mult_p_tbl[color].x * (fqrand() - 0.5f);
ofs.y += mult_p_tbl[color].y * (fqrand() - 0.5f);
ofs.z += mult_p_tbl[color].z * (fqrand() - 0.5f);
/* Initialize effect offset */
xyz_t_move(&ofs, &offset_tbl[color]);
/* Move effect offset into a world position */
Matrix_Position(&ofs, &eff_pos);
/* Randomize effect offset */
ofs.x += mult_p_tbl[color].x * (fqrand() - 0.5f);
ofs.y += mult_p_tbl[color].y * (fqrand() - 0.5f);
ofs.z += mult_p_tbl[color].z * (fqrand() - 0.5f);
/* Spawn effect */
(*Common_Get(clip).effect_clip->effect_make_proc)(eEC_DOUZOU_LIGHT, eff_pos, 1, 0, game, DOUZOU, color, 0);
/* Move effect offset into a world position */
Matrix_Position(&ofs, &eff_pos);
Matrix_pull();
/* Spawn effect */
(*Common_Get(clip).effect_clip->effect_make_proc)(eEC_DOUZOU_LIGHT, eff_pos, 1, 0, game, DOUZOU, color, 0);
return TRUE;
Matrix_pull();
return TRUE;
}
static void aDOU_setEffect(ACTOR* actor, GAME* game) {
static f32 b_timetbl[mHS_HOUSE_NUM] = { 5.0f, 15.0f, 20.0f, 30.0f };
static f32 r_timetbl[mHS_HOUSE_NUM] = { 10.0f, 30.0f, 40.0f, 60.0f };
static f32 b_timetbl[mHS_HOUSE_NUM] = { 5.0f, 15.0f, 20.0f, 30.0f };
static f32 r_timetbl[mHS_HOUSE_NUM] = { 10.0f, 30.0f, 40.0f, 60.0f };
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
s16 time_tbl[mHS_HOUSE_NUM];
int i;
s16 time_tbl[mHS_HOUSE_NUM];
int i;
time_tbl[0] = douzou->arg0_f;
time_tbl[1] = douzou->arg1_f;
time_tbl[2] = douzou->arg2_f;
time_tbl[3] = douzou->arg3_f;
time_tbl[0] = douzou->arg0_f;
time_tbl[1] = douzou->arg1_f;
time_tbl[2] = douzou->arg2_f;
time_tbl[3] = douzou->arg3_f;
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
if (time_tbl[i] == 0) {
int color = aDOU_get_color(i);
time_tbl[i] = (b_timetbl[color] + r_timetbl[color] * fqrand());
aDOU_setEffect_sub(actor, game, i, color);
}
else {
time_tbl[i]--;
}
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
if (time_tbl[i] == 0) {
int color = aDOU_get_color(i);
time_tbl[i] = (b_timetbl[color] + r_timetbl[color] * fqrand());
aDOU_setEffect_sub(actor, game, i, color);
} else {
time_tbl[i]--;
}
}
}
}
douzou->arg0_f = time_tbl[0];
douzou->arg1_f = time_tbl[1];
douzou->arg2_f = time_tbl[2];
douzou->arg3_f = time_tbl[3];
douzou->arg0_f = time_tbl[0];
douzou->arg1_f = time_tbl[1];
douzou->arg2_f = time_tbl[2];
douzou->arg3_f = time_tbl[3];
}
static void aDOU_set_bgOffset(ACTOR* actor, int height) {
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
xyz_t wpos;
s16 ofs = height == 0 ? 9 : 9;
int i;
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
xyz_t_move(&wpos, &actor->home.position);
wpos.x += xpostbl[i];
wpos.z += zpostbl[i];
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
xyz_t wpos;
s16 ofs = height == 0 ? 9 : 9;
int i;
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
xyz_t_move(&wpos, &actor->home.position);
wpos.x += xpostbl[i];
wpos.z += zpostbl[i];
mCoBG_SetPlussOffset(wpos, ofs, 100);
mCoBG_SetPlussOffset(wpos, ofs, 100);
}
}
}
}
static void aDOU_set_talk_info(ACTOR* actor) {
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
mMsg_Window_c* msg_win = mMsg_Get_base_window_p();
int player_no = mHS_get_pl_no(douzou->arg2);
u8 player_name[PLAYER_NAME_LEN];
rgba_t window_color;
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
mMsg_Window_c* msg_win = mMsg_Get_base_window_p();
int player_no = mHS_get_pl_no(douzou->arg2);
u8 player_name[PLAYER_NAME_LEN];
rgba_t window_color;
if (mLd_PlayerManKindCheckNo(player_no) == FALSE && mPr_GetPlayerName(player_name, player_no)) {
mMsg_Set_free_str(msg_win, 0, player_name, PLAYER_NAME_LEN);
}
if (mLd_PlayerManKindCheckNo(player_no) == FALSE && mPr_GetPlayerName(player_name, player_no)) {
mMsg_Set_free_str(msg_win, 0, player_name, PLAYER_NAME_LEN);
}
mDemo_Set_talk_turn(FALSE);
mDemo_Set_msg_num(0x136B);
mDemo_Set_talk_display_name(FALSE);
mDemo_Set_camera(TRUE);
mPlib_Set_able_hand_all_item_in_demo(TRUE);
mDemo_Set_ListenAble();
mDemo_Set_talk_turn(FALSE);
mDemo_Set_msg_num(0x136B);
mDemo_Set_talk_display_name(FALSE);
mDemo_Set_camera(TRUE);
mPlib_Set_able_hand_all_item_in_demo(TRUE);
mDemo_Set_ListenAble();
window_color.r = 185;
window_color.g = 60;
window_color.b = 40;
window_color.a = 255;
window_color.r = 185;
window_color.g = 60;
window_color.b = 40;
window_color.a = 255;
mDemo_Set_talk_window_color(&window_color);
mDemo_Set_talk_window_color(&window_color);
}
static void aDOU_wait(ACTOR* actor, GAME* game) {
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
GAME_PLAY* play = (GAME_PLAY*)game;
PLAYER_ACTOR* player = get_player_actor_withoutCheck(play);
xyz_t wpos;
xyz_t t_wpos;
s16 target;
s16 now_angle;
s_xyz target_rot;
int i;
static void aDOU_wait(STRUCTURE_ACTOR* douzou, GAME_PLAY* play) {
PLAYER_ACTOR* player = get_player_actor_withoutCheck(play);
xyz_t wpos;
xyz_t t_wpos;
s16 target;
s16 now_angle;
s_xyz target_rot;
int i;
if (mDemo_Check(mDemo_TYPE_SPEAK, actor) == TRUE) {
i = douzou->arg2;
if (mDemo_Check(mDemo_TYPE_SPEAK, (ACTOR*)douzou) == TRUE) {
i = douzou->arg2;
xyz_t_move(&wpos, &actor->world.position);
wpos.x += xpostbl[i];
wpos.z += zpostbl[i];
xyz_t_move(&wpos, &douzou->actor_class.world.position);
wpos.x += xpostbl[i];
wpos.z += zpostbl[i];
target = search_position_angleY(&player->actor_class.world.position, &wpos);
now_angle = player->actor_class.shape_info.rotation.y;
add_calc_short_angle2(&now_angle, target, 0.3f, 0x1000, 0);
target_rot.x = player->actor_class.shape_info.rotation.x;
target_rot.y = now_angle;
target_rot.z = player->actor_class.shape_info.rotation.z;
target = search_position_angleY(&player->actor_class.world.position, &wpos);
now_angle = player->actor_class.shape_info.rotation.y;
add_calc_short_angle2(&now_angle, target, 0.3f, 0x1000, 0);
target_rot.x = player->actor_class.shape_info.rotation.x;
target_rot.y = now_angle;
target_rot.z = player->actor_class.shape_info.rotation.z;
(*get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->Set_force_position_angle_proc)(gamePT, NULL, &target_rot, mPlayer_FORCE_POSITION_ANGLE_ROTY);
}
else {
if (chkTrigger(BUTTON_A)) {
if (ABS(player->actor_class.shape_info.rotation.y) >= 0x6000 && mDemo_Get_talk_actor() == NULL) {
s_xyz test;
f32 dist_xz;
s16 angle_y;
(*get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->Set_force_position_angle_proc)(
gamePT, NULL, &target_rot, mPlayer_FORCE_POSITION_ANGLE_ROTY);
} else {
if (chkTrigger(BUTTON_A)) {
if (ABS(player->actor_class.shape_info.rotation.y) >= 0x6000 && mDemo_Get_talk_actor() == NULL) {
s_xyz test;
f32 dist_xz;
s16 angle_y;
xyz_t_move(&t_wpos, &actor->world.position);
xyz_t_move(&t_wpos, &douzou->actor_class.world.position);
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
wpos.x = t_wpos.x + xpostbl[i];
wpos.z = t_wpos.z + zpostbl[i];
for (i = 0; i < mHS_HOUSE_NUM; i++) {
if (aDOU_set_check(i)) {
wpos.x = t_wpos.x + xpostbl[i];
wpos.z = t_wpos.z + zpostbl[i];
dist_xz = search_position_distanceXZ(&player->actor_class.world.position, &wpos);
now_angle = search_position_angleY(&wpos, &player->actor_class.world.position);
dist_xz = search_position_distanceXZ(&player->actor_class.world.position, &wpos);
now_angle = search_position_angleY(&wpos, &player->actor_class.world.position);
if (dist_xz > 50.0f) {
continue;
if (dist_xz > 50.0f) {
continue;
}
if (ABS((int)now_angle) > 0x1800) {
continue;
}
/* resetti check in the train station acre */
if (Common_Get(reset_flag) == TRUE) {
Common_Set(reset_type, 4);
return;
}
douzou->arg2 = i; // set current statue idx
mDemo_Request(mDemo_TYPE_SPEAK, (ACTOR*)douzou,
&aDOU_set_talk_info); // tell game to process demo sequence
return;
}
}
}
if (ABS((int)now_angle) > 0x1800) {
continue;
}
/* resetti check in the train station acre */
if (Common_Get(reset_flag) == TRUE) {
Common_Set(reset_type, 4);
return;
}
douzou->arg2 = i; // set current statue idx
mDemo_Request(mDemo_TYPE_SPEAK, actor, &aDOU_set_talk_info); // tell game to process demo sequence
return;
}
}
}
}
}
}
extern cKF_Animation_R_c cKF_ba_r_obj_s_douzou;
extern cKF_Animation_R_c cKF_ba_r_obj_w_douzou;
static void aDOU_setup_action(ACTOR* actor, int action) {
static cKF_Animation_R_c* ani[2] = { &cKF_ba_r_obj_s_douzou, &cKF_ba_r_obj_w_douzou };
static aSTR_MOVE_PROC process[1] = { &aDOU_wait };
static cKF_Animation_R_c* ani[2] = { &cKF_ba_r_obj_s_douzou, &cKF_ba_r_obj_w_douzou };
static aSTR_MOVE_PROC process[1] = { &aDOU_wait };
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
cKF_SkeletonInfo_R_init(&douzou->keyframe, douzou->keyframe.skeleton, ani[douzou->season == mTM_SEASON_WINTER], 1.0f, 1.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_REPEAT, NULL);
douzou->action_proc = process[action];
douzou->action = action;
cKF_SkeletonInfo_R_init(&douzou->keyframe, douzou->keyframe.skeleton, ani[douzou->season == mTM_SEASON_WINTER],
1.0f, 1.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_REPEAT, NULL);
douzou->action_proc = process[action];
douzou->action = action;
}
static void aDOU_actor_move(ACTOR* actor, GAME* game) {
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
GAME_PLAY* play = (GAME_PLAY*)game;
STRUCTURE_ACTOR* douzou = (STRUCTURE_ACTOR*)actor;
douzou->keyframe_state = cKF_SkeletonInfo_R_play(&douzou->keyframe);
douzou->keyframe_saved_keyframe = douzou->keyframe.frame_control.current_frame;
(*douzou->action_proc)((ACTOR*)douzou, game);
aDOU_setEffect(actor, game);
douzou->keyframe_state = cKF_SkeletonInfo_R_play(&douzou->keyframe);
douzou->keyframe_saved_keyframe = douzou->keyframe.frame_control.current_frame;
(*douzou->action_proc)(douzou, play);
aDOU_setEffect(actor, game);
}
static void aDOU_actor_init(ACTOR* actor, GAME* game) {
mFI_SetFG_common(DUMMY_DOUZOU, actor->home.position, FALSE);
aDOU_actor_move(actor, game);
actor->mv_proc = &aDOU_actor_move;
mFI_SetFG_common(DUMMY_DOUZOU, actor->home.position, FALSE);
aDOU_actor_move(actor, game);
actor->mv_proc = &aDOU_actor_move;
}
+6 -9
View File
@@ -1,11 +1,10 @@
void aKAG_set_bgOffset(KAGO_ACTOR* actor, int id){
void aKAG_set_bgOffset(KAGO_ACTOR* actor, int id) {
id = id == 0 ? 10 : 10;
mCoBG_SetPlussOffset(actor->structure_class.actor_class.home.position, id, 100);
}
void aKAG_wait(ACTOR*, GAME*){
void aKAG_wait(STRUCTURE_ACTOR* actorx, GAME_PLAY* play) {
}
void aKAG_setup_action(KAGO_ACTOR* kago, int id) {
@@ -17,7 +16,6 @@ void aKAG_setup_action(KAGO_ACTOR* kago, int id) {
kago->structure_class.arg0 = id;
}
void aKAG_actor_move(ACTOR* actor, GAME* game) {
GAME_PLAY* play = (GAME_PLAY*)game;
KAGO_ACTOR* kago = (KAGO_ACTOR*)actor;
@@ -38,14 +36,13 @@ void aKAG_actor_move(ACTOR* actor, GAME* game) {
(mDemo_Check(mDemo_TYPE_SCROLL3, &player->actor_class) == 0) && ((bx != playerbx) || (bz != playerbz))) {
Actor_delete(actor);
} else {
kago->structure_class.action_proc(&kago->structure_class.actor_class, &play->game);
kago->structure_class.action_proc(&kago->structure_class, play);
}
}
void aKAG_actor_init(ACTOR* actor, GAME* game){
void aKAG_actor_init(ACTOR* actor, GAME* game) {
mFI_SetFG_common(0xF111, actor->home.position, 0);
aKAG_actor_move(actor,game);
aKAG_actor_move(actor, game);
actor->mv_proc = aKAG_actor_move;
}
+4 -3
View File
@@ -1,10 +1,11 @@
static void aKOI_wait(ACTOR* actor, GAME* game) {
static void aKOI_wait(STRUCTURE_ACTOR* actorx, GAME_PLAY* play) {
}
static void aKOI_setup_action(KOINOBORI_ACTOR* koinobori, int action) {
static aSTR_MOVE_PROC process[8] = { &aKOI_wait, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
cKF_SkeletonInfo_R_init(&koinobori->structure_class.keyframe, koinobori->structure_class.keyframe.skeleton, &cKF_ba_r_obj_e_koinobori, 1.0f, 1.0f, 1.0f, 0.5f, 0.0f, TRUE, NULL);
cKF_SkeletonInfo_R_init(&koinobori->structure_class.keyframe, koinobori->structure_class.keyframe.skeleton,
&cKF_ba_r_obj_e_koinobori, 1.0f, 1.0f, 1.0f, 0.5f, 0.0f, TRUE, NULL);
koinobori->structure_class.action_proc = process[action];
koinobori->structure_class.action = action;
}
@@ -15,7 +16,7 @@ static void aKOI_actor_move(ACTOR* actor, GAME* game) {
GET_PLAYER_ACTOR(game_play);
cKF_SkeletonInfo_R_play(&koinobori->structure_class.keyframe);
koinobori->structure_class.action_proc(actor, game);
koinobori->structure_class.action_proc(&koinobori->structure_class, game_play);
sAdo_OngenPos((u32)actor, 0x35, &actor->world.position);
}
+15 -28
View File
@@ -1,48 +1,37 @@
extern cKF_Animation_R_c cKF_ba_r_obj_s_lotus;
static int aLOT_getPalNo() {
static int flower_pal_idx_table[18] = {
8, 8, 8,
0, 1, 1,
1, 2, 2,
3, 4, 5,
6, 7, 8,
8, 8, 8
};
static int flower_pal_idx_table[18] = { 8, 8, 8, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8 };
return flower_pal_idx_table[Common_Get(time).term_idx];
}
static void aLOT_wait(ACTOR* actor, GAME* game) {
static void aLOT_wait(STRUCTURE_ACTOR* actorx, GAME_PLAY* play) {
LOTUS_ACTOR* lotus;
int comeback_status;
lotus = (LOTUS_ACTOR*)actor;
lotus = (LOTUS_ACTOR*)actorx;
comeback_status = mPlib_Check_UKI_COMEBACK_STATUS();
if (comeback_status == FALSE
&& (pipeinfo.collision_obj.collision_flags0 & 2) != 0
&& pipeinfo.collision_obj.collided_actor != NULL
&& pipeinfo.collision_obj.collided_actor->id == mAc_PROFILE_UKI) {
if (comeback_status == FALSE && (pipeinfo.collision_obj.collision_flags0 & 2) != 0 &&
pipeinfo.collision_obj.collided_actor != NULL && pipeinfo.collision_obj.collided_actor->id == mAc_PROFILE_UKI) {
lotus->structure_class.keyframe.frame_control.speed = 2.0f;
aLOT_setup_action(lotus, aLOT_ACTION_SHAKE);
}
else {
} else {
add_calc(&lotus->structure_class.keyframe.frame_control.speed, 0.5f, 0.1f, 0.03f, 0.0f);
}
}
static void aLOT_shake(ACTOR* actor, GAME* game) {
static void aLOT_shake(STRUCTURE_ACTOR* actorx, GAME_PLAY* play) {
LOTUS_ACTOR* lotus;
int comeback_status;
lotus = (LOTUS_ACTOR*)actor;
lotus = (LOTUS_ACTOR*)actorx;
comeback_status = mPlib_Check_UKI_COMEBACK_STATUS();
if (comeback_status == FALSE) {
add_calc(&lotus->structure_class.keyframe.frame_control.speed, 0.5f, 0.1f, 0.03f, 0.0f);
}
else {
} else {
aLOT_setup_action(lotus, aLOT_ACTION_WAIT2);
}
}
@@ -51,7 +40,8 @@ static void aLOT_setup_action(LOTUS_ACTOR* lotus, int action) {
static aSTR_MOVE_PROC process[3] = { aLOT_wait, aLOT_wait, aLOT_shake };
if (action == aLOT_ACTION_WAIT1) {
cKF_SkeletonInfo_R_init(&lotus->structure_class.keyframe, lotus->structure_class.keyframe.skeleton, &cKF_ba_r_obj_s_lotus, 1.0f, 129.0f, 1.0f, 0.5f, 0.0f, TRUE, NULL);
cKF_SkeletonInfo_R_init(&lotus->structure_class.keyframe, lotus->structure_class.keyframe.skeleton,
&cKF_ba_r_obj_s_lotus, 1.0f, 129.0f, 1.0f, 0.5f, 0.0f, TRUE, NULL);
}
lotus->structure_class.action_proc = process[action];
@@ -59,15 +49,12 @@ static void aLOT_setup_action(LOTUS_ACTOR* lotus, int action) {
}
static void aLOT_actor_move(ACTOR* actor, GAME* game) {
LOTUS_ACTOR* lotus;
GAME_PLAY* game_play;
GAME_PLAY* game_play = (GAME_PLAY*)game;
STRUCTURE_ACTOR* lotus = (STRUCTURE_ACTOR*)actor;
lotus = (LOTUS_ACTOR*)actor;
game_play = (GAME_PLAY*)game;
cKF_SkeletonInfo_R_play(&lotus->keyframe);
cKF_SkeletonInfo_R_play(&lotus->structure_class.keyframe);
lotus->structure_class.action_proc(actor, game);
lotus->action_proc(lotus, game_play);
CollisionCheck_Uty_ActorWorldPosSetPipeC(actor, &pipeinfo);
CollisionCheck_setOC(game, &game_play->collision_check, &pipeinfo.collision_obj);
+2 -2
View File
@@ -1012,8 +1012,8 @@ static u32 aQMgr_actor_get_pay(u32 base_pay) {
pay = 700;
}
// min: (90.9 * 100) / 10000 = ~0.91x (max percent = ~1.1x)
// max: (109.9 * 760) / 10000 = ~8.36x (min percent = ~6.916x)
// min: (~90.0 * 100) / 10000 = ~0.91x (max percent = ~1.1x)
// max: (~109.9 * 760) / 10000 = ~8.36x (min percent = ~6.916x)
pay_f = 100.0f;
pay_f += pay;
final_pay = (scale * pay_f) / 10000.0f;
+34 -321
View File
@@ -9,346 +9,59 @@ static void aSTR_actor_ct(ACTOR* actor, GAME* game);
static void aSTR_actor_dt(ACTOR* actor, GAME* game);
static void aSTR_actor_move(ACTOR* actor, GAME* game);
ACTOR_PROFILE Structure_Profile = {
mAc_PROFILE_STRUCTURE,
ACTOR_PART_CONTROL,
ACTOR_STATE_NO_MOVE_WHILE_CULLED | ACTOR_STATE_NO_DRAW_WHILE_CULLED,
EMPTY_NO,
ACTOR_OBJ_BANK_KEEP,
sizeof(STRUCTURE_CONTROL_ACTOR),
ACTOR_PROFILE Structure_Profile = { mAc_PROFILE_STRUCTURE,
ACTOR_PART_CONTROL,
ACTOR_STATE_NO_MOVE_WHILE_CULLED | ACTOR_STATE_NO_DRAW_WHILE_CULLED,
EMPTY_NO,
ACTOR_OBJ_BANK_KEEP,
sizeof(STRUCTURE_CONTROL_ACTOR),
&aSTR_actor_ct,
&aSTR_actor_dt,
&aSTR_actor_move,
NONE_ACTOR_PROC,
NULL
};
&aSTR_actor_ct,
&aSTR_actor_dt,
&aSTR_actor_move,
NONE_ACTOR_PROC,
NULL };
static u8 aSTR_overlay[aSTR_ACTOR_TBL_COUNT][aSTR_OVERLAY_SIZE];
static STRUCTURE_ACTOR aSTR_actor_cl[aSTR_ACTOR_TBL_COUNT];
static void aSTR_init_clip_area();
static void aSTR_free_clip_area();
#include "../src/ac_structure_clip.c_inc"
static void aSTR_actor_ct(ACTOR* actor, GAME* game) {
STRUCTURE_CONTROL_ACTOR* structure = (STRUCTURE_CONTROL_ACTOR*)actor;
aSTR_init_clip_area();
structure->str_door_name = Common_Get(door_data).door_actor_name;
structure->reset = Common_Get(door_data).exit_type;
STRUCTURE_CONTROL_ACTOR* structure = (STRUCTURE_CONTROL_ACTOR*)actor;
aSTR_init_clip_area();
structure->str_door_name = Common_Get(door_data).door_actor_name;
structure->reset = Common_Get(door_data).exit_type;
}
static void aSTR_actor_dt(ACTOR* actor, GAME* game) {
aSTR_free_clip_area();
aSTR_free_clip_area();
}
static int request[2]; // TODO: fix ordering by using separate TUs
static void aSTR_check_door_data(STRUCTURE_CONTROL_ACTOR* actor, GAME* game) {
//static int request[2] = { 4, 5 };
static int request[2] = { 4, 5 };
GAME_PLAY* play = (GAME_PLAY*)game;
GAME_PLAY* play = (GAME_PLAY*)game;
if (ITEM_NAME_GET_TYPE(actor->str_door_name) == NAME_TYPE_STRUCT) {
STRUCTURE_ACTOR* str_actor = (STRUCTURE_ACTOR*)Actor_info_fgName_search(&play->actor_info, actor->str_door_name, ACTOR_PART_ITEM);
if (ITEM_NAME_GET_TYPE(actor->str_door_name) == NAME_TYPE_STRUCT) {
STRUCTURE_ACTOR* str_actor =
(STRUCTURE_ACTOR*)Actor_info_fgName_search(&play->actor_info, actor->str_door_name, ACTOR_PART_ITEM);
if (str_actor != NULL && str_actor->request_type == 0) {
str_actor->request_type = request[actor->reset == TRUE];
actor->str_door_name = EMPTY_NO;
if (str_actor != NULL && str_actor->request_type == 0) {
str_actor->request_type = request[actor->reset == TRUE];
actor->str_door_name = EMPTY_NO;
}
} else {
actor->str_door_name = EMPTY_NO;
}
}
else {
actor->str_door_name = EMPTY_NO;
}
}
static void aSTR_actor_move(ACTOR* actor, GAME* game) {
STRUCTURE_CONTROL_ACTOR* structure = (STRUCTURE_CONTROL_ACTOR*)actor;
switch (mFI_GetFieldId()) {
case mFI_FIELD_FG:
aSTR_check_door_data(structure, game);
break;
}
}
extern u16* structure_pal_adrs_nowinter[];
extern u16* structure_pal_adrs_winter[];
static u16* aSTR_get_pal_segment(s16 structure_type) {
static u16** pal_adrs_table[2] = { structure_pal_adrs_nowinter, structure_pal_adrs_winter };
int winter = Common_Get(time).season == mTM_SEASON_WINTER;
return pal_adrs_table[winter][structure_type];
}
typedef struct structure_setup_info_s {
s16 profile;
s16 structure_type; // aSTR_TYPE_*
s16 pal_no; // aSTR_PAL_*
s16 pad;
} aSTR_setup_info;
static STRUCTURE_ACTOR* aSTR_setupActor_proc(GAME* game, mActor_name_t structure_name, s16 arg, f32 x, f32 z) {
static aSTR_setup_info setupInfo_table[] = {
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_A, 0 },
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_B, 0 },
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_C, 0 },
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_D, 0 },
{ mAc_PROFILE_SHOP, aSTR_TYPE_SHOP1, aSTR_PAL_SHOP1, 0 },
{ mAc_PROFILE_CONVENI, aSTR_TYPE_SHOP2, aSTR_PAL_SHOP2, 0 },
{ mAc_PROFILE_SUPER, aSTR_TYPE_SHOP3, aSTR_PAL_SHOP3, 0 },
{ mAc_PROFILE_DEPART, aSTR_TYPE_SHOP4, aSTR_PAL_SHOP4, 0 },
{ mAc_PROFILE_POST_OFFICE, aSTR_TYPE_POST_OFFICE, aSTR_PAL_POST_OFFICE, 0 },
{ mAc_PROFILE_STATION, aSTR_TYPE_STATION1, aSTR_PAL_STATION1_A, 0 },
{ mAc_PROFILE_TRAIN0, aSTR_TYPE_TRAIN0, aSTR_PAL_TRAIN1_A1, 0 },
{ mAc_PROFILE_TRAIN1, aSTR_TYPE_TRAIN1, aSTR_PAL_TRAIN1_A2, 0 },
{ mAc_PROFILE_POLICE_BOX, aSTR_TYPE_POLICE_BOX, aSTR_PAL_POLICE_BOX, 0 },
{ mAc_PROFILE_FALLS, aSTR_TYPE_FALLS, aSTR_PAL_FALLS, 0 },
{ mAc_PROFILE_FALLSESW, aSTR_TYPE_FALLSESW, aSTR_PAL_FALLSESW, 0 },
{ mAc_PROFILE_FALLSESW, aSTR_TYPE_FALLSESW, aSTR_PAL_FALLSESW, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_SHRINE, aSTR_TYPE_SHRINE, aSTR_PAL_SHRINE, 0 },
{ mAc_PROFILE_BRSHOP, aSTR_TYPE_BRSHOP, aSTR_PAL_BR_SHOP, 0 },
{ mAc_PROFILE_BUGGY, aSTR_TYPE_BUGGY, aSTR_PAL_BUGGY, 0 },
{ mAc_PROFILE_S_CAR, aSTR_TYPE_S_CAR, aSTR_PAL_S_CAR, 0 },
{ mAc_PROFILE_KAMAKURA, aSTR_TYPE_KAMAKURA, aSTR_PAL_KAMAKURA, 0 },
{ mAc_PROFILE_GOZA, aSTR_TYPE_GOZA, aSTR_PAL_GOZA, 0 },
{ mAc_PROFILE_GOZA, aSTR_TYPE_GOZA, aSTR_PAL_GOZA, 0 },
{ mAc_PROFILE_RADIO, aSTR_TYPE_RADIO, aSTR_PAL_RADIO, 0 },
{ mAc_PROFILE_YATAI, aSTR_TYPE_YATAI, aSTR_PAL_YATAI, 0 },
{ mAc_PROFILE_YATAI, aSTR_TYPE_YATAI, aSTR_PAL_YATAI, 0 },
{ mAc_PROFILE_TUKIMI, aSTR_TYPE_TUKIMI, aSTR_PAL_TUKIMI, 0 },
{ mAc_PROFILE_TUKIMI, aSTR_TYPE_TUKIMI2, aSTR_PAL_TUKIMI2, 0 },
{ mAc_PROFILE_MIKUJI, aSTR_TYPE_MIKUJI, aSTR_PAL_MIKUJI, 0 },
{ mAc_PROFILE_COUNT, aSTR_TYPE_COUNT, aSTR_PAL_COUNT, 0 },
{ mAc_PROFILE_COUNT02, aSTR_TYPE_COUNT02, aSTR_PAL_COUNT02, 0 },
{ mAc_PROFILE_TAMA, aSTR_TYPE_SPORTSFAIR_A, aSTR_PAL_KAGO_R, 0 },
{ mAc_PROFILE_TAMA, aSTR_TYPE_SPORTSFAIR_B, aSTR_PAL_KAGO_W, 0 },
{ mAc_PROFILE_KAGO, aSTR_TYPE_SPORTSFAIR_A, aSTR_PAL_KAGO_R, 0 },
{ mAc_PROFILE_KAGO, aSTR_TYPE_SPORTSFAIR_B, aSTR_PAL_KAGO_W, 0 },
{ mAc_PROFILE_TURI, aSTR_TYPE_TURI, aSTR_PAL_TURI, 0 },
{ mAc_PROFILE_TURI, aSTR_TYPE_TURI2, aSTR_PAL_TURI2, 0 },
{ mAc_PROFILE_KOINOBORI, aSTR_TYPE_KOINOBORI, aSTR_PAL_KOINOBORI_A, 0 },
{ mAc_PROFILE_DUMP, aSTR_TYPE_DUMP, aSTR_PAL_DUMP, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_A, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_B, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_C, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_D, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_E, 0 },
{ mAc_PROFILE_LOTUS, aSTR_TYPE_LOTUS, aSTR_PAL_01_LOTUS, 0 },
{ mAc_PROFILE_MIKANBOX, aSTR_TYPE_MIKANBOX, aSTR_PAL_MIKANBOX, 0 },
{ mAc_PROFILE_DOUZOU, aSTR_TYPE_DOUZOU, aSTR_PAL_DOUZOU_DAI, 0 },
{ mAc_PROFILE_TOUDAI, aSTR_TYPE_TOUDAI, aSTR_PAL_TOUDAI, 0 },
{ mAc_PROFILE_GHOG, aSTR_TYPE_GHOG, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_HTABLE, aSTR_TYPE_HTABLE, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_HTABLE, aSTR_TYPE_HTABLE, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_HTABLE, aSTR_TYPE_HTABLE, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_TENT, aSTR_TYPE_KAMAKURA, aSTR_PAL_KAMAKURA, 0 },
{ mAc_PROFILE_MUSEUM, aSTR_TYPE_MUSEUM, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_BRIDGE_A, aSTR_TYPE_BRIDGE_A, aSTR_PAL_BRIDGE_A, 0 },
{ mAc_PROFILE_BRIDGE_A, aSTR_TYPE_BRIDGE_A, aSTR_PAL_BRIDGE_A, 0 },
{ mAc_PROFILE_NEEDLEWORK_SHOP, aSTR_TYPE_NEEDLEWORK_SHOP, aSTR_PAL_TAILOR, 0 },
{ mAc_PROFILE_FLAG, aSTR_TYPE_FLAG, aSTR_PAL_FLAG, 0 },
{ mAc_PROFILE_BOAT, aSTR_TYPE_BOAT, aSTR_PAL_BOAT, 0 },
{ mAc_PROFILE_COTTAGE_MY, aSTR_TYPE_COTTAGE_MY, aSTR_PAL_MYHOME_ISLAND, 0 },
{ mAc_PROFILE_COTTAGE_NPC, aSTR_TYPE_COTTAGE_NPC, aSTR_PAL_HOUSE_I, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
};
STRUCTURE_ACTOR* str_actor;
GAME_PLAY* play = (GAME_PLAY*)game;
s16 profile;
xyz_t pos;
if (structure_name < NPC_HOUSE_END) {
mNpc_SearchAnimalinfo(Save_Get(animals), NPC_HOUSE_ID_TO_NPC_ID(structure_name), ANIMAL_NUM_MAX);
profile = mAc_PROFILE_HOUSE;
}
else if (structure_name >= HOUSE0 && structure_name < SHOP0) {
int idx = structure_name - STRUCTURE_START;
profile = setupInfo_table[idx].profile;
}
else if (structure_name >= TRAIN_STATION && structure_name < TRAIN0) {
profile = mAc_PROFILE_STATION;
}
else {
int idx = structure_name - STRUCTURE_START;
profile = setupInfo_table[idx].profile;
}
pos.x = x;
pos.z = z;
pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pos, 0.0f);
str_actor = (STRUCTURE_ACTOR*)Actor_info_make_actor(&play->actor_info, game, profile, pos.x, pos.y, pos.z, 0, 0, 0, play->block_table.block_x, play->block_table.block_z, -1, structure_name, arg, -1, -1);
if (str_actor != NULL) {
mFI_SetFG_common(RSV_NO, pos, FALSE);
}
return str_actor;
}
static int aSTR_get_overlay_free_area_idx() {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
aSTR_Overlay_info_c* overlay_info = clip->overlay_area;
int res = -1;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (overlay_info->used == FALSE) {
res = i;
break;
STRUCTURE_CONTROL_ACTOR* structure = (STRUCTURE_CONTROL_ACTOR*)actor;
switch (mFI_GetFieldId()) {
case mFI_FIELD_FG:
aSTR_check_door_data(structure, game);
break;
}
overlay_info++;
}
return res;
}
static void aSTR_get_overlay_area_proc(ACTOR_DLFTBL* dlftbl) {
int overlay_idx = aSTR_get_overlay_free_area_idx();
if (overlay_idx != -1) {
aSTR_Overlay_info_c* overlay_info = Common_Get(clip).structure_clip->overlay_area + overlay_idx;
aSTR_Overlay_info_c* overlay2_info;
dlftbl->alloc_buf = overlay_info->overlay_p;
overlay2_info = Common_Get(clip).structure_clip->overlay_area + overlay_idx;
overlay2_info->used = TRUE;
}
else {
dlftbl->alloc_buf = NULL;
}
}
static void aSTR_free_overlay_area_proc(ACTOR_DLFTBL* dlftbl) {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
aSTR_Overlay_info_c* overlay_info = clip->overlay_area;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (overlay_info->overlay_p == dlftbl->alloc_buf) {
overlay_info->used = FALSE;
dlftbl->alloc_buf = NULL;
break;
}
overlay_info++;
}
}
static STRUCTURE_ACTOR* aSTR_get_actor_area_proc() {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
STRUCTURE_ACTOR** str_tbl = clip->structure_actor_tbl;
int* str_used_tbl = clip->structure_actor_used_tbl;
STRUCTURE_ACTOR* res = NULL;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (*str_tbl != NULL && *str_used_tbl == FALSE) {
*str_used_tbl = TRUE;
res = *str_tbl;
break;
}
str_tbl++;
str_used_tbl++;
}
return res;
}
static void aSTR_free_actor_area_proc(STRUCTURE_ACTOR* str_actor) {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
STRUCTURE_ACTOR** str_tbl = clip->structure_actor_tbl;
int* str_used_tbl = clip->structure_actor_used_tbl;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (*str_tbl == str_actor) {
*str_used_tbl = FALSE;
break;
}
str_tbl++;
str_used_tbl++;
}
}
static void aSTR_init_clip_area() {
if (Common_Get(clip).structure_clip == NULL) {
int i;
Common_Set(clip.structure_clip, (aSTR_Clip_c*)zelda_malloc(sizeof(aSTR_Clip_c)));
Common_Get(clip).structure_clip->setup_actor_proc = &aSTR_setupActor_proc;
Common_Get(clip).structure_clip->get_overlay_area_proc = &aSTR_get_overlay_area_proc;
Common_Get(clip).structure_clip->free_overlay_area_proc = &aSTR_free_overlay_area_proc;
Common_Get(clip).structure_clip->get_actor_area_proc = &aSTR_get_actor_area_proc;
Common_Get(clip).structure_clip->free_actor_area_proc = &aSTR_free_actor_area_proc;
Common_Get(clip).structure_clip->get_pal_segment_proc = &aSTR_get_pal_segment;
{
STRUCTURE_ACTOR** str_tbl = Common_Get(clip).structure_clip->structure_actor_tbl;
int* str_used_tbl = Common_Get(clip).structure_clip->structure_actor_used_tbl;
aSTR_Overlay_info_c* overlay_info = Common_Get(clip).structure_clip->overlay_area;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
*str_tbl = &aSTR_actor_cl[i];
*str_used_tbl = FALSE;
str_tbl++;
str_used_tbl++;
overlay_info->overlay_p = aSTR_overlay[i];
overlay_info->used = FALSE;
overlay_info++;
}
}
}
}
static void aSTR_free_clip_area() {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
if (clip != NULL) {
STRUCTURE_ACTOR** str_tbl = clip->structure_actor_tbl;
aSTR_Overlay_info_c* overlay_info = clip->overlay_area;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (*str_tbl != NULL) {
*str_tbl = NULL;
}
if (overlay_info->overlay_p != NULL) {
overlay_info->overlay_p = NULL;
}
str_tbl++;
overlay_info++;
}
zelda_free(Common_Get(clip).structure_clip);
Common_Set(clip.structure_clip, NULL);
}
}
static int request[2] = { 4, 5 }; // TODO: remove when separated TUs are implemented and aSTR_check_door_data is corrected
+278
View File
@@ -0,0 +1,278 @@
extern u16* structure_pal_adrs_nowinter[];
extern u16* structure_pal_adrs_winter[];
static u16* aSTR_get_pal_segment(s16 structure_type) {
static u16** pal_adrs_table[2] = { structure_pal_adrs_nowinter, structure_pal_adrs_winter };
int winter = Common_Get(time).season == mTM_SEASON_WINTER;
return pal_adrs_table[winter][structure_type];
}
typedef struct structure_setup_info_s {
s16 profile;
s16 structure_type; // aSTR_TYPE_*
s16 pal_no; // aSTR_PAL_*
s16 pad;
} aSTR_setup_info;
static STRUCTURE_ACTOR* aSTR_setupActor_proc(GAME* game, mActor_name_t structure_name, s16 arg, f32 x, f32 z) {
static aSTR_setup_info setupInfo_table[] = {
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_A, 0 },
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_B, 0 },
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_C, 0 },
{ mAc_PROFILE_MYHOUSE, aSTR_TYPE_MYHOME, aSTR_PAL_MYHOME_D, 0 },
{ mAc_PROFILE_SHOP, aSTR_TYPE_SHOP1, aSTR_PAL_SHOP1, 0 },
{ mAc_PROFILE_CONVENI, aSTR_TYPE_SHOP2, aSTR_PAL_SHOP2, 0 },
{ mAc_PROFILE_SUPER, aSTR_TYPE_SHOP3, aSTR_PAL_SHOP3, 0 },
{ mAc_PROFILE_DEPART, aSTR_TYPE_SHOP4, aSTR_PAL_SHOP4, 0 },
{ mAc_PROFILE_POST_OFFICE, aSTR_TYPE_POST_OFFICE, aSTR_PAL_POST_OFFICE, 0 },
{ mAc_PROFILE_STATION, aSTR_TYPE_STATION1, aSTR_PAL_STATION1_A, 0 },
{ mAc_PROFILE_TRAIN0, aSTR_TYPE_TRAIN0, aSTR_PAL_TRAIN1_A1, 0 },
{ mAc_PROFILE_TRAIN1, aSTR_TYPE_TRAIN1, aSTR_PAL_TRAIN1_A2, 0 },
{ mAc_PROFILE_POLICE_BOX, aSTR_TYPE_POLICE_BOX, aSTR_PAL_POLICE_BOX, 0 },
{ mAc_PROFILE_FALLS, aSTR_TYPE_FALLS, aSTR_PAL_FALLS, 0 },
{ mAc_PROFILE_FALLSESW, aSTR_TYPE_FALLSESW, aSTR_PAL_FALLSESW, 0 },
{ mAc_PROFILE_FALLSESW, aSTR_TYPE_FALLSESW, aSTR_PAL_FALLSESW, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
{ mAc_PROFILE_SHRINE, aSTR_TYPE_SHRINE, aSTR_PAL_SHRINE, 0 },
{ mAc_PROFILE_BRSHOP, aSTR_TYPE_BRSHOP, aSTR_PAL_BR_SHOP, 0 },
{ mAc_PROFILE_BUGGY, aSTR_TYPE_BUGGY, aSTR_PAL_BUGGY, 0 },
{ mAc_PROFILE_S_CAR, aSTR_TYPE_S_CAR, aSTR_PAL_S_CAR, 0 },
{ mAc_PROFILE_KAMAKURA, aSTR_TYPE_KAMAKURA, aSTR_PAL_KAMAKURA, 0 },
{ mAc_PROFILE_GOZA, aSTR_TYPE_GOZA, aSTR_PAL_GOZA, 0 },
{ mAc_PROFILE_GOZA, aSTR_TYPE_GOZA, aSTR_PAL_GOZA, 0 },
{ mAc_PROFILE_RADIO, aSTR_TYPE_RADIO, aSTR_PAL_RADIO, 0 },
{ mAc_PROFILE_YATAI, aSTR_TYPE_YATAI, aSTR_PAL_YATAI, 0 },
{ mAc_PROFILE_YATAI, aSTR_TYPE_YATAI, aSTR_PAL_YATAI, 0 },
{ mAc_PROFILE_TUKIMI, aSTR_TYPE_TUKIMI, aSTR_PAL_TUKIMI, 0 },
{ mAc_PROFILE_TUKIMI, aSTR_TYPE_TUKIMI2, aSTR_PAL_TUKIMI2, 0 },
{ mAc_PROFILE_MIKUJI, aSTR_TYPE_MIKUJI, aSTR_PAL_MIKUJI, 0 },
{ mAc_PROFILE_COUNT, aSTR_TYPE_COUNT, aSTR_PAL_COUNT, 0 },
{ mAc_PROFILE_COUNT02, aSTR_TYPE_COUNT02, aSTR_PAL_COUNT02, 0 },
{ mAc_PROFILE_TAMA, aSTR_TYPE_SPORTSFAIR_A, aSTR_PAL_KAGO_R, 0 },
{ mAc_PROFILE_TAMA, aSTR_TYPE_SPORTSFAIR_B, aSTR_PAL_KAGO_W, 0 },
{ mAc_PROFILE_KAGO, aSTR_TYPE_SPORTSFAIR_A, aSTR_PAL_KAGO_R, 0 },
{ mAc_PROFILE_KAGO, aSTR_TYPE_SPORTSFAIR_B, aSTR_PAL_KAGO_W, 0 },
{ mAc_PROFILE_TURI, aSTR_TYPE_TURI, aSTR_PAL_TURI, 0 },
{ mAc_PROFILE_TURI, aSTR_TYPE_TURI2, aSTR_PAL_TURI2, 0 },
{ mAc_PROFILE_KOINOBORI, aSTR_TYPE_KOINOBORI, aSTR_PAL_KOINOBORI_A, 0 },
{ mAc_PROFILE_DUMP, aSTR_TYPE_DUMP, aSTR_PAL_DUMP, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_A, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_B, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_C, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_D, 0 },
{ mAc_PROFILE_WINDMILL, aSTR_TYPE_WINDMILL, aSTR_PAL_WINDMILL_E, 0 },
{ mAc_PROFILE_LOTUS, aSTR_TYPE_LOTUS, aSTR_PAL_01_LOTUS, 0 },
{ mAc_PROFILE_MIKANBOX, aSTR_TYPE_MIKANBOX, aSTR_PAL_MIKANBOX, 0 },
{ mAc_PROFILE_DOUZOU, aSTR_TYPE_DOUZOU, aSTR_PAL_DOUZOU_DAI, 0 },
{ mAc_PROFILE_TOUDAI, aSTR_TYPE_TOUDAI, aSTR_PAL_TOUDAI, 0 },
{ mAc_PROFILE_GHOG, aSTR_TYPE_GHOG, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_HTABLE, aSTR_TYPE_HTABLE, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_HTABLE, aSTR_TYPE_HTABLE, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_HTABLE, aSTR_TYPE_HTABLE, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_TENT, aSTR_TYPE_KAMAKURA, aSTR_PAL_KAMAKURA, 0 },
{ mAc_PROFILE_MUSEUM, aSTR_TYPE_MUSEUM, aSTR_PAL_MUSEUM, 0 },
{ mAc_PROFILE_BRIDGE_A, aSTR_TYPE_BRIDGE_A, aSTR_PAL_BRIDGE_A, 0 },
{ mAc_PROFILE_BRIDGE_A, aSTR_TYPE_BRIDGE_A, aSTR_PAL_BRIDGE_A, 0 },
{ mAc_PROFILE_NEEDLEWORK_SHOP, aSTR_TYPE_NEEDLEWORK_SHOP, aSTR_PAL_TAILOR, 0 },
{ mAc_PROFILE_FLAG, aSTR_TYPE_FLAG, aSTR_PAL_FLAG, 0 },
{ mAc_PROFILE_BOAT, aSTR_TYPE_BOAT, aSTR_PAL_BOAT, 0 },
{ mAc_PROFILE_COTTAGE_MY, aSTR_TYPE_COTTAGE_MY, aSTR_PAL_MYHOME_ISLAND, 0 },
{ mAc_PROFILE_COTTAGE_NPC, aSTR_TYPE_COTTAGE_NPC, aSTR_PAL_HOUSE_I, 0 },
{ mAc_PROFILE_RESERVE, aSTR_TYPE_RESERVE, aSTR_PAL_RESERVE, 0 },
};
STRUCTURE_ACTOR* str_actor;
GAME_PLAY* play = (GAME_PLAY*)game;
s16 profile;
xyz_t pos;
if (structure_name < NPC_HOUSE_END) {
mNpc_SearchAnimalinfo(Save_Get(animals), NPC_HOUSE_ID_TO_NPC_ID(structure_name), ANIMAL_NUM_MAX);
profile = mAc_PROFILE_HOUSE;
} else if (structure_name >= HOUSE0 && structure_name < SHOP0) {
int idx = structure_name - STRUCTURE_START;
profile = setupInfo_table[idx].profile;
} else if (structure_name >= TRAIN_STATION && structure_name < TRAIN0) {
profile = mAc_PROFILE_STATION;
} else {
int idx = structure_name - STRUCTURE_START;
profile = setupInfo_table[idx].profile;
}
pos.x = x;
pos.z = z;
pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(pos, 0.0f);
str_actor = (STRUCTURE_ACTOR*)Actor_info_make_actor(&play->actor_info, game, profile, pos.x, pos.y, pos.z, 0, 0, 0,
play->block_table.block_x, play->block_table.block_z, -1,
structure_name, arg, -1, -1);
if (str_actor != NULL) {
mFI_SetFG_common(RSV_NO, pos, FALSE);
}
return str_actor;
}
static int aSTR_get_overlay_free_area_idx() {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
aSTR_Overlay_info_c* overlay_info = clip->overlay_area;
int res = -1;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (overlay_info->used == FALSE) {
res = i;
break;
}
overlay_info++;
}
return res;
}
static void aSTR_get_overlay_area_proc(ACTOR_DLFTBL* dlftbl) {
int overlay_idx = aSTR_get_overlay_free_area_idx();
if (overlay_idx != -1) {
aSTR_Overlay_info_c* overlay_info = Common_Get(clip).structure_clip->overlay_area + overlay_idx;
aSTR_Overlay_info_c* overlay2_info;
dlftbl->alloc_buf = overlay_info->overlay_p;
overlay2_info = Common_Get(clip).structure_clip->overlay_area + overlay_idx;
overlay2_info->used = TRUE;
} else {
dlftbl->alloc_buf = NULL;
}
}
static void aSTR_free_overlay_area_proc(ACTOR_DLFTBL* dlftbl) {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
aSTR_Overlay_info_c* overlay_info = clip->overlay_area;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (overlay_info->overlay_p == dlftbl->alloc_buf) {
overlay_info->used = FALSE;
dlftbl->alloc_buf = NULL;
break;
}
overlay_info++;
}
}
static STRUCTURE_ACTOR* aSTR_get_actor_area_proc() {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
STRUCTURE_ACTOR** str_tbl = clip->structure_actor_tbl;
int* str_used_tbl = clip->structure_actor_used_tbl;
STRUCTURE_ACTOR* res = NULL;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (*str_tbl != NULL && *str_used_tbl == FALSE) {
*str_used_tbl = TRUE;
res = *str_tbl;
break;
}
str_tbl++;
str_used_tbl++;
}
return res;
}
static void aSTR_free_actor_area_proc(STRUCTURE_ACTOR* str_actor) {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
STRUCTURE_ACTOR** str_tbl = clip->structure_actor_tbl;
int* str_used_tbl = clip->structure_actor_used_tbl;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (*str_tbl == str_actor) {
*str_used_tbl = FALSE;
break;
}
str_tbl++;
str_used_tbl++;
}
}
static void aSTR_init_clip_area() {
if (Common_Get(clip).structure_clip == NULL) {
int i;
Common_Set(clip.structure_clip, (aSTR_Clip_c*)zelda_malloc(sizeof(aSTR_Clip_c)));
Common_Get(clip).structure_clip->setup_actor_proc = &aSTR_setupActor_proc;
Common_Get(clip).structure_clip->get_overlay_area_proc = &aSTR_get_overlay_area_proc;
Common_Get(clip).structure_clip->free_overlay_area_proc = &aSTR_free_overlay_area_proc;
Common_Get(clip).structure_clip->get_actor_area_proc = &aSTR_get_actor_area_proc;
Common_Get(clip).structure_clip->free_actor_area_proc = &aSTR_free_actor_area_proc;
Common_Get(clip).structure_clip->get_pal_segment_proc = &aSTR_get_pal_segment;
{
STRUCTURE_ACTOR** str_tbl = Common_Get(clip).structure_clip->structure_actor_tbl;
int* str_used_tbl = Common_Get(clip).structure_clip->structure_actor_used_tbl;
aSTR_Overlay_info_c* overlay_info = Common_Get(clip).structure_clip->overlay_area;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
*str_tbl = &aSTR_actor_cl[i];
*str_used_tbl = FALSE;
str_tbl++;
str_used_tbl++;
overlay_info->overlay_p = aSTR_overlay[i];
overlay_info->used = FALSE;
overlay_info++;
}
}
}
}
static void aSTR_free_clip_area() {
aSTR_Clip_c* clip = Common_Get(clip).structure_clip;
if (clip != NULL) {
STRUCTURE_ACTOR** str_tbl = clip->structure_actor_tbl;
aSTR_Overlay_info_c* overlay_info = clip->overlay_area;
int i;
for (i = 0; i < aSTR_ACTOR_TBL_COUNT; i++) {
if (*str_tbl != NULL) {
*str_tbl = NULL;
}
if (overlay_info->overlay_p != NULL) {
overlay_info->overlay_p = NULL;
}
str_tbl++;
overlay_info++;
}
zelda_free(Common_Get(clip).structure_clip);
Common_Set(clip.structure_clip, NULL);
}
}