Unhardcode many for loop conditions (#1179)

* suggest possible bgm name if it is not found

* remove pointless ()

* run black

* ...run updated black

* unhardcode many for loop conditions

* fix inconsistent RGBA_BUF_SIZE naming

* requested macro changes
This commit is contained in:
Rainchus 2024-03-06 10:03:33 -06:00 committed by GitHub
parent e342a33a20
commit ed46ab0c70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 118 additions and 95 deletions

View File

@ -1370,15 +1370,17 @@ typedef struct RadiatingEnergyOrbFXData {
/* 0x30 */ f32 unk_30; /* 0x30 */ f32 unk_30;
} RadiatingEnergyOrbFXData; // size = 0x34 } RadiatingEnergyOrbFXData; // size = 0x34
#define UNK_ARRAY_SIZE_1 4
typedef struct MotionBlurFlameFXData { typedef struct MotionBlurFlameFXData {
/* 0x00 */ s32 unk_00; /* 0x00 */ s32 unk_00;
/* 0x04 */ f32 unk_04; /* 0x04 */ f32 unk_04;
/* 0x08 */ f32 unk_08; /* 0x08 */ f32 unk_08;
/* 0x0C */ f32 unk_0C; /* 0x0C */ f32 unk_0C;
/* 0x10 */ Vec3f pos; /* 0x10 */ Vec3f pos;
/* 0x1C */ f32 unk_1C[4]; /* 0x1C */ f32 unk_1C[UNK_ARRAY_SIZE_1];
/* 0x2C */ f32 unk_2C[4]; /* 0x2C */ f32 unk_2C[UNK_ARRAY_SIZE_1];
/* 0x3C */ f32 unk_3C[4]; /* 0x3C */ f32 unk_3C[UNK_ARRAY_SIZE_1];
/* 0x4C */ s32 unk_4C; /* 0x4C */ s32 unk_4C;
/* 0x50 */ s32 unk_50; /* 0x50 */ s32 unk_50;
/* 0x54 */ s32 unk_54; /* 0x54 */ s32 unk_54;
@ -2131,6 +2133,8 @@ typedef struct Effect75FXData {
/* 0x7C */ f32 unk_7C; /* 0x7C */ f32 unk_7C;
} Effect75FXData; // size = 0x80 } Effect75FXData; // size = 0x80
#define ROCKET_BUF_SIZE 4
typedef struct FireworkRocketFXData { typedef struct FireworkRocketFXData {
/* 0x00 */ s32 variation; /* 0x00 */ s32 variation;
/* 0x04 */ Vec3f pos; /* 0x04 */ Vec3f pos;
@ -2148,12 +2152,12 @@ typedef struct FireworkRocketFXData {
/* 0x44 */ f32 radius; /* 0x44 */ f32 radius;
/* 0x48 */ f32 maxRadius; /* 0x48 */ f32 maxRadius;
/* 0x4C */ s32 isExploded; /* 0x4C */ s32 isExploded;
/* 0x50 */ f32 rocketX[4]; /* 0x50 */ f32 rocketX[ROCKET_BUF_SIZE];
/* 0x60 */ f32 rocketY[4]; /* 0x60 */ f32 rocketY[ROCKET_BUF_SIZE];
/* 0x70 */ f32 rocketZ[4]; /* 0x70 */ f32 rocketZ[ROCKET_BUF_SIZE];
/* 0x80 */ f32 rocketVelX[4]; /* 0x80 */ f32 rocketVelX[ROCKET_BUF_SIZE];
/* 0x90 */ f32 rocketVelY[4]; /* 0x90 */ f32 rocketVelY[ROCKET_BUF_SIZE];
/* 0xA0 */ f32 rocketVelZ[4]; /* 0xA0 */ f32 rocketVelZ[ROCKET_BUF_SIZE];
} FireworkRocketFXData; // size = 0xB0 } FireworkRocketFXData; // size = 0xB0
typedef struct PeachStarBeamSpirit { typedef struct PeachStarBeamSpirit {

View File

@ -263,19 +263,21 @@ typedef struct PadlockData {
/* 0x18 */ Gfx* shackleGfx; /* 0x18 */ Gfx* shackleGfx;
} PadlockData; // size = 0x1C } PadlockData; // size = 0x1C
#define FRAGMENT_BUF_SIZE 13
typedef struct BoardedFloorData { typedef struct BoardedFloorData {
/* 0x000 */ Gfx** fragmentsGfx; /* 0x000 */ Gfx** fragmentsGfx;
/* 0x004 */ f32 inititalY; /* 0x004 */ f32 inititalY;
/* 0x008 */ s8 fragmentRebounds[13]; /* 0x008 */ s8 fragmentRebounds[FRAGMENT_BUF_SIZE];
/* 0x015 */ u8 fragmentMoveAngle[13]; /* 0x015 */ u8 fragmentMoveAngle[FRAGMENT_BUF_SIZE];
/* 0x022 */ u8 fragmentRotX[13]; /* 0x022 */ u8 fragmentRotX[FRAGMENT_BUF_SIZE];
/* 0x02F */ u8 fragmentRotY[13]; /* 0x02F */ u8 fragmentRotY[FRAGMENT_BUF_SIZE];
/* 0x03C */ u8 fragmentLateralSpeed[13]; /* 0x03C */ u8 fragmentLateralSpeed[FRAGMENT_BUF_SIZE];
/* 0x04C */ f32 fragmentRotSpeed[13]; /* 0x04C */ f32 fragmentRotSpeed[FRAGMENT_BUF_SIZE];
/* 0x080 */ f32 fragmentPosX[13]; /* 0x080 */ f32 fragmentPosX[FRAGMENT_BUF_SIZE];
/* 0x0B4 */ f32 fragmentPosY[13]; /* 0x0B4 */ f32 fragmentPosY[FRAGMENT_BUF_SIZE];
/* 0x0E8 */ f32 fragmentPosZ[13]; /* 0x0E8 */ f32 fragmentPosZ[FRAGMENT_BUF_SIZE];
/* 0x11C */ f32 fragmentFallSpeed[13]; /* 0x11C */ f32 fragmentFallSpeed[FRAGMENT_BUF_SIZE];
} BoardedFloorData; // size = 0x150 } BoardedFloorData; // size = 0x150
typedef struct BombableRockData { typedef struct BombableRockData {

View File

@ -51,7 +51,7 @@ void spawn_drops(Enemy* enemy) {
if (drops->itemDropChance > rand_int(100)) { if (drops->itemDropChance > rand_int(100)) {
tempMax = 0; tempMax = 0;
for (i = 0; i < 8; i++) { for (i = 0; i < ARRAY_COUNT(drops->itemDrops) / 3; i++) {
if (drops->itemDrops[3 * i] != 0) { if (drops->itemDrops[3 * i] != 0) {
tempMax += drops->itemDrops[3 * i + 1]; tempMax += drops->itemDrops[3 * i + 1];
} else { } else {
@ -63,7 +63,7 @@ void spawn_drops(Enemy* enemy) {
dropCount = rand_int(tempMax); dropCount = rand_int(tempMax);
itemToDrop = ITEM_NONE; itemToDrop = ITEM_NONE;
for (i = 0; i < 8; i++) { for (i = 0; i < ARRAY_COUNT(drops->itemDrops) / 3; i++) {
if (drops->itemDrops[3 * i] == 0) { if (drops->itemDrops[3 * i] == 0) {
break; break;
} }
@ -122,7 +122,7 @@ void spawn_drops(Enemy* enemy) {
itemToDrop = ITEM_NONE; itemToDrop = ITEM_NONE;
fraction = playerData->curHP / (f32) playerData->curMaxHP; fraction = playerData->curHP / (f32) playerData->curMaxHP;
for (i = 0; i < 8; i++) { for (i = 0; i < ARRAY_COUNT(drops->itemDrops) / 3; i++) {
attempts = drops->heartDrops[4 * i]; attempts = drops->heartDrops[4 * i];
threshold = drops->heartDrops[4 * i + 1]; threshold = drops->heartDrops[4 * i + 1];
attempts /= 32767.0f; attempts /= 32767.0f;
@ -176,7 +176,7 @@ void spawn_drops(Enemy* enemy) {
itemToDrop = ITEM_NONE; itemToDrop = ITEM_NONE;
fraction = playerData->curFP / (f32) playerData->curMaxFP; fraction = playerData->curFP / (f32) playerData->curMaxFP;
for (i = 0; i < 8; i++) { for (i = 0; i < ARRAY_COUNT(drops->itemDrops) / 3; i++) {
attempts = drops->flowerDrops[4 * i + 0]; attempts = drops->flowerDrops[4 * i + 0];
threshold = drops->flowerDrops[4 * i + 1]; threshold = drops->flowerDrops[4 * i + 1];
attempts /= 32767.0f; attempts /= 32767.0f;

View File

@ -72,7 +72,7 @@ void func_800F0D5C(void) {
Unk8a160Outer* outer = &D_8010D000[0]; Unk8a160Outer* outer = &D_8010D000[0];
s32 i; s32 i;
for (i = 0; i < 1; i++) { for (i = 0; i < ARRAY_COUNT(D_8010D000); i++) {
outer[i].subs[0].alive = FALSE; outer[i].subs[0].alive = FALSE;
} }
} }

View File

@ -90,7 +90,7 @@ void au_bgm_update_main(BGMPlayer* player) {
BGMDrumInfo* drum = &player->drumsInfo[i]; BGMDrumInfo* drum = &player->drumsInfo[i];
player->drums[i] = drum; player->drums[i] = drum;
} }
for (; i < 12; i++) { for (; i < ARRAY_COUNT(player->drums); i++) {
player->drums[i] = player->drums[0]; player->drums[i] = player->drums[0];
} }
} else { } else {
@ -1799,7 +1799,7 @@ void au_BGMCmd_FF(BGMPlayer* player, BGMPlayerTrack* track) {
if (arg1 == 0) { if (arg1 == 0) {
if (track->unk_4E != 0) { if (track->unk_4E != 0) {
track->unk_4E = 0; track->unk_4E = 0;
for (i = 0; i < 16; i++) { for (i = 0; i < ARRAY_COUNT(player->tracks); i++) {
BGMPlayerTrack* otherTrack = &player->tracks[i]; BGMPlayerTrack* otherTrack = &player->tracks[i];
if (player->proxMixVolume == 0x7F) { if (player->proxMixVolume == 0x7F) {
if (otherTrack->unk_4F != 0) { if (otherTrack->unk_4F != 0) {

View File

@ -79,7 +79,7 @@ void au_engine_init(s32 outputRate) {
globals->unk_globals_6C[i].unk_5 = 0; globals->unk_globals_6C[i].unk_5 = 0;
} }
for (i = 0; i < 4; i++) { for (i = 0; i < ARRAY_COUNT(globals->effectChanges); i++) {
globals->effectChanges[i].type = AU_FX_NONE; globals->effectChanges[i].type = AU_FX_NONE;
globals->effectChanges[i].changed = FALSE; globals->effectChanges[i].changed = FALSE;
} }

View File

@ -80,13 +80,13 @@ void bgm_reset_volume(void) {
//TODO refactor out constants //TODO refactor out constants
void bgm_update_music_settings(void) { void bgm_update_music_settings(void) {
MusicSettings* music = &gMusicSettings[0]; MusicSettings* music = gMusicSettings;
s32 i = 0; s32 i = 0;
s16 state2 = 2; s16 state2 = 2;
s16 flag4 = MUSIC_SETTINGS_FLAG_4; s16 flag4 = MUSIC_SETTINGS_FLAG_4;
s32 flags; s32 flags;
for (i; i < 2; i++, music++) { for (i; i < ARRAY_COUNT(gMusicSettings); i++, music++) {
switch (music->state) { switch (music->state) {
case 0: case 0:
break; break;
@ -360,7 +360,7 @@ s32 func_8014AD40(void) {
MusicSettings* settings = gMusicSettings; MusicSettings* settings = gMusicSettings;
s32 i; s32 i;
for (i = 0; i < 2; i++, settings++) { for (i = 0; i < ARRAY_COUNT(gMusicSettings); i++, settings++) {
if (!(settings->flags & MUSIC_SETTINGS_FLAG_1)) { if (!(settings->flags & MUSIC_SETTINGS_FLAG_1)) {
continue; continue;
} }

View File

@ -116,7 +116,7 @@ static void _init_lpfilter(AuLowPass* lp) {
timeConstant = timeConstant >> 1; timeConstant = timeConstant >> 1;
lp->fgain = SCALE - timeConstant; lp->fgain = SCALE - timeConstant;
for (i = 0; i < 8; i++) { for (i = 0; i < ARRAY_COUNT(lp->fccoef) / 2; i++) {
lp->fccoef[i] = 0; lp->fccoef[i] = 0;
} }
@ -125,7 +125,7 @@ static void _init_lpfilter(AuLowPass* lp) {
// ith value is 16384 * (timeConstant / 16384)^(i-7) // ith value is 16384 * (timeConstant / 16384)^(i-7)
// ex: i = 9 --> timeConstant^2 / 16384 // ex: i = 9 --> timeConstant^2 / 16384
attenuation = ((f64)timeConstant / SCALE); attenuation = ((f64)timeConstant / SCALE);
for (i = 9; i < 16; i++) { for (i = 9; i < ARRAY_COUNT(lp->fccoef); i++) {
attenuation *= ((f64)timeConstant /SCALE); attenuation *= ((f64)timeConstant /SCALE);
lp->fccoef[i] = attenuation * SCALE; lp->fccoef[i] = attenuation * SCALE;
} }

View File

@ -46,18 +46,19 @@ s32 gfx_frame_filter_pass_0(const u16* frameBuffer0, const u16* frameBuffer1, s3
} }
void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u16* out) { void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u16* out) {
#define RGBA_BUF_SIZE 32
Color_RGBA8 sp0; Color_RGBA8 sp0;
Color_RGBA8 sp8; Color_RGBA8 sp8;
Color_RGBA8 final; Color_RGBA8 final;
u8 rs[0x20]; u8 rs[RGBA_BUF_SIZE];
u8 gs[0x20]; u8 gs[RGBA_BUF_SIZE];
u8 bs[0x20]; u8 bs[RGBA_BUF_SIZE];
s32 i; s32 i;
sp8 = filterBuf1; sp8 = filterBuf1;
sp0 = filterBuf1; sp0 = filterBuf1;
for (i = 0; i < ARRAY_COUNT(rs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
rs[i] = 0; rs[i] = 0;
gs[i] = 0; gs[i] = 0;
bs[i] = 0; bs[i] = 0;
@ -71,13 +72,13 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
} }
} }
for (i = 0; i < ARRAY_COUNT(rs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
if (rs[i] != 0) { if (rs[i] != 0) {
rs[i]--; rs[i]--;
break; break;
} }
} }
for (; i < ARRAY_COUNT(rs); i++) { for (; i < RGBA_BUF_SIZE; i++) {
if (rs[i] != 0) { if (rs[i] != 0) {
break; break;
} }
@ -86,13 +87,13 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
sp0.r = i; sp0.r = i;
} }
for (i = 0; i < ARRAY_COUNT(gs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
if (gs[i] != 0) { if (gs[i] != 0) {
gs[i]--; gs[i]--;
break; break;
} }
} }
for (; i < ARRAY_COUNT(gs); i++) { for (; i < RGBA_BUF_SIZE; i++) {
if (gs[i] != 0) { if (gs[i] != 0) {
break; break;
} }
@ -101,13 +102,13 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
sp0.g = i; sp0.g = i;
} }
for (i = 0; i < ARRAY_COUNT(bs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
if (bs[i] != 0) { if (bs[i] != 0) {
bs[i]--; bs[i]--;
break; break;
} }
} }
for (; i < ARRAY_COUNT(bs); i++) { for (; i < RGBA_BUF_SIZE; i++) {
if (bs[i] != 0) { if (bs[i] != 0) {
break; break;
} }
@ -116,7 +117,7 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
sp0.b = i; sp0.b = i;
} }
for (i = ARRAY_COUNT(rs) - 1; i >= 0; i--) { for (i = RGBA_BUF_SIZE - 1; i >= 0; i--) {
if (rs[i] != 0) { if (rs[i] != 0) {
break; break;
} }
@ -125,7 +126,7 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
sp8.r = i; sp8.r = i;
} }
for (i = ARRAY_COUNT(gs) - 1; i >= 0; i--) { for (i = RGBA_BUF_SIZE - 1; i >= 0; i--) {
if (gs[i] != 0) { if (gs[i] != 0) {
break; break;
} }
@ -134,7 +135,7 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
sp8.g = i; sp8.g = i;
} }
for (i = ARRAY_COUNT(bs) - 1; i >= 0; i--) { for (i = RGBA_BUF_SIZE - 1; i >= 0; i--) {
if (bs[i] != 0) { if (bs[i] != 0) {
break; break;
} }
@ -152,17 +153,19 @@ void gfx_frame_filter_pass_1(Color_RGBA8* filterBuf0, Color_RGBA8 filterBuf1, u1
final.b = ((filterBuf1.b * filterBuf1.a) + (final.b * (8 - filterBuf1.a))) >> 3; final.b = ((filterBuf1.b * filterBuf1.a) + (final.b * (8 - filterBuf1.a))) >> 3;
*out = (final.r << 11) + (final.g << 6) + (final.b << 1) + 1; *out = (final.r << 11) + (final.g << 6) + (final.b << 1) + 1;
#undef RGBA_BUF_SIZE
} }
void func_80027600(Color_RGBA8* arg0, s16* out) { void func_80027600(Color_RGBA8* arg0, s16* out) {
#define RGBA_BUF_SIZE 32
Color_RGBA8 final; Color_RGBA8 final;
u8 rs[0x20]; u8 rs[RGBA_BUF_SIZE];
u8 gs[0x20]; u8 gs[RGBA_BUF_SIZE];
u8 bs[0x20]; u8 bs[RGBA_BUF_SIZE];
s32 i; s32 i;
s32 sum; s32 sum;
for (i = 0; i < ARRAY_COUNT(rs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
rs[i] = 0; rs[i] = 0;
gs[i] = 0; gs[i] = 0;
bs[i] = 0; bs[i] = 0;
@ -175,7 +178,7 @@ void func_80027600(Color_RGBA8* arg0, s16* out) {
} }
sum = 0; sum = 0;
for (i = 0; i < ARRAY_COUNT(rs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
sum += rs[i]; sum += rs[i];
if (sum >= 5) { if (sum >= 5) {
break; break;
@ -184,7 +187,7 @@ void func_80027600(Color_RGBA8* arg0, s16* out) {
final.r = i; final.r = i;
sum = 0; sum = 0;
for (i = 0; i < ARRAY_COUNT(gs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
sum += gs[i]; sum += gs[i];
if (sum >= 5) { if (sum >= 5) {
break; break;
@ -193,7 +196,7 @@ void func_80027600(Color_RGBA8* arg0, s16* out) {
final.g = i; final.g = i;
sum = 0; sum = 0;
for (i = 0; i < ARRAY_COUNT(bs); i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
sum += bs[i]; sum += bs[i];
if (sum >= 5) { if (sum >= 5) {
break; break;
@ -202,6 +205,7 @@ void func_80027600(Color_RGBA8* arg0, s16* out) {
final.b = i; final.b = i;
*out = (final.r << 11) + (final.g << 6) + (final.b << 1) + 1; *out = (final.r << 11) + (final.g << 6) + (final.b << 1) + 1;
#undef RGBA_BUF_SIZE
} }
void func_80027774(u16* frameBuffer0, u16* frameBuffer1, u16* zBuffer) { void func_80027774(u16* frameBuffer0, u16* frameBuffer1, u16* zBuffer) {

View File

@ -37,7 +37,7 @@ API_CALLABLE(N(init)) {
hud_element_set_render_depth(id, 0); hud_element_set_render_depth(id, 0);
hud_element_set_flags(id, HUD_ELEMENT_FLAG_80 | HUD_ELEMENT_FLAG_DISABLED); hud_element_set_flags(id, HUD_ELEMENT_FLAG_80 | HUD_ELEMENT_FLAG_DISABLED);
for (i = 1; i < 15; i++) { for (i = 1; i < ARRAY_COUNT(actionCommandStatus->hudElements) - 1; i++) {
id = hud_element_create(&HES_AButton); id = hud_element_create(&HES_AButton);
actionCommandStatus->hudElements[i] = id; actionCommandStatus->hudElements[i] = id;
hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY); hud_element_set_render_pos(id, actionCommandStatus->hudPosX, actionCommandStatus->hudPosY);
@ -298,7 +298,7 @@ void N(update)(void) {
void N(draw)(void) { void N(draw)(void) {
s32 i; s32 i;
for (i = 1; i < 15; i++) { for (i = 1; i < ARRAY_COUNT(gActionCommandStatus.hudElements) - 1; i++) {
hud_element_draw_clipped(gActionCommandStatus.hudElements[i]); hud_element_draw_clipped(gActionCommandStatus.hudElements[i]);
} }
} }
@ -308,7 +308,7 @@ void N(free)(void) {
hud_element_free(gActionCommandStatus.hudElements[0]); hud_element_free(gActionCommandStatus.hudElements[0]);
for (i = 1; i < 15; i++) { for (i = 1; i < ARRAY_COUNT(gActionCommandStatus.hudElements) - 1; i++) {
hud_element_free(gActionCommandStatus.hudElements[i]); hud_element_free(gActionCommandStatus.hudElements[i]);
} }
} }

View File

@ -158,12 +158,13 @@ ImgFXOverlayTexture N(MonstarDetailTexture) = {
}; };
API_CALLABLE(N(UpdateMonstarImgFX)) { API_CALLABLE(N(UpdateMonstarImgFX)) {
#define RGBA_BUF_SIZE 20
ActorPart* part = get_actor_part(get_actor(script->owner1.actorID), 1); ActorPart* part = get_actor_part(get_actor(script->owner1.actorID), 1);
s32 i; s32 i;
u8 colR[20]; u8 colR[RGBA_BUF_SIZE];
u8 colG[20]; u8 colG[RGBA_BUF_SIZE];
u8 colB[20]; u8 colB[RGBA_BUF_SIZE];
u8 colA[20]; u8 colA[RGBA_BUF_SIZE];
if (isInitialCall) { if (isInitialCall) {
script->functionTemp[1] = 0; script->functionTemp[1] = 0;
@ -178,17 +179,19 @@ API_CALLABLE(N(UpdateMonstarImgFX)) {
script->functionTemp[1] %= 360; script->functionTemp[1] %= 360;
} }
for (i = 0; i < 20; i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
colR[i] = (cosine(script->functionTemp[1] + i * 25) + 1.0) * 56.0; colR[i] = (cosine(script->functionTemp[1] + i * 25) + 1.0) * 56.0;
colG[i] = (cosine(script->functionTemp[1] + i * 25 + 45) + 1.0) * 56.0; colG[i] = (cosine(script->functionTemp[1] + i * 25 + 45) + 1.0) * 56.0;
colB[i] = (cosine(script->functionTemp[1] + i * 25 + 90) + 1.0) * 56.0; colB[i] = (cosine(script->functionTemp[1] + i * 25 + 90) + 1.0) * 56.0;
} }
for (i = 0; i < 20; i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
set_npc_imgfx_comp(part->spriteInstanceID, 0, IMGFX_COLOR_BUF_SET_MODULATE, i, colR[i] << 0x18 | colG[i] << 0x10 | colB[i] << 8 | 255, 0, 255, 0); set_npc_imgfx_comp(part->spriteInstanceID, 0, IMGFX_COLOR_BUF_SET_MODULATE, i, colR[i] << 0x18 | colG[i] << 0x10 | colB[i] << 8 | 255, 0, 255, 0);
} }
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
#undef RGBA_BUF_SIZE
} }
#include "common/Dist3D.inc.c" #include "common/Dist3D.inc.c"

View File

@ -252,7 +252,7 @@ typedef struct PlayerCelebrationAnimOptions {
/* 0x00 */ s16 randomChance; /* 0x00 */ s16 randomChance;
/* 0x02 */ s16 hpBasedChance; /* 0x02 */ s16 hpBasedChance;
/* 0x04 */ s32 options[80]; /* 0x04 */ s32 options[80];
} PlayerCelebrationAnimOptions; // size = 0x8 } PlayerCelebrationAnimOptions; // size = 0x144
#ifndef NO_EXTERN_VARIABLES #ifndef NO_EXTERN_VARIABLES

View File

@ -4372,7 +4372,7 @@ void btl_state_update_partner_menu(void) {
break; break;
case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1: case BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1:
popupIndex = 0; popupIndex = 0;
for (i = 1; i < 12; i++) { for (i = 1; i < ARRAY_COUNT(PartnerIDFromMenuIndex); i++) {
s32 partnerId = PartnerIDFromMenuIndex[i]; s32 partnerId = PartnerIDFromMenuIndex[i];
if (playerData->partners[partnerId].enabled) { if (playerData->partners[partnerId].enabled) {
popupProps = &gPartnerPopupProperties[partnerId]; popupProps = &gPartnerPopupProperties[partnerId];

View File

@ -8,12 +8,13 @@
#endif #endif
API_CALLABLE(N(UpdateEnchantedBowserColors)) { API_CALLABLE(N(UpdateEnchantedBowserColors)) {
#define RGBA_BUF_SIZE 20
Actor* actor = get_actor(script->owner1.actorID); Actor* actor = get_actor(script->owner1.actorID);
ActorPart* part; ActorPart* part;
s32 i, j; s32 i, j;
u8 colR[20]; u8 colR[RGBA_BUF_SIZE];
u8 colG[20]; u8 colG[RGBA_BUF_SIZE];
u8 colB[20]; u8 colB[RGBA_BUF_SIZE];
s32 colorRGBA; s32 colorRGBA;
s32 temp; s32 temp;
s32 lol; s32 lol;
@ -39,7 +40,7 @@ API_CALLABLE(N(UpdateEnchantedBowserColors)) {
script->functionTemp[1] %= 360; script->functionTemp[1] %= 360;
} }
for (j = 0; j < 20; j++) { for (j = 0; j < RGBA_BUF_SIZE; j++) {
colR[j] = (cosine(script->functionTemp[1] + j * 25 + 120) + 1.0) * 56.0; colR[j] = (cosine(script->functionTemp[1] + j * 25 + 120) + 1.0) * 56.0;
colG[j] = (cosine(script->functionTemp[1] + j * 25 + 60) + 1.0) * 56.0; colG[j] = (cosine(script->functionTemp[1] + j * 25 + 60) + 1.0) * 56.0;
colB[j] = (cosine(script->functionTemp[1] + j * 25 + 180) + 1.0) * 56.0; colB[j] = (cosine(script->functionTemp[1] + j * 25 + 180) + 1.0) * 56.0;
@ -47,7 +48,7 @@ API_CALLABLE(N(UpdateEnchantedBowserColors)) {
if (part->eventFlags & BOWSER_FLAG_TOCHECK) { if (part->eventFlags & BOWSER_FLAG_TOCHECK) {
for (j = 0; j < 20; j++) { for (j = 0; j < RGBA_BUF_SIZE; j++) {
colorRGBA = colR[j] << 0x18 | colG[j] << 0x10 | colB[j] << 8 | 0xFF; colorRGBA = colR[j] << 0x18 | colG[j] << 0x10 | colB[j] << 8 | 0xFF;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_COLOR_BUF_SET_MODULATE, j, colorRGBA, 0, 255, 0); set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_COLOR_BUF_SET_MODULATE, j, colorRGBA, 0, 255, 0);
@ -56,7 +57,7 @@ API_CALLABLE(N(UpdateEnchantedBowserColors)) {
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
} else { } else {
s32 opacity = 255; s32 opacity = 255;
for (j = 0; j < 20; j++) { for (j = 0; j < RGBA_BUF_SIZE; j++) {
colorRGBA = 255; colorRGBA = 255;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
// TODO find better match for opacity // TODO find better match for opacity
@ -68,4 +69,6 @@ API_CALLABLE(N(UpdateEnchantedBowserColors)) {
script->functionTemp[0] = 0; script->functionTemp[0] = 0;
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
} }
#undef RGBA_BUF_SIZE
} }

View File

@ -124,7 +124,7 @@ EffectInstance* firework_rocket_main(s32 variation, f32 centerX, f32 centerY, f3
data->unk_3C = 150; data->unk_3C = 150;
data->unk_40 = 255; data->unk_40 = 255;
for (i = 0; i < 4; i++) { for (i = 0; i < ROCKET_BUF_SIZE; i++) {
data->rocketX[i] = data->pos.x; data->rocketX[i] = data->pos.x;
data->rocketY[i] = data->pos.y - 1000.0f; data->rocketY[i] = data->pos.y - 1000.0f;
data->rocketZ[i] = data->pos.z; data->rocketZ[i] = data->pos.z;
@ -189,7 +189,7 @@ void firework_rocket_update(EffectInstance* effect) {
data->rocketVelY[i] = (rand_int(10) - 5) * 0.1f; data->rocketVelY[i] = (rand_int(10) - 5) * 0.1f;
data->rocketVelZ[i] = (rand_int(10) - 5) * 0.1f; data->rocketVelZ[i] = (rand_int(10) - 5) * 0.1f;
for (i = 0; i < 4; i++) { for (i = 0; i < ROCKET_BUF_SIZE; i++) {
data->rocketX[i] += data->rocketVelX[i]; data->rocketX[i] += data->rocketVelX[i];
data->rocketY[i] += data->rocketVelY[i]; data->rocketY[i] += data->rocketVelY[i];
data->rocketZ[i] += data->rocketVelZ[i]; data->rocketZ[i] += data->rocketVelZ[i];

View File

@ -157,7 +157,7 @@ void motion_blur_flame_appendGfx(void* effect) {
gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data)); gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
gSPDisplayList(gMainGfxPos++, D_E00A29D0[temp_a2]); gSPDisplayList(gMainGfxPos++, D_E00A29D0[temp_a2]);
for (i = 0; i < 4; i++) { for (i = 0; i < UNK_ARRAY_SIZE_1; i++) {
f32 temp_f12 = data->unk_1C[i]; f32 temp_f12 = data->unk_1C[i];
f32 temp_f14 = data->unk_2C[i]; f32 temp_f14 = data->unk_2C[i];
f32 temp_f0 = data->unk_3C[i]; f32 temp_f0 = data->unk_3C[i];

View File

@ -103,7 +103,7 @@ EffectInstance* quizmo_audience_main(s32 arg0, f32 posX, f32 posY, f32 posZ) {
data->pos.z = posZ; data->pos.z = posZ;
data->lifeTime = 0; data->lifeTime = 0;
for(i = 0; i < 10; i++) { for (i = 0; i < ARRAY_COUNT(data->compState); i++) {
data->compState[i] = 0; data->compState[i] = 0;
data->compX[i] = data->compY[i] = 0.0f; data->compX[i] = data->compY[i] = 0.0f;
} }

View File

@ -118,7 +118,7 @@ void sun_update(EffectInstance* effect) {
} }
} }
for (i = 0; i < 5; i++) { for (i = 0; i < ARRAY_COUNT(data->texScrollAmt); i++) {
data->texScrollAmt[i] -= 4.0 data->texScrollAmt[i] -= 4.0
* ((sin_deg((time * 2 + (20 * i))) * 0.01) + 0.05) * ((sin_deg((time * 2 + (20 * i))) * 0.01) + 0.05)
* sin_deg(((f32) time * 0.25) + (SQ(i) * 20)); * sin_deg(((f32) time * 0.25) + (SQ(i) * 20));

View File

@ -21,7 +21,7 @@ void Entity_BoardedFloor_init_fragments(Entity* entity, Gfx** dlists, Mtx* matri
entity->pos.y = data->inititalY; entity->pos.y = data->inititalY;
guTranslateF(mtxTrans, entity->pos.x, entity->pos.y, entity->pos.z); guTranslateF(mtxTrans, entity->pos.x, entity->pos.y, entity->pos.z);
for (i = 0; i < 12; i++) { for (i = 0; i < FRAGMENT_BUF_SIZE - 1; i++) {
guMtxL2F(mtxFragment, ENTITY_ADDR(entity, Mtx*, matrices++)); guMtxL2F(mtxFragment, ENTITY_ADDR(entity, Mtx*, matrices++));
guMtxCatF(mtxTrans, mtxFragment, mtxFragment); guMtxCatF(mtxTrans, mtxFragment, mtxFragment);
data->fragmentPosX[i] = mtxFragment[3][0]; data->fragmentPosX[i] = mtxFragment[3][0];

View File

@ -2040,14 +2040,14 @@ Bytecode* evt_find_label(Evt* script, s32 arg1) {
return (Bytecode*) arg1; return (Bytecode*) arg1;
} }
for (i = 0; i < 16; i++) { for (i = 0; i < ARRAY_COUNT(script->labelIndices); i++) {
if (script->labelIndices[i] == arg1) { if (script->labelIndices[i] == arg1) {
ret = script->labelPositions[i]; ret = script->labelPositions[i];
break; break;
} }
} }
ASSERT(i < 16); ASSERT(i < ARRAY_COUNT(script->labelIndices));
return ret; return ret;
} }

View File

@ -1963,9 +1963,10 @@ void npc_remove_decoration_glow_behind(Npc* npc, s32 idx) {
} }
void npc_update_decoration_charged(Npc* npc, s32 idx) { void npc_update_decoration_charged(Npc* npc, s32 idx) {
u8 rbuf[20]; #define RGBA_BUF_SIZE 20
u8 gbuf[20]; u8 rbuf[RGBA_BUF_SIZE];
u8 bbuf[20]; u8 gbuf[RGBA_BUF_SIZE];
u8 bbuf[RGBA_BUF_SIZE];
s32 color; s32 color;
s32 alpha; s32 alpha;
s32 i; s32 i;
@ -1980,18 +1981,19 @@ void npc_update_decoration_charged(Npc* npc, s32 idx) {
npc->decorationGlowPhase[idx] %= 360; npc->decorationGlowPhase[idx] %= 360;
} }
for (i = 0; i < 20; i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
rbuf[i] = (cosine(npc->decorationGlowPhase[idx] + (25 * i)) + 1.0) * 80.0f; rbuf[i] = (cosine(npc->decorationGlowPhase[idx] + (25 * i)) + 1.0) * 80.0f;
gbuf[i] = (cosine(npc->decorationGlowPhase[idx] + (25 * i) + 45) + 1.0) * 80.0f; gbuf[i] = (cosine(npc->decorationGlowPhase[idx] + (25 * i) + 45) + 1.0) * 80.0f;
bbuf[i] = (cosine(npc->decorationGlowPhase[idx] + (25 * i) + 90) + 1.0) * 80.0f; bbuf[i] = (cosine(npc->decorationGlowPhase[idx] + (25 * i) + 90) + 1.0) * 80.0f;
} }
alpha = 255; alpha = 255;
for (i = 0; i < 20; i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
color = (rbuf[i] << 24) | (gbuf[i] << 16) | (bbuf[i] << 8) | alpha; color = (rbuf[i] << 24) | (gbuf[i] << 16) | (bbuf[i] << 8) | alpha;
set_npc_imgfx_all(npc->spriteInstanceID, IMGFX_COLOR_BUF_SET_MODULATE, i, color, 0, 255, 0); set_npc_imgfx_all(npc->spriteInstanceID, IMGFX_COLOR_BUF_SET_MODULATE, i, color, 0, 255, 0);
} }
} }
#undef RGBA_BUF_SIZE
} }
void npc_remove_decoration_charged(Npc* npc, s32 idx) { void npc_remove_decoration_charged(Npc* npc, s32 idx) {

View File

@ -418,7 +418,7 @@ void pause_partners_draw_contents(MenuPanel* menu, s32 baseX, s32 baseY, s32 wid
portraitOffsetX *= 0.01; portraitOffsetX *= 0.01;
portraitIndex = portraitScrollIndex; portraitIndex = portraitScrollIndex;
pause_partners_load_portrait(portraitIndex % gPausePartnersNumPartners); pause_partners_load_portrait(portraitIndex % gPausePartnersNumPartners);
for (i = 0; i < 2; portraitOffsetX += 150, i++) { for (i = 0; i < ARRAY_COUNT(gPausePartnersPaletteBuffers); portraitOffsetX += 150, i++) {
gSPDisplayList(gMainGfxPos++, &gPausePartnersDL); gSPDisplayList(gMainGfxPos++, &gPausePartnersDL);
gDPLoadTLUT_pal256(gMainGfxPos++, gPausePartnersPaletteBuffers[i]); gDPLoadTLUT_pal256(gMainGfxPos++, gPausePartnersPaletteBuffers[i]);

View File

@ -91,7 +91,7 @@ API_CALLABLE(N(func_80245028_8058A8)) {
if (isInitialCall) { if (isInitialCall) {
numEntries = 0; numEntries = 0;
for (i = 1; i < 12; i++) { for (i = 1; i < ARRAY_COUNT(PartnerIDFromMenuIndex); i++) {
partnerID = PartnerIDFromMenuIndex[i]; partnerID = PartnerIDFromMenuIndex[i];
if (playerData->partners[partnerID].enabled && partnerID != PARTNER_GOOMPA) { if (playerData->partners[partnerID].enabled && partnerID != PARTNER_GOOMPA) {
temp_s2 = &gPartnerPopupProperties[partnerID]; temp_s2 = &gPartnerPopupProperties[partnerID];

View File

@ -60,12 +60,13 @@ ImgFXOverlayTexture N(MonstarDetailTexture) = {
}; };
API_CALLABLE(N(UpdateMonstarSpriteEffects)) { API_CALLABLE(N(UpdateMonstarSpriteEffects)) {
#define RGBA_BUF_SIZE 20
Enemy* enemy = script->owner1.enemy; Enemy* enemy = script->owner1.enemy;
Npc* npc = get_npc_unsafe(enemy->npcID); Npc* npc = get_npc_unsafe(enemy->npcID);
u8 sp20[20]; u8 rbuf[RGBA_BUF_SIZE];
u8 sp38[20]; u8 gbuf[RGBA_BUF_SIZE];
u8 sp50[20]; u8 bbuf[RGBA_BUF_SIZE];
u8 sp68[20]; u8 abuf[RGBA_BUF_SIZE];
s32 i; s32 i;
if (isInitialCall) { if (isInitialCall) {
@ -84,13 +85,14 @@ API_CALLABLE(N(UpdateMonstarSpriteEffects)) {
script->functionTemp[0] %= 360; script->functionTemp[0] %= 360;
} }
for (i = 0; i < 20; i++) { for (i = 0; i < RGBA_BUF_SIZE; i++) {
sp20[i] = (cosine(script->functionTemp[0] + (i * 25)) + 1.0) * 56.0; rbuf[i] = (cosine(script->functionTemp[0] + (i * 25)) + 1.0) * 56.0;
sp38[i] = (cosine(script->functionTemp[0] + (i * 25) + 45) + 1.0) * 56.0; gbuf[i] = (cosine(script->functionTemp[0] + (i * 25) + 45) + 1.0) * 56.0;
sp50[i] = (cosine(script->functionTemp[0] + (i * 25) + 90) + 1.0) * 56.0; bbuf[i] = (cosine(script->functionTemp[0] + (i * 25) + 90) + 1.0) * 56.0;
sp68[i] = enemy->varTable[3]; abuf[i] = enemy->varTable[3];
set_npc_imgfx_comp(npc->spriteInstanceID, 0, IMGFX_COLOR_BUF_SET_MODULATE, i, (sp20[i] << 24) | (sp38[i] << 16) | (sp50[i] << 8) | sp68[i], 0, 255, 0); set_npc_imgfx_comp(npc->spriteInstanceID, 0, IMGFX_COLOR_BUF_SET_MODULATE, i,
(rbuf[i] << 24) | (gbuf[i] << 16) | (bbuf[i] << 8) | abuf[i], 0, 255, 0);
} }
if (enemy->varTable[3] == 255) { if (enemy->varTable[3] == 255) {
@ -98,9 +100,12 @@ API_CALLABLE(N(UpdateMonstarSpriteEffects)) {
set_npc_imgfx_comp(npc->spriteInstanceID, 1, IMGFX_OVERLAY, (s32) &N(MonstarDetailTexture), 255, 0, 255, 0); set_npc_imgfx_comp(npc->spriteInstanceID, 1, IMGFX_OVERLAY, (s32) &N(MonstarDetailTexture), 255, 0, 255, 0);
} else { } else {
npc->renderMode = RENDER_MODE_SURFACE_XLU_LAYER2; npc->renderMode = RENDER_MODE_SURFACE_XLU_LAYER2;
set_npc_imgfx_comp(npc->spriteInstanceID, 1, IMGFX_OVERLAY, (s32) &N(MonstarDetailTexture), enemy->varTable[3], 0, enemy->varTable[3], 0); set_npc_imgfx_comp(npc->spriteInstanceID, 1, IMGFX_OVERLAY, (s32) &N(MonstarDetailTexture),
enemy->varTable[3], 0, enemy->varTable[3], 0);
} }
return ApiStatus_BLOCK; return ApiStatus_BLOCK;
#undef RGBA_BUF_SIZE
} }
API_CALLABLE(N(CheckSkipInput)) { API_CALLABLE(N(CheckSkipInput)) {