Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHIFT_BSS be gone #1173

Merged
merged 13 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/PR/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ u8 __osContAddressCrc(u16 addr);
u8 __osContDataCrc(u8 *data);
s32 __osPfsGetStatus(OSMesgQueue *queue, int channel);

#ifndef NO_EXTERN_VARIABLES

extern u8 __osContLastCmd;
extern OSTimer __osEepromTimer;
extern OSMesg __osEepromTimerMsg;
Expand All @@ -227,6 +229,8 @@ extern OSPifRam __osContPifRam;
extern OSPifRam __osPfsPifRam;
extern u8 __osMaxControllers;

#endif

//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0
#define ERRCK(fn) \
ret = fn; \
Expand Down
6 changes: 5 additions & 1 deletion include/PR/os_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ typedef struct OSMesgQueue_s {

/* Events */
#ifdef _FINALROM
#define OS_NUM_EVENTS 15
# ifndef BBPLAYER
# define OS_NUM_EVENTS 15
# else
# define OS_NUM_EVENTS 32
# endif
#else
#define OS_NUM_EVENTS 23
#endif
Expand Down
3 changes: 3 additions & 0 deletions include/PR/osint.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ extern void __osTimerInterrupt(void);
extern u32 __osProbeTLB(void *);
extern int __osSpDeviceBusy(void);

#ifndef NO_EXTERN_VARIABLES

extern OSThread *__osRunningThread;
extern OSThread *__osActiveQueue;
extern OSThread *__osFaultedThread;
Expand All @@ -41,6 +43,7 @@ extern u32 __osShutdown;

extern __OSEventState __osEventStateTab[OS_NUM_EVENTS];

#endif

//not sure if this should be here
extern s32 osViClock;
Expand Down
2 changes: 2 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include "types.h"
#include "common_structs.h"
#include "functions.h"
#ifndef NO_EXTERN_VARIABLES
#include "variables.h"
#endif
#include "macros.h"
#include "enums.h"
#include "evt.h"
Expand Down
7 changes: 7 additions & 0 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2514,6 +2514,13 @@ typedef struct PartnerDMAData {
/* 0x10 */ s32 y;
} PartnerDMAData; // size = 0x14

typedef struct UseItemStruct {
/* 0x00 */ u8* dmaStart;
/* 0x04 */ u8* dmaEnd;
/* 0x08 */ EvtScript* main;
/* 0x0C */ s32 unk_0C;
} UseItemStruct;

typedef struct MsgVoice {
/* 0x00 */ s32 voiceA;
/* 0x04 */ s32 voiceB;
Expand Down
10 changes: 6 additions & 4 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
#define MATCHING_BSS(size) static BSS u8 padding_bss[size];
#endif

#define BSS __attribute__ ((section (".bss")))
#define BSS __attribute__ ((nocommon, section (".bss")))
#define TRANSPARENT_UNION __attribute__ ((__transparent_union__))
#else
#define SHIFT_BSS static
#define BSS static
#define TRANSPARENT_UNION
#endif

#define ALIGNED(x) __attribute__((aligned(x)))

#ifndef BBPLAYER
# define ALIGNED(x) __attribute__((aligned(x)))
# define OSALIGNED(x) ALIGNED(x)
#else
# define ALIGNED(x)
# define OSALIGNED(x)
#endif

#define BBALIGNED(x) __attribute__((aligned(x)))
# define BBALIGNED(x) ALIGNED(x)

#define ALIGN16(val) (((val) + 0xF) & ~0xF)
#define ALIGN8(val) (((val) + 0x7) & ~0x7)
Expand Down
5 changes: 5 additions & 0 deletions include/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ typedef struct ShapeFile {
} ShapeFile; // size = variable

typedef ModelTreeInfo ModelTreeInfoList[0x200];

#ifndef NO_EXTERN_VARIABLES

extern ModelTreeInfoList* gCurrentModelTreeNodeInfo;
extern ModelList* gCurrentModels;

#endif

void mdl_set_depth_tint_params(u8 primR, u8 primG, u8 primB, u8 primA, u8 fogR, u8 fogG, u8 fogB, s32 fogStart, s32 fogEnd);
void mdl_set_remap_tint_params(u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB);
void mdl_get_remap_tint_params(u8* primR, u8* primG, u8* primB, u8* envR, u8* envG, u8* envB);
Expand Down
9 changes: 6 additions & 3 deletions include/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,15 @@ typedef struct EncounterStatus {
/* 0x0A8 */ FieldStatus unusedAttack2;
/* 0x0AC */ FieldStatus unusedAttack3;
/* 0x0B0 */ s32 defeatFlags[60][12];
/* 0xFB0 */ s16 recentMaps[2];
/* 0xFB4 */ char unk_FB4[4];
} EncounterStatus; // size = 0xFB8
/* 0xBF0 */ s16 recentMaps[2];
} EncounterStatus; // size = 0xBF4

#ifndef NO_EXTERN_VARIABLES

extern EncounterStatus gCurrentEncounter;

#endif

s32 basic_ai_check_player_dist(EnemyDetectVolume* arg0, Enemy* arg1, f32 arg2, f32 arg3, s8 arg4);

/// The default Npc::onUpdate and Npc::onRender callback.
Expand Down
12 changes: 10 additions & 2 deletions include/nu/nualsgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ typedef struct st_SndState {
typedef void (*NUAuPreNMIFunc)(NUScMsg,u32); /* PRENMI callback function */
typedef void (*NUAuMgrFunc)(void); /* Acmd callback function */

#ifndef NO_EXTERN_VARIABLES

/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* extern variables */
Expand All @@ -194,11 +196,15 @@ typedef void (*NUAuMgrFunc)(void); /* Acmd callback function */
/*--------------------------------------*/
/* audio variables */
/*--------------------------------------*/

// NOTE: some variables have been commented out due to
// being declared static which affects bss reordering

extern u64* nuAuMgrStack;
extern NUScTask nuAuTask; /* Audio task buffer*/
extern s16* nuAuBuffer_ptr[]; /* Audio buffer */
extern NUScClient nuAuClient;
extern OSThread nuAuMgrThread;
//extern OSThread nuAuMgrThread;
extern u32 nuAuFrameCounter; /* Frame counter */
extern ALHeap nuAuHeap; /* Heap structure */
extern NUAuSeqPlayer nuAuSeqPlayer[];
Expand All @@ -219,7 +225,7 @@ extern OSMesgQueue nuAuMesgQ; /* Audio Manager queue */
extern ALGlobals nuAuGlobal;
extern s16 nuAuDmaBufNum;
extern s16 nuAuDmaBufSize;
extern NUDMAState nuAuDmaState;
//extern NUDMAState nuAuDmaState;
extern NUDMABuffer* nuAuDmaBuf;
extern Acmd* nuAuCmdListBuf; /* pointer of command list */
extern u32 nuAuAcmdLen;
Expand All @@ -240,6 +246,8 @@ extern u32 nuAuDebAcmdLenMax; /* Maximum length of the audio command list */
extern s16 nuAuFrameSampleSize; /* Number of samples created at one time */
extern s16 nuAuExtraSampleSize; /* Number of extra samples */

#endif

/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* Global Function */
Expand Down
3 changes: 3 additions & 0 deletions include/nu/nusys.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ typedef struct st_DebConWindow {
u16 text[NU_DEB_CON_TEXT_SIZE]; /* Character buffer*/
} NUDebConWindow;

#ifndef NO_EXTERN_VARIABLES

/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* extern variables */
Expand Down Expand Up @@ -752,6 +754,7 @@ extern u32 nuDebTaskPerfInterval;
extern volatile u32 nuDebTaskPerfCnt;
extern volatile u32 nuDebTaskPerfEnd;

#endif

/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
Expand Down
10 changes: 5 additions & 5 deletions src/111f0_len_860.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include "nu/nusys.h"
#include "game_modes.h"

SHIFT_BSS s16 gMapTransitionAlpha;
SHIFT_BSS s16 gMapTransitionFadeRate;
SHIFT_BSS s16 gMapTransitionState;
SHIFT_BSS s16 gMapTransitionStateTime;
SHIFT_BSS s16 gLoadedFromFileSelect;
BSS s16 gMapTransitionAlpha;
BSS s16 gMapTransitionFadeRate;
BSS s16 gMapTransitionState;
BSS s16 gMapTransitionStateTime;
BSS s16 gLoadedFromFileSelect;

void set_map_change_fade_rate(s16 fadeRate) {
gMapTransitionFadeRate = fadeRate;
Expand Down
13 changes: 8 additions & 5 deletions src/77480.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ extern Addr inspect_icon_ROM_START;
extern Addr inspect_icon_ROM_END;
#endif

SHIFT_BSS UNK_FUN_PTR(ISpyNotificationCallback);
SHIFT_BSS UNK_FUN_PTR(PulseStoneNotificationCallback);
SHIFT_BSS UNK_FUN_PTR(TalkNotificationCallback);
SHIFT_BSS UNK_FUN_PTR(InteractNotificationCallback);
SHIFT_BSS s32 D_8010C950;
UNK_FUN_PTR(ISpyNotificationCallback);
UNK_FUN_PTR(PulseStoneNotificationCallback);
UNK_FUN_PTR(TalkNotificationCallback);
UNK_FUN_PTR(InteractNotificationCallback);
s32 D_8010C950;

PlayerStatus gPlayerStatus;
PlayerData gPlayerData;

extern f32 D_800F7B48;
extern s32 D_800F7B4C;
Expand Down
19 changes: 10 additions & 9 deletions src/7B440.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include "common.h"

SHIFT_BSS s32 PeachDisguiseNpcIndex;
SHIFT_BSS Entity* TweesterTouchingPartner;
SHIFT_BSS Entity* TweesterTouchingPlayer;
SHIFT_BSS s32 PrevPlayerDirection;
SHIFT_BSS s32 PlayerRunStateTime;
SHIFT_BSS f32 PlayerNormalYaw;
SHIFT_BSS f32 PlayerNormalPitch;
SHIFT_BSS PlayerSpinState gPlayerSpinState;
SHIFT_BSS s32 PlayerYInterpUpdateDelay;
s32 PeachDisguiseNpcIndex;
Entity* TweesterTouchingPartner;
Entity* TweesterTouchingPlayer;
s32 PrevPlayerDirection;
s32 PlayerRunStateTime;
f32 PlayerNormalYaw;
f32 PlayerNormalPitch;
PlayerSpinState gPlayerSpinState;

BSS s32 PlayerYInterpUpdateDelay;

void update_player_input(void) {
PlayerStatus* playerStatus = &gPlayerStatus;
Expand Down
10 changes: 5 additions & 5 deletions src/7BB60.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include "world/partners.h"
#include "sprite/player.h"

SHIFT_BSS CollisionStatus gCollisionStatus;
SHIFT_BSS f32 D_8010C928;
SHIFT_BSS f32 JumpedOnSwitchX;
SHIFT_BSS f32 JumpedOnSwitchZ;
SHIFT_BSS f32 D_8010C984;
CollisionStatus gCollisionStatus;
f32 D_8010C928;
f32 JumpedOnSwitchX;
f32 JumpedOnSwitchZ;
f32 D_8010C984;

extern f32 GravityParamsStartJump[];

Expand Down
19 changes: 10 additions & 9 deletions src/7E9D0.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@
#define PLAYER_ACTION_VRAM_DEF (void*) 0x802B6000
#endif

SHIFT_BSS void* D_8010C924;
SHIFT_BSS s32 D_8010C92C;
SHIFT_BSS s32 D_8010C964;
SHIFT_BSS s32 gSpinHistoryBufferPos;
SHIFT_BSS s16 D_8010C9B0;
SHIFT_BSS s32 gSpinHistoryPosY[5];
SHIFT_BSS s32 gSpinHistoryPosX[5];
SHIFT_BSS s32 gSpinHistoryPosZ[5];
SHIFT_BSS s16 gSpinHistoryPosAngle[5];
void* D_8010C924;
s32 D_8010C92C;
s32 D_8010C964;
s32 gSpinHistoryBufferPos;
s32 gSpinHistoryPosY[5];
s32 gSpinHistoryPosX[5];
s32 gSpinHistoryPosZ[5];
s16 gSpinHistoryPosAngle[5];

BSS s16 D_8010C9B0;

void func_800E5520(void) {
D_8010C9B0 = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/891b0_len_fb0.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ s32 D_801094A8 = 0;
s16 D_801094AC = 4;
s16 D_801094AE = 4;

SHIFT_BSS s32 D_8010CFF0;
SHIFT_BSS s32 D_8010CFF4;
BSS s32 D_8010CFF0;
BSS s32 D_8010CFF4;

void func_800EFD00(void) {
}
Expand Down
2 changes: 1 addition & 1 deletion src/8a160_len_700.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct Unk8a160Outer {
/* 0x00 */ Unk8a160 subs[57]; // one base + 56 others?
} Unk8a160Outer;

SHIFT_BSS Unk8a160Outer D_8010D000[1];
BSS Unk8a160Outer D_8010D000[1];

void func_800F0CB0(s32 arg0, f32 x, f32 y, f32 scale) {
Unk8a160Outer* outer = &D_8010D000[arg0];
Expand Down
Loading
Loading