Skip to content

Commit 37c4c50

Browse files
committed
split pipe sequence from pipe horn, start pipe sequence documentation
1 parent b968521 commit 37c4c50

File tree

14 files changed

+797
-767
lines changed

14 files changed

+797
-767
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@
367367
"palettes.h": "c",
368368
"dma.h": "c",
369369
"ceiling_slope.h": "c",
370-
"french_horn.h": "c"
370+
"french_horn.h": "c",
371+
"pipe_sequence.h": "c"
371372
},
372373
"asm-code-lens.donated": true,
373374
"editor.formatOnSave": true,

include/data/handlers_ia_pipe_horn_sequences.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "global.h"
55
#include "game/interactables_2/music_plant/pipe_horn.h"
66

7-
extern const Pipe_Data *gUnknown_08C8793C[9];
8-
extern const Pipe_Data *gUnknown_08C87960[3];
7+
extern const PipeSegment *gUnknown_08C8793C[9];
8+
extern const PipeSegment *gUnknown_08C87960[3];
99

1010
#endif

include/game/interactables_2/music_plant/french_horn.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
#include "global.h"
55
#include "game/entity.h"
6-
#include "game/interactables_2/music_plant/pipe_horn.h"
7-
8-
#define NUM_PIPE_HANDLERS 16
6+
#include "game/interactables_2/music_plant/pipe_sequence.h"
97

108
void CreateEntity_FrenchHorn_Entry(MapEntity *me, u16 spriteRegionX, u16 spriteRegionY, u8 spriteY);
119

12-
extern const Pipe_Data gUnknown_080DFEE4[];
13-
extern const Pipe_Data gUnknown_080DFF3C[];
14-
extern const Pipe_Data gUnknown_080DFF9C[];
10+
extern const PipeSegment gFrenchHornPipeSequence0[];
11+
extern const PipeSegment gFrenchHornPipeSequence1[];
12+
extern const PipeSegment gFrenchHornPipeSequence2[];
1513

1614
#endif // GUARD_INTERACTABLE_FRENCH_HORN_H

include/game/interactables_2/music_plant/pipe_horn.h

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,14 @@
33

44
#include "global.h"
55
#include "game/entity.h"
6-
7-
typedef struct {
8-
/* 0x00 */ s32 x0;
9-
/* 0x04 */ s32 y0;
10-
/* 0x08 */ s32 x1;
11-
/* 0x0C */ s32 y1;
12-
/* 0x10 */ s32 x2;
13-
/* 0x14 */ s32 y2;
14-
/* 0x18 */ u16 unk18;
15-
/* 0x1A */ s16 unk1A;
16-
/* 0x1C */ s32 posX;
17-
/* 0x20 */ s32 posY;
18-
/* 0x24 */ u16 kind;
19-
/* 0x26 */ u16 unk26;
20-
/* 0x28 */ MapEntity *me;
21-
/* 0x2C */ u8 spriteX;
22-
/* 0x2D */ u8 spriteY;
23-
} Sprite_PipeHorn;
24-
25-
#define NUM_PIPE_HANDLERS 16
26-
27-
// VERY unsure about this union...
28-
typedef union {
29-
s16 _16[2];
30-
s32 _32; // Q_24_8?
31-
} PipeData_Weirdness;
32-
33-
typedef struct Pipe_Data {
34-
u16 unk0;
35-
u16 unk2;
36-
37-
PipeData_Weirdness unk4;
38-
39-
} Pipe_Data;
6+
#include "game/interactables_2/music_plant/pipe_sequence.h"
407

418
void CreateEntity_PipeInstrument_Entry(MapEntity *me, u16 spriteRegionX, u16 spriteRegionY, u8 spriteY);
42-
bool32 sub_8077788(Sprite_PipeHorn *pipe, const Pipe_Data *data);
43-
void sub_8077774(Sprite_PipeHorn *pipe, s32 x, s32 y);
449

45-
extern const Pipe_Data gUnknown_080DFCF0[];
46-
extern const Pipe_Data gUnknown_080DFD40[];
47-
extern const Pipe_Data gUnknown_080DFD98[];
48-
extern const Pipe_Data gUnknown_080DFDD8[];
49-
extern const Pipe_Data gUnknown_080DFE30[];
10+
extern const PipeSegment gPipeHornPipeSequence0[];
11+
extern const PipeSegment gUnknown_080DFD40[];
12+
extern const PipeSegment gPipeHornPipSequence1[];
13+
extern const PipeSegment gUnknown_080DFDD8[];
14+
extern const PipeSegment gPipeHornPipeSequence2[];
5015

5116
#endif // GUARD_INTERACTABLE_PIPE_HORN_H
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef GUARD_INTERACTABLE_PIPE_SEQUENCE_H
2+
#define GUARD_INTERACTABLE_PIPE_SEQUENCE_H
3+
4+
#include "global.h"
5+
#include "game/entity.h"
6+
7+
#define NUM_PIPE_SEGMENT_TYPES 16
8+
#define PIPE_SEGMENT_TYPE_TRANSLATE 0
9+
10+
typedef struct {
11+
/* 0x00 */ s32 initialX;
12+
/* 0x04 */ s32 initialY;
13+
/* 0x08 */ s32 segmentBaseX;
14+
/* 0x0C */ s32 segmentBaseY;
15+
/* 0x10 */ s32 currentX;
16+
/* 0x14 */ s32 currentY;
17+
/* 0x18 */ u16 index;
18+
/* 0x1A */ s16 accumulator;
19+
} PipeSequence;
20+
21+
typedef struct {
22+
s16 dX;
23+
s16 dY;
24+
} OffsetPos;
25+
26+
// VERY unsure about this union...
27+
typedef union {
28+
s16 _16[2];
29+
s32 _32; // Q_24_8?
30+
OffsetPos translate;
31+
s32 offset;
32+
} PipeData_Weirdness;
33+
34+
typedef struct PipeSegment {
35+
u16 type;
36+
u16 step;
37+
PipeData_Weirdness d;
38+
} PipeSegment;
39+
40+
bool32 IncrementPipeSequence(PipeSequence *pipe, const PipeSegment *data);
41+
void InitPipeSequence(PipeSequence *pipe, s32 x, s32 y);
42+
43+
#endif // GUARD_INTERACTABLE_PIPE_SEQUENCE_H

ldscript.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ SECTIONS
282282
src/game/interactables_2/music_plant/chord.o(.text);
283283
src/game/interactables_2/music_plant/keyboard.o(.text);
284284
src/game/interactables_2/music_plant/german_flute.o(.text);
285+
src/game/interactables_2/music_plant/pipe_sequence.o(.text);
285286
src/game/interactables_2/music_plant/pipe_horn.o(.text);
286287
src/game/interactables_2/music_plant/french_horn.o(.text);
287288
src/game/interactables_2/ice_paradise/slowing_snow.o(.text);
@@ -494,6 +495,7 @@ SECTIONS
494495
src/game/interactables_2/music_plant/note_block.o(.rodata);
495496
src/game/interactables_2/music_plant/keyboard.o(.rodata);
496497
src/game/interactables_2/music_plant/german_flute.o(.rodata);
498+
src/game/interactables_2/music_plant/pipe_sequence.o(.rodata);
497499
src/game/interactables_2/music_plant/pipe_horn.o(.rodata);
498500
src/game/interactables_2/music_plant/french_horn.o(.rodata);
499501
src/game/interactables_2/techno_base/bounce_block.o(.rodata);
@@ -526,7 +528,7 @@ SECTIONS
526528

527529
src/data/sprite_tables.o(.rodata);
528530
src/data/animations/animations.o(.rodata);
529-
src/data/animations/animation_table.o(.data);
531+
src/data/animations/animation_table.o(.rodata);
530532
src/data/sprite_dimensions.o(.rodata);
531533
src/data/sprite_oam_data.o(.rodata);
532534
data/sprite_animation_data.o(.rodata);

src/data/animations/animation_table.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ extern const s32 * const anim_1131[];
993993
extern const s32 * const anim_1132[];
994994
extern const s32 * const anim_logos[];
995995

996-
const s32 * const *gAnimations[] = {
996+
const s32 * const * const gAnimations[] = {
997997
anim_0000,
998998
anim_0001,
999999
anim_0002,

src/data/handlers_ia_pipe_horn_sequences.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33

44
// NOTE: Stored at end of rom, probably because it's configured data (like levels and
55
// assets?)
6-
const Pipe_Data *const gUnknown_08C8793C[9] = {
7-
gUnknown_080DFCF0,
8-
gUnknown_080DFCF0,
6+
const PipeSegment *const gUnknown_08C8793C[9] = {
7+
gPipeHornPipeSequence0,
8+
gPipeHornPipeSequence0,
99
gUnknown_080DFD40,
1010
gUnknown_080DFD40,
11-
gUnknown_080DFD98,
11+
gPipeHornPipSequence1,
1212
gUnknown_080DFDD8,
1313
gUnknown_080DFDD8,
14-
gUnknown_080DFE30,
15-
gUnknown_080DFE30,
14+
gPipeHornPipeSequence2,
15+
gPipeHornPipeSequence2,
1616
};
1717

18-
const Pipe_Data * const gUnknown_08C87960[3] = {
19-
gUnknown_080DFEE4,
20-
gUnknown_080DFF3C,
21-
gUnknown_080DFF9C,
18+
const PipeSegment * const gUnknown_08C87960[3] = {
19+
gFrenchHornPipeSequence0,
20+
gFrenchHornPipeSequence1,
21+
gFrenchHornPipeSequence2,
2222
};

src/game/interactables_2/ice_paradise/funnel_sphere.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct {
2828
// prevPriority2
2929
u16 unk14;
3030

31-
s32 unk18;
31+
s32 keyFrame;
3232
u16 unk1C;
3333
MapEntity *me; /* 0x20 */
3434
s8 spriteX; /* 0x24 */
@@ -64,9 +64,9 @@ static void sub_8077F7C(void)
6464

6565
funnelSphere->unk10 -= 0x40;
6666
r6 = (funnelSphere->unk10 >> 2);
67-
if (funnelSphere->unk18 == 0 && (r6 < 0x40)) {
67+
if (funnelSphere->keyFrame == 0 && (r6 < 0x40)) {
6868
gCamera.unk50 |= 1;
69-
funnelSphere->unk18 = 1;
69+
funnelSphere->keyFrame = 1;
7070
}
7171

7272
#ifndef NON_MATCHING
@@ -168,7 +168,7 @@ static void sub_8078170(Sprite_FunnelSphere *funnelSphere)
168168
} else {
169169
funnelSphere->unk1C = 0;
170170
}
171-
funnelSphere->unk18 = 0;
171+
funnelSphere->keyFrame = 0;
172172
gCurTask->main = sub_807844C;
173173
};
174174

src/game/interactables_2/ice_paradise/slowing_snow.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,14 @@
88
#include "game/entity.h"
99
#include "sprite.h"
1010

11-
PACKED(Interactable_SlowingSnow, {
12-
/* 0x00 */ u8 x;
13-
/* 0x01 */ u8 y;
14-
/* 0x02 */ u8 index;
15-
16-
/* 0x03 */ s8 offsetX;
17-
/* 0x04 */ s8 offsetY;
18-
/* 0x05 */ u8 width;
19-
/* 0x06 */ u8 height;
20-
});
21-
2211
typedef struct {
2312
/* 0x00 */ s16 left;
2413
/* 0x02 */ s16 top;
2514
/* 0x04 */ s16 right;
2615
/* 0x06 */ s16 bottom;
2716
/* 0x08 */ s32 posX;
2817
/* 0x0C */ s32 posY;
29-
/* 0x10 */ Interactable_SlowingSnow *me;
18+
/* 0x10 */ MapEntity *me;
3019
/* 0x14 */ u8 spriteX;
3120
/* 0x15 */ u8 spriteY;
3221
} Sprite_SlowingSnow; // size = 0x18
@@ -40,11 +29,11 @@ void CreateEntity_SlowingSnow(MapEntity *in_ia, u16 spriteRegionX, u16 spriteReg
4029
struct Task *t = TaskCreate(Task_SlowingSnow, sizeof(Sprite_SlowingSnow), 0x2010, 0, TaskDestructor_SlowingSnow);
4130

4231
Sprite_SlowingSnow *snow = TASK_DATA(t);
43-
Interactable_SlowingSnow *me = (Interactable_SlowingSnow *)in_ia;
44-
snow->left = me->offsetX * 8;
45-
snow->top = me->offsetY * 8;
46-
snow->right = snow->left + me->width * 8;
47-
snow->bottom = snow->top + me->height * 8;
32+
MapEntity *me = in_ia;
33+
snow->left = me->d.sData[0] * 8;
34+
snow->top = me->d.sData[1] * 8;
35+
snow->right = snow->left + me->d.uData[2] * 8;
36+
snow->bottom = snow->top + me->d.uData[3] * 8;
4837
snow->me = me;
4938
snow->spriteX = me->x;
5039
snow->spriteY = spriteY;

0 commit comments

Comments
 (0)