Advertisement
exodus122

MM J 1.1 Debug Menu finder

May 6th, 2019
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. -- debug_finder_j.lua
  2. --
  3. -- For use with Majora's Mask (J) 1.1
  4. -- Open up the Song of Soaring menu before activating the script
  5. -- Check if any of the substrings for the destination will cause the debug menu
  6. -- to appear as well as the OoT Save menu. These results would only be theoretically
  7. -- possible on VC due to crashing.
  8. --
  9. -- Author: @Faschz (modified by Exodus)
  10. -- Created: May 5th, 2019
  11.  
  12. MESSAGE_ADDRESS = 0x1CB010
  13. LENGTH_ADDRESS = 0x1CB0D8
  14.  
  15. --If this byte is written with a value < 7... the string gets written twice
  16. INSTRUCTION_OFFSET = 191
  17.  
  18. PAUSE_OFFSET = 1742
  19. DEBUG_OFFSET = 1744
  20. REQUIRED_LENGTH = DEBUG_OFFSET/2
  21.  
  22. for index=-32768, 32767 do
  23.     -- The string is given
  24.     length = mainmemory.read_s16_be(LENGTH_ADDRESS + index*2)
  25.  
  26.     -- Check if this string would be written twice according to this short
  27.     instruction_short = mainmemory.read_s16_be(MESSAGE_ADDRESS + index*18 + INSTRUCTION_OFFSET)
  28.    
  29.     if length >= REQUIRED_LENGTH then
  30.         debug_short = mainmemory.read_u16_be(MESSAGE_ADDRESS + index*18 + DEBUG_OFFSET)
  31.         pause_short = mainmemory.read_u16_be(MESSAGE_ADDRESS + index*18 + PAUSE_OFFSET)
  32.        
  33.         if (debug_short == 1 or debug_short == 2) and (pause_short == 7 or (pause_short >= 9 and pause_short <= 14)) then
  34.             print("WORKING INDEX: "..index..", length = "..length..", menu = "..pause_short)
  35.         end
  36.  
  37.     elseif length >= INSTRUCTION_OFFSET and instruction_short < 7 and length*2 >= REQUIRED_LENGTH then
  38.         -- Here the string gets written twice, so the offset from the substring is different
  39.         -- from normal. For instance: If normally the offset was the 7th byte, but the length was 4
  40.         -- when the string is written twice it would be the 3rd byte on the 2nd write (7%4)
  41.  
  42.         --TODO: This isn't actually true 100%, because once it prints the string the first time it also
  43.         -- prints the data for the yes/no options and reprints the start of the string. So the offset would
  44.         -- have to take into account how large this data is.
  45.  
  46.         debug_short = mainmemory.read_u16_be(MESSAGE_ADDRESS + index*18 + (DEBUG_OFFSET%length))
  47.         pause_short = mainmemory.read_u16_be(MESSAGE_ADDRESS + index*18 + (PAUSE_OFFSET%length))
  48.        
  49.         --if (debug_short == 1 or debug_short == 2) and (pause_short >= 9 and pause_short <= 14) then
  50.         --  print("WORKING INDEX: "..index)
  51.         --end
  52.  
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement