forked from mchubby-3rdparty/Bgi_script_tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bgi_config.py
57 lines (46 loc) · 2.2 KB
/
bgi_config.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
BGI version configurations
These can possibly differ between different BGI games. Modify/add as necessary.
This file is meant to be included in other modules.
Usage: config = bgi_config.get_config(databuf)
"""
# no header
VER000 = {
'HDR_SIZE': 0x0, # base header size
'HDRAS_POS': None, # offset of additional header data size (set to None if not used)
'STR_TYPE': 0x3, # string type identifier
'FILE_TYPE': 0x7F, # file type identifier
'TEXT_FCN': 0x140, # function id for text command (set to None if not used)
'BKLG_FCN': 0x143, # function id for backlog text command (set to None if not used)
'RUBY_FCN': 0x14B, # function id for ruby command (set to None if not used)
'NAME_POS': 0x24, # offset of TXT_FCN from name argument
'TEXT_POS': 0x2C, # offset of TXT_FCN from text argument
'RUBYK_POS': 0x14, # offset of RUBY_FCN from kanji argument
'RUBYF_POS': 0x0C, # offset or RUBY_FCN from furigana argument
'BKLG_POS': 0x0C, # offset of BKLG_FCN from text argument
}
# header beginning with "BurikoCompiledScriptVer1.00"
VER100 = {
'HDR_SIZE': 0x1C, # base header size
'HDRAS_POS': 0x1C, # offset of additional header data size (set to None if not used)
'STR_TYPE': 0x3, # string type identifier
'FILE_TYPE': 0x7F, # file type identifier
'TEXT_FCN': 0x140, # function id for text command (set to None if not used)
'BKLG_FCN': 0x143, # function id for backlog text command (set to None if not used)
'RUBY_FCN': 0x14B, # function id for ruby command (set to None if not used)
'NAME_POS': 0x0C, # offset of TXT_FCN from name argument
'TEXT_POS': 0x04, # offset of TXT_FCN from text argument
'RUBYK_POS': 0x04, # offset of RUBY_FCN from kanji argument
'RUBYF_POS': 0x0C, # offset or RUBY_FCN from furigana argument
'BKLG_POS': 0x0C, # offset of BKLG_FCN from text argument
}
def get_config(data):
"""
select which version based on known header string
Returns: dict
"""
if data.startswith(b'BurikoCompiledScriptVer1.00\x00'):
config = VER100
else:
config = VER000
return config