luckytyphlosion

MMBN6(F?) Coordinate Trigger Lua Script

Jan 21st, 2019
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- By: luckytyphlosion
  2. -- Use to determine what is picked up by each coordinate trigger struct
  3. -- Hold A when interacting with a map object (0x2013920) to see its return value (doesn't read new collision until A is released)
  4.  
  5. -- I don't like Lua.
  6.  
  7. local x = 2; -- puts text one pixel from edge
  8. local y = 1; -- puts text one pixel from edge
  9.  
  10. -- font is 4 pixels by 7 pixels
  11.  
  12. local function addY()
  13.     y = y + 8; -- 1 char == 7 pixels
  14. end
  15.  
  16. local function addX(text)
  17.     x = x + 4 * (string.len(text) + 1); -- 1 char == 4 pixels
  18. end
  19.  
  20. local function toScreen(text, sameLine)
  21.     gui.text(x, y, text);
  22.     if sameLine then
  23.         addX(text);
  24.     else
  25.         addY();
  26.     end
  27. end
  28.  
  29. function on2011A20Breakpoint()
  30.     _2011A20Str = _2011A20Str .. string.format("0x%02x, ", memory.getregister("r6"));
  31. end
  32.  
  33. function on2011D10BreakpointEventFlag()
  34.     local flagSet = memory.getregister("r0");
  35.     _2011D10Str = _2011D10Str .. string.format("0x%04x:%d", 0x1640 + memory.getregister("r6"), flagSet);
  36.     if flagSet == 0 then
  37.         _2011D10Str = _2011D10Str .. ", "
  38.     else
  39.         _2011D10Str = _2011D10Str .. "|"
  40.     end
  41. end
  42.  
  43. function on2011D10Breakpoint()
  44.     _2011D10Str = _2011D10Str .. string.format("0x%02x, ", memory.getregister("r6"));
  45. end
  46.  
  47. function on2013940Breakpoint()
  48.     _2013940Str = _2013940Str .. string.format("0x%02x, ", memory.getregister("r6"));
  49. end
  50.  
  51. function on2013920Breakpoint()
  52.     if not aInputAfterPress then
  53.         _2013920Str = _2013920Str .. string.format("0x%02x->", memory.getregister("r6"));
  54.     end
  55. end
  56.  
  57. function on2013920JumptableReturnBreakpoint()
  58.     if not aInputAfterPress then
  59.         local eventFlag = memory.getregister("r0");
  60.         _2013920Str = _2013920Str .. string.format("0x%02x", eventFlag);
  61.         if eventFlag > 0xe then
  62.             _2013920Str = _2013920Str .. ",";
  63.         else
  64.             _2013920Str = _2013920Str .. ":";
  65.         end
  66.     end
  67. end
  68.  
  69. function on2013920AfterEventFlagBreakpoint()
  70.     if not aInputAfterPress then
  71.         _2013920Str = _2013920Str .. string.format("0x%02x,", memory.getregister("r0"));
  72.     end
  73. end
  74.  
  75. _2011A20Breakpoint = 0x803166a;
  76. _2011A20Str = "";
  77. _2011D10BreakpointEventFlag = 0x8030bec;
  78. _2011D10Breakpoint = 0x8030bf0;
  79. _2011D10Str = "";
  80. _2013940Breakpoint = 0x80318f6;
  81. _2013940Str = "";
  82. _2013920Breakpoint = 0x8031ac0;
  83. _2013920JumptableReturnBreakpoint = 0x8031ad2;
  84. _2013920AfterEventFlagBreakpoint = 0x8031aee;
  85. _2013920Str = "";
  86.  
  87. memory.registerexec(_2011A20Breakpoint, on2011A20Breakpoint);
  88. memory.registerexec(_2011D10BreakpointEventFlag, on2011D10BreakpointEventFlag);
  89. memory.registerexec(_2011D10Breakpoint, on2011D10Breakpoint);
  90. memory.registerexec(_2013920Breakpoint, on2013920Breakpoint);
  91. memory.registerexec(_2013920JumptableReturnBreakpoint, on2013920JumptableReturnBreakpoint);
  92. memory.registerexec(_2013920AfterEventFlagBreakpoint, on2013920AfterEventFlagBreakpoint);
  93.  
  94. while true do
  95.     x = 2;
  96.     y = 1;
  97.     --_2011A20Str = nil;
  98.     _2011A20Str = "2011A20: ";
  99.     _2011D10Str = "2011D10: ";
  100.     _2013940Str = "2013940: ";
  101.     aInputTemp = joypad.getdown(1)["A"];
  102.     aInputPressed = (not aInputTemp ~= not aInputDown) and aInputTemp;
  103.     aInputDown = aInputTemp;
  104.     aInputAfterPress = not aInputPressed and aInputDown;
  105.     if not aInputDown then
  106.         _2013920Str = "";
  107.     --[[    framesSinceAfterAPress = 0;
  108.     else
  109.         if (_2013920Str == "") then
  110.             framesSinceAfterAPress = framesSinceAfterAPress + 1;
  111.         else
  112.             print(framesSinceAfterAPress);
  113.         end]]--
  114.     end
  115.     vba.frameadvance();
  116.     toScreen(_2011A20Str);
  117.     toScreen(_2011D10Str);
  118.     toScreen(_2013940Str);
  119.     toScreen("2013920: ");
  120.     toScreen(_2013920Str);
  121.     --toScreen(string.format("framesSinceAfterAPress: %d", framesSinceAfterAPress));
  122. end
RAW Paste Data