summaryrefslogtreecommitdiff
path: root/src/d/d_attention.cpp
diff options
context:
space:
mode:
authorTakaRikka <38417346+TakaRikka@users.noreply.github.com>2025-09-08 02:01:20 -0700
committerGitHub <noreply@github.com>2025-09-08 12:01:20 +0300
commit52aa5f677f722f14f10298a3ebe1e355a4c26938 (patch)
tree583eb03de69d9a2232be573fd4fe5f4e5380e417 /src/d/d_attention.cpp
parentcbe5aaca8f2cb2e5046166b79a46de1e97f82730 (diff)
scannon / scannon_crs / scannon_ten done (#2632)
* scannon done * scannon_crs done * scannon_ten done * pr * attention debug stuff * attn flags * fix build
Diffstat (limited to 'src/d/d_attention.cpp')
-rw-r--r--src/d/d_attention.cpp431
1 files changed, 332 insertions, 99 deletions
diff --git a/src/d/d_attention.cpp b/src/d/d_attention.cpp
index 1e992bf016..8d8a652ebd 100644
--- a/src/d/d_attention.cpp
+++ b/src/d/d_attention.cpp
@@ -1,25 +1,26 @@
-//
-// Generated By: dol2asm
-// Translation Unit: d/d_attention
-//
-
#include "d/dolzel.h"
#include "d/d_attention.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "d/actor/d_a_player.h"
#include "d/d_com_inf_game.h"
+#include "d/d_s_play.h"
+#include "d/d_debug_viewer.h"
+#include "d/d_stage.h"
#include "f_op/f_op_actor_mng.h"
#include "m_Do/m_Do_controller_pad.h"
+#include "SSystem/SComponent/c_counter.h"
#define DRAW_TYPE_YELLOW 0
#define DRAW_TYPE_RED 1
-class dAttDrawParam_c {
+class dAttDrawParam_c : public JORReflexible {
public:
/* 80070158 */ dAttDrawParam_c();
/* 80073FC4 */ virtual ~dAttDrawParam_c() {}
+ void genMessage(JORMContext*);
+
/* 0x4 */ s8 field_0x4;
/* 0x8 */ f32 mCursorDistance;
/* 0xC */ f32 field_0xc;
@@ -28,6 +29,10 @@ public:
/* 80070018-80070038 06A958 0020+00 2/2 0/0 0/0 .text padLockButton__25@unnamed@d_attention_cpp@Fl
*/
namespace {
+static bool padLockTrigger(s32 i_padNo) {
+ return mDoCPd_c::getTrigL(i_padNo) != 0;
+}
+
static bool padLockButton(s32 i_padNo) {
return mDoCPd_c::getHoldLockL(i_padNo) != 0;
}
@@ -35,18 +40,18 @@ static bool padLockButton(s32 i_padNo) {
/* 803A9BF8-803A9C04 006D18 000C+00 2/2 0/0 0/0 .data loc_type_tbl__12dAttention_c */
type_tbl_entry dAttention_c::loc_type_tbl[3] = {
- {fopAc_attn_LOCK_e, 0x1},
- {fopAc_attn_TALK_e, 0x2},
- {fopAc_attn_BATTLE_e, 0x4},
+ {fopAc_attn_LOCK_e, fopAc_AttnFlag_LOCK_e},
+ {fopAc_attn_TALK_e, fopAc_AttnFlag_TALK_e},
+ {fopAc_attn_BATTLE_e, fopAc_AttnFlag_BATTLE_e},
};
/* 803A9C04-803A9C18 006D24 0014+00 1/1 0/0 0/0 .data act_type_tbl__12dAttention_c */
type_tbl_entry dAttention_c::act_type_tbl[5] = {
- {fopAc_attn_SPEAK_e, 0x8},
- {fopAc_attn_CARRY_e, 0x10},
- {fopAc_attn_DOOR_e, 0x20},
- {fopAc_attn_JUEL_e, 0x40},
- {fopAc_attn_ETC_e, 0x80},
+ {fopAc_attn_SPEAK_e, fopAc_AttnFlag_SPEAK_e},
+ {fopAc_attn_CARRY_e, fopAc_AttnFlag_CARRY_e},
+ {fopAc_attn_DOOR_e, fopAc_AttnFlag_DOOR_e},
+ {fopAc_attn_JUEL_e, fopAc_AttnFlag_JUEL_e},
+ {fopAc_attn_ETC_e, fopAc_AttnFlag_ETC_e},
};
/* 80450F58-80450F60 000458 0008+00 0/0 2/2 0/0 .sbss None */
@@ -78,11 +83,61 @@ dAttParam_c::dAttParam_c(s32) {
field_0x38 = 1.7f;
field_0x3c = 1.0f;
- l_isFinalBossStg = strcmp(dComIfGp_getStartStageName(), "D_MN09B") == 0;
+ if (strcmp(dComIfGp_getStartStageName(), "D_MN09B") == 0) {
+ l_isFinalBossStg = 1;
+ } else {
+ l_isFinalBossStg = 0;
+ }
+
+#if DEBUG
+ // "Attention System"
+ connectHIO("注目システム");
+#endif
}
/* 80070110-80070158 06AA50 0048+00 2/1 0/0 0/0 .text __dt__11dAttParam_cFv */
-dAttParam_c::~dAttParam_c() {}
+dAttParam_c::~dAttParam_c() {
+#if DEBUG
+ releaseHIO();
+#endif
+}
+
+#if DEBUG
+void dAttParam_c::genMessage(JORMContext* mctx) {
+ mctx->genCheckBox(" リスト表示", &mFlags, 0x4000, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("-", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genCheckBox(" 有効", &mFlags, 4, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genCheckBox(" ホールドモード", &mFlags, 1, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genCheckBox(" 矢印表示OFF", &mFlags, 0x10, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("カーソル", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("選択時", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("スケールX", &mSelCursorScaleX, 1.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("スケールY", &mSelCursorScaleY, 1.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("Y Pos Offset", &mSelCursorOffsetY, -100.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("注目時", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("スケールX", &mAttnCursorScaleX, 1.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("スケールY", &mAttnCursorScaleY, 1.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("Y Pos Offset", &mAttnCursorOffsetY, -100.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("出現フレーム", &mAttnCursorAppearFrames, 0, 0xff, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("消去フレーム", &mAttnCursorDisappearFrames, 0, 0xff, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("アニメーションスピード", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("選択時", &field_0x38, 1.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("注目時", &field_0x3c, 1.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("-", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider(" SW Mode 解除", &mSWModeDisable, -1.0f, 0.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("-", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genCheckBox(" 表示デバック", &mFlags, 2, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("-", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider(" 警告BGM距離", &mDangerBGMDistance, 0.0f, 8000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider(" + マージン", &mBGMDistMargin, 0.0f, 8000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("-", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genCheckBox(" デバッグ表示", &mFlags, 0x8000, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider(" 表示位置 X", &mDebugDispPosX, 0, 0x280, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider(" Y", &mDebugDispPosY, 0, 0x1e0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genCheckBox(" KEEP挙動", &mFlags, 8, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genLabel("-", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+}
+#endif
/* 80070158-80070178 06AA98 0020+00 1/1 0/0 0/0 .text __ct__15dAttDrawParam_cFv */
dAttDrawParam_c::dAttDrawParam_c() {
@@ -90,11 +145,18 @@ dAttDrawParam_c::dAttDrawParam_c() {
field_0xc = 2.0f;
}
+#if DEBUG
+void dAttDrawParam_c::genMessage(JORMContext* mctx) {
+ mctx->genLabel("カーソル", 0, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+ mctx->genSlider("距離", &mCursorDistance, 0.0f, 500000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18);
+}
+#endif
+
/* 80070178-80070198 06AAB8 0020+00 1/0 0/0 0/0 .text
* execute__19dAttDraw_CallBack_cFUsP16J3DTransformInfo */
int dAttDraw_CallBack_c::execute(u16 param_0, J3DTransformInfo* transform) {
if (param_0 == 0) {
- transform->mTranslate.y *= 0.6f;
+ transform->mTranslate.y *= YREG_F(17) + 0.6f;
}
return 1;
@@ -112,14 +174,11 @@ dAttention_c::dAttention_c(fopAc_ac_c* i_player, u32 i_padNo) {
field_0x32e = 0;
field_0x32f = 0;
- mCheckObjectOffset = 0;
- mActionOffset = 0;
- mLockOnOffset = 0;
+ mLockOnOffset = mActionOffset = mCheckObjectOffset = 0;
initList(0xFFFFFFFF);
mPlayerAttentionFlags = 0;
- field_0x32a = 0;
- mAttnStatus = EState_NONE;
+ mAttnStatus = field_0x32a = EState_NONE;
field_0x32b = 4;
field_0x32c = 0;
mAttnBlockTimer = 0;
@@ -135,10 +194,10 @@ dAttention_c::dAttention_c(fopAc_ac_c* i_player, u32 i_padNo) {
for (int i = 0; i < 2; i++) {
draw[i].mModel[DRAW_TYPE_YELLOW] = mDoExt_J3DModel__create(modelDataY, 0x80000, 0x11000285);
- JUT_ASSERT(0x1CA, draw[i].mModel[DRAW_TYPE_YELLOW] != 0);
+ JUT_ASSERT(0x1CA, draw[i].mModel[0] != 0);
draw[i].mModel[DRAW_TYPE_RED] = mDoExt_J3DModel__create(modelDataR, 0x80000, 0x11000285);
- JUT_ASSERT(0x1D4, draw[i].mModel[DRAW_TYPE_RED] != 0);
+ JUT_ASSERT(0x1D4, draw[i].mModel[1] != 0);
int res;
res = draw[i].mNoticeCursorBck[DRAW_TYPE_YELLOW].init((J3DAnmTransform*)dComIfG_getObjectRes("Always", 0x11), TRUE, 2, 1.0f, 0, -1, false);
@@ -206,7 +265,7 @@ dAttention_c::dAttention_c(fopAc_ac_c* i_player, u32 i_padNo) {
mLookTarget.init();
new (&mAttParam) dAttParam_c(0);
- g_AttDwHIO.field_0x4 = -1;
+ g_AttDwHIO.field_0x4 = mDoHIO_CREATE_CHILD("注目カーソル", &g_AttDwHIO);
}
/* 80070774-80070844 06B0B4 00D0+00 0/0 2/2 0/0 .text __dt__12dAttention_cFv */
@@ -215,6 +274,8 @@ dAttention_c::~dAttention_c() {
mDoExt_destroySolidHeap(heap);
heap = NULL;
}
+
+ mDoHIO_DELETE_CHILD(g_AttDwHIO.field_0x4);
}
/* 80070844-80070880 06B184 003C+00 2/2 2/2 8/8 .text GetLockonList__12dAttention_cFl */
@@ -230,12 +291,13 @@ dAttList_c* dAttention_c::GetLockonList(s32 i_no) {
dAttList_c* dAttention_c::getActionBtnB() {
int i;
dAttList_c* list = GetLockonList(0);
+ fopAc_ac_c* actor;
- if (list != NULL && list->getActor() != NULL &&
- list->mType == fopAc_attn_TALK_e && LockonTruth() &&
- !(list->getActor()->attention_info.flags & 0x2000000))
- {
- return list;
+ if (list != NULL && list->getActor() != NULL && list->mType == fopAc_attn_TALK_e && LockonTruth()) {
+ actor = list->getActor();
+ if (!(actor->attention_info.flags & fopAc_AttnFlag_NOTALK_e)) {
+ return list;
+ }
}
if (mActionCount == 0) {
@@ -244,7 +306,8 @@ dAttList_c* dAttention_c::getActionBtnB() {
for (i = 0; i < mActionCount; i++) {
if (mActionList[i].mType == fopAc_attn_SPEAK_e) {
- if (!(mActionList[i].getActor()->attention_info.flags & 0x2000000)) {
+ actor = mActionList[i].getActor();
+ if (!(actor->attention_info.flags & fopAc_AttnFlag_NOTALK_e)) {
return &mActionList[i];
}
continue;
@@ -259,9 +322,11 @@ dAttList_c* dAttention_c::getActionBtnB() {
dAttList_c* dAttention_c::getActionBtnXY() {
int i;
dAttList_c* list = GetLockonList(0);
+ fopAc_ac_c* actor;
if (list != NULL && list->getActor() != NULL && list->mType == fopAc_attn_TALK_e && LockonTruth()) {
- if (list->getActor()->eventInfo.chkCondition(dEvtCnd_CANTALKITEM_e)) {
+ actor = list->getActor();
+ if (actor->eventInfo.chkCondition(dEvtCnd_CANTALKITEM_e)) {
return list;
}
@@ -274,7 +339,8 @@ dAttList_c* dAttention_c::getActionBtnXY() {
for (i = 0; i < mActionCount; i++) {
if (mActionList[i].mType == fopAc_attn_SPEAK_e) {
- if (mActionList[i].getActor()->eventInfo.chkCondition(dEvtCnd_CANTALKITEM_e)) {
+ actor = mActionList[i].getActor();
+ if (actor->eventInfo.chkCondition(dEvtCnd_CANTALKITEM_e)) {
return &mActionList[i];
}
}
@@ -288,7 +354,8 @@ int dAttention_c::loc_type_num = 3;
/* 80070A70-80070AC0 06B3B0 0050+00 1/1 0/0 0/0 .text chkAttMask__12dAttention_cFUlUl */
int dAttention_c::chkAttMask(u32 i_type, u32 i_mask) {
- for (int i = 0; i < loc_type_num; i++) {
+ int i;
+ for (i = 0; i < loc_type_num; i++) {
if (i_type == loc_type_tbl[i].type) {
return i_mask & loc_type_tbl[i].mask;
}
@@ -300,15 +367,12 @@ int dAttention_c::chkAttMask(u32 i_type, u32 i_mask) {
/* 80070AC0-80070B2C 06B400 006C+00 2/2 0/0 0/0 .text check_event_condition__FUlUs */
static int check_event_condition(u32 i_attnType, u16 i_condition) {
switch (i_attnType) {
- case fopAc_attn_SPEAK_e:
case fopAc_attn_TALK_e:
+ case fopAc_attn_SPEAK_e:
if (!(i_condition & dEvtCnd_CANTALK_e)) {
return true;
}
break;
- case fopAc_attn_CARRY_e:
- case fopAc_attn_BATTLE_e:
- break;
case fopAc_attn_DOOR_e:
if (!(i_condition & dEvtCnd_CANDOOR_e)) {
return true;
@@ -329,7 +393,7 @@ int dAttention_c::act_type_num = 5;
/* 80450668-8045066C 0000E8 0004+00 1/1 0/0 0/0 .sdata chk_type_tbl__12dAttention_c */
type_tbl_entry dAttention_c::chk_type_tbl[1] = {
- {fopAc_attn_CHECK_e, 0x100},
+ {fopAc_attn_CHECK_e, fopAc_AttnFlag_CHECK_e},
};
/* 8045066C-80450670 0000EC 0004+00 1/1 0/0 0/0 .sdata chk_type_num__12dAttention_c */
@@ -360,7 +424,8 @@ static int check_flontofplayer(u32 i_checkMask, s16 i_ang1, s16 i_ang2) {
i_ang2 = -i_ang2;
}
- for (int i = 0; i < 3; i++) {
+ int i;
+ for (i = 0; i < 3; i++) {
if (i_checkMask & ftp_table[i]) {
if (i_ang1 > ang_table[i]) {
return true;
@@ -368,7 +433,7 @@ static int check_flontofplayer(u32 i_checkMask, s16 i_ang1, s16 i_ang2) {
}
}
- for (int i = 8; i > 2; i--) {
+ for (i = 8; i >= 3; i--) {
if (i_checkMask & ftp_table[i]) {
if (i_ang2 > ang_table2[i - 3]) {
return true;
@@ -381,18 +446,20 @@ static int check_flontofplayer(u32 i_checkMask, s16 i_ang1, s16 i_ang2) {
/* 80070BF4-80070C40 06B534 004C+00 2/2 0/0 0/0 .text distace_weight__Ffsf */
static f32 distace_weight(f32 i_distance, s16 i_angle, f32 i_ratio) {
- f32 tmp = i_angle / (f32)0x8000;
- return i_distance * ((1.0f - i_ratio) + (i_ratio * (tmp * tmp)));
+ f32 var_f31 = i_angle / (f32)0x8000;
+ f32 var_f30 = SQUARE(var_f31);
+ return i_distance * ((1.0f - i_ratio) + (i_ratio * var_f30));
}
/* 80070C40-80070CA0 06B580 0060+00 2/2 0/0 0/0 .text distace_angle_adjust__Ffsf */
static f32 distace_angle_adjust(f32 i_distAdjust, s16 i_angle, f32 i_ratio) {
- f32 tmp = i_angle / (f32)0x8000;
- if (tmp < 0.0f) {
- tmp = -tmp;
+ f32 var_f31 = i_angle / (f32)0x8000;
+ if (var_f31 < 0.0f) {
+ var_f31 = -var_f31;
}
+ f32 var_f30 = SQUARE(1.0f - var_f31);
- return i_distAdjust * ((1.0f - i_ratio) + (i_ratio * ((1.0f - tmp) * (1.0f - tmp))));
+ return i_distAdjust * ((1.0f - i_ratio) + (i_ratio * var_f30));
}
/* 80070CA0-80070E90 06B5E0 01F0+00 3/3 0/0 0/0 .text check_distace__FP4cXyzsP4cXyzffff
@@ -431,7 +498,7 @@ f32 dAttention_c::calcWeight(int i_listType, fopAc_ac_c* i_actor, f32 i_distance
table = loc_type_tbl;
break;
default:
- OS_REPORT("attention: %d: illegal type\n", 0x419);
+ OS_REPORT("attention: %d: illegal type\n", 1049);
case 'A':
num = act_type_num;
table = act_type_tbl;
@@ -445,9 +512,11 @@ f32 dAttention_c::calcWeight(int i_listType, fopAc_ac_c* i_actor, f32 i_distance
f32 weight = 0.0f;
f32 max_weight = -1.0f;
+ int dist_index;
daPy_py_c* player = daPy_getPlayerActorClass();
if (player != NULL) {
- if (i_actor == fopAcM_SearchByID(player->getGrabActorID())) {
+ fpc_ProcID grab_actor_id = player->getGrabActorID();
+ if (i_actor == fopAcM_SearchByID(grab_actor_id)) {
return 0.0f;
}
}
@@ -457,10 +526,10 @@ f32 dAttention_c::calcWeight(int i_listType, fopAc_ac_c* i_actor, f32 i_distance
type_tbl_entry* type_tbl_entry = &table[i];
if (mPlayerAttentionFlags & type_tbl_entry->mask & i_actor->attention_info.flags) {
- u8 dist_index = i_actor->attention_info.distances[type_tbl_entry->type];
+ dist_index = i_actor->attention_info.distances[type_tbl_entry->type];
dist_entry* dist_tbl_entry = &dist_table[dist_index];
- if (fopAcM_checkStatus(i_actor, 0x20000000) ||
+ if (fopAcM_CheckStatus(i_actor, 0x20000000) ||
check_event_condition(type_tbl_entry->type, i_actor->eventInfo.getCondition())) {
dist_weight = 0.0f;
} else if (check_flontofplayer(dist_tbl_entry->mAngleSelect, i_angle, i_invAngle)) {
@@ -491,7 +560,7 @@ void dAttention_c::setList(int i_listType, fopAc_ac_c* i_actor, f32 i_weight, f3
cSAngle i_angle, u32 i_attnType) {
int max;
int* list_count;
- s32 maxIndex;
+ int maxIndex;
dAttList_c* list;
switch (i_listType) {
@@ -505,6 +574,7 @@ void dAttention_c::setList(int i_listType, fopAc_ac_c* i_actor, f32 i_weight, f3
list = mLockOnList;
break;
default:
+ OS_REPORT("attention: %d: illegal type\n", 1169);
case 'A':
max = 4;
list_count = &mActionCount;
@@ -517,16 +587,14 @@ void dAttention_c::setList(int i_listType, fopAc_ac_c* i_actor, f32 i_weight, f3
break;
}
- f32 weight = 0.0f;
-
- if (i_weight > weight) {
+ if (i_weight > 0.0f) {
if (*list_count < max) {
maxIndex = *list_count;
(*list_count)++;
} else {
- f32 maxWeight = weight;
- s32 i = 0;
- maxIndex = 0;
+ f32 maxWeight = 0.0f;
+ int i = 0;
+ maxIndex = i;
for (; i < max; i++) {
if (list[i].mWeight > maxWeight) {
maxWeight = list[i].mWeight;
@@ -587,7 +655,9 @@ static int select_attention(fopAc_ac_c* i_actor, void* i_attention) {
return 0;
}
- return ((dAttention_c*)i_attention)->SelectAttention(i_actor);
+ dAttention_c* attention = (dAttention_c*)i_attention;
+ int rt = attention->SelectAttention(i_actor);
+ return rt;
}
/* 800713CC-80071424 06BD0C 0058+00 4/4 0/0 0/0 .text makeList__12dAttention_cFv */
@@ -622,17 +692,17 @@ int dAttention_c::SelectAttention(fopAc_ac_c* i_actor) {
inv_angle = cSAngle(globe.U().Inv()) - fopAcM_GetShapeAngle_p(i_actor)->y;
u32 attn_type;
- if ((i_actor->attention_info.flags & 7) && !chkFlag(0x4000)) {
+ if ((i_actor->attention_info.flags & fopAc_AttnFlags_LOCK) && !chkFlag(0x4000)) {
f32 weight = calcWeight('L', i_actor, globe.R(), angle.Val(), inv_angle.Val(), &attn_type);
setList('L', i_actor, weight, globe.R(), angle, attn_type);
}
- if (i_actor->attention_info.flags & 0xF8) {
+ if (i_actor->attention_info.flags & fopAc_AttnFlags_ACTION) {
f32 weight = calcWeight('A', i_actor, globe.R(), angle.Val(), inv_angle.Val(), &attn_type);
setList('A', i_actor, weight, globe.R(), angle, attn_type);
}
- if (i_actor->attention_info.flags & 0x100) {
+ if (i_actor->attention_info.flags & fopAc_AttnFlag_CHECK_e) {
f32 weight = calcWeight('C', i_actor, globe.R(), angle.Val(), inv_angle.Val(), &attn_type);
setList('C', i_actor, weight, globe.R(), angle, attn_type);
}
@@ -748,6 +818,9 @@ int dAttention_c::freeAttention() {
/* 80071A98-80071CC0 06C3D8 0228+00 2/2 0/0 0/0 .text chaseAttention__12dAttention_cFv */
bool dAttention_c::chaseAttention() {
+ cSAngle a1;
+ cSAngle a2;
+
int offset = mLockOnOffset;
fopAc_ac_c* actor = mLockOnList[offset].getActor();
@@ -757,11 +830,9 @@ bool dAttention_c::chaseAttention() {
if (!chkFlag(0x4000)) {
cSGlobe g1 = actor->attention_info.position - mOwnerAttnPos;
- cSAngle a1;
a1 = g1.U() - fopAcM_GetShapeAngle_p(mpPlayer)->y;
cSGlobe g2(mOwnerAttnPos - actor->attention_info.position);
- cSAngle a2;
a2 = g2.U() - fopAcM_GetShapeAngle_p(actor)->y;
u32 type;
@@ -780,7 +851,8 @@ bool dAttention_c::chaseAttention() {
dist_table[tbl_idx].mDistMaxRelease,
dist_table[tbl_idx].mDistanceAdjust,
dist_table[tbl_idx].mUpperY, dist_table[tbl_idx].mLowerY)) {
- mLockOnList[offset].mWeight = distace_weight(g1.R(), a1.Val(), 0.5f);
+ f32 weight = distace_weight(g1.R(), a1.Val(), 0.5f);
+ mLockOnList[offset].mWeight = weight;
return true;
}
@@ -794,63 +866,60 @@ bool dAttention_c::chaseAttention() {
return true;
}
- return (actor->attention_info.flags & 7) != false;
+ return (actor->attention_info.flags & fopAc_AttnFlags_LOCK) != false;
}
-
/* 80071CC0-80071D6C 06C600 00AC+00 1/1 0/0 0/0 .text EnemyDistance__12dAttention_cFP10fopAc_ac_c
*/
f32 dAttention_c::EnemyDistance(fopAc_ac_c* i_actor) {
- f32 distance;
-
if (i_actor == mpPlayer || mpPlayer == NULL) {
- distance = -1.0f;
+ return -1.0f;
} else if (fopAcM_GetProfName(i_actor) == PROC_ALINK) {
- distance = -1.0f;
- } else if (!(i_actor->attention_info.flags & 4) &&
- !(i_actor->attention_info.flags & 0x4000000)) {
- distance = -1.0f;
+ return -1.0f;
+ } else if (!(i_actor->attention_info.flags & fopAc_AttnFlag_BATTLE_e) &&
+ !(i_actor->attention_info.flags & fopAc_AttnFlag_ENEMY_NOLOCK_e)) {
+ return -1.0f;
} else {
- distance = fopAcM_searchActorDistance(mpPlayer, i_actor);
- u8 tmp = i_actor->attention_info.distances[fopAc_attn_BATTLE_e];
+ f32 distance = fopAcM_searchActorDistance(mpPlayer, i_actor);
+ int tmp = i_actor->attention_info.distances[fopAc_attn_BATTLE_e];
if (distance < dist_table[tmp].mDistMax + dist_table[tmp].mDistanceAdjust) {
return distance;
}
-
- distance = -1.0f;
}
- return distance;
+ return -1.0f;
}
/* 80071D6C-80071DEC 06C6AC 0080+00 1/1 0/0 0/0 .text sound_attention__FP10fopAc_ac_cPv
*/
static int sound_attention(fopAc_ac_c* i_actor, void* i_attention) {
- f32 dist = ((dAttention_c*)i_attention)->EnemyDistance(i_actor);
+ dAttention_c* attention = (dAttention_c*)i_attention;
+ f32 dist = attention->EnemyDistance(i_actor);
if (dist < 0.0f) {
return 0;
}
- if (dist < ((dAttention_c*)i_attention)->mEnemyDist) {
- ((dAttention_c*)i_attention)->mEnemyActorID = fopAcM_GetID(i_actor);
- ((dAttention_c*)i_attention)->mEnemyDist = dist;
+ if (dist < attention->mEnemyDist) {
+ attention->mEnemyActorID = fopAcM_GetID(i_actor);
+ attention->mEnemyDist = dist;
}
return 0;
}
-
/* 80071DEC-80071E84 06C72C 0098+00 1/1 0/0 0/0 .text runSoundProc__12dAttention_cFv */
void dAttention_c::runSoundProc() {
mEnemyActorID = fpcM_ERROR_PROCESS_ID_e;
mEnemyDist = 10000.0f;
+ fopAc_ac_c* enemy_p;
if (!chkFlag(0x80000000)) {
fopAcIt_Executor((fopAcIt_ExecutorFunc)sound_attention, this);
- if (fopAcM_SearchByID(mEnemyActorID) != NULL) {
+ enemy_p = fopAcM_SearchByID(mEnemyActorID);
+ if (enemy_p != NULL) {
mDoAud_bgmNowBattle(mEnemyDist * 0.1f);
setFlag(0x100);
}
@@ -859,7 +928,9 @@ void dAttention_c::runSoundProc() {
/* 80071E84-800720F4 06C7C4 0270+00 1/1 0/0 0/0 .text runDrawProc__12dAttention_cFv */
void dAttention_c::runDrawProc() {
- if ((mFlags >> 3) & 1) {
+ int lockon_cnt = GetLockonCount();
+
+ if (chkFlag(8)) {
draw[0].setAlphaAnm(mAttParam.mAttnCursorAppearFrames, 0);
draw[0].setAnm(DRAW_TYPE_RED, mAttParam.field_0x3c);
draw[0].mCursorSizeX = mAttParam.mAttnCursorScaleX;
@@ -919,8 +990,96 @@ void dAttention_c::runDrawProc() {
}
}
+#if DEBUG
+void dAttention_c::runDebugDisp0() {
+ f32 analog_l = mDoCPd_c::getAnalogL(mPadNo);
+ if (mAttParam.CheckFlag(0x8000)) {
+ dDbVw_Report(mAttParam.mDebugDispPosX, mAttParam.mDebugDispPosY, "attention %d/%d", mLockOnOffset, mLockonCount);
+ dDbVw_Report(mAttParam.mDebugDispPosX, mAttParam.mDebugDispPosY + 20, "L %f (%d:%d)", analog_l, padLockTrigger(mPadNo), mDoCPd_c::getHoldL(mPadNo));
+ dDbVw_Report(mAttParam.mDebugDispPosX, mAttParam.mDebugDispPosY + 40, "LS %d stick.y = %f", mAttnStatus, mDoCPd_c::getStickY(mPadNo));
+
+ if (LockonTarget(0)) {
+ dDbVw_Report(mAttParam.mDebugDispPosX, mAttParam.mDebugDispPosY + 60, "LTN %s", dStage_getName(fopAcM_GetProfName(LockonTarget(0)), -1));
+ }
+ }
+}
+#endif
+
/* 800720F4-800720F8 06CA34 0004+00 1/1 0/0 0/0 .text runDebugDisp__12dAttention_cFv */
-void dAttention_c::runDebugDisp() {}
+void dAttention_c::runDebugDisp() {
+#if DEBUG
+ if (mAttParam.CheckFlag(0x4000)) {
+ int i;
+ int print_y = 100;
+ int no = 0;
+
+ char* type_str[] = {
+ "LOCK",
+ "TALK",
+ "BATL",
+ "SPEK",
+ "CARY",
+ "DOOR",
+ "JUEL",
+ "ETC?",
+ "CHEK",
+ "????",
+ };
+
+ dDbVw_Report(10, print_y, " **** attention **** %03d", field_0x32e);
+ dDbVw_Report(10, print_y += 15, " No TYPE WEIGHT PID NAME");
+
+ if (mLockonCount != 0) {
+ for (i = 0; i < mLockonCount; i++) {
+ char name[16];
+ fopAcM_getNameString(mLockOnList[i].getActor(), name);
+
+ char sp9;
+ if (i == mLockOnOffset) {
+ sp9 = '*';
+ } else {
+ sp9 = ' ';
+ }
+
+ dDbVw_Report(10, print_y += 15, "%c%02d %s %06.1f %3d %s", sp9, no, type_str[mLockOnList[i].mType], mLockOnList[i].mWeight, mLockOnList[i].getPid(), name);
+ no++;
+ }
+
+ print_y += 15;
+ }
+
+ if (mActionCount != 0) {
+ for (i = 0; i < mActionCount; i++) {
+ char name[16];
+ fopAcM_getNameString(mActionList[i].getActor(), name);
+ dDbVw_Report(10, print_y += 15, " %02d %s %06.1f %3d %s", no, type_str[mActionList[i].mType], mActionList[i].mWeight, mActionList[i].getPid(), name);
+ no++;
+ }
+ }
+
+ if (mCheckObjectCount != 0) {
+ for (i = 0; i < mCheckObjectCount; i++) {
+ char name[16];
+ fopAcM_getNameString(mCheckObjectList[i].getActor(), name);
+
+ char sp8;
+ if (i == mCheckObjectOffset) {
+ sp8 = '+';
+ } else {
+ sp8 = ' ';
+ }
+
+ dDbVw_Report(10, print_y += 15, "%c%02d %s %06.1f %3d %s", sp8, no, type_str[mCheckObjectList[i].mType], mCheckObjectList[i].mAngle.Degree(), mCheckObjectList[i].getPid(), name);
+ no++;
+ }
+ }
+
+ if (no == 0) {
+ dDbVw_Report(10, print_y += 15, " (EMPTY)");
+ }
+ }
+#endif
+}
/* 800720F8-800722A0 06CA38 01A8+00 1/1 0/0 0/0 .text checkButton__12dAttention_cFv */
void dAttention_c::checkButton() {
@@ -991,8 +1150,12 @@ int dAttention_c::lostCheck() {
/* 80072344-800725F0 06CC84 02AC+00 1/1 0/0 0/0 .text judgementStatus4Hold__12dAttention_cFv */
void dAttention_c::judgementStatus4Hold() {
+ int var_r29 = mAttnStatus;
+ int var_r30 = -1;
+
switch (mAttnStatus) {
case EState_NONE:
+ var_r30 = 10;
field_0x32f = 0;
field_0x32e = 0;
mLockTargetID = fpcM_ERROR_PROCESS_ID_e;
@@ -1001,11 +1164,13 @@ void dAttention_c::judgementStatus4Hold() {
if (field_0x32b == 0 && triggerProc()) {
mAttnStatus = EState_LOCK;
field_0x32e = 15;
+ var_r30 = 11;
}
break;
case EState_LOCK:
mLockTargetID = LockonTargetPId(0);
field_0x32f = 0;
+ var_r30 = 20;
if (lostCheck()) {
mLockTargetID = fpcM_ERROR_PROCESS_ID_e;
@@ -1018,16 +1183,19 @@ void dAttention_c::judgementStatus4Hold() {
freeAttention();
setFlag(0x800000);
}
+ var_r30 = 21;
} else if (field_0x32b == 4) {
mAttnStatus = EState_RELEASE;
setFlag(0x10);
field_0x32f = 10;
+ var_r30 = 22;
} else if (field_0x32e == 0) {
initList(0xFFFFFFFF);
if (makeList()) {
sortList();
}
+ var_r30 = 23;
}
if (field_0x32e != 0) {
@@ -1037,6 +1205,7 @@ void dAttention_c::judgementStatus4Hold() {
break;
case EState_RELEASE:
setFlag(0x40);
+ var_r30 = 30;
if (lostCheck()) {
mLockTargetID = fpcM_ERROR_PROCESS_ID_e;
@@ -1049,6 +1218,7 @@ void dAttention_c::judgementStatus4Hold() {
freeAttention();
setFlag(0x800000);
}
+ var_r30 = 31;
} else if (field_0x32b == 0) {
if (nextAttention()) {
setFlag(0x8);
@@ -1058,9 +1228,11 @@ void dAttention_c::judgementStatus4Hold() {
mAttnStatus = EState_NONE;
freeAttention();
}
+ var_r30 = 32;
} else if (LockonTarget(0) == NULL || field_0x32f == 0) {
mAttnStatus = EState_NONE;
freeAttention();
+ var_r30 = 33;
}
if (field_0x32f != 0) {
@@ -1078,29 +1250,42 @@ void dAttention_c::judgementStatus4Hold() {
sortList();
}
}
+
+#if DEBUG
+ if (var_r29 != mAttnStatus) {
+ OS_REPORT("%06d: attention: status %d, %d -> %d (%d)\n", g_Counter.mCounter0, mLockonCount, var_r29, mAttnStatus, var_r30);
+ }
+#endif
}
/* 800725F0-80072924 06CF30 0334+00 1/1 0/0 0/0 .text judgementStatus4Switch__12dAttention_cFv */
void dAttention_c::judgementStatus4Switch() {
+ int var_r29 = mAttnStatus;
+ int var_r30 = -1;
+
switch (mAttnStatus) {
case EState_NONE:
mLockTargetID = fpcM_ERROR_PROCESS_ID_e;
stockAttention();
field_0x32f = 0;
field_0x32e = 0;
+ var_r30 = 10;
if (field_0x32b == 0 && triggerProc()) {
mAttnStatus = EState_LOCK;
field_0x32e = 15;
field_0x32f = 15;
+ var_r30 = 11;
}
break;
case EState_LOCK:
mLockTargetID = LockonTargetPId(0);
+ var_r30 = 20;
if (field_0x32f == 0) {
mAttnStatus = EState_NONE;
freeAttention();
+ var_r30 = 29;
} else if (lostCheck()) {
mLockTargetID = fpcM_ERROR_PROCESS_ID_e;
stockAttention();
@@ -1112,8 +1297,9 @@ void dAttention_c::judgementStatus4Switch() {
freeAttention();
setFlag(0x800000);
}
+ var_r30 = 21;
} else if (field_0x32b == 0) {
- if (mDoCPd_c::getStickY(mPadNo) < -0.9f) {
+ if (mDoCPd_c::getStickY(mPadNo) < mAttParam.FreeStick()) {
mAttnStatus = EState_NONE;
freeAttention();
} else if (nextAttention()) {
@@ -1124,12 +1310,14 @@ void dAttention_c::judgementStatus4Switch() {
mAttnStatus = EState_NONE;
freeAttention();
}
+ var_r30 = 22;
} else if (field_0x32e == 0) {
initList(0xFFFFFFFF);
if (makeList()) {
sortList();
}
+ var_r30 = 23;
}
if (!chkFlag(0x8) && field_0x32e != 0) {
@@ -1147,6 +1335,7 @@ void dAttention_c::judgementStatus4Switch() {
break;
case EState_RELEASE:
setFlag(0x40);
+ var_r30 = 30;
if (lostCheck()) {
mLockTargetID = fpcM_ERROR_PROCESS_ID_e;
@@ -1159,6 +1348,7 @@ void dAttention_c::judgementStatus4Switch() {
freeAttention();
setFlag(0x800000);
}
+ var_r30 = 31;
} else if (field_0x32b == 0) {
mAttnStatus = EState_NONE;
@@ -1167,9 +1357,11 @@ void dAttention_c::judgementStatus4Switch() {
field_0x32e = 15;
field_0x32f = 15;
}
+ var_r30 = 32;
} else if (LockonTarget(0) == NULL || field_0x32f == 0) {
mAttnStatus = EState_NONE;
freeAttention();
+ var_r30 = 33;
}
break;
@@ -1183,6 +1375,12 @@ void dAttention_c::judgementStatus4Switch() {
sortList();
}
}
+
+#if DEBUG
+ if (var_r29 != mAttnStatus) {
+ OS_REPORT("%06d: attention: status %d, %d -> %d (%d)\n", g_Counter.mCounter0, mLockonCount, var_r29, mAttnStatus, var_r30);
+ }
+#endif
}
/* 80072924-80072BD4 06D264 02B0+00 0/0 1/1 0/0 .text Run__12dAttention_cFv */
@@ -1196,6 +1394,12 @@ int dAttention_c::Run() {
attn_opt_hold = usingHold;
+#if DEBUG
+ if (mAttParam.CheckFlag(4)) {
+ attn_opt_hold = mAttParam.CheckFlag(1);
+ }
+#endif
+
if (mAttnBlockTimer != 0) {
mAttnBlockTimer--;
return 1;
@@ -1206,6 +1410,10 @@ int dAttention_c::Run() {
mPadNo = PAD_1;
}
+#if DEBUG
+ runDebugDisp0();
+#endif
+
setOwnerAttentionPos();
if (dComIfGp_event_runCheck() || chkFlag(0x10000)) {
@@ -1225,7 +1433,7 @@ int dAttention_c::Run() {
judgementStatus4Switch();
}
- if ((mFlags >> 0x17) & 1) {
+ if (chkFlag(0x800000)) {
freeAttention();
if (LockonTarget(0) == NULL) {
setFlag(0x20000020);
@@ -1281,24 +1489,41 @@ void dAttention_c::Draw() {
}
Mtx inv_m;
- MTXInverse(dComIfGd_getViewRotMtx(), inv_m);
+ cMtx_inverse(dComIfGd_getViewRotMtx(), inv_m);
fopAc_ac_c* lockon_actor = LockonTarget(0);
if (!dComIfGp_event_runCheck()) {
+ #if DEBUG
+ if (mAttParam.CheckFlag(4) && mAttParam.CheckFlag(0x10)) {
+ return;
+ }
+ #endif
+
if (lockon_actor != NULL) {
+ #if DEBUG
+ if (mAttParam.CheckFlag(8)) {
+ dDbVw_Report(300, 40, "000");
+ }
+ #endif
+
draw[0].draw(lockon_actor->attention_info.position, inv_m);
if (mLockonCount >= 2 && draw[1].field_0x173 == 2) {
int listIdx = mLockOnOffset;
-
if (mLockOnOffset == 0) {
listIdx = mLockonCount - 1;
} else {
listIdx--;
}
+
if (mLockOnList[listIdx].getActor() != NULL) {
- fopAc_ac_c* actor = mLockOnList[listIdx].getActor();
- draw[1].draw(actor->attention_info.position, inv_m);
+ draw[1].draw(mLockOnList[listIdx].getActor()->attention_info.position, inv_m);
+
+ #if DEBUG
+ if (mAttParam.CheckFlag(8)) {
+ dDbVw_Report(300, 40, "111");
+ }
+ #endif
}
}
@@ -1314,6 +1539,12 @@ void dAttention_c::Draw() {
} else {
draw[0].draw(mDrawAttnPos, inv_m);
}
+
+ #if DEBUG
+ if (mAttParam.CheckFlag(8)) {
+ dDbVw_Report(300, 40, "222");
+ }
+ #endif
}
}
}
@@ -1412,18 +1643,20 @@ void dAttDraw_c::draw(cXyz& i_pos, Mtx i_mtx) {
mModel[mDrawType]->setBaseTRMtx(mDoMtx_stack_c::get());
view_class* view = dComIfGd_getView();
- f32 temp_f31 = tan(DEG_TO_RAD(0.5f * view->fovy));
- f32 temp_f30 = (-100.0f - g_AttDwHIO.mCursorDistance) / temp_f31;
+ f32 fovy = view->fovy;
+ f32 temp_f31 = std::tan(DEG_TO_RAD(0.5f * fovy));
+ f32 temp_f30 = (-100.0f + -g_AttDwHIO.mCursorDistance) / temp_f31;
cXyz view_pos;
- MTXMultVec(dComIfGd_getViewMtx(), &i_pos, &view_pos);
+ cMtx_multVec(dComIfGd_getViewMtx(), &i_pos, &view_pos);
f32 size = 1.0f;
if (view_pos.z < temp_f30) {
- size = (view_pos.z * temp_f31) / (-100.0f - g_AttDwHIO.mCursorDistance);
+ size = (view_pos.z * temp_f31) / (-100.0f + -g_AttDwHIO.mCursorDistance);
}
- mModel[mDrawType]->setBaseScale(cXyz(mCursorSizeX * size, mCursorSizeY * size, mCursorSizeX * size));
+ cXyz scale(mCursorSizeX * size, mCursorSizeY * size, mCursorSizeX * size);
+ mModel[mDrawType]->setBaseScale(scale);
alphaAnm();
@@ -1462,7 +1695,7 @@ fopAc_ac_c* dAttention_c::LockonTarget(s32 i_no) {
}
fopAc_ac_c* actor = mLockOnList[listIdx].getActor();
- if (actor == NULL || !(actor->attention_info.flags & 7)) {
+ if (actor == NULL || !(actor->attention_info.flags & fopAc_AttnFlags_LOCK)) {
return NULL;
}