1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 06:54:33 +00:00

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>
This commit is contained in:
cadmic 2024-08-02 17:31:15 -07:00 committed by GitHub
parent 078e21f6c6
commit 0da402b9de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 1071 additions and 352 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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;