Sly 1:GS: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
(Changed hatnote, added links)
(Fix field types)
 
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
{{Distinguish|Graphics Synthesizer}}
{{Distinguish|Graphics Synthesizer}}


'''GS''' ('''G'''ame '''S'''tate) is a data structure in {{Sly 1}}. It stores information about the current save file, including an array of [[WS|World States]] which in turn each store an array of [[LS|Level States]].
'''GS''' (game state) is a data structure in {{Sly 1}}. It contains information about the current state of the game world, including an array of {{Sly 1|WS|world states}} which, in turn, each contain an array of {{Sly 1|LS|level states}}.


== Structure ==
== Fields ==

The GS struct is declared as follows:<syntaxhighlight lang="c++">
The GS struct has the following fields

{{Struct top}}
{{Struct field|0x0|0x4|int|gsv|'''Unknown'''}}
{{Struct field|0x4|0x4|int|cbThis|Size of this struct in bytes}}
{{Struct field|0x8|0x4|int|nChecksum|Unknown, possibly compared against <tt>cbThis</tt> for integrity check}}
{{Struct field|0xc|0x4|float|dt|Total time spent in game (secs)}}
{{Struct field|0x10|0x19c8|struct WS[6]|aws|Array of {{Sly 1|WS|world states}}}}
{{Struct field|0x19d8|0x4|enum GAMEWORLD|gameworldCur|Current gameworld}}
{{Struct field|0x19dc|0x4|enum WORLDLEVEL|worldlevelCur|Current worldlevel}}
{{Struct field|0x19e0|0x4|int|clife|Lives count}}
{{Struct field|0x19e4|0x4|int|ccharm|Charm count}}
{{Struct field|0x19e8|0x4|int|ccoin|Coin count}}
{{Struct field|0c19ec|0x4|int|grfgs|'''Unknown bitfield''', possibly settings flags}}
{{Struct field|0x19f0|0x4|int|grfvault|Bitfield of unlocked powerups}}
{{Struct field|0x19f4|0x4|int|grfmovie|Unofficial name, probably called something else internally}}
{{Struct field|0x19f8|0x4|enum FGS|fgs|Game state flags}}
{{Struct field|0x19fc|0x4|int|last powerup?|Unofficial name, may be wrong}}
{{Struct bottom}}

<!--<syntaxhighlight lang="c++">
struct GS {
struct GS {
int gsv;
int gsv;
Line 27: Line 48:
int last_powerup; /* Last selected powerup (name is not official) */
int last_powerup; /* Last selected powerup (name is not official) */
};
};
</syntaxhighlight>-->


<code>GRFGS</code> and <code>GRFVAULT</code> are aliases of <code>int</code>.
</syntaxhighlight>


== World states array ==
== World states array ==
Line 41: Line 63:
* 5: {{Sly 1|The Cold Heart of Hate|Clockwerk}}
* 5: {{Sly 1|The Cold Heart of Hate|Clockwerk}}


== Unlockable flags ==
== Bitfields ==
{{todo|Add tables showing the value of each bit}}
{{todo|Add tables showing the value of each bit}}


There are three{{check}} sets of flags after the world states.
There are three sets of bitfields/flags after the world states.


=== Settings flags (GRFGS) ===
=== Settings flags (GRFGS) ===
There is a set of flags of type <code>GRFGS</code> whose purpose is unclear. At least some of the bits appear to be used for game settings. <code>GRFGS</code> is an alias of <code>int</code> and occupies 4 bytes, or 32 bits.
The purpose of <code>grfgs</code> is unclear. At least some of the bits appear to be used for game settings.


=== Powerup flags (GRFVAULT) ===
=== Powerup flags (GRFVAULT) ===
There is a set of flags of type <code>GRFVAULT</code> for the unlocked [[powerups]], with each bit corresponding to a particular powerup being unlocked. <code>GRFVAULT</code> is an alias of <code>int</code> and occupies 4 bytes, or 32 bits.
<code>grfvault</code> is a bitfield representing unlocked [[powerups]]. Each bit corresponding to a particular powerup being unlocked.
<!--
{| class="wikitable mw-collapsible mw-collapsed"
|+ GRFGS bitfield
|-
! Bit !! Usage
|-
| 0 || Example
|-
| 1 || Example
|-
| 2 || Example
|-
| 3 || Example
|-
| 4 || Example
|-
| 5 || Example
|-
| 6 || Example
|-
| 7 || Example
|-
| 8 || Example
|-
| 9 || Example
|-
| 10 || Example
|-
| 11 || Example
|-
| 12 || Example
|-
| 13 || Example
|-
| 14 || Example
|-
| 15 || Example
|-
| 16 || Example
|-
| 17 || Example
|-
| 18 || Example
|-
| 19 || Example
|-
| 20 || Example
|-
| 21 || Example
|-
| 22|| Example
|-
| 23 || Example
|-
| 24|| Example
|-
| 25 || Example
|-
| 26 || Example
|-
| 27 || Example
|-
| 28 || Example
|-
| 29 || Example
|-
| 30 || Example
|-
| 31 || Example
|}
-->


=== Cutscene flags ===
=== Cutscene flags ===
There are 16 bits for the cutscene flags, with each bit corresponding to a particular cutscene being unlocked. It is probably also stored as a typedef alias of <code>int</code> but the type is currently unknown.
There are 16 bits for the cutscene flags, with each bit corresponding to a particular cutscene being unlocked. It is probably also stored as a typedef alias of <code>int</code> but the type is currently unknown.
<!--

{| class="wikitable mw-collapsible mw-collapsed"
== Game state flags ==
|+ GRFGS bitfield
The current game state is represented by the <code>FGS</code> enum, which has the following possible values:
{| class="wikitable"
! Name
! Value
|-
|-
! Bit !! Usage
|FGS::FirstClue
|0x1
|-
|-
| 0 || Example
|FGS::HalfClues
|0x2
|-
|-
| 1 || Example
|FGS::AllClues
|0x4
|-
|-
| 2 || Example
|FGS::FirstVault
|0x8
|-
|-
| 3 || Example
|FGS::SecondVault
|-
|0x10
| 4 || Example
|-
| 5 || Example
|-
| 6 || Example
|-
| 7 || Example
|-
| 8 || Example
|-
| 9 || Example
|-
| 10 || Example
|-
| 11 || Example
|-
| 12 || Example
|-
| 13 || Example
|-
| 14 || Example
|-
| 15 || Example
|}
|}
-->

== Game state flags (FGS)==
The current game state is represented by the <code>FGS</code> enum, which has the following possible values:
{{Enum top}}
{{Enum value|FGS_FirstClue|0x1}}
{{Enum value|FGS_HalfClues|0x2}}
{{Enum value|FGS_AllClues|0x4}}
{{Enum value|FGS_FirstVault|0x8}}
{{Enum value|FGS_SecondVault|0x10}}
{{Enum bottom}}


{{Navbox Sly 1}}
{{Navbox Sly 1}}

Latest revision as of 03:39, 26 September 2023

GS
Data Structure
GameSly Cooper and the Thievius Raccoonus
Official NameYes

GS (game state) is a data structure in Sly Cooper and the Thievius Raccoonus. It contains information about the current state of the game world, including an array of world states which, in turn, each contain an array of level states.

Fields

The GS struct has the following fields

Offset Size Type Name Notes
0x0 0x4
int
gsv Unknown
0x4 0x4
int
cbThis Size of this struct in bytes
0x8 0x4
int
nChecksum Unknown, possibly compared against cbThis for integrity check
0xc 0x4
float
dt Total time spent in game (secs)
0x10 0x19c8
struct WS[6]
aws Array of world states
0x19d8 0x4
enum GAMEWORLD
gameworldCur Current gameworld
0x19dc 0x4
enum WORLDLEVEL
worldlevelCur Current worldlevel
0x19e0 0x4
int
clife Lives count
0x19e4 0x4
int
ccharm Charm count
0x19e8 0x4
int
ccoin Coin count
0c19ec 0x4
int
grfgs Unknown bitfield, possibly settings flags
0x19f0 0x4
int
grfvault Bitfield of unlocked powerups
0x19f4 0x4
int
grfmovie Unofficial name, probably called something else internally
0x19f8 0x4
enum FGS
fgs Game state flags
0x19fc 0x4
int
last powerup? Unofficial name, may be wrong


GRFGS and GRFVAULT are aliases of int.

World states array

aws is an array of 5 WS structs, one for each world. In the release build, the order is as follows:

Bitfields

There are three sets of bitfields/flags after the world states.

Settings flags (GRFGS)

The purpose of grfgs is unclear. At least some of the bits appear to be used for game settings.

Powerup flags (GRFVAULT)

grfvault is a bitfield representing unlocked powerups. Each bit corresponding to a particular powerup being unlocked.

Cutscene flags

There are 16 bits for the cutscene flags, with each bit corresponding to a particular cutscene being unlocked. It is probably also stored as a typedef alias of int but the type is currently unknown.

Game state flags (FGS)

The current game state is represented by the FGS enum, which has the following possible values:

Name Value Description
FGS_FirstClue 0x1
FGS_HalfClues 0x2
FGS_AllClues 0x4
FGS_FirstVault 0x8
FGS_SecondVault 0x10