mirror of
https://github.com/pmret/papermario.git
synced 2025-12-19 17:58:12 -05:00
minor-sprite-doc (#1246)
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
#define SPRITE_ROM_START 0x1A40000 + 0x10
|
#define SPRITE_ROM_START 0x1A40000 + 0x10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern s32 spr_allocateBtlComponentsOnWorldHeap;
|
extern bool SpriteUseGeneralHeap;
|
||||||
extern HeapNode heap_generalHead;
|
extern HeapNode heap_generalHead;
|
||||||
extern HeapNode heap_spriteHead;
|
extern HeapNode heap_spriteHead;
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ SpriteComponent** spr_allocate_components(s32 count) {
|
|||||||
listSize = (count + 1) * 4;
|
listSize = (count + 1) * 4;
|
||||||
totalSize = (count * sizeof(SpriteComponent)) + listSize;
|
totalSize = (count * sizeof(SpriteComponent)) + listSize;
|
||||||
|
|
||||||
if (spr_allocateBtlComponentsOnWorldHeap) {
|
if (SpriteUseGeneralHeap) {
|
||||||
listStart = _heap_malloc(&heap_generalHead, totalSize);
|
listStart = _heap_malloc(&heap_generalHead, totalSize);
|
||||||
listPos = listStart;
|
listPos = listStart;
|
||||||
component = (SpriteComponent*) listPos;
|
component = (SpriteComponent*) listPos;
|
||||||
|
|||||||
232
src/sprite.c
232
src/sprite.c
@@ -7,32 +7,32 @@ extern HeapNode heap_generalHead;
|
|||||||
extern HeapNode heap_spriteHead;
|
extern HeapNode heap_spriteHead;
|
||||||
|
|
||||||
BSS s32 D_802DF520; // unused?
|
BSS s32 D_802DF520; // unused?
|
||||||
BSS s32 spr_allocateBtlComponentsOnWorldHeap;
|
BSS bool SpriteUseGeneralHeap;
|
||||||
BSS s32 D_802DF528[2]; // unused?
|
BSS s32 D_802DF528[2]; // unused?
|
||||||
BSS s32 MaxLoadedSpriteInstanceID;
|
BSS s32 MaxLoadedSpriteInstanceID;
|
||||||
BSS s32 D_802DF534[3]; // unused?
|
BSS s32 D_802DF534[3]; // unused?
|
||||||
BSS s32 D_802DF540;
|
BSS s32 CurSpriteImgFX;
|
||||||
BSS s32 D_802DF544; // unused?
|
BSS s32 D_802DF544; // unused?
|
||||||
BSS SpriteAnimData* spr_playerSprites[13];
|
BSS SpriteAnimData* PlayerSprites[13];
|
||||||
BSS s32 D_802DF57C;
|
BSS s32 CurPlayerSpriteIndex;
|
||||||
BSS s32 spr_playerMaxComponents;
|
BSS s32 MaxPlayerSpriteComponents;
|
||||||
BSS s32 D_802DF584; // unused?
|
BSS s32 D_802DF584; // unused?
|
||||||
BSS PlayerCurrentAnimInfo spr_playerCurrentAnimInfo[3];
|
BSS PlayerCurrentAnimInfo CurPlayerAnimInfo[3];
|
||||||
BSS s32 D_802DF5AC; // unused?
|
BSS s32 D_802DF5AC; // unused?
|
||||||
BSS SpriteAnimData* NpcSpriteData[MAX_SPRITE_ID];
|
BSS SpriteAnimData* NpcSpriteData[MAX_SPRITE_ID];
|
||||||
BSS u8 NpcSpriteInstanceCount[MAX_SPRITE_ID];
|
BSS u8 NpcSpriteInstanceCount[MAX_SPRITE_ID];
|
||||||
BSS s32 D_802DFA44; // unused?
|
BSS s32 D_802DFA44; // unused?
|
||||||
BSS SpriteInstance SpriteInstances[51];
|
BSS SpriteInstance SpriteInstances[51];
|
||||||
BSS Quad* D_802DFE44;
|
BSS Quad* SpriteQuadCache;
|
||||||
BSS s32 D_802DFE48[22];
|
BSS s32 SpriteQuadCacheInfo[22]; // upper bytes: width, height; lower 16 bits: time left
|
||||||
BSS s32 D_802DFEA0[3];
|
BSS s32 SpriteCurBaseRot[3];
|
||||||
BSS s32 SpriteUpdateNotifyValue;
|
BSS s32 SpriteUpdateNotifyValue;
|
||||||
|
|
||||||
SpriteComponent** spr_allocate_components(s32);
|
SpriteComponent** spr_allocate_components(s32);
|
||||||
void spr_load_npc_extra_anims(SpriteAnimData*, u32*);
|
void spr_load_npc_extra_anims(SpriteAnimData*, u32*);
|
||||||
void spr_init_player_raster_cache(s32 cacheSize, s32 maxRasterSize);
|
void spr_init_player_raster_cache(s32 cacheSize, s32 maxRasterSize);
|
||||||
|
|
||||||
Quad spr_defaultQuad = {
|
Quad SpriteQuadTemplate = {
|
||||||
{
|
{
|
||||||
{{{ -16, 56, 0 }, false, { 0, 0 }, { 240, 240, 240, 255 }}},
|
{{{ -16, 56, 0 }, false, { 0, 0 }, { 240, 240, 240, 255 }}},
|
||||||
{{{ 16, 56, 0 }, false, { 1024, 0 }, { 120, 120, 120, 255 }}},
|
{{{ 16, 56, 0 }, false, { 1024, 0 }, { 120, 120, 120, 255 }}},
|
||||||
@@ -41,19 +41,19 @@ Quad spr_defaultQuad = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Vp SprPauseVp = {{
|
Vp SpritePauseVp = {{
|
||||||
{ 640, 480, 511, 0 },
|
{ 640, 480, 511, 0 },
|
||||||
{ 640, 480, 511, 0 },
|
{ 640, 480, 511, 0 },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Vp SprPauseVpAlt = {{
|
Vp SpritePauseVpAlt = {{
|
||||||
{ 640, 480, 511, 0 },
|
{ 640, 480, 511, 0 },
|
||||||
{ 640, 480, 512, 0 },
|
{ 640, 480, 512, 0 },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Gfx D_802DF3F0[] = {
|
Gfx OpaqueSpriteGfx[] = {
|
||||||
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
||||||
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
|
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
|
||||||
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
||||||
@@ -63,7 +63,7 @@ Gfx D_802DF3F0[] = {
|
|||||||
gsSPEndDisplayList(),
|
gsSPEndDisplayList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Gfx D_802DF428[] = {
|
Gfx TranslucentSpriteGfx[] = {
|
||||||
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
||||||
gsDPSetCombineMode(PM_CC_02, PM_CC_02),
|
gsDPSetCombineMode(PM_CC_02, PM_CC_02),
|
||||||
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
||||||
@@ -73,7 +73,7 @@ Gfx D_802DF428[] = {
|
|||||||
gsSPEndDisplayList(),
|
gsSPEndDisplayList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Gfx D_802DF460[] = {
|
Gfx OpaqueShadedSpriteGfx[] = {
|
||||||
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
||||||
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
||||||
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
|
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
|
||||||
@@ -82,7 +82,7 @@ Gfx D_802DF460[] = {
|
|||||||
gsSPEndDisplayList(),
|
gsSPEndDisplayList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
Gfx D_802DF490[] = {
|
Gfx TranslucentShadedSpriteGfx[] = {
|
||||||
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
gsSPClearGeometryMode(G_CULL_BOTH | G_LIGHTING),
|
||||||
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
gsSPTexture(-1, -1, 0, G_TX_RENDERTILE, G_ON),
|
||||||
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
|
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH),
|
||||||
@@ -91,7 +91,7 @@ Gfx D_802DF490[] = {
|
|||||||
gsSPEndDisplayList(),
|
gsSPEndDisplayList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
f32 spr_animUpdateTimeScale = 1.0f;
|
f32 SpriteAnimUpdateTimescale = 1.0f;
|
||||||
|
|
||||||
#define MARIO_SPRITE_COMMON_BITS \
|
#define MARIO_SPRITE_COMMON_BITS \
|
||||||
1 << SPR_Mario1 \
|
1 << SPR_Mario1 \
|
||||||
@@ -118,7 +118,7 @@ f32 spr_animUpdateTimeScale = 1.0f;
|
|||||||
|
|
||||||
// TODO(player raster splat header generation):
|
// TODO(player raster splat header generation):
|
||||||
// - macroify rasterSize based on the biggest raster
|
// - macroify rasterSize based on the biggest raster
|
||||||
PlayerSpriteSet spr_playerSpriteSets[] = {
|
PlayerSpriteSet PlayerSpriteSets[] = {
|
||||||
[PLAYER_SPRITES_MARIO_WORLD] { 6, 0x700, MARIO_SPRITE_WORLD_BITS },
|
[PLAYER_SPRITES_MARIO_WORLD] { 6, 0x700, MARIO_SPRITE_WORLD_BITS },
|
||||||
[PLAYER_SPRITES_MARIO_REFLECT_FLOOR] { 18, 0x700, MARIO_SPRITE_WORLD_BITS },
|
[PLAYER_SPRITES_MARIO_REFLECT_FLOOR] { 18, 0x700, MARIO_SPRITE_WORLD_BITS },
|
||||||
[PLAYER_SPRITES_COMBINED_EPILOGUE] { 10, 0x900, MARIO_SPRITE_WORLD_BITS | PEACH_SPRITE_BITS },
|
[PLAYER_SPRITES_COMBINED_EPILOGUE] { 10, 0x900, MARIO_SPRITE_WORLD_BITS | PEACH_SPRITE_BITS },
|
||||||
@@ -131,25 +131,25 @@ PlayerSpriteSet spr_playerSpriteSets[] = {
|
|||||||
void spr_init_quad_cache(void) {
|
void spr_init_quad_cache(void) {
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
D_802DFE44 = _heap_malloc(&heap_spriteHead, ARRAY_COUNT(D_802DFE48) * sizeof(*D_802DFE44));
|
SpriteQuadCache = _heap_malloc(&heap_spriteHead, ARRAY_COUNT(SpriteQuadCacheInfo) * sizeof(*SpriteQuadCache));
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(D_802DFE48); i++) {
|
for (i = 0; i < ARRAY_COUNT(SpriteQuadCacheInfo); i++) {
|
||||||
D_802DFE48[i] = -1;
|
SpriteQuadCacheInfo[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Quad* spr_get_cached_quad(s32 quadIndex) {
|
Quad* spr_get_cached_quad(s32 quadIndex) {
|
||||||
s32* temp_v1 = &D_802DFE48[quadIndex];
|
s32* temp_v1 = &SpriteQuadCacheInfo[quadIndex];
|
||||||
|
|
||||||
*temp_v1 |= 0x1F;
|
*temp_v1 |= 0x1F;
|
||||||
return &D_802DFE44[quadIndex];
|
return &SpriteQuadCache[quadIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void spr_make_quad_for_size(Quad* quad, s32 width, s32 height) {
|
void spr_make_quad_for_size(Quad* quad, s32 width, s32 height) {
|
||||||
Vtx* vtx = &quad->v[0];
|
Vtx* vtx = &quad->v[0];
|
||||||
s32 w = width; // required to match
|
s32 w = width; // required to match
|
||||||
|
|
||||||
*quad = spr_defaultQuad;
|
*quad = SpriteQuadTemplate;
|
||||||
|
|
||||||
vtx->v.ob[0] = -w / 2;
|
vtx->v.ob[0] = -w / 2;
|
||||||
vtx->v.ob[1] = height;
|
vtx->v.ob[1] = height;
|
||||||
@@ -182,26 +182,26 @@ Quad* spr_get_quad_for_size(s32* quadIndex, s32 width, s32 height) {
|
|||||||
if ((width * height) / 2 <= 0x800) {
|
if ((width * height) / 2 <= 0x800) {
|
||||||
dimensions = (width << 0x18) + (height << 0x10);
|
dimensions = (width << 0x18) + (height << 0x10);
|
||||||
qi = *quadIndex;
|
qi = *quadIndex;
|
||||||
if (qi != -1 && (dimensions == (D_802DFE48[qi] & 0xFFFF0000))) {
|
if (qi != -1 && (dimensions == (SpriteQuadCacheInfo[qi] & 0xFFFF0000))) {
|
||||||
return spr_get_cached_quad(qi);
|
return spr_get_cached_quad(qi);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(D_802DFE48); i++) {
|
for (i = 0; i < ARRAY_COUNT(SpriteQuadCacheInfo); i++) {
|
||||||
if (dimensions == (D_802DFE48[i] & 0xFFFF0000)) {
|
if (dimensions == (SpriteQuadCacheInfo[i] & 0xFFFF0000)) {
|
||||||
*quadIndex = i;
|
*quadIndex = i;
|
||||||
return spr_get_cached_quad(i);
|
return spr_get_cached_quad(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(D_802DFE48); i++) {
|
for (i = 0; i < ARRAY_COUNT(SpriteQuadCacheInfo); i++) {
|
||||||
if (D_802DFE48[i] == -1) {
|
if (SpriteQuadCacheInfo[i] == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != ARRAY_COUNT(D_802DFE48)) {
|
if (i != ARRAY_COUNT(SpriteQuadCacheInfo)) {
|
||||||
*quadIndex = i;
|
*quadIndex = i;
|
||||||
D_802DFE48[i] = dimensions;
|
SpriteQuadCacheInfo[i] = dimensions;
|
||||||
quad = spr_get_cached_quad(i);
|
quad = spr_get_cached_quad(i);
|
||||||
spr_make_quad_for_size(quad, width, height);
|
spr_make_quad_for_size(quad, width, height);
|
||||||
return quad;
|
return quad;
|
||||||
@@ -213,11 +213,11 @@ Quad* spr_get_quad_for_size(s32* quadIndex, s32 width, s32 height) {
|
|||||||
void spr_clear_quad_cache(void) {
|
void spr_clear_quad_cache(void) {
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(D_802DFE48); i++) {
|
for (i = 0; i < ARRAY_COUNT(SpriteQuadCacheInfo); i++) {
|
||||||
if (D_802DFE48[i] != -1) {
|
if (SpriteQuadCacheInfo[i] != -1) {
|
||||||
D_802DFE48[i]--;
|
SpriteQuadCacheInfo[i]--;
|
||||||
if (!(D_802DFE48[i] & 0xFFFF)) {
|
if (!(SpriteQuadCacheInfo[i] & 0xFFFF)) {
|
||||||
D_802DFE48[i] = -1;
|
SpriteQuadCacheInfo[i] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ void spr_appendGfx_component_flat(
|
|||||||
if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) {
|
if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) {
|
||||||
Camera* camera = &gCameras[gCurrentCamID];
|
Camera* camera = &gCameras[gCurrentCamID];
|
||||||
if (gGameStatusPtr->context == CONTEXT_PAUSE) {
|
if (gGameStatusPtr->context == CONTEXT_PAUSE) {
|
||||||
gSPViewport(gMainGfxPos++, &SprPauseVpAlt);
|
gSPViewport(gMainGfxPos++, &SpritePauseVpAlt);
|
||||||
} else {
|
} else {
|
||||||
gSPViewport(gMainGfxPos++, &camera->vpAlt);
|
gSPViewport(gMainGfxPos++, &camera->vpAlt);
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ void spr_appendGfx_component_flat(
|
|||||||
if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) {
|
if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_SET_VIEWPORT) {
|
||||||
Camera* camera = &gCameras[gCurrentCamID];
|
Camera* camera = &gCameras[gCurrentCamID];
|
||||||
if (gGameStatusPtr->context == CONTEXT_PAUSE) {
|
if (gGameStatusPtr->context == CONTEXT_PAUSE) {
|
||||||
gSPViewport(gMainGfxPos++, &SprPauseVpAlt);
|
gSPViewport(gMainGfxPos++, &SpritePauseVpAlt);
|
||||||
} else {
|
} else {
|
||||||
gSPViewport(gMainGfxPos++, &camera->vpAlt);
|
gSPViewport(gMainGfxPos++, &camera->vpAlt);
|
||||||
}
|
}
|
||||||
@@ -305,9 +305,9 @@ void spr_appendGfx_component_flat(
|
|||||||
Camera* camera = &gCameras[gCurrentCamID];
|
Camera* camera = &gCameras[gCurrentCamID];
|
||||||
|
|
||||||
if (gGameStatusPtr->context == CONTEXT_PAUSE) {
|
if (gGameStatusPtr->context == CONTEXT_PAUSE) {
|
||||||
gSPViewport(gMainGfxPos++, &SprPauseVp);
|
gSPViewport(gMainGfxPos++, &SpritePauseVp);
|
||||||
SprPauseVpAlt.vp.vtrans[0] = SprPauseVp.vp.vtrans[0] + gGameStatusPtr->altViewportOffset.x;
|
SpritePauseVpAlt.vp.vtrans[0] = SpritePauseVp.vp.vtrans[0] + gGameStatusPtr->altViewportOffset.x;
|
||||||
SprPauseVpAlt.vp.vtrans[1] = SprPauseVp.vp.vtrans[1] + gGameStatusPtr->altViewportOffset.y;
|
SpritePauseVpAlt.vp.vtrans[1] = SpritePauseVp.vp.vtrans[1] + gGameStatusPtr->altViewportOffset.y;
|
||||||
} else {
|
} else {
|
||||||
gSPViewport(gMainGfxPos++, &camera->vp);
|
gSPViewport(gMainGfxPos++, &camera->vp);
|
||||||
}
|
}
|
||||||
@@ -360,16 +360,16 @@ void spr_appendGfx_component(
|
|||||||
|
|
||||||
if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_ENABLED) {
|
if (gSpriteShadingProfile->flags & SPR_SHADING_FLAG_ENABLED) {
|
||||||
if ((u8) opacity == 255) {
|
if ((u8) opacity == 255) {
|
||||||
gSPDisplayList(gMainGfxPos++, D_802DF460);
|
gSPDisplayList(gMainGfxPos++, OpaqueShadedSpriteGfx);
|
||||||
} else {
|
} else {
|
||||||
gSPDisplayList(gMainGfxPos++, D_802DF490);
|
gSPDisplayList(gMainGfxPos++, TranslucentShadedSpriteGfx);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((u8) opacity == 255) {
|
if ((u8) opacity == 255) {
|
||||||
gSPDisplayList(gMainGfxPos++, D_802DF3F0);
|
gSPDisplayList(gMainGfxPos++, OpaqueSpriteGfx);
|
||||||
} else {
|
} else {
|
||||||
gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, (u8) opacity);
|
gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, (u8) opacity);
|
||||||
gSPDisplayList(gMainGfxPos++, D_802DF428);
|
gSPDisplayList(gMainGfxPos++, TranslucentSpriteGfx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ void spr_appendGfx_component(
|
|||||||
height = cache->height;
|
height = cache->height;
|
||||||
quadIndex = cache->quadCacheIndex;
|
quadIndex = cache->quadCacheIndex;
|
||||||
quad = nullptr;
|
quad = nullptr;
|
||||||
if (!(D_802DF540 & SPR_IMGFX_FLAG_ALL)) {
|
if (!(CurSpriteImgFX & SPR_IMGFX_FLAG_ALL)) {
|
||||||
quad = spr_get_quad_for_size(&quadIndex, width, height);
|
quad = spr_get_quad_for_size(&quadIndex, width, height);
|
||||||
cache->quadCacheIndex = quadIndex;
|
cache->quadCacheIndex = quadIndex;
|
||||||
}
|
}
|
||||||
@@ -392,8 +392,8 @@ void spr_appendGfx_component(
|
|||||||
ifxImg.xOffset = -(width / 2);
|
ifxImg.xOffset = -(width / 2);
|
||||||
ifxImg.yOffset = height;
|
ifxImg.yOffset = height;
|
||||||
ifxImg.alpha = opacity;
|
ifxImg.alpha = opacity;
|
||||||
if (imgfx_appendGfx_component((u8) D_802DF540, &ifxImg, IMGFX_FLAG_80000, mtxTransform) == 1) {
|
if (imgfx_appendGfx_component((u8) CurSpriteImgFX, &ifxImg, IMGFX_FLAG_80000, mtxTransform) == 1) {
|
||||||
D_802DF540 &= ~SPR_IMGFX_FLAG_ALL;
|
CurSpriteImgFX &= ~SPR_IMGFX_FLAG_ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
|
gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
|
||||||
@@ -440,9 +440,9 @@ void spr_draw_component(s32 drawOpts, SpriteComponent* component, SpriteAnimComp
|
|||||||
f32 inX, inY, inZ;
|
f32 inX, inY, inZ;
|
||||||
|
|
||||||
if (component->initialized && component->curRaster != -1) {
|
if (component->initialized && component->curRaster != -1) {
|
||||||
rotX = D_802DFEA0[0];
|
rotX = SpriteCurBaseRot[0];
|
||||||
rotY = D_802DFEA0[1];
|
rotY = SpriteCurBaseRot[1];
|
||||||
rotZ = D_802DFEA0[2];
|
rotZ = SpriteCurBaseRot[2];
|
||||||
inX = component->compPos.x + anim->compOffset.x;
|
inX = component->compPos.x + anim->compOffset.x;
|
||||||
inY = component->compPos.y + anim->compOffset.y;
|
inY = component->compPos.y + anim->compOffset.y;
|
||||||
inZ = component->compPos.z + anim->compOffset.z;
|
inZ = component->compPos.z + anim->compOffset.z;
|
||||||
@@ -451,9 +451,9 @@ void spr_draw_component(s32 drawOpts, SpriteComponent* component, SpriteAnimComp
|
|||||||
cacheEntry = cache[component->curRaster];
|
cacheEntry = cache[component->curRaster];
|
||||||
paletteIdx = component->curPalette;
|
paletteIdx = component->curPalette;
|
||||||
if (drawOpts & DRAW_SPRITE_USE_PLAYER_RASTERS) {
|
if (drawOpts & DRAW_SPRITE_USE_PLAYER_RASTERS) {
|
||||||
cacheEntry->image = spr_get_player_raster(component->curRaster & 0xFFF, D_802DF57C);
|
cacheEntry->image = spr_get_player_raster(component->curRaster & 0xFFF, CurPlayerSpriteIndex);
|
||||||
}
|
}
|
||||||
D_802DF540 = component->imgfxIdx;
|
CurSpriteImgFX = component->imgfxIdx;
|
||||||
pal = palettes[paletteIdx];
|
pal = palettes[paletteIdx];
|
||||||
|
|
||||||
spr_appendGfx_component(
|
spr_appendGfx_component(
|
||||||
@@ -467,7 +467,7 @@ void spr_draw_component(s32 drawOpts, SpriteComponent* component, SpriteAnimComp
|
|||||||
component->scale.z,
|
component->scale.z,
|
||||||
drawOpts, pal, mtx
|
drawOpts, pal, mtx
|
||||||
);
|
);
|
||||||
component->imgfxIdx = D_802DF540;
|
component->imgfxIdx = CurSpriteImgFX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ void spr_component_update_commands(SpriteComponent* comp, SpriteAnimComponent* a
|
|||||||
bufPos = comp->readPos;
|
bufPos = comp->readPos;
|
||||||
gotoPos = (u16*) -1;
|
gotoPos = (u16*) -1;
|
||||||
|
|
||||||
comp->waitTime -= spr_animUpdateTimeScale;
|
comp->waitTime -= SpriteAnimUpdateTimescale;
|
||||||
|
|
||||||
while (comp->waitTime <= 0.0f) {
|
while (comp->waitTime <= 0.0f) {
|
||||||
// overflow check
|
// overflow check
|
||||||
@@ -757,15 +757,15 @@ void spr_init_anim_state(SpriteComponent** compList, SpriteAnimComponent** animL
|
|||||||
}
|
}
|
||||||
|
|
||||||
void spr_set_anim_timescale(f32 timescale) {
|
void spr_set_anim_timescale(f32 timescale) {
|
||||||
spr_animUpdateTimeScale = timescale * 2.0f;
|
SpriteAnimUpdateTimescale = timescale * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spr_load_player_sprite(s32 spriteIndex) {
|
void spr_load_player_sprite(s32 spriteIndex) {
|
||||||
SpriteAnimData* playerSprite = spr_load_sprite(spriteIndex - 1, true, false);
|
SpriteAnimData* playerSprite = spr_load_sprite(spriteIndex - 1, true, false);
|
||||||
|
|
||||||
spr_playerSprites[spriteIndex - 1] = playerSprite;
|
PlayerSprites[spriteIndex - 1] = playerSprite;
|
||||||
if (spr_playerMaxComponents < playerSprite->maxComponents) {
|
if (MaxPlayerSpriteComponents < playerSprite->maxComponents) {
|
||||||
spr_playerMaxComponents = playerSprite->maxComponents;
|
MaxPlayerSpriteComponents = playerSprite->maxComponents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -773,24 +773,24 @@ void spr_init_sprites(s32 playerSpriteSet) {
|
|||||||
s32 loadedFlags;
|
s32 loadedFlags;
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
spr_allocateBtlComponentsOnWorldHeap = false;
|
SpriteUseGeneralHeap = false;
|
||||||
_heap_create(&heap_spriteHead, SPRITE_HEAP_SIZE);
|
_heap_create(&heap_spriteHead, SPRITE_HEAP_SIZE);
|
||||||
imgfx_init();
|
imgfx_init();
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(spr_playerSprites); i++) {
|
for (i = 0; i < ARRAY_COUNT(PlayerSprites); i++) {
|
||||||
SpriteAnimData** playerSprites = spr_playerSprites;
|
SpriteAnimData** playerSprites = PlayerSprites;
|
||||||
playerSprites[i] = 0;
|
playerSprites[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spr_playerMaxComponents = 0;
|
MaxPlayerSpriteComponents = 0;
|
||||||
|
|
||||||
if (gGameStatusPtr->peachFlags & PEACH_FLAG_IS_PEACH) {
|
if (gGameStatusPtr->peachFlags & PEACH_FLAG_IS_PEACH) {
|
||||||
playerSpriteSet = PLAYER_SPRITES_PEACH_WORLD;
|
playerSpriteSet = PLAYER_SPRITES_PEACH_WORLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadedFlags = (&spr_playerSpriteSets[playerSpriteSet])->initiallyLoaded;
|
loadedFlags = (&PlayerSpriteSets[playerSpriteSet])->initiallyLoaded;
|
||||||
spr_init_player_raster_cache((&spr_playerSpriteSets[playerSpriteSet])->cacheSize,
|
spr_init_player_raster_cache((&PlayerSpriteSets[playerSpriteSet])->cacheSize,
|
||||||
(&spr_playerSpriteSets[playerSpriteSet])->rasterSize);
|
(&PlayerSpriteSets[playerSpriteSet])->rasterSize);
|
||||||
|
|
||||||
for (i = 1; i <= SPR_Peach3; i++) {
|
for (i = 1; i <= SPR_Peach3; i++) {
|
||||||
if ((loadedFlags >> i) & 1) {
|
if ((loadedFlags >> i) & 1) {
|
||||||
@@ -798,9 +798,9 @@ void spr_init_sprites(s32 playerSpriteSet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(spr_playerCurrentAnimInfo); i++) {
|
for (i = 0; i < ARRAY_COUNT(CurPlayerAnimInfo); i++) {
|
||||||
spr_playerCurrentAnimInfo[i].componentList = nullptr;
|
CurPlayerAnimInfo[i].componentList = nullptr;
|
||||||
spr_playerCurrentAnimInfo[i].animID = -1;
|
CurPlayerAnimInfo[i].animID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(NpcSpriteData); i++) {
|
for (i = 0; i < ARRAY_COUNT(NpcSpriteData); i++) {
|
||||||
@@ -824,7 +824,7 @@ void spr_render_init(void) {
|
|||||||
spr_clear_quad_cache();
|
spr_clear_quad_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 func_802DDA84(void) {
|
s32 spr_unused_nop(void) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -834,14 +834,14 @@ s32 spr_update_player_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale) {
|
|||||||
SpriteComponent* component;
|
SpriteComponent* component;
|
||||||
SpriteAnimComponent** animList;
|
SpriteAnimComponent** animList;
|
||||||
SpriteRasterCacheEntry** rasterList;
|
SpriteRasterCacheEntry** rasterList;
|
||||||
s32 spriteId = ((animID >> 16) & 0xFF) - 1;
|
s32 spriteIdx = SPR_UNPACK_SPR(animID) - 1;
|
||||||
s32 instanceIdx = spriteInstanceID & 0xFF;
|
s32 instanceIdx = spriteInstanceID & 0xFF;
|
||||||
s32 animIndex = animID & 0xFF;
|
s32 animIndex = SPR_UNPACK_ANIM(animID);
|
||||||
D_802DF57C = spriteId;
|
CurPlayerSpriteIndex = spriteIdx;
|
||||||
|
|
||||||
if (spr_playerCurrentAnimInfo[instanceIdx].componentList == nullptr) {
|
if (CurPlayerAnimInfo[instanceIdx].componentList == nullptr) {
|
||||||
compList = spr_allocate_components(spr_playerMaxComponents);
|
compList = spr_allocate_components(MaxPlayerSpriteComponents);
|
||||||
spr_playerCurrentAnimInfo[instanceIdx].componentList = compList;
|
CurPlayerAnimInfo[instanceIdx].componentList = compList;
|
||||||
while (*compList != PTR_LIST_END) {
|
while (*compList != PTR_LIST_END) {
|
||||||
component = *compList;
|
component = *compList;
|
||||||
component->imgfxIdx = imgfx_get_free_instances(1);
|
component->imgfxIdx = imgfx_get_free_instances(1);
|
||||||
@@ -849,8 +849,8 @@ s32 spr_update_player_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spriteData = (u32*)spr_playerSprites[spriteId];
|
spriteData = (u32*)PlayerSprites[spriteIdx];
|
||||||
compList = spr_playerCurrentAnimInfo[instanceIdx].componentList;
|
compList = CurPlayerAnimInfo[instanceIdx].componentList;
|
||||||
|
|
||||||
if (spriteData == nullptr) {
|
if (spriteData == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -862,24 +862,24 @@ s32 spr_update_player_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale) {
|
|||||||
|
|
||||||
spr_set_anim_timescale(timeScale);
|
spr_set_anim_timescale(timeScale);
|
||||||
if ((spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) ||
|
if ((spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) ||
|
||||||
(animID & ~SPRITE_ID_BACK_FACING) != (spr_playerCurrentAnimInfo[instanceIdx].animID & ~SPRITE_ID_BACK_FACING))
|
(animID & ~SPRITE_ID_BACK_FACING) != (CurPlayerAnimInfo[instanceIdx].animID & ~SPRITE_ID_BACK_FACING))
|
||||||
{
|
{
|
||||||
spr_init_anim_state(compList, animList);
|
spr_init_anim_state(compList, animList);
|
||||||
spr_playerCurrentAnimInfo[instanceIdx].notifyValue = 0;
|
CurPlayerAnimInfo[instanceIdx].notifyValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spr_playerCurrentAnimInfo[instanceIdx].animID = animID;
|
CurPlayerAnimInfo[instanceIdx].animID = animID;
|
||||||
|
|
||||||
if (!(spriteInstanceID & DRAW_SPRITE_OVERRIDE_YAW)) {
|
if (!(spriteInstanceID & DRAW_SPRITE_OVERRIDE_YAW)) {
|
||||||
spr_playerCurrentAnimInfo[instanceIdx].notifyValue = spr_component_update(spr_playerCurrentAnimInfo[instanceIdx].notifyValue,
|
CurPlayerAnimInfo[instanceIdx].notifyValue = spr_component_update(CurPlayerAnimInfo[instanceIdx].notifyValue,
|
||||||
compList, animList, rasterList, 0);
|
compList, animList, rasterList, 0);
|
||||||
}
|
}
|
||||||
return spr_playerCurrentAnimInfo[instanceIdx].notifyValue;
|
return CurPlayerAnimInfo[instanceIdx].notifyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR* paletteList, Matrix4f mtx) {
|
s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR* paletteList, Matrix4f mtx) {
|
||||||
s32 instanceIdx = spriteInstanceID & 0xFF;
|
s32 instanceIdx = spriteInstanceID & 0xFF;
|
||||||
s32 animID = spr_playerCurrentAnimInfo[instanceIdx].animID;
|
s32 animID = CurPlayerAnimInfo[instanceIdx].animID;
|
||||||
SpriteRasterCacheEntry** rasters;
|
SpriteRasterCacheEntry** rasters;
|
||||||
PAL_PTR* palettes;
|
PAL_PTR* palettes;
|
||||||
SpriteAnimComponent** animComponents;
|
SpriteAnimComponent** animComponents;
|
||||||
@@ -887,15 +887,15 @@ s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR*
|
|||||||
f32 zscale;
|
f32 zscale;
|
||||||
u32 alpha;
|
u32 alpha;
|
||||||
u32* spriteData;
|
u32* spriteData;
|
||||||
s32 spriteId;
|
s32 spriteIdx;
|
||||||
s32 spriteIdBackFacing;
|
s32 spriteIdBackFacing;
|
||||||
|
|
||||||
if (animID == ANIM_LIST_END) {
|
if (animID == ANIM_LIST_END) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
D_802DF57C = spriteId = ((animID >> 0x10) & 0xFF) - 1;
|
CurPlayerSpriteIndex = spriteIdx = SPR_UNPACK_SPR(animID) - 1;
|
||||||
spriteData = (u32*)spr_playerSprites[spriteId];
|
spriteData = (u32*)PlayerSprites[spriteIdx];
|
||||||
if (spriteData == nullptr) {
|
if (spriteData == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -905,17 +905,17 @@ s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR*
|
|||||||
palettes = (PAL_PTR*)*spriteData++;
|
palettes = (PAL_PTR*)*spriteData++;
|
||||||
spriteData++;
|
spriteData++;
|
||||||
spriteData++;
|
spriteData++;
|
||||||
animComponents = (SpriteAnimComponent**)spriteData[animID & 0xFF];
|
animComponents = (SpriteAnimComponent**)spriteData[SPR_UNPACK_ANIM(animID)];
|
||||||
|
|
||||||
if (animID & SPRITE_ID_BACK_FACING) {
|
if (animID & SPRITE_ID_BACK_FACING) {
|
||||||
switch (spriteId) {
|
switch (spriteIdx) {
|
||||||
case 0:
|
case SPR_Mario1 - 1:
|
||||||
case 5:
|
case SPR_MarioW1 - 1:
|
||||||
case 9:
|
case SPR_Peach1 - 1:
|
||||||
spriteIdBackFacing = spriteId + 1;
|
spriteIdBackFacing = spriteIdx + 1;
|
||||||
// TODO find better match
|
// TODO find better match
|
||||||
rasters = (SpriteRasterCacheEntry**)spr_playerSprites[spriteIdBackFacing];
|
rasters = (SpriteRasterCacheEntry**)PlayerSprites[spriteIdBackFacing];
|
||||||
D_802DF57C = spriteIdBackFacing;
|
CurPlayerSpriteIndex = spriteIdBackFacing;
|
||||||
rasters = (SpriteRasterCacheEntry**)*rasters;
|
rasters = (SpriteRasterCacheEntry**)*rasters;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -941,9 +941,9 @@ s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR*
|
|||||||
zscale = 0.0f - zscale;
|
zscale = 0.0f - zscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
D_802DFEA0[0] = 0;
|
SpriteCurBaseRot[0] = 0;
|
||||||
D_802DFEA0[1] = yaw;
|
SpriteCurBaseRot[1] = yaw;
|
||||||
D_802DFEA0[2] = 0;
|
SpriteCurBaseRot[2] = 0;
|
||||||
|
|
||||||
if (spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) {
|
if (spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) {
|
||||||
alpha = alphaIn & 0xFF;
|
alpha = alphaIn & 0xFF;
|
||||||
@@ -954,7 +954,7 @@ s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR*
|
|||||||
alpha = 255;
|
alpha = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
components = spr_playerCurrentAnimInfo[instanceIdx].componentList;
|
components = CurPlayerAnimInfo[instanceIdx].componentList;
|
||||||
if (spriteInstanceID & DRAW_SPRITE_OVERRIDE_PALETTES) {
|
if (spriteInstanceID & DRAW_SPRITE_OVERRIDE_PALETTES) {
|
||||||
palettes = paletteList;
|
palettes = paletteList;
|
||||||
}
|
}
|
||||||
@@ -970,7 +970,7 @@ s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR*
|
|||||||
}
|
}
|
||||||
|
|
||||||
s32 func_802DDEC4(s32 spriteIdx) {
|
s32 func_802DDEC4(s32 spriteIdx) {
|
||||||
return spr_playerCurrentAnimInfo[spriteIdx].notifyValue;
|
return CurPlayerAnimInfo[spriteIdx].notifyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_player_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 flags) {
|
void set_player_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 flags) {
|
||||||
@@ -978,8 +978,8 @@ void set_player_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgf
|
|||||||
SpriteComponent** componentListIt;
|
SpriteComponent** componentListIt;
|
||||||
s32 i;
|
s32 i;
|
||||||
|
|
||||||
if (spr_playerCurrentAnimInfo[spriteIdx].componentList != nullptr) {
|
if (CurPlayerAnimInfo[spriteIdx].componentList != nullptr) {
|
||||||
componentListIt = spr_playerCurrentAnimInfo[spriteIdx].componentList;
|
componentListIt = CurPlayerAnimInfo[spriteIdx].componentList;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (*componentListIt != PTR_LIST_END) {
|
while (*componentListIt != PTR_LIST_END) {
|
||||||
@@ -1009,7 +1009,7 @@ void spr_get_player_raster_info(SpriteRasterInfo* out, s32 playerSpriteID, s32 r
|
|||||||
u16** paletteOffsetCopy;
|
u16** paletteOffsetCopy;
|
||||||
|
|
||||||
playerSpriteID--;
|
playerSpriteID--;
|
||||||
sprite = spr_playerSprites[playerSpriteID];
|
sprite = PlayerSprites[playerSpriteID];
|
||||||
if (sprite != nullptr) {
|
if (sprite != nullptr) {
|
||||||
paletteOffsetCopy = sprite->palettesOffset;
|
paletteOffsetCopy = sprite->palettesOffset;
|
||||||
cache = sprite->rastersOffset[rasterIndex];
|
cache = sprite->rastersOffset[rasterIndex];
|
||||||
@@ -1021,7 +1021,7 @@ void spr_get_player_raster_info(SpriteRasterInfo* out, s32 playerSpriteID, s32 r
|
|||||||
}
|
}
|
||||||
|
|
||||||
PAL_PTR* spr_get_player_palettes(s32 spriteIndex) {
|
PAL_PTR* spr_get_player_palettes(s32 spriteIndex) {
|
||||||
SpriteAnimData* sprites = spr_playerSprites[spriteIndex - 1];
|
SpriteAnimData* sprites = PlayerSprites[spriteIndex - 1];
|
||||||
|
|
||||||
if (sprites == nullptr) {
|
if (sprites == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -1084,7 +1084,7 @@ s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale) {
|
|||||||
|
|
||||||
s32 palID;
|
s32 palID;
|
||||||
s32 i = spriteInstanceID & 0xFF;
|
s32 i = spriteInstanceID & 0xFF;
|
||||||
s32 animIndex = animID & 0xFF;
|
s32 animIndex = SPR_UNPACK_ANIM(animID);
|
||||||
|
|
||||||
compList = SpriteInstances[i].componentList;
|
compList = SpriteInstances[i].componentList;
|
||||||
spriteData = (u32*)SpriteInstances[i].spriteData;
|
spriteData = (u32*)SpriteInstances[i].spriteData;
|
||||||
@@ -1093,7 +1093,7 @@ s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale) {
|
|||||||
spriteData += 4 + animIndex;
|
spriteData += 4 + animIndex;
|
||||||
animList = (SpriteAnimComponent**)*spriteData;
|
animList = (SpriteAnimComponent**)*spriteData;
|
||||||
|
|
||||||
palID = (animID >> 8) & 0xFF;
|
palID = SPR_UNPACK_PAL(animID);
|
||||||
spr_set_anim_timescale(timeScale);
|
spr_set_anim_timescale(timeScale);
|
||||||
if ((spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) || ((SpriteInstances[i].curAnimID & 0xFF) != animIndex)) {
|
if ((spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) || ((SpriteInstances[i].curAnimID & 0xFF) != animIndex)) {
|
||||||
spr_init_anim_state(compList, animList);
|
spr_init_anim_state(compList, animList);
|
||||||
@@ -1107,7 +1107,7 @@ s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale) {
|
|||||||
return SpriteInstances[i].notifyValue;
|
return SpriteInstances[i].notifyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* paletteList, Matrix4f mtx) {
|
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR* paletteList, Matrix4f mtx) {
|
||||||
s32 i = spriteInstanceID & 0xFF;
|
s32 i = spriteInstanceID & 0xFF;
|
||||||
s32 animID = SpriteInstances[i].curAnimID;
|
s32 animID = SpriteInstances[i].curAnimID;
|
||||||
SpriteRasterCacheEntry** rasters;
|
SpriteRasterCacheEntry** rasters;
|
||||||
@@ -1129,11 +1129,11 @@ s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* palett
|
|||||||
palettes = (PAL_PTR*)*spriteData++;
|
palettes = (PAL_PTR*)*spriteData++;
|
||||||
spriteData++;
|
spriteData++;
|
||||||
spriteData++;
|
spriteData++;
|
||||||
animComponents = (SpriteAnimComponent**)spriteData[animID & 0xFF];
|
animComponents = (SpriteAnimComponent**)spriteData[SPR_UNPACK_ANIM(animID)];
|
||||||
|
|
||||||
D_802DFEA0[0] = 0;
|
SpriteCurBaseRot[0] = 0;
|
||||||
D_802DFEA0[1] = yaw;
|
SpriteCurBaseRot[1] = yaw;
|
||||||
D_802DFEA0[2] = 0;
|
SpriteCurBaseRot[2] = 0;
|
||||||
|
|
||||||
if (!(spriteInstanceID & DRAW_SPRITE_OVERRIDE_YAW)) {
|
if (!(spriteInstanceID & DRAW_SPRITE_OVERRIDE_YAW)) {
|
||||||
yaw += gCameras[gCurrentCamID].curYaw;
|
yaw += gCameras[gCurrentCamID].curYaw;
|
||||||
@@ -1152,8 +1152,8 @@ s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* palett
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) {
|
if (spriteInstanceID & DRAW_SPRITE_OVERRIDE_ALPHA) {
|
||||||
alpha = arg2 & 0xFF;
|
alpha = alphaIn & 0xFF;
|
||||||
if (arg2 == 0) {
|
if (alphaIn == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1175,8 +1175,8 @@ s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* palett
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 spr_get_notify_value(s32 spriteIndex) {
|
s32 spr_get_notify_value(s32 spriteInstanceID) {
|
||||||
return SpriteInstances[spriteIndex].notifyValue;
|
return SpriteInstances[spriteInstanceID].notifyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 spr_free_sprite(s32 spriteInstanceID) {
|
s32 spr_free_sprite(s32 spriteInstanceID) {
|
||||||
@@ -1206,7 +1206,7 @@ s32 spr_free_sprite(s32 spriteInstanceID) {
|
|||||||
_heap_free(&heap_spriteHead, spriteData);
|
_heap_free(&heap_spriteHead, spriteData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spr_allocateBtlComponentsOnWorldHeap) {
|
if (SpriteUseGeneralHeap) {
|
||||||
_heap_free(&heap_generalHead, compList);
|
_heap_free(&heap_generalHead, compList);
|
||||||
} else {
|
} else {
|
||||||
_heap_free(&heap_spriteHead, compList);
|
_heap_free(&heap_spriteHead, compList);
|
||||||
|
|||||||
18
src/sprite.h
18
src/sprite.h
@@ -6,6 +6,10 @@
|
|||||||
#define SPR_PLAYER_COLOR_VARIATIONS 6
|
#define SPR_PLAYER_COLOR_VARIATIONS 6
|
||||||
#define SPR_PEACH_BTL_PAL_STRIDE 4
|
#define SPR_PEACH_BTL_PAL_STRIDE 4
|
||||||
|
|
||||||
|
#define SPR_UNPACK_SPR(animID) (((animID) >> 16) & 0xFF)
|
||||||
|
#define SPR_UNPACK_PAL(animID) (((animID) >> 8) & 0xFF)
|
||||||
|
#define SPR_UNPACK_ANIM(animID) ((animID) & 0xFF)
|
||||||
|
|
||||||
enum SpriteIDFields {
|
enum SpriteIDFields {
|
||||||
SPRITE_ID_ANIM_MASK = 0x000000FF,
|
SPRITE_ID_ANIM_MASK = 0x000000FF,
|
||||||
SPRITE_ID_PAL_MASK = 0x0000FF00,
|
SPRITE_ID_PAL_MASK = 0x0000FF00,
|
||||||
@@ -116,16 +120,6 @@ typedef struct Quad {
|
|||||||
Vtx v[4];
|
Vtx v[4];
|
||||||
} Quad; // size = 0x40
|
} Quad; // size = 0x40
|
||||||
|
|
||||||
extern Quad spr_defaultQuad;
|
|
||||||
extern Vp SprPauseVp;
|
|
||||||
extern Vp SprPauseVpAlt;
|
|
||||||
extern Gfx D_802DF3F0[];
|
|
||||||
extern Gfx D_802DF428[];
|
|
||||||
extern Gfx D_802DF460[];
|
|
||||||
extern Gfx D_802DF490[];
|
|
||||||
extern f32 spr_animUpdateTimeScale;
|
|
||||||
extern PlayerSpriteSet spr_playerSpriteSets[7];
|
|
||||||
|
|
||||||
void imgfx_init(void);
|
void imgfx_init(void);
|
||||||
|
|
||||||
void spr_init_sprites(s32 playerSpriteSet);
|
void spr_init_sprites(s32 playerSpriteSet);
|
||||||
@@ -155,9 +149,9 @@ s32 spr_load_npc_sprite(s32 animID, u32* extraAnimList);
|
|||||||
|
|
||||||
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale);
|
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale);
|
||||||
|
|
||||||
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* paletteList, Matrix4f mtx);
|
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR* paletteList, Matrix4f mtx);
|
||||||
|
|
||||||
s32 spr_get_notify_value(s32 arg0);
|
s32 spr_get_notify_value(s32 spriteInstanceID);
|
||||||
|
|
||||||
s32 spr_free_sprite(s32 spriteInstanceID);
|
s32 spr_free_sprite(s32 spriteInstanceID);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
extern HeapNode heap_spriteHead;
|
extern HeapNode heap_spriteHead;
|
||||||
|
|
||||||
extern s32 spr_allocateBtlComponentsOnWorldHeap;
|
extern bool SpriteUseGeneralHeap;
|
||||||
extern ParadeNpcInfo N(ParadeNpcsTable)[];
|
extern ParadeNpcInfo N(ParadeNpcsTable)[];
|
||||||
|
|
||||||
extern EvtScript N(EVS_ParadePhase_Luigi);
|
extern EvtScript N(EVS_ParadePhase_Luigi);
|
||||||
@@ -38,7 +38,7 @@ API_CALLABLE(N(CreateParadeNPC)) {
|
|||||||
bp.onUpdate = nullptr;
|
bp.onUpdate = nullptr;
|
||||||
bp.onRender = nullptr;
|
bp.onRender = nullptr;
|
||||||
|
|
||||||
spr_allocateBtlComponentsOnWorldHeap = true;
|
SpriteUseGeneralHeap = true;
|
||||||
|
|
||||||
npc = get_npc_by_index(create_standard_npc(&bp, npcInfo->animList));
|
npc = get_npc_by_index(create_standard_npc(&bp, npcInfo->animList));
|
||||||
npc->npcID = npcID;
|
npc->npcID = npcID;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
extern HeapNode heap_spriteHead;
|
extern HeapNode heap_spriteHead;
|
||||||
|
|
||||||
extern s32 spr_allocateBtlComponentsOnWorldHeap;
|
extern bool SpriteUseGeneralHeap;
|
||||||
extern ParadeNpcInfo N(ParadeNpcsTable)[];
|
extern ParadeNpcInfo N(ParadeNpcsTable)[];
|
||||||
|
|
||||||
extern EvtScript N(EVS_ParadePhase_Wizards);
|
extern EvtScript N(EVS_ParadePhase_Wizards);
|
||||||
@@ -34,7 +34,7 @@ API_CALLABLE(N(CreateParadeNPC)) {
|
|||||||
bp.onUpdate = nullptr;
|
bp.onUpdate = nullptr;
|
||||||
bp.onRender = nullptr;
|
bp.onRender = nullptr;
|
||||||
|
|
||||||
spr_allocateBtlComponentsOnWorldHeap = true;
|
SpriteUseGeneralHeap = true;
|
||||||
|
|
||||||
npc = get_npc_by_index(create_standard_npc(&bp, npcInfo->animList));
|
npc = get_npc_by_index(create_standard_npc(&bp, npcInfo->animList));
|
||||||
npc->npcID = npcID;
|
npc->npcID = npcID;
|
||||||
|
|||||||
@@ -1598,29 +1598,29 @@ DemoReleaseButton = 0x802D9AF8; // type:func rom:0x101C98
|
|||||||
DemoSetButtons = 0x802D9B34; // type:func rom:0x101CD4
|
DemoSetButtons = 0x802D9B34; // type:func rom:0x101CD4
|
||||||
DemoJoystickRadial = 0x802D9B64; // type:func rom:0x101D04
|
DemoJoystickRadial = 0x802D9B64; // type:func rom:0x101D04
|
||||||
DemoJoystickXY = 0x802D9C10; // type:func rom:0x101DB0
|
DemoJoystickXY = 0x802D9C10; // type:func rom:0x101DB0
|
||||||
spr_defaultQuad = 0x80112EE0; // rom:0xA95E0
|
SpriteQuadTemplate = 0x80112EE0; // rom:0xA95E0
|
||||||
SprPauseVp = 0x80112F20; // rom:0xA9620
|
SpritePauseVp = 0x80112F20; // rom:0xA9620
|
||||||
SprPauseVpAlt = 0x80112F30; // rom:0xA9630
|
SpritePauseVpAlt = 0x80112F30; // rom:0xA9630
|
||||||
D_802DF3F0 = 0x80112F40; // rom:0xA9640
|
OpaqueSpriteGfx = 0x80112F40; // rom:0xA9640
|
||||||
D_802DF428 = 0x80112F78; // rom:0xA9678
|
TranslucentSpriteGfx = 0x80112F78; // rom:0xA9678
|
||||||
D_802DF460 = 0x80112FB0; // rom:0xA96B0
|
OpaqueShadedSpriteGfx = 0x80112FB0; // rom:0xA96B0
|
||||||
D_802DF490 = 0x80112FE0; // rom:0xA96E0
|
TranslucentShadedSpriteGfx = 0x80112FE0; // rom:0xA96E0
|
||||||
spr_animUpdateTimeScale = 0x80113010; // rom:0xA9710
|
SpriteAnimUpdateTimescale = 0x80113010; // rom:0xA9710
|
||||||
spr_playerSpriteSets = 0x80113014; // rom:0xA9714
|
PlayerSpriteSets = 0x80113014; // rom:0xA9714
|
||||||
spr_init_quad_cache = 0x8010F890; // type:func rom:0xA5F90
|
spr_init_quad_cache = 0x8010F890; // type:func rom:0xA5F90
|
||||||
D_802DFE44 = 0x80113994;
|
SpriteQuadCache = 0x80113994;
|
||||||
D_802DFE48 = 0x80113998;
|
SpriteQuadCacheInfo = 0x80113998;
|
||||||
spr_get_cached_quad = 0x8010F8DC; // type:func rom:0xA5FDC
|
spr_get_cached_quad = 0x8010F8DC; // type:func rom:0xA5FDC
|
||||||
spr_make_quad_for_size = 0x8010F90C; // type:func rom:0xA600C
|
spr_make_quad_for_size = 0x8010F90C; // type:func rom:0xA600C
|
||||||
spr_get_quad_for_size = 0x8010F9C8; // type:func rom:0xA60C8
|
spr_get_quad_for_size = 0x8010F9C8; // type:func rom:0xA60C8
|
||||||
spr_clear_quad_cache = 0x8010FB10; // type:func rom:0xA6210
|
spr_clear_quad_cache = 0x8010FB10; // type:func rom:0xA6210
|
||||||
spr_appendGfx_component_flat = 0x8010FB58; // type:func rom:0xA6258
|
spr_appendGfx_component_flat = 0x8010FB58; // type:func rom:0xA6258
|
||||||
spr_appendGfx_component = 0x80110444; // type:func rom:0xA6B44
|
spr_appendGfx_component = 0x80110444; // type:func rom:0xA6B44
|
||||||
D_802DF540 = 0x80113090;
|
CurSpriteImgFX = 0x80113090;
|
||||||
spr_transform_point = 0x80110850; // type:func rom:0xA6F50
|
spr_transform_point = 0x80110850; // type:func rom:0xA6F50
|
||||||
spr_draw_component = 0x80110A2C; // type:func rom:0xA712C
|
spr_draw_component = 0x80110A2C; // type:func rom:0xA712C
|
||||||
D_802DFEA0 = 0x801139F0;
|
SpriteCurBaseRot = 0x801139F0;
|
||||||
D_802DF57C = 0x801130CC;
|
CurPlayerSpriteIndex = 0x801130CC;
|
||||||
spr_unpack_signed_12bit = 0x80110C2C; // type:func rom:0xA732C
|
spr_unpack_signed_12bit = 0x80110C2C; // type:func rom:0xA732C
|
||||||
spr_unpack_signed_16bit = 0x80110C4C; // type:func rom:0xA734C
|
spr_unpack_signed_16bit = 0x80110C4C; // type:func rom:0xA734C
|
||||||
spr_component_update_commands = 0x80110C6C; // type:func rom:0xA736C
|
spr_component_update_commands = 0x80110C6C; // type:func rom:0xA736C
|
||||||
@@ -1631,14 +1631,14 @@ spr_init_component_anim_state = 0x80111300; // type:func rom:0xA7A00
|
|||||||
spr_init_anim_state = 0x80111370; // type:func rom:0xA7A70
|
spr_init_anim_state = 0x80111370; // type:func rom:0xA7A70
|
||||||
spr_set_anim_timescale = 0x801113DC; // type:func rom:0xA7ADC
|
spr_set_anim_timescale = 0x801113DC; // type:func rom:0xA7ADC
|
||||||
spr_load_player_sprite = 0x801113EC; // type:func rom:0xA7AEC
|
spr_load_player_sprite = 0x801113EC; // type:func rom:0xA7AEC
|
||||||
spr_playerMaxComponents = 0x801130D0;
|
MaxPlayerSpriteComponents = 0x801130D0;
|
||||||
spr_playerSprites = 0x80113098;
|
PlayerSprites = 0x80113098;
|
||||||
spr_allocateBtlComponentsOnWorldHeap = 0x80113074;
|
SpriteUseGeneralHeap = 0x80113074;
|
||||||
spr_playerCurrentAnimInfo = 0x801130D8;
|
CurPlayerAnimInfo = 0x801130D8;
|
||||||
NpcSpriteInstanceCount = 0x801134A8;
|
NpcSpriteInstanceCount = 0x801134A8;
|
||||||
NpcSpriteData = 0x80113100;
|
NpcSpriteData = 0x80113100;
|
||||||
SpriteInstances = 0x80113598;
|
SpriteInstances = 0x80113598;
|
||||||
func_802DDA84 = 0x801115D4; // type:func rom:0xA7CD4
|
spr_unused_nop = 0x801115D4; // type:func rom:0xA7CD4
|
||||||
spr_update_player_sprite = 0x801115DC; // type:func rom:0xA7CDC
|
spr_update_player_sprite = 0x801115DC; // type:func rom:0xA7CDC
|
||||||
spr_draw_player_sprite = 0x80111790; // type:func rom:0xA7E90
|
spr_draw_player_sprite = 0x80111790; // type:func rom:0xA7E90
|
||||||
func_802DDEC4 = 0x80111A14; // type:func rom:0xA8114
|
func_802DDEC4 = 0x80111A14; // type:func rom:0xA8114
|
||||||
|
|||||||
@@ -5581,7 +5581,7 @@ spr_set_anim_timescale = 0x802DD88C; // type:func rom:0x10097C
|
|||||||
spr_load_player_sprite = 0x802DD89C; // type:func rom:0x10098C
|
spr_load_player_sprite = 0x802DD89C; // type:func rom:0x10098C
|
||||||
spr_init_sprites = 0x802DD8F8; // type:func rom:0x1009E8
|
spr_init_sprites = 0x802DD8F8; // type:func rom:0x1009E8
|
||||||
spr_render_init = 0x802DDA60; // type:func rom:0x100B50
|
spr_render_init = 0x802DDA60; // type:func rom:0x100B50
|
||||||
func_802DDA84 = 0x802DDA84; // type:func rom:0x100B74
|
spr_unused_nop = 0x802DDA84; // type:func rom:0x100B74
|
||||||
spr_update_player_sprite = 0x802DDA8C; // type:func rom:0x100B7C
|
spr_update_player_sprite = 0x802DDA8C; // type:func rom:0x100B7C
|
||||||
spr_draw_player_sprite = 0x802DDC40; // type:func rom:0x100D30
|
spr_draw_player_sprite = 0x802DDC40; // type:func rom:0x100D30
|
||||||
func_802DDEC4 = 0x802DDEC4; // type:func rom:0x100FB4
|
func_802DDEC4 = 0x802DDEC4; // type:func rom:0x100FB4
|
||||||
@@ -5608,15 +5608,15 @@ spr_get_player_raster = 0x802DEEA0; // type:func rom:0x101F90
|
|||||||
spr_update_player_raster_cache = 0x802DEFB4; // type:func rom:0x1020A4
|
spr_update_player_raster_cache = 0x802DEFB4; // type:func rom:0x1020A4
|
||||||
spr_load_npc_extra_anims = 0x802DF00C; // type:func rom:0x1020FC
|
spr_load_npc_extra_anims = 0x802DF00C; // type:func rom:0x1020FC
|
||||||
spr_allocate_components = 0x802DF2D8; // type:func rom:0x1023C8
|
spr_allocate_components = 0x802DF2D8; // type:func rom:0x1023C8
|
||||||
spr_defaultQuad = 0x802DF390; // rom:0x102480
|
SpriteQuadTemplate = 0x802DF390; // rom:0x102480
|
||||||
SprPauseVp = 0x802DF3D0; // rom:0x1024C0
|
SpritePauseVp = 0x802DF3D0; // rom:0x1024C0
|
||||||
SprPauseVpAlt = 0x802DF3E0; // rom:0x1024D0
|
SpritePauseVpAlt = 0x802DF3E0; // rom:0x1024D0
|
||||||
D_802DF3F0 = 0x802DF3F0; // rom:0x1024E0
|
OpaqueSpriteGfx = 0x802DF3F0; // rom:0x1024E0
|
||||||
D_802DF428 = 0x802DF428; // rom:0x102518
|
TranslucentSpriteGfx = 0x802DF428; // rom:0x102518
|
||||||
D_802DF460 = 0x802DF460; // rom:0x102550
|
OpaqueShadedSpriteGfx = 0x802DF460; // rom:0x102550
|
||||||
D_802DF490 = 0x802DF490; // rom:0x102580
|
TranslucentShadedSpriteGfx = 0x802DF490; // rom:0x102580
|
||||||
spr_animUpdateTimeScale = 0x802DF4C0; // rom:0x1025B0
|
SpriteAnimUpdateTimescale = 0x802DF4C0; // rom:0x1025B0
|
||||||
spr_playerSpriteSets = 0x802DF4C4; // rom:0x1025B4
|
PlayerSpriteSets = 0x802DF4C4; // rom:0x1025B4
|
||||||
entity_Shadow_init = 0x802E0D90; // type:func rom:0x102610
|
entity_Shadow_init = 0x802E0D90; // type:func rom:0x102610
|
||||||
entity_can_collide_with_jumping_player = 0x802E0DB0; // type:func rom:0x102630
|
entity_can_collide_with_jumping_player = 0x802E0DB0; // type:func rom:0x102630
|
||||||
entity_SaveBlock_setupGfx = 0x802E0DE0; // type:func rom:0x102660
|
entity_SaveBlock_setupGfx = 0x802E0DE0; // type:func rom:0x102660
|
||||||
@@ -26198,20 +26198,20 @@ gWorldMapVars = 0x802DBCA8; // size:0x40
|
|||||||
gBattleMapVars = 0x802DBCE8; // size:0x40
|
gBattleMapVars = 0x802DBCE8; // size:0x40
|
||||||
DoorModelsSwingCCW = 0x802DBD28; //
|
DoorModelsSwingCCW = 0x802DBD28; //
|
||||||
gBattleMapFlags = 0x802DBD34; // size:0xC
|
gBattleMapFlags = 0x802DBD34; // size:0xC
|
||||||
spr_allocateBtlComponentsOnWorldHeap = 0x802DF524; //
|
SpriteUseGeneralHeap = 0x802DF524; //
|
||||||
MaxLoadedSpriteInstanceID = 0x802DF530; //
|
MaxLoadedSpriteInstanceID = 0x802DF530; //
|
||||||
D_802DF540 = 0x802DF540; //
|
CurSpriteImgFX = 0x802DF540; //
|
||||||
spr_playerSprites = 0x802DF548; //
|
PlayerSprites = 0x802DF548; //
|
||||||
D_802DF57C = 0x802DF57C; //
|
CurPlayerSpriteIndex = 0x802DF57C; //
|
||||||
spr_playerMaxComponents = 0x802DF580; //
|
MaxPlayerSpriteComponents = 0x802DF580; //
|
||||||
spr_playerCurrentAnimInfo = 0x802DF588; //
|
CurPlayerAnimInfo = 0x802DF588; //
|
||||||
NpcSpriteData = 0x802DF5B0; //
|
NpcSpriteData = 0x802DF5B0; //
|
||||||
NpcSpriteInstanceCount = 0x802DF958; //
|
NpcSpriteInstanceCount = 0x802DF958; //
|
||||||
SpriteInstances = 0x802DFA48; //
|
SpriteInstances = 0x802DFA48; //
|
||||||
D_802DFE44 = 0x802DFE44; //
|
SpriteQuadCache = 0x802DFE44; //
|
||||||
D_802DFE48 = 0x802DFE48; //
|
SpriteQuadCacheInfo = 0x802DFE48; //
|
||||||
D_802DFE9C = 0x802DFE9C; //
|
D_802DFE9C = 0x802DFE9C; //
|
||||||
D_802DFEA0 = 0x802DFEA0; //
|
SpriteCurBaseRot = 0x802DFEA0; //
|
||||||
SpriteUpdateNotifyValue = 0x802DFEAC; //
|
SpriteUpdateNotifyValue = 0x802DFEAC; //
|
||||||
spr_asset_entry = 0x802DFEB0; //
|
spr_asset_entry = 0x802DFEB0; //
|
||||||
PlayerRasterLoadDescBuffer = 0x802DFEB8; //
|
PlayerRasterLoadDescBuffer = 0x802DFEB8; //
|
||||||
|
|||||||
Reference in New Issue
Block a user