Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
WhaleAnim.inc.c File Reference

Go to the source code of this file.

Functions

Npc *N resolve_npc (Evt *script, s32 npcIdOrPtr)
 
void N unkVtxFunc001 (Vtx *firstVertex, Vtx *copiedVertices, s32 numVertices, s32 *wagPhasePtr)
 
void N unkAngleFunc002 (void)
 
void N unkAngleFunc003 (void)
 

Function Documentation

◆ resolve_npc()

Npc *N resolve_npc ( Evt * script,
s32 npcIdOrPtr )

Definition at line 4 of file WhaleAnim.inc.c.

4 {
5 if (npcIdOrPtr == NPC_SELF) {
6 return get_npc_safe(script->owner2.npcID);
7 } else if (npcIdOrPtr >= EVT_LIMIT) {
8 return get_npc_safe(npcIdOrPtr);
9 } else {
10 return (Npc*) npcIdOrPtr;
11 }
12}
union Evt::@9 owner2
Initially -1.
@ NPC_SELF
Definition enums.h:2526
Npc * get_npc_safe(s32 npcID)
Definition npc.c:1010
#define EVT_LIMIT
Definition macros.h:47

Referenced by _show_message().

◆ unkVtxFunc001()

void N unkVtxFunc001 ( Vtx * firstVertex,
Vtx * copiedVertices,
s32 numVertices,
s32 * wagPhasePtr )

Definition at line 47 of file WhaleAnim.inc.c.

47 {
48 s32 wagPhase;
49 s32 bendPow, bendFrac;
50 s32 i, j;
51 s16* vtxPos;
52 f32 newX, newY;
53 f32 angle;
54 s32 offset;
55
56 wagPhase = *wagPhasePtr;
57 switch (get_npc_safe(NPC_Whale)->curAnim) {
58 case ANIM_Kolorado_Still:
59 case ANIM_Kolorado_Yell:
60 case ANIM_Kolorado_IdleSad:
61 case ANIM_Kolorado_Walk:
62 case ANIM_Kolorado_WalkSad:
63 case ANIM_Kolorado_Run:
64 case ANIM_Kolorado_Panic:
65 case ANIM_Kolorado_Talk:
66 case ANIM_Kolorado_TalkSad:
67 case ANIM_Kolorado_Fallen:
68 case ANIM_Kolorado_HurtStill:
69 break;
70 case ANIM_Kolorado_Idle:
71 case ANIM_Kolorado_Shout:
72 if (*wagPhasePtr < 0) {
73 wagPhase = 0;
74 *wagPhasePtr = 0;
75 }
76 break;
77 }
78
79 for (i = 0; i < numVertices; i++) {
80 vtxPos = firstVertex[i].v.ob;
81 offset = 30;
82
83 if (vtxPos[0] > 30) {
84 newX = 0.0f;
85 newY = 0.0f;
86 // determine number of bend stages to apply
87 bendPow = (vtxPos[0] - offset) / 10;
88 bendFrac = vtxPos[0] - ((bendPow * 10) + offset);
89 // apply formula once per 10 unit interval from X = 30
90 for (j = 0; j < bendPow; j++) {
91 angle = (j / 15.0f) + ((j / 40.0f) * sin_deg(wagPhase));
92 newX += cos_rad(angle) * 10.0f;
93 newY += sin_rad(angle) * 10.0f;
94 }
95 // add fractional part between current and next interval
96 angle = (j / 15.0f) + ((j / 40.0f) * sin_deg(wagPhase));
97 newX += bendFrac * cos_rad(angle);
98 newY += bendFrac * sin_rad(angle);
99
100 copiedVertices[i].v.ob[0] = newX;
101 copiedVertices[i].v.ob[1] = vtxPos[1] + newY;
102 }
103 }
104}
#define sin_deg
f32 cos_rad(f32 x)
Definition 43F0.c:717
f32 sin_rad(f32 x)
Definition 43F0.c:713

Referenced by unkAngleFunc002(), and unkAngleFunc003().

◆ unkAngleFunc002()

void N unkAngleFunc002 ( void )

Definition at line 106 of file WhaleAnim.inc.c.

106 {
107 Vtx* firstVertex;
108 Vtx* copiedVertices;
109 s32 numVertices;
110
111 mdl_get_copied_vertices(VTX_COPY_1, &firstVertex, &copiedVertices, &numVertices);
112 N(unkVtxFunc001)(firstVertex, copiedVertices, numVertices, &N(unkAngle2));
113
114 gSPDisplayList(gMainGfxPos++, mdl_get_copied_gfx(VTX_COPY_1));
115 if (N(unkAngle2) >= 0) {
116 N(unkAngle2) += 4;
117 }
118 if (N(unkAngle2) >= 360) {
119 N(unkAngle2) = -1;
120 }
121}
void N unkVtxFunc001(Vtx *firstVertex, Vtx *copiedVertices, s32 numVertices, s32 *wagPhasePtr)
@ VTX_COPY_1
Definition enums.h:4441
Gfx * mdl_get_copied_gfx(s32 copyIndex)
Definition model.c:4086
void mdl_get_copied_vertices(s32 copyIndex, Vtx **firstVertex, Vtx **copiedVertices, s32 *numCopied)
Definition model.c:4077
Gfx * gMainGfxPos
Definition cam_main.c:15

◆ unkAngleFunc003()

void N unkAngleFunc003 ( void )

Definition at line 123 of file WhaleAnim.inc.c.

123 {
124 Vtx* firstVertex;
125 Vtx* copiedVertices;
126 s32 numVertices;
127
128 mdl_get_copied_vertices(VTX_COPY_2, &firstVertex, &copiedVertices, &numVertices);
129 N(unkVtxFunc001)(firstVertex, copiedVertices, numVertices, &N(unkAngle3));
130
131 gSPDisplayList(gMainGfxPos++, mdl_get_copied_gfx(VTX_COPY_2));
132 if (N(unkAngle3) >= 0) {
133 N(unkAngle3) += 4;
134 }
135 if (N(unkAngle3) >= 360) {
136 N(unkAngle3) = -1;
137 }
138}
@ VTX_COPY_2
Definition enums.h:4442