Scheduled system upgrade on Sunday 21 April 2024 15:00-16:00 UTC - On that day, the wiki and other services might go down for 5-15 minutes.

GameScene: Difference between revisions

From ZeldaMods (Breath of the Wild)
Jump to navigation Jump to search
imported>Leoetlino
imported>Leoetlino
No edit summary
Line 167: Line 167:
=== postcalc ===
=== postcalc ===
{{empty section}}
{{empty section}}
== Stage generation ==
* Terrain::sInstance->flags |= 0x180u
* Step 0
** Reload Title.pack if the stage that needs to be generated is TitleStage (3)<ref>0x71007AC8A0</ref>.
** StageSelect checks<ref>0x71007AD3AC</ref>
* Step 1
** If a pack was loaded by DungeonPackMgr, wait for DungeonPack loading to finish<ref>DungeonPack読み込み待ち</ref> and switch active pack to the [[dungeon pack]].
* Step 2
** If the stage to load is TitleStage, wait for TitlePack loading to finish<ref>TitlePack読み込み待ち</ref> and switch active pack to the title pack.
* Step 3: start stage generation<ref>ステージ生成開始</ref>
**PlacementMgr
**ActorSystem::sInstance->field_13A = 0
**Update current map flags (e.g. sIsDungeon)
**Clear BaseProcMgr ActorCreate queue{{check}}
**Create uking::Stage::ForBaseProcDual heap (if not already done), which will be used for actors, ActorCreator and BaseProcMgr
**ActorSystem::sInstance->field_139 = 0
**If the [[#State strings|state string]] starts with 初回シーケンス, MainField, GameTestField, GameTestField2, AocField, CDungeon, MainFieldDungeonStage, GameTestDungeon, MonolithTestDungeon, SrdTestDungeon, MarioClubTestDungeon, TestField, 研修用, MonolithTest100enemy, MinimumField, or ActorViewer, call GameScene::startBgProcessing (0x71007B2054)
**If "new save" was selected, initialize PauseMenuDataMgr data
**If the stage to load is TitleStage, load Layout/Title.blarc for ui::LayoutResourceMgr.
**If "new save" was selected and the awakening demo hasn't been played since the game was launched<ref>0x71007ADB3C</ref>, ask [[EventMgr]] to call Demo169_0.
** Some PhysicsMemSys stuff (0x71007ADBE0).
* Step 4
** Wait for completion of Title BG processing '''(20% of the loading bar)'''
** uiManager (0x71007ACD04)
** Initialize StatisticsMgr paths depending on current map type.
** Update aoc2's mapType and mapName fields.
* Step 5
** PhysicsMemSys stuff (0x71007ACDB8, 0x71007ACDC0, 0x71007ACDD0)
** BaseProcMgr: request "PreDelete" actors<ref>0x71007ACDE4</ref>
** BaseProcMgr: stop ActorCreate initializer thread and clean up internal state{{check}}
** agl::lyr::Renderer and Graphics stuff
* Step 6
** Load [[env.genvb]] binary (gsys::ModelSceneEnv::clearImpl + loadBinaryImpl)
** If the stage binder type is 0, 1 or 2 (OpenWorldStage, IndoorStage or MainFieldDungeonStage):
***'''Set loading progress to 40%.'''
***Graphics stuff, again
***OnUiActorMgr
***GameScene::loadTera (on a separate thread)
* Step 7
** If the stage binder type is 0, 1 or 2 (OpenWorldStage, IndoorStage or MainFieldDungeonStage):
***Wait for Tera to load<ref>tera読み込み待ち</ref>
* Step 8
**...
**Wait for Tera to generate collision
**...
* Step 9
* Step 10
* Step 11
* Step 12
* Step 13


<hr>
<hr>

Revision as of 10:41, 24 October 2018

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

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.

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
MainField
GameTestField
GameTestField2
AocField
GameTestDungeon
MonolithTestDungeon
SrdTestDungeon
MarioClubTestDungeon
TestField
研修用
MonolithTest100enemy
MinimumField
ActorViewer

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

Stage generation

  • Terrain::sInstance->flags |= 0x180u
  • Step 0
    • Reload Title.pack if the stage that needs to be generated is TitleStage (3)[5].
    • StageSelect checks[6]
  • Step 1
    • If a pack was loaded by DungeonPackMgr, wait for DungeonPack loading to finish[7] and switch active pack to the dungeon pack.
  • Step 2
    • If the stage to load is TitleStage, wait for TitlePack loading to finish[8] and switch active pack to the title pack.
  • Step 3: start stage generation[9]
    • PlacementMgr
    • ActorSystem::sInstance->field_13A = 0
    • Update current map flags (e.g. sIsDungeon)
    • Clear BaseProcMgr ActorCreate queue[check]
    • Create uking::Stage::ForBaseProcDual heap (if not already done), which will be used for actors, ActorCreator and BaseProcMgr
    • ActorSystem::sInstance->field_139 = 0
    • If the state string starts with 初回シーケンス, MainField, GameTestField, GameTestField2, AocField, CDungeon, MainFieldDungeonStage, GameTestDungeon, MonolithTestDungeon, SrdTestDungeon, MarioClubTestDungeon, TestField, 研修用, MonolithTest100enemy, MinimumField, or ActorViewer, call GameScene::startBgProcessing (0x71007B2054)
    • If "new save" was selected, initialize PauseMenuDataMgr data
    • If the stage to load is TitleStage, load Layout/Title.blarc for ui::LayoutResourceMgr.
    • If "new save" was selected and the awakening demo hasn't been played since the game was launched[10], ask EventMgr to call Demo169_0.
    • Some PhysicsMemSys stuff (0x71007ADBE0).
  • Step 4
    • Wait for completion of Title BG processing (20% of the loading bar)
    • uiManager (0x71007ACD04)
    • Initialize StatisticsMgr paths depending on current map type.
    • Update aoc2's mapType and mapName fields.
  • Step 5
    • PhysicsMemSys stuff (0x71007ACDB8, 0x71007ACDC0, 0x71007ACDD0)
    • BaseProcMgr: request "PreDelete" actors[11]
    • BaseProcMgr: stop ActorCreate initializer thread and clean up internal state[check]
    • agl::lyr::Renderer and Graphics stuff
  • Step 6
    • Load env.genvb binary (gsys::ModelSceneEnv::clearImpl + loadBinaryImpl)
    • If the stage binder type is 0, 1 or 2 (OpenWorldStage, IndoorStage or MainFieldDungeonStage):
      • Set loading progress to 40%.
      • Graphics stuff, again
      • OnUiActorMgr
      • GameScene::loadTera (on a separate thread)
  • Step 7
    • If the stage binder type is 0, 1 or 2 (OpenWorldStage, IndoorStage or MainFieldDungeonStage):
      • Wait for Tera to load[12]
  • Step 8
    • ...
    • Wait for Tera to generate collision
    • ...
  • Step 9
  • Step 10
  • Step 11
  • Step 12
  • Step 13

  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
  5. 0x71007AC8A0
  6. 0x71007AD3AC
  7. DungeonPack読み込み待ち
  8. TitlePack読み込み待ち
  9. ステージ生成開始
  10. 0x71007ADB3C
  11. 0x71007ACDE4
  12. tera読み込み待ち