summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorcadmic <cadmic24@gmail.com>2024-08-02 17:31:15 -0700
committerGitHub <noreply@github.com>2024-08-02 20:31:15 -0400
commit0da402b9de9b6874a7e04f8e9e8333079f61a75e (patch)
treed7ff6691b3be25d543745adc3d177f54406f5d54 /src/code
parent078e21f6c62b5acb4744cefd97718f63bc622831 (diff)
Automate fixing BSS ordering (#2009)
* Automate fixing BSS ordering * Typo * Some cleanups * Move pragma check after printing BSS info * Some proofreading * multiprocessing, require version, some colors * Tweak output * Black + mypy * Move logging and sys.exit out of helper functions * Use stdout instead of stderr in fix_bss.py * Add suggestion to conflicting offsets error Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Remove var = list[T]() * Improve error handling Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Add error if no pointers to BSS * Add comment about process_file_worker * Only print updates if stdout is a tty * Use new binary-search-esque candidate generation algorithm Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * Add Wikipedia link * More comment tweaks --------- Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
Diffstat (limited to 'src/code')
-rw-r--r--src/code/fault.c9
-rw-r--r--src/code/main.c4
-rw-r--r--src/code/sys_math3d.c4
-rw-r--r--src/code/z_actor.c5
-rw-r--r--src/code/z_camera.c6
-rw-r--r--src/code/z_collision_check.c6
-rw-r--r--src/code/z_common_data.c5
-rw-r--r--src/code/z_demo.c4
-rw-r--r--src/code/z_kaleido_scope_call.c5
-rw-r--r--src/code/z_kankyo.c10
10 files changed, 14 insertions, 44 deletions
diff --git a/src/code/fault.c b/src/code/fault.c
index 16f1a183f..990285615 100644
--- a/src/code/fault.c
+++ b/src/code/fault.c
@@ -44,14 +44,7 @@
#include "terminal.h"
#include "alloca.h"
-// For retail BSS ordering, the block number of sFaultInstance must be 0 or
-// just above (the exact upper bound depends on the block numbers assigned to
-// extern variables declared in headers).
-#if OOT_DEBUG
-#pragma increment_block_number 0
-#else
-#pragma increment_block_number 20
-#endif
+#pragma increment_block_number "gc-eu:64 gc-eu-mq:64 gc-eu-mq-dbg:0"
void FaultDrawer_Init(void);
void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled);
diff --git a/src/code/main.c b/src/code/main.c
index ca72ab0e5..e39e8974b 100644
--- a/src/code/main.c
+++ b/src/code/main.c
@@ -7,9 +7,7 @@ s32 gScreenWidth = SCREEN_WIDTH;
s32 gScreenHeight = SCREEN_HEIGHT;
u32 gSystemHeapSize = 0;
-// For retail BSS ordering, the block number of gIrqMgr must be greater than the
-// the block numbers assigned to extern variables above (declared in variables.h).
-#pragma increment_block_number 220
+#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"
PreNmiBuff* gAppNmiBufferPtr;
Scheduler gScheduler;
diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c
index bb86036ad..b9e712e29 100644
--- a/src/code/sys_math3d.c
+++ b/src/code/sys_math3d.c
@@ -5,9 +5,7 @@
#include "macros.h"
#include "sys_math3d.h"
-// For retail BSS ordering, the block number of cbf in Math3D_CylVsCylOverlapCenterDist
-// must be 0.
-#pragma increment_block_number 108
+#pragma increment_block_number "gc-eu:108 gc-eu-mq:108"
s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB,
Vec3f* lineAClosestToB, Vec3f* lineBClosestToA);
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 620586961..1da1f1ce3 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -8,8 +8,7 @@
#include "assets/objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
#include "assets/objects/object_bdoor/object_bdoor.h"
-// For retail BSS ordering, the block number of sCurCeilingPoly
-// must be between 2 and 243 inclusive.
+#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"
static CollisionPoly* sCurCeilingPoly;
static s32 sCurCeilingBgId;
@@ -1906,7 +1905,7 @@ s32 func_8002F9EC(PlayState* play, Actor* actor, CollisionPoly* poly, s32 bgId,
return false;
}
-#pragma increment_block_number 22
+#pragma increment_block_number "gc-eu:22 gc-eu-mq:22"
// Local data used for Farore's Wind light (stored in BSS)
LightInfo D_8015BC00;
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index 4caafe18c..e6edcb6e3 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -4,9 +4,7 @@
#include "terminal.h"
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
-// For retail BSS ordering, the block number of D_8015BD7C
-// must be between 88 and 123 inclusive.
-#pragma increment_block_number 30
+#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"
s16 Camera_RequestSettingImpl(Camera* camera, s16 requestedSetting, s16 flags);
s32 Camera_RequestModeImpl(Camera* camera, s16 requestedMode, u8 forceModeChange);
@@ -3632,7 +3630,7 @@ s32 Camera_KeepOn3(Camera* camera) {
return 1;
}
-#pragma increment_block_number 100
+#pragma increment_block_number "gc-eu:128 gc-eu-mq:128"
s32 Camera_KeepOn4(Camera* camera) {
static Vec3f D_8015BD50;
diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c
index 9b0e03131..e78c78fd1 100644
--- a/src/code/z_collision_check.c
+++ b/src/code/z_collision_check.c
@@ -12,9 +12,7 @@ typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec
#define SAC_ENABLE (1 << 0)
-// For retail BSS ordering, the block number of sparkInit in CollisionCheck_BlueBlood
-// must be between 183 and 255 inclusive.
-#pragma increment_block_number 50
+#pragma increment_block_number "gc-eu:64 gc-eu-mq:64"
#if OOT_DEBUG
/**
@@ -2695,7 +2693,7 @@ typedef enum {
/* 2 */ MASSTYPE_NORMAL
} ColChkMassType;
-#pragma increment_block_number 253
+#pragma increment_block_number "gc-eu:252 gc-eu-mq:252"
/**
* Get mass type. Immovable colliders cannot be pushed, while heavy colliders can only be pushed by heavy and immovable
diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c
index a0588d929..0f40faddc 100644
--- a/src/code/z_common_data.c
+++ b/src/code/z_common_data.c
@@ -1,9 +1,6 @@
#include "global.h"
-// For retail BSS ordering, the block number of D_8015FA88 must be 0 or
-// just above (the exact upper bound depends on the block numbers assigned to
-// extern variables declared in headers).
-#pragma increment_block_number 60
+#pragma increment_block_number "gc-eu:128 gc-eu-mq:128"
ALIGNED(16) SaveContext gSaveContext;
u32 D_8015FA88;
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index 6961ed25b..8f7b9a886 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -120,9 +120,7 @@ u16 gCamAtSplinePointsAppliedFrame;
u16 gCamEyePointAppliedFrame;
u16 gCamAtPointAppliedFrame;
-// For retail BSS ordering, the block number of sReturnToCamId must be greater
-// than that of gCamAtPointAppliedFrame (declared in variables.h).
-#pragma increment_block_number 180
+#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"
// Cam ID to return to when a scripted cutscene is finished
s16 sReturnToCamId;
diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c
index 7b53b8521..272156f63 100644
--- a/src/code/z_kaleido_scope_call.c
+++ b/src/code/z_kaleido_scope_call.c
@@ -1,10 +1,7 @@
#include "global.h"
#include "terminal.h"
-// For retail BSS ordering, the block number of sKaleidoScopeUpdateFunc must be 0 or
-// just above (the exact upper bound depends on the block numbers assigned to
-// extern variables declared in headers).
-#pragma increment_block_number 60
+#pragma increment_block_number "gc-eu:128 gc-eu-mq:128"
void (*sKaleidoScopeUpdateFunc)(PlayState* play);
void (*sKaleidoScopeDrawFunc)(PlayState* play);
diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c
index 60f5c651f..c35f0d1dc 100644
--- a/src/code/z_kankyo.c
+++ b/src/code/z_kankyo.c
@@ -7,10 +7,7 @@
#include "assets/objects/gameplay_keep/gameplay_keep.h"
#include "assets/objects/gameplay_field_keep/gameplay_field_keep.h"
-// For retail BSS ordering, the block number of sLensFlareUnused must be lower
-// than the extern variables declared in the header (e.g. gLightningStrike)
-// while the block number of sNGameOverLightNode must be higher.
-#pragma increment_block_number 80
+#pragma increment_block_number "gc-eu:128 gc-eu-mq:128"
typedef enum {
/* 0x00 */ LIGHTNING_BOLT_START,
@@ -215,10 +212,7 @@ s16 sLightningFlashAlpha;
s16 sSunDepthTestX;
s16 sSunDepthTestY;
-// These variables could be moved farther down in the file to reduce the amount
-// of block number padding here, but currently this causes BSS ordering issues
-// for debug.
-#pragma increment_block_number 217
+#pragma increment_block_number "gc-eu:128 gc-eu-mq:128"
LightNode* sNGameOverLightNode;
LightInfo sNGameOverLightInfo;