Skip to content

Commit

Permalink
Cleanup seq_title
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekyCt committed Sep 2, 2024
1 parent 33d22ac commit f99c67e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 26 deletions.
27 changes: 23 additions & 4 deletions spm-headers/include/spm/seq_title.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,38 @@ CPP_WRAPPER(spm::seq_title)
USING(spm::seqdrv::SeqWork)
USING(wii::mem::MEMAllocator)

/*
seqWork stage values
*/

// Wait for button press, or to timeout and replay intro
#define SEQ_TITLE_WAIT_INPUT -1

// Button pressed, start file select transition
#define SEQ_TITLE_FILE_SELECT_PRESS 0

// Wait for file select transition
#define SEQ_TITLE_FILE_SELECT_FADE 1

// Timeout, replay intro
#define SEQ_TITLE_REPLAY_TIMEOUT 2

// Wait for intro replay transition
#define SEQ_TITLE_REPLAY_FADE 3

typedef struct
{
/* 0x00 */ s32 unknown_0x0;
/* 0x04 */ u32 unknown_0x4;
/* 0x00 */ s32 openingReplayTimer;
/* 0x04 */ u32 unknown_0x4; // unused?
/* 0x08 */ void * arc;
/* 0x0C */ void * heap;
/* 0x10 */ u32 heapSize;
/* 0x14 */ void * heapHandle;
/* 0x18 */ MEMAllocator allocator;
/* 0x28 */ nw4r::lyt::ArcResourceAccessor * arcResAccessor;
/* 0x2C */ nw4r::lyt::Layout * layout;
/* 0x30 */ nw4r::lyt::Pane * pushu2Pane; // nw4r::lyt::Pane
/* 0x30 */ nw4r::lyt::Pane * pushuBotanPane; // nw4r::lyt::Pane
/* 0x30 */ nw4r::lyt::Pane * pushu2Pane;
/* 0x30 */ nw4r::lyt::Pane * pushuBotanPane;
/* 0x38 */ nw4r::lyt::AnimTransform * animations[2]; // 0 start, 1 loop
/* 0x40 */ nw4r::lyt::DrawInfo drawInfo;
/* 0x94 */ s32 animNum;
Expand Down
66 changes: 44 additions & 22 deletions src/seq_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,61 +42,83 @@ void seq_titleInit(SeqWork * seqWork)
gp->flags &= ~SPMARIO_FLAG_1;
gp->flags &= ~SPMARIO_FLAG_2;

seqWork->stage = -1;
seqWork->stage = SEQ_TITLE_WAIT_INPUT;

// Start transition
fadeEntry(1, 300, (GXColor) {0x00, 0x00, 0x00, 0xff});

marioReset();
wp->unknown_0x0 = 0;

// Setup display
wp->openingReplayTimer = 0;
wp->unknown_0x4 = 0;
seqTitleInitLayout();

// Play music
spsndBGMOn(0, "BGM_EVT_TITLE1");
}

void seq_titleMain(SeqWork * seqWork)
{
if (seqWork->stage != -1)
wp->unknown_0x0 = 0;
if (seqWork->stage != SEQ_TITLE_WAIT_INPUT)
wp->openingReplayTimer = 0;

switch (seqWork->stage)
{
case -1:
if (fadeIsFinish())
case SEQ_TITLE_WAIT_INPUT:
// Wait for transition to finish
if (!fadeIsFinish())
break;

// Check for input or timeout
// TODO: flag macro
if (((wpadGetButtonsPressed(0) >> 8) & 1) != 0)
{
seqWork->stage = SEQ_TITLE_FILE_SELECT_PRESS;
}
else
{
// TODO: flag macro
if (((wpadGetButtonsPressed(0) >> 8) & 1) != 0)
{
seqWork->stage = 0;
}
else
{
if (++wp->unknown_0x0 > 1800)
seqWork->stage = 2;
}
}
if (++wp->openingReplayTimer > 1800)
seqWork->stage = SEQ_TITLE_REPLAY_TIMEOUT;
}

break;

case 0:
case SEQ_TITLE_FILE_SELECT_PRESS:
// Start transition
fadeEntry(2, 300, (GXColor) {0x00, 0x00, 0x00, 0xff});

// Play sound effect
spsndSFXOn("SFX_SYS_PRESS_START1");
func_8023ce20(0, 70, 1000);
seqWork->stage = 1;

seqWork->stage = SEQ_TITLE_FILE_SELECT_FADE;

break;

case 1:
case SEQ_TITLE_FILE_SELECT_FADE:
// Open file select after transition
if (fadeIsFinish())
seqSetSeq(SEQ_LOAD, NULL, NULL);

break;

case 2:
case SEQ_TITLE_REPLAY_TIMEOUT:
// Stop music
spsndBGMOff_f_d_alt(0, 2000);

// Start transition
fadeEntry(2, 300, (GXColor) {0x00, 0x00, 0x00, 0xff});

seqWork->stage = 3;

break;

case 3:
case SEQ_TITLE_REPLAY_FADE:
// Replay intro after transition
if (fadeIsFinish())
seqSetSeq(SEQ_MAPCHANGE,"aa4_01",NULL);

break;
}

Expand Down

0 comments on commit f99c67e

Please sign in to comment.