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

Go to the source code of this file.

Data Structures

struct  InspectIconData
 

Enumerations

enum  { INSPECT_ICON_APPEAR = 0 , INSPECT_ICON_HOLD = 1 , INSPECT_ICON_IDLE = 2 , INSPECT_ICON_VANISH = 3 }
 

Functions

 INCLUDE_IMG ("inspect_icon.png", inspect_icon_img)
 
 INCLUDE_PAL ("inspect_icon.pal", inspect_icon_pal)
 
void interact_inspect_update (void)
 
void interact_inspect_dismiss (void)
 
void interact_inspect_setup (void)
 
void appendGfx_interact_prompt (void)
 
s32 should_continue_inspect (void)
 
void update_inspect_icon_pos (void)
 

Variables

s32 D_8010C950
 
BSS InspectIconData InspectIcon
 
InspectIconDataInspectIconPtr = &InspectIcon
 

Data Structure Documentation

◆ InspectIconData

struct InspectIconData
Data Fields
Vec3f pos
f32 yaw
f32 scale
s32 holdTime
char unk_18[0x4]
s32 alpha
char unk_20[0x1]
s8 iconBounceVel
s8 iconBounceDir
u8 state
u8 brightness
char unk_25[0x3]

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
INSPECT_ICON_APPEAR 
INSPECT_ICON_HOLD 
INSPECT_ICON_IDLE 
INSPECT_ICON_VANISH 

Definition at line 23 of file inspect_icon.c.

23 {
28};
@ INSPECT_ICON_APPEAR
@ INSPECT_ICON_VANISH
@ INSPECT_ICON_HOLD
@ INSPECT_ICON_IDLE

Function Documentation

◆ INCLUDE_IMG()

INCLUDE_IMG ( "inspect_icon.png" ,
inspect_icon_img  )

◆ INCLUDE_PAL()

INCLUDE_PAL ( "inspect_icon.pal" ,
inspect_icon_pal  )

◆ interact_inspect_update()

void interact_inspect_update ( void )

Definition at line 197 of file inspect_icon.c.

197 {
198 PlayerStatus* playerStatus = &gPlayerStatus;
199 s32 brightness = 255;
200 f32 angle;
201 s32 actionState;
202
204
205 switch (InspectIconPtr->state) {
207 InspectIconPtr->yaw = 0.0f;
208 InspectIconPtr->scale += 0.05;
209 if (InspectIconPtr->scale >= 0.55) {
210 InspectIconPtr->scale = 0.55f;
213 }
214 break;
216 InspectIconPtr->yaw = 0.0f;
218 if (InspectIconPtr->holdTime <= 0) {
220 }
221 break;
223 angle = InspectIconPtr->yaw;
224 angle += 10.0f;
225 if (angle >= 360.0f) {
226 angle -= 360.0f;
227 }
228 InspectIconPtr->yaw = angle;
229 brightness = N(GetIconBrightnessForAngle)(angle);
230 break;
232 angle = InspectIconPtr->yaw;
233 angle += 25.0f;
234 if (angle >= 360.0f) {
235 angle -= 360.0f;
236 }
237 InspectIconPtr->yaw = angle;
238 InspectIconPtr->alpha -= 25;
239 if (InspectIconPtr->alpha < 0) {
241 }
242 if ((angle >= 70.0f && angle <= 110.0f) || (angle >= 250.0f && angle <= 290.0f)) {
243 // only dimiss when the icon is rotated away from view
245 }
246 brightness = N(GetIconBrightnessForAngle)(angle);
247 break;
248 }
249 InspectIconPtr->brightness = brightness;
250
251 actionState = playerStatus->actionState;
253 || (playerStatus->inputDisabledCount != 0)
254 || (playerStatus->flags & PS_FLAG_PAUSED)
255 || !(actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || actionState == ACTION_STATE_RUN)
256 ) {
258 }
259
260 if ((playerStatus->interactingWithID >= 0)
263 ) {
265 }
266}
s32 N GetIconBrightnessForAngle(f32 angle)
@ PS_FLAG_PAUSED
Definition enums.h:3040
@ ENTITY_FLAG_SHOWS_INSPECT_PROMPT
Definition enums.h:2625
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_RUN
Definition enums.h:2428
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
s32 should_continue_inspect(void)
InspectIconData * InspectIconPtr
void update_inspect_icon_pos(void)
void interact_inspect_dismiss(void)
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
PlayerStatus gPlayerStatus
Definition 77480.c:39
void(* InteractNotificationCallback)(void)
Definition 77480.c:36

Referenced by interact_inspect_setup().

◆ interact_inspect_dismiss()

void interact_inspect_dismiss ( void )

Definition at line 268 of file inspect_icon.c.

268 {
273 gPlayerStatusPtr->animFlags &= ~PA_FLAG_INTERACT_PROMPT_AVAILABLE;
274 func_800EF3D4(0);
276}
void func_800EF3D4(s32)
Definition partners.c:2414
void partner_reset_tether_distance(void)
Definition partners.c:2405
#define NO_COLLIDER
Definition macros.h:156
PlayerStatus * gPlayerStatusPtr

Referenced by interact_inspect_update().

◆ interact_inspect_setup()

void interact_inspect_setup ( void )

Definition at line 43 of file inspect_icon.c.

43 {
44 PlayerStatus* playerStatus = &gPlayerStatus;
45 f32 new_var;
46
47 if (playerStatus->animFlags & PA_FLAG_INTERACT_PROMPT_AVAILABLE) {
49 D_8010C950 = -1;
50 InspectIconPtr->pos.x = playerStatus->pos.x;
51 InspectIconPtr->pos.y = playerStatus->pos.y + playerStatus->colliderHeight +
52 (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) ? 8.0f : 2.0f);
53 InspectIconPtr->pos.z = playerStatus->pos.z;
54 InspectIconPtr->scale = 0.4f;
59 InspectIconPtr->alpha = 255;
60 }
61}
#define mem_clear
@ PA_FLAG_USING_PEACH_PHYSICS
Definition enums.h:3103
@ PA_FLAG_INTERACT_PROMPT_AVAILABLE
! prompt
Definition enums.h:3095
void interact_inspect_update(void)
s32 D_8010C950
Definition 77480.c:37
Camera gCameras[4]
Definition cam_main.c:17
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by check_for_interactables().

◆ appendGfx_interact_prompt()

void appendGfx_interact_prompt ( void )

Definition at line 63 of file inspect_icon.c.

63 {
64 ImgFXTexture ifxImg;
65 Matrix4f sp38, sp78;
66
69 guRotateF(sp78, InspectIconPtr->yaw - gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
70 guMtxCatF(sp38, sp78, sp38);
72 guMtxCatF(sp38, sp78, sp78);
74
76 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
77 gSPDisplayList(gMainGfxPos++, &inspect_icon_gfx);
78
79 ifxImg.raster = inspect_icon_img;
80 ifxImg.palette = inspect_icon_pal;
81 ifxImg.width = inspect_icon_img_width;
82 ifxImg.height = inspect_icon_img_height;
83 ifxImg.xOffset = -16;
84 ifxImg.yOffset = 26;
85 ifxImg.alpha = 255;
90 imgfx_appendGfx_component(0, &ifxImg, 0, sp78);
91
92 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
93 }
94}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
@ IMGFX_SET_COLOR
Definition enums.h:5123
@ IMGFX_CLEAR
Definition enums.h:5117
@ IMGFX_FLAG_40
Definition enums.h:5099
@ IMGFX_FLAG_400
Definition enums.h:5103
@ IMGFX_FLAG_8
Definition enums.h:5096
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:704
void imgfx_update(u32, ImgFXType, s32, s32, s32, s32, s32)
Definition imgfx.c:487
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by render_interact_prompt().

◆ should_continue_inspect()

s32 should_continue_inspect ( void )

Definition at line 97 of file inspect_icon.c.

97 {
98 CollisionStatus* collisionStatus = &gCollisionStatus;
99 PlayerStatus* playerStatus = &gPlayerStatus;
100 s32 curInteraction = collisionStatus->curWall;
101 Npc* npc = playerStatus->encounteredNPC;
102
103 if (curInteraction == NO_COLLIDER) {
104 s32 floor = gCollisionStatus.curFloor;
105
106 if (floor >= 0 && (floor & COLLISION_WITH_ENTITY_BIT)) {
107 curInteraction = floor;
108 switch (get_entity_type(floor)) {
116 curInteraction = NO_COLLIDER;
117 break;
118 }
119 } else if (!(playerStatus->flags & PS_FLAG_INPUT_DISABLED)
120 && (playerStatus->flags & PS_FLAG_HAS_CONVERSATION_NPC)
121 && (npc != NULL)
123 ) {
124 curInteraction = npc->npcID | COLLISION_WITH_NPC_BIT;
125 if (playerStatus->interactingWithID == curInteraction) {
126 return TRUE;
127 }
128 } else {
129 playerStatus->interactingWithID = NO_COLLIDER;
130 playerStatus->flags &= ~PS_FLAG_INTERACTED;
131 return FALSE;
132 }
133 } else {
134 if (!(curInteraction & COLLISION_WITH_ENTITY_BIT)) {
135 if (!(curInteraction & COLLISION_WITH_NPC_BIT)) {
136 if (!should_collider_allow_interact(curInteraction)) {
137 playerStatus->interactingWithID = NO_COLLIDER;
138 playerStatus->flags &= ~PS_FLAG_INTERACTED;
139 return FALSE;
140 }
141 }
142 } else {
144 playerStatus->interactingWithID = NO_COLLIDER;
145 playerStatus->flags &= ~PS_FLAG_INTERACTED;
146 return FALSE;
147 }
148 }
149 }
150 if (playerStatus->interactingWithID == curInteraction) {
151 if ((playerStatus->flags & PS_FLAG_INTERACTED)) {
152 return FALSE;
153 }
154 } else {
155 playerStatus->flags &= ~PS_FLAG_INTERACTED;
156 }
157
158 playerStatus->interactingWithID = curInteraction;
159 return TRUE;
160}
@ PS_FLAG_INTERACTED
Definition enums.h:3077
@ PS_FLAG_INPUT_DISABLED
Definition enums.h:3052
@ PS_FLAG_HAS_CONVERSATION_NPC
Definition enums.h:3074
@ ENTITY_TYPE_PUSH_BLOCK
Definition enums.h:2555
@ ENTITY_TYPE_PADLOCK
Definition enums.h:2546
@ ENTITY_TYPE_SIGNPOST
Definition enums.h:2588
@ ENTITY_TYPE_CHEST
Definition enums.h:2587
@ ENTITY_TYPE_PADLOCK_RED_FACE
Definition enums.h:2548
@ ENTITY_TYPE_PADLOCK_RED_FRAME
Definition enums.h:2547
@ ENTITY_TYPE_PADLOCK_BLUE_FACE
Definition enums.h:2549
@ NPC_FLAG_USE_INSPECT_ICON
Definition enums.h:3026
s32 phys_can_player_interact(void)
Definition 7BB60.c:1159
u32 get_entity_type(s32 arg0)
Definition entity.c:568
s32 should_collider_allow_interact(s32)
Definition trigger.c:281
#define COLLISION_WITH_NPC_BIT
Definition macros.h:151
s32 flags
CollisionStatus gCollisionStatus
Definition 7BB60.c:6

Referenced by interact_inspect_update().

◆ update_inspect_icon_pos()

void update_inspect_icon_pos ( void )

Definition at line 162 of file inspect_icon.c.

162 {
163 PlayerStatus* playerStatus = &gPlayerStatus;
164 f32 bounceDeltaY;
165 f32 playerHeadY;
166 f32 lastPosY;
167 f32 delta;
168
169 // this bouncing behavior is never seen because dir is never changed from zero
171
172 if (InspectIconPtr->iconBounceVel > 4) {
175 }
176 if (InspectIconPtr->iconBounceVel < -4) {
179 }
180
181 delta = (playerStatus->pos.x - InspectIconPtr->pos.x) * 0.666f;
182 InspectIconPtr->pos.x += delta;
183 delta = (playerStatus->pos.z - InspectIconPtr->pos.z) * 0.666f;
184 InspectIconPtr->pos.z += delta;
185
186 playerHeadY = playerStatus->pos.y + playerStatus->colliderHeight;
187 bounceDeltaY = InspectIconPtr->iconBounceVel;
188 lastPosY = InspectIconPtr->pos.y;
189 if (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS)) {
190 delta = (playerHeadY + 8.0f + bounceDeltaY - lastPosY) * 0.25f;
191 } else {
192 delta = (playerHeadY + 2.0f + bounceDeltaY - lastPosY) * 0.25f;
193 }
194 InspectIconPtr->pos.y += delta;
195}

Referenced by interact_inspect_dismiss(), and interact_inspect_update().

Variable Documentation

◆ D_8010C950

s32 D_8010C950
extern

Definition at line 37 of file 77480.c.

Referenced by func_800E06C0(), and interact_inspect_setup().

◆ InspectIcon

BSS InspectIconData InspectIcon

Definition at line 35 of file inspect_icon.c.

◆ InspectIconPtr