Implements better way to use new draw functions and adds Double Defense colors.

This commit is contained in:
Christopher Leggett 2022-08-23 23:48:14 -04:00
parent 28afbec341
commit c7b998b33b
No known key found for this signature in database
GPG Key ID: 7093AE5FF7037D79
12 changed files with 75 additions and 56 deletions

View File

@ -859,6 +859,7 @@ void Cutscene_HandleEntranceTriggers(GlobalContext* globalCtx);
void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx);
void Cutscene_SetSegment(GlobalContext* globalCtx, void* segment);
void GetItem_Draw(GlobalContext* globalCtx, s16 drawId);
void GetItemEntry_Draw(GlobalContext* globalCtx, GetItemEntry getItemEntry);
void SoundSource_InitAll(GlobalContext* globalCtx);
void SoundSource_UpdateAll(GlobalContext* globalCtx);
void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* pos, s32 duration, u16 sfxId);

View File

@ -6,37 +6,22 @@
#include <array>
#include "objects/object_gi_key/object_gi_key.h"
#include "objects/object_gi_bosskey/object_gi_bosskey.h"
#include "objects/object_gi_hearts/object_gi_hearts.h"
extern "C" void Randomizer_DrawSmallKey(GlobalContext* globalCtx, GetItemEntry* getItemEntry) {
s32 pad;
std::array<s16, 3> color;
switch(getItemEntry->getItemId) {
case RG_FOREST_TEMPLE_SMALL_KEY:
color = {4, 195, 46};
break;
case RG_FIRE_TEMPLE_SMALL_KEY:
color = {237, 95, 95};
break;
case RG_WATER_TEMPLE_SMALL_KEY:
color = {85, 180, 223};
break;
case RG_SPIRIT_TEMPLE_SMALL_KEY:
color = {222, 158, 47};
break;
case RG_SHADOW_TEMPLE_SMALL_KEY:
color = {126, 16, 177};
break;
case RG_GERUDO_TRAINING_GROUNDS_SMALL_KEY:
color = {221, 212, 60};
break;
case RG_BOTTOM_OF_THE_WELL_SMALL_KEY:
color = {227, 110, 255};
break;
case RG_GANONS_CASTLE_SMALL_KEY:
color = {80, 80, 80};
break;
}
s16 color_slot = getItemEntry->getItemId - RG_FOREST_TEMPLE_SMALL_KEY;
s16 colors[8][3] = {
{ 4, 195, 46 }, // Forest Temple
{ 237, 95, 95 }, // Fire Temple
{ 85, 180, 223 }, // Water Temple
{ 222, 158, 47 }, // Spirit Temple
{ 126, 16, 177 }, // Shadow Temple
{ 221, 212, 60 }, // Gerudo Training Grounds
{ 227, 110, 255 }, // Bottom of the Well
{ 80, 80, 80 } // Ganon's Castle
};
OPEN_DISPS(globalCtx->state.gfxCtx);
@ -45,10 +30,7 @@ extern "C" void Randomizer_DrawSmallKey(GlobalContext* globalCtx, GetItemEntry*
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__),
G_MTX_MODELVIEW | G_MTX_LOAD);
gsDPSetGrayscaleColor(POLY_OPA_DISP++, color[0], color[1], color[2], 255);
gsDPSetGrayscaleColor(POLY_OPA_DISP++, colors[color_slot][0], colors[color_slot][1], colors[color_slot][2], 255);
gsSPGrayscale(POLY_OPA_DISP++, true);
gSPDisplayList(POLY_OPA_DISP++, (Gfx*)gGiSmallKeyDL);
@ -74,8 +56,6 @@ extern "C" void Randomizer_DrawBossKey(GlobalContext* globalCtx, GetItemEntry* g
OPEN_DISPS(globalCtx->state.gfxCtx);
func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__),
G_MTX_MODELVIEW | G_MTX_LOAD);
@ -92,8 +72,6 @@ extern "C" void Randomizer_DrawBossKey(GlobalContext* globalCtx, GetItemEntry* g
}
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__),
G_MTX_MODELVIEW | G_MTX_LOAD);
@ -112,3 +90,27 @@ extern "C" void Randomizer_DrawBossKey(GlobalContext* globalCtx, GetItemEntry* g
CLOSE_DISPS(globalCtx->state.gfxCtx);
}
extern "C" void Randomizer_DrawDoubleDefense(GlobalContext* globalCtx, GetItemEntry getItemEntry) {
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx);
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, (char*)__FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD);
// if (drawId == doubleDef) {
gsDPSetGrayscaleColor(POLY_XLU_DISP++, 255, 255, 255, 255);
gsSPGrayscale(POLY_XLU_DISP++, true);
// }
gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gGiHeartBorderDL);
// if (drawId == doubleDef) {
gsSPGrayscale(POLY_XLU_DISP++, false);
// }
gSPDisplayList(POLY_XLU_DISP++, (Gfx*)gGiHeartContainerDL);
CLOSE_DISPS(globalCtx->state.gfxCtx);
}

View File

@ -8,5 +8,6 @@ typedef struct GlobalContext GlobalContext;
extern "C" void Randomizer_DrawSmallKey(GlobalContext* globalCtx, GetItemEntry* getItemEntry);
extern "C" void Randomizer_DrawBossKey(GlobalContext* globalCtx, GetItemEntry* getItemEntry);
extern "C" void Randomizer_DrawDoubleDefense(GlobalContext* globalCtx, GetItemEntry getItemEntry);
#endif

View File

@ -3894,6 +3894,8 @@ void InitRandoItemTable() {
randoGetItemTable[i].drawFunc = (CustomDrawFunc)Randomizer_DrawSmallKey;
} else if (randoGetItemTable[i].itemId >= RG_FOREST_TEMPLE_BOSS_KEY && randoGetItemTable[i].itemId <= RG_GANONS_CASTLE_BOSS_KEY) {
randoGetItemTable[i].drawFunc = (CustomDrawFunc)Randomizer_DrawBossKey;
} else if (randoGetItemTable[i].itemId == RG_DOUBLE_DEFENSE) {
randoGetItemTable[i].drawFunc = (CustomDrawFunc)Randomizer_DrawDoubleDefense;
}
ItemTableManager::Instance->AddItemEntry(MOD_RANDOMIZER, randoGetItemTable[i].itemId, randoGetItemTable[i]);
}

View File

@ -395,6 +395,18 @@ void GetItem_Draw(GlobalContext* globalCtx, s16 drawId) {
sDrawItemTable[drawId].drawFunc(globalCtx, drawId);
}
/**
* Draw "Get Item" Model from a `GetItemEntry`
* Uses the Custom Draw Function if it exists, or just calls `GetItem_Draw`
*/
void GetItemEntry_Draw(GlobalContext* globalCtx, GetItemEntry getItemEntry) {
if (getItemEntry.drawFunc != NULL) {
getItemEntry.drawFunc(globalCtx, &getItemEntry);
} else {
GetItem_Draw(globalCtx, getItemEntry.gid);
}
}
// All remaining functions in this file are draw functions referenced in the table and called by the function above
/* 0x0178 */ u8 primXluColor[3];

View File

@ -1272,7 +1272,7 @@ void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, GetI
color_slot = 0;
break;
case RG_DOUBLE_DEFENSE:
color_slot = 1;
color_slot = 8;
break;
default:
return;
@ -1284,14 +1284,14 @@ void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, GetI
s16* colors[9][3] = {
{ 34, 255, 76 }, // Minuet and Magic Upgrades Colors
{ 177, 35, 35 }, // Bolero and Double Defense Colors
{ 177, 35, 35 }, // Bolero Colors
{ 115, 251, 253 }, // Serenade Color
{ 177, 122, 35 }, // Requiem Color
{ 177, 28, 212 }, // Nocturne Color
{ 255, 255, 92 }, // Prelude Color
{ 31, 152, 49 }, // Stick Upgrade Color
{ 222, 182, 20 }, // Nut Upgrade Color
{ 255, 255, 255 } // White Color placeholder
{ 255, 255, 255 } // Double Defense Color
};
s16* colorsEnv[9][3] = {
@ -1360,11 +1360,7 @@ void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx) {
GetItemEntry randoGetItemEntry =
Randomizer_GetRandomizedItem(this->getItemId, this->actor.id, this->ogParams, globalCtx->sceneNum);
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItemEntry);
if (randoGetItemEntry.drawFunc != NULL) {
randoGetItemEntry.drawFunc(globalCtx, &randoGetItemEntry);
} else {
GetItem_Draw(globalCtx, randoGetItemEntry.gid);
}
GetItemEntry_Draw(globalCtx, randoGetItemEntry);
} else {
s32 texIndex = this->actor.params - 3;
@ -1423,11 +1419,7 @@ void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) {
GetItemEntry randoGetItemEntry =
Randomizer_GetRandomizedItem(GI_HEART_PIECE, this->actor.id, this->ogParams, globalCtx->sceneNum);
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItemEntry);
if (randoGetItemEntry.drawFunc != NULL) {
randoGetItemEntry.drawFunc(globalCtx, &randoGetItemEntry);
} else {
GetItem_Draw(globalCtx, randoGetItemEntry.gid);
}
GetItemEntry_Draw(globalCtx, randoGetItemEntry);
} else {
s32 pad;

View File

@ -2089,6 +2089,10 @@ void DemoEffect_DrawGetItem(Actor* thisx, GlobalContext* globalCtx) {
if (gSaveContext.n64ddFlag && globalCtx->sceneNum == SCENE_BDAN) {
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(RC_BARINADE, RG_ZORA_SAPPHIRE);
this->getItem.drawId = getItemEntry.gid;
func_8002EBCC(thisx, globalCtx, 0);
func_8002ED80(thisx, globalCtx, 0);
GetItemEntry_Draw(globalCtx, getItemEntry);
return;
}
func_8002EBCC(thisx, globalCtx, 0);
func_8002ED80(thisx, globalCtx, 0);

View File

@ -524,6 +524,8 @@ void EnExItem_DrawItems(EnExItem* this, GlobalContext* globalCtx) {
}
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItem);
GetItemEntry_Draw(globalCtx, randoGetItem);
return;
}
GetItem_Draw(globalCtx, this->giDrawId);
@ -536,7 +538,7 @@ void EnExItem_DrawHeartPiece(EnExItem* this, GlobalContext* globalCtx) {
GetItemEntry randoGetItem =
Randomizer_GetItemFromKnownCheck(RC_MARKET_BOMBCHU_BOWLING_SECOND_PRIZE, GI_HEART_PIECE);
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItem);
GetItem_Draw(globalCtx, randoGetItem.gid);
GetItemEntry_Draw(globalCtx, randoGetItem);
} else {
GetItem_Draw(globalCtx, GID_HEART_PIECE);
}

View File

@ -184,7 +184,7 @@ void EnSi_Draw(Actor* thisx, GlobalContext* globalCtx) {
f32 mtxScale = 1.5f;
Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY);
}
GetItem_Draw(globalCtx, getItem.gid);
GetItemEntry_Draw(globalCtx, getItem);
}
}

View File

@ -99,8 +99,8 @@ void ItemBHeart_Draw(Actor* thisx, GlobalContext* globalCtx) {
}
if (gSaveContext.n64ddFlag) {
GetItem_Draw(globalCtx, Randomizer_GetRandomizedItem(GI_HEART_CONTAINER_2,
this->actor.id,this->actor.params, globalCtx->sceneNum).gid);
GetItemEntry_Draw(globalCtx, Randomizer_GetRandomizedItem(GI_HEART_CONTAINER_2,
this->actor.id,this->actor.params, globalCtx->sceneNum));
} else {
if (flag) {
func_80093D84(globalCtx->state.gfxCtx);

View File

@ -233,7 +233,7 @@ void ItemEtcetera_DrawThroughLens(Actor* thisx, GlobalContext* globalCtx) {
GetItemEntry randoGetItem = GetChestGameRandoGetItem(this->actor.room, this->giDrawId, globalCtx);
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItem);
if (randoGetItem.itemId != ITEM_NONE) {
GetItem_Draw(globalCtx, randoGetItem.gid);
GetItemEntry_Draw(globalCtx, randoGetItem);
return;
}
}
@ -257,7 +257,10 @@ void ItemEtcetera_Draw(Actor* thisx, GlobalContext* globalCtx) {
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItem);
if (randoGetItem.itemId != RG_NONE) {
this->giDrawId = randoGetItem.gid;
func_8002EBCC(&this->actor, globalCtx, 0);
func_8002ED80(&this->actor, globalCtx, 0);
GetItemEntry_Draw(globalCtx, randoGetItem);
return;
}
}

View File

@ -218,7 +218,7 @@ void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx) {
if (gSaveContext.n64ddFlag) {
GetItemEntry randoGetItem = Randomizer_GetItemFromKnownCheck(RC_HF_OCARINA_OF_TIME_ITEM, GI_OCARINA_OOT);
EnItem00_CustomItemsParticles(&this->actor, globalCtx, randoGetItem);
GetItem_Draw(globalCtx, randoGetItem.gid);
GetItemEntry_Draw(globalCtx, randoGetItem);
return;
}