Advertisement
atreyu187

Dreamcast Guides : DCRes File Re-Linking Explained

Jan 6th, 2013
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.52 KB | None | 0 0
  1. ----------------------- Page 1-----------------------
  2.  
  3. What is this "re-linking redundant files" about?
  4.  
  5. by TuxTheWise
  6.  
  7.  
  8.  
  9. I usually write this sentence in my readme files, but recently I've been receiving
  10.  
  11. some questions and tutorial requests about this theme. The problem is that some
  12.  
  13. people that wrote me made some weird questions, showing that they don't know
  14.  
  15. exactly what it's about. This short guide will explain what "re-linking redundant files"
  16.  
  17. is, at least the basic. How to do it will be explained in a (possible) future guide.
  18.  
  19.  
  20.  
  21. Note that the principle of this technique can be applied in any not-dynamic media
  22.  
  23. (like DVDs), so it's not a Dreamcast-only stuff. It also can be used to file formats with
  24.  
  25. structure similar to ISO format.
  26.  
  27.  
  28.  
  29. What are redundant files?
  30.  
  31. What I call "redundant files" are files with the same content, meaning that they
  32.  
  33. match on a byte-to-byte comparison.
  34.  
  35.  
  36.  
  37. Why are there redundant files?
  38.  
  39. Imagine you're developing a game. This game has two levels. In the disc, you create
  40.  
  41. a folder LEVEL1 and a folder LEVEL2. Now imagine that you're using a texture
  42.  
  43. BRICKS.BMP (size = 1mb) for a wall, and this texture is used in both levels. You'll
  44.  
  45. have a BRICKS.BMP in LEVEL1 folder, and a BRICKS.BMP in LEVEL2 folder. Note that
  46.  
  47. both files have the exact same information, they're byte-to-byte equal. But since
  48.  
  49. you have two copies of it in the same disc, you need to use 2mb, and 1mb is just the
  50.  
  51. copy of an already existent file.
  52.  
  53.  
  54.  
  55. That was just an example of how redundant files may appear. Note that not
  56.  
  57. necessarily redundant files have the same name.
  58.  
  59.  
  60.  
  61. It's common for Dreamcast games to have 1~10mb of redundant files, but there are
  62.  
  63. extremely cases like Resident Evil 2 where you have a 200mb duplicated file. If you
  64.  
  65. re-link this file like I did in the DCRES release, you can make the game fit on a CD-R
  66.  
  67. without downsampling any video. This technique has a wonderful potential.
  68.  
  69.  
  70.  
  71. The basic ISO structure:
  72.  
  73. Basically the ISO is the file that will be recorded in the disc. It contains all the "real"
  74.  
  75. data of the disc (physically there are more information), so it contains all the disc
  76.  
  77. files.
  78.  
  79.  
  80.  
  81. Wait... but an ISO is a single file, so how do the reader (we're upper the hardware
  82.  
  83. layer here) know how to find the files? Because ISO has a header. In this header,
  84.  
  85. among other information, you'll find the logic position and the size of all the files
  86.  
  87. inside the ISO, so the software knows exactly where to read to retrieve a file.
  88.  
  89.  
  90.  
  91. OK, let's invent a structure like an ISO, but instead of bytes, we'll be using
  92.  
  93.  
  94.  
  95. 1
  96.  
  97.  
  98. ----------------------- Page 2-----------------------
  99.  
  100. characters. We'll have three files (files A, B and C) with the following content:
  101.  
  102.  
  103.  
  104. A: TUX
  105.  
  106. B: DCRES
  107.  
  108. C: TUX
  109.  
  110.  
  111.  
  112. Our task is to put everything together in a single file, that from now on we'll call IZO.
  113.  
  114. So a natural way for an IZO would be to put everything together:
  115.  
  116.  
  117.  
  118. TUXDCRESTUX
  119.  
  120.  
  121.  
  122. Okay, everything is in a single file. But there is a problem: we can't retrieve the
  123.  
  124. information! If you haven't seen the original files yet, and I tell you to tell me what
  125.  
  126. the second file of the IZO is, you won't be able to tell me! Would it be DCRES? But it
  127.  
  128. can also be XDCREST!
  129.  
  130.  
  131.  
  132. However, you could retrieve the information if I told you that the second file starts
  133.  
  134. at position 4 and is 5 characters long. So we need to invent some kind of header.
  135.  
  136.  
  137.  
  138. For commodity, we'll also put the file name in the header.
  139.  
  140.  
  141.  
  142. For the IZO file, we could invent this type of header:
  143.  
  144.  
  145.  
  146. Quote:
  147.  
  148.  
  149.  
  150. - IZO header starts with the number of files (two characters). After that you have the
  151.  
  152. file list, a file entry after another.
  153.  
  154. - Each entry will have 5 characters.
  155.  
  156. - The first character is the file name.
  157.  
  158. - The next two characters are the start position of the file.
  159.  
  160. - The next two characters are the size of the file. So let's write our header!
  161.  
  162.  
  163.  
  164. We have three files, so we start with:
  165.  
  166.  
  167.  
  168. 03
  169.  
  170. X XX XX
  171.  
  172. X XX XX
  173.  
  174. X XX XX
  175.  
  176. TUXDCRESTUX
  177.  
  178.  
  179.  
  180. First file is file A, that starts at position 18 and is 3 characters long, so we would get:
  181.  
  182.  
  183.  
  184. 03
  185.  
  186. A 18 03
  187.  
  188. X XX XX
  189.  
  190. X XX XX
  191.  
  192. TUXDCRESTUX
  193.  
  194.  
  195.  
  196. And we write the same information for files B and C:
  197.  
  198.  
  199.  
  200. 03
  201.  
  202. A 18 03
  203.  
  204. B 21 05
  205.  
  206.  
  207.  
  208. 2
  209.  
  210.  
  211. ----------------------- Page 3-----------------------
  212.  
  213. C 26 03
  214.  
  215. TUXDCRESTUX
  216.  
  217.  
  218.  
  219. So our final file would be:
  220.  
  221.  
  222.  
  223. 03A1803B2105C2603TUXDCRESTUX
  224.  
  225.  
  226.  
  227. If I only give you this sequence of characters, you won't be able to tell me a thing
  228.  
  229. about it. Now if I give you the IZO specifications, you'll be able to tell me exactly
  230.  
  231. what files A, B and C are.
  232.  
  233.  
  234.  
  235. ISO has the same logic for files location, and it's important that you understand the
  236.  
  237. example above so you can see where I want to get.
  238.  
  239.  
  240.  
  241. Re-linking redundant files:
  242.  
  243. In the fictional IZO case above, you probably noticed that the files A and C have the
  244.  
  245. same content: TUX. You may be wondering... could we make the message three
  246.  
  247. character shorter? In other words, can I save the space of this redundant file? Yes,
  248.  
  249. you can. The idea is to make the information of the header of both files A and C to
  250.  
  251. point to the same data. Simple, right?
  252.  
  253.  
  254.  
  255. This is a simulation of how it's done in the Dreamcast games.
  256.  
  257.  
  258.  
  259. I have files A, B and C in my directory. Somehow, I know A and C are redundant files.
  260.  
  261. So I'll erase file C and put a file with 0 characters in its place. So I have:
  262.  
  263.  
  264.  
  265. A: TUX
  266.  
  267. B: DCRES
  268.  
  269. C: (nothing)
  270.  
  271.  
  272.  
  273. Now I'll create an IZO for this set of files:
  274.  
  275.  
  276.  
  277. 03
  278.  
  279. A 18 03
  280.  
  281. B 21 05
  282.  
  283. C -- 00
  284.  
  285. TUXDCRES
  286.  
  287.  
  288.  
  289. The " " can be any valid position, because file C now is 0 bytes long.
  290.  
  291.  
  292.  
  293. But I know file A and C originally had the same data, right? And I also know that I
  294.  
  295. replaced the file C for an empty file. So now I'll copy A's information over C's:
  296.  
  297.  
  298.  
  299. 03
  300.  
  301. A 18 03
  302.  
  303. B 21 05
  304.  
  305. C 18 03
  306.  
  307. TUXDCRES
  308.  
  309.  
  310.  
  311. Make the test now, try to identify files A, B and C. You'll see that you'll have the
  312.  
  313. exact information that we started from:
  314.  
  315.  
  316.  
  317. A: TUX
  318.  
  319.  
  320.  
  321. 3
  322.  
  323.  
  324. ----------------------- Page 4-----------------------
  325.  
  326. B: DCRES
  327.  
  328. C: TUX
  329.  
  330.  
  331.  
  332. Applications will see files A and C as different files, but they'll be read in the same
  333.  
  334. position in the IZO file. If we compare the IZO with redundant information and the
  335.  
  336. IZO without redundant information (after the re-link) we'll get:
  337.  
  338.  
  339.  
  340. 03A1803B2105C2603TUXDCRESTUX (28 characters)
  341.  
  342. 03A1803B2105C1803TUXDCRES (25 characters)
  343.  
  344.  
  345.  
  346. Our IZO got 3 characters smaller without loss of information. That's the idea of
  347.  
  348. redundant files re-linking, that's how you save space with it. You just have to
  349.  
  350. imagine an ISO as a set of bytes (not characters) with its own logic of files
  351.  
  352. positioning (that has the same logic of our fictional IZO).
  353.  
  354.  
  355.  
  356. Final notes:
  357.  
  358. As said, the operational part will be in a possible future guide. But know that you'll
  359.  
  360. have to fully understand this guide if you want to go on with this.
  361.  
  362.  
  363.  
  364. 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement