private static int runInputPastAddressHiOrLoNoLimit(int move, int joypadInputAdd, int addressToPass) {
    while (true) {
      State initial = curGb.newState();
      runToAddressNoLimit(0, 0, addressToPass);
      int stepsToAddress = curGb.stepCount;

      curGb.restore(initial);
      runToNextInputFrameHiOrLoLimit(joypadInputAdd, Integer.MAX_VALUE);
      if (curGb.stepCount >= stepsToAddress) { // address occurred before this input frame already
        System.out.println("runInputPastAddressHiOrLo: "+curGb.stepCount+" >= "+stepsToAddress);
        curGb.restore(initial);
        runToAddressNoLimit(0, 0, addressToPass);
        return addressToPass;
      }
      State cur = curGb.newState();
      int add = curGb.step(move, joypadInputAdd, addressToPass);
      if (add == addressToPass) {
        curGb.restore(cur);
        return 0;
      }
      if (add != joypadInputAdd)
        throw new RuntimeException("runToNextInputFrameHiOrLo returned invalid input frame!");
      add = runToAddressNoLimit(0, 0, curGb.rom.readJoypadAddress, addressToPass);
      if (add == addressToPass) {
        curGb.restore(cur);
        return 0;
      }
      curGb.restore(cur);
      add = curGb.step(0, addressToPass); // skip unsuitable input frame
      if (add == addressToPass)
        return addressToPass;
    }
  }