NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_s_boot.cpp
1#include <game/bases/d_s_boot.hpp>
2#include <game/bases/d_system.hpp>
3#include <game/bases/d_game_com.hpp>
4#include <game/bases/d_graph.hpp>
6#include <game/bases/d_info.hpp>
7#include <game/bases/d_s_stage.hpp>
9#include <game/bases/d_reset.hpp>
10#include <game/bases/d_remocon_manager.hpp>
11#include <game/bases/d_dylink.hpp>
12#include <game/bases/d_hbm.hpp>
13#include <game/bases/d_fader.hpp>
14#include <game/bases/d_wipe_kuppa.hpp>
15#include <game/bases/d_wipe_dokan.hpp>
16#include <game/bases/d_wipe_mario.hpp>
17#include <game/bases/d_wipe_circle.hpp>
18#include <game/bases/d_nand_thread.hpp>
19#include <game/bases/d_s_restart_crsin.hpp>
20#include <game/bases/d_save_mng.hpp>
21#include <game/bases/d_WarningManager.hpp>
22#include <game/mLib/m_pad.hpp>
23#include <revolution/VI.h>
24
26
28
29void painter() {
30 d2d::draw();
31}
32
33namespace {
34
35dDynamicModuleControl s_DBasesDMC("d_bases", nullptr);
36dDynamicModuleControl s_EnemiesDMC("d_enemies", nullptr);
37dDynamicModuleControl s_En_BossDMC("d_en_boss", nullptr);
38
39sPhase_c::METHOD_RESULT_e myDylinkInitPhase_0a(void *) {
40 if (s_DBasesDMC.load_async()) {
41 s_DBasesDMC.link();
42 return sPhase_c::OK;
43 }
44 return sPhase_c::WAIT;
45}
46
47sPhase_c::METHOD_RESULT_e myDylinkInitPhase_0b(void *) {
48 if (s_EnemiesDMC.load_async()) {
49 s_EnemiesDMC.link();
50 return sPhase_c::OK;
51 }
52 return sPhase_c::WAIT;
53}
54
55sPhase_c::METHOD_RESULT_e myDylinkInitPhase_0c(void *) {
56 if (s_En_BossDMC.load_async()) {
57 s_En_BossDMC.link();
58 return sPhase_c::OK;
59 }
60 return sPhase_c::WAIT;
61}
62
63sPhase_c::METHOD_RESULT_e myDylinkInitPhase_2a(void *) {
64 if (
65 dDyl::LinkASync(fProf::CRSIN) == 1 &&
66 dDyl::LinkASync(fProf::STAGE) == 1 &&
67 dDyl::LinkASync(fProf::RESTART_CRSIN) == 1 &&
68 dDyl::LinkASync(fProf::GAMEOVER) == 1 &&
69 dDyl::LinkASync(fProf::RESULT) == 1 &&
70 dDyl::LinkASync(fProf::MOVIE) == 1
71 ) {
72 return sPhase_c::OK;
73 }
74 return sPhase_c::WAIT;
75}
76
77sPhase_c::METHOD_RESULT_e myDylinkInitPhase_2b(void *) {
78 if (dDyl::LinkASync(fProf::BOOT) == 1) {
79 return sPhase_c::OK;
80 }
81 return sPhase_c::WAIT;
82}
83
84sPhase_c::METHOD_RESULT_e myDylinkInitPhase_2c(void *) {
85 return sPhase_c::OK;
86}
87
88sPhase_c::METHOD_RESULT_e myDylinkInitPhase_2d(void *) {
89 if (dDyl::LinkASync(fProf::WORLD_9_DEMO) == 1) {
90 return sPhase_c::OK;
91 }
92 return sPhase_c::WAIT;
93}
94
95sPhase_c::METHOD_RESULT_e myDylinkInitPhase_2e(void *) {
96 if (dDyl::LinkASync(fProf::WORLD_MAP) == 1) {
97 return sPhase_c::OK;
98 }
99 return sPhase_c::WAIT;
100}
101
102sPhase_c::METHOD_RESULT_e myDylinkInitPhase_3a(void *) {
103 if (dDyl::LinkASync(fProf::GAME_SETUP) == 1) {
104 return sPhase_c::OK;
105 }
106 return sPhase_c::WAIT;
107}
108
109sPhase_c::METHOD_RESULT_e myDylinkInitPhase_3b(void *) {
110 if (dDyl::LinkASync(fProf::MULTI_PLAY_COURSE_SELECT) == 1) {
111 return sPhase_c::OK;
112 }
113 return sPhase_c::WAIT;
114}
115
116} // anonymous namespace
117
118sPhase_c::METHOD_RESULT_e myCreate_linkWaitProc(void *) {
120 return sPhase_c::WAIT;
121 }
123 return sPhase_c::WAIT;
124 }
125 return sPhase_c::OK;
126}
127
128/// @unofficial
129sPhase_c::METHOD_RESULT_e myCreate_WiiStrap(void *thisPtr) {
130 dScBoot_c *self = (dScBoot_c *) thisPtr;
131 dWiiStrap_c *strapScreen = (dWiiStrap_c *) fBase_c::createChild(fProf::WII_STRAP, self, 0, 0);
132 self->mpWiiStrap = strapScreen;
133 return sPhase_c::OK;
134}
135
136sPhase_c::METHOD_RESULT_e myCreate_LogoScreen(void *thisPtr) {
137 dScBoot_c *self = (dScBoot_c *) thisPtr;
138 if (!self->mpWiiStrap->mHasLoadedLayout) {
139 return sPhase_c::WAIT;
140 }
141 return sPhase_c::OK;
142}
143
144sPhase_c::METHOD_RESULT_e myCreate_ExtensionMng(void *) {
145 dWarningManager_c::CreateWarningManager();
146 dWarningManager_c::addWarningForbid();
147 return sPhase_c::OK;
148}
149
150sPhase_c::METHOD_RESULT_e myCreate_setPainterCallbackProc(void *) {
151 dGraph_c::ms_Instance->mpPainterFunc = painter;
152 return sPhase_c::OK;
153}
154
155sPhase_c::phaseMethod myCreate_PhaseMethod[] = {
156 myCreate_WiiStrap,
157 myCreate_LogoScreen,
158 myCreate_setPainterCallbackProc
159};
160
161/// @brief This phase is run via dScene_c::mpPhase, so before dScBoot_c::execute() is run.
162sPhase_c myCreate_InitPhase(myCreate_PhaseMethod, ARRAY_SIZE(myCreate_PhaseMethod));
163
164mDvd_callback_c *s_dvdcb;
165
166void *BootSound(void *) {
167 dAudio::boot();
168 return (void *) 1;
169}
170
171sPhase_c::METHOD_RESULT_e myReadArc_BootSound(void *) {
172 s_dvdcb = mDvd_callback_c::createOrDie(BootSound, nullptr);
173 return sPhase_c::OK;
174}
175
176sPhase_c::METHOD_RESULT_e myReadArc_Sound(void *) {
177 if (!s_dvdcb->mDone) {
178 return sPhase_c::WAIT;
179 }
180 s_dvdcb->destroy();
181 s_dvdcb = nullptr;
183 dAudio::loadSceneSnd();
184 return sPhase_c::OK;
185}
186
187sPhase_c::METHOD_RESULT_e myReadArc_resSndWait(void *thisPtr) {
188 dScBoot_c *self = (dScBoot_c *) thisPtr;
189 if (dAudio::isLoadedSceneSnd()) {
190 self->mSceneSoundLoaded = true;
191 return sPhase_c::OK;
192 }
193 return sPhase_c::WAIT;
194}
195
196sPhase_c::METHOD_RESULT_e myReadArc_PhaseHbm_0(void *) {
198 if (dHbm::Manage_c::GetInstance()->Load()) {
199 res = sPhase_c::OK;
200 }
201 return res;
202}
203
204sPhase_c::METHOD_RESULT_e myReadArc_SaveBanner(void *) {
205 const char *saveBannerPath = "/EU/save_banner";
206 static const char saveBannerName[] = "save_banner"; ///< @unofficial
207 dResMng_c::m_instance->setRes(saveBannerPath, saveBannerName, nullptr);
208 return sPhase_c::OK;
209}
210
211/// @unofficial
212const char *l_env_names[] = {
213 "Env_world",
214 "Env_course",
215 "Env_movie"
216};
217
218sPhase_c::METHOD_RESULT_e myReadArc_RegRes(void *) {
219 dResMng_c::m_instance->setRes("Env", l_env_names, ARRAY_SIZE(l_env_names), nullptr);
220 return sPhase_c::OK;
221}
222
223
224sPhase_c::METHOD_RESULT_e myReadArc_resWait(void *) {
225 if (dResMng_c::m_instance->syncAllRes()) {
226 return sPhase_c::WAIT;
227 }
228 return sPhase_c::OK;
229}
230
231sPhase_c::METHOD_RESULT_e myReadArc_WipeKuppa(void *) {
232 if (dWipeKuppa_c::m_instance != nullptr && dWipeKuppa_c::m_instance->createLayout()) {
233 return sPhase_c::OK;
234 }
235 return sPhase_c::WAIT;
236}
237sPhase_c::METHOD_RESULT_e myReadArc_WipeDokan(void *) {
238 if (dWipeDokan_c::m_instance != nullptr && dWipeDokan_c::m_instance->createLayout()) {
239 return sPhase_c::OK;
240 }
241 return sPhase_c::WAIT;
242}
243sPhase_c::METHOD_RESULT_e myReadArc_WipeMario(void *) {
244 if (dWipeMario_c::m_instance != nullptr && dWipeMario_c::m_instance->createLayout()) {
245 return sPhase_c::OK;
246 }
247 return sPhase_c::WAIT;
248}
249sPhase_c::METHOD_RESULT_e myReadArc_WipeCircle(void *) {
250 if (dWipeCircle_c::m_instance != nullptr && dWipeCircle_c::m_instance->createLayout()) {
251 return sPhase_c::OK;
252 }
253 return sPhase_c::WAIT;
254}
255
256/// @unofficial
257sPhase_c::METHOD_RESULT_e myCreate_CreateYesNoWindow(void *selfPtr) {
258 dScBoot_c *self = (dScBoot_c *) selfPtr;
260 self->mpYesNoWindow = ynWindow;
261 dSelectCursor_c *selectCursor = (dSelectCursor_c *) fBase_c::createChild(fProf::SELECT_CURSOR, self, 0, 0);
262 self->mpSelectCursor = selectCursor;
263 return sPhase_c::OK;
264}
265
266sPhase_c::METHOD_RESULT_e myReadArc_ExtensionMng(void *) {
267 if (!dWarningManager_c::m_Created) {
268 return sPhase_c::WAIT;
269 }
270 return sPhase_c::OK;
271}
272
273sPhase_c::METHOD_RESULT_e myReadArc_MakeControllerInformation(void *selfPtr) {
274 dScBoot_c *self = (dScBoot_c *) selfPtr;
276 self->mpControllerInformation = controllerInfo;
277 return sPhase_c::OK;
278}
279
280/// @unofficial
281sPhase_c::METHOD_RESULT_e myCreate_ControllerInformationReady(void *selfPtr) {
282 dScBoot_c *self = (dScBoot_c *) selfPtr;
284 return sPhase_c::WAIT;
285 }
286 return sPhase_c::OK;
287}
288
289/// @unofficial
290sPhase_c::METHOD_RESULT_e myCreate_YesNoWindowReady(void *selfPtr) {
291 dScBoot_c *self = (dScBoot_c *) selfPtr;
292 dYesNoWindow_c *ynWindow = self->mpYesNoWindow;
293 dSelectCursor_c *selectCursor = self->mpSelectCursor;
294 if (!ynWindow->mHasLoadedLayout || !selectCursor->mHasLoadedLayout) {
295 return sPhase_c::WAIT;
296 }
297 return sPhase_c::OK;
298}
299
300sPhase_c::phaseMethod myBackGround_PhaseMethod[] = {
301 myCreate_linkWaitProc,
302 dSystem::createFontManagerPhase,
303 dSystem::createMessageManagerPhase,
304 myCreate_CreateYesNoWindow,
305 myCreate_YesNoWindowReady,
306 myCreate_ExtensionMng,
307 myReadArc_ExtensionMng,
308 myReadArc_PhaseHbm_0,
309 myReadArc_MakeControllerInformation,
310 myCreate_ControllerInformationReady,
311 myReadArc_BootSound,
312 myReadArc_Sound,
313 myReadArc_resSndWait,
314 myReadArc_SaveBanner,
315 myReadArc_resWait,
316 myDylinkInitPhase_0a,
317 myDylinkInitPhase_0b,
318 myDylinkInitPhase_0c,
319 myDylinkInitPhase_2a,
320 myDylinkInitPhase_2b,
321 myDylinkInitPhase_2c,
322 myDylinkInitPhase_2d,
323 myDylinkInitPhase_2e,
324 myDylinkInitPhase_3a,
325 myDylinkInitPhase_3b,
326 myReadArc_RegRes,
327 myReadArc_resWait,
328 myReadArc_WipeKuppa,
329 myReadArc_WipeDokan,
330 myReadArc_WipeMario,
331 myReadArc_WipeCircle,
332 dSystem::createEffectManagerPhase1
333};
334
335/// @brief This phase is run directly inside of dScBoot_c::execute() each frame.
336sPhase_c myBackGround_Phase(myBackGround_PhaseMethod, ARRAY_SIZE(myBackGround_PhaseMethod));
337
338STATE_DEFINE(dScBoot_c, ResetWait);
339STATE_DEFINE(dScBoot_c, ResetFadeOut);
340STATE_DEFINE(dScBoot_c, ResetFadeIn);
341
342STATE_DEFINE(dScBoot_c, FadeOutWait);
343STATE_DEFINE(dScBoot_c, WiiStrapKeyWait);
344STATE_DEFINE(dScBoot_c, WiiStrapDispEndWait);
345STATE_DEFINE(dScBoot_c, WiiStrapFadeOut);
346STATE_DEFINE(dScBoot_c, ControllerInformationFadeIn);
347STATE_DEFINE(dScBoot_c, ControllerInformationSoundWait);
348STATE_DEFINE(dScBoot_c, ControllerInformationKeyWait);
349STATE_DEFINE(dScBoot_c, ControllerInformationDispEndWait);
350STATE_DEFINE(dScBoot_c, NandCommandEndWait);
351STATE_DEFINE(dScBoot_c, ExistFileCheck);
352STATE_DEFINE(dScBoot_c, NandSpaceCheck);
353STATE_DEFINE(dScBoot_c, CreateFile);
355STATE_DEFINE(dScBoot_c, GoToErrorFadeOut);
356STATE_DEFINE(dScBoot_c, GoToErrorFadeIn);
357STATE_DEFINE(dScBoot_c, NewSaveFileDisp);
358STATE_DEFINE(dScBoot_c, ButtonInputWait);
359STATE_DEFINE(dScBoot_c, WindowExitWait);
360STATE_DEFINE(dScBoot_c, ProcEnd);
361STATE_DEFINE(dScBoot_c, ErrorWindowOnStageWait);
362STATE_DEFINE(dScBoot_c, ErrorInfinityDisp);
363
367{
368 mpPhase = &myCreate_InitPhase;
369 m_instance = this;
370}
371
373 m_instance = nullptr;
374}
375
377 dSys_c::setClearColor(nw4r::ut::Color::BLACK);
378 dSys_c::setFrameRate(1);
379 setFadeInFrame(30);
380 setFadeOutFrame(30);
381
383
384 new dResMng_c();
385 new dInfo_c();
386
387 dScStage_c::setTitleReplayRandomTable();
388 dGameCom::initGame();
389
390 mResetFadeOutStarted = false;
392
393 VIEnableDimming(true);
394
395 return SUCCEEDED;
396}
397
399 dGraph_c::ms_Instance->mpPainterFunc = nullptr;
400}
401
403 if (myBackGround_Phase.callMethod(this) != sPhase_c::DONE) {
404 return NOT_READY;
405 }
406
407 dReset::Manage_c::GetInstance()->BootComplete();
408 dRemoconMng_c::dConnect_c::m_isBoot = 0;
409 setFadeInFrame(30);
410 setFadeOutFrame(30);
411
413 return NOT_READY;
414 }
416 return NOT_READY;
417 }
418
419 dSystem::createEffectManagerPhase2(nullptr);
420
421 return SUCCEEDED;
422}
423
426 return NOT_READY;
427 }
428 dReset::Manage_c::GetInstance()->PermitSoftReset(true);
429 return SUCCEEDED;
430}
431
433 myBackGround_Phase.callMethod(this);
434 mResetStateMgr.executeState();
435 if (!mIsResetting) {
436 mStateMgr.executeState();
437 }
438 return SUCCEEDED;
439}
440
442 return SUCCEEDED;
443}
444
445// [Unsure how one could get rid of this pragma...]
446#pragma push
447#pragma pool_data off
448
449void dScBoot_c::initializeState_ResetWait() {
450 mIsResetting = false;
451 mpWiiStrap->mLayout.getAnmGroup(0).setAndUpdate(0.0f);
452}
453
454void dScBoot_c::executeState_ResetWait() {
455 if (dReset::Manage_c::GetInstance()->mSoftResetStateMaybe != 1) {
456 return;
457 }
458 dHbm::Manage_c::GetInstance()->mFlags |= 0x40;
460}
461
462void dScBoot_c::finalizeState_ResetWait() {}
463
464void dScBoot_c::initializeState_ResetFadeOut() {
465 mIsResetting = true;
467 dFader_c::setFader(dFader_c::FADER_FADE);
469 mResetFaderDone = false;
470}
471
472void dScBoot_c::executeState_ResetFadeOut() {
475 return;
476 }
477 if (!mResetFaderDone && dReset::Manage_c::GetInstance()->IsFaderBlank()) {
478 mResetFaderDone = true;
479 }
481 if (mpControllerInformation != nullptr && mpControllerInformation->mIsCreated) {
482 if (dWarningManager_c::m_instance->m_b00 >= 1) {
483 dWarningManager_c::m_instance->AllWarningEnd(false);
484 }
486 // Hide the yes/no window so that it doesn't show up again after reset
487 finalizeState_ResetFadeIn();
488 mStateMgr.changeState(StateID_ProcEnd);
489 dYesNoWindow_c *ynWindow = mpYesNoWindow;
491 ynWindow->mIsActive = false;
492 mpControllerInformation->mVisible = false;
494 } else {
496 }
497 }
498 }
499}
500
501void dScBoot_c::finalizeState_ResetFadeOut() {
502 dReset::Manage_c::GetInstance()->SetSoftResetFinish();
504 mResetFaderDone = false;
505 if (isState(StateID_WiiStrapDispEndWait)) {
506 dWarningManager_c::m_instance->AllWarningEnd(false);
507 mpControllerInformation->mVisible = true;
508 mpWiiStrap->mVisible = false;
510 } else {
511 mpControllerInformation->mVisible = false;
513 }
515 mMinWaitTimer = 0;
516 }
517 mResetFadeOutStarted = false;
518}
519
520void dScBoot_c::initializeState_ResetFadeIn() {
521 dReset::Manage_c::GetInstance()->ActiveSaveWindow(true);
522 dFader_c::setFader(dFader_c::FADER_FADE);
524 mpWiiStrap->mLayout.getAnmGroup(0).setAndUpdate(0.0f);
525}
526
527void dScBoot_c::executeState_ResetFadeIn() {
530 }
531}
532
533void dScBoot_c::finalizeState_ResetFadeIn() {
534 m_isAutoFadeIn = true;
535 dReset::Manage_c::GetInstance()->ActiveSaveWindow(false);
536 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
539 }
542 mMinWaitTimer = 0;
543 } else {
544 mAutoAdvanceTimer = 1200;
545 mMinWaitTimer = 60;
546 }
547 mResetFaderDone = false;
548 mIsResetting = false;
549}
550
551void dScBoot_c::initializeState_FadeOutWait() {}
552
553void dScBoot_c::executeState_FadeOutWait() {
556 }
557}
558
559void dScBoot_c::finalizeState_FadeOutWait() {}
560
561#pragma pop
562
563void dScBoot_c::initializeState_WiiStrapKeyWait() {
564 mAutoAdvanceTimer = 1200;
565 mMinWaitTimer = 60;
566 mpWiiStrap->mLayout.getAnmGroup(0).setAndUpdate(0.0f);
567}
568
569void dScBoot_c::executeState_WiiStrapKeyWait() {
572 if (mMinWaitTimer <= 0) {
574 }
575}
576
577void dScBoot_c::finalizeState_WiiStrapKeyWait() {}
578
579void dScBoot_c::initializeState_WiiStrapDispEndWait() {}
580
581void dScBoot_c::executeState_WiiStrapDispEndWait() {
583 ulong buttons = (
584 WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT | WPAD_BUTTON_DOWN | WPAD_BUTTON_UP |
585 WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_BUTTON_1 | WPAD_BUTTON_2 |
586 WPAD_BUTTON_PLUS | WPAD_BUTTON_MINUS |
587 WPAD_BUTTON_FS_Z | WPAD_BUTTON_FS_C
588 );
591 }
592}
593
594void dScBoot_c::finalizeState_WiiStrapDispEndWait() {}
595
596void dScBoot_c::initializeState_WiiStrapFadeOut() {
598 dFader_c::setFader(dFader_c::FADER_FADE);
600 dHbm::Manage_c::GetInstance()->mFlags |= 0x40;
601 dReset::Manage_c::GetInstance()->ActiveSaveWindow(true);
602}
603
604void dScBoot_c::executeState_WiiStrapFadeOut() {
606 if (mpControllerInformation != nullptr && mpControllerInformation->mIsCreated) {
607 mpWiiStrap->mVisible = false;
609 }
610 }
611}
612
613void dScBoot_c::finalizeState_WiiStrapFadeOut() {
614 dWarningManager_c::m_instance->AllWarningEnd(false);
615}
616
617void dScBoot_c::initializeState_ControllerInformationFadeIn() {
618 dFader_c::setFader(dFader_c::FADER_FADE);
620 mpControllerInformation->mVisible = true;
621}
622
623void dScBoot_c::executeState_ControllerInformationFadeIn() {
626 }
627}
628
629void dScBoot_c::finalizeState_ControllerInformationFadeIn() {
631 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
632 dReset::Manage_c::GetInstance()->ActiveSaveWindow(false);
633 dWarningManager_c::subWarningForbid();
634}
635
636void dScBoot_c::initializeState_ControllerInformationSoundWait() {
637 dHbm::Manage_c::GetInstance()->mFlags &= ~0x08;
638 mAutoAdvanceTimer = 300;
639 mMinWaitTimer = 30;
640}
641
642void dScBoot_c::executeState_ControllerInformationSoundWait() {
643 if (mAutoAdvanceTimer > 0) {
645 }
646 if (mMinWaitTimer > 0) {
648 }
649 if (mSceneSoundLoaded) {
651 }
652}
653
654void dScBoot_c::finalizeState_ControllerInformationSoundWait() {}
655
656void dScBoot_c::initializeState_ControllerInformationKeyWait() {}
657
658void dScBoot_c::executeState_ControllerInformationKeyWait() {
659 if (mAutoAdvanceTimer > 0) {
661 }
663 if (mMinWaitTimer <= 0) {
666 }
667}
668
669void dScBoot_c::finalizeState_ControllerInformationKeyWait() {}
670
671void dScBoot_c::initializeState_ControllerInformationDispEndWait() {}
672
673void dScBoot_c::executeState_ControllerInformationDispEndWait() {
674 if (mAutoAdvanceTimer != 0) {
676 }
677 ulong buttons = (
678 WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT | WPAD_BUTTON_DOWN | WPAD_BUTTON_UP |
679 WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_BUTTON_1 | WPAD_BUTTON_2 |
680 WPAD_BUTTON_PLUS | WPAD_BUTTON_MINUS |
681 WPAD_BUTTON_FS_Z | WPAD_BUTTON_FS_C
682 );
683 if (mPad::g_currentCore->downTrigger(buttons) || dInfo_c::mGameFlag & dInfo_c::GAME_FLAG_AUTO_SKIP) {
686 }
687 if (mAutoAdvanceTimer <= 0) {
689 }
690}
691
692void dScBoot_c::finalizeState_ControllerInformationDispEndWait() {}
693
694void dScBoot_c::initializeState_NandCommandEndWait() {}
695
696void dScBoot_c::executeState_NandCommandEndWait() {
697 if (dNandThread_c::m_instance->mState == 0) {
698 if (!dReset::Manage_c::GetInstance()->isSafetyWait()) {
700 }
701 }
702}
703
704void dScBoot_c::finalizeState_NandCommandEndWait() {}
705
706void dScBoot_c::initializeState_ExistFileCheck() {
707 dHbm::Manage_c::GetInstance()->mFlags |= 0x40;
708 dReset::Manage_c::GetInstance()->ActiveSaveWindow(true);
709 dNandThread_c::m_instance->cmdExistCheck();
710 mNewSaveFileCreated = false;
711}
712
713void dScBoot_c::finalizeState_ExistFileCheck() {}
714
715void dScBoot_c::executeState_ExistFileCheck() {
716 if (dSaveMng_c::m_instance->isNandBusy()) {
717 return;
718 }
719 if (dNandThread_c::m_instance->mError != 0) {
721 } else if (dNandThread_c::m_instance->mFileExists) {
722 mStateMgr.changeState(StateID_Load);
723 } else {
725 }
726}
727
728void dScBoot_c::initializeState_NandSpaceCheck() {
729 dNandThread_c::m_instance->cmdSpaceCheck();
730}
731
732void dScBoot_c::finalizeState_NandSpaceCheck() {}
733
734void dScBoot_c::executeState_NandSpaceCheck() {
735 if (dSaveMng_c::m_instance->isNandBusy()) {
736 return;
737 }
738 if (dNandThread_c::m_instance->mError != 0) {
740 } else {
741 const char *save_icon = "save_icon.bti";
742 const char *save_banner = "save_banner";
743 if (dResMng_c::m_instance->getRes(save_banner, save_icon).IsValid()) {
744 mStateMgr.changeState(StateID_CreateFile);
745 }
746 }
747}
748
749void dScBoot_c::initializeState_CreateFile() {
750 dSaveMng_c *saveMng = dSaveMng_c::m_instance;
751 saveMng->mHeader.initialize();
752 for (int i = 0; i < SAVE_SLOT_COUNT; i++) {
753 saveMng->getSaveGame(i)->initialize();
754 saveMng->getTempGame(i)->initialize();
755 }
756 saveMng->calcCRC();
757 saveMng->startNandSave();
758}
759
760void dScBoot_c::executeState_CreateFile() {
761 if (dSaveMng_c::m_instance->isNandBusy()) {
762 return;
763 }
764 if (dNandThread_c::m_instance->mError == 0) {
765 mNewSaveFileCreated = true;
766 }
769}
770
771void dScBoot_c::finalizeState_CreateFile() {}
772
773void dScBoot_c::initializeState_Load() {
774 dSaveMng_c::m_instance->startNandLoad();
775}
776
777void dScBoot_c::executeState_Load() {
778 if (dSaveMng_c::m_instance->isNandBusy()) {
779 return;
780 }
781 if (dNandThread_c::m_instance->mError != 0) {
783 return;
784 }
785 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
786 dReset::Manage_c::GetInstance()->ActiveSaveWindow(false);
787 mStateMgr.changeState(StateID_ProcEnd);
788}
789
790void dScBoot_c::finalizeState_Load() {}
791
792void dScBoot_c::initializeState_ProcEnd() {}
793
794void dScBoot_c::executeState_ProcEnd() {
796}
797
798void dScBoot_c::finalizeState_ProcEnd() {}
799
800void dScBoot_c::initializeState_NewSaveFileDisp() {
801 mpYesNoWindow->mType = dYesNoWindow_c::SAVE_DATA_CREATED;
802 mpYesNoWindow->mIsActive = true;
803}
804
805void dScBoot_c::executeState_NewSaveFileDisp() {
806 if (!mpYesNoWindow->mIsAnimating) {
808 }
809}
810
811void dScBoot_c::finalizeState_NewSaveFileDisp() {
812 dReset::Manage_c::GetInstance()->ActiveSaveWindow(false);
813}
814
815void dScBoot_c::initializeState_ButtonInputWait() {
817}
818
819void dScBoot_c::executeState_ButtonInputWait() {
820 if (mPad::g_currentCore->downTrigger(WPAD_BUTTON_A | WPAD_BUTTON_2) || dInfo_c::mGameFlag & dInfo_c::GAME_FLAG_AUTO_SKIP) {
821 dReset::Manage_c::GetInstance()->ActiveSaveWindow(true);
823 }
824}
825
826void dScBoot_c::finalizeState_ButtonInputWait() {}
827
828void dScBoot_c::initializeState_WindowExitWait() {
829 mpYesNoWindow->mHitButton = true;
830}
831
832void dScBoot_c::executeState_WindowExitWait() {
833 if (!mpYesNoWindow->mIsAnimating) {
834 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
835 dReset::Manage_c::GetInstance()->ActiveSaveWindow(false);
836 mNewSaveFileCreated = false;
837 mStateMgr.changeState(StateID_ProcEnd);
838 }
839}
840
841void dScBoot_c::finalizeState_WindowExitWait() {}
842
843void dScBoot_c::initializeState_GoToErrorFadeOut() {
845 dFader_c::setFader(dFader_c::FADER_FADE);
847 dReset::Manage_c::GetInstance()->ActiveSaveWindow(true);
848}
849
850void dScBoot_c::executeState_GoToErrorFadeOut() {
852 mpWiiStrap->mVisible = false;
853 mpControllerInformation->mVisible = false;
855 }
856}
857
858void dScBoot_c::finalizeState_GoToErrorFadeOut() {}
859
860void dScBoot_c::initializeState_GoToErrorFadeIn() {
861 dFader_c::setFader(dFader_c::FADER_FADE);
863}
864
865void dScBoot_c::executeState_GoToErrorFadeIn() {
870 } else {
872 dReset::Manage_c::GetInstance()->ActiveSaveWindow(false);
874 }
875 }
876}
877
878void dScBoot_c::finalizeState_GoToErrorFadeIn() {
879 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
880}
881
882void dScBoot_c::initializeState_ErrorWindowOnStageWait() {
883 dWarningManager_c::m_instance->setError(dNandThread_c::m_instance->mError);
884}
885
886void dScBoot_c::executeState_ErrorWindowOnStageWait() {
887 dWarningManager_c *warningMgr = dWarningManager_c::m_instance;
888 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
889 if (warningMgr->mErrorID == 6) {
890 if (!warningMgr->m_b09) {
891 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
893 }
894 } else if (!dWarningManager_c::isWarningInline()) {
895 dHbm::Manage_c::GetInstance()->mFlags &= ~0x40;
897 }
898}
899
900void dScBoot_c::finalizeState_ErrorWindowOnStageWait() {}
901
902void dScBoot_c::initializeState_ErrorInfinityDisp() {}
903
904void dScBoot_c::executeState_ErrorInfinityDisp() {}
905
906void dScBoot_c::finalizeState_ErrorInfinityDisp() {}
Displays the controller information screen.
bool mIsCreated
If the layout has been successfully created.
@ SHOW_IN
Playing the button pop-out animation.
@ END
Playing the button pressed sound effect and the button shrinking animation.
Constructs a new DynamicModuleControl.
Definition d_dylink.hpp:9
static bool startFadeOut(u16 duration)
Starts a fade out with the current fader.
static bool startFadeIn(u16 duration)
Starts a fade in with the current fader.
static dHbm::Manage_c * GetInstance()
Gets a pointer to the instance of this class.
static unsigned int mGameFlag
See GAME_FLAG_e.
Definition d_info.hpp:96
@ GAME_FLAG_AUTO_SKIP
Whether to automatically skip the Wii strap and controller information screens.
Definition d_info.hpp:38
void initialize()
Initializes the slot data.
void initialize()
Initializes the header data.
A higher-level archive resource management class.
Definition d_res_mng.hpp:10
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:71
static dReset::Manage_c * GetInstance()
Gets a pointer to the instance of this class.
This scene handles the game's boot process. It does the following:
Definition d_s_boot.hpp:19
dSelectCursor_c * mpSelectCursor
The select cursor instance.
Definition d_s_boot.hpp:75
virtual int create()
do method for the create operation.
Definition d_s_boot.cpp:376
sFStateMgr_c< dScBoot_c, sStateMethodUsr_FI_c > mResetStateMgr
The state manager for the ResetXXX states.
Definition d_s_boot.hpp:69
virtual void deleteReady()
Informs the base that it's about to be deleted.
Definition d_s_boot.cpp:398
virtual int doDelete()
do method for the delete operation.
Definition d_s_boot.cpp:402
bool mSceneSoundLoaded
Whether the sound (for the button press) has finished loading.
Definition d_s_boot.hpp:82
static sFStateID_c< dScBoot_c > StateID_WiiStrapFadeOut
The Wii strap screen is fading out.
Definition d_s_boot.hpp:49
static sFStateID_c< dScBoot_c > StateID_GoToErrorFadeIn
Fading in the error message.
Definition d_s_boot.hpp:60
static sFStateID_c< dScBoot_c > StateID_ButtonInputWait
Waiting for button input after creating new save data.
Definition d_s_boot.hpp:62
dScBoot_c()
Creates a new scene.
Definition d_s_boot.cpp:364
static sFStateID_c< dScBoot_c > StateID_ResetFadeOut
Fading out the game for the reset.
Definition d_s_boot.hpp:43
static sFStateID_c< dScBoot_c > StateID_ExistFileCheck
Checking for existing save data.
Definition d_s_boot.hpp:55
static sFStateID_c< dScBoot_c > StateID_CreateFile
Creating new save data.
Definition d_s_boot.hpp:57
static sFStateID_c< dScBoot_c > StateID_ControllerInformationSoundWait
Waiting for the scene sound to load.
Definition d_s_boot.hpp:51
dYesNoWindow_c * mpYesNoWindow
The yes/no window instance.
Definition d_s_boot.hpp:74
static sFStateID_c< dScBoot_c > StateID_ResetFadeIn
Fading back in after the reset.
Definition d_s_boot.hpp:44
bool mResetFaderDone
Whether the reset fade-out has completed.
Definition d_s_boot.hpp:80
int mAutoAdvanceTimer
The number of frames after which the scene will automatically advance.
Definition d_s_boot.hpp:88
dControllerInformation_c * mpControllerInformation
The controller information instance.
Definition d_s_boot.hpp:76
static sFStateID_c< dScBoot_c > StateID_FadeOutWait
Waiting for fade out to complete.
Definition d_s_boot.hpp:46
static sFStateID_c< dScBoot_c > StateID_ControllerInformationKeyWait
Forced delay before key press is accepted.
Definition d_s_boot.hpp:52
static sFStateID_c< dScBoot_c > StateID_WiiStrapDispEndWait
Waiting for key press to continue.
Definition d_s_boot.hpp:48
static sFStateID_c< dScBoot_c > StateID_ResetWait
Waiting for a reset event.
Definition d_s_boot.hpp:42
bool mNewSaveFileCreated
Whether new save data was created during boot.
Definition d_s_boot.hpp:79
bool mSaveDataCreatedMessageShown
Whether the "new save data created" message has been shown.
Definition d_s_boot.hpp:87
static sFStateID_c< dScBoot_c > StateID_GoToErrorFadeOut
Fading out to show an error message.
Definition d_s_boot.hpp:59
static sFStateID_c< dScBoot_c > StateID_ErrorInfinityDisp
Showing an irrecoverable error message.
Definition d_s_boot.hpp:66
dWiiStrap_c * mpWiiStrap
The Wii strap screen instance.
Definition d_s_boot.hpp:73
virtual int preExecute()
pre method for the execute operation.
Definition d_s_boot.cpp:424
int mMinWaitTimer
The minimum number of frames to wait before a button may be pressed to advance the scene.
Definition d_s_boot.hpp:89
virtual int draw()
do method for the draw operation.
Definition d_s_boot.cpp:441
virtual ~dScBoot_c()
Destroys the scene.
Definition d_s_boot.cpp:372
static sFStateID_c< dScBoot_c > StateID_ErrorWindowOnStageWait
Showing an error message.
Definition d_s_boot.hpp:65
static sFStateID_c< dScBoot_c > StateID_Load
Loading existing save data.
Definition d_s_boot.hpp:58
bool mResetFadeOutStarted
Whether the reset fade-out has started.
Definition d_s_boot.hpp:86
static sFStateID_c< dScBoot_c > StateID_NandSpaceCheck
Checking for sufficient NAND space for the save data.
Definition d_s_boot.hpp:56
virtual int execute()
do method for the execute operation.
Definition d_s_boot.cpp:432
static sFStateID_c< dScBoot_c > StateID_NewSaveFileDisp
Animating in the "new save data created" message.
Definition d_s_boot.hpp:61
static sFStateID_c< dScBoot_c > StateID_WiiStrapKeyWait
Forced delay before key press is accepted.
Definition d_s_boot.hpp:47
static sFStateID_c< dScBoot_c > StateID_ControllerInformationFadeIn
The controller information screen is fading in.
Definition d_s_boot.hpp:50
static dScBoot_c * m_instance
The singleton instance of the boot scene.
Definition d_s_boot.hpp:92
sFStateMgr_c< dScBoot_c, sStateMethodUsr_FI_c > mStateMgr
The main state manager for the boot scene.
Definition d_s_boot.hpp:68
bool mIsResetting
Whether the game is currently resetting.
Definition d_s_boot.hpp:84
static sFStateID_c< dScBoot_c > StateID_ControllerInformationDispEndWait
Waiting for key press to continue.
Definition d_s_boot.hpp:53
static sFStateID_c< dScBoot_c > StateID_ProcEnd
Going to the title screen.
Definition d_s_boot.hpp:64
static sFStateID_c< dScBoot_c > StateID_WindowExitWait
Waiting for the "save data created" window to close.
Definition d_s_boot.hpp:63
static sFStateID_c< dScBoot_c > StateID_NandCommandEndWait
Waiting for the system to be ready for a NAND command.
Definition d_s_boot.hpp:54
static void startTitle(u8 isReplay, bool forceChange)
Starts the title screen stage or a title replay.
virtual int preExecute()
pre method for the execute operation.
Definition d_scene.cpp:77
static void setFadeInFrame(unsigned short length)
Sets the duration of the next fade-in transition to length.
Definition d_scene.cpp:184
static void setFadeOutFrame(unsigned short length)
Sets the duration of the next fade-out transition to length.
Definition d_scene.cpp:188
static bool m_isAutoFadeIn
If a fade-in should automatically be performed on scene load.
Definition d_scene.hpp:62
sPhase_c * mpPhase
The phase used for scene initialization.
Definition d_scene.hpp:52
Manages the animated L-shaped corner rectangles around selected buttons.
void Cancel(int layoutId)
Deactivates and hides the specified cursor layout.
bool mHasLoadedLayout
Whether the layout has been loaded.
static dSelectCursor_c * m_instance
The static instance of the selection cursor manager.
Displays the Wii Strap safety warning screen.
LytBase_c mLayout
The layout for the screen.
bool mHasLoadedLayout
Whether the layout has been loaded.
static dWipeCircle_c * m_instance
The instance of the fader.
static dWipeDokan_c * m_instance
The instance of the fader.
static dWipeKuppa_c * m_instance
The instance of the fader.
static dWipeMario_c * m_instance
The instance of the fader.
Displays a confirmation prompt.
bool mIsActive
Whether the window is currently open.
bool mHasLoadedLayout
Whether the layout has been loaded.
static fBase_c * createChild(ProfileName profName, fBase_c *parent, unsigned long param, u8 groupType)
Creates a child base under the given parent.
Definition f_base.cpp:511
@ NOT_READY
The step could not completed at this time.
Definition f_base.hpp:45
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:46
@ HIDDEN
The screen is completely unblocked.
@ OPAQUE
The screen is completely blacked out.
static bool isStatus(mFaderBase_c::EStatus status)
Checks if the current fader's status matches status .
Definition m_fader.hpp:12
A phase is a list of methods to be called in order.
Definition s_Phase.hpp:5
METHOD_RESULT_e
Return value of a phase method and callMethod().
Definition s_Phase.hpp:9
@ OK
Proceed to the next method in the phase.
Definition s_Phase.hpp:11
@ WAIT
Do not proceed to the next method in the phase.
Definition s_Phase.hpp:10
@ DONE
The phase is done.
Definition s_Phase.hpp:12
void FUN_8006a6a0(bool)
#define SAVE_SLOT_COUNT
The total save slot count.
#define BASE_PROFILE(profName, className)
Creates a basic profile, using the profile number as the execute and draw order value.
Definition f_profile.hpp:23
@ CONTROLLER_INFORMATION
The profile for dControllerInformation_c.
@ YES_NO_WINDOW
The profile for dYesNoWindow_c.
void draw()
Draws all registered 2D objects.
Definition d_2d.cpp:13
int LinkASync(ProfileName profile)
Links the module associated with the given profile.
Definition d_dylink.cpp:73
bool Unlink(ProfileName profile)
Unlinks the module associated with the given profile.
Definition d_dylink.cpp:62
void initRandomSeed()
Initializes the random seed used for randomness.
#define STATE_DEFINE(class, name)
Defines a state.
Definition s_State.hpp:36