Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Special Stage documentation and a crash fix #187

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/game/special_stage/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void CreateSpecialStage(s16 selectedCharacter, s16 level)

static void SetupIntroScreenRegisters(void)
{
gDispCnt = 0x1641;
gBgCntRegs[1] = 0x703;
gBgCntRegs[2] = 0xD086;
gBldRegs.bldCnt = 0xAF;
gDispCnt = (DISPCNT_OBJ_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_MODE_1);
gBgCntRegs[1] = (BGCNT_TXT256x256 | BGCNT_16COLOR | BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(7));
gBgCntRegs[2] = (BGCNT_TXT512x512 | BGCNT_256COLOR | BGCNT_PRIORITY(2) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(16));
gBldRegs.bldCnt = BLDCNT_EFFECT_LIGHTEN | (BLDCNT_TGT1_ALL & ~BLDCNT_TGT1_OBJ);
gBldRegs.bldY = 0x10;

gBgScrollRegs[1][0] = 0;
Expand Down Expand Up @@ -716,7 +716,7 @@ static void Task_ShowIntroScreen(void)
{
struct SpecialStage *stage = TASK_DATA(gCurTask);
SetupIntroScreenRegisters();
sub_806CA88(&stage->introText, RENDER_TARGET_SCREEN, 0x28, 0x37C, 0, 0x78, 0x50, 0, 0, 0);
sub_806CA88(&stage->introText, RENDER_TARGET_SCREEN, 0x28, 0x37C, 0, (DISPLAY_WIDTH / 2), (DISPLAY_HEIGHT / 2), 0, 0, 0);

stage->state = 1;
m4aSongNumStart(MUS_SPECIAL_STAGE_INTRO);
Expand Down
11 changes: 6 additions & 5 deletions src/game/special_stage/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ struct Task *CreateSpecialStagePlayer(struct SpecialStage *stage)
s->graphics.dest = player->unkA0;
s->graphics.size = 0;
s->graphics.anim = SA2_ANIM_SP_STAGE_ARROW;
s->frameFlags = 0x107E;
s->frameFlags = SPRITE_FLAG(PRIORITY, 1) | SPRITE_FLAG(ROT_SCALE_DOUBLE_SIZE, 1) | SPRITE_FLAG(ROT_SCALE_ENABLE, 1)
| SPRITE_FLAG(ROT_SCALE, 30);
s->x = (DISPLAY_WIDTH / 2);
s->y = (DISPLAY_HEIGHT / 2);
s->oamFlags = SPRITE_OAM_ORDER(0);
Expand Down Expand Up @@ -296,19 +297,19 @@ void sub_806D4E4(void)

void sub_806D548(Sprite *s, void *vram, s16 a, u8 b, const struct UNK_80DF670 *c4)
{
u32 unk10 = 0x1000;
u32 frameFlags = SPRITE_FLAG(PRIORITY, 1);
if (c4->unk7 & 1) {
unk10 |= 0x400;
frameFlags |= SPRITE_FLAG(X_FLIP, 1);
}

if (c4->unk7 & 2) {
unk10 |= 0x800;
frameFlags |= SPRITE_FLAG(Y_FLIP, 1);
}

s->graphics.dest = vram;
s->graphics.size = 0;
s->graphics.anim = c4->anim;
s->frameFlags = unk10;
s->frameFlags = frameFlags;
s->x = (DISPLAY_WIDTH / 2);
s->y = a;
s->oamFlags = SPRITE_OAM_ORDER(b);
Expand Down
15 changes: 12 additions & 3 deletions src/game/special_stage/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,20 @@ void sub_806CA88(Sprite *obj, s8 target, u32 size, u16 anim, u32 unk10, s16 xPos
// TODO: SpecialStageCollectables_UNK874 is probably it's own type
bool16 sub_806CB84(struct UNK_806CB84 *a, struct SpecialStageCollectables_UNK874_2 *unk874, struct SpecialStage *stage)
{
struct SpecialStageWorld *world = TASK_DATA(stage->worldTask);
struct SpecialStageWorld *world;
s32 r9;
s32 r4;
s16 val2, val;

#ifdef BUG_FIX
// worldTask can sometimes be NULL when directly calling Special Stage code
if (stage->worldTask == NULL) {
return FALSE;
}
#endif

world = TASK_DATA(stage->worldTask);

{
u16 deg = -stage->cameraBearing & 0x3FF;
s32 r2 = SIN(deg) * 4;
Expand Down Expand Up @@ -181,14 +190,14 @@ void InitSpecialStageScreenVram(void)
gUnknown_03005B58 = NULL;
}

void sub_806CEC4(Background *background, u32 a, u32 b, u8 assetId, u16 d, u16 e, u16 palOffset, u8 bg_id, u16 scrollX, u16 scrollY)
void sub_806CEC4(Background *background, u32 a, u32 b, u8 tilemapId, u16 d, u16 e, u16 palOffset, u8 bg_id, u16 scrollX, u16 scrollY)
{
background->graphics.dest = (void *)BG_CHAR_ADDR(a);
background->graphics.anim = 0;
background->layoutVram = (void *)BG_SCREEN_ADDR(b);
background->unk18 = 0;
background->unk1A = 0;
background->tilemapId = assetId;
background->tilemapId = tilemapId;
background->unk1E = 0;
background->unk20 = 0;
background->unk22 = 0;
Expand Down