Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
pulse_stone.c
Go to the documentation of this file.
1#include "common.h"
2#include "include_asset.h"
3
4typedef struct PulseStoneData {
5 /* 0x00 */ Vec3f pos;
6 /* 0x0C */ f32 scale;
7 /* 0x10 */ char unk_10[0x8];
8 /* 0x18 */ s32 appearDelay;
9 /* 0x1C */ char unk_1C[0x4];
10 /* 0x20 */ s32 pingTime;
11 /* 0x24 */ s32 state;
12} PulseStoneData; // size = 0x28
13
14enum {
15 PULSE_STONE_APPEAR = 0, // icon appears
16 PULSE_STONE_OVERSHOOT = 1, // icon scale overshoots
17 PULSE_STONE_HOLD = 2, // icon reaches final size
18};
19
20#include "pulse_stone_icon.png.h"
21INCLUDE_IMG("pulse_stone_icon.png", pulse_stone_icon_img);
22INCLUDE_PAL("pulse_stone_icon.pal", pulse_stone_icon_1_pal);
23INCLUDE_PAL("pulse_stone_icon.flash.pal", pulse_stone_icon_2_pal);
24#include "pulse_stone_icon.gfx.inc.c"
25
28
30
32 PlayerStatus* playerStatus = &gPlayerStatus;
33 PartnerStatus* partnerStatus = &gPartnerStatus;
34 s8 actionState = playerStatus->actionState;
35
36 if (actionState == ACTION_STATE_USE_TWEESTER) {
37 return TRUE;
38 }
39
40 if (partnerStatus->partnerActionState == PARTNER_ACTION_USE
41 && (partnerStatus->actingPartner == PARTNER_BOW || partnerStatus->actingPartner == PARTNER_PARAKARRY)
42 ) {
43 return TRUE;
44 }
45
46 return FALSE;
47}
48
50 PlayerStatus* playerStatus = &gPlayerStatus;
51
53 && !(playerStatus->flags & PS_FLAG_PAUSED)
54 && playerStatus->animFlags & PA_FLAG_USING_PULSE_STONE
56 && !func_800E06D8()
57 ) {
58 // hardcoded map IDs assuming first 49 maps (in sbk) are a 7x7 grid
59 s32 dx = abs((gGameStatusPtr->mapID % 7) - 2);
60 s32 dy = gGameStatusPtr->mapID / 7;
61
62 if ((dx + dy) < 6) {
64 return TRUE;
65 }
66 }
67 }
68 return FALSE;
69}
70
72 PlayerStatus* playerStatus = &gPlayerStatus;
73
75 PulseStonePtr->pos.x = playerStatus->pos.x;
76 PulseStonePtr->pos.y = playerStatus->pos.y + playerStatus->colliderHeight + 8.0f;
77 PulseStonePtr->pos.z = playerStatus->pos.z;
80}
81
83 PlayerStatus* playerStatus = &gPlayerStatus;
84 Matrix4f sp18, sp58;
85 ImgFXTexture ifxImg;
86 s32 pingDelay;
87 s32 dx, dy;
88
89 if (playerStatus->animFlags & PA_FLAG_PULSE_STONE_VISIBLE) {
91 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
92 guMtxCatF(sp18, sp58, sp18);
94 guMtxCatF(sp18, sp58, sp58);
96
98 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
99 gSPDisplayList(gMainGfxPos++, pulse_stone_icon_gfx);
100
101 dx = abs((gGameStatusPtr->mapID % 7) - 2);
102 dy = gGameStatusPtr->mapID / 7;
103
104 switch (dx + dy) {
105 case 0:
106 pingDelay = 4;
107 break;
108 case 1:
109 pingDelay = 8;
110 break;
111 case 2:
112 pingDelay = 16;
113 break;
114 case 3:
115 pingDelay = 32;
116 break;
117 case 4:
118 pingDelay = 64;
119 break;
120 case 5:
121 pingDelay = 128;
122 break;
123 default:
124 pingDelay = -1;
126 break;
127 }
128
129 ifxImg.palette = pulse_stone_icon_1_pal;
130 if (pingDelay >= 0) {
132 if (PulseStonePtr->pingTime >= pingDelay + 2) {
135 }
136 if (PulseStonePtr->pingTime < 2) {
137 ifxImg.palette = pulse_stone_icon_2_pal;
138 } else {
139 ifxImg.palette = pulse_stone_icon_1_pal;
140 }
141 }
142
143 ifxImg.raster = pulse_stone_icon_img;
144 ifxImg.width = pulse_stone_icon_img_width;
145 ifxImg.height = pulse_stone_icon_img_height;
146 ifxImg.xOffset = -28;
147 ifxImg.yOffset = 46;
148 ifxImg.alpha = 255;
149 imgfx_appendGfx_component(0, &ifxImg, 0, sp58);
150 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
151 }
152}
153
155 PlayerStatus* playerStatus = &gPlayerStatus;
156
158 ((playerStatus->pos.y + playerStatus->colliderHeight + 10.0f) - PulseStonePtr->pos.y) / 1.5f;
159 PulseStonePtr->pos.x = playerStatus->pos.x;
160 PulseStonePtr->pos.z = playerStatus->pos.z;
161
164 playerStatus->animFlags &= ~PA_FLAG_PULSE_STONE_VISIBLE;
165 return;
166 }
167
168 switch (PulseStonePtr->state) {
170 if (PulseStonePtr->appearDelay++ < 6) {
171 break;
172 }
173 PulseStonePtr->scale = 0.36f;
175 break;
177 PulseStonePtr->scale = 0.57f;
179 break;
180 case PULSE_STONE_HOLD:
181 PulseStonePtr->scale = 0.53f;
183 break;
184 }
185}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define mem_clear
#define guScaleF
@ PS_FLAG_PAUSED
Definition enums.h:3040
@ PARTNER_ACTION_USE
Definition enums.h:2933
@ PA_FLAG_PULSE_STONE_VISIBLE
The pulse stone icon is being shown.
Definition enums.h:3097
@ PA_FLAG_USING_PULSE_STONE
Definition enums.h:3098
@ SOUND_PULSE_STONE
Definition enums.h:646
@ PARTNER_BOW
Definition enums.h:2894
@ PARTNER_PARAKARRY
Definition enums.h:2889
@ ACTION_STATE_USE_TWEESTER
Definition enums.h:2459
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
s32 has_valid_conversation_npc(void)
Definition 77480.c:1111
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:704
s32 is_starting_conversation(void)
Definition encounter.c:2818
s32 func_800E06D8(void)
Definition 77480.c:1164
#define INCLUDE_PAL(FILENAME, SYMBOLNAME)
#define INCLUDE_IMG(FILENAME, SYMBOLNAME)
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521
@ PULSE_STONE_HOLD
Definition pulse_stone.c:17
@ PULSE_STONE_OVERSHOOT
Definition pulse_stone.c:16
@ PULSE_STONE_APPEAR
Definition pulse_stone.c:15
void pulse_stone_notification_update(void)
s32 should_continue_pulse_stone(void)
Definition pulse_stone.c:49
void appendGfx_pulse_stone_icon(void)
Definition pulse_stone.c:82
char unk_1C[0x4]
Definition pulse_stone.c:9
void pulse_stone_notification_setup(void)
Definition pulse_stone.c:71
s32 should_cancel_pulse_stone(void)
Definition pulse_stone.c:31
char unk_10[0x8]
Definition pulse_stone.c:7
BSS PulseStoneData PulseStoneNotification
Definition pulse_stone.c:26
PulseStoneData * PulseStonePtr
Definition pulse_stone.c:27
#define BSS
Definition macros.h:7
PartnerStatus gPartnerStatus
Definition partners.c:42
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
void(* PulseStoneNotificationCallback)(void)
Definition 77480.c:34
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16