2#include "sprite/player.h"
5#define MAX_SPRITE_ID 0xFF
31 {{{ -16, 56, 0 },
FALSE, { 0, 0 }, { 240, 240, 240, 255 }}},
32 {{{ 16, 56, 0 },
FALSE, { 1024, 0 }, { 120, 120, 120, 255 }}},
33 {{{ 16, 0, 0 },
FALSE, { 1024, 1792 }, { 0, 0, 0, 255 }}},
34 {{{ -16, 0, 0 },
FALSE, { 0, 1792 }, { 120, 120, 120, 255 }}},
90#define MARIO_SPRITE_COMMON_BITS \
92 | 1 << SPR_Mario1_Back \
94#define MARIO_SPRITE_WORLD_BITS \
95 MARIO_SPRITE_COMMON_BITS \
97 | 1 << SPR_MarioW1_Back \
101#define MARIO_SPRITE_BATTLE_BITS \
102 MARIO_SPRITE_COMMON_BITS \
107#define PEACH_SPRITE_BITS \
109 | 1 << SPR_Peach1_Back \
147 vtx->
v.ob[0] = -width / 2;
148 vtx->v.ob[1] = height;
149 vtx->v.tc[0] = 0x2000;
150 vtx->v.tc[1] = 0x2000;
153 vtx->v.ob[0] = width / 2;
154 vtx->v.ob[1] = height;
155 vtx->v.tc[0] = (width + 256) * 32;
156 vtx->v.tc[1] = 0x2000;
159 vtx->v.tc[0] = (width + 256) * 32;
160 vtx->v.ob[0] = width / 2;
161 vtx->v.tc[1] = (height + 256) * 32;
164 vtx->v.ob[0] = -width / 2;
165 vtx->v.tc[0] = 0x2000;
166 vtx->v.tc[1] = (height + 256) * 32;
175 if ((width * height) / 2 <= 0x800) {
176 dimensions = (width << 0x18) + (height << 0x10);
230 0, 0, width - 1, height - 1, 0,
233 gDPSetTile(
gMainGfxPos++,
G_IM_FMT_RGBA,
G_IM_SIZ_16b, 4, 0x0100, 2, 0,
G_TX_WRAP,
G_TX_NOMASK,
G_TX_NOLOD,
G_TX_WRAP,
G_TX_NOMASK,
G_TX_NOLOD);
345 if (scaleX != 1.0f || scaleY != 1.0f ||
scaleZ != 1.0f) {
355 if ((
u8) opacity == 255) {
361 if ((
u8) opacity == 255) {
369 width =
cache->width;
370 height =
cache->height;
385 ifxImg.xOffset = -(width / 2);
396 if (rotX == 0 && rotY == 0 && rotZ == 0) {
432 f32 rotX, rotY, rotZ;
471 return temp | ~0xFFF;
481 return temp | ~0xFFFF;
488 f32 posX, posY, posZ;
489 f32 rotX, rotY, rotZ;
497 if (
comp->initialized) {
508 while (
comp->waitTime <= 0.0f) {
515 switch (*
bufPos & 0xF000) {
520 if (
comp->waitTime == 0.0f) {
521 comp->waitTime = 4095.0f;
523 comp->posOffset.z = 0.0f;
524 comp->posOffset.y = 0.0f;
525 comp->posOffset.x = 0.0f;
529 comp->scale.z = 1.0f;
530 comp->scale.y = 1.0f;
531 comp->scale.x = 1.0f;
539 comp->waitTime = 1.0f;
550 comp->curRaster = -1;
552 comp->curPalette = -1;
561 comp->curPalette = -1;
583 switch (*
bufPos++ & 0xF) {
604 switch (*
bufPos++ & 0xF) {
611 scaleX = *
bufPos++ / 100.0f;
614 scaleY = *
bufPos++ / 100.0f;
625 if (
comp->loopCounter != 0) {
627 if (
comp->loopCounter == 0) {
639 comp->waitTime = 1.0f;
646 comp->posOffset.x = posX;
647 comp->posOffset.y = posY;
648 comp->posOffset.z = posZ;
656 comp->scale.x = scaleX;
657 comp->scale.y = scaleY;
669 if (
comp->initialized) {
670 comp->compPos.x =
comp->posOffset.x;
671 comp->compPos.y =
comp->posOffset.y;
672 comp->compPos.z =
comp->posOffset.z;
674 if ((
comp->properties & 0xF00) == 0x100) {
681 if (
comp->curRaster != -1) {
683 if (
comp->curPalette == -1) {
722 comp->properties = 0;
725 comp->loopCounter = 0;
726 comp->curRaster = -1;
727 comp->curPalette = -1;
728 comp->posOffset.x = 0.0f;
729 comp->posOffset.y = 0.0f;
730 comp->posOffset.z = 0.0f;
731 comp->compPos.x = 0.0f;
732 comp->compPos.y = 0.0f;
733 comp->compPos.z = 0.0f;
737 comp->scale.x = 1.0f;
738 comp->scale.y = 1.0f;
739 comp->scale.z = 1.0f;
843 if (spriteData ==
NULL) {
887 if (spriteData ==
NULL) {
1021 s32 spriteIndex = (animID >> 0x10) & 0x7FFF;
1045 if (extraAnimList !=
NULL) {
1068 s32 i = spriteInstanceID & 0xFF;
1082 ASSERT_MSG(animList != -1,
"Anim %lx is not loaded", animID);
1169 return spriteInstanceID;
1173 spriteData =
sprite->spriteData;
1205 if (componentList ==
NULL) {
1218 componentList =
sprite->componentList;
1255 animID =
sprite->curAnimID;
1256 if (animID != 255) {
IMG_PTR spr_get_player_raster(s32 rasterIndex, s32 playerSpriteID)
void spr_update_player_raster_cache(void)
SpriteAnimData * spr_load_sprite(s32 idx, s32 isPlayerSprite, s32 useTailAlloc)
BSS s32 PopupMenu_SelectedIndex
@ SPR_SHADING_FLAG_SET_VIEWPORT
@ SPR_SHADING_FLAG_ENABLED
@ SPR_IMGFX_FLAG_10000000
@ PLAYER_SPRITES_MARIO_WORLD
@ PLAYER_SPRITES_PEACH_WORLD
@ PLAYER_SPRITES_COMBINED_EPILOGUE
@ PLAYER_SPRITES_MARIO_REFLECT_FLOOR
@ PLAYER_SPRITES_PEACH_BATTLE
@ PLAYER_SPRITES_MARIO_PARADE
@ PLAYER_SPRITES_MARIO_BATTLE
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
s32 imgfx_get_free_instances(s32)
void * _heap_malloc(HeapNode *head, u32 size)
u32 _heap_free(HeapNode *heapNodeList, void *addrToFree)
void imgfx_release_instance(u32)
void imgfx_update(u32, ImgFXType, s32, s32, s32, s32, s32)
HeapNode * _heap_create(HeapNode *addr, u32 size)
#define gDPScrollMultiTile2_4b(pkt, timg, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt)
#define gDPScrollTextureBlock_4b(pkt, timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt, scrolls, scrollt)
#define ASSERT_MSG(condition, msg, args...)
#define VIRTUAL_TO_PHYSICAL(addr)
Quad * spr_get_cached_quad(s32 quadIndex)
Quad * spr_get_quad_for_size(s32 *quadIndex, s32 width, s32 height)
void spr_draw_component(s32 drawOpts, SpriteComponent *component, SpriteAnimComponent *anim, SpriteRasterCacheEntry **cache, PAL_PTR *palettes, f32 zscale, Matrix4f mtx)
void spr_transform_point(s32 rotX, s32 rotY, s32 rotZ, f32 inX, f32 inY, f32 inZ, f32 *outX, f32 *outY, f32 *outZ)
s32 spr_get_notify_value(s32 spriteInstanceID)
void spr_component_update_commands(SpriteComponent *comp, SpriteAnimComponent *anim)
BSS b32 SpriteUseGeneralHeap
void spr_init_quad_cache(void)
void spr_make_quad_for_size(Quad *quad, s32 width, s32 height)
void spr_get_player_raster_info(SpriteRasterInfo *out, s32 playerSpriteID, s32 rasterIndex)
void spr_init_component_anim_state(SpriteComponent *comp, SpriteAnimComponent *anim)
BSS SpriteAnimData * NpcSpriteData[0xFF]
f32 SpriteAnimUpdateTimescale
void spr_render_init(void)
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
s32 spr_free_sprite(s32 spriteInstanceID)
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
s32 spr_get_npc_color_variations(s32 npcSpriteID)
BSS PlayerCurrentAnimInfo CurPlayerAnimInfo[3]
BSS s32 SpriteQuadCacheInfo[22]
BSS SpriteInstance SpriteInstances[51]
void spr_appendGfx_component_flat(Quad *vertices, IMG_PTR raster, PAL_PTR palette, s32 width, s32 height, f32 arg5, Matrix4f mtx, s32 alpha)
void spr_set_anim_timescale(f32 timescale)
void spr_appendGfx_component(SpriteRasterCacheEntry *cache, f32 dx, f32 dy, f32 dz, f32 rotX, f32 rotY, f32 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, s32 opacity, PAL_PTR palette, Matrix4f mtx)
BSS u8 NpcSpriteInstanceCount[0xFF]
s32 spr_get_npc_raster_info(SpriteRasterInfo *out, s32 npcSpriteID, s32 rasterIndex)
void spr_load_npc_extra_anims(SpriteAnimData *, u32 *)
void spr_load_player_sprite(s32 spriteIndex)
Gfx TranslucentSpriteGfx[]
s32 spr_unpack_signed_12bit(u16 val)
Gfx OpaqueShadedSpriteGfx[]
void spr_component_update_finish(SpriteComponent *comp, SpriteComponent **compList, SpriteRasterCacheEntry **rasterCacheEntry, s32 overridePalette)
void set_player_imgfx_all(s32 animID, ImgFXType imgfxType, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
#define MARIO_SPRITE_WORLD_BITS
s32 spr_unpack_signed_16bit(u16 val)
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR *paletteList, Matrix4f mtx)
void spr_init_sprites(s32 playerSpriteSet)
BSS s32 SpriteCurBaseRot[3]
HeapNode heap_generalHead
s32 spr_component_update(s32 curNotifyValue, SpriteComponent **compList, SpriteAnimComponent **animList, SpriteRasterCacheEntry **rasterCache, s32 overridePalette)
PAL_PTR * spr_get_npc_palettes(s32 npcSpriteID)
#define MARIO_SPRITE_BATTLE_BITS
Gfx TranslucentShadedSpriteGfx[]
SpriteComponent ** spr_allocate_components(s32)
s32 spr_get_comp_position(s32 spriteIdx, s32 compListIdx, s32 *outX, s32 *outY, s32 *outZ)
BSS Quad * SpriteQuadCache
BSS s32 SpriteUpdateNotifyValue
s32 func_802DDEC4(s32 spriteIdx)
s32 spr_load_npc_sprite(s32 animID, u32 *extraAnimList)
s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR *paletteList, Matrix4f mtx)
BSS SpriteAnimData * PlayerSprites[13]
void set_npc_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
void spr_clear_quad_cache(void)
BSS s32 MaxPlayerSpriteComponents
PAL_PTR * spr_get_player_palettes(s32 spriteIndex)
void spr_init_anim_state(SpriteComponent **compList, SpriteAnimComponent **animList)
#define MARIO_SPRITE_COMMON_BITS
BSS s32 CurPlayerSpriteIndex
#define PEACH_SPRITE_BITS
s32 spr_update_player_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
s32 get_npc_comp_imgfx_idx(s32 spriteIdx, s32 compIdx)
void set_player_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 flags)
BSS s32 MaxLoadedSpriteInstanceID
void spr_init_player_raster_cache(s32 cacheSize, s32 maxRasterSize)
SpriteAnimComponent ** animListStart[VLA]
SpriteAnimData * spriteData
#define SPR_UNPACK_PAL(animID)
#define SPR_UNPACK_ANIM(animID)
void create_shading_palette(Matrix4f mtx, s32 uls, s32 ult, s32 lrs, s32 lrt, s32 alpha, s32)
SpriteRasterCacheEntry ** rastersOffset
SpriteComponent ** componentList
@ DRAW_SPRITE_OVERRIDE_YAW
@ DRAW_SPRITE_OVERRIDE_ALPHA
@ DRAW_SPRITE_OVERRIDE_PALETTES
@ DRAW_SPRITE_UPSIDE_DOWN
@ DRAW_SPRITE_USE_PLAYER_RASTERS
#define SPR_UNPACK_SPR(animID)
SpriteComponent ** componentList
#define ANIM_LIST_END
Terminates an extraAnimationList.
GameStatus * gGameStatusPtr
SpriteShadingProfile * gSpriteShadingProfile
DisplayContext * gDisplayContext