Skip to content

Commit 054ffae

Browse files
authored
Merge pull request #139 from Kelebek1/fragment3
Fragment3
2 parents b8181f5 + e85f570 commit 054ffae

37 files changed

+2481
-272
lines changed

include/global.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ typedef struct unk_D_86002F58_004_000 {
145145
/* 0x0F8 */ char pad0F8[0x70];
146146
} unk_D_86002F58_004_000; // size = 0x168
147147

148+
typedef struct unk_D_86002F34_000_014_004 {
149+
/* 0x00 */ u8 unk_00[5];
150+
} unk_D_86002F34_000_014_004; // size = 0x5
151+
152+
typedef struct unk_D_86002F34_000_014_010 {
153+
/* 0x00 */ u8 unk_00[4];
154+
} unk_D_86002F34_000_014_010; // size = 0x4
155+
156+
typedef struct unk_D_86002F34_000_014 {
157+
/* 0x00 */ u8* unk_00;
158+
/* 0x04 */ u8* unk_04;
159+
} unk_D_86002F34_000_014; // size >= 0x8
160+
148161
typedef struct unk_D_86002F34_000 {
149162
/* 0x00 */ u8 unk_00;
150163
/* 0x01 */ u8 unk_01;
@@ -155,7 +168,7 @@ typedef struct unk_D_86002F34_000 {
155168
/* 0x08 */ struct unk_D_86002F34_000* unk_08;
156169
/* 0x0C */ struct unk_D_86002F34_000* unk_0C;
157170
/* 0x10 */ s32 (*unk_10)(s32, struct unk_D_86002F34_000*);
158-
/* 0x14 */ char unk14[0x4];
171+
/* 0x14 */ unk_D_86002F34_000_014* unk_14;
159172
} unk_D_86002F34_000; // size >= 0x18
160173

161174
typedef struct unk_D_86002F34_00C_018 {

include/macros.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
#define ROUND_MAX(x) (((x) > 0.0f ? 0.5f : -0.5f) + (x))
5050

51-
#define ABS(x) ((x) >= 0 ? (x) : -(x))
52-
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
51+
#define ABS(x) ((x) < 0 ? -(x) : (x))
52+
#define ABS_ALT(x) ((x) >= 0 ? (x) : -(x))
5353

5454
#define FRAGMENT_ID(fragment) ((((u32)fragment##_TEXT_START & 0x0FF00000) >> 0x14) - 0x10)
5555
#define ASSET_ID(asset) (((u32)asset & 0x0F000000) >> 0x18)

include/variables.h

-13
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,6 @@ extern u32 D_B0000D10;
8181

8282
extern u8 D_800818E0[0x20];
8383

84-
typedef struct unk_D_80068BA0 {
85-
/* 0x00 */ char pad00[0x2];
86-
/* 0x02 */ s16 unk_02;
87-
/* 0x04 */ s16 unk_04;
88-
/* 0x06 */ u16 unk_06;
89-
/* 0x08 */ u16 unk_08;
90-
/* 0x0A */ char pad0A[0x2];
91-
} unk_D_80068BA0; // size >= 0xC
92-
93-
extern unk_D_80068BA0* D_80068BA0;
94-
extern unk_D_80068BA0* D_80068BA4;
95-
extern unk_D_80068BA0* D_80068BA8;
96-
extern unk_D_80068BA0* D_80068BAC;
9784
extern Gfx D_8006F518[];
9885
extern Gfx D_8006F630[];
9986
extern u8 D_82000000;

linker_scripts/us/symbol_addrs.txt

+12-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ D_87906048 = 0x87906048;
7777
D_87906060 = 0x87906060;
7878
D_87906064 = 0x87906064;
7979
D_87906068 = 0x87906068;
80-
D_8790606C = 0x8790606C;
8180
D_87906070 = 0x87906070;
8281
D_87906094 = 0x87906094;
8382
D_87906098 = 0x87906098;
@@ -296,3 +295,15 @@ D_8006F050 = 0x8006F050; // size:0xC
296295
D_8006F05C = 0x8006F05C; // size:0x6
297296
D_8006F064 = 0x8006F064; // size:0xC
298297
D_800ABE10 = 0x800ABE10; // size:0xA18
298+
gPlayer1Controller = 0x80068BA0;
299+
gPlayer2Controller = 0x80068BA4;
300+
gPlayer3Controller = 0x80068BA8;
301+
gPlayer4Controller = 0x80068BAC;
302+
D_8790606C = 0x8790606C; // size:0x6
303+
D_87906088 = 0x87906088; // size:0xC
304+
D_8790609C = 0x8790609C; // size:0x6
305+
D_879060AC = 0x879060AC; // size:0x6
306+
pad_D_879060B4 = 0x879060B4; // size:0x8
307+
D_879060E0 = 0x879060E0; // size:0xC
308+
D_87906100 = 0x87906100; // size:0xC
309+
D_87906110 = 0x87906110; // size:0xC

src/11BA0.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,10 @@ typedef struct unk_func_80011B94 {
99
/* 0x18 */ Gfx* unk_18;
1010
} unk_func_80011B94; // size = 0x1C
1111

12-
typedef struct unk_D_86404778_190 {
13-
/* 0x00 */ unk_D_86002F58_004_000_000 unk_00;
14-
/* 0x18 */ Gfx* unk_18;
15-
/* 0x1C */ Vec3f unk_1C;
16-
/* 0x28 */ f32 unk_28;
17-
} unk_D_86404778_190; // size = 0x2C
18-
1912
unk_D_86002F58_004_000_000* func_8001103C(MainPoolState*, void*);
2013
unk_D_86002F58_004_000* func_80011938(MainPoolState* arg0, unk_D_86002F58_004_000* arg1, s16 arg2, Vec3f* arg3, Vec3s* arg4, Vec3f* arg5);
2114
unk_func_80011B94* func_80011B94(MainPoolState*, unk_func_80011B94*, s32, Gfx*);
22-
unk_D_86404778_190* func_80011B10(MainPoolState*, s32, s32, s32, Vec3f*, f32);
15+
unk_D_86002F34_alt9* func_80011B10(MainPoolState*, s32, s32, s32, Vec3f*, f32);
2316
void func_80012094(unk_D_86002F58_004_000_000*, unk_D_86002F58_004_000_000*);
2417

2518

src/12D80.c

+18-18
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ unk_D_86002F34_00C* D_8006F094 = NULL;
2929
unk_D_86002F34_alt1* D_8006F098 = NULL;
3030
unk_D_86002F58_004_000* D_8006F09C = NULL;
3131
unk_D_86002F34_alt11* D_8006F0A0 = NULL;
32-
func_D_8006F0A4 D_8006F0A4[] = {
32+
static func_D_8006F0A4 D_8006F0A4[] = {
3333
func_80013330, func_800133D8, func_80013464, func_80013764, func_8001378C, func_8001395C, func_800139E8,
3434
func_80013AF8, func_80013B8C, func_80013C14, func_80013C1C, func_80013D34, func_80013F7C, func_80013F84,
3535
func_80014124, func_80014D70, func_80014214, func_800142BC, func_80014334, func_80014384, func_800143C0,
3636
func_80014624, func_80014690, func_800148D8, func_80014980, func_80014A60, func_80014AEC, func_80014D24,
3737
func_80014D50, NULL, NULL,
3838
};
3939

40-
s32 D_8006F120 = 0;
40+
static s32 D_8006F120 = 0;
4141

42-
u32 D_8006F124[4][9] = {
42+
static u32 D_8006F124[4][9] = {
4343
{
4444
0x3024000,
4545
0x3024000,
@@ -86,7 +86,7 @@ u32 D_8006F124[4][9] = {
8686
},
8787
};
8888

89-
u8 D_8006F1B4[15][16] = {
89+
static u8 D_8006F1B4[15][16] = {
9090
{ 0x1F, 0x1F, 0x1F, 3, 7, 7, 7, 3, 0, 0x1F, 4, 0x1F, 0, 7, 6, 7 },
9191
{ 1, 0x1F, 3, 0x1F, 7, 7, 7, 1, 0, 0x1F, 4, 0x1F, 0, 7, 6, 7 },
9292
{ 1, 3, 8, 3, 7, 7, 3, 7, 0, 0x1F, 4, 0x1F, 0, 7, 6, 7 },
@@ -104,20 +104,20 @@ u8 D_8006F1B4[15][16] = {
104104
{ 1, 0x1F, 4, 0x1F, 1, 7, 4, 7, 0x1F, 0x1F, 0x1F, 0, 0, 7, 6, 7 },
105105
};
106106

107-
s16 D_8006F2A4[] = { 16, 8, 4, 2, 0, 0 };
108-
109-
s32 D_800AA6C0;
110-
MtxF* D_800AA6C8[8];
111-
u8 pad_D_800AA6E8[0x1E0];
112-
unk_D_800AA8C8 D_800AA8C8;
113-
unk_D_800AB970 D_800AB970;
114-
s32 D_800ABB00;
115-
s32 D_800ABB04;
116-
s32 D_800ABB08;
117-
unk_D_800ABB10 D_800ABB10;
118-
unk_D_800ABB28 D_800ABB28[10];
119-
unk_D_800ABB28* D_800ABCB8;
120-
s32 D_800ABCBC;
107+
static s16 D_8006F2A4[] = { 16, 8, 4, 2, 0, 0 };
108+
109+
static s32 D_800AA6C0;
110+
static MtxF* D_800AA6C8[8];
111+
static u8 pad_D_800AA6E8[0x1E0];
112+
static unk_D_800AA8C8 D_800AA8C8;
113+
static unk_D_800AB970 D_800AB970;
114+
static s32 D_800ABB00;
115+
static s32 D_800ABB04;
116+
static s32 D_800ABB08;
117+
static unk_D_800ABB10 D_800ABB10;
118+
static unk_D_800ABB28 D_800ABB28[10];
119+
static unk_D_800ABB28* D_800ABCB8;
120+
static s32 D_800ABCBC;
121121

122122
void func_80012180(void) {
123123
D_800AA8C8.unk_10A0 = 0;

src/12D80.h

+10
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ typedef struct unk_D_800ABB10 {
4444
/* 0x14 */ Gfx* unk_14;
4545
} unk_D_800ABB10; // size = 0x18?
4646

47+
extern s32 D_8006F080;
48+
extern u16 D_8006F084;
49+
extern unk_D_86002F34_00C* D_8006F088;
50+
extern unk_D_86002F34_alt1* D_8006F08C;
51+
extern unk_D_86002F34_alt1* D_8006F090;
52+
extern unk_D_86002F34_00C* D_8006F094;
53+
extern unk_D_86002F34_alt1* D_8006F098;
54+
extern unk_D_86002F58_004_000* D_8006F09C;
55+
extern unk_D_86002F34_alt11* D_8006F0A0;
56+
4757
void func_80012180(void);
4858
void func_800121C8(void);
4959
void func_80012230(MtxF* arg0);

src/17300.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void func_800173CC(unk_D_86002F58_004_000* arg0) {
330330
arg0->unk_040.unk_04 = NULL;
331331
}
332332

333-
s32 func_800173DC(unk_D_86002F58_004_000* arg0, s16 arg1, s32 arg2, s32 arg3) {
333+
s32 func_800173DC(unk_D_86002F58_004_000* arg0, s16 arg1, void* arg2, s32 arg3) {
334334
unk_D_86002F58_004_000_040_004* temp_v0 = Util_ConvertAddrToVirtAddr(arg2);
335335
unk_D_86002F58_004_000_040* ptr = &arg0->unk_040;
336336

@@ -375,8 +375,8 @@ s32 func_80017484(unk_D_86002F58_004_000* arg0, s16 arg1) {
375375
return var_a2;
376376
}
377377

378-
void func_800174E4(unk_D_86002F58_004_000* arg0) {
379-
func_80017484(arg0, arg0->unk_040.unk_04->unk_0A - 1);
378+
s32 func_800174E4(unk_D_86002F58_004_000* arg0) {
379+
return func_80017484(arg0, arg0->unk_040.unk_04->unk_0A - 1);
380380
}
381381

382382
s32 func_80017514(unk_D_86002F58_004_000* arg0) {

src/17300.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ void func_80017090(unk_D_86002F58_004_000_040* arg0, u16 arg1, s32 arg2);
3636
void func_80017188(void);
3737
void func_800171A8(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, s32 arg3);
3838
void func_800173CC(unk_D_86002F58_004_000* arg0);
39-
s32 func_800173DC(unk_D_86002F58_004_000* arg0, s16 arg1, s32 arg2, s32 arg3);
39+
s32 func_800173DC(unk_D_86002F58_004_000* arg0, s16 arg1, void* arg2, s32 arg3);
4040
s32 func_80017454(unk_D_86002F58_004_000* arg0, s32 arg1);
4141
void func_80017464(unk_D_86002F58_004_000* arg0, s16 arg1);
4242
s32 func_80017484(unk_D_86002F58_004_000* arg0, s16 arg1);
43-
void func_800174E4(unk_D_86002F58_004_000* arg0);
43+
s32 func_800174E4(unk_D_86002F58_004_000* arg0);
4444
s32 func_80017514(unk_D_86002F58_004_000* arg0);
4545

4646

src/20330.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33

44
static s32 pad_D_800AC880[0x2];
55
static s32 D_800AC888;
6-
static unk_D_80068BA0* D_800AC88C;
6+
static Controller* D_800AC88C;
77

88
void func_8001F730(void) {
99
}
1010

11-
void func_8001F738(unk_D_80068BA0* arg0) {
11+
void func_8001F738(Controller* arg0) {
1212
D_800AC888 = 0xA;
1313
D_800AC88C = arg0;
1414
}
1515

1616
s32 func_8001F750(void) {
17-
if (D_800AC88C->unk_08 & 0x800) {
17+
if (D_800AC88C->buttonPressed & 0x800) {
1818
D_800AC888 = 0xA;
1919
return 0x800;
2020
}
2121

22-
if (D_800AC88C->unk_08 & 0x400) {
22+
if (D_800AC88C->buttonPressed & 0x400) {
2323
D_800AC888 = 0xA;
2424
return 0x400;
2525
}
2626

27-
if (D_800AC88C->unk_08 & 0x200) {
27+
if (D_800AC88C->buttonPressed & 0x200) {
2828
D_800AC888 = 0xA;
2929
return 0x200;
3030
}
3131

32-
if (D_800AC88C->unk_08 & 0x100) {
32+
if (D_800AC88C->buttonPressed & 0x100) {
3333
D_800AC888 = 0xA;
3434
return 0x100;
3535
}
@@ -39,22 +39,22 @@ s32 func_8001F750(void) {
3939
D_800AC888 = 0;
4040

4141
// clang-format off
42-
if (D_800AC88C->unk_06 & 0x800) {
42+
if (D_800AC88C->buttonDown & 0x800) {
4343
D_800AC888 = 2; return 0x800;
4444
}
4545
// clang-format on
4646

47-
if (D_800AC88C->unk_06 & 0x400) {
47+
if (D_800AC88C->buttonDown & 0x400) {
4848
D_800AC888 = 2;
4949
return 0x400;
5050
}
5151

52-
if (D_800AC88C->unk_06 & 0x200) {
52+
if (D_800AC88C->buttonDown & 0x200) {
5353
D_800AC888 = 2;
5454
return 0x200;
5555
}
5656

57-
if (D_800AC88C->unk_06 & 0x100) {
57+
if (D_800AC88C->buttonDown & 0x100) {
5858
D_800AC888 = 2;
5959
return 0x100;
6060
}

src/20330.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#define _20330_H_
33

44
#include "global.h"
5+
#include "src/controller.h"
56

67
void func_8001F730(void);
7-
void func_8001F738(unk_D_80068BA0*);
8+
void func_8001F738(Controller*);
89
s32 func_8001F750(void);
910

1011

src/29BA0.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "global.h"
55
#include "3FB0.h"
6+
#include "src/controller.h"
67

78
typedef struct unk_D_800AE520 {
89
/* 0x00 */ s16 unk_00;
@@ -64,7 +65,7 @@ typedef struct unk_D_800AE540_0004 {
6465
/* 0x000 */ u8 unk_000;
6566
/* 0x001 */ u8 unk_001;
6667
/* 0x002 */ u8 unk_002;
67-
/* 0x004 */ struct Controller* controller;
68+
/* 0x004 */ Controller* controller;
6869
/* 0x008 */ char unk_008[0x4];
6970
/* 0x00C */ char unk00C[0xC];
7071
/* 0x018 */ s32 unk_018;

src/2FEA0.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void func_8002F2A0(void) {
8787
FRAGMENT_LOAD(fragment3);
8888
var_s0 = FRAGMENT_LOAD_AND_CALL(fragment19, 0, 0);
8989
break;
90-
case 15: //
90+
case 15: //
9191
FRAGMENT_LOAD(fragment3);
9292
var_s0 = FRAGMENT_LOAD_AND_CALL(fragment20, 0, 0);
9393
break;

src/controller.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
#include "gb_tower.h"
44
#include "math_util.h"
55

6-
struct Controller gControllers[4];
6+
Controller* gPlayer1Controller = &gControllers[0];
7+
Controller* gPlayer2Controller = &gControllers[1];
8+
Controller* gPlayer3Controller = &gControllers[2];
9+
Controller* gPlayer4Controller = &gControllers[3];
10+
11+
Controller gControllers[4];
712
OSMesgQueue gSIEventMesgQueue;
813
u8 gControllerBits;
914
u8 gEepromProbe;
@@ -22,7 +27,7 @@ void Cont_InitControllers(void) {
2227

2328
// clear each gControllers member.
2429
for (i = 0; i < MAXCONTROLLERS; i++) {
25-
bzero((void*)&gControllers[i], sizeof(struct Controller));
30+
bzero((void*)&gControllers[i], sizeof(Controller));
2631
}
2732

2833
// Initialize each connected controller.
@@ -41,7 +46,7 @@ void Cont_InitControllers(void) {
4146
* Take the updated controller struct and calculate
4247
* the new x, y, and distance floats.
4348
*/
44-
void Cont_AdjustAnalogStick(struct Controller* controller) {
49+
void Cont_AdjustAnalogStick(Controller* controller) {
4550
// reset the controller's x and y floats.
4651
controller->stickX = 0.0f;
4752
controller->stickY = 0.0f;
@@ -75,7 +80,7 @@ void Cont_AdjustAnalogStick(struct Controller* controller) {
7580
}
7681

7782
if (controller->stickMag > 0.0f) {
78-
controller->unkE = MathUtil_Atan2s(-controller->stickY, controller->stickX);
83+
controller->angle = MathUtil_Atan2s(-controller->stickY, controller->stickX);
7984
}
8085
}
8186

@@ -93,7 +98,7 @@ void Cont_StartReadInputs(void) {
9398
*/
9499
void Cont_ReadInputs(void) {
95100
s32 i;
96-
struct Controller* controller = &gControllers[0];
101+
Controller* controller = &gControllers[0];
97102

98103
osRecvMesg(&gSIEventMesgQueue, NULL, OS_MESG_BLOCK);
99104
osContGetReadData(&gControllerPads[0]);

0 commit comments

Comments
 (0)