-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzone_of_the_enders.bms
200 lines (195 loc) · 6.28 KB
/
zone_of_the_enders.bms
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
get zoe_dat_size asize
math byte_size = 0x20
callfunction hashing_algorithm 1
math zoe_dat_ver = 0
if result == 0x0496db6a
# zoe.dat - TGS2000
math zoe_dat_ver = 1
elif result == 0x12db7aa8
# zoe.dat - retail
math zoe_dat_ver = 2
else
string show_hash p "0x%08x" result
print " this script has a built-in hashing algorithm system in place \n so it can generate fingerprints as to which ZOE.DAT will this script work with. \n \n alas, this ZOE.DAT file doesn't work with this generated fingerprint - %show_hash% "
break
endif
math entry = 0
math last_entry = 0
math entries = -1
math entry_info_offset = 0
math backup_entries_01 = 0
math backup_entries_02 = 0
math backup_info_offset_01 = 0
math backup_info_offset_02 = 0
math current_backup_entry_01 = 0
math current_backup_entry_02 = 0
math naming_type = 0
math backup_name_number = 0
math current_name_number = 0
for entry = entry != entries
set file_name_per_entry string ""
set entry_name string ""
xmath last_entry "entries - 1"
goto entry_info_offset
getdstring entry_info 0x20
math entry_info_offset += 0x20
math backup_info_offset_01 == entry_info_offset
math current_name_number + 1
getvarchr temp_01 entry_info 0x10 long
getvarchr temp_02 entry_info 0x14 long
if zoe_dat_ver = 2
getvarchr entry_flags entry_info 0x18 long
endif
if temp_01 == 0 || temp_02 == 0
math naming_type = 1
else
math naming_type = 2
endif
if naming_type = 1
for char = 0 < 8
getvarchr string_byte entry_info char byte
string string_char = string_byte
if string_byte != 0
string entry_name + string_char
endif
next char
math current_name_number - 1
if zoe_dat_ver = 1
math backup_name_number = current_name_number
math backup_entries_01 == entries
math current_backup_entry_01 == entry
getvarchr directory_value_01 entry_info 0x08 long
math entries == directory_value_01
math entries + 1
getvarchr directory_value_02 entry_info 0x0c long
math entry_info_offset == directory_value_02
math entry == 0
elif zoe_dat_ver = 2
if entry_flags == 0x102
math backup_name_number = current_name_number
math backup_entries_01 == entries
math current_backup_entry_01 == entry
getvarchr directory_value_01 entry_info 0x08 long
math entries == directory_value_01
math entries + 1
getvarchr directory_value_02 entry_info 0x0c long
math entry_info_offset == directory_value_02
math entry == 0
endif
endif
elif naming_type = 2
for char = 0 < 16
getvarchr string_byte entry_info char byte
string string_char = string_byte
if string_byte != 0
string entry_name + string_char
endif
next char
if zoe_dat_ver = 1
if entry_name & "."
if entry > 1
math current_name_number - 1
endif
getvarchr file_offset_per_entry entry_info 0x10 long
xmath file_offset_per_entry "(file_offset_per_entry - 0x18) << 11"
getvarchr file_size_per_entry entry_info 0x14 long
else
math backup_name_number = current_name_number
math backup_entries_02 == entries
math current_backup_entry_02 == entry
math backup_info_offset_02 == backup_info_offset_01
getvarchr directory_value_03 entry_info 0x10 long
math entries == directory_value_03
math entries + 1
getvarchr directory_value_04 entry_info 0x14 long
xmath entry_info_offset "(directory_value_04 - 0x18) << 11"
if entry_name == "fa1"
xmath directory_info_limit "entry_info_offset + ((entries - 3) * 0x20)"
elif entry_name == "title"
xmath directory_info_limit "entry_info_offset + ((entries - 2) * 0x20)"
else
xmath directory_info_limit "entry_info_offset + ((entries - 1) * 0x20)"
endif
math entry == 0
endif
elif zoe_dat_ver = 2
if entry_flags == 0
if entry > 1
math current_name_number - 1
endif
getvarchr file_offset_per_entry entry_info 0x10 long
math file_offset_per_entry << 11
getvarchr file_size_per_entry entry_info 0x14 long
elif entry_flags == 0x102
math backup_name_number = current_name_number
math backup_entries_02 == entries
math current_backup_entry_02 == entry
math backup_info_offset_02 == backup_info_offset_01
getvarchr directory_value_03 entry_info 0x10 long
math entries == directory_value_03
math entries + 1
getvarchr directory_value_04 entry_info 0x14 long
xmath entry_info_offset "directory_value_04 << 11"
math entry == 0
endif
endif
endif
putarray 1 current_name_number entry_name
math name_list = current_name_number
for j = 0 <= name_list
getarray entry_name 1 j
string file_name_per_entry + entry_name
if j != name_list
string file_name_per_entry + /
endif
next j
if zoe_dat_ver = 1
if file_name_per_entry & "."
log file_name_per_entry file_offset_per_entry file_size_per_entry
endif
elif zoe_dat_ver = 2
if entry_flags == 0
log file_name_per_entry file_offset_per_entry file_size_per_entry
endif
endif
if zoe_dat_ver = 1
if naming_type = 1
if entry == last_entry
math current_name_number - backup_name_number
math entries == backup_entries_01
math entry == current_backup_entry_01
math entry_info_offset == backup_info_offset_01
endif
elif naming_type = 2
if entry_info_offset = directory_info_limit
math current_name_number - backup_name_number
math entries == backup_entries_02
math entry == current_backup_entry_02
math entry_info_offset == backup_info_offset_02
endif
endif
elif zoe_dat_ver = 2
if entry == last_entry
if naming_type = 1
math current_name_number - backup_name_number
math entries == backup_entries_01
math entry == current_backup_entry_01
math entry_info_offset == backup_info_offset_01
elif naming_type = 2
math current_name_number - backup_name_number
math entries == backup_entries_02
math entry == current_backup_entry_02
math entry_info_offset == backup_info_offset_02
endif
endif
endif
next entry
startfunction hashing_algorithm
math hash = 0
math result = 0
for i = 0 < byte_size
get overall_byte byte
xmath hash "hash + ((hash << (overall_byte & 0x0f)) | (hash >> 3) + (overall_byte << (char & 0x0f)) + overall_byte)"
next i
math result = hash
endfunction