Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
sprite.h
Go to the documentation of this file.
1#ifndef _SPRITE_H_
2#define _SPRITE_H_
3
4#include "common.h"
5
6#define SPR_PLAYER_COLOR_VARIATIONS 6
7#define SPR_PEACH_BTL_PAL_STRIDE 4
8
10 SPRITE_ID_ANIM_MASK = 0x000000FF,
11 SPRITE_ID_PAL_MASK = 0x0000FF00,
12 SPRITE_ID_SPR_MASK = 0x00FF0000,
15};
16
24
25enum {
29};
30
31//TODO this is just a boolean isNpcSprite, using a temp enum for documenting
32enum {
35};
36
37typedef struct SpriteComponent {
38 /* 0x00 */ s32 initialized;
39 /* 0x04 */ s32 properties;
40 /* 0x08 */ s16* readPos;
41 /* 0x0C */ f32 waitTime;
42 /* 0x10 */ s32 loopCounter;
43 /* 0x14 */ s32 curRaster;
44 /* 0x18 */ s32 curPalette;
45 /* 0x1C */ Vec3f posOffset;
46 /* 0x28 */ Vec3f compPos;
47 /* 0x34 */ Vec3i rot;
48 /* 0x40 */ Vec3f scale;
49 /* 0x4C */ s32 imgfxIdx;
50} SpriteComponent; // size = 0x50
51
52typedef struct PlayerCurrentAnimInfo {
54 /* 0x04 */ s32 animID;
55 /* 0x08 */ s32 notifyValue;
56} PlayerCurrentAnimInfo; // size = 0xC
57
58typedef struct SpriteAnimComponent {
59 /* 0x00 */ u16* cmdList;
60 /* 0x04 */ s16 cmdListSize;
61 /* 0x06 */ Vec3s compOffset;
62} SpriteAnimComponent; // size = 0xC
63
64// TODO: consider moving to 101b90_len_8f0 (sprite_cache)
65typedef struct SpriteRasterCacheEntry {
66 /* 0x00 */ IMG_PTR image;
67 /* 0x04 */ u8 width;
68 /* 0x05 */ u8 height;
69 /* 0x06 */ s8 palette;
70 /* 0x07 */ s8 quadCacheIndex;
71} SpriteRasterCacheEntry; // size = 0x8
72
74typedef struct SpriteAnimData {
77 /* 0x08 */ s32 maxComponents;
78 /* 0x0C */ s32 colorVariations;
80} SpriteAnimData; // size = 0x14
81
82typedef struct SpriteInstance {
83 /* 0x00 */ s32 spriteIndex;
86 /* 0x0C */ s32 curAnimID;
87 /* 0x10 */ s32 notifyValue;
88} SpriteInstance; // size = 0x14
89
90typedef struct PlayerRastersHeader {
91 /* 0x00 */ s32 indexRanges;
92 /* 0x04 */ s32 loadDescriptors;
93 /* 0x08 */ s32 imageData;
94} PlayerRastersHeader; // size = 0xC
95
96typedef struct PlayerSpriteSet {
98 /* 0x00 */ s32 cacheSize;
99
101 /* 0x04 */ s32 rasterSize;
102
105 /* 0x08 */ s32 initiallyLoaded;
106} PlayerSpriteSet; // size = 0xC
107
109 /* 0x00 */ s32 lazyDeleteTime;
110 /* 0x04 */ s32 rasterIndex;
111 /* 0x08 */ s32 spriteIndex;
112 /* 0x0C */ IMG_PTR raster;
113} PlayerSpriteCacheEntry; // size = 0x10
114
115typedef struct Quad {
116 Vtx v[4];
117} Quad; // size = 0x40
118
119extern Quad spr_defaultQuad;
120extern Vp SprPauseVp;
121extern Vp SprPauseVpAlt;
122extern Gfx D_802DF3F0[];
123extern Gfx D_802DF428[];
124extern Gfx D_802DF460[];
125extern Gfx D_802DF490[];
126extern f32 spr_animUpdateTimeScale;
128
129void imgfx_init(void);
130
131void spr_init_sprites(s32 playerSpriteSet);
132
133void spr_render_init(void);
134
136
137s32 spr_update_player_sprite(s32 arg0, s32 arg1, f32 timescale);
138
139s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* paletteList, Matrix4f mtx);
140
141s32 func_802DDEC4(s32 arg0);
142
143void set_player_imgfx_comp(s32, s32, ImgFXType, s32, s32, s32, s32, s32);
144
145void set_player_imgfx_all(s32, ImgFXType, s32, s32, s32, s32, s32);
146
147IMG_PTR spr_get_player_raster(s32 rasterIndex, s32 playerSpriteID);
148
149void spr_get_player_raster_info(SpriteRasterInfo* out, s32 playerSpriteID, s32 rasterIndex);
150
151PAL_PTR* spr_get_player_palettes(s32 spriteIndex);
152
154s32 spr_load_npc_sprite(s32 animID, u32* extraAnimList);
155
156s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale);
157
158s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR* paletteList, Matrix4f mtx);
159
160s32 spr_get_notify_value(s32 arg0);
161
162s32 spr_free_sprite(s32 spriteInstanceID);
163
164s32 get_npc_comp_imgfx_idx(s32, s32);
165
166void set_npc_imgfx_comp(s32, s32, ImgFXType, s32, s32, s32, s32, s32);
167
168void set_npc_imgfx_all(s32 arg0, ImgFXType arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6);
169
170s32 spr_get_comp_position(s32 spriteIdx, s32 compListIdx, s32* outX, s32* outY, s32* outZ);
171
172s32 spr_get_npc_raster_info(SpriteRasterInfo* out, s32 npcSpriteID, s32 rasterIndex);
173
174PAL_PTR* spr_get_npc_palettes(s32 npcSpriteID);
175
176s32 spr_get_npc_color_variations(s32 npcSpriteID);
177
178void create_shading_palette(Matrix4f mtx, s32 uls, s32 ult, s32 lrs, s32 lrt, s32 alpha, s32);
179
180SpriteAnimData* spr_load_sprite(s32 idx, s32 arg1, s32 arg2);
181
182#endif
#define PAL_PTR
#define IMG_PTR
f32 Matrix4f[4][4]
ImgFXType
Definition enums.h:5116
#define VLA
Definition macros.h:516
SpriteAnimComponent ** animListStart[VLA]
Definition sprite.h:79
PlayerSpriteSet spr_playerSpriteSets[7]
Definition sprite.c:114
IMG_PTR spr_get_player_raster(s32 rasterIndex, s32 playerSpriteID)
s32 rasterSize
Maximum raster size.
Definition sprite.h:101
Vec3f posOffset
Definition sprite.h:45
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:1106
void spr_get_player_raster_info(SpriteRasterInfo *out, s32 playerSpriteID, s32 rasterIndex)
Definition sprite.c:999
SpriteAnimData * spriteData
Definition sprite.h:85
s32 initiallyLoaded
Flags saying which rasters to load into the cache in spr_init_sprites(), with each bit corresponding ...
Definition sprite.h:105
s32 spriteIndex
Definition sprite.h:83
Vec3f compPos
Definition sprite.h:46
void spr_render_init(void)
Definition sprite.c:814
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
Definition sprite.c:1072
void spr_update_player_raster_cache(void)
s32 spr_free_sprite(s32 spriteInstanceID)
Definition sprite.c:1178
s32 properties
AABBCCCC : AA = unused?, BB = parent, CCCC = notify value.
Definition sprite.h:39
s32 spr_get_npc_color_variations(s32 npcSpriteID)
Definition sprite.c:1329
Gfx D_802DF3F0[]
Definition sprite.c:49
@ SPRITE_MODE_NPC
Definition sprite.h:34
@ SPRITE_MODE_PLAYER
Definition sprite.h:33
void create_shading_palette(Matrix4f mtx, s32 uls, s32 ult, s32 lrs, s32 lrt, s32 alpha, s32)
SpriteAnimData * spr_load_sprite(s32 idx, s32 arg1, s32 arg2)
s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:872
s16 * readPos
Definition sprite.h:40
SpriteRasterCacheEntry ** rastersOffset
Definition sprite.h:75
s32 get_npc_comp_imgfx_idx(s32, s32)
Definition sprite.c:1218
s32 curAnimID
Definition sprite.h:86
Vp SprPauseVp
Definition sprite.c:37
s32 spr_get_npc_raster_info(SpriteRasterInfo *out, s32 npcSpriteID, s32 rasterIndex)
Definition sprite.c:1302
@ PLAYER_SPRITE_AUX1
Definition sprite.h:27
@ PLAYER_SPRITE_AUX2
Definition sprite.h:28
@ PLAYER_SPRITE_MAIN
Definition sprite.h:26
s32 spr_get_notify_value(s32 arg0)
Definition sprite.c:1174
Gfx D_802DF428[]
Definition sprite.c:59
void set_npc_imgfx_comp(s32, s32, ImgFXType, s32, s32, s32, s32, s32)
Definition sprite.c:1228
Quad spr_defaultQuad
Definition sprite.c:28
s32 spr_update_player_sprite(s32 arg0, s32 arg1, f32 timescale)
Definition sprite.c:823
void set_player_imgfx_all(s32, ImgFXType, s32, s32, s32, s32, s32)
Definition sprite.c:995
SpriteComponent ** componentList
Definition sprite.h:84
DrawSpriteOptions
Definition sprite.h:17
@ DRAW_SPRITE_OVERRIDE_YAW
Definition sprite.h:21
@ DRAW_SPRITE_OVERRIDE_ALPHA
Definition sprite.h:22
@ DRAW_SPRITE_OVERRIDE_PALETTES
Definition sprite.h:20
@ DRAW_SPRITE_UPSIDE_DOWN
Definition sprite.h:19
@ DRAW_SPRITE_USE_PLAYER_RASTERS
Definition sprite.h:18
void imgfx_init(void)
Definition imgfx.c:243
s32 cacheSize
Number of cache entries.
Definition sprite.h:98
s32 initialized
Definition sprite.h:38
void spr_init_sprites(s32 playerSpriteSet)
Definition sprite.c:764
Gfx D_802DF490[]
Definition sprite.c:78
PAL_PTR * spr_get_npc_palettes(s32 npcSpriteID)
Definition sprite.c:1319
s32 spr_get_comp_position(s32 spriteIdx, s32 compListIdx, s32 *outX, s32 *outY, s32 *outZ)
Definition sprite.c:1258
f32 spr_animUpdateTimeScale
Definition sprite.c:87
s32 spr_load_npc_sprite(s32 animID, u32 *extraAnimList)
Definition sprite.c:1026
Vtx v[4]
Definition sprite.h:116
void set_player_imgfx_comp(s32, s32, ImgFXType, s32, s32, s32, s32, s32)
Definition sprite.c:969
SpriteComponent ** componentList
Definition sprite.h:53
PAL_PTR * spr_get_player_palettes(s32 spriteIndex)
Definition sprite.c:1016
s32 loopCounter
Definition sprite.h:42
PAL_PTR * palettesOffset
Definition sprite.h:76
Gfx D_802DF460[]
Definition sprite.c:69
s32 func_802DDEC4(s32 arg0)
Definition sprite.c:965
void set_npc_imgfx_all(s32 arg0, ImgFXType arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
Definition sprite.c:1254
s32 notifyValue
Definition sprite.h:87
Vec3f scale
Definition sprite.h:48
SpriteIDFields
Definition sprite.h:9
@ SPRITE_ID_SPR_MASK
Definition sprite.h:12
@ SPRITE_ID_ANIM_MASK
Definition sprite.h:10
@ SPRITE_ID_TAIL_ALLOCATE
Definition sprite.h:14
@ SPRITE_ID_PAL_MASK
Definition sprite.h:11
@ SPRITE_ID_BACK_FACING
Definition sprite.h:13
Vp SprPauseVpAlt
Definition sprite.c:43
s32 colorVariations
Definition sprite.h:78
s32 maxComponents
Definition sprite.h:77
Definition sprite.h:115
Sprite data header.
Definition sprite.h:74