diff --git a/soh/soh/Enhancements/randomizer/draw.cpp b/soh/soh/Enhancements/randomizer/draw.cpp index 6b3788db6d..f837f59106 100644 --- a/soh/soh/Enhancements/randomizer/draw.cpp +++ b/soh/soh/Enhancements/randomizer/draw.cpp @@ -18,11 +18,22 @@ #include "objects/object_toki_objects/object_toki_objects.h" #include "objects/object_gi_bomb_2/object_gi_bomb_2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" +#include "objects/object_goma/object_goma.h" +#include "objects/object_kingdodongo/object_kingdodongo.h" +#include "objects/object_bv/object_bv.h" +#include "objects/object_gnd/object_gnd.h" +#include "objects/object_fd/object_fd.h" +#include "objects/object_mo/object_mo.h" +#include "objects/object_sst/object_sst.h" +#include "overlays/ovl_Boss_Sst/ovl_Boss_Sst.h" +#include "objects/object_tw/object_tw.h" +#include "objects/object_ganon2/object_ganon2.h" #include "soh_assets.h" #include "dungeon.h" #include "soh/Enhancements/cosmetics/cosmeticsTypes.h" extern "C" { +extern PlayState* gPlayState; extern SaveContext gSaveContext; } @@ -482,6 +493,312 @@ extern "C" void Randomizer_DrawMysteryItem(PlayState* play, GetItemEntry getItem CLOSE_DISPS(play->state.gfxCtx); } +Gfx* GetEmptyDlist(GraphicsContext* gfxCtx) { + Gfx* dListHead; + Gfx* dList; + + dList = dListHead = (Gfx*)Graph_Alloc(gfxCtx, sizeof(Gfx) * 1); + + gSPEndDisplayList(dListHead++); + + return dList; +} + +#define LIMB_COUNT_GOHMA 86 +extern "C" void DrawGohma() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Translate(0.0f, -20.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(0.005f, 0.005f, 0.005f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_GOHMA]; + static Vec3s otherTable[LIMB_COUNT_GOHMA]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&gGohmaSkel, + (AnimationHeader*)&gGohmaIdleCrouchedAnim, jointTable, otherTable, LIMB_COUNT_GOHMA); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + gSPSegment(POLY_OPA_DISP++, 0x08, (uintptr_t)GetEmptyDlist(gPlayState->state.gfxCtx)); + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_KING_DODONGO 49 +extern "C" void DrawKingDodongo() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Translate(0.0f, -20.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(0.003f, 0.003f, 0.003f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_KING_DODONGO]; + static Vec3s otherTable[LIMB_COUNT_KING_DODONGO]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&object_kingdodongo_Skel_01B310, + (AnimationHeader*)&object_kingdodongo_Anim_00F0D8, jointTable, otherTable, + LIMB_COUNT_KING_DODONGO); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, + NULL, + NULL, + NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_BARINADE 64 +extern "C" void DrawBarinade() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Translate(0.0f, -25.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(0.03f, 0.03f, 0.03f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_BARINADE]; + static Vec3s otherTable[LIMB_COUNT_BARINADE]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_Init(gPlayState, &skelAnime, (SkeletonHeader*)&gBarinadeBodySkel, + (AnimationHeader*)&gBarinadeBodyAnim, jointTable, otherTable, LIMB_COUNT_BARINADE); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + SkelAnime_DrawSkeletonOpa(gPlayState, &skelAnime, NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_PHANTOM_GANON 26 +extern "C" void DrawPhantomGanon() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Translate(0.0f, 10.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(0.007f, 0.007f, 0.007f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_PHANTOM_GANON]; + static Vec3s otherTable[LIMB_COUNT_PHANTOM_GANON]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&gPhantomGanonSkel, + (AnimationHeader*)&gPhantomGanonNeutralAnim, jointTable, otherTable, + LIMB_COUNT_PHANTOM_GANON); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_VOLVAGIA 7 +extern "C" void DrawVolvagia() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Scale(0.007f, 0.007f, 0.007f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_VOLVAGIA]; + static Vec3s otherTable[LIMB_COUNT_VOLVAGIA]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&gVolvagiaHeadSkel, + (AnimationHeader*)&gVolvagiaHeadEmergeAnim, jointTable, otherTable, LIMB_COUNT_VOLVAGIA); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + gSPSegment(POLY_OPA_DISP++, 0x08, + (uintptr_t)Gfx_TwoTexScroll(gPlayState->state.gfxCtx, 0, gPlayState->state.frames, + gPlayState->state.frames, 0x20, 0x20, 1, gPlayState->state.frames, + gPlayState->state.frames, 0x20, 0x20)); + + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); + + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +extern "C" void DrawMorpha() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Xlu(gPlayState->state.gfxCtx); + + Matrix_Scale(0.015f, 0.015f, 0.015f, MTXMODE_APPLY); + + gSPSegment(POLY_XLU_DISP++, 0x08, + (uintptr_t)Gfx_TwoTexScroll(gPlayState->state.gfxCtx, 0, gPlayState->state.frames, + gPlayState->state.frames, 32, 32, 1, gPlayState->state.frames, + gPlayState->state.frames, + 32, 32)); + + gSPSegment(POLY_XLU_DISP++, 0x09, + (uintptr_t)Gfx_TwoTexScroll(gPlayState->state.gfxCtx, 0, gPlayState->state.frames % 3, 0, 32, 32, 1, 0, + gPlayState->state.frames % 3, 32, 32)); + + Matrix_RotateX(gPlayState->state.frames * 0.1f, MTXMODE_APPLY); + Matrix_RotateZ(gPlayState->state.frames * 0.16f, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gPlayState->state.gfxCtx, (char*)__FILE__, __LINE__), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, (s8)255); + + gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gMorphaCoreMembraneDL); + + gDPPipeSync(POLY_XLU_DISP++); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 220, 255, 128); + gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, 255, 255); + + gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gMorphaCoreNucleusDL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_BONGO_BONGO 27 +extern "C" void DrawBongoBongo() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Translate(0.0f, -25.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(0.006f, 0.006f, 0.006f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_BONGO_BONGO]; + static Vec3s otherTable[LIMB_COUNT_BONGO_BONGO]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&gBongoLeftHandSkel, + (AnimationHeader*)&gBongoLeftHandIdleAnim, jointTable, otherTable, + LIMB_COUNT_BONGO_BONGO); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + gDPSetPrimColor(POLY_OPA_DISP++, 0x80, 0x80, 255, 255, 255, (s8)255); + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_KOTAKE 27 +extern "C" void DrawKotake() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_KOTAKE]; + static Vec3s otherTable[LIMB_COUNT_KOTAKE]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&gTwinrovaKotakeSkel, + (AnimationHeader*)&gTwinrovaKotakeKoumeFlyAnim, jointTable, otherTable, + LIMB_COUNT_KOTAKE); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, + NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + +#define LIMB_COUNT_GANON 47 +extern "C" void DrawGanon() { + OPEN_DISPS(gPlayState->state.gfxCtx); + + Gfx_SetupDL_25Opa(gPlayState->state.gfxCtx); + Matrix_Translate(0.0f, -33.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(0.005f, 0.005f, 0.005f, MTXMODE_APPLY); + + static bool initialized = false; + static SkelAnime skelAnime; + static Vec3s jointTable[LIMB_COUNT_GANON]; + static Vec3s otherTable[LIMB_COUNT_GANON]; + static u32 lastUpdate = 0; + + if (!initialized) { + initialized = true; + SkelAnime_InitFlex(gPlayState, &skelAnime, (FlexSkeletonHeader*)&gGanonSkel, + (AnimationHeader*)&gGanonGuardIdleAnim, jointTable, otherTable, + LIMB_COUNT_GANON); + } + + if (gPlayState != NULL && lastUpdate != gPlayState->state.frames) { + lastUpdate = gPlayState->state.frames; + SkelAnime_Update(&skelAnime); + } + + SkelAnime_DrawFlexOpa(gPlayState, skelAnime.skeleton, skelAnime.jointTable, skelAnime.dListCount, + NULL, NULL, NULL); + + CLOSE_DISPS(gPlayState->state.gfxCtx); +} + extern "C" void Randomizer_DrawBossSoul(PlayState* play, GetItemEntry* getItemEntry) { s16 slot = getItemEntry->getItemId - RG_GOHMA_SOUL; s16 flameColors[9][3] = { @@ -493,43 +810,75 @@ extern "C" void Randomizer_DrawBossSoul(PlayState* play, GetItemEntry* getItemEn { 85, 180, 223 }, // Morpha { 126, 16, 177 }, // Bongo Bongo { 222, 158, 47 }, // Twinrova - { 80, 80, 80 }, // Ganon/Dorf + { 150, 150, 150 }, // Ganon/Dorf }; - OPEN_DISPS(play->state.gfxCtx); + // Draw the blue fire DL but coloured to the boss soul. + OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL_25Xlu(play->state.gfxCtx); + gSPSegment(POLY_XLU_DISP++, 8, + (uintptr_t)Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0), + 0 * (play->state.frames * 0), 16, 32, 1, 1 * (play->state.frames * 1), + -1 * (play->state.frames * 8), 16, 32)); + Matrix_Push(); + Matrix_Translate(0.0f, -70.0f, 0.0f, MTXMODE_APPLY); + Matrix_Scale(5.0f, 5.0f, 5.0f, MTXMODE_APPLY); + Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); - - if (slot == 8) { // For Ganon only... - gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 255); - } else { - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); - } - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gBossSoulSkullDL); - - if (slot >= 0) { - Gfx_SetupDL_25Xlu(play->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 8, (uintptr_t)Gfx_TwoTexScroll( - play->state.gfxCtx, 0, 0 * (play->state.frames * 0), - 0 * (play->state.frames * 0), 16, 32, 1, 1 * (play->state.frames * 1), - -1 * (play->state.frames * 8), 16, 32 - )); - Matrix_Push(); - Matrix_Translate(0.0f, -70.0f, 0.0f, MTXMODE_APPLY); - Matrix_Scale(5.0f, 5.0f, 5.0f, MTXMODE_APPLY); - Matrix_ReplaceRotation(&play->billboardMtxF); + gDPSetGrayscaleColor(POLY_XLU_DISP++, flameColors[slot][0], flameColors[slot][1], flameColors[slot][2], 255); + gSPGrayscale(POLY_XLU_DISP++, true); + gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gGiBlueFireFlameDL); + gSPGrayscale(POLY_XLU_DISP++, false); + Matrix_Pop(); + CLOSE_DISPS(play->state.gfxCtx); + + // Draw the generic boss soul model + if (CVarGetInteger(CVAR_RANDOMIZER_ENHANCEMENT("SimplerBossSoulModels"), 0)) { + OPEN_DISPS(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); - gDPSetGrayscaleColor(POLY_XLU_DISP++, flameColors[slot][0], flameColors[slot][1], flameColors[slot][2], 255); - gSPGrayscale(POLY_XLU_DISP++, true); - gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gGiBlueFireFlameDL); - gSPGrayscale(POLY_XLU_DISP++, false); - Matrix_Pop(); + if (slot == 8) { // For Ganon only... + gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, 255); + } else { + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, 255); + } + gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gBossSoulSkullDL); + CLOSE_DISPS(play->state.gfxCtx); + // Draw the boss' skeleton + } else { + switch (slot) { + case 0: // Gohma + DrawGohma(); + break; + case 1: // King Dodongo + DrawKingDodongo(); + break; + case 2: // Barinade + DrawBarinade(); + break; + case 3: // Phantom Ganon + DrawPhantomGanon(); + break; + case 4: // Volvagia + DrawVolvagia(); + break; + case 5: // Morpha + DrawMorpha(); + break; + case 6: // Bongo Bongo + DrawBongoBongo(); + break; + case 7: // Twinrova + DrawKotake(); + break; + case 8: // Ganon + DrawGanon(); + break; + default: + break; + } } - - CLOSE_DISPS(play->state.gfxCtx); - } extern "C" void Randomizer_DrawOcarinaButton(PlayState* play, GetItemEntry* getItemEntry) { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 6a2ce1c540..1edb7e4616 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -2265,6 +2265,12 @@ void DrawRandomizerMenu() { "Displays a \"Mystery Item\" model in place of any freestanding/GS/shop items that were shuffled, " "and replaces item names for them and scrubs and merchants, regardless of hint settings, " "so you never know what you're getting."); + UIWidgets::PaddedEnhancementCheckbox("Simpler Boss Soul Models", + CVAR_RANDOMIZER_ENHANCEMENT("SimplerBossSoulModels"), true, false); + UIWidgets::Tooltip( + "When shuffling boss souls, they'll appear as a simpler model instead of showing the boss' models." + "This might make boss souls more distinguishable from a distance, and can help with performance." + ); ImGui::EndMenu(); }