Sly 1:GS: Difference between revisions

From SlyMods
Jump to navigation Jump to search
Content added Content deleted
(Fix format and typos)
(Added more stuff)
Line 4: Line 4:


== Structure ==
== Structure ==
The GS struct is declared as follows:
The GS struct is declared as follows:<syntaxhighlight lang="c++">
struct GS {
int gsv;
int cbThis; /* Size of this struct in bytes */
int nChecksum; /* Checksum is the size of the savedata */
float dt; /* Time spent in save file (secs) */
struct WS aws[6]; /* Saves for each world */
enum GAMEWORLD gameworldCur; /* Current gameworld */
enum WORLDLEVEL worldlevelCur; /* Current worldlevel */
int clife; /* Lives count */
int ccharm; /* Charms count */
int ccoin; /* Coins count */
GRFGS grfgs; /* Settings flags? */
GRFVAULT grfvault; /* Powerup flags */
uint unlocked_cutscenes; /* Cutscene flags */
enum FGS fgs; /* Game state flags */
int last_powerup; /* Last selected powerup */
};


</syntaxhighlight>
{{todo|Add the C++ struct declaration}}


== Game State Flags ==
== World states array ==
The current game state is represented by the FGS enum, which has the following possible values:

{{todo|Add the FLS enum values}}

== World States ==
{{main|WS}}
{{main|WS}}


The GS struct stores an array of 5 WS structs, one for each world. The order is as follows:
<code>aws</code> is an array of 5 <code>WS</code> structs, one for each world. In the release build, the order is as follows:
* 0: Intro
* 0: Intro
* 1: Underwater
* 1: Underwater
Line 25: Line 37:


== Unlockable flags ==
== Unlockable flags ==
{{todo|Add the meaning corresponding to each bit/enum value}}
{{todo|Add tables showing the value of each bit}}


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


=== Powerup flags ===
=== 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.
There are 16 bits for the [[Powerups|powerup]] flags, with each bit corresponding to a particular powerup being unlocked.


=== Cutscene flags ===
=== Powerup flags (GRFVAULT) ===
There are 16 bits for the cutscene flags, with each bit corresponding to a particular cutscene being unlocked.
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.


=== GRFGS ===
=== 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 is a set of flags defined by the GRFGS enum whose purpose is unclear. At least some of the bits appear to be used for game settings.


== Game state flags ==
The current game state is represented by the <code>FGS</code> enum, which has the following possible values:
{| class="wikitable"
|FGS_FirstClue
|0x1
|-
|FGS_HalfClues
|0x2
|-
|FGS_AllClues
|0x4
|-
|FGS_FirstVault
|0x8
|-
|FGS_SecondVault
|0x10
|}
[[Category:Game mechanics]]
[[Category:Game mechanics]]
[[Category:Game mechanics in Sly 1]]
[[Category:Game mechanics in Sly 1]]

Revision as of 04:35, 12 July 2022

GS (Game State) is a data structure in Sly 1. It stores an array of World States, which in turn each store an array of Level States.

Structure

The GS struct is declared as follows:

struct GS {
    int gsv;
    int cbThis; /* Size of this struct in bytes */
    int nChecksum; /* Checksum is the size of the savedata */
    float dt; /* Time spent in save file (secs) */
    struct WS aws[6]; /* Saves for each world */
    enum GAMEWORLD gameworldCur; /* Current gameworld */
    enum WORLDLEVEL worldlevelCur; /* Current worldlevel */
    int clife; /* Lives count */
    int ccharm; /* Charms count */
    int ccoin; /* Coins count */
    GRFGS grfgs; /* Settings flags? */
    GRFVAULT grfvault; /* Powerup flags */
    uint unlocked_cutscenes; /* Cutscene flags */
    enum FGS fgs; /* Game state flags */
    int last_powerup; /* Last selected powerup */
};

World states array

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

  • 0: Intro
  • 1: Underwater
  • 2: Mesa
  • 3: Voodoo
  • 4: Snow
  • 5: Clockwerk

Unlockable flags

There are three[check] sets of flags after the world states.

Settings flags (GRFGS)

There is a set of flags of type GRFGS whose purpose is unclear. At least some of the bits appear to be used for game settings. GRFGS is an alias of int and occupies 4 bytes, or 32 bits.

Powerup flags (GRFVAULT)

There is a set of flags of type GRFVAULT for the unlocked powerups, with each bit corresponding to a particular powerup being unlocked. GRFVAULT is an alias of int and occupies 4 bytes, or 32 bits.

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

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

FGS_FirstClue 0x1
FGS_HalfClues 0x2
FGS_AllClues 0x4
FGS_FirstVault 0x8
FGS_SecondVault 0x10