Skip to content

Commit b279eba

Browse files
committed
Refactor function declarations into headers
1 parent 52e9e50 commit b279eba

74 files changed

Lines changed: 1019 additions & 258 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DECOMPILATION_LEARNINGS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,3 +529,16 @@ when a `0x3C` stride view advanced from the `Player` base and a second typed vie
529529
offset `0x38`; iterating `Player.bodyPartDisplayObjects` directly added two instructions. A small documented adapter
530530
view can preserve this induction shape while the function signatures and all actual field accesses continue using
531531
the canonical `Player` and `DisplayListObject` types.
532+
533+
## Preserve Historical ABIs When Centralizing Prototypes
534+
535+
Moving local extern declarations into shared headers can change KMC GCC output even when a caller ignores the
536+
return value. `onTrickCompletedHook` has an empty body and behaves like a `void` hook, but its original `s16`
537+
prototype affects instruction scheduling in `beginPostTrickSlidingStep`. Changing the declaration to `void`
538+
reordered three stores and broke 12 ROM bytes. Keep the historical non-void ABI and narrowly suppress the
539+
checker warning on the empty implementation.
540+
541+
Argument signedness is similarly codegen-sensitive at call sites. For example, the final render-flags argument
542+
to `setupAndEnqueueSprite` and the cutscene frame index must retain their signed types so callers emit the target
543+
sign-extension sequence. When factoring headers, derive prototypes from both the definition and caller
544+
assembly rather than widening small integer arguments to a convenient unsigned type.

include/animation/model_scale.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include "common.h"
4+
5+
typedef struct ModelScaleAnimationState ModelScaleAnimationState;
6+
7+
void initModelScaleAnimation(ModelScaleAnimationState *state);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include "common.h"
4+
5+
typedef struct ModelTransitionEffectState ModelTransitionEffectState;
6+
7+
void initModelTransitionEffect(ModelTransitionEffectState *state);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include "common.h"
4+
5+
typedef struct PulsingSpriteState PulsingSpriteState;
6+
7+
void initPulsingSpriteIndicator(PulsingSpriteState *state);

include/animation/stepped_matrix.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include "common.h"
4+
5+
typedef struct SteppedMatrixState SteppedMatrixState;
6+
7+
void initSteppedMatrixController(SteppedMatrixState *state);

include/cutscene/1DD170.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
#include "common.h"
44
#include "cutscene/cutscene_manager.h"
55

6+
typedef struct CurrentCommand CurrentCommand;
7+
typedef struct CommandData CommandData;
8+
69
s32 getCategorySkipValue(u8 categoryIndex);
710
s32 initializeSlotState(StateEntry *state, CutsceneManager *cutsceneManager, s8 slotIndex);
811
s32 updateSlotData(CutsceneManager *cutsceneManager, s8 slotIndex);
12+
13+
void initializeCutsceneCommand(
14+
CurrentCommand *currentCommand,
15+
CommandData *commandData,
16+
u8 commandCategory,
17+
u8 commandIndex,
18+
s8 frameIndex
19+
);

include/cutscene/cutscene_manager.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
#include "math/geometry.h"
88
#include "ui/level_preview_3d.h"
99

10+
typedef union {
11+
s32 value;
12+
struct {
13+
u8 unused;
14+
u8 alpha;
15+
u8 fractional[2];
16+
} bytes;
17+
} CutsceneAlphaFixed;
18+
1019
typedef struct {
1120
u8 r;
1221
u8 g;
@@ -41,7 +50,7 @@ typedef struct {
4150
struct {
4251
s16 remainingFrames;
4352
u8 padding[0xE];
44-
s32 currentAlphaFixed;
53+
CutsceneAlphaFixed currentAlphaFixed;
4554
s32 easingParam0;
4655
s32 easingParam1;
4756
s32 easingParam2;
@@ -300,7 +309,7 @@ typedef struct {
300309
struct {
301310
s16 remainingFrames;
302311
u8 padding[0xE];
303-
s32 currentAlphaFixed;
312+
CutsceneAlphaFixed currentAlphaFixed;
304313
s32 easingParam0;
305314
s32 easingParam1;
306315
s32 easingParam2;

include/effects/orbital_sprite.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
#include "common.h"
4+
5+
typedef struct OrbitalSpriteRingInitArg OrbitalSpriteRingInitArg;
6+
7+
void initOrbitalSpriteRing(OrbitalSpriteRingInitArg *state);

include/graphics/displaylist.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,6 @@ typedef struct {
260260
} MatrixEntry_202A0;
261261
void enqueueRotatedBillboardSprite(s32 arg0, MatrixEntry_202A0 *arg1);
262262
void renderRotatedBillboardSpriteCI(MatrixEntry_202A0 *arg1);
263+
264+
s32 normalizeSurfaceType(s32);
265+
s32 projectPositionOntoTrackSegment(TrackGeometryData *trackGeom, u16 sectorIdx, PositionXZ *pos);

include/graphics/preview_render.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include "common.h"
4+
5+
void initBoardShopBoardIcons(void);
6+
void initBoardShopCharacterPreview(void);
7+
void initBoardShopCharacterTransition(void);
8+
void initBoardShopColumnSelectorArrow(void);
9+
void initBoardShopComparisonIcons(void);
10+
void initBoardShopExitOverlay(void);
11+
void initBoardShopPreviewWipe(void);
12+
void initBoardShopRowSelectorArrow(void);
13+
void initBoardShopShopkeeper(void);
14+
void initBoardShopSnowParticles(void);
15+
void initBoardShopSnowflakeSlideIn(void);
16+
void initBoardShopTitleCorners(void);
17+
void initBoardShopTitleText(void);
18+
void loadBoardShopBackground(void);

0 commit comments

Comments
 (0)