Index  •  2DA  •  Effects  •  File Formats  •  Actions  •  Identifiers  •  Triggers  •  Appendices  •  Site Info  •  Legal

GAM file format

Applies to:
BG2, BG2: ToB

General Description
This file format is used to hold game information in save games. The GAM file does not store area, creature or item information, instead, it stores information on the party members and the global variables which affect party members.

Detailed Description


Offset Size (datatype) Description
0x0000 4 (char array) Signature ('GAME')
0x0004 4 (char array) Version ('V2.0')
0x0008 4 (dword) Game time (300 units == 1 hour)
0x000c 2 (word) Selected formation
0x000e 2 (word) Formation button 1
0x0010 2 (word) Formation button 2
0x0012 2 (word) Formation button 3
0x0014 2 (word) Formation button 4
0x0016 2 (word) Formation button 5
0x0018 4 (dword) Party gold
0x001c 2 (dword) Count of NPC structs for party members (excluding Protagonist)
0x001e 2 (word) Weather bitfield
  • bit0: Rain
  • bit1: Snow
Higher bits determine the density and intensity of the weather
0x0020 4 (dword) Offset to NPC structs for party members
0x0024 4 (dword) Count of NPC structs for party members (including Protagonist)
0x0028 4 (dword)
Unknown
0x002c 4 (dword)
Unknown
0x0030 4 (dword) Offset to NPC structs for non-party members
0x0034 4 (dword) Count of NPC structs for non-party members
0x0038 4 (dword) Offset to GLOBAL namespace variables
0x003c 4 (dword) Count of GLOBAL namespace variables
0x0040 8 (resref) Main area
0x0048 4 (dword) Unknown
0x004c 4 (dword) Count of journal entries
0x0050 4 (dword) Offset to journal entries
0x0054 4 (dword) Party reputation (*10)
0x0058 8 (resref) Current area
0x0060 4 (dword) GUI flags
  • bit 0: (0) Party AI disabled / (1) Party AI enabled
  • bit 1: Text window size*
  • bit 2: Text window size*
  • bit 3: Unknown
  • bit 4: (0) Show GUI / (1) Hide GUI
  • bit 5: (0) Show options panel / (1) Hide options panel
  • bit 6: (0) Show portraits panel / (1) Hide portraits panel
  • bit 7: (0) Hide automap notes / (1) Show automap notes
* These bits control the text window size. The bits relate to the size as follows:
  •   00 = Small
  •   01 = Medium
  •   10 = Unused
  •   11 = Large
NB. Not all engines use all bits
0x0064 4 (dword) Unknown
0x0068 4 (dword) Offset to familiar info
0x006c 4 (dword) Offset to stored locations
0x0070 4 (dword) Count of stored locations
0x0074 4 (dword) Game time (real seconds)
0x0078 4 (dword) Offset to pocket plane locations
0x007c 4 (dword) Count of pocket plane locations
0x0080 52 (bytes) Unknown



Offset Size (datatype) Description
0x0000 2 (word) Character selection
  • 0 = Not selected
  • 1 = Selected
  • 0x8000 = Dead
0x0002 2 (word) Party order (0x0-0x5 = PlayerXFill, 0xFFFF = not in party)
0x0004 4 (dword) Offset (from start of file) to CRE resource data for this character
0x0008 4 (dword) Size of CRE resource data for this character
0x000c 8 (bytes) Character Name
0x0014 4 (dword) Character orientation
0x0018 8 (resref) Characters current area
0x0020 2 (word) Character X coordinate
0x0022 2 (word) Character Y coordinate
0x0024 2 (word) Viewing rectangle X coordinate
0x0026 2 (word) Viewing rectangle Y coordinate
0x0028 2 (word) Modal action
0x002a 2 (word) Happiness
0x002c 96 (bytes) Unknown
0x008c 2 (word) Index into slots.ids for Quick Weapon 1 (0xFFFF = none)
0x008e 2 (word) Index into slots.ids for Quick Weapon 2 (0xFFFF = none)
0x0090 2 (word) Index into slots.ids for Quick Weapon 3 (0xFFFF = none)
0x0092 2 (word) Index into slots.ids for Quick Weapon 4 (0xFFFF = none)
0x0094 2 (word) Quick Weapon 1 slot enabled
0x0096 2 (word) Quick Weapon 2 slot enabled
0x0098 2 (word) Quick Weapon 3 slot enabled
0x009a 2 (word) Quick Weapon 4 slot enabled
0x009c 8 (resref) Quick Spell 1 resouce
0x00a4 8 (resref) Quick Spell 2 resouce
0x00ac 8 (resref) Quick Spell 3 resouce
0x00b4 2 (word) Index into slots.ids for Quick Item 1 (0xFFFF = none)
0x00b6 2 (word) Index into slots.ids for Quick Item 2 (0xFFFF = none)
0x00b8 2 (word) Index into slots.ids for Quick Item 3 (0xFFFF = none)
0x00ba 2 (word) Quick Item 1 slot enabled
0x00bc 2 (word) Quick Item 2 slot enabled
0x00be 2 (word) Quick Item 3 slot enabled
0x00c0 32 (bytes) Name
0x00e0 4 (dword) Talkcount
0x00e4 116 bytes character stats for this character
0x0158 8 bytes Voice Set


Offset Size (data type) Description
0x0000 4 (strref) "Most powerful vanquished" - Name
0x0004 4 (dword) "Most powerful vanquished" - XP Reward
0x0008 4 (dword) Time in party (1/15 seconds)
0x000c 4 (dword) Time Joined (1/15 seconds)
0x0010 2 (word) Party member (0 = Not in party, 1 = In party)
0x0012 2 (word) Unknown
0x0014 4 (dword) Kills - XP Gained (chapter)
0x0018 4 (dword) Kills - Number (chapter)
0x001c 4 (dword) Kills - XP (game)
0x0020 4 (dword) Kills - number (game)
0x0024 4*8 (resref array) Favourite spells
0x0044 4*2 (word array) Favourite spell count
0x004c 4*8 (resref array) Favourite weapons
0x006c 4*2 (word) Favourite weapon time (time equipped in combat - 1/15 seconds)


Offset Size (data type) Description
0x0000 32 (char array) Variable name
0x0020 8 (bytes) Unknown
0x0028 4 (dword) Variable value
0x002c 40 (bytes) Unknown


This section stores the strref, chapter and time for any entry added to the journal.

Offset Size (data type) Description
0x0000 4 (strref) Journal text
0x0004 4 (dword) Time (seconds)
0x0008 4 (dword) Current chapter number
0x000C 1 (byte) Unknown
0x000D 1 (byte) Journal section
  • bit 0: Quests
  • bit 1: Competed quest
  • bit 2: Journal Info
NB. If no bits are set, the entry is a user-note
0x000E 1 (byte) Location flag (0x1F = external TOT/TOH, 0xFF = internal TLK)


The familiar (summoned by the Find Familiar spell) is dependent on the alignment of the caster. This section contains the mapping between caster alingment and the CRE file to summon.

Offset Size (data type) Description
0x0000 8 (resref) Lawful Good Familiar
0x0008 8 (resref) Lawful Neutral Familiar
0x0010 8 (resref) Lawful Evil Familiar
0x0018 8 (resref) Neutral Good Familiar
0x0020 8 (resref) Neutral Familiar
0x0028 8 (resref) Neutral Evil Familiar
0x0030 8 (resref) Chaotic Good Familiar
0x0038 8 (resref) Chaotic Neutral Familiar
0x0040 8 (resref) Chaotic Evil Familiar
0x0048 328 (bytes) Unknown


This struct is filled by the StorePartyLocations() action and cleared by the RestorePartyLocations() action. There is one record for each member of the party at the time the action was called.

Offset Size (data type) Description
0x0000 8 (resref) Area
0x0008 2 (word) X coordinate
0x000a 2 (word) Y coordinate


This struct is filled by the Spell Effect: Area Switch [298] effect and cleared by the ExitPocketPlane effect. There is one record for each member of the party at the time the effect was called.

Offset Size (data type) Description
0x0000 8 (resref) Area
0x0008 2 (word) X coordinate
0x000a 2 (word) Y coordinate