Skip to content

Commit a53420b

Browse files
committed
doc: Add demo.ksy
1 parent 0085b3e commit a53420b

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

doc/demo.ksy

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
meta:
2+
id: tw_demo_v3_v4_v5_v6
3+
file-extension: demo
4+
endian: be
5+
license: MIT/Apache-2.0
6+
doc-ref: https://github.com/heinrich5991/libtw2/blob/0085b3eb76ff1ffc7136f874129c79fce0f955ee/doc/demo.md
7+
seq:
8+
- id: header
9+
type: header
10+
- id: timeline_markers
11+
type: timeline_markers
12+
if: header.version >= 4
13+
- id: map_sha256
14+
type: map_sha256
15+
if: header.version >= 6
16+
- id: map
17+
size: header.map_size
18+
- id: chunks
19+
type: chunk
20+
repeat: eos
21+
enums:
22+
chunk_type:
23+
1: snapshot
24+
2: message
25+
3: snapshot_delta
26+
types:
27+
header:
28+
seq:
29+
- id: magic
30+
contents: ['TWDEMO', 0]
31+
- id: version
32+
type: u1
33+
- id: net_version
34+
type: strz
35+
encoding: utf8
36+
size: 64
37+
- id: map_name
38+
type: strz
39+
encoding: utf8
40+
size: 64
41+
- id: map_size
42+
type: s4
43+
- id: map_crc
44+
type: u4
45+
- id: type
46+
type: strz
47+
encoding: utf8
48+
size: 8
49+
- id: length
50+
type: s4
51+
- id: timestamp
52+
type: strz
53+
encoding: utf8
54+
size: 20
55+
timeline_markers:
56+
seq:
57+
- id: num_timeline_markers
58+
type: s4
59+
- id: timeline_marker
60+
type: s4
61+
repeat: expr
62+
repeat-expr: 64
63+
map_sha256:
64+
seq:
65+
- id: magic
66+
contents: [0x6b, 0xe6, 0xda, 0x4a, 0xce, 0xbd, 0x38, 0x0c, 0x9b, 0x5b, 0x12, 0x89, 0xc8, 0x42, 0xd7, 0x80]
67+
- id: map_sha256
68+
size: 32
69+
chunk:
70+
seq:
71+
- id: is_tick
72+
type: b1
73+
74+
# tick
75+
- id: keyframe
76+
type: b1
77+
if: is_tick
78+
- id: inline_tick_delta
79+
type: b1
80+
if: _root.header.version >= 5 and is_tick
81+
- id: tick_delta_v5
82+
type: b5
83+
if: _root.header.version >= 5 and is_tick
84+
- id: tick_delta_v3
85+
type: b6
86+
if: _root.header.version < 5 and is_tick
87+
88+
# non-tick
89+
- id: type
90+
type: b2
91+
enum: chunk_type
92+
if: not is_tick
93+
- id: size_inline
94+
type: b5
95+
if: not is_tick
96+
97+
# tick
98+
- id: tick_absolute
99+
type: s4
100+
if: is_tick and (_root.header.version >= 5 ? not inline_tick_delta : tick_delta_v3 == 0)
101+
102+
# non-tick
103+
- id: size_extern_8
104+
type: u1
105+
if: not is_tick and size_inline == 30
106+
- id: size_extern_16
107+
type: u2le
108+
if: not is_tick and size_inline == 31
109+
- id: compressed_data
110+
size: size
111+
112+
instances:
113+
tick_delta:
114+
value: _root.header.version >= 5 ? tick_delta_v5 : tick_delta_v3
115+
if: is_tick and (_root.header.version >= 5 ? inline_tick_delta : tick_delta_v3 != 0)
116+
size:
117+
value: size_inline == 31 ? size_extern_16 : size_inline == 30 ? size_extern_8 : size_inline
118+
if: not is_tick

0 commit comments

Comments
 (0)