Skip to content

Commit

Permalink
Merge branch 'auto-bss' into colliders_effectsfields
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragorn421 committed Aug 1, 2024
2 parents a13a4c7 + 0bf2a19 commit f801a28
Show file tree
Hide file tree
Showing 21 changed files with 1,038 additions and 348 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ $(BUILD_DIR)/src/code/jpegdecoder.o: CC := $(CC_OLD)

ifeq ($(PERMUTER),) # permuter + preprocess.py misbehaves, permuter doesn't care about rodata diffs or bss ordering so just don't use it in that case
# Handle encoding (UTF-8 -> EUC-JP) and custom pragmas
$(BUILD_DIR)/src/%.o: CC := $(PYTHON) tools/preprocess.py $(CC)
$(BUILD_DIR)/src/%.o: CC := $(PYTHON) tools/preprocess.py -v $(VERSION) -- $(CC)
endif

else
Expand Down
5 changes: 1 addition & 4 deletions src/boot/idle.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#include "global.h"
#include "terminal.h"

// For retail BSS ordering, the block number of sMainThread 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:50 gc-eu-mq:50"

OSThread sMainThread;
STACK(sMainStack, 0x900);
Expand Down
9 changes: 1 addition & 8 deletions src/code/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:20 gc-eu-mq:20 gc-eu-mq-dbg:0"

void FaultDrawer_Init(void);
void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled);
Expand Down
4 changes: 1 addition & 3 deletions src/code/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/code/sys_math3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions src/code/z_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 2 additions & 4 deletions src/code/z_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -3632,7 +3630,7 @@ s32 Camera_KeepOn3(Camera* camera) {
return 1;
}

#pragma increment_block_number 100
#pragma increment_block_number "gc-eu:120 gc-eu-mq:120"

s32 Camera_KeepOn4(Camera* camera) {
static Vec3f D_8015BD50;
Expand Down
6 changes: 2 additions & 4 deletions src/code/z_collision_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:36 gc-eu-mq:36"

#if OOT_DEBUG
/**
Expand Down Expand Up @@ -2700,7 +2698,7 @@ typedef enum {
/* 2 */ MASSTYPE_NORMAL
} ColChkMassType;

#pragma increment_block_number 253
#pragma increment_block_number "gc-eu:254 gc-eu-mq:254"

/**
* Get mass type. Immovable colliders cannot be pushed, while heavy colliders can only be pushed by heavy and immovable
Expand Down
5 changes: 1 addition & 4 deletions src/code/z_common_data.c
Original file line number Diff line number Diff line change
@@ -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:50 gc-eu-mq:50"

ALIGNED(16) SaveContext gSaveContext;
u32 D_8015FA88;
Expand Down
4 changes: 1 addition & 3 deletions src/code/z_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions src/code/z_kaleido_scope_call.c
Original file line number Diff line number Diff line change
@@ -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:50 gc-eu-mq:50"

void (*sKaleidoScopeUpdateFunc)(PlayState* play);
void (*sKaleidoScopeDrawFunc)(PlayState* play);
Expand Down
10 changes: 2 additions & 8 deletions src/code/z_kankyo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:80 gc-eu-mq:80"

typedef enum {
/* 0x00 */ LIGHTNING_BOLT_START,
Expand Down Expand Up @@ -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:160 gc-eu-mq:160"

LightNode* sNGameOverLightNode;
LightInfo sNGameOverLightInfo;
Expand Down
12 changes: 5 additions & 7 deletions src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,19 @@ static ColliderCylinderInit sLightBallCylinderInit = {
static u8 D_808E4C58[] = { 0, 12, 10, 12, 14, 16, 12, 14, 16, 12, 14, 16, 12, 14, 16, 10, 16, 14 };
static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f };

// For retail BSS ordering, the block number of sGanondorf must be 0 or just above.

// TODO: There's probably a way to do this with less padding by spreading the variables out and moving
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
#pragma increment_block_number 50
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"

static EnGanonMant* sCape;

#pragma increment_block_number 200
// TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
#pragma increment_block_number "gc-eu:200 gc-eu-mq:200"

static s32 sSeed1;
static s32 sSeed2;
static s32 sSeed3;

#pragma increment_block_number 200
#pragma increment_block_number "gc-eu:240 gc-eu-mq:240"

static BossGanon* sGanondorf;

Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_En_Wonder_Item/z_en_wonder_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ActorInit En_Wonder_Item_InitVars = {
/**/ NULL,
};

#pragma increment_block_number 1
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"

static Vec3f sTagPointsFree[9];
static Vec3f sTagPointsOrdered[9];
Expand Down
5 changes: 2 additions & 3 deletions src/overlays/actors/ovl_En_Xc/z_en_xc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#include "assets/scenes/dungeons/ice_doukutu/ice_doukutu_scene.h"
#include "terminal.h"

// For retail BSS ordering, the block number of sSfxPos
// must be between 0 and 213 inclusive.
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"

#define FLAGS ACTOR_FLAG_4

Expand Down Expand Up @@ -1396,7 +1395,7 @@ void func_80B3F3D8(void) {
Sfx_PlaySfxCentered2(NA_SE_PL_SKIP);
}

#pragma increment_block_number 20
#pragma increment_block_number "gc-eu:20 gc-eu-mq:20"

void EnXc_PlayDiveSFX(Vec3f* src, PlayState* play) {
static Vec3f D_80B42DA0;
Expand Down
3 changes: 1 addition & 2 deletions src/overlays/actors/ovl_Fishing/z_fishing.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#include "ichain.h"
#include "terminal.h"

// For retail BSS ordering, the block number of sStreamSfxProjectedPos must be 0.
#pragma increment_block_number 206
#pragma increment_block_number "gc-eu:206 gc-eu-mq:206"

#define FLAGS ACTOR_FLAG_4

Expand Down
13 changes: 5 additions & 8 deletions src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,19 @@ void Player_Action_CsAction(Player* this, PlayState* play);

// .bss part 1

// For retail BSS ordering, the block number of sDogSpawnPos in Player_Update
// must be between 0 and 53 inclusive.

// TODO: There's probably a way to do this with less padding by spreading the variables out and moving
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
#pragma increment_block_number 30
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0"

static s32 D_80858AA0;

#pragma increment_block_number 250
// TODO: There's probably a way to match BSS ordering with less padding by spreading the variables out and moving
// data around. It would be easier if we had more options for controlling BSS ordering in debug.
#pragma increment_block_number "gc-eu:100 gc-eu-mq:100"

static s32 D_80858AA4;
static Vec3f sInteractWallCheckResult;
static Input* sControlInput;

#pragma increment_block_number 50
#pragma increment_block_number "gc-eu:220 gc-eu-mq:220"

// .data

Expand Down
Loading

0 comments on commit f801a28

Please sign in to comment.