diff --git a/include/effects.h b/include/effects.h index 536f6c0c01..9bcdc2bb99 100644 --- a/include/effects.h +++ b/include/effects.h @@ -387,8 +387,19 @@ typedef struct EmoteFXData { } EmoteFXData; // size = 0x40 typedef struct SparklesFXData { - /* 0x00 */ char todo[0]; -} SparklesFXData; // size = unknown + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s32 unk_20; + /* 0x24 */ s32 unk_24; + /* 0x28 */ s32 unk_28; + /* 0x2C */ s32 unk_2C; +} SparklesFXData; // size = 0x30 enum SparkesFXTypes { FX_SPARKLES_0 = 0, @@ -556,9 +567,9 @@ typedef struct FlameFXData { /* 0x10 */ f32 unk_10; /* 0x14 */ f32 unk_14; /* 0x18 */ s32 unk_18; - /* 0x1C */ s32 unk_1C; - /* 0x20 */ s32 unk_20; - /* 0x24 */ s32 unk_24; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; /* 0x28 */ f32 unk_28; /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; @@ -1141,7 +1152,7 @@ typedef struct SnowfallFXData { typedef struct Effect46FXData { /* 0x00 */ s32 unk_00; - /* 0x04 */ f32* unk_04; // pointer to another struct? + /* 0x04 */ PlayerStatus* unk_04; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; /* 0x10 */ f32 unk_10; @@ -1157,9 +1168,9 @@ typedef struct Effect46FXData { /* 0x38 */ f32 unk_38; /* 0x3C */ f32 unk_3C; /* 0x40 */ f32 unk_40; - /* 0x44 */ s8 unk_44; - /* 0x45 */ s8 unk_45; - /* 0x46 */ s8 unk_46; + /* 0x44 */ u8 unk_44; + /* 0x45 */ u8 unk_45; + /* 0x46 */ u8 unk_46; /* 0x47 */ char unk_47; } Effect46FXData; // size = 0x48 @@ -1313,10 +1324,22 @@ typedef struct QuizmoAnswerFXData { } QuizmoAnswerFXData; // size = unknown typedef struct MotionBlurFlameFXData { - /* 0x00 */ char unk_00[0x10]; + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; /* 0x10 */ Vec3f position; - /* 0x1C */ char todo[0]; -} MotionBlurFlameFXData; // size = unknown + /* 0x1C */ f32 unk_1C[4]; + /* 0x2C */ f32 unk_2C[4]; + /* 0x3C */ f32 unk_3C[4]; + /* 0x4C */ s32 unk_4C; + /* 0x50 */ s32 unk_50; + /* 0x54 */ s32 unk_54; + /* 0x58 */ char unk_58[4]; + /* 0x5C */ s32 unk_5C; + /* 0x60 */ s32 unk_60; + /* 0x64 */ s32 unk_64; +} MotionBlurFlameFXData; // size = 0x68 typedef struct EnergyOrbWaveFXData { /* 0x00 */ s32 unk_00; @@ -1334,8 +1357,22 @@ typedef struct EnergyOrbWaveFXData { } EnergyOrbWaveFXData; // size = 0x38 typedef struct MerlinHouseStarsFXData { - /* 0x00 */ char todo[0]; -} MerlinHouseStarsFXData; // size = unknown + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ s32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ s32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ f32 unk_28; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ f32 unk_38; +} MerlinHouseStarsFXData; // size = 0x3C typedef struct QuizmoAudienceFXData { /* 0x00 */ char todo[0]; @@ -1990,8 +2027,24 @@ typedef struct LilOinkFXData { } LilOinkFXData; // size = 0x148 typedef struct SomethingRotatingFXData { - /* 0x00 */ char todo[0]; -} SomethingRotatingFXData; // size = unknown + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s32 unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s32 unk_20; + /* 0x24 */ s8 unk_24; + /* 0x25 */ s8 unk_25; + /* 0x26 */ u8 unk_26; + /* 0x27 */ u8 unk_27; + /* 0x28 */ s8 unk_28; + /* 0x29 */ s8 unk_29; + /* 0x2A */ char unk_2A[2]; + /* 0x2C */ f32 unk_2C; +} SomethingRotatingFXData; // size = 0x30 typedef struct BreakingJunkFXData { /* 0x00 */ s32 unk_00; @@ -2023,7 +2076,7 @@ typedef struct BuffData { /* 0x04 */ s16 turnsLeft; /* 0x06 */ s16 state; /* 0x08 */ s16 stateTimer; -} BuffData; +} BuffData; // size = 0xA typedef struct PartnerBuffFXData { /* 0x00 */ s16 useRandomValues; @@ -2077,8 +2130,18 @@ typedef struct StarSpiritsEnergyFXData { } StarSpiritsEnergyFXData; // size = ? typedef struct PinkSparklesFXData { - /* 0x00 */ char todo[0]; -} PinkSparklesFXData; // size = unknown + /* 0x00 */ s32 unk_00; + /* 0x04 */ f32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ s32 unk_1C; + /* 0x20 */ s32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ s32 unk_28; +} PinkSparklesFXData; // size = 0x2C typedef struct StarOutlineFXData { /* 0x00 */ s16 unk_00; @@ -2268,14 +2331,6 @@ typedef struct WattEffectData { /* 0x1C */ s32 debuff; } WattEffectData; -// seems to actually be PlayerStatus, but it's too large seemingly given the bss padding in UnkWhirlwindEffectFunc.inc.c -typedef struct EffectWhirlwindUnk { - /* 0x00 */ char unk_00[0x28]; - /* 0x28 */ f32 unk_28; - /* 0x2C */ f32 unk_2C; - /* 0x30 */ f32 unk_30; -} EffectWhirlwindUnk; - typedef struct StarSpiritData { /* 0x00 */ f32 unk_00; /* 0x04 */ f32 unk_04; @@ -2409,7 +2464,7 @@ EffectInstance* fx_bombette_breaking(s32, s32, s32, f32, s32, s32); EffectInstance* fx_firework(s32, f32, f32, f32, f32, s32); EffectInstance* fx_confetti(s32, f32, f32, f32, f32, s32); EffectInstance* fx_snowfall(s32, s32); -EffectInstance* fx_46(s32, EffectWhirlwindUnk*, f32, s32); +EffectInstance* fx_46(s32, PlayerStatus*, f32, s32); EffectInstance* fx_gather_magic(s32, f32, f32, f32, f32, s32); EffectInstance* fx_attack_result_text(s32, f32, f32, f32, f32, s32); EffectInstance* fx_small_gold_sparkle(s32, f32, f32, f32, f32, s32); diff --git a/include/effects_internal.h b/include/effects_internal.h index e2b9c58569..945e5f370c 100644 --- a/include/effects_internal.h +++ b/include/effects_internal.h @@ -49,22 +49,22 @@ void floating_flower_main(s32, f32, f32, f32, s32); void snowflake_main(f32, f32, f32, s32, s32); EffectInstance* star_main(s32, f32, f32, f32, f32, f32, f32, f32); void emote_main(s32, Npc*, f32, f32, f32, f32, f32, s32, EffectInstance**); -FX_MAIN(sparkles_main); +void sparkles_main(s32, f32, f32, f32, f32); EffectInstance* shape_spell_main(s32, f32, f32, f32, f32, f32, f32, s32); void gather_energy_pink_main(s32, f32, f32, f32, f32, s32); void drop_leaves_main(s32, f32, f32, f32, s32); EffectInstance* dust_main(s32, f32, f32, f32, s32); FX_MAIN(shattering_stones_main); -FX_MAIN(smoke_ring_main); -FX_MAIN(damage_stars_main); -FX_MAIN(explosion_main); +void smoke_ring_main(s32, f32, f32, f32); +void damage_stars_main(s32, f32, f32, f32, f32, f32, f32, s32); +void explosion_main(s32, f32, f32, f32); FX_MAIN(lens_flare_main); void got_item_outline_main(s32, f32, f32, f32, f32, EffectInstance**); FX_MAIN(spiky_white_aura_main); FX_MAIN(smoke_impact_main); void damage_indicator_main(s32, f32, f32, f32, f32, f32, s32, EffectInstance**); FX_MAIN(purple_ring_main); -FX_MAIN(flame_main); +void flame_main(s32, f32, f32, f32, f32, EffectInstance**); void stars_burst_main(s32, f32, f32, f32, f32, f32, s32); FX_MAIN(stars_shimmer_main); void rising_bubble_main(s32, f32, f32, f32, f32); @@ -98,10 +98,10 @@ EffectInstance* fire_flower_main(s32, f32, f32, f32, s32); EffectInstance* recover_main(s32, f32, f32, f32, s32); EffectInstance* disable_x_main(s32, f32, f32, f32, s32); EffectInstance* bombette_breaking_main(s32, s32, s32, f32, s32, s32); -FX_MAIN(firework_main); -FX_MAIN(confetti_main); +EffectInstance* firework_main(s32, f32, f32, f32, f32, s32); +EffectInstance* confetti_main(s32, f32, f32, f32, f32, s32); EffectInstance* snowfall_main(s32, s32); -FX_MAIN(fx_46_main); +EffectInstance* fx_46_main(s32, PlayerStatus*, f32, s32); EffectInstance* gather_magic_main(s32, f32, f32, f32, f32, s32); EffectInstance* attack_result_text_main(s32, f32, f32, f32, f32, s32); EffectInstance* small_gold_sparkle_main(s32, f32, f32, f32, f32); @@ -112,9 +112,9 @@ EffectInstance* chomp_drop_main(s32, f32, f32, f32, f32, s32, f32, s32, f32, s32 EffectInstance* quizmo_stage_main(s32, f32, f32, f32); FX_MAIN(radiating_energy_orb_main); FX_MAIN(quizmo_answer_main); -FX_MAIN(motion_blur_flame_main); +EffectInstance* motion_blur_flame_main(s32, f32, f32, f32, f32, s32); EffectInstance* energy_orb_wave_main(s32, f32, f32, f32, f32, s32); -FX_MAIN(merlin_house_stars_main); +EffectInstance* merlin_house_stars_main(s32, f32, f32, f32); FX_MAIN(quizmo_audience_main); EffectInstance* butterflies_main(s32, f32, f32, f32); EffectInstance* stat_change_main(s32, f32, f32, f32, f32, s32); @@ -137,7 +137,7 @@ FX_MAIN(tubba_heart_attack_main); FX_MAIN(whirlwind_main); EffectInstance* red_impact_main(s32, f32, f32, f32, f32); EffectInstance* floating_cloud_puff_main(s32, f32, f32, f32, f32, s32); -FX_MAIN(energy_in_out_main); +EffectInstance* energy_in_out_main(s32, f32, f32, f32, f32, s32); EffectInstance* tattle_window_main(s32, f32, f32, f32, f32, s32); EffectInstance* shiny_flare_main(s32, f32, f32, f32, f32); EffectInstance* huff_puff_breath_main(s32, f32, f32, f32, f32, f32, f32, s32); @@ -154,14 +154,14 @@ EffectInstance* chapter_change_main(s32, f32, f32, f32, f32, s32); FX_MAIN(ice_shard_main); FX_MAIN(spirit_card_main); EffectInstance* lil_oink_main(void); -FX_MAIN(something_rotating_main); +EffectInstance* something_rotating_main(s32, f32, f32, f32, f32, s32); EffectInstance* breaking_junk_main(s32, f32, f32, f32, f32, s32); EffectInstance* partner_buff_main(s32, f32, f32, f32, f32, s32); FX_MAIN(quizmo_assistant_main); FX_MAIN(ice_pillar_main); EffectInstance* sun_main(s32, f32, f32, f32, f32, s32); FX_MAIN(star_spirits_energy_main); -FX_MAIN(pink_sparkles_main); +EffectInstance* pink_sparkles_main(s32, f32, f32, f32, f32, f32); FX_MAIN(star_outline_main); EffectInstance* fx_86_main(s32, f32, f32, f32, f32, s32); diff --git a/src/battle/area_omo/actor/groove_guy.c b/src/battle/area_omo/actor/groove_guy.c index 0d63c50d25..1a1ada80a2 100644 --- a/src/battle/area_omo/actor/groove_guy.c +++ b/src/battle/area_omo/actor/groove_guy.c @@ -65,7 +65,7 @@ s32 N(statusTable_80224A40)[] = { STATUS_END, }; -BSS EffectWhirlwindUnk D_802310D0; +BSS PlayerStatus D_802310D0; ActorPartBlueprint N(partsTable_80224AEC)[] = { { @@ -609,9 +609,9 @@ s32 func_8021878C_512D5C(Evt* script, s32 isInitialCall) { temp_f20 = evt_get_float_variable(script, *args++); temp_v0 = evt_get_variable(script, *args++); - D_802310D0.unk_28 = x; - D_802310D0.unk_2C = y; - D_802310D0.unk_30 = z; + D_802310D0.position.x = x; + D_802310D0.position.y = y; + D_802310D0.position.z = z; fx_46(6, &D_802310D0, temp_f20, temp_v0); return ApiStatus_DONE2; diff --git a/src/battle/area_omo/stage/omo_04.c b/src/battle/area_omo/stage/omo_04.c index 1bcbf0c453..25fbf301f2 100644 --- a/src/battle/area_omo/stage/omo_04.c +++ b/src/battle/area_omo/stage/omo_04.c @@ -58,6 +58,4 @@ Formation N(fromation_slot_machine) = { { .actor = &N(slot_machine_stop), .home = { .vec = &N(slot_machine_pos4) }, .var0 = 3 }, }; -BSS char N(unused)[0x250]; - #include "battle/common/actor/slot_machine.inc.c" diff --git a/src/common/UnkWhirlwindEffectFunc.inc.c b/src/common/UnkWhirlwindEffectFunc.inc.c index ee5e53f369..abd03a7a58 100644 --- a/src/common/UnkWhirlwindEffectFunc.inc.c +++ b/src/common/UnkWhirlwindEffectFunc.inc.c @@ -1,8 +1,7 @@ #include "common.h" #include "effects.h" -BSS EffectWhirlwindUnk N(effectUnk); -BSS static s32 padding[0x94]; +BSS PlayerStatus N(effectUnk); ApiStatus N(UnkWhirlwindEffectFunc)(Evt* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; @@ -11,9 +10,9 @@ ApiStatus N(UnkWhirlwindEffectFunc)(Evt* script, s32 isInitialCall) { s32 var3 = evt_get_variable(script, *args++); s32 var4 = evt_get_variable(script, *args++); - N(effectUnk).unk_28 = var1; - N(effectUnk).unk_2C = var2 - 10.0f; - N(effectUnk).unk_30 = var3; + N(effectUnk).position.x = var1; + N(effectUnk).position.y = var2 - 10.0f; + N(effectUnk).position.z = var3; fx_46(6, &N(effectUnk), 1.0f, var4); return ApiStatus_DONE2; diff --git a/src/effects.c b/src/effects.c index 25d02a701c..aa03212740 100644 --- a/src/effects.c +++ b/src/effects.c @@ -110,7 +110,7 @@ EffectTableEntry gEffectTable[] = { /* 0x50 */ FX_ENTRY(quizmo_answer, _3A2440), /* 0x51 */ FX_ENTRY(motion_blur_flame, _3A33D0), /* 0x52 */ FX_ENTRY(energy_orb_wave, effect_gfx_energy_orb_wave), - /* 0x53 */ FX_ENTRY(merlin_house_stars, _3A5BE0), + /* 0x53 */ FX_ENTRY(merlin_house_stars, effect_gfx_merlin_house_stars), /* 0x54 */ FX_ENTRY(quizmo_audience, _3A77A0), /* 0x55 */ FX_ENTRY(butterflies, effect_gfx_butterflies), /* 0x56 */ FX_ENTRY(stat_change, _3AF700), diff --git a/src/effects/confetti.c b/src/effects/confetti.c index 15d2190366..ddc054442e 100644 --- a/src/effects/confetti.c +++ b/src/effects/confetti.c @@ -1,6 +1,33 @@ #include "common.h" #include "effects_internal.h" +extern Gfx D_090009E8_38C588[]; +extern Gfx D_09000A00_38C5A0[]; + +Gfx* D_E0088CC0[] = { + D_090009E8_38C588, D_090009E8_38C588, D_090009E8_38C588, D_09000A00_38C5A0, + D_090009E8_38C588, D_090009E8_38C588, D_090009E8_38C588 +}; + +u8 D_E0088CDC[] = { + 232, 160, 168, + 168, 80, 88, + 160, 168, 232, + 72, 72, 232, + 160, 232, 160, + 96, 176, 120, + 224, 224, 88, + 176, 160, 56, + 232, 160, 232, + 176, 64, 160, + 160, 216, 216, + 88, 168, 168 +}; + +s8 D_E0088D00[] = { 0, 1, 2, 3, 2, 1, 0, 0 }; + +s32 D_E0088D08[] = { 0x002D003C, 0x00000000 }; + void confetti_appendGfx(void* effect); void func_E0088000(ConfettiFXData* part) { diff --git a/src/effects/damage_stars.c b/src/effects/damage_stars.c index 26efbf212b..3758411913 100644 --- a/src/effects/damage_stars.c +++ b/src/effects/damage_stars.c @@ -5,27 +5,173 @@ extern Gfx D_090004C0_343500[]; extern Gfx D_090005E0_343620[]; u8 D_E0030E90[] = { - 0xFE, 0xAC, 0xAC, - 0xFE, 0xAC, 0xD5, - 0xFE, 0xB4, 0x9A, - 0xD5, 0xB4, 0xFE, - 0xB4, 0xB4, 0xFE, - 0xB4, 0xDD, 0xFE, - 0xB4, 0xFE, 0xFE, - 0xB4, 0xFE, 0xD5, - 0xB4, 0xFE, 0xB4, - 0xD5, 0xFE, 0xB4, - 0xFE, 0xFE, 0xB4, - 0xFE, 0xD5, 0xAC + 254, 172, 172, + 254, 172, 213, + 254, 180, 154, + 213, 180, 254, + 180, 180, 254, + 180, 221, 254, + 180, 254, 254, + 180, 254, 213, + 180, 254, 180, + 213, 254, 180, + 254, 254, 180, + 254, 213, 172 }; -u8 D_E0030EB4[] = { 0, 0, 0 }; +f32 D_E0030EB4; +void damage_stars_init(EffectInstance* effect); +void damage_stars_update(EffectInstance* effect); +void damage_stars_render(EffectInstance* effect); void damage_stars_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/damage_stars", damage_stars_main); +void damage_stars_main( + s32 arg0, + f32 arg1, + f32 arg2, + f32 arg3, + f32 arg4, + f32 arg5, + f32 arg6, + s32 arg7 +) { + EffectBlueprint bp; + EffectBlueprint* bpPtr = &bp; + EffectInstance* effect; + DamageStarsFXData* part; + f32 temp_f12; + f32 var_f28; + f32 var_f30; + f32 rotateX; + f32 rotateZ; + f32 sp70; + Matrix4f sp30; + s32 i; -void damage_stars_init(void) { + if (arg7 != 0) { + temp_f12 = SQ(arg4) + SQ(arg5) + SQ(arg6); + if (temp_f12 != 0.0f) { + temp_f12 = -1.0f / shim_sqrtf(temp_f12); + + arg4 *= temp_f12; + arg5 *= temp_f12; + arg6 *= temp_f12; + + if (arg4 != 0.0f) { + sp70 = 1.0f; + var_f30 = -arg5 / arg4; + var_f28 = 0.0f; + } else if (arg5 != 0.0f) { + sp70 = -arg4 / arg5; + var_f30 = 1.0f; + var_f28 = 0.0f; + } else { + sp70 = 0.0f; + var_f30 = 1.0f; + var_f28 = -arg4 / arg6; + } + + temp_f12 = SQ(var_f30) + SQ(sp70) + SQ(var_f28); + if (temp_f12 != 0) { + temp_f12 = 1.0f / shim_sqrtf(temp_f12); + + var_f30 *= temp_f12; + sp70 *= temp_f12; + var_f28 *= temp_f12; + + var_f30 *= 8.0f; + sp70 *= 8.0f; + var_f28 *= 8.0f; + arg4 *= 8.0f; + arg5 *= 8.0f; + arg6 *= 8.0f; + + bpPtr->unk_00 = 0; + bpPtr->init = damage_stars_init; + bpPtr->update = damage_stars_update; + bpPtr->renderWorld = damage_stars_render; + bpPtr->unk_14 = NULL; + bpPtr->effectID = EFFECT_DAMAGE_STARS; + + effect = shim_create_effect_instance(bpPtr); + effect->numParts = arg7; + part = effect->data.damageStars = shim_general_heap_malloc(arg7 * sizeof(*part)); + ASSERT(effect->data.damageStars != NULL); + + for (i = 0; i < arg7; i++, part++) { + part->unk_00 = arg0; + part->unk_04 = arg1; + part->unk_08 = arg2; + part->unk_0C = arg3; + + switch (arg0) { + case 0: + case 1: + case 2: + shim_guRotateF(sp30, (i * 360) / (arg7 - 1), arg4, arg5, arg6); + part->unk_10 = arg4 + sp30[0][0] * var_f30 + sp30[1][0] * sp70 + sp30[2][0] * var_f28; + part->unk_14 = arg5 + sp30[0][1] * var_f30 + sp30[1][1] * sp70 + sp30[2][1] * var_f28; + part->unk_18 = arg6 + sp30[0][2] * var_f30 + sp30[1][2] * sp70 + sp30[2][2] * var_f28; + break; + case 3: + rotateX = shim_sin_deg(gCameras[gCurrentCameraID].currentYaw); + rotateZ = -shim_cos_deg(gCameras[gCurrentCameraID].currentYaw); + shim_guRotateF(sp30, + (arg7 != 1) ? (i * 100) / (arg7 - 1) - 50 : 0.0f, + rotateX, 0.0f, rotateZ); + part->unk_10 = sp30[0][0] * arg4 + sp30[1][0] * arg5 + sp30[2][0] * arg6; + part->unk_14 = sp30[0][1] * arg4 + sp30[1][1] * arg5 + sp30[2][1] * arg6; + part->unk_18 = sp30[0][2] * arg4 + sp30[1][2] * arg5 + sp30[2][2] * arg6; + break; + case 4: + rotateX = shim_sin_deg(gCameras[gCurrentCameraID].currentYaw); + rotateZ = -shim_cos_deg(gCameras[gCurrentCameraID].currentYaw); + shim_guRotateF(sp30, (i * 360.0f) / (arg7 - 1), rotateX, 0.0f, rotateZ); + part->unk_10 = sp30[0][0] * arg4 + sp30[1][0] * arg5 + sp30[2][0] * arg6; + part->unk_14 = sp30[0][1] * arg4 + sp30[1][1] * arg5 + sp30[2][1] * arg6; + part->unk_18 = sp30[0][2] * arg4 + sp30[1][2] * arg5 + sp30[2][2] * arg6; + break; + } + + switch (arg0) { + case 0: + part->unk_20 = 0; + part->unk_28 = 24; + break; + case 1: + part->unk_20 = 20.0f; + part->unk_28 = 24; + break; + case 2: + part->unk_20 = 20.0f; + part->unk_28 = 40; + part->unk_10 *= 0.5; + part->unk_14 *= 0.5; + part->unk_18 *= 0.5; + break; + case 3: + case 4: + part->unk_20 = 20.0f; + part->unk_28 = 24; + break; + } + + part->unk_1C = 0; + part->unk_2C = 0; + part->unk_24 = 255; + } + + D_E0030EB4 += 15.0f; + if (D_E0030EB4 > 360.0f) { + D_E0030EB4 = 0.0f; + } + } + } + } +} + +void damage_stars_init(EffectInstance* effect) { } void damage_stars_update(EffectInstance* effect) { @@ -60,7 +206,7 @@ void damage_stars_update(EffectInstance* effect) { part->unk_14 *= 0.8; part->unk_18 *= 0.8; } - if (unk_28 - 6 < 0xEU) { + if (unk_28 >= 6 && unk_28 <= 19) { if (part->unk_00 == 0) { part->unk_20 += 1.0f; } diff --git a/src/effects/effect_3D.c b/src/effects/effect_3D.c index 6b34a45f72..b898f70944 100644 --- a/src/effects/effect_3D.c +++ b/src/effects/effect_3D.c @@ -14,10 +14,6 @@ void fx_3D_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 EffectBlueprint* bpPtr = &bp; EffectInstance* effect; Effect3DFXData* part; - f32 temp_f22 = arg4; - f32 temp_f24 = arg5; - f32 temp_f26 = arg6; - s32 numParts = arg7; f32 temp_f12; f32 temp_f28; f32 temp_f30; @@ -25,29 +21,29 @@ void fx_3D_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 Matrix4f sp30; s32 i; - if (numParts != 0) { - numParts++; + if (arg7 != 0) { + arg7++; - temp_f12 = SQ(temp_f22) + SQ(temp_f24) + SQ(temp_f26); + temp_f12 = SQ(arg4) + SQ(arg5) + SQ(arg6); if (temp_f12 != 0.0f) { temp_f12 = -1.0f / shim_sqrtf(temp_f12); - temp_f22 *= temp_f12; - temp_f24 *= temp_f12; - temp_f26 *= temp_f12; + arg4 *= temp_f12; + arg5 *= temp_f12; + arg6 *= temp_f12; - if (temp_f22 != 0.0f) { + if (arg4 != 0.0f) { sp70 = 1.0f; - temp_f30 = -temp_f24 / temp_f22; + temp_f30 = -arg5 / arg4; temp_f28 = 0.0f; - } else if (temp_f24 != 0.0f) { - sp70 = -temp_f22 / temp_f24; + } else if (arg5 != 0.0f) { + sp70 = -arg4 / arg5; temp_f30 = 1.0f; temp_f28 = 0.0f; } else { sp70 = 0.0f; temp_f30 = 1.0f; - temp_f28 = -temp_f22 / temp_f26; + temp_f28 = -arg4 / arg6; } temp_f12 = SQ(temp_f30) + SQ(sp70) + SQ(temp_f28); @@ -61,9 +57,9 @@ void fx_3D_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 temp_f30 *= 8.0f; sp70 *= 8.0f; temp_f28 *= 8.0f; - temp_f22 *= 8.0f; - temp_f24 *= 8.0f; - temp_f26 *= 8.0f; + arg4 *= 8.0f; + arg5 *= 8.0f; + arg6 *= 8.0f; bpPtr->unk_00 = 0; bpPtr->init = fx_3D_init; @@ -73,8 +69,8 @@ void fx_3D_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 bpPtr->effectID = EFFECT_3D; effect = shim_create_effect_instance(bpPtr); - effect->numParts = numParts; - part = effect->data.unk_3D = shim_general_heap_malloc(numParts * sizeof(*part)); + effect->numParts = arg7; + part = effect->data.unk_3D = shim_general_heap_malloc(arg7 * sizeof(*part)); ASSERT(effect->data.unk_3D != NULL); part->unk_04 = 0; @@ -86,17 +82,17 @@ void fx_3D_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 part->unk_60 = 0; part++; - for (i = 1; i < numParts; i++, part++) { + for (i = 1; i < arg7; i++, part++) { part->pos.x = 0; part->pos.y = 0; part->pos.z = 0; - shim_guRotateF(sp30, i * 72, temp_f22, temp_f24, temp_f26); - part->unk_14 = part->unk_20 = 2.0f * temp_f22; - part->unk_18 = part->unk_24 = 2.0f * temp_f24; - part->unk_1C = part->unk_28 = 2.0f * temp_f26; - part->unk_38 = -temp_f22 * 0.05 * 4.0; - part->unk_3C = -temp_f24 * 0.05 * 4.0; - part->unk_40 = -temp_f26 * 0.05 * 4.0; + shim_guRotateF(sp30, i * 72, arg4, arg5, arg6); + part->unk_14 = part->unk_20 = 2.0f * arg4; + part->unk_18 = part->unk_24 = 2.0f * arg5; + part->unk_1C = part->unk_28 = 2.0f * arg6; + part->unk_38 = -arg4 * 0.05 * 4.0; + part->unk_3C = -arg5 * 0.05 * 4.0; + part->unk_40 = -arg6 * 0.05 * 4.0; part->unk_2C = (sp30[0][0] * temp_f30 + sp30[1][0] * sp70 + sp30[2][0] * temp_f28) * 0.1 * 4.0; part->unk_30 = (sp30[0][1] * temp_f30 + sp30[1][1] * sp70 + sp30[2][1] * temp_f28) * 0.1 * 4.0; part->unk_34 = (sp30[0][2] * temp_f30 + sp30[1][2] * sp70 + sp30[2][2] * temp_f28) * 0.1 * 4.0; diff --git a/src/effects/effect_46.c b/src/effects/effect_46.c index 9594270d2c..a2df02d1a2 100644 --- a/src/effects/effect_46.c +++ b/src/effects/effect_46.c @@ -4,11 +4,126 @@ extern Gfx D_090003A0_38ED30[]; extern Gfx D_09000420_38EDB0[]; +s32 D_E008CAF0[] = { + 0xFEACACFE, 0xACD5FEB4, 0x9AD5B4FE, 0xB4B4FEB4, 0xDDFEB4FE, + 0xFEB4FED5, 0xB4FEB4D5, 0xFEB4FEFE, 0xB4FED5AC +}; + +u8 D_E008CB14[] = { 255, 255, 64 }; +u8 D_E008CB18[] = { 255, 64, 64 }; +u8 D_E008CB1C[] = { 255, 64, 255 }; + +void fx_46_init(EffectInstance* effect); +void fx_46_update(EffectInstance* effect); +void fx_46_render(EffectInstance* effect); void fx_46_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/effect_46", fx_46_main); +EffectInstance* fx_46_main(s32 arg0, PlayerStatus* arg1, f32 arg2, s32 arg3) { + EffectBlueprint bp; + EffectInstance* effect; + Effect46FXData* part; + s32 numParts = 5; + s32 index; + s32 i; -void fx_46_init(void) { + bp.init = fx_46_init; + bp.update = fx_46_update; + bp.renderWorld = fx_46_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_46; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + part = effect->data.unk_46 = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.unk_46 != NULL); + + part->unk_00 = arg0; + part->unk_04 = arg1; + part->unk_14 = arg2 * 1.2; + part->unk_18 = arg2 * 1.2; + part->unk_20 = arg3; + part->unk_24 = arg3; + part->unk_1C = 0; + part->unk_28 = 0; + + part++; + for (i = 1; i < numParts; i++, part++) { + switch (arg0) { + case 0: + case 2: + case 4: + case 6: + part->unk_08 = 0.0f; + part->unk_0C = i * 7 + 4; + part->unk_10 = 0.0f; + part->unk_38 = 0.0f; + part->unk_3C = 60.0f; + part->unk_40 = 0.0f; + part->unk_2C = 0.0f; + part->unk_30 = i * 120; + part->unk_34 = 0.0f; + part->unk_14 = 1.0f; + break; + case 1: + case 3: + case 5: + case 7: + part->unk_08 = 0.0f; + part->unk_0C = i * 7 + 4; + part->unk_10 = 0.0f; + part->unk_38 = 0.0f; + part->unk_3C = -60.0f; + part->unk_40 = 0.0f; + part->unk_2C = 0.0f; + part->unk_30 = i * 120; + part->unk_34 = 0.0f; + part->unk_14 = 1.0f; + part->unk_46 = 255; + part->unk_45 = 255; + part->unk_44 = 255; + break; + default: + part->unk_08 = 0; + part->unk_0C = arg1->colliderHeight * 0.5; + part->unk_10 = 0; + part->unk_38 = func_E0200000(1) * 8 - 4; + part->unk_3C = 0; + part->unk_40 = func_E0200000(1) * 8 - 4; + part->unk_2C = i * 25; + part->unk_30 = (i - 1) * 360 / (numParts - 1); + part->unk_34 = 360 - i * 38; + part->unk_14 = (f32) (i - 1) / (numParts - 1) * 0.5 + 0.5; + break; + } + + switch (arg0) { + case 2: + case 3: + index = 1; + break; + case 4: + case 5: + index = 2; + break; + case 6: + case 7: + index = (i & 1) + 1; + break; + default: + index = 0; + break; + } + + part->unk_44 = D_E008CB14[index]; + part->unk_45 = D_E008CB18[index]; + part->unk_46 = D_E008CB1C[index]; + } + + return effect; +} + +void fx_46_init(EffectInstance* effect) { } void fx_46_update(EffectInstance* effect) { @@ -34,7 +149,7 @@ void fx_46_update(EffectInstance* effect) { } part->unk_14 = (part->unk_18 * unk_24) / part->unk_20; if (unk_24 < 10) { - part->unk_1C = unk_24 * 0x19; + part->unk_1C = unk_24 * 25; } } else { if (unk_24 >= 6) { @@ -46,9 +161,9 @@ void fx_46_update(EffectInstance* effect) { } } - part->unk_08 = part->unk_04[10]; - part->unk_0C = part->unk_04[11]; - part->unk_10 = part->unk_04[12]; + part->unk_08 = part->unk_04->position.x; + part->unk_0C = part->unk_04->position.y; + part->unk_10 = part->unk_04->position.z; part++; for (i = 1; i < effect->numParts; i++, part++) { @@ -107,17 +222,17 @@ void fx_46_appendGfx(void* effect) { part++; for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) { - f32 (*matrix)[4] = sp60; // required to match - shim_guPositionF(sp20, part->unk_2C, 0.0f, part->unk_34, unk_14 * part->unk_14, part->unk_08, part->unk_0C, part->unk_10); - shim_guRotateF(matrix, part->unk_30, 0.0f, 1.0f, 0.0f); - shim_guMtxCatF(matrix, sp20, sp20); + shim_guRotateF(sp60, part->unk_30, 0.0f, 1.0f, 0.0f); + shim_guMtxCatF(sp60, sp20, sp20); + if (unk_00 < 8) { - shim_guTranslateF(matrix, 3.0f - (unk_14 - unk_18) * 3.0f / unk_18, 0.0f, 0.0f); + shim_guTranslateF(sp60, 3.0f - (unk_14 - unk_18) * 3.0f / unk_18, 0.0f, 0.0f); + shim_guMtxCatF(sp60, sp20, sp20); } else { - shim_guTranslateF(matrix, 2.0f, 0.0f, 0.0f); + shim_guTranslateF(sp60, 2.0f, 0.0f, 0.0f); + shim_guMtxCatF(sp60, sp20, sp20); } - shim_guMtxCatF(matrix, sp20, sp20); gDPSetPrimColor(gMasterGfxPos++, 0, 0, part->unk_44, part->unk_45, part->unk_46, unk_1C); diff --git a/src/effects/embers.c b/src/effects/embers.c index 7d56e975d6..e289945dd6 100644 --- a/src/effects/embers.c +++ b/src/effects/embers.c @@ -1,13 +1,95 @@ #include "common.h" #include "effects_internal.h" -extern f32 D_E00E0A48[]; +extern Gfx D_09000280_3DC1C0[]; +extern Gfx D_090003B0_3DC2F0[]; +Gfx* D_E00E0A40[] = { D_090003B0_3DC2F0, D_09000280_3DC1C0 }; + +f32 D_E00E0A48[] = { + 0.01f, 0.05f, 0.1f, 0.2f, 0.35f, 0.5f, + 0.65f, 0.8f, 0.95f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 0.95f, 0.8f, 0.65f, + 0.5f, 0.35f, 0.2f, 0.1f, 0.05f, 0.01f +}; + +void embers_init(EffectInstance* effect); +void embers_update(EffectInstance* effect); +void embers_render(EffectInstance* effect); void embers_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/embers", embers_main); +EffectInstance* embers_main( + s32 arg0, + f32 arg1, + f32 arg2, + f32 arg3, + f32 arg4, + f32 arg5, + f32 arg6, + s32 arg7, + s32 arg8, + f32 arg9, + f32 argA +) { + EffectBlueprint bp; + EffectInstance* effect; + EmbersFXData* part; + s32 numParts; + f32 temp1; + s32 i; -void embers_init(void) { + arg7++; + + bp.init = embers_init; + bp.update = embers_update; + bp.renderWorld = embers_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_EMBERS; + + effect = shim_create_effect_instance(&bp); + effect->numParts = arg7; + part = effect->data.embers = shim_general_heap_malloc(arg7 * sizeof(*part)); + ASSERT(effect->data.embers != NULL); + + part->unk_00 = arg0; + part->unk_1C = 0; + if (arg8 <= 0) { + part->unk_18 = 1000; + } else { + part->unk_18 = arg8; + } + part->unk_2C = 0; + part->unk_04 = arg1; + part->unk_08 = arg2; + part->unk_0C = arg3; + part->unk_40 = arg6; + part->unk_10 = arg4; + part->unk_14 = arg5; + part->unk_68 = arg9; + part->unk_6C = argA; + part->unk_20 = 127; + part->unk_24 = 0; + part->unk_28 = 0; + part->unk_30 = 127; + part->unk_34 = 127; + part->unk_38 = 0; + part->unk_3C = 255; + + temp1 = 30.0f / (arg7 - 1); + temp1 *= 0.5; + + part++; + for (i = 1; i < arg7; i++, part++) { + s32 temp_f0 = -(f32) i * temp1; + part->unk_64 = temp_f0 - 1; + } + + return effect; +} + +void embers_init(EffectInstance* effect) { } void embers_update(EffectInstance* effect) { @@ -103,4 +185,41 @@ void embers_render(EffectInstance* effect) { void func_E00E05F8(void) { } -INCLUDE_ASM(s32, "effects/embers", embers_appendGfx); +void embers_appendGfx(void* effect) { + EmbersFXData* part = ((EffectInstance*)effect)->data.embers; + Camera* camera = &gCameras[gCurrentCameraID]; + s32 unk_2C = part->unk_2C; + Matrix4f sp10; + Matrix4f sp50; + s32 i; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + shim_guTranslateF(sp10, part->unk_04, part->unk_08, part->unk_0C); + shim_guScaleF(sp50, part->unk_40, part->unk_40, part->unk_40); + shim_guMtxCatF(sp50, sp10, sp10); + shim_guMtxF2L(sp10, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gMasterGfxPos++, camera->unkMatrix, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, part->unk_20, part->unk_24, part->unk_28, unk_2C); + gDPSetEnvColor(gMasterGfxPos++, part->unk_30, part->unk_34, part->unk_38, part->unk_3C); + gSPDisplayList(gMasterGfxPos++, D_E00E0A40[1]); + + part++; + for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) { + if (part->unk_64 >= 0) { + shim_guTranslateF(sp10, part->unk_04, part->unk_08, part->unk_0C); + shim_guMtxF2L(sp10, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE, 0, (i % 4) * 16 * 4, 15 * 4, ((i % 4) * 16 + 15) * 4); + gDPSetTileSize(gMasterGfxPos++, 1, (s32) part->unk_5C * 4, (s32) part->unk_60 * 4, ((s32) part->unk_5C + 15) * 4, ((s32) part->unk_60 + 15) * 4); + gSPDisplayList(gMasterGfxPos++, D_E00E0A40[0]); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + } + + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); +} diff --git a/src/effects/emote.c b/src/effects/emote.c index 8506597c4a..7f3a8c3b04 100644 --- a/src/effects/emote.c +++ b/src/effects/emote.c @@ -40,8 +40,14 @@ s8 D_E0020D30[80] = { s8* D_E0020D80[5] = { D_E0020CB8, D_E0020CE0, D_E0020CFC, D_E0020D24, D_E0020D30 }; -s8 D_E0020D94[] = { - 64, 0, 0, 32, 0, 32, 0, 0, 64, 0, 32, 32, 0, 64, 0, 32, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +u8 D_E0020D94[] = { + 64, 0, 0, + 32, 0, 32, + 0, 0, 64, + 0, 32, 32, + 0, 64, 0, + 32, 32, 0, + 0, 0, 0 }; void emote_init(EffectInstance* effect); @@ -195,50 +201,44 @@ void emote_render(EffectInstance* effect) { retTask->renderMode |= RENDER_TASK_FLAG_2; } -// lots of issues -#ifdef NON_EQUIVALENT void emote_appendGfx(void* effect) { + EmoteFXData* part = ((EffectInstance*)effect)->data.emote; + s32 type = part->unk_00; + s32 unk_38; + Gfx* dlist; + Gfx* dlist2; + Mtx* matrix; + s32 w; + s32 h; + s32 uls; + s32 ult; + s32 idx; Matrix4f sp18; Matrix4f sp58; - EffectInstance* effectTemp = effect; - EmoteFXData* part = effectTemp->data; - s32 idx; - s32 type; - Gfx* temp_a3; - Gfx* temp_t0; - Mtx* blah; + s32 i; - s32 sp9C; - s32 spA0; - s32 temp_a0_3; - s32 phi_t1; - s32 phi_s7; - s32 phi_fp; - - type = part->unk_00; gDPPipeSync(gMasterGfxPos++); - gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effectTemp->graphics->data)); - //phi_s7 = saved_reg_s7; - //phi_fp = saved_reg_fp; + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); if (type != 1) { shim_guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C); shim_guRotateF(sp58, -gCameras[gCurrentCameraID].currentYaw, 0.0f, 1.0f, 0.0f); shim_guMtxCatF(sp58, sp18, sp18); + + matrix = &gDisplayContext->matrixStack[gMatrixListPos]; + shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos++]); shim_guScaleF(sp58, 1.0f, 0.8f, 1.0f); shim_guMtxCatF(sp58, sp18, sp18); shim_guRotateF(sp58, part->unk_24, 0.0f, 0.0f, 1.0f); shim_guMtxCatF(sp58, sp18, sp18); shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gMasterGfxPos++, D_09002170_336DE0) + gSPDisplayList(gMasterGfxPos++, D_09002170_336DE0); gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); - gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } else { if (part->unk_38 == 0) { - s32 i; - for (i = 0; i < 3; i++, part++) { shim_guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C); shim_guRotateF(sp58, -gCameras[gCurrentCameraID].currentYaw, 0.0f, 1.0f, 0.0f); @@ -248,65 +248,63 @@ void emote_appendGfx(void* effect) { shim_guScaleF(sp58, part->unk_28, part->unk_28, 1.0f); shim_guMtxCatF(sp58, sp18, sp18); shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 235, 28, 0, 255); gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gMasterGfxPos++, D_09002578_3371E8); gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); } } + + return; } - temp_a0_3 = part->unk_38; - temp_a3 = D_E0020CA4[type]; - temp_t0 = D_E0020C90[type]; + gSPMatrix(gMasterGfxPos++, matrix, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + unk_38 = part->unk_38; + dlist = D_E0020CA4[type]; + dlist2 = D_E0020C90[type]; switch (type) { - case 2: - sp9C = 0x20; - phi_t1 = 0x30; - phi_s7 = 0x80 - (temp_a0_3 << 5); - spA0 = phi_t1; + case 0: + w = 16; + h = 16; + uls = 128 - unk_38 * 16; + ult = 0; + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 220, 0, 0, 255); + break; + case 2: + w = 32; + h = 48; + uls = 128 - unk_38 * 32; + ult = 0; gDPSetPrimColor(gMasterGfxPos++, 0, 0, 220, 0, 0, 255); - phi_fp = 0; break; case 3: - sp9C = 0x20; - spA0 = 0x20; - idx = (part->unk_2C * 3) % 7; + w = 32; + h = 32; + uls = 128 - unk_38 * 32; + ult = 0; + idx = (part->unk_2C * 3) % (ARRAY_COUNT(D_E0020D94) / 3); gDPSetPrimColor(gMasterGfxPos++, 0, 0, D_E0020D94[idx], D_E0020D94[idx + 1], D_E0020D94[idx + 2], 255); - phi_s7 = 0x80 - (temp_a0_3 << 5); - phi_fp = 0; break; case 4: - sp9C = 0x20; - spA0 = 8; - phi_s7 = 0x80 - (temp_a0_3 << 5); - phi_fp = 0; - break; - default: - phi_t1 = 0x10; - if (type == 0) { - sp9C = 0x10; - phi_s7 = 0x80 - (temp_a0_3 * 0x10); - spA0 = phi_t1; - gDPSetPrimColor(gMasterGfxPos++, 0, 0, 220, 0, 0, 255); - phi_fp = 0; - } + w = 32; + h = 8; + uls = 128 - unk_38 * 32; + ult = 0; break; } - if (temp_a3 != NULL) { - gSPDisplayList(gMasterGfxPos++, temp_a3); + if (dlist != NULL) { + gSPDisplayList(gMasterGfxPos++, dlist); } - gDPSetTileSize(gMasterGfxPos++, 2, phi_s7, 0, phi_s7 + sp9C, spA0); + gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE, uls * 4, ult * 4, (uls + w) * 4, (ult + h) * 4); - if (temp_t0 != NULL) { - gSPDisplayList(gMasterGfxPos++, temp_t0); + if (dlist2 != NULL) { + gSPDisplayList(gMasterGfxPos++, dlist2); } gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); } -#else -INCLUDE_ASM(s32, "effects/emote", emote_appendGfx); -#endif diff --git a/src/effects/energy_in_out.c b/src/effects/energy_in_out.c index 7f63c06a42..9f0ef8f2f8 100644 --- a/src/effects/energy_in_out.c +++ b/src/effects/energy_in_out.c @@ -27,11 +27,143 @@ u8 D_E00D6E84[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +void energy_in_out_init(EffectInstance* effect); +void energy_in_out_update(EffectInstance* effect); +void energy_in_out_render(EffectInstance* effect); void energy_in_out_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/energy_in_out", energy_in_out_main); +EffectInstance* energy_in_out_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) { + EffectBlueprint bp; + EffectInstance* effect; + EnergyInOutFXData* part; + EnergyInOutFXData* firstPart; + s32 numParts = D_E00D6E74[arg0]; + f32 randAngle; + s32 i; -void energy_in_out_init(void) { + bp.init = energy_in_out_init; + bp.update = energy_in_out_update; + bp.renderWorld = energy_in_out_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_ENERGY_IN_OUT; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + firstPart = part = effect->data.energyInOut = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.energyInOut != NULL); + + part->unk_00 = arg0; + part->unk_14 = 0; + if (arg5 <= 0) { + part->unk_10 = 1000; + } else { + part->unk_10 = arg5; + } + part->unk_24 = 0; + part->pos.x = arg1; + part->pos.y = arg2; + part->pos.z = arg3; + part->scale = arg4; + part->unk_18 = 255; + part->unk_1C = 255; + part->unk_20 = 255; + part->unk_28 = 255; + part->unk_2C = 245; + part->unk_30 = 0; + part->unk_44 = 1.0f; + part->unk_38 = D_E00D6E84[arg0]; + + randAngle = shim_rand_int(360); + + part++; + for (i = 1; i < effect->numParts; i++, part++) { + part->unk_00 = arg0 % 3; + + switch (arg0) { + case 0: + case 1: + case 2: + part->unk_38 = -(shim_rand_int(10) * 0.2 + 0.2); + part->unk_10 = 20; + part->unk_40 = 0; + part->scale = 1.0 - (i % 3) * 0.1; + break; + case 3: + case 5: + part->unk_38 = shim_rand_int(10) * 0.2 + 0.2; + part->unk_10 = 20; + part->unk_40 = 0; + part->scale = 1.0 - (i % 3) * 0.1; + break; + case 6: + part->unk_38 = -(shim_rand_int(10) + 4); + part->unk_10 = 10; + part->unk_40 = 0; + part->scale = 1.0 - (i % 3) * 0.3; + break; + case 7: + part->unk_38 = -(shim_rand_int(10) + 4); + part->unk_10 = 10; + part->unk_40 = 0; + part->scale = 1.0 - (i % 3) * 0.3; + break; + case 8: + part->unk_38 = shim_rand_int(10) * 0.2 + 0.6; + part->unk_10 = 20; + part->unk_40 = -1.0f; + part->scale = 1.0 - (i % 3) * 0.3; + break; + case 9: + part->unk_38 = -(shim_rand_int(10) * 0.2 + 0.6); + part->unk_10 = 20; + part->unk_40 = -2.0f; + part->scale = 1.0 - (i % 3) * 0.3; + firstPart->unk_18 = 255; + firstPart->unk_1C = 245; + firstPart->unk_20 = 215; + firstPart->unk_28 = 220; + firstPart->unk_2C = 60; + firstPart->unk_30 = 10; + break; + case 10: + part->unk_38 = shim_rand_int(10) * 0.1 + 2.0; + part->unk_10 = 10; + part->unk_40 = 0; + part->scale = (1.0 - (i % 3) * 0.3) * 0.5; + break; + case 11: + part->unk_38 = shim_rand_int(10) * 0.05 + 0.2; + part->unk_40 = -1.0f; + part->unk_10 = 30; + part->scale = 1.0 - (i % 3) * 0.3; + break; + case 4: + case 12: + part->unk_38 = shim_rand_int(10) * 0.2 + 0.6; + part->unk_10 = 20; + part->unk_40 = -2.0f; + part->scale = 1.0 - (i % 3) * 0.3; + break; + } + + part->unk_14 = -shim_rand_int(part->unk_10); + + if (part->unk_38 < 0.0f) { + part->pos.x = (part->unk_10 - part->unk_14) * (-part->unk_38); + } else { + part->pos.x = (-part->unk_14) * part->unk_38; + } + part->pos.y = 0; + part->pos.z = 0; + + part->unk_3C = (i - 1) * 360 / (numParts - 1) + randAngle; + } + + return effect; +} + +void energy_in_out_init(EffectInstance* effect) { } void energy_in_out_update(EffectInstance* effect) { diff --git a/src/effects/explosion.c b/src/effects/explosion.c index 5e80299d35..826ea9e7b7 100644 --- a/src/effects/explosion.c +++ b/src/effects/explosion.c @@ -14,10 +14,62 @@ void explosion_appendGfx(void* effect); INCLUDE_ASM(s32, "effects/explosion", explosion_main); -void explosion_init(void) { +void explosion_init(EffectInstance* effect) { } -INCLUDE_ASM(s32, "effects/explosion", explosion_update); +void explosion_update(EffectInstance* effect) { + ExplosionFXData* part = effect->data.explosion; + s32 unk_00; + s32 unk_34; + + part->unk_30--; + if (part->unk_30 < 0) { + shim_remove_effect(effect); + return; + } + + part->unk_34++; + + unk_00 = part->unk_00; + unk_34 = part->unk_34; + + if (unk_34 == 7) { + shim_load_effect(EFFECT_SMOKE_RING); + smoke_ring_main(unk_00, part->unk_04, part->unk_08, part->unk_0C); + } else if (unk_34 == 1) { + shim_load_effect(EFFECT_CONFETTI); + confetti_main(unk_00 + 4, part->unk_04, part->unk_08, part->unk_0C, 1.0f, 50); + } + + part++; + + part->unk_20 += part->unk_24; + + if (unk_34 < 8) { + part->unk_24 += (unk_00 == 2) ? 1.0f : 0.4; + part->unk_38 = (255 - part->unk_38) * 0.6; + } else { + part->unk_24 *= 0.6; + part->unk_38 *= 0.9; + } + + part++; + + if (unk_34 >= 3) { + if (unk_34 == 3) { + part->unk_20 = 1.0f; + } + part->unk_20 += part->unk_24; + if (unk_34 < 6) { + part->unk_24 += 0.1; + } else { + part->unk_24 *= 0.5; + part->unk_38 *= 0.9; + } + } + + part->unk_28 += part->unk_2C; +} void explosion_render(EffectInstance* effect) { RenderTask renderTask; diff --git a/src/effects/firework.c b/src/effects/firework.c index 5a83e3c90f..dd1900c28e 100644 --- a/src/effects/firework.c +++ b/src/effects/firework.c @@ -1,15 +1,129 @@ #include "common.h" #include "effects_internal.h" -extern u8 D_E0086AC0[]; -extern u8 D_E0086AC4[]; -extern u8 D_E0086AD4[]; +extern Gfx D_09000940_38AC90[]; +extern Gfx D_09000A00_38AD50[]; +extern Gfx D_09000A20_38AD70[]; +extern Gfx D_09000A40_38AD90[]; +extern Gfx D_09000A60_38ADB0[]; +extern Gfx D_09000A80_38ADD0[]; -void func_E00863B4(void); +Gfx* D_E0086AA0[] = { + D_09000A00_38AD50, D_09000A20_38AD70, D_09000A40_38AD90, + D_09000A60_38ADB0, D_09000A80_38ADD0 +}; -INCLUDE_ASM(s32, "effects/firework", firework_main); +Gfx* D_E0086AB4[] = { D_09000940_38AC90, D_09000940_38AC90, D_09000940_38AC90 }; -void firework_init(void) { +u8 D_E0086AC0[] = { 0x0D, 0x0D, 0x0D, 0x00 }; + +u8 D_E0086AC4[] = { + 0x40, 0x68, 0x90, 0xA4, 0xB8, 0xC0, 0xD0, 0xD8, + 0xE0, 0xE8, 0xF0, 0xF8, 0xFF, 0x00, 0x00, 0x00 +}; + +u8 D_E0086AD4[] = { + 0x0A, 0x14, 0x1C, 0x23, 0x2A, 0x30, 0x35, 0x39, + 0x3C, 0x3E, 0x3F, 0x40, 0x41, 0x00, 0x00, 0x00 +}; + +u8 D_E0086AE4[] = { + 0xFF, 0xFF, 0xC8, 0x82, 0x3C, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + +void firework_init(EffectInstance* effect); +void firework_update(EffectInstance* effect); +void firework_render(EffectInstance* effect); +void func_E0086398(EffectInstance* effect); +void func_E00863B4(EffectInstance* effect); + +EffectInstance* firework_main( + s32 arg0, + f32 arg1, + f32 arg2, + f32 arg3, + f32 arg4, + s32 arg5 +) { + EffectBlueprint bp; + EffectInstance* effect; + FireworkFXData* part; + s32 numParts = (arg5 * 5 + 20) / 3 + 1; + s32 i; + + bp.unk_00 = 0; + bp.init = firework_init; + bp.update = firework_update; + bp.renderWorld = firework_render; + bp.unk_14 = func_E0086398; + bp.effectID = EFFECT_FIREWORK; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + part = effect->data.firework = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.firework != NULL); + + part->unk_00 = arg0; + part->unk_04 = arg1; + part->unk_08 = arg2; + part->unk_0C = arg3; + part->unk_30 = D_E0086AC0[arg0]; + part->unk_34 = 0; + part->unk_38 = 0; + switch (arg0) { + case 0: + part->unk_3C = 255; + part->unk_3D = 255; + part->unk_3E = 255; + part->unk_3F = 255; + part->unk_40 = 255; + part->unk_41 = 255; + break; + case 1: + part->unk_3C = 255; + part->unk_3D = 255; + part->unk_3E = 0; + part->unk_3F = 255; + part->unk_40 = 0; + part->unk_41 = 0; + break; + case 2: + default: + part->unk_3C = 255; + part->unk_3D = 255; + part->unk_3E = 0; + part->unk_3F = 200; + part->unk_40 = 255; + part->unk_41 = 230; + break; + } + part->unk_28 = arg4; + + part++; + for (i = 1; i < numParts; i++, part++) { + f32 unk_1C = (i * 360) / (numParts - 1); + s32 unk_24 = shim_rand_int(359); + + part->unk_04 = 0; + part->unk_08 = 0; + part->unk_0C = 0; + part->unk_10 = 0; + part->unk_14 = 0; + part->unk_20 = 0; + part->unk_00 = 0; + part->unk_1C = unk_1C; + part->unk_24 = unk_24; + part->unk_10 = 0; + part->unk_2C = 255; + } + + return effect; +} + +void firework_init(EffectInstance* effect) { } void firework_update(EffectInstance* effect) { @@ -48,11 +162,132 @@ void firework_update(EffectInstance* effect) { } } -void firework_render(void) { +void firework_render(EffectInstance* effect) { } -void func_E0086398(void) { - func_E00863B4(); +void func_E0086398(EffectInstance* effect) { + func_E00863B4(effect); } -INCLUDE_ASM(s32, "effects/firework", func_E00863B4); +void func_E00863B4(EffectInstance* effect) { + FireworkFXData* part = effect->data.firework; + Gfx* savedGfxPos; + f32 temp_f32 = part->unk_38 * 5.0f; + s32 envA; + s32 temp_s32 = temp_f32; + s32 primR; + s32 primG; + s32 primB; + s32 envR; + s32 envG; + s32 engB; + s32 primA; + s32 unk_34 = part->unk_34; + s32 unk_00 = part->unk_00; + s32 var_v1; + Matrix4f sp20; + Matrix4f sp60; + s32 i; + + if (temp_s32 < 5) { + s32 cond; + f32 unk_28; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effect->graphics->data)); + + unk_28 = part->unk_28; + + shim_guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].currentYaw, 0.0f, unk_28, part->unk_04, part->unk_08, part->unk_0C); + shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + + envA = (temp_f32 - temp_s32) * 256.0f; + primA = part->unk_2C; + cond = (temp_s32 >= 4); + + switch (unk_00) { + case 1: + if (unk_34 - 1 < 13) { + var_v1 = D_E0086AE4[unk_34 - 1]; + } else { + var_v1 = 0; + } + primR = part->unk_3C; + primG = (part->unk_3D * var_v1) >> 8; + primB = (part->unk_3E * var_v1) >> 8; + envR = (part->unk_3F * var_v1) >> 8; + envG = (part->unk_40 * var_v1) >> 8; + engB = (part->unk_41 * var_v1) >> 8; + break; + case 2: + if (unk_34 % 2 == 0) { + primR = 0; + primG = 0; + primB = 0; + envR = part->unk_3C; + envG = part->unk_3D; + engB = part->unk_3E; + } else { + primR = part->unk_3C; + primG = part->unk_3D; + primB = part->unk_3E; + envR = part->unk_3F; + envG = part->unk_40; + engB = part->unk_41; + } + break; + case 0: + default: + primR = part->unk_3C; + primG = part->unk_3D; + primB = part->unk_3E; + envR = part->unk_3F; + envG = part->unk_40; + engB = part->unk_41; + break; + } + + savedGfxPos = gMasterGfxPos++; + gSPDisplayList(gMasterGfxPos++, D_E0086AB4[unk_00]); + + part++; + + if (cond) { + gDPSetTileSize(gMasterGfxPos++, 1, 0, 0, 0, 0); + } + + for (i = 1; i < effect->numParts; i++, part++) { + gSPDisplayList(gMasterGfxPos++, D_E0086AB4[part->unk_00]); + + shim_guRotateF(sp20, part->unk_1C, 0.0f, 0.0f, 1.0f); + shim_guRotateF(sp60, part->unk_24, 0.0f, 1.0f, 0.0f); + shim_guMtxCatF(sp60, sp20, sp20); + shim_guTranslateF(sp60, part->unk_04, part->unk_08, part->unk_0C); + shim_guMtxCatF(sp60, sp20, sp20); + shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, D_E0086AA0[temp_s32]); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + + gSPEndDisplayList(gMasterGfxPos++); + gSPBranchList(savedGfxPos, gMasterGfxPos); + + gDPSetPrimColor(gMasterGfxPos++, 0, 0, primR, primG, primB, primA); + gDPSetEnvColor(gMasterGfxPos++, envR, envG, engB, envA); + gSPDisplayList(gMasterGfxPos++, savedGfxPos + 1); + + shim_guRotateF(sp20, 120.0f, 1.0f, 1.0f, 1.0f); + shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, savedGfxPos + 1); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, savedGfxPos + 1); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + gDPPipeSync(gMasterGfxPos++); + } +} diff --git a/src/effects/flame.c b/src/effects/flame.c index ceaf09240a..e170b8202c 100644 --- a/src/effects/flame.c +++ b/src/effects/flame.c @@ -1,20 +1,113 @@ #include "common.h" #include "effects_internal.h" +#include "nu/nusys.h" +typedef struct UnkStruct { + /* 0x00 */ s8 unk_00; + /* 0x01 */ s8 unk_01; + /* 0x02 */ s8 unk_02; + /* 0x03 */ s8 unk_03; + /* 0x04 */ s8 unk_04; + /* 0x05 */ s8 unk_05; + /* 0x06 */ s8 unk_06; + /* 0x07 */ s8 unk_07; + /* 0x08 */ u8 unk_08; + /* 0x09 */ char unk_09[3]; // likely padding + /* 0x0C */ Gfx* unk_0C; +} UnkStruct; // size = 0x10 + +extern Gfx D_09000800[]; +extern Gfx D_090008F8[]; +extern Gfx D_09000918[]; +extern Gfx D_090009E0[]; + +UnkStruct D_E0040840[] = { + { 255, 109, 255, 92, 102, 191, 255, 75, 50, {}, D_09000800 }, + { 255, 255, 255, 0, 255, 32, 0, 75, 100, {}, D_09000800 }, + { 255, 0, 255, 92, 107, 168, 255, 75, 10, {}, D_09000800 }, + { 255, 255, 255, 244, 247, 175, 175, 22, 30, {}, D_09000800 } +}; + +s32 D_E0040880; + +void flame_init(EffectInstance* effect); +void flame_update(EffectInstance* effect); +void flame_render(EffectInstance* effect); void flame_appendGfx(void* effect); -u32 D_E0040840[2] = { 0xFF6DFF5C, 0x66BFFF4B }; +void flame_main( + s32 arg0, + f32 arg1, + f32 arg2, + f32 arg3, + f32 arg4, + EffectInstance** outEffect +) { + EffectBlueprint bp; + EffectBlueprint* bpPtr = &bp; + EffectInstance* effect; + FlameFXData* data; + s32 numParts = 1; -s8 D_E0040848[56] = { 0x32, 0x00, 0x00, 0x00, 0x09, 0x00, 0x08, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x20, 0x00, 0x4B, 0x64, 0x00, 0x00, 0x00, 0x09, 0x00, 0x08, 0x00, 0xFF, 0x00, 0xFF, 0x5C, 0x6B, 0xA8, 0xFF, 0x4B, 0x0A, 0x00, 0x00, 0x00, 0x09, 0x00, 0x08, 0x00, 0xFF, 0xFF, 0xFF, 0xF4, 0xF7, 0xAF, 0xAF, 0x16, 0x1E, 0x00, 0x00, 0x00, 0x09, 0x00, 0x08, 0x00 }; + if (arg0 >= 4) { + arg0 = 3; + } -s32 D_E0040880[4] = { 0, 0, 0, 0 }; + bpPtr->init = flame_init; + bpPtr->update = flame_update; + bpPtr->renderWorld = flame_render; + bpPtr->unk_00 = 0; + bpPtr->unk_14 = NULL; + bpPtr->effectID = EFFECT_FLAME; -INCLUDE_ASM(s32, "effects/flame", flame_main); + effect = shim_create_effect_instance(bpPtr); + effect->numParts = numParts; + data = effect->data.flame = shim_general_heap_malloc(numParts * sizeof(*data)); + ASSERT(effect->data.flame != NULL); -void flame_init(void) { + data->unk_00 = arg0; + data->unk_18 = 0; + data->pos.x = arg1; + data->pos.y = arg2; + data->pos.z = arg3; + data->unk_10 = arg4 * D_E0040840[arg0].unk_08 * 0.01; + data->unk_1C = 0; + data->unk_24 = 0; + data->unk_20 = 0; + data->unk_30 = 1.0f; + data->unk_2C = 1.0f; + data->unk_28 = 1.0f; + + if (outEffect != NULL) { + *outEffect = effect; + } } -INCLUDE_ASM(s32, "effects/flame", flame_update); +void flame_init(EffectInstance* effect) { +} + +void flame_update(EffectInstance* effect) { + FlameFXData* part = effect->data.flame; + s32 i; + + for (i = 0; i < effect->numParts; i++, part++) { + part->unk_1C += part->unk_20; + if (part->unk_1C > 64.0f) { + part->unk_1C -= 64.0f; + } + if (part->unk_1C < 0.0f) { + part->unk_1C += 64.0f; + } + + part->unk_24 += part->unk_28; + if (part->unk_24 > 128.0f) { + part->unk_24 -= 128.0f; + } + if (part->unk_24 < 0.0f) { + part->unk_24 += 128.0f; + } + } +} void flame_render(EffectInstance* effect) { FlameFXData* data = effect->data.flame; @@ -48,4 +141,50 @@ void flame_render(EffectInstance* effect) { shim_queue_render_task(renderTaskPtr); } -INCLUDE_ASM(s32, "effects/flame", flame_appendGfx); +void flame_appendGfx(void* effect) { + FlameFXData* data = ((EffectInstance*)effect)->data.flame; + Camera* camera = &gCameras[gCurrentCameraID]; + s32 unk_00 = data->unk_00; + s32 uls = data->unk_1C * 4.0f; + s32 ult = data->unk_24 * 4.0f; + UnkStruct* unkStruct; + Matrix4f sp18; + Matrix4f sp58; + Matrix4f sp98; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + if (D_E0040880 != gGameStatusPtr->frameCounter) { + D_E0040880 = gGameStatusPtr->frameCounter; + gSPDisplayList(gMasterGfxPos++, D_09000918); + gDPSetTileSize(gMasterGfxPos++, 1, uls, ult, uls + 128, ult + 256); + gSPDisplayList(gMasterGfxPos++, D_090009E0); + gDPSetColorImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, VIRTUAL_TO_PHYSICAL(nuGfxCfb_ptr)); + gDPSetScissorFrac(gMasterGfxPos++, G_SC_NON_INTERLACE, + camera->viewportStartX * 4.0f, + camera->viewportStartY * 4.0f, + (camera->viewportStartX + camera->viewportW) * 4.0f, + (camera->viewportStartY + camera->viewportH) * 4.0f); + } + + unkStruct = &D_E0040840[unk_00]; + + gSPDisplayList(gMasterGfxPos++, unkStruct->unk_0C); + gDPSetKeyR(gMasterGfxPos++, unkStruct->unk_03, unkStruct->unk_00, 0); + gDPSetKeyGB(gMasterGfxPos++, unkStruct->unk_03, unkStruct->unk_01, 0, unkStruct->unk_03, unkStruct->unk_02, 0); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, unkStruct->unk_07, unkStruct->unk_07, unkStruct->unk_07, 0); + gDPSetEnvColor(gMasterGfxPos++, unkStruct->unk_04, unkStruct->unk_05, unkStruct->unk_06, 0); + + shim_guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z); + shim_guRotateF(sp58, -gCameras[gCurrentCameraID].currentYaw, 0.0f, 1.0f, 0.0f); + shim_guMtxCatF(sp58, sp18, sp98); + shim_guScaleF(sp58, data->unk_10 * data->unk_30, data->unk_10 * data->unk_2C, data->unk_10); + shim_guMtxCatF(sp58, sp98, sp98); + shim_guMtxF2L(sp98, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, D_090008F8); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + gDPPipeSync(gMasterGfxPos++); +} diff --git a/src/effects/gfx/merlin_house_stars.c b/src/effects/gfx/merlin_house_stars.c new file mode 100644 index 0000000000..6d22d3590f --- /dev/null +++ b/src/effects/gfx/merlin_house_stars.c @@ -0,0 +1,13 @@ +#include "effects/gfx/D_09000000_3A5BE0.png.inc.c" +#include "effects/gfx/D_09000800_3A63E0.png.inc.c" + +#include "effects/gfx/D_09001000_3A6BE0.gfx.inc.c" + +#include "effects/gfx/D_090010F8_3A6CD8.vtx.inc.c" +#include "effects/gfx/D_09001288_3A6E68.vtx.inc.c" +#include "effects/gfx/D_090012A8_3A6E88.vtx.inc.c" +#include "effects/gfx/D_090012B8_3A6E98.vtx.inc.c" +#include "effects/gfx/D_090012D8_3A6EB8.vtx.inc.c" +#include "effects/gfx/D_090012E8_3A6EC8.vtx.inc.c" + +#include "effects/gfx/D_09001418_3A6FF8.gfx.inc.c" diff --git a/src/effects/merlin_house_stars.c b/src/effects/merlin_house_stars.c index cfe65b4799..94b876007e 100644 --- a/src/effects/merlin_house_stars.c +++ b/src/effects/merlin_house_stars.c @@ -1,14 +1,114 @@ #include "common.h" #include "effects_internal.h" +extern Gfx D_09001000_3A6BE0[]; +extern Gfx D_09001418_3A6FF8[]; + +void merlin_house_stars_init(EffectInstance* effect); +void merlin_house_stars_update(EffectInstance* effect); +void merlin_house_stars_render(EffectInstance* effect); void merlin_house_stars_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/merlin_house_stars", merlin_house_stars_main); +EffectInstance* merlin_house_stars_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3) { + EffectBlueprint bp; + EffectInstance* effect; + MerlinHouseStarsFXData* data; + s32 numParts = 1; -void merlin_house_stars_init(void) { + bp.init = merlin_house_stars_init; + bp.update = merlin_house_stars_update; + bp.renderWorld = merlin_house_stars_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_MERLIN_HOUSE_STARS; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + data = effect->data.merlinHouseStars = shim_general_heap_malloc(numParts * sizeof(*data)); + ASSERT(effect->data.merlinHouseStars != NULL); + + data->unk_04 = 100; + data->unk_00 = arg0; + data->unk_18 = 255; + data->unk_0C = arg1; + data->unk_10 = arg2; + data->unk_14 = arg3; + data->unk_08 = 0; + data->unk_1C = data->unk_20 = 0.0f; + data->unk_24 = data->unk_28 = 0.0f; + data->unk_2C = 1.2f; + data->unk_30 = 0.4f; + data->unk_34 = -1.0f; + data->unk_38 = 0.4f; + + return effect; } -INCLUDE_ASM(s32, "effects/merlin_house_stars", merlin_house_stars_update); +void merlin_house_stars_init(EffectInstance* effect) { +} + +void merlin_house_stars_update(EffectInstance* effect) { + MerlinHouseStarsFXData* data = effect->data.merlinHouseStars; + s32 unk_04; + + if (effect->flags & 0x10) { + effect->flags &= ~0x10; + data->unk_04 = 30; + } + + if (data->unk_04 < 100) { + data->unk_04--; + } + + data->unk_08++; + + if (data->unk_04 < 0) { + shim_remove_effect(effect); + return; + } + + data->unk_1C += data->unk_2C; + data->unk_20 += data->unk_30; + data->unk_24 += data->unk_34; + data->unk_28 += data->unk_38; + + unk_04 = data->unk_04; + + if (data->unk_08 < 17) { + data->unk_18 = data->unk_08 * 16 - 1; + } + + if (unk_04 < 16) { + data->unk_18 = unk_04 * 16; + } + + if (data->unk_1C < 0.0f) { + data->unk_1C += 128.0f; + } else if (data->unk_1C > 128.0f) { + data->unk_1C -= 128.0f; + } + + data->unk_20 += data->unk_30; + if (data->unk_20 < 0.0f) { + data->unk_20 += 128.0f; + } else if (data->unk_20 > 128.0f) { + data->unk_20 -= 128.0f; + } + + data->unk_24 += data->unk_34; + if (data->unk_24 < 0.0f) { + data->unk_24 += 128.0f; + } else if (data->unk_24 > 128.0f) { + data->unk_24 -= 128.0f; + } + + data->unk_28 += data->unk_38; + if (data->unk_28 < 0.0f) { + data->unk_28 += 128.0f; + } else if (data->unk_28 > 128.0f) { + data->unk_28 -= 128.0f; + } +} void merlin_house_stars_render(EffectInstance* effect) { RenderTask renderTask; @@ -26,4 +126,37 @@ void merlin_house_stars_render(EffectInstance* effect) { void func_E00A639C(void) { } -INCLUDE_ASM(s32, "effects/merlin_house_stars", merlin_house_stars_appendGfx); +void merlin_house_stars_appendGfx(void* effect) { + MerlinHouseStarsFXData* data = ((EffectInstance*)effect)->data.merlinHouseStars; + s32 unk_18 = data->unk_18; + Matrix4f sp10; + Matrix4f sp50; + s32 uls; + s32 ult; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + shim_guTranslateF(sp10, data->unk_0C, data->unk_10, data->unk_14); + shim_guScaleF(sp50, 0.96f, 0.96f, 0.96f); + shim_guMtxCatF(sp50, sp10, sp10); + shim_guMtxF2L(sp10, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 0, 0, 0, 127); + gDPSetEnvColor(gMasterGfxPos++, 0, 0, 0, unk_18); + gDPSetCombineLERP(gMasterGfxPos++, 0, 0, 0, 1, TEXEL1, 0, PRIMITIVE, TEXEL0, 0, 0, 0, COMBINED, COMBINED, 0, ENVIRONMENT, 0); + gSPDisplayList(gMasterGfxPos++, D_09001000_3A6BE0); + + uls = data->unk_1C * 4.0f; + ult = data->unk_20 * 4.0f; + gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE, uls, ult, uls + 252, ult + 252); + + uls = data->unk_24 * 4.0f; + ult = data->unk_28 * 4.0f; + gDPSetTileSize(gMasterGfxPos++, 1, uls, ult, uls + 252, ult + 252); + + gSPDisplayList(gMasterGfxPos++, D_09001418_3A6FF8); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + gDPPipeSync(gMasterGfxPos++); +} diff --git a/src/effects/motion_blur_flame.c b/src/effects/motion_blur_flame.c index b210845de3..003abdde40 100644 --- a/src/effects/motion_blur_flame.c +++ b/src/effects/motion_blur_flame.c @@ -7,11 +7,55 @@ s32 D_E00A29DC[] = { 0x00000010, 0x00000010, 0x3F800000, 0x3F800000, 0x00000008, s32 D_E00A2A24[] = { 0x00000064, 0x0000003C, 0x0000001E, 0x0000000A, 0x00000000, 0x00000000, 0x00000000 }; +void motion_blur_flame_init(EffectInstance* effect); +void motion_blur_flame_update(EffectInstance* effect); +void motion_blur_flame_render(EffectInstance* effect); void motion_blur_flame_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/motion_blur_flame", motion_blur_flame_main); +EffectInstance* motion_blur_flame_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) { + EffectBlueprint bp; + EffectInstance* effect; + MotionBlurFlameFXData* data; + s32 numParts = 1; + s32 i; -void motion_blur_flame_init(void) { + bp.init = motion_blur_flame_init; + bp.update = motion_blur_flame_update; + bp.renderWorld = motion_blur_flame_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_MOTION_BLUR_FLAME; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + data = effect->data.motionBlurFlame = shim_general_heap_malloc(numParts * sizeof(*data)); + ASSERT(effect->data.motionBlurFlame != NULL); + + data->unk_00 = arg0; + if (arg5 < 0) { + data->unk_50 = 1000; + } else { + data->unk_50 = arg5; + } + data->unk_4C = 127; + data->unk_54 = 0; + data->unk_04 = arg1; + data->unk_08 = arg2; + data->unk_0C = arg3; + data->position.x = 0; + data->position.y = 0; + data->position.z = 0; + data->unk_5C = 255; + data->unk_60 = 255; + data->unk_64 = 255; + data->unk_3C[1] = 0; + data->unk_3C[2] = 0; + data->unk_3C[3] = 0; + + return effect; +} + +void motion_blur_flame_init(EffectInstance* effect) { } INCLUDE_ASM(s32, "effects/motion_blur_flame", motion_blur_flame_update); diff --git a/src/effects/pink_sparkles.c b/src/effects/pink_sparkles.c index d3e550f3c4..cfc2a79ab0 100644 --- a/src/effects/pink_sparkles.c +++ b/src/effects/pink_sparkles.c @@ -1,14 +1,218 @@ #include "common.h" #include "effects_internal.h" +extern Gfx D_09000F20_338EE0[]; +extern Gfx D_090011C8_339188[]; +extern Gfx D_090011E0_3391A0[]; +extern Gfx D_090011F8_3391B8[]; +extern Gfx D_09001210_3391D0[]; +extern Gfx D_09001228_3391E8[]; +extern Gfx D_09001240_339200[]; +extern Gfx D_09001258_339218[]; +extern Gfx D_09001270_339230[]; + +Gfx* D_E01248A0[] = { + D_09001210_3391D0, D_09001228_3391E8, D_09001240_339200, + D_09001258_339218, D_09001270_339230, D_090011C8_339188, + D_090011E0_3391A0, D_090011F8_3391B8 +}; + +s8 D_E01248C0[] = { + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x40, 0x2E, 0x23, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x24, 0x25, 0x26, 0x2E, 0x2A, 0x3D, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2D, 0x2E, 0x2E, 0x2E, 0x3B, 0x3E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2C, 0x27, 0x2E, 0x2E, 0x2E, 0x2E, 0x29, 0x21, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x7E, 0x7E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x7B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x7E, 0x7E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x5D, 0x40, 0x40, 0x5E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x7E, 0x2F, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x28, 0x5F, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x23, 0x3A, 0x3C, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x5B, 0x7D, 0x7C, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x31, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x32, 0x33, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x34, 0x35, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x36, 0x37, 0x37, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x38, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x37, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x39, 0x30, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x37, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x61, 0x32, 0x32, 0x62, 0x2E, 0x2E, 0x2E, 0x63, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x64, 0x65, 0x65, 0x65, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x66, 0x2B, 0x2B, 0x2B, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x66, 0x66, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x66, 0x66, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x66, 0x66, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, + 0x2E, 0x66, 0x2B, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, + 0x66, 0x66, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x66, 0x2E, + 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x66, 0x66, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x2E, 0x66, 0x2B, 0x2E, 0x66, 0x2B, 0x2B, 0x2B, 0x66, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2B, 0x66, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x66, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x68, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2B, 0x67, 0x2E, 0x67, 0x67, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x68, 0x68, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x68, 0x68, 0x2E, 0x2E, 0x68, 0x68, 0x2E, 0x68, 0x68, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x68, 0x67, 0x2B, 0x67, 0x68, 0x67, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x68, 0x67, 0x68, 0x67, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x68, 0x67, 0x67, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2B, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x67, 0x2B, 0x2E, 0x68, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, + 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, + 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x68, 0x67, 0x67, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x67, 0x2E, + 0x2E, 0x2E, 0x67, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x68, 0x67, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x67, 0x68, 0x2E, 0x2E, 0x2E +}; + +u8 D_E0124BC0[] = { + 0xFE, 0xAC, 0xAC, + 0xFE, 0xAC, 0xD5, + 0xFE, 0xB4, 0x9A, + 0xD5, 0xB4, 0xFE, + 0xB4, 0xB4, 0xFE, + 0xB4, 0xDD, 0xFE, + 0xB4, 0xFE, 0xFE, + 0xB4, 0xFE, 0xD5, + 0xB4, 0xFE, 0xB4, + 0xD5, 0xFE, 0xB4, + 0xFE, 0xFE, 0xB4, + 0xFE, 0xD5, 0xAC +}; + +u8 D_E0124BE4[] = { + 0x1E, 0x3C, 0x5A, 0x64, 0x68, + 0x6A, 0x6C, 0x6E, 0x70, 0x71, + 0x71, 0x6E, 0x6B, 0x67, 0x64, + 0x68, 0x6A, 0x6C, 0x6E, 0x70, + 0x71, 0x71, 0x6E, 0x6B, 0x67 +}; + +void pink_sparkles_init(EffectInstance* effect); +void pink_sparkles_update(EffectInstance* effect); +void pink_sparkles_render(EffectInstance* effect); void pink_sparkles_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/pink_sparkles", pink_sparkles_main); +EffectInstance* pink_sparkles_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5) { + EffectBlueprint bp; + EffectInstance* effect; + PinkSparklesFXData* part; + s32 numParts = 101; + s32 count; + f32 angle; + s32 i; + s32 j; -void pink_sparkles_init(void) { + bp.init = pink_sparkles_init; + bp.update = pink_sparkles_update; + bp.renderWorld = pink_sparkles_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_PINK_SPARKLES; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + part = effect->data.pinkSparkles = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.pinkSparkles != NULL); + + part->unk_04 = arg1; + part->unk_08 = arg2; + part->unk_0C = arg3; + part->unk_20 = 0; + part->unk_00 = arg0; + part->unk_1C = 80; + + part++; + angle = arg5; + count = 1; + + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + if (D_E01248C0[j + (15 - i) * 16 + arg0 * 256] != 46) { + f32 temp_f20 = j * 2 - 16 + (shim_rand_int(20) - 10) * 0.1; + + part->unk_04 = temp_f20 * shim_cos_deg(angle); + part->unk_08 = i * 2 + (shim_rand_int(20) - 10) * 0.1; + part->unk_0C = temp_f20 * shim_sin_deg(angle); + part->unk_10 = part->unk_04 * 0.04; + part->unk_14 = part->unk_08 * 0.04; + part->unk_18 = shim_rand_int(10) * 0.001; + part->unk_1C = shim_rand_int(7) + 30; + part->unk_20 = 0; + + count++; + part++; + + if (count >= numParts) { + break; + } + } + } + + if (count >= numParts) { + break; + } + } + + for (; count < numParts; count++, part++) { + part->unk_04 = part->unk_08 = part->unk_0C = + part->unk_10 = part->unk_14 = part->unk_18 = + part->unk_24 = 0.0f; + part->unk_1C = -1; + part->unk_20 = 0; + }; + + return effect; } -INCLUDE_ASM(s32, "effects/pink_sparkles", pink_sparkles_update); +void pink_sparkles_init(EffectInstance* effect) { +} + +void pink_sparkles_update(EffectInstance* effect) { + PinkSparklesFXData* part = effect->data.pinkSparkles; + s32 unk_20; + s32 count = 0; + s32 i; + + part->unk_1C--; + part->unk_20++; + unk_20 = part->unk_20; + + part++; + for (i = 0; i < effect->numParts - 1; i++, part++) { + part->unk_28 = (unk_20 + i + i) & 7; + + if (part->unk_1C < 0) { + count += 1; + } + + part->unk_1C--; + if (part->unk_1C < 0 || part->unk_1C >= 31) { + part->unk_28 = -1; + } else { + part->unk_20++; + unk_20 = part->unk_20; + + if (unk_20 - 1 < 25) { + part->unk_24 = (f32) D_E0124BE4[unk_20 - 1] * 0.01 * 0.4; + } else { + part->unk_24 += (0.1 - part->unk_24) * 0.1; + } + + part->unk_04 += part->unk_10; + part->unk_08 += part->unk_14; + part->unk_14 += part->unk_18; + part->unk_0C += part->unk_10; + } + } + + if (count >= effect->numParts - 1) { + shim_remove_effect(effect); + } +} void pink_sparkles_render(EffectInstance* effect) { RenderTask renderTask; @@ -22,4 +226,66 @@ void pink_sparkles_render(EffectInstance* effect) { retTask = shim_queue_render_task(&renderTask); } -INCLUDE_ASM(s32, "effects/pink_sparkles", pink_sparkles_appendGfx); +void pink_sparkles_appendGfx(void* effect) { + PinkSparklesFXData* part = ((EffectInstance*)effect)->data.pinkSparkles; + s32 primR; + s32 primG; + s32 primB; + f32 factorR = 1.4f; + f32 factorG = 0.7f; + f32 factorB = 0.7f; + Matrix4f sp18; + Matrix4f sp58; + Matrix4f sp98; + s32 colorIdx; + s32 i; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + gSPDisplayList(gMasterGfxPos++, D_09000F20_338EE0); + + colorIdx = (part->unk_20 - 1) * 3; + + shim_guTranslateF(sp98, part->unk_04, part->unk_08, part->unk_0C); + shim_guRotateF(sp58, -gCameras[gCurrentCameraID].currentYaw, 0.0f, 1.0f, 0.0f); + shim_guMtxCatF(sp58, sp98, sp98); + + part++; + for (i = 0; i < ((EffectInstance*)effect)->numParts - 1; i++, part++) { + s32 unk_28 = part->unk_28; + + if (unk_28 >= 0) { + shim_guTranslateF(sp58, part->unk_04, part->unk_08, part->unk_0C); + + sp58[0][0] = sp58[1][1] = sp58[2][2] = part->unk_24; + + shim_guMtxCatF(sp58, sp98, sp18); + shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + + if (colorIdx >= ARRAY_COUNT(D_E0124BC0)) { + colorIdx = 0; + } + + primR = D_E0124BC0[colorIdx++] * factorR; + primG = D_E0124BC0[colorIdx++] * factorG; + primB = D_E0124BC0[colorIdx++] * factorB; + + if (primR > 255) { + primR = 255; + } + if (primG > 255) { + primG = 255; + } + if (primB > 255) { + primB = 255; + } + + gDPSetPrimColor(gMasterGfxPos++, 0, 0, primR, primG, primB, 255); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, D_E01248A0[unk_28 & 7]); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + } + + gDPPipeSync(gMasterGfxPos++); +} diff --git a/src/effects/something_rotating.c b/src/effects/something_rotating.c index eb7bdfca93..1e55ae825f 100644 --- a/src/effects/something_rotating.c +++ b/src/effects/something_rotating.c @@ -1,11 +1,69 @@ #include "common.h" #include "effects_internal.h" +void something_rotating_init(EffectInstance* effect); +void something_rotating_update(EffectInstance* effect); +void something_rotating_render(EffectInstance* effect); void something_rotating_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/something_rotating", something_rotating_main); +EffectInstance* something_rotating_main( + s32 arg0, + f32 arg1, + f32 arg2, + f32 arg3, + f32 arg4, + s32 arg5 +) { + EffectBlueprint bp; + EffectInstance* effect; + SomethingRotatingFXData* part; + s32 numParts = 8; + s32 i; -void something_rotating_init(void) { + bp.init = something_rotating_init; + bp.update = something_rotating_update; + bp.renderWorld = something_rotating_render; + bp.unk_00 = 0; + bp.unk_14 = NULL; + bp.effectID = EFFECT_SOMETHING_ROTATING; + + effect = shim_create_effect_instance(&bp); + effect->numParts = numParts; + part = effect->data.somethingRotating = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.somethingRotating != NULL); + + part->unk_00 = arg0; + part->unk_14 = 0; + if (arg5 <= 0) { + part->unk_10 = 1000; + } else { + part->unk_10 = arg5; + } + part->unk_04 = arg1; + part->unk_08 = arg2; + part->unk_0C = arg3; + part->unk_18 = arg4; + part->unk_1C = 30.0f; + part->unk_20 = 0; + + part++; + for (i = 1; i < numParts; i++, part++) { + part->unk_24 = 0; + part->unk_18 = arg4 * 0.5; + part->unk_26 = 255; + part->unk_27 = 255; + part->unk_28 = 0; + part->unk_25 = 0; + part->unk_1C = 30.0f; + part->unk_20 = 0; + part->unk_29 = 0; + part->unk_2C = 50.0f; + } + + return effect; +} + +void something_rotating_init(EffectInstance* effect) { } INCLUDE_ASM(s32, "effects/something_rotating", something_rotating_update); diff --git a/src/effects/sparkles.c b/src/effects/sparkles.c index 2ddbd1d630..7b4b4fb816 100644 --- a/src/effects/sparkles.c +++ b/src/effects/sparkles.c @@ -1,14 +1,234 @@ #include "common.h" #include "effects_internal.h" +extern Gfx D_09000F20_338EE0[]; +extern Gfx D_090011C8_339188[]; +extern Gfx D_090011E0_3391A0[]; +extern Gfx D_090011F8_3391B8[]; +extern Gfx D_09001210_3391D0[]; +extern Gfx D_09001228_3391E8[]; +extern Gfx D_09001240_339200[]; +extern Gfx D_09001258_339218[]; +extern Gfx D_09001270_339230[]; + +Gfx* D_E0022CD0[] = { + D_09001210_3391D0, D_09001228_3391E8, D_09001240_339200, + D_09001258_339218, D_09001270_339230, D_090011C8_339188, + D_090011E0_3391A0, D_090011F8_3391B8 +}; + +u8 D_E0022CF0[] = { + 254, 172, 172, + 254, 172, 213, + 254, 180, 154, + 213, 180, 254, + 180, 180, 254, + 180, 221, 254, + 180, 254, 254, + 180, 254, 213, + 180, 254, 180, + 213, 254, 180, + 254, 254, 180, + 254, 213, 172 +}; + +u8 D_E0022D14[] = { 0x1E, 0x3C, 0x50, 0x5F, 0x64, 0x68, 0x6A }; +u8 D_E0022D1C[] = { 0x3C, 0x5A, 0x64, 0x68, 0x6A, 0x6C, 0x6D }; + +void sparkles_init(EffectInstance* effect); +void sparkles_update(EffectInstance* effect); +void sparkles_render(EffectInstance* effect); void sparkles_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/sparkles", sparkles_main); +void sparkles_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + EffectBlueprint bp; + EffectBlueprint* bpPtr = &bp; + EffectInstance* effect; + SparklesFXData* part; + s32 numParts; + f32 var_f30; + f32 angle; + f32 angle2; + s32 i; -void sparkles_init(void) { + switch (arg0) { + case 0: + numParts = 36; + var_f30 = arg4; + break; + case 1: + numParts = 4; + var_f30 = arg4; + break; + case 2: + numParts = 8; + var_f30 = arg4; + break; + case 3: + numParts = 4; + var_f30 = 8.0f; + break; + default: + numParts = 8; + var_f30 = 8.0f; + break; + } + + numParts++; + + bpPtr->init = sparkles_init; + bpPtr->update = sparkles_update; + bpPtr->renderWorld = sparkles_render; + bpPtr->unk_00 = 0; + bpPtr->unk_14 = NULL; + bpPtr->effectID = EFFECT_SPARKLES; + + effect = shim_create_effect_instance(bpPtr); + effect->numParts = numParts; + part = effect->data.sparkles = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.sparkles != NULL); + + part->unk_04 = arg1; + part->unk_08 = arg2; + part->unk_0C = arg3; + part->unk_20 = 0; + part->unk_00 = arg0; + part->unk_24 = 30; + + part++; + for (i = 1; i < numParts; i++, part++) { + f32 rand1 = shim_rand_int(arg4 * 1000.0f) / 1000.0f; + f32 rand2 = shim_rand_int(var_f30 * 1000.0f) / 1000.0f; + + switch (arg0) { + case 0: + angle = (360.0f / (numParts - 1)) * i; + angle2 = (1800.0f / (numParts - 1)) * i - 90.0f; + part->unk_18 = 0.0f; + part->unk_10 = (shim_sin_deg(angle) * (85.0f - shim_sin_deg(angle2) * 15.0f - (i & 1) * 5) / 100.0f) * arg4; + part->unk_14 = (shim_cos_deg(angle) * (85.0f - shim_sin_deg(angle2) * 15.0f - (i & 1) * 5) / 100.0f) * arg4; + part->unk_0C = 0; + part->unk_28 = 0; + break; + case 1: + case 2: + angle = (360.0f / (numParts - 1)) * i + shim_rand_int(359); + if (i & 1) { + part->unk_18 = -(shim_rand_int(50) / 1000 + 0.05); + } else { + part->unk_18 = 0; + } + part->unk_10 = 0; + part->unk_14 = 0; + part->unk_04 = rand1 * shim_sin_deg(angle); + part->unk_08 = rand2 * shim_cos_deg(angle); + part->unk_0C = 0; + part->unk_1C = 1.0f; + part->unk_24 = i * 2 + 30; + part->unk_28 = i % 3; + part->unk_20 = 0; + break; + case 3: + case 4: + default: + angle = (360.0f / (numParts - 1)) * i + shim_rand_int(359); + part->unk_18 = -(shim_rand_int(50) / 1000 + 0.05); + part->unk_10 = 0.0f; + part->unk_14 = 0.0f; + part->unk_04 = rand1 * shim_sin_deg(angle); + part->unk_08 = rand2 * shim_cos_deg(angle); + part->unk_0C = 0; + part->unk_1C = 1.0f; + part->unk_24 = i * 2 + 18; + part->unk_28 = i % 3; + part->unk_20 = 0; + break; + } + } } -INCLUDE_ASM(s32, "effects/sparkles", sparkles_update); +void sparkles_init(EffectInstance* effect) { +} + +void sparkles_update(EffectInstance *effect) { + SparklesFXData* part = effect->data.sparkles; + SparklesFXData* firstPart = part; + s32 unk_00 = part->unk_00; + f32 unk_10; + f32 unk_14; + s32 unk_20; + s32 count = 0; + f32 temp_f20; + f32 angle; + s32 i; + + part->unk_24--; + part->unk_20++; + + unk_20 = part->unk_20; + + if ((unk_00 == 0 || unk_00 == 10) && part->unk_24 < 0) { + shim_remove_effect(effect); + return; + } + + part++; + for (i = 0; i < effect->numParts - 1; i++, part++) { + part->unk_2C = (unk_20 + i) & 7; + switch (unk_00) { + case 0: + part->unk_18 += -0.02; + if (unk_20 - 1 < 7) { + part->unk_04 = part->unk_10 * D_E0022D14[unk_20 - 1] * 0.01; + part->unk_08 = part->unk_14 * D_E0022D14[unk_20 - 1] * 0.01 + part->unk_18; + part->unk_1C = (f32) D_E0022D1C[unk_20 - 1] * 0.01; + } else { + angle = func_E0200044(360, i + 177); + temp_f20 = (i & 3) * 0.5f + 1.0f; + firstPart->unk_00 = 10; + part->unk_10 = temp_f20 * shim_sin_deg(angle); + part->unk_14 = temp_f20 * shim_cos_deg(angle); + part->unk_18 = -0.05f; + } + break; + case 10: + part->unk_10 *= 0.96; + part->unk_1C += (0.1 - part->unk_1C) * 0.1; + part->unk_14 *= 0.96; + part->unk_14 += part->unk_18; + part->unk_04 += part->unk_10; + part->unk_08 += part->unk_14; + break; + default: + part->unk_10 *= 0.9; + part->unk_14 += part->unk_18; + unk_10 = part->unk_10; + unk_14 = part->unk_14; + if (part->unk_24 < 0) { + count++; + } + part->unk_04 += unk_10; + part->unk_08 += unk_14; + part->unk_24--; + if (part->unk_24 < 0 || part->unk_24 >= 21) { + part->unk_2C = -1; + } else { + part->unk_20++; + unk_20 = part->unk_20; + if (unk_20 - 1 < 7) { + part->unk_1C = (f32) D_E0022D1C[unk_20 - 1] * 0.01; + } else { + part->unk_1C += (0.1 - part->unk_1C) * 0.1; + } + } + break; + } + } + + if (unk_00 != 0 && unk_00 != 10 && count >= effect->numParts - 1) { + shim_remove_effect(effect); + } +} void sparkles_render(EffectInstance* effect) { RenderTask renderTask; @@ -22,4 +242,47 @@ void sparkles_render(EffectInstance* effect) { retTask = shim_queue_render_task(&renderTask); } -INCLUDE_ASM(s32, "effects/sparkles", sparkles_appendGfx); +void sparkles_appendGfx(void* effect) { + SparklesFXData* part = ((EffectInstance*)effect)->data.sparkles; + Matrix4f sp18; + Matrix4f sp58; + Matrix4f sp98; + s32 colorIdx; + s32 i; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + gSPDisplayList(gMasterGfxPos++, D_09000F20_338EE0); + + colorIdx = (part->unk_20 - 1) * 3; + + shim_guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C); + shim_guRotateF(sp58, -gCameras[gCurrentCameraID].currentYaw, 0.0f, 1.0f, 0.0f); + shim_guMtxCatF(sp58, sp18, sp98); + + part++; + for (i = 0; i < ((EffectInstance*)effect)->numParts - 1; i++, part++) { + s32 unk_2C = part->unk_2C; + + if (unk_2C >= 0) { + shim_guTranslateF(sp58, part->unk_04, part->unk_08, part->unk_0C); + + sp58[0][0] = part->unk_1C; + sp58[1][1] = part->unk_1C; + sp58[2][2] = part->unk_1C; + colorIdx += 3; + + shim_guMtxCatF(sp58, sp98, sp18); + shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + + colorIdx %= ARRAY_COUNT(D_E0022CF0); + + gDPSetPrimColor(gMasterGfxPos++, 0, 0, D_E0022CF0[colorIdx], D_E0022CF0[colorIdx + 1], D_E0022CF0[colorIdx + 2], 255); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, D_E0022CD0[unk_2C & 7]); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + } + + gDPPipeSync(gMasterGfxPos++); +} diff --git a/src/evt/fx_api.c b/src/evt/fx_api.c index 54149f7ad7..2de18d7e2f 100644 --- a/src/evt/fx_api.c +++ b/src/evt/fx_api.c @@ -577,7 +577,7 @@ ApiStatus PlayEffect(Evt* script, s32 isInitialCall) { effectRet = fx_snowfall(iVar1, iVar2); break; case EFFECT_46: - effectRet = fx_46(iVar1, (EffectWhirlwindUnk*)a2, fVar3, iVar4); + effectRet = fx_46(iVar1, (PlayerStatus*)a2, fVar3, iVar4); break; case EFFECT_GATHER_MAGIC: effectRet = fx_gather_magic(iVar1, fVar2, fVar3, fVar4, fVar5, iVar6); diff --git a/ver/us/asm/data/effects/337F10.data.s b/ver/us/asm/data/effects/337F10.data.s deleted file mode 100644 index 0fccc685f9..0000000000 --- a/ver/us/asm/data/effects/337F10.data.s +++ /dev/null @@ -1,15 +0,0 @@ -.include "macro.inc" - -.section .data - -dlabel D_E0022CD0 -.word 0x09001210, 0x09001228, 0x09001240, 0x09001258, 0x09001270, 0x090011C8, 0x090011E0, 0x090011F8 - -dlabel D_E0022CF0 -.word 0xFEACACFE, 0xACD5FEB4, 0x9AD5B4FE, 0xB4B4FEB4, 0xDDFEB4FE, 0xFEB4FED5, 0xB4FEB4D5, 0xFEB4FEFE, 0xB4FED5AC - -dlabel D_E0022D14 -.word 0x1E3C505F, 0x64686A00 - -dlabel D_E0022D1C -.ascii "