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

Go to the source code of this file.

Functions

void update_player_input (void)
 
void reset_player_status (void)
 
void player_input_to_move_vector (f32 *outAngle, f32 *outMagnitude)
 
void game_input_to_move_vector (f32 *outAngle, f32 *outMagnitude)
 
void calculate_camera_yinterp_rate (void)
 

Variables

s32 PeachDisguiseNpcIndex
 
EntityTweesterTouchingPartner
 
EntityTweesterTouchingPlayer
 
s32 PrevPlayerDirection
 
s32 PlayerRunStateTime
 
f32 PlayerNormalYaw
 
f32 PlayerNormalPitch
 
PlayerSpinState gPlayerSpinState
 
BSS s32 PlayerYInterpUpdateDelay
 
f32 DefaultWalkSpeed = 2.0f
 
f32 DefaultRunSpeed = 4.0f
 
f32 DefaultJumpSpeed = 32.0f
 
s32 PeachDisguiseReapplyDelay
 

Function Documentation

◆ update_player_input()

void update_player_input ( void )

Definition at line 22 of file 7B440.c.

22 {
23 PlayerStatus* playerStatus = &gPlayerStatus;
24 s32 inputBufPos = playerStatus->inputBufPos;
25
26 playerStatus->stickAxis[0] = gGameStatusPtr->stickX[0];
27 playerStatus->stickAxis[1] = gGameStatusPtr->stickY[0];
28 playerStatus->curButtons = gGameStatusPtr->curButtons[0];
30 playerStatus->heldButtons = gGameStatusPtr->heldButtons[0];
31
32 inputBufPos++;
33 if (inputBufPos >= 10) {
34 inputBufPos = 0;
35 }
36
37 playerStatus->stickXBuffer[inputBufPos] = playerStatus->stickAxis[0];
38 playerStatus->stickYBuffer[inputBufPos] = playerStatus->stickAxis[1];
39 playerStatus->curButtonsBuffer[inputBufPos] = playerStatus->curButtons;
40 playerStatus->pressedButtonsBuffer[inputBufPos] = playerStatus->pressedButtons;
41 playerStatus->heldButtonsBuffer[inputBufPos] = playerStatus->heldButtons;
42 playerStatus->inputBufPos = inputBufPos;
43
45 playerStatus->stickAxis[0] = 0;
46 playerStatus->stickAxis[1] = 0;
47 playerStatus->curButtons = 0;
48 playerStatus->pressedButtons = 0;
49 playerStatus->heldButtons = 0;
50 }
51
52 if (playerStatus->animFlags & PA_FLAG_FORCE_USE_PARTNER) {
54 playerStatus->pressedButtons |= 4;
55 }
56}
u32 pressedButtons[4]
s32 pressedButtonsBuffer[10]
s32 heldButtonsBuffer[10]
s32 curButtonsBuffer[10]
@ PS_FLAG_NO_STATIC_COLLISION
Definition enums.h:3051
@ PS_FLAG_INPUT_DISABLED
Definition enums.h:3052
@ PA_FLAG_FORCE_USE_PARTNER
triggers partner use when set
Definition enums.h:3094
@ PA_FLAG_PARTNER_USAGE_FORCED
Definition enums.h:3115
GameStatus * gGameStatusPtr
Definition main_loop.c:32
PlayerStatus gPlayerStatus
Definition 77480.c:39

Referenced by update_player().

◆ reset_player_status()

void reset_player_status ( void )

Definition at line 58 of file 7B440.c.

58 {
59 PlayerStatus* playerStatus = &gPlayerStatus;
60 MapSettings* mapSettings;
61
71 D_800F7B44 = 0;
73 PlayerNormalPitch = 0.0f;
74 playerStatus->availableDisguiseType = 1;
75 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
76
77 playerStatus->curAlpha = 255;
78 playerStatus->prevAlpha = 255;
79 gGameStatusPtr->peachFlags &= ~PEACH_FLAG_BLOCK_NEXT_DISGUISE;
80 gGameStatusPtr->peachFlags &= ~PEACH_FLAG_DEPRESSED;
81
83 playerStatus->colliderHeight = 55;
84 playerStatus->colliderDiameter = 38;
86
90 }
91 } else {
92 playerStatus->colliderHeight = 37;
93 playerStatus->colliderDiameter = 26;
95 }
96
97 playerStatus->walkSpeed = DefaultWalkSpeed;
98 playerStatus->runSpeed = DefaultRunSpeed;
99 playerStatus->maxJumpSpeed = DefaultJumpSpeed;
100
102
103 playerStatus->curSpeed = 0.0f;
104 playerStatus->targetYaw = 0.0f;
105 playerStatus->overlapPushAmount = 0.0f;
106 playerStatus->overlapPushYaw = 0.0f;
107 playerStatus->anim = 0;
108 playerStatus->timeInAir = 0;
109 playerStatus->pos.x = 0.0f;
110 playerStatus->pos.y = 0.0f;
111 playerStatus->pos.z = 0.0f;
112 playerStatus->curYaw = 0.0f;
113 playerStatus->flipYaw[CAM_DEFAULT] = 0.0f;
114 playerStatus->flipYaw[CAM_BATTLE] = 0.0f;
115 playerStatus->flipYaw[CAM_TATTLE] = 0.0f;
116 playerStatus->flipYaw[CAM_HUD] = 0.0f;
117
118 ASSERT_MSG(gGameStatusPtr->areaID < ARRAY_COUNT(gAreas) - 1, "Invalid area ID %d", gGameStatusPtr->areaID);
120 ASSERT_MSG(gGameStatusPtr->mapID < area->mapCount, "Invalid map ID %d in %s", gGameStatusPtr->mapID, area->id);
121 mapSettings = area->maps[gGameStatusPtr->mapID].settings;
122
123 if (mapSettings->entryList != NULL) {
124 if (gGameStatusPtr->entryID < mapSettings->entryCount) {
125 playerStatus->pos.x = (*mapSettings->entryList)[gGameStatusPtr->entryID].x;
126 playerStatus->pos.y = (*mapSettings->entryList)[gGameStatusPtr->entryID].y;
127 playerStatus->pos.z = (*mapSettings->entryList)[gGameStatusPtr->entryID].z;
128 playerStatus->curYaw = (*mapSettings->entryList)[gGameStatusPtr->entryID].yaw;
129 }
130 }
131
132 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
133 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
134 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
135
138}
s32 PeachDisguiseReapplyDelay
Definition 7E9D0.c:22
Entity * TweesterTouchingPartner
Definition 7B440.c:5
s32 PrevPlayerDirection
Definition 7B440.c:7
f32 PlayerNormalPitch
Definition 7B440.c:10
PlayerSpinState gPlayerSpinState
Definition 7B440.c:11
f32 DefaultWalkSpeed
Definition 7B440.c:16
f32 PlayerNormalYaw
Definition 7B440.c:9
f32 DefaultJumpSpeed
Definition 7B440.c:18
s32 PlayerRunStateTime
Definition 7B440.c:8
f32 DefaultRunSpeed
Definition 7B440.c:17
s32 PeachDisguiseNpcIndex
Definition 7B440.c:4
s8 availableDisguiseType
set in main map scripts
#define mem_clear
@ PEACH_FLAG_DISGUISED
Definition enums.h:2489
@ PEACH_FLAG_IS_PEACH
Definition enums.h:2488
@ PA_FLAG_USING_PEACH_PHYSICS
Definition enums.h:3103
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ PEACH_BAKING_NONE
Definition enums.h:2496
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ CAM_TATTLE
Definition enums.h:1802
@ CAM_DEFAULT
Definition enums.h:1800
@ CAM_HUD
Definition enums.h:1803
@ CAM_BATTLE
Definition enums.h:1801
void phys_reset_spin_history(void)
Definition 7E9D0.c:95
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define ASSERT_MSG(condition, msg, args...)
Definition macros.h:66
s32 entryCount
Definition map.h:33
char * id
"area_xxx"
Definition map.h:65
s32 mapCount
Definition map.h:63
AreaConfig gAreas[29]
Zero-terminated.
Definition world.c:868
MapSettings * settings
Definition map.h:51
MapConfig * maps
Definition map.h:64
EntryList * entryList
Definition map.h:32
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:26
Vec3f targetPos
s32 D_800F7B44
Definition 7E9D0.c:32
void(* TalkNotificationCallback)(void)
Definition 77480.c:35
Camera gCameras[4]
Definition cam_main.c:17
s32 PrevPlayerCamRelativeYaw
Definition 7E9D0.c:31
void(* PulseStoneNotificationCallback)(void)
Definition 77480.c:34
void(* InteractNotificationCallback)(void)
Definition 77480.c:36

Referenced by player_reset_data().

◆ player_input_to_move_vector()

void player_input_to_move_vector ( f32 * outAngle,
f32 * outMagnitude )

Definition at line 140 of file 7B440.c.

140 {
141 PlayerStatus* playerStatus = &gPlayerStatus;
142 f32 stickAxisX = playerStatus->stickAxis[0];
143 f32 stickAxisY = -playerStatus->stickAxis[1];
144 f32 maxRadius = 70.0f;
145 f32 magnitude;
146 f32 angle;
147
148 magnitude = dist2D(0.0f, 0.0f, stickAxisX, stickAxisY);
149 if (magnitude >= maxRadius) {
150 magnitude = maxRadius;
151 }
152
153 angle = clamp_angle(atan2(0.0f, 0.0f, stickAxisX, stickAxisY) + gCameras[CAM_DEFAULT].curYaw);
154 if (magnitude == 0.0f) {
155 angle = playerStatus->targetYaw;
156 }
157
158 *outAngle = angle;
159 *outMagnitude = magnitude;
160}
#define clamp_angle
#define atan2
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670

Referenced by action_update_idle(), action_update_idle_peach(), action_update_land(), action_update_peach_land(), action_update_peach_step_down_land(), action_update_pushing_block(), action_update_run(), action_update_spin(), action_update_step_down_land(), action_update_walk(), collision_main_above(), collision_main_lateral(), and phys_player_land().

◆ game_input_to_move_vector()

void game_input_to_move_vector ( f32 * outAngle,
f32 * outMagnitude )

Definition at line 162 of file 7B440.c.

162 {
163 f32 stickX = gGameStatusPtr->stickX[0];
164 f32 stickY = -gGameStatusPtr->stickY[0];
165 f32 maxRadius = 70.0f;
166 f32 magnitude;
167 f32 angle;
168
169 magnitude = dist2D(0.0f, 0.0f, stickX, stickY);
170 if (magnitude >= maxRadius) {
171 magnitude = maxRadius;
172 }
173
174 angle = clamp_angle(atan2(0.0f, 0.0f, stickX, stickY) + gCameras[CAM_DEFAULT].curYaw);
175 if (magnitude == 0.0f) {
176 angle = gPlayerStatus.targetYaw;
177 }
178
179 *outAngle = angle;
180 *outMagnitude = magnitude;
181}

Referenced by action_update_use_spinning_flower().

◆ calculate_camera_yinterp_rate()

void calculate_camera_yinterp_rate ( void )

Definition at line 183 of file 7B440.c.

183 {
185 f32 x = shadow->rot.x + 180.0;
186 f32 z = shadow->rot.z + 180.0;
187 Camera* camera = &gCameras[CAM_DEFAULT];
188 f32 rate;
189
190 if (x != 0.0f || z != 0.0f) {
191 switch (gPlayerStatus.actionState) {
194 rate = 32.0f;
195 camera->yinterpRate = rate;
196 break;
198 case ACTION_STATE_RUN:
199 if (camera->targetScreenCoords.y < 130) {
200 camera->yinterpRate = 3.0f;
201 break;
202 }
203 rate = 3.0f;
204 if (PlayerYInterpUpdateDelay++ <= 10) {
205 return;
206 }
208 camera->yinterpRate -= 2.0f;
209 if (camera->yinterpRate < rate) {
210 camera->yinterpRate = rate;
211 }
212 break;
214 rate = 3.0f;
215 camera->yinterpRate = rate;
216 break;
217 default:
218 rate = 3.0f;
220 camera->yinterpRate -= 2.0f;
221 if (camera->yinterpRate < rate) {
222 camera->yinterpRate = rate;
223 }
224 break;
225 }
226 } else {
227 switch (gPlayerStatus.actionState) {
229 case ACTION_STATE_RUN:
232 rate = 7.2f;
233 break;
234 default:
235 rate = 24.0f;
236 break;
237 }
238
239 camera->yinterpRate = rate;
240 }
241}
BSS s32 PlayerYInterpUpdateDelay
Definition 7B440.c:13
@ ACTION_STATE_JUMP
Definition enums.h:2430
@ ACTION_STATE_FALLING
Definition enums.h:2435
@ ACTION_STATE_SLIDING
Definition enums.h:2445
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_RUN
Definition enums.h:2428
Shadow * get_shadow_by_index(s32 index)
Definition entity.c:534
f32 yinterpRate
Vec3s targetScreenCoords

Referenced by phys_peach_update(), and phys_update_action_state().

Variable Documentation

◆ PeachDisguiseNpcIndex

◆ TweesterTouchingPartner

◆ TweesterTouchingPlayer

Entity* TweesterTouchingPlayer

Definition at line 6 of file 7B440.c.

Referenced by action_update_use_tweester(), and entity_Tweester_idle().

◆ PrevPlayerDirection

s32 PrevPlayerDirection

Definition at line 7 of file 7B440.c.

Referenced by action_update_parasol(), player_update_sprite(), and reset_player_status().

◆ PlayerRunStateTime

s32 PlayerRunStateTime

Definition at line 8 of file 7B440.c.

Referenced by action_update_run(), and reset_player_status().

◆ PlayerNormalYaw

f32 PlayerNormalYaw

Definition at line 9 of file 7B440.c.

Referenced by action_update_state_23(), player_raycast_down(), and reset_player_status().

◆ PlayerNormalPitch

f32 PlayerNormalPitch

Definition at line 10 of file 7B440.c.

Referenced by action_update_state_23(), player_raycast_down(), and reset_player_status().

◆ gPlayerSpinState

◆ PlayerYInterpUpdateDelay

BSS s32 PlayerYInterpUpdateDelay

Definition at line 13 of file 7B440.c.

Referenced by calculate_camera_yinterp_rate().

◆ DefaultWalkSpeed

f32 DefaultWalkSpeed = 2.0f

Definition at line 16 of file 7B440.c.

Referenced by reset_player_status().

◆ DefaultRunSpeed

f32 DefaultRunSpeed = 4.0f

Definition at line 17 of file 7B440.c.

Referenced by reset_player_status().

◆ DefaultJumpSpeed

f32 DefaultJumpSpeed = 32.0f

Definition at line 18 of file 7B440.c.

Referenced by reset_player_status().

◆ PeachDisguiseReapplyDelay

s32 PeachDisguiseReapplyDelay
extern

Definition at line 22 of file 7E9D0.c.

Referenced by peach_check_for_parasol_input(), and reset_player_status().