1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 15:55:59 +00:00
oot/src/code/z_lifemeter.c

542 lines
21 KiB
C
Raw Normal View History

#include "global.h"
Decompile Gameplay_Keep and fix all existing decompiled objects (#595) * First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2021-01-25 00:36:40 +00:00
#include "textures/parameter_static/parameter_static.h"
2020-03-17 04:31:30 +00:00
2021-02-24 20:42:25 +00:00
static s16 sHeartsPrimColors[3][3] = {
{ HEARTS_PRIM_R, HEARTS_PRIM_G, HEARTS_PRIM_B },
{ HEARTS_BURN_PRIM_R, HEARTS_BURN_PRIM_G, HEARTS_BURN_PRIM_B }, // unused
{ HEARTS_DROWN_PRIM_R, HEARTS_DROWN_PRIM_G, HEARTS_DROWN_PRIM_B }, // unused
};
static s16 sHeartsEnvColors[3][3] = {
{ HEARTS_ENV_R, HEARTS_ENV_G, HEARTS_ENV_B },
{ HEARTS_BURN_ENV_R, HEARTS_BURN_ENV_G }, // unused
{ HEARTS_DROWN_ENV_R, HEARTS_DROWN_ENV_G, HEARTS_DROWN_ENV_B }, // unused
2021-02-24 20:42:25 +00:00
};
static s16 sHeartsPrimFactors[3][3] = {
{
HEARTS_PRIM_R - HEARTS_PRIM_R,
HEARTS_PRIM_G - HEARTS_PRIM_G,
HEARTS_PRIM_B - HEARTS_PRIM_B,
},
// unused
{
HEARTS_BURN_PRIM_R - HEARTS_PRIM_R,
HEARTS_BURN_PRIM_G - HEARTS_PRIM_G,
HEARTS_BURN_PRIM_B - HEARTS_PRIM_B,
},
// unused
{
HEARTS_DROWN_PRIM_R - HEARTS_PRIM_R,
HEARTS_DROWN_PRIM_G - HEARTS_PRIM_G,
HEARTS_DROWN_PRIM_B - HEARTS_PRIM_B,
},
};
static s16 sHeartsEnvFactors[3][3] = {
{
HEARTS_ENV_R - HEARTS_ENV_R,
HEARTS_ENV_G - HEARTS_ENV_G,
HEARTS_ENV_B - HEARTS_ENV_B,
},
// unused
{
HEARTS_BURN_ENV_R - HEARTS_ENV_R,
HEARTS_BURN_ENV_G - HEARTS_ENV_G,
HEARTS_BURN_ENV_B - HEARTS_ENV_B,
},
// unused
{
HEARTS_DROWN_ENV_R - HEARTS_ENV_R,
HEARTS_DROWN_ENV_G - HEARTS_ENV_G,
HEARTS_DROWN_ENV_B - HEARTS_ENV_B,
},
};
static s16 sHeartsDDPrimColors[3][3] = {
{ HEARTS_DD_PRIM_R, HEARTS_DD_PRIM_G, HEARTS_DD_PRIM_B },
{ HEARTS_BURN_PRIM_R, HEARTS_BURN_PRIM_G, HEARTS_BURN_PRIM_B }, // unused
{ HEARTS_DROWN_PRIM_R, HEARTS_DROWN_PRIM_G, HEARTS_DROWN_PRIM_B }, // unused
};
static s16 sHeartsDDEnvColors[3][3] = {
{ HEARTS_DD_ENV_R, HEARTS_DD_ENV_G, HEARTS_DD_ENV_B },
{ HEARTS_BURN_ENV_R, HEARTS_BURN_ENV_G, HEARTS_BURN_ENV_B }, // unused
{ HEARTS_DROWN_ENV_R, HEARTS_DROWN_ENV_G, HEARTS_DROWN_ENV_B }, // unused
};
static s16 sHeartsDDPrimFactors[3][3] = {
{
HEARTS_DD_PRIM_R - HEARTS_DD_PRIM_R,
HEARTS_DD_PRIM_G - HEARTS_DD_PRIM_G,
HEARTS_DD_PRIM_B - HEARTS_DD_PRIM_B,
},
// unused
{
HEARTS_BURN_PRIM_R - HEARTS_DD_PRIM_R,
HEARTS_BURN_PRIM_G - HEARTS_DD_PRIM_G,
HEARTS_BURN_PRIM_B - HEARTS_DD_PRIM_B,
},
// unused
{
HEARTS_DROWN_PRIM_R - HEARTS_DD_PRIM_R,
HEARTS_DROWN_PRIM_G - HEARTS_DD_PRIM_G,
HEARTS_DROWN_PRIM_B - HEARTS_DD_PRIM_B,
},
};
static s16 sHeartsDDEnvFactors[3][3] = {
{
HEARTS_DD_ENV_R - HEARTS_DD_ENV_R,
HEARTS_DD_ENV_G - HEARTS_DD_ENV_G,
HEARTS_DD_ENV_B - HEARTS_DD_ENV_B,
},
// unused
{
HEARTS_BURN_ENV_R - HEARTS_DD_ENV_R,
HEARTS_BURN_ENV_G - HEARTS_DD_ENV_G,
HEARTS_BURN_ENV_B - HEARTS_DD_ENV_B,
},
// unused
{
HEARTS_DROWN_ENV_R - HEARTS_DD_ENV_R,
HEARTS_DROWN_ENV_G - HEARTS_DD_ENV_G,
HEARTS_DROWN_ENV_B - HEARTS_DD_ENV_B,
},
};
// Current colors for the double defense hearts
s16 sBeatingHeartsDDPrim[3];
s16 sBeatingHeartsDDEnv[3];
s16 sHeartsDDPrim[2][3];
s16 sHeartsDDEnv[2][3];
void Health_InitMeter(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
2020-03-17 04:31:30 +00:00
interfaceCtx->unk_228 = 0x140;
interfaceCtx->unk_226 = gSaveContext.health;
interfaceCtx->beatingHeartOscillator = interfaceCtx->heartColorOscillator = 0;
interfaceCtx->beatingHeartOscillatorDirection = interfaceCtx->heartColorOscillatorDirection = 0;
2020-03-17 04:31:30 +00:00
interfaceCtx->heartsPrimR[0] = HEARTS_PRIM_R;
interfaceCtx->heartsPrimG[0] = HEARTS_PRIM_G;
interfaceCtx->heartsPrimB[0] = HEARTS_PRIM_B;
interfaceCtx->heartsEnvR[0] = HEARTS_ENV_R;
interfaceCtx->heartsEnvG[0] = HEARTS_ENV_G;
interfaceCtx->heartsEnvB[0] = HEARTS_ENV_B;
interfaceCtx->heartsPrimR[1] = HEARTS_PRIM_R;
interfaceCtx->heartsPrimG[1] = HEARTS_PRIM_G;
interfaceCtx->heartsPrimB[1] = HEARTS_PRIM_B;
interfaceCtx->heartsEnvR[1] = HEARTS_ENV_R;
interfaceCtx->heartsEnvG[1] = HEARTS_ENV_G;
interfaceCtx->heartsEnvB[1] = HEARTS_ENV_B;
sHeartsDDPrim[0][0] = sHeartsDDPrim[1][0] = HEARTS_DD_PRIM_R;
sHeartsDDPrim[0][1] = sHeartsDDPrim[1][1] = HEARTS_DD_PRIM_G;
sHeartsDDPrim[0][2] = sHeartsDDPrim[1][2] = HEARTS_DD_PRIM_B;
sHeartsDDEnv[0][0] = sHeartsDDEnv[1][0] = HEARTS_DD_ENV_R;
sHeartsDDEnv[0][1] = sHeartsDDEnv[1][1] = HEARTS_DD_ENV_G;
sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = HEARTS_DD_ENV_B;
2020-03-17 04:31:30 +00:00
}
void Health_UpdateMeter(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
f32 factor = interfaceCtx->heartColorOscillator * 0.1f;
f32 ddFactor;
s32 type = 0;
s32 ddType;
s16 rFactor;
s16 gFactor;
s16 bFactor;
2020-03-17 04:31:30 +00:00
if (interfaceCtx) {}
if (interfaceCtx->heartColorOscillatorDirection != 0) {
interfaceCtx->heartColorOscillator--;
if (interfaceCtx->heartColorOscillator <= 0) {
interfaceCtx->heartColorOscillator = 0;
interfaceCtx->heartColorOscillatorDirection = 0;
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
} else {
interfaceCtx->heartColorOscillator++;
if (interfaceCtx->heartColorOscillator >= 10) {
interfaceCtx->heartColorOscillator = 10;
interfaceCtx->heartColorOscillatorDirection = 1;
2020-03-17 04:31:30 +00:00
}
}
ddFactor = factor;
interfaceCtx->heartsPrimR[0] = HEARTS_PRIM_R;
interfaceCtx->heartsPrimG[0] = HEARTS_PRIM_G;
interfaceCtx->heartsPrimB[0] = HEARTS_PRIM_B;
interfaceCtx->heartsEnvR[0] = HEARTS_ENV_R;
interfaceCtx->heartsEnvG[0] = HEARTS_ENV_G;
interfaceCtx->heartsEnvB[0] = HEARTS_ENV_B;
interfaceCtx->heartsPrimR[1] = sHeartsPrimColors[type][0];
interfaceCtx->heartsPrimG[1] = sHeartsPrimColors[type][1];
interfaceCtx->heartsPrimB[1] = sHeartsPrimColors[type][2];
interfaceCtx->heartsEnvR[1] = sHeartsEnvColors[type][0];
interfaceCtx->heartsEnvG[1] = sHeartsEnvColors[type][1];
interfaceCtx->heartsEnvB[1] = sHeartsEnvColors[type][2];
rFactor = sHeartsPrimFactors[0][0] * factor;
gFactor = sHeartsPrimFactors[0][1] * factor;
bFactor = sHeartsPrimFactors[0][2] * factor;
interfaceCtx->beatingHeartPrim[0] = (u8)(rFactor + HEARTS_PRIM_R) & 0xFF;
interfaceCtx->beatingHeartPrim[1] = (u8)(gFactor + HEARTS_PRIM_G) & 0xFF;
interfaceCtx->beatingHeartPrim[2] = (u8)(bFactor + HEARTS_PRIM_B) & 0xFF;
rFactor = sHeartsEnvFactors[0][0] * factor;
gFactor = sHeartsEnvFactors[0][1] * factor;
bFactor = sHeartsEnvFactors[0][2] * factor;
if (1) {}
ddType = type;
interfaceCtx->beatingHeartEnv[0] = (u8)(rFactor + HEARTS_ENV_R) & 0xFF;
interfaceCtx->beatingHeartEnv[1] = (u8)(gFactor + HEARTS_ENV_G) & 0xFF;
interfaceCtx->beatingHeartEnv[2] = (u8)(bFactor + HEARTS_ENV_B) & 0xFF;
sHeartsDDPrim[0][0] = HEARTS_DD_PRIM_R;
sHeartsDDPrim[0][1] = HEARTS_DD_PRIM_G;
sHeartsDDPrim[0][2] = HEARTS_DD_PRIM_B;
sHeartsDDEnv[0][0] = HEARTS_DD_ENV_R;
sHeartsDDEnv[0][1] = HEARTS_DD_ENV_G;
sHeartsDDEnv[0][2] = HEARTS_DD_ENV_B;
sHeartsDDPrim[1][0] = sHeartsDDPrimColors[ddType][0];
sHeartsDDPrim[1][1] = sHeartsDDPrimColors[ddType][1];
sHeartsDDPrim[1][2] = sHeartsDDPrimColors[ddType][2];
sHeartsDDEnv[1][0] = sHeartsDDEnvColors[ddType][0];
sHeartsDDEnv[1][1] = sHeartsDDEnvColors[ddType][1];
sHeartsDDEnv[1][2] = sHeartsDDEnvColors[ddType][2];
rFactor = sHeartsDDPrimFactors[ddType][0] * ddFactor;
gFactor = sHeartsDDPrimFactors[ddType][1] * ddFactor;
bFactor = sHeartsDDPrimFactors[ddType][2] * ddFactor;
sBeatingHeartsDDPrim[0] = (u8)(rFactor + HEARTS_DD_PRIM_R) & 0xFF;
sBeatingHeartsDDPrim[1] = (u8)(gFactor + HEARTS_DD_PRIM_G) & 0xFF;
sBeatingHeartsDDPrim[2] = (u8)(bFactor + HEARTS_DD_PRIM_B) & 0xFF;
rFactor = sHeartsDDEnvFactors[ddType][0] * ddFactor;
gFactor = sHeartsDDEnvFactors[ddType][1] * ddFactor;
bFactor = sHeartsDDEnvFactors[ddType][2] * ddFactor;
sBeatingHeartsDDEnv[0] = (u8)(rFactor + HEARTS_DD_ENV_R) & 0xFF;
sBeatingHeartsDDEnv[1] = (u8)(gFactor + HEARTS_DD_ENV_G) & 0xFF;
sBeatingHeartsDDEnv[2] = (u8)(bFactor + HEARTS_DD_ENV_B) & 0xFF;
2020-03-17 04:31:30 +00:00
}
// Unused
s32 func_80078E18(PlayState* play) {
gSaveContext.health = play->interfaceCtx.unk_226;
2020-03-17 04:31:30 +00:00
return 1;
}
// Unused
s32 func_80078E34(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
2020-03-17 04:31:30 +00:00
interfaceCtx->unk_228 = 0x140;
interfaceCtx->unk_226 += 0x10;
2020-03-22 21:19:43 +00:00
if (interfaceCtx->unk_226 >= gSaveContext.health) {
2020-03-17 04:31:30 +00:00
interfaceCtx->unk_226 = gSaveContext.health;
return 1;
}
return 0;
}
// Unused
s32 func_80078E84(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (interfaceCtx->unk_228 != 0) {
2020-03-17 04:31:30 +00:00
interfaceCtx->unk_228--;
2020-03-22 21:19:43 +00:00
} else {
2020-03-17 04:31:30 +00:00
interfaceCtx->unk_228 = 0x140;
interfaceCtx->unk_226 -= 0x10;
2020-03-22 21:19:43 +00:00
if (interfaceCtx->unk_226 <= 0) {
2020-03-17 04:31:30 +00:00
interfaceCtx->unk_226 = 0;
play->damagePlayer(play, -(gSaveContext.health + 1));
2020-03-17 04:31:30 +00:00
return 1;
}
}
return 0;
}
static void* sHeartTextures[] = {
gHeartFullTex, gHeartQuarterTex, gHeartQuarterTex, gHeartQuarterTex,
gHeartQuarterTex, gHeartQuarterTex, gHeartHalfTex, gHeartHalfTex,
gHeartHalfTex, gHeartHalfTex, gHeartHalfTex, gHeartThreeQuarterTex,
gHeartThreeQuarterTex, gHeartThreeQuarterTex, gHeartThreeQuarterTex, gHeartThreeQuarterTex,
Decompile Gameplay_Keep and fix all existing decompiled objects (#595) * First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2021-01-25 00:36:40 +00:00
};
static void* sHeartDDTextures[] = {
gDefenseHeartFullTex, gDefenseHeartQuarterTex, gDefenseHeartQuarterTex,
gDefenseHeartQuarterTex, gDefenseHeartQuarterTex, gDefenseHeartQuarterTex,
gDefenseHeartHalfTex, gDefenseHeartHalfTex, gDefenseHeartHalfTex,
gDefenseHeartHalfTex, gDefenseHeartHalfTex, gDefenseHeartThreeQuarterTex,
gDefenseHeartThreeQuarterTex, gDefenseHeartThreeQuarterTex, gDefenseHeartThreeQuarterTex,
gDefenseHeartThreeQuarterTex,
Decompile Gameplay_Keep and fix all existing decompiled objects (#595) * First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2021-01-25 00:36:40 +00:00
};
void Health_DrawMeter(PlayState* play) {
2020-03-17 04:31:30 +00:00
s32 pad[5];
void* heartBgImg;
2020-03-17 04:31:30 +00:00
u32 curColorSet;
f32 offsetX;
f32 offsetY;
s32 heartIndex;
f32 halfHeartLength;
f32 heartCenterX;
f32 heartCenterY;
f32 heartTexCoordPerPixel;
InterfaceContext* interfaceCtx = &play->interfaceCtx;
GraphicsContext* gfxCtx = play->state.gfxCtx;
Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx;
2020-03-17 04:31:30 +00:00
s32 curHeartFraction = gSaveContext.health % 0x10;
s16 totalHeartCount = gSaveContext.healthCapacity / 0x10;
2020-03-17 04:31:30 +00:00
s16 fullHeartCount = gSaveContext.health / 0x10;
s32 pad2;
f32 beatingHeartPulsingSize = interfaceCtx->beatingHeartOscillator * 0.1f;
2020-03-17 04:31:30 +00:00
s32 curCombineModeSet = 0;
u8* curBgImgLoaded = NULL;
s32 ddHeartCountMinusOne = gSaveContext.inventory.defenseHearts - 1;
2020-03-17 04:31:30 +00:00
OPEN_DISPS(gfxCtx, "../z_lifemeter.c", 353);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
if (!(gSaveContext.health % 0x10)) {
2020-03-17 04:31:30 +00:00
fullHeartCount--;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
curColorSet = -1;
offsetY = 0.0f;
offsetX = 0.0f;
for (heartIndex = 0; heartIndex < totalHeartCount; heartIndex++) {
if ((ddHeartCountMinusOne < 0) || (heartIndex > ddHeartCountMinusOne)) {
if (heartIndex < fullHeartCount) {
2020-03-22 21:19:43 +00:00
if (curColorSet != 0) {
2020-03-17 04:31:30 +00:00
curColorSet = 0;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->heartsPrimR[0], interfaceCtx->heartsPrimG[0],
interfaceCtx->heartsPrimB[0], interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->heartsEnvR[0], interfaceCtx->heartsEnvG[0],
interfaceCtx->heartsEnvB[0], 255);
2020-03-17 04:31:30 +00:00
}
} else if (heartIndex == fullHeartCount) {
2020-03-22 21:19:43 +00:00
if (curColorSet != 1) {
2020-03-17 04:31:30 +00:00
curColorSet = 1;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->beatingHeartPrim[0],
interfaceCtx->beatingHeartPrim[1], interfaceCtx->beatingHeartPrim[2],
interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->beatingHeartEnv[0], interfaceCtx->beatingHeartEnv[1],
interfaceCtx->beatingHeartEnv[2], 255);
2020-03-17 04:31:30 +00:00
}
} else if (heartIndex > fullHeartCount) {
2020-03-22 21:19:43 +00:00
if (curColorSet != 2) {
2020-03-17 04:31:30 +00:00
curColorSet = 2;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->heartsPrimR[0], interfaceCtx->heartsPrimG[0],
interfaceCtx->heartsPrimB[0], interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->heartsEnvR[0], interfaceCtx->heartsEnvG[0],
interfaceCtx->heartsEnvB[0], 255);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
} else {
if (curColorSet != 3) {
2020-03-17 04:31:30 +00:00
curColorSet = 3;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, interfaceCtx->heartsPrimR[1], interfaceCtx->heartsPrimG[1],
interfaceCtx->heartsPrimB[1], interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, interfaceCtx->heartsEnvR[1], interfaceCtx->heartsEnvG[1],
interfaceCtx->heartsEnvB[1], 255);
2020-03-17 04:31:30 +00:00
}
}
if (heartIndex < fullHeartCount) {
heartBgImg = gHeartFullTex;
} else if (heartIndex == fullHeartCount) {
heartBgImg = sHeartTextures[curHeartFraction];
2020-03-22 21:19:43 +00:00
} else {
heartBgImg = gHeartEmptyTex;
2020-03-22 21:19:43 +00:00
}
} else {
if (heartIndex < fullHeartCount) {
2020-03-22 21:19:43 +00:00
if (curColorSet != 4) {
2020-03-17 04:31:30 +00:00
curColorSet = 4;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0][0], sHeartsDDPrim[0][1], sHeartsDDPrim[0][2],
interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0][0], sHeartsDDEnv[0][1], sHeartsDDEnv[0][2], 255);
2020-03-17 04:31:30 +00:00
}
} else if (heartIndex == fullHeartCount) {
2020-03-22 21:19:43 +00:00
if (curColorSet != 5) {
2020-03-17 04:31:30 +00:00
curColorSet = 5;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sBeatingHeartsDDPrim[0], sBeatingHeartsDDPrim[1],
sBeatingHeartsDDPrim[2], interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, sBeatingHeartsDDEnv[0], sBeatingHeartsDDEnv[1],
sBeatingHeartsDDEnv[2], 255);
2020-03-17 04:31:30 +00:00
}
} else if (heartIndex > fullHeartCount) {
2020-03-22 21:19:43 +00:00
if (curColorSet != 6) {
2020-03-17 04:31:30 +00:00
curColorSet = 6;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[0][0], sHeartsDDPrim[0][1], sHeartsDDPrim[0][2],
interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[0][0], sHeartsDDEnv[0][1], sHeartsDDEnv[0][2], 255);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
} else {
if (curColorSet != 7) {
2020-03-17 04:31:30 +00:00
curColorSet = 7;
gDPPipeSync(OVERLAY_DISP++);
gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sHeartsDDPrim[1][0], sHeartsDDPrim[1][1], sHeartsDDPrim[1][2],
interfaceCtx->healthAlpha);
gDPSetEnvColor(OVERLAY_DISP++, sHeartsDDEnv[1][0], sHeartsDDEnv[1][1], sHeartsDDEnv[1][2], 255);
2020-03-17 04:31:30 +00:00
}
}
if (heartIndex < fullHeartCount) {
heartBgImg = gDefenseHeartFullTex;
} else if (heartIndex == fullHeartCount) {
heartBgImg = sHeartDDTextures[curHeartFraction];
2020-03-22 21:19:43 +00:00
} else {
heartBgImg = gDefenseHeartEmptyTex;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
if (curBgImgLoaded != heartBgImg) {
2020-03-17 04:31:30 +00:00
curBgImgLoaded = heartBgImg;
gDPLoadTextureBlock(OVERLAY_DISP++, heartBgImg, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 16, 0,
2020-03-22 21:19:43 +00:00
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
2020-03-17 04:31:30 +00:00
G_TX_NOLOD, G_TX_NOLOD);
}
if (heartIndex != fullHeartCount) {
if ((ddHeartCountMinusOne < 0) || (heartIndex > ddHeartCountMinusOne)) {
2020-03-22 21:19:43 +00:00
if (curCombineModeSet != 1) {
2020-03-17 04:31:30 +00:00
curCombineModeSet = 1;
func_80094520(gfxCtx);
gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE,
0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
} else {
if (curCombineModeSet != 3) {
2020-03-17 04:31:30 +00:00
curCombineModeSet = 3;
func_80094520(gfxCtx);
gDPSetCombineLERP(OVERLAY_DISP++, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE,
0, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0);
2020-03-17 04:31:30 +00:00
}
}
heartCenterY = 26.0f + offsetY;
heartCenterX = 30.0f + offsetX;
heartTexCoordPerPixel = 1.0f;
heartTexCoordPerPixel /= 0.68f;
heartTexCoordPerPixel *= 1 << 10;
halfHeartLength = 8.0f;
halfHeartLength *= 0.68f;
2022-02-12 23:29:48 +00:00
gSPTextureRectangle(OVERLAY_DISP++, (s32)((heartCenterX - halfHeartLength) * 4),
(s32)((heartCenterY - halfHeartLength) * 4),
(s32)((heartCenterX + halfHeartLength) * 4),
(s32)((heartCenterY + halfHeartLength) * 4), G_TX_RENDERTILE, 0, 0,
(s32)heartTexCoordPerPixel, (s32)heartTexCoordPerPixel);
2020-03-22 21:19:43 +00:00
} else {
if ((ddHeartCountMinusOne < 0) || (heartIndex > ddHeartCountMinusOne)) {
2020-03-22 21:19:43 +00:00
if (curCombineModeSet != 2) {
2020-03-17 04:31:30 +00:00
curCombineModeSet = 2;
func_80094A14(gfxCtx);
gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE,
0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
2020-03-17 04:31:30 +00:00
}
2020-03-22 21:19:43 +00:00
} else {
if (curCombineModeSet != 4) {
2020-03-17 04:31:30 +00:00
curCombineModeSet = 4;
func_80094A14(gfxCtx);
gDPSetCombineLERP(OVERLAY_DISP++, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE,
0, ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0);
2020-03-17 04:31:30 +00:00
}
}
{
2020-03-17 04:31:30 +00:00
Mtx* matrix = Graph_Alloc(gfxCtx, sizeof(Mtx));
2022-02-12 23:29:48 +00:00
Matrix_SetTranslateScaleMtx2(
matrix, 1.0f - (0.32f * beatingHeartPulsingSize), 1.0f - (0.32f * beatingHeartPulsingSize),
1.0f - (0.32f * beatingHeartPulsingSize), -130.0f + offsetX, 94.5f - offsetY, 0.0f);
gSPMatrix(OVERLAY_DISP++, matrix, G_MTX_MODELVIEW | G_MTX_LOAD);
gSPVertex(OVERLAY_DISP++, beatingHeartVtx, 4, 0);
gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0);
2020-03-17 04:31:30 +00:00
}
}
// Move offset to next heart
2020-03-17 04:31:30 +00:00
offsetX += 10.0f;
// Go down one line after 10 hearts
if (heartIndex == 9) {
2020-03-17 04:31:30 +00:00
offsetY += 10.0f;
offsetX = 0.0f;
}
}
CLOSE_DISPS(gfxCtx, "../z_lifemeter.c", 606);
2020-03-17 04:31:30 +00:00
}
void Health_UpdateBeatingHeart(PlayState* play) {
InterfaceContext* interfaceCtx = &play->interfaceCtx;
2020-03-17 04:31:30 +00:00
if (interfaceCtx->beatingHeartOscillatorDirection != 0) {
interfaceCtx->beatingHeartOscillator--;
if (interfaceCtx->beatingHeartOscillator <= 0) {
interfaceCtx->beatingHeartOscillator = 0;
interfaceCtx->beatingHeartOscillatorDirection = 0;
if (!Player_InCsMode(play) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) &&
Health_IsCritical() && !Play_InCsMode(play)) {
2020-03-17 04:31:30 +00:00
func_80078884(NA_SE_SY_HITPOINT_ALARM);
}
}
2020-03-22 21:19:43 +00:00
} else {
interfaceCtx->beatingHeartOscillator++;
if (interfaceCtx->beatingHeartOscillator >= 10) {
interfaceCtx->beatingHeartOscillator = 10;
interfaceCtx->beatingHeartOscillatorDirection = 1;
2020-03-17 04:31:30 +00:00
}
}
}
u32 Health_IsCritical(void) {
s32 criticalHealth;
2020-03-17 04:31:30 +00:00
if (gSaveContext.healthCapacity <= 0x50) {
criticalHealth = 0x10;
} else if (gSaveContext.healthCapacity <= 0xA0) {
criticalHealth = 0x18;
} else if (gSaveContext.healthCapacity <= 0xF0) {
criticalHealth = 0x20;
2020-03-22 21:19:43 +00:00
} else {
criticalHealth = 0x2C;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
if ((criticalHealth >= gSaveContext.health) && (gSaveContext.health > 0)) {
return true;
2020-03-22 21:19:43 +00:00
} else {
return false;
2020-03-22 21:19:43 +00:00
}
2020-03-17 04:31:30 +00:00
}