Merge branch 'documented_health' into 'master'

Document health score

See merge request banjo.decomp/banjo-kazooie!90
This commit is contained in:
Banjo Kazooie
2024-10-08 06:10:59 +00:00
11 changed files with 93 additions and 77 deletions

View File

@@ -3932,6 +3932,8 @@ enum asset_e
ASSET_7E6_SPRITE_VILE, ASSET_7E6_SPRITE_VILE,
ASSET_7E7_SPRITE_CROC_BANJO, ASSET_7E7_SPRITE_CROC_BANJO,
ASSET_7EA_SPRITE_RED_HEALTH = 0x7ea,
ASSET_7EE_JOKER_CARD = 0x7ee, ASSET_7EE_JOKER_CARD = 0x7ee,
ASSET_7EF_SPRITE_BANJO, ASSET_7EF_SPRITE_BANJO,
ASSET_7F0_SPRITE_BOTTLES, ASSET_7F0_SPRITE_BOTTLES,

View File

@@ -164,12 +164,14 @@ void func_8033B020(void *ptr){
end_ptr = (struct21s *) vector_getEnd(D_80383CE0[0]); end_ptr = (struct21s *) vector_getEnd(D_80383CE0[0]);
start_ptr = (struct21s *) vector_getBegin(D_80383CE0[0]); start_ptr = (struct21s *) vector_getBegin(D_80383CE0[0]);
for(iPtr = start_ptr; iPtr < end_ptr && ptr != iPtr->unk1; iPtr++);
for (iPtr = start_ptr; iPtr < end_ptr && ptr != iPtr->unk1; iPtr++);
if (iPtr < end_ptr) { if (iPtr < end_ptr) {
iPtr->unk0++; iPtr->unk0++;
} }
else{ else {
iPtr = (struct21s *)vector_pushBackNew(&D_80383CE0[0]); iPtr = (struct21s *) vector_pushBackNew(&D_80383CE0[0]);
iPtr->unk0 = 1; iPtr->unk0 = 1;
iPtr->unk1 = ptr; iPtr->unk1 = ptr;
} }
@@ -463,7 +465,7 @@ void func_8033BD20(BKModelBin **arg0){
*arg0 = NULL; *arg0 = NULL;
} }
void func_8033BD4C(void *arg0){ void assetCache_free(void *arg0){
func_8033B020(arg0); func_8033B020(arg0);
} }

View File

@@ -108,7 +108,7 @@ u8 func_8033FA84(void){
void func_8033FB64(u8 indx){ void func_8033FB64(u8 indx){
if(D_80385000[indx].sprite_0){ if(D_80385000[indx].sprite_0){
func_8033BD4C(D_80385000[indx].sprite_0); assetCache_free(D_80385000[indx].sprite_0);
} }
D_80385000[indx].sprite_0 = NULL; D_80385000[indx].sprite_0 = NULL;
D_80385000[indx].unk28_13 = 0; D_80385000[indx].unk28_13 = 0;
@@ -116,7 +116,7 @@ void func_8033FB64(u8 indx){
void projectile_setSprite(u8 indx, enum asset_e arg1){ void projectile_setSprite(u8 indx, enum asset_e arg1){
if(D_80385000[indx].sprite_0){ if(D_80385000[indx].sprite_0){
func_8033BD4C(D_80385000[indx].sprite_0); assetCache_free(D_80385000[indx].sprite_0);
} }
D_80385000[indx].sprite_0 = assetcache_get(arg1); D_80385000[indx].sprite_0 = assetcache_get(arg1);
} }

View File

@@ -46,7 +46,7 @@ void func_803016F0(void) {
void fxairscore_free(s32 arg0, struct7s *arg1) { void fxairscore_free(s32 arg0, struct7s *arg1) {
if (s_sprite != NULL) { if (s_sprite != NULL) {
func_8033BD4C(s_sprite); assetCache_free(s_sprite);
s_sprite = NULL; s_sprite = NULL;
} }
func_803016F0(); func_803016F0();

View File

@@ -308,7 +308,7 @@ void fxcommon2score_draw(enum item_e item_id, struct8s *arg1, Gfx **gfx, Mtx **m
void fxcommon2score_free(enum item_e item_id, struct8s *arg1){ void fxcommon2score_free(enum item_e item_id, struct8s *arg1){
if(arg1->unk50){ if(arg1->unk50){
func_8033BD4C(arg1->unk50); //assetCache_free assetCache_free(arg1->unk50); //assetCache_free
arg1->unk50 = NULL; arg1->unk50 = NULL;
} }
} }

View File

@@ -226,7 +226,7 @@ void fxcommon3score_free(enum item_e item_id, void *arg1){
} }
if(a1->model != NULL){ if(a1->model != NULL){
func_8033BD4C(a1->model); assetCache_free(a1->model);
a1->model = NULL; a1->model = NULL;
a1->unk6C = 0.0f; a1->unk6C = 0.0f;
} }

View File

@@ -10,8 +10,8 @@ extern s32 framebuffer_width;
extern s32 framebuffer_height; extern s32 framebuffer_height;
/* .data */ /* .data */
BKSprite * D_8036A910 = NULL; BKSprite * gSpriteHealth = NULL;
BKSprite * D_8036A914 = NULL; BKSprite * gSpriteRedHealth = NULL;
Gfx D_8036A918[] = { Gfx D_8036A918[] = {
gsDPPipeSync(), gsDPPipeSync(),
gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
@@ -28,8 +28,8 @@ s32 D_80381EF0;
f32 D_80381EF4; f32 D_80381EF4;
f32 D_80381EF8; f32 D_80381EF8;
f32 D_80381EFC; f32 D_80381EFC;
s32 D_80381F00; s32 gTotalHealth;
f32 D_80381F04; f32 gHealth;
f32 D_80381F08[8]; f32 D_80381F08[8];
f32 D_80381F28; f32 D_80381F28;
f32 D_80381F2C; f32 D_80381F2C;
@@ -48,17 +48,16 @@ void func_80300C10(void) {
} }
void fxhealthscore_free(enum item_e item_id, struct8s *arg1){ void fxhealthscore_free(enum item_e item_id, struct8s *arg1){
s32 temp_a0; if (gSpriteHealth != NULL) {
s32 temp_a0_2; assetCache_free(gSpriteHealth);
gSpriteHealth = NULL;
}
if (D_8036A910 != 0) { if (gSpriteRedHealth != NULL) {
func_8033BD4C(D_8036A910); assetCache_free(gSpriteRedHealth);
D_8036A910 = 0; gSpriteRedHealth = NULL;
}
if (D_8036A914 != 0) {
func_8033BD4C(D_8036A914);
D_8036A914 = 0;
} }
func_80300C10(); func_80300C10();
} }
@@ -68,61 +67,72 @@ struct7s *fxhealthscore_new(enum item_e item_id){
return &D_80381F30; return &D_80381F30;
} }
void fxhealthscore_draw(enum item_e item_id, struct8s *arg1, Gfx **gfx, Mtx **mtx, Vtx **vtx){ void fxhealthscore_draw(enum item_e item_id, struct8s *arg1, Gfx **gfx, Mtx **mtx, Vtx **vtx) {
int i; int i;
int tmp_v1; int tmp_v1;
s32 spEC; s32 honeycomb_width;
s32 spE8; s32 honeycomb_height;
int tmp_v0; int tmp_v0;
f32 f18; f32 f18;
f32 f14; f32 f14;
f32 f20; f32 f20;
s32 spD4 = 0; s32 is_red_health_initialized = FALSE;
s32 s6; s32 s6;
if(D_8036A910 == NULL) return; if (gSpriteHealth == NULL) {
return;
}
gSPDisplayList((*gfx)++, D_8036A918); gSPDisplayList((*gfx)++, D_8036A918);
func_80347FC0(gfx, D_8036A910, 0, 0, 0, 0, 0, 2, 2, &spEC, &spE8); func_80347FC0(gfx, gSpriteHealth, 0, 0, 0, 0, 0, 2, 2, &honeycomb_width, &honeycomb_height);
viewport_setRenderViewportAndOrthoMatrix(gfx, mtx); viewport_setRenderViewportAndOrthoMatrix(gfx, mtx);
//loop over each honeycomb piece //loop over each honeycomb piece
for(i = D_80381F00-1; i >= 0; i--){//L80300E40 for (i = gTotalHealth - 1; i >= 0; i--) {//L80300E40
if(i != 0 && (i + 1 != D_80381F00 || D_80381F00 & 1) if (i != 0 && (i + 1 != gTotalHealth || gTotalHealth & 1)) {
){
s6 = (i & 1) ? i + 1 : i - 1; s6 = (i & 1) ? i + 1 : i - 1;
} }
else{//L80300E84 else {//L80300E84
s6 = i; s6 = i;
} }
gDPPipeSync((*gfx)++); gDPPipeSync((*gfx)++);
if(D_80381F04 > i){
if((0 < D_80381F04 - 8.0f) && ((D_80381F04 - 8.0f) > i)){ if (gHealth > i) {
if(!spD4){ if (0 < (gHealth - 8.0f) && (gHealth - 8.0f) > i) {
func_80347FC0(gfx, D_8036A914, 0, 0, 0, 0, 0, 2, 2, &spEC, &spE8); if (!is_red_health_initialized) {
spD4 = TRUE; func_80347FC0(gfx, gSpriteRedHealth, 0, 0, 0, 0, 0, 2, 2, &honeycomb_width, &honeycomb_height);
is_red_health_initialized = TRUE;
} }
}//L80300F38 }//L80300F38
gDPSetPrimColor((*gfx)++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); gDPSetPrimColor((*gfx)++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
} }
else{//L80300F58 else {//L80300F58
gDPSetPrimColor((*gfx)++, 0, 0, 0xFF, 0xFF, 0xFF, 0x78); gDPSetPrimColor((*gfx)++, 0, 0, 0xFF, 0xFF, 0xFF, 0x78);
} }
f20 = 96.0f - (f32)framebuffer_width/2 + (i*13);
f14 = (f32)framebuffer_height/2 - func_802FB0E4(arg1) - D_80381F08[s6] - -48.0f; f20 = 96.0f - (f32) framebuffer_width / 2 + (i * 13);
f14 = (f32) framebuffer_height / 2 - func_802FB0E4(arg1) - D_80381F08[s6] - -48.0f;
f14 = (i & 1) ? f14 + 5.75 : f14 - 5.75; f14 = (i & 1) ? f14 + 5.75 : f14 - 5.75;
gSPVertex((*gfx)++, *vtx, 4, 0); gSPVertex((*gfx)++, *vtx, 4, 0);
for(tmp_v1 = 0; tmp_v1 < 2; tmp_v1++){//L8030101C
for(tmp_v0 = 0; tmp_v0 < 2; tmp_v0++){//L80301030 for (tmp_v1 = 0; tmp_v1 < 2; tmp_v1++) {//L8030101C
(*vtx)->v.ob[0] = (((spEC * D_80381EFC)*tmp_v0 - (spEC * D_80381EFC)/2) + f20)*4.0f; for (tmp_v0 = 0; tmp_v0 < 2; tmp_v0++) {//L80301030
(*vtx)->v.ob[1] = (((spE8 * D_80381EFC)/2 - (spE8 * D_80381EFC)*tmp_v1) + f14) * 4.0f; (*vtx)->v.ob[0] = (((honeycomb_width * D_80381EFC) * tmp_v0 - (honeycomb_width * D_80381EFC) / 2) + f20) * 4.0f;
(*vtx)->v.ob[1] = (((honeycomb_height * D_80381EFC) / 2 - (honeycomb_height * D_80381EFC) * tmp_v1) + f14) * 4.0f;
(*vtx)->v.ob[2] = -0x14; (*vtx)->v.ob[2] = -0x14;
(*vtx)->v.tc[0] = ((spEC - 1) *tmp_v0) << 6;
(*vtx)->v.tc[1] = ((spE8 - 1) *tmp_v1) << 6; (*vtx)->v.tc[0] = ((honeycomb_width - 1) * tmp_v0) << 6;
(*vtx)->v.tc[1] = ((honeycomb_height - 1) * tmp_v1) << 6;
(*vtx)++; (*vtx)++;
} }
} }
gSP1Quadrangle((*gfx)++, 0, 1, 3, 2, 0); gSP1Quadrangle((*gfx)++, 0, 1, 3, 2, 0);
} }
gDPPipeSync((*gfx)++); gDPPipeSync((*gfx)++);
gDPSetTextureLUT((*gfx)++, G_TT_NONE); gDPSetTextureLUT((*gfx)++, G_TT_NONE);
gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE);
@@ -140,7 +150,7 @@ void func_803012F8(void) {
D_80381EF0 = 1; D_80381EF0 = 1;
D_80381F28 = 0.0f; D_80381F28 = 0.0f;
item_adjustByDiffWithHud(ITEM_14_HEALTH, 0); item_adjustByDiffWithHud(ITEM_14_HEALTH, 0);
D_80381F04 = (f32) item_getCount(ITEM_14_HEALTH); gHealth = (f32) item_getCount(ITEM_14_HEALTH);
} }
@@ -153,20 +163,20 @@ void fxhealthscore_update(enum item_e item_id, struct8s *arg1) {
temp_f20 = time_getDelta(); temp_f20 = time_getDelta();
sp2C = func_802FB0D4(arg1); sp2C = func_802FB0D4(arg1);
if (item_getCount(ITEM_15_HEALTH_TOTAL) >= 9) { if (item_getCount(ITEM_15_HEALTH_TOTAL) >= 9) {
D_80381F00 = 8; gTotalHealth = 8;
} else { } else {
D_80381F00 = item_getCount(ITEM_15_HEALTH_TOTAL); gTotalHealth = item_getCount(ITEM_15_HEALTH_TOTAL);
} }
switch (D_80381EF0) { switch (D_80381EF0) {
case 0: case 0:
D_80381F04 = (f32) itemPrint_getValue(item_id); gHealth = (f32) itemPrint_getValue(item_id);
break; break;
case 1: case 1:
D_80381F04 += temp_f20 * 10.0f; gHealth += temp_f20 * 10.0f;
if (D_80381F00 <= D_80381F04) { if (gTotalHealth <= gHealth) {
D_80381F04 = D_80381F04 - D_80381F00; gHealth = gHealth - gTotalHealth;
} }
D_80381F28 += temp_f20; D_80381F28 += temp_f20;
if (D_80381F28 > 2.5) { if (D_80381F28 > 2.5) {
@@ -177,36 +187,38 @@ void fxhealthscore_update(enum item_e item_id, struct8s *arg1) {
case 2: case 2:
if (sp2C != 1) { if (sp2C != 1) {
D_80381F04 += temp_f20 * 10.0f; gHealth += temp_f20 * 10.0f;
if (D_80381F00 <= D_80381F04) { if (gTotalHealth <= gHealth) {
D_80381F04 = D_80381F04 - D_80381F00; gHealth = gHealth - gTotalHealth;
} }
} }
if (randf2(0.0f, 1.0f) < (1.0 / D_80381F00)) { if (randf2(0.0f, 1.0f) < (1.0 / gTotalHealth)) {
if (D_80381F04 < 1.0f) { if (gHealth < 1.0f) {
D_80381F04 =D_80381F04 + 1.0; gHealth =gHealth + 1.0;
} }
if (item_getCount(ITEM_14_HEALTH) < D_80381F04) { if (item_getCount(ITEM_14_HEALTH) < gHealth) {
func_8025A6EC(COMUSIC_2B_DING_B, 22000); func_8025A6EC(COMUSIC_2B_DING_B, 22000);
} }
if (D_80381F04 < (f32) item_getCount(ITEM_14_HEALTH)) { if (gHealth < (f32) item_getCount(ITEM_14_HEALTH)) {
func_8025A6EC(COMUSIC_2C_BUZZER, 22000); func_8025A6EC(COMUSIC_2C_BUZZER, 22000);
} }
item_set(ITEM_14_HEALTH, (s32) D_80381F04); item_set(ITEM_14_HEALTH, (s32) gHealth);
D_80381EF0 = 0; D_80381EF0 = 0;
} }
break; break;
} }
switch (sp2C) { switch (sp2C) {
case 2: case 2:
break; break;
case 1: case 1:
if (D_8036A910 == NULL) { if (gSpriteHealth == NULL) {
D_8036A910 = assetcache_get(ASSET_7DD_SPRITE_HEALTH); gSpriteHealth = assetcache_get(ASSET_7DD_SPRITE_HEALTH);
} }
if (D_8036A914 == NULL) {
D_8036A914 = assetcache_get(0x7EA); if (gSpriteRedHealth == NULL) {
gSpriteRedHealth = assetcache_get(ASSET_7EA_SPRITE_RED_HEALTH);
} }
break; break;
@@ -215,8 +227,8 @@ void fxhealthscore_update(enum item_e item_id, struct8s *arg1) {
break; break;
} }
if (sp2C) { if (sp2C) {
for(var_s0 = 0; var_s0 < D_80381F00; var_s0++){ for(var_s0 = 0; var_s0 < gTotalHealth; var_s0++){
if (func_803012B8(-15.0f, var_s0, D_80381F00)) { if (func_803012B8(-15.0f, var_s0, gTotalHealth)) {
D_80381F08[var_s0] = D_80381F08[var_s0] * 0.6; D_80381F08[var_s0] = D_80381F08[var_s0] * 0.6;
} }
} }

View File

@@ -67,11 +67,11 @@ void func_802FDD20(void) {
void fxhoneycarrierscore_free(s32 arg0, struct8s *arg1){ void fxhoneycarrierscore_free(s32 arg0, struct8s *arg1){
if(D_8036A010){ if(D_8036A010){
func_8033BD4C(D_8036A010); assetCache_free(D_8036A010);
D_8036A010 = NULL; D_8036A010 = NULL;
} }
if(D_8036A014){ if(D_8036A014){
func_8033BD4C(D_8036A014); assetCache_free(D_8036A014);
D_8036A014 = NULL; D_8036A014 = NULL;
} }
D_803815E8 = 0x50; D_803815E8 = 0x50;

View File

@@ -124,7 +124,7 @@ void fxjinjoscore_free(enum item_e item_id, struct8s * arg1){
for(i = 0; i < 5; i++){ for(i = 0; i < 5; i++){
if(D_80381E40[i] != NULL){ if(D_80381E40[i] != NULL){
func_8033BD4C(D_80381E40[i]); assetCache_free(D_80381E40[i]);
D_80381E40[i] = NULL; D_80381E40[i] = NULL;
} }
} }

View File

@@ -58,7 +58,7 @@ void fxlifescore_free(s32 item_id, struct8s *arg1){
s32 i; s32 i;
for(i = 0; i < 2; i++){ for(i = 0; i < 2; i++){
if(D_80381EB0[i] != NULL){ if(D_80381EB0[i] != NULL){
func_8033BD4C(D_80381EB0[i]); assetCache_free(D_80381EB0[i]);
D_80381EB0[i] = NULL; D_80381EB0[i] = NULL;
} }
}; };
@@ -150,7 +150,7 @@ void fxlifescore_update(enum item_e item_id, struct8s *arg1) {
if (sp18 != D_80381EC0) { if (sp18 != D_80381EC0) {
D_80381EC4 = NOT(D_80381EC4); D_80381EC4 = NOT(D_80381EC4);
if (D_80381EB0[D_80381EC4] != 0) { if (D_80381EB0[D_80381EC4] != 0) {
func_8033BD4C(D_80381EB0[D_80381EC4]); assetCache_free(D_80381EB0[D_80381EC4]);
} }
D_80381EB0[D_80381EC4] = assetcache_get(sp18); D_80381EB0[D_80381EC4] = assetcache_get(sp18);
D_80381EC0 = sp18; D_80381EC0 = sp18;

View File

@@ -14,7 +14,7 @@ extern bool func_802ED420(BKModelUnk20List *arg0, u8 *arg1, u32 arg2);
extern void func_802ED52C(BKModelUnk20List *, f32[3], f32); extern void func_802ED52C(BKModelUnk20List *, f32[3], f32);
extern void func_80252AF0(f32[3], f32[3], f32[3], f32, f32[3]); extern void func_80252AF0(f32[3], f32[3], f32[3], f32, f32[3]);
extern void mlMtxRotatePYR(f32, f32, f32); extern void mlMtxRotatePYR(f32, f32, f32);
extern void func_8033BD4C(BKModelBin *); extern void assetCache_free(BKModelBin *);
extern s32 func_8024DB50(f32[3], f32); extern s32 func_8024DB50(f32[3], f32);
extern AnimMtxList *animMtxList_new(); extern AnimMtxList *animMtxList_new();
extern AnimMtxList *animMtxList_defrag(AnimMtxList *); extern AnimMtxList *animMtxList_defrag(AnimMtxList *);
@@ -1286,7 +1286,7 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 rotation
} }
if(D_803837C8.model_id){ if(D_803837C8.model_id){
func_8033BD4C(model_bin); //assetCache_free assetCache_free(model_bin);
} }
modelRender_reset(); modelRender_reset();