Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
input.c
Go to the documentation of this file.
1#include "common.h"
2#include "nu/nusys.h"
3
4OSContPad D_8009A5B8;
9
22
23void func_80028838(void) {
25 D_8009A6A0 = 0;
26 D_8009A6A2 = 0;
27 D_8009A6A4 = 0;
28 D_8009A6A6 = 0;
29}
30
31void update_input(void) {
32 OSContPad* contData = &D_8009A5B8;
33 s16 handleInput = FALSE;
34 s16 cond1;
35 s32 buttons;
36 s16 stickX;
37 s16 stickY;
38
40 handleInput = TRUE;
41 nuContDataGet(contData, 0);
42 }
43
46 && (contData->button & (BUTTON_A | BUTTON_B | BUTTON_Z | BUTTON_START))
47 && handleInput
48 ) {
50 }
51 contData->button = gGameStatusPtr->demoButtonInput;
52 contData->stick_x = gGameStatusPtr->demoStickX;
53 contData->stick_y = gGameStatusPtr->demoStickY;
54 handleInput = TRUE;
55 }
56
57 if (!handleInput) {
58 return;
59 }
60
61 stickX = contData->stick_x;
62 stickY = contData->stick_y;
63 if (stickX > 0) {
64 stickX -= 4;
65 if (stickX < 0) {
66 stickX = 0;
67 }
68 }
69 if (stickX < 0) {
70 stickX += 4;
71 if (stickX > 0) {
72 stickX = 0;
73 }
74 }
75
76 if (stickY > 0) {
77 stickY -= 4;
78 if (stickY < 0) {
79 stickY = 0;
80 }
81 }
82 if (stickY < 0) {
83 stickY += 4;
84 if (stickY > 0) {
85 stickY = 0;
86 }
87 }
88
89 gGameStatusPtr->stickX[0] = stickX;
90 gGameStatusPtr->stickY[0] = stickY;
91
92 buttons = contData->button;
93 cond1 = FALSE;
94 if (stickX > 0x20) {
95 cond1 = TRUE;
96 buttons |= BUTTON_STICK_RIGHT;
98 D_8009A6A0 = stickX;
99 } else if (D_8009A6A4 == 0) {
100 if (D_8009A6A0 < stickX) {
101 D_8009A6A0 = stickX;
102 }
103 } else {
104 if (D_8009A6A0 > stickX) {
105 D_8009A6A0 = stickX;
106 }
107 }
108 }
109
110 if (stickX < -0x20) {
111 cond1 = TRUE;
112 buttons |= BUTTON_STICK_LEFT;
114 D_8009A6A0 = stickX;
115 } else if (D_8009A6A4 == 0) {
116 if (D_8009A6A0 > stickX) {
117 D_8009A6A0 = stickX;
118 }
119 } else {
120 if (D_8009A6A0 < stickX)
121 {
122 D_8009A6A0 = stickX;
123 }
124 }
125 }
126
127 if (!cond1) {
128 D_8009A6A4 = 0;
129 D_8009A6A0 = stickX;
130 }
131
132 cond1 = FALSE;
133 if (stickY > 0x20) {
134 cond1 = TRUE;
135 buttons |= BUTTON_STICK_UP;
137 D_8009A6A2 = stickY;
138 } else if (D_8009A6A6 == 0) {
139 if (D_8009A6A2 < stickY) {
140 D_8009A6A2 = stickY;
141 }
142 } else {
143 if (D_8009A6A2 > stickY) {
144 D_8009A6A2 = stickY;
145 }
146 }
147 }
148
149 if (stickY < -0x20) {
150 cond1 = TRUE;
151 buttons |= BUTTON_STICK_DOWN;
153 D_8009A6A2 = stickY;
154 } else if (D_8009A6A6 == 0) {
155 if (D_8009A6A2 > stickY) {
156 D_8009A6A2 = stickY;
157 }
158 } else {
159 if (D_8009A6A2 < stickY) {
160 D_8009A6A2 = stickY;
161 }
162 }
163 }
164
165 if (!cond1) {
166 D_8009A6A6 = 0;
167 D_8009A6A2 = stickY;
168 }
169
170 if (stickX > 0x20) {
171 if (D_8009A6A4 == 1 && stickX - D_8009A6A0 > 0x10) {
172 buttons &= ~BUTTON_STICK_RIGHT;
173 D_8009A6A4 = 0;
174 }
175 if (D_8009A6A0 - stickX > 0x10) {
176 D_8009A6A4 = 1;
177 }
178 }
179
180 if (stickX < -0x20) {
181 if (D_8009A6A4 == 1 && D_8009A6A0 - stickX > 0x10) {
182 buttons &= ~BUTTON_STICK_LEFT;
183 D_8009A6A4 = 0;
184 }
185 if (stickX - D_8009A6A0 > 0x10) {
186 D_8009A6A4 = 1;
187 }
188 }
189
190 if (stickY > 0x20) {
191 if (D_8009A6A6 == 1 && stickY - D_8009A6A2 > 0x10) {
192 buttons &= ~BUTTON_STICK_UP;
193 D_8009A6A6 = 0;
194 }
195 if (D_8009A6A2 - stickY > 0x10) {
196 D_8009A6A6 = 1;
197 }
198 }
199
200 if (stickY < -0x20) {
201 if (D_8009A6A6 == 1 && D_8009A6A2 - stickY > 0x10) {
202 buttons &= ~BUTTON_STICK_DOWN;
203 D_8009A6A6 = 0;
204 }
205 if (stickY - D_8009A6A2 > 0x10) {
206 D_8009A6A6 = 1;
207 }
208 }
209
210 gGameStatusPtr->curButtons[0] = buttons;
213
214 if (gGameStatusPtr->curButtons[0] == 0) {
216 } else if (gGameStatusPtr->prevButtons[0] != gGameStatusPtr->curButtons[0]) {
222 } else {
223 if (gGameStatusPtr->unk_60 >= 0) {
225 if (gGameStatusPtr->unk_60 != 0) {
227 } else {
230 }
231 } else {
233 if (gGameStatusPtr->unk_58 != 0) {
235 } else {
238 }
239 }
240 }
241
243}
u32 pressedButtons[4]
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_START
Definition enums.h:2787
@ BUTTON_STICK_UP
Definition enums.h:2791
@ BUTTON_STICK_DOWN
Definition enums.h:2792
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ BUTTON_B
Definition enums.h:2789
@ BUTTON_Z
Definition enums.h:2788
@ DEMO_STATE_CHANGE_MAP
Definition enums.h:3537
@ DEMO_STATE_NONE
Definition enums.h:3535
void func_80028838(void)
Definition input.c:23
BSS s16 D_8009A6A4
Definition input.c:7
void update_input(void)
Definition input.c:31
OSContPad D_8009A5B8
Definition input.c:4
BSS s16 D_8009A6A2
Definition input.c:6
void func_800287F0(void)
Definition input.c:10
BSS s16 D_8009A6A0
Definition input.c:5
BSS s16 D_8009A6A6
Definition input.c:8
#define BSS
Definition macros.h:7
GameStatus * gGameStatusPtr
Definition main_loop.c:32