diff --git a/include/enums.h b/include/enums.h index 543185ca..ca3761ce 100644 --- a/include/enums.h +++ b/include/enums.h @@ -3875,6 +3875,8 @@ enum asset_e ASSET_7E6_SPRITE_VILE, ASSET_7E7_SPRITE_CROC_BANJO, + ASSET_7EA_SPRITE_RED_HEALTH = 0x7ea, + ASSET_7EE_JOKER_CARD = 0x7ee, ASSET_7EF_SPRITE_BANJO, ASSET_7F0_SPRITE_BOTTLES, diff --git a/src/core2/code_B3A80.c b/src/core2/code_B3A80.c index 7637fdd5..15a0537d 100644 --- a/src/core2/code_B3A80.c +++ b/src/core2/code_B3A80.c @@ -164,12 +164,14 @@ void func_8033B020(void *ptr){ end_ptr = (struct21s *) vector_getEnd(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) { iPtr->unk0++; } - else{ - iPtr = (struct21s *)vector_pushBackNew(&D_80383CE0[0]); + else { + iPtr = (struct21s *) vector_pushBackNew(&D_80383CE0[0]); iPtr->unk0 = 1; iPtr->unk1 = ptr; } @@ -463,7 +465,7 @@ void func_8033BD20(BKModelBin **arg0){ *arg0 = NULL; } -void func_8033BD4C(void *arg0){ +void assetCache_free(void *arg0){ func_8033B020(arg0); } diff --git a/src/core2/code_B8860.c b/src/core2/code_B8860.c index 6fa7f192..929730cf 100644 --- a/src/core2/code_B8860.c +++ b/src/core2/code_B8860.c @@ -108,7 +108,7 @@ u8 func_8033FA84(void){ void func_8033FB64(u8 indx){ 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].unk28_13 = 0; @@ -116,7 +116,7 @@ void func_8033FB64(u8 indx){ void projectile_setSprite(u8 indx, enum asset_e arg1){ 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); } diff --git a/src/core2/fx/airscore.c b/src/core2/fx/airscore.c index 7319b57f..7efec759 100644 --- a/src/core2/fx/airscore.c +++ b/src/core2/fx/airscore.c @@ -46,7 +46,7 @@ void func_803016F0(void) { void fxairscore_free(s32 arg0, struct7s *arg1) { if (s_sprite != NULL) { - func_8033BD4C(s_sprite); + assetCache_free(s_sprite); s_sprite = NULL; } func_803016F0(); diff --git a/src/core2/fx/common2score.c b/src/core2/fx/common2score.c index b353e1ae..c5694113 100644 --- a/src/core2/fx/common2score.c +++ b/src/core2/fx/common2score.c @@ -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){ if(arg1->unk50){ - func_8033BD4C(arg1->unk50); //assetCache_free + assetCache_free(arg1->unk50); //assetCache_free arg1->unk50 = NULL; } } diff --git a/src/core2/fx/common3score.c b/src/core2/fx/common3score.c index f73877f5..ec06491e 100644 --- a/src/core2/fx/common3score.c +++ b/src/core2/fx/common3score.c @@ -226,7 +226,7 @@ void fxcommon3score_free(enum item_e item_id, void *arg1){ } if(a1->model != NULL){ - func_8033BD4C(a1->model); + assetCache_free(a1->model); a1->model = NULL; a1->unk6C = 0.0f; } diff --git a/src/core2/fx/healthscore.c b/src/core2/fx/healthscore.c index f70c80f1..65d16d5b 100644 --- a/src/core2/fx/healthscore.c +++ b/src/core2/fx/healthscore.c @@ -10,8 +10,8 @@ extern s32 framebuffer_width; extern s32 framebuffer_height; /* .data */ -BKSprite * D_8036A910 = NULL; -BKSprite * D_8036A914 = NULL; +BKSprite * gSpriteHealth = NULL; +BKSprite * gSpriteRedHealth = NULL; Gfx D_8036A918[] = { 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), @@ -28,8 +28,8 @@ s32 D_80381EF0; f32 D_80381EF4; f32 D_80381EF8; f32 D_80381EFC; -s32 D_80381F00; -f32 D_80381F04; +s32 gTotalHealth; +f32 gHealth; f32 D_80381F08[8]; f32 D_80381F28; f32 D_80381F2C; @@ -48,17 +48,16 @@ void func_80300C10(void) { } void fxhealthscore_free(enum item_e item_id, struct8s *arg1){ - s32 temp_a0; - s32 temp_a0_2; + if (gSpriteHealth != NULL) { + assetCache_free(gSpriteHealth); + gSpriteHealth = NULL; + } - if (D_8036A910 != 0) { - func_8033BD4C(D_8036A910); - D_8036A910 = 0; - } - if (D_8036A914 != 0) { - func_8033BD4C(D_8036A914); - D_8036A914 = 0; + if (gSpriteRedHealth != NULL) { + assetCache_free(gSpriteRedHealth); + gSpriteRedHealth = NULL; } + func_80300C10(); } @@ -68,61 +67,72 @@ struct7s *fxhealthscore_new(enum item_e item_id){ return &D_80381F30; } -void fxhealthscore_draw(enum item_e item_id, struct8s *arg1, Gfx **gfx, Mtx **mtx, Vtx **vtx){ - int i; +void fxhealthscore_draw(enum item_e item_id, struct8s *arg1, Gfx **gfx, Mtx **mtx, Vtx **vtx) { + int i; int tmp_v1; - s32 spEC; - s32 spE8; + s32 honeycomb_width; + s32 honeycomb_height; int tmp_v0; f32 f18; f32 f14; f32 f20; - s32 spD4 = 0; + s32 is_red_health_initialized = FALSE; s32 s6; - if(D_8036A910 == NULL) return; + if (gSpriteHealth == NULL) { + return; + } 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); + //loop over each honeycomb piece - for(i = D_80381F00-1; i >= 0; i--){//L80300E40 - if(i != 0 && (i + 1 != D_80381F00 || D_80381F00 & 1) - ){ + for (i = gTotalHealth - 1; i >= 0; i--) {//L80300E40 + if (i != 0 && (i + 1 != gTotalHealth || gTotalHealth & 1)) { s6 = (i & 1) ? i + 1 : i - 1; } - else{//L80300E84 + else {//L80300E84 s6 = i; } + gDPPipeSync((*gfx)++); - if(D_80381F04 > i){ - if((0 < D_80381F04 - 8.0f) && ((D_80381F04 - 8.0f) > i)){ - if(!spD4){ - func_80347FC0(gfx, D_8036A914, 0, 0, 0, 0, 0, 2, 2, &spEC, &spE8); - spD4 = TRUE; + + if (gHealth > i) { + if (0 < (gHealth - 8.0f) && (gHealth - 8.0f) > i) { + if (!is_red_health_initialized) { + func_80347FC0(gfx, gSpriteRedHealth, 0, 0, 0, 0, 0, 2, 2, &honeycomb_width, &honeycomb_height); + is_red_health_initialized = TRUE; } }//L80300F38 + gDPSetPrimColor((*gfx)++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); } - else{//L80300F58 - gDPSetPrimColor((*gfx)++, 0, 0, 0xFF, 0xFF, 0xFF, 0x78); + else {//L80300F58 + 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; + 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 - (*vtx)->v.ob[0] = (((spEC * D_80381EFC)*tmp_v0 - (spEC * D_80381EFC)/2) + f20)*4.0f; - (*vtx)->v.ob[1] = (((spE8 * D_80381EFC)/2 - (spE8 * D_80381EFC)*tmp_v1) + f14) * 4.0f; + + for (tmp_v1 = 0; tmp_v1 < 2; tmp_v1++) {//L8030101C + for (tmp_v0 = 0; tmp_v0 < 2; tmp_v0++) {//L80301030 + (*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.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)++; } } + gSP1Quadrangle((*gfx)++, 0, 1, 3, 2, 0); } + gDPPipeSync((*gfx)++); gDPSetTextureLUT((*gfx)++, G_TT_NONE); gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); @@ -140,7 +150,7 @@ void func_803012F8(void) { D_80381EF0 = 1; D_80381F28 = 0.0f; 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(); sp2C = func_802FB0D4(arg1); if (item_getCount(ITEM_15_HEALTH_TOTAL) >= 9) { - D_80381F00 = 8; + gTotalHealth = 8; } else { - D_80381F00 = item_getCount(ITEM_15_HEALTH_TOTAL); + gTotalHealth = item_getCount(ITEM_15_HEALTH_TOTAL); } switch (D_80381EF0) { case 0: - D_80381F04 = (f32) itemPrint_getValue(item_id); + gHealth = (f32) itemPrint_getValue(item_id); break; case 1: - D_80381F04 += temp_f20 * 10.0f; - if (D_80381F00 <= D_80381F04) { - D_80381F04 = D_80381F04 - D_80381F00; + gHealth += temp_f20 * 10.0f; + if (gTotalHealth <= gHealth) { + gHealth = gHealth - gTotalHealth; } D_80381F28 += temp_f20; if (D_80381F28 > 2.5) { @@ -177,36 +187,38 @@ void fxhealthscore_update(enum item_e item_id, struct8s *arg1) { case 2: if (sp2C != 1) { - D_80381F04 += temp_f20 * 10.0f; - if (D_80381F00 <= D_80381F04) { - D_80381F04 = D_80381F04 - D_80381F00; + gHealth += temp_f20 * 10.0f; + if (gTotalHealth <= gHealth) { + gHealth = gHealth - gTotalHealth; } } - if (randf2(0.0f, 1.0f) < (1.0 / D_80381F00)) { - if (D_80381F04 < 1.0f) { - D_80381F04 =D_80381F04 + 1.0; + if (randf2(0.0f, 1.0f) < (1.0 / gTotalHealth)) { + if (gHealth < 1.0f) { + 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); } - if (D_80381F04 < (f32) item_getCount(ITEM_14_HEALTH)) { + if (gHealth < (f32) item_getCount(ITEM_14_HEALTH)) { func_8025A6EC(COMUSIC_2C_BUZZER, 22000); } - item_set(ITEM_14_HEALTH, (s32) D_80381F04); + item_set(ITEM_14_HEALTH, (s32) gHealth); D_80381EF0 = 0; } break; } + switch (sp2C) { case 2: break; case 1: - if (D_8036A910 == NULL) { - D_8036A910 = assetcache_get(ASSET_7DD_SPRITE_HEALTH); + if (gSpriteHealth == NULL) { + 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; @@ -215,8 +227,8 @@ void fxhealthscore_update(enum item_e item_id, struct8s *arg1) { break; } if (sp2C) { - for(var_s0 = 0; var_s0 < D_80381F00; var_s0++){ - if (func_803012B8(-15.0f, var_s0, D_80381F00)) { + for(var_s0 = 0; var_s0 < gTotalHealth; var_s0++){ + if (func_803012B8(-15.0f, var_s0, gTotalHealth)) { D_80381F08[var_s0] = D_80381F08[var_s0] * 0.6; } } diff --git a/src/core2/fx/honeycarrierscore.c b/src/core2/fx/honeycarrierscore.c index 6766dec8..3eae4891 100644 --- a/src/core2/fx/honeycarrierscore.c +++ b/src/core2/fx/honeycarrierscore.c @@ -67,11 +67,11 @@ void func_802FDD20(void) { void fxhoneycarrierscore_free(s32 arg0, struct8s *arg1){ if(D_8036A010){ - func_8033BD4C(D_8036A010); + assetCache_free(D_8036A010); D_8036A010 = NULL; } if(D_8036A014){ - func_8033BD4C(D_8036A014); + assetCache_free(D_8036A014); D_8036A014 = NULL; } D_803815E8 = 0x50; diff --git a/src/core2/fx/jinjoscore.c b/src/core2/fx/jinjoscore.c index 4e99a2c4..fca34533 100644 --- a/src/core2/fx/jinjoscore.c +++ b/src/core2/fx/jinjoscore.c @@ -124,7 +124,7 @@ void fxjinjoscore_free(enum item_e item_id, struct8s * arg1){ for(i = 0; i < 5; i++){ if(D_80381E40[i] != NULL){ - func_8033BD4C(D_80381E40[i]); + assetCache_free(D_80381E40[i]); D_80381E40[i] = NULL; } } diff --git a/src/core2/fx/lifescore.c b/src/core2/fx/lifescore.c index a05852fd..e479535c 100644 --- a/src/core2/fx/lifescore.c +++ b/src/core2/fx/lifescore.c @@ -58,7 +58,7 @@ void fxlifescore_free(s32 item_id, struct8s *arg1){ s32 i; for(i = 0; i < 2; i++){ if(D_80381EB0[i] != NULL){ - func_8033BD4C(D_80381EB0[i]); + assetCache_free(D_80381EB0[i]); D_80381EB0[i] = NULL; } }; @@ -150,7 +150,7 @@ void fxlifescore_update(enum item_e item_id, struct8s *arg1) { if (sp18 != D_80381EC0) { D_80381EC4 = NOT(D_80381EC4); 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_80381EC0 = sp18; diff --git a/src/core2/modelRender.c b/src/core2/modelRender.c index 927dc8b7..e324e848 100644 --- a/src/core2/modelRender.c +++ b/src/core2/modelRender.c @@ -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_80252AF0(f32[3], f32[3], f32[3], f32, f32[3]); extern void mlMtxRotatePYR(f32, f32, f32); -extern void func_8033BD4C(BKModelBin *); +extern void assetCache_free(BKModelBin *); extern s32 func_8024DB50(f32[3], f32); extern AnimMtxList *animMtxList_new(); 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){ - func_8033BD4C(model_bin); //assetCache_free + assetCache_free(model_bin); } modelRender_reset();