Advertisement
LuigiBlood

TutorialOverlayTable

Feb 8th, 2012
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. How to fix the Overlay Table ^^
  2. (Tutorial made for Rockman EXE Operate Shooting Star)
  3.  
  4. So, if you use CrystalTile2 or anything, you should be able to look at a file called: 'arm9ovltable.bin' (or something like that).
  5. I have to explain how overlays works though. (Even if you know it, i will still explain)
  6.  
  7. The NDS can't run code directly on ROM, unlike the GBA, it needs to copy code (or in this case, text) on RAM and then execute/read it.
  8. Here's how the overlay table works (blatantly copied from HackMii, duh):
  9. /* 0x00 */ u32 id;
  10. /* 0x04 */ u32 ram_addr;
  11. /* 0x08 */ u32 ram_size;
  12. /* 0x0C */ u32 bss_size;
  13. /* 0x10 */ u32 sinit_init;
  14. /* 0x14 */ u32 sinit_init_end;
  15. /* 0x18 */ u32 file_id;
  16. /* 0x1C */ u32 unknown;
  17.  
  18. The hex value in /* ??? */ is the offset, and every value takes 4 bytes (32-bit) and in little endian.
  19. For the sake to be able to completely understand what's Little Endian and Big Endian, here's an exemple:
  20. Let's take an easy to understand 32-bit Hexadecimal value: 0x12345678
  21. Let's say you look in a Hex Editor, and values don't appear straight-forward:
  22.  
  23. The Big Endian, is easy to understand, the way the value will appear, is like this:
  24. 0x00000000: 12 34 56 78
  25.  
  26. Quite easy huh?
  27. But this is the tricky part, the Little Endian, here's the way it appears:
  28. 0x00000000: 78 56 34 12
  29.  
  30. Bytes are inverted, and it's like that 90% of the time on most of the game consoles, and even PC programs. NEVER forget that.
  31.  
  32. Let's go back to this:
  33. /* 0x00 */ u32 id;
  34. /* 0x04 */ u32 ram_addr;
  35. /* 0x08 */ u32 ram_size;
  36. /* 0x0C */ u32 bss_size;
  37. /* 0x10 */ u32 sinit_init;
  38. /* 0x14 */ u32 sinit_init_end;
  39. /* 0x18 */ u32 file_id;
  40. /* 0x1C */ u32 unknown;
  41.  
  42. Every value is inverted, but the order you see, is not inverted, keep that in mind, only the values are.
  43. On NDS, the RAM is at 0x02000000, this is a Memory Address. The overlay table is that list i gave you, but repeats until the last overlay file.
  44.  
  45. This is the parts of the overlay table that we need to look;
  46. /* 0x00 */ u32 id;
  47. /* 0x04 */ u32 ram_addr;
  48. /* 0x10 */ u32 sinit_init;
  49.  
  50. Not really much huh?
  51. Anyway, the id part is important (after all, you need to know which overlay you are editing), in this case, i'll be editing Overlay9_261 (which i had problems with, it's text for everything in Lan's Room).
  52. We kinda need to convert 261 from decimal to hexadecimal...
  53. Take the Windows Calculator, or do it online (with the random website i found): http://www.statman.info/conversions/hexadecimal.html
  54. 261 = 0x105. (Note: 0x means the value is in hexadecimal, in that website, it won't appear like that.)
  55.  
  56. Search for 05 01 00 00 (remember Little Endian?) in the Overlay Table file.
  57. Here's how it looks to me (in the original version):
  58. 05 01 00 00 E0 E2 2B 02 00 0A 00 00 00 00 00 00
  59. D4 EC 2B 02 D8 EC 2B 02 05 01 00 00 BC 06 00 01
  60.  
  61. Let me say what's on it:
  62. 05 01 00 00 E0 E2 2B 02 00 0A 00 00 00 00 00 00
  63. [ id ] [ ram_addr] [ ram_size] [ bss_size]
  64. D4 EC 2B 02 D8 EC 2B 02 05 01 00 00 BC 06 00 01
  65. [ sinit ] [sinit_end] [ file_id ] [ unknown ]
  66.  
  67. So Overlay9_261 is copied to RAM address 0x022BE2E0.
  68. The thing that was messing up everything is the sinit parts.
  69. For some reason, the game runs code at the sinit part after it finishes copying the Overlay data.
  70.  
  71. But when the file has a different size, sometimes it gets what was not expected, and crashes the game.
  72. So, the sinit part is at RAM 0x022BECD4. To know where it is in the Overlay File:
  73. sinit - ram_addr. In this case: 0x022BECD4 - 0x022BE2E0 = 0x9F4 (use the Windows Calculator)
  74. Also, take a look at sinit_end. It ends 4 bytes after the sinit data.
  75. 0x022BECD8 (sinit_end) - 0x022BECD4 (sinit) = 0x4.
  76.  
  77. Look at 0x9F4 of the uncompressed Overlay File. It only contains 00s, and it's almost at the end of the file. At the modified file (bigger or shorter), it should be pointed TO THE SAME DATA (and also, MUST be a multiple of 4).
  78. Just take the offset of where it is in the overlay file with the hex editor, let's say it's at 0x102C, i made the file bigger.
  79.  
  80. So, to know how to edit the sinit value:
  81. 0x102C (where the data pointed is now) + 0x022BE2E0 (aka ram_addr) = 0x022BF30C.
  82. You have now the new sinit offset. Don't forget the sinit_end part (0x022BF30C + 0x4 = 0x022BF310 in this case)
  83.  
  84. Also, if you use CrystalTile2, edit the sinit AFTER replacing the overlay file. Reload the ROM, to be sure of not doing any mistakes (you might save the old settings...).
  85. Anyway, here's the new table data:
  86. 05 01 00 00 E0 E2 2B 02 38 10 00 00 00 00 00 00
  87. 0C F3 2B 02 10 F3 2B 02 05 01 00 00 BC 06 00 01
  88. [ EDITED PART ]
  89. (Only care about the sinit parts, CrystalTile2 does the other stuff by itself)
  90. Now, the overlay file should work fine.
  91.  
  92. All right. I hope it's understandable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement