8extern Addr imgfx_data_ROM_START;
128Lights2
ImgFXLights = gdSPDefLights2(144, 144, 144, 255, 255, 255, 0, 0, 120, 255, 255, 255, 0, 0, 136);
132 .vscale = { 640, 480, 511, 0 },
133 .vtrans = { 640, 480, 511, 0 },
139 .vscale = { 640, 480, 511, 0 },
140 .vtrans = { 640, 480, 512, 0 },
147 gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
148 gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
149 gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
150 gsDPSetAlphaCompare(G_AC_NONE),
151 gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 18,
152 G_AD_DISABLE | G_CD_DISABLE | G_TC_FILT | G_TF_BILERP | G_TP_PERSP),
153 gsSPEndDisplayList(),
291 (*ImgFXInstances)[i].colorBuf = NULL;
292 (*ImgFXInstances)[i].colorBufCount = 0;
352 if (numAssigned < count) {
369 (*ImgFXInstances)[iPrev].nextIdx = i;
372 (*ImgFXInstances)[i].arrayIdx = i;
377 if (numAssigned == count) {
378 (*ImgFXInstances)[i].nextIdx = -1;
388 (*ImgFXInstances)[idx].flags = 0;
389 (*ImgFXInstances)[idx].nextIdx = -1;
398 next = (*ImgFXInstances)[idx].nextIdx;
401 }
while (next != -1);
418 return &(*ImgFXInstances)[idx];
425 if (state->
vtxBufs[0] != NULL) {
429 if (state->
vtxBufs[1] != NULL) {
433 if (state->
gfxBufs[0] != NULL) {
437 if (state->
gfxBufs[1] != NULL) {
499 oldFlags = state->
flags;
502 state->
flags = oldFlags;
546 && state->
ints.
anim.type == imgfxArg1
547 && state->
ints.
anim.interval == imgfxArg2
548 && state->
ints.
anim.step == imgfxArg3
608 if (imgfxArg1 >= 255 && imgfxArg2 >= 255 && imgfxArg3 >= 255 && imgfxArg4 >= 255) {
611 }
else if (imgfxArg4 >= 255) {
614 }
else if (imgfxArg1 >= 255 && imgfxArg2 >= 255 && imgfxArg3 >= 255) {
624 if (imgfxArg4 == 255.0) {
631 if (imgfxArg1 < state->colorBufCount) {
633 r = (imgfxArg2 & 0xFF000000) >> 24;
634 g = (imgfxArg2 & 0xFF0000) >> 16;
635 b = (imgfxArg2 & 0xFF00) >> 8;
636 a = (imgfxArg2 & 0xFF);
652 if (imgfxArg1 < state->colorBufCount) {
654 r = (imgfxArg2 & 0xFF000000) >> 24;
655 g = (imgfxArg2 & 0xFF0000) >> 16;
656 b = (imgfxArg2 & 0xFF00) >> 8;
657 a = (imgfxArg2 & 0xFF);
681 if (imgfxArg2 >= 255) {
697 (*ImgFXInstances)[idx].flags |= flagBits;
699 (*ImgFXInstances)[idx].flags &= ~flagBits;
708 if (ifxImg->
alpha == 0) {
713 state->
flags |= flagBits;
762 if (state->
ints.
raw[1][2] == 0) {
797 s16 skipModeChange = FALSE;
825 mode1 = renderMode->
mode1;
826 mode2 = renderMode->
mode2;
828 skipModeChange = TRUE;
849 primAlpha = state->
ints.
color.a * ifxImgAlpha;
853 skipModeChange = TRUE;
857 mode1 &= ~CVG_DST_FULL;
858 mode2 &= ~CVG_DST_FULL;
859 mode1 |= (ALPHA_CVG_SEL | IM_RD);
860 mode2 |= (ALPHA_CVG_SEL | IM_RD);
867 if (skipModeChange) {
871 mode1 |= (Z_CMP | Z_UPD);
872 mode2 |= (Z_CMP | Z_UPD);
878 switch (renderType) {
882 gDPSetCombineMode(
gMainGfxPos++, G_CC_MODULATEIDECALA_PRIM, G_CC_MODULATEIDECALA_PRIM);
889 if (primAlpha <= 0) {
893 gDPSetPrimColor(
gMainGfxPos++, 0, 0, 0, 0, 0, primAlpha);
898 if (primAlpha <= 0) {
901 gDPSetCombineMode(
gMainGfxPos++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
915 if (primAlpha <= 0) {
925 gDPSetCombineMode(
gMainGfxPos++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
926 gSPSetGeometryMode(
gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
933 gSPSetGeometryMode(
gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
940 gSPSetGeometryMode(
gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
946 gDPSetCombineMode(
gMainGfxPos++, G_CC_MODULATEIA, G_CC_MODULATEIA);
947 gSPSetGeometryMode(
gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
954 gSPSetGeometryMode(
gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
961 gDPSetCombineMode(
gMainGfxPos++, G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA);
962 gSPSetGeometryMode(
gMainGfxPos++, G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
975 gDPSetCombineMode(
gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
979 primAlpha = state->
ints.
hologram.alphaAmt * ifxImgAlpha;
989 primAlpha = state->
ints.
hologram.alphaAmt * ifxImgAlpha;
993 gDPSetPrimColor(
gMainGfxPos++, 0, 0, 0, 0, 0, primAlpha);
997 if (blendAlpha > 255) {
1000 primAlpha = state->
ints.
hologram.alphaAmt * ifxImgAlpha;
1005 gDPSetAlphaCompare(
gMainGfxPos++, G_AC_THRESHOLD);
1006 gDPSetPrimColor(
gMainGfxPos++, 0, 0, 0, 0, 0, primAlpha);
1007 gDPSetBlendColor(
gMainGfxPos++, 0, 0, 0, blendAlpha);
1022 gDPSetCombineMode(
gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
1101 leftColor = rightColor + 120;
1158 for (i = 0; i <= state->
subdivY; i++) {
1168 for (j = 0; j <= state->
subdivX; vtx++, j++) {
1173 vtx->n.ob[0] = posX;
1174 vtx->n.ob[1] = posY;
1176 vtx->n.tc[0] = ((s32) texU + 256) * 32;
1177 vtx->n.tc[1] = ((s32) texV + 256) * 32;
1200 if (state->
vtxBufs[0] != NULL) {
1204 if (state->
vtxBufs[1] != NULL) {
1208 if (state->
gfxBufs[0] != NULL) {
1212 if (state->
gfxBufs[1] != NULL) {
1214 romEnd = (u8*) state->
gfxBufs[1];
1223 romStart = imgfx_data_ROM_START + (s32)anim->
gfxOffset;
1224 romEnd = romStart + anim->
gfxCount *
sizeof(Gfx);
1231 Gfx* gfxBuffer = state->
gfxBufs[i];
1237 u32 w0 = gfxBuffer[j++].words.w0;
1245 gfxBuffer[j-1].words.w1 = ((((s32) gfxBuffer[j-1].words.w1 - (s32) anim->
keyframesOffset) / 3) * 4) +
1248 }
while (cmd != G_ENDDL);
1256 s32 absKeyframeInterval;
1261 s32 keyframeInterval = state->
ints.
anim.interval;
1262 s32 animStep = state->
ints.
anim.step;
1263 s32 curSubframe = state->
floats.
anim.curFrame;
1269 if (header == NULL) {
1274 state->
flags &= ~IMGFX_FLAG_200;
1280 absKeyframeInterval = abs(keyframeInterval);
1282 nextKeyIdx = curKeyIdx;
1285 nextKeyIdx = curKeyIdx - 1;
1286 if (nextKeyIdx < 0) {
1287 nextKeyIdx = curKeyIdx;
1293 nextKeyIdx = curKeyIdx + 1;
1295 nextKeyIdx = curKeyIdx;
1307 if (keyframeInterval > 1) {
1313 lerpAlpha = (f32) curSubframe / (f32) keyframeInterval;
1314 for (i = 0; i < header->
vtxCount; i++) {
1319 if (keyframeInterval > 1) {
1376 if (nextKeyframe != NULL) {
1384 if (keyframeInterval > 0) {
1386 if (curSubframe >= keyframeInterval) {
1389 if (curKeyIdx < 0) {
1418 }
else if (keyframeInterval < 0) {
1420 curKeyIdx -= absKeyframeInterval;
1421 if (curKeyIdx < 0) {
1434 curKeyIdx += absKeyframeInterval;
1477 && (state->
flags & someFlags)
1489 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP,
1491 G_TX_NOLOD, G_TX_NOLOD,
1493 gDPSetTile(
gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x100, 2, 0,
1494 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP,
1495 G_TX_NOMASK, G_TX_NOLOD);
1513 && (state->
flags & someFlags)
1533 gSP2Triangles(
gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1544 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP,
1546 G_TX_NOLOD, G_TX_NOLOD,
1551 && (state->
flags & someFlags)
1562 if (alpha2 == 255) {
1563 gDPSetRenderMode(
gMainGfxPos++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
1565 gDPSetRenderMode(
gMainGfxPos++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
1589 gSP2Triangles(
gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1592 if (alpha2 == 255) {
1593 gDPSetRenderMode(
gMainGfxPos++, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2);
1595 gDPSetRenderMode(
gMainGfxPos++, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2);
1598 gDPSetEnvColor(
gMainGfxPos++, 100, 100, 100, 255);
1599 gDPSetPrimColor(
gMainGfxPos++, 0, 0, 0, 0, 0, alpha2);
1608 && (state->
flags & someFlags)
1621 gSP2Triangles(
gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1641 for (i = 0; i < state->
subdivY; i++) {
1642 for (j = 0; j < state->
subdivX; j++) {
1643 s32 ulIdx = firstVtxIdx + i * (state->
subdivX + 1) + j;
1644 s32 urIdx = firstVtxIdx + i * (state->
subdivX + 1) + j + 1;
1645 s32 llIdx = firstVtxIdx + (i + 1) * (state->
subdivX + 1) + j;
1646 s32 lrIdx = firstVtxIdx + (i + 1) * (state->
subdivX + 1) + j + 1;
1649 && (*ImgFXInstances)[0].arrayIdx != 0
1662 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP,
1664 G_TX_NOLOD, G_TX_NOLOD,
1666 gDPSetTile(
gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
1667 gDPSetTileSize(
gMainGfxPos++, 2, 0, 0, 63 << 2, 0);
1691 G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP,
1693 G_TX_NOLOD, G_TX_NOLOD,
1702 gSP2Triangles(
gMainGfxPos++, 0, 2, 1, 0, 1, 2, 3, 0);
1729 G_TX_CLAMP, G_TX_CLAMP, 8, 8, G_TX_NOLOD, G_TX_NOLOD,
1731 gDPSetTile(
gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0,
1732 G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
1753 G_TX_CLAMP, G_TX_CLAMP, 8, 8, G_TX_NOLOD, G_TX_NOLOD,
1770 gDPSetRenderMode(
gMainGfxPos++, G_RM_ZB_XLU_DECAL, G_RM_ZB_XLU_DECAL2);
1774 gDPSetPrimColor(
gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
1777 gDPSetCombineMode(
gMainGfxPos++, G_CC_MODULATEIA, G_CC_MODULATEIA);
1783 G_TX_WRAP, G_TX_WRAP, shifts, shiftt, G_TX_NOLOD, G_TX_NOLOD,
1790 gDPSetTileSize(
gMainGfxPos++, G_TX_RENDERTILE, uls, ult, lrs, lrt);
1823 while (phase1 > 360.0) {
1828 while (phase2 > 360.0) {
1833 while (phase3 > 360.0) {
1857 for (i = 0; i < amt; i++) {
1858 angle1 = state->
floats.
wavy.phase1 + (angleInc * 45) + (
sign * 180);
1859 angle2 = state->
floats.
wavy.phase2 + (angleInc * 45) + (
sign * 180);
1860 angle3 = state->
floats.
wavy.phase3 + (angleInc * 45) + (
sign * 180);
1876 if (i % (state->
subdivX + 1) == 0) {
1888 for (i = 0; i <= vtxCount; i++) {
@ SPR_SHADING_FLAG_SET_VIEWPORT
@ SPR_SHADING_FLAG_ENABLED
@ IMGFX_RENDER_MULTIPLY_RGBA
@ IMGFX_RENDER_MULTIPLY_SHADE_ALPHA
@ IMGFX_RENDER_MULTIPLY_SHADE_RGB
@ IMGFX_RENDER_OVERLAY_RGBA
@ IMGFX_RENDER_MODULATE_PRIM_RGBA
@ IMGFX_RENDER_MULTIPLY_RGB
@ IMGFX_RENDER_MULTIPLY_SHADE_RGBA
@ IMGFX_RENDER_OVERLAY_RGB
@ IMGFX_RENDER_MODULATE_PRIM_RGB
@ IMGFX_RENDER_MULTIPLY_ALPHA
@ IMGFX_RENDER_MODULATE_SHADE_RGB
@ IMGFX_RENDER_MODULATE_SHADE_RGBA
@ IMGFX_RENDER_COLOR_FILL
@ IMGFX_COLOR_BUF_SET_MULTIPLY
@ IMGFX_COLOR_BUF_SET_MODULATE
@ IMGFX_ANIM_VERTICAL_PIPE_CURL
@ IMGFX_ANIM_HORIZONTAL_PIPE_CURL
@ IMGFX_ANIM_FLUTTER_DOWN
@ IMGFX_ANIM_SHUFFLE_CARDS
@ IMGFX_ANIM_SPIRIT_CAPTURE
@ IMGFX_ANIM_TUTANKOOPA_SWIRL_1
@ IMGFX_ANIM_TUTANKOOPA_SWIRL_2
@ IMGFX_ANIM_CYMBAL_CRUSH
@ IMGFX_ANIM_TUTANKOOPA_GATHER
@ IMGFX_RENDER_NO_OVERRIDE
@ IMGFX_HOLOGRAM_THRESHOLD
@ IMGFX_FLAG_SKIP_TEX_SETUP
@ IMGFX_FLAG_G_CULL_FRONT
@ IMGFX_FLAG_REVERSE_ANIM
@ IMGFX_FLAG_NO_FILTERING
@ IMGFX_FLAG_SKIP_GFX_SETUP
s32 integer_log(s32 number, u32 base)
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
void * _heap_malloc(HeapNode *head, u32 size)
s32 general_heap_free(void *data)
void * heap_malloc(s32 size)
#define gDPScrollMultiTile2_4b(pkt, timg, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt)
#define gDPScrollTextureTile_4b(pkt, timg, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt)
void imgfx_release_instance(u32 idx)
ImgFXState ImgFXInstanceList[MAX_IMGFX_INSTANCES]
struct ImgFXFloatVars::@129 anim
void imgfx_wavy_init(ImgFXState *state)
Addr vertical_pipe_curl_header
void imgfx_update_cache(void)
void imgfx_clear_instance_data(ImgFXState *state)
void imgfx_appendGfx_mesh_strip(ImgFXState *, Matrix4f mtx)
struct ImgFXFloatVars::@131 overlay
Addr shuffle_cards_header
struct ImgFXIntVars::@124 anim
s32 imgfx_get_next_instance(s32 idx)
BSS ImgFXAnimHeader ImgFXAnimHeaders[MAX_IMGFX_INSTANCES]
ImgFXAnimHeader * imgfx_load_anim(ImgFXState *state)
void imgfx_mesh_make_strip(ImgFXState *state)
ImgFXWorkingTexture * ImgFXCurrentTexturePtr
ImgFXRenderMode ImgFXRenderModes[]
void imgfx_update_cache_impl(void)
struct ImgFXIntVars::@126 color
void imgfx_set_vtx_buf_capacity(s16 arg0)
BSS Vtx * ImgFXVtxBuffers[2]
void imgfx_mesh_load_colors(ImgFXState *state)
struct ImgFXIntVars::@123 args
ImgFXState * imgfx_get_instance(s32 idx)
void imgfx_add_to_cache(void *data, s8 usingContextualHeap)
void imgfx_mesh_make_grid(ImgFXState *state)
s32 imgfx_get_free_instances(s32 count)
BSS ImgFXInstanceList * ImgFXInstances
void imgfx_appendGfx_mesh_basic(ImgFXState *, Matrix4f mtx)
s32 imgfx_appendGfx_component(s32 idx, ImgFXTexture *ifxImg, u32 flagBits, Matrix4f mtx)
void imgfx_appendGfx_mesh_anim(ImgFXState *, Matrix4f mtx)
Addr horizontal_pipe_curl_header
void imgfx_set_state_flags(s32 idx, u16 flagBits, s32 mode)
void imgfx_appendGfx_mesh_grid(ImgFXState *, Matrix4f mtx)
@ IMGFX_ANIM_FLAG_ABSOLUTE_COORDS
Addr tutankoopa_gather_header
struct ImgFXIntVars::@125 wavy
void imgfx_appendGfx_mesh(ImgFXState *state, Matrix4f mtx)
struct ImgFXIntVars::@128 overlay
void imgfx_release_instance_chain(u32 idx)
u16 ImgFXVtxBufferCapacity
Gfx DefaultImgFXSetupGfx[]
struct ImgFXFloatVars::@130 wavy
void imgfx_update(u32 idx, ImgFXType type, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 flags)
void imgfx_init_instance(ImgFXState *state)
Addr tutankoopa_swirl_2_header
void imgfx_cache_instance_data(ImgFXState *state)
BSS ImgFXCacheEntry ImgFXDataCache[8]
struct ImgFXIntVars::@127 hologram
void imgfx_mesh_make_wavy(ImgFXState *state)
BSS ImgFXWorkingTexture ImgFXCurrentTexture
void imgfx_mesh_anim_update(ImgFXState *state)
void imgfx_make_mesh(ImgFXState *state)
Addr tutankoopa_swirl_1_header
Addr spirit_capture_header
ImgFXVtx * keyframesOffset
#define PM_CC_IMGFX_COLOR_FILL
#define MAX_IMGFX_INSTANCES
#define VIRTUAL_TO_PHYSICAL(addr)
#define PM_CC_IMGFX_HOLOGRAM
void create_shading_palette(Matrix4f mtx, s32 uls, s32 ult, s32 lrs, s32 lrt, s32 alpha, s32)
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
GameStatus * gGameStatusPtr
SpriteShadingProfile * gSpriteShadingProfile
s32 gCurrentDisplayContextIndex
DisplayContext * gDisplayContext