Advertisement
Faschz

Majora's Mask - brute_force

Apr 10th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. -- brute_force.lua
  2. --
  3. -- Brute force search for some interesting results of Index Warp.
  4. -- Used for Majora's Mask (U), can be changed to (J) by changing
  5. -- memory addresses to their equivalent value
  6. --
  7. -- Author: @Faschz
  8. -- Created: April 10th, 2019
  9.  
  10. MAP_INDEX_ADDR = 0x3FDA90
  11.  
  12. MENU_ADDR = 0x3FDA3C
  13. DEBUG_ADDR = 0x3FDA3E
  14. NOTEBOOK_ADDR = 0x3FDA40
  15.  
  16. -- 'S' in "Soar to" part of the textbox, used for checking when the textbox is written
  17. MESSAGE_ADDR = 0x3FD34C
  18.  
  19. for index=-32768, 32767 do
  20.     -- Load state ready to select a Song of Soaring location
  21.     savestate.loadslot(2)
  22.    
  23.     -- Write the index
  24.     mainmemory.write_s16_be(MAP_INDEX_ADDR, index)
  25.    
  26.     -- Select the index
  27.     joypad.set({["A"] = true}, 1)
  28.     emu.frameadvance()
  29.     joypad.set({["A"] = false}, 1)
  30.            
  31.     -- Wait for the textbox to appear
  32.     repeat
  33.         emu.frameadvance()
  34.     until mainmemory.readbyte(MESSAGE_ADDR) == 0x53
  35.     emu.frameadvance()
  36.    
  37.     -- Additional waiting, only so many characters can be written per VI
  38.     for frame=0, 30 do
  39.         emu.frameadvance()
  40.     end
  41.    
  42.     -- Begin checking for the interesting results
  43.     if (mainmemory.read_u16_be(MENU_ADDR) >= 4 and mainmemory.read_u16_be(MENU_ADDR) <= 14) or
  44.             (mainmemory.read_u16_be(MENU_ADDR) >= 16 and mainmemory.read_u16_be(MENU_ADDR) <= 18) then
  45.         print("Menu: "..index)
  46.     end
  47.  
  48.     if mainmemory.read_u16_be(DEBUG_ADDR) == 1 or mainmemory.read_u16_be(DEBUG_ADDR) == 2 then
  49.         print("Debug: "..index)
  50.     end
  51.    
  52.     if mainmemory.readbyte(NOTEBOOK_ADDR) ~= 0 then
  53.         print("Notebook: "..index)
  54.     end
  55.    
  56. end
  57.  
  58. print("DONE!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement