-
Notifications
You must be signed in to change notification settings - Fork 1
/
quest.py
30 lines (26 loc) · 842 Bytes
/
quest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import kouzou as k
from kouzou import _, ref
from collections import defaultdict
zstr = k.iso(
lambda a: a.replace("\1", "\n"),
lambda b: b.replace("\n", "\1"),
)@k.enc("cp932")@k.zbytes()
questStruct = k.while_(lambda x: x["n"] != 0xFF)@k.struct(
k.iso( # I should add a bitstring handler
lambda a: {"unk": bool(a&0x20), "side": bool(a&0x10), "chapter": a&0xF},
lambda b: b["unk"]<<5 | b["side"]<<4 | b["chapter"],
)@k.u1,
[email protected](k.u2, k.u2),
[email protected]("name", k.u4)@zstr,
[email protected]("name", k.u4)@zstr,
[email protected]("name", k.u4)@zstr,
[email protected]("steps", k.u4)@k.list(k.switch(ref.n,
defaultdict(lambda: 32, { 0: 2, 0xFF: 1})
))@k.later("step", k.u4)@zstr,
) << k.now("steps") << k.now("name") << k.now("step")