src/game
The Game rules guide explains this folder.
Folders
game.c
The game object: the rules of the party and its world. Units and their stats, a new game, items and inventories, Psynergy and levels, the game flags, enemy units and the party's counters, element levels and classes, battle arithmetic and the Djinn.
game_internal.h holds what every part shares (its includes and one inline helper); the code is in the files under game/, included here in the order it has in the ROM. Camelot's own files are not recoverable: the ROM shows one object, and these parts are ours, cut where one family ends and the next begins. Its tables are the .tsv files in this folder, built by the .s files beside them; README.md gives the words and prefixes. Where to start:
Units units.c: UnitGet, UnitCalc, GameState_InitDefaults
Items inventory.c: Inventory_AddItem, Inventory_Equip,
PartyInventory_Add
Levels levels.c: Unit_RefreshPsynergy, Owner_LevelUp
Flags flags.c: GameFlag_Test, GameFlag_SetBit
Enemies, party party.c: BattleUnitSet, Party_AddActiveOwner,
Party_AdjustCoins
Classes classes.c: Class_Determine, Unit_UpdateClass
Battle maths battle_calc.c: Battle_GetElementMultiplier,
BattleRandom
Djinn djinn.c: Djinn_AddToOwner, Djinn_Activategame_internal.h
games/tbs/src/game/game_internal.h
Functions
Inventory_CompactSlots
static inline void Inventory_CompactSlots(s16 *inventory)
Keeps occupied slots in order and clears the unused inventory tail, for Inventory_Remove (inventory.c) and InventorySnapshot_Save (snapshot.c).
Used by InventorySnapshot_Save, Inventory_Remove.
starting_equipment.c
games/tbs/src/game/starting_equipment.c
Globals, without a comment: gCharacter_StartingEquipOwnerIds.