GameScene

Revision as of 15:20, 20 October 2018 by imported>Leoetlino (→‎StageTransition)

GameScene is a critical subsystem that is responsible for core functionality such as initialising other components, creating stages (world, title screen, etc.) and handling the game's main loop.

GameScene
Subsystem
Official name Yes
Description Handles the main loop and stages
Init function Switch 1.5.0: 0x71007D1DD8
Wii U 1.5.0: ???
Debug only No

Unlike most other subsystems, GameScene is not a singleton: it is a member of the uking::frm::System structure[1].

Init

Initial state

The initial state the game launches into is determined by GameScene[2].

const bool isFirstLaunch = SaveSystem::sInstance->isFirstLaunch();
State* state = isFirstLaunch ? &state_NewSave : &state_LunchTitle;

if ( aocManager::sInstance && aocManager::sInstance->flags & 2 )
  nn::err::ShowUnacceptableAddOnContentVersionError();

const bool isDemo = E3Mgr::sInstance && E3Mgr::sInstance->isDemoMode();
if (isDemo)
  state = &state_LunchTitle;

if (!isDemo && isFirstLaunch)
  sIsFirstNonDemoLaunch = 1;

StateMachine::changeState(&this->stateMachine, state);

State strings

List of state strings in 1.5.0 (incomplete)[3]
Name Description
1st Demo mode [check]
2nd Demo mode
初回シーケンス Initial sequence - New save
TitleMenu Title menu
Presentation Demo mode
E3_2016/Presentation Demo mode
StartupSaveCheckStage
Viewer
CDungeon
MainFieldDungeonStage

States

Note: when the Indoor stage binder is initialised and if the map name changes, a "dungeon" telemetry report is emitted with "leave" or "enter" as the event name and the old/new map name as additional data[4].

StageMgr

StageSelect

StageTransition

Entered before stage generation starts and after Fade (loading screen) has been initialised and made visible. This state machine state is a noop.

LunchTitle

LunchTitle (sic) is entered when the game is launched. The internal state string is "TitleMenu" or (in demo mode) "2nd".

NewSave

Entered on the first boot or when the new game option is selected. The associated state string is "初回シーケンス" ("initial sequence").

PatchError

Main loop

Three GameScene functions are called in a row from RootTask (see Executable) after initialisation has completed, i.e. in the game's main loop. (Note: these 3 names are unofficial.)

precalc

calc

postcalc


  1. uking::frm::System::gameScene @ 0x10 (Switch)
  2. GameScene::initialize, 0x71007A86CC
  3. The state string is a sead::FixedSafeString<0x100> stored in GameScene @ 0x720.
  4. StageBinder::initAndReportDungeonLeaveEnter[unofficial name] at 0x71007B79A8