Skip to content

Commit

Permalink
Merge pull request pret#139 from Kelebek1/fragment3
Browse files Browse the repository at this point in the history
Fragment3
  • Loading branch information
RevoSucks authored Sep 25, 2024
2 parents 64c4751 + bd70bb7 commit 0643c67
Show file tree
Hide file tree
Showing 37 changed files with 2,481 additions and 272 deletions.
15 changes: 14 additions & 1 deletion include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ typedef struct unk_D_86002F58_004_000 {
/* 0x0F8 */ char pad0F8[0x70];
} unk_D_86002F58_004_000; // size = 0x168

typedef struct unk_D_86002F34_000_014_004 {
/* 0x00 */ u8 unk_00[5];
} unk_D_86002F34_000_014_004; // size = 0x5

typedef struct unk_D_86002F34_000_014_010 {
/* 0x00 */ u8 unk_00[4];
} unk_D_86002F34_000_014_010; // size = 0x4

typedef struct unk_D_86002F34_000_014 {
/* 0x00 */ u8* unk_00;
/* 0x04 */ u8* unk_04;
} unk_D_86002F34_000_014; // size >= 0x8

typedef struct unk_D_86002F34_000 {
/* 0x00 */ u8 unk_00;
/* 0x01 */ u8 unk_01;
Expand All @@ -155,7 +168,7 @@ typedef struct unk_D_86002F34_000 {
/* 0x08 */ struct unk_D_86002F34_000* unk_08;
/* 0x0C */ struct unk_D_86002F34_000* unk_0C;
/* 0x10 */ s32 (*unk_10)(s32, struct unk_D_86002F34_000*);
/* 0x14 */ char unk14[0x4];
/* 0x14 */ unk_D_86002F34_000_014* unk_14;
} unk_D_86002F34_000; // size >= 0x18

typedef struct unk_D_86002F34_00C_018 {
Expand Down
4 changes: 2 additions & 2 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

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

#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
#define ABS(x) ((x) < 0 ? -(x) : (x))
#define ABS_ALT(x) ((x) >= 0 ? (x) : -(x))

#define FRAGMENT_ID(fragment) ((((u32)fragment##_TEXT_START & 0x0FF00000) >> 0x14) - 0x10)
#define ASSET_ID(asset) (((u32)asset & 0x0F000000) >> 0x18)
Expand Down
13 changes: 0 additions & 13 deletions include/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,6 @@ extern u32 D_B0000D10;

extern u8 D_800818E0[0x20];

typedef struct unk_D_80068BA0 {
/* 0x00 */ char pad00[0x2];
/* 0x02 */ s16 unk_02;
/* 0x04 */ s16 unk_04;
/* 0x06 */ u16 unk_06;
/* 0x08 */ u16 unk_08;
/* 0x0A */ char pad0A[0x2];
} unk_D_80068BA0; // size >= 0xC

extern unk_D_80068BA0* D_80068BA0;
extern unk_D_80068BA0* D_80068BA4;
extern unk_D_80068BA0* D_80068BA8;
extern unk_D_80068BA0* D_80068BAC;
extern Gfx D_8006F518[];
extern Gfx D_8006F630[];
extern u8 D_82000000;
Expand Down
13 changes: 12 additions & 1 deletion linker_scripts/us/symbol_addrs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ D_87906048 = 0x87906048;
D_87906060 = 0x87906060;
D_87906064 = 0x87906064;
D_87906068 = 0x87906068;
D_8790606C = 0x8790606C;
D_87906070 = 0x87906070;
D_87906094 = 0x87906094;
D_87906098 = 0x87906098;
Expand Down Expand Up @@ -296,3 +295,15 @@ D_8006F050 = 0x8006F050; // size:0xC
D_8006F05C = 0x8006F05C; // size:0x6
D_8006F064 = 0x8006F064; // size:0xC
D_800ABE10 = 0x800ABE10; // size:0xA18
gPlayer1Controller = 0x80068BA0;
gPlayer2Controller = 0x80068BA4;
gPlayer3Controller = 0x80068BA8;
gPlayer4Controller = 0x80068BAC;
D_8790606C = 0x8790606C; // size:0x6
D_87906088 = 0x87906088; // size:0xC
D_8790609C = 0x8790609C; // size:0x6
D_879060AC = 0x879060AC; // size:0x6
pad_D_879060B4 = 0x879060B4; // size:0x8
D_879060E0 = 0x879060E0; // size:0xC
D_87906100 = 0x87906100; // size:0xC
D_87906110 = 0x87906110; // size:0xC
9 changes: 1 addition & 8 deletions src/11BA0.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,10 @@ typedef struct unk_func_80011B94 {
/* 0x18 */ Gfx* unk_18;
} unk_func_80011B94; // size = 0x1C

typedef struct unk_D_86404778_190 {
/* 0x00 */ unk_D_86002F58_004_000_000 unk_00;
/* 0x18 */ Gfx* unk_18;
/* 0x1C */ Vec3f unk_1C;
/* 0x28 */ f32 unk_28;
} unk_D_86404778_190; // size = 0x2C

unk_D_86002F58_004_000_000* func_8001103C(MainPoolState*, void*);
unk_D_86002F58_004_000* func_80011938(MainPoolState* arg0, unk_D_86002F58_004_000* arg1, s16 arg2, Vec3f* arg3, Vec3s* arg4, Vec3f* arg5);
unk_func_80011B94* func_80011B94(MainPoolState*, unk_func_80011B94*, s32, Gfx*);
unk_D_86404778_190* func_80011B10(MainPoolState*, s32, s32, s32, Vec3f*, f32);
unk_D_86002F34_alt9* func_80011B10(MainPoolState*, s32, s32, s32, Vec3f*, f32);
void func_80012094(unk_D_86002F58_004_000_000*, unk_D_86002F58_004_000_000*);


Expand Down
36 changes: 18 additions & 18 deletions src/12D80.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ unk_D_86002F34_00C* D_8006F094 = NULL;
unk_D_86002F34_alt1* D_8006F098 = NULL;
unk_D_86002F58_004_000* D_8006F09C = NULL;
unk_D_86002F34_alt11* D_8006F0A0 = NULL;
func_D_8006F0A4 D_8006F0A4[] = {
static func_D_8006F0A4 D_8006F0A4[] = {
func_80013330, func_800133D8, func_80013464, func_80013764, func_8001378C, func_8001395C, func_800139E8,
func_80013AF8, func_80013B8C, func_80013C14, func_80013C1C, func_80013D34, func_80013F7C, func_80013F84,
func_80014124, func_80014D70, func_80014214, func_800142BC, func_80014334, func_80014384, func_800143C0,
func_80014624, func_80014690, func_800148D8, func_80014980, func_80014A60, func_80014AEC, func_80014D24,
func_80014D50, NULL, NULL,
};

s32 D_8006F120 = 0;
static s32 D_8006F120 = 0;

u32 D_8006F124[4][9] = {
static u32 D_8006F124[4][9] = {
{
0x3024000,
0x3024000,
Expand Down Expand Up @@ -86,7 +86,7 @@ u32 D_8006F124[4][9] = {
},
};

u8 D_8006F1B4[15][16] = {
static u8 D_8006F1B4[15][16] = {
{ 0x1F, 0x1F, 0x1F, 3, 7, 7, 7, 3, 0, 0x1F, 4, 0x1F, 0, 7, 6, 7 },
{ 1, 0x1F, 3, 0x1F, 7, 7, 7, 1, 0, 0x1F, 4, 0x1F, 0, 7, 6, 7 },
{ 1, 3, 8, 3, 7, 7, 3, 7, 0, 0x1F, 4, 0x1F, 0, 7, 6, 7 },
Expand All @@ -104,20 +104,20 @@ u8 D_8006F1B4[15][16] = {
{ 1, 0x1F, 4, 0x1F, 1, 7, 4, 7, 0x1F, 0x1F, 0x1F, 0, 0, 7, 6, 7 },
};

s16 D_8006F2A4[] = { 16, 8, 4, 2, 0, 0 };

s32 D_800AA6C0;
MtxF* D_800AA6C8[8];
u8 pad_D_800AA6E8[0x1E0];
unk_D_800AA8C8 D_800AA8C8;
unk_D_800AB970 D_800AB970;
s32 D_800ABB00;
s32 D_800ABB04;
s32 D_800ABB08;
unk_D_800ABB10 D_800ABB10;
unk_D_800ABB28 D_800ABB28[10];
unk_D_800ABB28* D_800ABCB8;
s32 D_800ABCBC;
static s16 D_8006F2A4[] = { 16, 8, 4, 2, 0, 0 };

static s32 D_800AA6C0;
static MtxF* D_800AA6C8[8];
static u8 pad_D_800AA6E8[0x1E0];
static unk_D_800AA8C8 D_800AA8C8;
static unk_D_800AB970 D_800AB970;
static s32 D_800ABB00;
static s32 D_800ABB04;
static s32 D_800ABB08;
static unk_D_800ABB10 D_800ABB10;
static unk_D_800ABB28 D_800ABB28[10];
static unk_D_800ABB28* D_800ABCB8;
static s32 D_800ABCBC;

void func_80012180(void) {
D_800AA8C8.unk_10A0 = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/12D80.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ typedef struct unk_D_800ABB10 {
/* 0x14 */ Gfx* unk_14;
} unk_D_800ABB10; // size = 0x18?

extern s32 D_8006F080;
extern u16 D_8006F084;
extern unk_D_86002F34_00C* D_8006F088;
extern unk_D_86002F34_alt1* D_8006F08C;
extern unk_D_86002F34_alt1* D_8006F090;
extern unk_D_86002F34_00C* D_8006F094;
extern unk_D_86002F34_alt1* D_8006F098;
extern unk_D_86002F58_004_000* D_8006F09C;
extern unk_D_86002F34_alt11* D_8006F0A0;

void func_80012180(void);
void func_800121C8(void);
void func_80012230(MtxF* arg0);
Expand Down
6 changes: 3 additions & 3 deletions src/17300.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void func_800173CC(unk_D_86002F58_004_000* arg0) {
arg0->unk_040.unk_04 = NULL;
}

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

Expand Down Expand Up @@ -375,8 +375,8 @@ s32 func_80017484(unk_D_86002F58_004_000* arg0, s16 arg1) {
return var_a2;
}

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

s32 func_80017514(unk_D_86002F58_004_000* arg0) {
Expand Down
4 changes: 2 additions & 2 deletions src/17300.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ void func_80017090(unk_D_86002F58_004_000_040* arg0, u16 arg1, s32 arg2);
void func_80017188(void);
void func_800171A8(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, s32 arg3);
void func_800173CC(unk_D_86002F58_004_000* arg0);
s32 func_800173DC(unk_D_86002F58_004_000* arg0, s16 arg1, s32 arg2, s32 arg3);
s32 func_800173DC(unk_D_86002F58_004_000* arg0, s16 arg1, void* arg2, s32 arg3);
s32 func_80017454(unk_D_86002F58_004_000* arg0, s32 arg1);
void func_80017464(unk_D_86002F58_004_000* arg0, s16 arg1);
s32 func_80017484(unk_D_86002F58_004_000* arg0, s16 arg1);
void func_800174E4(unk_D_86002F58_004_000* arg0);
s32 func_800174E4(unk_D_86002F58_004_000* arg0);
s32 func_80017514(unk_D_86002F58_004_000* arg0);


Expand Down
20 changes: 10 additions & 10 deletions src/20330.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@

static s32 pad_D_800AC880[0x2];
static s32 D_800AC888;
static unk_D_80068BA0* D_800AC88C;
static Controller* D_800AC88C;

void func_8001F730(void) {
}

void func_8001F738(unk_D_80068BA0* arg0) {
void func_8001F738(Controller* arg0) {
D_800AC888 = 0xA;
D_800AC88C = arg0;
}

s32 func_8001F750(void) {
if (D_800AC88C->unk_08 & 0x800) {
if (D_800AC88C->buttonPressed & 0x800) {
D_800AC888 = 0xA;
return 0x800;
}

if (D_800AC88C->unk_08 & 0x400) {
if (D_800AC88C->buttonPressed & 0x400) {
D_800AC888 = 0xA;
return 0x400;
}

if (D_800AC88C->unk_08 & 0x200) {
if (D_800AC88C->buttonPressed & 0x200) {
D_800AC888 = 0xA;
return 0x200;
}

if (D_800AC88C->unk_08 & 0x100) {
if (D_800AC88C->buttonPressed & 0x100) {
D_800AC888 = 0xA;
return 0x100;
}
Expand All @@ -39,22 +39,22 @@ s32 func_8001F750(void) {
D_800AC888 = 0;

// clang-format off
if (D_800AC88C->unk_06 & 0x800) {
if (D_800AC88C->buttonDown & 0x800) {
D_800AC888 = 2; return 0x800;
}
// clang-format on

if (D_800AC88C->unk_06 & 0x400) {
if (D_800AC88C->buttonDown & 0x400) {
D_800AC888 = 2;
return 0x400;
}

if (D_800AC88C->unk_06 & 0x200) {
if (D_800AC88C->buttonDown & 0x200) {
D_800AC888 = 2;
return 0x200;
}

if (D_800AC88C->unk_06 & 0x100) {
if (D_800AC88C->buttonDown & 0x100) {
D_800AC888 = 2;
return 0x100;
}
Expand Down
3 changes: 2 additions & 1 deletion src/20330.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#define _20330_H_

#include "global.h"
#include "src/controller.h"

void func_8001F730(void);
void func_8001F738(unk_D_80068BA0*);
void func_8001F738(Controller*);
s32 func_8001F750(void);


Expand Down
3 changes: 2 additions & 1 deletion src/29BA0.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "global.h"
#include "3FB0.h"
#include "src/controller.h"

typedef struct unk_D_800AE520 {
/* 0x00 */ s16 unk_00;
Expand Down Expand Up @@ -64,7 +65,7 @@ typedef struct unk_D_800AE540_0004 {
/* 0x000 */ u8 unk_000;
/* 0x001 */ u8 unk_001;
/* 0x002 */ u8 unk_002;
/* 0x004 */ struct Controller* controller;
/* 0x004 */ Controller* controller;
/* 0x008 */ char unk_008[0x4];
/* 0x00C */ char unk00C[0xC];
/* 0x018 */ s32 unk_018;
Expand Down
2 changes: 1 addition & 1 deletion src/2FEA0.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void func_8002F2A0(void) {
FRAGMENT_LOAD(fragment3);
var_s0 = FRAGMENT_LOAD_AND_CALL(fragment19, 0, 0);
break;
case 15: //
case 15: //
FRAGMENT_LOAD(fragment3);
var_s0 = FRAGMENT_LOAD_AND_CALL(fragment20, 0, 0);
break;
Expand Down
15 changes: 10 additions & 5 deletions src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include "gb_tower.h"
#include "math_util.h"

struct Controller gControllers[4];
Controller* gPlayer1Controller = &gControllers[0];
Controller* gPlayer2Controller = &gControllers[1];
Controller* gPlayer3Controller = &gControllers[2];
Controller* gPlayer4Controller = &gControllers[3];

Controller gControllers[4];
OSMesgQueue gSIEventMesgQueue;
u8 gControllerBits;
u8 gEepromProbe;
Expand All @@ -22,7 +27,7 @@ void Cont_InitControllers(void) {

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

// Initialize each connected controller.
Expand All @@ -41,7 +46,7 @@ void Cont_InitControllers(void) {
* Take the updated controller struct and calculate
* the new x, y, and distance floats.
*/
void Cont_AdjustAnalogStick(struct Controller* controller) {
void Cont_AdjustAnalogStick(Controller* controller) {
// reset the controller's x and y floats.
controller->stickX = 0.0f;
controller->stickY = 0.0f;
Expand Down Expand Up @@ -75,7 +80,7 @@ void Cont_AdjustAnalogStick(struct Controller* controller) {
}

if (controller->stickMag > 0.0f) {
controller->unkE = MathUtil_Atan2s(-controller->stickY, controller->stickX);
controller->angle = MathUtil_Atan2s(-controller->stickY, controller->stickX);
}
}

Expand All @@ -93,7 +98,7 @@ void Cont_StartReadInputs(void) {
*/
void Cont_ReadInputs(void) {
s32 i;
struct Controller* controller = &gControllers[0];
Controller* controller = &gControllers[0];

osRecvMesg(&gSIEventMesgQueue, NULL, OS_MESG_BLOCK);
osContGetReadData(&gControllerPads[0]);
Expand Down
Loading

0 comments on commit 0643c67

Please sign in to comment.