+#if 1
+ int min_load = 0;
+ int min_load_slot = 0;
+ for( int i = 0; i < qh_sizes[period_slot]; i ++ )
+ {
+ int load, index;
+ index = qh_offsets[period_slot] + i;
+ load = 0;
+ while( index >= 0 && index < 127 )
+ {
+ qh = Cont->TDQHPage->InterruptQHs + index;
+ load += Cont->InterruptLoad[index];
+ index = ((qh->Next & ~3) - Cont->PhysTDQHPage)/sizeof(tUHCI_QH);
+ }
+
+ LOG("Slot %i (and below) load %i", qh_offsets[period_slot] + i, load);
+
+ // i = 0 will initialise the values, otherwise update if lower
+ if( i == 0 || load < min_load )
+ {
+ min_load = load;
+ min_load_slot = i;
+ }
+ // - Fast return if no load
+ if( load == 0 ) break;
+ }
+ min_load_slot += qh_offsets[period_slot];
+ TD->_info.QueueIndex = min_load_slot;
+ if( min_load + (TD->Control & 0x7FF) > MAX_INTERRUPT_LOAD )
+ {
+ Log_Warning("UHCI", "Interrupt load on %i ms is too high (slot %i load %i bytes)",
+ 1 << (period_slot+2), min_load_slot, min_load
+ );
+ }
+ Cont->InterruptLoad[min_load_slot] += (TD->Control & 0x7FF);
+#endif
+ qh = Cont->TDQHPage->InterruptQHs + TD->_info.QueueIndex;