Advertisement
exodus122

MM JP 1.0 brute force

Apr 11th, 2019
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 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 (J)
  5. --
  6. -- Author: @Faschz (modified by Exodus)
  7. -- Created: April 10th, 2019
  8.  
  9. MAP_INDEX_ADDR = 0x3FDC40
  10.  
  11. MENU_ADDR = 0x3FDBEC
  12. DEBUG_ADDR = 0x3FDBEE
  13. NOTEBOOK_ADDR = 0x3FDBF0
  14.  
  15. BASE_ADDRESS_LENGTH = 0x1CAEC8
  16.  
  17. file = io.open('debug_JP_1.0.txt', 'w')
  18.  
  19. for index = -32768, 32767 do
  20.     -- Load state ready to select a Song of Soaring location
  21.     savestate.loadslot(2)
  22.    
  23.     length = mainmemory.read_s16_be(bit.band(BASE_ADDRESS_LENGTH + bit.lshift(index, 1), 0xFFFFFF))
  24.    
  25.     -- Write the index
  26.     mainmemory.write_s16_be(MAP_INDEX_ADDR, index)
  27.    
  28.     -- Select the index
  29.     joypad.set({["A"] = true}, 1)
  30.     emu.frameadvance()
  31.     joypad.set({["A"] = false}, 1)
  32.            
  33.     -- Wait for the textbox to appear
  34.     for f=0,60 do
  35.         emu.frameadvance()
  36.     end
  37.    
  38.     goodmenu = false
  39.     gooddebug = false
  40.    
  41.     print(index.." ("..length..")")
  42.     file:write(index.." ("..length..")\n")
  43.    
  44.     -- Begin checking for the interesting results
  45.     menub = mainmemory.read_u16_be(MENU_ADDR)
  46.     if (menub >= 9 and menub <= 14) or
  47.             (menub >= 16 and menub <= 18) then
  48.         print("Menu: "..menub)
  49.         file:write("Menu: "..menub.."\n")
  50.         goodmenu = true
  51.     end
  52.  
  53.     debugb = mainmemory.read_u16_be(DEBUG_ADDR)
  54.     if debugb == 1 or debugb == 2 then
  55.         print("Debug: "..debugb)
  56.         file:write("Debug: "..debugb.."\n")
  57.         gooddebug = true
  58.     end
  59.    
  60.     noteb = mainmemory.readbyte(NOTEBOOK_ADDR)
  61.     if noteb ~= 0 then
  62.         print("Notebook: "..noteb)
  63.         file:write("Notebook: "..noteb.."\n")
  64.     end
  65.  
  66.     if((goodmenu == true) and (gooddebug == true)) then
  67.         print("SOLUTION")
  68.         file:write("SOLUTION\n")
  69.     end
  70.    
  71. end
  72.  
  73. file:close()
  74.  
  75. print("DONE!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement