-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy paththe_bouncer.bms
More file actions
249 lines (241 loc) · 6.4 KB
/
the_bouncer.bms
File metadata and controls
249 lines (241 loc) · 6.4 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# The Bouncer
# ---
# v1 by AnonBaiter (initial version)
# v2 by bnnm (.nam names)
# v3 by AnonBaiter (filling in the gaps)
# v4 by AnonBaiter (removing "sz" part as there's no need for that)
# v5 by AnonBaiter (massive re-write around here)
get bouncer_filename filename
get bouncer_extension extension
math 32bit_minus_one = 0xffffffff
if bouncer_filename == "BOUNCER.bin"
callfunction PARSE_BIN_1 1
elif bouncer_filename == "bgmdata.bin" || bouncer_filename == "bgmlist.bin" || bouncer_filename == "bgmofst.bin"
callfunction PARSE_BIN_2 1
elif bouncer_filename == "bgmwddat.bin" || bouncer_filename == "bgmwdtbl.bin"
callfunction PARSE_BIN_2 1
elif bouncer_filename == "sdwddat.bin" || bouncer_filename == "sdwdtbl.bin"
callfunction PARSE_BIN_3 1
else
if bouncer_extension == "tbl" || bouncer_extension == "nam" || bouncer_extension == "dat"
open FDDE "tbl" 0
open FDDE "nam" 1
open FDDE "dat" 2
math file_number = 0
callfunction tbl_nam_bgmlist_init_header_info 1
math file_number = 1
callfunction tbl_nam_bgmlist_init_header_info 1
math final_files = 0
for i = 0 < tnb_files
getarray file_offset 0 i
getarray file_size 1 i
getarray file_name 2 i
if file_offset != 32bit_minus_one || file_size != 32bit_minus_one
putarray 3 final_files file_offset
putarray 4 final_files file_size
putarray 5 final_files file_name
math final_files + 1
endif
next i
for i = 0 < final_files
getarray file_offset 3 i
math file_offset << 11
getarray file_size 4 i
getarray file_name 5 i
log file_name file_offset file_size 2
next i
elif bouncer_extension == "bin"
get is_iz01 long
if is_iz01 == 0x31305a49 # IZ01
get iz01_02 long
if iz01_02 != 0
cleanexit
endif
get iz01_03 long
if iz01_03 != 0x72657375
cleanexit
endif
get iz01_04 long
if iz01_04 != 0
cleanexit
endif
get iz01_05 long
if iz01_05 != 1
cleanexit
endif
get original_size long
else
goto 0
callfunction PARSE_BIN_1 1
endif
endif
endif
startfunction PARSE_BIN_1
get bin_files long
xmath bin_file_info_sector_size "((bin_files + 1) * 4) + 8"
xmath modulus_test_01 "bin_file_info_sector_size % (1 << 5)"
if modulus_test != 0
xmath iz01_size_collection_offset "((bin_file_info_sector_size >> 5) + 1) << 5"
endif
get name_string_collection_offset long
math name_string_collection_offset << 11
for i = 0 <= bin_files
get file_offset long
putarray 0 i file_offset
next i
if bouncer_filename == "BOUNCER.bin"
math iz01_file_start = 7
math last_uncompressed_file = 6
goto iz01_size_collection_offset
for i = 0 < bin_files
if i <= last_uncompressed_file
putarray 1 i 0
elif i >= iz01_file_start
get iz01_size long
putarray 1 i iz01_size
endif
next i
endif
goto name_string_collection_offset
for i = 0 < bin_files
get file_name_string_offset long
putarray 2 i file_name_string_offset
next i
xmath iso9660_block_size "1 << 11"
for i = 0 < bin_files
getarray file_name_string_offset 2 i
math file_name_string_offset + iso9660_block_size
goto file_name_string_offset
get file_name string
putarray 3 i file_name
next i
for i = 0 < bin_files
getarray aid_01 0 i
math i + 1
getarray aid_02 0 i
math i - 1
xmath file_size "(aid_02 - aid_01) << 11"
putarray 4 i file_size
next i
for i = 0 < bin_files
getarray file_offset 0 i
math file_offset << 11
if bouncer_filename == "BOUNCER.bin"
getarray iz01_decompressed_size 1 i
endif
getarray file_name 3 i
getarray file_size 4 i
log file_name file_offset file_size
next i
endfunction
startfunction PARSE_BIN_2
open FDSE "bgmlist.bin" 0
open FDSE "bgmofst.bin" 1
open FDSE "bgmdata.bin" 2
open FDSE "bgmwdtbl.bin" 3
open FDSE "bgmwddat.bin" 4
math file_number = 0
callfunction tbl_nam_bgmlist_init_header_info 1
math file_number = 1
math data_number = 2
callfunction parse_tbl_dat_bin_headers 1
math file_number = 3
math data_number = 4
callfunction parse_tbl_dat_bin_headers 1
endfunction
startfunction PARSE_BIN_3
open FDSE "sdwdtbl.bin" 0
open FDSE "sdwddat.bin" 1
math file_number = 0
math data_number = 1
callfunction parse_tbl_dat_bin_headers 1
endfunction
startfunction parse_tbl_dat_bin_headers
get id_01 long file_number
get id_02 long file_number
get td_files long file_number
get td_block_size long file_number
math a = 0
for i = 0 < td_files
get file_offset long file_number
get file_size long file_number
if file_offset != 32bit_minus_one || file_size != 32bit_minus_one
putarray 11 a file_offset
putarray 12 a file_size
if id_01 == 0x4f4d4742
if id_02 == 0x545346
# "BGMOFST"
getarray file_name 0 a
endif
endif
if id_01 == 0x4d4742
if id_02 == 0
# "BGM"
getarray file_name 1 a
endif
endif
if id_01 == 0x4553
if id_02 == 0
# "SE"
string file_name p "se%03d.wd" i
endif
endif
putarray 13 a file_name
math a + 1
endif
next i
for i2 = 0 < a
getarray file_offset 11 i2
math file_offset << 11
getarray file_size 12 i2
getarray file_name 13 i2
log file_name file_offset file_size data_number
next i2
endfunction
startfunction tbl_nam_bgmlist_init_header_info
math array_listing_is_generated = 0
get tnb_01 long file_number
get tnb_02 long file_number
get tnb_files long file_number
get tnb_04 long file_number
if tnb_01 == 0
get bgmlist_size asize file_number
xmath bgmlist_files "((bgmlist_size - (1 << 4)) >> 4) >> 1"
for i = 0 < bgmlist_files
for j = 0 < 2
get bgm_id long 0
getdstring bgm_name 12 0
if j = 0
string bgm_name + ".bgm"
elif j = 1
string bgm_name + ".wd"
endif
putarray j bgm_id bgm_name
next j
next i
endif
if tnb_01 == 0x5453464f
for i = 0 < tnb_files
get file_offset long file_number
get file_size long file_number
if file_number = 0
putarray 0 i file_offset
putarray 1 i file_size
endif
next i
endif
if tnb_01 == 0x454d414e
for i = 0 < tnb_files
if file_number = 1
getarray file_offset 0 i
getarray file_size 1 i
if file_offset != 32bit_minus_one || file_size != 32bit_minus_one
getdstring file_name 8 file_number
putarray 2 i file_name
else
putarray 2 i ""
endif
endif
next i
endif
endfunction