mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
parent
b062511b1a
commit
af880293a3
@ -940,21 +940,6 @@ typedef struct StaticAnimatorNode {
|
||||
/* 0x2A */ char unk_2A[0x2];
|
||||
} StaticAnimatorNode; // size = 0x2C
|
||||
|
||||
typedef struct SpriteComponent {
|
||||
/* 0x00 */ s32 initialized;
|
||||
/* 0x04 */ s32 unk_04;
|
||||
/* 0x08 */ s16** readPos;
|
||||
/* 0x0C */ f32 waitTime;
|
||||
/* 0x10 */ s32 loopCounter;
|
||||
/* 0x14 */ s32 currentRaster;
|
||||
/* 0x18 */ s32 currentPalette;
|
||||
/* 0x1C */ Vec3f posOffset;
|
||||
/* 0x28 */ Vec3f compPos;
|
||||
/* 0x34 */ Vec3f rotation;
|
||||
/* 0x40 */ Vec3f scale;
|
||||
/* 0x4C */ char unk_4C[4];
|
||||
} SpriteComponent; // size = 0x50
|
||||
|
||||
typedef struct MessagePrintState {
|
||||
/* 0x000 */ s8* srcBuffer;
|
||||
/* 0x004 */ s16 printBufferPos;
|
||||
|
@ -455,7 +455,6 @@ void state_step_demo(void);
|
||||
void state_drawUI_demo(void);
|
||||
|
||||
void func_802B2078(void);
|
||||
void spr_update_player_sprite(s32, s32, f32);
|
||||
|
||||
void initialize_curtains(void);
|
||||
void update_curtains(void);
|
||||
@ -492,10 +491,6 @@ s32 func_8004A784(Npc* npc, f32 arg1, f32* arg2, f32* arg3, f32* arg4, f32* arg5
|
||||
void base_UnkNpcAIFunc1(Evt* script, NpcAISettings* aiSettings, EnemyTerritoryThing* territory);
|
||||
void UnkNpcAIFunc1(Evt* script, NpcAISettings* aiSettings, EnemyTerritoryThing* territory);
|
||||
|
||||
s32** spr_get_npc_palettes(s32 npcSpriteID);
|
||||
void spr_draw_player_sprite(s32 arg0, s32 arg1, s32 arg2, s32 arg3, Matrix4f arg4);
|
||||
void spr_draw_npc_sprite(s32 arg0, s32 arg1, s32 arg2, s32 arg3, Matrix4f* arg4);
|
||||
s32 spr_update_sprite(s32 arg0, s32 arg1, f32 arg2);
|
||||
void sin_cos_rad(f32 rad, f32* outSinTheta, f32* outCosTheta);
|
||||
|
||||
|
||||
@ -544,7 +539,6 @@ void btl_set_state(s32 battleState);
|
||||
void draw_entity_model_E(s32, Mtx*);
|
||||
void draw_entity_model_A(s32, Mtx*);
|
||||
void free_entity_model_by_index(s32 idx);
|
||||
s32 func_802DDFF8(s32, s32, s32, s32, s32, s32, u16);
|
||||
void func_8024E40C(s32);
|
||||
void btl_cam_set_zoffset(s16);
|
||||
void btl_cam_target_actor(s32);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "common.h"
|
||||
#include "sprite.h"
|
||||
|
||||
s32 func_80254250(void) {
|
||||
s32 ret;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "ld_addrs.h"
|
||||
#include "battle.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern s32 D_800DC060;
|
||||
extern Stage* D_800DC064;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "common.h"
|
||||
#include "map.h"
|
||||
#include "sprite.h"
|
||||
|
||||
typedef struct struct802E89B0 {
|
||||
/* 0x00 */ s32 unk_00;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "common.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern StaticEntityData D_802BC7D0_E2F100;
|
||||
extern f32 D_802BCE20;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "common.h"
|
||||
#include "sprite.h"
|
||||
|
||||
Npc* playerNpc = (Npc*) 0x802DB270; // XXX: raw ptr
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "nu/nusys.h"
|
||||
#include "ld_addrs.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
s8 D_80074020 = 1;
|
||||
s8 D_80074021 = 5;
|
||||
@ -172,7 +173,7 @@ void gfx_draw_frame(void) {
|
||||
|
||||
gSPMatrix(gMasterGfxPos++, D_800741A8, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
spr_render_init(gDisplayContext, &gMasterGfxPos);
|
||||
spr_render_init();
|
||||
|
||||
if (!(gOverrideFlags & 2)) {
|
||||
render_frame(0);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "map.h"
|
||||
#include "npc.h"
|
||||
#include "effects.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern s16 D_8010C97A;
|
||||
extern s32 D_8010C978;
|
||||
|
36
src/sprite.c
36
src/sprite.c
@ -1,38 +1,4 @@
|
||||
#include "common.h"
|
||||
|
||||
struct spr_playerCurrentAnimInfo {
|
||||
/* 0x00 */ SpriteComponent** componentList;
|
||||
/* 0x04 */ s32 animID;
|
||||
/* 0x08 */ s32 unk_08;
|
||||
}; // size = 0xC
|
||||
|
||||
struct D_802DFA48 {
|
||||
s32 unk_00;
|
||||
s32 unk_04;
|
||||
s32 unk_08;
|
||||
s32 unk_0C;
|
||||
s32 unk_10;
|
||||
}; // size = 0x14
|
||||
|
||||
typedef struct PlayerSpriteSet {
|
||||
/// Number of cache entries.
|
||||
/* 0x00 */ s32 cacheSize;
|
||||
|
||||
/// Maximum raster size.
|
||||
/* 0x04 */ s32 rasterSize;
|
||||
|
||||
/// Flags saying which rasters to load into the cache in spr_init_sprites(), with each bit corresponding to the Nth
|
||||
/// raster (with LSB = raster 0).
|
||||
/* 0x08 */ s32 initiallyLoaded;
|
||||
} PlayerSpriteSet; // size = 0xC
|
||||
|
||||
/// Sprite data header.
|
||||
typedef struct SpriteAnimData {
|
||||
/* 0x00 */ s32** rastersOffset;
|
||||
/* 0x04 */ s32** palettesOffset;
|
||||
/* 0x08 */ s32 maxComponents;
|
||||
/* 0x0C */ s32 colorVariations;
|
||||
} SpriteAnimData; // size = 0x10
|
||||
#include "sprite.h"
|
||||
|
||||
extern s32 D_802DF590[];
|
||||
extern s32 D_802DFA58[];
|
||||
|
195
src/sprite.h
Normal file
195
src/sprite.h
Normal file
@ -0,0 +1,195 @@
|
||||
#ifndef _SPRITE_H_
|
||||
#define _SPRITE_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct SpriteComponent {
|
||||
/* 0x00 */ s32 initialized;
|
||||
/* 0x04 */ s32 unk_04;
|
||||
/* 0x08 */ s16** readPos;
|
||||
/* 0x0C */ f32 waitTime;
|
||||
/* 0x10 */ s32 loopCounter;
|
||||
/* 0x14 */ s32 currentRaster;
|
||||
/* 0x18 */ s32 currentPalette;
|
||||
/* 0x1C */ Vec3f posOffset;
|
||||
/* 0x28 */ Vec3f compPos;
|
||||
/* 0x34 */ Vec3f rotation;
|
||||
/* 0x40 */ Vec3f scale;
|
||||
/* 0x4C */ char unk_4C[4];
|
||||
} SpriteComponent; // size = 0x50
|
||||
|
||||
struct spr_playerCurrentAnimInfo {
|
||||
/* 0x00 */ SpriteComponent** componentList;
|
||||
/* 0x04 */ s32 animID;
|
||||
/* 0x08 */ s32 unk_08;
|
||||
}; // size = 0xC
|
||||
|
||||
typedef struct SpriteComponentAnim {
|
||||
/* 0x00 */ s16** cmdList;
|
||||
/* 0x04 */ s16 cmdListSize;
|
||||
/* 0x08 */ Vec3s compOffset;
|
||||
} SpriteComponentAnim; // size = 0xC
|
||||
|
||||
// TODO: consider moving to 101b90_len_8f0 (sprite_cache)
|
||||
typedef struct SpriteRasterCacheEntry {
|
||||
/* 0x00 */ void* image;
|
||||
/* 0x04 */ u8 width;
|
||||
/* 0x05 */ u8 height;
|
||||
/* 0x06 */ u8 palette;
|
||||
/* 0x07 */ u8 quadCacheIndex;
|
||||
} SpriteRasterCacheEntry; // size = 0x8
|
||||
|
||||
struct D_802DFA48 {
|
||||
s32 unk_00;
|
||||
s32 unk_04;
|
||||
s32 unk_08;
|
||||
s32 unk_0C;
|
||||
s32 unk_10;
|
||||
}; // size = 0x14
|
||||
|
||||
typedef struct PlayerSpriteSet {
|
||||
/// Number of cache entries.
|
||||
/* 0x00 */ s32 cacheSize;
|
||||
|
||||
/// Maximum raster size.
|
||||
/* 0x04 */ s32 rasterSize;
|
||||
|
||||
/// Flags saying which rasters to load into the cache in spr_init_sprites(), with each bit corresponding to the Nth
|
||||
/// raster (with LSB = raster 0).
|
||||
/* 0x08 */ s32 initiallyLoaded;
|
||||
} PlayerSpriteSet; // size = 0xC
|
||||
|
||||
/// Sprite data header.
|
||||
typedef struct SpriteAnimData {
|
||||
/* 0x00 */ s32** rastersOffset;
|
||||
/* 0x04 */ s32** palettesOffset;
|
||||
/* 0x08 */ s32 maxComponents;
|
||||
/* 0x0C */ s32 colorVariations;
|
||||
} SpriteAnimData; // size = 0x10
|
||||
|
||||
typedef struct SpriteRasterInfo {
|
||||
/* 0x00 */ void* raster;
|
||||
/* 0x04 */ void* defaultPal;
|
||||
/* 0x08 */ s32 width;
|
||||
/* 0x0C */ s32 height;
|
||||
} SpriteRasterInfo; // size = 0x10
|
||||
|
||||
extern Vtx spr_defaultQuad[4];
|
||||
extern Vp D_802DF3D0;
|
||||
extern Vp D_802DF3E0;
|
||||
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 spr_init_quad_cache(void);
|
||||
|
||||
Vtx* spr_get_cached_quad(s32* quadIndex);
|
||||
|
||||
void spr_make_quad_for_size(Vtx* quad, s32 width, s32 height);
|
||||
|
||||
Vtx* spr_get_quad_for_size(s32* quadIndex, s32 width, s32 height);
|
||||
|
||||
void spr_clear_quad_cache(void);
|
||||
|
||||
void spr_appendGfx_component_flat(
|
||||
Vtx* vertices,
|
||||
void* raster, void* palette,
|
||||
s32 width, s32 height,
|
||||
s32 arg5,
|
||||
Matrix4f mtx,
|
||||
s32 alpha
|
||||
);
|
||||
|
||||
void spr_appendGfx_component(
|
||||
Vtx* vertices,
|
||||
void* raster, void* palette,
|
||||
s32 width, s32 height,
|
||||
s32 arg5,
|
||||
Matrix4f mtx,
|
||||
s32 alpha
|
||||
);
|
||||
|
||||
void spr_transform_point(s32 rotX, s32 rotY, s32 rotZ, f32 inX, f32 inY, f32 inZ, f32* outX, f32* outY, f32* outZ);
|
||||
|
||||
void spr_draw_component(
|
||||
SpriteRasterCacheEntry* raster,
|
||||
f32 dx, f32 dy, f32 dz,
|
||||
f32 rotX, f32 rotY, f32 rotZ,
|
||||
f32 scaleX, f32 scaleY, f32 scaleZ,
|
||||
s32 opacity,
|
||||
void* palette,
|
||||
Matrix4f mtx
|
||||
);
|
||||
|
||||
s32 spr_sign_extend_12bit(u16 val);
|
||||
|
||||
s32 spr_sign_extend_16bit(u16 val);
|
||||
|
||||
void spr_component_update_commands(SpriteComponent* comp, SpriteComponentAnim* anim);
|
||||
|
||||
void spr_component_update_finish(
|
||||
SpriteComponent* comp,
|
||||
SpriteComponent** compList,
|
||||
SpriteRasterCacheEntry* rasterCacheEntry,
|
||||
s32 overridePalette
|
||||
);
|
||||
|
||||
// TODO: anim possibly should be SpriteComponentAnim*
|
||||
void spr_init_component_anim_state(SpriteComponent* comp, s16*** anim);
|
||||
|
||||
void spr_init_anim_state(SpriteComponent** compList, s16** cmdList);
|
||||
|
||||
void spr_set_anim_timescale(f32 timeScale);
|
||||
|
||||
void spr_load_player_sprite(s32 spriteIndex);
|
||||
|
||||
void spr_init_sprites(s32 playerSpriteSet);
|
||||
|
||||
void spr_render_init(void);
|
||||
|
||||
s32 func_802DDA84(void);
|
||||
|
||||
void spr_update_player_sprite(s32 arg0, s32 arg1, f32 arg2);
|
||||
|
||||
s32 spr_draw_player_sprite(s32 arg0, s32 yaw, s32 arg2, s16** paletteList, Matrix4f mtx);
|
||||
|
||||
s32 func_802DDEC4(s32 arg0);
|
||||
|
||||
s32 func_802DDEE4(s32, s32, s32, s32, s32, s32, s32, s32);
|
||||
|
||||
// TODO: problem with arg6, see the NON_MATCHING in sprite.c
|
||||
s32 func_802DDFF8(s32, s32, s32, s32, s32, s32, u16);
|
||||
|
||||
void spr_get_player_raster_info(SpriteRasterInfo* out, s32 playerSpriteID, s32 rasterIndex);
|
||||
|
||||
s16** spr_get_player_palettes(s32 spriteIndex);
|
||||
|
||||
/// @param animID - Set MSB for tail allocation (i.e. `0x80XXYYZZ`)
|
||||
s32 spr_load_npc_sprite(s32 animID, s32** extraAnimList);
|
||||
|
||||
void spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale);
|
||||
|
||||
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, s16** paletteList, Matrix4f mtx);
|
||||
|
||||
s32 func_802DE5C8(s32 arg0);
|
||||
|
||||
s32 spr_free_sprite(s32 spriteInstanceID);
|
||||
|
||||
//s32 func_802DE748(); // TODO
|
||||
|
||||
//s32 func_802DE780(); // TODO
|
||||
|
||||
s32 func_802DE894(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6);
|
||||
|
||||
//s32 func_802DE8DC(); // TODO
|
||||
|
||||
s32 spr_get_npc_raster_info(SpriteRasterInfo* out, int npcSpriteID, int rasterIndex);
|
||||
|
||||
s32** spr_get_npc_palettes(s32 npcSpriteID);
|
||||
|
||||
s32 spr_get_npc_color_variations(s32 npcSpriteID);
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
#include "nu/nusys.h"
|
||||
#include "hud_element.h"
|
||||
#include "ld_addrs.h"
|
||||
#include "sprite.h"
|
||||
|
||||
s32 D_800778A0[] = {
|
||||
&D_8038F800, &D_803B5000, &D_803DA800,
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "common.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
typedef struct DemoSceneData {
|
||||
/* 0x0 */ s16 unk_0;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "nu/nusys.h"
|
||||
#include "camera.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
s32 D_80077980[] = { &D_8038F800, &D_803B5000, &D_803DA800, };
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "common.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
extern s32 D_800A0950;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "ld_addrs.h"
|
||||
#include "camera.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
void appendGfx_intro_logos();
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "map.h"
|
||||
#include "nu/nusys.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
s32 D_80077950[] = { 0x8038F800, 0x803B5000, &D_803DA800 };
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "common.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
void state_init_startup(void) {
|
||||
gOverrideFlags |= 0x8;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "tst_04.h"
|
||||
#include "sprite.h"
|
||||
|
||||
static char* N(exit_str_0) = "tst_03";
|
||||
static char* N(exit_str_1) = "";
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "tst_11.h"
|
||||
#include "sprite.h"
|
||||
|
||||
void func_8024003C_B1CA8C(void);
|
||||
void func_80240100_B1CB50(PlayerStatus*);
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "map.h"
|
||||
#include "sprite.h"
|
||||
|
||||
enum Reflection {
|
||||
REFLECTION_FLOOR_WALL,
|
||||
@ -189,9 +190,11 @@ void N(reflection_setup_floor)(void) {
|
||||
renderTaskPtr->renderMode = renderMode;
|
||||
renderTaskPtr->appendGfxArg = playerStatus;
|
||||
renderTaskPtr->distance = -screenZ;
|
||||
renderTaskPtr->appendGfx = (!(playerStatus->flags & 0x20000) ?
|
||||
N(reflection_render_floor) :
|
||||
N(reflection_render_floor_fancy));
|
||||
renderTaskPtr->appendGfx = (void (*)(void*)) (
|
||||
!(playerStatus->flags & 0x20000)
|
||||
? N(reflection_render_floor)
|
||||
: N(reflection_render_floor_fancy)
|
||||
);
|
||||
queue_render_task(renderTaskPtr);
|
||||
}
|
||||
}
|
||||
@ -226,7 +229,7 @@ void N(reflection_render_floor)(PlayerStatus* playerStatus) {
|
||||
}
|
||||
|
||||
void N(reflection_render_floor_fancy)(PlayerStatus* playerStatus) {
|
||||
Matrix4f main;
|
||||
Matrix4f mtx;
|
||||
Matrix4f translation;
|
||||
Matrix4f rotation;
|
||||
Matrix4f scale;
|
||||
@ -267,8 +270,8 @@ void N(reflection_render_floor_fancy)(PlayerStatus* playerStatus) {
|
||||
func_802DDEE4(1, -1, 6, tint, tint, tint, 255, 0);
|
||||
|
||||
guRotateF(rotation, yaw, 0.0f, -1.0f, 0.0f);
|
||||
guRotateF(main, clamp_angle(playerStatus->unk_8C), 0.0f, 0.0f, 1.0f);
|
||||
guMtxCatF(rotation, main, main);
|
||||
guRotateF(mtx, clamp_angle(playerStatus->unk_8C), 0.0f, 0.0f, 1.0f);
|
||||
guMtxCatF(rotation, mtx, mtx);
|
||||
px = playerStatus->position.x;
|
||||
py = playerStatus->position.y;
|
||||
pz = playerStatus->position.z;
|
||||
@ -286,24 +289,24 @@ void N(reflection_render_floor_fancy)(PlayerStatus* playerStatus) {
|
||||
px = playerStatus->position.x;
|
||||
pz = playerStatus->position.z;
|
||||
func_802DDEE4(1, -1, 7, 0, 0, 0, 0x40, 0);
|
||||
guRotateF(main, yaw, 0.0f, -1.0f, 0.0f);
|
||||
guRotateF(mtx, yaw, 0.0f, -1.0f, 0.0f);
|
||||
guRotateF(rotation, yaw, 0.0f, -1.0f, 0.0f);
|
||||
guRotateF(main, blurAngle, 0.0f, 1.0f, 0.0f);
|
||||
guMtxCatF(rotation, main, main);
|
||||
guRotateF(mtx, blurAngle, 0.0f, 1.0f, 0.0f);
|
||||
guMtxCatF(rotation, mtx, mtx);
|
||||
}
|
||||
|
||||
guTranslateF(translation, 0.0f, -playerStatus->colliderHeight * 0.5f, 0.0f);
|
||||
guMtxCatF(translation, main, main);
|
||||
guMtxCatF(translation, mtx, mtx);
|
||||
guRotateF(rotation, yaw, 0.0f, 1.0f, 0.0f);
|
||||
guMtxCatF(main, rotation, main);
|
||||
guMtxCatF(mtx, rotation, mtx);
|
||||
guRotateF(rotation, playerStatus->spriteFacingAngle, 0.0f, 1.0f, 0.0f);
|
||||
guMtxCatF(main, rotation, main);
|
||||
guMtxCatF(mtx, rotation, mtx);
|
||||
guTranslateF(translation, 0.0f, playerStatus->colliderHeight * 0.5f, 0.0f);
|
||||
guMtxCatF(main, translation, main);
|
||||
guMtxCatF(mtx, translation, mtx);
|
||||
guScaleF(scale, SPRITE_WORLD_SCALE, -SPRITE_WORLD_SCALE, SPRITE_WORLD_SCALE);
|
||||
guMtxCatF(main, scale, main);
|
||||
guMtxCatF(mtx, scale, mtx);
|
||||
guTranslateF(translation, px, -py, pz);
|
||||
guMtxCatF(main, translation, main);
|
||||
guMtxCatF(mtx, translation, mtx);
|
||||
|
||||
if (playerStatus->spriteFacingAngle >= 90.0f && playerStatus->spriteFacingAngle < 270.0f) {
|
||||
flags = 0x10000001;
|
||||
@ -311,7 +314,7 @@ void N(reflection_render_floor_fancy)(PlayerStatus* playerStatus) {
|
||||
flags = 1;
|
||||
}
|
||||
|
||||
spr_draw_player_sprite(flags, 0, 0, 0, &main);
|
||||
spr_draw_player_sprite(flags, 0, 0, NULL, mtx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "map.h"
|
||||
#include "camera.h"
|
||||
#include "hud_element.h"
|
||||
#include "sprite.h"
|
||||
|
||||
#define ASSET_TABLE_ROM_START 0x1E40000
|
||||
#define ASSET_TABLE_HEADER_SIZE 0x20
|
||||
|
Loading…
Reference in New Issue
Block a user