From cc54d21d6f8d6cd73f10b55635f3a404fa1a6508 Mon Sep 17 00:00:00 2001 From: roblabla Date: Mon, 18 Nov 2024 21:19:09 +0100 Subject: [PATCH] Move Enemy ECL instructions to EnemyEclInstr.cpp --- config/ghidra_ns_to_obj.csv | 2 +- config/implemented.csv | 58 ++++---- objdiff.json | 6 +- scripts/configure.py | 2 +- src/EclManager.cpp | 205 ++++++++++++++------------- src/Enemy.hpp | 33 ----- src/{Enemy.cpp => EnemyEclInstr.cpp} | 145 +++++++++---------- src/EnemyEclInstr.hpp | 42 ++++++ 8 files changed, 253 insertions(+), 240 deletions(-) rename src/{Enemy.cpp => EnemyEclInstr.cpp} (89%) create mode 100644 src/EnemyEclInstr.hpp diff --git a/config/ghidra_ns_to_obj.csv b/config/ghidra_ns_to_obj.csv index ad9c119e..ba3f383d 100644 --- a/config/ghidra_ns_to_obj.csv +++ b/config/ghidra_ns_to_obj.csv @@ -6,7 +6,7 @@ Chain,th06::Chain,th06::ChainElem EclManager,th06::EclManager EffectManager,th06::EffectManager Ending,th06::Ending -Enemy,th06::Enemy +EnemyEclInstr,th06::EnemyEclInstr EnemyManager,th06::EnemyManager,th06::Enemy FileAbstraction,th06::FileAbstraction FileSystem,th06::FileSystem diff --git a/config/implemented.csv b/config/implemented.csv index 3fe4097c..5ec9761c 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -126,43 +126,43 @@ th06::EnemyManager::OnUpdate th06::EnemyManager::OnDraw th06::EnemyManager::RunEclTimeline th06::EnemyManager::SpawnEnemy +th06::EnemyEclInstr::GetVar +th06::EnemyEclInstr::GetVarFloat +th06::EnemyEclInstr::SetVar +th06::EnemyEclInstr::MathAdd +th06::EnemyEclInstr::MathSub +th06::EnemyEclInstr::MathMul +th06::EnemyEclInstr::MathDiv +th06::EnemyEclInstr::MathMod +th06::EnemyEclInstr::MathAtan2 +th06::EnemyEclInstr::MoveTime +th06::EnemyEclInstr::MoveDirTime +th06::EnemyEclInstr::MovePosTime +th06::EnemyEclInstr::ExInsCirnoRainbowBallJank +th06::EnemyEclInstr::ExInsShootAtRandomArea +th06::EnemyEclInstr::ExInsShootStarPattern +th06::EnemyEclInstr::ExInsPatchouliShottypeSetVars +th06::EnemyEclInstr::ExInsStage56Func4 +th06::EnemyEclInstr::ExInsStage5Func5 +th06::EnemyEclInstr::ExInsStage6XFunc6 +th06::EnemyEclInstr::ExInsStage6Func7 +th06::EnemyEclInstr::ExInsStage6Func8 +th06::EnemyEclInstr::ExInsStage6Func9 +th06::EnemyEclInstr::ExInsStage6Func11 +th06::EnemyEclInstr::ExInsStage6XFunc10 +th06::EnemyEclInstr::ExInsStage4Func12 +th06::EnemyEclInstr::ExInsStageXFunc13 +th06::EnemyEclInstr::ExInsStageXFunc14 +th06::EnemyEclInstr::ExInsStageXFunc15 +th06::EnemyEclInstr::ExInsStageXFunc16 th06::Enemy::Enemy -th06::Enemy::GetVar -th06::Enemy::GetVarFloat -th06::Enemy::SetVar -th06::Enemy::MathAdd -th06::Enemy::MathSub -th06::Enemy::MathMul -th06::Enemy::MathDiv -th06::Enemy::MathMod -th06::Enemy::MathAtan2 th06::Enemy::Move -th06::Enemy::MoveTime -th06::Enemy::MoveDirTime -th06::Enemy::MovePosTime th06::Enemy::ClampPos th06::Enemy::HandleLifeCallback th06::Enemy::HandleTimerCallback th06::Enemy::Despawn th06::Enemy::ResetEffectArray th06::Enemy::UpdateEffects -th06::Enemy::ExInsCirnoRainbowBallJank -th06::Enemy::ExInsShootAtRandomArea -th06::Enemy::ExInsShootStarPattern -th06::Enemy::ExInsPatchouliShottypeSetVars -th06::Enemy::ExInsStage56Func4 -th06::Enemy::ExInsStage5Func5 -th06::Enemy::ExInsStage6XFunc6 -th06::Enemy::ExInsStage6Func7 -th06::Enemy::ExInsStage6Func8 -th06::Enemy::ExInsStage6Func9 -th06::Enemy::ExInsStage6Func11 -th06::Enemy::ExInsStage6XFunc10 -th06::Enemy::ExInsStage4Func12 -th06::Enemy::ExInsStageXFunc13 -th06::Enemy::ExInsStageXFunc14 -th06::Enemy::ExInsStageXFunc15 -th06::Enemy::ExInsStageXFunc16 th06::GameErrorContext::Fatal th06::GameErrorContext::Log th06::GameErrorContext::Flush diff --git a/objdiff.json b/objdiff.json index fd719c71..efc28c99 100644 --- a/objdiff.json +++ b/objdiff.json @@ -83,10 +83,10 @@ "reverse_fn_order": false }, { - "name": "Enemy", + "name": "EnemyEclInstr", - "target_path": "build/objdiff/orig/Enemy.obj", - "base_path": "build/objdiff/reimpl/Enemy.obj", + "target_path": "build/objdiff/orig/EnemyEclInstr.obj", + "base_path": "build/objdiff/reimpl/EnemyEclInstr.obj", "reverse_fn_order": false }, diff --git a/scripts/configure.py b/scripts/configure.py index 61bc390a..4fcd1a96 100644 --- a/scripts/configure.py +++ b/scripts/configure.py @@ -95,7 +95,7 @@ def configure(build_type): "Stage", "BombData", "EclManager", - "Enemy", # ECL instructions. + "EnemyEclInstr", "EffectManager", "Ending", "EnemyManager", diff --git a/src/EclManager.cpp b/src/EclManager.cpp index fbdf81e8..f81d017b 100644 --- a/src/EclManager.cpp +++ b/src/EclManager.cpp @@ -2,6 +2,7 @@ #include "AnmManager.hpp" #include "EffectManager.hpp" #include "Enemy.hpp" +#include "EnemyEclInstr.hpp" #include "EnemyManager.hpp" #include "FileSystem.hpp" #include "GameErrorContext.hpp" @@ -22,16 +23,16 @@ DIFFABLE_STATIC_ARRAY_ASSIGN(i32, 64, g_SpellcardScore) = { 700000, 700000, 700000, 700000, 700000, 700000, 700000, 700000, 700000, 700000, 700000, 700000}; DIFFABLE_STATIC(EclManager, g_EclManager); typedef void (*ExInsn)(Enemy *, EclRawInstr *); -DIFFABLE_STATIC_ARRAY_ASSIGN(ExInsn, 17, - g_EclExInsn) = {Enemy::ExInsCirnoRainbowBallJank, Enemy::ExInsShootAtRandomArea, - Enemy::ExInsShootStarPattern, Enemy::ExInsPatchouliShottypeSetVars, - Enemy::ExInsStage56Func4, Enemy::ExInsStage5Func5, - Enemy::ExInsStage6XFunc6, Enemy::ExInsStage6Func7, - Enemy::ExInsStage6Func8, Enemy::ExInsStage6Func9, - Enemy::ExInsStage6XFunc10, Enemy::ExInsStage6Func11, - Enemy::ExInsStage4Func12, Enemy::ExInsStageXFunc13, - Enemy::ExInsStageXFunc14, Enemy::ExInsStageXFunc15, - Enemy::ExInsStageXFunc16}; +DIFFABLE_STATIC_ARRAY_ASSIGN(ExInsn, 17, g_EclExInsn) = { + EnemyEclInstr::ExInsCirnoRainbowBallJank, EnemyEclInstr::ExInsShootAtRandomArea, + EnemyEclInstr::ExInsShootStarPattern, EnemyEclInstr::ExInsPatchouliShottypeSetVars, + EnemyEclInstr::ExInsStage56Func4, EnemyEclInstr::ExInsStage5Func5, + EnemyEclInstr::ExInsStage6XFunc6, EnemyEclInstr::ExInsStage6Func7, + EnemyEclInstr::ExInsStage6Func8, EnemyEclInstr::ExInsStage6Func9, + EnemyEclInstr::ExInsStage6XFunc10, EnemyEclInstr::ExInsStage6Func11, + EnemyEclInstr::ExInsStage4Func12, EnemyEclInstr::ExInsStageXFunc13, + EnemyEclInstr::ExInsStageXFunc14, EnemyEclInstr::ExInsStageXFunc15, + EnemyEclInstr::ExInsStageXFunc16}; ZunResult EclManager::Load(char *eclPath) { @@ -120,9 +121,9 @@ ZunResult EclManager::RunEcl(Enemy *enemy) case ECL_OPCODE_UNIMP: return ZUN_ERROR; case ECL_OPCODE_JUMPDEC: - local_14 = *Enemy::GetVar(enemy, &args->jump.var, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->jump.var, NULL); local_14--; - Enemy::SetVar(enemy, args->jump.var, &local_14); + EnemyEclInstr::SetVar(enemy, args->jump.var, &local_14); if (local_14 <= 0) break; case ECL_OPCODE_JUMP: @@ -132,86 +133,86 @@ ZunResult EclManager::RunEcl(Enemy *enemy) goto YOLO; case ECL_OPCODE_SETINT: case ECL_OPCODE_SETFLOAT: - Enemy::SetVar(enemy, instruction->args.alu.res, &args->alu.arg1.i32); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &args->alu.arg1.i32); break; case ECL_OPCODE_MATHNORMANGLE: - local_18 = *(f32 *)Enemy::GetVar(enemy, &instruction->args.alu.res, NULL); + local_18 = *(f32 *)EnemyEclInstr::GetVar(enemy, &instruction->args.alu.res, NULL); local_18 = utils::AddNormalizeAngle(local_18, 0.0f); - Enemy::SetVar(enemy, instruction->args.alu.res, &local_18); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &local_18); break; case ECL_OPCODE_SETINTRAND: - local_24 = *Enemy::GetVar(enemy, &args->alu.arg1.id, NULL); + local_24 = *EnemyEclInstr::GetVar(enemy, &args->alu.arg1.id, NULL); local_14 = g_Rng.GetRandomU32InRange(local_24); - Enemy::SetVar(enemy, instruction->args.alu.res, &local_14); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &local_14); break; case ECL_OPCODE_SETINTRANDMIN: - local_28 = *Enemy::GetVar(enemy, &args->alu.arg1.id, NULL); - local_2c = *Enemy::GetVar(enemy, &args->alu.arg2.id, NULL); + local_28 = *EnemyEclInstr::GetVar(enemy, &args->alu.arg1.id, NULL); + local_2c = *EnemyEclInstr::GetVar(enemy, &args->alu.arg2.id, NULL); local_14 = g_Rng.GetRandomU32InRange(local_28); local_14 += local_2c; - Enemy::SetVar(enemy, instruction->args.alu.res, &local_14); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &local_14); break; case ECL_OPCODE_SETFLOATRAND: - local_30 = *Enemy::GetVarFloat(enemy, &args->alu.arg1.f32, NULL); + local_30 = *EnemyEclInstr::GetVarFloat(enemy, &args->alu.arg1.f32, NULL); local_18 = g_Rng.GetRandomF32InRange(local_30); - Enemy::SetVar(enemy, instruction->args.alu.res, &local_18); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &local_18); break; case ECL_OPCODE_SETFLOATRANDMIN: - local_34 = *Enemy::GetVarFloat(enemy, &args->alu.arg1.f32, NULL); - local_38 = *Enemy::GetVarFloat(enemy, &args->alu.arg2.f32, NULL); + local_34 = *EnemyEclInstr::GetVarFloat(enemy, &args->alu.arg1.f32, NULL); + local_38 = *EnemyEclInstr::GetVarFloat(enemy, &args->alu.arg2.f32, NULL); local_18 = g_Rng.GetRandomF32InRange(local_34); local_18 += local_38; - Enemy::SetVar(enemy, instruction->args.alu.res, &local_18); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &local_18); break; case ECL_OPCODE_SETVARSELFX: - Enemy::SetVar(enemy, instruction->args.alu.res, &enemy->position.x); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &enemy->position.x); break; case ECL_OPCODE_SETVARSELFY: - Enemy::SetVar(enemy, instruction->args.alu.res, &enemy->position.y); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &enemy->position.y); break; case ECL_OPCODE_SETVARSELFZ: - Enemy::SetVar(enemy, instruction->args.alu.res, &enemy->position.z); + EnemyEclInstr::SetVar(enemy, instruction->args.alu.res, &enemy->position.z); break; case ECL_OPCODE_MATHINTADD: case ECL_OPCODE_MATHFLOATADD: - Enemy::MathAdd(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); + EnemyEclInstr::MathAdd(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); break; case ECL_OPCODE_MATHINC: - local_3c = Enemy::GetVar(enemy, &instruction->args.alu.res, NULL); + local_3c = EnemyEclInstr::GetVar(enemy, &instruction->args.alu.res, NULL); *local_3c += 1; break; case ECL_OPCODE_MATHDEC: - local_40 = Enemy::GetVar(enemy, &instruction->args.alu.res, NULL); + local_40 = EnemyEclInstr::GetVar(enemy, &instruction->args.alu.res, NULL); *local_40 -= 1; break; case ECL_OPCODE_MATHINTSUB: case ECL_OPCODE_MATHFLOATSUB: - Enemy::MathSub(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); + EnemyEclInstr::MathSub(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); break; case ECL_OPCODE_MATHINTMUL: case ECL_OPCODE_MATHFLOATMUL: - Enemy::MathMul(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); + EnemyEclInstr::MathMul(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); break; case ECL_OPCODE_MATHINTDIV: case ECL_OPCODE_MATHFLOATDIV: - Enemy::MathDiv(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); + EnemyEclInstr::MathDiv(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); break; case ECL_OPCODE_MATHINTMOD: case ECL_OPCODE_MATHFLOATMOD: - Enemy::MathMod(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); + EnemyEclInstr::MathMod(enemy, instruction->args.alu.res, &args->alu.arg1.id, &args->alu.arg2.id); break; case ECL_OPCODE_MATHATAN2: - Enemy::MathAtan2(enemy, instruction->args.alu.res, &args->alu.arg1.f32, &args->alu.arg2.f32, - &args->alu.arg3.f32, &args->alu.arg4.f32); + EnemyEclInstr::MathAtan2(enemy, instruction->args.alu.res, &args->alu.arg1.f32, &args->alu.arg2.f32, + &args->alu.arg3.f32, &args->alu.arg4.f32); break; case ECL_OPCODE_CMPINT: - local_48 = *Enemy::GetVar(enemy, &instruction->args.cmp.lhs.id, NULL); - local_44 = *Enemy::GetVar(enemy, &instruction->args.cmp.rhs.id, NULL); + local_48 = *EnemyEclInstr::GetVar(enemy, &instruction->args.cmp.lhs.id, NULL); + local_44 = *EnemyEclInstr::GetVar(enemy, &instruction->args.cmp.rhs.id, NULL); enemy->currentContext.compareRegister = local_48 == local_44 ? 0 : local_48 < local_44 ? -1 : 1; break; case ECL_OPCODE_CMPFLOAT: - local_4c = *Enemy::GetVarFloat(enemy, &instruction->args.cmp.lhs.f32, NULL); - local_50 = *Enemy::GetVarFloat(enemy, &instruction->args.cmp.rhs.f32, NULL); + local_4c = *EnemyEclInstr::GetVarFloat(enemy, &instruction->args.cmp.lhs.f32, NULL); + local_50 = *EnemyEclInstr::GetVarFloat(enemy, &instruction->args.cmp.rhs.f32, NULL); enemy->currentContext.compareRegister = local_4c == local_50 ? 0 : (local_4c < local_50 ? -1 : 1); break; case ECL_OPCODE_JUMPLSS: @@ -264,32 +265,32 @@ ZunResult EclManager::RunEcl(Enemy *enemy) memcpy(&enemy->currentContext, &enemy->savedContextStack[enemy->stackDepth], sizeof(EnemyEclContext)); continue; case ECL_OPCODE_CALLLSS: - local_14 = *Enemy::GetVar(enemy, &args->call.cmpLhs, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->call.cmpLhs, NULL); if (local_14 < args->call.cmpRhs) goto HANDLE_CALL; break; case ECL_OPCODE_CALLLEQ: - local_14 = *Enemy::GetVar(enemy, &args->call.cmpLhs, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->call.cmpLhs, NULL); if (local_14 <= args->call.cmpRhs) goto HANDLE_CALL; break; case ECL_OPCODE_CALLEQU: - local_14 = *Enemy::GetVar(enemy, &args->call.cmpLhs, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->call.cmpLhs, NULL); if (local_14 == args->call.cmpRhs) goto HANDLE_CALL; break; case ECL_OPCODE_CALLGRE: - local_14 = *Enemy::GetVar(enemy, &args->call.cmpLhs, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->call.cmpLhs, NULL); if (local_14 > args->call.cmpRhs) goto HANDLE_CALL; break; case ECL_OPCODE_CALLGEQ: - local_14 = *Enemy::GetVar(enemy, &args->call.cmpLhs, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->call.cmpLhs, NULL); if (local_14 >= args->call.cmpRhs) goto HANDLE_CALL; break; case ECL_OPCODE_CALLNEQ: - local_14 = *Enemy::GetVar(enemy, &args->call.cmpLhs, NULL); + local_14 = *EnemyEclInstr::GetVar(enemy, &args->call.cmpLhs, NULL); if (local_14 != args->call.cmpRhs) goto HANDLE_CALL; break; @@ -307,43 +308,43 @@ ZunResult EclManager::RunEcl(Enemy *enemy) break; case ECL_OPCODE_MOVEPOSITION: enemy->position = *instruction->args.move.pos.AsD3dXVec(); - enemy->position.x = *Enemy::GetVarFloat(enemy, &enemy->position.x, NULL); - enemy->position.y = *Enemy::GetVarFloat(enemy, &enemy->position.y, NULL); - enemy->position.z = *Enemy::GetVarFloat(enemy, &enemy->position.z, NULL); + enemy->position.x = *EnemyEclInstr::GetVarFloat(enemy, &enemy->position.x, NULL); + enemy->position.y = *EnemyEclInstr::GetVarFloat(enemy, &enemy->position.y, NULL); + enemy->position.z = *EnemyEclInstr::GetVarFloat(enemy, &enemy->position.z, NULL); enemy->ClampPos(); break; case ECL_OPCODE_MOVEAXISVELOCITY: enemy->axisSpeed = *instruction->args.move.pos.AsD3dXVec(); - enemy->axisSpeed.x = *Enemy::GetVarFloat(enemy, &enemy->axisSpeed.x, NULL); - enemy->axisSpeed.y = *Enemy::GetVarFloat(enemy, &enemy->axisSpeed.y, NULL); - enemy->axisSpeed.z = *Enemy::GetVarFloat(enemy, &enemy->axisSpeed.z, NULL); + enemy->axisSpeed.x = *EnemyEclInstr::GetVarFloat(enemy, &enemy->axisSpeed.x, NULL); + enemy->axisSpeed.y = *EnemyEclInstr::GetVarFloat(enemy, &enemy->axisSpeed.y, NULL); + enemy->axisSpeed.z = *EnemyEclInstr::GetVarFloat(enemy, &enemy->axisSpeed.z, NULL); enemy->flags.unk1 = 0; break; case ECL_OPCODE_MOVEVELOCITY: local_8 = instruction->args.move.pos; - enemy->angle = *Enemy::GetVarFloat(enemy, &local_8.x, NULL); - enemy->speed = *Enemy::GetVarFloat(enemy, &local_8.y, NULL); + enemy->angle = *EnemyEclInstr::GetVarFloat(enemy, &local_8.x, NULL); + enemy->speed = *EnemyEclInstr::GetVarFloat(enemy, &local_8.y, NULL); enemy->flags.unk1 = 1; break; case ECL_OPCODE_MOVEANGULARVELOCITY: local_8 = instruction->args.move.pos; - enemy->angularVelocity = *Enemy::GetVarFloat(enemy, &local_8.x, NULL); + enemy->angularVelocity = *EnemyEclInstr::GetVarFloat(enemy, &local_8.x, NULL); enemy->flags.unk1 = 1; break; case ECL_OPCODE_MOVEATPLAYER: local_8 = instruction->args.move.pos; enemy->angle = g_Player.AngleToPlayer(&enemy->position) + local_8.x; - enemy->speed = *Enemy::GetVarFloat(enemy, &local_8.y, NULL); + enemy->speed = *EnemyEclInstr::GetVarFloat(enemy, &local_8.y, NULL); enemy->flags.unk1 = 1; break; case ECL_OPCODE_MOVESPEED: local_8 = instruction->args.move.pos; - enemy->speed = *Enemy::GetVarFloat(enemy, &local_8.x, NULL); + enemy->speed = *EnemyEclInstr::GetVarFloat(enemy, &local_8.x, NULL); enemy->flags.unk1 = 1; break; case ECL_OPCODE_MOVEACCELERATION: local_8 = instruction->args.move.pos; - enemy->acceleration = *Enemy::GetVarFloat(enemy, &local_8.x, NULL); + enemy->acceleration = *EnemyEclInstr::GetVarFloat(enemy, &local_8.x, NULL); enemy->flags.unk1 = 1; break; case ECL_OPCODE_BULLETFANAIMED: @@ -359,23 +360,23 @@ ZunResult EclManager::RunEcl(Enemy *enemy) local_58 = &enemy->bulletProps; local_58->sprite = local_54->sprite; local_58->aimMode = instruction->opCode - ECL_OPCODE_BULLETFANAIMED; - local_58->count1 = *Enemy::GetVar(enemy, &local_54->count1, NULL); + local_58->count1 = *EnemyEclInstr::GetVar(enemy, &local_54->count1, NULL); local_58->count1 += enemy->BulletRankAmount1(g_GameManager.rank); if (local_58->count1 <= 0) { local_58->count1 = 1; } - local_58->count2 = *Enemy::GetVar(enemy, &local_54->count2, NULL); + local_58->count2 = *EnemyEclInstr::GetVar(enemy, &local_54->count2, NULL); local_58->count2 += enemy->BulletRankAmount2(g_GameManager.rank); if (local_58->count2 <= 0) { local_58->count2 = 1; } local_58->position = enemy->position + enemy->shootOffset; - local_58->angle1 = *Enemy::GetVarFloat(enemy, &local_54->angle1, NULL); + local_58->angle1 = *EnemyEclInstr::GetVarFloat(enemy, &local_54->angle1, NULL); local_58->angle1 = utils::AddNormalizeAngle(local_58->angle1, 0.0f); - local_58->speed1 = *Enemy::GetVarFloat(enemy, &local_54->speed1, NULL); + local_58->speed1 = *EnemyEclInstr::GetVarFloat(enemy, &local_54->speed1, NULL); if (local_58->speed1 != 0.0f) { local_58->speed1 += enemy->BulletRankSpeed(g_GameManager.rank); @@ -384,8 +385,8 @@ ZunResult EclManager::RunEcl(Enemy *enemy) local_58->speed1 = 0.3; } } - local_58->angle2 = *Enemy::GetVarFloat(enemy, &local_54->angle2, NULL); - local_58->speed2 = *Enemy::GetVarFloat(enemy, &local_54->speed2, NULL); + local_58->angle2 = *EnemyEclInstr::GetVarFloat(enemy, &local_54->angle2, NULL); + local_58->speed2 = *EnemyEclInstr::GetVarFloat(enemy, &local_54->speed2, NULL); local_58->speed2 += enemy->BulletRankSpeed(g_GameManager.rank) / 2.0f; if (local_58->speed2 < 0.3f) { @@ -395,21 +396,21 @@ ZunResult EclManager::RunEcl(Enemy *enemy) local_58->flags = local_54->flags; local_14 = local_54->color; // TODO: Strict aliasing rule be like. - local_58->spriteOffset = *Enemy::GetVar(enemy, (EclVarId *)&local_14, NULL); + local_58->spriteOffset = *EnemyEclInstr::GetVar(enemy, (EclVarId *)&local_14, NULL); if (enemy->flags.unk3 == 0) { g_BulletManager.SpawnBulletPattern(local_58); } break; case ECL_OPCODE_BULLETEFFECTS: - enemy->bulletProps.exInts[0] = *Enemy::GetVar(enemy, &args->bulletEffects.ivar1, NULL); - enemy->bulletProps.exInts[1] = *Enemy::GetVar(enemy, &args->bulletEffects.ivar2, NULL); - enemy->bulletProps.exInts[2] = *Enemy::GetVar(enemy, &args->bulletEffects.ivar3, NULL); - enemy->bulletProps.exInts[3] = *Enemy::GetVar(enemy, &args->bulletEffects.ivar4, NULL); - enemy->bulletProps.exFloats[0] = *Enemy::GetVarFloat(enemy, &args->bulletEffects.fvar1, NULL); - enemy->bulletProps.exFloats[1] = *Enemy::GetVarFloat(enemy, &args->bulletEffects.fvar2, NULL); - enemy->bulletProps.exFloats[2] = *Enemy::GetVarFloat(enemy, &args->bulletEffects.fvar3, NULL); - enemy->bulletProps.exFloats[3] = *Enemy::GetVarFloat(enemy, &args->bulletEffects.fvar4, NULL); + enemy->bulletProps.exInts[0] = *EnemyEclInstr::GetVar(enemy, &args->bulletEffects.ivar1, NULL); + enemy->bulletProps.exInts[1] = *EnemyEclInstr::GetVar(enemy, &args->bulletEffects.ivar2, NULL); + enemy->bulletProps.exInts[2] = *EnemyEclInstr::GetVar(enemy, &args->bulletEffects.ivar3, NULL); + enemy->bulletProps.exInts[3] = *EnemyEclInstr::GetVar(enemy, &args->bulletEffects.ivar4, NULL); + enemy->bulletProps.exFloats[0] = *EnemyEclInstr::GetVarFloat(enemy, &args->bulletEffects.fvar1, NULL); + enemy->bulletProps.exFloats[1] = *EnemyEclInstr::GetVarFloat(enemy, &args->bulletEffects.fvar2, NULL); + enemy->bulletProps.exFloats[2] = *EnemyEclInstr::GetVarFloat(enemy, &args->bulletEffects.fvar3, NULL); + enemy->bulletProps.exFloats[3] = *EnemyEclInstr::GetVarFloat(enemy, &args->bulletEffects.fvar4, NULL); break; case ECL_OPCODE_ANMSETDEATH: local_5c = &instruction->args.anmSetDeath; @@ -441,9 +442,9 @@ ZunResult EclManager::RunEcl(Enemy *enemy) g_BulletManager.SpawnBulletPattern(&enemy->bulletProps); break; case ECL_OPCODE_SHOOTOFFSET: - enemy->shootOffset.x = *Enemy::GetVarFloat(enemy, &args->move.pos.x, NULL); - enemy->shootOffset.y = *Enemy::GetVarFloat(enemy, &args->move.pos.y, NULL); - enemy->shootOffset.z = *Enemy::GetVarFloat(enemy, &args->move.pos.z, NULL); + enemy->shootOffset.x = *EnemyEclInstr::GetVarFloat(enemy, &args->move.pos.x, NULL); + enemy->shootOffset.y = *EnemyEclInstr::GetVarFloat(enemy, &args->move.pos.y, NULL); + enemy->shootOffset.z = *EnemyEclInstr::GetVarFloat(enemy, &args->move.pos.z, NULL); break; case ECL_OPCODE_LASERCREATE: case ECL_OPCODE_LASERCREATEAIMED: @@ -452,11 +453,11 @@ ZunResult EclManager::RunEcl(Enemy *enemy) local_60->position = enemy->position + enemy->shootOffset; local_60->sprite = local_64->sprite; local_60->spriteOffset = local_64->color; - local_60->angle = *Enemy::GetVarFloat(enemy, &local_64->angle, NULL); - local_60->speed = *Enemy::GetVarFloat(enemy, &local_64->speed, NULL); - local_60->startOffset = *Enemy::GetVarFloat(enemy, &local_64->startOffset, NULL); - local_60->endOffset = *Enemy::GetVarFloat(enemy, &local_64->endOffset, NULL); - local_60->startLength = *Enemy::GetVarFloat(enemy, &local_64->startLength, NULL); + local_60->angle = *EnemyEclInstr::GetVarFloat(enemy, &local_64->angle, NULL); + local_60->speed = *EnemyEclInstr::GetVarFloat(enemy, &local_64->speed, NULL); + local_60->startOffset = *EnemyEclInstr::GetVarFloat(enemy, &local_64->startOffset, NULL); + local_60->endOffset = *EnemyEclInstr::GetVarFloat(enemy, &local_64->endOffset, NULL); + local_60->startLength = *EnemyEclInstr::GetVarFloat(enemy, &local_64->startLength, NULL); local_60->width = local_64->width; local_60->startTime = local_64->startTime; local_60->duration = local_64->duration; @@ -475,13 +476,13 @@ ZunResult EclManager::RunEcl(Enemy *enemy) enemy->lasers[enemy->laserStore] = g_BulletManager.SpawnLaserPattern(local_60); break; case ECL_OPCODE_LASERINDEX: - enemy->laserStore = *Enemy::GetVar(enemy, &instruction->args.alu.res, NULL); + enemy->laserStore = *EnemyEclInstr::GetVar(enemy, &instruction->args.alu.res, NULL); break; case ECL_OPCODE_LASERROTATE: if (enemy->lasers[instruction->args.laserOp.laserIdx] != NULL) { enemy->lasers[instruction->args.laserOp.laserIdx]->angle += - *Enemy::GetVarFloat(enemy, &instruction->args.laserOp.arg1.x, NULL); + *EnemyEclInstr::GetVarFloat(enemy, &instruction->args.laserOp.arg1.x, NULL); } break; case ECL_OPCODE_LASERROTATEFROMPLAYER: @@ -489,7 +490,7 @@ ZunResult EclManager::RunEcl(Enemy *enemy) { enemy->lasers[instruction->args.laserOp.laserIdx]->angle = g_Player.AngleToPlayer(&enemy->lasers[instruction->args.laserOp.laserIdx]->pos) + - *Enemy::GetVarFloat(enemy, &instruction->args.laserOp.arg1.x, NULL); + *EnemyEclInstr::GetVarFloat(enemy, &instruction->args.laserOp.arg1.x, NULL); } break; case ECL_OPCODE_LASEROFFSET: @@ -550,55 +551,55 @@ ZunResult EclManager::RunEcl(Enemy *enemy) enemy->effectIdx++; break; case ECL_OPCODE_MOVEDIRTIMEDECELERATE: - Enemy::MoveDirTime(enemy, instruction); + EnemyEclInstr::MoveDirTime(enemy, instruction); enemy->flags.unk2 = 1; break; case ECL_OPCODE_MOVEDIRTIMEDECELERATEFAST: - Enemy::MoveDirTime(enemy, instruction); + EnemyEclInstr::MoveDirTime(enemy, instruction); enemy->flags.unk2 = 2; break; case ECL_OPCODE_MOVEDIRTIMEACCELERATE: - Enemy::MoveDirTime(enemy, instruction); + EnemyEclInstr::MoveDirTime(enemy, instruction); enemy->flags.unk2 = 3; break; case ECL_OPCODE_MOVEDIRTIMEACCELERATEFAST: - Enemy::MoveDirTime(enemy, instruction); + EnemyEclInstr::MoveDirTime(enemy, instruction); enemy->flags.unk2 = 4; break; case ECL_OPCODE_MOVEPOSITIONTIMELINEAR: - Enemy::MovePosTime(enemy, instruction); + EnemyEclInstr::MovePosTime(enemy, instruction); enemy->flags.unk2 = 0; break; case ECL_OPCODE_MOVEPOSITIONTIMEDECELERATE: - Enemy::MovePosTime(enemy, instruction); + EnemyEclInstr::MovePosTime(enemy, instruction); enemy->flags.unk2 = 1; break; case ECL_OPCODE_MOVEPOSITIONTIMEDECELERATEFAST: - Enemy::MovePosTime(enemy, instruction); + EnemyEclInstr::MovePosTime(enemy, instruction); enemy->flags.unk2 = 2; break; case ECL_OPCODE_MOVEPOSITIONTIMEACCELERATE: - Enemy::MovePosTime(enemy, instruction); + EnemyEclInstr::MovePosTime(enemy, instruction); enemy->flags.unk2 = 3; break; case ECL_OPCODE_MOVEPOSITIONTIMEACCELERATEFAST: - Enemy::MovePosTime(enemy, instruction); + EnemyEclInstr::MovePosTime(enemy, instruction); enemy->flags.unk2 = 4; break; case ECL_OPCODE_MOVETIMEDECELERATE: - Enemy::MoveTime(enemy, instruction); + EnemyEclInstr::MoveTime(enemy, instruction); enemy->flags.unk2 = 1; break; case ECL_OPCODE_MOVETIMEDECELERATEFAST: - Enemy::MoveTime(enemy, instruction); + EnemyEclInstr::MoveTime(enemy, instruction); enemy->flags.unk2 = 2; break; case ECL_OPCODE_MOVETIMEACCELERATE: - Enemy::MoveTime(enemy, instruction); + EnemyEclInstr::MoveTime(enemy, instruction); enemy->flags.unk2 = 3; break; case ECL_OPCODE_MOVETIMEACCELERATEFAST: - Enemy::MoveTime(enemy, instruction); + EnemyEclInstr::MoveTime(enemy, instruction); enemy->flags.unk2 = 4; break; case ECL_OPCODE_MOVEBOUNDSSET: @@ -833,7 +834,7 @@ ZunResult EclManager::RunEcl(Enemy *enemy) break; case ECL_OPCODE_TIMESET: enemy->currentContext.time.IncrementInline( - *Enemy::GetVar(enemy, &instruction->args.timeSet.timeToSet, NULL)); + *EnemyEclInstr::GetVar(enemy, &instruction->args.timeSet.timeToSet, NULL)); break; case ECL_OPCODE_DROPITEMID: g_ItemManager.SpawnItem(&enemy->position, instruction->args.dropItem.itemId, 0); @@ -847,9 +848,9 @@ ZunResult EclManager::RunEcl(Enemy *enemy) break; case ECL_OPCODE_ENEMYCREATE: local_b0 = instruction->args.enemyCreate; - local_b0.pos.x = *Enemy::GetVarFloat(enemy, &local_b0.pos.x, NULL); - local_b0.pos.y = *Enemy::GetVarFloat(enemy, &local_b0.pos.y, NULL); - local_b0.pos.z = *Enemy::GetVarFloat(enemy, &local_b0.pos.z, NULL); + local_b0.pos.x = *EnemyEclInstr::GetVarFloat(enemy, &local_b0.pos.x, NULL); + local_b0.pos.y = *EnemyEclInstr::GetVarFloat(enemy, &local_b0.pos.y, NULL); + local_b0.pos.z = *EnemyEclInstr::GetVarFloat(enemy, &local_b0.pos.z, NULL); g_EnemyManager.SpawnEnemy(local_b0.subId, local_b0.pos.AsD3dXVec(), local_b0.life, local_b0.itemDrop, local_b0.score); break; diff --git a/src/Enemy.hpp b/src/Enemy.hpp index 78ea59a0..d28f84d0 100644 --- a/src/Enemy.hpp +++ b/src/Enemy.hpp @@ -145,39 +145,6 @@ struct Enemy static void ResetEffectArray(Enemy *enemy); static void UpdateEffects(Enemy *enemy); - static i32 *GetVar(Enemy *enemy, EclVarId *varId, EclValueType *valueType); - static f32 *GetVarFloat(Enemy *enemy, f32 *varId, EclValueType *valueType); - static void SetVar(Enemy *enemy, EclVarId lhs, void *rhs); - - static void MathAdd(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); - static void MathSub(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); - static void MathMul(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); - static void MathDiv(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); - static void MathMod(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); - static void MathAtan2(Enemy *enemy, EclVarId out, f32 *a1, f32 *a2, f32 *b1, f32 *b2); - - static void MoveDirTime(Enemy *enemy, EclRawInstr *instr); - static void MovePosTime(Enemy *enemy, EclRawInstr *instr); - static void MoveTime(Enemy *enemy, EclRawInstr *instr); - - static void ExInsCirnoRainbowBallJank(Enemy *enemy, EclRawInstr *instr); - static void ExInsShootAtRandomArea(Enemy *enemy, EclRawInstr *instr); - static void ExInsShootStarPattern(Enemy *enemy, EclRawInstr *instr); - static void ExInsPatchouliShottypeSetVars(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage56Func4(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage5Func5(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage6Func7(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage6Func8(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage6Func9(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage6Func11(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage6XFunc10(Enemy *enemy, EclRawInstr *instr); - static void ExInsStage4Func12(Enemy *enemy, EclRawInstr *instr); - static void ExInsStageXFunc13(Enemy *enemy, EclRawInstr *instr); - static void ExInsStageXFunc14(Enemy *enemy, EclRawInstr *instr); - static void ExInsStageXFunc15(Enemy *enemy, EclRawInstr *instr); - static void ExInsStageXFunc16(Enemy *enemy, EclRawInstr *instr); - f32 LifePercent() { return (f32)this->life / (f32)this->maxLife; diff --git a/src/Enemy.cpp b/src/EnemyEclInstr.cpp similarity index 89% rename from src/Enemy.cpp rename to src/EnemyEclInstr.cpp index e68a2b17..2fb8b051 100644 --- a/src/Enemy.cpp +++ b/src/EnemyEclInstr.cpp @@ -1,7 +1,8 @@ -#include "Enemy.hpp" +#include "EnemyEclInstr.hpp" #include "BulletManager.hpp" #include "EclManager.hpp" #include "EffectManager.hpp" +#include "Enemy.hpp" #include "EnemyManager.hpp" #include "GameManager.hpp" #include "Gui.hpp" @@ -12,7 +13,8 @@ namespace th06 { - +namespace EnemyEclInstr +{ #define MAX_BOSS_TIME 7200 struct PatchouliShottypeVars @@ -35,13 +37,13 @@ DIFFABLE_STATIC_ARRAY(f32, 6, g_StarAngleTable); DIFFABLE_STATIC(D3DXVECTOR3, g_EnemyPosVector); DIFFABLE_STATIC(D3DXVECTOR3, g_PlayerPosVector); -void Enemy::MoveDirTime(Enemy *enemy, EclRawInstr *instr) +void MoveDirTime(Enemy *enemy, EclRawInstr *instr) { EclRawInstrAluArgs *alu; f32 angle; alu = &instr->args.alu; - angle = *Enemy::GetVarFloat(enemy, &alu->arg1.f32, NULL); + angle = *GetVarFloat(enemy, &alu->arg1.f32, NULL); enemy->moveInterp.x = sinf(angle) * alu->arg2.f32 * alu->res / 2.0f; enemy->moveInterp.y = cosf(angle) * alu->arg2.f32 * alu->res / 2.0f; @@ -55,14 +57,14 @@ void Enemy::MoveDirTime(Enemy *enemy, EclRawInstr *instr) enemy->flags.unk1 = 2; } -void Enemy::MovePosTime(Enemy *enemy, EclRawInstr *instr) +void MovePosTime(Enemy *enemy, EclRawInstr *instr) { D3DXVECTOR3 newPos; EclRawInstrAluArgs *alu = &instr->args.alu; - newPos.x = *Enemy::GetVarFloat(enemy, &alu->arg1.f32, NULL); - newPos.y = *Enemy::GetVarFloat(enemy, &alu->arg2.f32, NULL); - newPos.z = *Enemy::GetVarFloat(enemy, &alu->arg3.f32, NULL); + newPos.x = *GetVarFloat(enemy, &alu->arg1.f32, NULL); + newPos.y = *GetVarFloat(enemy, &alu->arg2.f32, NULL); + newPos.z = *GetVarFloat(enemy, &alu->arg3.f32, NULL); enemy->moveInterp = newPos - enemy->position; enemy->moveInterpStartPos = enemy->position; @@ -74,13 +76,13 @@ void Enemy::MovePosTime(Enemy *enemy, EclRawInstr *instr) enemy->axisSpeed = D3DXVECTOR3(0.0f, 0.0f, 0.0f); } -void Enemy::MoveTime(Enemy *enemy, EclRawInstr *instr) +void MoveTime(Enemy *enemy, EclRawInstr *instr) { EclRawInstrAluArgs *alu; f32 angle; alu = &instr->args.alu; - angle = *Enemy::GetVarFloat(enemy, &enemy->angle, NULL); + angle = *GetVarFloat(enemy, &enemy->angle, NULL); enemy->moveInterp.x = sinf(angle) * enemy->speed * alu->res / 2.0f; enemy->moveInterp.y = cosf(angle) * enemy->speed * alu->res / 2.0f; @@ -94,7 +96,7 @@ void Enemy::MoveTime(Enemy *enemy, EclRawInstr *instr) enemy->flags.unk1 = 2; } -i32 *Enemy::GetVar(Enemy *enemy, EclVarId *eclVarId, EclValueType *valueType) +i32 *GetVar(Enemy *enemy, EclVarId *eclVarId, EclValueType *valueType) { if (valueType != NULL) *valueType = ECL_VALUE_TYPE_UNDEFINED; @@ -232,10 +234,10 @@ i32 *Enemy::GetVar(Enemy *enemy, EclVarId *eclVarId, EclValueType *valueType) return (i32 *)eclVarId; } -f32 *Enemy::GetVarFloat(Enemy *enemy, f32 *eclVarId, EclValueType *valueType) +f32 *GetVarFloat(Enemy *enemy, f32 *eclVarId, EclValueType *valueType) { i32 varId = *eclVarId; - i32 *res = Enemy::GetVar(enemy, (EclVarId *)&varId, valueType); + i32 *res = GetVar(enemy, (EclVarId *)&varId, valueType); if (res == &varId) { return eclVarId; @@ -247,13 +249,13 @@ f32 *Enemy::GetVarFloat(Enemy *enemy, f32 *eclVarId, EclValueType *valueType) } #pragma var_order(lhsPtr, rhsPtr, lhsType) -void Enemy::SetVar(Enemy *enemy, EclVarId lhs, void *rhs) +void SetVar(Enemy *enemy, EclVarId lhs, void *rhs) { i32 *lhsPtr; EclValueType lhsType; i32 *rhsPtr; - rhsPtr = Enemy::GetVar(enemy, (EclVarId *)rhs, NULL); + rhsPtr = GetVar(enemy, (EclVarId *)rhs, NULL); lhsPtr = GetVar(enemy, &lhs, &lhsType); if (lhsType == ECL_VALUE_TYPE_INT) { @@ -267,7 +269,7 @@ void Enemy::SetVar(Enemy *enemy, EclVarId lhs, void *rhs) } #pragma var_order(outPtr, rhsPtr, lhsPtr, outType) -void Enemy::MathAdd(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) +void MathAdd(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) { EclValueType outType; i32 *outPtr; @@ -275,141 +277,141 @@ void Enemy::MathAdd(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarI i32 *rhsPtr; // Get output variable. - outPtr = Enemy::GetVar(enemy, &outVarId, &outType); + outPtr = GetVar(enemy, &outVarId, &outType); if (outType == ECL_VALUE_TYPE_INT) { - lhsPtr = Enemy::GetVar(enemy, lhsVarId, NULL); - rhsPtr = Enemy::GetVar(enemy, rhsVarId, NULL); + lhsPtr = GetVar(enemy, lhsVarId, NULL); + rhsPtr = GetVar(enemy, rhsVarId, NULL); *outPtr = *lhsPtr + *rhsPtr; } else if (outType == ECL_VALUE_TYPE_FLOAT) { - lhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)lhsVarId, NULL); - rhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)rhsVarId, NULL); + lhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)lhsVarId, NULL); + rhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)rhsVarId, NULL); *(f32 *)outPtr = *(f32 *)lhsPtr + *(f32 *)rhsPtr; } return; } #pragma var_order(outPtr, rhsPtr, lhsPtr, outType) -void Enemy::MathSub(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) +void MathSub(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) { EclValueType outType; i32 *outPtr; i32 *lhsPtr; i32 *rhsPtr; - outPtr = Enemy::GetVar(enemy, &outVarId, &outType); + outPtr = GetVar(enemy, &outVarId, &outType); if (outType == ECL_VALUE_TYPE_INT) { - lhsPtr = Enemy::GetVar(enemy, lhsVarId, NULL); - rhsPtr = Enemy::GetVar(enemy, rhsVarId, NULL); + lhsPtr = GetVar(enemy, lhsVarId, NULL); + rhsPtr = GetVar(enemy, rhsVarId, NULL); *outPtr = *lhsPtr - *rhsPtr; } else if (outType == ECL_VALUE_TYPE_FLOAT) { - lhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)lhsVarId, NULL); - rhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)rhsVarId, NULL); + lhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)lhsVarId, NULL); + rhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)rhsVarId, NULL); *(f32 *)outPtr = *(f32 *)lhsPtr - *(f32 *)rhsPtr; } return; } #pragma var_order(outPtr, rhsPtr, lhsPtr, outType) -void Enemy::MathMul(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) +void MathMul(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) { EclValueType outType; i32 *outPtr; i32 *lhsPtr; i32 *rhsPtr; - lhsPtr = Enemy::GetVar(enemy, lhsVarId, NULL); - rhsPtr = Enemy::GetVar(enemy, rhsVarId, NULL); - outPtr = Enemy::GetVar(enemy, &outVarId, &outType); + lhsPtr = GetVar(enemy, lhsVarId, NULL); + rhsPtr = GetVar(enemy, rhsVarId, NULL); + outPtr = GetVar(enemy, &outVarId, &outType); if (outType == ECL_VALUE_TYPE_INT) { - lhsPtr = Enemy::GetVar(enemy, lhsVarId, NULL); - rhsPtr = Enemy::GetVar(enemy, rhsVarId, NULL); + lhsPtr = GetVar(enemy, lhsVarId, NULL); + rhsPtr = GetVar(enemy, rhsVarId, NULL); *outPtr = *lhsPtr * *rhsPtr; } else if (outType == ECL_VALUE_TYPE_FLOAT) { - lhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)lhsVarId, NULL); - rhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)rhsVarId, NULL); + lhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)lhsVarId, NULL); + rhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)rhsVarId, NULL); *(f32 *)outPtr = *(f32 *)lhsPtr * *(f32 *)rhsPtr; } return; } #pragma var_order(outPtr, rhsPtr, lhsPtr, outType) -void Enemy::MathDiv(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) +void MathDiv(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) { EclValueType outType; i32 *outPtr; i32 *lhsPtr; i32 *rhsPtr; - outPtr = Enemy::GetVar(enemy, &outVarId, &outType); + outPtr = GetVar(enemy, &outVarId, &outType); if (outType == ECL_VALUE_TYPE_INT) { - lhsPtr = Enemy::GetVar(enemy, lhsVarId, NULL); - rhsPtr = Enemy::GetVar(enemy, rhsVarId, NULL); + lhsPtr = GetVar(enemy, lhsVarId, NULL); + rhsPtr = GetVar(enemy, rhsVarId, NULL); *outPtr = *lhsPtr / *rhsPtr; } else if (outType == ECL_VALUE_TYPE_FLOAT) { - lhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)lhsVarId, NULL); - rhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)rhsVarId, NULL); + lhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)lhsVarId, NULL); + rhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)rhsVarId, NULL); *(f32 *)outPtr = *(f32 *)lhsPtr / *(f32 *)rhsPtr; } return; } #pragma var_order(outPtr, rhsPtr, lhsPtr, outType) -void Enemy::MathMod(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) +void MathMod(Enemy *enemy, EclVarId outVarId, EclVarId *lhsVarId, EclVarId *rhsVarId) { EclValueType outType; i32 *outPtr; i32 *lhsPtr; i32 *rhsPtr; - outPtr = Enemy::GetVar(enemy, &outVarId, &outType); + outPtr = GetVar(enemy, &outVarId, &outType); if (outType == ECL_VALUE_TYPE_INT) { - lhsPtr = Enemy::GetVar(enemy, lhsVarId, NULL); - rhsPtr = Enemy::GetVar(enemy, rhsVarId, NULL); + lhsPtr = GetVar(enemy, lhsVarId, NULL); + rhsPtr = GetVar(enemy, rhsVarId, NULL); *outPtr = *lhsPtr % *rhsPtr; } else if (outType == ECL_VALUE_TYPE_FLOAT) { - lhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)lhsVarId, NULL); - rhsPtr = (i32 *)Enemy::GetVarFloat(enemy, (f32 *)rhsVarId, NULL); + lhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)lhsVarId, NULL); + rhsPtr = (i32 *)GetVarFloat(enemy, (f32 *)rhsVarId, NULL); *(f32 *)outPtr = fmodf(*(f32 *)lhsPtr, *(f32 *)rhsPtr); } return; } #pragma var_order(y2Ptr, outPtr, x1Ptr, y1Ptr, outType, x2Ptr) -void Enemy::MathAtan2(Enemy *enemy, EclVarId outVarId, f32 *x1, f32 *y1, f32 *y2, f32 *x2) +void MathAtan2(Enemy *enemy, EclVarId outVarId, f32 *x1, f32 *y1, f32 *y2, f32 *x2) { EclValueType outType; f32 *outPtr; f32 *y1Ptr, *x1Ptr, *x2Ptr, *y2Ptr; - outPtr = (f32 *)Enemy::GetVar(enemy, &outVarId, &outType); + outPtr = (f32 *)GetVar(enemy, &outVarId, &outType); if (outType == ECL_VALUE_TYPE_FLOAT) { - y1Ptr = Enemy::GetVarFloat(enemy, x1, NULL); - x1Ptr = Enemy::GetVarFloat(enemy, y1, NULL); - y2Ptr = Enemy::GetVarFloat(enemy, y2, NULL); - x2Ptr = Enemy::GetVarFloat(enemy, x2, NULL); + y1Ptr = GetVarFloat(enemy, x1, NULL); + x1Ptr = GetVarFloat(enemy, y1, NULL); + y2Ptr = GetVarFloat(enemy, y2, NULL); + x2Ptr = GetVarFloat(enemy, x2, NULL); *outPtr = atan2f(*x2Ptr - *x1Ptr, *y2Ptr - *y1Ptr); } return; } #pragma var_order(i, currentBullet, effectIndex, velocityVector, bulletTimer, accelerationMultiplier, accelerationAngle) -void Enemy::ExInsCirnoRainbowBallJank(Enemy *enemy, EclRawInstr *instr) +void ExInsCirnoRainbowBallJank(Enemy *enemy, EclRawInstr *instr) { f32 accelerationAngle; f32 accelerationMultiplier; @@ -458,7 +460,7 @@ void Enemy::ExInsCirnoRainbowBallJank(Enemy *enemy, EclRawInstr *instr) } } -void Enemy::ExInsShootAtRandomArea(Enemy *enemy, EclRawInstr *instr) +void ExInsShootAtRandomArea(Enemy *enemy, EclRawInstr *instr) { f32 bulletSpeed; @@ -474,7 +476,7 @@ void Enemy::ExInsShootAtRandomArea(Enemy *enemy, EclRawInstr *instr) #pragma var_order(i, propsSpeedBackup, starPatterTarget1, targetDistance, starPatternTarget0, patternPosition, \ baseTargetPosition) -void Enemy::ExInsShootStarPattern(Enemy *enemy, EclRawInstr *instr) +void ExInsShootStarPattern(Enemy *enemy, EclRawInstr *instr) { // Variable names are more quick guesses at functionality than anything else, they should not be trusted D3DXVECTOR3 baseTargetPosition; @@ -538,7 +540,7 @@ void Enemy::ExInsShootStarPattern(Enemy *enemy, EclRawInstr *instr) enemy->currentContext.var2++; } -void Enemy::ExInsPatchouliShottypeSetVars(Enemy *enemy, EclRawInstr *instr) +void ExInsPatchouliShottypeSetVars(Enemy *enemy, EclRawInstr *instr) { enemy->currentContext.var1 = g_PatchouliShottypeVars[g_GameManager.character].shotVars[g_GameManager.shotType].var1; enemy->currentContext.var2 = g_PatchouliShottypeVars[g_GameManager.character].shotVars[g_GameManager.shotType].var2; @@ -546,7 +548,7 @@ void Enemy::ExInsPatchouliShottypeSetVars(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(playerBulletOffset, bulletsLeft, i, currentBullet) -void Enemy::ExInsStage56Func4(Enemy *enemy, EclRawInstr *instr) +void ExInsStage56Func4(Enemy *enemy, EclRawInstr *instr) { i32 bulletsLeft; Bullet *currentBullet; @@ -649,7 +651,7 @@ void Enemy::ExInsStage56Func4(Enemy *enemy, EclRawInstr *instr) #pragma var_order(patternPosition, i, bulletProps, sinOut, bpPositionOffset, matrixOutSeed, matrixIn, bulletAngle, \ cosOut, matrixInSeed, matrixOut) -void Enemy::ExInsStage5Func5(Enemy *enemy, EclRawInstr *instr) +void ExInsStage5Func5(Enemy *enemy, EclRawInstr *instr) { D3DXVECTOR3 bpPositionOffset; f32 bulletAngle; @@ -732,7 +734,7 @@ void Enemy::ExInsStage5Func5(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(effect, baseAngleModifier, distanceModifier, finalAngle, particlePos) -void Enemy::ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr) +void ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr) { i32 baseAngleModifier; f32 distanceModifier; @@ -742,7 +744,7 @@ void Enemy::ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr) if (enemy->flags.unk15 != 0) { - ResetEffectArray(enemy); + Enemy::ResetEffectArray(enemy); return; } enemy->exInsFunc6Angle += RADIANS(1.0f); @@ -790,7 +792,7 @@ void Enemy::ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr) #pragma var_order(laserProps, i, lengthMultiplier, attackType, innerLoopCount, angleDiff, outerLoopCount, laserAngle, \ randomAngleModifier, positionVectors) -void Enemy::ExInsStage6Func7(Enemy *enemy, EclRawInstr *instr) +void ExInsStage6Func7(Enemy *enemy, EclRawInstr *instr) { f32 angleDiff; i32 attackType; @@ -909,7 +911,7 @@ void Enemy::ExInsStage6Func7(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(bulletProps, changedBullets, i, currentBullet) -void Enemy::ExInsStage6Func8(Enemy *enemy, EclRawInstr *instr) +void ExInsStage6Func8(Enemy *enemy, EclRawInstr *instr) { EnemyBulletShooter bulletProps; i32 changedBullets; @@ -948,7 +950,7 @@ void Enemy::ExInsStage6Func8(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(unusedBulletProps, i, local64, currentBullet, randomAngleModifier) -void Enemy::ExInsStage6Func9(Enemy *enemy, EclRawInstr *instr) +void ExInsStage6Func9(Enemy *enemy, EclRawInstr *instr) { Bullet *currentBullet; f32 distance; @@ -996,7 +998,7 @@ void Enemy::ExInsStage6Func9(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(unusedBulletProps, i, currentBullet, unusedRandomNumber) -void Enemy::ExInsStage6Func11(Enemy *enemy, EclRawInstr *instr) +void ExInsStage6Func11(Enemy *enemy, EclRawInstr *instr) { Bullet *currentBullet; i32 i; @@ -1032,7 +1034,7 @@ void Enemy::ExInsStage6Func11(Enemy *enemy, EclRawInstr *instr) } } -void Enemy::ExInsStage6XFunc10(Enemy *enemy, EclRawInstr *instr) +void ExInsStage6XFunc10(Enemy *enemy, EclRawInstr *instr) { if (enemy->life <= 0) { @@ -1066,7 +1068,7 @@ void Enemy::ExInsStage6XFunc10(Enemy *enemy, EclRawInstr *instr) } } -void Enemy::ExInsStage4Func12(Enemy *enemy, EclRawInstr *instr) +void ExInsStage4Func12(Enemy *enemy, EclRawInstr *instr) { i32 i; @@ -1083,7 +1085,7 @@ void Enemy::ExInsStage4Func12(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(i, bulletProps, basePatternAngle, numPatterns) -void Enemy::ExInsStageXFunc13(Enemy *enemy, EclRawInstr *instr) +void ExInsStageXFunc13(Enemy *enemy, EclRawInstr *instr) { f32 basePatternAngle; EnemyBulletShooter bulletProps; @@ -1108,7 +1110,7 @@ void Enemy::ExInsStageXFunc13(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(bulletPosition, i, angleSin, currentLaser, angleCos, positionMultiplier) -void Enemy::ExInsStageXFunc14(Enemy *enemy, EclRawInstr *instr) +void ExInsStageXFunc14(Enemy *enemy, EclRawInstr *instr) { f32 angleCos; f32 angleSin; @@ -1143,7 +1145,7 @@ void Enemy::ExInsStageXFunc14(Enemy *enemy, EclRawInstr *instr) #pragma var_order(unusedBulletProps, totalIterations, i, innerBullet, enemyAngle, distance, currentBullet, \ bulletsAngle, j) -void Enemy::ExInsStageXFunc15(Enemy *enemy, EclRawInstr *instr) +void ExInsStageXFunc15(Enemy *enemy, EclRawInstr *instr) { f32 bulletsAngle; Bullet *currentBullet; @@ -1209,7 +1211,7 @@ void Enemy::ExInsStageXFunc15(Enemy *enemy, EclRawInstr *instr) } #pragma var_order(remainingLife, rangeModifier) -void Enemy::ExInsStageXFunc16(Enemy *enemy, EclRawInstr *instr) +void ExInsStageXFunc16(Enemy *enemy, EclRawInstr *instr) { f32 rangeModifier; i32 remainingLife; @@ -1233,4 +1235,5 @@ void Enemy::ExInsStageXFunc16(Enemy *enemy, EclRawInstr *instr) enemy->currentContext.float3 = g_Rng.GetRandomF32InRange(rangeModifier) + (96.0f - rangeModifier / 2.0f); } } +}; // namespace EnemyEclInstr }; // namespace th06 diff --git a/src/EnemyEclInstr.hpp b/src/EnemyEclInstr.hpp new file mode 100644 index 00000000..ec543a87 --- /dev/null +++ b/src/EnemyEclInstr.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "Enemy.hpp" + +namespace th06 +{ +namespace EnemyEclInstr +{ +i32 *GetVar(Enemy *enemy, EclVarId *varId, EclValueType *valueType); +f32 *GetVarFloat(Enemy *enemy, f32 *varId, EclValueType *valueType); +void SetVar(Enemy *enemy, EclVarId lhs, void *rhs); + +void MathAdd(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); +void MathSub(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); +void MathMul(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); +void MathDiv(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); +void MathMod(Enemy *enemy, EclVarId out, EclVarId *lhs, EclVarId *rhs); +void MathAtan2(Enemy *enemy, EclVarId out, f32 *a1, f32 *a2, f32 *b1, f32 *b2); + +void MoveDirTime(Enemy *enemy, EclRawInstr *instr); +void MovePosTime(Enemy *enemy, EclRawInstr *instr); +void MoveTime(Enemy *enemy, EclRawInstr *instr); + +void ExInsCirnoRainbowBallJank(Enemy *enemy, EclRawInstr *instr); +void ExInsShootAtRandomArea(Enemy *enemy, EclRawInstr *instr); +void ExInsShootStarPattern(Enemy *enemy, EclRawInstr *instr); +void ExInsPatchouliShottypeSetVars(Enemy *enemy, EclRawInstr *instr); +void ExInsStage56Func4(Enemy *enemy, EclRawInstr *instr); +void ExInsStage5Func5(Enemy *enemy, EclRawInstr *instr); +void ExInsStage6XFunc6(Enemy *enemy, EclRawInstr *instr); +void ExInsStage6Func7(Enemy *enemy, EclRawInstr *instr); +void ExInsStage6Func8(Enemy *enemy, EclRawInstr *instr); +void ExInsStage6Func9(Enemy *enemy, EclRawInstr *instr); +void ExInsStage6Func11(Enemy *enemy, EclRawInstr *instr); +void ExInsStage6XFunc10(Enemy *enemy, EclRawInstr *instr); +void ExInsStage4Func12(Enemy *enemy, EclRawInstr *instr); +void ExInsStageXFunc13(Enemy *enemy, EclRawInstr *instr); +void ExInsStageXFunc14(Enemy *enemy, EclRawInstr *instr); +void ExInsStageXFunc15(Enemy *enemy, EclRawInstr *instr); +void ExInsStageXFunc16(Enemy *enemy, EclRawInstr *instr); +}; // namespace EnemyEclInstr +}; // namespace th06