Advertisement
Guest User

mgs2_dat.bms - sixth test patch

a guest
Dec 19th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.75 KB | None | 0 0
  1. # Metal Gear Solid 2(both Original(PS2), Document(PS2) and Substance(PS2/XBOX) editions)
  2. # Metal Gear Solid The Twin Snakes
  3. # Zone of the Enders The 2nd Runner(both the original(PS2) and Special Edition(PS2) versions)
  4. # Metal Gear Solid 3(both Original(PS2) and Subsistence(PS2 - DVD5x3) versions)
  5.  
  6. get archive_name basename
  7. get archive_size asize
  8.  
  9. if archive_name & "stage" | archive_name & "face"
  10. get sign1 long
  11. get sign2 long
  12. if sign1 == 0x00000001
  13. endian little
  14. goto 0
  15. callfunction stage_extract 1
  16. elif sign1 == 0x10000000
  17. endian big
  18. goto 0
  19. callfunction stage_extract 1
  20. else
  21. if sign2 == 0x00010001
  22. endian little
  23. goto 0
  24. callfunction stage_extract 1
  25. elif sign2 == 0x01000100
  26. endian big
  27. goto 0
  28. callfunction stage_extract 1
  29. else
  30. print "whoops"
  31. cleanexit
  32. endif
  33. endif
  34. elif archive_name & "codec"
  35. elif archive_name & "slot"
  36. else
  37. get offset_limit asize
  38. get endian_check long
  39. endian guess endian_check
  40. goto 0
  41. math xz = 1
  42. for y = 0
  43. math y2 = 0
  44. string name p "%s_%08d" archive_name xz
  45. append
  46. do
  47. savepos offset
  48. math initial_info = 0
  49. get dummy01 long
  50. get size long
  51. get count1 long
  52. get zero long
  53. if dummy01 == 0x10
  54. if size == 0x10
  55. if count1 == 0
  56. math initial_info = 1
  57. putarray 11 y2 zero
  58. math y2 + 1
  59. endif
  60. endif
  61. elif dummy01 == 0xf0
  62. math initial_info = 1
  63. endif
  64. putarray 11 y2 ""
  65. if dummy01 != 0
  66. if initial_info = 0
  67. math total_types = y2
  68. math last_type = total_types
  69. for t1 = 0 <= total_types
  70. getarray file_type 11 t1
  71. if dummy01 == file_type
  72. putarray 1 30 dummy01
  73. putarray 2 30 size
  74. putarray 3 30 count1
  75. putarray 4 30 zero
  76. if size == size
  77. if count1 == count1
  78. if zero == zero
  79. log name offset size
  80. break
  81. endif
  82. endif
  83. endif
  84. else
  85. if t1 = last_type
  86. math size = 0x10
  87. log name offset size
  88. endif
  89. endif
  90. next t1
  91. elif initial_info = 1
  92. log name offset size
  93. endif
  94. else
  95. break
  96. endif
  97. if offset <= offset_limit
  98. math offset + size
  99. goto offset
  100. endif
  101. while dummy01 != 0
  102. append
  103. math xz + 1
  104. next y
  105. endif
  106.  
  107. startfunction stage_extract
  108. get sd01 long
  109. if sd01 != 1
  110. goto -4 0 SEEK_CUR
  111. get time_stamp time
  112. endif
  113. get sd02 long
  114. xmath minor_version "sd02 & 0xffff"
  115. xmath minor_version "sd02 >> 16"
  116. get sd03 long
  117. xmath stage_entries "sd03 & 0xffff"
  118. xmath stage_dat_signature "sd03 >> 16"
  119. get sd04 long
  120. for i = 0 < stage_entries
  121. getdstring stage_name 8
  122. get stage_offset long
  123. math stage_offset << 11
  124. savepos stage_temp_position_01
  125. goto stage_offset
  126. get file_entries long
  127. xmath file_offset "(((file_entries * 8) + 4) && 0x800) + stage_offset"
  128. for j = 0 < file_entries
  129. get h1 long
  130. xmath c1 "h1 >> 24"
  131. putarray 1 j c1
  132. xmath c2 "h1 & 0xffffff"
  133. putarray 2 j c2
  134. get h2 long
  135. putarray 3 j h2
  136. next j
  137. goto stage_temp_position_01
  138. math end_of_line = 0
  139. math sdx_is_here = 0
  140. string directory_name_per_entry p "%s/" stage_name
  141. set sub_directory_name_per_entry string ""
  142. set file_name_per_entry string ""
  143. set full_file_name_per_entry string ""
  144. for j2 = 0 < file_entries
  145. putarray 4 j2 file_offset
  146. getarray file_type 1 j2
  147. if file_type == 0x7f
  148. getarray dynamic_type 2 j2
  149. getarray dynamic_size 3 j2
  150. string sub_directory_name_per_entry p "%06x/" dynamic_type
  151. if dynamic_type == 0
  152. math file_offset x 0x800
  153. if sdx_is_here = 1
  154. math sdx_is_here = 0
  155. endif
  156. math end_of_line = 1
  157. else
  158. math end_of_line = 0
  159. if dynamic_type = 0x10
  160. math sdx_is_here = 1
  161. endif
  162. endif
  163. else
  164. if end_of_line = 0
  165. if sdx_is_here = 0
  166. getarray file_name_hash 2 j2
  167. if file_name_hash != 0
  168. getarray singular_file_offset 3 j2
  169. math j2 + 1
  170. getarray next_file_offset 3 j2
  171. math j2 - 1
  172. xmath singular_file_size "next_file_offset - singular_file_offset"
  173. endif
  174. string file_name_per_entry p "%06x.%02x" file_name_hash file_type
  175. elif sdx_is_here = 1
  176. getarray file_name_hash 2 j2
  177. getarray singular_file_offset 3 j2
  178. math j2 + 1
  179. getarray next_file_offset 3 j2
  180. math j2 - 1
  181. xmath singular_file_size "next_file_offset - singular_file_offset"
  182. string file_name_per_entry p "pk%06x.sdx" individual_name_hash
  183. endif
  184. string full_file_name_per_entry p "%s%s%s" directory_name_per_entry sub_directory_name_per_entry file_name_per_entry
  185. log full_file_name_per_entry file_offset singular_file_size
  186. math file_offset + singular_file_size
  187. endif
  188. endif
  189. next j2
  190. next i
  191. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement