Inventory 3: 0x43cef0 to 0x4630e0 (300 functions)
Names are applied in the Ghidra project; the record is tools/ghidra/names.tsv. Addresses are VAs in gta.exe. Struct offsets are byte offsets from the start of the record. Fixed-point: world positions are 16.16 "pixels" (64 pixels per block), so >>22 gives the block coordinate and >>16 gives pixels. Angles are 10-bit (0..0x3ff). 0 points along +y ("down" on screen), 0x100 is +x.
1. Modules (in link order)
| Span | Module | Purpose |
|---|---|---|
| 0x43cef0–0x44ab3f | mission | MISSION.INI script runtime: object spawners, 150-opcode interpreter, per-opcode handlers, loader. The module probably starts before 0x43cef0, since 0x43cac0/0x43cd30 are mission helpers in range 2. |
| 0x44ab40–0x44b15f | mission_ini | Reads the mission.ini section and its tokenizer (ints, words, (x,y,z), {comments}). Possibly the same .c file as mission. |
| 0x44b160 | movie | Plays the intro MOVIE.SMK through SMACKW32 ordinals. |
| 0x44b310 | map_query | Block attribute test on the cached block-info dword. |
| 0x44b4a0–0x44b89f | area | CMP navigation zones ("area names"), N/S/E/W subdivision, FXT localisation. |
| 0x44b8a0–0x44c2cf | net | Multiplayer lock-step input sync, start handshake, chat prefix. Built on the 0x4129xx/0x412axx network layer. |
| 0x44c2d0–0x44ee4f | obj | Map objects ("object_pos" from CMP, "object_info" from G24). Covers create/delete, moving/thrown objects, animations and attachment. |
| 0x44ee50–0x4607af | ped | Pedestrians: pool, spawning, AI movement and collision, animation, weapons, entering and leaving cars, plus player respawn. Also holds the ground-height helpers that obj uses. |
| 0x4607b0–0x4616af | carphys | Float rigid-body car dynamics (x87 fsin/fcos): forces, integrate, bounce, tyre model. |
| 0x4616b0–0x4630e0 | player | Player record accessors: score, multiplier, lives, wanted level, weapons and ammo, kill-frenzy weapon, controlled object and camera target, name and colour. The module continues past 0x4630e0 (0x463100.. are player functions that call into ped). |
2. Key structures and globals
Mission script (module mission)
- Command table
0x676660: 5000 records × 24 bytes (ends 0x693b20). The loader fills unused records with opcode 999.+0u16 opcode, indexing the name table at0x4b0ec0(0x00 LOCATE_STOPPED … 0x95 IS_PED_STUNNED, 150 names, dumped).+4i32 a (usually an object line number)+8i32 b (success label)+0xci32 c (fail label)+0x10i32 d (timer/param)+0x14i32 e (score)- Branch rule (
Mission_BranchSuccess/Fail): 0 means next command, -1 ends the process, anything else is a label resolved via0x693b30.
- Label map
0x693b30: short[65536], mapping label to command index. - Line→object map
0x6561c0: short[65536], mapping script line number to object slot. - Script objects
0x5f30e8: 1400 × 32 bytes (ends 0x5fdfe8).+0i32 type, indexing the type-name table at0x4b0d98(CAR=0, PED=1, OBJECT=2, PLAYER=3 … ALT_DAMAGE_TRIG=0x47, 72 names). 99 marks a spawned PED.+4runtime handle (car/ped/object/trigger id)+8param 2+0x10/0x14/0x18x, y, z+0x1cu8 persistent flag
- Processes: 32 script "threads", indexed by
0x6b3b70. Indices below the player count belong to the players; spawned processes chain to an owner through0x676348. The interpreter resolves the owner into0x676608("current player").- Per-process arrays:
0x6761c0short active0x676620short PC0x676280short wait counter0x6560b8short step state (1 = first entry; handlers count timers from there)0x6b3de8short linked handle0x676200i32 kind0x6762c8i32 trigger that started it0x6b3b30short result
- The current PC is in
0x655e58.0x5f30e0holds the current player's ped id (copied from0x656180[player]).
- Per-process arrays:
- Parse scratch:
0x676610/14/18x,y,z;0x5fe004p1;0x6765f0p2. - Counters:
0x676388is the MISSION_COUNTER object,0x693b28the SECRET_MISSION_COUNTER object,0x6b3b78MISSION_TOTAL,0x6b3b84TARGET_SCORE. - Cleanup lists, flushed by RESET: cars
0x6b3b90/0x6b3b88, peds0x676390/0x6b3b80, objects0x655e60/0x656178. KF list:0x5fe010/0x676604. - Result code
0x513230drives the end text: 1 success, 2 failed, 3 dead, 4 arrest, 5 timeout, 6 time over (MP), 8 score, 10 cannon, 11 demo.
Ped pool (module ped)
0x7284e0: 620 × 0x100 bytes (Ped_Get0x44f500).- Slots 0..199 are ambient/mission peds.
- Slots 200..599 are the drivers of cars 0..399 (ped id = car id + 200).
- Slots 600..619 are special peds (
Ped_CreateSpecial).
- Fields:
+0id+6speed+8u8 move speed (4/6)+0x10control type+0x16graphic type (0 civilian, 1 cop; 0xbd sprite frames per type)+0x18anim state; 0 means the slot is free, 0x88 standing, 1..0x10 walking frames+0x1cu8 player-controlled+0x2c/0x30target point+0x38/0x3cwalk target+0x42short mode+0x46u8 firing+0x49i8 health (100)+0x4ccar id (-1 when on foot)+0x50/+0x52attach kind/id (1 car, 2 object, 3 ped)+0x58carried object+0x5eremap+0x60weapon (1..4; from the ammo code, probably 1 pistol, 2 machine gun, 3 rocket, 4 flamethrower)+0x6cobjective (0x19 wander, 0x25 player, 0x15/0x16 group leader/follower, 0x34/0x35 go to car door…)+0x70state (1, 2 walk, 4 go-to, 7 in car, 9, 10, 0x0c/0x17 dead/dying, 0x18)+0x78/+0x7csub-modes+0x86target ped+0x89/+0x8agroup index/slot+0x90sprite/position block: x, y, z, z2 at +0x90/94/98/9c; angle at +0xa8
- Groups:
0x728498, 0x1c bytes each (leader short, count byte, members short[]). Active ped count is0x74f104; peds are spawned while it is below 200.
Car pool (range 1, used heavily here)
0x4be248, stride 0x2b0 (Car_Get 0x408200).- Fields seen:
+2driver ped id+0x1cspeed+0x22car type, mapped through0x4be178to the car-info pointer table at*0x501574. Car info has door count at +0xac and door offsets at +0xae/+0xb0 and +0xb6/+0xb8.+0x144float-physics flag+0x18c..0x1d4rigid body (floats). The body starts at +0x190 with x, y, angle (+0x198), velocities, accumulators and mass/inertia (+0x1b0/+0x1b4).+0x250/254/258x, y, z (16.16)+0x268angle+0x2achandling-params pointer
- Car info physics fields at +0x76..+0x9c: mass, grip, wheelbase.
Objects (module obj)
0x6b40d0: 3500 × 0x88 bytes (Obj_Get).- Fields:
+0id+2speed+6heading+0xatype (object_info index)+0xcstate/frame+0xeframe timer+0x14owner id+0x18attach kind (0 obj, 1/5 car, 2 ?, 4 ped)+0x1a/+0x1coffset+0x20u8 in-anim-list+0x24next ptr,+0x28prev ptr+0x2csprite/position block (x, y, z, z2, angle at +0x44)
- Lists:
0x6b40bcmoving/thrown objects0x6b40c0status-7 objects0x6b40c4attached objects0x728430animated objects (status 5/9)
0x6b40c8counts smashable objects (limit 200).
Players (module player)
- Base
0x74f148, stride 0x1bc (local player0x74f83c, viewed player0x74f844). - Fields:
+2ped id+4view rect i32[4] (xmin, xmax, ymin, ymax in pixels;Player_GetViewRect)+0xbc/+0xc0controlled ref (kind, id)+0xd0/+0xd4camera-target ref+0xd8..+0xe0fixed camera point+0xe4name+0xf4score+0xf8multiplier+0xfcshort[5] kill counters,+0x110short[5] totals+0x150wanted points (≤2000)+0x154wanted level+0x158..0x15bammo for weapons 1..4 (≤99; 100 = unlimited frenzy weapon)+0x15c/+0x15d5-shot sub-counters for weapons 2 and 4+0x160current weapon+0x164..saved weapon during a frenzy+0x170/+0x174bonus chain+0x197lives (≤99)+0x1acfrenzy timer+0x1b4colour
- Ref kinds: 0 car, 1 table-7 entity via 0x46a9f0 (train?), 2 ped, 3/4 fixed point, 5 via 0x40dc80.
Shared tables
0x511e28: sine table, int 16.16, 1024 + 256 entries. Cosine issin[a+0x100]; code also reads0x512228(= cos(0)),0x512628and0x512a28directly.0x55fab0: byte cell map[z 0..5][y 256][x 256]. It caches the low byte of each block'stype_map:- bits 0–3 road direction (1 N, 2 S, 4 W, 8 E)
- bits 4–6 block type (0 air, 1 water, 2 road, 3 pavement, 4 field, 5 building)
- bit 7 flat
- Full block attributes come from
Map_GetTypeMap 0x438900/Map_GetTypeAt 0x4388a0, as type_map | ext<<16. Slope is bits 8–13.
3. Data formats verified here
- MISSION.INI (checked against game/GTADATA):
[N]header, thenname, ?, file.cmp, style,. The second number goes to the strippedDbg_Nop.- A header line of 6 ints follows (100 1 1 1 1 0: p0 → 0x475f10, p1 == 1 → 0x475f60, p3 → 0x478800, p4 → 0x478810).
- Object lines:
line [1] (x,y,z) TYPE p1 p2. The optional digit makes the object persistent; without it the object goes on a RESET cleanup list. Coordinates are in blocks, or in pixels for the*_PIXELS/CRANE types. - A negative number ends the object list.
- Command lines:
label OPCODE a b c d e, ended by a negative number. {…}is a comment.
- CMP tail (verified on NYC/SANB/MIAMI), after the blocks: object_pos, route, location data (108 bytes), nav data.
- object_pos records are 14 bytes: x, y, z (u16, pixels), type u8, remap u8, rotation u16, pitch u16, roll u16. remap ≥ 0x80 means a parked car with car type
type. - Location data is 36 entries × (x, y, z) bytes. Entries 0..5 are police stations and 6..11 hospitals (used by
Player_RespawnAtStation: mode 0 = police, mode 1 = hospital, i.e. busted vs. died). The counter in 0x50caa4 is presumably 6. - Nav records are 35 bytes: x, y, w, h, sample, name[30].
- object_pos records are 14 bytes: x, y, z (u16, pixels), type u8, remap u8, rotation u16, pitch u16, roll u16. remap ≥ 0x80 means a parked car with car type
- G24 object_info (from code; not yet cross-checked with a file parser): records of 20 + 2·num_into bytes.
- width, height, depth (u32; ints below 0x10000 are shifted to 16.16)
- spr_num u16 (rebased by
0x774f0c) - weight u16 (+0xe)
- aux u16 (+0x10)
- status u8 (+0x12)
- num_into u8 (+0x13)
- into[] u16 (+0x14), the objects spawned when smashed
- Status values used: 0 normal, 1, 3 invisible (fixed position, no sprite init), 5/9 animated, 6 car-attached, 7, 8.
4. Call-graph links to other ranges
- Range 2:
0x430a20(level start) callsMission_Load,Obj_InitFromMapandPed_InitAll.0x430c00(world step) callsMission_Update,Ped_UpdateAllandObj_UpdateAll.0x437230(WinMain) callsMovie_PlayIntro,Area_LoadDirPrefixesandMission_ReadIni.0x4148a0callsNet_SyncFrameInputs.0x438200(CMP loader) callsObj_SetMapObjects,Area_SetNavDataandArea_LocalizeNames.0x422900is the fatal-error reporter, called everywhere.
- Range 4+:
- The style loader
0x47cf10callsObj_LoadInfos. - Triggers/doors are created by
0x4744a0/0x4740f0(kind codes as inMission_Load). - Message/FXT:
0x47d9a0(FXT lookup),0x481d40/0x481a40(screen message),0x481540(floating score),0x4819b0(arrow). - Sound at position:
0x4047f0/0x404840. - Sprites:
0x47c9f0init,0x47c960frame,0x47c9c0remap. - Spatial grid:
0x436c30insert,0x436e30remove,0x434300box query,0x436b20end query. 0x434160rand(0..0x7fff);0x4899eeatan2 → 10-bit angle.- Player iteration:
0x412a70first /0x412a90next.
- The style loader
CarPhys_Stepis called from the car update0x40a640.Ped_EjectDriver/Ped_CreateCarDriverare called from car code at 0x40xxxx–0x41xxxx.
5. Porting priorities
- (a) Loading and drawing the city:
Obj_LoadInfos0x44ed60 andObj_SetMapObjects0x44ee20Obj_InitFromMap0x44c620 andObj_CreateStatic0x44c870Obj_UpdateSprite0x44c3a0Area_*0x44b4a0–0x44b7b0 (area names, HUD)Map_TestBlockAttr0x44b310Mission_ReadIni0x44ab90 plus the tokenizer (picks the CMP/style).
- (b) Player on foot / in a car:
Ped_UpdateAll0x45cd50,Ped_Process0x45a3b0,Ped_ComputeStep0x456fb0Map_GetGroundZ0x4544e0 (+Map_SlopeDelta)Ped_IsDirClear0x455dc0Ped_Animate0x44fa70 andPed_UpdateSprite0x44f100Ped_SetTurnInput0x45f670Ped_EnterExitKey0x45f5e0 →Ped_TryEnterCar0x45def0 /Ped_FinishEnterCar0x45ddc0 /Ped_PlayerExitCar0x45d3d0Ped_FireWeapon0x4532f0CarPhys_*0x4607b0–0x4615e0, in particularCarPhys_Step0x460be0- Player accessors 0x4616b0+ (controlled ref, view rect, camera target)
- (c) Frame loop:
Mission_Update0x446fe0 →Mission_StepProcess0x4471a0,Obj_UpdateAll0x44d790,Ped_UpdateAll0x45cd50,Net_SyncFrameInputs0x44b930 (MP only). These are the in-range pieces of0x430c00.
6. Open questions
- Exact semantics of ref kind 1 and kind 5 (0x46a9f0 table 7, 0x40dc80). Kind 1 is possibly trains.
- Mission header ints 0, 1, 3, 4, and the second value on the
[N]name line. - Weapon 3 vs 4 identity (sound ids 0x24/0x23; projectile spawners 0x489150/0x488fd0).
- Many ped/obj state numbers are only partially decoded (anim states 0x11–0x88, objectives). The 0x44fa70 and 0x45a3b0 switch bodies still need a dedicated pass.
Net_unk_0044b900/910/920wrap 0x412a00/0x412980/0x412960 (network layer, range 2).- The opcode handlers were named from the interpreter switch (case to handler); their bodies were only skimmed. Inline opcodes (e.g. 0x04 SURVIVE, 0x0a END, 0x0c EXPLODE, 0x0e THROW, 0x81 RESET…) live inside
Mission_StepProcess.