mirror of https://github.com/zeldaret/tp.git
Improve beautify anm data (#2487)
This commit is contained in:
parent
1a189d3d95
commit
bb008ca9cf
|
|
@ -19,10 +19,11 @@
|
|||
* @details
|
||||
*
|
||||
*/
|
||||
class e_rdy_class : public fopEn_enemy_c {
|
||||
class e_rdy_class {
|
||||
public:
|
||||
/* 80779340 */ e_rdy_class();
|
||||
|
||||
/* 0x0000 */ fopEn_enemy_c actor;
|
||||
/* 0x05AC */ request_of_phase_process_class mPhase;
|
||||
/* 0x05B4 */ s16 mMode;
|
||||
/* 0x05B6 */ u8 field_0x5b6;
|
||||
|
|
|
|||
|
|
@ -94,42 +94,42 @@ public:
|
|||
/* 8053E6E8 */ ~daNpc_Besu_Param_c();
|
||||
|
||||
struct Data {
|
||||
/* 0x00 */ u32 field_0x00;
|
||||
/* 0x04 */ u32 field_0x04;
|
||||
/* 0x08 */ u32 field_0x08;
|
||||
/* 0x0C */ u32 field_0x0c;
|
||||
/* 0x10 */ u32 field_0x10;
|
||||
/* 0x14 */ u32 field_0x14;
|
||||
/* 0x18 */ u32 field_0x18;
|
||||
/* 0x1C */ u32 field_0x1c;
|
||||
/* 0x00 */ f32 field_0x00;
|
||||
/* 0x04 */ f32 field_0x04;
|
||||
/* 0x08 */ f32 field_0x08;
|
||||
/* 0x0C */ f32 field_0x0c;
|
||||
/* 0x10 */ f32 field_0x10;
|
||||
/* 0x14 */ f32 field_0x14;
|
||||
/* 0x18 */ f32 field_0x18;
|
||||
/* 0x1C */ f32 field_0x1c;
|
||||
/* 0x20 */ u32 field_0x20;
|
||||
/* 0x24 */ u32 field_0x24;
|
||||
/* 0x28 */ u32 field_0x28;
|
||||
/* 0x2C */ u32 field_0x2c;
|
||||
/* 0x30 */ u32 field_0x30;
|
||||
/* 0x34 */ u32 field_0x34;
|
||||
/* 0x38 */ u32 field_0x38;
|
||||
/* 0x3C */ u32 field_0x3c;
|
||||
/* 0x40 */ u32 field_0x40;
|
||||
/* 0x44 */ u32 field_0x44;
|
||||
/* 0x28 */ f32 field_0x28;
|
||||
/* 0x2C */ f32 field_0x2c;
|
||||
/* 0x30 */ f32 field_0x30;
|
||||
/* 0x34 */ f32 field_0x34;
|
||||
/* 0x38 */ f32 field_0x38;
|
||||
/* 0x3C */ f32 field_0x3c;
|
||||
/* 0x40 */ f32 field_0x40;
|
||||
/* 0x44 */ f32 field_0x44;
|
||||
/* 0x48 */ u32 field_0x48;
|
||||
/* 0x4C */ u32 field_0x4c;
|
||||
/* 0x50 */ u32 field_0x50;
|
||||
/* 0x50 */ f32 field_0x50;
|
||||
/* 0x54 */ u32 field_0x54;
|
||||
/* 0x58 */ u32 field_0x58;
|
||||
/* 0x5C */ u32 field_0x5c;
|
||||
/* 0x60 */ u32 field_0x60;
|
||||
/* 0x64 */ u32 field_0x64;
|
||||
/* 0x68 */ u32 field_0x68;
|
||||
/* 0x6C */ u32 field_0x6c;
|
||||
/* 0x70 */ u32 field_0x70;
|
||||
/* 0x6C */ f32 field_0x6c;
|
||||
/* 0x70 */ f32 field_0x70;
|
||||
/* 0x74 */ u32 field_0x74;
|
||||
/* 0x78 */ u32 field_0x78;
|
||||
/* 0x7C */ u32 field_0x7c;
|
||||
/* 0x80 */ u32 field_0x80;
|
||||
/* 0x84 */ u32 field_0x84;
|
||||
/* 0x88 */ u32 field_0x88;
|
||||
/* 0x8C */ u32 field_0x8c;
|
||||
/* 0x78 */ f32 field_0x78;
|
||||
/* 0x7C */ f32 field_0x7c;
|
||||
/* 0x80 */ f32 field_0x80;
|
||||
/* 0x84 */ f32 field_0x84;
|
||||
/* 0x88 */ f32 field_0x88;
|
||||
/* 0x8C */ f32 field_0x8c;
|
||||
};
|
||||
|
||||
static const Data m;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -79,7 +79,8 @@ static void damage_check(e_yc_class* i_this) {
|
|||
|
||||
/* 807F01AC-807F06AC 0003CC 0500+00 2/1 0/0 0/0 .text e_yc_fly__FP10e_yc_class */
|
||||
static void e_yc_fly(e_yc_class* i_this) {
|
||||
e_rdy_class* rider = static_cast<e_rdy_class*>(fopAcM_SearchByID(i_this->mRiderID));
|
||||
fopAc_ac_c* base_rdy = fopAcM_SearchByID(i_this->mRiderID);
|
||||
e_rdy_class* rider = (e_rdy_class*) base_rdy;
|
||||
int frame = i_this->mpMorf->getFrame();
|
||||
f32 target_speed = 0.0f;
|
||||
f32 accel = 1.0f;
|
||||
|
|
@ -144,7 +145,7 @@ static void e_yc_fly(e_yc_class* i_this) {
|
|||
target_speed = 35.0f;
|
||||
accel = 0.25f;
|
||||
}
|
||||
i_this->mTargetPos = rider->current.pos;
|
||||
i_this->mTargetPos = base_rdy->current.pos;
|
||||
i_this->mTargetPos.y += 150.0f;
|
||||
break;
|
||||
|
||||
|
|
@ -166,7 +167,7 @@ static void e_yc_fly(e_yc_class* i_this) {
|
|||
|
||||
case 6:
|
||||
cLib_addCalc0(&i_this->field_0x694, 1.0f, 1.0f);
|
||||
cLib_addCalc2(&i_this->current.pos.y, rider->home.pos.y + 400.0f, 0.05f, 3.0f);
|
||||
cLib_addCalc2(&i_this->current.pos.y, base_rdy->home.pos.y + 400.0f, 0.05f, 3.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +319,8 @@ static void e_yc_hovering(e_yc_class* i_this) {
|
|||
static void e_yc_attack(e_yc_class* i_this) {
|
||||
fopAc_ac_c* player = dComIfGp_getPlayer(0);
|
||||
cXyz delta;
|
||||
e_rdy_class* rider = static_cast<e_rdy_class*>(fopAcM_SearchByID(i_this->mRiderID));
|
||||
fopAc_ac_c* base_rdy = fopAcM_SearchByID(i_this->mRiderID);
|
||||
e_rdy_class* rider = (e_rdy_class*) base_rdy;
|
||||
f32 target_speed = 0.0f;
|
||||
int frame = i_this->mpMorf->getFrame();
|
||||
|
||||
|
|
@ -437,7 +439,7 @@ static void e_yc_attack(e_yc_class* i_this) {
|
|||
static void e_yc_wolfbite(e_yc_class* i_this) {
|
||||
fopAc_ac_c* _this = static_cast<fopAc_ac_c*>(i_this);
|
||||
daPy_py_c* player = static_cast<daPy_py_c*>(dComIfGp_getPlayer(0));
|
||||
e_rdy_class* rider = static_cast<e_rdy_class*>(fopAcM_SearchByID(i_this->mRiderID));
|
||||
e_rdy_class* rider = (e_rdy_class*) fopAcM_SearchByID(i_this->mRiderID);
|
||||
|
||||
int frame = i_this->mpMorf->getFrame();
|
||||
i_this->mCcDisableTimer = 10;
|
||||
|
|
|
|||
|
|
@ -1236,49 +1236,52 @@ daNpc_Besu_c::~daNpc_Besu_c() {
|
|||
/* ############################################################################################## */
|
||||
/* 8053E754-8053E7E4 000000 0090+00 13/13 0/0 0/0 .rodata m__18daNpc_Besu_Param_c */
|
||||
daNpc_Besu_Param_c::Data const daNpc_Besu_Param_c::m = {
|
||||
0x43200000,
|
||||
0xC0400000,
|
||||
0x3F800000,
|
||||
0x43C80000,
|
||||
0x437F0000,
|
||||
0x430C0000,
|
||||
0x420C0000,
|
||||
0x41F00000,
|
||||
160.0f,
|
||||
-3.0f,
|
||||
1.0f,
|
||||
400.0f,
|
||||
255.0f,
|
||||
140.0f,
|
||||
35.0f,
|
||||
30.0f,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x41200000,
|
||||
0xC1200000,
|
||||
0x41F00000,
|
||||
0xC1200000,
|
||||
0x42340000,
|
||||
0xC2340000,
|
||||
0x3F19999A,
|
||||
0x41400000,
|
||||
10.0f,
|
||||
-10.0f,
|
||||
30.0f,
|
||||
-10.0f,
|
||||
45.0f,
|
||||
-45.0f,
|
||||
0.6f,
|
||||
12.0f,
|
||||
0x00030006,
|
||||
0x00050006,
|
||||
0x42DC0000,
|
||||
110.0f,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x003C0008,
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
0x40800000,
|
||||
0xC1700000,
|
||||
4.0f,
|
||||
-15.0f,
|
||||
0x00000000,
|
||||
0xC1700000,
|
||||
0x41700000,
|
||||
0x41F00000,
|
||||
0x41700000,
|
||||
0x428C0000,
|
||||
0x3F800000,
|
||||
-15.0f,
|
||||
15.0f,
|
||||
30.0f,
|
||||
15.0f,
|
||||
70.0f,
|
||||
1.0f,
|
||||
};
|
||||
|
||||
/* 8053701C-805372FC 0002BC 02E0+00 1/1 0/0 0/0 .text create__12daNpc_Besu_cFv */
|
||||
void daNpc_Besu_c::create() {
|
||||
static int const heapSize[19] = {
|
||||
13760, 13760, 13584, 13776, 13776, 13776, 15808, 16064, 15824, 13760, 13760, 13776,
|
||||
13760, 13760, 13776, 13760, 13760, 13760, 0,
|
||||
0x35C0, 0x35C0, 0x3510, 0x35D0,
|
||||
0x35D0, 0x35D0, 0x3DC0, 0x3EC0,
|
||||
0x3DD0, 0x35C0, 0x35C0, 0x35D0,
|
||||
0x35C0, 0x35C0, 0x35D0, 0x35C0,
|
||||
0x35C0, 0x35C0, 0x0,
|
||||
};
|
||||
// NONMATCHING
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
import struct
|
||||
|
||||
|
||||
FACE_MOTION_TYPE = "daNpcT_faceMotionAnmData_c l_faceMotionAnmData"
|
||||
|
|
@ -38,6 +39,31 @@ def twos_complement(hexstr, bits):
|
|||
return value
|
||||
|
||||
|
||||
def prm_is_float(hex_str):
|
||||
value = int(hex_str, 16)
|
||||
exponent_raw = (value >> 23) & 0xFF # Get bits 30-23
|
||||
exponent_actual = exponent_raw - 127 # Remove bias
|
||||
# print(exponent_actual)
|
||||
EXP_TOLERANCE = 10
|
||||
if exponent_actual < EXP_TOLERANCE * -1:
|
||||
return False
|
||||
|
||||
if exponent_actual > EXP_TOLERANCE:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
# Expects NO leading "0x":
|
||||
def hex_to_float(hex_str):
|
||||
return struct.unpack('!f', bytes.fromhex(hex_str))[0]
|
||||
|
||||
|
||||
def float_to_hex(f):
|
||||
[d] = struct.unpack(">I", struct.pack(">f", f))
|
||||
return f"0x{d:X}"
|
||||
|
||||
|
||||
def build_anm_struct(byte_collection, anm_type, param_name):
|
||||
my_len = len(byte_collection)
|
||||
piece_size = 1
|
||||
|
|
@ -66,7 +92,7 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
is_array = True
|
||||
elif anm_type is HEAP_SIZE_TYPE:
|
||||
piece_size = 4
|
||||
instr_arr = ["s4"]
|
||||
instr_arr = ["h4"]
|
||||
|
||||
if my_len % piece_size != 0:
|
||||
print(f"Error: len() = '{my_len}' isn't divisble by '{piece_size}'")
|
||||
|
|
@ -77,6 +103,7 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
hexstr = ""
|
||||
full_res_arr = []
|
||||
pos_arr = []
|
||||
prms_is_float: list[bool] = []
|
||||
while ptr < my_len:
|
||||
curbyte = byte_collection[ptr]
|
||||
ptr += 1
|
||||
|
|
@ -92,6 +119,11 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
val = twos_complement(hexstr, exp_bytes*8)
|
||||
pos_arr.append(val)
|
||||
elif my_type == 'h':
|
||||
if anm_type is HEAP_SIZE_TYPE:
|
||||
trimmed = hexstr.lstrip('0')
|
||||
hexstr = trimmed if trimmed else '0'
|
||||
elif anm_type is PARAM_TYPE:
|
||||
prms_is_float.append(prm_is_float(hexstr))
|
||||
pos_arr.append("0x" + hexstr)
|
||||
else:
|
||||
print(f"Error: unknown type '{my_type}'")
|
||||
|
|
@ -111,7 +143,8 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
while idx < my_len:
|
||||
upper = f'{idx:02X}'
|
||||
lower = f'{idx:02x}'
|
||||
res_str += " /* 0x{} */ u32 field_0x{};\n".format(upper, lower)
|
||||
mych = 'f' if (prms_is_float[int(idx / 4)] is True) else 'u'
|
||||
res_str += " /* 0x{} */ {}32 field_0x{};\n".format(upper, mych, lower)
|
||||
idx += 4
|
||||
res_str += "};\n"
|
||||
res_str += "static const Data m;\n\n"
|
||||
|
|
@ -124,13 +157,16 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
if anm_type is SEQ_FACE_MOTION_TYPE or anm_type is SEQ_MOTION_TYPE:
|
||||
cutoff_num = 8
|
||||
elif anm_type is HEAP_SIZE_TYPE:
|
||||
cutoff_num = 12
|
||||
cutoff_num = 4
|
||||
|
||||
if anm_type is not PARAM_TYPE:
|
||||
res_str += "[{}]".format(int(res_len))
|
||||
|
||||
prmfloat_dbg = False
|
||||
|
||||
res_str += " = {\n"
|
||||
cur_in_line = 0
|
||||
cur_idx = 0
|
||||
for my_arr in full_res_arr:
|
||||
if cur_in_line == 0:
|
||||
res_str += " "
|
||||
|
|
@ -150,7 +186,17 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
elif isinstance(value, float):
|
||||
res_str += str(value) + "f"
|
||||
else:
|
||||
res_str += value
|
||||
if anm_type is PARAM_TYPE and prms_is_float[cur_idx] is True:
|
||||
fvalue = hex_to_float(value[2:])
|
||||
fvalue = round(fvalue, 6)
|
||||
res_str += f"{fvalue}f"
|
||||
chk_val = float_to_hex(fvalue)
|
||||
# Sanity check in case rounding is too aggressive:
|
||||
assert chk_val == value, f"chk_val {chk_val} != value {value}"
|
||||
if prmfloat_dbg is True:
|
||||
res_str += f" // {value}"
|
||||
else:
|
||||
res_str += value
|
||||
|
||||
if is_array is True:
|
||||
res_str += "}"
|
||||
|
|
@ -163,6 +209,8 @@ def build_anm_struct(byte_collection, anm_type, param_name):
|
|||
else:
|
||||
res_str += " "
|
||||
|
||||
cur_idx += 1
|
||||
|
||||
if cur_in_line != 0:
|
||||
res_str += "\n"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue