diff --git a/include/effects.h b/include/effects.h index dbc7c700a9..c931513f6f 100644 --- a/include/effects.h +++ b/include/effects.h @@ -680,8 +680,17 @@ typedef struct StarsBurstFXData { } StarsBurstFXData; // size = 0x38 typedef struct StarsShimmerFXData { - /* 0x00 */ char todo[0]; -} StarsShimmerFXData; // size = unknown + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ Vec3f pos; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ f32 unk_18; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ s32 lifeTime; + /* 0x24 */ s32 timeLeft; + /* 0x28 */ s32 unk_28; +} StarsShimmerFXData; // size = 0x2C typedef struct RisingBubbleFXData { /* 0x00 */ s32 unk_00; @@ -944,8 +953,8 @@ typedef struct RadialShimmerFXData { /* 0x1C */ f32 unk_1C; /* 0x20 */ f32 unk_20; /* 0x24 */ s32 unk_24; - /* 0x28 */ s32 unk_28; - /* 0x2C */ s32 unk_2C; + /* 0x28 */ s32 timeLeft; + /* 0x2C */ s32 lifeTime; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; /* 0x38 */ f32 unk_38; @@ -1355,8 +1364,12 @@ typedef struct ConfettiFXData { typedef struct SnowfallFXData { /* 0x00 */ s32 unk_00; /* 0x04 */ s32 unk_04; - /* 0x08 */ s32 unk_08; - /* 0x0C */ char unk_0C[0x14]; + /* 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 timeLeft; /* 0x24 */ s32 lifeTime; /* 0x28 */ s32 unk_28; @@ -2526,12 +2539,18 @@ typedef struct QuizmoAssistantFXData { } QuizmoAssistantFXData; // size = 0x20 typedef struct IcePillarFXData { - /* 0x00 */ char unk_00[0x4]; + /* 0x00 */ s32 unk_00; /* 0x04 */ Vec3f pos; - /* 0x10 */ char unk_10[0x10]; - /* 0x20 */ f32 unk_20; - /* 0x24 */ char todo[0]; -} IcePillarFXData; // size = unknown + /* 0x10 */ s32 timeLeft; + /* 0x14 */ s32 lifeTime; + /* 0x18 */ Color_RGBA8 prim; + /* 0x1C */ Color_RGBA8 env; + /* 0x20 */ f32 scale; + /* 0x24 */ s8 unk_24; + /* 0x25 */ s8 unk_25; + /* 0x26 */ char unk_26[0x2]; + /* 0x28 */ struct EffectInstance* miscParticles; +} IcePillarFXData; // size = 0x2C // sun shine directions enum { diff --git a/include/effects_internal.h b/include/effects_internal.h index 49948ee28d..c3abf97a40 100644 --- a/include/effects_internal.h +++ b/include/effects_internal.h @@ -27,6 +27,7 @@ void shim_guTranslateF(float mf[4][4], float x, float y, float z); void shim_guPerspectiveF(f32 mf[4][4], u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); void shim_guPositionF(float mf[4][4], float r, float p, float h, float s, float x, float y, float z); void shim_guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale); +void shim_guFrustumF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale); void shim_mem_clear(void* data, s32 numBytes); void shim_transform_point(Matrix4f mtx, f32 inX, f32 inY, f32 inZ, f32 inS, f32* outX, f32* outY, f32* outZ, f32* outS); s32 shim_npc_raycast_down_sides(s32, f32*, f32*, f32*, f32*); @@ -69,7 +70,7 @@ void damage_indicator_main(s32, f32, f32, f32, f32, f32, s32, EffectInstance**); EffectInstance* purple_ring_main(s32, f32, f32, f32, f32, f32, f32, f32); 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 stars_shimmer_main(s32, f32 x, f32 y, f32 z, f32, f32, s32, s32); void rising_bubble_main(s32, f32, f32, f32, f32); void ring_blast_main(s32, f32, f32, f32, f32, s32); void shockwave_main(s32, f32, f32, f32); @@ -161,7 +162,7 @@ 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); EffectInstance* quizmo_assistant_main(s32, f32, f32, f32, f32, s32); -FX_MAIN(ice_pillar_main); +EffectInstance* ice_pillar_main(s32 arg0, f32 x, f32 y, f32 z, f32 arg4, s32 arg5); EffectInstance* sun_main(s32, f32, f32, f32, f32, s32); EffectInstance* star_spirits_energy_main(s32, f32, f32, f32, f32, s32); EffectInstance* pink_sparkles_main(s32, f32, f32, f32, f32, f32); diff --git a/src/182B30.c b/src/182B30.c index 3db79ebb3e..31be6f9017 100644 --- a/src/182B30.c +++ b/src/182B30.c @@ -778,7 +778,7 @@ void appendGfx_npc_actor(s32 isPartner, s32 actorIndex) { effect->data.icePillar->pos.x = actorPosX; effect->data.icePillar->pos.y = actorPosY; effect->data.icePillar->pos.z = actorPosZ; - effect->data.icePillar->unk_20 = actor->size.y / 24.0; + effect->data.icePillar->scale = actor->size.y / 24.0; } else { effect->data.icePillar->pos.x = 0.0f; effect->data.icePillar->pos.y = -1000.0f; @@ -1423,7 +1423,7 @@ void appendGfx_player_actor(void* arg0) { effect->data.icePillar->pos.x = playerPosX - 8.0f; effect->data.icePillar->pos.y = playerPosY; effect->data.icePillar->pos.z = playerPosZ; - effect->data.icePillar->unk_20 = player->size.y / 24.0; + effect->data.icePillar->scale = player->size.y / 24.0; } else { effect->data.icePillar->pos.x = 0.0f; effect->data.icePillar->pos.y = -1000.0f; diff --git a/src/effects.c b/src/effects.c index 2cdd05cc4d..be7b880d9a 100644 --- a/src/effects.c +++ b/src/effects.c @@ -78,7 +78,7 @@ EffectTableEntry gEffectTable[] = { /* 0x30 */ FX_ENTRY(big_snowflakes, effect_gfx_big_snowflakes), /* 0x31 */ FX_ENTRY(debuff, effect_gfx_debuff), /* 0x32 */ FX_ENTRY(green_impact, effect_gfx_green_impact), - /* 0x33 */ FX_ENTRY(radial_shimmer, _366D60), + /* 0x33 */ FX_ENTRY(radial_shimmer, effect_gfx_radial_shimmer), /* 0x34 */ FX_ENTRY(ending_decals, effect_gfx_ending_decals), /* 0x35 */ FX_ENTRY(light_rays, effect_gfx_light_rays), /* 0x36 */ FX_ENTRY(lightning, effect_gfx_lightning), @@ -96,7 +96,7 @@ EffectTableEntry gEffectTable[] = { /* 0x42 */ FX_ENTRY(bombette_breaking, effect_gfx_blast), /* 0x43 */ FX_ENTRY(firework, effect_gfx_firework), /* 0x44 */ FX_ENTRY(confetti, effect_gfx_confetti), - /* 0x45 */ FX_ENTRY(snowfall, _38D070), + /* 0x45 */ FX_ENTRY(snowfall, effect_gfx_snowfall), /* 0x46 */ FX_ENTRY_NUMBERED(46, effect_gfx_effect_46), /* 0x47 */ FX_ENTRY(gather_magic, effect_gfx_gather_magic), /* 0x48 */ FX_ENTRY(attack_result_text, effect_gfx_attack_result_text), @@ -156,7 +156,7 @@ EffectTableEntry gEffectTable[] = { /* 0x7E */ FX_ENTRY(breaking_junk, effect_gfx_breaking_junk), /* 0x7F */ FX_ENTRY(partner_buff, _404F40), /* 0x80 */ FX_ENTRY(quizmo_assistant, effect_gfx_quizmo_assistant), - /* 0x81 */ FX_ENTRY(ice_pillar, _40A1C0), + /* 0x81 */ FX_ENTRY(ice_pillar, effect_gfx_ice_pillar), /* 0x82 */ FX_ENTRY(sun, effect_gfx_sun), /* 0x83 */ FX_ENTRY(star_spirits_energy, effect_gfx_star_spirits_energy), /* 0x84 */ FX_ENTRY(pink_sparkles, effect_gfx_sparkles), diff --git a/src/effects/bulb_glow.c b/src/effects/bulb_glow.c index d83a1269f2..a8a2605dcc 100644 --- a/src/effects/bulb_glow.c +++ b/src/effects/bulb_glow.c @@ -1,7 +1,46 @@ #include "common.h" +#include "nu/nusys.h" #include "effects_internal.h" -extern s32 D_E00789A8; +typedef struct UnkBulbGlow { + /* 0x00 */ s32 unk_00; + /* 0x04 */ s32 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s32 unk_10; + /* 0x14 */ s32 unk_14; +} UnkBulbGlow; // size = 0x18 + +extern Gfx D_09001400_37C1D0[]; +extern Gfx D_090014B8_37C288[]; +extern Gfx D_09001570_37C340[]; +extern Gfx D_09001618_37C3E8[]; +extern Gfx D_090016C0_37C490[]; + +Gfx* D_E0078900[] = { + D_09001400_37C1D0, D_090014B8_37C288, D_09001570_37C340, D_09001618_37C3E8, D_090016C0_37C490, D_09001570_37C340 +}; + +UnkBulbGlow D_E0078918[] = { + { 0x00000080, 0x00000080, 0.5f, 0.5f, 0x00000040, 0x00000004 }, + { 0x00000040, 0x00000040, 2.0f, 2.0f, 0x00000020, 0x00000010 }, + { 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000040, 0x00000008 }, + { 0x00000040, 0x00000040, 2.0f, 2.0f, 0x00000010, 0x00000010 }, + { 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000020, 0x00000010 }, + { 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000040, 0x00000008 }, +}; + +s32 D_E00789A8 = 0; + +u8 D_E00789AC[] = { + 255, 255, 255, + 255, 255, 128, + 255, 128, 255, + 128, 255, 255, + 255, 128, 128, + 128, 255, 128, + 128, 128, 255, +}; void bulb_glow_init(EffectInstance* effect); void bulb_glow_update(EffectInstance* effect); @@ -26,7 +65,7 @@ void bulb_glow_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, EffectInst data = effect->data.bulbGlow = shim_general_heap_malloc(numParts * sizeof(*data)); ASSERT(effect->data.bulbGlow != NULL); - data->unk_00 = arg0 & 0xFF; + data->unk_00 = arg0 & 255; if (arg0 < 256) { data->unk_14 = 100; } else { @@ -112,4 +151,157 @@ void bulb_glow_render(EffectInstance* effect) { void func_E0078274(void) { } +// wip +#ifdef WIP +void bulb_glow_appendGfx(void* effect) { + f32 sp18; + f32 sp1C; + s32 sp20; + s32 sp24; + s32 sp28; + EffectInstance* effectTemp = effect; + BulbGlowFXData* data = effectTemp->data.bulbGlow; + Gfx* temp_a0_4; + Gfx* temp_a1; + Gfx* temp_a3; + Gfx* temp_a3_2; + Gfx* temp_v1; + UnkBulbGlow* temp_s1; + f32 temp_f0; + f32 temp_f4; + s32 temp_a0_3; + s32 temp_a2; + s32 temp_f6; + s32 temp_lo; + s32 temp_s0_2; + s32 temp_s2; + s32 temp_s2_2; + s32 temp_s3; + s32 temp_s6; + s32 temp_s6_2; + s32 temp_t0; + s32 temp_t5; + s32 var_s4; + s32 var_t2; + s32 var_t3; + s32 var_t4; + s32 var_t5; + s32 var_t7; + s32 var_v1; + s32 var_v1_2; + u32 temp_t6; + u8* temp_v0; + + s32 j; + + + var_s4 = data->unk_10; + temp_s2 = data->unk_00; + if (var_s4 > 127) { + var_s4 = 127; + } + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + temp_s1 = &D_E0078918[temp_s2]; + temp_s6 = temp_s1->unk_10; + temp_s3 = temp_s1->unk_14; + + var_v1 = shim_func_8011CFBC(data->pos.x, data->pos.y); + if (temp_s2 == 5) { + var_v1 = 1; + } + if ((var_v1 != 0) && !(sp18 < 0.0f) && !(sp1C < 0.0f) && !(sp18 >= 320.0f) && !(sp1C >= 240.0f)) { + gSPDisplayList(gMasterGfxPos++, D_E0078900[temp_s2]); + + temp_v0 = D_E00789AC[data->unk_20 * 3]; + temp_t0 = var_s4 * 2; + temp_f0 = (f32) temp_s6; + sp20 = (s32) (sp18 - temp_f0); + temp_a0_3 = temp_s6 * 2; + var_t7 = sp20 + temp_a0_3; + temp_f6 = (s32) (sp1C - temp_f0); + var_t4 = temp_f6 + temp_a0_3; + + gDPSetPrimColor(gMasterGfxPos++, 0, 0, + (temp_v0[0] * temp_t0) / 255, + (temp_v0[1] * temp_t0) / 255, + (temp_v0[2] * temp_t0) / 255, + 127 + ); + + var_t5 = 0; + if (sp20 < 0) { + var_t5 = -sp20; + } + var_v1_2 = 0; + if (temp_f6 < 0) { + var_v1_2 = -temp_f6; + } + if (var_t7 > SCREEN_WIDTH) { + var_t7 = SCREEN_WIDTH - 1; + } + if (var_t4 > SCREEN_HEIGHT) { + var_t4 = SCREEN_HEIGHT - 1; + } + var_t3 = var_v1_2 / temp_s3; + temp_lo = (s32) (var_t4 - temp_f6) / temp_s3; + sp24 = temp_lo; + if (var_t3 < temp_lo) { + temp_s6_2 = sp20 + var_t5; + sp28 = (var_t7 - temp_s6_2) * 2; + var_t2 = (var_t3 * temp_s3) + temp_f6; +loop_19: + if ((var_t2 + temp_s3) < 0xF0) { + temp_f4 = (f32) sp20; + temp_t5 = ((temp_s6_2 * 4) & 0xFFF) << 0xC; + temp_s2_2 = (((var_t7 - 1) * 4) & 0xFFF) << 0xC; + temp_s0_2 = ((temp_s3 - 1) * 4) & 0xFFF; + + temp_a3_2->words.w0 = ((((s32) (temp_f4 * temp_s1->unk_08) * 4) & 0xFFF) << 0xC) | ((((s32) ((f32) (temp_s1->unk_04 * 0x14) - ((f32) (var_t3 * temp_s1->unk_14) * temp_s1->unk_0C)) * 4) & 0xFFF) | 0xF2000000); + temp_a3_2->words.w1 = ((((s32) ((temp_f4 * temp_s1->unk_08) + (f32) temp_s1->unk_00) * 4) & 0xFFF) << 0xC) | (((s32) ((f32) (temp_s1->unk_04 * 0x15) - ((f32) (var_t3 * temp_s1->unk_14) * temp_s1->unk_0C)) * 4) & 0xFFF); + + for (j = 0; j < 1; j++) { + temp_a0_4->words.w0 = 0xFD10013F; + temp_a0_4->words.w1 = (u32) (nuGfxCfb_ptr + (var_t2 * 0x280) + 0x80000000); + + temp_a1->words.w0 = ((((s32) (sp28 + 7) >> 3) & 0x1FF) << 9) | 0xF5100100; + temp_a1->words.w1 = 07020090 + + temp_a1->unk8 = E600000000000000 + + temp_a2 = var_t2 + temp_s3; + + temp_a1->unk10 = temp_t5 | 0xF4000000; + temp_a1->unk14 = (s32) (temp_s2_2 | (temp_s0_2 | 0x07000000)); + + temp_a1->unk18 = E700000000000000 + + temp_a1->unk20 = ((((s32) (sp28 + 7) >> 3) & 0x1FF) << 9) | 0xF5100100; + temp_a1->unk24 = 0x01020090; + + temp_a1->unk28 = (s32) (temp_t5 | 0xF2000000); + temp_a1->unk2C = (s32) (temp_s2_2 | (temp_s0_2 | 0x01000000)); + + temp_a1->unk30 = (s32) ((((var_t7 * 4) & 0xFFF) << 0xC) | (((temp_a2 * 4) & 0xFFF) | 0xE4000000)); + temp_a1->unk34 = (s32) (temp_t5 | ((var_t2 * 4) & 0xFFF)); + + temp_a1->unk38 = E1000000 + temp_a1->unk3C = (s32) ((temp_s6_2 & 0x1FF) << 0x15); + + temp_a1->unk40 = F100000004000400 + temp_a1->unk48 = E700000000000000 + } + var_t3 += 1; + var_t2 = temp_a2; + if (var_t3 < sp24) { + goto loop_19; + } + } + } + } +} +#else INCLUDE_ASM(s32, "effects/bulb_glow", bulb_glow_appendGfx); +#endif diff --git a/src/effects/confetti.c b/src/effects/confetti.c index ddc054442e..201e9d1b88 100644 --- a/src/effects/confetti.c +++ b/src/effects/confetti.c @@ -1,6 +1,11 @@ #include "common.h" #include "effects_internal.h" +void confetti_init(EffectInstance* effect); +void confetti_update(EffectInstance* effect); +void confetti_render(EffectInstance* effect); +void confetti_appendGfx(void* effect); + extern Gfx D_090009E8_38C588[]; extern Gfx D_09000A00_38C5A0[]; @@ -26,9 +31,7 @@ u8 D_E0088CDC[] = { s8 D_E0088D00[] = { 0, 1, 2, 3, 2, 1, 0, 0 }; -s32 D_E0088D08[] = { 0x002D003C, 0x00000000 }; - -void confetti_appendGfx(void* effect); +u8 D_E0088D08[] = { 0, 45, 0, 60 }; void func_E0088000(ConfettiFXData* part) { part->unk_04 = shim_rand_int(700) * 0.1f - 35.0f; @@ -40,9 +43,130 @@ void func_E0088000(ConfettiFXData* part) { part->unk_20 = 120; } -INCLUDE_ASM(s32, "effects/confetti", confetti_main); +// weirdness abound +#ifdef NON_EQUIVALENT +EffectInstance* confetti_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) { + EffectBlueprint bp; + EffectBlueprint* bpPtr = &bp; + f32 sp28; + ConfettiFXData* data; + EffectInstance* effect; + s32 numParts; + f32 theta; + f32 sinTheta; + f32 cosTheta; + f32 theta2; + f32 sinTheta2; + f32 cosTheta2; + f32 temp_f28; + f32 temp_f30; + s32 temp_fp; + s32 np; + s32 var_v0; + s32 i; -void confetti_init(void) { + switch (arg0) { + case 0: + case 4: + np = 12; + break; + case 1: + case 5: + np = 18; + break; + case 2: + case 6: + np = 24; + break; + default: + np = 48; + break; + } + + switch (arg0) { + case 0: + case 4: + sp28 = 3.0f; + break; + case 1: + case 5: + sp28 = 4.0f; + break; + case 2: + case 3: + case 6: + default: + sp28 = 5.0f; + break; + } + + numParts = np + 1; + + bpPtr->init = confetti_init; + bpPtr->update = confetti_update; + bpPtr->renderWorld = confetti_render; + bpPtr->unk_00 = 0; + bpPtr->unk_14 = NULL; + bpPtr->effectID = EFFECT_CONFETTI; + + effect = shim_create_effect_instance(bpPtr); + effect->numParts = numParts; + data = effect->data.fireworkRocket = shim_general_heap_malloc(numParts * sizeof(*data)); + ASSERT(effect->data.fireworkRocket != NULL); + + data->unk_04 = arg1; + data->unk_08 = arg2; + data->unk_0C = arg3; + data->unk_24 = 0; + data->unk_00 = arg0; + data->unk_20 = arg5; + data->unk_2C = np; + data->unk_28 = 255; + + temp_fp = shim_rand_int(360); + + for (i = 0; i < np; i++, data++) { + temp_f30 = sp28 * (func_E0200000(100) * 0.01f); + if ((u32) arg0 < 7U) { + + } + temp_f28 = 2.0 * (sp28 * 0.5); + var_v0 = i; + if (i < 0) { + var_v0 = i + 3; + } + theta = ((i * 360.0f) / np) + temp_fp; + data->unk_30 = arg0; + theta2 = D_E0088D08[i - ((var_v0 >> 2) * 4)]; + sinTheta = shim_sin_deg(theta); + cosTheta = shim_cos_deg(theta); + sinTheta2 = shim_sin_deg(theta2); + cosTheta2 = shim_cos_deg(theta2); + if (arg0 == 3) { + func_E0088000(data); + data->unk_30 = i * 3; + } else { + data->unk_0C = temp_f30 * sinTheta2; + data->unk_18 = temp_f28 * sinTheta2; + data->unk_04 = temp_f30 * sinTheta * cosTheta2; + data->unk_08 = temp_f30 * cosTheta * cosTheta2; + data->unk_10 = temp_f28 * sinTheta * cosTheta2; + data->unk_14 = (temp_f28 * cosTheta * cosTheta2) + 1.0f; + if (arg0 >= 4) { + data->unk_1C = -0.02 - (((i + 1) % 3) * 0.02); + } else { + data->unk_1C = 0.0f; + } + data->unk_30 = i & 3; + } + } + return effect; +} +#else +INCLUDE_ASM(s32, "effects/confetti", confetti_main); +#endif + +void confetti_init(EffectInstance* effect) { } void confetti_update(EffectInstance* effect) { diff --git a/src/effects/effect_65.c b/src/effects/effect_65.c index b1649fd812..41c65f70a1 100644 --- a/src/effects/effect_65.c +++ b/src/effects/effect_65.c @@ -6,6 +6,10 @@ void fx_65_update(EffectInstance* effect); void fx_65_render(EffectInstance* effect); void fx_65_appendGfx(void* effect); +extern Gfx D_09000400_3D15E0[]; + +Gfx* D_E00CACB0[] = { D_09000400_3D15E0, D_09000400_3D15E0, D_09000400_3D15E0, D_09000400_3D15E0 }; + EffectInstance* fx_65_main( s32 arg0, f32 arg1, diff --git a/src/effects/firework_rocket.c b/src/effects/firework_rocket.c index ab47fedda0..43d093577e 100644 --- a/src/effects/firework_rocket.c +++ b/src/effects/firework_rocket.c @@ -6,6 +6,64 @@ void firework_rocket_render(EffectInstance* effect); void firework_rocket_update(EffectInstance* effect); void firework_rocket_appendGfx(void* effect); +typedef struct FireworkRocketUnk { + /* 0x00 */ Color_RGB8* unk_00; + /* 0x04 */ s32 num; +} FireworkRocketUnk; // size = 0x8 + +extern Gfx D_09000080_3E53D0[]; +extern Gfx D_09000158_3E54A8[]; + +Gfx* D_E010ACC0[] = { D_09000158_3E54A8, D_09000158_3E54A8, D_09000158_3E54A8 }; +Gfx* D_E010ACCC[] = { D_09000080_3E53D0, D_09000080_3E53D0, D_09000080_3E53D0 }; + +Color_RGB8 D_E010ACD8[] = { + {36, 0, 93}, {54, 216, 74}, {67, 0, 74}, {82, 220, 45}, {89, 0, 45}, {60, 190, 45}, {21, 192, 74}, {28, 171, 45}, + {10, 158, 15}, {49, 170, 15}, {166, 216, 15}, {169, 237, 45}, {157, 0, 15}, {184, 203, 45}, {169, 19, 45}, + {166, 40, 15}, {190, 73, 15}, {184, 53, 45}, {211, 77, 45}, {225, 94, 15}, {247, 89, 45}, {184, 53, 45}, + {11, 222, 93}, {0, 0, 100}, {202, 216, 74}, {184, 203, 45}, {211, 179, 45}, {166, 216, 15}, {190, 183, 15}, + {11, 222, 93}, {235, 192, 74}, {21, 192, 74}, {247, 167, 45}, {28, 171, 45}, {10, 98, 15}, {80, 198, 15}, + {97, 235, 15}, {49, 170, 15}, {10, 158, 15}, {225, 162, 15}, {190, 183, 15}, {49, 86, 15}, {80, 58, 15}, + {97, 21, 15}, {227, 235, 93}, {0, 0, 100}, {11, 34, 93}, {227, 21, 93}, {21, 64, 74}, {235, 64, 74}, {202, 40, 74}, + {28, 85, 45}, {67, 0, 74}, {89, 0, 45}, {36, 0, 93}, {0, 0, 100}, {11, 34, 93}, {54, 40, 74}, {21, 64, 74}, + {202, 40, 74}, {184, 53, 45}, {0, 0, 100}, {227, 235, 93}, {189, 0, 74}, {202, 216, 74}, {227, 21, 93}, {0, 0, 100}, + {60, 190, 45}, {82, 220, 45}, {89, 0, 45}, {28, 171, 45}, {28, 171, 45}, {247, 167, 45}, {211, 179, 45}, + {184, 203, 45}, {60, 66, 45}, {28, 85, 45}, {82, 36, 45}, {28, 85, 45}, {89, 0, 45}, {247, 89, 45}, {211, 77, 45}, + {184, 53, 45}, {49, 86, 15}, {10, 98, 15}, {82, 36, 45}, {97, 235, 15}, {97, 21, 15}, {60, 66, 45}, {28, 85, 45}, + {169, 19, 45}, {190, 73, 15}, {166, 40, 15}, {169, 237, 45}, {184, 203, 45} +}; + +Color_RGB8 D_E010ADF8[] = { + {208, 241, 0}, {220, 230, 22}, {211, 0, 22}, {208, 15, 0}, {220, 26, 22}, {227, 40, 0}, {220, 26, 22}, + {242, 43, 22}, {0, 50, 0}, {14, 43, 22}, {8, 231, 43}, {14, 213, 22}, {36, 230, 22}, {26, 0, 43}, {0, 0, 50}, + {0, 206, 0}, {29, 216, 0}, {45, 0, 22}, {29, 216, 0}, {36, 230, 22}, {14, 213, 22}, {48, 241, 0}, {45, 0, 22}, + {0, 206, 0}, {14, 213, 22}, {242, 213, 22}, {227, 216, 0}, {220, 230, 22}, {29, 40, 0}, {36, 26, 22}, {48, 15, 0}, + {14, 43, 22}, {45, 0, 22}, {0, 0, 50}, {8, 25, 43}, {235, 15, 43}, {14, 43, 22}, {26, 0, 43}, {45, 0, 22}, + {0, 0, 50}, {8, 25, 43}, {235, 241, 43}, {0, 0, 50}, {220, 230, 22}, {8, 231, 43}, {0, 0, 50}, {235, 15, 43}, + {235, 241, 43}, {220, 26, 22}, {242, 43, 22}, {220, 26, 22}, {29, 40, 0}, {0, 50, 0}, {36, 26, 22}, {48, 241, 0}, + {48, 15, 0}, {14, 43, 22}, {242, 213, 22}, {208, 241, 0}, {227, 216, 0}, {14, 213, 22}, {211, 0, 22}, + {220, 230, 22}, {227, 40, 0}, {208, 15, 0}, {0, 0, 0} +}; + +Color_RGB8 D_E010AEC0[] = { + {247, 105, 0}, {239, 87, 0}, {17, 87, 0}, {9, 105, 0}, {0, 122, 0}, {230, 69, 0}, {26, 69, 0}, {221, 52, 0}, + {35, 52, 0}, {202, 49, 0}, {186, 255, 0}, {200, 241, 0}, {0, 200, 0}, {56, 241, 0}, {70, 255, 0}, {54, 49, 0}, + {196, 222, 0}, {239, 191, 0}, {17, 191, 0}, {60, 222, 0}, {85, 13, 0}, {74, 46, 0}, {99, 27, 0}, {93, 43, 0}, + {12, 33, 0}, {12, 22, 0}, {24, 22, 0}, {24, 33, 0}, {12, 10, 0}, {24, 10, 0}, {24, 45, 0}, {232, 33, 0}, + {232, 22, 0}, {232, 45, 0}, {113, 40, 0}, {193, 203, 0}, {190, 183, 0}, {182, 46, 0}, {163, 43, 0}, {35, 182, 0}, + {52, 173, 0}, {12, 45, 0}, {244, 22, 0}, {244, 33, 0}, {232, 10, 0}, {244, 10, 0}, {244, 45, 0}, {204, 173, 0}, + {221, 182, 0}, {186, 164, 0}, {171, 13, 0}, {157, 27, 0}, {143, 40, 0}, {63, 203, 0}, {66, 183, 0}, {70, 164, 0} +}; + +FireworkRocketUnk D_E010AF68[] = { + {D_E010ACD8, ARRAY_COUNT(D_E010ACD8)}, + {D_E010ADF8, ARRAY_COUNT(D_E010ADF8)}, + {D_E010AEC0, ARRAY_COUNT(D_E010AEC0)} +}; + +s32 D_E010AF80 = 0; +s32 D_E010AF84 = 0; + EffectInstance* firework_rocket_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8) { EffectBlueprint bp; EffectInstance* effect; diff --git a/src/effects/gfx/ice_pillar.c b/src/effects/gfx/ice_pillar.c new file mode 100644 index 0000000000..9cfac2f1e8 --- /dev/null +++ b/src/effects/gfx/ice_pillar.c @@ -0,0 +1,17 @@ +#include "effects/gfx/D_09000000_40A1C0.png.inc.c" +#include "effects/gfx/D_09000400_40A5C0.png.inc.c" +#include "effects/gfx/D_09000800_40A9C0.png.inc.c" +#include "effects/gfx/D_09000C00_40ADC0.png.inc.c" + +#include "effects/gfx/D_09001000_40B1C0.gfx.inc.c" +#include "effects/gfx/D_090010A8_40B268.vtx.inc.c" +#include "effects/gfx/D_090010E8_40B2A8.vtx.inc.c" +#include "effects/gfx/D_09001128_40B2E8.vtx.inc.c" +#include "effects/gfx/D_09001168_40B328.vtx.inc.c" + +char D_09001198_40B358[] = { 0xFF, 0xF0, 0x00, 0x40, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xFF }; + +#include "effects/gfx/D_090011A8_40B368.gfx.inc.c" +#include "effects/gfx/D_090011C8_40B388.gfx.inc.c" +#include "effects/gfx/D_090011E8_40B3A8.gfx.inc.c" +#include "effects/gfx/D_09001208_40B3C8.gfx.inc.c" diff --git a/src/effects/gfx/radial_shimmer.c b/src/effects/gfx/radial_shimmer.c new file mode 100644 index 0000000000..96467de657 --- /dev/null +++ b/src/effects/gfx/radial_shimmer.c @@ -0,0 +1,23 @@ +#include "effects/gfx/D_09000000_366D60.png.inc.c" +#include "effects/gfx/D_09000200_366F60.png.inc.c" +#include "effects/gfx/D_09000400_367160.png.inc.c" +#include "effects/gfx/D_09000C00_367960.png.inc.c" +#include "effects/gfx/D_09000E00_367B60.png.inc.c" +#include "effects/gfx/D_09001600_368360.png.inc.c" +#include "effects/gfx/D_09001E00_368B60.png.inc.c" +#include "effects/gfx/D_09002600_369360.png.inc.c" +#include "effects/gfx/D_09002E00_369B60.png.inc.c" + +#include "effects/gfx/D_09003000_369D60.vtx.inc.c" +#include "effects/gfx/D_090031A0_369F00.vtx.inc.c" + +#include "effects/gfx/D_09003340_36A0A0.gfx.inc.c" +#include "effects/gfx/D_09003428_36A188.gfx.inc.c" +#include "effects/gfx/D_09003508_36A268.gfx.inc.c" +#include "effects/gfx/D_090035E8_36A348.gfx.inc.c" +#include "effects/gfx/D_090036C8_36A428.gfx.inc.c" +#include "effects/gfx/D_090037A8_36A508.gfx.inc.c" +#include "effects/gfx/D_09003830_36A590.gfx.inc.c" +#include "effects/gfx/D_090038B8_36A618.gfx.inc.c" +#include "effects/gfx/D_090039A8_36A708.gfx.inc.c" +#include "effects/gfx/D_09003A88_36A7E8.gfx.inc.c" diff --git a/src/effects/gfx/snowfall.c b/src/effects/gfx/snowfall.c new file mode 100644 index 0000000000..b713403ff3 --- /dev/null +++ b/src/effects/gfx/snowfall.c @@ -0,0 +1,13 @@ +#include "effects/gfx/D_09000000_38D070.png.inc.c" +#include "effects/gfx/D_09000080_38D0F0.png.inc.c" +#include "effects/gfx/D_09000880_38D8F0.vtx.inc.c" +#include "effects/gfx/D_09000A00_38DA70.vtx.inc.c" + +#include "effects/gfx/D_09000A80_38DAF0.vtx.inc.c" + +// todo wut dis +u8 D_09000C00_38DC70[] = { 0xE7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD7, 0x00, 0x10, 0x02, 0xFF, 0xFF, 0xFF, 0xFF }; + +#include "effects/gfx/D_09000C10_38DC80.gfx.inc.c" +#include "effects/gfx/D_09000D30_38DDA0.gfx.inc.c" +#include "effects/gfx/D_09000D50_38DDC0.gfx.inc.c" diff --git a/src/effects/ice_pillar.c b/src/effects/ice_pillar.c index b40c8e5cb0..229e69ec23 100644 --- a/src/effects/ice_pillar.c +++ b/src/effects/ice_pillar.c @@ -1,14 +1,138 @@ #include "common.h" #include "effects_internal.h" +void ice_pillar_init(EffectInstance* effect); +void ice_pillar_update(EffectInstance* effect); +void ice_pillar_render(EffectInstance* effect); void ice_pillar_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/ice_pillar", ice_pillar_main); +extern Gfx D_09001000_40B1C0[]; +extern Gfx D_090011A8_40B368[]; +extern Gfx D_090011C8_40B388[]; +extern Gfx D_090011E8_40B3A8[]; +extern Gfx D_09001208_40B3C8[]; -void ice_pillar_init(void) { +Gfx* D_E011E7F0[] = { D_090011A8_40B368, D_090011C8_40B388, D_090011E8_40B3A8, D_09001208_40B3C8 }; +Gfx* D_E011E800[] = { D_09001000_40B1C0 }; + +EffectInstance* ice_pillar_main(s32 arg0, f32 x, f32 y, f32 z, f32 scale, s32 arg5) { + EffectBlueprint effectBp; + EffectInstance* effect; + IcePillarFXData* data; + s32 numParts = 1; + + effectBp.init = ice_pillar_init; + effectBp.update = ice_pillar_update; + effectBp.renderWorld = ice_pillar_render; + effectBp.unk_00 = 0; + effectBp.unk_14 = 0; + effectBp.effectID = EFFECT_ICE_PILLAR; + + effect = shim_create_effect_instance(&effectBp); + effect->numParts = numParts; + + data = effect->data.icePillar = shim_general_heap_malloc(numParts * sizeof(*data)); + ASSERT(data != NULL); + + data->unk_00 = arg0; + data->lifeTime = 0; + if (arg5 <= 0) { + data->timeLeft = 1000; + } else { + data->timeLeft = arg5; + } + + data->prim.a = 255; + data->pos.x = x; + data->pos.y = y; + data->pos.z = z; + data->scale = scale; + data->prim.r = 255; + data->prim.g = 255; + data->prim.b = 255; + data->env.r = 240; + data->env.g = 255; + data->env.b = 255; + data->env.a = 255; + data->unk_24 = data->unk_25 = 0; + + shim_load_effect(EFFECT_MISC_PARTICLES); + data->miscParticles = misc_particles_main(1, x, y + 10.0f, z, 32.0f, 30.0f, scale, 4, 0); + + shim_load_effect(EFFECT_COLD_BREATH); + return effect; } -INCLUDE_ASM(s32, "effects/ice_pillar", ice_pillar_update); +void ice_pillar_init(EffectInstance* effect) { +} + +void ice_pillar_update(EffectInstance* effect) { + IcePillarFXData* data = effect->data.icePillar; + s32 timeLeft; + s32 lifeTime; + s32 i; + + if (effect->flags & 0x10) { + effect->flags &= ~0x10; + data->timeLeft = 16; + } + + if (data->timeLeft < 1000) { + data->timeLeft--; + } + + data->lifeTime++; + + if (data->timeLeft < 0) { + shim_load_effect(EFFECT_ICE_SHARD); + + for (i = 0; i < 20; i++) { + EffectInstance* iceShard; + + iceShard = ice_shard_main( + (i - ((i / 2) * 2)) + 2, + (data->pos.x + shim_rand_int(20)) - 10.0f, + data->pos.y + (shim_rand_int(40) * data->scale), + data->pos.z + 3.0f, + (data->scale * ((shim_rand_int(10) * 0.7 * 0.1) + 0.3)), + i + 30 + ); + iceShard->data.iceShard->unk_44 = shim_rand_int(10) * 0.1; + iceShard->data.iceShard->unk_48 = (shim_rand_int(30) * 0.01) + 0.1; + iceShard->data.iceShard->unk_3C = shim_rand_int(359); + iceShard->data.iceShard->unk_40 = shim_rand_int(20); + iceShard->data.iceShard->unk_4C = shim_rand_int(10) - 5; + iceShard->data.iceShard->unk_50 = shim_rand_int(10) - 5; + iceShard->data.iceShard->unk_54 = 0; + iceShard->data.iceShard->unk_58 = -0.1f; + } + shim_remove_effect(data->miscParticles); + shim_remove_effect(effect); + return; + } + + timeLeft = data->timeLeft; + lifeTime = data->lifeTime; + + data->unk_25--; + if (data->unk_25 < 0) { + data->unk_25 = shim_rand_int(60) + 8; + } + + if (data->unk_25 < 8) { + data->unk_24 = data->unk_25 / 2; + } else { + data->unk_24 = 0; + } + + if (timeLeft > 16 && (lifeTime % 16) == 0) { + shim_load_effect(EFFECT_COLD_BREATH); + cold_breath_main(2, data->pos.x, data->pos.y + (data->scale * 40.0f), data->pos.z, data->scale, 30); + } + data->miscParticles->data.miscParticles->pos.x = data->pos.x; + data->miscParticles->data.miscParticles->pos.y = data->pos.y + 10.0f; + data->miscParticles->data.miscParticles->pos.z = data->pos.z; +} void ice_pillar_render(EffectInstance* effect) { RenderTask renderTask; @@ -23,4 +147,27 @@ void ice_pillar_render(EffectInstance* effect) { retTask->renderMode |= RENDER_TASK_FLAG_2; } -INCLUDE_ASM(s32, "effects/ice_pillar", ice_pillar_appendGfx); +void ice_pillar_appendGfx(void* effect) { + IcePillarFXData* data = ((EffectInstance*)effect)->data.icePillar; + s32 alpha = data->prim.a; + Matrix4f sp10, sp50; + Camera* camera; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + camera = &gCameras[gCurrentCameraID]; + shim_guTranslateF(sp10, data->pos.x, data->pos.y, data->pos.z); + shim_guScaleF(sp50, data->scale, data->scale, data->scale); + 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, data->prim.r, data->prim.g, data->prim.b, alpha); + gDPSetEnvColor(gMasterGfxPos++, data->env.r, data->env.g, data->env.b, data->env.a); + gSPDisplayList(gMasterGfxPos++, D_E011E800[0]); + gSPDisplayList(gMasterGfxPos++, D_E011E7F0[data->unk_24]); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); +} diff --git a/src/effects/radial_shimmer.c b/src/effects/radial_shimmer.c index 7bacb5e7c5..40bd40ac33 100644 --- a/src/effects/radial_shimmer.c +++ b/src/effects/radial_shimmer.c @@ -6,6 +6,32 @@ void radial_shimmer_update(EffectInstance* effect); void radial_shimmer_render(EffectInstance* effect); void radial_shimmer_appendGfx(void* effect); +extern Gfx D_09003428_36A188[]; +extern Gfx D_09003508_36A268[]; +extern Gfx D_090035E8_36A348[]; +extern Gfx D_090036C8_36A428[]; +extern Gfx D_09003830_36A590[]; +extern Gfx D_090038B8_36A618[]; +extern Gfx D_090039A8_36A708[]; +extern Gfx D_09003A88_36A7E8[]; + +Gfx* D_E0066C50[] = { + D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, + D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, + D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, D_09003830_36A590, D_09003830_36A590 +}; + +Gfx* D_E0066C8C[] = { + D_09003508_36A268, D_090035E8_36A348, D_09003428_36A188, D_090039A8_36A708, D_09003A88_36A7E8, + D_09003428_36A188, D_090039A8_36A708, D_09003A88_36A7E8, D_090038B8_36A618, D_09003508_36A268, + D_090038B8_36A618, D_090038B8_36A618, D_09003428_36A188, D_09003A88_36A7E8, D_090036C8_36A428, +}; + +// todo ??? unused +s32 D_E0066CC8[] = { + 0xFFC59CFF, 0x9CFFFF73, 0xD6FF9CFF, 0xFFC57BFF, 0xB4FFDE73, 0xFFFF949C +}; + EffectInstance* radial_shimmer_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) { EffectBlueprint bp; EffectInstance* effect; @@ -26,8 +52,8 @@ EffectInstance* radial_shimmer_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 ASSERT(effect->data.radialShimmer != NULL); data->unk_00 = arg0; - data->unk_28 = arg5_2; - data->unk_24 = data->unk_2C = 0; + data->timeLeft = arg5_2; + data->unk_24 = data->lifeTime = 0; data->unk_10 = arg1; data->unk_14 = arg2; data->unk_18 = arg3; @@ -186,23 +212,23 @@ void radial_shimmer_update(EffectInstance* effect) { f32 outS; s32 i; - part->unk_28--; - part->unk_2C++; + part->timeLeft--; + part->lifeTime++; if (effect->flags & 0x10) { effect->flags &= ~0x10; - part->unk_28 = 16; + part->timeLeft = 16; } - if (part->unk_28 < 0) { + if (part->timeLeft < 0) { shim_remove_effect(effect); return; } - unk_28 = part->unk_28; + unk_28 = part->timeLeft; - if (part->unk_2C < 11) { - part->unk_24 = (part->unk_2C * 255) / 10; + if (part->lifeTime <= 10) { + part->unk_24 = (part->lifeTime * 255) / 10; } if (unk_28 < 6) { @@ -215,7 +241,8 @@ void radial_shimmer_update(EffectInstance* effect) { part->unk_1C = part->unk_20; - shim_transform_point(&gCameras[gCurrentCameraID].perspectiveMatrix[0], part->unk_04, part->unk_08, part->unk_0C, 1.0f, &outX, &outY, &outZ, &outS); + shim_transform_point(&gCameras[gCurrentCameraID].perspectiveMatrix[0], part->unk_04, part->unk_08, part->unk_0C, + 1.0f, &outX, &outY, &outZ, &outS); outS = 1.0f / outS; outX *= outS; @@ -257,4 +284,89 @@ void radial_shimmer_render(EffectInstance* effect) { retTask->renderMode |= RENDER_TASK_FLAG_2; } -INCLUDE_ASM(s32, "effects/radial_shimmer", radial_shimmer_appendGfx); +void radial_shimmer_appendGfx(void* effect) { + Matrix4f sp20, sp60; + u16 spA0; + EffectInstance* effectTemp = effect; + RadialShimmerFXData* dataOrig = effectTemp->data.radialShimmer; + RadialShimmerFXData* data = effectTemp->data.radialShimmer; + Camera* camera = &gCameras[gCurrentCameraID]; + s32 temp_f0; + s32 temp_f2; + s32 temp_f4; + s32 temp_f6; + Gfx* dlist2; + Gfx* dlist1; + s32 temp_s5; + s32 temp_t1; + s32 var_a3; + s32 alpha; + s32 other; + s32 t1; + s32 t2; + s32 i; + + temp_s5 = data->unk_00; + dlist1 = D_E0066C8C[temp_s5]; + dlist2 = D_E0066C50[temp_s5]; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + shim_guTranslateF(sp20, data->unk_10, data->unk_14, data->unk_18); + shim_guScaleF(sp60, data->unk_1C, data->unk_1C, 1.0f); + shim_guMtxCatF(sp60, sp20, sp20); + shim_guPerspectiveF(sp60, &spA0, data->unk_60, (f32) camera->viewportW / camera->viewportH, 4.0f, 16384.0f, 1.0f); + shim_guMtxCatF(sp60, sp20, sp20); + shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + + shim_guTranslateF(sp20, 0.0f, 0.0f, data->unk_64); + shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + alpha = data->unk_24; + gDPSetEnvColor(gMasterGfxPos++, data->unk_6B, data->unk_6C, data->unk_6D, 127); + gSPDisplayList(gMasterGfxPos++, dlist1); + + for (i = 0; i < effectTemp->numParts; i++, data++) { + gDPSetPrimColor(gMasterGfxPos++, 0, 0, data->unk_68, data->unk_69, data->unk_6A, alpha); + + switch (temp_s5) { + case 0: + case 1: + other = 0x3F; + var_a3 = 0x1FF; + break; + case 8: + other = 0x3F; + var_a3 = 0x7F; + break; + case 11: + other = 0x3F; + var_a3 = 0xFF; + break; + default: + other = 0x3F; + var_a3 = 0x1FF; + break; + } + + temp_f0 = data->unk_30; + temp_f2 = data->unk_40; + temp_f4 = data->unk_38; + temp_f6 = data->unk_48; + + gDPSetTileSize(gMasterGfxPos++, 0, temp_f0, temp_f2, temp_f0 + other * 4, temp_f2 + var_a3 * 4); + gDPSetTileSize(gMasterGfxPos++, G_TX_MIRROR, temp_f4, temp_f6, temp_f4 + other * 4, temp_f6 + var_a3 * 4); + gSPDisplayList(gMasterGfxPos++, dlist2); + } + + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->camPerspMatrix[gCurrentCameraID], + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gDPPipeSync(gMasterGfxPos++); +} diff --git a/src/effects/snowfall.c b/src/effects/snowfall.c index f89f0aa7ca..c438054179 100644 --- a/src/effects/snowfall.c +++ b/src/effects/snowfall.c @@ -1,15 +1,27 @@ #include "common.h" #include "effects_internal.h" - void snowfall_init(EffectInstance* effect); void snowfall_update(EffectInstance* effect); void snowfall_render(EffectInstance* effect); void snowfall_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/snowfall", func_E008A000); +extern Gfx D_09000C00_38DC70[]; +extern Gfx D_09000D50_38DDC0[]; -void func_E008A000(SnowfallFXData* data); +Gfx* D_E008AA50[] = { D_09000D50_38DDC0, D_09000D50_38DDC0 }; + +void func_E008A000(SnowfallFXData* data) { + Camera* camera = &gCameras[gCurrentCameraID]; + + data->unk_08 = (camera->lookAt_eye.x + func_E0200000(2000)) - 1000.0f; + data->unk_0C = (camera->lookAt_eye.y + func_E0200000(2000)) - 1000.0f; + data->unk_10 = (camera->lookAt_eye.z + func_E0200000(2000)) - 1000.0f; + data->unk_14 = (func_E0200000(20) - 10.0f) * 0.05; + data->unk_18 = -1.2 - (func_E0200000(80) * 0.01); + data->unk_1C = (func_E0200000(20) - 10.0f) * 0.05; + data->unk_28 = 255; +} EffectInstance* snowfall_main(s32 arg0, s32 arg1) { EffectBlueprint effectBp; @@ -50,9 +62,90 @@ EffectInstance* snowfall_main(s32 arg0, s32 arg1) { void snowfall_init(EffectInstance* effect) { } -INCLUDE_ASM(s32, "effects/snowfall", func_E008A290); +void func_E008A290(SnowfallFXData* data, s32 arg1, s32 arg2, s32 arg3) { + Camera* camera = &gCameras[gCurrentCameraID]; + f32 unk_08 = data->unk_08; + f32 unk_0C = data->unk_0C; + f32 unk_10 = data->unk_10; + f32 lookX = camera->lookAt_obj.x; + f32 lookY = camera->lookAt_obj.y; + f32 lookZ = camera->lookAt_obj.z; + s32 temp_f12; + s32 temp_f12_2; + s32 temp_f12_3; -INCLUDE_ASM(s32, "effects/snowfall", snowfall_update); + temp_f12 = unk_08 - lookX; + if (arg1 < temp_f12) { + temp_f12 = temp_f12 % arg1; + data->unk_08 = (lookX - arg1) + temp_f12; + } else if (-arg1 > temp_f12) { + temp_f12 = -temp_f12; + temp_f12 = temp_f12 % arg1; + data->unk_08 = (lookX + arg1) - temp_f12; + } + + temp_f12_2 = unk_0C - lookY; + if (arg2 < temp_f12_2) { + temp_f12_2 = temp_f12_2 % arg2; + data->unk_0C = (lookY - arg2) + temp_f12_2; + } else if (temp_f12_2 < -arg2) { + if (arg3 < 100) { + data->unk_18 = 0; + data->unk_28 = 0; + } else { + temp_f12_2 = -temp_f12_2; + temp_f12_2 = temp_f12_2 % arg2; + data->unk_0C = (lookY + arg2) - temp_f12_2; + } + } + + temp_f12_3 = unk_10 - lookZ; + if (arg1 < temp_f12_3) { + temp_f12_3 = temp_f12_3 % arg1; + data->unk_10 = (lookZ - arg1) + temp_f12_3; + } else if (temp_f12_3 < -arg1) { + temp_f12_3 = -temp_f12_3; + temp_f12_3 = temp_f12_3 % arg1; + data->unk_10 = (lookZ + arg1) - temp_f12_3; + } +} + +void snowfall_update(EffectInstance* effect) { + Camera* camera = &gCameras[gCurrentCameraID]; + SnowfallFXData* data = effect->data.snowfall; + s32 timeLeft; + s32 boomLength; + s32 temp_s5; + s32 temp_s6; + s32 i; + + if (data->timeLeft < 100) { + data->timeLeft--; + } + if (data->timeLeft < 0) { + shim_remove_effect(effect); + return; + } + + data->lifeTime++; + timeLeft = data->timeLeft; + temp_s5 = data->unk_2C; + if (timeLeft < 10) { + data->unk_28 = timeLeft * 25; + } + boomLength = camera->currentBoomLength; + temp_s6 = (boomLength * 0.3) + 1.0; + + data++; + for (i = 0; i < temp_s5; i++, data++) { + if (data->unk_30 <= 0 || --data->unk_30 <= 0) { + data->unk_08 += data->unk_14; + data->unk_0C += data->unk_18; + data->unk_10 += data->unk_1C; + func_E008A290(data, boomLength, temp_s6, timeLeft); + } + } +} void snowfall_render(EffectInstance* effect) { RenderTask renderTask; @@ -67,4 +160,55 @@ void snowfall_render(EffectInstance* effect) { retTask->renderMode |= RENDER_TASK_FLAG_2; } -INCLUDE_ASM(s32, "effects/snowfall", snowfall_appendGfx); +void snowfall_appendGfx(void* effect) { + EffectInstance* effectTemp = effect; + SnowfallFXData* data = effectTemp->data.snowfall; + Matrix4f sp18; + Gfx* dlist; + Mtx* mtx; + u8 bgRGB; + u8 bgAlpha; + s32 unk_28; + s32 unk_2C; + s32 i; + + if (data->unk_00 != 0) { + unk_28 = data->unk_28; + bgAlpha = 255; + unk_2C = data->unk_2C; + dlist = D_E008AA50[data->unk_04]; + if (*gBgRenderTypePtr == 1) { + shim_get_background_color_blend(&bgRGB, &bgRGB, &bgRGB, &bgAlpha); + unk_28 = 255 - bgAlpha; + } + + if (unk_28 != 0) { + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + + gSPDisplayList(gMasterGfxPos++, D_09000C00_38DC70); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, 255, 255, 255, unk_28); + + shim_guRotateF(sp18, -gCameras[gCurrentCameraID].currentYaw, 0.0f, 1.0f, 0.0f); + shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + + mtx = &gDisplayContext->matrixStack[gMatrixListPos++]; + + data++; + for (i = 0; i < unk_2C; i++, data++) { + if (data->unk_30 <= 0 && data->unk_28 != 0) { + shim_guTranslateF(sp18, data->unk_08, data->unk_0C, data->unk_10); + shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gMasterGfxPos++, mtx, + G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, dlist); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + } + gDPPipeSync(gMasterGfxPos++); + } + } +} diff --git a/src/effects/spiky_white_aura.c b/src/effects/spiky_white_aura.c index 1e938c1134..26fbca5e2e 100644 --- a/src/effects/spiky_white_aura.c +++ b/src/effects/spiky_white_aura.c @@ -4,6 +4,22 @@ extern Gfx* D_09000440_34EBB0[]; extern Gfx* D_090004E8_34EC58[]; +// RGB values? unused +u8 D_E00389F0[] = { + 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, +}; + void spiky_white_aura_init(EffectInstance* effect); void spiky_white_aura_update(EffectInstance* effect); void spiky_white_aura_render(EffectInstance* effect); diff --git a/src/effects/star_spirits_energy.c b/src/effects/star_spirits_energy.c index 0ba36c8b6c..11eee70e59 100644 --- a/src/effects/star_spirits_energy.c +++ b/src/effects/star_spirits_energy.c @@ -124,10 +124,12 @@ void star_spirits_energy_appendGfx(void* effect) { gDPPipeSync(gMasterGfxPos++); gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); - shim_guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].currentYaw, 0.0f, data->unk_3C, data->unk_08, data->unk_0C, data->unk_10); + shim_guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].currentYaw, 0.0f, + data->unk_3C, data->unk_08, data->unk_0C, data->unk_10); shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); - gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gMasterGfxPos++, D_E0122BA4[0]); gDPSetEnvColor(gMasterGfxPos++, data->unk_2C, data->unk_30, data->unk_34, data->unk_38); @@ -137,7 +139,8 @@ void star_spirits_energy_appendGfx(void* effect) { shim_guPositionF(sp20, 0.0f, 0.0f, 0.0f, data->unk_40[i], 0.0f, 0.0f, 0.0f); shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); - gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); gDPSetPrimColor(gMasterGfxPos++, 0, 0, data->unk_1C, data->unk_20, data->unk_24, data->unk_50[i]); gSPDisplayList(gMasterGfxPos++, D_E0122B90[i]); gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); diff --git a/src/effects/stars_burst.c b/src/effects/stars_burst.c index 30ca333938..1af24bd56e 100644 --- a/src/effects/stars_burst.c +++ b/src/effects/stars_burst.c @@ -3,7 +3,21 @@ extern Gfx D_090004C0_343500[]; extern Gfx D_090005E0_343620[]; -extern u8 D_E0042780[]; + +u8 D_E0042780[] = { + 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, +}; void stars_burst_init(EffectInstance* effect); void stars_burst_update(EffectInstance* effect); diff --git a/src/effects/stars_shimmer.c b/src/effects/stars_shimmer.c index b66467f996..cb11d2df69 100644 --- a/src/effects/stars_shimmer.c +++ b/src/effects/stars_shimmer.c @@ -1,14 +1,292 @@ #include "common.h" #include "effects_internal.h" +void stars_shimmer_init(EffectInstance* effect); +void stars_shimmer_update(EffectInstance* effect); +void stars_shimmer_render(EffectInstance* effect); void stars_shimmer_appendGfx(void* effect); -INCLUDE_ASM(s32, "effects/stars_shimmer", stars_shimmer_main); +extern Gfx D_09000F20[]; +extern Gfx D_09001210[]; +extern Gfx D_09001228[]; +extern Gfx D_09001240[]; +extern Gfx D_09001258[]; +extern Gfx D_09001270[]; +extern Gfx D_090011C8[]; +extern Gfx D_090011E0[]; +extern Gfx D_090011F8[]; -void stars_shimmer_init(void) { +Gfx* D_E0044DB0[] = { + D_09001210, D_09001228, D_09001240, D_09001258, D_09001270, D_090011C8, D_090011E0, D_090011F8 +}; + +u8 D_E0044DD0[][3] = { + { 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_E0044DF4[] = { + 30, 60, 90, 100, 104, 106, 108, 110, 112, 113, 113, 110, 107, 103, 0x00, 0x00 +}; + +u8 D_E0044E04[] = { + 30, 60, 90, 100, 104, 106, 108, 110, 112, 113, 113, 110, 107, 103, 0x00, 0x00 +}; + +// ordering crap +#ifdef NON_EQUIVALENT +void stars_shimmer_main(s32 type, f32 x, f32 y, f32 z, f32 arg4, f32 arg5, s32 arg6, s32 arg7) { + EffectBlueprint bp; + EffectBlueprint* bpPtr = &bp; + EffectInstance* effect; + StarsShimmerFXData* part; + s32 numParts = arg6; + f32 theta; + f32 cosTheta; + f32 sinTheta; + f32 temp_f22; + f32 temp_f8; + f32 temp_ft; + f32 sinT3; + f32 temp5; + f32 t3; + s32 i; + + numParts = arg6 + 1; + + bpPtr->init = stars_shimmer_init; + bpPtr->update = stars_shimmer_update; + bpPtr->renderWorld = stars_shimmer_render; + bpPtr->unk_00 = 0; + bpPtr->unk_14 = NULL; + bpPtr->effectID = EFFECT_STARS_SHIMMER; + + effect = shim_create_effect_instance(bpPtr); + effect->numParts = numParts; + part = effect->data.starsBurst = shim_general_heap_malloc(numParts * sizeof(*part)); + ASSERT(effect->data.starsBurst != NULL); + + if (type == 6) { + part->unk_00 = 1; + type = 3; + } else { + part->unk_00 = 0; + } + part->pos.x = x; + part->pos.y = y; + part->pos.z = z; + part->lifeTime = 0; + part->unk_02 = type; + part->timeLeft = arg7; + + part++; + for (i = 1; i < numParts; i++, part++) { + temp_f22 = (360.0f / (numParts - 1)) * i; + if (type > 1) { + theta = temp_f22 + shim_rand_int(359); + } else { + theta = temp_f22 + 0.0f; + } + t3 = (temp_f22 * 10.0f) - 90.0f; + sinTheta = shim_sin_deg(theta); + cosTheta = shim_cos_deg(theta); + sinT3 = shim_sin_deg(t3); + temp_f8 = (arg4 * 0.4) - (arg4 * 0.1 * sinT3); + temp_ft = (arg5 * 0.4) - (arg5 * 0.1 * sinT3); + temp5 = (arg5 / (numParts - 1)) * (i - 1); + + part->timeLeft = i + 30; + part->lifeTime = 0; + part->unk_1C = 1.0f; + + switch (type) { + case 0: + case 1: + part->unk_18 = 0; + part->pos.z = 0.0f; + part->unk_10 = sinTheta * temp_f8; + part->unk_14 = cosTheta * temp_ft; + break; + case 3: + part->pos.x = (sinTheta * arg4 * shim_rand_int(100)) * 0.005; + part->pos.y = (cosTheta * arg5 * shim_rand_int(100)) * 0.005; + part->pos.z = 0.0f; + + part->unk_18 = part->unk_10 = part->unk_14 = 0.0f; + + part->timeLeft += i * 2; + break; + case 2: + case 4: + case 5: + default: + part->unk_10 = sinTheta * temp_f8; + part->pos.y = temp5; + part->pos.z = cosTheta * temp_f8; + part->unk_14 = -shim_rand_int(10) * 0.03f; + part->unk_18 = (shim_rand_int(10) * 0.04f) + 0.01; + break; + } + } +} +#else +INCLUDE_ASM(s32, "effects/stars_shimmer", stars_shimmer_main); +#endif + +void stars_shimmer_init(EffectInstance* effect) { } +// tons of issues +#ifdef NON_EQUIVALENT +void stars_shimmer_update(EffectInstance* effect) { + StarsShimmerFXData* data = effect->data.starsShimmer; + u8** new_var = &D_E0044E04; + s32 count = 0; + f32 temp_f0; + f32 temp_f8; + f32 var_f20; + s32 temp_s3; + s32 temp_v1; + s32 temp_v1_2; + s32 new_var2; + s32 temp_v1_4; + s32 var_s2; + s32 var_v0; + s32 i; + + + temp_s3 = data->unk_02; + data->timeLeft--; + data->lifeTime++; + var_s2 = data->lifeTime; + new_var2 = var_s2; + if (!(temp_s3 != 0 && temp_s3 != 1) || temp_s3 == 3 || temp_s3 >= 10) { + if (data->timeLeft < 0) { + shim_remove_effect(effect); + return; + } + } + + for (i = 0; i < effect->numParts - 1; i++, data++) { + var_v0 = var_s2 + i; + switch (temp_s3) { + case 0: + case 1: + temp_v1 = var_s2 - 1; + data->unk_28 = (var_s2 + i) & 7; + data->unk_18 += -0.02; + if (temp_v1 < 14) { + temp_f0 = (f32) D_E0044DF4[temp_v1] * 0.01; + data->pos.x = data->unk_10 * temp_f0; + data->pos.y = (data->unk_14 * temp_f0) + data->unk_18; + data->unk_1C = (f32) (*new_var)[var_s2 - 1] * 0.01; + } else { + var_f20 = ((360.0f / (effect->numParts - 1)) * i) + 60.0f; + if (i % 2) { + var_f20 -= 120.0f; + } + data->unk_02 = 10; + data->unk_10 = shim_sin_deg(var_f20); + data->unk_14 = shim_cos_deg(var_f20); + data->unk_18 = -0.05f; + } + break; + case 10: + case 30: + data->unk_10 *= 0.96; + data->unk_14 *= 0.96; + data->unk_14 += data->unk_18; + data->unk_28 = (var_s2 + i) & 7; + data->unk_1C += (0.1 - data->unk_1C) * 0.1; + data->pos.x += data->unk_10; + data->pos.y += data->unk_14; + break; + case 3: + data->unk_28 = (var_s2 + i + i) & 7; + if (var_s2 - 1 < 14) { + data->unk_1C = (f32) D_E0044E04[new_var2 - 1] * 0.01; + break; + } + data->unk_02 = 30; + break; + case 2: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + var_v0 = var_s2 + i; + /* fallthrough */ + default: + data->unk_28 = (var_v0 + i) & 7; + if (data->timeLeft < 0) { + count++; + } + data->timeLeft--; + if (data->timeLeft >= 0x1FU) { + data->unk_28 = -1; + } else { + var_s2 = data->lifeTime + 1; + data->lifeTime++; + if (data->lifeTime < 14) { + data->unk_1C = (f32) D_E0044E04[data->lifeTime] * 0.01; + if (temp_s3 == 5) { + data->unk_14 += data->unk_18; + data->pos.y += data->unk_14; + } + } else { + data->unk_14 += data->unk_18; + data->pos.y += data->unk_14; + data->unk_1C += (0.1 - data->unk_1C) * 0.1; + } + if (temp_s3 == 4) { + data->pos.x = data->unk_10 * shim_sin_deg(var_s2 * 12); + data->pos.z = data->unk_10 * shim_cos_deg(var_s2 * 12); + } else { + data->pos.x = data->unk_10; + } + data->unk_14 *= 0.96; + } + break; + } + } + if (!(temp_s3 == 0 || temp_s3 == 1) && temp_s3 != 3 && temp_s3 < 10 && (count >= effect->numParts - 1)) { + shim_remove_effect(effect); + } +} +#else INCLUDE_ASM(s32, "effects/stars_shimmer", stars_shimmer_update); +#endif void stars_shimmer_render(EffectInstance* effect) { RenderTask renderTask; @@ -22,4 +300,94 @@ void stars_shimmer_render(EffectInstance* effect) { retTask = shim_queue_render_task(&renderTask); } +// this one sucks too +#ifdef NON_EQUIVALENT +void stars_shimmer_appendGfx(void* effect) { + Matrix4f sp18, sp58, sp98; + StarsShimmerFXData* data = ((EffectInstance*)effect)->data.starsShimmer; + s32 type; + s32 temp_s4; + s32 timeLeft; + f32 rf, gf, bf; + s32 r, g, b; + u8* var_s0; + s32 i; + + type = data->unk_02; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); + gSPDisplayList(gMasterGfxPos++, D_09000F20); + + temp_s4 = (data->lifeTime - 1) * 3; + 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); + + switch (type) { + case 0: + case 1: + case 2: + case 10: + rf = 1.0f; + gf = 0.5f; + bf = 0.1f; + break; + case 3: + case 30: + rf = 1.0f; + gf = 0.8f; + bf = 0.7f; + if (data->unk_00 != 0) { + gDPSetRenderMode(gMasterGfxPos++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2); + } + break; + case 5: + rf = 1.4f; + gf = 1.4f; + bf = 0.7f; + break; + default: + rf = 1.4f; + gf = 0.7f; + bf = 0.7f; + break; + } + + var_s0 = D_E0044DD0[temp_s4]; + + data++; + for (i = 0; i < ((EffectInstance*)effect)->numParts - 1; i++, data++) { + timeLeft = data->timeLeft; + if (timeLeft >= 0) { + shim_guTranslateF(sp58, data->pos.x, data->pos.y, data->pos.z); + sp58[0][0] = data->unk_1C; + shim_guMtxCatF(sp58, sp98, sp18); + shim_guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); + if (var_s0 >= &D_E0044DD0[36]) { + var_s0 = D_E0044DD0; + } + r = *var_s0++ * rf; + g = *var_s0++ * gf; + b = *var_s0++ * bf; + if (r > 255) { + r = 255; + } + if (g > 255) { + g = 255; + } + if (b > 255) { + b = 255; + } + gDPSetPrimColor(gMasterGfxPos++, 0, 0, r, g, b, 255); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); + gSPDisplayList(gMasterGfxPos++, D_E0044DB0[timeLeft & 7]); + gSPPopMatrix(gMasterGfxPos++, G_MTX_MODELVIEW); + } + } + gDPPipeSync(gMasterGfxPos++); +} +#else INCLUDE_ASM(s32, "effects/stars_shimmer", stars_shimmer_appendGfx); +#endif diff --git a/src/effects/underwater.c b/src/effects/underwater.c index 5f31bb306b..7151cd4ebe 100644 --- a/src/effects/underwater.c +++ b/src/effects/underwater.c @@ -1,5 +1,6 @@ #include "common.h" #include "effects_internal.h" +#include "nu/nusys.h" void underwater_init(EffectInstance* effect); void underwater_update(EffectInstance* effect); @@ -146,4 +147,176 @@ void underwater_render(EffectInstance* effect) { void func_E00BA618(void) { } +extern Vtx D_09000428[]; +extern Gfx D_09000528[]; +extern Gfx D_09000570[]; + +#ifdef WIP +void underwater_appendGfx(void* effect) { + EffectInstance* effectTemp = effect; + UnderwaterFXData* data; + Matrix4f sp20; + s32 spA0; + s32 spA8; + s32 temp_a0_3; + s32 temp_a1_5; + s32 temp_a1_6; + s32 temp_a1_7; + s32 temp_a2_2; + s32 temp_s3; + s32 temp_t7; + s32 temp_t8; + s32 temp_v1_2; + s32 temp_v1_4; + s32 var_a0; + s32 var_s1; + s32 var_s2; + s32 cond; + s32 var_t3_2; + s32 var_t4; + s32 var_t9; + s32 var_v1; + u32 temp_v1_3; + + s32 i; + s32 j; + + data = effectTemp->data.underwater; + + gDPPipeSync(gMasterGfxPos++); + gSPSegment(gMasterGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effectTemp->graphics->data)); + gDPSetColorImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, nuGfxZBuffer); + gSPDisplayList(gMasterGfxPos++, D_09000528); + + for (i = 0; i < 40; i++) { + // todo probably a composite macro? + gDPSetTextureImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, &nuGfxCfb_ptr[0xF00 * i]); + gDPSetTile(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 80, 0x0000, G_TX_LOADTILE, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOLOD); + gDPLoadSync(gMasterGfxPos++); + gDPLoadTile(gMasterGfxPos++, G_TX_LOADTILE, 0, 0, 0x04FC, 0x0014); + gDPPipeSync(gMasterGfxPos++); + gDPSetTile(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 80, 0x0000, G_TX_RENDERTILE, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, + G_TX_NOLOD); + gDPSetTileSize(gMasterGfxPos++, G_TX_RENDERTILE, 0, 0, 0x04FC, 0x0014); + gSPTextureRectangle(gMasterGfxPos++, 0, i * 0x18, 0x04FC, 20 + (i * 18), G_TX_RENDERTILE, 0, 0, 0x1000, 0x0400); + gDPPipeSync(gMasterGfxPos++); + } + + gDPSetColorImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, nuGfxCfb_ptr); + gDPSetPrimColor(gMasterGfxPos++, 0, 0, data->unk_1C, data->unk_1D, data->unk_1E, data->unk_1F); + gDPSetCycleType(gMasterGfxPos++, G_CYC_1CYCLE); + gDPSetCombineLERP(gMasterGfxPos++, PRIMITIVE, 0, PRIMITIVE_ALPHA, TEXEL0, 0, 0, 0, SHADE, PRIMITIVE, 0, + PRIMITIVE_ALPHA, TEXEL0, 0, 0, 0, SHADE); + gDPSetTextureImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, VIRTUAL_TO_PHYSICAL(nuGfxZBuffer)); + gDPSetRenderMode(gMasterGfxPos++, CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | G_RM_PASS, + CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)); + gDPSetTexturePersp(gMasterGfxPos++, G_TP_PERSP); + gDPSetTextureFilter(gMasterGfxPos++, G_TF_BILERP); + + shim_guFrustumF(sp20, -80.0f, 80.0f, 60.0f, -60.0f, 160.0f, 640.0f, 1.0f); + shim_guMtxF2L(sp20, &gDisplayContext->matrixStack[gMatrixListPos]); + + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPClearGeometryMode(gMasterGfxPos++, G_CULL_BOTH | G_LIGHTING); + gSPSetGeometryMode(gMasterGfxPos++, G_SHADE | G_SHADING_SMOOTH); + gSPVertex(gMasterGfxPos++, D_09000428, 16, 0); + + var_t9 = 0x18; + for (i = 0; i < 12; i++) { + var_s2 = 0; + if (i == 0) { + var_a0 = -4; + var_s2 = 1; + } else { + var_a0 = 0; + } + var_v1 = 0; + if (i == 11) { + var_v1 = 4; + var_s2 = 1; + } + temp_t8 = (var_t9 + var_a0) * 4; + spA0 = (temp_t8 & 0xFFF) | 0xF4000000; + temp_v1_2 = var_t9 + var_v1; + temp_s3 = (temp_v1_2 + 0x10) * 4; + spA8 = -var_s2; + + for (j = 0; j < 12; j++) { + cond = FALSE; + temp_t7 = (j * 0x10) + 0x10; + if (j == 0) { + var_t3_2 = -4; + cond = TRUE; + } else { + var_t3_2 = 0; + } + var_s1 = 0; + if (j == 0x11) { + var_s1 = 4; + cond = TRUE; + } + temp_a2_2 = temp_t7 + var_s1; + temp_a0_3 = temp_t7 + var_t3_2; + + temp_v1_3 = ((((s32) ((((temp_a2_2 - (temp_a0_3 - 0x10)) + 1) * 2) + 7) >> 3) & 0x1FF) << 9) | 0xF5100000; + + temp_a3->words.w0 = temp_v1_3; + temp_a3->words.w1 = 0x07098260; + + temp_a1_4->words.w0 = E600000000000000 + + temp_a1_4->unkC = (s32) (((((temp_a2_2 + 0x10) * 4) & 0xFFF) << 0xC) | ((temp_s3 & 0xFFF) | 0x07000000)); + temp_a1_4->unk8 = (s32) ((((temp_a0_3 * 4) & 0xFFF) << 0xC) | spA0); + + temp_a1_4->unk10 = E700000000000000 + + temp_a1_4->unk18 = temp_v1_3; + temp_a1_4->unk1C = 00098260 + + temp_a1_4->unk20 = F2000000 + temp_a1_4->unk24 = (s32) (((((temp_a2_2 + 0x1F) * 4) & 0xFFF) << 0xC) | (((temp_v1_2 + 0x1F) * 4) & 0xFFF)); + if (!cond || (var_t4 = 0xC, (var_s2 == 0))) { + var_t4 = 4; + if (!cond) { + var_t4 = spA8 & 8; + } + } + temp_a1_5 = j * 0xD; + + temp_a0_4->words.w0 = (var_t4 * 2) | 0x02180000; + temp_a0_4->words.w1 = ((temp_t7 + var_t3_2) << 0x12) | (temp_t8 + (data + (i + temp_a1_5))->unk23); + + temp_v1_4 = j * 0xD; + temp_a2_3->words.w0 = ((var_t4 + 1) * 2) | 0x02180000; + temp_a2_3->words.w1 = ((temp_t7 + var_s1 + 0x10) << 0x12) | (temp_t8 + (data + (i + temp_v1_4))->unk23); + + temp_a2_3->unk8 = (s32) (((var_t4 + 2) * 2) | 0x02180000); + temp_a2_3->unkC = (s32) (((temp_t7 + var_t3_2) << 0x12) | (temp_s3 + (data + (i + (temp_a1_5 + 1)))->unk23)); + + temp_a1_6 = (var_t4 + 3) * 2; + temp_a2_3->unk10 = (s32) (temp_a1_6 | 0x02180000); + temp_a2_3->unk14 = (s32) (((temp_t7 + var_s1 + 0x10) << 0x12) | (temp_s3 + (data + (i + (temp_v1_4 + 1)))->unk23)); + + temp_a1_7 = temp_a1_6 & 0xFF; + temp_a2_3->unk18 = (s32) (((var_t4 * 2) << 0x10) | (temp_a1_7 << 8) | ((var_t4 + 1) * 2) | 0x06000000); + temp_a2_3->unk1C = (s32) (((var_t4 * 2) << 0x10) | (((var_t4 + 2) * 2) << 8) | temp_a1_7); + + temp_a2_3->unk20 = E700000000000000; + } + var_t9 += 0x10; + } + gDPSetColorImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, nuGfxZBuffer); + gSPDisplayList(gMasterGfxPos++, D_09000570); + gDPSetColorImage(gMasterGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, nuGfxZBuffer); + gDPPipeSync(gMasterGfxPos++); + gSPMatrix(gMasterGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos], + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gDPPipeSync(gMasterGfxPos++); +} +#else INCLUDE_ASM(s32, "effects/underwater", underwater_appendGfx); +#endif diff --git a/ver/us/asm/data/effects/34E710.data.s b/ver/us/asm/data/effects/34E710.data.s deleted file mode 100644 index 5ddd6bba9e..0000000000 --- a/ver/us/asm/data/effects/34E710.data.s +++ /dev/null @@ -1,6 +0,0 @@ -.include "macro.inc" - -.section .data - -dlabel D_E00389F0 -.word 0xFEACACFE, 0xACD5FEB4, 0x9AD5B4FE, 0xB4B4FEB4, 0xDDFEB4FE, 0xFEB4FED5, 0xB4FEB4D5, 0xFEB4FEFE, 0xB4FED5AC, 0x00000000, 0x00000000, 0x00000000 diff --git a/ver/us/asm/data/effects/354F20.data.s b/ver/us/asm/data/effects/354F20.data.s deleted file mode 100644 index 993ab574b8..0000000000 --- a/ver/us/asm/data/effects/354F20.data.s +++ /dev/null @@ -1,6 +0,0 @@ -.include "macro.inc" - -.section .data - -dlabel D_E0042780 -.word 0xFEACACFE, 0xACD5FEB4, 0x9AD5B4FE, 0xB4B4FEB4, 0xDDFEB4FE, 0xFEB4FED5, 0xB4FEB4D5, 0xFEB4FEFE, 0xB4FED5AC, 0x00000000, 0x00000000, 0x00000000 diff --git a/ver/us/asm/data/effects/355D10.data.s b/ver/us/asm/data/effects/355D10.data.s deleted file mode 100644 index d676d64aec..0000000000 --- a/ver/us/asm/data/effects/355D10.data.s +++ /dev/null @@ -1,15 +0,0 @@ -.include "macro.inc" - -.section .data - -dlabel D_E0044DB0 -.word 0x09001210, 0x09001228, 0x09001240, 0x09001258, 0x09001270, 0x090011C8, 0x090011E0, 0x090011F8 - -dlabel D_E0044DD0 -.word 0xFEACACFE, 0xACD5FEB4, 0x9AD5B4FE, 0xB4B4FEB4, 0xDDFEB4FE, 0xFEB4FED5, 0xB4FEB4D5, 0xFEB4FEFE, 0xB4FED5AC - -dlabel D_E0044DF4 -.byte 0x1E, 0x3C, 0x5A, 0x64, 0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x71, 0x71, 0x6E, 0x6B, 0x67, 0x00, 0x00 - -dlabel D_E0044E04 -.ascii "