Advertisement
Faschz

Majora's Mask - debug_finder

May 10th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. -- debug_finder.lua
  2. --
  3. -- This script is designed to run on Majora's Mask (U), however can easily be
  4. -- changed to run on (J) by making changes to addresses/sizes.
  5. --
  6. -- This script checks the strings written from index warp to see if they will
  7. -- cause overflow into the debug menu (inventory editor). These indices that are
  8. -- pulled from this script most likely will crash on N64 due to printed
  9. -- characters crashing, however on VC or Wii U they will not crash until you
  10. -- reach a loading zone.
  11. --
  12. -- Author: @Faschz
  13. -- Created: May 5th, 2019
  14. -- Updated: August 7th, 2019
  15.  
  16. -- All specific to the current language/version of the game.
  17. STRING_BASE = 0x1D0714  -- Address to the start of the table for the strings.
  18. LENGTH_BASE = 0x1D07C4  -- Address to the start of the table for the lengths.
  19. ENTRANT_SIZE = 16       -- Size of each entrant of the string table.
  20.  
  21. -- The amount of bytes offset from the start of the written string in order to
  22. -- reach the specific addresses.
  23. PAUSE_OFFSET = 1767
  24. DEBUG_OFFSET = 1769
  25.  
  26. -- The calculated required length to overwrite the addresses from the text
  27. -- overflow glitch without the use of the instruction counter.
  28. REQUIRED_LENGTH = DEBUG_OFFSET + 1 -- Added 1 because the address is a short.
  29.  
  30. -- The address for the index is a signed short, so the value range is as follows
  31. for index=-32768, 32767 do
  32.     -- On Japanese the length is not in bytes, but instead shorts due to
  33.     -- fact that characters on J are 2 bytes instead of 1.
  34.     length = mainmemory.read_s16_be(LENGTH_BASE + 2*index)
  35.    
  36.     if (length >= REQUIRED_LENGTH) then
  37.         -- Read what the values would be for the overwritten addresses
  38.         pause = mainmemory.read_u16_be(STRING_BASE + ENTRANT_SIZE*index +
  39.                                         PAUSE_OFFSET)
  40.         editor = mainmemory.read_u16_be(STRING_BASE + ENTRANT_SIZE*index +
  41.                                         DEBUG_OFFSET)
  42.  
  43.         -- These values make for a workable inventory editor that can be saved
  44.         -- through the use of the left over OoT save menu.
  45.         if ((editor == 1 or editor == 2) and (pause >= 9 and pause <= 14)) then
  46.             print(index)
  47.         end
  48.     end
  49.  
  50. end
  51.  
  52. print("Finished debug_finder.lua!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement