saints row iv · how the game works
How Saints Row IV Works
The game's life cycle in order: start-up, menus, loading, and what happens every frame.
How the Game Works19 rows
The game's life from double-click to quit. Each step names the function where it happens.
| Step | What happens | Key function | Address | Notes |
|---|---|---|---|---|
| Start-up | ||||
| 1 | Windows starts the exe; the C runtime sets up and calls WinMain. | WinMain | 007250a0 | |
| 2 | Reads the command line, creates the 'dumps' and 'mods' folders next to the exe, turns off the screensaver. | init_mods_dir | 00722a60 | The mods folder is real 2017 mod support - see Files & Mods. |
| 3 | Creates the window ('Saints Row IV') and the Direct3D 11 graphics device. If that fails you get 'Failed to create graphics device'. | game_create_window_and_device | 00722f50 | Also registers where files are searched for, mods folder first. |
| 4 | Registers the BOOT game state and enters it. | gamestate_register | 00865f20 | The whole game is a stack of states - see Game States. |
| 5 | BOOT: reserves memory pools, mounts the core packfiles, starts a small loading-screen render thread, loads all data tables (animation, gameplay constants, effects...). | game_init_callback / boot_load_game_data | 00724d70 / 00723bd0 | Memory sizes: see Memory Budgets. |
| 6 | Starts the worker threads (rendering, file loading, audio, job scheduler). | thread_create | 010c1a10 | See Threads. |
| The main loop (runs until you quit) | ||||
| 7 | Handle Windows messages (keyboard, focus, close button). | platform_pump_messages | 010befe0 | |
| 8 | Run one frame: input, the current game state's update, audio, UI, network, then apply any queued state changes (e.g. menu -> loading). | game_frame_tick | 00724f40 | Returns 'quit' when the state stack reaches QUIT (10). |
| 9 | Meanwhile the render thread draws the previous frame: shadows, lighting, effects, UI, then presents it. | render_thread_main | 00729ce0 | See Rendering. |
| Going from the menu into the city | ||||
| 10 | MAIN_MENU state shows the menu and handles save selection. | gs_main_menu_enter | 008ca950 | |
| 11 | CITY_LOAD state loads the city on its own thread while a loading screen plays. | gs_city_load_enter | 008c8d20 | Also starts Havok's physics job threads. |
| 12 | IN_GAME state: the world simulates every frame - humans, cars, AI, physics, Lua mission scripts, HUD. | gs_in_game_enter | 00861f70 | |
| 13 | Streaming: as you move, nearby city zones and assets load in the background and far ones unload. | stream2_container_create | 010dd670 | Files are read by the 'hdd thread', unpacked by the 'mem thread'. |
| Inside one in-game frame (simplified) | ||||
| 14 | Each AI character picks what to do: goals are checked in priority order, and each goal's actions are tried until one succeeds. | ai_select_action | 00532300 | See AI tab. |
| 15 | Damage of any kind (bullets, explosions, powers, scripts) goes through one function that lowers health and handles death. | human_take_damage | 00adeb60 | Health is at human+0x1E20. |
| 16 | Mission logic runs as Lua scripts that call ~1,900 engine commands. | lua_gameplay_vm_init | 00bbd970 | See Lua Commands. |
| 17 | In co-op, changes are sent to the other player as small compressed messages. | net_register_msg | 009a85d0 | 98 message types. |
| Saving and quitting | ||||
| 18 | Saves are written only to Steam Cloud on a background thread. | gamesave_platform_write_begin | 00d93540 | Files: sr4save_N.sr4s_pc + savedir.sr3d_pc. |
| 19 | Quitting pushes the QUIT state; the loop ends and every system shuts down in reverse order. | game_shutdown_all_states | 00866ff0 | |
Built from SR4_Game_Explained.xlsx (650 KB), if you'd rather filter it in Excel. SaintsRowIV.exe v1.0.6.1 (Steam). Names are ours unless they're Volition's own Lua or C++ class names.

