first commit

This commit is contained in:
dasha 2026-01-05 12:33:47 +03:00
commit acd31cdf9d
73 changed files with 650543 additions and 0 deletions

167
old/asset_index.ksy Normal file
View file

@ -0,0 +1,167 @@
meta:
id: asset_index
file-extension: funnycat
endian: le
encoding: UTF-8
seq:
- id: type_mapping_count
type: u4
- id: type_mapping
type: type_mapping_entry
repeat: expr
repeat-expr: type_mapping_count
doc: This specifies what specific type is serialized into (?)
- id: asset_count
type: u4
- id: assets
type: asset_info
repeat: expr
repeat-expr: asset_count
doc: List of all the assets in the game, with their names, hashes and types
- id: dependency_count
type: u4
- id: magic_31
type: u4
- id: magic_32
type: u4
- id: dependencies
type: dependency_info
repeat: expr
repeat-expr: dependency_count
doc: List of inter-asset dependencies
- id: preload_blocks_count
type: u4
- id: preload_blocks
type: u4
repeat: expr
repeat-expr: preload_blocks_count
doc: Blocks to be preoaded during the game start (?)
- id: preload_shader_blocks_count
type: u4
- id: preload_shader_blocks
type: u4
repeat: expr
repeat-expr: preload_shader_blocks_count
doc: Blocks containing shaders to be preloaded during the game startup (?)
- id: block_group_count
type: u4
- id: block_groups
type: block_group
repeat: expr
repeat-expr: block_group_count
doc: Info about distribution of BLKs in file system directories
- id: block_info_count
type: u4
- id: block_infos
type: block_info
repeat: expr
repeat-expr: block_info_count
doc: Info about distribution of assets in BLKs
types:
string:
seq:
- id: len
type: u4
- id: data
type: str
size: len
type_mapping_entry:
seq:
- id: name
type: string
- id: mapped_to
type: string
asset_info:
seq:
- id: path_hash_pre
type: u1
- id: path_hash_last
type: u4
- id: magic
type: u1
repeat: expr
repeat-expr: 3
- id: magic_real
type: u1
- id: magic_2
type: u1
- id: sub_asset_id
type: u4
- id: magic_conditional
type: u1
if: magic_real == 2
repeat: expr
repeat-expr: 5
dependency_info:
doc: Describes that asset asset_id depends on assets from the specified list
seq:
- id: asset_id
type: u4
- id: dependency_info_count
type: u4
- id: dependencies_list
type: u4
repeat: expr
repeat-expr: dependency_info_count
block_info:
doc: Specifies which assets this specific block contains and their offsets in the BLK file
seq:
- id: block_id
type: u4
- id: asset_offset_count
type: u4
- id: asset_offsets
type: asset_offset_info
repeat: expr
repeat-expr: asset_offset_count
asset_offset_info:
seq:
- id: path_hash_pre
type: u4
- id: offset
type: u4
- id: size
type: u4
block_group:
doc: List of BLKs in a directory specified by the group_id
seq:
- id: group_id
type: u4
- id: block_count
type: u4
- id: block_list
type: block_list_magic
repeat: expr
repeat-expr: block_count
block_list_magic:
seq:
- id: block_list
type: u4
- id: magic
type: u2
- id: magic_2
type: u1

168
old/aux_types.ksy Normal file
View file

@ -0,0 +1,168 @@
meta:
id: aux_types
file-extension: aux_types
endian: le
doc: |
Miscellaneous types used in serialization
Credit for dynamic_* stuff goes to Raz
types:
error:
doc: Type used in misc situations to signal about an error
seq:
- id: message
contents: "There was an error parsing data; please check KSY definition"
string:
seq:
- id: length
type: vlq_base128_le_u
- id: data
size: length.value
type: str
encoding: UTF-8
length_prefixed_bitfield:
seq:
- id: length
type: vlq_base128_le_u
- id: bitfield
type: u1
repeat: expr
repeat-expr: length.value
instances:
value:
value: >-
(length.value >= 1 ? bitfield[0] : 0) +
(length.value >= 2 ? (bitfield[1] << 8) : 0) +
(length.value >= 3 ? (bitfield[2] << 16) : 0) +
(length.value >= 4 ? (bitfield[3] << 24) : 0) +
(length.value >= 5 ? (bitfield[4] << 32) : 0) +
(length.value >= 6 ? (bitfield[5] << 40) : 0) +
(length.value >= 7 ? (bitfield[6] << 48) : 0) +
(length.value >= 8 ? (bitfield[7] << 56) : 0) +
(length.value >= 9 ? (bitfield[8] << 64) : 0)
dynamic_int:
seq:
- id: is_string
type: u1
- id: data
type:
switch-on: is_string
cases:
0: vlq_base128_le_s
1: string
base_dynamic_float:
seq:
- id: is_string
type: u1
- id: data
type:
switch-on: is_string
cases:
0: f4
1: string
dynamic_operator:
seq:
- id: is_operator
type: u1 # TODO: bool!
- id: data
type:
switch-on: is_operator
cases:
0: base_dynamic_float
1: vlq_base128_le_s
dynamic_formula:
seq:
- id: length
type: vlq_base128_le_s
- id: elements
type: dynamic_operator
repeat: expr
repeat-expr: length.value
dynamic_float:
seq:
- id: is_formula
type: u1 # TODO: bool!
- id: data
type:
switch-on: is_formula
cases:
0: base_dynamic_float
1: dynamic_formula
dynamic_string:
seq:
- id: is_dynamic
type: u1 # TODO: bool!
- id: data
type: string
dynamic_argument:
seq:
- id: type_code
type: vlq_base128_le_u
- id: data
type:
switch-on: type_code.value
cases:
1: s1
2: u1
3: s2
4: u2
5: s4
6: u4
7: f4
8: f8
9: u1 # TODO: bool!
10: string
vlq_base128_le: # Stolen from Kaitai website and modified accordingly with Zigzag encoding
seq:
- id: ks__groups
type: group
repeat: until
repeat-until: not _.has_next
types:
group:
seq:
- id: b
type: u1
instances:
has_next:
value: (b & 0b1000_0000) != 0
doc: If true, then we have more bytes to read
value:
value: b & 0b0111_1111
doc: The 7-bit (base128) numeric value chunk of this group
instances:
len:
value: ks__groups.size
value_unsigned:
value: >-
ks__groups[0].value
+ (len >= 2 ? (ks__groups[1].value << 7) : 0)
+ (len >= 3 ? (ks__groups[2].value << 14) : 0)
+ (len >= 4 ? (ks__groups[3].value << 21) : 0)
+ (len >= 5 ? (ks__groups[4].value << 28) : 0)
+ (len >= 6 ? (ks__groups[5].value << 35) : 0)
+ (len >= 7 ? (ks__groups[6].value << 42) : 0)
+ (len >= 8 ? (ks__groups[7].value << 49) : 0)
doc: Resulting unsigned value as normal integer
value_absolute:
value: 'value_unsigned >> 1'
doc: Absolute value for Zigzag-encoded integer
sign_bit:
value: 'value_unsigned & 1'
doc: Sign bit for Zigzag-encoded integer
value_signed:
value: 'value_absolute ^ (-sign_bit)'
doc: Resulting signed value as Zigzag-encoded integer
vlq_base128_le_s:
seq:
- id: data
type: vlq_base128_le
instances:
value:
value: data.value_signed
vlq_base128_le_u:
seq:
- id: data
type: vlq_base128_le
instances:
value:
value: data.value_unsigned

119812
old/output.ksy Normal file

File diff suppressed because it is too large Load diff