-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdark_cloud.bms
More file actions
200 lines (197 loc) · 5.37 KB
/
dark_cloud.bms
File metadata and controls
200 lines (197 loc) · 5.37 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
# Level-5 games / Dark Cloud (2021/10/08)
# original script by aluigi, modified by RetingencyPlan
# ---
# in every Level-5 game on the PS2, there was this
# self-contained archvial file whose format
# kinda changed across many of their releases.
get EXT extension
if EXT == "HED"
# Dark Cloud (PS2) - strangely enough, data.hed comes from the full USA release of the game
open FDDE "DAT" 1
get hed_size asize # necessary because of how simple this format is, later HD# formats put a delimiter of sorts to tell the game that there's no files to read beyond that point.
xmath files "hed_size / 0x50" # calculate the number of files through the hed_size value
for i = 0 < files
getdstring file_name 0x40 # garbage leaks everywhere
get file_offset long
get file_size long
get file_offset_in_cdvd_sectors long
math file_offset_in_cdvd_sectors << 11
if file_offset != file_offset_in_cdvd_sectors
break
endif
get file_size_in_cdvd_sectors long
math file_size_in_cdvd_sectors << 11
callfunction check_file_size 1
log file_name file_offset file_size 1
next i
elif EXT == "HD2"
# Dark Cloud (PS2) - data.hd2, used elsewhere including the aforementioned USA release
open FDDE "DAT" 1
for
get name_offset long
savepos temp_01
goto name_offset
get file_name string
if file_name == "" # when i said "delimiter of sorts" i meant EXACTLY that, if the file_name value contains literally nothing, that's it.
break
endif
goto temp_01
get hd2_02 long # always 0
if hd2_02 != 0
break
endif
get hd2_03 long # ditto
if hd2_03 != 0
break
endif
get hd2_04 long # ditto
if hd2_04 != 0
break
endif
get file_offset long
get file_size long
get file_offset_in_cdvd_sectors long
math file_offset_in_cdvd_sectors << 11
if file_offset != file_offset_in_cdvd_sectors
break
endif
get file_size_in_cdvd_sectors long
math file_size_in_cdvd_sectors << 11
callfunction check_file_size 1
log file_name file_offset file_size 1
next
elif EXT == "HD3"
# Dark Chronicle/Dark Cloud 2 (PS2)
open FDDE "DAT" 1
for
get name_offset long
savepos temp_01
goto name_offset
get file_name string
if file_name == ""
break
endif
goto temp_01
get file_size long
get file_offset long
math file_offset << 11
get file_size_in_cdvd_sectors long
math file_size_in_cdvd_sectors << 11
callfunction check_file_size 1
log file_name file_offset file_size 1
next
elif EXT == "HD4"
# Dark Chronicle/Dark Cloud 2 (PS2)
open FDDE "DAT" 1
for
get name_offset long
savepos temp_01
goto name_offset
get file_name string
if file_name == ""
break
endif
goto temp_01
get file_size long
get file_offset long
math file_offset << 11
log file_name file_offset file_size 1
next
elif EXT == "HD5"
# Dragon Quest VIII Premium Eizou Disc (SLPM-62490)
open FDDE "DAT" 1
for
get name_offset long
savepos temp_01
goto name_offset
get file_name string
goto temp_01
if file_name == ""
break
endif
get file_02 long # always 0
if file_02 != 0
break
endif
get file_size_01 long
get file_size_02 long
get file_offset long
math file_offset << 11
if file_size_01 != file_size_02
break
endif
log file_name file_offset file_size_01 1
next
elif EXT == "HD6"
# Dragon Quest VIII (PS2)
# Rogue Galaxy (PS2)
open FDDE "DAT" 1
idstring "HD6\0"
get keyword_info_offset long
get keyword_info_size long
get total_keywords long
get hd6_04 long
if hd6_04 != 0
break
endif
get keyword_fetch_offset long
get keyword_fetch_size long
get hd6_07 long
if hd6_07 != 0
break
endif
get block_size_per_file long
get files long
get file_info_offset long
get hd6_11 long
if hd6_11 != 0
break
endif
get hd6_size long
goto keyword_info_offset
for a = 0 < total_keywords
get keyword string
putarray 0 a keyword
next a
goto file_info_offset
for i = 0 < files
# HD6 structure has a bug in which the last actual file gets repeated twice.
#getdstring hd6_file_info 8
getbits name_offset 18
math name_offset + keyword_fetch_offset
savepos temp_01
goto name_offset
set file_name string ""
do
get keyword_number variable4
getarray keyword 0 keyword_number
string file_name + keyword
while keyword_number != 0
goto temp_01
if file_name == ""
break
endif
getbits file_offset 22
math file_offset << 11
getbits file_size 24
math file_size * block_size_per_file
log file_name file_offset file_size 1
next i
else
print " this script can only work with .hed/.hd2/.hd3/.hd4/.hd5/.hd6 files at this point. "
cleanexit
endif
startfunction check_file_size
# what this function does is it compares one file size value to another
# with the DVD block size number as a basis to do the comparison from.
# although, given that the game streams everything from disk
# this is simply here for information sake.
xmath modulus1 "2048 - (file_size_in_cdvd_sectors % 2048)"
xmath modulus2 "2048 - (file_size % 2048)"
if modulus1 == modulus2
print " file size is aligned to a multiple of 2048 (DVD sector size) "
else
string wv1 p "%s blank spaces" modulus2
print " file size is short of %wv1% "
endif
endfunction