2#include "sprite/player.h"
4#define MAX_SPRITE_ID 0xFF
30 {{{ -16, 56, 0 },
FALSE, { 0, 0 }, { 240, 240, 240, 255 }}},
31 {{{ 16, 56, 0 },
FALSE, { 1024, 0 }, { 120, 120, 120, 255 }}},
32 {{{ 16, 0, 0 },
FALSE, { 1024, 1792 }, { 0, 0, 0, 255 }}},
33 {{{ -16, 0, 0 },
FALSE, { 0, 1792 }, { 120, 120, 120, 255 }}},
89#define MARIO_SPRITE_COMMON_BITS \
91 | 1 << SPR_Mario1_Back \
93#define MARIO_SPRITE_WORLD_BITS \
94 MARIO_SPRITE_COMMON_BITS \
96 | 1 << SPR_MarioW1_Back \
100#define MARIO_SPRITE_BATTLE_BITS \
101 MARIO_SPRITE_COMMON_BITS \
106#define PEACH_SPRITE_BITS \
108 | 1 << SPR_Peach1_Back \
146 vtx->
v.ob[0] = -width / 2;
147 vtx->v.ob[1] = height;
148 vtx->v.tc[0] = 0x2000;
149 vtx->v.tc[1] = 0x2000;
152 vtx->v.ob[0] = width / 2;
153 vtx->v.ob[1] = height;
154 vtx->v.tc[0] = (width + 256) * 32;
155 vtx->v.tc[1] = 0x2000;
158 vtx->v.tc[0] = (width + 256) * 32;
159 vtx->v.ob[0] = width / 2;
160 vtx->v.tc[1] = (height + 256) * 32;
163 vtx->v.ob[0] = -width / 2;
164 vtx->v.tc[0] = 0x2000;
165 vtx->v.tc[1] = (height + 256) * 32;
174 if ((width * height) / 2 <= 0x800) {
175 dimensions = (width << 0x18) + (height << 0x10);
221 s32 width, s32 height,
229 0, 0, width - 1, height - 1, 0,
232 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);
344 if (scaleX != 1.0f || scaleY != 1.0f ||
scaleZ != 1.0f) {
354 if ((
u8) opacity == 255) {
360 if ((
u8) opacity == 255) {
368 width =
cache->width;
369 height =
cache->height;
384 ifxImg.xOffset = -(width / 2);
395 if (rotX == 0 && rotY == 0 && rotZ == 0) {
431 f32 rotX, rotY, rotZ;
470 return temp | ~0xFFF;
480 return temp | ~0xFFFF;
487 f32 posX, posY, posZ;
488 f32 rotX, rotY, rotZ;
496 if (
comp->initialized) {
507 while (
comp->waitTime <= 0.0f) {
514 switch (*
bufPos & 0xF000) {
519 if (
comp->waitTime == 0.0f) {
520 comp->waitTime = 4095.0f;
522 comp->posOffset.z = 0.0f;
523 comp->posOffset.y = 0.0f;
524 comp->posOffset.x = 0.0f;
528 comp->scale.z = 1.0f;
529 comp->scale.y = 1.0f;
530 comp->scale.x = 1.0f;
538 comp->waitTime = 1.0f;
549 comp->curRaster = -1;
551 comp->curPalette = -1;
560 comp->curPalette = -1;
582 switch (*
bufPos++ & 0xF) {
603 switch (*
bufPos++ & 0xF) {
610 scaleX = *
bufPos++ / 100.0f;
613 scaleY = *
bufPos++ / 100.0f;
624 if (
comp->loopCounter != 0) {
626 if (
comp->loopCounter == 0) {
638 comp->waitTime = 1.0f;
645 comp->posOffset.x = posX;
646 comp->posOffset.y = posY;
647 comp->posOffset.z = posZ;
655 comp->scale.x = scaleX;
656 comp->scale.y = scaleY;
668 if (
comp->initialized) {
669 comp->compPos.x =
comp->posOffset.x;
670 comp->compPos.y =
comp->posOffset.y;
671 comp->compPos.z =
comp->posOffset.z;
673 if ((
comp->properties & 0xF00) == 0x100) {
680 if (
comp->curRaster != -1) {
682 if (
comp->curPalette == -1) {
721 comp->properties = 0;
724 comp->loopCounter = 0;
725 comp->curRaster = -1;
726 comp->curPalette = -1;
727 comp->posOffset.x = 0.0f;
728 comp->posOffset.y = 0.0f;
729 comp->posOffset.z = 0.0f;
730 comp->compPos.x = 0.0f;
731 comp->compPos.y = 0.0f;
732 comp->compPos.z = 0.0f;
736 comp->scale.x = 1.0f;
737 comp->scale.y = 1.0f;
738 comp->scale.z = 1.0f;
829 s32
spriteId = ((animID >> 16) & 0xFF) - 1;
847 if (spriteData ==
NULL) {
891 if (spriteData ==
NULL) {
1031 s32 spriteIndex = (animID >> 0x10) & 0x7FFF;
1055 if (extraAnimList !=
NULL) {
1078 s32 i = spriteInstanceID & 0xFF;
1090 palID = (animID >> 8) & 0xFF;
1093 ASSERT_MSG(animList != -1,
"Anim %lx is not loaded", animID);
1106 s32 i = spriteInstanceID & 0xFF;
1150 alpha =
arg2 & 0xFF;
1181 s32 spriteIndex =
sprite->spriteIndex;
1184 return spriteInstanceID;
1188 spriteData =
sprite->spriteData;
1220 if (componentList ==
NULL) {
1233 componentList =
sprite->componentList;
1271 animID =
sprite->curAnimID;
1272 if (animID != 255) {
1276 spriteData += 4 + animID;
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)
void spr_component_update_commands(SpriteComponent *comp, SpriteAnimComponent *anim)
BSS s32 spr_allocateBtlComponentsOnWorldHeap
void spr_init_quad_cache(void)
void spr_make_quad_for_size(Quad *quad, s32 width, s32 height)
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR *paletteList, Matrix4f mtx)
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]
BSS SpriteAnimData * spr_playerSprites[13]
void spr_render_init(void)
BSS s32 spr_playerMaxComponents
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
s32 spr_free_sprite(s32 spriteInstanceID)
s32 spr_get_notify_value(s32 spriteIndex)
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)
PlayerSpriteSet spr_playerSpriteSets[]
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)
s32 spr_unpack_signed_12bit(u16 val)
BSS PlayerCurrentAnimInfo spr_playerCurrentAnimInfo[3]
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)
void spr_init_sprites(s32 playerSpriteSet)
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
SpriteComponent ** spr_allocate_components(s32)
s32 spr_get_comp_position(s32 spriteIdx, s32 compListIdx, s32 *outX, s32 *outY, s32 *outZ)
BSS s32 SpriteUpdateNotifyValue
s32 func_802DDEC4(s32 spriteIdx)
f32 spr_animUpdateTimeScale
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)
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)
PAL_PTR * spr_get_player_palettes(s32 spriteIndex)
void spr_init_anim_state(SpriteComponent **compList, SpriteAnimComponent **animList)
#define MARIO_SPRITE_COMMON_BITS
#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)
SpriteAnimData * spriteData
void create_shading_palette(Matrix4f mtx, s32 uls, s32 ult, s32 lrs, s32 lrt, s32 alpha, s32)
SpriteComponent ** componentList
@ DRAW_SPRITE_OVERRIDE_YAW
@ DRAW_SPRITE_OVERRIDE_ALPHA
@ DRAW_SPRITE_OVERRIDE_PALETTES
@ DRAW_SPRITE_UPSIDE_DOWN
@ DRAW_SPRITE_USE_PLAYER_RASTERS
SpriteComponent ** componentList
#define ANIM_LIST_END
Terminates an extraAnimationList.
GameStatus * gGameStatusPtr
SpriteShadingProfile * gSpriteShadingProfile
DisplayContext * gDisplayContext