Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
inspect_icon.c
Go to the documentation of this file.
1#include "common.h"
2#include "include_asset.h"
3
4extern s32 D_8010C950; //TODO never read, consider removing
5
6#define NAMESPACE inspect_icon
7
8typedef struct InspectIconData {
9 /* 0x00 */ Vec3f pos;
10 /* 0x0C */ f32 yaw;
11 /* 0x10 */ f32 scale;
12 /* 0x14 */ s32 holdTime;
13 /* 0x18 */ char unk_18[0x4];
14 /* 0x1C */ s32 alpha; // unused
15 /* 0x20 */ char unk_20[0x1];
16 /* 0x21 */ s8 iconBounceVel;
17 /* 0x22 */ s8 iconBounceDir;
18 /* 0x23 */ u8 state;
19 /* 0x24 */ u8 brightness;
20 /* 0x25 */ char unk_25[0x3];
21} InspectIconData; // size = 0x28
22
23enum {
28};
29
30#include "inspect_icon.png.h"
31INCLUDE_IMG("inspect_icon.png", inspect_icon_img);
32INCLUDE_PAL("inspect_icon.pal", inspect_icon_pal);
33#include "inspect_icon.gfx.inc.c"
34
37
39
42
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}
62
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}
95
96// similar to check_for_interactables
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}
161
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}
196
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}
267
s32 N GetIconBrightnessForAngle(f32 angle)
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define mem_clear
#define guScaleF
@ IMGFX_SET_COLOR
Definition enums.h:5123
@ IMGFX_CLEAR
Definition enums.h:5117
@ PS_FLAG_PAUSED
Definition enums.h:3040
@ 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
@ PA_FLAG_USING_PEACH_PHYSICS
Definition enums.h:3103
@ PA_FLAG_INTERACT_PROMPT_AVAILABLE
! prompt
Definition enums.h:3095
@ 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
@ IMGFX_FLAG_40
Definition enums.h:5099
@ IMGFX_FLAG_400
Definition enums.h:5103
@ IMGFX_FLAG_8
Definition enums.h:5096
@ NPC_FLAG_USE_INSPECT_ICON
Definition enums.h:3026
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
s32 phys_can_player_interact(void)
Definition 7BB60.c:1159
void func_800EF3D4(s32)
Definition partners.c:2414
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:704
u32 get_entity_type(s32 arg0)
Definition entity.c:568
s32 should_collider_allow_interact(s32)
Definition trigger.c:281
void imgfx_update(u32, ImgFXType, s32, s32, s32, s32, s32)
Definition imgfx.c:487
void partner_reset_tether_distance(void)
Definition partners.c:2405
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
s32 should_continue_inspect(void)
BSS InspectIconData InspectIcon
char unk_20[0x1]
void interact_inspect_update(void)
void interact_inspect_setup(void)
InspectIconData * InspectIconPtr
void update_inspect_icon_pos(void)
s32 D_8010C950
Definition 77480.c:37
char unk_18[0x4]
char unk_25[0x3]
void appendGfx_interact_prompt(void)
void interact_inspect_dismiss(void)
@ INSPECT_ICON_APPEAR
@ INSPECT_ICON_VANISH
@ INSPECT_ICON_HOLD
@ INSPECT_ICON_IDLE
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:152
#define BSS
Definition macros.h:7
#define NO_COLLIDER
Definition macros.h:156
#define COLLISION_WITH_NPC_BIT
Definition macros.h:151
s32 flags
PlayerStatus * gPlayerStatusPtr
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
void(* InteractNotificationCallback)(void)
Definition 77480.c:36
DisplayContext * gDisplayContext
Definition cam_main.c:16