Sly 1:Game state: Difference between revisions
TheOnlyZac (talk | contribs) (Created Sly 1 subsystem article) |
TheOnlyZac (talk | contribs) (Removed stub tag) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{Infobox subsystem |
{{Infobox subsystem |
||
| description= Manages the current state of the game world |
|||
⚫ | |||
| startup= 0x160070 |
|||
| update= 1607d0 |
|||
}} |
}} |
||
Game state is the subsystem that |
'''Game state''' is the subsystem that manages the current state of the game world. It manages a global instance of the {{Sly 1|GS}} struct, which keeps track of things such as the quantity of keys, coins, and charms collected; unlocked powerups; which cutscenes have been watched; and more. |
||
== |
==Startup== |
||
The startup function, <code>StartupGame</code>, only calls <code>StartGame</code>. |
|||
=== StartGame === |
|||
<code>StartGame</code> calls <code>UnloadGame</code> followed by <code>WipeToWorldWarp</code>. |
|||
==== UnloadGame ==== |
|||
<code>UnloadGame</code> is called during startup and during a level transition if the ClearGame transition flag is set. It calls <code>InitGameState</code>, <code>OnDifficultyGameLoad</code>, and <code>RetryGame</code>. It also disables cheat codes by setting <code>g_grfcht</code> to <code>GRFCHT::None</code> and it sets the stored value for the previous level ID to <tt>-1</tt>. |
|||
===== InitGameState ===== |
|||
The <code>InitGameState</code> function at 1605e8 resets fields on the global <code>g_gs</code> instance to their defaults. Specifically, it sets the following values: |
|||
{| class="wikitable" |
{| class="wikitable" |
||
⚫ | |||
|+ Caption text |
|||
!Field |
|||
!Value |
|||
|- |
|- |
||
|gameworldCur |
|||
⚫ | |||
|GAMEWORLD::Intro |
|||
|- |
|- |
||
|grfvault |
|||
| g_pgsCur || GS* || 0x2623c0 |
|||
|0 |
|||
|- |
|- |
||
|gsv |
|||
| g_pwsCur || WS* || 0x2623c4 |
|||
|0x12 |
|||
|- |
|- |
||
|cbThis |
|||
| g_plsCur || LS* || 0x2623c8 |
|||
|0x1a00 |
|||
|- |
|||
|worldlevelCur |
|||
|WORLDLEVEL_2 |
|||
|- |
|||
|clife |
|||
|5 |
|||
|- |
|||
|last_powerup |
|||
| -1 |
|||
|} |
|} |
||
It then calls a function which resets the game settings to their defaults. |
|||
==Update== |
|||
The update function, <code>UpdateGameState</code>, takes the current frame's <code>dt</code> as input and updates the play times on the global <code>g_gs</code> instance. Specifically, it adds the <code>dt</code> value to the current game play time (<code>g_pgsCur->dt</code>), the current world play time (<code>g_wsCur->dt</code>), and the current level play time (<code>g_lsCur->dt</code>). It does not call any other functions. |
|||
==Global values== |
|||
{| class="wikitable" |
|||
⚫ | |||
|- |
|||
|g_pgsCur||GS*||0x2623c0||Pointer to current game state |
|||
|- |
|||
|g_pwsCur||WS*||0x2623c4||Pointer to current world state |
|||
|- |
|||
|g_plsCur||LS*||0x2623c8||Pointer to current level state |
|||
|} |
|||
== See also == |
|||
* [[Sly 1:GS]] |
|||
* [[Sly 1:WS]] |
|||
* [[Sly 1:LS]] |
|||
{{Navbox Sly 1}} |
{{Navbox Sly 1}} |
||
{{stub}} |
Latest revision as of 23:06, 23 November 2022
Subsystem | |
---|---|
![]() | |
Description | Manages the current state of the game world |
Game | Sly Cooper and the Thievius Raccoonus |
Startup Function | 0x160070 |
Update Function | 1607d0 |
Game state is the subsystem that manages the current state of the game world. It manages a global instance of the GS struct, which keeps track of things such as the quantity of keys, coins, and charms collected; unlocked powerups; which cutscenes have been watched; and more.
Startup
The startup function, StartupGame
, only calls StartGame
.
StartGame
StartGame
calls UnloadGame
followed by WipeToWorldWarp
.
UnloadGame
UnloadGame
is called during startup and during a level transition if the ClearGame transition flag is set. It calls InitGameState
, OnDifficultyGameLoad
, and RetryGame
. It also disables cheat codes by setting g_grfcht
to GRFCHT::None
and it sets the stored value for the previous level ID to -1.
InitGameState
The InitGameState
function at 1605e8 resets fields on the global g_gs
instance to their defaults. Specifically, it sets the following values:
Field | Value |
---|---|
gameworldCur | GAMEWORLD::Intro |
grfvault | 0 |
gsv | 0x12 |
cbThis | 0x1a00 |
worldlevelCur | WORLDLEVEL_2 |
clife | 5 |
last_powerup | -1 |
It then calls a function which resets the game settings to their defaults.
Update
The update function, UpdateGameState
, takes the current frame's dt
as input and updates the play times on the global g_gs
instance. Specifically, it adds the dt
value to the current game play time (g_pgsCur->dt
), the current world play time (g_wsCur->dt
), and the current level play time (g_lsCur->dt
). It does not call any other functions.
Global values
Address | Type | Name | Description |
---|---|---|---|
g_pgsCur | GS* | 0x2623c0 | Pointer to current game state |
g_pwsCur | WS* | 0x2623c4 | Pointer to current world state |
g_plsCur | LS* | 0x2623c8 | Pointer to current level state |