Skip to content

Game Objects (.dat files)

Benjamin Sutas edited this page Sep 14, 2023 · 10 revisions

Technical Info

Tools

Sources

Indexes/Aggregators

Binary Visualisation/Investigation Tools

Kaitai Struct (WIP)

meta:
  id: loco_dat
  file-extension: dat
  endian: le

seq:
  - id: dat_header
    type: dat_header_t
  - id: sawyer_encoding
    type: u1
    enum: sawyer_encoding_t
  - id: length
    type: u4
  - id: data # could be compressed/encoded, need to invoke custom decoder (7.6)
    size: length
    
  #- id: object_header
  #  type:
  #    switch-on: dat_header.flags.obj_type.as<u1>
  #    cases:
  #      0x00: interface_header_t
  #      0x17: vehicle_header_t

types:
  dat_header_t:
    seq:
      - id: flags
        type: dat_header_flags_t
      - id: filename
        type: str
        size: 8
        encoding: ASCII
      - id: checksum
        type: u4
        
  dat_header_flags_t:
    seq:
      - id: custom_obj
        type: b2
        enum: custom_obj
      - id: obj_type
        type: b6
        enum: obj_type_t
      - id: unk
        type: u2
      - id: original_loco_file
        type: u1
        enum: original_loco_file
        
  interface_header_t:
    seq:
      - id: name
        type: str
        size: 2
        encoding: ASCII
      - id: img
        type: u4
        
  vehicle_header_t:
    seq:
      - id: name
        type: u2
      - id: transport_mode
        type: u1
        enum: transport_mode_t
      - id: vehicle_type
        type: u1
        enum: vehicle_type_t
      - id: var_04
        type: u1
      - id: track_type
        type: u1
      - id: num_mods
        type: u1
      - id: cost_index
        type: u1
      - id: cost_factor
        type: s2
      - id: reliability
        type: u1
      - id: run_cost_index
        type: u1
      - id: run_cost_factor
        type: s2
      - id: colour_type
        type: u1
      - id: num_compat
        type: u1
      - id: compatible_vehicles
        type: u2
        repeat: expr
        repeat-expr: 8
      - id: required_track_extras
        type: u1
        repeat: expr
        repeat-expr: 4
      - id: var_24_unk
        type: u1
        repeat: expr
        repeat-expr: 6 * 4
      - id: body_sprites
        type: u1
        repeat: expr
        repeat-expr: 30 * 4
      - id: bogie_sprites
        type: u1
        repeat: expr
        repeat-expr: 18 * 2
      - id: power
        type: u2
      - id: speed
        type: s2
      - id: rack_speed
        type: s2
      - id: weight
        type: u2
      - id: unk
        size: 0x15E - 60;
        
enums:
  sawyer_encoding_t:
    0: uncompressed
    1: rle_single
    2: rle_multi
    3: rotate

  custom_obj:
    0x00: custom
    0x02: standard
    
  original_loco_file:
    0x11: original
    
  obj_type_t:
    0x00: interface
    0x01: sound
    0x02: currency
    0x03: exhaust # /spark/steam
    0x04: rock # (vertical face)
    0x05: water
    0x06: grass # /rock/sand
    0x07: town_name
    0x08: resource
    0x09: fence # /wall
    0x0A: train_signal
    0x0B: level_crossing
    0x0C: street_light
    0x0D: tunnel
    0x0E: bridge
    0x0F: train_station
    0x10: track_extra # (3rd rail, electric, etc)
    0x11: track # (narrow/standard)
    0x12: road_station
    0x13: road_extra # (overhead, electric, etc)
    0x14: road
    0x15: airport
    0x16: dock
    0x17: vehicle
    0x18: tree
    0x19: snow
    0x1A: climate
    0x1B: hill_shape
    0x1C: building
    0x1D: scaffolding
    0x1E: industry # (factory, farm, etc)
    0x1F: region # (US/UK/ALP)
    0x20: competitors
    0x21: scenario
    
  transport_mode_t:
    0: rail
    1: road
    2: air
    3: water
    
  vehicle_type_t:
    0: train
    1: bus
    2: truck
    3: tram
    4: aircraft
    5: ship