Skip to content

How was this project originally set up

AnonymousRandomPerson edited this page Oct 3, 2023 · 2 revisions
  1. Start with an existing DS project like HeartGold (and make sure you can build it).
  2. Remove any project-specific files (e.g., C source, ASM, data files) and replace any reference to the old game name with the new game name.
  3. Find the SHA-1 hash of the ROM from Dat-o-Matic and add it to rom.sha1. Make sure your own copy of the ROM has the same hash, as many DS ROMs are improperly dumped.
  4. Dump the ROM with a tool like DSLazy or ndstool.
  5. Use the dumped header file to fill in the game's internal name and code in the Makefiles. Add the header as rom_header_template.sbin in the decomp.
  6. Load the ARM9 and overlays into a disassembler program like Ghidra or IDA and run auto-analysis to locate functions.
  7. Use ndsdisasm along with the function addresses from the disassembler to dump the ASM from ARM9 and overlays in a decomp-friendly format.
  8. Locate "holes" in the disassembly where functions are incorrectly left as data bytes. Add these to the ndsdisasm config and re-disassemble until the holes are filled.
  9. Add assembly files to the decomp with these disassemblies.
  10. Dump any additional non-code bytes that come after the disassembled functions.
  11. Take the start of ARM9 and move it to the secure area and crt0.s files.
  12. Locate ITCM and DTCM functions and extract those out of ARM9.
  13. Use the dumped overlay table to fill in main.lsf with the overlays and their order.
  14. Add the SHA-1 hashes for ARM9/overlays in main.sha1.
  15. Attempt to build the project and fill in the includes from ASM files cross-referencing each others' functions.
  16. If any overlays get optimized out, ensure that there is at least one reference to the overlay from the program start. Locate any pointer to that overlay from the other overlays or ARM9 and turn it into a symbol if needed.
  17. Continue until ARM9 and overlays match.
  18. Look in the overlay table and match the boundaries of the data and BSS sections of ARM9/overlays.
  19. Dump ARM7 in the same way as ARM9, then add it to the decomp.
  20. Split off the WRAM section of ARM7.
  21. Build the project and ensure that ARM7 matches.
  22. Add the SHA-1 hash for ARM7 and ensure that the ARM7 code builds and matches.
  23. Add the data files to the project along with their SHA-1 hashes.
  24. Add each data file to the Makefile. Ensure that the data files are listed in the same order that they are located at in the ROM.
  25. Convert the dumped banner to a PNG and add it to the project. The Unarchiver (Mac only) can dump the banner from the ROM into a PNG.
  26. Build the project and ensure that the complete ROM matches.
  27. Find a simple function (or a few) and try to decompile them in decomp.me. Play around with the compiler version and compiler flags until the function matches.
  28. Add the decompiled function to the project and swap out the proper compiler version and flags.
  29. Build the project and ensure that the complete ROM still matches with the decompiled function.
  30. Start decompiling all the things!
Clone this wiki locally