private static void runToFirstInputFrameAfterAddressHiOrLoNoLimit(int move, int joypadInputAdd, int addressToPass) {
    State initial = curGb.newState();
//    System.out.println("runToFirstInputFrameAfterAddressHiOrLo steps1: " + curGb.currentStepCount);
    runToAddressNoLimit(0, 0, addressToPass);
//    System.out.println("runToFirstInputFrameAfterAddressHiOrLo steps2: " + curGb.currentStepCount);
    int stepsToAddress = curGb.stepCount;
    curGb.restore(initial);

    while (true) {
      //      System.out.println("runToFirstInputFrameAfterAddressHiOrLo steps1: " + curGb.currentStepCount);
      runToNextInputFrameHiOrLoLimit(joypadInputAdd, Integer.MAX_VALUE);
//      System.out.println("runToFirstInputFrameAfterAddressHiOrLo steps3: " + curGb.currentStepCount);
      if (curGb.stepCount >= stepsToAddress) // address occurred before this input frame already
        return;
      State cur = curGb.newState();
      int add = curGb.step(move, addressToPass);
      if (add != 0) {
        curGb.restore(cur);
        return;
      }
      add = runToAddressNoLimit(0, 0, addressToPass, joypadInputAdd);
      if (add == joypadInputAdd) {
//        System.out.println("runToFirstInputFrameAfterAddressHiOrLo unsuitable1: " + curGb.currentStepCount);
        curGb.restore(cur);
        curGb.step(); // skip unsuitable input frame; note that addressToPass can't be skipped here
        continue;
      }
      add = runToAddressNoLimit(0, 0, curGb.rom.readJoypadAddress, joypadInputAdd);
      if (add == joypadInputAdd) {
//        System.out.println("runToFirstInputFrameAfterAddressHiOrLo unsuitable2: " + curGb.currentStepCount);
        curGb.restore(cur);
        curGb.step(); // skip unsuitable input frame; note that addressToPass can't be skipped here
        continue;
      }
      curGb.restore(cur);
      return;
    }
  }