Having trouble with the waitForZeroCross routine for X10

I have my Uno connected to a TW523 compliant device and a handy O-scope. I seem to be getting a 60Hz square wave of 5V as expected but, it doesn't seem to satisfy the waitForZeroCross routine below. I've checked to ensure my ZeroCross pin is correct. I am using pin 9. I am curious how the routine detects a transition on pin 9 without a digitalRead command. I am still in the beginning phases of learning C++ based code.

void x10::waitForZeroCross(int pin, int howManyTimes) {
	unsigned long cycleTime = 0;
	
  	// cache the port and bit of the pin in order to speed up the
  	// pulse width measuring loop and achieve finer resolution.  calling
  	// digitalRead() instead yields much coarser resolution.
 
  	uint8_t bit = digitalPinToBitMask(pin);
  	uint8_t port = digitalPinToPort(pin);

  	for (int i = 0; i < howManyTimes; i++) {
		// wait for pin to change:
    	if((*portInputRegister(port) & bit))
    	 	while((*portInputRegister(port) & bit)) {
        		cycleTime++;
				// Yield to prevent WDT reset
				delay(0);
			}
    	else
      		while(!(*portInputRegister(port) & bit)) {
        		cycleTime++;
				// Yield to prevent WDT reset
				delay(0);
			}
  		}
}
				// Yield to prevent WDT reset
				delay(0);

This is stupid. You CAN call yield() directly.

cycleTime is counting cycles, NOT time.

I am curious how the routine detects a transition on pin 9 without a digitalRead command.

digitalRead() does a lot of stuff, including determining which port the pin is on, which bit in the port the pin corresponds to, and reading the port and sorting out the value of the proper bit. That code does the same stuff.

You haven't told us what the code does, or how that differs from what you want.